Hi,
smwikipedia wrote:Now I am wondering:
- What preliminaries are required to use LBA BIOS?
I'd assume "LBA BIOS" means a BIOS that supports the "IBM/MS INT 13 Extensions" BIOS functions, like
this function.
smwikipedia wrote:- How to use LBA BIOS?
There's a formal specification called "BIOS Enhanced Disk Drive Specification", which is produced by Phoenix (in conjunction with a group of other companies). It should be easy to find a copy of this specification with
a google search.
They're also listed in Ralph Brown's Interrupt list. There's a HTML version of this list online, and the "IBM/MS INT 13 Extensions" BIOS functions are all listed on the
"Int 0x13" page - just scroll down until you get to "Int 13/AH=42h".
smwikipedia wrote:- Also, I am using VMware and Bochs, I am not sure whether they support LBA BIOS to interact block devices, say an ISO image or a USB disk?
They should - most OSs use these functions, as the older "int 0x13" functions are limited to 8 GiB (or less), and they are required by (and extended by) El Torito for "no-emulation".
Originally, floppy drives were numbered starting from 0x00 and hard drives were numbered starting from 0x80. For USB or CD-ROM emulating floppy or hard disk, the same numbering is used for the emulated device (and real devices are re-numbered to suit ). For e.g. an emulated hard disk on a CD-ROM would become device 0x80 and the real first hard disk would be shifted to 0x81 to make room. For "no emulation" CD, the device number could be anything - typically they're 0xC0 or above, but they could be anything.
The important thing is that you should never have a reason to care what the device number is. The BIOS tells you which device number you booted from (in DL) and you use that; and if you need to know more about the device you ask the BIOS (either using
"Extended Read Drive Parameters" if supported, or the older
"Read Drive Parameters" function.
Also note that using the "IBM/MS INT 13 Extensions" BIOS functions properly isn't necessarily as easy as it sounds - be careful of removable media like CD and USB (where the user can remove it during boot, and where it might be possible to lock the device to prevent this); and don't assume 512-byte sectors as CD uses 2048-byte sectors, and hard drives will probably shift to 4 KiB sectors one day (rather than "4 KiB sectors pretending to be 512-byte sectors").
It's also good idea to use ISO9660 for CD, and some other file system (or none) for hard disk. For USB (and hard disk too I guess), you can't really provide a partitioned generic USB image that everyone can download and use because you need to know the device geometry before you can create partitions correctly; and to get around that problem the easiest way is to provide an unpartitioned image. This means you may need many different boot loaders despite using "IBM/MS INT 13 Extensions" BIOS functions - one for "no emulation" CD that uses ISO9660, one for other devices that supports "MBR partitions", one for other devices that support "hybrid GPT partitions", one for other devices that aren't partitioned, etc.
In general, in my opinion, the entire idea of a single "one size fits all" boot loader is limited and broken. Even if there is only one boot loader initially; an OS's boot code should be designed with some abstraction, so that the OS itself doesn't care which boot loader was used (or what the boot device was), so that it's easy to write more boot loaders later to allow the OS to boot from radically different devices (including booting from network where there's no file system or sectors, and potentially including booting from EFI or other types of firmware).
Cheers,
Brendan