From 434ddcd907832b1febc7d70e4faa52109c7eb3bd Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 7 Oct 2026 17:37:26 -0400 Subject: add memory region object for better memory managment --- arch/x86_64/hal/obj.c | 2 +- arch/x86_64/hal/paging.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'arch/x86_64/hal') diff --git a/arch/x86_64/hal/obj.c b/arch/x86_64/hal/obj.c index 75cb0c0..110351c 100644 --- a/arch/x86_64/hal/obj.c +++ b/arch/x86_64/hal/obj.c @@ -1,5 +1,5 @@ #include "obj.h" -#include "arch/x86_64/lock.h" +#include "sys/lock.h" #include "lib/printf.h" #include "paging.h" #include "hal/obj.h" diff --git a/arch/x86_64/hal/paging.c b/arch/x86_64/hal/paging.c index a0d6ca9..1587c62 100644 --- a/arch/x86_64/hal/paging.c +++ b/arch/x86_64/hal/paging.c @@ -28,6 +28,14 @@ phys_tovirt(uintptr_t phys) return (void*)(phys | IDENT_VIRT_BASE); } +physaddr_t +phys_fromvirt(virtaddr_t virt) +{ + if(virt < IDENT_VIRT_BASE) return 0; + if(virt > KERNEL_VIRT_BASE) return KPTR_TOPHYS(virt); + return virt & ~IDENT_VIRT_BASE; +} + uintptr_t paging_get_pml4(void) { -- cgit v1.2.3