From 85c8fd05f1a0c0224882c4fafa60003d3ef56cf3 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Mon, 30 Sep 2024 10:59:59 -0400 Subject: compile with wall,extra,error,pedantic --- boot.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'boot.cpp') diff --git a/boot.cpp b/boot.cpp index 1c46b63..6b1da6a 100644 --- a/boot.cpp +++ b/boot.cpp @@ -1,10 +1,20 @@ #include #include +#include +extern void (*__init_array_start)(); +extern void (*__init_array_end)(); extern void kernel_main(); alignas(16) -std::array stack; +static std::array stack; + +static void init_array() +{ + std::span initArray (&__init_array_start, &__init_array_end); + for (auto& fn : initArray) + fn(); +} extern "C" __attribute__((naked)) @@ -16,16 +26,7 @@ void _start() mov %0, %%esp )" :: "i" (stack.data() + stack.size())); - extern std::uint32_t __init_array_start; - extern std::uint32_t __init_array_end; - - auto it = &__init_array_start; - while (it < &__init_array_end) { - auto fn = reinterpret_cast(*it); - fn(); - ++it; - } - + init_array(); kernel_main(); asm volatile("cli"); -- cgit v1.2.3