-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathmemory.h
48 lines (36 loc) · 847 Bytes
/
memory.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
/**
*
*/
#ifndef _MEMORY_H_
#define _MEMORY_H_
#ifdef __linux__
#include <stdint.h>
#include <stddef.h>
#endif
typedef void *(*memzone_allocator_t)(size_t);
typedef int (*memzone_deallocator_t)(void *, size_t);
enum memtype_flags {
MEMORY_MMAP = (1 << 0),
MEMORY_DMA = (1 << 1),
MEMORY_HUGEPAGE = (1 << 2),
MEMORY_HEAP = (1 << 3)
};
struct memtype {
const char *name;
int flags;
size_t alignment;
memzone_allocator_t alloc;
memzone_deallocator_t dealloc;
};
/** @todo Unused for now */
struct memzone {
struct memtype * const type;
void *addr;
uintptr_t physaddr;
size_t len;
};
void * memory_alloc(const struct memtype *m, size_t len);
int memory_free(const struct memtype *m, void *ptr, size_t len);
extern const struct memtype memtype_heap;
extern const struct memtype memtype_hugepage;
#endif /* _MEMORY_H_ */