mmu: arch_mmu_destroytable

This commit is contained in:
Matheus
2023-05-16 19:35:09 -03:00
parent 6f1eae6db1
commit e0b2f2a582
2 changed files with 19 additions and 0 deletions
+18
View File
@@ -111,6 +111,24 @@ static bool add_page(pagetableptr_t top, void *vaddr, uint64_t entry, int depth)
return true;
}
static void destroy(uint64_t *table, int depth) {
for (int i = 0; i < 512; ++i) {
void *addr = (void *)((*table & ADDRMASK));
if (addr == NULL)
continue;
if (depth > 0)
destroy(MAKE_HHDM(addr), depth - 1);
pmm_free(addr, 1);
}
}
void arch_mmu_destroytable(pagetableptr_t table) {
destroy(MAKE_HHDM(table), 3);
pmm_free(table, 1);
}
bool arch_mmu_map(pagetableptr_t table, void *paddr, void *vaddr, mmuflags_t flags) {
uint64_t entry = ((uintptr_t)paddr & ADDRMASK) | flags;
return add_page(table, vaddr, entry, 0);
+1
View File
@@ -19,6 +19,7 @@
typedef uint64_t mmuflags_t;
typedef uint64_t * pagetableptr_t; // physical address
void arch_mmu_destroytable(pagetableptr_t table);
bool arch_mmu_map(pagetableptr_t table, void *paddr, void *vaddr, mmuflags_t flags);
void arch_mmu_invalidate(void *vaddr);
void arch_mmu_unmap(pagetableptr_t table, void *vaddr);