Hi,
onlyonemac wrote:
I haven't posted for a while but the other day I was thinking about a stark difference between the BIOS and us operating system developers. You see, we always struggle to support every different kind of hardware that could possibly exist, yet whenever there's a BIOS function to do something it will probably be able to do it with whatever hardware you supply. And now what I can't work out is how come BIOSes are so able to work with any kind of hardware.
BIOS doesn't support that much hardware. For example, it doesn't support:
- Sound input or output (other than PC speaker)
- Video (it's provided by the video card's ROM)
- Networking (it's provided by the network card's ROM)
- IO APICs (not used at all)
- HPET (not used at all)
- IOMMUs (not used at all)
- Game controller/s (joysticks, etc)
In addition; for the hardware it does support, often it's using crusty/slow legacy modes (e.g. basic PIO for hard disks, rather than the full
NCQ with bus-mastering/DMA, etc).
Also; the code is simpler than the corresponding code you'd expect in an decent OS, because:
- there's no protection/isolation (other than being in "hard to modify ROM")
- no support for multiple CPUs (excluding setting MTRRs and populating ACPI tables)
- no support for multi-tasking
- very little memory management
- very simple user interface
- no file system/s
- no disk cache/s
- no need for good performance for anything
- poor fault tolerance (e.g. not even basic exception handlers that work - if anything goes wrong then crash/reboot)
Basically; it only has to be "bare minimum" code that's able to start an OS (and is only used for less than 5 seconds); and none of it is actually good (for any definition of "good" - features, performance, fault handling, etc).
Finally, BIOS developers don't write everything from scratch for every motherboard. Instead, they'd have "generic BIOS code" and customise a few things to suit the chipset/motherboard. The majority of the code would be code that has evolved over the last 30+ years. Some things (e.g. RTC and PIC code) may have been untouched for several decades, some things (e.g. USB support) might have been added 15+ years ago. The amount of "new and untested" code for a motherboard is likely to be very little.
Cheers,
Brendan