继续上1P,我们现在要开始读取光驱里面的内容了。以前我描述过BIOS显示服务和磁盘服务(这里),但是我只将了CHS读软盘,没有涉及到硬盘和光驱。由于硬盘和光驱的构造与软盘截然不同,使用读软盘的手段是行不通的,为此,BIOS给我们提供了扩展13h中断。
Continue to the next part, we are going to read the content in the cdrom. I described the bios display service and disk service in previous posts (Here, in Chinese), but I only introduced the way to read floppy through CHS method, but not harddisk and cdrom. Because the hardware construction of these devices are totally different, we cannot apply the floppy-way to harddisk(ATA) and cdrom(ATAPI) devices. In order to solve the problem, BIOS provides us extended int 13h.
Register | Value | Description |
AH | Function(0x42) | Extended Read from ATA/ATAPI Device |
DL | Drive Number | |
DS:SI | Address of Disk Address Packet |
参数和读软盘不一样了。我们使用Disk Address Packet(DAP, 磁盘地址包)来间接传递参数,而不是传CHS信息。DAP的构造如下表:
The argument is different from the normal read function. We no longer pass the CHS arguments to the BIOS, but a Disk Address Packet(DAP) instead. The format of DAP is described by the following table:
Offset | Size | Name | Description |
0 | 1 | Packet Size | Always 16 (At least now) |
1 | 1 | Reserved | Should be zero |
2 | 2 | Sector Count | Number of sectors to read |
4 | 4 | Buffer Address | Format is segment:offset, a word-long offset is stored first |