Page 2 of 2

Re:How do I detect floppy and hard drives?

Posted: Mon Jun 03, 2002 3:53 pm
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)

Re:How do I detect floppy and hard drives?

Posted: Wed Jun 05, 2002 7:19 pm
by Ghost
Nice driver. Where can I find info on how to write my own hdd driver?
10x.

Re:How do I detect floppy and hard drives?

Posted: Thu Jun 06, 2002 8:43 am
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.