return 0;
}
+#ifdef __linux__
+
int drmFenceCreate(int fd, int shareable, int class,unsigned type,
int emit,
drmFence *fence)
return 0;
}
-static unsigned long drmUL(drm_u64_t val)
-{
- unsigned long ret = val.lo;
- if (sizeof(ret) == 8) {
- int shift = 32;
- ret |= (val.hi << shift);
- }
- return ret;
-}
-
-static drm_u64_t drmU64(unsigned long val)
-{
- drm_u64_t ret;
- ret.lo = val & 0xFFFFFFFFUL;
- if (sizeof(val) == 8) {
- int shift = 32;
- ret.hi = val >> shift;
- } else {
- ret.hi = 0;
- }
- return ret;
-}
-
int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags)
{
drm_ttm_arg_t arg;
arg.op = drm_ttm_create;
arg.flags = flags;
- arg.size = drmU64(size);
+ arg.size = size;
if (ioctl(fd, DRM_IOCTL_TTM, &arg))
return -errno;
ttm->handle = arg.handle;
ttm->user_token = (drm_handle_t) arg.user_token;
ttm->flags = arg.flags;
- ttm->size = drmUL(arg.size);
+ ttm->size = arg.size;
return 0;
}
ttm->handle = arg.handle;
ttm->user_token = (drm_handle_t) arg.user_token;
ttm->flags = arg.flags;
- ttm->size = drmUL(arg.size);
+ ttm->size = arg.size;
return 0;
}
(void) fd;
return ttm->user_token;
}
+#endif
drm_ttm_object_t *ttm_object;
drm_ttm_backend_list_t *ttm_region;
void __user *user_pages;
+ unsigned long num_pages;
atomic_t mapped;
-
uint32_t flags;
uint32_t mask;
uint32_t mask_hint;
extern int drm_bo_ioctl(DRM_IOCTL_ARGS);
-/*
- * Convenience drm_u64_t functions
- */
-
-static __inline__ unsigned long drm_ul(drm_u64_t val)
-{
- unsigned long ret = val.lo;
-#if (BITS_PER_LONG == 64)
- ret |= (val.hi << 32);
-#endif
- return ret;
-}
-
-static __inline__ drm_u64_t drm_u64(unsigned long val)
-{
- drm_u64_t ret;
-
- ret.lo = val & 0xFFFFFFFFUL;
-#if (BITS_PER_LONG == 64)
- ret.hi = val >> 32;
-#else
- ret.hi = 0;
-#endif
- return ret;
-}
-
/* Inline replacements for DRM_IOREMAP macros */
static __inline__ void drm_core_ioremap(struct drm_map *map,
return 0;
}
+
int drm_buffer_object_create(drm_file_t *priv,
int size,
drm_bo_type_t type,
drm_buffer_object_t *bo;
int ret = 0;
uint32_t ttm_flags = 0;
+ drm_ttm_t *ttm;
bo = drm_calloc(1, sizeof(*bo), DRM_MEM_BUFOBJ);
goto out_err;
break;
case drm_bo_type_ttm:
+ if (buffer_start & ~PAGE_MASK) {
+ DRM_ERROR("Illegal buffer object start\n");
+ ret = -EINVAL;
+ }
+ bo->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ if (!bo->num_pages) {
+ DRM_ERROR("Illegal buffer object size\n");
+ ret = -EINVAL;
+ goto out_err;
+ }
bo->ttm_object = drm_lookup_ttm_object(priv, ttm_handle, 1);
+ if (!bo->ttm_object) {
+ DRM_ERROR("Could not find buffer object TTM\n");
+ ret = -EINVAL;
+ goto out_err;
+ }
+ ttm = drm_ttm_from_object(bo->ttm_object);
+ ret = drm_create_ttm_region(ttm, buffer_start >> PAGE_SHIFT,
+ bo->num_pages, 0, &bo->ttm_region);
if (ret)
goto out_err;
break;
case drm_bo_type_user:
+ if (buffer_start & ~PAGE_MASK) {
+ DRM_ERROR("Illegal buffer object start\n");
+ ret = -EINVAL;
+ goto out_err;
+ }
+ bo->num_pages = (size + PAGE_SIZE - 1) >> PAGE_SHIFT;
bo->user_pages = (void __user *)buffer_start;
break;
default:
rep.handled = 0;
switch (req->op) {
case drm_bo_create: {
- unsigned long buffer_start = drm_ul(req->buffer_start);
- rep.ret = drm_buffer_object_create(priv, drm_ul(req->size),
+ unsigned long buffer_start = req->buffer_start;
+ rep.ret = drm_buffer_object_create(priv, req->size,
req->type, req->arg_handle,
req->mask, req->hint,
buffer_start,
default:
rep.ret = -EINVAL;
}
- next = drm_ul(req->next);
+ next = req->next;
rep.handled = 1;
arg.rep = rep;
DRM_COPY_TO_USER_IOCTL((void __user *)data, arg, sizeof(arg));
switch(arg.op) {
case drm_ttm_create:
mutex_lock(&dev->struct_mutex);
- size = drm_ul(arg.size);
+ size = arg.size;
ret = drm_ttm_object_create(dev, size, arg.flags, &entry);
if (ret) {
mutex_unlock(&dev->struct_mutex);
}
arg.handle = entry->base.hash.key;
arg.user_token = entry->map_list.user_token;
- arg.size = drm_u64(entry->map_list.map->size);
+ arg.size = entry->map_list.map->size;
drm_ttm_object_deref_locked(dev, entry);
mutex_unlock(&dev->struct_mutex);
extern void drm_ttm_delete_mm(drm_ttm_t * ttm, struct mm_struct *mm);
extern int drm_ttm_ioctl(DRM_IOCTL_ARGS);
+static __inline__ drm_ttm_t *drm_ttm_from_object(drm_ttm_object_t *to)
+{
+ return (drm_ttm_t *) to->map_list.map->offset;
+}
+
#define DRM_MASK_VAL(dest, mask, val) \
(dest) = ((dest) & ~(mask)) | ((val) & (mask));
#define _DRM_LOCKING_CONTEXT(lock) ((lock) & ~(_DRM_LOCK_HELD|_DRM_LOCK_CONT))
#if defined(__linux__)
+#if defined(__KERNEL__)
+typedef __u64 drm_u64_t;
+#else
+typedef unsigned long long drm_u64_t;
+#endif
+
typedef unsigned int drm_handle_t;
#else
typedef unsigned long drm_handle_t; /**< To mapped regions */
int drm_dd_minor;
} drm_set_version_t;
-typedef struct drm_u64{
- unsigned lo;
- unsigned hi;
-}drm_u64_t;
+#ifdef __linux__
#define DRM_FENCE_FLAG_EMIT 0x00000001
#define DRM_FENCE_FLAG_SHAREABLE 0x00000002
drm_bo_arg_request_t req;
drm_bo_arg_reply_t rep;
} drm_bo_arg_t;
-
+#endif
/**
* \name Ioctls Definitions
#define DRM_IOCTL_WAIT_VBLANK DRM_IOWR(0x3a, drm_wait_vblank_t)
+#ifdef __linux__
#define DRM_IOCTL_FENCE DRM_IOWR(0x3b, drm_fence_arg_t)
#define DRM_IOCTL_TTM DRM_IOWR(0x3c, drm_ttm_arg_t)
+#endif
/*@}*/