-
Notifications
You must be signed in to change notification settings - Fork 0
/
sheap.h
34 lines (26 loc) · 871 Bytes
/
sheap.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef SHEAP_H
#define SHEAP_H
#include "types.h"
/* These macros are flags for sheap_create.
* SHEAP_SUPER sets the supervisor flag in allocated pages.
* SHEAP_WRITE sets the read/write flag.
* SHEAP_DYNSIZE allows the heap to allocate/free pages when proper.
* SHEAP_DPPANIC (DP for Dead Pointer) turns MM operations on a dead pointer
* into kernel panics. */
#define SHEAP_SUPER (1 << 7)
#define SHEAP_WRITE (1 << 6)
#define SHEAP_DYNSIZE (1 << 5)
#define SHEAP_DPPANIC (1 << 4)
struct sheap_t {
uaddr_t root;
size_t size;
uaddr_t start_addr;
uaddr_t end_addr;
u8 pmerge;
u8 flags;
};
struct sheap_t *sheap_create(uaddr_t start, uaddr_t end, u8 flags);
void *sheap_alloc(size_t size, u8 align, struct sheap_t *heap);
void sheap_free(void *ptr, struct sheap_t *heap);
size_t sheap_resize(size_t size, struct sheap_t *heap);
#endif /* SHEAP_H */