ATA PIO Mode: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
m →48 bit PIO: minor wording change |
→400ns delays: minor rewording |
||
Line 29:
The method suggested in the ATA specs for sending ATA commands tells you to check the BSY and DRQ bits before trying to send a command. This means that you need to read a Status Register (Alternate Status is a good choice) <i>for the proper drive</i> before sending the next command. Which means that you need to select the correct device <i>first</i>, before you can read that status (and then send all the other values to the other IO ports).
Which means that a drive select may always happen <i>just before</i> a status read. This is bad. Many drives require a little time to respond to a "select", and push their status onto the bus. The suggestion is to read the Status register <b>FIVE TIMES</b>, and only pay attention to the value returned by the last one -- after selecting a new master or slave device.
Reading IO ports to create delays wastes a lot of CPU cycles. So, it is
Alternately, you never want to send new commands to a drive that is already servicing a previous command, anyway. Your driver <b>always</b> needs to block if the current device is actively modifying BSY/DRQ/ERR, and your device driver always already knows that the device is in that condition (because the driver just sent the command to the device, and it hasn't been marked "complete" yet). Once a drive has actually completed a command, it will always clear BSY and DRQ. You can simply verify this, <i>before</i> your next Device Select command -- that the previously selected device cleared BSY and DRQ properly at command completion. Then you will never have to check if they are clear <b>after</b> a Device Select -- so you will not have to read the Status Register after the Device Select at all.
There is a similar problem after writing the Command Register, with the ERR/DF bits. They are two slightly different kinds of errors
==Cache Flush==
|