2019-03-15 17:51:20 +03:00
|
|
|
#ifndef HW_XEN_LEGACY_BACKEND_H
|
|
|
|
#define HW_XEN_LEGACY_BACKEND_H
|
2009-04-22 19:19:15 +04:00
|
|
|
|
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_pvdev.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2020-09-03 23:43:22 +03:00
|
|
|
#include "qom/object.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"
|
|
|
|
|
2020-08-25 22:20:22 +03:00
|
|
|
typedef struct XenLegacyDevice XenLegacyDevice;
|
2020-09-03 01:43:05 +03:00
|
|
|
DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND,
|
2020-09-01 00:07:33 +03:00
|
|
|
TYPE_XENBACKEND)
|
2016-11-22 09:10:56 +03:00
|
|
|
|
2009-04-22 19:19:15 +04:00
|
|
|
/* variables */
|
2023-01-02 14:05:16 +03:00
|
|
|
extern struct qemu_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);
|
2019-01-08 17:48:46 +03: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);
|
|
|
|
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 08:50:08 +03:00
|
|
|
uint64_t *uval);
|
2009-04-22 19:19:15 +04:00
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
void xen_be_check_state(struct XenLegacyDevice *xendev);
|
2009-04-22 19:19:15 +04:00
|
|
|
|
|
|
|
/* xen backend driver bits */
|
2023-02-15 18:05:26 +03:00
|
|
|
void xen_be_init(void);
|
2024-05-10 12:25:08 +03:00
|
|
|
int xen_be_register(const char *type, const struct XenDevOps *ops);
|
2019-01-08 17:48:46 +03: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 18:35:51 +03:00
|
|
|
unsigned int nr_refs);
|
2019-01-08 17:48:46 +03:00
|
|
|
void *xen_be_map_grant_refs(struct XenLegacyDevice *xendev, uint32_t *refs,
|
2018-05-17 18:35:51 +03:00
|
|
|
unsigned int nr_refs, int prot);
|
2019-01-08 17:48:46 +03:00
|
|
|
void xen_be_unmap_grant_refs(struct XenLegacyDevice *xendev, void *ptr,
|
2023-01-10 03:03:49 +03:00
|
|
|
uint32_t *refs, unsigned int nr_refs);
|
2018-05-17 18:35:51 +03:00
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
int xen_be_copy_grant_refs(struct XenLegacyDevice *xendev,
|
2018-05-17 18:35:51 +03:00
|
|
|
bool to_domain, XenGrantCopySegment segs[],
|
|
|
|
unsigned int nr_segs);
|
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
static inline void *xen_be_map_grant_ref(struct XenLegacyDevice *xendev,
|
2018-05-17 18:35:51 +03:00
|
|
|
uint32_t ref, int prot)
|
|
|
|
{
|
|
|
|
return xen_be_map_grant_refs(xendev, &ref, 1, prot);
|
|
|
|
}
|
|
|
|
|
2019-01-08 17:48:46 +03:00
|
|
|
static inline void xen_be_unmap_grant_ref(struct XenLegacyDevice *xendev,
|
2023-01-10 03:03:49 +03:00
|
|
|
void *ptr, uint32_t ref)
|
2018-05-17 18:35:51 +03:00
|
|
|
{
|
2023-01-10 03:03:49 +03:00
|
|
|
return xen_be_unmap_grant_refs(xendev, ptr, &ref, 1);
|
2018-05-17 18:35:51 +03:00
|
|
|
}
|
2009-04-22 19:19:15 +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: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
|
|
|
|
2019-03-15 17:51:20 +03:00
|
|
|
#endif /* HW_XEN_LEGACY_BACKEND_H */
|