From 45f944c52e592c0386d3cb44dcecdedb67a71ec2 Mon Sep 17 00:00:00 2001 From: Richard Qin Date: Wed, 13 May 2026 15:58:19 +0800 Subject: feat: add boot parameters management with initialization and access functions --- na/include/lume/console.h | 1 + na/kernel/boot_params.cc | 45 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 na/kernel/boot_params.cc 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 + +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(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; +} -- cgit v1.2.3