qxl.h 4.8 KB

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