diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-05-13 15:58:19 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-05-13 15:58:19 +0800 |
| commit | 45f944c52e592c0386d3cb44dcecdedb67a71ec2 (patch) | |
| tree | 0879332305c7c2ea63c849455ea87249cb7235dc | |
| parent | fa99ae2e264ba0beeec0b2883cdb6fcc04369270 (diff) | |
| download | lume-45f944c52e592c0386d3cb44dcecdedb67a71ec2.tar.gz lume-45f944c52e592c0386d3cb44dcecdedb67a71ec2.tar.xz | |
feat: add boot parameters management with initialization and access functions
| -rw-r--r-- | na/include/lume/console.h | 1 | ||||
| -rw-r--r-- | na/kernel/boot_params.cc | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/na/include/lume/console.h b/na/include/lume/console.h index df129cf..a4fdf3f 100644 --- a/na/include/lume/console.h +++ b/na/include/lume/console.h @@ -7,6 +7,7 @@ extern "C" void early_putc(char c); extern "C" void early_puts(const char* s); +extern "C" void console_set_mmu_enabled(); /* Early UART discovery via raw FDT parsing. */ void console_early_init(uint64 fdt_paddr); diff --git a/na/kernel/boot_params.cc b/na/kernel/boot_params.cc new file mode 100644 index 0000000..e5d4ee5 --- /dev/null +++ b/na/kernel/boot_params.cc @@ -0,0 +1,45 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2026 Richard Qin */ + +#include <lume/boot_params.h> + +static BootParams g_boot_params = {}; + +static void boot_params_init_once() +{ + if (g_boot_params.magic == kBootParamsMagic) { + return; + } + g_boot_params = {}; + g_boot_params.magic = kBootParamsMagic; + g_boot_params.version = kBootParamsVersion; + g_boot_params.size = static_cast<uint32>(sizeof(BootParams)); +} + +void boot_params_init_fdt(uint64 fdt_paddr) +{ + boot_params_init_once(); + g_boot_params.fdt_ptr = fdt_paddr; + g_boot_params.seed_source = BOOT_SEED_NONE; +} + +const BootParams* boot_params_get() +{ + if (g_boot_params.magic != kBootParamsMagic) { + return nullptr; + } + return &g_boot_params; +} + +void boot_params_set_image_info(uint64 phys_base, uint64 image_size, + uint64 reloc_offset, uint64 reloc_size, + uint32 comp, uint32 image_flags) +{ + boot_params_init_once(); + g_boot_params.kimage_phys_base = phys_base; + g_boot_params.kimage_size = image_size; + g_boot_params.kimage_reloc_offset = reloc_offset; + g_boot_params.kimage_reloc_size = reloc_size; + g_boot_params.kimage_comp = comp; + g_boot_params.kimage_flags = image_flags; +} |
