目前,计算机主板IDE控制器连接的硬盘有ATA(AT Attachment)类型和ATAPI(AT Attachment Packet Interface)类型。那么,软件程序BIOS或者Linux内核是如何才能识别出硬盘是那种类型的呢? 在参考文档[1]中,定义了识别硬盘类型的方法,如下所示: A device not implementing the PACKET command feature set shall place the signature in the Command Block registers listed below for power-on reset, hardware reset, software reset, and the EXECUTE DEVICE DIAGNOSTIC command. If the device does not implement the PACKET command feature set, the signature shall be: Sector Count 01h LBA Low 01h LBA Mid 00h LBA High 00h Device 00h A device implementing the PACKET command feature set shall place the signature in the Command Block registers listed below for power-on reset, hardware reset, software reset, the EXECUTE DEVICE DIAGNOSTIC command, and the DEVICE RESET command. If the device implements the PACKET command feature set, the signature shall be: Sector Count 01h LBA Low 01h LBA Mid 14h LBA High EBh Device 000x0000b where x equals 0 except when responding to a DEVICE RESET, IDENTIFY DEVICE, or READ SECTOR(S) command. For a DEVICE RESET, IDENTIFY DEVICE, or READ SECTOR(S) command the value of x is not changed from that existing when the command is written to the Command register. 在经过软件复位或者硬件复位等操作后,比较LBA Mid和LBA High寄存器中的值是否分别是14h和EBh,就可知连接的硬盘是ATA(AT Attachment)类型还是ATAPI(AT Attachment Packet Interface)类型。 参考文档: [1]. Information Technology – AT Attachment with Packet Interface – 6(ATA /ATAPI-6) |
http://hi.baidu.com/linuxcasting/blog/item/3b04d7383e78f4ff3b87ce39.html