-1

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

Machavity
  • 30,841
  • 27
  • 92
  • 100
Panther Coder
  • 1,058
  • 1
  • 16
  • 43

1 Answers1

5

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.

Margaret Bloom
  • 41,768
  • 5
  • 78
  • 124
  • If you are using the BIOS to read real floppy media most of the controllers didn't support LBA (via extended BIOS service) on floppy devices. I wouldn't say there is absolutely no reason.I still have a non USB floppy drive in an active system and it doesn't support LBA on the floppies. Technically speaking, if you know your code will be run on standard floppy media it is probably a reasonable choice to use CHS. – Michael Petch Feb 21 '18 at 23:49
  • Good point @MichaelPetch! Thanks, I updated the answer with your insights. – Margaret Bloom Feb 22 '18 at 09:25