diff options
Diffstat (limited to 'na/include')
| -rw-r--r-- | na/include/lume/addr.h | 17 | ||||
| -rw-r--r-- | na/include/lume/config.h | 57 | ||||
| -rw-r--r-- | na/include/lume/console.h | 7 | ||||
| -rw-r--r-- | na/include/lume/fdt.h | 1 | ||||
| -rw-r--r-- | na/include/lume/pmm.h | 3 |
5 files changed, 79 insertions, 6 deletions
diff --git a/na/include/lume/addr.h b/na/include/lume/addr.h index 9c20d66..572b6fe 100644 --- a/na/include/lume/addr.h +++ b/na/include/lume/addr.h @@ -29,6 +29,23 @@ inline PhysAddr va_to_pa(VirtAddr va) return PhysAddr{va.raw - arch::g_direct_map_base}; } +/* + * Early-boot conversions pinned to the bootstrap direct-map base. + * + * Use these only before vmm_init() activates the final kernel page table. + * They are required when KASLR has already randomized g_direct_map_base, + * but the CPU is still running on the bootstrap mapping built in entry.S. + */ +inline VirtAddr boot_pa_to_va(PhysAddr pa) +{ + return VirtAddr{pa.raw + arch::kDirectMapBaseDefault}; +} + +inline PhysAddr boot_va_to_pa(VirtAddr va) +{ + return PhysAddr{va.raw - arch::kDirectMapBaseDefault}; +} + /* Align up to page boundary */ inline uint64 page_align_up(uint64 addr) { diff --git a/na/include/lume/config.h b/na/include/lume/config.h index acd76ef..40787cc 100644 --- a/na/include/lume/config.h +++ b/na/include/lume/config.h @@ -12,12 +12,59 @@ * This header is safe to include from both C++ and assembly files. * Assembly-visible constants use #define; C++ code gets typed constexpr. * + * Values are injected by the build system via -DCONFIG_xxx flags + * (see scripts/Kconfig.mk). The #ifndef guards below provide + * safe defaults so the header is self-contained for IDE analysis. + * * Reference: docs/specs/00_conventions.md §1.3 */ -/* These macros are shared with assembly (entry.S) */ -#define LUME_MAX_CPUS 8 -#define LUME_PAGE_SIZE 4096 +/* ================================================================ + * Defaults — only used when CONFIG_xxx is NOT supplied by -D flag. + * In a normal build, scripts/Kconfig.mk always provides them. + * ================================================================ */ + +#ifndef CONFIG_NR_CPUS +#define CONFIG_NR_CPUS 8 +#endif + +#ifndef CONFIG_PAGE_SIZE +#define CONFIG_PAGE_SIZE 4096 +#endif + +#ifndef CONFIG_MAX_ORDER +#define CONFIG_MAX_ORDER 11 +#endif + +#ifndef CONFIG_KERNEL_STACK_SIZE +#define CONFIG_KERNEL_STACK_SIZE 8192 +#endif + +#ifndef CONFIG_HZ +#define CONFIG_HZ 100 +#endif + +#ifndef CONFIG_NR_PRIORITIES +#define CONFIG_NR_PRIORITIES 32 +#endif + +#ifndef CONFIG_DEFAULT_PRIORITY +#define CONFIG_DEFAULT_PRIORITY (CONFIG_NR_PRIORITIES / 2) +#endif + +#ifndef CONFIG_IDLE_PRIORITY +#define CONFIG_IDLE_PRIORITY (CONFIG_NR_PRIORITIES - 1) +#endif + +#ifndef CONFIG_DEFAULT_TIMESLICE +#define CONFIG_DEFAULT_TIMESLICE (CONFIG_HZ / 10) +#endif + +/* ================================================================ + * Legacy compatibility aliases (shared with assembly) + * ================================================================ */ +#define LUME_MAX_CPUS CONFIG_NR_CPUS +#define LUME_PAGE_SIZE CONFIG_PAGE_SIZE #ifndef __ASSEMBLER__ @@ -26,9 +73,9 @@ /* Maximum number of CPUs supported by the kernel. * Compile-time limit for static arrays (boot stacks, per-cpu data). * Actual CPU count is detected at runtime via FDT. */ -inline constexpr int kMaxCpus = LUME_MAX_CPUS; +inline constexpr int kMaxCpus = CONFIG_NR_CPUS; /* Virtual memory page size (4KB, matching SV39 base page). */ -inline constexpr uint64 kPageSize = LUME_PAGE_SIZE; +inline constexpr uint64 kPageSize = CONFIG_PAGE_SIZE; #endif /* __ASSEMBLER__ */
\ No newline at end of file diff --git a/na/include/lume/console.h b/na/include/lume/console.h index ff9f019..df129cf 100644 --- a/na/include/lume/console.h +++ b/na/include/lume/console.h @@ -13,3 +13,10 @@ void console_early_init(uint64 fdt_paddr); /* Full console initialization. Maps MMIO. */ void console_init(); + +/* + * Notify console that the runtime kernel page table is active. + * After this point early_putc() must use runtime direct-map base + * instead of the bootstrap fixed base. + */ +void console_use_runtime_mapping(); diff --git a/na/include/lume/fdt.h b/na/include/lume/fdt.h index 63d185b..626cc48 100644 --- a/na/include/lume/fdt.h +++ b/na/include/lume/fdt.h @@ -82,3 +82,4 @@ DeviceNode *fdt_get_node_by_path(const char *path); // Early scan wrappers (delegate to FdtManager static methods). void fdt_early_get_mem_info(uint64 *base, uint64 *size); void fdt_early_get_uart_info(uint64 *uart_addr, uint64 *uart_size); +void fdt_early_get_kaslr_seed(uint64 *seed); diff --git a/na/include/lume/pmm.h b/na/include/lume/pmm.h index a9249ac..266a83c 100644 --- a/na/include/lume/pmm.h +++ b/na/include/lume/pmm.h @@ -22,9 +22,10 @@ #include <lume/types.h> #include <lume/frame.h> #include <lume/addr_types.h> +#include <lume/config.h> /* Buddy system constants */ -inline constexpr int kMaxOrder = 11; // Orders 0..10 → 4KB..4MB +inline constexpr int kMaxOrder = CONFIG_MAX_ORDER; // Orders 0..(N-1) /* Per-CPU cache dynamic parameters (calculated in pmm_init) */ extern uint32 g_pcp_high_watermark; |
