debuggers.hg

view tools/libxc/xc_memshr.c @ 21067:b4a1832a916f

Update Xen version to 4.0.0-rc6
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 09 18:18:05 2010 +0000 (2010-03-09)
parents bde24590c13a
children 779c0ef9682c
line source
1 /******************************************************************************
2 *
3 * xc_memshr.c
4 *
5 * Interface to low-level memory sharing functionality.
6 *
7 * Copyright (c) 2009 Citrix Systems, Inc. (Grzegorz Milos)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
24 #include "xc_private.h"
25 #include <xen/memory.h>
26 #include <xen/grant_table.h>
28 int xc_memshr_control(int xc_handle,
29 uint32_t domid,
30 int enable)
31 {
32 DECLARE_DOMCTL;
33 struct xen_domctl_mem_sharing_op *op;
35 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
36 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
37 domctl.domain = (domid_t)domid;
38 op = &(domctl.u.mem_sharing_op);
39 op->op = XEN_DOMCTL_MEM_SHARING_OP_CONTROL;
40 op->u.enable = enable;
42 return do_domctl(xc_handle, &domctl);
43 }
45 int xc_memshr_nominate_gfn(int xc_handle,
46 uint32_t domid,
47 unsigned long gfn,
48 uint64_t *handle)
49 {
50 DECLARE_DOMCTL;
51 struct xen_domctl_mem_sharing_op *op;
52 int ret;
54 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
55 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
56 domctl.domain = (domid_t)domid;
57 op = &(domctl.u.mem_sharing_op);
58 op->op = XEN_DOMCTL_MEM_SHARING_OP_NOMINATE_GFN;
59 op->u.nominate.u.gfn = gfn;
61 ret = do_domctl(xc_handle, &domctl);
62 if(!ret) *handle = op->u.nominate.handle;
64 return ret;
65 }
67 int xc_memshr_nominate_gref(int xc_handle,
68 uint32_t domid,
69 grant_ref_t gref,
70 uint64_t *handle)
71 {
72 DECLARE_DOMCTL;
73 struct xen_domctl_mem_sharing_op *op;
74 int ret;
76 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
77 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
78 domctl.domain = (domid_t)domid;
79 op = &(domctl.u.mem_sharing_op);
80 op->op = XEN_DOMCTL_MEM_SHARING_OP_NOMINATE_GREF;
81 op->u.nominate.u.grant_ref = gref;
83 ret = do_domctl(xc_handle, &domctl);
84 if(!ret) *handle = op->u.nominate.handle;
86 return ret;
87 }
89 int xc_memshr_share(int xc_handle,
90 uint64_t source_handle,
91 uint64_t client_handle)
92 {
93 DECLARE_DOMCTL;
94 struct xen_domctl_mem_sharing_op *op;
96 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
97 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
98 domctl.domain = 0;
99 op = &(domctl.u.mem_sharing_op);
100 op->op = XEN_DOMCTL_MEM_SHARING_OP_SHARE;
101 op->u.share.source_handle = source_handle;
102 op->u.share.client_handle = client_handle;
104 return do_domctl(xc_handle, &domctl);
105 }
107 int xc_memshr_domain_resume(int xc_handle,
108 uint32_t domid)
109 {
110 DECLARE_DOMCTL;
111 struct xen_domctl_mem_sharing_op *op;
113 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
114 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
115 domctl.domain = (domid_t)domid;
116 op = &(domctl.u.mem_sharing_op);
117 op->op = XEN_DOMCTL_MEM_SHARING_OP_RESUME;
119 return do_domctl(xc_handle, &domctl);
120 }
122 int xc_memshr_debug_gfn(int xc_handle,
123 uint32_t domid,
124 unsigned long gfn)
125 {
126 DECLARE_DOMCTL;
127 struct xen_domctl_mem_sharing_op *op;
129 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
130 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
131 domctl.domain = (domid_t)domid;
132 op = &(domctl.u.mem_sharing_op);
133 op->op = XEN_DOMCTL_MEM_SHARING_OP_DEBUG_GFN;
134 op->u.debug.u.gfn = gfn;
136 return do_domctl(xc_handle, &domctl);
137 }
139 int xc_memshr_debug_mfn(int xc_handle,
140 uint32_t domid,
141 unsigned long mfn)
142 {
143 DECLARE_DOMCTL;
144 struct xen_domctl_mem_sharing_op *op;
146 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
147 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
148 domctl.domain = (domid_t)domid;
149 op = &(domctl.u.mem_sharing_op);
150 op->op = XEN_DOMCTL_MEM_SHARING_OP_DEBUG_MFN;
151 op->u.debug.u.mfn = mfn;
153 return do_domctl(xc_handle, &domctl);
154 }
156 int xc_memshr_debug_gref(int xc_handle,
157 uint32_t domid,
158 grant_ref_t gref)
159 {
160 DECLARE_DOMCTL;
161 struct xen_domctl_mem_sharing_op *op;
163 domctl.cmd = XEN_DOMCTL_mem_sharing_op;
164 domctl.interface_version = XEN_DOMCTL_INTERFACE_VERSION;
165 domctl.domain = (domid_t)domid;
166 op = &(domctl.u.mem_sharing_op);
167 op->op = XEN_DOMCTL_MEM_SHARING_OP_DEBUG_GREF;
168 op->u.debug.u.gref = gref;
170 return do_domctl(xc_handle, &domctl);
171 }