Skip to main content

Module dtb_boot

Module dtb_boot 

Source
Expand description

Boot-protocol entry point (DTB/PVH) Boot protocol entry point.

This module handles the kernel entry from the bootloader or PVH stub. The bootloader passes a pointer to a strat9_abi::boot::KernelArgs structure. PVH boot passes null : a minimal KernelArgs is built internally.

ยงBoot flow

boot64.S (_start)
  => save KernelArgs pointer, setup 8 KB bootstrap stack, clear BSS
  => call kmain(args_ptr)
    => enable SSE/OSXSAVE (CPU features)
    => early serial output
    => read KernelArgs from pointer (bootloader) or build_minimal_args (PVH)
    => call crate::kernel_main(args)
      => (buddy allocator init)
      => allocate 256 KB kernel stack
      => switch_stack(new_stack, continue_init)

Constantsยง

KERNEL_STACK_SIZE
Size of the real kernel stack allocated after buddy allocator init.

Staticsยง

KERNEL_ELF_BASE ๐Ÿ”’
Saved kernel ELF base address and size for symbol resolution during panic.
KERNEL_ELF_SIZE ๐Ÿ”’

Functionsยง

build_minimal_args ๐Ÿ”’
Build minimal KernelArgs for PVH boot (no DTB).
early_print ๐Ÿ”’ โš 
Very early serial output using raw COM1 port I/O. Safe to call before any kernel subsystem is initialized.
early_print_hex ๐Ÿ”’ โš 
Write a u64 as hex to COM1 (no alloc, no fmt traits).
enable_cpu_features ๐Ÿ”’ โš 
Enable SSE (OSFXSR, OSXMMEXCPT) and FPU (NE) in CR0/CR4.
hlt_loop ๐Ÿ”’
Halt the CPU forever.
kernel_elf_bytes
Get the kernel ELF bytes as a slice. Returns None if not yet initialized.
kmainโš 
Kernel entry point called by the bootloader or PVH boot.