ACHI (SATA) driver

234 views
Skip to first unread message

Ian Seyler

unread,
Mar 28, 2012, 9:21:23 AM3/28/12
to bareme...@googlegroups.com
I have begun work on a native ACHI driver for accessing SATA drives. Yesterday I was able to read a sector from a drive so things are looking good. ACHI is much more complicated than doing port access for old IDE drives but the advantages are worth it.

Once Pure64 is working correctly with the driver it will be added to BareMetal OS as well. At this point the legacy IDE access will be phased out and no longer supported.

The main downside to this is that BareMetal OS (and Pure64) will no longer work under Bochs or QEMU since they only emulate IDE drives. QEMU is supposed to have support for emulating SATA drives but I could not get the latest Windows QEMU binaries to work.

Moving forward it will be VirtualBox that is the VM of choice. In fact I am using VirtualBox to test the new driver.

-Ian

Ian Seyler

unread,
Mar 29, 2012, 9:27:18 PM3/29/12
to bareme...@googlegroups.com
I have made more progress on this and can read multiple sectors now.

The screenshot shows that 4MiB was transferred from the disk into memory (This was two separate 2MiB reads). I'm booting Pure64 via PXE at the moment and Pure64 reads the kernel off of the disk and starts it. At the moment nothing shows up since the kernel hangs (as it is looking for an IDE drive).

Also the disk image I'm using is "formatted" with BareMetal File System :)

-Ian
Capture.PNG

42Bastian

unread,
Mar 30, 2012, 12:00:22 AM3/30/12
to bareme...@googlegroups.com
Hi Ian

> Once Pure64 is working correctly with the driver it will be added to
> BareMetal OS as well. At this point the legacy IDE access will be phased
> out and no longer supported.

Why this. Pure64 is small enough to support both.

> The main downside to this is that BareMetal OS (and Pure64) will no longer
> work under Bochs or QEMU since they only emulate IDE drives. QEMU is
> supposed to have support for emulating SATA drives but I could not get the
> latest Windows QEMU binaries to work.

That will be very bad, since Bochs allows nice debugging.

--
42Bastian

Ian Seyler

unread,
Mar 30, 2012, 9:43:11 AM3/30/12
to bareme...@googlegroups.com
Supporting both will depend on the compiled code size. I want to keep Pure64 limited to a small size (currently 7168 bytes) as it makes PXE booting and chainloading easier. Though removing the FAT16 code did save some more space.

As for debugging I have been using Bochs less since it can't emulate the network hardware that BareMetal OS supports. The Bochs debugger was great in the early stages of the OS but as the code is becoming mode advanced it can no longer help as well. VirtualBox also has an integrated debugger (http://www.virtualbox.org/manual/ch12.html#idp6387504) but I have not tried it myself.

Simics (http://www.windriver.com/products/simics/) would be the debugger of choice as it can emulate the hardware BareMetal OS required. I got a chance to use it at the Intel Developer Forum last summer and it was quite interesting.

-Ian

Fred Eckert

unread,
Mar 30, 2012, 9:52:27 AM3/30/12
to bareme...@googlegroups.com
If we don't have a FAT16 or other widely used file system. How will we get our programs onto the disk?

Ian Seyler

unread,
Mar 30, 2012, 1:38:58 PM3/30/12
to bareme...@googlegroups.com
I'll be writing utilities to handle that. You will be able to transfer files via the network or by attaching the BareMetal drive to another computer. It may also be possible to write a FUSE plugin to support the new File System.

-Ian

Ian Seyler

unread,
Apr 4, 2012, 11:42:41 PM4/4/12
to bareme...@googlegroups.com
So the basics of the driver are in. I can read sectors and also 'identify' a drive to get its specs. Everything works as expected in VirtualBox. Once you get the hang of ACHI its actually not that bad.

The big issue right now is testing it on real hardware. None of the systems I have contain an ACHI controller. My test systems do have SATA ports but they behave like IDE devices. Very lame.

Looking into some newer hardware to test on as well as seeing if there are ACHI add-in cards out there. I may have to keep IDE support in after all to support more systems.

-Ian

Saurabh Rawat

unread,
Apr 5, 2012, 12:37:35 AM4/5/12
to bareme...@googlegroups.com
Isn't it AHCI ? :)

Regards,

Saurabh Rawat

Ian Seyler

unread,
Apr 5, 2012, 12:14:53 PM4/5/12
to bareme...@googlegroups.com
Yes it is.. I can't believe I've been mistyping it for so long.

-Ian


On Thursday, April 5, 2012 12:37:35 AM UTC-4, Saurabh Rawat wrote:
Isn't it AHCI ? :)

Regards,

Saurabh Rawat

Ian Seyler

unread,
Apr 5, 2012, 1:31:33 PM4/5/12
to bareme...@googlegroups.com
Looking further into AHCI..

For instance.. A Dell Optiplex 745 has four internal SATA ports. But the controller does not support ACHI. In fact the controllers report the following in Linux:

82801H (ICH8 Family) 4 port SATA Controller [IDE mode]
82801HR/HO/HH (ICH8R/DO/DH) 2 port SATA Controller [IDE mode]

In the BIOS there are two options for the SATA Operation. Normal and Legacy. I would assume that 'Normal' means AHCI but changing it in the BIOS doesn't seem to change what Linux sees. I look for a SATA controller by searching the PCI bus for a device with Device class 1 and Device subclass 6. On the Optiplex no such device exists. In fact I tried this later on with two other systems with the same results.

ICH8 and up support AHCI operation but the BIOS doesn't seem to turn it on.

A quick Google search came up with this:


The PDF in the FreeBSD post: http://www.intel.com/content/dam/doc/datasheet/intel-io-controller-hub-8-datasheet.pdf 

It may be possible to force a controller into AHCI operation if the BIOS doesn't do it.

Page 486:
MAP—Address Map Register (SATA–D31:F2)
Address Offset: 90h Attribute: R/W
Default Value: 00h Size: 8 bits
SATA Mode Select (SMS) — R/W: SW programs these bits to control the mode in which the SATA HBA should operate:
00b = IDE mode
01b = AHCI mode
10b = RAID mode
11b = Reserved

Will try to force it.

-Ian

Ian Seyler

unread,
Apr 15, 2012, 10:38:21 AM4/15/12
to bareme...@googlegroups.com
I didn't have much luck trying to force it but did finally get some newer hardware to test on.

Some minor adjustments to the code got things rolling on real hardware.


Doing some cleanups to the code and adding more comments. Then I will work on getting Pure64 to support IDE as well as AHCI.

-Ian
Reply all
Reply to author
Forward
0 new messages