From 473112b1541cf81fa3670e0d1cb6de1c4a3281de Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 16 Jul 2024 23:55:32 +0200 Subject: kernel: make kmalloc accept a numeric "tag" instead of a freeform description This will both let me save space in the allocation header, and make the debugprint more readable. --- src/kernel/malloc.h | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'src/kernel/malloc.h') diff --git a/src/kernel/malloc.h b/src/kernel/malloc.h index bda2745..a38d49b 100644 --- a/src/kernel/malloc.h +++ b/src/kernel/malloc.h @@ -10,6 +10,28 @@ * dead code. */ #define KMALLOC_MAX 1024 +/* also see the string table in malloc.c */ +enum MallocTag { + TagInvalid, + TagKernelFs, + TagProcFs, + TagUserFs, + TagOpenPath, + TagMountPath, + TagMountUser, + TagMountRoot, + TagExecbuf, + TagVfsReq, + TagHandleset, + TagHandle, + TagProcess, + TagProcessHandle, + TagDevTime, + TagRootCache, + TagPageRefcount, + TagLast, +}; + void mem_init(void *memtop); void mem_reserve(void *addr, size_t len); void mem_debugprint(void); @@ -24,12 +46,12 @@ 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 *kmalloc(size_t len, enum MallocTag tag); void kfree(void *ptr); // TODO calloc -static inline void *kzalloc(size_t len, const char *desc) { - void *b = kmalloc(len, desc); +static inline void *kzalloc(size_t len, enum MallocTag tag) { + void *b = kmalloc(len, tag); memset(b, 0, len); return b; } -- cgit v1.2.3