How do I detect floppy and hard drives?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Tim

Re:How do I detect floppy and hard drives?

Post by Tim »

Heck, I'll give you a copy of my ATA driver. The ATA driver source is fairly large, but towards the bottom is the routine for detecting drives on a given controller. This one doesn't actually use PCI yet.

I put all my source code on my SourceForge CVS account, but for some reason it won't accept my ata.c file. I'll upload it temporarily instead. Here's the URL:

http://www.gaat.freeserve.co.uk/ata.c

Look at the AtaInitController function. The basic method I use is:

Reset the controller
For the master and slave drives:
Issue the IDENTIFY command as you would any other ATA command
If it times out, issue the ATAPI IDENTIFY packet as you would any other packet
If that times out, then the drive isn't present; move onto the next one
Read the 'sector' data from whichever IDENTIFY command worked, into a 512-byte buffer
Do what you want with the information there (probably best to save the disk size or numbers of cylinders/heads/seconds)
Ghost

Re:How do I detect floppy and hard drives?

Post by Ghost »

Nice driver. Where can I find info on how to write my own hdd driver?
10x.
Tim

Re:How do I detect floppy and hard drives?

Post by Tim »

Mine started out at the AT winchester driver from Minix. I moved it over to the Mobius driver model and brought it up to date.

A good place for technical information is www.ata-atapi.com. The official site is www.t13.org, and they have various PDFs containing the standards there. I've been using revision 4 of the ATA/ATAPI standard.
Post Reply