diff options
author | Marvin Borner | 2019-09-30 22:41:39 +0200 |
---|---|---|
committer | Marvin Borner | 2019-09-30 22:42:02 +0200 |
commit | 682c47a98844ffec3f3129160e9cdb98ba129989 (patch) | |
tree | e673ace5ef65c83907cbd6575ec3a1a7e49b0fd6 /src/kernel/paging/kheap.h | |
parent | 2fb0965a68dd232a70d1616bfbd7281fc65c2b0a (diff) |
Added paging and fixed several bugs
Diffstat (limited to 'src/kernel/paging/kheap.h')
-rw-r--r-- | src/kernel/paging/kheap.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/kernel/paging/kheap.h b/src/kernel/paging/kheap.h new file mode 100644 index 0000000..7a92957 --- /dev/null +++ b/src/kernel/paging/kheap.h @@ -0,0 +1,51 @@ +#ifndef MELVIX_KHEAP_H +#define MELVIX_KHEAP_H + +#include <stdbool.h> +#include <stddef.h> + +#define KHEAP_MAGIC 0x13374242 +#define KHEAP_MAGIC2 0xDEADBEEF +#define KHEAP_END 0xFFFFDEAD +#define MEM_END 0x8000000 + +extern unsigned int end; + +typedef struct { + unsigned int magic; + bool free; + unsigned int size; + unsigned int magic2; +} heap_header_t; + +typedef struct { + unsigned int magic; + unsigned int size; + unsigned int magic2; +} heap_footer_t; + +#define HEAP_S (sizeof(heap_header_t)) +#define HEAP_TOTAL (sizeof(heap_footer_t) + HEAP_S) +#define HEAP_MINIMUM 1 +#define HEAP_FIND_SIZE (HEAP_TOTAL + HEAP_MINIMUM) + +void init_kheap(); + +void *fmalloc(unsigned int size); + +void *kmalloc(unsigned int size); + +void *kmalloc_a(unsigned int size); + +void kfree(void *ptr); + +void *umalloc(size_t size); + +void ufree(void *address); + +void init_heap(heap_header_t *heap, size_t size); + +#define KHEAP_SIZE 0xFFFFF +#define UHEAP_SIZE 0xFFFFF + +#endif |