diff options
Diffstat (limited to 'multiboot.cpp')
-rw-r--r-- | multiboot.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/multiboot.cpp b/multiboot.cpp new file mode 100644 index 0000000..0c34984 --- /dev/null +++ b/multiboot.cpp @@ -0,0 +1,41 @@ +#include "textoutput.hpp" + +#include <cstdint> + +extern TextOutput& term; + +std::uint32_t multiboot_magic; +std::uint32_t *multiboot_ptr; + +std::uint32_t lowerMem = 0; +std::uint32_t upperMem = 0; + +bool multiboot_initialize() +{ + if (multiboot_magic != 0x36d76289) { + term.write("Not multiboot!"); + return false; + } + + term.write("Found multiboot headers: "); + + auto ptr = multiboot_ptr + 2; + while (ptr[0] != 0 && ptr[1] != 8) { + term.write(ptr[0]); + term.write(", "); + + if (ptr[0] == 4) { + lowerMem = ptr[2] * 1024; + upperMem = ptr[3] * 1024; + } + + auto next = reinterpret_cast<std::uintptr_t>(ptr); + next += ptr[1]; + next = (next + 7) & ~7; + ptr = reinterpret_cast<std::uint32_t *>(next); + } + + term.write('\n'); + return true; +} + |