From 6f3d273fe996b1dcc0a06909cf846922f2f0f4c0 Mon Sep 17 00:00:00 2001 From: "Chloe M." Date: Sat, 27 Jun 2026 23:53:12 +0000 Subject: [PATCH] stos: hal+amd64: Add helper to unmap single page Signed-off-by: Chloe M. --- paw/stos/arch/amd64/cpu/mmu.c | 22 ++++++++++++++++++++++ paw/stos/head/hal/mmu.h | 9 +++++++++ 2 files changed, 31 insertions(+) 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_ */