diff options
Diffstat (limited to 'kernel.cpp')
-rw-r--r-- | kernel.cpp | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/kernel.cpp b/kernel.cpp new file mode 100644 index 0000000..41c3a61 --- /dev/null +++ b/kernel.cpp @@ -0,0 +1,55 @@ +#include "gdt.hpp" +#include "idt.hpp" +#include "memory.hpp" +#include "multiboot.hpp" +#include "pic.hpp" +#include "pit.hpp" +#include "tasking.hpp" +#include "vgaterminal.hpp" + +static VGATerminal vga; +TextOutput& term = vga; + +extern "C" +void kernel_main(void) +{ + term.write("Clyne's kernel, v2024\n\n"); + + if (!multiboot_initialize()) + for (;;); + + idt_register_callback(14, [](const Registers& regs) { + term.write("Page fault! eip="); + term.write(regs.eip); + term.write('\n'); + for (;;); + }); + + memory_initialize(); + gdt_initialize(); + pic_initialize(); + idt_initialize(); + pit_initialize(50); + asm volatile("sti"); + tasking_initialize(); + term.write("Tasking enabled.\n"); + + tasking_spawn([] { + for (;;) + term.write('B'); + }, 256); + + for (;;) + term.write('A'); +} + +extern "C" +void memmove(char* dst, char* src, size_t sz) { + while (sz) { + *dst = *src; + ++dst; + ++src; + --sz; + } +} + |