aboutsummaryrefslogtreecommitdiffstats
path: root/include/xen/grant_table.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/xen/grant_table.h')
-rw-r--r--include/xen/grant_table.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h
index 4478f4b4aae2..34b1379f9777 100644
--- a/include/xen/grant_table.h
+++ b/include/xen/grant_table.h
@@ -45,8 +45,10 @@
45#include <asm/xen/hypervisor.h> 45#include <asm/xen/hypervisor.h>
46 46
47#include <xen/features.h> 47#include <xen/features.h>
48#include <xen/page.h>
48#include <linux/mm_types.h> 49#include <linux/mm_types.h>
49#include <linux/page-flags.h> 50#include <linux/page-flags.h>
51#include <linux/kernel.h>
50 52
51#define GNTTAB_RESERVED_XENSTORE 1 53#define GNTTAB_RESERVED_XENSTORE 1
52 54
@@ -129,6 +131,15 @@ void gnttab_cancel_free_callback(struct gnttab_free_callback *callback);
129void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid, 131void gnttab_grant_foreign_access_ref(grant_ref_t ref, domid_t domid,
130 unsigned long frame, int readonly); 132 unsigned long frame, int readonly);
131 133
134/* Give access to the first 4K of the page */
135static inline void gnttab_page_grant_foreign_access_ref_one(
136 grant_ref_t ref, domid_t domid,
137 struct page *page, int readonly)
138{
139 gnttab_grant_foreign_access_ref(ref, domid, xen_page_to_gfn(page),
140 readonly);
141}
142
132void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid, 143void gnttab_grant_foreign_transfer_ref(grant_ref_t, domid_t domid,
133 unsigned long pfn); 144 unsigned long pfn);
134 145
@@ -224,4 +235,50 @@ static inline struct xen_page_foreign *xen_page_foreign(struct page *page)
224#endif 235#endif
225} 236}
226 237
238/* Split Linux page in chunk of the size of the grant and call fn
239 *
240 * Parameters of fn:
241 * gfn: guest frame number
242 * offset: offset in the grant
243 * len: length of the data in the grant.
244 * data: internal information
245 */
246typedef void (*xen_grant_fn_t)(unsigned long gfn, unsigned int offset,
247 unsigned int len, void *data);
248
249void gnttab_foreach_grant_in_range(struct page *page,
250 unsigned int offset,
251 unsigned int len,
252 xen_grant_fn_t fn,
253 void *data);
254
255/* Helper to get to call fn only on the first "grant chunk" */
256static inline void gnttab_for_one_grant(struct page *page, unsigned int offset,
257 unsigned len, xen_grant_fn_t fn,
258 void *data)
259{
260 /* The first request is limited to the size of one grant */
261 len = min_t(unsigned int, XEN_PAGE_SIZE - (offset & ~XEN_PAGE_MASK),
262 len);
263
264 gnttab_foreach_grant_in_range(page, offset, len, fn, data);
265}
266
267/* Get @nr_grefs grants from an array of page and call fn for each grant */
268void gnttab_foreach_grant(struct page **pages,
269 unsigned int nr_grefs,
270 xen_grant_fn_t fn,
271 void *data);
272
273/* Get the number of grant in a specified region
274 *
275 * start: Offset from the beginning of the first page
276 * len: total length of data (can cross multiple page)
277 */
278static inline unsigned int gnttab_count_grant(unsigned int start,
279 unsigned int len)
280{
281 return XEN_PFN_UP(xen_offset_in_page(start) + len);
282}
283
227#endif /* __ASM_GNTTAB_H__ */ 284#endif /* __ASM_GNTTAB_H__ */