Boot Kernel From UEFI Application
The article with example you found looks AI-generated – if it were written by a real person, surely they would have looked at their own post at least once and fixed the broken HTML of #includes. (Some of their other posts outright reference commands and options that do not exist and have never existed.)
Does the UEFI application need to read the file system to find the kernel?
There’s no fixed process. The UEFI program does anything it needs, loads to memory whatever it needs loaded in any manner it wants, then eventually calls ExitBootServices() and jumps to the kernel entry point. Probably the only constant is getting the memory map from EFI.
The program can use the EFI filesystem access protocol to load a separate file into memory (e.g. using ordinary Open/Read/Close), or it can also use the EFI block-device access protocol to implement its own filesystem drivers (e.g. GRUB2 does that), or it can itself be the kernel (Linux does that with its “EFI stub” feature).
Taking a look at Linux:
-
The old efilinux boot loader for Linux is fairly simple – fs/fs.c uses the EFI “File System Protocol” to read its config file and load the Linux kernel image from filesystem (as well as the initrd archive that’ll be handed over to Linux), then loaders/bzimage/bzimage.c prepares a structure with some initial parameters to hand over to the kernel, then it calls ExitBootServices and jumps (via loaders/bzimage/x86_64.h) to a memory pointer.
-
GRUB2 uses some EFI services, but it relies heavily on direct device access as well; it comes with internal support for various filesystems and even hardware types (e.g. it has internal SATA support). The initial config is embedded within grub.efi and points it at the path of grub.cfg, which then includes the path to the kernel.
-
systemd-boot doesn’t do any kernel loading; it expects the kernel to include an “EFI stub” so that it could be launched as an EFI executable (i.e. the kernel being its own bootloader). The kernel’s EFI stub then already has the rest of the kernel in memory, so it doesn’t need any filesystem access.
Read more here: Source link
