summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bsd/.cvsignore1
-rw-r--r--bsd/Makefile71
-rw-r--r--bsd/ati_pcigart.h114
-rw-r--r--bsd/drmP.h625
-rw-r--r--bsd/drm_agpsupport.h314
-rw-r--r--bsd/drm_auth.h164
-rw-r--r--bsd/drm_bufs.h961
-rw-r--r--bsd/drm_context.h349
-rw-r--r--bsd/drm_dma.h171
-rw-r--r--bsd/drm_drawable.h50
-rw-r--r--bsd/drm_drv.h1157
-rw-r--r--bsd/drm_fops.h117
-rw-r--r--bsd/drm_ioctl.h279
-rw-r--r--bsd/drm_irq.h281
-rw-r--r--bsd/drm_linux_list.h69
-rw-r--r--bsd/drm_lock.h96
-rw-r--r--bsd/drm_memory.h187
-rw-r--r--bsd/drm_memory_debug.h420
-rw-r--r--bsd/drm_os_freebsd.h471
-rw-r--r--bsd/drm_os_netbsd.h375
-rw-r--r--bsd/drm_pci.h65
-rw-r--r--bsd/drm_scatter.h151
-rw-r--r--bsd/drm_sysctl.h324
-rw-r--r--bsd/drm_vm.h130
-rw-r--r--bsd/i915/Makefile23
-rw-r--r--bsd/i915_drv.c59
-rw-r--r--bsd/mach64/.cvsignore8
-rw-r--r--bsd/mach64/Makefile23
-rw-r--r--bsd/mach64_drv.c57
-rw-r--r--bsd/mga/.cvsignore8
-rw-r--r--bsd/mga/Makefile23
-rw-r--r--bsd/mga_drv.c58
-rw-r--r--bsd/r128/.cvsignore8
-rw-r--r--bsd/r128/Makefile23
-rw-r--r--bsd/r128_drv.c63
-rw-r--r--bsd/radeon/.cvsignore8
-rw-r--r--bsd/radeon/Makefile23
-rw-r--r--bsd/radeon_drv.c61
-rw-r--r--bsd/sis/.cvsignore8
-rw-r--r--bsd/sis/Makefile23
-rw-r--r--bsd/sis_drv.c53
-rw-r--r--bsd/tdfx/.cvsignore8
-rw-r--r--bsd/tdfx/Makefile23
-rw-r--r--bsd/tdfx_drv.c58
44 files changed, 0 insertions, 7560 deletions
diff --git a/bsd/.cvsignore b/bsd/.cvsignore
deleted file mode 100644
index c196cbc7..00000000
--- a/bsd/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-drm_pciids.h
diff --git a/bsd/Makefile b/bsd/Makefile
deleted file mode 100644
index 03b6d4ff..00000000
--- a/bsd/Makefile
+++ /dev/null
@@ -1,71 +0,0 @@
-SHARED= ../shared
-SHAREDFILES= drm.h \
- drm_sarea.h \
- i915.h \
- i915_dma.c \
- i915_drm.h \
- i915_drv.h \
- i915_irq.c \
- i915_mem.c \
- mach64.h \
- mach64_dma.c \
- mach64_drm.h \
- mach64_drv.h \
- mach64_irq.c \
- mach64_state.c \
- mga.h \
- mga_dma.c \
- mga_drm.h \
- mga_drv.h \
- mga_irq.c \
- mga_state.c \
- mga_ucode.h \
- mga_warp.c \
- r128.h \
- r128_cce.c \
- r128_drm.h \
- r128_drv.h \
- r128_irq.c \
- r128_state.c \
- radeon.h \
- radeon_cp.c \
- radeon_drm.h \
- radeon_drv.h \
- radeon_irq.c \
- radeon_mem.c \
- radeon_state.c \
- sis.h \
- sis_drm.h \
- sis_drv.h \
- sis_ds.c \
- sis_ds.h \
- sis_mm.c \
- tdfx.h \
- via.h \
- via_drm.h \
- via_drv.c \
- via_drv.h \
- via_ds.c \
- via_ds.h \
- via_irq.c \
- via_map.c \
- via_mm.c \
- via_mm.h \
- via_3d_reg.h \
- via_dma.c
-
-SUBDIR = i915 mach64 mga r128 radeon sis tdfx
-
-CLEANFILES+= ${SHAREDFILES}
-
-.include <bsd.obj.mk>
-
-depend: drm_pciids.h ${SHAREDFILES}
-all: drm_pciids.h ${SHAREDFILES}
-
-drm_pciids.h: ${SHARED}/drm_pciids.txt
- sh ../scripts/create_bsd_pci_lists.sh < ${SHARED}/drm_pciids.txt
-
-${SHAREDFILES}:
- ln -sf ${SHARED}/$@ $@
-
diff --git a/bsd/ati_pcigart.h b/bsd/ati_pcigart.h
deleted file mode 100644
index 9aa2192f..00000000
--- a/bsd/ati_pcigart.h
+++ /dev/null
@@ -1,114 +0,0 @@
-/* ati_pcigart.h -- ATI PCI GART support -*- linux-c -*-
- * Created: Wed Dec 13 21:52:19 2000 by gareth@valinux.com
- *
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-#if PAGE_SIZE == 8192
-# define ATI_PCIGART_TABLE_ORDER 2
-# define ATI_PCIGART_TABLE_PAGES (1 << 2)
-#elif PAGE_SIZE == 4096
-# define ATI_PCIGART_TABLE_ORDER 3
-# define ATI_PCIGART_TABLE_PAGES (1 << 3)
-#elif
-# error - PAGE_SIZE not 8K or 4K
-#endif
-
-# define ATI_MAX_PCIGART_PAGES 8192 /* 32 MB aperture, 4K pages */
-# define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */
-
-int DRM(ati_pcigart_init)( drm_device_t *dev,
- unsigned long *addr,
- dma_addr_t *bus_addr)
-{
- drm_sg_mem_t *entry = dev->sg;
- unsigned long address = 0;
- unsigned long pages;
- u32 *pci_gart=0, page_base, bus_address = 0;
- int i, j, ret = 0;
-
- if ( !entry ) {
- DRM_ERROR( "no scatter/gather memory!\n" );
- goto done;
- }
-
- address = (long)contigmalloc((1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
- DRM(M_DRM), M_NOWAIT, 0ul, 0xfffffffful, PAGE_SIZE, 0);
- if ( !address ) {
- DRM_ERROR( "cannot allocate PCI GART page!\n" );
- goto done;
- }
-
- /* XXX: we need to busdma this */
- bus_address = vtophys( address );
-
- pci_gart = (u32 *)address;
-
- pages = ( entry->pages <= ATI_MAX_PCIGART_PAGES )
- ? entry->pages : ATI_MAX_PCIGART_PAGES;
-
- bzero( pci_gart, ATI_MAX_PCIGART_PAGES * sizeof(u32) );
-
- for ( i = 0 ; i < pages ; i++ ) {
- entry->busaddr[i] = vtophys( entry->handle + (i*PAGE_SIZE) );
- page_base = (u32) entry->busaddr[i];
-
- for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
- *pci_gart++ = cpu_to_le32( page_base );
- page_base += ATI_PCIGART_PAGE_SIZE;
- }
- }
-
- DRM_MEMORYBARRIER();
-
- ret = 1;
-
-done:
- *addr = address;
- *bus_addr = bus_address;
- return ret;
-}
-
-int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
- unsigned long addr,
- dma_addr_t bus_addr)
-{
- drm_sg_mem_t *entry = dev->sg;
-
- /* we need to support large memory configurations */
- if ( !entry ) {
- DRM_ERROR( "no scatter/gather memory!\n" );
- return 0;
- }
-
-#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/drmP.h b/bsd/drmP.h
deleted file mode 100644
index 50612ad0..00000000
--- a/bsd/drmP.h
+++ /dev/null
@@ -1,625 +0,0 @@
-/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
- * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All rights reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#ifndef _DRM_P_H_
-#define _DRM_P_H_
-
-#if defined(_KERNEL) || defined(__KERNEL__)
-
-/* DRM template customization defaults
- */
-#ifndef __HAVE_AGP
-#define __HAVE_AGP 0
-#endif
-#ifndef __HAVE_MTRR
-#define __HAVE_MTRR 0
-#endif
-#ifndef __HAVE_CTX_BITMAP
-#define __HAVE_CTX_BITMAP 0
-#endif
-#ifndef __HAVE_DMA
-#define __HAVE_DMA 0
-#endif
-#ifndef __HAVE_IRQ
-#define __HAVE_IRQ 0
-#endif
-
-#define DRM_DEBUG_CODE 0 /* Include debugging code (if > 1, then
- also include looping detection. */
-
-typedef struct drm_device drm_device_t;
-typedef struct drm_file drm_file_t;
-
-/* There's undoubtably more of this file to go into these OS dependent ones. */
-
-#ifdef __FreeBSD__
-#include "drm_os_freebsd.h"
-#elif defined __NetBSD__
-#include "drm_os_netbsd.h"
-#endif
-
-#include "drm.h"
-
-/* Begin the DRM... */
-
-#define DRM_HASH_SIZE 16 /* Size of key hash table */
-#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
-#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
-
-#define DRM_FLAG_DEBUG 0x01
-
-#define DRM_MEM_DMA 0
-#define DRM_MEM_SAREA 1
-#define DRM_MEM_DRIVER 2
-#define DRM_MEM_MAGIC 3
-#define DRM_MEM_IOCTLS 4
-#define DRM_MEM_MAPS 5
-#define DRM_MEM_BUFS 6
-#define DRM_MEM_SEGS 7
-#define DRM_MEM_PAGES 8
-#define DRM_MEM_FILES 9
-#define DRM_MEM_QUEUES 10
-#define DRM_MEM_CMDS 11
-#define DRM_MEM_MAPPINGS 12
-#define DRM_MEM_BUFLISTS 13
-#define DRM_MEM_AGPLISTS 14
-#define DRM_MEM_TOTALAGP 15
-#define DRM_MEM_BOUNDAGP 16
-#define DRM_MEM_CTXBITMAP 17
-#define DRM_MEM_STUB 18
-#define DRM_MEM_SGLISTS 19
-
-#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
-
- /* Internal types and structures */
-#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
-#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
-#define DRM_MAX(a,b) ((a)>(b)?(a):(b))
-
-#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
-
-#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
- (_map) = (_dev)->context_sareas[_ctx]; \
-} while(0)
-
-
-typedef struct drm_pci_id_list
-{
- int vendor;
- int device;
- long driver_private;
- char *name;
-} drm_pci_id_list_t;
-
-typedef struct drm_ioctl_desc {
- int (*func)(DRM_IOCTL_ARGS);
- int auth_needed;
- int root_only;
-} drm_ioctl_desc_t;
-
-typedef struct drm_magic_entry {
- drm_magic_t magic;
- struct drm_file *priv;
- struct drm_magic_entry *next;
-} drm_magic_entry_t;
-
-typedef struct drm_magic_head {
- struct drm_magic_entry *head;
- struct drm_magic_entry *tail;
-} drm_magic_head_t;
-
-typedef struct drm_buf {
- int idx; /* Index into master buflist */
- int total; /* Buffer size */
- int order; /* log-base-2(total) */
- int used; /* Amount of buffer in use (for DMA) */
- unsigned long offset; /* Byte offset (used internally) */
- void *address; /* Address of buffer */
- unsigned long bus_address; /* Bus address of buffer */
- struct drm_buf *next; /* Kernel-only: used for free list */
- __volatile__ int pending; /* On hardware DMA queue */
- DRMFILE filp; /* Unique identifier of holding process */
- int context; /* Kernel queue for this buffer */
- enum {
- DRM_LIST_NONE = 0,
- DRM_LIST_FREE = 1,
- DRM_LIST_WAIT = 2,
- DRM_LIST_PEND = 3,
- DRM_LIST_PRIO = 4,
- DRM_LIST_RECLAIM = 5
- } list; /* Which list we're on */
-
- int dev_priv_size; /* Size of buffer private stoarge */
- void *dev_private; /* Per-buffer private storage */
-} drm_buf_t;
-
-typedef struct drm_freelist {
- int initialized; /* Freelist in use */
- atomic_t count; /* Number of free buffers */
- drm_buf_t *next; /* End pointer */
-
- int low_mark; /* Low water mark */
- int high_mark; /* High water mark */
-} drm_freelist_t;
-
-typedef struct drm_buf_entry {
- int buf_size;
- int buf_count;
- drm_buf_t *buflist;
- int seg_count;
- int page_order;
- vm_offset_t *seglist;
- dma_addr_t *seglist_bus;
-
- drm_freelist_t freelist;
-} drm_buf_entry_t;
-
-typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
-struct drm_file {
- TAILQ_ENTRY(drm_file) link;
- int authenticated;
- int minor;
- pid_t pid;
- uid_t uid;
- int refs;
- drm_magic_t magic;
- unsigned long ioctl_count;
- struct drm_device *devXX;
-#ifdef DRIVER_FILE_FIELDS
- DRIVER_FILE_FIELDS;
-#endif
-};
-
-typedef struct drm_lock_data {
- drm_hw_lock_t *hw_lock; /* Hardware lock */
- DRMFILE filp; /* Unique identifier of holding process (NULL is kernel)*/
- int lock_queue; /* Queue of blocked processes */
- unsigned long lock_time; /* Time of last lock in jiffies */
-} drm_lock_data_t;
-
-/* This structure, in the drm_device_t, is always initialized while the device
- * is open. dev->dma_lock protects the incrementing of dev->buf_use, which
- * when set marks that no further bufs may be allocated until device teardown
- * occurs (when the last open of the device has closed). The high/low
- * watermarks of bufs are only touched by the X Server, and thus not
- * concurrently accessed, so no locking is needed.
- */
-typedef struct drm_device_dma {
- drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
- int buf_count;
- drm_buf_t **buflist; /* Vector of pointers info bufs */
- int seg_count;
- int page_count;
- unsigned long *pagelist;
- unsigned long byte_count;
- enum {
- _DRM_DMA_USE_AGP = 0x01,
- _DRM_DMA_USE_SG = 0x02,
- _DRM_DMA_USE_FB = 0x04
- } flags;
-
- /* DMA support */
- drm_buf_t *this_buffer; /* Buffer being sent */
- drm_buf_t *next_buffer; /* Selected buffer to send */
-} drm_device_dma_t;
-
-#if __REALLY_HAVE_AGP
-typedef struct drm_agp_mem {
- void *handle;
- unsigned long bound; /* address */
- int pages;
- struct drm_agp_mem *prev;
- struct drm_agp_mem *next;
-} drm_agp_mem_t;
-
-typedef struct drm_agp_head {
- device_t agpdev;
- struct agp_info info;
- const char *chipset;
- drm_agp_mem_t *memory;
- unsigned long mode;
- int enabled;
- int acquired;
- unsigned long base;
- int mtrr;
- int cant_use_aperture;
- unsigned long page_mask;
-} drm_agp_head_t;
-#endif
-
-typedef struct drm_sg_mem {
- unsigned long handle;
- void *virtual;
- int pages;
- dma_addr_t *busaddr;
-} drm_sg_mem_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; /* Boolean: MTRR 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_local_map_t *map;
-} drm_map_list_entry_t;
-
-TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig);
-typedef struct drm_vbl_sig {
- TAILQ_ENTRY(drm_vbl_sig) link;
- unsigned int sequence;
- int signo;
- int pid;
-} drm_vbl_sig_t;
-
-/**
- * DRM device functions structure
- */
-struct drm_device;
-
-struct drm_driver_fn {
- int (*preinit)(struct drm_device *, unsigned long flags);
- int (*postinit)(struct drm_device *, unsigned long flags);
- void (*prerelease)(struct drm_device *, void *filp);
- void (*pretakedown)(struct drm_device *);
- int (*postcleanup)(struct drm_device *);
- int (*presetup)(struct drm_device *);
- int (*postsetup)(struct drm_device *);
- void (*open_helper)(struct drm_device *, drm_file_t *);
- void (*release)(struct drm_device *, void *filp);
- void (*dma_ready)(struct drm_device *);
- int (*dma_quiescent)(struct drm_device *);
- int (*dma_flush_block_and_flush)(struct drm_device *, int context, drm_lock_flags_t flags);
- int (*dma_flush_unblock)(struct drm_device *, int context, drm_lock_flags_t flags);
- int (*context_ctor)(struct drm_device *dev, int context);
- int (*context_dtor)(struct drm_device *dev, int context);
- int (*kernel_context_switch)(struct drm_device *dev, int old, int new);
- int (*kernel_context_switch_unlock)(struct drm_device *dev);
- int (*dma_schedule)(struct drm_device *dev, int locked);
-};
-
-struct drm_device {
-#ifdef __NetBSD__
- struct device device; /* NetBSD's softc is an extension of struct device */
-#endif
- const char *name; /* Simple driver name */
- char *unique; /* Unique identifier: e.g., busid */
- int unique_len; /* Length of unique field */
-#ifdef __FreeBSD__
- device_t device; /* Device instance from newbus */
-#endif
- struct cdev *devnode; /* Device number for mknod */
- int if_version; /* Highest interface version set */
-
- int flags; /* Flags to open(2) */
-
- /* Locks */
-#if defined(__FreeBSD__) && __FreeBSD_version > 500000
-#if __HAVE_DMA
- struct mtx dma_lock; /* protects dev->dma */
-#endif
-#if __HAVE_IRQ
- struct mtx irq_lock; /* protects irq condition checks */
-#endif
- struct mtx dev_lock; /* protects everything else */
-#endif
- /* Usage Counters */
- int open_count; /* Outstanding files open */
- int buf_use; /* Buffers in use -- cannot alloc */
-
- /* Performance counters */
- unsigned long counters;
- drm_stat_type_t types[15];
- atomic_t counts[15];
-
- /* Authentication */
- drm_file_list_t files;
- drm_magic_head_t magiclist[DRM_HASH_SIZE];
-
- /* Linked list of mappable regions. Protected by dev_lock */
- drm_map_list_t *maplist;
-
- drm_local_map_t **context_sareas;
- int max_context;
-
- drm_lock_data_t lock; /* Information on hardware lock */
-
- /* DMA queues (contexts) */
- drm_device_dma_t *dma; /* Optional pointer for DMA support */
-
- /* Context support */
- int irq; /* Interrupt used by board */
- int irq_enabled; /* True if the irq handler is enabled */
-#ifdef __FreeBSD__
- int irqrid; /* Interrupt used by board */
- struct resource *irqr; /* Resource for interrupt used by board */
-#elif defined(__NetBSD__)
- struct pci_attach_args pa;
- pci_intr_handle_t ih;
-#endif
- void *irqh; /* Handle from bus_setup_intr */
-
- int pci_domain;
- int pci_bus;
- int pci_slot;
- int pci_func;
-
- atomic_t context_flag; /* Context swapping flag */
- int last_context; /* Last current context */
-#if __FreeBSD_version >= 400005
- struct task task;
-#endif
-#if __HAVE_VBL_IRQ
- int vbl_queue; /* vbl wait channel */
- atomic_t vbl_received;
-#endif
-
-#ifdef __FreeBSD__
- struct sigio *buf_sigio; /* Processes waiting for SIGIO */
-#elif defined(__NetBSD__)
- pid_t buf_pgid;
-#endif
-
- /* Sysctl support */
- struct drm_sysctl_info *sysctl;
-
-#if __REALLY_HAVE_AGP
- drm_agp_head_t *agp;
-#endif
- drm_sg_mem_t *sg; /* Scatter gather memory */
- atomic_t *ctx_bitmap;
- void *dev_private;
- struct drm_driver_fn fn_tbl;
- drm_local_map_t *agp_buffer_map;
- int dev_priv_size;
-};
-
-extern void DRM(driver_register_fns)(struct drm_device *dev);
-
-extern int DRM(flags);
-
- /* 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(calloc)(size_t nmemb, size_t size, int area);
-extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
- int area);
-extern void DRM(free)(void *pt, size_t size, int area);
-extern void *DRM(ioremap)(drm_device_t *dev, drm_local_map_t *map);
-extern void DRM(ioremapfree)(drm_local_map_t *map);
-extern int DRM(mtrr_add)(unsigned long offset, size_t size, int flags);
-extern int DRM(mtrr_del)(unsigned long offset, size_t size, int flags);
-
-#if __REALLY_HAVE_AGP
-extern agp_memory *DRM(alloc_agp)(int pages, u32 type);
-extern int DRM(free_agp)(agp_memory *handle, int pages);
-extern int DRM(bind_agp)(agp_memory *handle, unsigned int start);
-extern int DRM(unbind_agp)(agp_memory *handle);
-#endif
-
-extern int DRM(context_switch)(drm_device_t *dev, int old, int new);
-extern int DRM(context_switch_complete)(drm_device_t *dev, int new);
-
-#if __HAVE_CTX_BITMAP
-extern int DRM(ctxbitmap_init)( drm_device_t *dev );
-extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
-extern void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle );
-extern int DRM(ctxbitmap_next)( drm_device_t *dev );
-#endif
-
- /* Locking IOCTL support (drm_lock.h) */
-extern int DRM(lock_take)(__volatile__ unsigned int *lock,
- unsigned int context);
-extern int DRM(lock_transfer)(drm_device_t *dev,
- __volatile__ unsigned int *lock,
- unsigned int context);
-extern int DRM(lock_free)(drm_device_t *dev,
- __volatile__ unsigned int *lock,
- unsigned int context);
-
- /* Buffer management support (drm_bufs.h) */
-extern int DRM(order)( unsigned long size );
-
-#if __HAVE_DMA
- /* DMA support (drm_dma.h) */
-extern int DRM(dma_setup)(drm_device_t *dev);
-extern void DRM(dma_takedown)(drm_device_t *dev);
-extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
-extern void DRM(reclaim_buffers)(drm_device_t *dev, DRMFILE filp);
-#endif
-
-#if __HAVE_IRQ
- /* IRQ support (drm_irq.h) */
-extern int DRM(irq_install)(drm_device_t *dev);
-extern int DRM(irq_uninstall)( drm_device_t *dev );
-extern irqreturn_t DRM(irq_handler)( DRM_IRQ_ARGS );
-extern void DRM(driver_irq_preinstall)( drm_device_t *dev );
-extern void DRM(driver_irq_postinstall)( drm_device_t *dev );
-extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
-#if __HAVE_IRQ_BH
-extern void DRM(irq_immediate_bh)( DRM_TASKQUEUE_ARGS );
-#endif
-#endif
-
-#if __HAVE_VBL_IRQ
-extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
-extern void DRM(vbl_send_signals)( drm_device_t *dev );
-#endif
-
-#if __REALLY_HAVE_AGP
- /* AGP/GART support (drm_agpsupport.h) */
-extern drm_agp_head_t *DRM(agp_init)(void);
-extern void DRM(agp_uninit)(void);
-extern void DRM(agp_do_release)(void);
-extern agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type);
-extern int DRM(agp_free_memory)(agp_memory *handle);
-extern int DRM(agp_bind_memory)(agp_memory *handle, off_t start);
-extern int DRM(agp_unbind_memory)(agp_memory *handle);
-#endif
-
-#if __HAVE_SG
- /* Scatter Gather Support (drm_scatter.h) */
-extern void DRM(sg_cleanup)(drm_sg_mem_t *entry);
-#endif
-
-#if __REALLY_HAVE_SG
- /* ATI PCIGART support (ati_pcigart.h) */
-extern int DRM(ati_pcigart_init)(drm_device_t *dev,
- unsigned long *addr,
- dma_addr_t *bus_addr);
-extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
- unsigned long addr,
- dma_addr_t bus_addr);
-#endif
-
-/* Locking IOCTL support (drm_drv.h) */
-extern int DRM(lock)(DRM_IOCTL_ARGS);
-extern int DRM(unlock)(DRM_IOCTL_ARGS);
-extern int DRM(version)( DRM_IOCTL_ARGS );
-extern int DRM(setversion)( DRM_IOCTL_ARGS );
-
-/* Misc. IOCTL support (drm_ioctl.h) */
-extern int DRM(irq_by_busid)(DRM_IOCTL_ARGS);
-extern int DRM(getunique)(DRM_IOCTL_ARGS);
-extern int DRM(setunique)(DRM_IOCTL_ARGS);
-extern int DRM(getmap)(DRM_IOCTL_ARGS);
-extern int DRM(getclient)(DRM_IOCTL_ARGS);
-extern int DRM(getstats)(DRM_IOCTL_ARGS);
-extern int DRM(noop)(DRM_IOCTL_ARGS);
-
-/* Context IOCTL support (drm_context.h) */
-extern int DRM(resctx)(DRM_IOCTL_ARGS);
-extern int DRM(addctx)(DRM_IOCTL_ARGS);
-extern int DRM(modctx)(DRM_IOCTL_ARGS);
-extern int DRM(getctx)(DRM_IOCTL_ARGS);
-extern int DRM(switchctx)(DRM_IOCTL_ARGS);
-extern int DRM(newctx)(DRM_IOCTL_ARGS);
-extern int DRM(rmctx)(DRM_IOCTL_ARGS);
-extern int DRM(setsareactx)(DRM_IOCTL_ARGS);
-extern int DRM(getsareactx)(DRM_IOCTL_ARGS);
-
-/* Drawable IOCTL support (drm_drawable.h) */
-extern int DRM(adddraw)(DRM_IOCTL_ARGS);
-extern int DRM(rmdraw)(DRM_IOCTL_ARGS);
-
-/* Authentication IOCTL support (drm_auth.h) */
-extern int DRM(getmagic)(DRM_IOCTL_ARGS);
-extern int DRM(authmagic)(DRM_IOCTL_ARGS);
-
-/* Buffer management support (drm_bufs.h) */
-extern int DRM(addmap)(DRM_IOCTL_ARGS);
-extern int DRM(rmmap)(DRM_IOCTL_ARGS);
-#if __HAVE_DMA
-extern int DRM(addbufs)(DRM_IOCTL_ARGS);
-extern int DRM(infobufs)(DRM_IOCTL_ARGS);
-extern int DRM(markbufs)(DRM_IOCTL_ARGS);
-extern int DRM(freebufs)(DRM_IOCTL_ARGS);
-extern int DRM(mapbufs)(DRM_IOCTL_ARGS);
-#endif
-
-/* IRQ support (drm_irq.h) */
-#if __HAVE_IRQ || __HAVE_DMA
-extern int DRM(control)(DRM_IOCTL_ARGS);
-#endif
-#if __HAVE_VBL_IRQ
-extern int DRM(wait_vblank)(DRM_IOCTL_ARGS);
-#endif
-
-/* AGP/GART support (drm_agpsupport.h) */
-#if __REALLY_HAVE_AGP
-extern int DRM(agp_acquire)(DRM_IOCTL_ARGS);
-extern int DRM(agp_release)(DRM_IOCTL_ARGS);
-extern int DRM(agp_enable)(DRM_IOCTL_ARGS);
-extern int DRM(agp_info)(DRM_IOCTL_ARGS);
-extern int DRM(agp_alloc)(DRM_IOCTL_ARGS);
-extern int DRM(agp_free)(DRM_IOCTL_ARGS);
-extern int DRM(agp_unbind)(DRM_IOCTL_ARGS);
-extern int DRM(agp_bind)(DRM_IOCTL_ARGS);
-#endif
-
-/* Scatter Gather Support (drm_scatter.h) */
-#if __HAVE_SG
-extern int DRM(sg_alloc)(DRM_IOCTL_ARGS);
-extern int DRM(sg_free)(DRM_IOCTL_ARGS);
-#endif
-
-/* consistent PCI memory functions (drm_pci.h) */
-extern void *DRM(pci_alloc)(drm_device_t *dev, size_t size,
- size_t align, dma_addr_t maxaddr,
- dma_addr_t *busaddr);
-extern void DRM(pci_free)(drm_device_t *dev, size_t size,
- void *vaddr, dma_addr_t busaddr);
-
-/* Inline replacements for DRM_IOREMAP macros */
-static __inline__ void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
-{
- map->handle = DRM(ioremap)( dev, map );
-}
-#if 0
-static __inline__ void drm_core_ioremap_nocache(struct drm_map *map, struct drm_device *dev)
-{
- map->handle = DRM(ioremap_nocache)(dev, map);
-}
-#endif
-static __inline__ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
-{
- if ( map->handle && map->size )
- DRM(ioremapfree)( map );
-}
-
-static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, unsigned long offset)
-{
- drm_map_list_entry_t *listentry;
- TAILQ_FOREACH(listentry, dev->maplist, link) {
- if ( listentry->map->offset == offset ) {
- return listentry->map;
- }
- }
- return NULL;
-}
-
-static __inline__ void drm_core_dropmap(struct drm_map *map)
-{
-}
-
-#endif /* __KERNEL__ */
-#endif /* _DRM_P_H_ */
diff --git a/bsd/drm_agpsupport.h b/bsd/drm_agpsupport.h
deleted file mode 100644
index 7e290b87..00000000
--- a/bsd/drm_agpsupport.h
+++ /dev/null
@@ -1,314 +0,0 @@
-/* drm_agpsupport.h -- DRM support for AGP/GART backend -*- linux-c -*-
- * Created: Mon Dec 13 09:56:45 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Author:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-int DRM(agp_info)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- struct agp_info *kern;
- drm_agp_info_t info;
-
- if (!dev->agp || !dev->agp->acquired)
- return EINVAL;
-
- kern = &dev->agp->info;
- agp_get_info(dev->agp->agpdev, kern);
- info.agp_version_major = 1;
- info.agp_version_minor = 0;
- info.mode = kern->ai_mode;
- info.aperture_base = kern->ai_aperture_base;
- info.aperture_size = kern->ai_aperture_size;
- info.memory_allowed = kern->ai_memory_allowed;
- info.memory_used = kern->ai_memory_used;
- info.id_vendor = kern->ai_devid & 0xffff;
- info.id_device = kern->ai_devid >> 16;
-
- *(drm_agp_info_t *) data = info;
- return 0;
-}
-
-int DRM(agp_acquire)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- int retcode;
-
- if (!dev->agp || dev->agp->acquired)
- return EINVAL;
- retcode = agp_acquire(dev->agp->agpdev);
- if (retcode)
- return retcode;
- dev->agp->acquired = 1;
- return 0;
-}
-
-int DRM(agp_release)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
-
- if (!dev->agp || !dev->agp->acquired)
- return EINVAL;
- agp_release(dev->agp->agpdev);
- dev->agp->acquired = 0;
- return 0;
-
-}
-
-void DRM(agp_do_release)(void)
-{
- device_t agpdev;
-
- agpdev = DRM_AGP_FIND_DEVICE();
- if (agpdev)
- agp_release(agpdev);
-}
-
-int DRM(agp_enable)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- drm_agp_mode_t mode;
-
- if (!dev->agp || !dev->agp->acquired)
- return EINVAL;
-
- mode = *(drm_agp_mode_t *) data;
-
- dev->agp->mode = mode.mode;
- agp_enable(dev->agp->agpdev, mode.mode);
- dev->agp->base = dev->agp->info.ai_aperture_base;
- dev->agp->enabled = 1;
- return 0;
-}
-
-int DRM(agp_alloc)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- drm_agp_buffer_t request;
- drm_agp_mem_t *entry;
- void *handle;
- unsigned long pages;
- u_int32_t type;
- struct agp_memory_info info;
-
- if (!dev->agp || !dev->agp->acquired)
- return EINVAL;
-
- request = *(drm_agp_buffer_t *) data;
-
- if (!(entry = DRM(alloc)(sizeof(*entry), DRM_MEM_AGPLISTS)))
- return ENOMEM;
-
- bzero(entry, sizeof(*entry));
-
- pages = (request.size + PAGE_SIZE - 1) / PAGE_SIZE;
- type = (u_int32_t) request.type;
-
- if (!(handle = DRM(alloc_agp)(pages, type))) {
- DRM(free)(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
- return ENOMEM;
- }
-
- entry->handle = handle;
- entry->bound = 0;
- entry->pages = pages;
- entry->prev = NULL;
- entry->next = dev->agp->memory;
- if (dev->agp->memory)
- dev->agp->memory->prev = entry;
- dev->agp->memory = entry;
-
- agp_memory_info(dev->agp->agpdev, entry->handle, &info);
-
- request.handle = (unsigned long) entry->handle;
- request.physical = info.ami_physical;
-
- *(drm_agp_buffer_t *) data = request;
-
- return 0;
-}
-
-static drm_agp_mem_t * DRM(agp_lookup_entry)(drm_device_t *dev, void *handle)
-{
- drm_agp_mem_t *entry;
-
- for (entry = dev->agp->memory; entry; entry = entry->next) {
- if (entry->handle == handle) return entry;
- }
- return NULL;
-}
-
-int DRM(agp_unbind)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- drm_agp_binding_t request;
- drm_agp_mem_t *entry;
- int retcode;
-
- 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;
- if (!entry->bound) return EINVAL;
- retcode=DRM(unbind_agp)(entry->handle);
- if (!retcode)
- {
- entry->bound=0;
- return 0;
- }
- else
- return retcode;
-}
-
-int DRM(agp_bind)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- drm_agp_binding_t request;
- drm_agp_mem_t *entry;
- int retcode;
- int page;
-
- DRM_DEBUG("agp_bind, page_size=%x\n", PAGE_SIZE);
- 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;
- if (entry->bound) return EINVAL;
- page = (request.offset + PAGE_SIZE - 1) / PAGE_SIZE;
- if ((retcode = DRM(bind_agp)(entry->handle, page)))
- return retcode;
- entry->bound = dev->agp->base + (page << PAGE_SHIFT);
- return 0;
-}
-
-int DRM(agp_free)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- drm_agp_buffer_t request;
- drm_agp_mem_t *entry;
-
- 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->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;
-}
-
-drm_agp_head_t *DRM(agp_init)(void)
-{
- device_t agpdev;
- drm_agp_head_t *head = NULL;
- int agp_available = 1;
-
- agpdev = DRM_AGP_FIND_DEVICE();
- if (!agpdev)
- agp_available = 0;
-
- DRM_DEBUG("agp_available = %d\n", agp_available);
-
- if (agp_available) {
- if (!(head = DRM(alloc)(sizeof(*head), DRM_MEM_AGPLISTS)))
- return NULL;
- bzero((void *)head, sizeof(*head));
- head->agpdev = agpdev;
- agp_get_info(agpdev, &head->info);
- head->memory = NULL;
- DRM_INFO("AGP at 0x%08lx %dMB\n",
- (long)head->info.ai_aperture_base,
- (int)(head->info.ai_aperture_size >> 20));
- }
- return head;
-}
-
-void DRM(agp_uninit)(void)
-{
-/* FIXME: What goes here */
-}
-
-
-agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type)
-{
- device_t agpdev;
-
- agpdev = DRM_AGP_FIND_DEVICE();
- if (!agpdev)
- return NULL;
-
- return agp_alloc_memory(agpdev, type, pages << AGP_PAGE_SHIFT);
-}
-
-int DRM(agp_free_memory)(agp_memory *handle)
-{
- device_t agpdev;
-
- agpdev = DRM_AGP_FIND_DEVICE();
- if (!agpdev || !handle)
- return 0;
-
- agp_free_memory(agpdev, handle);
- return 1;
-}
-
-int DRM(agp_bind_memory)(agp_memory *handle, off_t start)
-{
- device_t agpdev;
-
- agpdev = DRM_AGP_FIND_DEVICE();
- if (!agpdev || !handle)
- return EINVAL;
-
- return agp_bind_memory(agpdev, handle, start * PAGE_SIZE);
-}
-
-int DRM(agp_unbind_memory)(agp_memory *handle)
-{
- device_t agpdev;
-
- agpdev = DRM_AGP_FIND_DEVICE();
- if (!agpdev || !handle)
- return EINVAL;
-
- return agp_unbind_memory(agpdev, handle);
-}
diff --git a/bsd/drm_auth.h b/bsd/drm_auth.h
deleted file mode 100644
index 537718c1..00000000
--- a/bsd/drm_auth.h
+++ /dev/null
@@ -1,164 +0,0 @@
-/* drm_auth.h -- IOCTLs for authentication -*- linux-c -*-
- * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-static int DRM(hash_magic)(drm_magic_t magic)
-{
- return magic & (DRM_HASH_SIZE-1);
-}
-
-static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic)
-{
- drm_file_t *retval = NULL;
- drm_magic_entry_t *pt;
- int hash = DRM(hash_magic)(magic);
-
- DRM_LOCK();
- for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
- if (pt->magic == magic) {
- retval = pt->priv;
- break;
- }
- }
- DRM_UNLOCK();
- return retval;
-}
-
-static int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
-{
- int hash;
- drm_magic_entry_t *entry;
-
- DRM_DEBUG("%d\n", magic);
-
- hash = DRM(hash_magic)(magic);
- entry = (drm_magic_entry_t*) DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC);
- if (!entry) return DRM_ERR(ENOMEM);
- memset(entry, 0, sizeof(*entry));
- entry->magic = magic;
- entry->priv = priv;
- entry->next = NULL;
-
- DRM_LOCK();
- if (dev->magiclist[hash].tail) {
- dev->magiclist[hash].tail->next = entry;
- dev->magiclist[hash].tail = entry;
- } else {
- dev->magiclist[hash].head = entry;
- dev->magiclist[hash].tail = entry;
- }
- DRM_UNLOCK();
-
- return 0;
-}
-
-static int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
-{
- drm_magic_entry_t *prev = NULL;
- drm_magic_entry_t *pt;
- int hash;
-
- DRM_DEBUG("%d\n", magic);
- hash = DRM(hash_magic)(magic);
-
- DRM_LOCK();
- for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
- if (pt->magic == magic) {
- if (dev->magiclist[hash].head == pt) {
- dev->magiclist[hash].head = pt->next;
- }
- if (dev->magiclist[hash].tail == pt) {
- dev->magiclist[hash].tail = prev;
- }
- if (prev) {
- prev->next = pt->next;
- }
- DRM_UNLOCK();
- return 0;
- }
- }
- DRM_UNLOCK();
-
- DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC);
- return DRM_ERR(EINVAL);
-}
-
-int DRM(getmagic)(DRM_IOCTL_ARGS)
-{
- static drm_magic_t sequence = 0;
- drm_auth_t auth;
- drm_file_t *priv;
- DRM_DEVICE;
-
- DRM_GET_PRIV_WITH_RETURN(priv, filp);
-
- /* Find unique magic */
- if (priv->magic) {
- auth.magic = priv->magic;
- } else {
- do {
- 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);
- }
-
- DRM_DEBUG("%u\n", auth.magic);
-
- DRM_COPY_TO_USER_IOCTL((drm_auth_t *)data, auth, sizeof(auth));
-
- return 0;
-}
-
-int DRM(authmagic)(DRM_IOCTL_ARGS)
-{
- drm_auth_t auth;
- drm_file_t *file;
- DRM_DEVICE;
-
- DRM_COPY_FROM_USER_IOCTL(auth, (drm_auth_t *)data, sizeof(auth));
-
- DRM_DEBUG("%u\n", auth.magic);
-
- if ((file = DRM(find_file)(dev, auth.magic))) {
- file->authenticated = 1;
- DRM(remove_magic)(dev, auth.magic);
- return 0;
- }
- return DRM_ERR(EINVAL);
-}
diff --git a/bsd/drm_bufs.h b/bsd/drm_bufs.h
deleted file mode 100644
index d27254c2..00000000
--- a/bsd/drm_bufs.h
+++ /dev/null
@@ -1,961 +0,0 @@
-/* drm_bufs.h -- Generic buffer template -*- linux-c -*-
- * Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-#ifndef __HAVE_PCI_DMA
-#define __HAVE_PCI_DMA 0
-#endif
-
-#ifndef __HAVE_SG
-#define __HAVE_SG 0
-#endif
-
-/*
- * Compute order. Can be made faster.
- */
-int DRM(order)( unsigned long size )
-{
- int order;
- unsigned long tmp;
-
- for ( order = 0, tmp = size ; tmp >>= 1 ; ++order );
-
- if ( size & ~(1 << order) )
- ++order;
-
- return order;
-}
-
-int DRM(addmap)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- 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 */
-
- 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->offset = request.offset;
- map->size = request.size;
- map->type = request.type;
- map->flags = request.flags;
- map->mtrr = 0;
- 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.
- */
- if ( (map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM ) {
- DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
- return DRM_ERR(EINVAL);
- }
- DRM_DEBUG( "offset = 0x%08lx, size = 0x%08lx, type = %d\n",
- map->offset, map->size, map->type );
- if ( (map->offset & PAGE_MASK) || (map->size & PAGE_MASK) ) {
- DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
- return DRM_ERR(EINVAL);
- }
- if (map->offset + map->size < map->offset) {
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
- return DRM_ERR(EINVAL);
- }
-
- switch ( map->type ) {
- case _DRM_REGISTERS:
- drm_core_ioremap(map, dev);
- if (!(map->flags & _DRM_WRITE_COMBINING))
- break;
- /* FALLTHROUGH */
- case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if (DRM(mtrr_add)(map->offset, map->size, DRM_MTRR_WC) == 0)
- map->mtrr = 1;
-#endif
- break;
- case _DRM_SHM:
- map->handle = (void *)DRM(alloc)(map->size, DRM_MEM_SAREA);
- DRM_DEBUG( "%lu %d %p\n",
- map->size, DRM(order)( map->size ), map->handle );
- if ( !map->handle ) {
- DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
- return DRM_ERR(ENOMEM);
- }
- map->offset = (unsigned long)map->handle;
- if ( map->flags & _DRM_CONTAINS_LOCK ) {
- /* Prevent a 2nd X Server from creating a 2nd lock */
- DRM_LOCK();
- if (dev->lock.hw_lock != NULL) {
- DRM_UNLOCK();
- DRM(free)(map->handle, map->size,
- DRM_MEM_SAREA);
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
- return DRM_ERR(EBUSY);
- }
- dev->lock.hw_lock = map->handle; /* Pointer to lock */
- DRM_UNLOCK();
- }
- break;
-#if __REALLY_HAVE_AGP
- case _DRM_AGP:
- map->offset += dev->agp->base;
- map->mtrr = dev->agp->mtrr; /* for getmap */
- break;
-#endif
- case _DRM_SCATTER_GATHER:
- if (!dev->sg) {
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
- return DRM_ERR(EINVAL);
- }
- map->offset = map->offset + dev->sg->handle;
- break;
-
- default:
- DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
- return DRM_ERR(EINVAL);
- }
-
- list = DRM(calloc)(1, sizeof(*list), DRM_MEM_MAPS);
- if (list == NULL) {
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
- return DRM_ERR(EINVAL);
- }
- list->map = map;
-
- DRM_LOCK();
- TAILQ_INSERT_TAIL(dev->maplist, list, link);
- DRM_UNLOCK();
-
- 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 ( 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;
-}
-
-
-/* Remove a map private from list and deallocate resources if the mapping
- * isn't in use.
- */
-
-int DRM(rmmap)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_map_list_entry_t *list;
- drm_local_map_t *map;
- drm_map_t request;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_map_t *)data, sizeof(request) );
-
- DRM_LOCK();
- TAILQ_FOREACH(list, dev->maplist, link) {
- map = list->map;
- if (map->handle == request.handle &&
- map->flags & _DRM_REMOVABLE)
- break;
- }
-
- /* No match found. */
- if (list == NULL) {
- DRM_UNLOCK();
- return DRM_ERR(EINVAL);
- }
- TAILQ_REMOVE(dev->maplist, list, link);
- DRM_UNLOCK();
-
- DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
-
- switch (map->type) {
- case _DRM_REGISTERS:
- case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if (map->mtrr) {
- int __unused retcode;
-
- retcode = DRM(mtrr_del)(map->offset, map->size,
- DRM_MTRR_WC);
- DRM_DEBUG("mtrr_del = %d\n", retcode);
- }
-#endif
- DRM(ioremapfree)(map);
- break;
- case _DRM_SHM:
- DRM(free)(map->handle, map->size, DRM_MEM_SAREA);
- break;
- case _DRM_AGP:
- case _DRM_SCATTER_GATHER:
- break;
- }
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
- return 0;
-}
-
-#if __HAVE_DMA
-
-
-static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry)
-{
- int i;
-
-#if __HAVE_PCI_DMA
- if (entry->seg_count) {
- for (i = 0; i < entry->seg_count; i++) {
- if (entry->seglist[i] != 0)
- DRM(pci_free)(dev, entry->buf_size,
- (void *)entry->seglist[i],
- entry->seglist_bus[i]);
- }
- DRM(free)(entry->seglist,
- entry->seg_count *
- sizeof(*entry->seglist),
- DRM_MEM_SEGS);
- DRM(free)(entry->seglist_bus, entry->seg_count *
- sizeof(*entry->seglist_bus), DRM_MEM_SEGS);
-
- entry->seg_count = 0;
- }
-#endif /* __HAVE_PCI_DMA */
-
- if (entry->buf_count) {
- for (i = 0; i < entry->buf_count; i++) {
- DRM(free)(entry->buflist[i].dev_private,
- entry->buflist[i].dev_priv_size, DRM_MEM_BUFS);
- }
- DRM(free)(entry->buflist,
- entry->buf_count *
- sizeof(*entry->buflist),
- DRM_MEM_BUFS);
-
- entry->buf_count = 0;
- }
-}
-
-#if __REALLY_HAVE_AGP
-static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
-{
- drm_device_dma_t *dma = dev->dma;
- drm_buf_entry_t *entry;
- drm_buf_t *buf;
- unsigned long offset;
- unsigned long agp_offset;
- int count;
- int order;
- int size;
- int alignment;
- int page_order;
- int total;
- int byte_count;
- int i;
- drm_buf_t **temp_buflist;
-
- count = request->count;
- order = DRM(order)(request->size);
- size = 1 << order;
-
- alignment = (request->flags & _DRM_PAGE_ALIGN)
- ? round_page(size) : size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
-
- byte_count = 0;
- agp_offset = dev->agp->base + request->agp_start;
-
- DRM_DEBUG( "count: %d\n", count );
- DRM_DEBUG( "order: %d\n", order );
- DRM_DEBUG( "size: %d\n", size );
- DRM_DEBUG( "agp_offset: 0x%lx\n", agp_offset );
- DRM_DEBUG( "alignment: %d\n", alignment );
- DRM_DEBUG( "page_order: %d\n", page_order );
- DRM_DEBUG( "total: %d\n", total );
-
- entry = &dma->bufs[order];
-
- entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist),
- DRM_MEM_BUFS );
- if ( !entry->buflist ) {
- return DRM_ERR(ENOMEM);
- }
- memset( entry->buflist, 0, count * sizeof(*entry->buflist) );
-
- entry->buf_size = size;
- entry->page_order = page_order;
-
- offset = 0;
-
- while ( entry->buf_count < count ) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
-
- buf->offset = (dma->byte_count + offset);
- buf->bus_address = agp_offset + offset;
- buf->address = (void *)(agp_offset + offset);
- buf->next = NULL;
- buf->pending = 0;
- buf->filp = NULL;
-
- buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = DRM(calloc)(1, buf->dev_priv_size,
- DRM_MEM_BUFS);
- if (buf->dev_private == NULL) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- DRM(cleanup_buf_error)(dev, entry);
- return DRM_ERR(ENOMEM);
- }
-
- offset += alignment;
- entry->buf_count++;
- byte_count += PAGE_SIZE << page_order;
- }
-
- DRM_DEBUG( "byte_count: %d\n", byte_count );
-
- temp_buflist = DRM(realloc)( dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS );
- if (temp_buflist == NULL) {
- /* Free the entry because it isn't valid */
- DRM(cleanup_buf_error)(dev, entry);
- return DRM_ERR(ENOMEM);
- }
- dma->buflist = temp_buflist;
-
- for ( i = 0 ; i < entry->buf_count ; i++ ) {
- dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
-
- dma->buf_count += entry->buf_count;
- dma->byte_count += byte_count;
-
- DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count );
- DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count );
-
- request->count = entry->buf_count;
- request->size = size;
-
- dma->flags = _DRM_DMA_USE_AGP;
-
- return 0;
-}
-#endif /* __REALLY_HAVE_AGP */
-
-#if __HAVE_PCI_DMA
-static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
-{
- drm_device_dma_t *dma = dev->dma;
- int count;
- int order;
- int size;
- int total;
- int page_order;
- drm_buf_entry_t *entry;
- vm_offset_t vaddr;
- drm_buf_t *buf;
- int alignment;
- unsigned long offset;
- int i;
- int byte_count;
- int page_count;
- unsigned long *temp_pagelist;
- drm_buf_t **temp_buflist;
- dma_addr_t bus_addr;
-
- count = request->count;
- order = DRM(order)(request->size);
- size = 1 << order;
-
- DRM_DEBUG( "count=%d, size=%d (%d), order=%d\n",
- request->count, request->size, size, order );
-
- alignment = (request->flags & _DRM_PAGE_ALIGN)
- ? round_page(size) : size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
-
- entry = &dma->bufs[order];
-
- entry->buflist = DRM(alloc)(count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- entry->seglist = DRM(alloc)(count * sizeof(*entry->seglist),
- DRM_MEM_SEGS);
- entry->seglist_bus = DRM(alloc)(count * sizeof(*entry->seglist_bus),
- DRM_MEM_SEGS);
-
- /* Keep the original pagelist until we know all the allocations
- * have succeeded
- */
- temp_pagelist = DRM(alloc)((dma->page_count + (count << page_order)) *
- sizeof(*dma->pagelist), DRM_MEM_PAGES);
-
- if (entry->buflist == NULL || entry->seglist == NULL ||
- temp_pagelist == NULL) {
- DRM(free)(entry->buflist, count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- DRM(free)(entry->seglist, count * sizeof(*entry->seglist),
- DRM_MEM_SEGS);
- DRM(free)(entry->seglist_bus, count *
- sizeof(*entry->seglist_bus), DRM_MEM_SEGS);
- return DRM_ERR(ENOMEM);
- }
-
- bzero(entry->buflist, count * sizeof(*entry->buflist));
- bzero(entry->seglist, count * sizeof(*entry->seglist));
-
- memcpy(temp_pagelist, dma->pagelist, dma->page_count *
- sizeof(*dma->pagelist));
-
- DRM_DEBUG( "pagelist: %d entries\n",
- dma->page_count + (count << page_order) );
-
- entry->buf_size = size;
- entry->page_order = page_order;
- byte_count = 0;
- page_count = 0;
-
- while ( entry->buf_count < count ) {
- vaddr = (vm_offset_t) DRM(pci_alloc)(dev, size, alignment,
- 0xfffffffful, &bus_addr);
- if (vaddr == 0) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- entry->seg_count = count;
- DRM(cleanup_buf_error)(dev, entry);
- DRM(free)(temp_pagelist, (dma->page_count +
- (count << page_order)) * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
- return DRM_ERR(ENOMEM);
- }
-
- entry->seglist_bus[entry->seg_count] = bus_addr;
- entry->seglist[entry->seg_count++] = vaddr;
- for ( i = 0 ; i < (1 << page_order) ; i++ ) {
- DRM_DEBUG( "page %d @ 0x%08lx\n",
- dma->page_count + page_count,
- (long)vaddr + PAGE_SIZE * i );
- temp_pagelist[dma->page_count + page_count++] =
- vaddr + PAGE_SIZE * i;
- }
- for ( offset = 0 ;
- offset + size <= total && entry->buf_count < count ;
- offset += alignment, ++entry->buf_count ) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
- buf->offset = (dma->byte_count + byte_count + offset);
- buf->address = (void *)(vaddr + offset);
- buf->bus_address = bus_addr + offset;
- buf->next = NULL;
- buf->pending = 0;
- buf->filp = NULL;
-
- buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = DRM(alloc)(buf->dev_priv_size,
- DRM_MEM_BUFS);
- if (buf->dev_private == NULL) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- entry->seg_count = count;
- DRM(cleanup_buf_error)(dev, entry);
- DRM(free)(temp_pagelist, (dma->page_count +
- (count << page_order)) *
- sizeof(*dma->pagelist), DRM_MEM_PAGES );
- return DRM_ERR(ENOMEM);
- }
- bzero(buf->dev_private, buf->dev_priv_size);
-
- DRM_DEBUG( "buffer %d @ %p\n",
- entry->buf_count, buf->address );
- }
- byte_count += PAGE_SIZE << page_order;
- }
-
- temp_buflist = DRM(realloc)( dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS );
- if (temp_buflist == NULL) {
- /* Free the entry because it isn't valid */
- DRM(cleanup_buf_error)(dev, entry);
- DRM(free)(temp_pagelist, (dma->page_count +
- (count << page_order)) * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
- return DRM_ERR(ENOMEM);
- }
- dma->buflist = temp_buflist;
-
- for ( i = 0 ; i < entry->buf_count ; i++ ) {
- dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
-
- /* No allocations failed, so now we can replace the orginal pagelist
- * with the new one.
- */
- DRM(free)(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
- dma->pagelist = temp_pagelist;
-
- dma->buf_count += entry->buf_count;
- dma->seg_count += entry->seg_count;
- dma->page_count += entry->seg_count << page_order;
- dma->byte_count += PAGE_SIZE * (entry->seg_count << page_order);
-
- request->count = entry->buf_count;
- request->size = size;
-
- return 0;
-
-}
-#endif /* __HAVE_PCI_DMA */
-
-#if __REALLY_HAVE_SG
-static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
-{
- drm_device_dma_t *dma = dev->dma;
- drm_buf_entry_t *entry;
- drm_buf_t *buf;
- unsigned long offset;
- unsigned long agp_offset;
- int count;
- int order;
- int size;
- int alignment;
- int page_order;
- int total;
- int byte_count;
- int i;
- drm_buf_t **temp_buflist;
-
- count = request->count;
- order = DRM(order)(request->size);
- size = 1 << order;
-
- alignment = (request->flags & _DRM_PAGE_ALIGN)
- ? round_page(size) : size;
- page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0;
- total = PAGE_SIZE << page_order;
-
- byte_count = 0;
- agp_offset = request->agp_start;
-
- DRM_DEBUG( "count: %d\n", count );
- DRM_DEBUG( "order: %d\n", order );
- DRM_DEBUG( "size: %d\n", size );
- DRM_DEBUG( "agp_offset: %ld\n", agp_offset );
- DRM_DEBUG( "alignment: %d\n", alignment );
- DRM_DEBUG( "page_order: %d\n", page_order );
- DRM_DEBUG( "total: %d\n", total );
-
- entry = &dma->bufs[order];
-
- entry->buflist = DRM(calloc)(1, count * sizeof(*entry->buflist),
- DRM_MEM_BUFS);
- if (entry->buflist == NULL)
- return DRM_ERR(ENOMEM);
-
- entry->buf_size = size;
- entry->page_order = page_order;
-
- offset = 0;
-
- while ( entry->buf_count < count ) {
- buf = &entry->buflist[entry->buf_count];
- buf->idx = dma->buf_count + entry->buf_count;
- buf->total = alignment;
- buf->order = order;
- buf->used = 0;
-
- buf->offset = (dma->byte_count + offset);
- buf->bus_address = agp_offset + offset;
- buf->address = (void *)(agp_offset + offset + dev->sg->handle);
- buf->next = NULL;
- buf->pending = 0;
- buf->filp = NULL;
-
- buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = DRM(calloc)(1, buf->dev_priv_size,
- DRM_MEM_BUFS);
- if (buf->dev_private == NULL) {
- /* Set count correctly so we free the proper amount. */
- entry->buf_count = count;
- DRM(cleanup_buf_error)(dev, entry);
- return DRM_ERR(ENOMEM);
- }
-
- DRM_DEBUG( "buffer %d @ %p\n",
- entry->buf_count, buf->address );
-
- offset += alignment;
- entry->buf_count++;
- byte_count += PAGE_SIZE << page_order;
- }
-
- DRM_DEBUG( "byte_count: %d\n", byte_count );
-
- temp_buflist = DRM(realloc)( dma->buflist,
- dma->buf_count * sizeof(*dma->buflist),
- (dma->buf_count + entry->buf_count)
- * sizeof(*dma->buflist),
- DRM_MEM_BUFS );
- if (temp_buflist == NULL) {
- /* Free the entry because it isn't valid */
- DRM(cleanup_buf_error)(dev, entry);
- return DRM_ERR(ENOMEM);
- }
- dma->buflist = temp_buflist;
-
- for ( i = 0 ; i < entry->buf_count ; i++ ) {
- dma->buflist[i + dma->buf_count] = &entry->buflist[i];
- }
-
- dma->buf_count += entry->buf_count;
- dma->byte_count += byte_count;
-
- DRM_DEBUG( "dma->buf_count : %d\n", dma->buf_count );
- DRM_DEBUG( "entry->buf_count : %d\n", entry->buf_count );
-
- request->count = entry->buf_count;
- request->size = size;
-
- dma->flags = _DRM_DMA_USE_SG;
-
- return 0;
-}
-#endif /* __REALLY_HAVE_SG */
-
-int DRM(addbufs)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_buf_desc_t request;
- int err;
- int order;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) );
-
- if (request.count < 0 || request.count > 4096)
- return DRM_ERR(EINVAL);
-
- order = DRM(order)(request.size);
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
- return DRM_ERR(EINVAL);
-
- DRM_SPINLOCK(&dev->dma_lock);
- /* No more allocations after first buffer-using ioctl. */
- if (dev->buf_use != 0) {
- DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(EBUSY);
- }
- /* No more than one allocation per order */
- if (dev->dma->bufs[order].buf_count != 0) {
- DRM_SPINUNLOCK(&dev->dma_lock);
- return DRM_ERR(ENOMEM);
- }
-
-#if __REALLY_HAVE_AGP
- if ( request.flags & _DRM_AGP_BUFFER )
- err = DRM(addbufs_agp)(dev, &request);
- else
-#endif
-#if __REALLY_HAVE_SG
- if ( request.flags & _DRM_SG_BUFFER )
- err = DRM(addbufs_sg)(dev, &request);
- else
-#endif
-#if __HAVE_PCI_DMA
- err = DRM(addbufs_pci)(dev, &request);
-#else
- err = DRM_ERR(EINVAL);
-#endif
- DRM_SPINUNLOCK(&dev->dma_lock);
-
- DRM_COPY_TO_USER_IOCTL((drm_buf_desc_t *)data, request, sizeof(request));
-
- return err;
-}
-
-int DRM(infobufs)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_device_dma_t *dma = dev->dma;
- drm_buf_info_t request;
- int i;
- int count;
- int retcode = 0;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_info_t *)data, sizeof(request) );
-
- DRM_SPINLOCK(&dev->dma_lock);
- ++dev->buf_use; /* Can't allocate more after this call */
- DRM_SPINUNLOCK(&dev->dma_lock);
-
- for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) {
- if ( dma->bufs[i].buf_count ) ++count;
- }
-
- DRM_DEBUG( "count = %d\n", count );
-
- if ( request.count >= count ) {
- for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) {
- if ( dma->bufs[i].buf_count ) {
- drm_buf_desc_t from;
-
- from.count = dma->bufs[i].buf_count;
- from.size = dma->bufs[i].buf_size;
- from.low_mark = dma->bufs[i].freelist.low_mark;
- from.high_mark = dma->bufs[i].freelist.high_mark;
-
- if (DRM_COPY_TO_USER(&request.list[count], &from,
- sizeof(drm_buf_desc_t)) != 0) {
- retcode = DRM_ERR(EFAULT);
- break;
- }
-
- DRM_DEBUG( "%d %d %d %d %d\n",
- i,
- dma->bufs[i].buf_count,
- dma->bufs[i].buf_size,
- dma->bufs[i].freelist.low_mark,
- dma->bufs[i].freelist.high_mark );
- ++count;
- }
- }
- }
- request.count = count;
-
- DRM_COPY_TO_USER_IOCTL( (drm_buf_info_t *)data, request, sizeof(request) );
-
- return retcode;
-}
-
-int DRM(markbufs)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_device_dma_t *dma = dev->dma;
- drm_buf_desc_t request;
- int order;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) );
-
- DRM_DEBUG( "%d, %d, %d\n",
- request.size, request.low_mark, request.high_mark );
-
-
- order = DRM(order)(request.size);
- if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ||
- request.low_mark < 0 || request.high_mark < 0) {
- return DRM_ERR(EINVAL);
- }
-
- DRM_SPINLOCK(&dev->dma_lock);
- if (request.low_mark > dma->bufs[order].buf_count ||
- request.high_mark > dma->bufs[order].buf_count) {
- return DRM_ERR(EINVAL);
- }
-
- dma->bufs[order].freelist.low_mark = request.low_mark;
- dma->bufs[order].freelist.high_mark = request.high_mark;
- DRM_SPINUNLOCK(&dev->dma_lock);
-
- return 0;
-}
-
-int DRM(freebufs)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_device_dma_t *dma = dev->dma;
- drm_buf_free_t request;
- int i;
- int idx;
- drm_buf_t *buf;
- int retcode = 0;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_free_t *)data, sizeof(request) );
-
- DRM_DEBUG( "%d\n", request.count );
-
- DRM_SPINLOCK(&dev->dma_lock);
- for ( i = 0 ; i < request.count ; i++ ) {
- if (DRM_COPY_FROM_USER(&idx, &request.list[i], sizeof(idx))) {
- retcode = DRM_ERR(EFAULT);
- break;
- }
- if ( idx < 0 || idx >= dma->buf_count ) {
- DRM_ERROR( "Index %d (of %d max)\n",
- idx, dma->buf_count - 1 );
- retcode = DRM_ERR(EINVAL);
- break;
- }
- buf = dma->buflist[idx];
- if ( buf->filp != filp ) {
- DRM_ERROR("Process %d freeing buffer not owned\n",
- DRM_CURRENTPID);
- retcode = DRM_ERR(EINVAL);
- break;
- }
- DRM(free_buffer)( dev, buf );
- }
- DRM_SPINUNLOCK(&dev->dma_lock);
-
- return retcode;
-}
-
-int DRM(mapbufs)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_device_dma_t *dma = dev->dma;
- int retcode = 0;
- const int zero = 0;
- vm_offset_t address;
- struct vmspace *vms;
-#ifdef __FreeBSD__
- vm_ooffset_t foff;
- vm_size_t size;
- vm_offset_t vaddr;
-#endif /* __FreeBSD__ */
-#ifdef __NetBSD__
- struct vnode *vn;
- vm_size_t size;
- vaddr_t vaddr;
-#endif /* __NetBSD__ */
-
- drm_buf_map_t request;
- int i;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_map_t *)data, sizeof(request) );
-
-#ifdef __NetBSD__
- if (!vfinddev(kdev, VCHR, &vn))
- return 0; /* FIXME: Shouldn't this be EINVAL or something? */
-#endif /* __NetBSD__ */
-
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- vms = p->td_proc->p_vmspace;
-#else
- vms = p->p_vmspace;
-#endif
-
- DRM_SPINLOCK(&dev->dma_lock);
- dev->buf_use++; /* Can't allocate more after this call */
- DRM_SPINUNLOCK(&dev->dma_lock);
-
- if (request.count < dma->buf_count)
- goto done;
-
- if ((__HAVE_AGP && (dma->flags & _DRM_DMA_USE_AGP)) ||
- (__HAVE_SG && (dma->flags & _DRM_DMA_USE_SG))) {
- drm_local_map_t *map = dev->agp_buffer_map;
-
- if (map == NULL) {
- retcode = EINVAL;
- goto done;
- }
- size = round_page(map->size);
- foff = map->offset;
- } else {
- size = round_page(dma->byte_count),
- foff = 0;
- }
-
-#ifdef __FreeBSD__
- vaddr = round_page((vm_offset_t)vms->vm_daddr + MAXDSIZ);
- retcode = vm_mmap(&vms->vm_map, &vaddr, size, PROT_READ | PROT_WRITE,
- VM_PROT_ALL, MAP_SHARED, SLIST_FIRST(&kdev->si_hlist), foff );
-#elif defined(__NetBSD__)
- vaddr = round_page((vaddr_t)vms->vm_daddr + MAXDSIZ);
- retcode = uvm_mmap(&vms->vm_map, &vaddr, size,
- UVM_PROT_READ | UVM_PROT_WRITE, UVM_PROT_ALL, MAP_SHARED,
- &vn->v_uobj, foff, p->p_rlimit[RLIMIT_MEMLOCK].rlim_cur);
-#endif /* __NetBSD__ */
- if (retcode)
- goto done;
-
- request.virtual = (void *)vaddr;
-
- for ( i = 0 ; i < dma->buf_count ; i++ ) {
- if (DRM_COPY_TO_USER(&request.list[i].idx,
- &dma->buflist[i]->idx, sizeof(request.list[0].idx))) {
- retcode = EFAULT;
- goto done;
- }
- if (DRM_COPY_TO_USER(&request.list[i].total,
- &dma->buflist[i]->total, sizeof(request.list[0].total))) {
- retcode = EFAULT;
- goto done;
- }
- if (DRM_COPY_TO_USER(&request.list[i].used, &zero,
- sizeof(zero))) {
- retcode = EFAULT;
- goto done;
- }
- address = vaddr + dma->buflist[i]->offset; /* *** */
- if (DRM_COPY_TO_USER(&request.list[i].address, &address,
- sizeof(address))) {
- retcode = EFAULT;
- goto done;
- }
- }
-
- done:
- request.count = dma->buf_count;
-
- DRM_DEBUG( "%d buffers, retcode = %d\n", request.count, retcode );
-
- DRM_COPY_TO_USER_IOCTL((drm_buf_map_t *)data, request, sizeof(request));
-
- return DRM_ERR(retcode);
-}
-
-#endif /* __HAVE_DMA */
diff --git a/bsd/drm_context.h b/bsd/drm_context.h
deleted file mode 100644
index aa655297..00000000
--- a/bsd/drm_context.h
+++ /dev/null
@@ -1,349 +0,0 @@
-/* drm_context.h -- IOCTLs for generic contexts -*- linux-c -*-
- * Created: Fri Nov 24 18:31:37 2000 by gareth@valinux.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-#if !__HAVE_CTX_BITMAP
-#error "__HAVE_CTX_BITMAP must be defined"
-#endif
-
-/* ================================================================
- * Context bitmap support
- */
-
-void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
-{
- if (ctx_handle < 0 || ctx_handle >= DRM_MAX_CTXBITMAP ||
- dev->ctx_bitmap == NULL) {
- DRM_ERROR("Attempt to free invalid context handle: %d\n",
- ctx_handle);
- return;
- }
-
- DRM_LOCK();
- clear_bit(ctx_handle, dev->ctx_bitmap);
- dev->context_sareas[ctx_handle] = NULL;
- DRM_UNLOCK();
- return;
-}
-
-int DRM(ctxbitmap_next)( drm_device_t *dev )
-{
- int bit;
-
- if (dev->ctx_bitmap == NULL)
- return -1;
-
- DRM_LOCK();
- bit = find_first_zero_bit( dev->ctx_bitmap, DRM_MAX_CTXBITMAP );
- if (bit >= DRM_MAX_CTXBITMAP) {
- DRM_UNLOCK();
- return -1;
- }
-
- set_bit(bit, dev->ctx_bitmap);
- DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit);
- if ((bit+1) > dev->max_context) {
- dev->max_context = (bit+1);
- if (dev->context_sareas != NULL) {
- drm_local_map_t **ctx_sareas;
-
- ctx_sareas = DRM(realloc)(dev->context_sareas,
- (dev->max_context - 1) *
- sizeof(*dev->context_sareas),
- dev->max_context *
- sizeof(*dev->context_sareas),
- DRM_MEM_MAPS);
- if (ctx_sareas == NULL) {
- clear_bit(bit, dev->ctx_bitmap);
- DRM_UNLOCK();
- return -1;
- }
- dev->context_sareas = ctx_sareas;
- dev->context_sareas[bit] = NULL;
- } else {
- /* max_context == 1 at this point */
- dev->context_sareas = DRM(alloc)(dev->max_context *
- sizeof(*dev->context_sareas), DRM_MEM_MAPS);
- if (dev->context_sareas == NULL) {
- clear_bit(bit, dev->ctx_bitmap);
- DRM_UNLOCK();
- return -1;
- }
- dev->context_sareas[bit] = NULL;
- }
- }
- DRM_UNLOCK();
- return bit;
-}
-
-int DRM(ctxbitmap_init)( drm_device_t *dev )
-{
- int i;
- int temp;
-
- DRM_LOCK();
- dev->ctx_bitmap = (atomic_t *)DRM(calloc)(1, PAGE_SIZE,
- DRM_MEM_CTXBITMAP);
- if ( dev->ctx_bitmap == NULL ) {
- DRM_UNLOCK();
- return DRM_ERR(ENOMEM);
- }
- dev->context_sareas = NULL;
- dev->max_context = -1;
- DRM_UNLOCK();
-
- for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
- temp = DRM(ctxbitmap_next)( dev );
- DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp );
- }
-
- return 0;
-}
-
-void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
-{
- DRM_LOCK();
- if (dev->context_sareas != NULL)
- DRM(free)(dev->context_sareas, sizeof(*dev->context_sareas) *
- dev->max_context, DRM_MEM_MAPS);
- DRM(free)( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP );
- DRM_UNLOCK();
-}
-
-/* ================================================================
- * Per Context SAREA Support
- */
-
-int DRM(getsareactx)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_ctx_priv_map_t request;
- drm_local_map_t *map;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
- sizeof(request) );
-
- DRM_LOCK();
- if (dev->max_context < 0 || request.ctx_id >= (unsigned) dev->max_context) {
- DRM_UNLOCK();
- return DRM_ERR(EINVAL);
- }
-
- map = dev->context_sareas[request.ctx_id];
- DRM_UNLOCK();
-
- request.handle = map->handle;
-
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_priv_map_t *)data, request, sizeof(request) );
-
- return 0;
-}
-
-int DRM(setsareactx)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_ctx_priv_map_t request;
- drm_local_map_t *map = NULL;
- drm_map_list_entry_t *list;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
- sizeof(request) );
-
- DRM_LOCK();
- TAILQ_FOREACH(list, dev->maplist, link) {
- map=list->map;
- 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);
-}
-
-/* ================================================================
- * The actual DRM context handling routines
- */
-
-int DRM(context_switch)( drm_device_t *dev, int old, int new )
-{
- if ( test_and_set_bit( 0, &dev->context_flag ) ) {
- DRM_ERROR( "Reentering -- FIXME\n" );
- return DRM_ERR(EBUSY);
- }
-
- DRM_DEBUG( "Context switch from %d to %d\n", old, new );
-
- if ( new == dev->last_context ) {
- clear_bit( 0, &dev->context_flag );
- return 0;
- }
-
- return 0;
-}
-
-int DRM(context_switch_complete)( drm_device_t *dev, int new )
-{
- dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
-
- if ( !_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ) {
- DRM_ERROR( "Lock isn't held after context switch\n" );
- }
-
- /* If a context switch is ever initiated
- when the kernel holds the lock, release
- that lock here. */
- clear_bit( 0, &dev->context_flag );
-
- return 0;
-}
-
-int DRM(resctx)( DRM_IOCTL_ARGS )
-{
- drm_ctx_res_t res;
- drm_ctx_t ctx;
- int i;
-
- DRM_COPY_FROM_USER_IOCTL( res, (drm_ctx_res_t *)data, sizeof(res) );
-
- if ( res.count >= DRM_RESERVED_CONTEXTS ) {
- bzero(&ctx, sizeof(ctx));
- for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
- ctx.handle = i;
- if ( DRM_COPY_TO_USER( &res.contexts[i],
- &i, sizeof(i) ) )
- return DRM_ERR(EFAULT);
- }
- }
- res.count = DRM_RESERVED_CONTEXTS;
-
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_res_t *)data, res, sizeof(res) );
-
- return 0;
-}
-
-int DRM(addctx)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
-
- ctx.handle = DRM(ctxbitmap_next)( dev );
- if ( ctx.handle == DRM_KERNEL_CONTEXT ) {
- /* Skip kernel's context and get a new one. */
- ctx.handle = DRM(ctxbitmap_next)( dev );
- }
- DRM_DEBUG( "%d\n", ctx.handle );
- if ( ctx.handle == -1 ) {
- DRM_DEBUG( "Not enough free contexts.\n" );
- /* Should this return -EBUSY instead? */
- return DRM_ERR(ENOMEM);
- }
-
- if ( dev->fn_tbl.context_ctor && ctx.handle != DRM_KERNEL_CONTEXT )
- dev->fn_tbl.context_ctor(dev, ctx.handle);
-
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
-
- return 0;
-}
-
-int DRM(modctx)( DRM_IOCTL_ARGS )
-{
- /* This does nothing */
- return 0;
-}
-
-int DRM(getctx)( DRM_IOCTL_ARGS )
-{
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
-
- /* This is 0, because we don't handle any context flags */
- ctx.flags = 0;
-
- DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
-
- return 0;
-}
-
-int DRM(switchctx)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
-
- DRM_DEBUG( "%d\n", ctx.handle );
- return DRM(context_switch)( dev, dev->last_context, ctx.handle );
-}
-
-int DRM(newctx)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
-
- DRM_DEBUG( "%d\n", ctx.handle );
- DRM(context_switch_complete)( dev, ctx.handle );
-
- return 0;
-}
-
-int DRM(rmctx)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_ctx_t ctx;
-
- DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
-
- DRM_DEBUG( "%d\n", ctx.handle );
- if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
- if (dev->fn_tbl.context_dtor)
- dev->fn_tbl.context_dtor(dev, ctx.handle);
-
- DRM(ctxbitmap_free)( dev, ctx.handle );
- }
-
- return 0;
-}
diff --git a/bsd/drm_dma.h b/bsd/drm_dma.h
deleted file mode 100644
index 4570a867..00000000
--- a/bsd/drm_dma.h
+++ /dev/null
@@ -1,171 +0,0 @@
-/* drm_dma.c -- DMA IOCTL and function support -*- linux-c -*-
- * Created: Fri Mar 19 14:30:16 1999 by faith@valinux.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-#ifndef __HAVE_DMA_WAITQUEUE
-#define __HAVE_DMA_WAITQUEUE 0
-#endif
-#ifndef __HAVE_DMA_RECLAIM
-#define __HAVE_DMA_RECLAIM 0
-#endif
-#ifndef __HAVE_SHARED_IRQ
-#define __HAVE_SHARED_IRQ 0
-#endif
-
-#if __HAVE_DMA
-
-int DRM(dma_setup)( drm_device_t *dev )
-{
-
- dev->dma = DRM(calloc)(1, sizeof(*dev->dma), DRM_MEM_DRIVER);
- if (dev->dma == NULL)
- return DRM_ERR(ENOMEM);
-
- DRM_SPININIT(dev->dma_lock, "drmdma");
-
- return 0;
-}
-
-void DRM(dma_takedown)(drm_device_t *dev)
-{
- drm_device_dma_t *dma = dev->dma;
- int i, j;
-
- if (dma == NULL)
- return;
-
- /* Clear dma buffers */
- for (i = 0; i <= DRM_MAX_ORDER; i++) {
-#if __HAVE_PCI_DMA
- if (dma->bufs[i].seg_count) {
- DRM_DEBUG("order %d: buf_count = %d,"
- " seg_count = %d\n",
- i,
- dma->bufs[i].buf_count,
- dma->bufs[i].seg_count);
- for (j = 0; j < dma->bufs[i].seg_count; j++) {
- if (dma->bufs[i].seglist[j] != 0)
- DRM(pci_free)(dev, dma->bufs[i].buf_size,
- (void *)dma->bufs[i].seglist[j],
- dma->bufs[i].seglist_bus[j]);
- }
- DRM(free)(dma->bufs[i].seglist,
- dma->bufs[i].seg_count
- * sizeof(*dma->bufs[0].seglist),
- DRM_MEM_SEGS);
- DRM(free)(dma->bufs[i].seglist_bus,
- dma->bufs[i].seg_count
- * sizeof(*dma->bufs[0].seglist_bus),
- DRM_MEM_SEGS);
- }
-#endif /* __HAVE_PCI_DMA */
-
- if (dma->bufs[i].buf_count) {
- for (j = 0; j < dma->bufs[i].buf_count; j++) {
- DRM(free)(dma->bufs[i].buflist[j].dev_private,
- dma->bufs[i].buflist[j].dev_priv_size,
- DRM_MEM_BUFS);
- }
- DRM(free)(dma->bufs[i].buflist,
- dma->bufs[i].buf_count *
- sizeof(*dma->bufs[0].buflist),
- DRM_MEM_BUFS);
- }
- }
-
- DRM(free)(dma->buflist, dma->buf_count * sizeof(*dma->buflist),
- DRM_MEM_BUFS);
- DRM(free)(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
- DRM_MEM_PAGES);
- DRM(free)(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
- dev->dma = NULL;
- DRM_SPINUNINIT(dev->dma_lock);
-}
-
-
-void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
-{
- if (!buf) return;
-
- buf->pending = 0;
- buf->filp = NULL;
- buf->used = 0;
-}
-
-#if !__HAVE_DMA_RECLAIM
-void DRM(reclaim_buffers)(drm_device_t *dev, DRMFILE filp)
-{
- drm_device_dma_t *dma = dev->dma;
- int i;
-
- if (!dma) return;
- for (i = 0; i < dma->buf_count; i++) {
- if (dma->buflist[i]->filp == filp) {
- switch (dma->buflist[i]->list) {
- case DRM_LIST_NONE:
- DRM(free_buffer)(dev, dma->buflist[i]);
- break;
- case DRM_LIST_WAIT:
- dma->buflist[i]->list = DRM_LIST_RECLAIM;
- break;
- default:
- /* Buffer already on hardware. */
- break;
- }
- }
- }
-}
-#endif
-
-#if !__HAVE_IRQ
-/* This stub DRM_IOCTL_CONTROL handler is for the drivers that used to require
- * IRQs for DMA but no longer do. It maintains compatibility with the X Servers
- * that try to use the control ioctl by simply returning success.
- */
-int DRM(control)( DRM_IOCTL_ARGS )
-{
- drm_control_t ctl;
-
- DRM_COPY_FROM_USER_IOCTL( ctl, (drm_control_t *) data, sizeof(ctl) );
-
- switch ( ctl.func ) {
- case DRM_INST_HANDLER:
- case DRM_UNINST_HANDLER:
- return 0;
- default:
- return DRM_ERR(EINVAL);
- }
-}
-#endif
-
-#endif /* __HAVE_DMA */
diff --git a/bsd/drm_drawable.h b/bsd/drm_drawable.h
deleted file mode 100644
index 890de1fb..00000000
--- a/bsd/drm_drawable.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* drm_drawable.h -- IOCTLs for drawables -*- linux-c -*-
- * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-int DRM(adddraw)( DRM_IOCTL_ARGS )
-{
- drm_draw_t draw;
-
- draw.handle = 0; /* NOOP */
- DRM_DEBUG("%d\n", draw.handle);
-
- DRM_COPY_TO_USER_IOCTL( (drm_draw_t *)data, draw, sizeof(draw) );
-
- return 0;
-}
-
-int DRM(rmdraw)( DRM_IOCTL_ARGS )
-{
- return 0; /* NOOP */
-}
diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h
deleted file mode 100644
index 4e82ef81..00000000
--- a/bsd/drm_drv.h
+++ /dev/null
@@ -1,1157 +0,0 @@
-/* drm_drv.h -- Generic driver template -*- linux-c -*-
- * Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
- *
- * Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-/*
- * To use this template, you must at least define the following (samples
- * given for the MGA driver):
- *
- * #define DRIVER_AUTHOR "VA Linux Systems, Inc."
- *
- * #define DRIVER_NAME "mga"
- * #define DRIVER_DESC "Matrox G200/G400"
- * #define DRIVER_DATE "20001127"
- *
- * #define DRIVER_MAJOR 2
- * #define DRIVER_MINOR 0
- * #define DRIVER_PATCHLEVEL 2
- *
- * #define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( mga_ioctls )
- *
- * #define DRM(x) mga_##x
- */
-
-#ifndef __MUST_HAVE_AGP
-#define __MUST_HAVE_AGP 0
-#endif
-#ifndef __HAVE_CTX_BITMAP
-#define __HAVE_CTX_BITMAP 0
-#endif
-#ifndef __HAVE_IRQ
-#define __HAVE_IRQ 0
-#endif
-#ifndef __HAVE_DMA_QUEUE
-#define __HAVE_DMA_QUEUE 0
-#endif
-#ifndef __HAVE_DMA_SCHEDULE
-#define __HAVE_DMA_SCHEDULE 0
-#endif
-#ifndef __HAVE_DMA_QUIESCENT
-#define __HAVE_DMA_QUIESCENT 0
-#endif
-#ifndef __HAVE_RELEASE
-#define __HAVE_RELEASE 0
-#endif
-#ifndef __HAVE_COUNTERS
-#define __HAVE_COUNTERS 0
-#endif
-#ifndef __HAVE_SG
-#define __HAVE_SG 0
-#endif
-
-#ifndef DRIVER_IOCTLS
-#define DRIVER_IOCTLS
-#endif
-#ifndef DRIVER_FOPS
-#endif
-
-#if 1 && DRM_DEBUG_CODE
-int DRM(flags) = DRM_FLAG_DEBUG;
-#else
-int DRM(flags) = 0;
-#endif
-
-static int DRM(init)(device_t nbdev);
-static void DRM(cleanup)(drm_device_t *dev);
-
-#ifdef __FreeBSD__
-#define DRIVER_SOFTC(unit) \
- ((drm_device_t *) devclass_get_softc(DRM(devclass), unit))
-
-#if __REALLY_HAVE_AGP
-MODULE_DEPEND(DRIVER_NAME, agp, 1, 1, 1);
-#endif
-#endif /* __FreeBSD__ */
-
-#ifdef __NetBSD__
-#define DRIVER_SOFTC(unit) \
- ((drm_device_t *) device_lookup(&DRM(cd), unit))
-#endif /* __NetBSD__ */
-
-static drm_ioctl_desc_t DRM(ioctls)[] = {
- [DRM_IOCTL_NR(DRM_IOCTL_VERSION)] = { DRM(version), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE)] = { DRM(getunique), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_MAGIC)] = { DRM(getmagic), 0, 0 },
-#if __HAVE_IRQ
- [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { DRM(irq_by_busid), 0, 1 },
-#endif
- [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP)] = { DRM(getmap), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_CLIENT)] = { DRM(getclient), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_STATS)] = { DRM(getstats), 0, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_SET_VERSION)] = { DRM(setversion), 0, 1 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_SET_UNIQUE)] = { DRM(setunique), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_BLOCK)] = { DRM(noop), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_UNBLOCK)] = { DRM(noop), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AUTH_MAGIC)] = { DRM(authmagic), 1, 1 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_MAP)] = { DRM(addmap), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RM_MAP)] = { DRM(rmmap), 1, 0 },
-
-#if __HAVE_CTX_BITMAP
- [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { DRM(setsareactx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { DRM(getsareactx), 1, 0 },
-#endif
-
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_CTX)] = { DRM(addctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RM_CTX)] = { DRM(rmctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MOD_CTX)] = { DRM(modctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_GET_CTX)] = { DRM(getctx), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_SWITCH_CTX)] = { DRM(switchctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_NEW_CTX)] = { DRM(newctx), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RES_CTX)] = { DRM(resctx), 1, 0 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_DRAW)] = { DRM(adddraw), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_RM_DRAW)] = { DRM(rmdraw), 1, 1 },
-
- [DRM_IOCTL_NR(DRM_IOCTL_LOCK)] = { DRM(lock), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_UNLOCK)] = { DRM(unlock), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_FINISH)] = { DRM(noop), 1, 0 },
-
-#if __HAVE_DMA
- [DRM_IOCTL_NR(DRM_IOCTL_ADD_BUFS)] = { DRM(addbufs), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_MARK_BUFS)] = { DRM(markbufs), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_INFO_BUFS)] = { DRM(infobufs), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_MAP_BUFS)] = { DRM(mapbufs), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_FREE_BUFS)] = { DRM(freebufs), 1, 0 },
- /* The DRM_IOCTL_DMA ioctl should be defined by the driver. */
-#endif
-#if __HAVE_IRQ || __HAVE_DMA
- [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { DRM(control), 1, 1 },
-#endif
-
-#if __REALLY_HAVE_AGP
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_ACQUIRE)] = { DRM(agp_acquire), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_RELEASE)] = { DRM(agp_release), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_ENABLE)] = { DRM(agp_enable), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_INFO)] = { DRM(agp_info), 1, 0 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_ALLOC)] = { DRM(agp_alloc), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_FREE)] = { DRM(agp_free), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_BIND)] = { DRM(agp_bind), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_AGP_UNBIND)] = { DRM(agp_unbind), 1, 1 },
-#endif
-
-#if __HAVE_SG
- [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { DRM(sg_alloc), 1, 1 },
- [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { DRM(sg_free), 1, 1 },
-#endif
-
-#if __HAVE_VBL_IRQ
- [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
-#endif
-
- DRIVER_IOCTLS
-};
-
-#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( DRM(ioctls) )
-
-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 ),
- .d_ioctl = DRM( ioctl ),
- .d_poll = DRM( poll ),
- .d_mmap = DRM( mmap ),
- .d_name = DRIVER_NAME,
-#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
-};
-
-#include "drm_pciids.h"
-
-static drm_pci_id_list_t DRM(pciidlist)[] = {
- DRM(PCI_IDS)
-};
-
-static int DRM(probe)(device_t dev)
-{
- const char *s = NULL;
- int pciid, vendor, device;
-
- /* XXX: Cope with agp bridge device? */
- if (!strcmp(device_get_name(dev), "drmsub"))
- pciid = pci_get_devid(device_get_parent(dev));
- else
- pciid = pci_get_devid(dev);
-
- vendor = (pciid & 0x0000ffff);
- device = (pciid & 0xffff0000) >> 16;
-
- s = DRM(find_description)(vendor, device);
- if (s != NULL) {
- device_set_desc(dev, s);
- return 0;
- }
-
- return ENXIO;
-}
-
-static int DRM(attach)(device_t dev)
-{
- return DRM(init)(dev);
-}
-
-static int DRM(detach)(device_t dev)
-{
- DRM(cleanup)(device_get_softc(dev));
- return 0;
-}
-static device_method_t DRM(methods)[] = {
- /* Device interface */
- DEVMETHOD(device_probe, DRM(probe)),
- DEVMETHOD(device_attach, DRM(attach)),
- DEVMETHOD(device_detach, DRM(detach)),
-
- { 0, 0 }
-};
-
-#ifndef DRM_DEV_NAME
-#define DRM_DEV_NAME "drm"
-#endif
-
-static driver_t DRM(driver) = {
- DRM_DEV_NAME,
- DRM(methods),
- sizeof(drm_device_t),
-};
-
-static devclass_t DRM(devclass);
-
-#elif defined(__NetBSD__)
-
-static struct cdevsw DRM(cdevsw) = {
- DRM(open),
- DRM(close),
- DRM(read),
- nowrite,
- 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
-MOD_DEV( DRIVER_NAME, LM_DT_CHAR, CDEV_MAJOR, &DRM(cdevsw) );
-#endif
-
-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;
- }
-
- 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)
-{
- const char *desc;
-
- desc = DRM(find_description)(PCI_VENDOR(pa->pa_id),
- PCI_PRODUCT(pa->pa_id));
- if (desc != NULL) {
- return 1;
- }
-
- return 0;
-}
-
-void DRM(attach)(struct pci_attach_args *pa, dev_t kdev)
-{
- 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);
-}
-
-int DRM(detach)(struct device *self, int flags)
-{
- DRM(cleanup)((drm_device_t *)self);
- return 0;
-}
-
-int DRM(activate)(struct device *self, enum devact act)
-{
- switch (act) {
- case DVACT_ACTIVATE:
- return (EOPNOTSUPP);
- break;
-
- case DVACT_DEACTIVATE:
- /* FIXME */
- break;
- }
- return (0);
-}
-#endif /* __NetBSD__ */
-
-const char *DRM(find_description)(int vendor, int device) {
- int i = 0;
-
- for (i = 0; DRM(pciidlist)[i].vendor != 0; i++) {
- if ((DRM(pciidlist)[i].vendor == vendor) &&
- (DRM(pciidlist)[i].device == device)) {
- return DRM(pciidlist)[i].name;
- }
- }
- return NULL;
-}
-
-/* Initialize the DRM on first open. */
-static int DRM(setup)( drm_device_t *dev )
-{
- int i;
-
- DRM_SPINLOCK_ASSERT(&dev->dev_lock);
-
- if (dev->fn_tbl.presetup)
- dev->fn_tbl.presetup(dev);
-
- dev->buf_use = 0;
-
-#if __HAVE_DMA
- i = DRM(dma_setup)( dev );
- if ( i != 0 )
- return i;
-#endif
-
- dev->counters = 6 + __HAVE_COUNTERS;
- dev->types[0] = _DRM_STAT_LOCK;
- dev->types[1] = _DRM_STAT_OPENS;
- dev->types[2] = _DRM_STAT_CLOSES;
- dev->types[3] = _DRM_STAT_IOCTLS;
- dev->types[4] = _DRM_STAT_LOCKS;
- dev->types[5] = _DRM_STAT_UNLOCKS;
-#ifdef __HAVE_COUNTER6
- dev->types[6] = __HAVE_COUNTER6;
-#endif
-#ifdef __HAVE_COUNTER7
- dev->types[7] = __HAVE_COUNTER7;
-#endif
-#ifdef __HAVE_COUNTER8
- dev->types[8] = __HAVE_COUNTER8;
-#endif
-#ifdef __HAVE_COUNTER9
- dev->types[9] = __HAVE_COUNTER9;
-#endif
-#ifdef __HAVE_COUNTER10
- dev->types[10] = __HAVE_COUNTER10;
-#endif
-#ifdef __HAVE_COUNTER11
- dev->types[11] = __HAVE_COUNTER11;
-#endif
-#ifdef __HAVE_COUNTER12
- dev->types[12] = __HAVE_COUNTER12;
-#endif
-#ifdef __HAVE_COUNTER13
- dev->types[13] = __HAVE_COUNTER13;
-#endif
-#ifdef __HAVE_COUNTER14
- dev->types[14] = __HAVE_COUNTER14;
-#endif
-#ifdef __HAVE_COUNTER15
- dev->types[14] = __HAVE_COUNTER14;
-#endif
-
- for ( i = 0 ; i < DRM_ARRAY_SIZE(dev->counts) ; i++ )
- atomic_set( &dev->counts[i], 0 );
-
- for ( i = 0 ; i < DRM_HASH_SIZE ; i++ ) {
- dev->magiclist[i].head = NULL;
- dev->magiclist[i].tail = NULL;
- }
-
- dev->lock.hw_lock = NULL;
- dev->lock.lock_queue = 0;
- dev->irq_enabled = 0;
- dev->context_flag = 0;
- dev->last_context = 0;
- dev->if_version = 0;
-
-#ifdef __FreeBSD__
- dev->buf_sigio = NULL;
-#elif defined(__NetBSD__)
- dev->buf_pgid = 0;
-#endif
-
- DRM_DEBUG( "\n" );
-
- if (dev->fn_tbl.postsetup)
- dev->fn_tbl.postsetup(dev);
-
- return 0;
-}
-
-/* Free resources associated with the DRM on the last close. */
-static int DRM(takedown)( drm_device_t *dev )
-{
- drm_magic_entry_t *pt, *next;
- drm_local_map_t *map;
- drm_map_list_entry_t *list;
- int i;
-
- DRM_SPINLOCK_ASSERT(&dev->dev_lock);
-
- DRM_DEBUG( "\n" );
-
- if (dev->fn_tbl.pretakedown)
- dev->fn_tbl.pretakedown(dev);
-
-#if __HAVE_IRQ
- if (dev->irq_enabled)
- DRM(irq_uninstall)( dev );
-#endif
-
- if ( dev->unique ) {
- DRM(free)( dev->unique, strlen( dev->unique ) + 1,
- DRM_MEM_DRIVER );
- dev->unique = NULL;
- dev->unique_len = 0;
- }
- /* Clear pid list */
- for ( i = 0 ; i < DRM_HASH_SIZE ; i++ ) {
- for ( pt = dev->magiclist[i].head ; pt ; pt = next ) {
- next = pt->next;
- DRM(free)( pt, sizeof(*pt), DRM_MEM_MAGIC );
- }
- dev->magiclist[i].head = dev->magiclist[i].tail = NULL;
- }
-
-#if __REALLY_HAVE_AGP
- /* Clear AGP information */
- if ( dev->agp ) {
- drm_agp_mem_t *entry;
- drm_agp_mem_t *nexte;
-
- /* Remove AGP resources, but leave dev->agp
- intact until DRM(cleanup) is called. */
- for ( entry = dev->agp->memory ; entry ; entry = nexte ) {
- nexte = entry->next;
- if ( entry->bound ) DRM(unbind_agp)( entry->handle );
- DRM(free_agp)( entry->handle, entry->pages );
- DRM(free)( entry, sizeof(*entry), DRM_MEM_AGPLISTS );
- }
- dev->agp->memory = NULL;
-
- if ( dev->agp->acquired ) DRM(agp_do_release)();
-
- dev->agp->acquired = 0;
- dev->agp->enabled = 0;
- }
-#endif
-#if __REALLY_HAVE_SG
- if (dev->sg != NULL) {
- DRM(sg_cleanup)(dev->sg);
- dev->sg = NULL;
- }
-#endif
-
- if (dev->maplist != NULL) {
- while ((list=TAILQ_FIRST(dev->maplist))) {
- map = list->map;
- switch ( map->type ) {
- case _DRM_REGISTERS:
- DRM(ioremapfree)(map);
- /* FALLTHROUGH */
- case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if (map->mtrr) {
- int __unused retcode;
-
- retcode = DRM(mtrr_del)(map->offset,
- map->size, DRM_MTRR_WC);
- DRM_DEBUG("mtrr_del = %d", retcode);
- }
-#endif
- break;
- case _DRM_SHM:
- DRM(free)(map->handle,
- map->size,
- DRM_MEM_SAREA);
- break;
-
- case _DRM_AGP:
- case _DRM_SCATTER_GATHER:
- /* Do nothing here, because this is all
- * handled in the AGP/GART/SG functions.
- */
- break;
- }
- TAILQ_REMOVE(dev->maplist, list, link);
- DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
- }
- }
-
-#if __HAVE_DMA
- DRM(dma_takedown)( dev );
-#endif
- if ( dev->lock.hw_lock ) {
- dev->lock.hw_lock = NULL; /* SHM removed */
- dev->lock.filp = NULL;
- DRM_WAKEUP_INT((void *)&dev->lock.lock_queue);
- }
-
- return 0;
-}
-
-/* linux: drm_init is called via init_module at module load time, or via
- * linux/init/main.c (this is not currently supported).
- * bsd: drm_init is called via the attach function per device.
- */
-static int DRM(init)( device_t nbdev )
-{
- int unit;
-#ifdef __FreeBSD__
- drm_device_t *dev;
-#elif defined(__NetBSD__)
- drm_device_t *dev = nbdev;
-#endif
-#if __HAVE_CTX_BITMAP
- int retcode;
-#endif
- DRM_DEBUG( "\n" );
-
-#ifdef __FreeBSD__
- unit = device_get_unit(nbdev);
- dev = device_get_softc(nbdev);
- memset( (void *)dev, 0, sizeof(*dev) );
-
- if (!strcmp(device_get_name(nbdev), "drmsub"))
- dev->device = device_get_parent(nbdev);
- else
- dev->device = nbdev;
-
- /* dev_priv_size can be changed by a driver in driver_register_fns */
- dev->dev_priv_size = sizeof(u32);
- DRM(driver_register_fns)(dev);
-
- if (dev->fn_tbl.preinit)
- dev->fn_tbl.preinit(dev, 0);
-
- dev->devnode = make_dev( &DRM(cdevsw),
- unit,
- DRM_DEV_UID,
- DRM_DEV_GID,
- DRM_DEV_MODE,
- "dri/card%d", unit );
-#if __FreeBSD_version >= 500000
- mtx_init(&dev->dev_lock, "drm device", NULL, MTX_DEF);
-#endif
-#elif defined(__NetBSD__)
- unit = minor(dev->device.dv_unit);
-
- /* dev_priv_size can be changed by a driver in driver_register_fns */
- dev->dev_priv_size = sizeof(u32);
- DRM(driver_register_fns)(dev);
-
- if (dev->fn_tbl.preinit)
- dev->fn_tbl.preinit(dev, 0);
-
-#endif
-
- dev->irq = pci_get_irq(dev->device);
- /* XXX Fix domain number (alpha hoses) */
- dev->pci_domain = 0;
- dev->pci_bus = pci_get_bus(dev->device);
- dev->pci_slot = pci_get_slot(dev->device);
- dev->pci_func = pci_get_function(dev->device);
-
- dev->maplist = DRM(calloc)(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
- if (dev->maplist == NULL) {
- retcode = ENOMEM;
- goto error;
- }
- TAILQ_INIT(dev->maplist);
-
- dev->name = DRIVER_NAME;
- DRM(mem_init)();
- DRM(sysctl_init)(dev);
- TAILQ_INIT(&dev->files);
-
-#if __REALLY_HAVE_AGP
- dev->agp = DRM(agp_init)();
-#if __MUST_HAVE_AGP
- if ( dev->agp == NULL ) {
- DRM_ERROR( "Cannot initialize the agpgart module.\n" );
- retcode = DRM_ERR(ENOMEM);
- goto error;
- }
-#endif /* __MUST_HAVE_AGP */
-#if __REALLY_HAVE_MTRR
- if (dev->agp) {
- if (DRM(mtrr_add)(dev->agp->info.ai_aperture_base,
- dev->agp->info.ai_aperture_size, DRM_MTRR_WC) == 0)
- dev->agp->mtrr = 1;
- }
-#endif /* __REALLY_HAVE_MTRR */
-#endif /* __REALLY_HAVE_AGP */
-
-#if __HAVE_CTX_BITMAP
- retcode = DRM(ctxbitmap_init)( dev );
- if (retcode != 0) {
- DRM_ERROR( "Cannot allocate memory for context bitmap.\n" );
- goto error;
- }
-#endif
-
- DRM_INFO( "Initialized %s %d.%d.%d %s on minor %d\n",
- DRIVER_NAME,
- DRIVER_MAJOR,
- DRIVER_MINOR,
- DRIVER_PATCHLEVEL,
- DRIVER_DATE,
- unit );
-
- if (dev->fn_tbl.postinit)
- dev->fn_tbl.postinit(dev, 0);
-
- return 0;
-
-error:
- DRM(sysctl_cleanup)(dev);
- DRM_LOCK();
- DRM(takedown)(dev);
- DRM_UNLOCK();
-#ifdef __FreeBSD__
- destroy_dev(dev->devnode);
-#if __FreeBSD_version >= 500000
- mtx_destroy(&dev->dev_lock);
-#endif
-#endif
- DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
- return retcode;
-}
-
-/* linux: drm_cleanup is called via cleanup_module at module unload time.
- * bsd: drm_cleanup is called per device at module unload time.
- * FIXME: NetBSD
- */
-static void DRM(cleanup)(drm_device_t *dev)
-{
-
- DRM_DEBUG( "\n" );
-
- DRM(sysctl_cleanup)( dev );
-#ifdef __FreeBSD__
- destroy_dev(dev->devnode);
-#endif
-#if __HAVE_CTX_BITMAP
- DRM(ctxbitmap_cleanup)( dev );
-#endif
-
-#if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR
- if (dev->agp && dev->agp->mtrr) {
- int __unused retcode;
-
- retcode = DRM(mtrr_del)(dev->agp->info.ai_aperture_base,
- dev->agp->info.ai_aperture_size, DRM_MTRR_WC);
- DRM_DEBUG("mtrr_del = %d", retcode);
- }
-#endif
-
- DRM_LOCK();
- DRM(takedown)( dev );
- DRM_UNLOCK();
-
-#if __REALLY_HAVE_AGP
- if ( dev->agp ) {
- DRM(agp_uninit)();
- DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
- dev->agp = NULL;
- }
-#endif
- if (dev->fn_tbl.postcleanup)
- dev->fn_tbl.postcleanup(dev);
-
- DRM(mem_uninit)();
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- mtx_destroy(&dev->dev_lock);
-#endif
- DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
-}
-
-
-int DRM(version)( DRM_IOCTL_ARGS )
-{
- drm_version_t version;
- int len;
-
- DRM_COPY_FROM_USER_IOCTL( version, (drm_version_t *)data, sizeof(version) );
-
-#define DRM_COPY( name, value ) \
- len = strlen( value ); \
- if ( len > name##_len ) len = name##_len; \
- name##_len = strlen( value ); \
- if ( len && name ) { \
- if ( DRM_COPY_TO_USER( name, value, len ) ) \
- return DRM_ERR(EFAULT); \
- }
-
- version.version_major = DRIVER_MAJOR;
- version.version_minor = DRIVER_MINOR;
- version.version_patchlevel = DRIVER_PATCHLEVEL;
-
- DRM_COPY( version.name, DRIVER_NAME );
- DRM_COPY( version.date, DRIVER_DATE );
- DRM_COPY( version.desc, DRIVER_DESC );
-
- DRM_COPY_TO_USER_IOCTL( (drm_version_t *)data, version, sizeof(version) );
-
- return 0;
-}
-
-int DRM(open)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
-{
- drm_device_t *dev = NULL;
- int retcode = 0;
-
- dev = DRIVER_SOFTC(minor(kdev));
-
- DRM_DEBUG( "open_count = %d\n", dev->open_count );
-
- retcode = DRM(open_helper)(kdev, flags, fmt, p, dev);
-
- if ( !retcode ) {
- atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
- DRM_LOCK();
-#ifdef __FreeBSD__
- device_busy(dev->device);
-#endif
- if ( !dev->open_count++ )
- retcode = DRM(setup)( dev );
- DRM_UNLOCK();
- }
-
- return retcode;
-}
-
-int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
-{
- drm_file_t *priv;
- DRM_DEVICE;
- int retcode = 0;
- DRMFILE filp = (void *)(uintptr_t)(DRM_CURRENTPID);
-
- DRM_DEBUG( "open_count = %d\n", dev->open_count );
-
- DRM_LOCK();
-
- priv = DRM(find_file_by_proc)(dev, p);
- if (!priv) {
- DRM_UNLOCK();
- DRM_ERROR("can't find authenticator\n");
- return EINVAL;
- }
-
- if (dev->fn_tbl.prerelease)
- dev->fn_tbl.prerelease(dev, filp);
-
- /* ========================================================
- * Begin inline drm_release
- */
-
-#ifdef __FreeBSD__
- DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
- DRM_CURRENTPID, (long)dev->device, dev->open_count );
-#elif defined(__NetBSD__)
- DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
- DRM_CURRENTPID, (long)&dev->device, dev->open_count);
-#endif
-
- if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
- && dev->lock.filp == filp) {
- DRM_DEBUG("Process %d dead, freeing lock for context %d\n",
- DRM_CURRENTPID,
- _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
-#if __HAVE_RELEASE
- DRIVER_RELEASE();
-#endif
- DRM(lock_free)(dev,
- &dev->lock.hw_lock->lock,
- _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock));
-
- /* FIXME: may require heavy-handed reset of
- hardware at this point, possibly
- processed via a callback to the X
- server. */
- }
-#if __HAVE_RELEASE
- else if ( dev->lock.hw_lock ) {
- /* The lock is required to reclaim buffers */
- for (;;) {
- if ( !dev->lock.hw_lock ) {
- /* Device has been unregistered */
- retcode = DRM_ERR(EINTR);
- break;
- }
- if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
- dev->lock.pid = DRM_CURRENTPID;
- dev->lock.lock_time = jiffies;
- atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
- break; /* Got lock */
- }
- /* Contention */
-#if defined(__FreeBSD__) && __FreeBSD_version > 500000
- retcode = msleep((void *)&dev->lock.lock_queue,
- dev->dev_lock, PZERO | PCATCH, "drmlk2", 0);
-#else
- retcode = tsleep((void *)&dev->lock.lock_queue,
- PZERO | PCATCH, "drmlk2", 0);
-#endif
- if (retcode)
- break;
- }
- if (retcode == 0) {
- DRIVER_RELEASE();
- DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT );
- }
- }
-#elif __HAVE_DMA
- DRM(reclaim_buffers)( dev, (void *)(uintptr_t)priv->pid );
-#endif
-
-#if defined (__FreeBSD__) && (__FreeBSD_version >= 500000)
- funsetown(&dev->buf_sigio);
-#elif defined(__FreeBSD__)
- funsetown(dev->buf_sigio);
-#elif defined(__NetBSD__)
- dev->buf_pgid = 0;
-#endif /* __NetBSD__ */
-
- if (--priv->refs == 0) {
- TAILQ_REMOVE(&dev->files, priv, link);
- DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
- }
-
- /* ========================================================
- * End inline drm_release
- */
-
- atomic_inc( &dev->counts[_DRM_STAT_CLOSES] );
-#ifdef __FreeBSD__
- device_unbusy(dev->device);
-#endif
- if (--dev->open_count == 0) {
- retcode = DRM(takedown)(dev);
- }
-
- DRM_UNLOCK();
-
- return retcode;
-}
-
-/* DRM(ioctl) is called whenever a process performs an ioctl on /dev/drm.
- */
-int DRM(ioctl)(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
- DRM_STRUCTPROC *p)
-{
- DRM_DEVICE;
- int retcode = 0;
- drm_ioctl_desc_t *ioctl;
- int (*func)(DRM_IOCTL_ARGS);
- int nr = DRM_IOCTL_NR(cmd);
- drm_file_t *priv;
-
- DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)(uintptr_t)DRM_CURRENTPID);
-
- atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
- ++priv->ioctl_count;
-
-#ifdef __FreeBSD__
- DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
- DRM_CURRENTPID, cmd, nr, (long)dev->device, priv->authenticated );
-#elif defined(__NetBSD__)
- DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
- DRM_CURRENTPID, cmd, nr, (long)&dev->device, priv->authenticated );
-#endif
-
- switch (cmd) {
- case FIONBIO:
- case FIOASYNC:
- return 0;
-
-#ifdef __FreeBSD__
- case FIOSETOWN:
- return fsetown(*(int *)data, &dev->buf_sigio);
-
- case FIOGETOWN:
-#if (__FreeBSD_version >= 500000)
- *(int *) data = fgetown(&dev->buf_sigio);
-#else
- *(int *) data = fgetown(dev->buf_sigio);
-#endif
- return 0;
-#endif /* __FreeBSD__ */
-#ifdef __NetBSD__
- case TIOCSPGRP:
- dev->buf_pgid = *(int *)data;
- return 0;
-
- case TIOCGPGRP:
- *(int *)data = dev->buf_pgid;
- return 0;
-#endif /* __NetBSD__ */
- }
-
- if (nr >= DRIVER_IOCTL_COUNT || IOCGROUP(cmd) != DRM_IOCTL_BASE)
- return EINVAL;
-
- ioctl = &DRM(ioctls)[nr];
- func = ioctl->func;
-
- if (func == NULL) {
- DRM_DEBUG( "no function\n" );
- return EINVAL;
- }
- if ((ioctl->root_only && DRM_SUSER(p)) || (ioctl->auth_needed &&
- !priv->authenticated))
- return EACCES;
-
- retcode = func(kdev, cmd, data, flags, p, (void *)(uintptr_t)DRM_CURRENTPID);
-
- return DRM_ERR(retcode);
-}
-
-int DRM(lock)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_lock_t lock;
- int ret = 0;
-
- DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) );
-
- if ( lock.context == DRM_KERNEL_CONTEXT ) {
- DRM_ERROR( "Process %d using kernel context %d\n",
- DRM_CURRENTPID, lock.context );
- return DRM_ERR(EINVAL);
- }
-
- DRM_DEBUG( "%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
- lock.context, DRM_CURRENTPID,
- dev->lock.hw_lock->lock, lock.flags );
-
-#if __HAVE_DMA_QUEUE
- if ( lock.context < 0 )
- return DRM_ERR(EINVAL);
-#endif
-
- DRM_LOCK();
- for (;;) {
- if (DRM(lock_take)(&dev->lock.hw_lock->lock, lock.context)) {
- dev->lock.filp = (void *)(uintptr_t)DRM_CURRENTPID;
- dev->lock.lock_time = jiffies;
- atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
- break; /* Got lock */
- }
-
- /* Contention */
-#if defined(__FreeBSD__) && __FreeBSD_version > 500000
- ret = msleep((void *)&dev->lock.lock_queue, &dev->dev_lock,
- PZERO | PCATCH, "drmlk2", 0);
-#else
- ret = tsleep((void *)&dev->lock.lock_queue, PZERO | PCATCH,
- "drmlk2", 0);
-#endif
- if (ret != 0)
- break;
- }
- DRM_UNLOCK();
- DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" );
-
- if (ret != 0)
- return ret;
-
- /* XXX: Add signal blocking here */
-
-#if __HAVE_DMA_QUIESCENT
- if (lock.flags & _DRM_LOCK_QUIESCENT) {
- DRIVER_DMA_QUIESCENT();
- }
-#endif
-
- return 0;
-}
-
-
-int DRM(unlock)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_lock_t lock;
-
- DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) ) ;
-
- if ( lock.context == DRM_KERNEL_CONTEXT ) {
- DRM_ERROR( "Process %d using kernel context %d\n",
- DRM_CURRENTPID, lock.context );
- return DRM_ERR(EINVAL);
- }
-
- atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] );
-
- DRM_LOCK();
- DRM(lock_transfer)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT );
-#if __HAVE_DMA_SCHEDULE
- DRM(dma_schedule)( dev, 1 );
-#endif
-
- if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
- DRM_ERROR( "\n" );
- }
- DRM_UNLOCK();
-
- return 0;
-}
-
-#if DRM_LINUX
-
-#include <sys/sysproto.h>
-
-MODULE_DEPEND(DRIVER_NAME, linux, 1, 1, 1);
-
-#define LINUX_IOCTL_DRM_MIN 0x6400
-#define LINUX_IOCTL_DRM_MAX 0x64ff
-
-static linux_ioctl_function_t DRM(linux_ioctl);
-static struct linux_ioctl_handler DRM(handler) = {DRM(linux_ioctl),
- LINUX_IOCTL_DRM_MIN, LINUX_IOCTL_DRM_MAX};
-
-SYSINIT(DRM(register), SI_SUB_KLD, SI_ORDER_MIDDLE,
- linux_ioctl_register_handler, &DRM(handler));
-SYSUNINIT(DRM(unregister), SI_SUB_KLD, SI_ORDER_MIDDLE,
- linux_ioctl_unregister_handler, &DRM(handler));
-
-/* The bits for in/out are switched on Linux */
-#define LINUX_IOC_IN IOC_OUT
-#define LINUX_IOC_OUT IOC_IN
-
-static int
-DRM(linux_ioctl)(DRM_STRUCTPROC *p, struct linux_ioctl_args* args)
-{
- int error;
- int cmd = args->cmd;
-
- args->cmd &= ~(LINUX_IOC_IN | LINUX_IOC_OUT);
- if (cmd & LINUX_IOC_IN)
- args->cmd |= IOC_IN;
- if (cmd & LINUX_IOC_OUT)
- args->cmd |= IOC_OUT;
-
- error = ioctl(p, (struct ioctl_args *)args);
-
- return error;
-}
-#endif /* DRM_LINUX */
diff --git a/bsd/drm_fops.h b/bsd/drm_fops.h
deleted file mode 100644
index 2c447992..00000000
--- a/bsd/drm_fops.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* drm_fops.h -- File operations for DRM -*- linux-c -*-
- * Created: Mon Jan 4 08:58:31 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Daryll Strauss <daryll@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p)
-{
-#if __FreeBSD_version >= 500021
- uid_t uid = p->td_ucred->cr_svuid;
- pid_t pid = p->td_proc->p_pid;
-#else
- uid_t uid = p->p_cred->p_svuid;
- pid_t pid = p->p_pid;
-#endif
- drm_file_t *priv;
-
- DRM_SPINLOCK_ASSERT(&dev->dev_lock);
-
- TAILQ_FOREACH(priv, &dev->files, link)
- if (priv->pid == pid && priv->uid == uid)
- return priv;
- return NULL;
-}
-
-/* DRM(open_helper) is called whenever a process opens /dev/drm. */
-int DRM(open_helper)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
- drm_device_t *dev)
-{
- int m = minor(kdev);
- drm_file_t *priv;
-
- if (flags & O_EXCL)
- return EBUSY; /* No exclusive opens */
- dev->flags = flags;
-
- DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
-
- DRM_LOCK();
- priv = DRM(find_file_by_proc)(dev, p);
- if (priv) {
- priv->refs++;
- } else {
- priv = (drm_file_t *) DRM(alloc)(sizeof(*priv), DRM_MEM_FILES);
- if (priv == NULL) {
- DRM_UNLOCK();
- return DRM_ERR(ENOMEM);
- }
- bzero(priv, sizeof(*priv));
-#if __FreeBSD_version >= 500000
- priv->uid = p->td_ucred->cr_svuid;
- priv->pid = p->td_proc->p_pid;
-#else
- priv->uid = p->p_cred->p_svuid;
- priv->pid = p->p_pid;
-#endif
-
- priv->refs = 1;
- priv->minor = m;
- priv->devXX = dev;
- priv->ioctl_count = 0;
- priv->authenticated = !DRM_SUSER(p);
-
- if (dev->fn_tbl.open_helper)
- dev->fn_tbl.open_helper(dev, priv);
-
- TAILQ_INSERT_TAIL(&dev->files, priv, link);
- }
- DRM_UNLOCK();
-#ifdef __FreeBSD__
- kdev->si_drv1 = dev;
-#endif
- return 0;
-}
-
-
-/* The DRM(read) and DRM(poll) are stubs to prevent spurious errors
- * on older X Servers (4.3.0 and earlier) */
-
-int DRM(read)(struct cdev *kdev, struct uio *uio, int ioflag)
-{
- return 0;
-}
-
-int DRM(poll)(struct cdev *kdev, int events, DRM_STRUCTPROC *p)
-{
- return 0;
-}
diff --git a/bsd/drm_ioctl.h b/bsd/drm_ioctl.h
deleted file mode 100644
index 0952211e..00000000
--- a/bsd/drm_ioctl.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/* drm_ioctl.h -- IOCTL processing for DRM -*- linux-c -*-
- * Created: Fri Jan 8 09:01:26 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-/*
- * Beginning in revision 1.1 of the DRM interface, getunique will return
- * a unique in the form pci:oooo:bb:dd.f (o=domain, b=bus, d=device, f=function)
- * before setunique has been called. The format for the bus-specific part of
- * the unique is not defined for any other bus.
- */
-int DRM(getunique)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_unique_t u;
-
- DRM_COPY_FROM_USER_IOCTL( u, (drm_unique_t *)data, sizeof(u) );
-
- if (u.unique_len >= dev->unique_len) {
- if (DRM_COPY_TO_USER(u.unique, dev->unique, dev->unique_len))
- return DRM_ERR(EFAULT);
- }
- u.unique_len = dev->unique_len;
-
- DRM_COPY_TO_USER_IOCTL( (drm_unique_t *)data, u, sizeof(u) );
-
- return 0;
-}
-
-/* Deprecated in DRM version 1.1, and will return EBUSY when setversion has
- * requested version 1.1 or greater.
- */
-int DRM(setunique)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_unique_t u;
- int domain, bus, slot, func, ret;
-
- if (dev->unique_len || dev->unique)
- return DRM_ERR(EBUSY);
-
- DRM_COPY_FROM_USER_IOCTL( u, (drm_unique_t *)data, sizeof(u) );
-
- if (!u.unique_len || u.unique_len > 1024)
- return DRM_ERR(EINVAL);
-
- dev->unique_len = u.unique_len;
- dev->unique = DRM(alloc)(u.unique_len + 1, DRM_MEM_DRIVER);
-
- if (dev->unique == NULL)
- return DRM_ERR(ENOMEM);
-
- if (DRM_COPY_FROM_USER(dev->unique, u.unique, dev->unique_len))
- return DRM_ERR(EFAULT);
-
- dev->unique[dev->unique_len] = '\0';
-
- /* Return error if the busid submitted doesn't match the device's actual
- * busid.
- */
- ret = sscanf(dev->unique, "PCI:%d:%d:%d", &bus, &slot, &func);
- if (ret != 3)
- return DRM_ERR(EINVAL);
- domain = bus >> 8;
- bus &= 0xff;
-
- if ((domain != dev->pci_domain) ||
- (bus != dev->pci_bus) ||
- (slot != dev->pci_slot) ||
- (func != dev->pci_func))
- return DRM_ERR(EINVAL);
-
- return 0;
-}
-
-
-static int
-DRM(set_busid)(drm_device_t *dev)
-{
-
- if (dev->unique != NULL)
- return EBUSY;
-
- dev->unique_len = 20;
- dev->unique = DRM(alloc)(dev->unique_len + 1, DRM_MEM_DRIVER);
- if (dev->unique == NULL)
- return ENOMEM;
-
- snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%1x",
- dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
-
- return 0;
-}
-
-int DRM(getmap)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_map_t map;
- drm_local_map_t *mapinlist;
- drm_map_list_entry_t *list;
- int idx;
- int i = 0;
-
- DRM_COPY_FROM_USER_IOCTL( map, (drm_map_t *)data, sizeof(map) );
-
- idx = map.offset;
-
- DRM_LOCK();
- if (idx < 0) {
- DRM_UNLOCK();
- return DRM_ERR(EINVAL);
- }
-
- TAILQ_FOREACH(list, dev->maplist, link) {
- mapinlist = list->map;
- if (i==idx) {
- map.offset = mapinlist->offset;
- map.size = mapinlist->size;
- map.type = mapinlist->type;
- map.flags = mapinlist->flags;
- map.handle = mapinlist->handle;
- map.mtrr = mapinlist->mtrr;
- break;
- }
- i++;
- }
-
- DRM_UNLOCK();
-
- if (!list)
- return EINVAL;
-
- DRM_COPY_TO_USER_IOCTL( (drm_map_t *)data, map, sizeof(map) );
-
- return 0;
-}
-
-int DRM(getclient)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_client_t client;
- drm_file_t *pt;
- int idx;
- int i = 0;
-
- DRM_COPY_FROM_USER_IOCTL( client, (drm_client_t *)data, sizeof(client) );
-
- idx = client.idx;
- DRM_LOCK();
- TAILQ_FOREACH(pt, &dev->files, link) {
- if (i==idx)
- {
- client.auth = pt->authenticated;
- client.pid = pt->pid;
- client.uid = pt->uid;
- client.magic = pt->magic;
- client.iocs = pt->ioctl_count;
- DRM_UNLOCK();
-
- *(drm_client_t *)data = client;
- return 0;
- }
- i++;
- }
- DRM_UNLOCK();
-
- DRM_COPY_TO_USER_IOCTL( (drm_client_t *)data, client, sizeof(client) );
-
- return 0;
-}
-
-int DRM(getstats)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_stats_t stats;
- int i;
-
- memset(&stats, 0, sizeof(stats));
-
- DRM_LOCK();
-
- for (i = 0; i < dev->counters; i++) {
- if (dev->types[i] == _DRM_STAT_LOCK)
- stats.data[i].value
- = (dev->lock.hw_lock
- ? dev->lock.hw_lock->lock : 0);
- else
- stats.data[i].value = atomic_read(&dev->counts[i]);
- stats.data[i].type = dev->types[i];
- }
-
- stats.count = dev->counters;
-
- DRM_UNLOCK();
-
- DRM_COPY_TO_USER_IOCTL( (drm_stats_t *)data, stats, sizeof(stats) );
-
- return 0;
-}
-
-#define DRM_IF_MAJOR 1
-#define DRM_IF_MINOR 2
-
-int DRM(setversion)(DRM_IOCTL_ARGS)
-{
- DRM_DEVICE;
- drm_set_version_t sv;
- drm_set_version_t retv;
- int if_version;
-
- DRM_COPY_FROM_USER_IOCTL(sv, (drm_set_version_t *)data, sizeof(sv));
-
- retv.drm_di_major = DRM_IF_MAJOR;
- retv.drm_di_minor = DRM_IF_MINOR;
- retv.drm_dd_major = DRIVER_MAJOR;
- retv.drm_dd_minor = DRIVER_MINOR;
-
- DRM_COPY_TO_USER_IOCTL((drm_set_version_t *)data, retv, sizeof(sv));
-
- if (sv.drm_di_major != -1) {
- if (sv.drm_di_major != DRM_IF_MAJOR ||
- sv.drm_di_minor < 0 || sv.drm_di_minor > DRM_IF_MINOR)
- return EINVAL;
- if_version = DRM_IF_VERSION(sv.drm_di_major, sv.drm_dd_minor);
- dev->if_version = DRM_MAX(if_version, dev->if_version);
- if (sv.drm_di_minor >= 1) {
- /*
- * Version 1.1 includes tying of DRM to specific device
- */
- DRM(set_busid)(dev);
- }
- }
-
- if (sv.drm_dd_major != -1) {
- if (sv.drm_dd_major != DRIVER_MAJOR ||
- sv.drm_dd_minor < 0 || sv.drm_dd_minor > DRIVER_MINOR)
- return EINVAL;
-#ifdef DRIVER_SETVERSION
- DRIVER_SETVERSION(dev, &sv);
-#endif
- }
- return 0;
-}
-
-
-int DRM(noop)(DRM_IOCTL_ARGS)
-{
- DRM_DEBUG("\n");
- return 0;
-}
diff --git a/bsd/drm_irq.h b/bsd/drm_irq.h
deleted file mode 100644
index eec6ab93..00000000
--- a/bsd/drm_irq.h
+++ /dev/null
@@ -1,281 +0,0 @@
-/* drm_dma.c -- DMA IOCTL and function support
- * Created: Fri Oct 18 2003 by anholt@FreeBSD.org
- *
- * Copyright 2003 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <anholt@FreeBSD.org>
- *
- */
-
-int DRM(irq_by_busid)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_irq_busid_t irq;
-
- DRM_COPY_FROM_USER_IOCTL(irq, (drm_irq_busid_t *)data, sizeof(irq));
-
- if ((irq.busnum >> 8) != dev->pci_domain ||
- (irq.busnum & 0xff) != dev->pci_bus ||
- irq.devnum != dev->pci_slot ||
- irq.funcnum != dev->pci_func)
- return EINVAL;
-
- irq.irq = dev->irq;
-
- DRM_DEBUG("%d:%d:%d => IRQ %d\n",
- irq.busnum, irq.devnum, irq.funcnum, irq.irq);
-
- DRM_COPY_TO_USER_IOCTL( (drm_irq_busid_t *)data, irq, sizeof(irq) );
-
- return 0;
-}
-
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
-static irqreturn_t
-DRM(irq_handler_wrap)(DRM_IRQ_ARGS)
-{
- drm_device_t *dev = (drm_device_t *)arg;
-
- DRM_SPINLOCK(&dev->irq_lock);
- DRM(irq_handler)(arg);
- DRM_SPINUNLOCK(&dev->irq_lock);
-}
-#endif
-
-int DRM(irq_install)(drm_device_t *dev)
-{
- int retcode;
-
- if (dev->irq == 0 || dev->dev_private == NULL)
- return DRM_ERR(EINVAL);
-
- DRM_LOCK();
- if (dev->irq_enabled) {
- DRM_UNLOCK();
- return DRM_ERR(EBUSY);
- }
- dev->irq_enabled = 1;
- DRM_UNLOCK();
-
- DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
-
- dev->context_flag = 0;
-
- dev->dma->next_buffer = NULL;
- dev->dma->this_buffer = NULL;
-
-#if __HAVE_IRQ_BH
- TASK_INIT(&dev->task, 0, DRM(dma_immediate_bh), dev);
-#endif
-
- DRM_SPININIT(dev->irq_lock, "DRM IRQ lock");
-
- /* Before installing handler */
- DRM(driver_irq_preinstall)( dev );
-
- /* Install handler */
-#ifdef __FreeBSD__
- dev->irqrid = 0;
- dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ,
- &dev->irqrid, RF_SHAREABLE);
- if (!dev->irqr) {
- retcode = ENOENT;
- goto err;
- }
-#if __FreeBSD_version < 500000
- retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY,
- DRM(irq_handler), dev, &dev->irqh);
-#else
- retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY | INTR_MPSAFE,
- DRM(irq_handler_wrap), dev, &dev->irqh);
-#endif
- if (retcode != 0)
- goto err;
-#elif defined(__NetBSD__)
- if (pci_intr_map(&dev->pa, &dev->ih) != 0) {
- retcode = ENOENT;
- goto err;
- }
- dev->irqh = pci_intr_establish(&dev->pa.pa_pc, dev->ih, IPL_TTY,
- (irqreturn_t (*)(DRM_IRQ_ARGS))DRM(irq_handler), dev);
- if (!dev->irqh) {
- retcode = ENOENT;
- goto err;
- }
-#endif
-
- /* After installing handler */
- DRM(driver_irq_postinstall)( dev );
-
- return 0;
-err:
- DRM_LOCK();
- dev->irq_enabled = 0;
-#ifdef ___FreeBSD__
- if (dev->irqrid != 0) {
- bus_release_resource(dev->device, SYS_RES_IRQ, dev->irqrid,
- dev->irqr);
- dev->irqrid = 0;
- }
-#endif
- DRM_SPINUNINIT(dev->irq_lock);
- DRM_UNLOCK();
- return retcode;
-}
-
-/* XXX: This function needs to be called with the device lock held. In some
- * cases it isn't, so far.
- */
-int DRM(irq_uninstall)( drm_device_t *dev )
-{
- int irqrid;
-
- if (!dev->irq_enabled)
- return DRM_ERR(EINVAL);
-
- dev->irq_enabled = 0;
- irqrid = dev->irqrid;
- dev->irqrid = 0;
-
- DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
-
- 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
- DRM_SPINUNINIT(dev->irq_lock);
-
- return 0;
-}
-
-int DRM(control)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_control_t ctl;
- int err;
-
- DRM_COPY_FROM_USER_IOCTL( ctl, (drm_control_t *) data, sizeof(ctl) );
-
- switch ( ctl.func ) {
- case DRM_INST_HANDLER:
- if (dev->if_version < DRM_IF_VERSION(1, 2) &&
- ctl.irq != dev->irq)
- return DRM_ERR(EINVAL);
- return DRM(irq_install)(dev);
- case DRM_UNINST_HANDLER:
- DRM_LOCK();
- err = DRM(irq_uninstall)( dev );
- DRM_UNLOCK();
- return err;
- default:
- return DRM_ERR(EINVAL);
- }
-}
-
-#if __HAVE_VBL_IRQ
-int DRM(wait_vblank)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_wait_vblank_t vblwait;
- struct timeval now;
- int ret;
-
- if (!dev->irq_enabled)
- return DRM_ERR(EINVAL);
-
- DRM_COPY_FROM_USER_IOCTL( vblwait, (drm_wait_vblank_t *)data,
- sizeof(vblwait) );
-
- if (vblwait.request.type & _DRM_VBLANK_RELATIVE) {
- vblwait.request.sequence += atomic_read(&dev->vbl_received);
- vblwait.request.type &= ~_DRM_VBLANK_RELATIVE;
- }
-
- flags = vblwait.request.type & _DRM_VBLANK_FLAGS_MASK;
- if (flags & _DRM_VBLANK_SIGNAL) {
-#if 0 /* disabled */
- drm_vbl_sig_t *vbl_sig = DRM_MALLOC(sizeof(drm_vbl_sig_t));
- if (vbl_sig == NULL)
- return ENOMEM;
- bzero(vbl_sig, sizeof(*vbl_sig));
-
- vbl_sig->sequence = vblwait.request.sequence;
- vbl_sig->signo = vblwait.request.signal;
- vbl_sig->pid = DRM_CURRENTPID;
-
- vblwait.reply.sequence = atomic_read(&dev->vbl_received);
-
- DRM_SPINLOCK(&dev->irq_lock);
- TAILQ_INSERT_HEAD(&dev->vbl_sig_list, vbl_sig, link);
- DRM_SPINUNLOCK(&dev->irq_lock);
- ret = 0;
-#endif
- ret = EINVAL;
- } else {
- ret = DRM(vblank_wait)(dev, &vblwait.request.sequence);
-
- microtime(&now);
- vblwait.reply.tval_sec = now.tv_sec;
- vblwait.reply.tval_usec = now.tv_usec;
- }
-
- DRM_COPY_TO_USER_IOCTL( (drm_wait_vblank_t *)data, vblwait,
- sizeof(vblwait) );
-
- return ret;
-}
-
-void DRM(vbl_send_signals)(drm_device_t *dev)
-{
-}
-
-#if 0 /* disabled */
-void DRM(vbl_send_signals)( drm_device_t *dev )
-{
- drm_vbl_sig_t *vbl_sig;
- unsigned int vbl_seq = atomic_read( &dev->vbl_received );
- struct proc *p;
-
- vbl_sig = TAILQ_FIRST(&dev->vbl_sig_list);
- while (vbl_sig != NULL) {
- drm_vbl_sig_t *next = TAILQ_NEXT(vbl_sig, link);
-
- if ( ( vbl_seq - vbl_sig->sequence ) <= (1<<23) ) {
- p = pfind(vbl_sig->pid);
- if (p != NULL)
- psignal(p, vbl_sig->signo);
-
- TAILQ_REMOVE(&dev->vbl_sig_list, vbl_sig, link);
- DRM_FREE(vbl_sig,sizeof(*vbl_sig));
- }
- vbl_sig = next;
- }
-}
-#endif
-
-#endif /* __HAVE_VBL_IRQ */
diff --git a/bsd/drm_linux_list.h b/bsd/drm_linux_list.h
deleted file mode 100644
index e4f9f0cf..00000000
--- a/bsd/drm_linux_list.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* drm_linux_list.h -- linux list functions for the BSDs.
- * Created: Mon Apr 7 14:30:16 1999 by anholt@FreeBSD.org
- *
- * Copyright 2003 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Eric Anholt <anholt@FreeBSD.org>
- */
-
-struct list_head {
- struct list_head *next, *prev;
-};
-
-/* Cheat, assume the list_head is at the start of the struct */
-#define list_entry(entry, type, member) (type *)(entry)
-
-static __inline__ void
-INIT_LIST_HEAD(struct list_head *head) {
- (head)->next = head;
- (head)->prev = head;
-}
-
-static __inline__ int
-list_empty(struct list_head *head) {
- return (head)->next == head;
-}
-
-static __inline__ void
-list_add_tail(struct list_head *entry, struct list_head *head) {
- (entry)->prev = (head)->prev;
- (entry)->next = head;
- (head)->prev->next = entry;
- (head)->prev = entry;
-}
-
-static __inline__ void
-list_del(struct list_head *entry) {
- (entry)->next->prev = (entry)->prev;
- (entry)->prev->next = (entry)->next;
-}
-
-#define list_for_each(entry, head) \
- for (entry = (head)->next; entry != head; entry = (entry)->next)
-
-#define list_for_each_safe(entry, temp, head) \
- for (entry = (head)->next, temp = (entry)->next; \
- temp != head; \
- entry = temp, temp = temp->next)
-
diff --git a/bsd/drm_lock.h b/bsd/drm_lock.h
deleted file mode 100644
index a87e0a3a..00000000
--- a/bsd/drm_lock.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* lock.c -- IOCTLs for locking -*- linux-c -*-
- * Created: Tue Feb 2 08:37:54 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
-{
- unsigned int old, new;
-
- do {
- old = *lock;
- if (old & _DRM_LOCK_HELD) new = old | _DRM_LOCK_CONT;
- else new = context | _DRM_LOCK_HELD;
- } while (!atomic_cmpset_int(lock, old, new));
-
- if (_DRM_LOCKING_CONTEXT(old) == context) {
- if (old & _DRM_LOCK_HELD) {
- if (context != DRM_KERNEL_CONTEXT) {
- DRM_ERROR("%d holds heavyweight lock\n",
- context);
- }
- return 0;
- }
- }
- if (new == (context | _DRM_LOCK_HELD)) {
- /* Have lock */
- return 1;
- }
- return 0;
-}
-
-/* This takes a lock forcibly and hands it to context. Should ONLY be used
- inside *_unlock to give lock to kernel before calling *_dma_schedule. */
-int DRM(lock_transfer)(drm_device_t *dev,
- __volatile__ unsigned int *lock, unsigned int context)
-{
- unsigned int old, new;
-
- dev->lock.filp = NULL;
- do {
- old = *lock;
- new = context | _DRM_LOCK_HELD;
- } while (!atomic_cmpset_int(lock, old, new));
-
- return 1;
-}
-
-int DRM(lock_free)(drm_device_t *dev,
- __volatile__ unsigned int *lock, unsigned int context)
-{
- unsigned int old, new;
-
- dev->lock.filp = NULL;
- do {
- old = *lock;
- new = 0;
- } 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\n",
- context, _DRM_LOCKING_CONTEXT(old));
- return 1;
- }
- DRM_WAKEUP_INT((void *)&dev->lock.lock_queue);
- return 0;
-}
-
diff --git a/bsd/drm_memory.h b/bsd/drm_memory.h
deleted file mode 100644
index 26adb085..00000000
--- a/bsd/drm_memory.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/* drm_memory.h -- Memory management wrappers for DRM -*- linux-c -*-
- * Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-#if defined(__FreeBSD__) || defined(__NetBSD__)
-#define malloctype DRM(M_DRM)
-/* The macros conflicted in the MALLOC_DEFINE */
-MALLOC_DEFINE(malloctype, "drm", "DRM Data Structures");
-#undef malloctype
-#endif
-
-#ifdef DEBUG_MEMORY
-#include "drm_memory_debug.h"
-#else
-void DRM(mem_init)(void)
-{
-#ifdef __NetBSD__
- malloc_type_attach(DRM(M_DRM));
-#endif
-}
-
-void DRM(mem_uninit)(void)
-{
-}
-
-void *DRM(alloc)(size_t size, int area)
-{
- return malloc(size, DRM(M_DRM), M_NOWAIT);
-}
-
-void *DRM(calloc)(size_t nmemb, size_t size, int area)
-{
- return malloc(size * nmemb, DRM(M_DRM), M_NOWAIT | M_ZERO);
-}
-
-void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
-{
- void *pt;
-
- pt = malloc(size, DRM(M_DRM), M_NOWAIT);
- if (pt == NULL)
- return NULL;
- if (oldpt && oldsize) {
- memcpy(pt, oldpt, oldsize);
- free(oldpt, DRM(M_DRM));
- }
- return pt;
-}
-
-void DRM(free)(void *pt, size_t size, int area)
-{
- free(pt, DRM(M_DRM));
-}
-
-void *DRM(ioremap)( drm_device_t *dev, drm_local_map_t *map )
-{
-#ifdef __FreeBSD__
- return pmap_mapdev(map->offset, map->size);
-#elif defined(__NetBSD__)
- map->iot = dev->pa.pa_memt;
- if (bus_space_map(map->iot, map->offset, map->size,
- BUS_SPACE_MAP_LINEAR, &map->ioh))
- return NULL;
- return bus_space_vaddr(map->iot, map->ioh);
-#endif
-}
-
-void DRM(ioremapfree)(drm_local_map_t *map)
-{
-#ifdef __FreeBSD__
- pmap_unmapdev((vm_offset_t) map->handle, map->size);
-#elif defined(__NetBSD__)
- bus_space_unmap(map->iot, map->ioh, map->size);
-#endif
-}
-
-#if __REALLY_HAVE_AGP
-agp_memory *DRM(alloc_agp)(int pages, u32 type)
-{
- return DRM(agp_allocate_memory)(pages, type);
-}
-
-int DRM(free_agp)(agp_memory *handle, int pages)
-{
- return DRM(agp_free_memory)(handle);
-}
-
-int DRM(bind_agp)(agp_memory *handle, unsigned int start)
-{
- return DRM(agp_bind_memory)(handle, start);
-}
-
-int DRM(unbind_agp)(agp_memory *handle)
-{
- return DRM(agp_unbind_memory)(handle);
-}
-#endif /* __REALLY_HAVE_AGP */
-
-#if __REALLY_HAVE_MTRR
-#ifdef __FreeBSD__
-int
-DRM(mtrr_add)(unsigned long offset, size_t size, int flags)
-{
- int act;
- struct mem_range_desc mrdesc;
-
- mrdesc.mr_base = offset;
- mrdesc.mr_len = size;
- mrdesc.mr_flags = flags;
- act = MEMRANGE_SET_UPDATE;
- strlcpy(mrdesc.mr_owner, DRIVER_NAME, sizeof(mrdesc.mr_owner));
- return mem_range_attr_set(&mrdesc, &act);
-}
-
-int
-DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
-{
- int act;
- struct mem_range_desc mrdesc;
-
- mrdesc.mr_base = offset;
- mrdesc.mr_len = size;
- mrdesc.mr_flags = flags;
- act = MEMRANGE_SET_REMOVE;
- strlcpy(mrdesc.mr_owner, DRIVER_NAME, sizeof(mrdesc.mr_owner));
- return mem_range_attr_set(&mrdesc, &act);
-}
-#elif defined(__NetBSD__)
-int
-DRM(mtrr_add)(unsigned long offset, size_t size, int flags)
-{
- struct mtrr mtrrmap;
- int one = 1;
-
- mtrrmap.base = offset;
- mtrrmap.len = size;
- mtrrmap.type = flags;
- mtrrmap.flags = MTRR_VALID;
- return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-}
-
-int
-DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
-{
- struct mtrr mtrrmap;
- int one = 1;
-
- mtrrmap.base = offset;
- mtrrmap.len = size;
- mtrrmap.type = flags;
- mtrrmap.flags = 0;
- return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-}
-#endif
-#endif /* __REALLY_HAVE_MTRR */
-
-#endif /* DEBUG_MEMORY */
diff --git a/bsd/drm_memory_debug.h b/bsd/drm_memory_debug.h
deleted file mode 100644
index d211b76b..00000000
--- a/bsd/drm_memory_debug.h
+++ /dev/null
@@ -1,420 +0,0 @@
-/* drm_memory.h -- Memory management wrappers for DRM -*- linux-c -*-
- * Created: Thu Feb 4 14:00:34 1999 by faith@valinux.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "drmP.h"
-
-#define DRM_SYSCTL_PRINT(fmt, arg...) \
-do { \
- snprintf(buf, sizeof(buf), fmt, ##arg); \
- error = SYSCTL_OUT(req, buf, strlen(buf)); \
- if (error) \
- return error; \
-} while (0)
-
-typedef struct drm_mem_stats {
- const char *name;
- int succeed_count;
- int free_count;
- int fail_count;
- unsigned long bytes_allocated;
- unsigned long bytes_freed;
-} drm_mem_stats_t;
-
-static DRM_SPINTYPE DRM(mem_lock);
-static unsigned long DRM(ram_available) = 0; /* In pages */
-static unsigned long DRM(ram_used) = 0;
-static drm_mem_stats_t DRM(mem_stats)[] = {
- [DRM_MEM_DMA] = { "dmabufs" },
- [DRM_MEM_SAREA] = { "sareas" },
- [DRM_MEM_DRIVER] = { "driver" },
- [DRM_MEM_MAGIC] = { "magic" },
- [DRM_MEM_IOCTLS] = { "ioctltab" },
- [DRM_MEM_MAPS] = { "maplist" },
- [DRM_MEM_BUFS] = { "buflist" },
- [DRM_MEM_SEGS] = { "seglist" },
- [DRM_MEM_PAGES] = { "pagelist" },
- [DRM_MEM_FILES] = { "files" },
- [DRM_MEM_QUEUES] = { "queues" },
- [DRM_MEM_CMDS] = { "commands" },
- [DRM_MEM_MAPPINGS] = { "mappings" },
- [DRM_MEM_BUFLISTS] = { "buflists" },
- [DRM_MEM_AGPLISTS] = { "agplist" },
- [DRM_MEM_SGLISTS] = { "sglist" },
- [DRM_MEM_TOTALAGP] = { "totalagp" },
- [DRM_MEM_BOUNDAGP] = { "boundagp" },
- [DRM_MEM_CTXBITMAP] = { "ctxbitmap"},
- [DRM_MEM_STUB] = { "stub" },
- { NULL, 0, } /* Last entry must be null */
-};
-
-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) {
- mem->succeed_count = 0;
- mem->free_count = 0;
- mem->fail_count = 0;
- mem->bytes_allocated = 0;
- mem->bytes_freed = 0;
- }
-
- DRM(ram_available) = 0; /* si.totalram */
- 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_mem_stats_t *stats, struct sysctl_oid *oidp, void *arg1,
- int arg2, struct sysctl_req *req)
-{
- drm_mem_stats_t *pt;
- char buf[128];
- int error;
-
- DRM_SYSCTL_PRINT(" total counts "
- " | outstanding \n");
- DRM_SYSCTL_PRINT("type alloc freed fail bytes freed"
- " | allocs bytes\n\n");
- DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu |\n",
- "system", 0, 0, 0, DRM(ram_available));
- DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu |\n",
- "locked", 0, 0, 0, DRM(ram_used));
- DRM_SYSCTL_PRINT("\n");
- for (pt = stats; pt->name; pt++) {
- DRM_SYSCTL_PRINT("%-9.9s %5d %5d %4d %10lu %10lu | %6d %10ld\n",
- pt->name,
- pt->succeed_count,
- pt->free_count,
- pt->fail_count,
- pt->bytes_allocated,
- pt->bytes_freed,
- pt->succeed_count - pt->free_count,
- (long)pt->bytes_allocated
- - (long)pt->bytes_freed);
- }
- SYSCTL_OUT(req, "", 1);
-
- return 0;
-}
-
-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));
- 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 /* __FreeBSD__ */
-
-void *DRM(alloc)(size_t size, int area)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(area, "Allocating 0 bytes\n");
- return NULL;
- }
-
- if (!(pt = malloc(size, DRM(M_DRM), M_NOWAIT))) {
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[area].fail_count;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return NULL;
- }
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[area].succeed_count;
- DRM(mem_stats)[area].bytes_allocated += size;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return pt;
-}
-
-void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
-{
- void *pt;
-
- if (!(pt = DRM(alloc)(size, area))) return NULL;
- if (oldpt && oldsize) {
- memcpy(pt, oldpt, oldsize);
- DRM(free)(oldpt, oldsize, area);
- }
- return pt;
-}
-
-void DRM(free)(void *pt, size_t size, int area)
-{
- int alloc_count;
- int free_count;
-
- if (pt == NULL)
- return;
- 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;
- alloc_count = DRM(mem_stats)[area].succeed_count;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-void *DRM(ioremap)( drm_device_t *dev, drm_local_map_t *map )
-{
- void *pt;
-
- if (!map->size) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Mapping 0 bytes at 0x%08lx\n", map->offset);
- return NULL;
- }
-#ifdef __NetBSD__
- map->iot = dev->pa.pa_memt;
-#endif
-
-#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 += map->size;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return pt;
-}
-
-/* unused so far */
-#if 0
-void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size)
-{
- void *pt;
-
- if (!size) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Mapping 0 bytes at 0x%08lx\n", offset);
- return NULL;
- }
-
- /* FIXME FOR BSD */
- if (!(pt = ioremap_nocache(offset, size))) {
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return NULL;
- }
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count;
- DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return pt;
-}
-#endif
-
-void DRM(ioremapfree)(drm_local_map_t *map)
-{
- int alloc_count;
- int free_count;
-
- if (map->handle == NULL)
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Attempt to free NULL pointer\n");
- else
-#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 += 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));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_MAPPINGS,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
-}
-
-#if __REALLY_HAVE_AGP
-agp_memory *DRM(alloc_agp)(int pages, u32 type)
-{
- agp_memory *handle;
-
- if (!pages) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Allocating 0 pages\n");
- return NULL;
- }
-
- if ((handle = DRM(agp_allocate_memory)(pages, type))) {
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated
- += pages << PAGE_SHIFT;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return handle;
- }
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return NULL;
-}
-
-int DRM(free_agp)(agp_memory *handle, int pages)
-{
- int alloc_count;
- int free_count;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
- "Attempt to free NULL AGP handle\n");
- return DRM_ERR(EINVAL);
- }
-
- if (DRM(agp_free_memory)(handle)) {
- DRM_SPINLOCK(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed
- += pages << PAGE_SHIFT;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_TOTALAGP,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
- return 0;
- }
- return DRM_ERR(EINVAL);
-}
-
-int DRM(bind_agp)(agp_memory *handle, unsigned int start)
-{
- int retcode;
- device_t dev = DRM_AGP_FIND_DEVICE();
- struct agp_memory_info info;
-
- if (!dev)
- return EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Attempt to bind NULL AGP handle\n");
- return DRM_ERR(EINVAL);
- }
-
- if (!(retcode = DRM(agp_bind_memory)(handle, start))) {
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
- agp_memory_info(dev, handle, &info);
- DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated
- += info.ami_size;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return DRM_ERR(0);
- }
- DRM_SPINLOCK(&DRM(mem_lock));
- ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- return DRM_ERR(retcode);
-}
-
-int DRM(unbind_agp)(agp_memory *handle)
-{
- int alloc_count;
- int free_count;
- int retcode = EINVAL;
- device_t dev = DRM_AGP_FIND_DEVICE();
- struct agp_memory_info info;
-
- if (!dev)
- return EINVAL;
-
- if (!handle) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Attempt to unbind NULL AGP handle\n");
- return DRM_ERR(retcode);
- }
-
- agp_memory_info(dev, handle, &info);
-
- if ((retcode = DRM(agp_unbind_memory)(handle)))
- return DRM_ERR(retcode);
-
- DRM_SPINLOCK(&DRM(mem_lock));
- free_count = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count;
- alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count;
- DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed
- += info.ami_size;
- DRM_SPINUNLOCK(&DRM(mem_lock));
- if (free_count > alloc_count) {
- DRM_MEM_ERROR(DRM_MEM_BOUNDAGP,
- "Excess frees: %d frees, %d allocs\n",
- free_count, alloc_count);
- }
- return DRM_ERR(retcode);
-}
-#endif
diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h
deleted file mode 100644
index 3ae2dc0b..00000000
--- a/bsd/drm_os_freebsd.h
+++ /dev/null
@@ -1,471 +0,0 @@
-/**
- * \file drm_os_freebsd.h
- * OS-specific #defines for FreeBSD
- *
- * \author Eric Anholt <anholt@FreeBSD.org>
- */
-
-/*
- * Copyright 2003 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <sys/proc.h>
-#include <sys/lock.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <sys/filio.h>
-#include <sys/sysctl.h>
-#include <sys/bus.h>
-#include <sys/signalvar.h>
-#include <sys/poll.h>
-#include <vm/vm.h>
-#include <vm/pmap.h>
-#include <vm/vm_extern.h>
-#include <vm/vm_map.h>
-#include <vm/vm_param.h>
-#include <machine/param.h>
-#include <machine/pmap.h>
-#include <machine/bus.h>
-#include <machine/resource.h>
-#if __FreeBSD_version >= 480000
-#include <sys/endian.h>
-#endif
-#include <sys/mman.h>
-#include <sys/rman.h>
-#include <sys/memrange.h>
-#if __FreeBSD_version >= 500000
-#include <dev/pci/pcivar.h>
-#include <sys/selinfo.h>
-#else
-#include <pci/pcivar.h>
-#include <sys/select.h>
-#endif
-#include <sys/bus.h>
-#if __FreeBSD_version >= 400005
-#include <sys/taskqueue.h>
-#endif
-#if __FreeBSD_version >= 500000
-#include <sys/mutex.h>
-#endif
-
-#include "drm_linux_list.h"
-
-#if __FreeBSD_version >= 400006
-#define __REALLY_HAVE_AGP __HAVE_AGP
-#endif
-
-#ifdef __i386__
-#define __REALLY_HAVE_MTRR (__HAVE_MTRR) && (__FreeBSD_version >= 460000)
-#elif defined(__amd64__)
-#define __REALLY_HAVE_MTRR (__HAVE_MTRR)
-#else
-#define __REALLY_HAVE_MTRR 0
-#endif
-
-#define __REALLY_HAVE_SG (__HAVE_SG)
-
-#if __REALLY_HAVE_AGP
-#include <pci/agpvar.h>
-#include <sys/agpio.h>
-#endif
-
-#include <opt_drm.h>
-#if DRM_DEBUG
-#undef DRM_DEBUG_CODE
-#define DRM_DEBUG_CODE 2
-#endif
-#undef DRM_DEBUG
-
-#if DRM_LINUX
-#include <sys/file.h>
-#include <sys/proc.h>
-#include <machine/../linux/linux.h>
-#include <machine/../linux/linux_proto.h>
-#endif
-
-#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
-
-#if __FreeBSD_version >= 500000
-#define DRM_CURPROC curthread
-#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_SPINLOCK_ASSERT(l) mtx_assert(l, MA_OWNED)
-#define DRM_CURRENTPID curthread->td_proc->p_pid
-#define DRM_LOCK() mtx_lock(&dev->dev_lock)
-#define DRM_UNLOCK() mtx_unlock(&dev->dev_lock)
-#else
-/* There is no need for locking on FreeBSD 4.x. Synchronization is handled by
- * the fact that there is no reentrancy of the kernel except for interrupt
- * handlers, and the interrupt handler synchronization is managed by spls.
- */
-#define DRM_CURPROC curproc
-#define DRM_STRUCTPROC struct proc
-#define DRM_SPINTYPE
-#define DRM_SPININIT(l,name)
-#define DRM_SPINUNINIT(l)
-#define DRM_SPINLOCK(l)
-#define DRM_SPINUNLOCK(u)
-#define DRM_SPINLOCK_ASSERT(l)
-#define DRM_CURRENTPID curproc->p_pid
-#define DRM_LOCK()
-#define DRM_UNLOCK()
-#endif
-
-/* Currently our DRMFILE (filp) is a void * which is actually the pid
- * of the current process. It should be a per-open unique pointer, but
- * code for that is not yet written */
-#define DRMFILE void *
-#define DRM_IOCTL_ARGS struct cdev *kdev, u_long cmd, caddr_t data, \
- int flags, DRM_STRUCTPROC *p, DRMFILE filp
-#define DRM_SUSER(p) suser(p)
-#define DRM_TASKQUEUE_ARGS void *arg, int pending
-#define DRM_IRQ_ARGS void *arg
-typedef void irqreturn_t;
-#define IRQ_HANDLED /* nothing */
-#define IRQ_NONE /* nothing */
-#define DRM_DEVICE drm_device_t *dev = kdev->si_drv1
-#define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT )
-#define DRM_FREE(pt,size) free( pt, DRM(M_DRM) )
-
-/* 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_READ16(map, offset) *(volatile u_int16_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_WRITE16(map, offset, val) *(volatile u_int16_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
-
-#define DRM_MTRR_WC MDF_WRITECOMBINE
-
-#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \
-do { \
- if (_filp != (DRMFILE)(intptr_t)DRM_CURRENTPID) { \
- DRM_ERROR("filp doesn't match curproc\n"); \
- return EINVAL; \
- } \
- DRM_LOCK(); \
- _priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
- DRM_UNLOCK(); \
- if (_priv == NULL) { \
- DRM_ERROR("can't find authenticator\n"); \
- return EINVAL; \
- } \
-} while (0)
-
-#define LOCK_TEST_WITH_RETURN(dev, filp) \
-do { \
- if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
- dev->lock.filp != filp) { \
- DRM_ERROR("%s called without lock held\n", \
- __FUNCTION__); \
- return EINVAL; \
- } \
-} while (0)
-
-#define DRM_UDELAY(udelay) DELAY(udelay)
-
-#define DRM_GETSAREA() \
-do { \
- drm_map_list_entry_t *listentry; \
- TAILQ_FOREACH(listentry, dev->maplist, link) { \
- drm_local_map_t *map = listentry->map; \
- if (map->type == _DRM_SHM && \
- map->flags & _DRM_CONTAINS_LOCK) { \
- dev_priv->sarea = map; \
- break; \
- } \
- } \
-} while (0)
-
-#define DRM_HZ hz
-
-#if defined(__FreeBSD__) && __FreeBSD_version > 500000
-#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
-for ( ret = 0 ; !ret && !(condition) ; ) { \
- mtx_lock(&dev->irq_lock); \
- if (!(condition)) \
- ret = msleep(&(queue), &dev->irq_lock, \
- PZERO | PCATCH, "drmwtq", (timeout)); \
- mtx_unlock(&dev->irq_lock); \
-}
-#else
-#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
-for ( ret = 0 ; !ret && !(condition) ; ) { \
- int s = spldrm(); \
- if (!(condition)) \
- ret = tsleep( &(queue), PZERO | PCATCH, \
- "drmwtq", (timeout) ); \
- splx(s); \
-}
-#endif
-
-#define DRM_WAKEUP( queue ) wakeup( queue )
-#define DRM_WAKEUP_INT( queue ) wakeup( queue )
-#define DRM_INIT_WAITQUEUE( queue ) do {} while (0)
-
-#define DRM_COPY_TO_USER_IOCTL(user, kern, size) \
- if ( IOCPARM_LEN(cmd) != size) \
- return EINVAL; \
- *user = kern;
-#define DRM_COPY_FROM_USER_IOCTL(kern, user, size) \
- if ( IOCPARM_LEN(cmd) != size) \
- return EINVAL; \
- kern = *user;
-#define DRM_COPY_TO_USER(user, kern, size) \
- copyout(kern, user, size)
-#define DRM_COPY_FROM_USER(kern, user, size) \
- copyin(user, kern, size)
-/* 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 ) \
- (!useracc((caddr_t)uaddr, size, VM_PROT_READ))
-#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
- copyin(arg2, arg1, arg3)
-#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \
- copyout(arg2, arg1, arg3)
-#define DRM_GET_USER_UNCHECKED(val, uaddr) \
- ((val) = fuword(uaddr), 0)
-#define DRM_PUT_USER_UNCHECKED(uaddr, val) \
- suword(uaddr, val)
-
-/* DRM_READMEMORYBARRIER() prevents reordering of reads.
- * DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
- * DRM_MEMORYBARRIER() prevents reordering of reads and writes.
- */
-#if defined(__i386__)
-#define DRM_READMEMORYBARRIER() __asm __volatile( \
- "lock; addl $0,0(%%esp)" : : : "memory");
-#define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory");
-#define DRM_MEMORYBARRIER() __asm __volatile( \
- "lock; addl $0,0(%%esp)" : : : "memory");
-#elif defined(__alpha__)
-#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)
-
-#ifndef M_WAITOK /* M_WAITOK (=0) name removed in -current */
-#define M_WAITOK 0
-#endif
-
-#define malloctype DRM(M_DRM)
-/* The macros conflicted in the MALLOC_DEFINE */
-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)
-#else
-#define cpu_to_le32(x) (x)
-#define le32_to_cpu(x) (x)
-#endif
-
-typedef unsigned long dma_addr_t;
-typedef u_int32_t atomic_t;
-typedef u_int32_t u32;
-typedef u_int16_t u16;
-typedef u_int8_t u8;
-#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)
-
-/* 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(volatile u_int *dst, u_int exp, u_int src)
-{
- int res = exp;
-
- __asm __volatile (
- " lock ; "
- " cmpxchgl %1,%2 ; "
- " setz %%al ; "
- " movzbl %%al,%0 ; "
- "1: "
- "# atomic_cmpset_int"
- : "+a" (res) /* 0 (result) */
- : "r" (src), /* 1 */
- "m" (*(dst)) /* 2 */
- : "memory");
-
- return (res);
-}
-#endif
-
-static __inline atomic_t
-test_and_set_bit(int b, volatile void *p)
-{
- int s = splhigh();
- unsigned int m = 1<<b;
- unsigned int r = *(volatile int *)p & m;
- *(volatile int *)p |= m;
- splx(s);
- return r;
-}
-
-static __inline void
-clear_bit(int b, volatile void *p)
-{
- atomic_clear_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f));
-}
-
-static __inline void
-set_bit(int b, volatile void *p)
-{
- atomic_set_int(((volatile int *)p) + (b >> 5), 1 << (b & 0x1f));
-}
-
-static __inline int
-test_bit(int b, volatile void *p)
-{
- return ((volatile int *)p)[b >> 5] & (1 << (b & 0x1f));
-}
-
-static __inline int
-find_first_zero_bit(volatile void *p, int max)
-{
- int b;
-
- for (b = 0; b < max; b += 32) {
- if (((volatile int *)p)[b >> 5] != ~0) {
- for (;;) {
- if ((((volatile int *)p)[b >> 5] & (1 << (b & 0x1f))) == 0)
- return b;
- b++;
- }
- }
- }
- return max;
-}
-
-#define spldrm() spltty()
-
-/*
- * Fake out the module macros for versions of FreeBSD where they don't
- * exist.
- */
-#if (__FreeBSD_version < 500002 && __FreeBSD_version > 500000) || __FreeBSD_version < 420000
-#define MODULE_VERSION(a,b) struct __hack
-#define MODULE_DEPEND(a,b,c,d,e) struct __hack
-#endif
-
-/* Redefinitions to make templating easy */
-#define wait_queue_head_t atomic_t
-#define agp_memory void
-#define jiffies ticks
-
- /* Macros to make printf easier */
-#define DRM_ERROR(fmt, arg...) \
- printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \
- DRM_CURRENTPID, __func__ , ## arg)
-
-#define DRM_MEM_ERROR(area, fmt, arg...) \
- printf("error: [" DRM_NAME ":pid%d:%s:%s] *ERROR* " fmt, \
- DRM_CURRENTPID , __func__, DRM(mem_stats)[area].name , ##arg)
-
-#define DRM_INFO(fmt, arg...) printf("info: [" DRM_NAME "] " fmt , ## arg)
-
-#if DRM_DEBUG_CODE
-#define DRM_DEBUG(fmt, arg...) \
- do { \
- if (DRM(flags) & DRM_FLAG_DEBUG) \
- printf("[" DRM_NAME ":pid%d:%s] " fmt, \
- DRM_CURRENTPID, __func__ , ## arg); \
- } while (0)
-#else
-#define DRM_DEBUG(fmt, arg...) do { } while (0)
-#endif
-
-#if (__FreeBSD_version >= 500000) || ((__FreeBSD_version < 500000) && (__FreeBSD_version >= 410002))
-#define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS)
-#else
-#define DRM_SYSCTL_HANDLER_ARGS SYSCTL_HANDLER_ARGS
-#endif
-
-/* Internal functions */
-
-/* drm_drv.h */
-extern d_ioctl_t DRM(ioctl);
-extern d_open_t DRM(open);
-extern d_close_t DRM(close);
-extern d_read_t DRM(read);
-extern d_poll_t DRM(poll);
-extern d_mmap_t DRM(mmap);
-extern int DRM(open_helper)(struct cdev *kdev, int flags, int fmt,
- DRM_STRUCTPROC *p, drm_device_t *dev);
-extern drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev,
- DRM_STRUCTPROC *p);
-
-/* sysctl support (drm_sysctl.h) */
-extern int DRM(sysctl_init)(drm_device_t *dev);
-extern int DRM(sysctl_cleanup)(drm_device_t *dev);
-
-/* Memory info sysctl (drm_memory_debug.h) */
-#ifdef DEBUG_MEMORY
-extern int DRM(mem_info) DRM_SYSCTL_HANDLER_ARGS;
-#endif
diff --git a/bsd/drm_os_netbsd.h b/bsd/drm_os_netbsd.h
deleted file mode 100644
index 832f8318..00000000
--- a/bsd/drm_os_netbsd.h
+++ /dev/null
@@ -1,375 +0,0 @@
-/**
- * \file drm_os_netbsd.h
- * OS-specific #defines for NetBSD
- *
- * \author Eric Anholt <anholt@FreeBSD.org>
- * \author Erik Reid <reide@canuck.com>
- */
-
-/*
- * Copyright 2003 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <sys/param.h>
-#include <sys/queue.h>
-#include <sys/malloc.h>
-#include <sys/kernel.h>
-#include <sys/systm.h>
-#include <sys/conf.h>
-#include <sys/stat.h>
-#include <sys/proc.h>
-#include <sys/lock.h>
-#include <sys/fcntl.h>
-#include <sys/uio.h>
-#include <sys/filio.h>
-#include <sys/sysctl.h>
-#include <sys/select.h>
-#include <sys/device.h>
-#include <sys/mman.h>
-#include <uvm/uvm.h>
-#include <sys/vnode.h>
-#include <sys/poll.h>
-#include <sys/lkm.h>
-/* For TIOCSPGRP/TIOCGPGRP */
-#include <sys/ttycom.h>
-#include <sys/endian.h>
-
-#include <uvm/uvm.h>
-
-#include <machine/pmap.h>
-#include <machine/bus.h>
-#include <sys/resourcevar.h>
-#include <machine/sysarch.h>
-#include <machine/mtrr.h>
-
-#include <dev/pci/pcireg.h>
-#include <dev/pci/pcivar.h>
-
-#define __REALLY_HAVE_AGP __HAVE_AGP
-
-#define __REALLY_HAVE_MTRR 1
-#define __REALLY_HAVE_SG 0
-
-#if __REALLY_HAVE_AGP
-#include <dev/pci/agpvar.h>
-#include <sys/agpio.h>
-#endif
-
-#include <opt_drm.h>
-
-#if DRM_DEBUG
-#undef DRM_DEBUG_CODE
-#define DRM_DEBUG_CODE 2
-#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 34
-
-#define DRM_CURPROC curproc
-#define DRM_STRUCTPROC struct proc
-#define DRM_SPINTYPE struct simplelock
-#define DRM_SPININIT(l,name)
-#define DRM_SPINUNINIT(l)
-#define DRM_SPINLOCK(l)
-#define DRM_SPINUNLOCK(u)
-#define DRM_CURRENTPID curproc->p_pid
-
-/* Currently our DRMFILE (filp) is a void * which is actually the pid
- * of the current process. It should be a per-open unique pointer, but
- * code for that is not yet written */
-#define DRMFILE void *
-#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p, DRMFILE filp
-#define DRM_LOCK()
-#define DRM_UNLOCK()
-#define DRM_SUSER(p) suser(p->p_ucred, &p->p_acflag)
-#define DRM_TASKQUEUE_ARGS void *dev, int pending
-#define DRM_IRQ_ARGS void *arg
-typedef int irqreturn_t;
-#define IRQ_NONE /* FIXME */
-#define IRQ_HANDLED /* FIXME */
-#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,size) free( pt, DRM(M_DRM) )
-
-#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_MTRR_WC MTRR_TYPE_WC
-
-#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
-
-#define DRM_GET_PRIV_WITH_RETURN(_priv, _filp) \
-do { \
- if (_filp != (DRMFILE)DRM_CURRENTPID) { \
- DRM_ERROR("filp doesn't match curproc\n"); \
- return EINVAL; \
- } \
- _priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
- if (_priv == NULL) { \
- DRM_ERROR("can't find authenticator\n"); \
- return EINVAL; \
- } \
-} while (0)
-
-#define LOCK_TEST_WITH_RETURN(dev, filp) \
-do { \
- if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
- dev->lock.filp != filp) { \
- DRM_ERROR("%s called without lock held\n", \
- __FUNCTION__); \
- return EINVAL; \
- } \
-} while (0)
-
-#define DRM_UDELAY( udelay ) \
-do { \
- struct timeval tv1, tv2; \
- microtime(&tv1); \
- do { \
- microtime(&tv2); \
- } \
- while (((tv2.tv_sec-tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec) < udelay ); \
-} while (0)
-
-#define DRM_GETSAREA() \
-do { \
- drm_map_list_entry_t *listentry; \
- TAILQ_FOREACH(listentry, dev->maplist, link) { \
- drm_local_map_t *map = listentry->map; \
- if (map->type == _DRM_SHM && \
- map->flags & _DRM_CONTAINS_LOCK) { \
- dev_priv->sarea = map; \
- break; \
- } \
- } \
-} while (0)
-
-#define DRM_HZ hz
-
-#define DRM_WAIT_ON( ret, queue, timeout, condition ) \
-while (!condition) { \
- int s = spldrm(); \
- ret = tsleep( (void *)&(queue), PZERO | PCATCH, "drmwtq", (timeout) ); \
- if ( ret ) \
- return ret; \
- splx(s); \
-}
-
-#define DRM_ERR(v) v
-
-#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
- *arg1 = arg2
-#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
- arg1 = *arg2
-#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
- 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_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \
- copyout(arg2, arg1, arg3)
-#define DRM_GET_USER_UNCHECKED(val, uaddr) \
- ((val) = fuword(uaddr), 0)
-
-/* DRM_READMEMORYBARRIER() prevents reordering of reads.
- * DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
- * DRM_MEMORYBARRIER() prevents reordering of reads and writes.
- */
-#if defined(__i386__)
-#define DRM_READMEMORYBARRIER() __asm __volatile( \
- "lock; addl $0,0(%%esp)" : : : "memory");
-#define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory");
-#define DRM_MEMORYBARRIER() __asm __volatile( \
- "lock; addl $0,0(%%esp)" : : : "memory");
-#elif defined(__alpha__)
-#define DRM_READMEMORYBARRIER() alpha_mb();
-#define DRM_WRITEMEMORYBARRIER() alpha_wmb();
-#define DRM_MEMORYBARRIER() alpha_mb();
-#endif
-
-#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)
-
-#define cpu_to_le32(x) htole32(x)
-#define le32_to_cpu(x) le32toh(x)
-
-typedef u_int32_t dma_addr_t;
-typedef volatile long atomic_t;
-typedef u_int32_t u32;
-typedef u_int16_t u16;
-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) (*(p) += 1)
-#define atomic_dec(p) (*(p) -= 1)
-#define atomic_add(n, p) (*(p) += (n))
-#define atomic_sub(n, p) (*(p) -= (n))
-
-/* 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)
-{
- int s = splhigh();
- unsigned int m = 1<<b;
- unsigned int r = *p & m;
- *p |= m;
- splx(s);
- return r;
-}
-
-static __inline void
-clear_bit(int b, atomic_t *p)
-{
- atomic_clear_int(p + (b >> 5), 1 << (b & 0x1f));
-}
-
-static __inline void
-set_bit(int b, atomic_t *p)
-{
- atomic_set_int(p + (b >> 5), 1 << (b & 0x1f));
-}
-
-static __inline int
-test_bit(int b, atomic_t *p)
-{
- return p[b >> 5] & (1 << (b & 0x1f));
-}
-
-static __inline int
-find_first_zero_bit(atomic_t *p, int max)
-{
- int b;
-
- for (b = 0; b < max; b += 32) {
- if (p[b >> 5] != ~0) {
- for (;;) {
- if ((p[b >> 5] & (1 << (b & 0x1f))) == 0)
- return b;
- b++;
- }
- }
- }
- return max;
-}
-
-#define spldrm() spltty()
-#define jiffies hardclock_ticks
-
-/* Redefinitions to make templating easy */
-#define wait_queue_head_t int
-#define agp_memory void
-
- /* Macros to make printf easier */
-#define DRM_ERROR(fmt, arg...) \
-do { \
- printf("error: [" DRM_NAME ":%s] *ERROR* ", __func__ ); \
- printf( fmt,## arg ); \
-} while (0)
-
-#define DRM_MEM_ERROR(area, fmt, arg...) \
- printf("error: [" DRM_NAME ":%s:%s] *ERROR* " fmt , \
- __func__, DRM(mem_stats)[area].name ,## arg)
-#define DRM_INFO(fmt, arg...) printf("info: " "[" DRM_NAME "] " fmt ,## arg)
-
-#if DRM_DEBUG_CODE
-#define DRM_DEBUG(fmt, arg...) \
- do { \
- if (DRM(flags) & DRM_FLAG_DEBUG) \
- printf("[" DRM_NAME ":%s] " fmt , __FUNCTION__ ,## arg); \
- } while (0)
-#else
-#define DRM_DEBUG(fmt, arg...) do { } while (0)
-#endif
-
-/* Internal functions */
-
-/* drm_drv.h */
-extern dev_type_ioctl(DRM(ioctl));
-extern dev_type_open(DRM(open));
-extern dev_type_close(DRM(close));
-extern dev_type_read(DRM(read));
-extern dev_type_poll(DRM(poll));
-extern dev_type_mmap(DRM(mmap));
-extern int DRM(open_helper)(dev_t kdev, int flags, int fmt,
- DRM_STRUCTPROC *p, drm_device_t *dev);
-extern drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev,
- DRM_STRUCTPROC *p);
-
-extern int DRM(sysctl_init)(drm_device_t *dev);
-extern int DRM(sysctl_cleanup)(drm_device_t *dev);
diff --git a/bsd/drm_pci.h b/bsd/drm_pci.h
deleted file mode 100644
index 1d8b593d..00000000
--- a/bsd/drm_pci.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/**
- * \file drm_pci.h
- * \brief PCI consistent, DMA-accessible memory functions.
- *
- * \author Eric Anholt <anholt@FreeBSD.org>
- */
-
-/*
- * Copyright 2003 Eric Anholt.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include "drmP.h"
-
-/**********************************************************************/
-/** \name PCI memory */
-/*@{*/
-
-/**
- * \brief Allocate a physically contiguous DMA-accessible consistent
- * memory block.
- */
-void *
-DRM(pci_alloc)(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr,
- dma_addr_t *busaddr)
-{
- void *vaddr;
-
- vaddr = contigmalloc(size, DRM(M_DRM), M_NOWAIT, 0ul, maxaddr, align,
- 0);
- *busaddr = vtophys(vaddr);
-
- return vaddr;
-}
-
-/**
- * \brief Free a DMA-accessible consistent memory block.
- */
-void
-DRM(pci_free)(drm_device_t *dev, size_t size, void *vaddr, dma_addr_t busaddr)
-{
-#if __FreeBSD_version > 500000
- contigfree(vaddr, size, DRM(M_DRM)); /* Not available on 4.x */
-#endif
-}
-
-/*@}*/
diff --git a/bsd/drm_scatter.h b/bsd/drm_scatter.h
deleted file mode 100644
index 13213227..00000000
--- a/bsd/drm_scatter.h
+++ /dev/null
@@ -1,151 +0,0 @@
-/* drm_scatter.h -- IOCTLs to manage scatter/gather memory -*- linux-c -*-
- * Created: Mon Dec 18 23:20:54 2000 by gareth@valinux.com
- *
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- * Eric Anholt <anholt@FreeBSD.org>
- *
- */
-
-#include "drmP.h"
-
-#define DEBUG_SCATTER 0
-
-#if __REALLY_HAVE_SG
-
-void DRM(sg_cleanup)( drm_sg_mem_t *entry )
-{
- free( entry->virtual, DRM(M_DRM) );
-
- DRM(free)( entry->busaddr,
- entry->pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES );
- DRM(free)( entry,
- sizeof(*entry),
- DRM_MEM_SGLISTS );
-}
-
-int DRM(sg_alloc)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_scatter_gather_t request;
- drm_sg_mem_t *entry;
- unsigned long pages;
-
- DRM_DEBUG( "%s\n", __FUNCTION__ );
-
- if ( dev->sg )
- return EINVAL;
-
- DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data,
- sizeof(request) );
-
- entry = DRM(alloc)( sizeof(*entry), DRM_MEM_SGLISTS );
- if ( !entry )
- return ENOMEM;
-
- bzero( entry, sizeof(*entry) );
-
- pages = round_page(request.size) / PAGE_SIZE;
- DRM_DEBUG( "sg size=%ld pages=%ld\n", request.size, pages );
-
- entry->pages = pages;
-
- entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES );
- if ( !entry->busaddr ) {
- DRM(free)( entry,
- sizeof(*entry),
- DRM_MEM_SGLISTS );
- return ENOMEM;
- }
- bzero( (void *)entry->busaddr, pages * sizeof(*entry->busaddr) );
-
- entry->virtual = malloc( pages << PAGE_SHIFT, DRM(M_DRM), M_WAITOK );
- if ( !entry->virtual ) {
- DRM(free)( entry->busaddr,
- entry->pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES );
- DRM(free)( entry,
- sizeof(*entry),
- DRM_MEM_SGLISTS );
- return ENOMEM;
- }
-
- bzero( entry->virtual, pages << PAGE_SHIFT );
-
- entry->handle = (unsigned long)entry->virtual;
-
- DRM_DEBUG( "sg alloc handle = %08lx\n", entry->handle );
- DRM_DEBUG( "sg alloc virtual = %p\n", entry->virtual );
-
- request.handle = entry->handle;
-
- DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data,
- request,
- sizeof(request) );
-
- dev->sg = entry;
-
- return 0;
-
- DRM(sg_cleanup)( entry );
- return ENOMEM;
-}
-
-int DRM(sg_free)( DRM_IOCTL_ARGS )
-{
- DRM_DEVICE;
- drm_scatter_gather_t request;
- drm_sg_mem_t *entry;
-
- DRM_COPY_FROM_USER_IOCTL( request, (drm_scatter_gather_t *)data,
- sizeof(request) );
-
- entry = dev->sg;
- dev->sg = NULL;
-
- if ( !entry || entry->handle != request.handle )
- return EINVAL;
-
- DRM_DEBUG( "sg free virtual = %p\n", entry->virtual );
-
- DRM(sg_cleanup)( entry );
-
- return 0;
-}
-
-#else /* __REALLY_HAVE_SG */
-
-int DRM(sg_alloc)( DRM_IOCTL_ARGS )
-{
- return DRM_ERR(EINVAL);
-}
-int DRM(sg_free)( DRM_IOCTL_ARGS )
-{
- return DRM_ERR(EINVAL);
-}
-
-#endif
diff --git a/bsd/drm_sysctl.h b/bsd/drm_sysctl.h
deleted file mode 100644
index 0897c359..00000000
--- a/bsd/drm_sysctl.h
+++ /dev/null
@@ -1,324 +0,0 @@
-/*
- * Copyright 2003 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#ifdef __FreeBSD__
-
-#include <sys/sysctl.h>
-
-static int DRM(name_info)DRM_SYSCTL_HANDLER_ARGS;
-static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS;
-static int DRM(clients_info)DRM_SYSCTL_HANDLER_ARGS;
-#if __HAVE_DMA
-static int DRM(bufs_info)DRM_SYSCTL_HANDLER_ARGS;
-#endif
-
-struct DRM(sysctl_list) {
- const char *name;
- int (*f) DRM_SYSCTL_HANDLER_ARGS;
-} DRM(sysctl_list)[] = {
- { "name", DRM(name_info) },
-#ifdef DEBUG_MEMORY
- { "mem", DRM(mem_info) },
-#endif
- { "vm", DRM(vm_info) },
- { "clients", DRM(clients_info) },
-#if __HAVE_DMA
- { "bufs", DRM(bufs_info) },
-#endif
-};
-#define DRM_SYSCTL_ENTRIES (sizeof(DRM(sysctl_list))/sizeof(DRM(sysctl_list)[0]))
-
-struct drm_sysctl_info {
- struct sysctl_ctx_list ctx;
- char name[2];
-};
-
-int DRM(sysctl_init)(drm_device_t *dev)
-{
- struct drm_sysctl_info *info;
- struct sysctl_oid *oid;
- struct sysctl_oid *top, *drioid;
- int i;
-
- info = DRM(alloc)(sizeof *info, DRM_MEM_DRIVER);
- if ( !info )
- return 1;
- bzero(info, sizeof *info);
- dev->sysctl = info;
-
- /* Add the sysctl node for DRI if it doesn't already exist */
- drioid = SYSCTL_ADD_NODE( &info->ctx, &sysctl__hw_children, OID_AUTO, "dri", CTLFLAG_RW, NULL, "DRI Graphics");
- if (!drioid)
- return 1;
-
- /* Find the next free slot under hw.dri */
- i = 0;
- SLIST_FOREACH(oid, SYSCTL_CHILDREN(drioid), oid_link) {
- if (i <= oid->oid_arg2)
- i = oid->oid_arg2 + 1;
- }
- if (i>9)
- return 1;
-
- /* Add the hw.dri.x for our device */
- info->name[0] = '0' + i;
- info->name[1] = 0;
- top = SYSCTL_ADD_NODE( &info->ctx, SYSCTL_CHILDREN(drioid), OID_AUTO, info->name, CTLFLAG_RW, NULL, NULL);
- if (!top)
- return 1;
-
- for (i = 0; i < DRM_SYSCTL_ENTRIES; i++) {
- oid = sysctl_add_oid( &info->ctx,
- SYSCTL_CHILDREN(top),
- OID_AUTO,
- DRM(sysctl_list)[i].name,
- CTLTYPE_INT | CTLFLAG_RD,
- dev,
- 0,
- DRM(sysctl_list)[i].f,
- "A",
- NULL);
- if (!oid)
- return 1;
- }
- return 0;
-}
-
-int DRM(sysctl_cleanup)(drm_device_t *dev)
-{
- int error;
- error = sysctl_ctx_free( &dev->sysctl->ctx );
-
- DRM(free)(dev->sysctl, sizeof *dev->sysctl, DRM_MEM_DRIVER);
- dev->sysctl = NULL;
-
- return error;
-}
-
-#define DRM_SYSCTL_PRINT(fmt, arg...) \
-do { \
- snprintf(buf, sizeof(buf), fmt, ##arg); \
- retcode = SYSCTL_OUT(req, buf, strlen(buf)); \
- if (retcode) \
- goto done; \
-} while (0)
-
-static int DRM(name_info)DRM_SYSCTL_HANDLER_ARGS
-{
- drm_device_t *dev = arg1;
- char buf[128];
- int retcode;
- int hasunique = 0;
-
- DRM_SYSCTL_PRINT("%s 0x%x", dev->name, dev2udev(dev->devnode));
-
- DRM_LOCK();
- if (dev->unique) {
- snprintf(buf, sizeof(buf), " %s", dev->unique);
- hasunique = 1;
- }
- DRM_UNLOCK();
-
- if (hasunique)
- SYSCTL_OUT(req, buf, strlen(buf));
-
- SYSCTL_OUT(req, "", 1);
-
-done:
- return retcode;
-}
-
-static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS
-{
- drm_device_t *dev = arg1;
- drm_local_map_t *map, *tempmaps;
- drm_map_list_entry_t *listentry;
- const char *types[] = { "FB", "REG", "SHM", "AGP", "SG" };
- const char *type, *yesno;
- int i, mapcount;
- char buf[128];
- int retcode;
-
- /* We can't hold the lock while doing SYSCTL_OUTs, so allocate a
- * temporary copy of all the map entries and then SYSCTL_OUT that.
- */
- DRM_LOCK();
-
- mapcount = 0;
- TAILQ_FOREACH(listentry, dev->maplist, link)
- mapcount++;
-
- tempmaps = DRM(alloc)(sizeof(drm_local_map_t) * mapcount, DRM_MEM_MAPS);
- if (tempmaps == NULL) {
- DRM_UNLOCK();
- return ENOMEM;
- }
-
- i = 0;
- TAILQ_FOREACH(listentry, dev->maplist, link)
- tempmaps[i++] = *listentry->map;
-
- DRM_UNLOCK();
-
- DRM_SYSCTL_PRINT("\nslot offset size type flags "
- "address mtrr\n");
-
- for (i = 0; i < mapcount; i++) {
- map = &tempmaps[i];
-
- if (map->type < 0 || map->type > 4)
- type = "??";
- else
- type = types[map->type];
-
- if (!map->mtrr)
- yesno = "no";
- else
- yesno = "yes";
-
- DRM_SYSCTL_PRINT(
- "%4d 0x%08lx 0x%08lx %4.4s 0x%02x 0x%08lx %s\n", i,
- map->offset, map->size, type, map->flags,
- (unsigned long)map->handle, yesno);
- }
- SYSCTL_OUT(req, "", 1);
-
-done:
- DRM(free)(tempmaps, sizeof(drm_local_map_t) * mapcount, DRM_MEM_MAPS);
- return retcode;
-}
-
-#if __HAVE_DMA
-static int DRM(bufs_info) DRM_SYSCTL_HANDLER_ARGS
-{
- drm_device_t *dev = arg1;
- drm_device_dma_t *dma = dev->dma;
- drm_device_dma_t tempdma;
- int *templists;
- int i;
- char buf[128];
- int retcode;
-
- /* We can't hold the locks around DRM_SYSCTL_PRINT, so make a temporary
- * copy of the whole structure and the relevant data from buflist.
- */
- DRM_LOCK();
- if (dma == NULL) {
- DRM_UNLOCK();
- return 0;
- }
- DRM_SPINLOCK(&dev->dma_lock);
- tempdma = *dma;
- templists = DRM(alloc)(sizeof(int) * dma->buf_count, DRM_MEM_BUFS);
- for (i = 0; i < dma->buf_count; i++)
- templists[i] = dma->buflist[i]->list;
- dma = &tempdma;
- DRM_SPINUNLOCK(&dev->dma_lock);
- DRM_UNLOCK();
-
- DRM_SYSCTL_PRINT("\n o size count free segs pages kB\n");
- for (i = 0; i <= DRM_MAX_ORDER; i++) {
- if (dma->bufs[i].buf_count)
- DRM_SYSCTL_PRINT("%2d %8d %5d %5d %5d %5d %5d\n",
- i,
- dma->bufs[i].buf_size,
- dma->bufs[i].buf_count,
- atomic_read(&dma->bufs[i]
- .freelist.count),
- dma->bufs[i].seg_count,
- dma->bufs[i].seg_count
- *(1 << dma->bufs[i].page_order),
- (dma->bufs[i].seg_count
- * (1 << dma->bufs[i].page_order))
- * PAGE_SIZE / 1024);
- }
- DRM_SYSCTL_PRINT("\n");
- for (i = 0; i < dma->buf_count; i++) {
- if (i && !(i%32)) DRM_SYSCTL_PRINT("\n");
- DRM_SYSCTL_PRINT(" %d", templists[i]);
- }
- DRM_SYSCTL_PRINT("\n");
-
- SYSCTL_OUT(req, "", 1);
-done:
- DRM(free)(templists, sizeof(int) * dma->buf_count, DRM_MEM_BUFS);
- return retcode;
-}
-#endif
-
-static int DRM(clients_info)DRM_SYSCTL_HANDLER_ARGS
-{
- drm_device_t *dev = arg1;
- drm_file_t *priv, *tempprivs;
- char buf[128];
- int retcode;
- int privcount, i;
-
- DRM_LOCK();
-
- privcount = 0;
- TAILQ_FOREACH(priv, &dev->files, link)
- privcount++;
-
- tempprivs = DRM(alloc)(sizeof(drm_file_t) * privcount, DRM_MEM_FILES);
- if (tempprivs == NULL) {
- DRM_UNLOCK();
- return ENOMEM;
- }
- i = 0;
- TAILQ_FOREACH(priv, &dev->files, link)
- tempprivs[i++] = *priv;
-
- DRM_UNLOCK();
-
- DRM_SYSCTL_PRINT("\na dev pid uid magic ioctls\n");
- for (i = 0; i < privcount; i++) {
- priv = &tempprivs[i];
- DRM_SYSCTL_PRINT("%c %3d %5d %5d %10u %10lu\n",
- priv->authenticated ? 'y' : 'n',
- priv->minor,
- priv->pid,
- priv->uid,
- priv->magic,
- priv->ioctl_count);
- }
-
- SYSCTL_OUT(req, "", 1);
-done:
- DRM(free)(tempprivs, sizeof(drm_file_t) * privcount, DRM_MEM_FILES);
- return retcode;
-}
-
-#elif defined(__NetBSD__)
-/* stub it out for now, sysctl is only for debugging */
-int DRM(sysctl_init)(drm_device_t *dev)
-{
- return 0;
-}
-
-int DRM(sysctl_cleanup)(drm_device_t *dev)
-{
- return 0;
-}
-#endif
diff --git a/bsd/drm_vm.h b/bsd/drm_vm.h
deleted file mode 100644
index e0d710fa..00000000
--- a/bsd/drm_vm.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright 2003 Eric Anholt
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
-static int DRM(dma_mmap)(struct cdev *kdev, vm_offset_t offset,
- vm_paddr_t *paddr, int prot)
-#elif defined(__FreeBSD__)
-static int DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot)
-#elif defined(__NetBSD__)
-static paddr_t DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot)
-#endif
-{
- DRM_DEVICE;
- drm_device_dma_t *dma = dev->dma;
- unsigned long physical;
- unsigned long page;
-
- if (dma == NULL || dma->pagelist == NULL)
- return -1;
-
- page = offset >> PAGE_SHIFT;
- physical = dma->pagelist[page];
-
- DRM_DEBUG("0x%08lx (page %lu) => 0x%08lx\n", (long)offset, page, physical);
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
- *paddr = physical;
- return 0;
-#else
- return atop(physical);
-#endif
-}
-
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
-int DRM(mmap)(struct cdev *kdev, vm_offset_t offset, vm_paddr_t *paddr,
- int prot)
-#elif defined(__FreeBSD__)
-int DRM(mmap)(dev_t kdev, vm_offset_t offset, int prot)
-#elif defined(__NetBSD__)
-paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot)
-#endif
-{
- DRM_DEVICE;
- drm_local_map_t *map = NULL;
- drm_map_list_entry_t *listentry = NULL;
- drm_file_t *priv;
-
- DRM_GET_PRIV_WITH_RETURN(priv, (DRMFILE)(uintptr_t)DRM_CURRENTPID);
-
- if (!priv->authenticated)
- return DRM_ERR(EACCES);
-
- if (dev->dma
- && offset >= 0
- && offset < ptoa(dev->dma->page_count))
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
- return DRM(dma_mmap)(kdev, offset, paddr, prot);
-#else
- return DRM(dma_mmap)(kdev, offset, prot);
-#endif
-
- /* A sequential search of a linked list is
- fine here because: 1) there will only be
- about 5-10 entries in the list and, 2) a
- DRI client only has to do this mapping
- once, so it doesn't have to be optimized
- for performance, even if the list was a
- bit longer. */
- TAILQ_FOREACH(listentry, dev->maplist, link) {
- map = listentry->map;
-/* DRM_DEBUG("considering 0x%x..0x%x\n", map->offset, map->offset + map->size - 1);*/
- if (offset >= map->offset
- && offset < map->offset + map->size) break;
- }
-
- if (!listentry) {
- DRM_DEBUG("can't find map\n");
- return -1;
- }
- if (((map->flags&_DRM_RESTRICTED) && DRM_SUSER(DRM_CURPROC))) {
- DRM_DEBUG("restricted map\n");
- return -1;
- }
-
- switch (map->type) {
- case _DRM_FRAME_BUFFER:
- case _DRM_REGISTERS:
- case _DRM_AGP:
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
- *paddr = offset;
- return 0;
-#else
- return atop(offset);
-#endif
- case _DRM_SCATTER_GATHER:
- case _DRM_SHM:
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
- *paddr = vtophys(offset);
- return 0;
-#else
- return atop(vtophys(offset));
-#endif
- default:
- return -1; /* This should never happen. */
- }
- DRM_DEBUG("bailing out\n");
-
- return -1;
-}
-
diff --git a/bsd/i915/Makefile b/bsd/i915/Makefile
deleted file mode 100644
index 5be067ef..00000000
--- a/bsd/i915/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/..
-KMOD = i915
-NOMAN= YES
-SRCS = i915_dma.c i915_drv.c i915_irq.c i915_mem.c
-SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
-CFLAGS += ${DEBUG_FLAGS} -I. -I..
-
-.if defined(DRM_DEBUG)
-DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
-.endif
-
-.if !defined(DRM_NOLINUX)
-DRM_LINUX_OPT= "\#define DRM_LINUX 1"
-.endif
-
-opt_drm.h:
- touch opt_drm.h
- echo $(DRM_DEBUG_OPT) >> opt_drm.h
- echo $(DRM_LINUX_OPT) >> opt_drm.h
-
-.include <bsd.kmod.mk>
diff --git a/bsd/i915_drv.c b/bsd/i915_drv.c
deleted file mode 100644
index 15ef406c..00000000
--- a/bsd/i915_drv.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* i915_drv.c -- ATI Radeon driver -*- linux-c -*-
- * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
- *
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#define DRM_DEV_NAME "drmsub"
-
-#include "i915.h"
-#include "drmP.h"
-#include "drm.h"
-#include "i915_drm.h"
-#include "i915_drv.h"
-
-#include "drm_agpsupport.h"
-#include "drm_auth.h"
-#include "drm_bufs.h"
-#include "drm_context.h"
-#include "drm_dma.h"
-#include "drm_drawable.h"
-#include "drm_drv.h"
-#include "drm_fops.h"
-#include "drm_ioctl.h"
-#include "drm_irq.h"
-#include "drm_lock.h"
-#include "drm_memory.h"
-#include "drm_pci.h"
-#include "drm_vm.h"
-#include "drm_sysctl.h"
-
-#ifdef __FreeBSD__
-DRIVER_MODULE(DRIVER_NAME, agp, DRM(driver), DRM(devclass), 0, 0);
-#elif defined(__NetBSD__)
-CFDRIVER_DECL(i915, DV_TTY, NULL);
-#endif /* __FreeBSD__ */
diff --git a/bsd/mach64/.cvsignore b/bsd/mach64/.cvsignore
deleted file mode 100644
index b9a7055b..00000000
--- a/bsd/mach64/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.depend
-bus_if.h
-device_if.h
-export_syms
-opt_drm.h
-pci_if.h
-mach64.kld
-mach64.ko
diff --git a/bsd/mach64/Makefile b/bsd/mach64/Makefile
deleted file mode 100644
index 741b8eea..00000000
--- a/bsd/mach64/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/..
-KMOD = mach64
-NOMAN= YES
-SRCS = mach64_dma.c mach64_drv.c mach64_irq.c mach64_state.c
-SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
-CFLAGS += ${DEBUG_FLAGS} -I. -I..
-
-.if defined(DRM_DEBUG)
-DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
-.endif
-
-.if !defined(DRM_NOLINUX)
-DRM_LINUX_OPT= "\#define DRM_LINUX 1"
-.endif
-
-opt_drm.h:
- touch opt_drm.h
- echo $(DRM_DEBUG_OPT) >> opt_drm.h
- echo $(DRM_LINUX_OPT) >> opt_drm.h
-
-.include <bsd.kmod.mk>
diff --git a/bsd/mach64_drv.c b/bsd/mach64_drv.c
deleted file mode 100644
index 07fc84af..00000000
--- a/bsd/mach64_drv.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
- * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- */
-
-
-#include <sys/types.h>
-
-#include "mach64.h"
-#include "drmP.h"
-#include "drm.h"
-#include "mach64_drm.h"
-#include "mach64_drv.h"
-
-#include "drm_agpsupport.h"
-#include "drm_auth.h"
-#include "drm_bufs.h"
-#include "drm_context.h"
-#include "drm_dma.h"
-#include "drm_drawable.h"
-#include "drm_drv.h"
-#include "drm_fops.h"
-#include "drm_ioctl.h"
-#include "drm_irq.h"
-#include "drm_lock.h"
-#include "drm_memory.h"
-#include "drm_pci.h"
-#include "drm_sysctl.h"
-#include "drm_vm.h"
-
-DRIVER_MODULE(mach64, pci, mach64_driver, mach64_devclass, 0, 0);
diff --git a/bsd/mga/.cvsignore b/bsd/mga/.cvsignore
deleted file mode 100644
index 0da9b114..00000000
--- a/bsd/mga/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.depend
-bus_if.h
-device_if.h
-export_syms
-opt_drm.h
-pci_if.h
-mga.kld
-mga.ko
diff --git a/bsd/mga/Makefile b/bsd/mga/Makefile
deleted file mode 100644
index a280e024..00000000
--- a/bsd/mga/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/..
-KMOD= mga
-NOMAN= YES
-SRCS= mga_drv.c mga_state.c mga_warp.c mga_dma.c mga_irq.c
-SRCS+= device_if.h bus_if.h pci_if.h opt_drm.h
-CFLAGS+= ${DEBUG_FLAGS} -I. -I..
-
-.if defined(DRM_DEBUG)
-DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
-.endif
-
-.if !defined(DRM_NOLINUX)
-DRM_LINUX_OPT= "\#define DRM_LINUX 1"
-.endif
-
-opt_drm.h:
- touch opt_drm.h
- echo $(DRM_DEBUG_OPT) >> opt_drm.h
- echo $(DRM_LINUX_OPT) >> opt_drm.h
-
-.include <bsd.kmod.mk>
diff --git a/bsd/mga_drv.c b/bsd/mga_drv.c
deleted file mode 100644
index 477086e2..00000000
--- a/bsd/mga_drv.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* mga_drv.c -- Matrox G200/G400 driver -*- linux-c -*-
- * Created: Mon Dec 13 01:56:22 1999 by jhartmann@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "mga.h"
-#include "drmP.h"
-#include "drm.h"
-#include "mga_drm.h"
-#include "mga_drv.h"
-
-#include "drm_agpsupport.h"
-#include "drm_auth.h"
-#include "drm_bufs.h"
-#include "drm_context.h"
-#include "drm_dma.h"
-#include "drm_drawable.h"
-#include "drm_drv.h"
-#include "drm_fops.h"
-#include "drm_ioctl.h"
-#include "drm_irq.h"
-#include "drm_lock.h"
-#include "drm_memory.h"
-#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/r128/.cvsignore b/bsd/r128/.cvsignore
deleted file mode 100644
index 0ee047dd..00000000
--- a/bsd/r128/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.depend
-bus_if.h
-device_if.h
-export_syms
-opt_drm.h
-pci_if.h
-r128.kld
-r128.ko
diff --git a/bsd/r128/Makefile b/bsd/r128/Makefile
deleted file mode 100644
index 2d2e7e4f..00000000
--- a/bsd/r128/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/..
-KMOD = r128
-NOMAN= YES
-SRCS = r128_cce.c r128_drv.c r128_state.c r128_irq.c
-SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
-CFLAGS += ${DEBUG_FLAGS} -I. -I..
-
-.if defined(DRM_DEBUG)
-DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
-.endif
-
-.if !defined(DRM_NOLINUX)
-DRM_LINUX_OPT= "\#define DRM_LINUX 1"
-.endif
-
-opt_drm.h:
- touch opt_drm.h
- echo $(DRM_DEBUG_OPT) >> opt_drm.h
- echo $(DRM_LINUX_OPT) >> opt_drm.h
-
-.include <bsd.kmod.mk>
diff --git a/bsd/r128_drv.c b/bsd/r128_drv.c
deleted file mode 100644
index a9af3694..00000000
--- a/bsd/r128_drv.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* r128_drv.c -- ATI Rage 128 driver -*- linux-c -*-
- * Created: Mon Dec 13 09:47:27 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "r128.h"
-#include "drmP.h"
-#include "drm.h"
-#include "r128_drm.h"
-#include "r128_drv.h"
-#if __REALLY_HAVE_SG
-#include "ati_pcigart.h"
-#endif
-
-#include "drm_agpsupport.h"
-#include "drm_auth.h"
-#include "drm_bufs.h"
-#include "drm_context.h"
-#include "drm_dma.h"
-#include "drm_drawable.h"
-#include "drm_drv.h"
-#include "drm_fops.h"
-#include "drm_ioctl.h"
-#include "drm_irq.h"
-#include "drm_lock.h"
-#include "drm_memory.h"
-#include "drm_pci.h"
-#include "drm_sysctl.h"
-#include "drm_vm.h"
-#include "drm_scatter.h"
-
-#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/radeon/.cvsignore b/bsd/radeon/.cvsignore
deleted file mode 100644
index 83df81da..00000000
--- a/bsd/radeon/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.depend
-bus_if.h
-device_if.h
-export_syms
-opt_drm.h
-pci_if.h
-radeon.kld
-radeon.ko
diff --git a/bsd/radeon/Makefile b/bsd/radeon/Makefile
deleted file mode 100644
index 691e9138..00000000
--- a/bsd/radeon/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/..
-KMOD = radeon
-NOMAN= YES
-SRCS = radeon_cp.c radeon_drv.c radeon_state.c radeon_irq.c radeon_mem.c
-SRCS += device_if.h bus_if.h pci_if.h opt_drm.h
-CFLAGS += ${DEBUG_FLAGS} -I. -I..
-
-.if defined(DRM_DEBUG)
-DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
-.endif
-
-.if !defined(DRM_NOLINUX)
-DRM_LINUX_OPT= "\#define DRM_LINUX 1"
-.endif
-
-opt_drm.h:
- touch opt_drm.h
- echo $(DRM_DEBUG_OPT) >> opt_drm.h
- echo $(DRM_LINUX_OPT) >> opt_drm.h
-
-.include <bsd.kmod.mk>
diff --git a/bsd/radeon_drv.c b/bsd/radeon_drv.c
deleted file mode 100644
index df941f9e..00000000
--- a/bsd/radeon_drv.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* radeon_drv.c -- ATI Radeon driver -*- linux-c -*-
- * Created: Wed Feb 14 17:10:04 2001 by gareth@valinux.com
- *
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "radeon.h"
-#include "drmP.h"
-#include "drm.h"
-#include "radeon_drm.h"
-#include "radeon_drv.h"
-#if __REALLY_HAVE_SG
-#include "ati_pcigart.h"
-#endif
-
-#include "drm_agpsupport.h"
-#include "drm_auth.h"
-#include "drm_bufs.h"
-#include "drm_context.h"
-#include "drm_dma.h"
-#include "drm_drawable.h"
-#include "drm_drv.h"
-#include "drm_fops.h"
-#include "drm_ioctl.h"
-#include "drm_irq.h"
-#include "drm_lock.h"
-#include "drm_memory.h"
-#include "drm_pci.h"
-#include "drm_vm.h"
-#include "drm_sysctl.h"
-#include "drm_scatter.h"
-
-#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/sis/.cvsignore b/bsd/sis/.cvsignore
deleted file mode 100644
index 7495508e..00000000
--- a/bsd/sis/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.depend
-bus_if.h
-device_if.h
-export_syms
-opt_drm.h
-pci_if.h
-sis.kld
-sis.ko
diff --git a/bsd/sis/Makefile b/bsd/sis/Makefile
deleted file mode 100644
index e6439499..00000000
--- a/bsd/sis/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/..
-KMOD= sis
-NOMAN= YES
-SRCS= sis_drv.c sis_ds.c sis_mm.c
-SRCS+= device_if.h bus_if.h pci_if.h opt_drm.h
-CFLAGS+= ${DEBUG_FLAGS} -I. -I..
-
-.if defined(DRM_DEBUG)
-DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
-.endif
-
-.if !defined(DRM_NOLINUX)
-DRM_LINUX_OPT= "\#define DRM_LINUX 1"
-.endif
-
-opt_drm.h:
- touch opt_drm.h
- echo $(DRM_DEBUG_OPT) >> opt_drm.h
- echo $(DRM_LINUX_OPT) >> opt_drm.h
-
-.include <bsd.kmod.mk>
diff --git a/bsd/sis_drv.c b/bsd/sis_drv.c
deleted file mode 100644
index 2d40018e..00000000
--- a/bsd/sis_drv.c
+++ /dev/null
@@ -1,53 +0,0 @@
-/* sis.c -- sis driver -*- linux-c -*-
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include "sis.h"
-#include "drmP.h"
-#include "sis_drm.h"
-#include "sis_drv.h"
-
-#include "drm_auth.h"
-#include "drm_agpsupport.h"
-#include "drm_bufs.h"
-#include "drm_context.h"
-#include "drm_dma.h"
-#include "drm_drawable.h"
-#include "drm_drv.h"
-#include "drm_fops.h"
-#include "drm_ioctl.h"
-#include "drm_lock.h"
-#include "drm_memory.h"
-#include "drm_vm.h"
-#include "drm_sysctl.h"
-
-#ifdef __FreeBSD__
-/* Avoid clash with sis ethernet */
-DRIVER_MODULE(sisdrm, pci, sisdrv_driver, sisdrv_devclass, 0, 0);
-#elif defined(__NetBSD__)
-CFDRIVER_DECL(sis, DV_TTY, NULL);
-#endif /* __FreeBSD__ */
-
diff --git a/bsd/tdfx/.cvsignore b/bsd/tdfx/.cvsignore
deleted file mode 100644
index bf7cb769..00000000
--- a/bsd/tdfx/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
-.depend
-bus_if.h
-device_if.h
-export_syms
-opt_drm.h
-pci_if.h
-tdfx.kld
-tdfx.ko
diff --git a/bsd/tdfx/Makefile b/bsd/tdfx/Makefile
deleted file mode 100644
index 12e7d745..00000000
--- a/bsd/tdfx/Makefile
+++ /dev/null
@@ -1,23 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${.CURDIR}/..
-KMOD= tdfx
-NOMAN= YES
-SRCS= tdfx_drv.c
-SRCS+= device_if.h bus_if.h pci_if.h opt_drm.h
-CFLAGS+= ${DEBUG_FLAGS} -I. -I..
-
-.if defined(DRM_DEBUG)
-DRM_DEBUG_OPT= "\#define DRM_DEBUG 1"
-.endif
-
-.if !defined(DRM_NOLINUX)
-DRM_LINUX_OPT= "\#define DRM_LINUX 1"
-.endif
-
-opt_drm.h:
- touch opt_drm.h
- echo $(DRM_DEBUG_OPT) >> opt_drm.h
- echo $(DRM_LINUX_OPT) >> opt_drm.h
-
-.include <bsd.kmod.mk>
diff --git a/bsd/tdfx_drv.c b/bsd/tdfx_drv.c
deleted file mode 100644
index bc038cc0..00000000
--- a/bsd/tdfx_drv.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* tdfx_drv.c -- tdfx driver -*- linux-c -*-
- * Created: Thu Oct 7 10:38:32 1999 by faith@precisioninsight.com
- *
- * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
- * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice (including the next
- * paragraph) shall be included in all copies or substantial portions of the
- * Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- * Rickard E. (Rik) Faith <faith@valinux.com>
- * Daryll Strauss <daryll@valinux.com>
- * Gareth Hughes <gareth@valinux.com>
- *
- */
-
-#include "tdfx.h"
-#include "drmP.h"
-
-#include "drm_auth.h"
-#include "drm_bufs.h"
-#include "drm_context.h"
-#include "drm_dma.h"
-#include "drm_drawable.h"
-#include "drm_drv.h"
-#include "drm_fops.h"
-#include "drm_ioctl.h"
-#include "drm_lock.h"
-#include "drm_memory.h"
-#include "drm_vm.h"
-#include "drm_sysctl.h"
-
-#ifdef __FreeBSD__
-DRIVER_MODULE(tdfx, pci, tdfx_driver, tdfx_devclass, 0, 0);
-#elif defined(__NetBSD__)
-CFDRIVER_DECL(tdfx, DV_TTY, NULL);
-#endif /* __FreeBSD__ */
-
-void DRM(driver_register_fns)(drm_device_t *dev)
-{
-}