From 513a8d20beeacb3a7fc2c3c140d014f7fb25cd6f Mon Sep 17 00:00:00 2001 From: Kimplul Date: Thu, 6 Jan 2022 17:41:38 +0200 Subject: Jump back to kernelspace tested + Added automated categories to debugging, bug/info/warn/error etc. Now I should just try to use them here and there :D --- common/main.c | 1 - common/pmem.c | 8 ++++++-- common/uapi/mem.c | 10 ++++++++-- 3 files changed, 14 insertions(+), 5 deletions(-) (limited to 'common') diff --git a/common/main.c b/common/main.c index f91fc22..52987d1 100644 --- a/common/main.c +++ b/common/main.c @@ -41,7 +41,6 @@ void __main main(void *fdt) arch_setup(fdt); init_pmem(fdt); - init_mem_blocks(); struct vm_branch *b = init_vmem(fdt); /* start up debugging in kernel IO */ diff --git a/common/pmem.c b/common/pmem.c index c919204..ae01175 100644 --- a/common/pmem.c +++ b/common/pmem.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -426,7 +427,7 @@ void init_pmem(void *fdt) size_t actual_size = populate_pmap(ram_base, ram_size, pmap_base); if(probe_size != actual_size) - dbg("BUG! probe_size (%#lx) != actual_size (%#lx)\n", + bug("probe_size (%#lx) != actual_size (%#lx)\n", probe_size, actual_size); /* mark init stack, this should be unmapped once we get to executing @@ -434,7 +435,8 @@ void init_pmem(void *fdt) mark_area_used((pm_t)__va(PM_STACK_BASE), (pm_t)__va(PM_STACK_TOP)); /* mark kernel */ - mark_area_used((pm_t)__va(PM_KERN_BASE), (pm_t)__va(PM_KERN_TOP)); + /* this could be made more explicit, I suppose. */ + mark_area_used(VM_KERN, VM_KERN + PM_KERN_SIZE); /* mark fdt and initrd */ mark_area_used(get_initrdbase(fdt), initrd_top); @@ -446,5 +448,7 @@ void init_pmem(void *fdt) /* mark reserved mem */ mark_reserved_mem(fdt); + init_mem_blocks(); + init_devmem((pm_t)__pa(ram_base), (pm_t)__pa(ram_base + ram_size)); } diff --git a/common/uapi/mem.c b/common/uapi/mem.c index 34ddda2..8c63a87 100644 --- a/common/uapi/mem.c +++ b/common/uapi/mem.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -21,7 +22,11 @@ vm_t sys_free_mem(vm_t start, vm_t u0, vm_t u1, vm_t u2) { UNUSED(u0); UNUSED(u1); UNUSED(u2); struct tcb *r = cur_tcb(); - free_uvmem(r, start); + if(start > __pre_top && start < __post_base) + free_uvmem(r, start); + else + free_devmem(r, start); + return 0; } @@ -33,7 +38,8 @@ vm_t sys_req_pmem(vm_t paddr, vm_t size, vm_t flags, vm_t u0) * outside the RAM area, and I'll probably have to implement some method * that keeps track of used regions outside of RAM. We'll see. */ - return 0; + struct tcb *r = cur_tcb(); + return alloc_devmem(r, paddr, size, flags); } vm_t sys_req_sharedmem(vm_t pid, vm_t start, vm_t size, vm_t flags) -- cgit v1.3