forked from aengelke/raspsim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mm.cpp
25 lines (20 loc) · 740 Bytes
/
mm.cpp
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
//
// PTLsim: Cycle Accurate x86-64 Simulator
// Memory Management
//
// Copyright 2000-2008 Matt T. Yourst <[email protected]>
//
#include <globals.h>
#include <ptlsim-api.h>
#include <mm.h>
void* ptl_mm_try_alloc_private_pages(Waddr bytecount, int prot, Waddr base, void* caller) {
int flags = MAP_ANONYMOUS|MAP_NORESERVE|MAP_PRIVATE | (base ? MAP_FIXED : 0);
return sys_mmap((void*)base, ceil(bytecount, PAGE_SIZE), prot, flags, 0, 0);
}
void* ptl_mm_alloc_private_pages(Waddr bytecount, int prot, Waddr base) {
return ptl_mm_try_alloc_private_pages(bytecount, prot, base, getcaller());
}
void ptl_mm_free_private_pages(void* addr, Waddr bytecount) {
bytecount = ceil(bytecount, PAGE_SIZE);
sys_munmap(addr, bytecount);
}