@nullplan: Yes, exactly! Though I'm pretty sure the Coreboot people succeeded a long time ago.
@xeyes: Oof! Have you read any of the wiki pages dealing with the PC BIOS? Many attempt to dissuade you from having anything to do with it. The
BIOS page doesn't directly discourage its use, but describes a lot of problems. For instance:
wiki:BIOS wrote:Unfortunately, RBIL does not clearly indicate which BIOS functions are "generic" (in some sense). That is, the ones that are always available, and that everyone uses. Partially this is because the "standard" BIOS functions grew over time, so if you go back far enough in time you can usually find a computer that does not support almost any specific BIOS function. But there is definitely a set that is commonly used in most current OSes.
It then lists functions, the majority of which would not have been available when CP/M was ported to the PC. Correspondingly, I expect many functions CP/M used are not likely to be available on later hardware.
The
Real Mode OS Warning page is more direct, opening with this:
Using BIOS functions (and "avoiding" the need to write drivers) can seem easier for beginners that don't know any better, however it makes everything much much harder in the long run. This makes it an alluring trap for the unwary.
Sections of this page include BIOS Does Not Support Any Device Well, which explains that the PC BIOS does a poor job of supporting even hardware as ancient and simple as
serial ports. BIOS disk support is synchronous, meaning you can't implement a write-back disk cache. I was thinking of using the BIOS for my first OS, but that one detail alone has dissuaded me. (On reflection, the serial port section alone would also be enough to dissuade me.) It's worth reading the entire page, I think.
If the BIOS was so important to Windows, how was Windows NT ported to Alpha? Windows 7 is a version of Windows NT; all 21st-century versions of Windows are except perhaps Windows ME. And isn't there now Windows for ARM? (I don't mean WinCE.)
But what about the concept of "a good BIOS"; firmware containing a generic set of drivers which could be used in any OS? Generic drivers come up occasionally, usually by someone new to OS dev. I've brought it up myself in the past. The answer is always that the design of the drivers depends on the design of the OS, so generic drivers would be of little use. At best, they'd degrade performance of operating systems which don't match their design.
I didn't mean
partitions are complex, I meant
booting a PC is complex. The MBR code has to move itself, then it has to load the PBR, then the PBR with very little space for code has to parse a filesystem and load the kernel, or if not the kernel then at least another bootloader stage. This latter part causes problems with filesystem and bootloader design. If you attempt to avoid the problem by hardcoding the location of the kernel into the bootloader, synthesizing the bootloader as LiLo did, then you risk running into the problem that the BIOS may present the disks in different order to the OS so the synthesized bootloader has the wrong numbers. And there's another problem in memory: some OSs require the PBR and all other bootloader stages to preserve the loaded MBR all the way to the kernel so it can know which partition it booted from. If you get chainloaded from an MBR designed for some other OS, how do you know where it moved itself to? You can get that from the DS:SI pointer, but what happens if you want your kernel at that location? Problems problems problems, NONE of which exist when dealing with bare hardware. I'm sure someone's going to reply to this with a standard address MBRs should copy themselves to, but that's another piece of knowlege to know on top of all the things you need to write actual drivers for your actual OS. It's no wonder the wiki attempts to dissuade people from writing their own bootloader.
As for targetting a phone, I guess we'll find out if I keep at it because I'm hoping to target my old Samsung S3 and S5 phones. The S5 had very good support from postmarketOS, so there's kernel source to read there. The S3 had less complete support but I think screen and USB worked.