1 /*
2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation;
5 * version 2.1 of the License.
6 *
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
11 *
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library; If not, see <http://www.gnu.org/licenses/>.
14 *
15 * Split out from xc_minios.c
16 *
17 * Copyright 2007-2008 Samuel Thibault <samuel.thibault@eu.citrix.com>.
18 */
19
20 #include <mini-os/types.h>
21 #include <mini-os/os.h>
22 #include <mini-os/mm.h>
23 #include <mini-os/lib.h>
24
25 #include <errno.h>
26
27 #include <sys/mman.h>
28
29 #include "private.h"
30
osdep_xenforeignmemory_open(xenforeignmemory_handle * fmem)31 int osdep_xenforeignmemory_open(xenforeignmemory_handle *fmem)
32 {
33 /* No fd required */
34 return 0;
35 }
36
osdep_xenforeignmemory_close(xenforeignmemory_handle * fmem)37 int osdep_xenforeignmemory_close(xenforeignmemory_handle *fmem)
38 {
39 return 0;
40 }
41
osdep_xenforeignmemory_map(xenforeignmemory_handle * fmem,uint32_t dom,void * addr,int prot,int flags,size_t num,const xen_pfn_t arr[],int err[])42 void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
43 uint32_t dom, void *addr,
44 int prot, int flags, size_t num,
45 const xen_pfn_t arr[/*num*/], int err[/*num*/])
46 {
47 unsigned long pt_prot = 0;
48 if (prot & PROT_READ)
49 pt_prot = L1_PROT_RO;
50 if (prot & PROT_WRITE)
51 pt_prot = L1_PROT;
52 return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot);
53 }
54
osdep_xenforeignmemory_unmap(xenforeignmemory_handle * fmem,void * addr,size_t num)55 int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
56 void *addr, size_t num)
57 {
58 return munmap(addr, num << PAGE_SHIFT);
59 }
60
61 /*
62 * Local variables:
63 * mode: C
64 * c-file-style: "BSD"
65 * c-basic-offset: 4
66 * tab-width: 4
67 * indent-tabs-mode: nil
68 * End:
69 */
70