#include "mm.h"
#include "libdrm_lists.h"
+/* Support gcc's __FUNCTION__ for people using other compilers */
+#if !defined(__GNUC__) && !defined(__FUNCTION__)
+# define __FUNCTION__ __func__ /* C99 */
+#endif
+
#define DBG(...) do { \
if (bufmgr_fake->bufmgr.debug) \
drmMsg(__VA_ARGS__); \
return;
}
- DBG("wait 0x%08x\n", iw.irq_seq);
-
iw.irq_seq = seq;
+ DBG("wait 0x%08x\n", iw.irq_seq);
+
/* The kernel IRQ_WAIT implementation is all sorts of broken.
* 1) It returns 1 to 0x7fffffff instead of using the full 32-bit
* unsigned range.
bo_fake->backing_store = malloc(bo->size);
- DBG("alloc_backing - buf %d %p %d\n", bo_fake->id,
+ DBG("alloc_backing - buf %d %p %lu\n", bo_fake->id,
bo_fake->backing_store, bo->size);
assert(bo_fake->backing_store);
}
if (alloc_block(bo))
return 1;
- DBG("%s 0x%x bytes failed\n", __FUNCTION__, bo->size);
+ DBG("%s 0x%lx bytes failed\n", __FUNCTION__, bo->size);
return 0;
}
bo_fake->flags = 0;
bo_fake->is_static = 0;
- DBG("drm_bo_alloc: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
+ DBG("drm_bo_alloc: (buf %d: %s, %lu kb)\n", bo_fake->id, bo_fake->name,
bo_fake->bo.size / 1024);
return &bo_fake->bo;
bo_fake->flags = BM_PINNED;
bo_fake->is_static = 1;
- DBG("drm_bo_alloc_static: (buf %d: %s, %d kb)\n", bo_fake->id,
+ DBG("drm_bo_alloc_static: (buf %d: %s, %lu kb)\n", bo_fake->id,
bo_fake->name, bo_fake->bo.size / 1024);
return &bo_fake->bo;
return 0;
{
- DBG("drm_bo_map: (buf %d: %s, %d kb)\n", bo_fake->id,
+ DBG("drm_bo_map: (buf %d: %s, %lu kb)\n", bo_fake->id,
bo_fake->name, bo_fake->bo.size / 1024);
if (bo->virtual != NULL) {
if (--bo_fake->map_count != 0)
return 0;
- DBG("drm_bo_unmap: (buf %d: %s, %d kb)\n", bo_fake->id, bo_fake->name,
+ DBG("drm_bo_unmap: (buf %d: %s, %lu kb)\n", bo_fake->id, bo_fake->name,
bo_fake->bo.size / 1024);
bo->virtual = NULL;
return ret;
}
+static int
+drm_intel_fake_bo_subdata(drm_intel_bo *bo, unsigned long offset,
+ unsigned long size, const void *data)
+{
+ int ret;
+
+ if (size == 0 || data == NULL)
+ return 0;
+
+ ret = drm_intel_bo_map(bo, 1);
+ if (ret)
+ return ret;
+ memcpy((unsigned char *)bo->virtual + offset, data, size);
+ drm_intel_bo_unmap(bo);
+ return 0;
+}
+
static void
drm_intel_fake_kick_all_locked(drm_intel_bufmgr_fake *bufmgr_fake)
{
bufmgr_fake = (drm_intel_bufmgr_fake *) bo->bufmgr;
- DBG("drm_bo_validate: (buf %d: %s, %d kb)\n", bo_fake->id,
+ DBG("drm_bo_validate: (buf %d: %s, %lu kb)\n", bo_fake->id,
bo_fake->name, bo_fake->bo.size / 1024);
/* Sanity check: Buffers should be unmapped before being validated.
/* Upload the buffer contents if necessary */
if (bo_fake->dirty) {
- DBG("Upload dirty buf %d:%s, sz %d offset 0x%x\n", bo_fake->id,
+ DBG("Upload dirty buf %d:%s, sz %lu offset 0x%x\n", bo_fake->id,
bo_fake->name, bo->size, bo_fake->block->mem->ofs);
assert(!(bo_fake->flags & (BM_NO_BACKING_STORE | BM_PINNED)));
}
if (sz > bufmgr_fake->size) {
- DBG("check_space: overflowed bufmgr size, %dkb vs %dkb\n",
+ DBG("check_space: overflowed bufmgr size, %ukb vs %lukb\n",
sz / 1024, bufmgr_fake->size / 1024);
return -1;
}
- DBG("drm_check_space: sz %dkb vs bufgr %dkb\n", sz / 1024,
+ DBG("drm_check_space: sz %ukb vs bufgr %lukb\n", sz / 1024,
bufmgr_fake->size / 1024);
return 0;
}
bufmgr_fake->bufmgr.bo_unreference = drm_intel_fake_bo_unreference;
bufmgr_fake->bufmgr.bo_map = drm_intel_fake_bo_map;
bufmgr_fake->bufmgr.bo_unmap = drm_intel_fake_bo_unmap;
+ bufmgr_fake->bufmgr.bo_subdata = drm_intel_fake_bo_subdata;
bufmgr_fake->bufmgr.bo_wait_rendering =
drm_intel_fake_bo_wait_rendering;
bufmgr_fake->bufmgr.bo_emit_reloc = drm_intel_fake_emit_reloc;