In this lesson, you will learn how the bootloader bridges the gap between hardware initialization and the Linux kernel by passing vital system metadata via specific memory structures.
Once the bootloader (such as GRUB or systemd-boot) finishes its tasks, it must hand over control to the kernel image loaded into memory. However, the kernel cannot simply "start"—it needs a roadmap of the hardware it is about to manage. This information is passed through a standardized contract known as the boot protocol.
The Handover Mechanism
The handoff involves two primary components: the Kernel Parameters and the Memory Map.
- Kernel Parameters: These are the command-line strings (e.g.,
root=UUID=... ro quiet) you see in your bootloader configuration. The bootloader places this string in a specific memory location and updates the kernel's header structure (typically thestruct boot_params) so the kernel knows where to find its startup instructions. - Memory Map (e820): Before the kernel takes control of the memory management unit (MMU), it needs to know which regions of physical RAM are usable, reserved for BIOS/UEFI, or hardware-mapped. The bootloader queries the firmware to build an
e820map—an array describing physical memory ranges—and passes a pointer to this map to the kernel.
The Bridge: The Boot Parameters Structure
The kernel expects the bootloader to populate a specific structure (often called boot_params in the x86 architecture). This structure acts as a data bridge, containing:
struct boot_params {
struct screen_info screen_info; // VGA/Console settings
struct e820_entry e820_map[E820_MAX_ENTRIES]; // Memory map
__u32 sentinel;
__u8 setup_sects; // Size of the setup header
// ... various offsets and flags
};
When the bootloader jumps to the kernel's entry point, it sets the CPU registers to point toward this boot_params structure. The kernel reads this memory block during its early assembly phase (before the C environment is even initialized) to configure early serial consoles, map memory regions, and establish the initial kernel command line. Without this handoff, the kernel would be effectively "blind" to the available RAM and the specific environment configuration requested by the system administrator.
Key Takeaway: The bootloader facilitates the handoff by populating a predefined memory structure that acts as a blueprint, providing the kernel with the necessary memory map and command-line instructions to initialize the operating system.