The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
region.h
Go to the documentation of this file.
1#pragma once
2
3#include "common/stdint.h"
5
6/**
7 * maximum number of reserved memory regions the table can hold.
8 */
9#define REGION_TABLE_MAX 16
10
11/**
12 * a single reserved memory region with byte-granularity boundaries.
13 */
14typedef struct
15{
16 phys_addr_t start; // first byte of the reserved region (inclusive).
17 phys_addr_t end; // first byte past the reserved region (exclusive).
18 const char *label; // human-readable name (e.g. "kernel", "stage2").
19
21
22/**
23 * reserve a memory region by recording it in the global table.
24 * panics if the table is full.
25 * @param start first byte of the region (inclusive).
26 * @param end first byte past the region (exclusive).
27 * @param label human-readable name for debug output.
28 */
29void region_reserve(phys_addr_t start, phys_addr_t end, const char *label);
30
31/**
32 * check whether a single address falls inside any reserved region.
33 * @param address the physical address to test.
34 * @return true if the address is reserved, false otherwise.
35 */
37
38/**
39 * check whether a range overlaps any reserved region.
40 * @param start first byte of the range (inclusive).
41 * @param end first byte past the range (exclusive).
42 * @return true if any overlap exists, false otherwise.
43 */
45
46/**
47 * return the number of currently reserved regions.
48 */
50
51/**
52 * print all reserved regions to the console.
53 */
54void region_print_all(void);
unsigned int uint32_t
Definition fb.h:17
uintptr_t phys_addr_t
physical addresses and the conversion between physical and virtual.
Definition phys.h:18
bool region_overlaps(phys_addr_t start, phys_addr_t end)
check whether a range overlaps any reserved region.
Definition region.c:42
void region_reserve(phys_addr_t start, phys_addr_t end, const char *label)
reserve a memory region by recording it in the global table.
Definition region.c:9
uint32_t region_count(void)
return the number of currently reserved regions.
Definition region.c:57
void region_print_all(void)
print all reserved regions to the console.
Definition region.c:62
bool region_is_reserved(phys_addr_t address)
check whether a single address falls inside any reserved region.
Definition region.c:27
a single reserved memory region with byte-granularity boundaries.
Definition region.h:15
const char * label
Definition region.h:18
phys_addr_t start
Definition region.h:16
phys_addr_t end
Definition region.h:17