book
book copied to clipboard
Linux kernel entry
head.S
for multiple architectures, there is arch/$ARCH/kernel/head.S, where the first instructions reside.
EFI stub
can be as simple as https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/arch/riscv/kernel/head.S?id=cb7d2dd5612a77a2597c00fce770a52c921e2ea5
or designed elegantly to allow for pure DT + EFI coexistence, see arm64 where the EFI stub checks for the EFI system table, calls the method to retrieve the kernel cmdline, injects that information into the FDT and then continues with the kernel as usual. A boot loader can just skip the whole stub and continue with the regular kernel, so loading an EFI kernel works without having the EFI interfaces. Note that the kernel later checks for presence of EFI features, which are tracked by setting bits in the EFI stub. The stub itself is added via Kconfig CONFIG_EFI_STUB, as well as the interface calling, but that comes with a separate CONFIG_EFI (default).
TODO: code references