From 7e10614afe11f2f5381f7ee66d80590104f2c735 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Tue, 22 Apr 2025 13:18:29 -0400 Subject: add pml4 allocation/mem ctx alloation --- kernel/include/comus/memory.h | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'kernel/include') diff --git a/kernel/include/comus/memory.h b/kernel/include/comus/memory.h index d91c9bb..588219e 100644 --- a/kernel/include/comus/memory.h +++ b/kernel/include/comus/memory.h @@ -126,17 +126,42 @@ void mem_unmapaddr(mem_ctx_t ctx, void *virt); /** * Allocate a single page of memory with the given paging structure * + * @param ctx - the memory context + * @param lazy - if to lazy allocate pages (alloc on fault) + * @returns the vitural address aloocated or NULL on failure + */ +void *mem_alloc_page(mem_ctx_t ctx, bool lazy); + +/** + * Allocate a single page of memory at the given vitural address with the given paging structure + * + * @param ctx - the memory context + * @param virt - the vitural address to allocate at + * @param lazy - if to lazy allocate pages (alloc on fault) * @returns the vitural address aloocated or NULL on failure */ -void *mem_alloc_page(mem_ctx_t ctx); +void *mem_alloc_page_at(mem_ctx_t ctx, void *virt, bool lazy); /** * Allocate size_t amount of contiguous virtual pages with the given paging structure * + * @param ctx - the memory context + * @param count - the number of pages to allocate + * @param lazy - if to lazy allocate pages (alloc on fault) + * @returns the address allocated or NULL on failure + */ +void *mem_alloc_pages(mem_ctx_t ctx, size_t count, bool lazy); + +/** + * Allocate size_t amount of contiguous virtual pages at a given virtural address with the given paging structure + * + * @param ctx - the memory context * @param count - the number of pages to allocate + * @param virt - the vitural address to allocate at + * @param lazy - if to lazy allocate pages (alloc on fault) * @returns the address allocated or NULL on failure */ -void *mem_alloc_pages(mem_ctx_t ctx, size_t count); +void *mem_alloc_pages_at(mem_ctx_t ctx, size_t count, void *virt, bool lazy); /** * Free allocated pages with the given paging structure. -- cgit v1.2.3-freya