qxl.h 4.1 KB
Newer Older
G
Gerd Hoffmann 已提交
1 2 3 4 5 6
#include "qemu-common.h"

#include "console.h"
#include "hw.h"
#include "pci.h"
#include "vga_int.h"
J
Jan Kiszka 已提交
7
#include "qemu-thread.h"
G
Gerd Hoffmann 已提交
8 9 10 11 12 13 14 15 16 17 18

#include "ui/qemu-spice.h"
#include "ui/spice-display.h"

enum qxl_mode {
    QXL_MODE_UNDEFINED,
    QXL_MODE_VGA,
    QXL_MODE_COMPAT, /* spice 0.4.x */
    QXL_MODE_NATIVE,
};

19 20
#define QXL_UNDEFINED_IO UINT32_MAX

G
Gerd Hoffmann 已提交
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
typedef struct PCIQXLDevice {
    PCIDevice          pci;
    SimpleSpiceDisplay ssd;
    int                id;
    uint32_t           debug;
    uint32_t           guestdebug;
    uint32_t           cmdlog;
    enum qxl_mode      mode;
    uint32_t           cmdflags;
    int                generation;
    uint32_t           revision;

    int32_t            num_memslots;
    int32_t            num_surfaces;

36 37 38
    uint32_t           current_async;
    QemuMutex          async_lock;

G
Gerd Hoffmann 已提交
39 40 41 42 43 44 45 46 47 48 49 50
    struct guest_slots {
        QXLMemSlot     slot;
        void           *ptr;
        uint64_t       size;
        uint64_t       delta;
        uint32_t       active;
    } guest_slots[NUM_MEMSLOTS];

    struct guest_primary {
        QXLSurfaceCreate surface;
        uint32_t       commands;
        uint32_t       resized;
G
Gerd Hoffmann 已提交
51 52
        int32_t        qxl_stride;
        uint32_t       abs_stride;
G
Gerd Hoffmann 已提交
53 54
        uint32_t       bits_pp;
        uint32_t       bytes_pp;
A
Alon Levy 已提交
55
        uint8_t        *data;
G
Gerd Hoffmann 已提交
56 57 58 59 60 61 62 63 64
    } guest_primary;

    struct surfaces {
        QXLPHYSICAL    cmds[NUM_SURFACES];
        uint32_t       count;
        uint32_t       max;
    } guest_surfaces;
    QXLPHYSICAL        guest_cursor;

65 66
    QemuMutex          track_lock;

G
Gerd Hoffmann 已提交
67
    /* thread signaling */
J
Jan Kiszka 已提交
68
    QemuThread         main;
G
Gerd Hoffmann 已提交
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
    int                pipe[2];

    /* ram pci bar */
    QXLRam             *ram;
    VGACommonState     vga;
    uint32_t           num_free_res;
    QXLReleaseInfo     *last_release;
    uint32_t           last_release_offset;
    uint32_t           oom_running;

    /* rom pci bar */
    QXLRom             shadow_rom;
    QXLRom             *rom;
    QXLModes           *modes;
    uint32_t           rom_size;
84
    MemoryRegion       rom_bar;
G
Gerd Hoffmann 已提交
85 86 87

    /* vram pci bar */
    uint32_t           vram_size;
88
    MemoryRegion       vram_bar;
G
Gerd Hoffmann 已提交
89 90

    /* io bar */
91
    MemoryRegion       io_bar;
92 93 94 95

    /* user-friendly properties (in megabytes) */
    uint32_t          ram_size_mb;
    uint32_t          vram_size_mb;
G
Gerd Hoffmann 已提交
96 97 98 99
} PCIQXLDevice;

#define PANIC_ON(x) if ((x)) {                         \
    printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \
100
    abort();                                           \
G
Gerd Hoffmann 已提交
101 102 103 104 105 106 107 108 109 110
}

#define dprint(_qxl, _level, _fmt, ...)                                 \
    do {                                                                \
        if (_qxl->debug >= _level) {                                    \
            fprintf(stderr, "qxl-%d: ", _qxl->id);                      \
            fprintf(stderr, _fmt, ## __VA_ARGS__);                      \
        }                                                               \
    } while (0)

G
Gerd Hoffmann 已提交
111 112
#define QXL_DEFAULT_REVISION QXL_REVISION_STABLE_V10

G
Gerd Hoffmann 已提交
113 114
/* qxl.c */
void *qxl_phys2virt(PCIQXLDevice *qxl, QXLPHYSICAL phys, int group_id);
115
void qxl_guest_bug(PCIQXLDevice *qxl, const char *msg, ...);
G
Gerd Hoffmann 已提交
116

G
Gerd Hoffmann 已提交
117 118 119
void qxl_spice_update_area(PCIQXLDevice *qxl, uint32_t surface_id,
                           struct QXLRect *area, struct QXLRect *dirty_rects,
                           uint32_t num_dirty_rects,
120
                           uint32_t clear_dirty_region,
A
Alon Levy 已提交
121
                           qxl_async_io async, QXLCookie *cookie);
G
Gerd Hoffmann 已提交
122 123 124 125 126 127 128
void qxl_spice_loadvm_commands(PCIQXLDevice *qxl, struct QXLCommandExt *ext,
                               uint32_t count);
void qxl_spice_oom(PCIQXLDevice *qxl);
void qxl_spice_reset_memslots(PCIQXLDevice *qxl);
void qxl_spice_reset_image_cache(PCIQXLDevice *qxl);
void qxl_spice_reset_cursor(PCIQXLDevice *qxl);

G
Gerd Hoffmann 已提交
129 130 131 132 133 134 135 136
/* qxl-logger.c */
void qxl_log_cmd_cursor(PCIQXLDevice *qxl, QXLCursorCmd *cmd, int group_id);
void qxl_log_command(PCIQXLDevice *qxl, const char *ring, QXLCommandExt *ext);

/* qxl-render.c */
void qxl_render_resize(PCIQXLDevice *qxl);
void qxl_render_update(PCIQXLDevice *qxl);
void qxl_render_cursor(PCIQXLDevice *qxl, QXLCommandExt *ext);