mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-07 01:33:56 -06:00
hw/xen: Add foreignmem operations to allow redirection to internal emulation
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Reviewed-by: Paul Durrant <paul@xen.org>
This commit is contained in:
parent
f80fad16af
commit
15e283c5b6
7 changed files with 88 additions and 26 deletions
|
@ -214,6 +214,32 @@ static inline int qemu_xen_gnttab_unmap(xengnttab_handle *xgt,
|
|||
return xen_gnttab_ops->unmap(xgt, start_address, refs, count);
|
||||
}
|
||||
|
||||
struct foreignmem_backend_ops {
|
||||
void *(*map)(uint32_t dom, void *addr, int prot, size_t pages,
|
||||
xen_pfn_t *pfns, int *errs);
|
||||
int (*unmap)(void *addr, size_t pages);
|
||||
};
|
||||
|
||||
extern struct foreignmem_backend_ops *xen_foreignmem_ops;
|
||||
|
||||
static inline void *qemu_xen_foreignmem_map(uint32_t dom, void *addr, int prot,
|
||||
size_t pages, xen_pfn_t *pfns,
|
||||
int *errs)
|
||||
{
|
||||
if (!xen_foreignmem_ops) {
|
||||
return NULL;
|
||||
}
|
||||
return xen_foreignmem_ops->map(dom, addr, prot, pages, pfns, errs);
|
||||
}
|
||||
|
||||
static inline int qemu_xen_foreignmem_unmap(void *addr, size_t pages)
|
||||
{
|
||||
if (!xen_foreignmem_ops) {
|
||||
return -ENOSYS;
|
||||
}
|
||||
return xen_foreignmem_ops->unmap(addr, pages);
|
||||
}
|
||||
|
||||
void setup_xen_backend_ops(void);
|
||||
|
||||
#endif /* QEMU_XEN_BACKEND_OPS_H */
|
||||
|
|
|
@ -32,19 +32,6 @@ typedef xc_interface xenforeignmemory_handle;
|
|||
#define xenforeignmemory_open(l, f) xen_xc
|
||||
#define xenforeignmemory_close(h)
|
||||
|
||||
static inline void *xenforeignmemory_map(xc_interface *h, uint32_t dom,
|
||||
int prot, size_t pages,
|
||||
const xen_pfn_t arr[/*pages*/],
|
||||
int err[/*pages*/])
|
||||
{
|
||||
if (err)
|
||||
return xc_map_foreign_bulk(h, dom, prot, arr, err, pages);
|
||||
else
|
||||
return xc_map_foreign_pages(h, dom, prot, arr, pages);
|
||||
}
|
||||
|
||||
#define xenforeignmemory_unmap(h, p, s) munmap(p, s * XC_PAGE_SIZE)
|
||||
|
||||
#else /* CONFIG_XEN_CTRL_INTERFACE_VERSION >= 40701 */
|
||||
|
||||
#include <xenforeignmemory.h>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue