[Spice-devel] [RFC 29/33] xspice: add init_qxl_ram
Alon Levy
alevy at redhat.com
Wed Apr 27 08:56:18 PDT 2011
---
src/qxl_driver.c | 2 +
src/spiceqxl_io_port.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
src/spiceqxl_io_port.h | 4 +++
3 files changed, 55 insertions(+), 0 deletions(-)
diff --git a/src/qxl_driver.c b/src/qxl_driver.c
index fe2f532..ef3139b 100644
--- a/src/qxl_driver.c
+++ b/src/qxl_driver.c
@@ -1312,6 +1312,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);
diff --git a/src/spiceqxl_io_port.c b/src/spiceqxl_io_port.c
index 8a2ea03..ba6ac4a 100644
--- a/src/spiceqxl_io_port.c
+++ b/src/spiceqxl_io_port.c
@@ -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)
{
diff --git a/src/spiceqxl_io_port.h b/src/spiceqxl_io_port.h
index fc461b4..9ea8399 100644
--- a/src/spiceqxl_io_port.h
+++ b/src/spiceqxl_io_port.h
@@ -6,4 +6,8 @@
/* device to spice-server, now xspice to spice-server */
void ioport_write(qxl_screen_t *qxl, uint32_t io_port, uint32_t val);
+/* 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
--
1.7.4.4
More information about the Spice-devel
mailing list