1 | /* |
---|
2 | * mman.c - User level <mman> library implementation. |
---|
3 | * |
---|
4 | * Author Alain Greiner (2016,2017,2018) |
---|
5 | * |
---|
6 | * Copyright (c) UPMC Sorbonne Universites |
---|
7 | * |
---|
8 | * This file is part of ALMOS-MKH. |
---|
9 | * |
---|
10 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
---|
11 | * under the terms of the GNU General Public License as published by |
---|
12 | * the Free Software Foundation; version 2.0 of the License. |
---|
13 | * |
---|
14 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
---|
15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
17 | * General Public License for more details. |
---|
18 | * |
---|
19 | * You should have received a copy of the GNU General Public License |
---|
20 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
21 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
---|
22 | */ |
---|
23 | |
---|
24 | #include <mman.h> |
---|
25 | #include <hal_shared_types.h> |
---|
26 | #include <hal_user.h> |
---|
27 | #include <syscalls_numbers.h> |
---|
28 | |
---|
29 | ////////////////////////////////y |
---|
30 | int munmap( void * addr, |
---|
31 | unsigned int size ) |
---|
32 | { |
---|
33 | return hal_user_syscall( SYS_MUNMAP, |
---|
34 | (reg_t)addr, |
---|
35 | (reg_t)size, 0, 0 ); |
---|
36 | } |
---|
37 | |
---|
38 | /////////////////////////////// |
---|
39 | void * mmap( void * addr, |
---|
40 | unsigned int length, |
---|
41 | int prot, |
---|
42 | int flags, |
---|
43 | int fd, |
---|
44 | unsigned int offset ) |
---|
45 | { |
---|
46 | mmap_attr_t attr; |
---|
47 | |
---|
48 | attr.addr = addr; |
---|
49 | attr.length = length; |
---|
50 | attr.prot = prot; |
---|
51 | attr.flags = flags; |
---|
52 | attr.fdid = fd; |
---|
53 | attr.offset = offset; |
---|
54 | |
---|
55 | if( hal_user_syscall( SYS_MMAP, |
---|
56 | (reg_t)&attr, 0, 0, 0 ) ) return NULL; |
---|
57 | else return attr.addr; |
---|
58 | } |
---|
59 | |
---|
60 | |
---|