From 5a8915f5b36cf3b21c843ef7959c24ac39318aca Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 14 Mar 2024 20:51:39 -0400 Subject: kernel: vm: Add routine to get kernel vas Signed-off-by: Ian Moffett --- sys/include/vm/vm.h | 1 + 1 file changed, 1 insertion(+) (limited to 'sys/include/vm') diff --git a/sys/include/vm/vm.h b/sys/include/vm/vm.h index 2a24d76..48e1b8f 100644 --- a/sys/include/vm/vm.h +++ b/sys/include/vm/vm.h @@ -61,5 +61,6 @@ vm_get_page_size(void) void vm_init(void); struct vm_ctx *vm_get_ctx(void); +struct vas vm_get_kvas(void); #endif /* !_VM_H_ */ -- cgit v1.2.3 From 3e3ff0acccfbb1d251a9b9bacbf0851c9de69561 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 14 Mar 2024 21:02:10 -0400 Subject: kernel/amd64: pmap: Add pmap_free_vas() Signed-off-by: Ian Moffett --- sys/arch/amd64/amd64/pmap.c | 13 +++++++++++++ sys/include/vm/pmap.h | 6 ++++++ 2 files changed, 19 insertions(+) (limited to 'sys/include/vm') diff --git a/sys/arch/amd64/amd64/pmap.c b/sys/arch/amd64/amd64/pmap.c index 2760532..54d4ca3 100644 --- a/sys/arch/amd64/amd64/pmap.c +++ b/sys/arch/amd64/amd64/pmap.c @@ -228,6 +228,19 @@ pmap_switch_vas(struct vm_ctx *ctx, struct vas vas) : "memory"); } +/* + * TODO: During the mapping of a virtual address, a level + * may be allocated. This function does not handle the + * freeing of allocated levels. We should keep track + * of levels allocated and free them here. + */ +int +pmap_free_vas(struct vm_ctx *ctx, struct vas vas) +{ + vm_free_pageframe(vas.top_level, 1); + return 0; +} + struct vas pmap_read_vas(void) { diff --git a/sys/include/vm/pmap.h b/sys/include/vm/pmap.h index ebabd32..3380199 100644 --- a/sys/include/vm/pmap.h +++ b/sys/include/vm/pmap.h @@ -89,6 +89,12 @@ struct vas pmap_read_vas(void); */ int pmap_map(struct vm_ctx *, struct vas, vaddr_t, paddr_t, vm_prot_t); +/* + * Get rid of a virtual address space and free + * resources. + */ +int pmap_free_vas(struct vm_ctx *, struct vas); + /* * Unmap a page. */ -- cgit v1.2.3