Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 1 | #include "qemu-common.h" |
| 2 | |
| 3 | #include "console.h" |
| 4 | #include "hw.h" |
| 5 | #include "pci.h" |
| 6 | #include "vga_int.h" |
Jan Kiszka | 691f5c7 | 2011-09-20 17:14:40 +0200 | [diff] [blame] | 7 | #include "qemu-thread.h" |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 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 | |
Alon Levy | 5ff4e36 | 2011-07-20 12:20:58 +0300 | [diff] [blame] | 19 | #define QXL_UNDEFINED_IO UINT32_MAX |
| 20 | |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 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 | |
Alon Levy | 5ff4e36 | 2011-07-20 12:20:58 +0300 | [diff] [blame] | 36 | uint32_t current_async; |
| 37 | QemuMutex async_lock; |
| 38 | |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 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; |
Gerd Hoffmann | 0e2487b | 2011-10-21 15:59:07 +0200 | [diff] [blame] | 51 | int32_t qxl_stride; |
| 52 | uint32_t abs_stride; |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 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 | |
Gerd Hoffmann | 14898cf | 2011-07-20 12:20:53 +0300 | [diff] [blame] | 65 | QemuMutex track_lock; |
| 66 | |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 67 | /* thread signaling */ |
Jan Kiszka | 691f5c7 | 2011-09-20 17:14:40 +0200 | [diff] [blame] | 68 | QemuThread main; |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 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; |
Avi Kivity | b195043 | 2011-08-08 16:08:57 +0300 | [diff] [blame] | 84 | MemoryRegion rom_bar; |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 85 | |
| 86 | /* vram pci bar */ |
| 87 | uint32_t vram_size; |
Avi Kivity | b195043 | 2011-08-08 16:08:57 +0300 | [diff] [blame] | 88 | MemoryRegion vram_bar; |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 89 | |
| 90 | /* io bar */ |
Avi Kivity | b195043 | 2011-08-08 16:08:57 +0300 | [diff] [blame] | 91 | MemoryRegion io_bar; |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 92 | } PCIQXLDevice; |
| 93 | |
| 94 | #define PANIC_ON(x) if ((x)) { \ |
| 95 | printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \ |
Gerd Hoffmann | 2bce040 | 2011-07-20 12:20:55 +0300 | [diff] [blame] | 96 | abort(); \ |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 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 | |
Gerd Hoffmann | 9197a7c | 2011-07-20 12:21:00 +0300 | [diff] [blame] | 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 | |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 113 | /* qxl.c */ |
| 114 | void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id); |
Alon Levy | 7635392 | 2011-07-20 12:20:56 +0300 | [diff] [blame] | 115 | void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...); |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 116 | |
Gerd Hoffmann | aee32bf | 2011-07-20 12:20:52 +0300 | [diff] [blame] | 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, |
Alon Levy | 5ff4e36 | 2011-07-20 12:20:58 +0300 | [diff] [blame] | 120 | uint32_t clear_dirty_region, |
| 121 | qxl_async_io async); |
Gerd Hoffmann | aee32bf | 2011-07-20 12:20:52 +0300 | [diff] [blame] | 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); |
Gerd Hoffmann | aee32bf | 2011-07-20 12:20:52 +0300 | [diff] [blame] | 126 | void qxl_spice_reset_image_cache(PCIQXLDevice *qxl); |
| 127 | void qxl_spice_reset_cursor(PCIQXLDevice *qxl); |
| 128 | |
Gerd Hoffmann | a19cbfb | 2010-04-27 11:50:11 +0200 | [diff] [blame] | 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); |
Alon Levy | 5ff4e36 | 2011-07-20 12:20:58 +0300 | [diff] [blame] | 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 |