Lecture 019
Requirement of Booting:
-
initialize machine to a known state
-
initialize different set of hardware each time it boot
-
load and run operating system
BIOS (Basic Input Output System)
Code: read-only memory (flash / EEPROM / EPROM / PROM / ROM) on motherboard, contains firmware
Do:
-
Execution begins in real mode (with only 1MB address space) at 0xFFFF0
-
power on self test (POST): check if CPU, RAM, keyboard, etc. are working
- Graphics card: look for driver code at
0xC0000 (640KB - 1MB), if found, load it and run it
- Disk: look for driver code at
0xC8000 (768KB - 1MB), if found, load it and run it
- Keyboard: "Keyboard missing, press F1 to continue"
- (the code is on hardware imported to CPU cache, so it can be different for different hardware, but the interface is the same)
-
configure RAM refresh rate, bus speed, password protection, boot order
-
Load OS for floppy disk: only support 1 OS
- look for
AA55 signature in the first sector of each device in boot order, if found, proceed
- boot sector (512 bytes) is loaded to
0x7C00 and executed
-
Load OS for hard disk: can support multiple OS
- Boot sector ("Master Boot Record", has maximum 512 bytes of code) is loaded to
0x7C00
- Boot sector code read partition table, find active partition
- move itself off
0x7C00 and load its boot sector to 0x7C00 and execute it
-
Boot loader: load OS kernel from disk to memory, and jump to it
- Why:
- MBR is only 512 bytes, can't have complex logic
- MBR assume kernel lives in raw sector location of disk with fixed offset (no filesystem (ext4, NTFS, FAT))
- MBR has no OS selection menu, recovery modes, etc.
- MBR provides no boot arguments (grub.cfg), hardware configuration hints to OS
- GRUB: Grand Unified Bootloader, support multiple OS, can load from network, support different file system, etc .
- can understand partition label (and extended partition labels)
- can understand different file system (directories, inodes, symbolic links)
- can decompress
.gz files to load /boot/kernel.gz
- multiboot header: file should contain magic number
0x1badb002 and some flags in first 8192 bytes
- PEE (Preboot Execution Environment): load OS kernel from network (DHCP protocol extension) by download via 2nd-stage boot via TFTP with UDP
- APM (Advanced Power Management): power-saving mode is difficult
- Problem
- different hardware have different power-saving features
- some hardware should enter power saving mode before other hardware
- user can close lid
- Solution: power kernel
- it's a small kernel runs in 16 bits real mode
- it handles power-saving features of different hardware
- it context switch to main kernel sometimes
- ACPI (Advanced Configuration and Power Interface): to replace APM
- instead of context switch, BIOS provide power management code for OS to interpret and execute.
- Windows ACPI spec is more accurate, and Linux kernel sometimes has to fake it as Windows
- very complicated
- EFI (Extensible Firmware Interface): to replace ACPI
- more device drivers
- drivers can be signed, certified, protected
- more, larger interfaces
-
provide device driver to OS
Links:
-
BIOS: https://sites.google.com/site/pinczakko
-
LinuxBIOS: coreboot.org, openbios.info
-
PXE: pxespec.pdf, ipxe.org
-
ACPI: uefi.org/specifications
-
UEFI: uefi.org/specifications
-
EFI: intel.com/technology/efi (use archive.org to read old version, so that it is short and contain main idea)
-
Quick Boot by Peter Dice: https://doi.org/10.1515/9781501506819