The manual
ginnOS
The reference: libc, the libraries and the kernel
Toggle main menu visibility
Loading...
Searching...
No Matches
region.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
common/stdint.h
"
4
#include "
kernel/memory/phys.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
*/
14
typedef
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
20
}
region_entry_t
;
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
*/
29
void
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
*/
36
bool
region_is_reserved
(
phys_addr_t
address);
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
*/
44
bool
region_overlaps
(
phys_addr_t
start,
phys_addr_t
end);
45
46
/**
47
* return the number of currently reserved regions.
48
*/
49
uint32_t
region_count
(
void
);
50
51
/**
52
* print all reserved regions to the console.
53
*/
54
void
region_print_all
(
void
);
stdint.h
uint32_t
unsigned int uint32_t
Definition
fb.h:17
phys.h
phys_addr_t
uintptr_t phys_addr_t
physical addresses and the conversion between physical and virtual.
Definition
phys.h:18
region_overlaps
bool region_overlaps(phys_addr_t start, phys_addr_t end)
check whether a range overlaps any reserved region.
Definition
region.c:42
region_reserve
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
region_count
uint32_t region_count(void)
return the number of currently reserved regions.
Definition
region.c:57
region_print_all
void region_print_all(void)
print all reserved regions to the console.
Definition
region.c:62
region_is_reserved
bool region_is_reserved(phys_addr_t address)
check whether a single address falls inside any reserved region.
Definition
region.c:27
region_entry_t
a single reserved memory region with byte-granularity boundaries.
Definition
region.h:15
region_entry_t::label
const char * label
Definition
region.h:18
region_entry_t::start
phys_addr_t start
Definition
region.h:16
region_entry_t::end
phys_addr_t end
Definition
region.h:17
src
kernel
memory
region.h
Generated by
1.18.0