blob: 2a55fb360e594e8d47c0cfe6383f828cb5033337 (
plain) (
blame)
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
|
#include <region.h>
#include <frame.h>
#include <paging.h>
bool alloc_map_single_frame(void* addr) {
int frame = frame_alloc(1);
if (frame == 0) return false;
if (!pd_map_page(addr, frame, true)) {
frame_free(frame, 1);
return false;
}
return true;
}
// ========================================================= //
// HELPER FUNCTIONS : SIMPLE PF HANDLERS ; FREEING FUNCTIONS //
// ========================================================= //
void region_free_unmap_free(void* ptr) {
region_info_t *i = find_region(ptr);
ASSERT(i != 0);
for (void* x = i->addr; x < i->addr + i->size; x += PAGE_SIZE) {
uint32_t f = pd_get_frame(x);
if (f != 0) {
pd_unmap_page(x);
frame_free(f, 1);
}
}
region_free(ptr);
}
void region_free_unmap(void* ptr) {
region_info_t *i = find_region(ptr);
ASSERT(i != 0);
for (void* x = i->addr; x < i->addr + i->size; x += PAGE_SIZE) {
pd_unmap_page(x);
}
region_free(ptr);
}
/* vim: set ts=4 sw=4 tw=0 noet :*/
|