Boot Process
https://www.alanfoster.me/posts/writing-a-bootloader/
https://m2m-tele.com/blog/2021/10/24/u-boot-initialization-sequence/
http://www.linuxjournal.com/article/2239
https://youtu.be/3brOzLJmeek?si=i_lZ_9cVAoYZnhrX
https://thasso.xyz/2024/07/13/setting-up-an-x86-cpu.html
| start() | arch/i386/boot/head.S |
| start_32() | arch/i386/boot/compress/head.S |
| decompress_kernel() | arch/i386/boot/compress/misc.c |
| startup_32() | arch/i386/kernel/head.S |
| start_kernel() | init/main.c |
| cpu_idle() | init/main.c |
https://tldp.org/LDP/LG/issue70/ghosh.html
1. Moves itself from address 0x00007c00 to address 0x00090000. 2. Using address 0x00003ff4, sets up the "Real Mode" stack. 3. Sets up the disk parameter table. This is used by BIOS to handle the hard disk device driver. 4. Displays the message "Loading Linux" by invoking a BIOS procedure. 5. Then, invokes a BIOS procedure to load the setup( ) code of the Kernel Image. It puts this into RAM starting from address 0x00090200. 6. Invokes a BIOS procedure finally. This procedure loads the rest of the Kernel image and puts the image in RAM starting from either address 0x00010000 (called "low address" for small Kernel Images compiled with "make zImage") or address 0x00100000 (called "high address" for big Kernel Images compiled with "make bzImage"). 7. Then, it finally jumps to the setup( ) code.
1. First, total amount of physical RAM available to the system is detected. It invokes a BIOS procedure for detecting the RAM. 2. Sets the Keyboard repeat delay and rate. 3. The Video adapter card is detected. 4. The Disk Controller is reinitialized and hard disk parameters are determined. 5. Checks for an IBM Micro Channel bus (MCA). 6. Checks for a PS/2 pointing device (bus mouse). 7. Checks for Advanced Power Management (APM) BIOS support. 8. Now checks the position of the Kernel Image loaded in RAM. If loaded "low" in RAM (when using zImage, at physical address 0x00010000) it is moved to "high" in RAM (at physical address 0x00001000). But, if the Kernel image is a "bzImage" loaded in "high" of RAM already, then it's NOT moved anywhere. 9. Sets up the Interrupt Descriptor Table (IDT) and a Global Descriptor Table (GDT). 10. If floating point unit (fpu) is present, it's now reset at this step. 11. PIC (Programmable Interrupt Controller) is reprogrammed at this step. 12. The CPU is switched from "Real mode" to "Protected mode" by setting the PE bit in the cr0 status register. 13. Jumps to the stratup_32( ) assembly language function.
1. The paging_init( ) function is executed that initializes the Page Tables. 2. The mem_init( ) function is executed that initializes the Page Descriptors. 3. The trap_init( ) and init_IRQ( ) functions are executed that initializes the IDT for the final time. 4. The kmem_cache_init( ) and kmem_cache_sizes_init ( ) functions are executed that initializes the Slab Allocator. 5. The time_init( ) function is executed that initializes the System Date & Time. 6. The Kernel thread for process 1 is created by invoking the kernel_thread( ) function. This in turn creates the other kernel threads and executes /sbin/init program.
https://opensource.com/article/17/2/linux-boot-and-startup
https://krinkinmu.github.io/2023/08/21/how-u-boot-loads-linux-kernel.htmlhttps://community.nxp.com/pwmxy87654/attachments/pwmxy87654/imx-processors%40tkb/3725/1/Bootloader%20Boot%20Procedure.pdf
ACPI
UEFI
UEFI Secure Boot
Coreboot reference implementation
Piotr Król / 3MDEB
https://beta.ost2.fyi/courses/course-v1:OpenSecurityTraining2+Arch4221+2023_v1/about
https://shop.3mdeb.com/wp-content/uploads/2022/08/S-RTM-and-Secure-Boot-for-VMs.pdf
https://shop.3mdeb.com/wp-content/uploads/2022/08/Enabling-TPM-2.0-on-coreboot-based-devices.pdf
https://trustedcomputinggroup.org/wp-content/uploads/TCG_VPWG_Architecture_V1-0_R0-26_FINAL.pdf
https://maplecircuit.dev/std/acpi.html
| Component | Description | |
|---|---|---|
| UEFI Core | The main firmware that initializes hardware and provides runtime services | |
| Boot Manager | Handles the boot process, including loading and executing boot loaders | |
| Device Drivers | Provides support for hardware devices (storage, network, etc.) | |
| Configuration Tables | Stores system configuration data and ACPI tables | |
| Runtime Services | Provides services available after the OS is loaded (e.g., time, variables) | |
| Boot Services | Temporary services available during boot (e.g., memory allocation) | |
| UEFI Shell | Interactive environment for debugging and configuration | |
| Secure Boot | Verifies the integrity of bootloaders and OS kernels | |
| TPM Support | Interface for Trusted Platform Module (TPM) for security features | |
| Network Stack | Provides network capabilities for remote management and updates | |
| Graphics Output Protocol | Handles display output during boot | |
| Variable Store | Non-volatile storage for UEFI variables | |
| Capsule Update | Mechanism for firmware updates |
Boot order
UEFI Bootrom
Bootloader on EFI
Linux Kernel
Init ramfs
Rootfs
Analysis
1. GRUB (GRand Unified Bootloader)
Filename: /boot/grub/grub.cfg
Step 1: The system UEFI loads GRUB from the boot device from the GPT partition
Step 2: Menu Selection: GRUB presents a menu of boot options
Step 3: Kernel Image Loading: GRUB loads the compressed kernel image into memory.
2. setup.S – Initial Memory Setup:
Filename: setup.S
Step 1: Execution: Immediately after the kernel image is loaded into memory, setup.S is executed. This is a very early stage.
Step 2: Memory Initialization: setup.S performs critical early memory initialization:
Sets up the memory map (crucial for the kernel to know where everything is).
Initializes basic memory management structures.
Sets up some early hardware registers.
Key Point: setup.S runs in an unprivileged mode, before the kernel itself has taken full control. This is why it's a minimal, highly optimized stage.
3. bootsect.S – Partition Table Handling:
Filename: bootsect.S
Step 1: Partition Table Access: bootsect.S is then invoked – often by setup.S.
Step 2: GPT/MBR Handling: It handles the partition table (MBR or GPT) to locate the kernel image and associated data (e.g., initramfs). This is necessary because the kernel image might not be directly on the boot partition.
Step 3: Setting up Boot Arguments: bootsect.S sets some of the early boot arguments.