blu_os
Loading...
Searching...
No Matches
heap.h
1//
2// Created by dylan on 19/07/2026.
3//
4
5#ifndef BLU_OS_HEAP_H
6#define BLU_OS_HEAP_H
7
8#include <kernel/mm/slab.h>
9#include <stddef.h>
10#include <stdint.h>
11
12// TODO add arch agnostic macros
13#define KERNEL_HEAP_START 0xC1000000
14#define KERNEL_HEAP_END 0xC2000000
15
16typedef enum : uint32_t { SLAB, PAGE } KmallocAllocationType;
17
18typedef enum : uint32_t { HEAP_ALLOCATED = 1 << 0, HEAP_FREED = 1 << 1 } KmallocFlags;
19
20typedef struct {
21 size_t size;
22 uint32_t type;
23 uint32_t flags;
25
26extern KernelMemoryCache cache8;
27extern KernelMemoryCache cache16;
28extern KernelMemoryCache cache32;
29extern KernelMemoryCache cache64;
30extern KernelMemoryCache cache128;
31extern KernelMemoryCache cache256;
32extern KernelMemoryCache cache512;
33extern KernelMemoryCache cache1024;
34extern KernelMemoryCache cache2048;
35extern KernelMemoryCache cache4096;
36
37void* slabAlloc(size_t size);
38
39void slabFree(void* ptr);
40
41void heapInit();
42
43void* allocPages(size_t numPages);
44
45void freePages(void* ptr, size_t pages);
46
47#endif // BLU_OS_HEAP_H
Common definitions for C programs.
Fixed-width integer types.
Definition slab.h:19
Definition heap.h:20