Hi,
Antti wrote:All right. I started the public domain MBR that will boot the active partition. This is a quick start so before writing any more code, we all (hopefully) need to stop and design it. Feel free to comment and contribute.
Looks fine so far; except you can do this:
Code: Select all
jmp 0x0000:.here ; far jump to the relocated code
.here:
mov ah,0x41 ; INT 13h installation check
However, in my experience with only 512 bytes it's impossible to have acceptable error handling (e.g. with a good descriptive error string for each possible problem) and there are other "not required but desired" things I'd want to include (see list below). Fortunately you've got the entire first track to play with; which means the first sector only needs to load the next sector and handle any errors that may have occurred while loading that next sector (which can be done without "int 0x13 extensions", saving more space for error handling).
For a list of "not required but potentially desired" features:
- Make PC speaker beep if there's any kind of error (headless systems)
- Redundancy - have 2 copies of everything it loads from disk, so that if there's a read error it can use an alternative copy to avoid boot failure (possibly including taking a copy of the first sector of the active partition/s and storing them somewhere else)
- Diddling with TPM to maintain the "chain of trust"
- Support for GPT. This makes it easier for people to have (e.g.) a USB flash stick with both BIOS boot loader and UEFI boot loader. Notes: for GPT the "partition attributes" has a "legacy BIOS bootable" flag for this purpose, and for redundancy there's 2 copies of the GPT partition table.
The ability to have multiple operating systems installed (where the MBR/boot manager allows the user to choose which to boot) is also relatively important (especially for hobbyist OS developers - e.g. end users installing the hobby OS alongside something like Windows, rather than end users replacing Windows with the hobby OS). Of course this is the beginning of a "slippery slope" - it would mean having some sort of boot menu/user interface; and then leads to other features, like partition hiding, auto-detecting installed OSs, a boot-time configuration utility, potential support for other boot protocols (e.g. chain-loading, multi-boot, Linux boot protocol, etc), various built-in utilities (e.g. for partitioning disks, copying/cloning/backing up partitions, testing hard disks for faulty sectors, testing RAM), etc.
Cheers,
Brendan