From b9bbc2157fd98e1546d40570423a63dcc78ebf07 Mon Sep 17 00:00:00 2001 From: mrg Date: Sun, 29 Mar 2009 17:00:50 +0000 Subject: [PATCH] add a comment explaining DRM_NETBSD_ADDR2HANDLE/DRM_NETBSD_HANDLE2ADDR: * This hack strips the top bit from amd64 addresses, which avoid * udv_attach() returning NULL for "negative" offset. * A better hack would be to encode the offset of some kernel data * structure.. add a new DRM_HANDLE_NEEDS_MASK macro to check whether the above need to be applied for various mapping types (_DRM_SHM and _DRM_SCATTER_GATHER.) --- sys/dev/drm/drmP.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/sys/dev/drm/drmP.h b/sys/dev/drm/drmP.h index 3ffce87690a8..91bf07d3b53f 100644 --- a/sys/dev/drm/drmP.h +++ b/sys/dev/drm/drmP.h @@ -1,4 +1,4 @@ -/* $NetBSD: drmP.h,v 1.32 2008/07/07 00:33:23 mrg Exp $ */ +/* $NetBSD: drmP.h,v 1.33 2009/03/29 17:00:50 mrg Exp $ */ /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com @@ -313,12 +313,20 @@ extern drm_device_t *drm_units[]; #define DRM_DEVICE \ drm_device_t *dev = (minor(kdev) < DRM_MAXUNITS) ? \ drm_units[minor(kdev)] : NULL -#ifdef __x86_64__ -#define DRM_NETBSD_ADDR2HANDLE(addr) (addr & 0x7fffffffffffffff) -#define DRM_NETBSD_HANDLE2ADDR(handle) (handle | 0x8000000000000000) +/* + * This hack strips the top bit from amd64 addresses, which avoid + * udv_attach() returning NULL for "negative" offset. + * A better hack would be to encode the offset of some kernel data + * structure.. + */ +#if defined(__x86_64__) && 1 +#define DRM_NETBSD_ADDR2HANDLE(addr) ((addr) & 0x7fffffffffffffff) +#define DRM_NETBSD_HANDLE2ADDR(handle) ((handle) | 0x8000000000000000) +#define DRM_HANDLE_NEEDS_MASK(type) ((type) == _DRM_SHM || (type) == _DRM_SCATTER_GATHER) #else #define DRM_NETBSD_ADDR2HANDLE(addr) (addr) #define DRM_NETBSD_HANDLE2ADDR(handle) (handle) +#define DRM_HANDLE_NEEDS_MASK(type) 0 #endif #elif defined(__OpenBSD__) #define DRM_DEVICE \