qemu/hw/xen_backend.h
<<
>>
Prefs
   1#ifndef QEMU_HW_XEN_BACKEND_H
   2#define QEMU_HW_XEN_BACKEND_H 1
   3
   4#include "xen_common.h"
   5#include "sysemu.h"
   6#include "net.h"
   7#include "net/hub.h"
   8
   9/* ------------------------------------------------------------- */
  10
  11#define XEN_BUFSIZE 1024
  12
  13struct XenDevice;
  14
  15/* driver uses grant tables  ->  open gntdev device (xendev->gnttabdev) */
  16#define DEVOPS_FLAG_NEED_GNTDEV   1
  17/* don't expect frontend doing correct state transitions (aka console quirk) */
  18#define DEVOPS_FLAG_IGNORE_STATE  2
  19
  20struct XenDevOps {
  21    size_t    size;
  22    uint32_t  flags;
  23    void      (*alloc)(struct XenDevice *xendev);
  24    int       (*init)(struct XenDevice *xendev);
  25    int       (*initialise)(struct XenDevice *xendev);
  26    void      (*connected)(struct XenDevice *xendev);
  27    void      (*event)(struct XenDevice *xendev);
  28    void      (*disconnect)(struct XenDevice *xendev);
  29    int       (*free)(struct XenDevice *xendev);
  30    void      (*backend_changed)(struct XenDevice *xendev, const char *node);
  31    void      (*frontend_changed)(struct XenDevice *xendev, const char *node);
  32};
  33
  34struct XenDevice {
  35    const char         *type;
  36    int                dom;
  37    int                dev;
  38    char               name[64];
  39    int                debug;
  40
  41    enum xenbus_state  be_state;
  42    enum xenbus_state  fe_state;
  43    int                online;
  44    char               be[XEN_BUFSIZE];
  45    char               *fe;
  46    char               *protocol;
  47    int                remote_port;
  48    int                local_port;
  49
  50    XenEvtchn          evtchndev;
  51    XenGnttab          gnttabdev;
  52
  53    struct XenDevOps   *ops;
  54    QTAILQ_ENTRY(XenDevice) next;
  55};
  56
  57/* ------------------------------------------------------------- */
  58
  59/* variables */
  60extern XenXC xen_xc;
  61extern struct xs_handle *xenstore;
  62extern const char *xen_protocol;
  63
  64/* xenstore helper functions */
  65int xenstore_write_str(const char *base, const char *node, const char *val);
  66int xenstore_write_int(const char *base, const char *node, int ival);
  67char *xenstore_read_str(const char *base, const char *node);
  68int xenstore_read_int(const char *base, const char *node, int *ival);
  69
  70int xenstore_write_be_str(struct XenDevice *xendev, const char *node, const char *val);
  71int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival);
  72char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
  73int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
  74char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
  75int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
  76
  77const char *xenbus_strstate(enum xenbus_state state);
  78struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
  79void xen_be_check_state(struct XenDevice *xendev);
  80
  81/* xen backend driver bits */
  82int xen_be_init(void);
  83int xen_be_register(const char *type, struct XenDevOps *ops);
  84int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state);
  85int xen_be_bind_evtchn(struct XenDevice *xendev);
  86void xen_be_unbind_evtchn(struct XenDevice *xendev);
  87int xen_be_send_notify(struct XenDevice *xendev);
  88void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
  89    GCC_FMT_ATTR(3, 4);
  90
  91/* actual backend drivers */
  92extern struct XenDevOps xen_console_ops;      /* xen_console.c     */
  93extern struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
  94extern struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
  95extern struct XenDevOps xen_blkdev_ops;       /* xen_disk.c        */
  96extern struct XenDevOps xen_netdev_ops;       /* xen_nic.c         */
  97
  98void xen_init_display(int domid);
  99
 100/* configuration (aka xenbus setup) */
 101void xen_config_cleanup(void);
 102int xen_config_dev_blk(DriveInfo *disk);
 103int xen_config_dev_nic(NICInfo *nic);
 104int xen_config_dev_vfb(int vdev, const char *type);
 105int xen_config_dev_vkbd(int vdev);
 106int xen_config_dev_console(int vdev);
 107
 108#endif /* QEMU_HW_XEN_BACKEND_H */
 109