From c53bba03921d0377280c80557b984c12b8a72f64 Mon Sep 17 00:00:00 2001 From: apio Date: Thu, 5 Jan 2023 21:50:06 +0100 Subject: [PATCH] MemoryManager: Add an unmap_weak_and_free_vm() helper function This function mirrors unmap_owned_and_free_vm(), but using weak unmapping (does not free the underlying physical memory) --- kernel/src/memory/MemoryManager.cpp | 9 +++++++++ kernel/src/memory/MemoryManager.h | 1 + 2 files changed, 10 insertions(+) diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index 93447a5d..75014bae 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -309,6 +309,15 @@ namespace MemoryManager return {}; } + Result unmap_weak_and_free_vm(u64 virt, usize count) + { + CHECK_PAGE_ALIGNED(virt); + + KernelVM::free_several_pages(virt, count); + + return unmap_weak(virt, count); + } + Result remap_unaligned(u64 address, usize count, int flags) { if (!is_aligned(address)) count++; diff --git a/kernel/src/memory/MemoryManager.h b/kernel/src/memory/MemoryManager.h index 13a02a8a..d22ed45c 100644 --- a/kernel/src/memory/MemoryManager.h +++ b/kernel/src/memory/MemoryManager.h @@ -30,6 +30,7 @@ namespace MemoryManager Result unmap_owned(u64 virt, usize count); Result unmap_owned_and_free_vm(u64 virt, usize count); Result unmap_weak(u64 virt, usize count); + Result unmap_weak_and_free_vm(u64 virt, usize count); usize free(); usize used();