linux-user: stack_base is now mandatory on all targets
[qemu.git] / hw / qxl.h
1 #include "qemu-common.h"
2
3 #include "console.h"
4 #include "hw.h"
5 #include "pci.h"
6 #include "vga_int.h"
7 #include "qemu-thread.h"
8
9 #include "ui/qemu-spice.h"
10 #include "ui/spice-display.h"
11
12 enum qxl_mode {
13 QXL_MODE_UNDEFINED,
14 QXL_MODE_VGA,
15 QXL_MODE_COMPAT, /* spice 0.4.x */
16 QXL_MODE_NATIVE,
17 };
18
19 #define QXL_UNDEFINED_IO UINT32_MAX
20
21 typedef struct PCIQXLDevice {
22 PCIDevice pci;
23 SimpleSpiceDisplay ssd;
24 int id;
25 uint32_t debug;
26 uint32_t guestdebug;
27 uint32_t cmdlog;
28 enum qxl_mode mode;
29 uint32_t cmdflags;
30 int generation;
31 uint32_t revision;
32
33 int32_t num_memslots;
34 int32_t num_surfaces;
35
36 uint32_t current_async;
37 QemuMutex async_lock;
38
39 struct guest_slots {
40 QXLMemSlot slot;
41 void *ptr;
42 uint64_t size;
43 uint64_t delta;
44 uint32_t active;
45 } guest_slots[NUM_MEMSLOTS];
46
47 struct guest_primary {
48 QXLSurfaceCreate surface;
49 uint32_t commands;
50 uint32_t resized;
51 int32_t qxl_stride;
52 uint32_t abs_stride;
53 uint32_t bits_pp;
54 uint32_t bytes_pp;
55 uint8_t *data, *flipped;
56 } guest_primary;
57
58 struct surfaces {
59 QXLPHYSICAL cmds[NUM_SURFACES];
60 uint32_t count;
61 uint32_t max;
62 } guest_surfaces;
63 QXLPHYSICAL guest_cursor;
64
65 QemuMutex track_lock;
66
67 /* thread signaling */
68 QemuThread main;
69 int pipe[2];
70
71 /* ram pci bar */
72 QXLRam *ram;
73 VGACommonState vga;
74 uint32_t num_free_res;
75 QXLReleaseInfo *last_release;
76 uint32_t last_release_offset;
77 uint32_t oom_running;
78
79 /* rom pci bar */
80 QXLRom shadow_rom;
81 QXLRom *rom;
82 QXLModes *modes;
83 uint32_t rom_size;
84 MemoryRegion rom_bar;
85
86 /* vram pci bar */
87 uint32_t vram_size;
88 MemoryRegion vram_bar;
89
90 /* io bar */
91 MemoryRegion io_bar;
92 } PCIQXLDevice;
93
94 #define PANIC_ON(x) if ((x)) { \
95 printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \
96 abort(); \
97 }
98
99 #define dprint(_qxl, _level, _fmt, ...) \
100 do { \
101 if (_qxl->debug >= _level) { \
102 fprintf(stderr, "qxl-%d: ", _qxl->id); \
103 fprintf(stderr, _fmt, ## __VA_ARGS__); \
104 } \
105 } while (0)
106
107 #if SPICE_INTERFACE_QXL_MINOR >= 1
108 #define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V10
109 #else
110 #define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V06
111 #endif
112
113 /* qxl.c */
114 void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
115 void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...);
116
117 void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
118 struct QXLRect *area, struct QXLRect *dirty_rects,
119 uint32_t num_dirty_rects,
120 uint32_t clear_dirty_region,
121 qxl_async_io async);
122 void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
123 uint32_t count);
124 void qxl_spice_oom(PCIQXLDevice *qxl);
125 void qxl_spice_reset_memslots(PCIQXLDevice *qxl);
126 void qxl_spice_reset_image_cache(PCIQXLDevice *qxl);
127 void qxl_spice_reset_cursor(PCIQXLDevice *qxl);
128
129 /* qxl-logger.c */
130 void qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id);
131 void qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext);
132
133 /* qxl-render.c */
134 void qxl_render_resize(PCIQXLDevice *qxl);
135 void qxl_render_update(PCIQXLDevice *qxl);
136 void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext);
137 #if SPICE_INTERFACE_QXL_MINOR >= 1
138 void qxl_spice_update_area_async(PCIQXLDevice *qxl, uint32_t surface_id,
139 struct QXLRect *area,
140 uint32_t clear_dirty_region,
141 int is_vga);
142 #endif