diff options
author | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2006-08-28 09:49:09 +0200 |
---|---|---|
committer | Thomas Hellstrom <thomas-at-tungstengraphics-dot-com> | 2006-08-28 09:49:09 +0200 |
commit | e181f594a4a75790ce1d2a8e907f9fcc5e88b419 (patch) | |
tree | 02465a6eb22dfe2271c0b345275275ebe9dff305 | |
parent | 4ddabd15620e6e4638a6a37a3a2b5bced626fcf9 (diff) |
Add a 64-bit drm unsigned type for 64-bit clean IOCTLS.
Conversion functions in drmP.h and xf86drm.c.
-rw-r--r-- | libdrm/xf86drm.c | 22 | ||||
-rw-r--r-- | libdrm/xf86drm.h | 2 | ||||
-rw-r--r-- | linux-core/drmP.h | 19 | ||||
-rw-r--r-- | linux-core/drm_ttm.c | 4 | ||||
-rw-r--r-- | shared-core/drm.h | 69 |
5 files changed, 56 insertions, 60 deletions
diff --git a/libdrm/xf86drm.c b/libdrm/xf86drm.c index 88676083..06c64303 100644 --- a/libdrm/xf86drm.c +++ b/libdrm/xf86drm.c @@ -2362,25 +2362,27 @@ int drmFenceWait(int fd, drmFence *fence, unsigned flush_type, return 0; } -static unsigned long combine64(unsigned lo, unsigned hi) +static unsigned long drmUL(drm_u64_t val) { - unsigned long ret = lo; + unsigned long ret = val.lo; if (sizeof(ret) == 8) { int shift = 32; - ret |= (hi << shift); + ret |= (val.hi << shift); } return ret; } -static void split32(unsigned long val, unsigned *lo, unsigned *hi) +static drm_u64_t drmU64(unsigned long val) { - *lo = val & 0xFFFFFFFFUL; + drm_u64_t ret; + ret.lo = val & 0xFFFFFFFFUL; if (sizeof(val) == 8) { int shift = 32; - *hi = val >> shift; + ret.hi = val >> shift; } else { - *hi = 0; + ret.hi = 0; } + return ret; } int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags) @@ -2389,7 +2391,7 @@ int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags) arg.op = drm_ttm_create; arg.flags = flags; - split32((unsigned long) size, &arg.size_lo, &arg.size_hi); + arg.size = drmU64(size); if (ioctl(fd, DRM_IOCTL_TTM, &arg)) return -errno; @@ -2397,7 +2399,7 @@ int drmTTMCreate(int fd, drmTTM *ttm, unsigned long size, unsigned flags) ttm->handle = arg.handle; ttm->user_token = (drm_handle_t) arg.user_token; ttm->flags = arg.flags; - ttm->size = combine64(arg.size_lo, arg.size_hi); + ttm->size = drmUL(arg.size); return 0; } @@ -2424,7 +2426,7 @@ int drmTTMReference(int fd, unsigned handle, drmTTM *ttm) ttm->handle = arg.handle; ttm->user_token = (drm_handle_t) arg.user_token; ttm->flags = arg.flags; - ttm->size = combine64(arg.size_lo, arg.size_hi); + ttm->size = drmUL(arg.size); return 0; } diff --git a/libdrm/xf86drm.h b/libdrm/xf86drm.h index 433191b4..58cbd16c 100644 --- a/libdrm/xf86drm.h +++ b/libdrm/xf86drm.h @@ -497,6 +497,8 @@ do { register unsigned int __old __asm("o0"); \ } \ } while(0) + + /* General user-level programmer's API: unprivileged */ extern int drmAvailable(void); extern int drmOpen(const char *name, const char *busid); diff --git a/linux-core/drmP.h b/linux-core/drmP.h index 2997293b..81f08dfc 100644 --- a/linux-core/drmP.h +++ b/linux-core/drmP.h @@ -1359,26 +1359,29 @@ extern int drm_fence_ioctl(DRM_IOCTL_ARGS); extern int drm_bo_ioctl(DRM_IOCTL_ARGS); /* - * Convenience 2*32-bit to 64-bit function + * Convenience drm_u64_t functions */ -static __inline__ unsigned long combine_64(uint32_t lo, uint32_t hi) +static __inline__ unsigned long drm_ul(drm_u64_t val) { - unsigned long ret = lo; + unsigned long ret = val.lo; #if (BITS_PER_LONG == 64) - ret |= (hi << 32); + ret |= (val.hi << 32); #endif return ret; } -static __inline__ void split_32(unsigned long val, uint32_t *lo, uint32_t *hi) +static __inline__ drm_u64_t drm_u64(unsigned long val) { - *lo = val & 0xFFFFFFFFUL; + drm_u64_t ret; + + ret.lo = val & 0xFFFFFFFFUL; #if (BITS_PER_LONG == 64) - *hi = val >> 32; + ret.hi = val >> 32; #else - *hi = 0; + ret.hi = 0; #endif + return ret; } diff --git a/linux-core/drm_ttm.c b/linux-core/drm_ttm.c index ad7b279e..e76b41fb 100644 --- a/linux-core/drm_ttm.c +++ b/linux-core/drm_ttm.c @@ -865,7 +865,7 @@ int drm_ttm_ioctl(DRM_IOCTL_ARGS) switch(arg.op) { case drm_ttm_create: mutex_lock(&dev->struct_mutex); - size = combine_64(arg.size_lo, arg.size_hi); + size = drm_ul(arg.size); ret = drm_ttm_object_create(dev, size, arg.flags, &entry); if (ret) { mutex_unlock(&dev->struct_mutex); @@ -903,7 +903,7 @@ int drm_ttm_ioctl(DRM_IOCTL_ARGS) } arg.handle = entry->base.hash.key; arg.user_token = entry->map_list.user_token; - split_32(entry->map_list.map->size, &arg.size_lo, &arg.size_hi); + arg.size = drm_u64(entry->map_list.map->size); atomic_dec(&entry->usage); mutex_unlock(&dev->struct_mutex); diff --git a/shared-core/drm.h b/shared-core/drm.h index 726a5140..7133eb8f 100644 --- a/shared-core/drm.h +++ b/shared-core/drm.h @@ -630,6 +630,11 @@ typedef struct drm_set_version { int drm_dd_minor; } drm_set_version_t; +typedef struct drm_u64{ + unsigned lo; + unsigned hi; +}drm_u64_t; + #define DRM_FENCE_FLAG_EMIT 0x00000001 #define DRM_FENCE_FLAG_SHAREABLE 0x00000002 #define DRM_FENCE_FLAG_WAIT_LAZY 0x00000004 @@ -655,6 +660,22 @@ typedef struct drm_fence_arg { } op; } drm_fence_arg_t; +#define DRM_TTM_FLAG_SHAREABLE 0x00000001 + +typedef struct drm_ttm_arg { + enum { + drm_ttm_create, + drm_ttm_destroy, + drm_ttm_reference, + drm_ttm_unreference + } op; + unsigned handle; + unsigned user_token; + drm_u64_t size; + unsigned flags; +}drm_ttm_arg_t; + + #define DRM_BO_FLAG_READ 0x00000001 #define DRM_BO_FLAG_WRITE 0x00000002 #define DRM_BO_FLAG_EXE 0x00000004 @@ -674,43 +695,12 @@ typedef struct drm_fence_arg { #define DRM_BO_HINT_AVOID_LOCAL 0x00000002 #define DRM_BO_HINT_DONT_BLOCK 0x00000004 -/* - * Multiplexing ioctl argument. - */ - -typedef struct drm_bo_arg { - unsigned num_requests; - enum { - drm_op_bo, - drm_op_ttm - } op; - unsigned data_lo; - unsigned data_hi; -} drm_bo_arg_t; - -#define DRM_TTM_FLAG_SHAREABLE 0x00000001 - -typedef struct drm_ttm_arg { - enum { - drm_ttm_create, - drm_ttm_destroy, - drm_ttm_reference, - drm_ttm_unreference - } op; - unsigned handle; - unsigned user_token; - unsigned size_lo; - unsigned size_hi; - unsigned flags; -}drm_ttm_arg_t; - typedef struct drm_bo_arg_request { unsigned handle; /* User space handle */ unsigned mask; unsigned hint; - unsigned size_lo; - unsigned size_hi; + drm_u64_t size; enum { drm_bo_type_ttm, @@ -718,8 +708,8 @@ typedef struct drm_bo_arg_request { drm_bo_type_user }type; unsigned arg_handle; - unsigned user_pointer_lo; - unsigned user_pointer_hi; + drm_u64_t user_pointer; + drm_u64_t next; enum { drm_bo_create, drm_bo_validate, @@ -733,21 +723,20 @@ typedef struct drm_bo_arg_request { typedef struct drm_bo_arg_reply { int ret; + int handled; unsigned handle; unsigned flags; - unsigned size_lo; - unsigned size_hi; - unsigned offset_lo; - unsigned offset_hi; + drm_u64_t size; + drm_u64_t offset; unsigned arg_handle; unsigned map_flags; }drm_bo_arg_reply_t; -typedef union drm_bo_arg_data { +typedef union drm_bo_arg{ drm_bo_arg_request_t req; drm_bo_arg_reply_t rep; -} drm_bo_arg_data_t; +} drm_bo_arg_t; /** |