mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 12:48:22 +00:00
mmu: arch_mmu_destroytable
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user