2
0

qxl.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. #ifndef HW_QXL_H
  2. #define HW_QXL_H 1
  3. #include "qemu-common.h"
  4. #include "ui/console.h"
  5. #include "hw/hw.h"
  6. #include "hw/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. #define QXL_PAGE_BITS 12
  23. #define QXL_PAGE_SIZE (1 << QXL_PAGE_BITS);
  24. typedef struct PCIQXLDevice {
  25. PCIDevice pci;
  26. SimpleSpiceDisplay ssd;
  27. int id;
  28. uint32_t debug;
  29. uint32_t guestdebug;
  30. uint32_t cmdlog;
  31. uint32_t guest_bug;
  32. enum qxl_mode mode;
  33. uint32_t cmdflags;
  34. int generation;
  35. uint32_t revision;
  36. int32_t num_memslots;
  37. uint32_t current_async;
  38. QemuMutex async_lock;
  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. 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. QemuMutex track_lock;
  64. /* thread signaling */
  65. QEMUBH *update_irq;
  66. /* ram pci bar */
  67. QXLRam *ram;
  68. VGACommonState vga;
  69. uint32_t num_free_res;
  70. QXLReleaseInfo *last_release;
  71. uint32_t last_release_offset;
  72. uint32_t oom_running;
  73. uint32_t vgamem_size;
  74. /* rom pci bar */
  75. QXLRom shadow_rom;
  76. QXLRom *rom;
  77. QXLModes *modes;
  78. uint32_t rom_size;
  79. MemoryRegion rom_bar;
  80. /* vram pci bar */
  81. uint32_t vram_size;
  82. MemoryRegion vram_bar;
  83. uint32_t vram32_size;
  84. MemoryRegion vram32_bar;
  85. /* io bar */
  86. MemoryRegion io_bar;
  87. /* user-friendly properties (in megabytes) */
  88. uint32_t ram_size_mb;
  89. uint32_t vram_size_mb;
  90. uint32_t vram32_size_mb;
  91. uint32_t vgamem_size_mb;
  92. /* qxl_render_update state */
  93. int render_update_cookie_num;
  94. int num_dirty_rects;
  95. QXLRect dirty[QXL_NUM_DIRTY_RECTS];
  96. QEMUBH *update_area_bh;
  97. } PCIQXLDevice;
  98. #define PANIC_ON(x) if ((x)) { \
  99. printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \
  100. abort(); \
  101. }
  102. #define dprint(_qxl, _level, _fmt, ...) \
  103. do { \
  104. if (_qxl->debug >= _level) { \
  105. fprintf(stderr, "qxl-%d: ", _qxl->id); \
  106. fprintf(stderr, _fmt, ## __VA_ARGS__); \
  107. } \
  108. } while (0)
  109. #define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V12
  110. /* qxl.c */
  111. void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
  112. void qxl_set_guest_bug(PCIQXLDevice *qxl, const char *msg, ...)
  113. GCC_FMT_ATTR(2, 3);
  114. void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
  115. struct QXLRect *area, struct QXLRect *dirty_rects,
  116. uint32_t num_dirty_rects,
  117. uint32_t clear_dirty_region,
  118. qxl_async_io async, QXLCookie *cookie);
  119. void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
  120. uint32_t count);
  121. void qxl_spice_oom(PCIQXLDevice *qxl);
  122. void qxl_spice_reset_memslots(PCIQXLDevice *qxl);
  123. void qxl_spice_reset_image_cache(PCIQXLDevice *qxl);
  124. void qxl_spice_reset_cursor(PCIQXLDevice *qxl);
  125. /* qxl-logger.c */
  126. int qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id);
  127. int qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext);
  128. /* qxl-render.c */
  129. void qxl_render_resize(PCIQXLDevice *qxl);
  130. void qxl_render_update(PCIQXLDevice *qxl);
  131. int qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext);
  132. void qxl_render_update_area_done(PCIQXLDevice *qxl, QXLCookie *cookie);
  133. void qxl_render_update_area_bh(void *opaque);
  134. #endif