#include <stddef.h>
#include <stdint.h>
Go to the source code of this file.
|
| #define | ALIGNMENT_MASK(x, a) ((typeof(x))(a) - 1) |
| | Aligns the given value x up to the nearest multiple of a.
|
| |
| #define | ALIGN_UP(x, a) (((x) + ALIGNMENT_MASK(x, a)) & ~ALIGNMENT_MASK(x, a)) |
| | Aligns the given value x up to the nearest multiple of a.
|
| |
| #define | ALIGN_DOWN(x, a) ((x) & ~ALIGNMENT_MASK(x, a)) |
| | Aligns the given value x down to the nearest multiple of a.
|
| |
| #define | PAGE_SIZE 4096 |
| | The size of a memory page in bytes.
|
| |
◆ ALIGN_DOWN
Aligns the given value x down to the nearest multiple of a.
- Parameters
-
| x | The value to align. |
| a | The alignment boundary. |
- Returns
- The aligned value.
◆ ALIGN_UP
Aligns the given value x up to the nearest multiple of a.
- Parameters
-
| x | The value to align. |
| a | The alignment boundary. |
- Returns
- The aligned value.
◆ ALIGNMENT_MASK
| #define ALIGNMENT_MASK |
( |
|
x, |
|
|
|
a |
|
) |
| ((typeof(x))(a) - 1) |
Aligns the given value x up to the nearest multiple of a.
- Parameters
-
| x | The value to align. |
| a | The alignment boundary. |
- Returns
- The aligned value.
◆ PAGE_SIZE
The size of a memory page in bytes.
◆ hhdm_physical_to_virtual()
| void * hhdm_physical_to_virtual |
( |
size_t |
phys | ) |
|
Converts a physical address to a virtual address according to the Higher Half Direct Mapping (HHDM) scheme.
- Parameters
-
| phys | The physical address to convert. |
- Returns
- The virtual address.
◆ hhdm_virtual_to_physical()
| size_t hhdm_virtual_to_physical |
( |
void * |
virt | ) |
|
Converts a virtual address to a physical address according to the Higher Half Direct Mapping (HHDM) scheme.
- Parameters
-
| virt | The virtual address to convert. |
- Returns
- The physical address.
◆ kalloc_init()
| void kalloc_init |
( |
void |
| ) |
|
Initializes the kernel memory allocator.
◆ page_align_down()
Rounds down the given address to the nearest page boundary.
- Parameters
-
| addr | The address to align. |
- Returns
- The aligned address.
◆ page_align_up()
Rounds up the given address to the nearest page boundary.
- Parameters
-
| addr | The address to align. |
- Returns
- The aligned address.