Help with the 'Identify' ATA command
Posted: Wed Jun 29, 2011 6:43 pm
So far, I have been able to identify that the CD drive is a PATA master drive on the secondary controller - which seems right, since QEMU reports that the drive is 'ide1-cd0'.
After I identify all that stuff, I set ports 0x172 through 0x175 to 0, and send the 'Identify' command (0xEC) on the command register port (0x177). Then I read the status port (0x177) until the BSY bit is no longer set.
Here is where I start losing it - according to the ATA PIO Mode wiki, I should wait until DRK or ERR (bits 0 and 7 from the status port) is set. DRK never sets, but ERR does. Then, the wiki says that if ERR is clear, I can read my 512 bytes from the data port. So I guess I should loop again until ERR goes clear? I tried that, but then when I try reading my data all I get are zeros. Does anyone know what might be wrong?
Thank you!
e: I guess I'll post my code, in case it will help -
snip
After I identify all that stuff, I set ports 0x172 through 0x175 to 0, and send the 'Identify' command (0xEC) on the command register port (0x177). Then I read the status port (0x177) until the BSY bit is no longer set.
Here is where I start losing it - according to the ATA PIO Mode wiki, I should wait until DRK or ERR (bits 0 and 7 from the status port) is set. DRK never sets, but ERR does. Then, the wiki says that if ERR is clear, I can read my 512 bytes from the data port. So I guess I should loop again until ERR goes clear? I tried that, but then when I try reading my data all I get are zeros. Does anyone know what might be wrong?
Thank you!
e: I guess I'll post my code, in case it will help -
snip