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
16
typedef
enum : uint32_t { SLAB, PAGE } KmallocAllocationType;
17
18
typedef
enum : uint32_t { HEAP_ALLOCATED = 1 << 0, HEAP_FREED = 1 << 1 } KmallocFlags;
19
20
typedef
struct
{
21
size_t
size;
22
uint32_t type;
23
uint32_t flags;
24
}
KmallocHeader
;
25
26
extern
KernelMemoryCache
cache8;
27
extern
KernelMemoryCache
cache16;
28
extern
KernelMemoryCache
cache32;
29
extern
KernelMemoryCache
cache64;
30
extern
KernelMemoryCache
cache128;
31
extern
KernelMemoryCache
cache256;
32
extern
KernelMemoryCache
cache512;
33
extern
KernelMemoryCache
cache1024;
34
extern
KernelMemoryCache
cache2048;
35
extern
KernelMemoryCache
cache4096;
36
37
void
* slabAlloc(
size_t
size);
38
39
void
slabFree(
void
* ptr);
40
41
void
heapInit();
42
43
void
* allocPages(
size_t
numPages);
44
45
void
freePages(
void
* ptr,
size_t
pages);
46
47
#endif
// BLU_OS_HEAP_H
stddef.h
Common definitions for C programs.
stdint.h
Fixed-width integer types.
KernelMemoryCache
Definition
slab.h:19
KmallocHeader
Definition
heap.h:20
kernel
include
kernel
mm
heap.h
Generated by
1.16.1