#pragma once #include #include #include /* This seems to be fine for now, and it means that i don't need to concern * myself with allocating contiguous pages for now, which is way easier to do * well. */ #define KMALLOC_MAX 2048 void mem_init(void *memtop); void mem_reserve(void *addr, size_t len); void mem_debugprint(void); void kmalloc_debugprint(void); /* internal, called by mem_debugprint */ // allocates `pages` consecutive pages void *page_alloc(size_t pages); // zeroes the allocated pages void *page_zalloc(size_t pages); // frees `pages` consecutive pages starting from *first void page_free(void *first, size_t pages); void *kmalloc(size_t len, const char *desc); void kfree(void *ptr); // TODO calloc static inline void *kzalloc(size_t len, const char *desc) { void *b = kmalloc(len, desc); memset(b, 0, len); return b; }