diff options
| author | Paul Durrant <paul.durrant@citrix.com> | 2018-05-17 16:35:51 +0100 |
|---|---|---|
| committer | Stefano Stabellini <sstabellini@kernel.org> | 2018-05-22 11:43:21 -0700 |
| commit | 9838824affced9e4db01a369dd28c14f694fa9b9 (patch) | |
| tree | 20fa01cab7d804cb706849cc76929abac20be725 /include/hw/xen/xen_backend.h | |
| parent | 5c0d914a9ba9e0641554d127b62859ac0e954b9e (diff) | |
| download | focaccia-qemu-9838824affced9e4db01a369dd28c14f694fa9b9.tar.gz focaccia-qemu-9838824affced9e4db01a369dd28c14f694fa9b9.zip | |
xen_backend: add grant table helpers
This patch adds grant table helper functions to the xen_backend code to localize error reporting and use of xen_domid. The patch also defers the call to xengnttab_open() until just before the initialise method in XenDevOps is invoked. This method is responsible for mapping the shared ring. No prior method requires access to the grant table. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Acked-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Diffstat (limited to 'include/hw/xen/xen_backend.h')
| -rw-r--r-- | include/hw/xen/xen_backend.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/include/hw/xen/xen_backend.h b/include/hw/xen/xen_backend.h index 3a27692407..29bf1c3bc3 100644 --- a/include/hw/xen/xen_backend.h +++ b/include/hw/xen/xen_backend.h @@ -42,6 +42,39 @@ void xen_be_register_common(void); int xen_be_register(const char *type, struct XenDevOps *ops); int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state); int xen_be_bind_evtchn(struct XenDevice *xendev); +void xen_be_set_max_grant_refs(struct XenDevice *xendev, + unsigned int nr_refs); +void *xen_be_map_grant_refs(struct XenDevice *xendev, uint32_t *refs, + unsigned int nr_refs, int prot); +void xen_be_unmap_grant_refs(struct XenDevice *xendev, void *ptr, + unsigned int nr_refs); + +typedef struct XenGrantCopySegment { + union { + void *virt; + struct { + uint32_t ref; + off_t offset; + } foreign; + } source, dest; + size_t len; +} XenGrantCopySegment; + +int xen_be_copy_grant_refs(struct XenDevice *xendev, + bool to_domain, XenGrantCopySegment segs[], + unsigned int nr_segs); + +static inline void *xen_be_map_grant_ref(struct XenDevice *xendev, + uint32_t ref, int prot) +{ + return xen_be_map_grant_refs(xendev, &ref, 1, prot); +} + +static inline void xen_be_unmap_grant_ref(struct XenDevice *xendev, + void *ptr) +{ + return xen_be_unmap_grant_refs(xendev, ptr, 1); +} /* actual backend drivers */ extern struct XenDevOps xen_console_ops; /* xen_console.c */ |