summaryrefslogtreecommitdiff
path: root/kernel/include
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-22 13:18:29 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-22 13:18:29 -0400
commit7e10614afe11f2f5381f7ee66d80590104f2c735 (patch)
tree707dbb57dc79258f85c549247a9fe9eccc97f9c1 /kernel/include
parentbuild user code in main make (diff)
downloadcomus-7e10614afe11f2f5381f7ee66d80590104f2c735.tar.gz
comus-7e10614afe11f2f5381f7ee66d80590104f2c735.tar.bz2
comus-7e10614afe11f2f5381f7ee66d80590104f2c735.zip
add pml4 allocation/mem ctx alloation
Diffstat (limited to 'kernel/include')
-rw-r--r--kernel/include/comus/memory.h29
1 files changed, 27 insertions, 2 deletions
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.