SATA questions

Hello all,

A little while ago I started writing my own OS, it is now going quite well, I have a working floppy driver, and have implemented the FAT12 file system with it to open, save and delete files, I have also just successfully completed the first stage of writing my P-ATA driver, which now works for reading. However I would like to know a little more about how to access SATA drives, I have been told they have the same command set as PATA, however I can not find any information about which ports you write to to access data from them.

Any help here would be appreciated.


  • SATA is essentially just PATA wrapped up in a different cable-nothing you need to concern yourself with on the software end.

    They all use the same ATA command set, which is sent down to the drive either in the standard I/O ports of 1f0-1f7 or 170-177, or if the IDE controller is non-legacy, the I/O ports' base addresses will be declared in the base address registers in the device's PCI config registers.

    The extended registers (4 I/O ports), used to do 48bit LBA access, are typically declared in a second base address register in PCI config space.

    I'd be glad to help with your project-I've got lots of (DOS based) code to not only read PCI devices, but to issue ATA commands down to the IDE controller in PIO mode anyway...

  • Thanks for the information, and the offer, however I would like to write all the code myself, as otherwise, I am not going to understand it.

    Unfortunatly I have had to put device drivers on hold for a while, due to a problem with my memory manager...the program is a lot larger than before, and trying to load larger sections...which seems to of stemmed from the bootloader...So I have had to completely rewrite the bootloader and start from scratch, and now even though the code is very similar to the original code, I keep on getting "interrupt(): gate descriptor is not valid sys seg" Whenever I re-enable interrupts after sorting the GDT, I have no idea why...
  • Does BIOS INT 13h use DMA?

  • : Does BIOS INT 13h use DMA?

    It depends on your BIOS and how they handle the translation of oldskool cylinder/head/sector that INT 13h uses into something the hard drive can work with. My guess is no, but that's all it is-a guess.

    Let me do some experiments and get back to you. I have access to the tools needed to see what an INT 13 actually gets translated to going over a SATA connection. This could be fun.
    sometime later...

    ok, I issued a single sector read of LBA address 0 (the master boot record) using INT 13 from DOS on a SATA drive connected to a gigabyte motherboard with an intel ICH-9 AHCI controller with award BIOS on it, and low and behold, it issued a Read DMA Ext command to the drive.

    I still think it depends on the BIOS and era of hardware you're using, but it does indeed look like INT 13h does use DMA. There are also setup options (or at least there used to be) to select if the drive should be accessed with PIO or DMA modes. Those should also have an effect on INT 13 using DMA or not.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!