From 6ff6be07541e2162dda5ca9af4a3a6749a85010f Mon Sep 17 00:00:00 2001 From: Baptiste Wicht Date: Sat, 9 Jul 2016 12:32:49 +0200 Subject: [PATCH] Add offset support to physica_address --- kernel/src/paging.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/src/paging.cpp b/kernel/src/paging.cpp index 94f53cde..fd6f3ffb 100644 --- a/kernel/src/paging.cpp +++ b/kernel/src/paging.cpp @@ -212,6 +212,9 @@ size_t paging::physical_address(size_t virt){ return 0; } + // Offset inside the page + auto offset = virt & uint64_t((1 << 13) - 1); + //Find the correct indexes inside the paging table for the physical address auto pml4e = pml4_entry(virt); auto pdpte = pdpt_entry(virt); @@ -223,7 +226,7 @@ size_t paging::physical_address(size_t virt){ auto pd = find_pd(pdpt, pdpte); auto pt = find_pt(pd, pde); - return reinterpret_cast(pt[pte]) & ~0xFFF; + return offset + reinterpret_cast(pt[pte]) & ~0xFFF; } bool paging::page_present(size_t virt){