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