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 /*
21 * xenctrl.h currently defines __XEN_TOOLS__ which affects what is
22 * exposed by Xen headers. As the define needs to be set consistently,
23 * we want to include xenctrl.h before the mini-os headers (they include
24 * public headers).
25 */
26 #include <xenctrl.h>
27
28 #include <mini-os/types.h>
29 #include <mini-os/os.h>
30 #include <mini-os/mm.h>
31 #include <mini-os/lib.h>
32
33 #include <errno.h>
34
35 #include <sys/mman.h>
36
37 #include "private.h"
38
osdep_xenforeignmemory_open(xenforeignmemory_handle * fmem)39 int osdep_xenforeignmemory_open(xenforeignmemory_handle *fmem)
40 {
41 /* No fd required */
42 return 0;
43 }
44
osdep_xenforeignmemory_close(xenforeignmemory_handle * fmem)45 int osdep_xenforeignmemory_close(xenforeignmemory_handle *fmem)
46 {
47 return 0;
48 }
49
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[])50 void *osdep_xenforeignmemory_map(xenforeignmemory_handle *fmem,
51 uint32_t dom, void *addr,
52 int prot, int flags, size_t num,
53 const xen_pfn_t arr[/*num*/], int err[/*num*/])
54 {
55 unsigned long pt_prot = 0;
56 if (prot & PROT_READ)
57 pt_prot = L1_PROT_RO;
58 if (prot & PROT_WRITE)
59 pt_prot = L1_PROT;
60 return map_frames_ex(arr, num, 1, 0, 1, dom, err, pt_prot);
61 }
62
osdep_xenforeignmemory_unmap(xenforeignmemory_handle * fmem,void * addr,size_t num)63 int osdep_xenforeignmemory_unmap(xenforeignmemory_handle *fmem,
64 void *addr, size_t num)
65 {
66 return munmap(addr, num << XC_PAGE_SHIFT);
67 }
68
69 /*
70 * Local variables:
71 * mode: C
72 * c-file-style: "BSD"
73 * c-basic-offset: 4
74 * tab-width: 4
75 * indent-tabs-mode: nil
76 * End:
77 */
78