OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 11:08 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Writing simple HDD driver (some questions).
PostPosted: Sun Dec 12, 2021 6:35 am 
Offline

Joined: Tue Jul 07, 2020 3:18 pm
Posts: 15
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?


Top
 Profile  
 
 Post subject: Re: Writing simple HDD driver (some questions).
PostPosted: Sun Dec 12, 2021 6:49 am 
Offline
Member
Member

Joined: Sun Aug 20, 2017 10:59 am
Posts: 43
Quote:
ATA PIO Mode driver is the easiest way to write hdd driver. Is it right?

I think so, yes.
Quote:
Do I need PCI driver ready first or something else?

You don't <need> a PCI driver, because you can use standard ATA ports (0x1F0, 0x3F6, 0x170, 0x376, cf wiki).
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 !


Top
 Profile  
 
 Post subject: Re: Writing simple HDD driver (some questions).
PostPosted: Sun Dec 12, 2021 7:39 am 
Offline

Joined: Tue Jul 07, 2020 3:18 pm
Posts: 15
vhaudiquet wrote:
Quote:
ATA PIO Mode driver is the easiest way to write hdd driver. Is it right?

I think so, yes.
Quote:
Do I need PCI driver ready first or something else?

You don't <need> a PCI driver, because you can use standard ATA ports (0x1F0, 0x3F6, 0x170, 0x376, cf wiki).
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: 8infy, Bing [Bot] and 58 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group