summaryrefslogtreecommitdiff
path: root/include/memory
diff options
context:
space:
mode:
Diffstat (limited to 'include/memory')
-rw-r--r--include/memory/physalloc.h30
-rw-r--r--include/memory/virtalloc.h24
2 files changed, 54 insertions, 0 deletions
diff --git a/include/memory/physalloc.h b/include/memory/physalloc.h
new file mode 100644
index 0000000..f22432e
--- /dev/null
+++ b/include/memory/physalloc.h
@@ -0,0 +1,30 @@
+#pragma once
+
+#ifndef MEMORY_INTERNAL
+ #error "Do not include headers from <memory/___.h>, only use <memory.h>"
+#endif
+
+/**
+ * Allocates a single physical page in memory
+ * @preturns the physical address of the page
+ */
+extern void *alloc_phys_page(void);
+
+/**
+ * Allocates count physical pages in memory
+ * @returns the physical address of the first page
+ */
+extern void *alloc_phys_pages(int count);
+
+/**
+* Frees a single physical page in memory
+ * @param ptr - the physical address of the page
+ */
+extern void free_phys_page(void *ptr);
+
+/**
+ * Frees count physical pages in memory
+ * @param ptr - the physical address of the first page
+ * @param count - the number of pages in the list
+ */
+extern void free_phys_pages(void *ptr, int count);
diff --git a/include/memory/virtalloc.h b/include/memory/virtalloc.h
new file mode 100644
index 0000000..c4bac56
--- /dev/null
+++ b/include/memory/virtalloc.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#ifndef MEMORY_INTERNAL
+ #error "Do not include headers from <memory/___.h>, only use <memory.h>"
+#endif
+
+/**
+ * Initalizes the virtual address allocator
+ */
+void virtaddr_init(void);
+
+/**
+ * Allocate a virtual address of length x pages
+ * @param pages - x pages
+ * @returns virt addr
+ */
+void *virtaddr_alloc(int pages);
+
+/**
+ * Free the virtual address from virtaddr_alloc
+ * @param virtaddr - the addr to free
+ * @returns number of pages used for virtaddr
+ */
+long virtaddr_free(void *virtaddr);