diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index 3ae6e27..396839e 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -42,7 +42,7 @@ pageDirectory[virtual->pageDirectoryIndex].pageTableID; PageTableEntry *pageTable = mapTemporary(ADDRESS(pageTableId)); uint32_t pageBase = pageTable[virtual->pageTableIndex].targetAddress; - return PTR(pageBase << 12 | virtual->pageOffset); + return ADDRESS(pageBase) + PAGE_OFFSET(address); } void *getPhysicalAddressKernel(void *address) { diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index 3ae6e27..396839e 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -42,7 +42,7 @@ pageDirectory[virtual->pageDirectoryIndex].pageTableID; PageTableEntry *pageTable = mapTemporary(ADDRESS(pageTableId)); uint32_t pageBase = pageTable[virtual->pageTableIndex].targetAddress; - return PTR(pageBase << 12 | virtual->pageOffset); + return ADDRESS(pageBase) + PAGE_OFFSET(address); } void *getPhysicalAddressKernel(void *address) { diff --git a/src/kernel/service/memorySyscalls.c b/src/kernel/service/memorySyscalls.c index 631b97b..432ef0c 100644 --- a/src/kernel/service/memorySyscalls.c +++ b/src/kernel/service/memorySyscalls.c @@ -30,7 +30,7 @@ ADDRESS(virtualStart + i), true, true); } } - call->returnValue = U32(ADDRESS(virtualStart)) + (U32(physical) & 0xFFF); + call->returnValue = U32(ADDRESS(virtualStart)) + PAGE_OFFSET(physical); } void handleGetPhysicalSyscall(Syscall *call) { diff --git a/src/kernel/memory/paging.c b/src/kernel/memory/paging.c index 3ae6e27..396839e 100644 --- a/src/kernel/memory/paging.c +++ b/src/kernel/memory/paging.c @@ -42,7 +42,7 @@ pageDirectory[virtual->pageDirectoryIndex].pageTableID; PageTableEntry *pageTable = mapTemporary(ADDRESS(pageTableId)); uint32_t pageBase = pageTable[virtual->pageTableIndex].targetAddress; - return PTR(pageBase << 12 | virtual->pageOffset); + return ADDRESS(pageBase) + PAGE_OFFSET(address); } void *getPhysicalAddressKernel(void *address) { diff --git a/src/kernel/service/memorySyscalls.c b/src/kernel/service/memorySyscalls.c index 631b97b..432ef0c 100644 --- a/src/kernel/service/memorySyscalls.c +++ b/src/kernel/service/memorySyscalls.c @@ -30,7 +30,7 @@ ADDRESS(virtualStart + i), true, true); } } - call->returnValue = U32(ADDRESS(virtualStart)) + (U32(physical) & 0xFFF); + call->returnValue = U32(ADDRESS(virtualStart)) + PAGE_OFFSET(physical); } void handleGetPhysicalSyscall(Syscall *call) { diff --git a/src/userland/hlib/service/service.c b/src/userland/hlib/service/service.c index 50a4f94..e31be53 100644 --- a/src/userland/hlib/service/service.c +++ b/src/userland/hlib/service/service.c @@ -29,5 +29,6 @@ } void *getPhysicalAddress(void *source) { - return PTR(syscall(SYS_GET_PHYSICAL, U32(source), 0, 0, 0)); + return PTR(syscall(SYS_GET_PHYSICAL, U32(source) & ~0xFFF, 0, 0, 0) | + (U32(source) & 0xFFF)); }