aboutsummaryrefslogtreecommitdiff
path: root/bsd-core
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2003-02-21 23:23:09 +0000
committerEric Anholt <anholt@freebsd.org>2003-02-21 23:23:09 +0000
commitcfa778af9c70faea8c13e5cb7f80029eee0d074e (patch)
tree15483e64b6c2b56d3bb0f247df9df2c2602e0404 /bsd-core
parenta64472d18493de575a7636704b45babe7b4b4572 (diff)
Merge from bsd-4-0-0-branch.
Diffstat (limited to 'bsd-core')
-rw-r--r--bsd-core/Makefile2
-rw-r--r--bsd-core/ati_pcigart.c51
-rw-r--r--bsd-core/drmP.h33
-rw-r--r--bsd-core/drm_agpsupport.c36
-rw-r--r--bsd-core/drm_auth.c17
-rw-r--r--bsd-core/drm_bufs.c58
-rw-r--r--bsd-core/drm_context.c28
-rw-r--r--bsd-core/drm_dma.c23
-rw-r--r--bsd-core/drm_drv.c192
-rw-r--r--bsd-core/drm_fops.c5
-rw-r--r--bsd-core/drm_ioctl.c2
-rw-r--r--bsd-core/drm_lock.c22
-rw-r--r--bsd-core/drm_memory.c79
-rw-r--r--bsd-core/drm_os_freebsd.h72
-rw-r--r--bsd-core/drm_os_netbsd.h133
-rw-r--r--bsd-core/drm_scatter.c57
-rw-r--r--bsd-core/drm_sysctl.c4
-rw-r--r--bsd-core/drm_vm.c2
-rw-r--r--bsd-core/mga_drv.c6
-rw-r--r--bsd-core/r128_drv.c7
-rw-r--r--bsd-core/radeon_drv.c41
-rw-r--r--bsd-core/tdfx_drv.c5
22 files changed, 479 insertions, 396 deletions
diff --git a/bsd-core/Makefile b/bsd-core/Makefile
index ea44a7cd..6281b00c 100644
--- a/bsd-core/Makefile
+++ b/bsd-core/Makefile
@@ -1,6 +1,6 @@
# $FreeBSD$
# i810, i830 & sis are not complete
-SUBDIR = gamma mga r128 radeon tdfx # i810 i830 sis
+SUBDIR = mga r128 radeon tdfx # i810 i830 sis gamma
.include <bsd.subdir.mk>
diff --git a/bsd-core/ati_pcigart.c b/bsd-core/ati_pcigart.c
index 28723f56..ba0b81a7 100644
--- a/bsd-core/ati_pcigart.c
+++ b/bsd-core/ati_pcigart.c
@@ -42,25 +42,6 @@
# define ATI_MAX_PCIGART_PAGES 8192 /* 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */
-static unsigned long DRM(ati_alloc_pcigart_table)( void )
-{
- unsigned long address;
-
- DRM_DEBUG( "\n" );
-
- address = (unsigned long) malloc( (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM), M_WAITOK );
-
- DRM_DEBUG( "returning 0x%08lx\n", address );
- return address;
-}
-
-static void DRM(ati_free_pcigart_table)( unsigned long address )
-{
- DRM_DEBUG( "\n" );
-
- free( (void *)address, DRM(M_DRM));
-}
-
int DRM(ati_pcigart_init)( drm_device_t *dev,
unsigned long *addr,
dma_addr_t *bus_addr)
@@ -76,23 +57,15 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
goto done;
}
- address = DRM(ati_alloc_pcigart_table)();
+ address = (long)contigmalloc((1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
+ DRM(M_DRM), M_WAITOK, 0ul, 0xfffffffful, PAGE_SIZE, 0);
if ( !address ) {
DRM_ERROR( "cannot allocate PCI GART page!\n" );
goto done;
}
- /* FIXME non-vtophys==bustophys-arches */
+ /* XXX: we need to busdma this */
bus_address = vtophys( address );
- /*pci_map_single(dev->pdev, (void *)address,
- ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
- PCI_DMA_TODEVICE);*/
-/* if (bus_address == 0) {
- DRM_ERROR( "unable to map PCIGART pages!\n" );
- DRM(ati_free_pcigart_table)( (unsigned long)address );
- address = 0;
- goto done;
- }*/
pci_gart = (u32 *)address;
@@ -102,16 +75,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
bzero( pci_gart, ATI_MAX_PCIGART_PAGES * sizeof(u32) );
for ( i = 0 ; i < pages ; i++ ) {
- /* we need to support large memory configurations */
- /* FIXME non-vtophys==vtobus-arches */
entry->busaddr[i] = vtophys( entry->handle + (i*PAGE_SIZE) );
-/* if (entry->busaddr[i] == 0) {
- DRM_ERROR( "unable to map PCIGART pages!\n" );
- DRM(ati_pcigart_cleanup)( dev, (unsigned long)address, bus_address );
- address = 0;
- bus_address = 0;
- goto done;
- }*/
page_base = (u32) entry->busaddr[i];
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
@@ -122,8 +86,6 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
ret = 1;
- DRM_READMEMORYBARRIER();
-
done:
*addr = address;
*bus_addr = bus_address;
@@ -142,9 +104,8 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
return 0;
}
- if ( addr ) {
- DRM(ati_free_pcigart_table)( addr );
- }
-
+#if __FreeBSD_version > 500000
+ contigfree( (void *)addr, (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM)); /* Not available on 4.x */
+#endif
return 1;
}
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 541bc2eb..a4308f37 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -121,15 +121,15 @@ typedef struct drm_file drm_file_t;
/* Mapping helper macros */
#define DRM_IOREMAP(map) \
- (map)->handle = DRM(ioremap)( (map)->offset, (map)->size )
+ (map)->handle = DRM(ioremap)( dev, map )
#define DRM_IOREMAP_NOCACHE(map) \
- (map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size)
+ (map)->handle = DRM(ioremap_nocache)( dev, map )
#define DRM_IOREMAPFREE(map) \
do { \
if ( (map)->handle && (map)->size ) \
- DRM(ioremapfree)( (map)->handle, (map)->size ); \
+ DRM(ioremapfree)( map ); \
} while (0)
/* Internal types and structures */
@@ -377,7 +377,6 @@ typedef struct drm_sg_mem {
unsigned long handle;
void *virtual;
int pages;
- struct page **pagelist;
dma_addr_t *busaddr;
} drm_sg_mem_t;
@@ -386,10 +385,23 @@ typedef struct drm_sigdata {
drm_hw_lock_t *lock;
} drm_sigdata_t;
+typedef struct drm_local_map {
+ unsigned long offset; /* Physical address (0 for SAREA)*/
+ unsigned long size; /* Physical size (bytes) */
+ drm_map_type_t type; /* Type of memory mapped */
+ drm_map_flags_t flags; /* Flags */
+ void *handle; /* User-space: "Handle" to pass to mmap */
+ /* Kernel-space: kernel-virtual address */
+ int mtrr; /* MTRR slot used */
+ /* Private data */
+ bus_space_tag_t iot;
+ bus_space_handle_t ioh;
+} drm_local_map_t;
+
typedef TAILQ_HEAD(drm_map_list, drm_map_list_entry) drm_map_list_t;
typedef struct drm_map_list_entry {
TAILQ_ENTRY(drm_map_list_entry) link;
- drm_map_t *map;
+ drm_local_map_t *map;
} drm_map_list_entry_t;
TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig);
@@ -440,7 +452,7 @@ struct drm_device {
drm_map_list_t *maplist; /* Linked list of regions */
int map_count; /* Number of mappable regions */
- drm_map_t **context_sareas;
+ drm_local_map_t **context_sareas;
int max_context;
drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */
@@ -454,9 +466,9 @@ struct drm_device {
drm_device_dma_t *dma; /* Optional pointer for DMA support */
/* Context support */
-#ifdef __FreeBSD__
int irq; /* Interrupt used by board */
int irqrid; /* Interrupt used by board */
+#ifdef __FreeBSD__
struct resource *irqr; /* Resource for interrupt used by board */
#elif defined(__NetBSD__)
struct pci_attach_args pa;
@@ -530,15 +542,16 @@ extern int DRM(write_string)(drm_device_t *dev, const char *s);
/* Memory management support (drm_memory.h) */
extern void DRM(mem_init)(void);
+extern void DRM(mem_uninit)(void);
extern void *DRM(alloc)(size_t size, int area);
extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
int area);
extern char *DRM(strdup)(const char *s, int area);
extern void DRM(strfree)(char *s, int area);
extern void DRM(free)(void *pt, size_t size, int area);
-extern void *DRM(ioremap)(unsigned long offset, unsigned long size);
-extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size);
-extern void DRM(ioremapfree)(void *pt, unsigned long size);
+extern void *DRM(ioremap)(drm_device_t *dev, drm_local_map_t *map);
+extern void *DRM(ioremap_nocache)(drm_device_t *dev, drm_local_map_t *map);
+extern void DRM(ioremapfree)(drm_local_map_t *map);
#if __REALLY_HAVE_AGP
extern agp_memory *DRM(alloc_agp)(int pages, u32 type);
diff --git a/bsd-core/drm_agpsupport.c b/bsd-core/drm_agpsupport.c
index a940378e..1414569d 100644
--- a/bsd-core/drm_agpsupport.c
+++ b/bsd-core/drm_agpsupport.c
@@ -37,7 +37,8 @@ int DRM(agp_info)(DRM_IOCTL_ARGS)
struct agp_info *kern;
drm_agp_info_t info;
- if (!dev->agp || !dev->agp->acquired) return EINVAL;
+ if (!dev->agp || !dev->agp->acquired)
+ return EINVAL;
kern = &dev->agp->info;
agp_get_info(dev->agp->agpdev, kern);
@@ -60,9 +61,11 @@ int DRM(agp_acquire)(DRM_IOCTL_ARGS)
DRM_DEVICE;
int retcode;
- if (!dev->agp || dev->agp->acquired) return EINVAL;
+ if (!dev->agp || dev->agp->acquired)
+ return EINVAL;
retcode = agp_acquire(dev->agp->agpdev);
- if (retcode) return retcode;
+ if (retcode)
+ return retcode;
dev->agp->acquired = 1;
return 0;
}
@@ -93,7 +96,8 @@ int DRM(agp_enable)(DRM_IOCTL_ARGS)
DRM_DEVICE;
drm_agp_mode_t mode;
- if (!dev->agp || !dev->agp->acquired) return EINVAL;
+ if (!dev->agp || !dev->agp->acquired)
+ return EINVAL;
mode = *(drm_agp_mode_t *) data;
@@ -114,7 +118,8 @@ int DRM(agp_alloc)(DRM_IOCTL_ARGS)
u_int32_t type;
struct agp_memory_info info;
- if (!dev->agp || !dev->agp->acquired) return EINVAL;
+ if (!dev->agp || !dev->agp->acquired)
+ return EINVAL;
request = *(drm_agp_buffer_t *) data;
@@ -136,7 +141,8 @@ int DRM(agp_alloc)(DRM_IOCTL_ARGS)
entry->pages = pages;
entry->prev = NULL;
entry->next = dev->agp->memory;
- if (dev->agp->memory) dev->agp->memory->prev = entry;
+ if (dev->agp->memory)
+ dev->agp->memory->prev = entry;
dev->agp->memory = entry;
agp_memory_info(dev->agp->agpdev, entry->handle, &info);
@@ -166,7 +172,8 @@ int DRM(agp_unbind)(DRM_IOCTL_ARGS)
drm_agp_mem_t *entry;
int retcode;
- if (!dev->agp || !dev->agp->acquired) return EINVAL;
+ if (!dev->agp || !dev->agp->acquired)
+ return EINVAL;
request = *(drm_agp_binding_t *) data;
if (!(entry = DRM(agp_lookup_entry)(dev, (void *) request.handle)))
return EINVAL;
@@ -209,15 +216,20 @@ int DRM(agp_free)(DRM_IOCTL_ARGS)
drm_agp_buffer_t request;
drm_agp_mem_t *entry;
- if (!dev->agp || !dev->agp->acquired) return EINVAL;
+ if (!dev->agp || !dev->agp->acquired)
+ return EINVAL;
request = *(drm_agp_buffer_t *) data;
if (!(entry = DRM(agp_lookup_entry)(dev, (void*) request.handle)))
return EINVAL;
- if (entry->bound) DRM(unbind_agp)(entry->handle);
+ if (entry->bound)
+ DRM(unbind_agp)(entry->handle);
- if (entry->prev) entry->prev->next = entry->next;
- else dev->agp->memory = entry->next;
- if (entry->next) entry->next->prev = entry->prev;
+ if (entry->prev)
+ entry->prev->next = entry->next;
+ else
+ dev->agp->memory = entry->next;
+ if (entry->next)
+ entry->next->prev = entry->prev;
DRM(free_agp)(entry->handle, entry->pages);
DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return 0;
diff --git a/bsd-core/drm_auth.c b/bsd-core/drm_auth.c
index 0b411d14..a03cc918 100644
--- a/bsd-core/drm_auth.c
+++ b/bsd-core/drm_auth.c
@@ -116,25 +116,20 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
{
static drm_magic_t sequence = 0;
drm_auth_t auth;
- static DRM_SPINTYPE lock;
- static int first = 1;
DRM_DEVICE;
DRM_PRIV;
- if (first) {
- DRM_SPININIT(lock, "drm getmagic");
- first = 0;
- }
-
/* Find unique magic */
if (priv->magic) {
auth.magic = priv->magic;
} else {
do {
- DRM_SPINLOCK(&lock);
- if (!sequence) ++sequence; /* reserve 0 */
- auth.magic = sequence++;
- DRM_SPINUNLOCK(&lock);
+ int old = sequence;
+
+ auth.magic = old+1;
+
+ if (!atomic_cmpset_int(&sequence, old, auth.magic))
+ continue;
} while (DRM(find_file)(dev, auth.magic));
priv->magic = auth.magic;
DRM(add_magic)(dev, priv, auth.magic);
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index 7d56d0a3..89390b56 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -69,18 +69,26 @@ int DRM(order)( unsigned long size )
int DRM(addmap)( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
- drm_map_t *map;
+ drm_map_t request;
+ drm_local_map_t *map;
drm_map_list_entry_t *list;
if (!(dev->flags & (FREAD|FWRITE)))
return DRM_ERR(EACCES); /* Require read/write */
- map = (drm_map_t *) DRM(alloc)( sizeof(*map), DRM_MEM_MAPS );
+ DRM_COPY_FROM_USER_IOCTL( request, (drm_map_t *)data, sizeof(drm_map_t) );
+
+ map = (drm_local_map_t *) DRM(alloc)( sizeof(*map), DRM_MEM_MAPS );
if ( !map )
return DRM_ERR(ENOMEM);
- *map = *(drm_map_t *)data;
-
+ map->offset = request.offset;
+ map->size = request.size;
+ map->type = request.type;
+ map->flags = request.flags;
+ map->mtrr = -1;
+ map->handle = 0;
+
/* Only allow shared memory to be removable since we only keep enough
* book keeping information about shared memory to allow for removal
* when processes fork.
@@ -95,22 +103,14 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
return DRM_ERR(EINVAL);
}
- map->mtrr = -1;
- map->handle = 0;
switch ( map->type ) {
case _DRM_REGISTERS:
case _DRM_FRAME_BUFFER:
-#if !defined(__sparc__) && !defined(__alpha__)
- if ( map->offset + map->size < map->offset
- ) {
+ if ( map->offset + map->size < map->offset ) {
DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
return DRM_ERR(EINVAL);
}
-#endif
-#ifdef __alpha__
- map->offset += dev->hose->mem_space->start;
-#endif
#if __REALLY_HAVE_MTRR
if ( map->type == _DRM_FRAME_BUFFER ||
(map->flags & _DRM_WRITE_COMBINING) ) {
@@ -130,14 +130,12 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
mtrrmap.base = map->offset;
mtrrmap.len = map->size;
mtrrmap.type = MTRR_TYPE_WC;
- mtrrmap.flags = MTRR_PRIVATE | MTRR_VALID;
- mtrrmap.owner = p->p_pid;
- /* USER? KERNEL? XXX */
- map->mtrr = mtrr_get( &mtrrmap, &one, p, MTRR_GETSET_KERNEL );
+ mtrrmap.flags = MTRR_VALID;
+ map->mtrr = mtrr_set( &mtrrmap, &one, p, MTRR_GETSET_KERNEL );
#endif
}
#endif /* __REALLY_HAVE_MTRR */
- map->handle = DRM(ioremap)( map->offset, map->size );
+ DRM_IOREMAP(map);
break;
case _DRM_SHM:
@@ -155,9 +153,6 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
break;
#if __REALLY_HAVE_AGP
case _DRM_AGP:
-#ifdef __alpha__
- map->offset += dev->hose->mem_space->start;
-#endif
map->offset += dev->agp->base;
map->mtrr = dev->agp->agp_mtrr; /* for getmap */
break;
@@ -187,11 +182,19 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
TAILQ_INSERT_TAIL(dev->maplist, list, link);
DRM_UNLOCK;
- *(drm_map_t *)data = *map;
+ request.offset = map->offset;
+ request.size = map->size;
+ request.type = map->type;
+ request.flags = map->flags;
+ request.mtrr = map->mtrr;
+ request.handle = map->handle;
- if ( map->type != _DRM_SHM ) {
- ((drm_map_t *)data)->handle = (void *)map->offset;
+ if ( request.type != _DRM_SHM ) {
+ request.handle = (void *)request.offset;
}
+
+ DRM_COPY_TO_USER_IOCTL( (drm_map_t *)data, request, sizeof(drm_map_t) );
+
return 0;
}
@@ -204,7 +207,7 @@ int DRM(rmmap)( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
drm_map_list_entry_t *list;
- drm_map_t *map;
+ drm_local_map_t *map;
drm_map_t request;
int found_maps = 0;
@@ -257,7 +260,7 @@ int DRM(rmmap)( DRM_IOCTL_ARGS )
#endif
}
#endif
- DRM(ioremapfree)(map->handle, map->size);
+ DRM(ioremapfree)( map );
break;
case _DRM_SHM:
DRM(free)( map->handle, map->size, DRM_MEM_SAREA );
@@ -1018,6 +1021,7 @@ int DRM(mapbufs)( DRM_IOCTL_ARGS )
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
struct vnode *vn;
+ struct vmspace *vms = p->p_vmspace;
#endif /* __NetBSD__ */
drm_buf_map_t request;
@@ -1043,7 +1047,7 @@ int DRM(mapbufs)( DRM_IOCTL_ARGS )
if ( request.count >= dma->buf_count ) {
if ( (__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) ||
(__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG)) ) {
- drm_map_t *map = DRIVER_AGP_BUFFERS_MAP( dev );
+ drm_local_map_t *map = DRIVER_AGP_BUFFERS_MAP( dev );
if ( !map ) {
retcode = EINVAL;
diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c
index 0274a8b7..ffabe661 100644
--- a/bsd-core/drm_context.c
+++ b/bsd-core/drm_context.c
@@ -69,7 +69,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
if((bit+1) > dev->max_context) {
dev->max_context = (bit+1);
if(dev->context_sareas) {
- drm_map_t **ctx_sareas;
+ drm_local_map_t **ctx_sareas;
ctx_sareas = DRM(realloc)(dev->context_sareas,
(dev->max_context - 1) *
@@ -149,7 +149,7 @@ int DRM(getsareactx)( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
drm_ctx_priv_map_t request;
- drm_map_t *map;
+ drm_local_map_t *map;
DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
sizeof(request) );
@@ -174,7 +174,7 @@ int DRM(setsareactx)( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
drm_ctx_priv_map_t request;
- drm_map_t *map = NULL;
+ drm_local_map_t *map = NULL;
drm_map_list_entry_t *list;
DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
@@ -183,24 +183,20 @@ int DRM(setsareactx)( DRM_IOCTL_ARGS )
DRM_LOCK;
TAILQ_FOREACH(list, dev->maplist, link) {
map=list->map;
- if(map->handle == request.handle)
- goto found;
+ if(map->handle == request.handle) {
+ if (dev->max_context < 0)
+ goto bad;
+ if (request.ctx_id >= (unsigned) dev->max_context)
+ goto bad;
+ dev->context_sareas[request.ctx_id] = map;
+ DRM_UNLOCK;
+ return 0;
+ }
}
bad:
DRM_UNLOCK;
return DRM_ERR(EINVAL);
-
-found:
- map = list->map;
- if (!map) goto bad;
- if (dev->max_context < 0)
- goto bad;
- if (request.ctx_id >= (unsigned) dev->max_context)
- goto bad;
- dev->context_sareas[request.ctx_id] = map;
- DRM_UNLOCK;
- return 0;
}
/* ================================================================
diff --git a/bsd-core/drm_dma.c b/bsd-core/drm_dma.c
index 0f0dd4fd..01b1cdb0 100644
--- a/bsd-core/drm_dma.c
+++ b/bsd-core/drm_dma.c
@@ -534,9 +534,13 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
/* Install handler */
dev->irqrid = 0;
+#ifdef __FreeBSD__
dev->irqr = bus_alloc_resource(dev->device, SYS_RES_IRQ, &dev->irqrid,
0, ~0, 1, RF_SHAREABLE);
if (!dev->irqr) {
+#elif defined(__NetBSD__)
+ if (pci_intr_map(&dev->pa, &dev->ih) != 0) {
+#endif
DRM_LOCK;
dev->irq = 0;
dev->irqrid = 0;
@@ -544,11 +548,24 @@ int DRM(irq_install)( drm_device_t *dev, int irq )
return ENOENT;
}
+#ifdef __FreeBSD__
+#if __FreeBSD_version < 500000
retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY,
DRM(dma_service), dev, &dev->irqh);
+#else
+ retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY | INTR_MPSAFE,
+ DRM(dma_service), dev, &dev->irqh);
+#endif
if ( retcode ) {
+#elif defined(__NetBSD__)
+ dev->irqh = pci_intr_establish(&dev->pa.pa_pc, dev->ih, IPL_TTY,
+ (int (*)(DRM_IRQ_ARGS))DRM(dma_service), dev);
+ if ( !dev->irqh ) {
+#endif
DRM_LOCK;
+#ifdef __FreeBSD__
bus_release_resource(dev->device, SYS_RES_IRQ, dev->irqrid, dev->irqr);
+#endif
dev->irq = 0;
dev->irqrid = 0;
DRM_UNLOCK;
@@ -580,9 +597,13 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM(driver_irq_uninstall)( dev );
+#ifdef __FreeBSD__
bus_teardown_intr(dev->device, dev->irqr, dev->irqh);
bus_release_resource(dev->device, SYS_RES_IRQ, irqrid, dev->irqr);
-
+#elif defined(__NetBSD__)
+ pci_intr_disestablish(&dev->pa.pa_pc, dev->irqh);
+#endif
+
return 0;
}
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 4a6fc15f..0e0dc1aa 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -125,16 +125,10 @@
#define DRIVER_NUM_CARDS 1
#endif
-#ifdef __FreeBSD__
static int DRM(init)(device_t nbdev);
static void DRM(cleanup)(device_t nbdev);
-#elif defined(__NetBSD__)
-static int DRM(init)(drm_device_t *);
-static void DRM(cleanup)(drm_device_t *);
-#endif
#ifdef __FreeBSD__
-#define CDEV_MAJOR 145
#define DRIVER_SOFTC(unit) \
((drm_device_t *) devclass_get_softc(DRM(devclass), unit))
@@ -147,9 +141,8 @@ MODULE_DEPEND(DRIVER_NAME, linux, 1, 1, 1);
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
-#define CDEV_MAJOR 90
#define DRIVER_SOFTC(unit) \
- ((drm_device_t *) device_lookup(&DRM(_cd), unit))
+ ((drm_device_t *) device_lookup(&DRM(cd), unit))
#endif /* __NetBSD__ */
static drm_ioctl_desc_t DRM(ioctls)[] = {
@@ -229,6 +222,27 @@ static drm_ioctl_desc_t DRM(ioctls)[] = {
const char *DRM(find_description)(int vendor, int device);
#ifdef __FreeBSD__
+static struct cdevsw DRM(cdevsw) = {
+ /* open */ DRM( open ),
+ /* close */ DRM( close ),
+ /* read */ DRM( read ),
+ /* write */ DRM( write ),
+ /* ioctl */ DRM( ioctl ),
+ /* poll */ DRM( poll ),
+ /* mmap */ DRM( mmap ),
+ /* strategy */ nostrategy,
+ /* name */ DRIVER_NAME,
+ /* maj */ CDEV_MAJOR,
+ /* dump */ nodump,
+ /* psize */ nopsize,
+ /* flags */ D_TTY | D_TRACKCLOSE,
+#if __FreeBSD_version >= 500000
+ /* kqfilter */ 0
+#else
+ /* bmaj */ -1
+#endif
+};
+
static int DRM(probe)(device_t dev)
{
const char *s = NULL;
@@ -271,57 +285,108 @@ static driver_t DRM(driver) = {
sizeof(drm_device_t),
};
-static devclass_t DRM( devclass);
+static devclass_t DRM(devclass);
-static struct cdevsw DRM( cdevsw) = {
- /* open */ DRM( open ),
- /* close */ DRM( close ),
- /* read */ DRM( read ),
- /* write */ DRM( write ),
- /* ioctl */ DRM( ioctl ),
- /* poll */ DRM( poll ),
- /* mmap */ DRM( mmap ),
- /* strategy */ nostrategy,
- /* name */ DRIVER_NAME,
- /* maj */ CDEV_MAJOR,
- /* dump */ nodump,
- /* psize */ nopsize,
- /* flags */ D_TTY | D_TRACKCLOSE,
-#if __FreeBSD_version >= 500000
- /* kqfilter */ 0
+#elif defined(__NetBSD__)
+
+static struct cdevsw DRM(cdevsw) = {
+ DRM(open),
+ DRM(close),
+ DRM(read),
+ DRM(write),
+ DRM(ioctl),
+ nostop,
+ notty,
+ DRM(poll),
+ DRM(mmap),
+ nokqfilter,
+ D_TTY
+};
+
+int DRM(refcnt) = 0;
+#if __NetBSD_Version__ >= 106080000
+MOD_DEV( DRIVER_NAME, DRIVER_NAME, NULL, -1, &DRM(cdevsw), CDEV_MAJOR);
#else
- /* bmaj */ -1
+MOD_DEV( DRIVER_NAME, LM_DT_CHAR, CDEV_MAJOR, &DRM(cdevsw) );
#endif
-};
-#elif defined(__NetBSD__)
-int DRM(probe)(struct device *parent, struct cfdata *match, void *aux);
-void DRM(attach)(struct device *parent, struct device *self, void *aux);
-int DRM(detach)(struct device *self, int flags);
-int DRM(activate)(struct device *self, enum devact act);
-
-struct cfattach DRM(_ca) = {
- sizeof(drm_device_t), DRM(probe),
- DRM(attach), DRM(detach), DRM(activate) };
+int DRM(lkmentry)(struct lkm_table *lkmtp, int cmd, int ver);
+static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd);
+
+int DRM(modprobe)();
+int DRM(probe)(struct pci_attach_args *pa);
+void DRM(attach)(struct pci_attach_args *pa, dev_t kdev);
+
+int DRM(lkmentry)(struct lkm_table *lkmtp, int cmd, int ver) {
+ DISPATCH(lkmtp, cmd, ver, DRM(lkmhandle), DRM(lkmhandle), DRM(lkmhandle));
+}
+
+static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd)
+{
+ int j, error = 0;
+#if defined(__NetBSD__) && (__NetBSD_Version__ > 106080000)
+ struct lkm_dev *args = lkmtp->private.lkm_dev;
+#endif
+
+ switch(cmd) {
+ case LKM_E_LOAD:
+ if (lkmexists(lkmtp))
+ return EEXIST;
+
+ if(DRM(modprobe)())
+ return 0;
+
+ return 1;
+
+ case LKM_E_UNLOAD:
+ if (DRM(refcnt) > 0)
+ return (EBUSY);
+ break;
+ case LKM_E_STAT:
+ break;
+
+ default:
+ error = EIO;
+ break;
+ }
-int DRM(probe)(struct device *parent, struct cfdata *match, void *aux)
+ return error;
+}
+
+int DRM(modprobe)() {
+ struct pci_attach_args pa;
+ int error = 0;
+ if((error = pci_find_device(&pa, DRM(probe))) != 0)
+ DRM(attach)(&pa, 0);
+
+ return error;
+}
+
+int DRM(probe)(struct pci_attach_args *pa)
{
- struct pci_attach_args *pa = aux;
const char *desc;
desc = DRM(find_description)(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id));
- if (desc != NULL)
- return 10;
+ if (desc != NULL) {
+ return 1;
+ }
+
return 0;
}
-void DRM(attach)(struct device *parent, struct device *self, void *aux)
+void DRM(attach)(struct pci_attach_args *pa, dev_t kdev)
{
- struct pci_attach_args *pa = aux;
- drm_device_t *dev = (drm_device_t *)self;
-
- memcpy(&dev->pa, aux, sizeof(dev->pa));
-
+ int i;
+ drm_device_t *dev;
+
+ config_makeroom(kdev, &DRM(cd));
+ DRM(cd).cd_devs[(kdev)] = DRM(alloc)(sizeof(drm_device_t),
+ DRM_MEM_DRIVER);
+ dev = DRIVER_SOFTC(kdev);
+
+ memset(dev, 0, sizeof(drm_device_t));
+ memcpy(&dev->pa, pa, sizeof(dev->pa));
+
DRM_INFO("%s", DRM(find_description)(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id)));
DRM(init)(dev);
}
@@ -345,8 +410,7 @@ int DRM(activate)(struct device *self, enum devact act)
}
return (0);
}
-
-#endif
+#endif /* __NetBSD__ */
const char *DRM(find_description)(int vendor, int device) {
const char *s = NULL;
@@ -487,7 +551,7 @@ static int DRM(setup)( drm_device_t *dev )
static int DRM(takedown)( drm_device_t *dev )
{
drm_magic_entry_t *pt, *next;
- drm_map_t *map;
+ drm_local_map_t *map;
drm_map_list_entry_t *list;
drm_vma_entry_t *vma, *vma_next;
int i;
@@ -581,15 +645,13 @@ static int DRM(takedown)( drm_device_t *dev )
mtrrmap.len = map->size;
mtrrmap.type = MTRR_TYPE_WC;
mtrrmap.flags = 0;
- /*mtrrmap.owner = p->p_pid;*/
- /* XXX: Use curproc here? */
retcode = mtrr_set( &mtrrmap, &one,
DRM_CURPROC, MTRR_GETSET_KERNEL);
#endif
DRM_DEBUG( "mtrr_del=%d\n", retcode );
}
#endif
- DRM(ioremapfree)( map->handle, map->size );
+ DRM(ioremapfree)( map );
break;
case _DRM_SHM:
DRM(free)(map->handle,
@@ -658,15 +720,13 @@ static int DRM(takedown)( drm_device_t *dev )
* linux/init/main.c (this is not currently supported).
* bsd: drm_init is called via the attach function per device.
*/
-#ifdef __FreeBSD__
static int DRM(init)( device_t nbdev )
-#elif defined(__NetBSD__)
-static int DRM(init)( drm_device_t *dev )
-#endif
{
int unit;
#ifdef __FreeBSD__
drm_device_t *dev;
+#elif defined(__NetBSD__)
+ drm_device_t *dev = nbdev;
#endif
#if __HAVE_CTX_BITMAP
int retcode;
@@ -724,7 +784,6 @@ static int DRM(init)( drm_device_t *dev )
struct mtrr mtrrmap;
int one = 1;
mtrrmap.base = dev->agp->info.ai_aperture_base;
- /* Might need a multiplier here XXX */
mtrrmap.len = dev->agp->info.ai_aperture_size;
mtrrmap.type = MTRR_TYPE_WC;
mtrrmap.flags = MTRR_VALID;
@@ -763,21 +822,16 @@ static int DRM(init)( drm_device_t *dev )
* bsd: drm_cleanup is called per device at module unload time.
* FIXME: NetBSD
*/
-#ifdef __FreeBSD__
static void DRM(cleanup)(device_t nbdev)
-#elif defined(__NetBSD__)
-static void DRM(cleanup)(drm_device_t *dev)
-#endif
{
-#ifdef __FreeBSD__
drm_device_t *dev;
-#endif
-#if __REALLY_HAVE_MTRR
#ifdef __NetBSD__
+#if __REALLY_HAVE_MTRR
struct mtrr mtrrmap;
int one = 1;
-#endif /* __NetBSD__ */
#endif /* __REALLY_HAVE_MTRR */
+ dev = nbdev;
+#endif /* __NetBSD__ */
DRM_DEBUG( "\n" );
@@ -799,7 +853,7 @@ static void DRM(cleanup)(drm_device_t *dev)
mtrrmap.len = dev->agp->info.ai_aperture_size;
mtrrmap.type = 0;
mtrrmap.flags = 0;
- retval = mtrr_set( &mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
+ mtrr_set( &mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
#endif
}
#endif
@@ -814,6 +868,8 @@ static void DRM(cleanup)(drm_device_t *dev)
}
#endif
DRIVER_POSTCLEANUP();
+ DRM(mem_uninit)();
+ DRM_SPINUNINIT(dev->count_lock);
}
@@ -926,7 +982,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p)
}
if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
DRM_KERNEL_CONTEXT ) ) {
- dev->lock.pid = p->p_pid;
+ dev->lock.pid = DRM_CURRENTPID;
dev->lock.lock_time = jiffies;
atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
break; /* Got lock */
@@ -1043,7 +1099,6 @@ int DRM(ioctl)( DRM_IOCTL_ARGS )
*(int *) data = fgetown(dev->buf_sigio);
#endif
return 0;
- }
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
case TIOCSPGRP:
@@ -1056,6 +1111,7 @@ int DRM(ioctl)( DRM_IOCTL_ARGS )
*(int *)data = dev->buf_pgid;
return 0;
#endif /* __NetBSD__ */
+ }
if ( nr >= DRIVER_IOCTL_COUNT ) {
retcode = EINVAL;
diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c
index ed85a8de..d2faaa43 100644
--- a/bsd-core/drm_fops.c
+++ b/bsd-core/drm_fops.c
@@ -100,7 +100,7 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p,
the circular buffer), is based on Alessandro Rubini's LINUX DEVICE
DRIVERS (Cambridge: O'Reilly, 1998), pages 111-113. */
-ssize_t DRM(read)(dev_t kdev, struct uio *uio, int ioflag)
+int DRM(read)(dev_t kdev, struct uio *uio, int ioflag)
{
DRM_DEVICE;
int left;
@@ -182,8 +182,8 @@ int DRM(write_string)(drm_device_t *dev, const char *s)
selwakeup(&dev->buf_sel);
}
- DRM_DEBUG("dev->buf_sigio=%p\n", dev->buf_sigio);
#ifdef __FreeBSD__
+ DRM_DEBUG("dev->buf_sigio=%p\n", dev->buf_sigio);
if (dev->buf_sigio) {
DRM_DEBUG("dev->buf_sigio->sio_pgid=%d\n", dev->buf_sigio->sio_pgid);
#if __FreeBSD_version >= 500000
@@ -200,6 +200,7 @@ int DRM(write_string)(drm_device_t *dev, const char *s)
gsignal(dev->buf_pgid, SIGIO);
else if(dev->buf_pgid && (p = pfind(-dev->buf_pgid)) != NULL)
psignal(p, SIGIO);
+ }
#endif /* __NetBSD__ */
DRM_DEBUG("waking\n");
wakeup(&dev->buf_rp);
diff --git a/bsd-core/drm_ioctl.c b/bsd-core/drm_ioctl.c
index 63562fef..b4770385 100644
--- a/bsd-core/drm_ioctl.c
+++ b/bsd-core/drm_ioctl.c
@@ -136,7 +136,7 @@ int DRM(getmap)( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
drm_map_t map;
- drm_map_t *mapinlist;
+ drm_local_map_t *mapinlist;
drm_map_list_entry_t *list;
int idx;
int i = 0;
diff --git a/bsd-core/drm_lock.c b/bsd-core/drm_lock.c
index 5e9294bc..bb99d9e6 100644
--- a/bsd-core/drm_lock.c
+++ b/bsd-core/drm_lock.c
@@ -47,14 +47,12 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new;
- char failed;
-
do {
old = *lock;
if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT;
else new = context | _DRM_LOCK_HELD;
- _DRM_CAS(lock, old, new, failed);
- } while (failed);
+ } while (!atomic_cmpset_int(lock, old, new));
+
if (_DRM_LOCKING_CONTEXT(old) == context) {
if (old & _DRM_LOCK_HELD) {
if (context != DRM_KERNEL_CONTEXT) {
@@ -77,14 +75,13 @@ int DRM(lock_transfer)(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new;
- char failed;
dev->lock.pid = 0;
do {
old = *lock;
new = context | _DRM_LOCK_HELD;
- _DRM_CAS(lock, old, new, failed);
- } while (failed);
+ } while (!atomic_cmpset_int(lock, old, new));
+
return 1;
}
@@ -93,14 +90,13 @@ int DRM(lock_free)(drm_device_t *dev,
{
unsigned int old, new;
pid_t pid = dev->lock.pid;
- char failed;
dev->lock.pid = 0;
do {
old = *lock;
new = 0;
- _DRM_CAS(lock, old, new, failed);
- } while (failed);
+ } while (!atomic_cmpset_int(lock, old, new));
+
if (_DRM_LOCK_IS_HELD(old) && _DRM_LOCKING_CONTEXT(old) != context) {
DRM_ERROR("%d freed heavyweight lock held by %d (pid %d)\n",
context,
@@ -224,8 +220,6 @@ int DRM(notifier)(void *priv)
{
drm_sigdata_t *s = (drm_sigdata_t *)priv;
unsigned int old, new;
- char failed;
-
/* Allow signal delivery if lock isn't held */
if (!_DRM_LOCK_IS_HELD(s->lock->lock)
@@ -236,8 +230,8 @@ int DRM(notifier)(void *priv)
do {
old = s->lock->lock;
new = old | _DRM_LOCK_CONT;
- _DRM_CAS(&s->lock->lock, old, new, failed);
- } while (failed);
+ } while (!atomic_cmpset_int(&s->lock->lock, old, new));
+
return 0;
}
diff --git a/bsd-core/drm_memory.c b/bsd-core/drm_memory.c
index f7dc547a..aa81363f 100644
--- a/bsd-core/drm_memory.c
+++ b/bsd-core/drm_memory.c
@@ -31,9 +31,9 @@
#include "drmP.h"
-#ifdef __FreeBSD__
+#if defined(__FreeBSD__) || defined(__NetBSD__)
#define malloctype DRM(M_DRM)
-/* The macros confliced in the MALLOC_DEFINE */
+/* The macros conflicted in the MALLOC_DEFINE */
MALLOC_DEFINE(malloctype, "drm", "DRM Data Structures");
@@ -81,6 +81,10 @@ void DRM(mem_init)(void)
{
drm_mem_stats_t *mem;
+#ifdef __NetBSD__
+ malloc_type_attach(DRM(M_DRM));
+#endif
+
DRM_SPININIT(DRM(mem_lock), "drm memory");
for (mem = DRM(mem_stats); mem->name; ++mem) {
@@ -95,9 +99,15 @@ void DRM(mem_init)(void)
DRM(ram_used) = 0;
}
+void DRM(mem_uninit)(void)
+{
+ DRM_SPINUNINIT(DRM(mem_lock));
+}
+
#ifdef __FreeBSD__
/* drm_mem_info is called whenever a process reads /dev/drm/mem. */
-static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
+static int DRM(_mem_info)(drm_mem_stats_t *stats, struct sysctl_oid *oidp, void *arg1,
+ int arg2, struct sysctl_req *req)
{
drm_mem_stats_t *pt;
char buf[128];
@@ -112,7 +122,7 @@ static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu |\n",
"locked", 0, 0, 0, DRM(ram_used));
DRM_SYSCTL_PRINT("\n");
- for (pt = DRM(mem_stats); pt->name; pt++) {
+ for (pt = stats; pt->name; pt++) {
DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
pt->name,
pt->succeed_count,
@@ -132,13 +142,22 @@ static int DRM(_mem_info) DRM_SYSCTL_HANDLER_ARGS
int DRM(mem_info) DRM_SYSCTL_HANDLER_ARGS
{
int ret;
-
+ drm_mem_stats_t *stats;
+
+ stats = malloc(sizeof(DRM(mem_stats)), DRM(M_DRM), M_NOWAIT);
+ if (stats == NULL)
+ return ENOMEM;
+
DRM_SPINLOCK(&DRM(mem_lock));
- ret = DRM(_mem_info)(oidp, arg1, arg2, req);
+ bcopy(DRM(mem_stats), stats, sizeof(DRM(mem_stats)));
DRM_SPINUNLOCK(&DRM(mem_lock));
+
+ ret = DRM(_mem_info)(stats, oidp, arg1, arg2, req);
+
+ free(stats, DRM(M_DRM));
return ret;
}
-#endif
+#endif /* __FreeBSD__ */
void *DRM(alloc)(size_t size, int area)
{
@@ -149,11 +168,7 @@ void *DRM(alloc)(size_t size, int area)
return NULL;
}
-#ifdef __FreeBSD__
if (!(pt = malloc(size, DRM(M_DRM), M_NOWAIT))) {
-#elif defined(__NetBSD__)
- if (!(pt = malloc(size, M_DEVBUF, M_NOWAIT))) {
-#endif
DRM_SPINLOCK(&DRM(mem_lock));
++DRM(mem_stats)[area].fail_count;
DRM_SPINUNLOCK(&DRM(mem_lock));
@@ -203,13 +218,10 @@ void DRM(free)(void *pt, size_t size, int area)
int alloc_count;
int free_count;
- if (!pt) DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
+ if (!pt)
+ DRM_MEM_ERROR(area, "Attempt to free NULL pointer\n");
else
-#ifdef __FreeBSD__
- free(pt, DRM(M_DRM));
-#elif defined(__NetBSD__)
- free(pt, M_DEVBUF);
-#endif
+ free(pt, DRM(M_DRM));
DRM_SPINLOCK(&DRM(mem_lock));
DRM(mem_stats)[area].bytes_freed += size;
free_count = ++DRM(mem_stats)[area].free_count;
@@ -221,25 +233,36 @@ void DRM(free)(void *pt, size_t size, int area)
}
}
-void *DRM(ioremap)(unsigned long offset, unsigned long size)
+void *DRM(ioremap)( drm_device_t *dev, drm_local_map_t *map )
{
void *pt;
- if (!size) {
+ if (!map->size) {
DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Mapping 0 bytes at 0x%08lx\n", offset);
+ "Mapping 0 bytes at 0x%08lx\n", map->offset);
return NULL;
}
+#ifdef __NetBSD__
+ map->iot = dev->pa.pa_memt;
+#endif
- if (!(pt = pmap_mapdev(offset, size))) {
+#ifdef __FreeBSD__
+ if (!(pt = pmap_mapdev(map->offset, map->size))) {
+#elif defined(__NetBSD__)
+ if (bus_space_map(map->iot, map->offset, map->size,
+ BUS_SPACE_MAP_LINEAR, &map->ioh)) {
+#endif
DRM_SPINLOCK(&DRM(mem_lock));
++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
DRM_SPINUNLOCK(&DRM(mem_lock));
return NULL;
}
+#ifdef __NetBSD__
+ pt = bus_space_vaddr(map->iot, map->ioh);
+#endif
DRM_SPINLOCK(&DRM(mem_lock));
++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
+ DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += map->size;
DRM_SPINUNLOCK(&DRM(mem_lock));
return pt;
}
@@ -271,19 +294,23 @@ void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size)
}
#endif
-void DRM(ioremapfree)(void *pt, unsigned long size)
+void DRM(ioremapfree)(drm_local_map_t *map)
{
int alloc_count;
int free_count;
- if (!pt)
+ if (map->handle == NULL)
DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
"Attempt to free NULL pointer\n");
else
- pmap_unmapdev((vm_offset_t) pt, size);
+#ifdef __FreeBSD__
+ pmap_unmapdev((vm_offset_t) map->handle, map->size);
+#elif defined(__NetBSD__)
+ bus_space_unmap(map->iot, map->ioh, map->size);
+#endif
DRM_SPINLOCK(&DRM(mem_lock));
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size;
+ DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += map->size;
free_count = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count;
alloc_count = DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
DRM_SPINUNLOCK(&DRM(mem_lock));
diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h
index 1a3feb6e..8b2e4581 100644
--- a/bsd-core/drm_os_freebsd.h
+++ b/bsd-core/drm_os_freebsd.h
@@ -79,6 +79,7 @@
#define DRM_STRUCTPROC struct thread
#define DRM_SPINTYPE struct mtx
#define DRM_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF)
+#define DRM_SPINUNINIT(l) mtx_destroy(&l)
#define DRM_SPINLOCK(l) mtx_lock(l)
#define DRM_SPINUNLOCK(u) mtx_unlock(u);
#define DRM_CURRENTPID curthread->td_proc->p_pid
@@ -87,6 +88,7 @@
#define DRM_STRUCTPROC struct proc
#define DRM_SPINTYPE struct simplelock
#define DRM_SPININIT(l,name) simple_lock_init(&l)
+#define DRM_SPINUNINIT(l,name)
#define DRM_SPINLOCK(l) simple_lock(l)
#define DRM_SPINUNLOCK(u) simple_unlock(u);
#define DRM_CURRENTPID curproc->p_pid
@@ -102,10 +104,18 @@
#define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT )
#define DRM_FREE(pt) free( pt, DRM(M_DRM) )
#define DRM_VTOPHYS(addr) vtophys(addr)
-#define DRM_READ8(addr) *((volatile char *)(addr))
-#define DRM_READ32(addr) *((volatile long *)(addr))
-#define DRM_WRITE8(addr, val) *((volatile char *)(addr)) = (val)
-#define DRM_WRITE32(addr, val) *((volatile long *)(addr)) = (val)
+
+/* Read/write from bus space, with byteswapping to le if necessary */
+#define DRM_READ8(map, offset) *(volatile u_int8_t *) (((unsigned long)(map)->handle) + (offset))
+#define DRM_READ32(map, offset) *(volatile u_int32_t *)(((unsigned long)(map)->handle) + (offset))
+#define DRM_WRITE8(map, offset, val) *(volatile u_int8_t *) (((unsigned long)(map)->handle) + (offset)) = val
+#define DRM_WRITE32(map, offset, val) *(volatile u_int32_t *)(((unsigned long)(map)->handle) + (offset)) = val
+/*
+#define DRM_READ8(map, offset) bus_space_read_1( (map)->iot, (map)->ioh, (offset) )
+#define DRM_READ32(map, offset) bus_space_read_4( (map)->iot, (map)->ioh, (offset) )
+#define DRM_WRITE8(map, offset, val) bus_space_write_1( (map)->iot, (map)->ioh, (offset), (val) )
+#define DRM_WRITE32(map, offset, val) bus_space_write_4( (map)->iot, (map)->ioh, (offset), (val) )
+*/
#define DRM_AGP_FIND_DEVICE() agp_find_device()
#define DRM_ERR(v) v
@@ -130,7 +140,7 @@ do { \
do { \
drm_map_list_entry_t *listentry; \
TAILQ_FOREACH(listentry, dev->maplist, link) { \
- drm_map_t *map = listentry->map; \
+ drm_local_map_t *map = listentry->map; \
if (map->type == _DRM_SHM && \
map->flags & _DRM_CONTAINS_LOCK) { \
dev_priv->sarea = map; \
@@ -166,7 +176,7 @@ while (!condition) { \
copyin(user, kern, size)
/* Macros for userspace access with checking readability once */
/* FIXME: can't find equivalent functionality for nocheck yet.
- * It's be slower than linux, but should be correct.
+ * It'll be slower than linux, but should be correct.
*/
#define DRM_VERIFYAREA_READ( uaddr, size ) \
(!useracc((caddr_t)uaddr, size, VM_PROT_READ))
@@ -175,20 +185,13 @@ while (!condition) { \
#define DRM_GET_USER_UNCHECKED(val, uaddr) \
((val) = fuword(uaddr), 0)
-/* From machine/bus_at386.h on i386 */
-#define DRM_READMEMORYBARRIER() \
-do { \
- __asm __volatile("lock; addl $0,0(%%esp)" : : : "memory"); \
-} while (0)
-
-#define DRM_WRITEMEMORYBARRIER() \
-do { \
- __asm __volatile("" : : : "memory"); \
-} while (0)
-
+#define DRM_WRITEMEMORYBARRIER( map ) \
+ bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, 0);
+#define DRM_READMEMORYBARRIER( map ) \
+ bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, BUS_SPACE_BARRIER_READ);
#define PAGE_ALIGN(addr) round_page(addr)
-
+
#ifndef M_WAITOK /* M_WAITOK (=0) name removed in -current */
#define M_WAITOK 0
#endif
@@ -206,7 +209,7 @@ typedef struct drm_chipinfo
char *name;
} drm_chipinfo_t;
-#define cpu_to_le32(x) (x)
+#define cpu_to_le32(x) (x) /* FIXME */
typedef u_int32_t dma_addr_t;
typedef u_int32_t atomic_t;
@@ -223,6 +226,23 @@ typedef u_int8_t u8;
#define atomic_sub(n, p) atomic_subtract_int(p, n)
/* Fake this */
+
+#if __FreeBSD_version < 500000
+/* The extra atomic functions from 5.0 haven't been merged to 4.x */
+static __inline int
+atomic_cmpset_int(int *dst, int old, int new)
+{
+ int s = splhigh();
+ if (*dst==old) {
+ *dst = new;
+ splx(s);
+ return 1;
+ }
+ splx(s);
+ return 0;
+}
+#endif
+
static __inline atomic_t
test_and_set_bit(int b, volatile void *p)
{
@@ -284,20 +304,6 @@ find_first_zero_bit(volatile void *p, int max)
#endif
-#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
-#define _DRM_CAS(lock,old,new,__ret) \
- do { \
- int __dummy; /* Can't mark eax as clobbered */ \
- __asm__ __volatile__( \
- "lock ; cmpxchg %4,%1\n\t" \
- "setnz %0" \
- : "=d" (__ret), \
- "=m" (__drm_dummy_lock(lock)), \
- "=a" (__dummy) \
- : "2" (old), \
- "r" (new)); \
- } while (0)
-
/* Redefinitions to make templating easy */
#define wait_queue_head_t atomic_t
#define agp_memory void
diff --git a/bsd-core/drm_os_netbsd.h b/bsd-core/drm_os_netbsd.h
index 2082c047..b1c36196 100644
--- a/bsd-core/drm_os_netbsd.h
+++ b/bsd-core/drm_os_netbsd.h
@@ -17,6 +17,7 @@
#include <uvm/uvm.h>
#include <sys/vnode.h>
#include <sys/poll.h>
+#include <sys/lkm.h>
/* For TIOCSPGRP/TIOCGPGRP */
#include <sys/ttycom.h>
@@ -31,11 +32,9 @@
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
-#include "drmvar.h"
-
#define __REALLY_HAVE_AGP __HAVE_AGP
-#define __REALLY_HAVE_MTRR 0
+#define __REALLY_HAVE_MTRR 1
#define __REALLY_HAVE_SG 0
#if __REALLY_HAVE_AGP
@@ -43,8 +42,7 @@
#include <sys/agpio.h>
#endif
-#define device_t struct device *
-extern struct cfdriver DRM(_cd);
+#include <opt_drm.h>
#if DRM_DEBUG
#undef DRM_DEBUG_CODE
@@ -52,36 +50,54 @@ extern struct cfdriver DRM(_cd);
#endif
#undef DRM_DEBUG
+#if DRM_LINUX
+#undef DRM_LINUX /* FIXME: Linux compat has not been ported yet */
+#endif
+
+typedef drm_device_t *device_t;
+
+extern struct cfdriver DRM(cd);
+
#define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */
#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 90
+#define CDEV_MAJOR 34
#define DRM_CURPROC curproc
-#define DRM_STRUCTPROC struct proc
+#define DRM_STRUCTPROC struct proc
#define DRM_SPINTYPE struct simplelock
#define DRM_SPININIT(l,name) simple_lock_init(&l)
-#define DRM_SPINLOCK(l) simple_lock(l)
+#define DRM_SPINUNINIT(l)
+#define DRM_SPINLOCK(l) simple_lock(l)
#define DRM_SPINUNLOCK(u) simple_unlock(u);
-#define DRM_CURRENTPID curproc->p_pid
+#define DRM_CURRENTPID curproc->p_pid
#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p
#define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, NULL)
#define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, NULL)
#define DRM_SUSER(p) suser(p->p_ucred, &p->p_acflag)
#define DRM_TASKQUEUE_ARGS void *dev, int pending
-#define DRM_IRQ_ARGS void *device
-#define DRM_DEVICE drm_device_t *dev = device_lookup(&DRM(_cd), minor(kdev))
+#define DRM_IRQ_ARGS void *arg
+#define DRM_DEVICE drm_device_t *dev = device_lookup(&DRM(cd), minor(kdev))
+/* XXX Not sure if this is the 'right' version.. */
+#if __NetBSD_Version__ >= 106140000
+MALLOC_DECLARE(DRM(M_DRM));
+#else
+/* XXX Make sure this works */
+extern const int DRM(M_DRM) = M_DEVBUF;
+#endif /* __NetBSD_Version__ */
#define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT )
#define DRM_FREE(pt) free( pt, DRM(M_DRM) )
#define DRM_VTOPHYS(addr) vtophys(addr)
-#define DRM_READ8(addr) *((volatile char *)(addr))
-#define DRM_READ32(addr) *((volatile long *)(addr))
-#define DRM_WRITE8(addr, val) *((volatile char *)(addr)) = (val)
-#define DRM_WRITE32(addr, val) *((volatile long *)(addr)) = (val)
-#define DRM_AGP_FIND_DEVICE()
+
+#define DRM_READ8(map, offset) bus_space_read_1( (map)->iot, (map)->ioh, (offset) )
+#define DRM_READ32(map, offset) bus_space_read_4( (map)->iot, (map)->ioh, (offset) )
+#define DRM_WRITE8(map, offset, val) bus_space_write_1( (map)->iot, (map)->ioh, (offset), (val) )
+#define DRM_WRITE32(map, offset, val) bus_space_write_4( (map)->iot, (map)->ioh, (offset), (val) )
+
+#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
#define DRM_PRIV \
drm_file_t *priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); \
@@ -104,7 +120,7 @@ do { \
do { \
drm_map_list_entry_t *listentry; \
TAILQ_FOREACH(listentry, dev->maplist, link) { \
- drm_map_t *map = listentry->map; \
+ drm_local_map_t *map = listentry->map; \
if (map->type == _DRM_SHM && \
map->flags & _DRM_CONTAINS_LOCK) { \
dev_priv->sarea = map; \
@@ -113,7 +129,15 @@ do { \
} \
} while (0)
-#define return DRM_ERR(v) return v;
+#define DRM_HZ hz
+
+#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
+while (!condition) { \
+ ret = tsleep( (void *)&(queue), PZERO | PCATCH, "drmwtq", (timeout) ); \
+ if ( ret ) \
+ return ret; \
+}
+
#define DRM_ERR(v) v
#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
@@ -124,21 +148,25 @@ do { \
copyout(arg2, arg1, arg3)
#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
copyin(arg2, arg1, arg3)
+/* Macros for userspace access with checking readability once */
+/* FIXME: can't find equivalent functionality for nocheck yet.
+ * It'll be slower than linux, but should be correct.
+ */
+#define DRM_VERIFYAREA_READ( uaddr, size ) \
+ (!uvm_useracc((caddr_t)uaddr, size, VM_PROT_READ))
+#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
+ copyin(arg2, arg1, arg3)
+#define DRM_GET_USER_UNCHECKED(val, uaddr) \
+ ((val) = fuword(uaddr), 0)
-#define DRM_READMEMORYBARRIER \
-{ \
- int xchangeDummy; \
- DRM_DEBUG("%s\n", __FUNCTION__); \
- __asm__ volatile(" push %%eax ; xchg %%eax, %0 ; pop %%eax" : : "m" (xchangeDummy)); \
- __asm__ volatile(" push %%eax ; push %%ebx ; push %%ecx ; push %%edx ;" \
- " movl $0,%%eax ; cpuid ; pop %%edx ; pop %%ecx ; pop %%ebx ;" \
- " pop %%eax" : /* no outputs */ : /* no inputs */ ); \
-} while (0);
-
-#define DRM_WRITEMEMORYBARRIER DRM_READMEMORYBARRIER
+#define DRM_WRITEMEMORYBARRIER( map ) \
+ bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, 0);
+#define DRM_READMEMORYBARRIER( map ) \
+ bus_space_barrier((map)->iot, (map)->ioh, 0, (map)->size, BUS_SPACE_BARRIER_READ);
-#define DRM_WAKEUP(w) wakeup(w)
+#define DRM_WAKEUP(w) wakeup((void *)w)
#define DRM_WAKEUP_INT(w) wakeup(w)
+#define DRM_INIT_WAITQUEUE( queue ) do {} while (0)
#define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK)
@@ -150,8 +178,10 @@ typedef struct drm_chipinfo
char *name;
} drm_chipinfo_t;
+#define cpu_to_le32(x) (x) /* FIXME */
+
typedef u_int32_t dma_addr_t;
-typedef volatile u_int32_t atomic_t;
+typedef volatile long atomic_t;
typedef u_int32_t cycles_t;
typedef u_int32_t spinlock_t;
typedef u_int32_t u32;
@@ -160,20 +190,35 @@ typedef u_int8_t u8;
typedef dev_type_ioctl(d_ioctl_t);
typedef vaddr_t vm_offset_t;
+/* FIXME */
#define atomic_set(p, v) (*(p) = (v))
#define atomic_read(p) (*(p))
-#define atomic_inc(p) atomic_add_int(p, 1)
-#define atomic_dec(p) atomic_subtract_int(p, 1)
-#define atomic_add(n, p) atomic_add_int(p, n)
-#define atomic_sub(n, p) atomic_subtract_int(p, n)
+#define atomic_inc(p) (*(p) += 1)
+#define atomic_dec(p) (*(p) -= 1)
+#define atomic_add(n, p) (*(p) += (n))
+#define atomic_sub(n, p) (*(p) -= (n))
-/* FIXME: Is NetBSD's kernel non-reentrant? */
+/* FIXME */
#define atomic_add_int(p, v) *(p) += v
#define atomic_subtract_int(p, v) *(p) -= v
#define atomic_set_int(p, bits) *(p) |= (bits)
#define atomic_clear_int(p, bits) *(p) &= ~(bits)
/* Fake this */
+
+static __inline int
+atomic_cmpset_int(__volatile__ int *dst, int old, int new)
+{
+ int s = splhigh();
+ if (*dst==old) {
+ *dst = new;
+ splx(s);
+ return 1;
+ }
+ splx(s);
+ return 0;
+}
+
static __inline atomic_t
test_and_set_bit(int b, atomic_t *p)
{
@@ -223,20 +268,6 @@ find_first_zero_bit(atomic_t *p, int max)
#define spldrm() spltty()
#define jiffies hardclock_ticks
-#define __drm_dummy_lock(lock) (*(__volatile__ unsigned int *)lock)
-#define _DRM_CAS(lock,old,new,__ret) \
- do { \
- int __dummy; /* Can't mark eax as clobbered */ \
- __asm__ __volatile__( \
- "lock ; cmpxchg %4,%1\n\t" \
- "setnz %0" \
- : "=d" (__ret), \
- "=m" (__drm_dummy_lock(lock)), \
- "=a" (__dummy) \
- : "2" (old), \
- "r" (new)); \
- } while (0)
-
/* Redefinitions to make templating easy */
#define wait_queue_head_t atomic_t
#define agp_memory void
@@ -257,7 +288,7 @@ do { \
#define DRM_DEBUG(fmt, arg...) \
do { \
if (DRM(flags) & DRM_FLAG_DEBUG) \
- printf("[" DRM_NAME ":%s] " fmt , __FUNCTION__,## arg); \
+ printf("[" DRM_NAME ":%s] " fmt , __FUNCTION__ ,## arg); \
} while (0)
#else
#define DRM_DEBUG(fmt, arg...) do { } while (0)
diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c
index c16b7c05..f639b697 100644
--- a/bsd-core/drm_scatter.c
+++ b/bsd-core/drm_scatter.c
@@ -40,9 +40,6 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry )
DRM(free)( entry->busaddr,
entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES );
- DRM(free)( entry->pagelist,
- entry->pages * sizeof(*entry->pagelist),
- DRM_MEM_PAGES );
DRM(free)( entry,
sizeof(*entry),
DRM_MEM_SGLISTS );
@@ -73,21 +70,10 @@ int DRM(sg_alloc)( DRM_IOCTL_ARGS )
DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
entry->pages = pages;
- entry->pagelist = DRM(alloc)( pages * sizeof(*entry->pagelist),
- DRM_MEM_PAGES );
- if ( !entry->pagelist ) {
- DRM(free)( entry, sizeof(*entry), DRM_MEM_SGLISTS );
- return ENOMEM;
- }
-
- bzero(entry->pagelist, pages * sizeof(*entry->pagelist));
entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES );
if ( !entry->busaddr ) {
- DRM(free)( entry->pagelist,
- entry->pages * sizeof(*entry->pagelist),
- DRM_MEM_PAGES );
DRM(free)( entry,
sizeof(*entry),
DRM_MEM_SGLISTS );
@@ -100,9 +86,6 @@ int DRM(sg_alloc)( DRM_IOCTL_ARGS )
DRM(free)( entry->busaddr,
entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES );
- DRM(free)( entry->pagelist,
- entry->pages * sizeof(*entry->pagelist),
- DRM_MEM_PAGES );
DRM(free)( entry,
sizeof(*entry),
DRM_MEM_SGLISTS );
@@ -124,46 +107,6 @@ int DRM(sg_alloc)( DRM_IOCTL_ARGS )
dev->sg = entry;
-#if DEBUG_SCATTER
- /* Verify that each page points to its virtual address, and vice
- * versa.
- */
- {
- int error = 0;
-
- for ( i = 0 ; i < pages ; i++ ) {
- unsigned long *tmp;
-
- tmp = page_address( entry->pagelist[i] );
- for ( j = 0 ;
- j < PAGE_SIZE / sizeof(unsigned long) ;
- j++, tmp++ ) {
- *tmp = 0xcafebabe;
- }
- tmp = (unsigned long *)((u8 *)entry->virtual +
- (PAGE_SIZE * i));
- for( j = 0 ;
- j < PAGE_SIZE / sizeof(unsigned long) ;
- j++, tmp++ ) {
- if ( *tmp != 0xcafebabe && error == 0 ) {
- error = 1;
- DRM_ERROR( "Scatter allocation error, "
- "pagelist does not match "
- "virtual mapping\n" );
- }
- }
- tmp = page_address( entry->pagelist[i] );
- for(j = 0 ;
- j < PAGE_SIZE / sizeof(unsigned long) ;
- j++, tmp++) {
- *tmp = 0;
- }
- }
- if (error == 0)
- DRM_ERROR( "Scatter allocation matches pagelist\n" );
- }
-#endif
-
return 0;
DRM(sg_cleanup)( entry );
diff --git a/bsd-core/drm_sysctl.c b/bsd-core/drm_sysctl.c
index 2ec7ff95..7cb5be22 100644
--- a/bsd-core/drm_sysctl.c
+++ b/bsd-core/drm_sysctl.c
@@ -125,7 +125,7 @@ static int DRM(name_info)DRM_SYSCTL_HANDLER_ARGS
static int DRM(_vm_info)DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
- drm_map_t *map;
+ drm_local_map_t *map;
drm_map_list_entry_t *listentry;
const char *types[] = { "FB", "REG", "SHM" };
const char *type;
@@ -203,7 +203,7 @@ static int DRM(_queues_info)DRM_SYSCTL_HANDLER_ARGS
q->read_queue ? 'r':'-',
q->write_queue ? 'w':'-',
q->flush_queue ? 'f':'-',
- DRM_BUFCOUNT(&q->waitlist),
+ (int)DRM_BUFCOUNT(&q->waitlist),
atomic_read(&q->total_flushed),
atomic_read(&q->total_queued),
atomic_read(&q->total_locks));
diff --git a/bsd-core/drm_vm.c b/bsd-core/drm_vm.c
index 70a5b0e6..040d58b8 100644
--- a/bsd-core/drm_vm.c
+++ b/bsd-core/drm_vm.c
@@ -27,7 +27,7 @@ paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot)
#endif
{
DRM_DEVICE;
- drm_map_t *map = NULL;
+ drm_local_map_t *map = NULL;
drm_map_list_entry_t *listentry=NULL;
drm_file_t *priv;
diff --git a/bsd-core/mga_drv.c b/bsd-core/mga_drv.c
index 8b69b41b..ffc83db9 100644
--- a/bsd-core/mga_drv.c
+++ b/bsd-core/mga_drv.c
@@ -29,8 +29,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include <sys/types.h>
-
#include "mga.h"
#include "drmP.h"
#include "drm.h"
@@ -63,4 +61,8 @@ drm_chipinfo_t DRM(devicelist)[] = {
#include "drm_vm.h"
#include "drm_sysctl.h"
+#ifdef __FreeBSD__
DRIVER_MODULE(mga, pci, mga_driver, mga_devclass, 0, 0);
+#elif defined(__NetBSD__)
+CFDRIVER_DECL(mga, DV_TTY, NULL);
+#endif
diff --git a/bsd-core/r128_drv.c b/bsd-core/r128_drv.c
index 1a8046fb..8a9c2837 100644
--- a/bsd-core/r128_drv.c
+++ b/bsd-core/r128_drv.c
@@ -29,9 +29,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-
-#include <sys/types.h>
-
#include "r128.h"
#include "drmP.h"
#include "drm.h"
@@ -83,4 +80,8 @@ drm_chipinfo_t DRM(devicelist)[] = {
#include "drm_scatter.h"
#endif
+#ifdef __FreeBSD__
DRIVER_MODULE(r128, pci, r128_driver, r128_devclass, 0, 0);
+#elif defined(__NetBSD__)
+CFDRIVER_DECL(r128, DV_TTY, NULL);
+#endif /* __FreeBSD__ */
diff --git a/bsd-core/radeon_drv.c b/bsd-core/radeon_drv.c
index d02ab959..79c982e3 100644
--- a/bsd-core/radeon_drv.c
+++ b/bsd-core/radeon_drv.c
@@ -27,8 +27,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#include <sys/types.h>
-
#include "radeon.h"
#include "drmP.h"
#include "drm.h"
@@ -38,21 +36,40 @@
#include "ati_pcigart.h"
#endif
-/* List acquired from http://www.yourvote.com/pci/pcihdr.h and xc/xc/programs/Xserver/hw/xfree86/common/xf86PciInfo.h
- * Please report to eta@lclark.edu inaccuracies or if a chip you have works that is marked unsupported here.
- */
drm_chipinfo_t DRM(devicelist)[] = {
+ {0x1002, 0x4242, 1, "ATI Radeon BB AIW 8500DV (AGP)"},
+ {0x1002, 0x4336, 1, "ATI Radeon Mobility"},
+ {0x1002, 0x4337, 1, "ATI Radeon IGP 340"},
+ {0x1002, 0x4964, 1, "ATI Radeon Id 9000"},
+ {0x1002, 0x4965, 1, "ATI Radeon Ie 9000"},
+ {0x1002, 0x4966, 1, "ATI Radeon If 9000"},
+ {0x1002, 0x4967, 1, "ATI Radeon Ig 9000"},
+ {0x1002, 0x496e, 1, "ATI Radeon Ig 9000"},
{0x1002, 0x4C57, 1, "ATI Radeon LW Mobility 7 (AGP)"},
+ {0x1002, 0x4C58, 1, "ATI Radeon LX Mobility 7 (AGP)"},
{0x1002, 0x4C59, 1, "ATI Radeon LY Mobility 6 (AGP)"},
{0x1002, 0x4C5A, 1, "ATI Radeon LZ Mobility 6 (AGP)"},
- {0x1002, 0x5144, 1, "ATI Radeon QD (AGP)"},
- {0x1002, 0x5145, 1, "ATI Radeon QE (AGP)"},
- {0x1002, 0x5146, 1, "ATI Radeon QF (AGP)"},
- {0x1002, 0x5147, 1, "ATI Radeon QG (AGP)"},
+ {0x1002, 0x4C64, 1, "ATI Radeon Ld Mobility 9000 (AGP)"},
+ {0x1002, 0x4C65, 1, "ATI Radeon Le Mobility 9000 (AGP)"},
+ {0x1002, 0x4C66, 1, "ATI Radeon Lf Mobility 9000 (AGP)"},
+ {0x1002, 0x4C67, 1, "ATI Radeon Lg Mobility 9000 (AGP)"},
+ {0x1002, 0x5144, 1, "ATI Radeon QD R100 (AGP)"},
+ {0x1002, 0x5145, 1, "ATI Radeon QE R100 (AGP)"},
+ {0x1002, 0x5146, 1, "ATI Radeon QF R100 (AGP)"},
+ {0x1002, 0x5147, 1, "ATI Radeon QG R100 (AGP)"},
+ {0x1002, 0x5148, 1, "ATI Radeon QH FireGL 8x00 (AGP)"},
+ {0x1002, 0x5149, 1, "ATI Radeon QI R200"},
+ {0x1002, 0x514A, 1, "ATI Radeon QJ R200"},
+ {0x1002, 0x514B, 1, "ATI Radeon QK R200"},
+ {0x1002, 0x514C, 1, "ATI Radeon QL 8500 (AGP)"},
{0x1002, 0x5157, 1, "ATI Radeon QW 7500 (AGP)"},
+ {0x1002, 0x5158, 1, "ATI Radeon QX 7500 (AGP)"},
{0x1002, 0x5159, 1, "ATI Radeon QY VE (AGP)"},
{0x1002, 0x515A, 1, "ATI Radeon QZ VE (AGP)"},
- {0x1002, 0x514C, 1, "ATI Radeon QL 8500 (AGP)"},
+ {0x1002, 0x5168, 1, "ATI Radeon Qh R200"},
+ {0x1002, 0x5169, 1, "ATI Radeon Qi R200"},
+ {0x1002, 0x516A, 1, "ATI Radeon Qj R200"},
+ {0x1002, 0x516B, 1, "ATI Radeon Qk R200"},
{0, 0, 0, NULL}
};
@@ -74,4 +91,8 @@ drm_chipinfo_t DRM(devicelist)[] = {
#include "drm_scatter.h"
#endif
+#ifdef __FreeBSD__
DRIVER_MODULE(DRIVER_NAME, pci, DRM(driver), DRM(devclass), 0, 0);
+#elif defined(__NetBSD__)
+CFDRIVER_DECL(radeon, DV_TTY, NULL);
+#endif /* __FreeBSD__ */
diff --git a/bsd-core/tdfx_drv.c b/bsd-core/tdfx_drv.c
index 8bc8c57d..c62ca2c5 100644
--- a/bsd-core/tdfx_drv.c
+++ b/bsd-core/tdfx_drv.c
@@ -30,9 +30,6 @@
* Gareth Hughes <gareth@valinux.com>
*/
-
-#include <sys/types.h>
-
#include "tdfx.h"
#include "drmP.h"
@@ -96,4 +93,6 @@ drm_chipinfo_t DRM(devicelist)[] = {
#ifdef __FreeBSD__
DRIVER_MODULE(tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0);
+#elif defined(__NetBSD__)
+CFDRIVER_DECL(tdfx, DV_TTY, NULL);
#endif /* __FreeBSD__ */