summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-03-02 13:44:57 -0800
committerEric Anholt <eric@anholt.net>2007-03-02 13:44:57 -0800
commitfd52d635603b7093c5a2b7fa9c987cf59f9be27c (patch)
treefa25a303689b73a88b6798e7fe7e9c3bf46fa5a4 /src/common.h
parentca0fa875e8bb5cb778d4db7d8053ec0a5ae34ef4 (diff)
Add a WIP UploadToScreen implementation. This almost displays right.
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h
index 8f42bde8..6e8ddbda 100644
--- a/src/common.h
+++ b/src/common.h
@@ -131,6 +131,43 @@ extern void I830DPRINTF_stub(const char *filename, int line,
outring &= ringmask; \
} while (0)
+static inline void memset_volatile(volatile void *b, int c, size_t len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ ((volatile char *)b)[i] = c;
+}
+
+static inline void memcpy_volatile(volatile void *dst, const void *src,
+ size_t len)
+{
+ int i;
+
+ for (i = 0; i < len; i++)
+ ((volatile char *)dst)[i] = ((volatile char *)src)[i];
+}
+
+/** Copies a given number of bytes to the ring */
+#define OUT_RING_COPY(n, ptr) do { \
+ if (I810_DEBUG & DEBUG_VERBOSE_RING) \
+ ErrorF("OUT_RING_DATA %d bytes\n", n); \
+ memcpy_volatile(virt + outring, ptr, n); \
+ outring += n; \
+ ringused += n; \
+ outring &= ringmask; \
+} while (0)
+
+/** Pads the ring with a given number of zero bytes */
+#define OUT_RING_PAD(n) do { \
+ if (I810_DEBUG & DEBUG_VERBOSE_RING) \
+ ErrorF("OUT_RING_PAD %d bytes\n", n); \
+ memset_volatile(virt + outring, 0, n); \
+ outring += n; \
+ ringused += n; \
+ outring &= ringmask; \
+} while (0)
+
union intfloat {
float f;
unsigned int ui;