Commit c4857498 authored by Alon Levy's avatar Alon Levy

xspice: add init_qxl_ram

parent 0848656d
......@@ -1321,6 +1321,8 @@ qxl_pre_init(ScrnInfoPtr pScrn, int flags)
#ifndef XSPICE
if (!qxl_check_device(pScrn, qxl))
goto out;
#else
init_qxl_ram(qxl); /* initialize the rings */
#endif
pScrn->videoRam = (qxl->rom->num_pages * 4096) / 1024;
xf86DrvMsg(scrnIndex, X_INFO, "%d KB of video RAM\n", pScrn->videoRam);
......
......@@ -5,6 +5,55 @@
#include "qxl.h"
#include "spiceqxl_io_port.h"
/* TODO: taken from qemu qxl.c, try to remove dupplication */
#undef SPICE_RING_PROD_ITEM
#define SPICE_RING_PROD_ITEM(r, ret) { \
typeof(r) start = r; \
typeof(r) end = r + 1; \
uint32_t prod = (r)->prod & SPICE_RING_INDEX_MASK(r); \
typeof(&(r)->items[prod]) m_item = &(r)->items[prod]; \
if (!((uint8_t*)m_item >= (uint8_t*)(start) && (uint8_t*)(m_item + 1) <= (uint8_t*)(end))) { \
abort(); \
} \
ret = &m_item->el; \
}
#undef SPICE_RING_CONS_ITEM
#define SPICE_RING_CONS_ITEM(r, ret) { \
typeof(r) start = r; \
typeof(r) end = r + 1; \
uint32_t cons = (r)->cons & SPICE_RING_INDEX_MASK(r); \
typeof(&(r)->items[cons]) m_item = &(r)->items[cons]; \
if (!((uint8_t*)m_item >= (uint8_t*)(start) && (uint8_t*)(m_item + 1) <= (uint8_t*)(end))) { \
abort(); \
} \
ret = &m_item->el; \
}
static int spiceqxl_io_port_debug_level = 5;
#define dprint(_level, _fmt, ...) \
do { \
if (spiceqxl_io_port_debug_level >= _level) { \
fprintf(stderr, _fmt, ## __VA_ARGS__); \
} \
} while (0)
void init_qxl_ram(qxl_screen_t *qxl)
{
QXLRam *ram = get_ram_header(qxl);
uint64_t *item;
ram->magic = QXL_RAM_MAGIC;
ram->int_pending = 0;
ram->int_mask = 0;
SPICE_RING_INIT(&ram->cmd_ring);
SPICE_RING_INIT(&ram->cursor_ring);
SPICE_RING_INIT(&ram->release_ring);
SPICE_RING_PROD_ITEM(&ram->release_ring, item);
*item = 0;
}
/* called from Xorg thread - not worker thread! */
void ioport_write(qxl_screen_t *qxl, uint32_t io_port, uint32_t val)
{
......
......@@ -3,4 +3,8 @@
#include "qxl.h"
/* used to initialize the rings before the first reset, avoid a valgrind
* warning */
void init_qxl_ram(qxl_screen_t *qxl);
#endif // SPICEQXL_IO_PORT_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment