Add preprocessor directives to supress logs per file.
Makes the output much cleaner by default but allows for getting more infor if debugging in the future.
This commit is contained in:
parent
add533071b
commit
53ff49b265
7 changed files with 52 additions and 5 deletions
|
|
@ -4,6 +4,8 @@
|
|||
#include "memory/paging_util.h"
|
||||
#include "memory/physical_memory.h"
|
||||
|
||||
#define K_VMAS_DEBUG 0
|
||||
|
||||
extern KernelStackManager* gKernelStackManager;
|
||||
|
||||
RefPtr<AddressSpace> AddressSpace::ForRoot() {
|
||||
|
|
@ -50,6 +52,9 @@ uint64_t* AddressSpace::AllocateKernelStack() {
|
|||
}
|
||||
|
||||
bool AddressSpace::HandlePageFault(uint64_t vaddr) {
|
||||
#if K_VMAS_DEBUG
|
||||
dbgln("[VMAS] Page Fault!");
|
||||
#endif
|
||||
MemoryMapping* mapping = GetMemoryMappingForAddr(vaddr);
|
||||
if (mapping == nullptr) {
|
||||
return false;
|
||||
|
|
@ -60,7 +65,9 @@ bool AddressSpace::HandlePageFault(uint64_t vaddr) {
|
|||
dbgln("WARN: Memory object returned invalid physical addr.");
|
||||
return false;
|
||||
}
|
||||
dbgln("Mapping P(%m) at V(%m)", physical_addr, vaddr);
|
||||
#if K_VMAS_DEBUG
|
||||
dbgln("[VMAS] Mapping P(%m) at V(%m)", physical_addr, vaddr);
|
||||
#endif
|
||||
MapPage(cr3_, vaddr, physical_addr);
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,14 @@
|
|||
#include "debug/debug.h"
|
||||
#include "memory/physical_memory.h"
|
||||
|
||||
#define K_MEM_DEBUG 0
|
||||
|
||||
MemoryObject::MemoryObject(uint64_t size) : size_(size) {
|
||||
if ((size & 0xFFF) != 0) {
|
||||
size_ = (size & ~0xFFF) + 0x1000;
|
||||
#if K_MEM_DEBUG
|
||||
dbgln("MemoryObject: aligned %x to %x", size, size_);
|
||||
#endif
|
||||
}
|
||||
// FIXME: Do this lazily.
|
||||
uint64_t num_pages = size_ / 0x1000;
|
||||
|
|
@ -56,7 +60,9 @@ uint64_t MemoryObject::PageNumberToPhysAddr(uint64_t page_num) {
|
|||
}
|
||||
|
||||
if (*iter == 0) {
|
||||
#if K_MEM_DEBUG
|
||||
dbgln("Allocating page num %u for mem object", page_num);
|
||||
#endif
|
||||
*iter = phys_mem::AllocatePage();
|
||||
}
|
||||
return *iter;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include "object/process.h"
|
||||
#include "scheduler/scheduler.h"
|
||||
|
||||
#define K_THREAD_DEBUG 0
|
||||
|
||||
namespace {
|
||||
|
||||
extern "C" void jump_user_space(uint64_t rip, uint64_t rsp, uint64_t arg1,
|
||||
|
|
@ -53,14 +55,18 @@ void Thread::Start(uint64_t entry, uint64_t arg1, uint64_t arg2) {
|
|||
}
|
||||
|
||||
void Thread::Init() {
|
||||
#if K_THREAD_DEBUG
|
||||
dbgln("Thread start.", pid(), id_);
|
||||
#endif
|
||||
uint64_t rsp = process_.vmas()->AllocateUserStack();
|
||||
SetRsp0(rsp0_start_);
|
||||
jump_user_space(rip_, rsp, arg1_, arg2_);
|
||||
}
|
||||
|
||||
void Thread::Exit() {
|
||||
dbgln("Exiting", pid(), id_);
|
||||
#if K_THREAD_DEBUG
|
||||
dbgln("Exiting");
|
||||
#endif
|
||||
state_ = FINISHED;
|
||||
process_.CheckState();
|
||||
gScheduler->Yield();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue