Introduce boot.mgr - a self-registering, dependency-ordered boot initialization framework with barrier-based phasing and glob pattern matching. Units now declare their own init procedures and dependencies via registerBoot()/registerBarrier() in their initialization sections, boot.mgr.run() topologically sorts and executes them. - Add src/boot/boot.mgr.pas with topoSort, glob matching, barrier two-pass algorithm, and boot tree printer - Gut src/asuro.pas (kmain): now just stores multiboot info, calls System.init(), boot.mgr.run, and yield() - Add initialization sections with registerBoot() to 53 existing units - Add new units: core.pas, test.pas, driver.storage.boot.pas, app.wasm.pas, app.bsod.pas (factored out of asuro.pas) - Define 9 barrier phases: immediate -> early -> middle -> storage -> bus -> device -> bus.late -> late -> final - Fix xHCI ISR: exclude PRC/WRC from PORTSC change bit clearing to prevent race with port reset busy-wait - Fix driver.bus.usb.core fire_completion_hooks: guard against uint32 underflow when CompletionHookCount = 0 - Move auto_mount_volumes from device barrier to late barrier so it runs after PCI scan discovers storage controllers - Add toolchain/compile_initcalls.sh for boot entry extraction - Add Boot Registration sections to all 51 doc files; create 4 new doc files; rewrite boot.mgr.md; update mkdocs.yml nav
2.4 KiB
asuro
Kernel main entry point.
Overview
asuro contains kmain, the first Pascal-level function called by the bootloader after the assembly stub hands off control. It stores the Multiboot info pointer and magic value, initialises the FPC system unit, then delegates the entire boot sequence to boot.mgr.run. Once all registered boot entries have executed, it calls yield to enable preemptive scheduling and idle the CPU.
The unit also registers its own init procedure with boot.mgr (depending on io.syslog). This procedure validates the Multiboot magic number — panicking if it does not match — and logs the framebuffer address and dimensions from the Multiboot info structure.
Dependencies
boot.mgrio.syslogcore.panicarch.x86.multibootarch.x86.proc.sched
Boot Registration
Registered with boot.mgr as asuro, depending on io.syslog.
Functions and Procedures
kmain
procedure kmain(mbinfo: Pmultiboot_info_t; mbmagic: uint32); stdcall;
Exported as kmain (public alias). Performs three steps:
- Stores the Multiboot info pointer and magic value into module-level globals.
- Calls
System.init()— FPC RTL initialisation (runs all unitinitializationsections, which populatesboot.mgr's registration table). - Calls
boot.mgr.run— executes all registered boot entries in dependency-resolved order. - Calls
yield— enables preemptive scheduling and enters the idle loop.
init (internal)
procedure init;
Registered with boot.mgr as asuro. Validates that the Multiboot magic number matches MULTIBOOT_BOOTLOADER_MAGIC, panicking if it does not. Logs the assigned framebuffer address and dimensions from the Multiboot info structure.
yield (internal)
procedure yield;
Logs "Boot complete", calls arch.x86.proc.sched.init to enable preemptive context switching (replaces ISR_32), then enters an infinite STI / HLT loop. All subsequent execution is driven by timer and device interrupts.
Notes
- The old hardcoded boot sequence previously in
kmainhas been replaced entirely byboot.mgr. Individual units now self-register their init procedures and dependencies;kmainonly bootstraps the framework and idles. System.init()triggersFPC_INITIALIZEUNITS, which runs every unit'sinitializationsection. This is what populatesboot.mgr's entry table beforerunis called.