diff --git a/paw/stos/arch/amd64/cpu/mmu.c b/paw/stos/arch/amd64/cpu/mmu.c index 898a756..eddf7d6 100644 --- a/paw/stos/arch/amd64/cpu/mmu.c +++ b/paw/stos/arch/amd64/cpu/mmu.c @@ -274,3 +274,25 @@ HalMmuMapSingle(MMU_VAS *Vas, UPTR Vma, UPTR Pma, USHORT Flags, MMU_PAGESIZE Pag MmuInvlpg(Vma); return STATUS_SUCCESS; } + +ST_STATUS +HalMmuUnmapSingle(MMU_VAS *Vas, UPTR Vma, MMU_PAGESIZE PageSize) +{ + UPTR *PageTable; + USHORT Index; + + if (Vas == NULL) { + return STATUS_INVALID_PARAM; + } + + PageTable = MmuExtractLevel(Vas, Vma, PAGE_LEVEL_PML1, false); + if (PageTable == NULL) { + return STATUS_NOT_FOUND; + } + + /* Unmap the page */ + Index = MmuLevelIndex(Vma, PAGE_LEVEL_PML1); + PageTable[Index] = 0; + MmuInvlpg(Vma); + return STATUS_SUCCESS; +} diff --git a/paw/stos/head/hal/mmu.h b/paw/stos/head/hal/mmu.h index f61be37..38376c1 100644 --- a/paw/stos/head/hal/mmu.h +++ b/paw/stos/head/hal/mmu.h @@ -63,4 +63,13 @@ ST_STATUS HalMmuMapSingle( USHORT Flags, MMU_PAGESIZE PageSize ); +/* + * Unmap a single page of memory + * + * @Vas: Virtual address space to unmap within + * @Vma: Virtual address to unmap + * @PageSize: Pagesize to unmap + */ +ST_STATUS HalMmuUnmapSingle(MMU_VAS *Vas, UPTR Vma, MMU_PAGESIZE PageSize); + #endif /* !_HAL_MMU_H_ */