start_kernel

Function start_kernel 

Source
#[unsafe(no_mangle)]
pub extern "C" fn start_kernel(boot_info: &BootInfo) -> !
Expand description

Main kernel entry point for the boot processor

This function is called by architecture-specific boot code and performs the complete kernel initialization sequence using information provided in the BootInfo structure.

§Boot Sequence

The kernel initialization follows this structured sequence:

  1. Early System Setup: Extract boot parameters from BootInfo
  2. Memory Initialization: Set up heap allocator with usable memory
  3. Early Initcalls: Initialize critical early subsystems
  4. Driver Initcalls: Load and initialize device drivers
  5. Virtual Memory: Set up kernel virtual memory management
  6. Device Discovery: Enumerate hardware from BootInfo device source
  7. Graphics Initialization: Initialize graphics subsystem and framebuffer
  8. Interrupt System: Set up interrupt controllers and handlers
  9. Timer Subsystem: Initialize kernel timer and scheduling infrastructure
  10. VFS Setup: Initialize virtual filesystem and mount root
  11. Initramfs Processing: Mount initramfs if provided in BootInfo
  12. Initial Task: Create and load initial userspace process
  13. Scheduler Start: Begin task scheduling and enter normal operation

§Architecture Integration

This function is architecture-agnostic and relies on the BootInfo structure to abstract hardware-specific details. Architecture-specific boot code is responsible for creating a properly initialized BootInfo before calling this function.

§Arguments

  • boot_info - Comprehensive boot information structure containing:
    • CPU ID for multicore initialization
    • Usable memory area for heap allocation
    • Optional initramfs location and size
    • Kernel command line parameters
    • Device information source (FDT/UEFI/ACPI)

§Memory Layout

The function expects the following memory layout:

  • Kernel image loaded and executable
  • BootInfo.usable_memory available for allocation
  • Hardware description (FDT/ACPI) accessible via device_source
  • Optional initramfs data at specified location

§Safety

This function assumes:

  • Architecture-specific initialization has completed successfully
  • BootInfo contains valid memory areas and addresses
  • Basic CPU features (MMU, interrupts) are available
  • Memory protection allows kernel operation

§Returns

This function never returns - it transitions to the scheduler and enters normal kernel operation mode.