diff --git a/kernel/src/init/InitRD.cpp b/kernel/src/init/InitRD.cpp index ca9cb7d4..c3dfb9d4 100644 --- a/kernel/src/init/InitRD.cpp +++ b/kernel/src/init/InitRD.cpp @@ -84,8 +84,16 @@ void InitRD::for_each(void (*callback)(File& f)) { TarHeader* hdr = (TarHeader*)KernelMemoryManager::get_unaligned_mapping(get_block(block)); block++; - if (hdr->typeflag == 53) { continue; } // Directory - if (!is_valid_header(hdr)) { continue; } + if (hdr->typeflag == 53) + { + KernelMemoryManager::release_unaligned_mapping(hdr); + continue; + } // Directory + if (!is_valid_header(hdr)) + { + KernelMemoryManager::release_unaligned_mapping(hdr); + continue; + } auto f = get_file(hdr); block += get_file_size_in_blocks(f); KernelMemoryManager::release_unaligned_mapping(hdr); diff --git a/kernel/src/interrupts/Entry.cpp b/kernel/src/interrupts/Entry.cpp index c44b78a3..0e313472 100644 --- a/kernel/src/interrupts/Entry.cpp +++ b/kernel/src/interrupts/Entry.cpp @@ -13,7 +13,13 @@ extern "C" void common_handler(SavedContext* context) } if (context->number == 14) { - printf("Page fault (RIP 0x%lx), while trying to access %lx\n", context->rip, context->cr2); + printf("Page fault (RIP 0x%lx), while trying to access %lx, error code %lx\n", context->rip, context->cr2, + context->error_code); + hang(); + } + if (context->number == 8) + { + printf("Double fault"); hang(); } if (context->number >= 0x20 && context->number < 0x30) { IRQ::interrupt_handler(context); } diff --git a/kernel/src/main.cpp b/kernel/src/main.cpp index 987284a9..0202954a 100644 --- a/kernel/src/main.cpp +++ b/kernel/src/main.cpp @@ -1,6 +1,7 @@ #define MODULE "main" #include "acpi/RSDT.h" +#include "assert.h" #include "config.h" #include "cpu/CPU.h" #include "gdt/GDT.h" @@ -17,6 +18,7 @@ #include "panic/hang.h" #include "power/reboot.h" #include "render/Framebuffer.h" +#include "render/TextRenderer.h" #include "scheduling/PIT.h" #include "std/stdio.h" #include "std/stdlib.h" @@ -63,6 +65,8 @@ extern "C" void _start() kinfoln("Interrupts enabled"); + ASSERT(TextRenderer::try_initialize()); + ACPI::SDTHeader* rootSDT = ACPI::GetRSDTOrXSDT(); bool isXSDT = ACPI::IsXSDT(); if (!ACPI::ValidateRSDTOrXSDT(rootSDT)) kerrorln("Invalid %s", isXSDT ? "XSDT" : "RSDT"); diff --git a/kernel/src/memory/RangeAllocator.cpp b/kernel/src/memory/RangeAllocator.cpp index e4eaabbd..621c3a69 100644 --- a/kernel/src/memory/RangeAllocator.cpp +++ b/kernel/src/memory/RangeAllocator.cpp @@ -1,3 +1,5 @@ +#define MODULE "mem" + #include "memory/RangeAllocator.h" #include "assert.h" #include "bootboot.h" @@ -19,6 +21,11 @@ void RangeAllocator::init_from_mmap() uint64_t mmap_entries = (bootboot.size - 128) / 16; for (uint64_t i = 0; i < mmap_entries; i++) { + if (!MMapEnt_IsFree(ptr)) + { + ptr++; + continue; + } if (MMapEnt_Size(ptr) > biggest_chunk_size) { biggest_chunk = (void*)MMapEnt_Ptr(ptr);