Writing simple HDD driver (some questions).
Writing simple HDD driver (some questions).
As I understand ATA PIO Mode driver is the easiest way to write hdd driver. Is it right? What do I need to start working with ATA? Do I need PCI driver ready first or something else?
-
- Member
- Posts: 43
- Joined: Sun Aug 20, 2017 10:59 am
Re: Writing simple HDD driver (some questions).
I think so, yes.ATA PIO Mode driver is the easiest way to write hdd driver. Is it right?
You don't <need> a PCI driver, because you can use standard ATA ports (0x1F0, 0x3F6, 0x170, 0x376, cf wiki).Do I need PCI driver ready first or something else?
However, in theory, a computer could have ATA controllers on other ports, that would be described in the PCI bars.
But if you only want to build a driver, you can for now hardcode the ports and later use PCI to detect all controllers on the device.
If you want to do more advanced stuff, like power managment (putting the drives to sleep when not used, etc...) you will need an ACPI driver ; but that is really complicated stuff (you will need an AML parser, more details on the ACPI wiki page) and not needed at all for a basic driver.
If i can give you an advice, try to read the ATA specifications, don't rely only on the wiki ; the wiki is here to help you know what you have to do and give you an overview of how ATA works, but when implementing a driver, you want to stay as close to the specs as possible. (when i implemented my first ATA driver, i was too lazy to read specs, and i ended up copying the IDENTIFY data structure from somewhere on the web, and it turned out to have wrong fields, and not being the size it is supposed to be...)
Good luck !
Re: Writing simple HDD driver (some questions).
vhaudiquet wrote:I think so, yes.ATA PIO Mode driver is the easiest way to write hdd driver. Is it right?You don't <need> a PCI driver, because you can use standard ATA ports (0x1F0, 0x3F6, 0x170, 0x376, cf wiki).Do I need PCI driver ready first or something else?
However, in theory, a computer could have ATA controllers on other ports, that would be described in the PCI bars.
But if you only want to build a driver, you can for now hardcode the ports and later use PCI to detect all controllers on the device.
If you want to do more advanced stuff, like power managment (putting the drives to sleep when not used, etc...) you will need an ACPI driver ; but that is really complicated stuff (you will need an AML parser, more details on the ACPI wiki page) and not needed at all for a basic driver.
If i can give you an advice, try to read the ATA specifications, don't rely only on the wiki ; the wiki is here to help you know what you have to do and give you an overview of how ATA works, but when implementing a driver, you want to stay as close to the specs as possible. (when i implemented my first ATA driver, i was too lazy to read specs, and i ended up copying the IDENTIFY data structure from somewhere on the web, and it turned out to have wrong fields, and not being the size it is supposed to be...)
Good luck !
Thank you for the useful information. Will try to find and read specification first.