Re:How do I detect floppy and hard drives?
Posted: Mon Jun 03, 2002 3:53 pm
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)
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)