2016-10-25 08:50:09 +03:00
|
|
|
#ifndef QEMU_HW_XEN_PVDEV_H
|
|
|
|
#define QEMU_HW_XEN_PVDEV_H
|
|
|
|
|
2023-01-01 20:54:41 +03:00
|
|
|
#include "hw/xen/xen_backend_ops.h"
|
2016-10-25 08:50:09 +03:00
|
|
|
#include "hw/xen/xen_common.h"
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#define XEN_BUFSIZE 1024
|
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
struct XenLegacyDevice;
|
2016-10-25 08:50:09 +03:00
|
|
|
|
|
|
|
/* driver uses grant tables -> open gntdev device (xendev->gnttabdev) */
|
|
|
|
#define DEVOPS_FLAG_NEED_GNTDEV 1
|
|
|
|
/* don't expect frontend doing correct state transitions (aka console quirk) */
|
|
|
|
#define DEVOPS_FLAG_IGNORE_STATE 2
|
|
|
|
|
|
|
|
struct XenDevOps {
|
|
|
|
size_t size;
|
|
|
|
uint32_t flags;
|
2019-01-08 17:48:46 +03:00
|
|
|
void (*alloc)(struct XenLegacyDevice *xendev);
|
|
|
|
int (*init)(struct XenLegacyDevice *xendev);
|
|
|
|
int (*initialise)(struct XenLegacyDevice *xendev);
|
|
|
|
void (*connected)(struct XenLegacyDevice *xendev);
|
|
|
|
void (*event)(struct XenLegacyDevice *xendev);
|
|
|
|
void (*disconnect)(struct XenLegacyDevice *xendev);
|
|
|
|
int (*free)(struct XenLegacyDevice *xendev);
|
|
|
|
void (*backend_changed)(struct XenLegacyDevice *xendev,
|
|
|
|
const char *node);
|
|
|
|
void (*frontend_changed)(struct XenLegacyDevice *xendev,
|
|
|
|
const char *node);
|
2016-10-25 08:50:09 +03:00
|
|
|
int (*backend_register)(void);
|
|
|
|
};
|
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
struct XenLegacyDevice {
|
2016-11-22 09:10:58 +03:00
|
|
|
DeviceState qdev;
|
2016-10-25 08:50:09 +03:00
|
|
|
const char *type;
|
|
|
|
int dom;
|
|
|
|
int dev;
|
|
|
|
char name[64];
|
|
|
|
int debug;
|
|
|
|
|
|
|
|
enum xenbus_state be_state;
|
|
|
|
enum xenbus_state fe_state;
|
|
|
|
int online;
|
|
|
|
char be[XEN_BUFSIZE];
|
|
|
|
char *fe;
|
|
|
|
char *protocol;
|
|
|
|
int remote_port;
|
|
|
|
int local_port;
|
|
|
|
|
|
|
|
xenevtchn_handle *evtchndev;
|
|
|
|
xengnttab_handle *gnttabdev;
|
|
|
|
|
|
|
|
struct XenDevOps *ops;
|
2019-01-08 17:48:46 +03:00
|
|
|
QTAILQ_ENTRY(XenLegacyDevice) next;
|
2016-10-25 08:50:09 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* xenstore helper functions */
|
|
|
|
int xenstore_write_str(const char *base, const char *node, const char *val);
|
|
|
|
int xenstore_write_int(const char *base, const char *node, int ival);
|
|
|
|
int xenstore_write_int64(const char *base, const char *node, int64_t ival);
|
|
|
|
char *xenstore_read_str(const char *base, const char *node);
|
|
|
|
int xenstore_read_int(const char *base, const char *node, int *ival);
|
|
|
|
int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval);
|
2016-10-25 08:50:10 +03:00
|
|
|
void xenstore_update(void *unused);
|
2016-10-25 08:50:09 +03:00
|
|
|
|
|
|
|
const char *xenbus_strstate(enum xenbus_state state);
|
|
|
|
|
2016-10-25 08:50:17 +03:00
|
|
|
void xen_pv_evtchn_event(void *opaque);
|
2019-01-08 17:48:46 +03:00
|
|
|
void xen_pv_insert_xendev(struct XenLegacyDevice *xendev);
|
|
|
|
void xen_pv_del_xendev(struct XenLegacyDevice *xendev);
|
|
|
|
struct XenLegacyDevice *xen_pv_find_xendev(const char *type, int dom, int dev);
|
2016-10-25 08:50:12 +03:00
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
void xen_pv_unbind_evtchn(struct XenLegacyDevice *xendev);
|
|
|
|
int xen_pv_send_notify(struct XenLegacyDevice *xendev);
|
2016-10-25 08:50:11 +03:00
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
void xen_pv_printf(struct XenLegacyDevice *xendev, int msg_level,
|
2022-02-20 19:39:25 +03:00
|
|
|
const char *fmt, ...) G_GNUC_PRINTF(3, 4);
|
2016-10-25 08:50:09 +03:00
|
|
|
|
|
|
|
#endif /* QEMU_HW_XEN_PVDEV_H */
|