- Mainly developped in C.
- Boots with UEFI.
- Does not do anything meaningful.
arch/*
: architecture-specific codeboot
: early boot (after firmware, before kernel_main)*
: same as non-arch
dev
: device driversinclude
kernel
: core kernel components (task management, core functions)lib
: hardware independant code (ELF, string manipulation, generic structures)mm
: memory management
build
: directory generated by./boot
script for QEMUscripts
: helper scriptsthird_party
: external libraries dependencies
./boot
: script to boot the kernel./boot efi ARGS
: starts kernel with QEMU (ARGS are passed to QEMU)./boot egdb ARGS
: starts GDB and use theuefi.py
lib to debug kernel
uefi.py
: GDB library to load kernel symbols during boot- GDB command
efi
: automatically called by./boot egdb
:- load kernel symbols to 2 positions:
- the address where EFI has loaded the kernel
- the address where the kernel relocates
- read the
auto.gdb
file
- load kernel symbols to 2 positions:
- GDB command
qq
: kill kernel and quit - GDB command
rbreakif
: likerbreak
but supports a condition
- GDB command
auto.gdb
: commands to run automatically byuefi.py
- lines starting with
#
are ignored - lines starting with
@
don't produce output to GDB console - lines starting with
*
are executed on when breakpoint is reached (last created breakpoint) - other lines are executed normally
- lines starting with
- Linux kernel Kconfig:
conf
andmconf
executables must be inPATH
- Configure with
make menuconfig
- Build with
make
Run the following boot
shell function:
boot() { ./boot efi ${QEMU_ARGS} & ./boot egdb "$@" ; kill -0 $! 1>/dev/null 2>&1 && kill $! ; killall qemu-system-x86_64; }
Extra args are passed to GDB.
QEMU_ARGS
environment variable is passed to QEMU as extra args.
- Terminal 1:
./boot efi -monitor stdio -display none
- Terminal 2:
./boot egdb
Each directory has:
- A
Kconfig
file - A
Makefile
which lists needed object files:- all files in the
obj-y
variable will be built in the final kernel - all files in the
bootloader-y
variable will be built in the bootloader (stage 1 kernel) Makefile
structure (in order):- include
Makefile.flags
- define variables (
obj-y
, ...) - include
Makefile.rules
- define build rules specific to this directory
- include
- all files in the
Compilation generates in each directory:
*.o
files for the final kernel*.bootloader.o
for the bootloadermodules.o
: all*.o
files mergedbootloader.o
: all*.bootloader.o
files merged*.d
files corresponding to their*.o
counterpart