Got memory map almost working

This commit is contained in:
2025-03-19 11:25:45 +01:00
parent 883cd5c1d4
commit 05561cd857
6 changed files with 99 additions and 44 deletions
+22 -2
View File
@@ -7,11 +7,13 @@
__noreturn
void kmain(void* ptr, uint32_t magic) {
if (boot_init(BOOT_MB1, ptr, magic) != 0) panic("Unsupporred bootloader.");
if (boot_initMB1(ptr, magic) != 0) panic("Unsupporred bootloader.");
// Serial console for debugging
serial_init(COM1);
debugf("\x1b[H\x1b[J\x1b[0mkern. \x1b[35m(serial console)\x1b[0m\n\n");
// ESC[H moves cursor to (0,0), ESC[J clears from cursor to end of screen
// ESC[<x>m sets graphics mode, 0 - reset, 36 - cyan
debugf("\x1b[H\x1b[J\x1b[0mkern. \x1b[36m(serial console)\x1b[0m\n\n");
// VGA tty thingy
tty_init();
@@ -26,6 +28,24 @@ void kmain(void* ptr, uint32_t magic) {
// pag_init();
debugf("Basic initialization complete!\n");
struct boot_memmap* entry;
for (
entry = (struct boot_memmap*)bootloader.memmap;
(uint64_t)entry < bootloader.memmap + bootloader.memmapLen;
entry = (struct boot_memmap*)((uint64_t)entry + entry->skip + sizeof(entry))
) {
debugf("[Region] base: %x size: %x b type: ", entry->base, entry->size);
switch (entry->type) {
case BOOT_MMAP_AVAILABLE: debugf("Available\n"); break;
case BOOT_MMAP_RESERVED: debugf("Reserved\n"); break;
case BOOT_MMAP_ACPI_RECLAIM: debugf("ACPI Reclaim\n"); break;
case BOOT_MMAP_NVS: debugf("NVS\n"); break;
case BOOT_MMAP_BADRAM: debugf("Bad RAM\n"); break;
default: debugf("Invalid type\n"); break;
}
}
panic("kmain() reached end.");