This should be a very simple jumping off point to modern kernel development.
The idea behind this project is to provide an easy to understand, minimalist bootstrap that lowers the barrier to entry for any new comers.
Code works for both
run ./build.sh
and you can boot the resulting example kernel on both x86_64 and AArch64
This bootstrap is being used to load this hobby OS https://github.com/stakach/crystal-kernel
Very easy to test and run on Windows with VirtualBox see Crystal Kernel for details on how to test and even step through debug your kernel on macOS.
EFI expects the bootable file to be in COFF/PE32+ format
./build.sh
to clean and build for all architecturesyou can also do this manually
make -f makefile_x86_64
bin/efi/boot/bootx64.efi
bin/kernelx64.elf
nm -C bin/uefi_bootstrap.obj
(or kernelx64.elf
)
U
tag, i.e. U memcpy
means memcpy needs to be defined in your projectVery simple to do this on Windows, for macOS see Crystal Kernel which builds disk images as part of the build script
diskmgmt.msc
)
/efi/boot
bootx64.efi
bin
folder contents to the VHDunmount the disk before booting it in VirtualBox
Starting the VM will now boot the bootx64.efi file
The process of booting should be fairly simple to follow along looking at uefi_bootstrap.zig
The real trick with UEFI code is that
-Wl,-entry:efi_main
in the make file)The bootstrap code likewise expects a few things of the kernel.elf file:
Take a look at kernel.ld
to see how this is laid out.
For instance I currently have the boot_info
label in the text
section. But I could probably swap around the text and data sections if I wanted boot_info as part of data or bss
https://eli.thegreenplace.net/2012/01/03/understanding-the-x64-code-models