]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ux/vmem_alloc-ux.cpp
Inital import
[l4.git] / kernel / fiasco / src / kern / ux / vmem_alloc-ux.cpp
1
2 IMPLEMENTATION[ux]:
3
4 #include <cerrno>
5 #include <cstring>
6 #include <unistd.h>
7 #include <sys/mman.h>
8 #include "boot_info.h"
9 #include "panic.h"
10
11 IMPLEMENT inline NEEDS [<cerrno>, <cstring>, <unistd.h>, <sys/mman.h>,
12                         "boot_info.h", "config.h", "panic.h"]
13 void
14 Vmem_alloc::page_map (void *address, int order, Zero_fill zf, Address phys)
15 {
16   if (mmap (address, (1 << order) * Config::PAGE_SIZE,
17             PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED,
18             Boot_info::fd(), phys) == MAP_FAILED)
19     panic ("mmap error: %s", strerror (errno));
20
21   if (zf == ZERO_FILL)
22     memset(address, 0, (1 << order) * Config::PAGE_SIZE);
23 }
24
25 IMPLEMENT inline NEEDS [<cerrno>, <cstring>, <unistd.h>, <sys/mman.h>,
26                         "boot_info.h", "config.h", "panic.h"]
27 void
28 Vmem_alloc::page_unmap (void *address, int order)
29 {
30   if (munmap (address, (1 << order) * Config::PAGE_SIZE) != 0)
31     panic ("munmap error: %s", strerror (errno));
32 }