-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmalloc.h
31 lines (28 loc) · 959 Bytes
/
pmalloc.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
#include <stdint.h>
#include <stdlib.h>
/**
* Returns the physical address to the given virtual one.
*
* \returns Physical address, not as a pointer to make you think twice before dereferencing it
*/
uint64_t virt_to_phys(void* mem);
/**
* allocate physically continuous block of memory
* with at least $size usable bytes and the start
* aligned to $align bytes.
*
* Beware! This is doing classic kernel things, in userspace.
*
* \param size Size of the newly allocated memory region in bytes
* \param align Alignment of the start of the allocated memory region
* \returns Virtual address pointer to the start
* of the allocated memory region with ($ret % $align == 0)
*/
void* pmalloc(size_t size, size_t align);
/**
* Free the given memory allocation, making it invalid and possibly return
* memory back to the system
*
* \param mem Memory allocation (that must be made by pmalloc) to free
*/
void pfree(void* mem);