mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-28 21:03:54 -06:00

Move the existing code using libxengnttab to xen-operations.c and allow the operations to be redirected so that we can add emulation of grant table mapping for backend drivers. In emulation, mapping more than one grant ref to be virtually contiguous would be fairly difficult. The best way to do it might be to make the ram_block mappings actually backed by a file (shmem or a deleted file, perhaps) so that we can have multiple *shared* mappings of it. But that would be fairly intrusive. Making the backend drivers cope with page *lists* instead of expecting the mapping to be contiguous is also non-trivial, since some structures would actually *cross* page boundaries (e.g. the 32-bit blkif responses which are 12 bytes). So for now, we'll support only single-page mappings in emulation. Add a XEN_GNTTAB_OP_FEATURE_MAP_MULTIPLE flag to indicate that the native Xen implementation *does* support multi-page maps, and a helper function to query it. Signed-off-by: David Woodhouse <dwmw@amazon.co.uk> Reviewed-by: Paul Durrant <paul@xen.org>
94 lines
3.8 KiB
C
94 lines
3.8 KiB
C
#ifndef HW_XEN_LEGACY_BACKEND_H
|
|
#define HW_XEN_LEGACY_BACKEND_H
|
|
|
|
#include "hw/xen/xen_backend_ops.h"
|
|
#include "hw/xen/interface/io/xenbus.h"
|
|
#include "hw/xen/xen_pvdev.h"
|
|
#include "net/net.h"
|
|
#include "qom/object.h"
|
|
|
|
#define TYPE_XENSYSDEV "xen-sysdev"
|
|
#define TYPE_XENSYSBUS "xen-sysbus"
|
|
#define TYPE_XENBACKEND "xen-backend"
|
|
|
|
typedef struct XenLegacyDevice XenLegacyDevice;
|
|
DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND,
|
|
TYPE_XENBACKEND)
|
|
|
|
/* variables */
|
|
extern struct xs_handle *xenstore;
|
|
extern const char *xen_protocol;
|
|
extern DeviceState *xen_sysdev;
|
|
extern BusState *xen_sysbus;
|
|
|
|
int xenstore_mkdir(char *path, int p);
|
|
int xenstore_write_be_str(struct XenLegacyDevice *xendev, const char *node,
|
|
const char *val);
|
|
int xenstore_write_be_int(struct XenLegacyDevice *xendev, const char *node,
|
|
int ival);
|
|
int xenstore_write_be_int64(struct XenLegacyDevice *xendev, const char *node,
|
|
int64_t ival);
|
|
char *xenstore_read_be_str(struct XenLegacyDevice *xendev, const char *node);
|
|
int xenstore_read_be_int(struct XenLegacyDevice *xendev, const char *node,
|
|
int *ival);
|
|
void xenstore_update_fe(char *watch, struct XenLegacyDevice *xendev);
|
|
void xenstore_update_be(char *watch, char *type, int dom,
|
|
struct XenDevOps *ops);
|
|
char *xenstore_read_fe_str(struct XenLegacyDevice *xendev, const char *node);
|
|
int xenstore_read_fe_int(struct XenLegacyDevice *xendev, const char *node,
|
|
int *ival);
|
|
int xenstore_read_fe_uint64(struct XenLegacyDevice *xendev, const char *node,
|
|
uint64_t *uval);
|
|
|
|
void xen_be_check_state(struct XenLegacyDevice *xendev);
|
|
|
|
/* xen backend driver bits */
|
|
void xen_be_init(void);
|
|
int xen_be_register(const char *type, struct XenDevOps *ops);
|
|
int xen_be_set_state(struct XenLegacyDevice *xendev, enum xenbus_state state);
|
|
int xen_be_bind_evtchn(struct XenLegacyDevice *xendev);
|
|
void xen_be_set_max_grant_refs(struct XenLegacyDevice *xendev,
|
|
unsigned int nr_refs);
|
|
void *xen_be_map_grant_refs(struct XenLegacyDevice *xendev, uint32_t *refs,
|
|
unsigned int nr_refs, int prot);
|
|
void xen_be_unmap_grant_refs(struct XenLegacyDevice *xendev, void *ptr,
|
|
unsigned int nr_refs);
|
|
|
|
int xen_be_copy_grant_refs(struct XenLegacyDevice *xendev,
|
|
bool to_domain, XenGrantCopySegment segs[],
|
|
unsigned int nr_segs);
|
|
|
|
static inline void *xen_be_map_grant_ref(struct XenLegacyDevice *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 XenLegacyDevice *xendev,
|
|
void *ptr)
|
|
{
|
|
return xen_be_unmap_grant_refs(xendev, ptr, 1);
|
|
}
|
|
|
|
/* actual backend drivers */
|
|
extern struct XenDevOps xen_console_ops; /* xen_console.c */
|
|
extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */
|
|
extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */
|
|
extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */
|
|
#ifdef CONFIG_VIRTFS
|
|
extern struct XenDevOps xen_9pfs_ops; /* xen-9p-backend.c */
|
|
#endif
|
|
extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */
|
|
#ifdef CONFIG_USB_LIBUSB
|
|
extern struct XenDevOps xen_usb_ops; /* xen-usb.c */
|
|
#endif
|
|
|
|
/* configuration (aka xenbus setup) */
|
|
void xen_config_cleanup(void);
|
|
int xen_config_dev_blk(DriveInfo *disk);
|
|
int xen_config_dev_nic(NICInfo *nic);
|
|
int xen_config_dev_vfb(int vdev, const char *type);
|
|
int xen_config_dev_vkbd(int vdev);
|
|
int xen_config_dev_console(int vdev);
|
|
|
|
#endif /* HW_XEN_LEGACY_BACKEND_H */
|