banner
fwqaaq

fwqaaq

🐭👨

UEFI Introduction

Computer Boot Process#

ROM -> LOADER -> RUNTIME -> OS LOADER -> OS

  • Loader: Commonly includes BIOS and UEFI (the latter being the successor of the former), generally responsible for memory initialization, loading Runtime and OS Loader programs.
  • Runtime: Firmware programs provide runtime services, which are the most basic abstraction of hardware (providing a series of abstractions to the OS).
  • OS Loader: Also known as BootLoader by many. It needs to perform tasks such as file system booting, network card booting, setting operating system startup configurations, operating system loading, etc. Common OS Loaders include GRUB, U-Boot, LinuxBoot, etc.

How UEFI Finds Loader and Starts#

Currently, UEFI is more commonly used as a Loader instead of BIOS, retaining the BIOS name is just a verbal habit. The motherboard's UEFI firmware only recognizes files in efi format, so it cannot load elf format kernels. This is where the OS Loader comes in, playing a role that bridges the gap. In the case of UEFI, it will package itself in efi format and save it in a specific location on the hard disk; when facing a kernel, it will parse the elf format and load it.

This way, the computer can smoothly find the Loader during the startup phase and further load and run the OS. The Loader is actually a program format. The specific location where the Loader is located must be on a FAT32 formatted partition on the boot device. Create an efi directory in the root directory of this partition, and then create a boot directory in the efi directory. The computer firmware will then search for the Loader along this fixed path, containing the required Bootx64.efi file (if it is a 32-bit system, it cannot have 64).

This FAT32 partition is generally located at the beginning of the entire disk, with a size of about 100M (or GB, or even more, quite flexible). The UEFI firmware will consider any disk with a FAT32 formatted partition as a boot disk and add these discovered disks to the boot menu. As for whether they can boot, that's another matter. When selecting a specific target, if it has a UEFI prefix, it will search the fixed path (/efi/boot to find loader).

Similarly, Loader searches for the kernel file in the same way, placing the kernel file in the same directory. When the Loader finds the kernel file, it parses it according to the elf file format. If it is a runnable elf file, it reads it into memory and jumps to run.

How Does the Kernel Read from a FAT32 Partition?#

This is the purpose of UEFI, eliminating the need to consider loading into which memory block, segment, or paging. It provides a rich set of services for developers to call during the startup and runtime phases. The services during the startup phase are called boot-time services, which are only available during startup; while the runtime services are available even after the computer has finished booting and is running normally. All of these are provided through the UEFI interface.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.