2
0

qxl.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #ifndef HW_QXL_H
  2. #define HW_QXL_H
  3. #include "hw/pci/pci.h"
  4. #include "vga_int.h"
  5. #include "qemu/thread.h"
  6. #include "ui/qemu-spice.h"
  7. #include "ui/spice-display.h"
  8. enum qxl_mode {
  9. QXL_MODE_UNDEFINED,
  10. QXL_MODE_VGA,
  11. QXL_MODE_COMPAT, /* spice 0.4.x */
  12. QXL_MODE_NATIVE,
  13. };
  14. #ifndef QXL_VRAM64_RANGE_INDEX
  15. #define QXL_VRAM64_RANGE_INDEX 4
  16. #endif
  17. #define QXL_UNDEFINED_IO UINT32_MAX
  18. #define QXL_NUM_DIRTY_RECTS 64
  19. #define QXL_PAGE_BITS 12
  20. #define QXL_PAGE_SIZE (1 << QXL_PAGE_BITS);
  21. typedef struct PCIQXLDevice {
  22. PCIDevice pci;
  23. PortioList vga_port_list;
  24. SimpleSpiceDisplay ssd;
  25. int id;
  26. bool have_vga;
  27. uint32_t debug;
  28. uint32_t guestdebug;
  29. uint32_t cmdlog;
  30. uint32_t guest_bug;
  31. Error *migration_blocker;
  32. enum qxl_mode mode;
  33. uint32_t cmdflags;
  34. uint32_t revision;
  35. int32_t num_memslots;
  36. uint32_t current_async;
  37. QemuMutex async_lock;
  38. struct guest_slots {
  39. QXLMemSlot slot;
  40. MemoryRegion *mr;
  41. uint64_t offset;
  42. uint64_t size;
  43. uint64_t delta;
  44. uint32_t active;
  45. } guest_slots[NUM_MEMSLOTS];
  46. struct guest_primary {
  47. QXLSurfaceCreate surface;
  48. uint32_t commands;
  49. uint32_t resized;
  50. int32_t qxl_stride;
  51. uint32_t abs_stride;
  52. uint32_t bits_pp;
  53. uint32_t bytes_pp;
  54. uint8_t *data;
  55. } guest_primary;
  56. struct surfaces {
  57. QXLPHYSICAL *cmds;
  58. uint32_t count;
  59. uint32_t max;
  60. } guest_surfaces;
  61. QXLPHYSICAL guest_cursor;
  62. QXLPHYSICAL guest_monitors_config;
  63. uint32_t guest_head0_width;
  64. uint32_t guest_head0_height;
  65. QemuMutex track_lock;
  66. /* thread signaling */
  67. QEMUBH *update_irq;
  68. /* ram pci bar */
  69. QXLRam *ram;
  70. VGACommonState vga;
  71. uint32_t num_free_res;
  72. QXLReleaseInfo *last_release;
  73. uint32_t last_release_offset;
  74. uint32_t oom_running;
  75. uint32_t vgamem_size;
  76. /* rom pci bar */
  77. QXLRom shadow_rom;
  78. QXLRom *rom;
  79. QXLModes *modes;
  80. uint32_t rom_size;
  81. MemoryRegion rom_bar;
  82. #if SPICE_SERVER_VERSION >= 0x000c06 /* release 0.12.6 */
  83. uint16_t max_outputs;
  84. #endif
  85. /* vram pci bar */
  86. uint64_t vram_size;
  87. MemoryRegion vram_bar;
  88. uint64_t vram32_size;
  89. MemoryRegion vram32_bar;
  90. /* io bar */
  91. MemoryRegion io_bar;
  92. /* user-friendly properties (in megabytes) */
  93. uint32_t ram_size_mb;
  94. uint32_t vram_size_mb;
  95. uint32_t vram32_size_mb;
  96. uint32_t vgamem_size_mb;
  97. uint32_t xres;
  98. uint32_t yres;
  99. /* qxl_render_update state */
  100. int render_update_cookie_num;
  101. int num_dirty_rects;
  102. QXLRect dirty[QXL_NUM_DIRTY_RECTS];
  103. QEMUBH *update_area_bh;
  104. } PCIQXLDevice;
  105. #define TYPE_PCI_QXL "pci-qxl"
  106. #define PCI_QXL(obj) OBJECT_CHECK(PCIQXLDevice, (obj), TYPE_PCI_QXL)
  107. #define PANIC_ON(x) if ((x)) { \
  108. printf("%s: PANIC %s failed\n", __func__, #x); \
  109. abort(); \
  110. }
  111. #define dprint(_qxl, _level, _fmt, ...) \
  112. do { \
  113. if (_qxl->debug >= _level) { \
  114. fprintf(stderr, "qxl-%d: ", _qxl->id); \
  115. fprintf(stderr, _fmt, ## __VA_ARGS__); \
  116. } \
  117. } while (0)
  118. #define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V12
  119. /* qxl.c */
  120. void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
  121. void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
  122. GCC_FMT_ATTR(2, 3);
  123. void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
  124. struct QXLRect *area, struct QXLRect *dirty_rects,
  125. uint32_t num_dirty_rects,
  126. uint32_t clear_dirty_region,
  127. qxl_async_io async, QXLCookie *cookie);
  128. void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
  129. uint32_t count);
  130. void qxl_spice_oom(PCIQXLDevice *qxl);
  131. void qxl_spice_reset_memslots(PCIQXLDevice *qxl);
  132. void qxl_spice_reset_image_cache(PCIQXLDevice *qxl);
  133. void qxl_spice_reset_cursor(PCIQXLDevice *qxl);
  134. /* qxl-logger.c */
  135. int qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id);
  136. int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext);
  137. /* qxl-render.c */
  138. void qxl_render_resize(PCIQXLDevice *qxl);
  139. void qxl_render_update(PCIQXLDevice *qxl);
  140. int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext);
  141. void qxl_render_update_area_done(PCIQXLDevice *qxl, QXLCookie *cookie);
  142. void qxl_render_update_area_bh(void *opaque);
  143. #endif