diff options
author | Eric Anholt <anholt@freebsd.org> | 2004-05-11 04:43:43 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2004-05-11 04:43:43 +0000 |
commit | 853adb8be338de113301d7db3c10058476f3bff7 (patch) | |
tree | 22ce0530d9c01993cdeea67c381fcd31a12fe673 | |
parent | 485b259b4492ed6b7abdf063d1d5cefe01d3a3b0 (diff) |
Merge from FreeBSD-current. Mostly 64-bit cleanliness fixes, but a few
driver interface changes from -current.
-rw-r--r-- | bsd-core/drm_drv.c | 21 | ||||
-rw-r--r-- | bsd-core/drm_irq.c | 4 | ||||
-rw-r--r-- | bsd-core/drm_os_freebsd.h | 14 | ||||
-rw-r--r-- | bsd-core/drm_vm.c | 2 | ||||
-rw-r--r-- | bsd/drm_drv.h | 21 | ||||
-rw-r--r-- | bsd/drm_irq.h | 4 | ||||
-rw-r--r-- | bsd/drm_os_freebsd.h | 14 | ||||
-rw-r--r-- | bsd/drm_vm.h | 2 | ||||
-rw-r--r-- | shared-core/sis_ds.h | 2 | ||||
-rw-r--r-- | shared-core/sis_mm.c | 6 | ||||
-rw-r--r-- | shared/sis_ds.h | 2 | ||||
-rw-r--r-- | shared/sis_mm.c | 6 |
12 files changed, 66 insertions, 32 deletions
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c index 4fa785a8..8ad130a3 100644 --- a/bsd-core/drm_drv.c +++ b/bsd-core/drm_drv.c @@ -211,6 +211,9 @@ const char *DRM(find_description)(int vendor, int device); #ifdef __FreeBSD__ static struct cdevsw DRM(cdevsw) = { +#if __FreeBSD_version >= 502103 + .d_version = D_VERSION, +#endif .d_open = DRM( open ), .d_close = DRM( close ), .d_read = DRM( read ), @@ -218,8 +221,12 @@ static struct cdevsw DRM(cdevsw) = { .d_poll = DRM( poll ), .d_mmap = DRM( mmap ), .d_name = DRIVER_NAME, - .d_maj = CDEV_MAJOR, - .d_flags = D_TTY | D_TRACKCLOSE, +#if __FreeBSD_version >= 502103 + .d_flags = D_TRACKCLOSE | D_NEEDGIANT, +#else + .d_maj = 145, + .d_flags = D_TRACKCLOSE, +#endif #if __FreeBSD_version < 500000 .d_bmaj = -1 #endif @@ -830,7 +837,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) drm_file_t *priv; DRM_DEVICE; int retcode = 0; - DRMFILE filp = (void *)(DRM_CURRENTPID); + DRMFILE filp = (void *)(uintptr_t)(DRM_CURRENTPID); DRM_DEBUG( "open_count = %d\n", dev->open_count ); @@ -908,7 +915,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) } } #elif __HAVE_DMA - DRM(reclaim_buffers)( dev, (void *)priv->pid ); + DRM(reclaim_buffers)( dev, (void *)(uintptr_t)priv->pid ); #endif #if defined (__FreeBSD__) && (__FreeBSD_version >= 500000) @@ -953,7 +960,7 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags, int nr = DRM_IOCTL_NR(cmd); drm_file_t *priv; - DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID); + DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)(uintptr_t)DRM_CURRENTPID); atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] ); ++priv->ioctl_count; @@ -1008,7 +1015,7 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags, !priv->authenticated)) return EACCES; - retcode = func(kdev, cmd, data, flags, p, (void *)DRM_CURRENTPID); + retcode = func(kdev, cmd, data, flags, p, (void *)(uintptr_t)DRM_CURRENTPID); return DRM_ERR(retcode); } @@ -1039,7 +1046,7 @@ int DRM(lock)( DRM_IOCTL_ARGS ) DRM_LOCK(); for (;;) { if (DRM(lock_take)(&dev->lock.hw_lock->lock, lock.context)) { - dev->lock.filp = (void *)DRM_CURRENTPID; + dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID; dev->lock.lock_time = jiffies; atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); break; /* Got lock */ diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c index 418e697e..eec6ab93 100644 --- a/bsd-core/drm_irq.c +++ b/bsd-core/drm_irq.c @@ -97,8 +97,8 @@ int DRM(irq_install)(drm_device_t *dev) /* Install handler */ #ifdef __FreeBSD__ dev->irqrid = 0; - dev->irqr = bus_alloc_resource(dev->device, SYS_RES_IRQ, &dev->irqrid, - 0, ~0, 1, RF_SHAREABLE); + dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ, + &dev->irqrid, RF_SHAREABLE); if (!dev->irqr) { retcode = ENOENT; goto err; diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h index 06079555..073ceb37 100644 --- a/bsd-core/drm_os_freebsd.h +++ b/bsd-core/drm_os_freebsd.h @@ -114,7 +114,6 @@ #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) #define DRM_DEV_UID 0 #define DRM_DEV_GID 0 -#define CDEV_MAJOR 145 #if __FreeBSD_version >= 500000 #define DRM_CURPROC curthread @@ -179,7 +178,7 @@ typedef void irqreturn_t; #define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \ do { \ - if (_filp != (DRMFILE)DRM_CURRENTPID) { \ + if (_filp != (DRMFILE)(intptr_t)DRM_CURRENTPID) { \ DRM_ERROR("filp doesn't match curproc\n"); \ return EINVAL; \ } \ @@ -292,6 +291,12 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \ #define DRM_READMEMORYBARRIER() alpha_mb(); #define DRM_WRITEMEMORYBARRIER() alpha_wmb(); #define DRM_MEMORYBARRIER() alpha_mb(); +#elif defined(__amd64__) +#define DRM_READMEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%rsp)" : : : "memory"); +#define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); +#define DRM_MEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%rsp)" : : : "memory"); #endif #define PAGE_ALIGN(addr) round_page(addr) @@ -305,6 +310,11 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \ MALLOC_DECLARE(malloctype); #undef malloctype +#if __FreeBSD_version < 502109 +#define bus_alloc_resource_any(dev, type, rid, flags) \ + bus_alloc_resource(dev, type, rid, 0ul, ~0ul, 1, flags) +#endif + #if __FreeBSD_version >= 480000 #define cpu_to_le32(x) htole32(x) #define le32_to_cpu(x) le32toh(x) diff --git a/bsd-core/drm_vm.c b/bsd-core/drm_vm.c index e4ae8c7e..6f0c01ea 100644 --- a/bsd-core/drm_vm.c +++ b/bsd-core/drm_vm.c @@ -65,7 +65,7 @@ paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot) drm_map_list_entry_t *listentry = NULL; drm_file_t *priv; - DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID); + DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)(uintptr_t)DRM_CURRENTPID); if (!priv->authenticated) return DRM_ERR(EACCES); diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h index 4fa785a8..8ad130a3 100644 --- a/bsd/drm_drv.h +++ b/bsd/drm_drv.h @@ -211,6 +211,9 @@ const char *DRM(find_description)(int vendor, int device); #ifdef __FreeBSD__ static struct cdevsw DRM(cdevsw) = { +#if __FreeBSD_version >= 502103 + .d_version = D_VERSION, +#endif .d_open = DRM( open ), .d_close = DRM( close ), .d_read = DRM( read ), @@ -218,8 +221,12 @@ static struct cdevsw DRM(cdevsw) = { .d_poll = DRM( poll ), .d_mmap = DRM( mmap ), .d_name = DRIVER_NAME, - .d_maj = CDEV_MAJOR, - .d_flags = D_TTY | D_TRACKCLOSE, +#if __FreeBSD_version >= 502103 + .d_flags = D_TRACKCLOSE | D_NEEDGIANT, +#else + .d_maj = 145, + .d_flags = D_TRACKCLOSE, +#endif #if __FreeBSD_version < 500000 .d_bmaj = -1 #endif @@ -830,7 +837,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) drm_file_t *priv; DRM_DEVICE; int retcode = 0; - DRMFILE filp = (void *)(DRM_CURRENTPID); + DRMFILE filp = (void *)(uintptr_t)(DRM_CURRENTPID); DRM_DEBUG( "open_count = %d\n", dev->open_count ); @@ -908,7 +915,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) } } #elif __HAVE_DMA - DRM(reclaim_buffers)( dev, (void *)priv->pid ); + DRM(reclaim_buffers)( dev, (void *)(uintptr_t)priv->pid ); #endif #if defined (__FreeBSD__) && (__FreeBSD_version >= 500000) @@ -953,7 +960,7 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags, int nr = DRM_IOCTL_NR(cmd); drm_file_t *priv; - DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID); + DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)(uintptr_t)DRM_CURRENTPID); atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] ); ++priv->ioctl_count; @@ -1008,7 +1015,7 @@ int DRM(ioctl)(dev_t kdev, u_long cmd, caddr_t data, int flags, !priv->authenticated)) return EACCES; - retcode = func(kdev, cmd, data, flags, p, (void *)DRM_CURRENTPID); + retcode = func(kdev, cmd, data, flags, p, (void *)(uintptr_t)DRM_CURRENTPID); return DRM_ERR(retcode); } @@ -1039,7 +1046,7 @@ int DRM(lock)( DRM_IOCTL_ARGS ) DRM_LOCK(); for (;;) { if (DRM(lock_take)(&dev->lock.hw_lock->lock, lock.context)) { - dev->lock.filp = (void *)DRM_CURRENTPID; + dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID; dev->lock.lock_time = jiffies; atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); break; /* Got lock */ diff --git a/bsd/drm_irq.h b/bsd/drm_irq.h index 418e697e..eec6ab93 100644 --- a/bsd/drm_irq.h +++ b/bsd/drm_irq.h @@ -97,8 +97,8 @@ int DRM(irq_install)(drm_device_t *dev) /* Install handler */ #ifdef __FreeBSD__ dev->irqrid = 0; - dev->irqr = bus_alloc_resource(dev->device, SYS_RES_IRQ, &dev->irqrid, - 0, ~0, 1, RF_SHAREABLE); + dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ, + &dev->irqrid, RF_SHAREABLE); if (!dev->irqr) { retcode = ENOENT; goto err; diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index 06079555..073ceb37 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -114,7 +114,6 @@ #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) #define DRM_DEV_UID 0 #define DRM_DEV_GID 0 -#define CDEV_MAJOR 145 #if __FreeBSD_version >= 500000 #define DRM_CURPROC curthread @@ -179,7 +178,7 @@ typedef void irqreturn_t; #define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \ do { \ - if (_filp != (DRMFILE)DRM_CURRENTPID) { \ + if (_filp != (DRMFILE)(intptr_t)DRM_CURRENTPID) { \ DRM_ERROR("filp doesn't match curproc\n"); \ return EINVAL; \ } \ @@ -292,6 +291,12 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \ #define DRM_READMEMORYBARRIER() alpha_mb(); #define DRM_WRITEMEMORYBARRIER() alpha_wmb(); #define DRM_MEMORYBARRIER() alpha_mb(); +#elif defined(__amd64__) +#define DRM_READMEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%rsp)" : : : "memory"); +#define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); +#define DRM_MEMORYBARRIER() __asm __volatile( \ + "lock; addl $0,0(%%rsp)" : : : "memory"); #endif #define PAGE_ALIGN(addr) round_page(addr) @@ -305,6 +310,11 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \ MALLOC_DECLARE(malloctype); #undef malloctype +#if __FreeBSD_version < 502109 +#define bus_alloc_resource_any(dev, type, rid, flags) \ + bus_alloc_resource(dev, type, rid, 0ul, ~0ul, 1, flags) +#endif + #if __FreeBSD_version >= 480000 #define cpu_to_le32(x) htole32(x) #define le32_to_cpu(x) le32toh(x) diff --git a/bsd/drm_vm.h b/bsd/drm_vm.h index e4ae8c7e..6f0c01ea 100644 --- a/bsd/drm_vm.h +++ b/bsd/drm_vm.h @@ -65,7 +65,7 @@ paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot) drm_map_list_entry_t *listentry = NULL; drm_file_t *priv; - DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)DRM_CURRENTPID); + DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)(uintptr_t)DRM_CURRENTPID); if (!priv->authenticated) return DRM_ERR(EACCES); diff --git a/shared-core/sis_ds.h b/shared-core/sis_ds.h index 482693fe..bbd3fe1b 100644 --- a/shared-core/sis_ds.h +++ b/shared-core/sis_ds.h @@ -35,7 +35,7 @@ #define SET_SIZE 5000 -typedef unsigned int ITEM_TYPE; +typedef unsigned long ITEM_TYPE; typedef struct { ITEM_TYPE val; diff --git a/shared-core/sis_mm.c b/shared-core/sis_mm.c index 092096c4..7b10db97 100644 --- a/shared-core/sis_mm.c +++ b/shared-core/sis_mm.c @@ -371,7 +371,7 @@ int sis_final_context(int context) if (i < MAX_CONTEXT) { set_t *set; - unsigned int item; + ITEM_TYPE item; int retval; DRM_DEBUG("find socket %d, context = %d\n", i, context); @@ -380,7 +380,7 @@ int sis_final_context(int context) set = global_ppriv[i].sets[0]; retval = setFirst(set, &item); while (retval) { - DRM_DEBUG("free video memory 0x%x\n", item); + DRM_DEBUG("free video memory 0x%lx\n", item); #if defined(__linux__) && defined(CONFIG_FB_SIS) sis_free(item); #else @@ -394,7 +394,7 @@ int sis_final_context(int context) set = global_ppriv[i].sets[1]; retval = setFirst(set, &item); while (retval) { - DRM_DEBUG("free agp memory 0x%x\n", item); + DRM_DEBUG("free agp memory 0x%lx\n", item); mmFreeMem((PMemBlock)item); retval = setNext(set, &item); } diff --git a/shared/sis_ds.h b/shared/sis_ds.h index 482693fe..bbd3fe1b 100644 --- a/shared/sis_ds.h +++ b/shared/sis_ds.h @@ -35,7 +35,7 @@ #define SET_SIZE 5000 -typedef unsigned int ITEM_TYPE; +typedef unsigned long ITEM_TYPE; typedef struct { ITEM_TYPE val; diff --git a/shared/sis_mm.c b/shared/sis_mm.c index 092096c4..7b10db97 100644 --- a/shared/sis_mm.c +++ b/shared/sis_mm.c @@ -371,7 +371,7 @@ int sis_final_context(int context) if (i < MAX_CONTEXT) { set_t *set; - unsigned int item; + ITEM_TYPE item; int retval; DRM_DEBUG("find socket %d, context = %d\n", i, context); @@ -380,7 +380,7 @@ int sis_final_context(int context) set = global_ppriv[i].sets[0]; retval = setFirst(set, &item); while (retval) { - DRM_DEBUG("free video memory 0x%x\n", item); + DRM_DEBUG("free video memory 0x%lx\n", item); #if defined(__linux__) && defined(CONFIG_FB_SIS) sis_free(item); #else @@ -394,7 +394,7 @@ int sis_final_context(int context) set = global_ppriv[i].sets[1]; retval = setFirst(set, &item); while (retval) { - DRM_DEBUG("free agp memory 0x%x\n", item); + DRM_DEBUG("free agp memory 0x%lx\n", item); mmFreeMem((PMemBlock)item); retval = setNext(set, &item); } |