summaryrefslogtreecommitdiff
path: root/include/memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/memory.h')
-rw-r--r--include/memory.h37
1 files changed, 19 insertions, 18 deletions
diff --git a/include/memory.h b/include/memory.h
index bec05f8..cbed363 100644
--- a/include/memory.h
+++ b/include/memory.h
@@ -2,19 +2,7 @@
#include <stddef.h>
#include <stdint.h>
-
-struct memory_segment {
- uint64_t addr;
- uint64_t len;
- uint32_t type;
- uint32_t reserved;
-} __attribute__((packed));
-
-struct memory_map {
- uint32_t size;
- uint32_t version;
- struct memory_segment entries[];
-} __attribute__((packed));
+#include <shim.h>
/**
* Initalize system memory allocator
@@ -61,10 +49,23 @@ extern void *alloc_page(void);
extern void *alloc_pages(int count);
/**
- * Frees a single page in memory
+ * Frees a signle page in memory.
+ * Must be a page aligned allocated vitural pointer.
+ * Freeing in the middle of a block is allowed.
* @param page - the pointer to the page
*/
extern void free_page(void *page);
+// TODO: implement free_page
+
+/**
+ * Frees block of pages in memory.
+ * Must be a page aligned allocated vitural pointer.
+ * Freeing int he middle of a block is allowed,
+ * free_pages will from *page to end of block allocated.
+ * @param page - the pointer to the page
+ */
+extern void free_pages(void *page);
+// TODO: implement freeing in middle of block
/**
* Allocates at least len bytes of memory starting at
@@ -85,11 +86,11 @@ extern void *mmap(void *addr, size_t len);
extern void unmap(void *addr);
/**
- * Allocates size_t bytes in memory
+ * Allocates size_t bytes in memory
* @param size - the amount of bytes to allocate
* @retruns the address allocated or NULL on failure
*/
-extern void *malloc(size_t size);
+extern void *kalloc(size_t size);
/**
* Reallocates a given allocated ptr to a new size of bytes in memory.
@@ -98,10 +99,10 @@ extern void *malloc(size_t size);
* @param size - the amount of bytes to set the pointer to
* @returns the address allocated or NULL on failure
*/
-extern void *realloc(void *ptr, size_t size);
+extern void *krealloc(void *ptr, size_t size);
/**
* Frees a allocated pointer in memory
* @param ptr - the pointer to free
*/
-extern void free(void *ptr);
+extern void kfree(void *ptr);