Part 3 of 7 · 2 min read
Firmware
Think of a stage manager who arrives before the actors, switches on the lights and checks that every prop is in place. Firmware does the same for the machine before any operating system exists. The analogy stops in one place: a stage manager can ask for help, and firmware has only its own small program.
In plain words: On a PC, the first code to run is the system firmware, stored in flash memory on the main board. For many years it was the BIOS (Basic Input Output System). BIOS holds low-level routines to read the keyboard, write to the screen and read the disk. Flash memory keeps its contents without power, and it can be updated to fix bugs.
When the machine is switched on, the firmware does the following.
- Self-test. It checks how much memory is installed and whether the keyboard and the other basic devices respond. It scans the buses for attached devices and configures any that are new.
- Choose a boot device. It tries the devices on a stored list in order, for example a USB drive first, then the hard disk. The user can change the list in the firmware setup screen.
- Load the first piece. It reads one fixed block of the boot device, the boot block (in older PCs, the first sector), into memory and runs it. That block is tiny, since it must fit in one disk block. It usually does just one job: find a second, larger boot loader and load it. The end of the boot block holds a partition table, which says which part of the disk is active.
Many newer systems use UEFI (Unified Extensible Firmware Interface) in place of BIOS. UEFI works better with 64-bit systems and large disks. Its biggest advantage is that it is a single, complete boot manager, so it is faster than the multi-stage BIOS route.
A worked example.
A made-up timing to show the idea. Suppose self-test and device scan take 6 seconds with BIOS, plus 1 second to load the second-stage loader, 7 seconds in all. A UEFI machine that skips the second stage and loads the OS loader directly may take 3 seconds for the same checks.
Firmware
Firmware is software stored in non-volatile memory built into a hardware device, such as the system board, so that it survives power-off. It runs before any operating system and performs the first set-up of the device.
Example: the BIOS or UEFI program that tests the memory and picks which disk to boot from.
Check yourself: 1. Why is the first-stage code so small? 2. Name two jobs the firmware does before it loads anything. 3. What is the main advantage of UEFI mentioned above?