diff options
Diffstat (limited to 'boot.cpp')
-rw-r--r-- | boot.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
@@ -1,10 +1,20 @@ #include <array> #include <cstdint> +#include <span> +extern void (*__init_array_start)(); +extern void (*__init_array_end)(); extern void kernel_main(); alignas(16) -std::array<std::uint8_t, 16384> stack; +static std::array<std::uint8_t, 16384> 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<void (*)()>(*it); - fn(); - ++it; - } - + init_array(); kernel_main(); asm volatile("cli"); |