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.

42 lines
843 B
C++

#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;
}