mirror of
https://github.com/Tom-on64/kern.git
synced 2026-11-04 02:23:10 +00:00
Got memory map almost working
This commit is contained in:
+22
-2
@@ -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.");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user