2009-04-22 19:19:15 +04:00
|
|
|
#ifndef QEMU_HW_XEN_BACKEND_H
|
2016-06-29 16:29:06 +03:00
|
|
|
#define QEMU_HW_XEN_BACKEND_H
|
2009-04-22 19:19:15 +04:00
|
|
|
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/xen/xen_common.h"
|
2016-10-25 08:50:09 +03:00
|
|
|
#include "hw/xen/xen_pvdev.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2009-04-22 19:19:15 +04:00
|
|
|
|
2016-11-22 09:10:56 +03:00
|
|
|
#define TYPE_XENSYSDEV "xen-sysdev"
|
|
|
|
#define TYPE_XENSYSBUS "xen-sysbus"
|
2016-11-22 09:10:58 +03:00
|
|
|
#define TYPE_XENBACKEND "xen-backend"
|
|
|
|
|
|
|
|
#define XENBACKEND_DEVICE(obj) \
|
|
|
|
OBJECT_CHECK(XenDevice, (obj), TYPE_XENBACKEND)
|
2016-11-22 09:10:56 +03:00
|
|
|
|
2009-04-22 19:19:15 +04:00
|
|
|
/* variables */
|
2016-02-10 14:07:03 +03:00
|
|
|
extern xc_interface *xen_xc;
|
xen: Switch uses of xc_map_foreign_{pages,bulk} to use libxenforeignmemory API.
In Xen 4.7 we are refactoring parts libxenctrl into a number of
separate libraries which will provide backward and forward API and ABI
compatiblity.
One such library will be libxenforeignmemory which provides access to
privileged foreign mappings and which will provide an interface
equivalent to xc_map_foreign_{pages,bulk}.
The new xenforeignmemory_map() function behaves like
xc_map_foreign_pages() when the err argument is NULL and like
xc_map_foreign_bulk() when err is non-NULL, which maps into the shim
here onto checking err == NULL and calling the appropriate old
function.
Note that xenforeignmemory_map() takes the number of pages before the
arrays themselves, in order to support potentially future use of
variable-length-arrays in the prototype (in the future, when Xen's
baseline toolchain requirements are new enough to ensure VLAs are
supported).
In preparation for adding support for libxenforeignmemory add support
to the <=4.0 and <=4.6 compat code in xen_common.h to allow us to
switch to using the new API. These shims will disappear for versions
of Xen which include libxenforeignmemory.
Since libxenforeignmemory will have its own handle type but for <= 4.6
the functionality is provided by using a libxenctrl handle we
introduce a new global xen_fmem alongside the existing xen_xc. In fact
we make xen_fmem a pointer to the existing xen_xc, which then works
correctly with both <=4.0 (xc handle is an int) and <=4.6 (xc handle
is a pointer). In the latter case xen_fmem is actually a double
indirect pointer, but it all falls out in the wash.
Unlike libxenctrl libxenforeignmemory has an explicit unmap function,
rather than just specifying that munmap should be used, so the unmap
paths are updated to use xenforeignmemory_unmap, which is a shim for
munmap on these versions of xen. The mappings in xen-hvm.c do not
appear to be unmapped (which makes sense for a qemu-dm process)
In fb_disconnect this results in a change from simply mmap over the
existing mapping (with an implicit munmap) to expliclty unmapping with
xenforeignmemory_unmap and then mapping the required anonymous memory
in the same hole. I don't think this is a problem since any other
thread which was racily touching this region would already be running
the risk of hitting the mapping halfway through the call. If this is
thought to be a problem then we could consider adding an extra API to
the libxenforeignmemory interface to replace a foreign mapping with
anonymous shared memory, but I'd prefer not to.
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
2016-01-15 16:23:41 +03:00
|
|
|
extern xenforeignmemory_handle *xen_fmem;
|
2009-04-22 19:19:15 +04:00
|
|
|
extern struct xs_handle *xenstore;
|
2009-04-22 19:19:39 +04:00
|
|
|
extern const char *xen_protocol;
|
2016-05-12 17:13:39 +03:00
|
|
|
extern DeviceState *xen_sysdev;
|
2016-11-22 09:10:56 +03:00
|
|
|
extern BusState *xen_sysbus;
|
2009-04-22 19:19:15 +04:00
|
|
|
|
2016-05-12 17:13:40 +03:00
|
|
|
int xenstore_mkdir(char *path, int p);
|
2009-04-22 19:19:15 +04:00
|
|
|
int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val);
|
|
|
|
int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival);
|
2013-04-05 19:37:32 +04:00
|
|
|
int xenstore_write_be_int64(struct XenDevice *xendev, const char *node, int64_t ival);
|
2009-04-22 19:19:15 +04:00
|
|
|
char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
|
|
|
|
int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
|
2016-10-25 08:50:10 +03:00
|
|
|
void xenstore_update_fe(char *watch, struct XenDevice *xendev);
|
|
|
|
void xenstore_update_be(char *watch, char *type, int dom,
|
|
|
|
struct XenDevOps *ops);
|
2009-04-22 19:19:15 +04:00
|
|
|
char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
|
|
|
|
int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
|
2016-10-25 08:50:08 +03:00
|
|
|
int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node,
|
|
|
|
uint64_t *uval);
|
2009-04-22 19:19:15 +04:00
|
|
|
|
|
|
|
void xen_be_check_state(struct XenDevice *xendev);
|
|
|
|
|
|
|
|
/* xen backend driver bits */
|
|
|
|
int xen_be_init(void);
|
2016-08-02 09:32:32 +03:00
|
|
|
void xen_be_register_common(void);
|
2009-04-22 19:19:15 +04:00
|
|
|
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);
|
|
|
|
|
2009-04-22 19:19:19 +04:00
|
|
|
/* actual backend drivers */
|
|
|
|
extern struct XenDevOps xen_console_ops; /* xen_console.c */
|
2009-04-22 19:19:25 +04:00
|
|
|
extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */
|
|
|
|
extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */
|
2009-04-22 19:19:30 +04:00
|
|
|
extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */
|
2009-04-22 19:19:35 +04:00
|
|
|
extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */
|
2016-05-12 17:13:41 +03:00
|
|
|
#ifdef CONFIG_USB_LIBUSB
|
|
|
|
extern struct XenDevOps xen_usb_ops; /* xen-usb.c */
|
|
|
|
#endif
|
2009-04-22 19:19:25 +04:00
|
|
|
|
|
|
|
void xen_init_display(int domid);
|
2009-04-22 19:19:19 +04:00
|
|
|
|
2009-04-22 19:19:39 +04:00
|
|
|
/* configuration (aka xenbus setup) */
|
2010-03-21 22:13:02 +03:00
|
|
|
void xen_config_cleanup(void);
|
2009-04-22 19:19:39 +04:00
|
|
|
int xen_config_dev_blk(DriveInfo *disk);
|
|
|
|
int xen_config_dev_nic(NICInfo *nic);
|
2009-04-22 19:19:44 +04:00
|
|
|
int xen_config_dev_vfb(int vdev, const char *type);
|
|
|
|
int xen_config_dev_vkbd(int vdev);
|
|
|
|
int xen_config_dev_console(int vdev);
|
2009-04-22 19:19:39 +04:00
|
|
|
|
2009-04-22 19:19:15 +04:00
|
|
|
#endif /* QEMU_HW_XEN_BACKEND_H */
|