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.

36 lines
664 B
C++

#include <array>
#include <cstdint>
extern void kernel_main();
alignas(16)
std::array<std::uint8_t, 16384> stack;
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()));
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;
}
kernel_main();
asm volatile("cli");
for (;;)
asm volatile("hlt");
}