From 0e3195ec3db84805b27c2ef3eab86f09a97ea42b Mon Sep 17 00:00:00 2001 From: Eggert Jung Date: Sat, 10 Jan 2026 17:21:14 +0100 Subject: [PATCH] test memory info --- kernel/main.cc | 4 ++++ kernel/memory/pageframealloc.cc | 13 +++++++++++++ kernel/thread/idlethread.cc | 2 +- kernel/user/app1/appl.cc | 6 +++--- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/kernel/main.cc b/kernel/main.cc index 396d3bf..740b5c3 100644 --- a/kernel/main.cc +++ b/kernel/main.cc @@ -3,6 +3,7 @@ #include "./debug/output.h" #include "./types.h" // This is actually used #include "arch/core_interrupt.h" +#include "memory/pageframealloc.h" #include "syscall/handler.h" #include "./device/textstream.h" @@ -22,6 +23,7 @@ OutputStream* copyout = ©stream; #include "./arch/ioapic.h" #include "./device/ps2controller.h" #include "./interrupt/guard.h" +#include "./boot/multiboot/data.h" #include "./sync/semaphore.h" #include "./thread/thread.h" //Semaphore koutsem(1); @@ -38,6 +40,8 @@ static KeyboardApplication kapp; // Main function extern "C" int main() { + PageFrameAllocator::init(); + tout.reset(); tout.setPos(33, 0); tout << OS_NAME << " (2.x)" << flush; diff --git a/kernel/memory/pageframealloc.cc b/kernel/memory/pageframealloc.cc index ac2dfe5..82c87d0 100644 --- a/kernel/memory/pageframealloc.cc +++ b/kernel/memory/pageframealloc.cc @@ -1,7 +1,20 @@ #include "../memory/pageframealloc.h" +#include "../boot/multiboot/data.h" #include "pageframe.h" +#include "../debug/output.h" + +#include "../memory/config.h" + void PageFrameAllocator::init(){ + Multiboot::Memory* memory_map_start = Multiboot::getMemoryMap(); + + dout << "kernel start: " << ___KERNEL_START___; + dout << " kernel end: " << ___KERNEL_END___ << endl; + while(memory_map_start != 0){ + dout << "Memory: " << hex << memory_map_start->getStartAddress() << " to " << memory_map_start->getEndAddress() << " is available: " << memory_map_start->isAvailable() << ".\n"; + memory_map_start = memory_map_start->getNext(); + } } void PageFrameAllocator::stats(){ diff --git a/kernel/thread/idlethread.cc b/kernel/thread/idlethread.cc index 0e3b62c..a566cb7 100644 --- a/kernel/thread/idlethread.cc +++ b/kernel/thread/idlethread.cc @@ -21,7 +21,7 @@ void IdleThread::action() { } Core::idle(); // We woke up. Start ticking again - dout << "idle "; + //dout << "idle "; LAPIC::Timer::setMasked(false); } else { diff --git a/kernel/user/app1/appl.cc b/kernel/user/app1/appl.cc index 450694c..0483ca5 100644 --- a/kernel/user/app1/appl.cc +++ b/kernel/user/app1/appl.cc @@ -14,9 +14,9 @@ void Application::action() { // NOLINT for (unsigned i = 1;; ++i) { write(1, text, sizeof(text)); if(i==id){ - write(2, "kill", 4); - write(2, &text[4], 1); - write(2, " ", 1); + //write(2, "kill", 4); + //write(2, &text[4], 1); + //write(2, " ", 1); sys_exit(); } sleep(1000);