问题
I am learning OS development and I'm in preliminary level. I created a simple boot loader. To access other files on the disk(say HDD or USB drive), which addressing mode should I use?(CHS or LBA or INT 13h extensions).
Which of these addressing mode is very efficient(means, can be used for most of the drive)?
Thanks
回答1:
First of all, the INT13h extensions are an extension to an API, not an HD addressing method.
You have to settle on whether you are going to use the BIOS or direct hardware access.
Using the BIOS is impractical, as it offers a 16-bit interface. However, it's very easy to use. In this case, you will use LBA as the addressing method.
LBA is to CHS like radians are to degrees. It is a much more natural unit and it breaks the 504 MiB and the 7.9 GiB limits. There is little reason to use CHS. CHS is a historical artefact that predates the diffusion of HDDs on the public market.
If you are going to use direct hardware access, then you can only use LBA. At the time of writing, the current ATA/ATAPI 8 Command Set deprecated CHS:
In standards ATA/ATAPI-5 and earlier, a CHS translation was defined. This translation is obsolete but if implemented it shall be implemented as defined in ATA/ATAPI-5.
Accessing the disk with direct hardware access is, however, not quite around the corner, you need at least a basic PCI/PCIe or USB bus driver to access the disk controller, a host controller driver (which can be IDE, AHCI, NVMe for PCI/PCIe devices) to issue commands to the disks and and driver that implements the protocol used by those commands (e.g. SCSI and variants, ATA/ATAPI, MMC, UMS and so on).
So I believe you will use INT13h extensions, and in such scenario, the best addressing method is the 64-bit LBA offered by the BIOS.
来源:https://stackoverflow.com/questions/41192837/which-addressing-mode-to-be-used-to-access-disk