Skip to content

Use of machine RAM and improve boot flow#60

Merged
LuernOutOfOrder merged 17 commits intodevelopfrom
54-improve-ram-usage
Dec 16, 2025
Merged

Use of machine RAM and improve boot flow#60
LuernOutOfOrder merged 17 commits intodevelopfrom
54-improve-ram-usage

Conversation

@LuernOutOfOrder
Copy link
Owner

This pull request implements a major refactor and documentation update for the kernel boot flow in LrnRTOS. The changes introduce a clear, phased boot process, modularize early boot logic, add robust memory initialization with dynamic stack switching, and provide detailed developer documentation. The most important changes are grouped below.

Kernel Boot Refactor and Modularization

  • Introduced a new boot module with the kernel_early_boot function, which handles the phased initialization of the platform, subsystems, trap frame, interrupts, and memory before jumping to the main kernel loop. The early boot logic was moved from main to this new function, clarifying responsibilities and improving maintainability. (src/boot.rs [1] src/main.rs [2] src/arch/riscv32/start.rs [3]
  • Added a detailed developer document describing the kernel boot flow, phases, invariants, and common pitfalls. This will help onboard new contributors and clarify boot sequence expectations. (Documentation/kernel/boot.md Documentation/kernel/boot.mdR1-R145)

Memory Management and Stack Switching

  • Added a new memory management module (mem) that initializes RAM based on platform/FDT information, sets up a dynamic kernel stack, and switches the stack pointer at the correct phase in the boot sequence using RISC-V assembly. (src/mem/mod.rs [1] src/mem/kernel.rs [2] src/arch/riscv32/asm/mod.rs [3] src/arch/riscv32/asm/set_kernel_sp.S [4] src/config.rs [5]
  • Added platform memory provider logic to support both static and FDT-based memory discovery, ensuring the kernel can boot on different hardware configurations. (src/platform/mem.rs [1] src/devices_info.rs [2] [3] src/platform/mod.rs [4] [5]

Device Tree and Platform Enhancements

  • Improved FDT (Flattened Device Tree) parsing by adding a helper to find nodes by device_type, and fixed a bug in property assignment during FDT parsing. (src/platform/fdt/helpers.rs [1] src/platform/fdt/mod.rs [2] [3] [4] [5]
  • Added debug output to indicate whether the platform is using FDT or static device configuration at boot. (src/platform/mod.rs src/platform/mod.rsR31-R37)

These changes provide a robust, extensible foundation for kernel bring-up, memory management, and platform abstraction, while also improving developer experience and documentation.

@LuernOutOfOrder LuernOutOfOrder added this to the v0.2.0 milestone Dec 16, 2025
@LuernOutOfOrder LuernOutOfOrder self-assigned this Dec 16, 2025
@LuernOutOfOrder LuernOutOfOrder added bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request labels Dec 16, 2025
@LuernOutOfOrder LuernOutOfOrder linked an issue Dec 16, 2025 that may be closed by this pull request
@LuernOutOfOrder LuernOutOfOrder merged commit 56cfdee into develop Dec 16, 2025
1 check passed
@LuernOutOfOrder LuernOutOfOrder deleted the 54-improve-ram-usage branch December 16, 2025 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve RAM usage

1 participant