The boot process

The boot process refers to the entire process from the moment the computer is powered up to the time the CPU starts executing the operating system code. At this very early stage, the CPU executes standard startup code. This part of the code needs to probe the hardware device to find the operating system most likely to boot and start the operating system according to user-defined parameters.

Traditional form of boot: BIOS

Most PCS still boot from BIOS, the default (universal) boot loader. The BIOS is a type of firmware that provides simple menu items through which you can modify motherboard parameters and boot device sequence. Firmware can be thought of as a piece of software that is written to a chip and therefore “solidified.” The firmware code itself can be stored in read-only memory (ROM). It may also be stored in programmable read-only memory (PROM) or electrically erasable read-only memory (EEPROM), the latter two forms being more common.

BIOS chips mainly store:

  • Self-diagnostic program: reads the hardware configuration in CMOS and self-checks and initializes it
  • CMOS setup program: during the boot process, it is started with special hotkeys, and after setting, it is stored in CMOS RAM
  • Bootstrap: After the self-check succeeds, load the boot program on the disk relative to sector 0 into memory and run it
  • Driver and interrupt service for primary I/O Settings

The BIOS and firmware do the same thing: load some basic bootstrap code for the CPU to execute. Bootstrap programs and BIOS or firmware are responsible for initializing hardware, detecting hardware, locating these boot devices, and executing boot loader programs. The job of the boot loader program is to find the selected operating system and pass all the necessary command-line arguments to the operating system kernel.

The traditional BIOS boot operating system (Windows) is shown as follows:

Computer boot, solidified in THE ROM BIOS will be loaded into the memory to run, BIOS self-check will be loaded after the PARAMETERS of COMS, through the PARAMETERS of COMS, BIOS load boot disk MBR to run in memory. By running the code of MBR, recorded in the MBR Partition table, the disk Partition PBR(Partition Boot Record) marked as active Partition is loaded into memory to run, and PBR can load the code of the operating system loader (such as BooTMGR of Windows) into memory to run after running. The OPERATING system loader loads the operating system kernel to the memory to complete the BIOS boot process.

Next generation BIOS: EFI

EFI is an Extensible Firmware Interface (EFI) technology that replaces the traditional BIOS. BIOS is a fixed program and is usually closed. EFI is a full-featured runtime system that provides a more powerful interface during boot and even later at run time, and EFI programs are usually boot loaders. An EFI program is actually a binary program.

EFI generally consists of the following parts:

  • Pre-efi Initializes the module
  • EFI driver execution environment
  • EFI driver
  • Compatibility Support Module (CSM)
  • EFI high level applications
  • GUID disk partition

# # # NVRAM variables

NVRAM is a very powerful feature in the firmware interface, and obviously not in the BIOS. NARAM variables are system-wide and accessible to both the operating system and the firmware itself. Generally speaking. NVRAM variables can be divided into the following categories:

  • Boot-related variables: Used to specify the kernel and root file system to boot, and also responsible for passing parameters to the kernel.
  • Internal firmware variables: Variables used by the firmware and ignored by the operating system
  • Temporary variables: Set or cleared as needed, usually not retained during a reboot

The process of EFI booting the operating system (Windows) is as follows:

After the computer is turned on, the pre-EFI initialization program solidified in the read-only memory RAM will be loaded to initialize the main bridge and memory. Then the EFI driver execution environment (DXE) will be loaded and initialized successively, and then the EFI system will be loaded and started. After EFI system is started, The GUID partition table will be identified, and the EFI system will decide whether to start the BootCamp program (Apple’s dual Boot solution) by loading NVRAM parameters. If the BootCamp program is not started, the Boot Loader will load the operating system kernel and complete the EFI Boot process.

Reference blog:

Mac System boot Process Overview & BootCamp secrets

References:

Baidu Encyclopedia: BIOS

Baidu Encyclopedia: EFI