2019-03-15 15:51:20 +01:00
|
|
|
#ifndef HW_XEN_LEGACY_BACKEND_H
|
|
|
|
#define HW_XEN_LEGACY_BACKEND_H
|
2009-04-22 17:19:15 +02:00
|
|
|
|
2013-02-05 17:06:20 +01:00
|
|
|
#include "hw/xen/xen_common.h"
|
2016-10-25 07:50:09 +02:00
|
|
|
#include "hw/xen/xen_pvdev.h"
|
2012-10-24 08:43:34 +02:00
|
|
|
#include "net/net.h"
|
2009-04-22 17:19:15 +02:00
|
|
|
|
2016-11-22 07:10:56 +01:00
|
|
|
#define TYPE_XENSYSDEV "xen-sysdev"
|
|
|
|
#define TYPE_XENSYSBUS "xen-sysbus"
|
2016-11-22 07:10:58 +01:00
|
|
|
#define TYPE_XENBACKEND "xen-backend"
|
|
|
|
|
|
|
|
#define XENBACKEND_DEVICE(obj) \
|
2019-01-08 15:48:46 +01:00
|
|
|
OBJECT_CHECK(XenLegacyDevice, (obj), TYPE_XENBACKEND)
|
2016-11-22 07:10:56 +01:00
|
|
|
|
2009-04-22 17:19:15 +02:00
|
|
|
/* variables */
|
|
|
|
extern struct xs_handle *xenstore;
|
2009-04-22 17:19:39 +02:00
|
|
|
extern const char *xen_protocol;
|
2016-05-12 16:13:39 +02:00
|
|
|
extern DeviceState *xen_sysdev;
|
2016-11-22 07:10:56 +01:00
|
|
|
extern BusState *xen_sysbus;
|
2009-04-22 17:19:15 +02:00
|
|
|
|
2016-05-12 16:13:40 +02:00
|
|
|
int xenstore_mkdir(char *path, int p);
|
2019-01-08 15:48:46 +01:00
|
|
|
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);
|
2016-10-25 07:50:10 +02:00
|
|
|
void xenstore_update_be(char *watch, char *type, int dom,
|
|
|
|
struct XenDevOps *ops);
|
2019-01-08 15:48:46 +01:00
|
|
|
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,
|
2016-10-25 07:50:08 +02:00
|
|
|
uint64_t *uval);
|
2009-04-22 17:19:15 +02:00
|
|
|
|
2019-01-08 15:48:46 +01:00
|
|
|
void xen_be_check_state(struct XenLegacyDevice *xendev);
|
2009-04-22 17:19:15 +02:00
|
|
|
|
|
|
|
/* xen backend driver bits */
|
|
|
|
int xen_be_init(void);
|
2016-08-02 08:32:32 +02:00
|
|
|
void xen_be_register_common(void);
|
2009-04-22 17:19:15 +02:00
|
|
|
int xen_be_register(const char *type, struct XenDevOps *ops);
|
2019-01-08 15:48:46 +01:00
|
|
|
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,
|
2018-05-17 17:35:51 +02:00
|
|
|
unsigned int nr_refs);
|
2019-01-08 15:48:46 +01:00
|
|
|
void *xen_be_map_grant_refs(struct XenLegacyDevice *xendev, uint32_t *refs,
|
2018-05-17 17:35:51 +02:00
|
|
|
unsigned int nr_refs, int prot);
|
2019-01-08 15:48:46 +01:00
|
|
|
void xen_be_unmap_grant_refs(struct XenLegacyDevice *xendev, void *ptr,
|
2018-05-17 17:35:51 +02:00
|
|
|
unsigned int nr_refs);
|
|
|
|
|
|
|
|
typedef struct XenGrantCopySegment {
|
|
|
|
union {
|
|
|
|
void *virt;
|
|
|
|
struct {
|
|
|
|
uint32_t ref;
|
|
|
|
off_t offset;
|
|
|
|
} foreign;
|
|
|
|
} source, dest;
|
|
|
|
size_t len;
|
|
|
|
} XenGrantCopySegment;
|
|
|
|
|
2019-01-08 15:48:46 +01:00
|
|
|
int xen_be_copy_grant_refs(struct XenLegacyDevice *xendev,
|
2018-05-17 17:35:51 +02:00
|
|
|
bool to_domain, XenGrantCopySegment segs[],
|
|
|
|
unsigned int nr_segs);
|
|
|
|
|
2019-01-08 15:48:46 +01:00
|
|
|
static inline void *xen_be_map_grant_ref(struct XenLegacyDevice *xendev,
|
2018-05-17 17:35:51 +02:00
|
|
|
uint32_t ref, int prot)
|
|
|
|
{
|
|
|
|
return xen_be_map_grant_refs(xendev, &ref, 1, prot);
|
|
|
|
}
|
|
|
|
|
2019-01-08 15:48:46 +01:00
|
|
|
static inline void xen_be_unmap_grant_ref(struct XenLegacyDevice *xendev,
|
2018-05-17 17:35:51 +02:00
|
|
|
void *ptr)
|
|
|
|
{
|
|
|
|
return xen_be_unmap_grant_refs(xendev, ptr, 1);
|
|
|
|
}
|
2009-04-22 17:19:15 +02:00
|
|
|
|
2009-04-22 17:19:19 +02:00
|
|
|
/* actual backend drivers */
|
|
|
|
extern struct XenDevOps xen_console_ops; /* xen_console.c */
|
2009-04-22 17:19:25 +02:00
|
|
|
extern struct XenDevOps xen_kbdmouse_ops; /* xen_framebuffer.c */
|
|
|
|
extern struct XenDevOps xen_framebuffer_ops; /* xen_framebuffer.c */
|
2009-04-22 17:19:30 +02:00
|
|
|
extern struct XenDevOps xen_blkdev_ops; /* xen_disk.c */
|
2017-03-22 18:17:09 +01:00
|
|
|
#ifdef CONFIG_VIRTFS
|
|
|
|
extern struct XenDevOps xen_9pfs_ops; /* xen-9p-backend.c */
|
|
|
|
#endif
|
2009-04-22 17:19:35 +02:00
|
|
|
extern struct XenDevOps xen_netdev_ops; /* xen_nic.c */
|
2016-05-12 16:13:41 +02:00
|
|
|
#ifdef CONFIG_USB_LIBUSB
|
|
|
|
extern struct XenDevOps xen_usb_ops; /* xen-usb.c */
|
|
|
|
#endif
|
2009-04-22 17:19:25 +02:00
|
|
|
|
2009-04-22 17:19:39 +02:00
|
|
|
/* configuration (aka xenbus setup) */
|
2010-03-21 20:13:02 +01:00
|
|
|
void xen_config_cleanup(void);
|
2009-04-22 17:19:39 +02:00
|
|
|
int xen_config_dev_blk(DriveInfo *disk);
|
|
|
|
int xen_config_dev_nic(NICInfo *nic);
|
2009-04-22 17:19:44 +02: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 17:19:39 +02:00
|
|
|
|
2019-03-15 15:51:20 +01:00
|
|
|
#endif /* HW_XEN_LEGACY_BACKEND_H */
|