-
Notifications
You must be signed in to change notification settings - Fork 2
/
memmap.h
67 lines (51 loc) · 1.39 KB
/
memmap.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef KERNAUX_INCLUDED_MEMMAP
#define KERNAUX_INCLUDED_MEMMAP
#ifdef __cplusplus
extern "C" {
#endif
#include <kernaux/generic/display.h>
#include <kernaux/generic/malloc.h>
#include <kernaux/macro.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define KERNAUX_MEMMAP_FREE(memmap) do { \
KernAux_Memmap_free(memmap); \
memmap = NULL; \
} while (0)
/*********
* Types *
*********/
typedef const struct KernAux_Memmap_Node {
uint64_t mem_start, mem_end, mem_size;
const char *tag;
const struct KernAux_Memmap_Node *next, *children;
} *KernAux_Memmap_Node;
typedef const struct KernAux_Memmap {
KernAux_Memmap_Node root_node;
KernAux_Malloc KERNAUX_PRIVATE_FIELD(malloc);
} *KernAux_Memmap;
typedef struct KernAux_Memmap_Builder {
KernAux_Memmap KERNAUX_PRIVATE_FIELD(memmap);
} *KernAux_Memmap_Builder;
/*************
* Functions *
*************/
KernAux_Memmap_Builder
KernAux_Memmap_Builder_new(KernAux_Malloc malloc);
KernAux_Memmap_Node
KernAux_Memmap_Builder_add(
KernAux_Memmap_Builder builder,
KernAux_Memmap_Node parent_node,
uint64_t mem_start,
uint64_t mem_size,
const char *tag
);
KernAux_Memmap
KernAux_Memmap_Builder_finish_and_free(KernAux_Memmap_Builder builder);
void KernAux_Memmap_free(KernAux_Memmap memmap);
void KernAux_Memmap_print(KernAux_Memmap memmap, KernAux_Display display);
#ifdef __cplusplus
}
#endif
#endif