You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
669 B
C++
37 lines
669 B
C++
#include <array>
|
|
#include <cstdint>
|
|
#include <span>
|
|
|
|
extern void (*__init_array_start)();
|
|
extern void (*__init_array_end)();
|
|
extern void kernel_main();
|
|
|
|
alignas(16)
|
|
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))
|
|
void _start()
|
|
{
|
|
asm volatile(R"(
|
|
mov %%eax, multiboot_magic
|
|
mov %%ebx, multiboot_ptr
|
|
mov %0, %%esp
|
|
)" :: "i" (stack.data() + stack.size()));
|
|
|
|
init_array();
|
|
kernel_main();
|
|
|
|
asm volatile("cli");
|
|
for (;;)
|
|
asm volatile("hlt");
|
|
}
|
|
|