ATA和ATAPI类型硬盘区别方法

ATA和ATAPI类型硬盘区别方法
2010-05-21 17:48

目前,计算机主板IDE控制器连接的硬盘有ATAAT Attachment)类型和ATAPIAT 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 MidLBA High寄存器中的值是否分别是14hEBh,就可知连接的硬盘是ATAAT Attachment)类型还是ATAPIAT Attachment Packet Interface)类型。

参考文档:

[1]. Information Technology – AT Attachment with Packet Interface – 6(ATA /ATAPI-6)

http://hi.baidu.com/linuxcasting/blog/item/3b04d7383e78f4ff3b87ce39.html