Files
Asuro/doc/src/asuro.md
T
t3hn3rd 2d190c221a feature: boot.mgr replace hardcoded init sequence with dependency-driven boot manager
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
2026-03-13 15:37:43 +00:00

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.mgr
  • io.syslog
  • core.panic
  • arch.x86.multiboot
  • arch.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:

  1. Stores the Multiboot info pointer and magic value into module-level globals.
  2. Calls System.init() — FPC RTL initialisation (runs all unit initialization sections, which populates boot.mgr's registration table).
  3. Calls boot.mgr.run — executes all registered boot entries in dependency-resolved order.
  4. 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 kmain has been replaced entirely by boot.mgr. Individual units now self-register their init procedures and dependencies; kmain only bootstraps the framework and idles.
  • System.init() triggers FPC_INITIALIZEUNITS, which runs every unit's initialization section. This is what populates boot.mgr's entry table before run is called.