]> git.proxmox.com Git - mirror_qemu.git/blame - include/hw/xen/xen-hvm-common.h
Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
[mirror_qemu.git] / include / hw / xen / xen-hvm-common.h
CommitLineData
f17068c1
SS
1#ifndef HW_XEN_HVM_COMMON_H
2#define HW_XEN_HVM_COMMON_H
3
f17068c1
SS
4#include "qemu/units.h"
5
6#include "cpu.h"
7#include "hw/pci/pci.h"
8#include "hw/hw.h"
9#include "hw/xen/xen_native.h"
10#include "hw/xen/xen-legacy-backend.h"
11#include "sysemu/runstate.h"
12#include "sysemu/sysemu.h"
13#include "sysemu/xen.h"
14#include "sysemu/xen-mapcache.h"
15#include "qemu/error-report.h"
16#include <xen/hvm/ioreq.h>
17
18extern MemoryRegion ram_memory;
19extern MemoryListener xen_io_listener;
20extern DeviceListener xen_device_listener;
21
22//#define DEBUG_XEN_HVM
23
24#ifdef DEBUG_XEN_HVM
25#define DPRINTF(fmt, ...) \
26 do { fprintf(stderr, "xen: " fmt, ## __VA_ARGS__); } while (0)
27#else
28#define DPRINTF(fmt, ...) \
29 do { } while (0)
30#endif
31
32static inline uint32_t xen_vcpu_eport(shared_iopage_t *shared_page, int i)
33{
34 return shared_page->vcpu_ioreq[i].vp_eport;
35}
36static inline ioreq_t *xen_vcpu_ioreq(shared_iopage_t *shared_page, int vcpu)
37{
38 return &shared_page->vcpu_ioreq[vcpu];
39}
40
41#define BUFFER_IO_MAX_DELAY 100
42
43typedef struct XenPhysmap {
44 hwaddr start_addr;
45 ram_addr_t size;
46 const char *name;
47 hwaddr phys_offset;
48
49 QLIST_ENTRY(XenPhysmap) list;
50} XenPhysmap;
51
52typedef struct XenPciDevice {
53 PCIDevice *pci_dev;
54 uint32_t sbdf;
55 QLIST_ENTRY(XenPciDevice) entry;
56} XenPciDevice;
57
58typedef struct XenIOState {
59 ioservid_t ioservid;
60 shared_iopage_t *shared_page;
61 buffered_iopage_t *buffered_io_page;
62 xenforeignmemory_resource_handle *fres;
63 QEMUTimer *buffered_io_timer;
64 CPUState **cpu_by_vcpu_id;
65 /* the evtchn port for polling the notification, */
66 evtchn_port_t *ioreq_local_port;
67 /* evtchn remote and local ports for buffered io */
68 evtchn_port_t bufioreq_remote_port;
69 evtchn_port_t bufioreq_local_port;
70 /* the evtchn fd for polling */
71 xenevtchn_handle *xce_handle;
72 /* which vcpu we are serving */
73 int send_vcpu;
74
75 struct xs_handle *xenstore;
76 MemoryListener memory_listener;
77 MemoryListener io_listener;
78 QLIST_HEAD(, XenPciDevice) dev_list;
79 DeviceListener device_listener;
80
81 Notifier exit;
82} XenIOState;
83
84void xen_exit_notifier(Notifier *n, void *data);
85
86void xen_region_add(MemoryListener *listener, MemoryRegionSection *section);
87void xen_region_del(MemoryListener *listener, MemoryRegionSection *section);
88void xen_io_add(MemoryListener *listener, MemoryRegionSection *section);
89void xen_io_del(MemoryListener *listener, MemoryRegionSection *section);
90void xen_device_realize(DeviceListener *listener, DeviceState *dev);
91void xen_device_unrealize(DeviceListener *listener, DeviceState *dev);
92
93void xen_hvm_change_state_handler(void *opaque, bool running, RunState rstate);
94void xen_register_ioreq(XenIOState *state, unsigned int max_cpus,
bcb40db0 95 const MemoryListener *xen_memory_listener);
f17068c1
SS
96
97void cpu_ioreq_pio(ioreq_t *req);
98#endif /* HW_XEN_HVM_COMMON_H */