summaryrefslogtreecommitdiff
path: root/bsd-core
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2004-11-06 01:41:47 +0000
committerEric Anholt <anholt@freebsd.org>2004-11-06 01:41:47 +0000
commitc9202c89653b8dac2ac322c3d3a7389945e1c94c (patch)
treeda57c01384977ea6a2962cfaac9c7c426da2c0f8 /bsd-core
parent39a23640b2de9e59e99d48e6de8c9edae0231856 (diff)
Commit WIP of BSD conversion to core model. Compiles for r128, radeon, but
doesn't run yet. Moves the ioctl definitions for these two drivers back to the shared code -- they aren't OS-specific.
Diffstat (limited to 'bsd-core')
-rw-r--r--bsd-core/Makefile4
-rw-r--r--bsd-core/ati_pcigart.c16
-rw-r--r--bsd-core/drmP.h424
-rw-r--r--bsd-core/drm_agpsupport.c63
-rw-r--r--bsd-core/drm_auth.c32
-rw-r--r--bsd-core/drm_bufs.c193
-rw-r--r--bsd-core/drm_context.c64
-rw-r--r--bsd-core/drm_dma.c67
-rw-r--r--bsd-core/drm_drawable.c4
-rw-r--r--bsd-core/drm_drv.c683
-rw-r--r--bsd-core/drm_fops.c21
-rw-r--r--bsd-core/drm_ioctl.c32
-rw-r--r--bsd-core/drm_irq.c55
-rw-r--r--bsd-core/drm_lock.c6
-rw-r--r--bsd-core/drm_memory.c63
-rw-r--r--bsd-core/drm_os_freebsd.h65
-rw-r--r--bsd-core/drm_os_netbsd.h47
-rw-r--r--bsd-core/drm_pci.c8
-rw-r--r--bsd-core/drm_scatter.c53
-rw-r--r--bsd-core/drm_sysctl.c71
-rw-r--r--bsd-core/drm_vm.c19
-rw-r--r--bsd-core/r128_drv.c98
-rw-r--r--bsd-core/radeon_drv.c101
23 files changed, 1005 insertions, 1184 deletions
diff --git a/bsd-core/Makefile b/bsd-core/Makefile
index 03b6d4ff..81b12477 100644
--- a/bsd-core/Makefile
+++ b/bsd-core/Makefile
@@ -1,4 +1,4 @@
-SHARED= ../shared
+SHARED= ../shared-core
SHAREDFILES= drm.h \
drm_sarea.h \
i915.h \
@@ -54,7 +54,7 @@ SHAREDFILES= drm.h \
via_3d_reg.h \
via_dma.c
-SUBDIR = i915 mach64 mga r128 radeon sis tdfx
+SUBDIR = drm i915 mach64 mga r128 radeon sis tdfx
CLEANFILES+= ${SHAREDFILES}
diff --git a/bsd-core/ati_pcigart.c b/bsd-core/ati_pcigart.c
index 9aa2192f..4d8a03f5 100644
--- a/bsd-core/ati_pcigart.c
+++ b/bsd-core/ati_pcigart.c
@@ -43,9 +43,8 @@
# 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)
+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;
@@ -59,7 +58,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
}
address = (long)contigmalloc((1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
- DRM(M_DRM), M_NOWAIT, 0ul, 0xfffffffful, PAGE_SIZE, 0);
+ M_DRM, M_NOWAIT, 0ul, 0xfffffffful, PAGE_SIZE, 0);
if ( !address ) {
DRM_ERROR( "cannot allocate PCI GART page!\n" );
goto done;
@@ -95,9 +94,8 @@ done:
return ret;
}
-int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
- unsigned long addr,
- dma_addr_t bus_addr)
+int drm_ati_pcigart_cleanup(drm_device_t *dev, unsigned long addr,
+ dma_addr_t bus_addr)
{
drm_sg_mem_t *entry = dev->sg;
@@ -108,7 +106,9 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
}
#if __FreeBSD_version > 500000
- contigfree( (void *)addr, (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM)); /* Not available on 4.x */
+ /* Not available on 4.x */
+ contigfree((void *)addr, (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
+ M_DRM);
#endif
return 1;
}
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index c67592f6..815fd5dd 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -35,24 +35,6 @@
#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. */
@@ -193,7 +175,7 @@ struct drm_file {
int refs;
drm_magic_t magic;
unsigned long ioctl_count;
- struct drm_device *devXX;
+ void *driver_priv;
#ifdef DRIVER_FILE_FIELDS
DRIVER_FILE_FIELDS;
#endif
@@ -231,7 +213,6 @@ typedef struct drm_device_dma {
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 */
@@ -253,7 +234,6 @@ typedef struct drm_agp_head {
int cant_use_aperture;
unsigned long page_mask;
} drm_agp_head_t;
-#endif
typedef struct drm_sg_mem {
unsigned long handle;
@@ -292,34 +272,63 @@ typedef struct drm_vbl_sig {
/**
* 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 */
+
+ /* Beginning of driver-config section */
+ 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);
+ void (*irq_preinstall)(drm_device_t *dev);
+ void (*irq_postinstall)(drm_device_t *dev);
+ void (*irq_uninstall)(drm_device_t *dev);
+ void (*irq_handler)(DRM_IRQ_ARGS);
+ int (*vblank_wait)(drm_device_t *dev, unsigned int *sequence);
+
+ drm_ioctl_desc_t *driver_ioctls;
+ int max_driver_ioctl;
+
+ int dev_priv_size;
+
+ int driver_major;
+ int driver_minor;
+ int driver_patchlevel;
+ const char *driver_name; /* Simple driver name */
+ const char *driver_desc; /* Longer driver name */
+ const char *driver_date; /* Date of last major changes. */
+
+ unsigned use_agp :1;
+ unsigned require_agp :1;
+ unsigned use_sg :1;
+ unsigned use_dma :1;
+ unsigned use_pci_dma :1;
+ unsigned use_dma_queue :1;
+ unsigned use_irq :1;
+ unsigned use_vbl_irq :1;
+ unsigned use_mtrr :1;
+ unsigned use_ctxbitmap :1;
+ /* End of driver-config section */
+
char *unique; /* Unique identifier: e.g., busid */
int unique_len; /* Length of unique field */
#ifdef __FreeBSD__
@@ -332,12 +341,8 @@ struct drm_device {
/* 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 */
@@ -386,10 +391,8 @@ struct drm_device {
#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 */
@@ -400,209 +403,182 @@ struct drm_device {
/* 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;
-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 );
+/* Device setup support (drm_drv.c) */
+#ifdef __FreeBSD__
+int drm_probe(device_t nbdev, drm_pci_id_list_t *idlist);
+int drm_attach(device_t nbdev, drm_pci_id_list_t *idlist);
+int drm_detach(device_t nbdev);
+#elif defined(__NetBSD__)
+int drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist);
+int drm_attach(struct pci_attach_args *pa, dev_t kdev, drm_pci_id_list_t *idlist);
#endif
- /* Locking IOCTL support (drm_lock.h) */
-extern int DRM(lock_take)(__volatile__ unsigned int *lock,
+/* Memory management support (drm_memory.c) */
+void drm_mem_init(void);
+void drm_mem_uninit(void);
+void *drm_alloc(size_t size, int area);
+void *drm_calloc(size_t nmemb, size_t size, int area);
+void *drm_realloc(void *oldpt, size_t oldsize, size_t size,
+ int area);
+void drm_free(void *pt, size_t size, int area);
+void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map);
+void drm_ioremapfree(drm_local_map_t *map);
+int drm_mtrr_add(unsigned long offset, size_t size, int flags);
+int drm_mtrr_del(unsigned long offset, size_t size, int flags);
+
+agp_memory *drm_alloc_agp(int pages, u32 type);
+int drm_free_agp(agp_memory *handle, int pages);
+int drm_bind_agp(agp_memory *handle, unsigned int start);
+int drm_unbind_agp(agp_memory *handle);
+
+int drm_context_switch(drm_device_t *dev, int old, int new);
+int drm_context_switch_complete(drm_device_t *dev, int new);
+
+int drm_ctxbitmap_init(drm_device_t *dev);
+void drm_ctxbitmap_cleanup(drm_device_t *dev);
+void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle);
+int drm_ctxbitmap_next(drm_device_t *dev);
+
+/* Locking IOCTL support (drm_lock.c) */
+int drm_lock_take(__volatile__ unsigned int *lock,
unsigned int context);
-extern int DRM(lock_transfer)(drm_device_t *dev,
+int drm_lock_transfer(drm_device_t *dev,
__volatile__ unsigned int *lock,
unsigned int context);
-extern int DRM(lock_free)(drm_device_t *dev,
+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);
+/* Buffer management support (drm_bufs.c) */
+int drm_order(unsigned long size);
+
+/* DMA support (drm_dma.c) */
+int drm_dma_setup(drm_device_t *dev);
+void drm_dma_takedown(drm_device_t *dev);
+void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf);
+void drm_reclaim_buffers(drm_device_t *dev, DRMFILE filp);
+
+/* IRQ support (drm_irq.c) */
+int drm_irq_install(drm_device_t *dev);
+int drm_irq_uninstall(drm_device_t *dev);
+irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
+void drm_driver_irq_preinstall(drm_device_t *dev);
+void drm_driver_irq_postinstall(drm_device_t *dev);
+void drm_driver_irq_uninstall(drm_device_t *dev);
+int drm_vblank_wait(drm_device_t *dev, unsigned int *vbl_seq);
+void drm_vbl_send_signals(drm_device_t *dev);
+
+/* AGP/GART support (drm_agpsupport.c) */
+int drm_device_is_agp(drm_device_t *dev);
+drm_agp_head_t *drm_agp_init(void);
+void drm_agp_uninit(void);
+void drm_agp_do_release(void);
+agp_memory *drm_agp_allocate_memory(size_t pages, u32 type);
+int drm_agp_free_memory(agp_memory *handle);
+int drm_agp_bind_memory(agp_memory *handle, off_t start);
+int drm_agp_unbind_memory(agp_memory *handle);
+
+/* Scatter Gather Support (drm_scatter.c) */
+void drm_sg_cleanup(drm_sg_mem_t *entry);
+
+/* ATI PCIGART support (ati_pcigart.c) */
+int drm_ati_pcigart_init(drm_device_t *dev, unsigned long *addr,
+ dma_addr_t *bus_addr);
+int drm_ati_pcigart_cleanup(drm_device_t *dev, unsigned long addr,
+ dma_addr_t bus_addr);
+
+/* Locking IOCTL support (drm_drv.c) */
+int drm_lock(DRM_IOCTL_ARGS);
+int drm_unlock(DRM_IOCTL_ARGS);
+int drm_version(DRM_IOCTL_ARGS);
+int drm_setversion(DRM_IOCTL_ARGS);
+
+/* Misc. IOCTL support (drm_ioctl.c) */
+int drm_irq_by_busid(DRM_IOCTL_ARGS);
+int drm_getunique(DRM_IOCTL_ARGS);
+int drm_setunique(DRM_IOCTL_ARGS);
+int drm_getmap(DRM_IOCTL_ARGS);
+int drm_getclient(DRM_IOCTL_ARGS);
+int drm_getstats(DRM_IOCTL_ARGS);
+int drm_noop(DRM_IOCTL_ARGS);
+
+/* Context IOCTL support (drm_context.c) */
+int drm_resctx(DRM_IOCTL_ARGS);
+int drm_addctx(DRM_IOCTL_ARGS);
+int drm_modctx(DRM_IOCTL_ARGS);
+int drm_getctx(DRM_IOCTL_ARGS);
+int drm_switchctx(DRM_IOCTL_ARGS);
+int drm_newctx(DRM_IOCTL_ARGS);
+int drm_rmctx(DRM_IOCTL_ARGS);
+int drm_setsareactx(DRM_IOCTL_ARGS);
+int drm_getsareactx(DRM_IOCTL_ARGS);
+
+/* Drawable IOCTL support (drm_drawable.c) */
+int drm_adddraw(DRM_IOCTL_ARGS);
+int drm_rmdraw(DRM_IOCTL_ARGS);
+
+/* Authentication IOCTL support (drm_auth.c) */
+int drm_getmagic(DRM_IOCTL_ARGS);
+int drm_authmagic(DRM_IOCTL_ARGS);
+
+/* Buffer management support (drm_bufs.c) */
+int drm_addmap(DRM_IOCTL_ARGS);
+int drm_rmmap(DRM_IOCTL_ARGS);
+int drm_addbufs(DRM_IOCTL_ARGS);
+int drm_infobufs(DRM_IOCTL_ARGS);
+int drm_markbufs(DRM_IOCTL_ARGS);
+int drm_freebufs(DRM_IOCTL_ARGS);
+int drm_mapbufs(DRM_IOCTL_ARGS);
+
+/* IRQ support (drm_irq.c) */
+int drm_control(DRM_IOCTL_ARGS);
+int drm_wait_vblank(DRM_IOCTL_ARGS);
+
+/* AGP/GART support (drm_agpsupport.c) */
+int drm_agp_acquire(DRM_IOCTL_ARGS);
+int drm_agp_release(DRM_IOCTL_ARGS);
+int drm_agp_enable(DRM_IOCTL_ARGS);
+int drm_agp_info(DRM_IOCTL_ARGS);
+int drm_agp_alloc(DRM_IOCTL_ARGS);
+int drm_agp_free(DRM_IOCTL_ARGS);
+int drm_agp_unbind(DRM_IOCTL_ARGS);
+int drm_agp_bind(DRM_IOCTL_ARGS);
+
+/* Scatter Gather Support (drm_scatter.c) */
+int drm_sg_alloc(DRM_IOCTL_ARGS);
+int drm_sg_free(DRM_IOCTL_ARGS);
+
+/* consistent PCI memory functions (drm_pci.c) */
+void *drm_pci_alloc(drm_device_t *dev, size_t size, size_t align,
+ dma_addr_t maxaddr, dma_addr_t *busaddr);
+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 );
+ 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);
+ 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 );
+ drm_ioremapfree(map);
}
static __inline__ struct drm_local_map *drm_core_findmap(struct drm_device *dev, unsigned long offset)
diff --git a/bsd-core/drm_agpsupport.c b/bsd-core/drm_agpsupport.c
index 7e290b87..899638d7 100644
--- a/bsd-core/drm_agpsupport.c
+++ b/bsd-core/drm_agpsupport.c
@@ -32,7 +32,14 @@
#include "drmP.h"
-int DRM(agp_info)(DRM_IOCTL_ARGS)
+int
+drm_device_is_agp(drm_device_t *dev)
+{
+ /* XXX: FILL ME IN HERE */
+ return 1;
+}
+
+int drm_agp_info(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
struct agp_info *kern;
@@ -57,7 +64,7 @@ int DRM(agp_info)(DRM_IOCTL_ARGS)
return 0;
}
-int DRM(agp_acquire)(DRM_IOCTL_ARGS)
+int drm_agp_acquire(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
int retcode;
@@ -71,7 +78,7 @@ int DRM(agp_acquire)(DRM_IOCTL_ARGS)
return 0;
}
-int DRM(agp_release)(DRM_IOCTL_ARGS)
+int drm_agp_release(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
@@ -83,7 +90,7 @@ int DRM(agp_release)(DRM_IOCTL_ARGS)
}
-void DRM(agp_do_release)(void)
+void drm_agp_do_release(void)
{
device_t agpdev;
@@ -92,7 +99,7 @@ void DRM(agp_do_release)(void)
agp_release(agpdev);
}
-int DRM(agp_enable)(DRM_IOCTL_ARGS)
+int drm_agp_enable(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_agp_mode_t mode;
@@ -109,7 +116,7 @@ int DRM(agp_enable)(DRM_IOCTL_ARGS)
return 0;
}
-int DRM(agp_alloc)(DRM_IOCTL_ARGS)
+int drm_agp_alloc(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_agp_buffer_t request;
@@ -124,7 +131,7 @@ int DRM(agp_alloc)(DRM_IOCTL_ARGS)
request = *(drm_agp_buffer_t *) data;
- if (!(entry = DRM(alloc)(sizeof(*entry), DRM_MEM_AGPLISTS)))
+ if (!(entry = drm_alloc(sizeof(*entry), DRM_MEM_AGPLISTS)))
return ENOMEM;
bzero(entry, sizeof(*entry));
@@ -132,8 +139,8 @@ int DRM(agp_alloc)(DRM_IOCTL_ARGS)
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);
+ if (!(handle = drm_alloc_agp(pages, type))) {
+ drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS);
return ENOMEM;
}
@@ -156,7 +163,7 @@ int DRM(agp_alloc)(DRM_IOCTL_ARGS)
return 0;
}
-static drm_agp_mem_t * DRM(agp_lookup_entry)(drm_device_t *dev, void *handle)
+static drm_agp_mem_t * drm_agp_lookup_entry(drm_device_t *dev, void *handle)
{
drm_agp_mem_t *entry;
@@ -166,7 +173,7 @@ static drm_agp_mem_t * DRM(agp_lookup_entry)(drm_device_t *dev, void *handle)
return NULL;
}
-int DRM(agp_unbind)(DRM_IOCTL_ARGS)
+int drm_agp_unbind(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_agp_binding_t request;
@@ -176,10 +183,10 @@ int DRM(agp_unbind)(DRM_IOCTL_ARGS)
if (!dev->agp || !dev->agp->acquired)
return EINVAL;
request = *(drm_agp_binding_t *) data;
- if (!(entry = DRM(agp_lookup_entry)(dev, (void *) request.handle)))
+ if (!(entry = drm_agp_lookup_entry(dev, (void *)request.handle)))
return EINVAL;
if (!entry->bound) return EINVAL;
- retcode=DRM(unbind_agp)(entry->handle);
+ retcode = drm_unbind_agp(entry->handle);
if (!retcode)
{
entry->bound=0;
@@ -189,7 +196,7 @@ int DRM(agp_unbind)(DRM_IOCTL_ARGS)
return retcode;
}
-int DRM(agp_bind)(DRM_IOCTL_ARGS)
+int drm_agp_bind(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_agp_binding_t request;
@@ -201,17 +208,17 @@ int DRM(agp_bind)(DRM_IOCTL_ARGS)
if (!dev->agp || !dev->agp->acquired)
return EINVAL;
request = *(drm_agp_binding_t *) data;
- if (!(entry = DRM(agp_lookup_entry)(dev, (void *) request.handle)))
+ 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)))
+ 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)
+int drm_agp_free(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_agp_buffer_t request;
@@ -220,10 +227,10 @@ int DRM(agp_free)(DRM_IOCTL_ARGS)
if (!dev->agp || !dev->agp->acquired)
return EINVAL;
request = *(drm_agp_buffer_t *) data;
- if (!(entry = DRM(agp_lookup_entry)(dev, (void*) request.handle)))
+ if (!(entry = drm_agp_lookup_entry(dev, (void*)request.handle)))
return EINVAL;
if (entry->bound)
- DRM(unbind_agp)(entry->handle);
+ drm_unbind_agp(entry->handle);
if (entry->prev)
entry->prev->next = entry->next;
@@ -231,12 +238,12 @@ int DRM(agp_free)(DRM_IOCTL_ARGS)
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);
+ 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)
+drm_agp_head_t *drm_agp_init(void)
{
device_t agpdev;
drm_agp_head_t *head = NULL;
@@ -249,7 +256,7 @@ drm_agp_head_t *DRM(agp_init)(void)
DRM_DEBUG("agp_available = %d\n", agp_available);
if (agp_available) {
- if (!(head = DRM(alloc)(sizeof(*head), DRM_MEM_AGPLISTS)))
+ if (!(head = drm_alloc(sizeof(*head), DRM_MEM_AGPLISTS)))
return NULL;
bzero((void *)head, sizeof(*head));
head->agpdev = agpdev;
@@ -262,13 +269,13 @@ drm_agp_head_t *DRM(agp_init)(void)
return head;
}
-void DRM(agp_uninit)(void)
+void drm_agp_uninit(void)
{
/* FIXME: What goes here */
}
-agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type)
+agp_memory *drm_agp_allocate_memory(size_t pages, u32 type)
{
device_t agpdev;
@@ -279,7 +286,7 @@ agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type)
return agp_alloc_memory(agpdev, type, pages << AGP_PAGE_SHIFT);
}
-int DRM(agp_free_memory)(agp_memory *handle)
+int drm_agp_free_memory(agp_memory *handle)
{
device_t agpdev;
@@ -291,7 +298,7 @@ int DRM(agp_free_memory)(agp_memory *handle)
return 1;
}
-int DRM(agp_bind_memory)(agp_memory *handle, off_t start)
+int drm_agp_bind_memory(agp_memory *handle, off_t start)
{
device_t agpdev;
@@ -302,7 +309,7 @@ int DRM(agp_bind_memory)(agp_memory *handle, off_t start)
return agp_bind_memory(agpdev, handle, start * PAGE_SIZE);
}
-int DRM(agp_unbind_memory)(agp_memory *handle)
+int drm_agp_unbind_memory(agp_memory *handle)
{
device_t agpdev;
diff --git a/bsd-core/drm_auth.c b/bsd-core/drm_auth.c
index 537718c1..c04c6546 100644
--- a/bsd-core/drm_auth.c
+++ b/bsd-core/drm_auth.c
@@ -32,16 +32,18 @@
#include "drmP.h"
-static int DRM(hash_magic)(drm_magic_t magic)
+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)
+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);
+ int hash;
+
+ hash = drm_hash_magic(magic);
DRM_LOCK();
for (pt = dev->magiclist[hash].head; pt; pt = pt->next) {
@@ -54,15 +56,15 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic)
return retval;
}
-static int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic)
+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);
+ 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;
@@ -82,14 +84,14 @@ static int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic
return 0;
}
-static int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
+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);
+ hash = drm_hash_magic(magic);
DRM_LOCK();
for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) {
@@ -109,11 +111,11 @@ static int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic)
}
DRM_UNLOCK();
- DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC);
+ drm_free(pt, sizeof(*pt), DRM_MEM_MAGIC);
return DRM_ERR(EINVAL);
}
-int DRM(getmagic)(DRM_IOCTL_ARGS)
+int drm_getmagic(DRM_IOCTL_ARGS)
{
static drm_magic_t sequence = 0;
drm_auth_t auth;
@@ -133,9 +135,9 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
if (!atomic_cmpset_int(&sequence, old, auth.magic))
continue;
- } while (DRM(find_file)(dev, auth.magic));
+ } while (drm_find_file(dev, auth.magic));
priv->magic = auth.magic;
- DRM(add_magic)(dev, priv, auth.magic);
+ drm_add_magic(dev, priv, auth.magic);
}
DRM_DEBUG("%u\n", auth.magic);
@@ -145,7 +147,7 @@ int DRM(getmagic)(DRM_IOCTL_ARGS)
return 0;
}
-int DRM(authmagic)(DRM_IOCTL_ARGS)
+int drm_authmagic(DRM_IOCTL_ARGS)
{
drm_auth_t auth;
drm_file_t *file;
@@ -155,9 +157,9 @@ int DRM(authmagic)(DRM_IOCTL_ARGS)
DRM_DEBUG("%u\n", auth.magic);
- if ((file = DRM(find_file)(dev, auth.magic))) {
+ if ((file = drm_find_file(dev, auth.magic))) {
file->authenticated = 1;
- DRM(remove_magic)(dev, auth.magic);
+ drm_remove_magic(dev, auth.magic);
return 0;
}
return DRM_ERR(EINVAL);
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index d27254c2..0148eaa0 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -32,18 +32,10 @@
#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 drm_order(unsigned long size)
{
int order;
unsigned long tmp;
@@ -56,7 +48,7 @@ int DRM(order)( unsigned long size )
return order;
}
-int DRM(addmap)( DRM_IOCTL_ARGS )
+int drm_addmap(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_map_t request;
@@ -68,7 +60,7 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
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 );
+ map = (drm_local_map_t *) drm_alloc(sizeof(*map), DRM_MEM_MAPS);
if ( !map )
return DRM_ERR(ENOMEM);
@@ -84,17 +76,17 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
* when processes fork.
*/
if ( (map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM ) {
- DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
+ 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 );
+ 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);
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return DRM_ERR(EINVAL);
}
@@ -105,17 +97,15 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
break;
/* FALLTHROUGH */
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
- if (DRM(mtrr_add)(map->offset, map->size, DRM_MTRR_WC) == 0)
+ 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);
+ map->handle = (void *)drm_alloc(map->size, DRM_MEM_SAREA);
DRM_DEBUG( "%lu %d %p\n",
- map->size, DRM(order)( map->size ), map->handle );
+ map->size, drm_order(map->size), map->handle );
if ( !map->handle ) {
- DRM(free)( map, sizeof(*map), DRM_MEM_MAPS );
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return DRM_ERR(ENOMEM);
}
map->offset = (unsigned long)map->handle;
@@ -124,37 +114,34 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
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);
+ 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);
+ 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 );
+ drm_free( map, sizeof(*map), DRM_MEM_MAPS );
return DRM_ERR(EINVAL);
}
- list = DRM(calloc)(1, sizeof(*list), DRM_MEM_MAPS);
+ list = drm_calloc(1, sizeof(*list), DRM_MEM_MAPS);
if (list == NULL) {
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
return DRM_ERR(EINVAL);
}
list->map = map;
@@ -184,7 +171,7 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
* isn't in use.
*/
-int DRM(rmmap)( DRM_IOCTL_ARGS )
+int drm_rmmap(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_map_list_entry_t *list;
@@ -209,65 +196,59 @@ int DRM(rmmap)( DRM_IOCTL_ARGS )
TAILQ_REMOVE(dev->maplist, list, link);
DRM_UNLOCK();
- DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
+ 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,
+ retcode = drm_mtrr_del(map->offset, map->size,
DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d\n", retcode);
}
-#endif
- DRM(ioremapfree)(map);
+ drm_ioremapfree(map);
break;
case _DRM_SHM:
- DRM(free)(map->handle, map->size, DRM_MEM_SAREA);
+ 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);
+ 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)
+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,
+ drm_pci_free(dev, entry->buf_size,
(void *)entry->seglist[i],
entry->seglist_bus[i]);
}
- DRM(free)(entry->seglist,
+ drm_free(entry->seglist,
entry->seg_count *
sizeof(*entry->seglist),
DRM_MEM_SEGS);
- DRM(free)(entry->seglist_bus, entry->seg_count *
+ 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,
+ drm_free(entry->buflist[i].dev_private,
entry->buflist[i].dev_priv_size, DRM_MEM_BUFS);
}
- DRM(free)(entry->buflist,
+ drm_free(entry->buflist,
entry->buf_count *
sizeof(*entry->buflist),
DRM_MEM_BUFS);
@@ -276,8 +257,7 @@ static void DRM(cleanup_buf_error)(drm_device_t *dev, drm_buf_entry_t *entry)
}
}
-#if __REALLY_HAVE_AGP
-static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
+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;
@@ -295,7 +275,7 @@ static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
drm_buf_t **temp_buflist;
count = request->count;
- order = DRM(order)(request->size);
+ order = drm_order(request->size);
size = 1 << order;
alignment = (request->flags & _DRM_PAGE_ALIGN)
@@ -316,8 +296,8 @@ static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
entry = &dma->bufs[order];
- entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist),
- DRM_MEM_BUFS );
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
+ DRM_MEM_BUFS);
if ( !entry->buflist ) {
return DRM_ERR(ENOMEM);
}
@@ -343,12 +323,12 @@ static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = DRM(calloc)(1, buf->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);
+ drm_cleanup_buf_error(dev, entry);
return DRM_ERR(ENOMEM);
}
@@ -359,14 +339,14 @@ static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
DRM_DEBUG( "byte_count: %d\n", byte_count );
- temp_buflist = DRM(realloc)( dma->buflist,
+ 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_cleanup_buf_error(dev, entry);
return DRM_ERR(ENOMEM);
}
dma->buflist = temp_buflist;
@@ -388,10 +368,8 @@ static int DRM(addbufs_agp)(drm_device_t *dev, drm_buf_desc_t *request)
return 0;
}
-#endif /* __REALLY_HAVE_AGP */
-#if __HAVE_PCI_DMA
-static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
+static int drm_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
{
drm_device_dma_t *dma = dev->dma;
int count;
@@ -412,7 +390,7 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
dma_addr_t bus_addr;
count = request->count;
- order = DRM(order)(request->size);
+ order = drm_order(request->size);
size = 1 << order;
DRM_DEBUG( "count=%d, size=%d (%d), order=%d\n",
@@ -425,26 +403,26 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
entry = &dma->bufs[order];
- entry->buflist = DRM(alloc)(count * sizeof(*entry->buflist),
+ entry->buflist = drm_alloc(count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
- entry->seglist = DRM(alloc)(count * sizeof(*entry->seglist),
+ entry->seglist = drm_alloc(count * sizeof(*entry->seglist),
DRM_MEM_SEGS);
- entry->seglist_bus = DRM(alloc)(count * sizeof(*entry->seglist_bus),
+ 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)) *
+ 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_free(entry->buflist, count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
- DRM(free)(entry->seglist, count * sizeof(*entry->seglist),
+ drm_free(entry->seglist, count * sizeof(*entry->seglist),
DRM_MEM_SEGS);
- DRM(free)(entry->seglist_bus, count *
+ drm_free(entry->seglist_bus, count *
sizeof(*entry->seglist_bus), DRM_MEM_SEGS);
return DRM_ERR(ENOMEM);
}
@@ -464,14 +442,14 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
page_count = 0;
while ( entry->buf_count < count ) {
- vaddr = (vm_offset_t) DRM(pci_alloc)(dev, size, alignment,
+ 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 +
+ 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);
@@ -502,14 +480,14 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = DRM(alloc)(buf->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 +
+ 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);
@@ -522,15 +500,15 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
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 );
+ 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 +
+ 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);
@@ -544,7 +522,7 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
/* 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_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
DRM_MEM_PAGES);
dma->pagelist = temp_pagelist;
@@ -559,10 +537,8 @@ static int DRM(addbufs_pci)(drm_device_t *dev, drm_buf_desc_t *request)
return 0;
}
-#endif /* __HAVE_PCI_DMA */
-#if __REALLY_HAVE_SG
-static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
+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;
@@ -580,7 +556,7 @@ static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
drm_buf_t **temp_buflist;
count = request->count;
- order = DRM(order)(request->size);
+ order = drm_order(request->size);
size = 1 << order;
alignment = (request->flags & _DRM_PAGE_ALIGN)
@@ -601,7 +577,7 @@ static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
entry = &dma->bufs[order];
- entry->buflist = DRM(calloc)(1, count * sizeof(*entry->buflist),
+ entry->buflist = drm_calloc(1, count * sizeof(*entry->buflist),
DRM_MEM_BUFS);
if (entry->buflist == NULL)
return DRM_ERR(ENOMEM);
@@ -626,12 +602,12 @@ static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
buf->filp = NULL;
buf->dev_priv_size = dev->dev_priv_size;
- buf->dev_private = DRM(calloc)(1, buf->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);
+ drm_cleanup_buf_error(dev, entry);
return DRM_ERR(ENOMEM);
}
@@ -645,14 +621,14 @@ static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
DRM_DEBUG( "byte_count: %d\n", byte_count );
- temp_buflist = DRM(realloc)( dma->buflist,
+ 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_cleanup_buf_error(dev, entry);
return DRM_ERR(ENOMEM);
}
dma->buflist = temp_buflist;
@@ -674,9 +650,8 @@ static int DRM(addbufs_sg)(drm_device_t *dev, drm_buf_desc_t *request)
return 0;
}
-#endif /* __REALLY_HAVE_SG */
-int DRM(addbufs)( DRM_IOCTL_ARGS )
+int drm_addbufs(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_buf_desc_t request;
@@ -688,7 +663,7 @@ int DRM(addbufs)( DRM_IOCTL_ARGS )
if (request.count < 0 || request.count > 4096)
return DRM_ERR(EINVAL);
- order = DRM(order)(request.size);
+ order = drm_order(request.size);
if (order < DRM_MIN_ORDER || order > DRM_MAX_ORDER)
return DRM_ERR(EINVAL);
@@ -704,21 +679,13 @@ int DRM(addbufs)( DRM_IOCTL_ARGS )
return DRM_ERR(ENOMEM);
}
-#if __REALLY_HAVE_AGP
if ( request.flags & _DRM_AGP_BUFFER )
- err = DRM(addbufs_agp)(dev, &request);
+ err = drm_addbufs_agp(dev, &request);
else
-#endif
-#if __REALLY_HAVE_SG
if ( request.flags & _DRM_SG_BUFFER )
- err = DRM(addbufs_sg)(dev, &request);
+ err = drm_addbufs_sg(dev, &request);
else
-#endif
-#if __HAVE_PCI_DMA
- err = DRM(addbufs_pci)(dev, &request);
-#else
- err = DRM_ERR(EINVAL);
-#endif
+ err = drm_addbufs_pci(dev, &request);
DRM_SPINUNLOCK(&dev->dma_lock);
DRM_COPY_TO_USER_IOCTL((drm_buf_desc_t *)data, request, sizeof(request));
@@ -726,7 +693,7 @@ int DRM(addbufs)( DRM_IOCTL_ARGS )
return err;
}
-int DRM(infobufs)( DRM_IOCTL_ARGS )
+int drm_infobufs(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
@@ -780,7 +747,7 @@ int DRM(infobufs)( DRM_IOCTL_ARGS )
return retcode;
}
-int DRM(markbufs)( DRM_IOCTL_ARGS )
+int drm_markbufs(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
@@ -793,7 +760,7 @@ int DRM(markbufs)( DRM_IOCTL_ARGS )
request.size, request.low_mark, request.high_mark );
- order = DRM(order)(request.size);
+ 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);
@@ -812,7 +779,7 @@ int DRM(markbufs)( DRM_IOCTL_ARGS )
return 0;
}
-int DRM(freebufs)( DRM_IOCTL_ARGS )
+int drm_freebufs(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
@@ -845,14 +812,14 @@ int DRM(freebufs)( DRM_IOCTL_ARGS )
retcode = DRM_ERR(EINVAL);
break;
}
- DRM(free_buffer)( dev, buf );
+ drm_free_buffer(dev, buf);
}
DRM_SPINUNLOCK(&dev->dma_lock);
return retcode;
}
-int DRM(mapbufs)( DRM_IOCTL_ARGS )
+int drm_mapbufs(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
@@ -894,8 +861,8 @@ int DRM(mapbufs)( DRM_IOCTL_ARGS )
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))) {
+ if ((dev->use_agp && (dma->flags & _DRM_DMA_USE_AGP)) ||
+ (dev->use_sg && (dma->flags & _DRM_DMA_USE_SG))) {
drm_local_map_t *map = dev->agp_buffer_map;
if (map == NULL) {
@@ -957,5 +924,3 @@ int DRM(mapbufs)( DRM_IOCTL_ARGS )
return DRM_ERR(retcode);
}
-
-#endif /* __HAVE_DMA */
diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c
index aa655297..87185f4e 100644
--- a/bsd-core/drm_context.c
+++ b/bsd-core/drm_context.c
@@ -32,15 +32,11 @@
#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 )
+void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle)
{
if (ctx_handle < 0 || ctx_handle >= DRM_MAX_CTXBITMAP ||
dev->ctx_bitmap == NULL) {
@@ -56,7 +52,7 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
return;
}
-int DRM(ctxbitmap_next)( drm_device_t *dev )
+int drm_ctxbitmap_next(drm_device_t *dev)
{
int bit;
@@ -77,7 +73,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
if (dev->context_sareas != NULL) {
drm_local_map_t **ctx_sareas;
- ctx_sareas = DRM(realloc)(dev->context_sareas,
+ ctx_sareas = drm_realloc(dev->context_sareas,
(dev->max_context - 1) *
sizeof(*dev->context_sareas),
dev->max_context *
@@ -92,7 +88,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
dev->context_sareas[bit] = NULL;
} else {
/* max_context == 1 at this point */
- dev->context_sareas = DRM(alloc)(dev->max_context *
+ 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);
@@ -106,13 +102,13 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
return bit;
}
-int DRM(ctxbitmap_init)( drm_device_t *dev )
+int drm_ctxbitmap_init(drm_device_t *dev)
{
int i;
int temp;
DRM_LOCK();
- dev->ctx_bitmap = (atomic_t *)DRM(calloc)(1, PAGE_SIZE,
+ dev->ctx_bitmap = (atomic_t *)drm_calloc(1, PAGE_SIZE,
DRM_MEM_CTXBITMAP);
if ( dev->ctx_bitmap == NULL ) {
DRM_UNLOCK();
@@ -123,20 +119,20 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
DRM_UNLOCK();
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
- temp = DRM(ctxbitmap_next)( dev );
+ temp = drm_ctxbitmap_next(dev);
DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp );
}
return 0;
}
-void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
+void drm_ctxbitmap_cleanup(drm_device_t *dev)
{
DRM_LOCK();
if (dev->context_sareas != NULL)
- DRM(free)(dev->context_sareas, sizeof(*dev->context_sareas) *
+ 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_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP);
DRM_UNLOCK();
}
@@ -144,7 +140,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
* Per Context SAREA Support
*/
-int DRM(getsareactx)( DRM_IOCTL_ARGS )
+int drm_getsareactx( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
drm_ctx_priv_map_t request;
@@ -169,7 +165,7 @@ int DRM(getsareactx)( DRM_IOCTL_ARGS )
return 0;
}
-int DRM(setsareactx)( DRM_IOCTL_ARGS )
+int drm_setsareactx( DRM_IOCTL_ARGS )
{
DRM_DEVICE;
drm_ctx_priv_map_t request;
@@ -202,7 +198,7 @@ bad:
* The actual DRM context handling routines
*/
-int DRM(context_switch)( drm_device_t *dev, int old, int new )
+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" );
@@ -219,7 +215,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new )
return 0;
}
-int DRM(context_switch_complete)( drm_device_t *dev, int new )
+int drm_context_switch_complete(drm_device_t *dev, int new)
{
dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
@@ -235,7 +231,7 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new )
return 0;
}
-int DRM(resctx)( DRM_IOCTL_ARGS )
+int drm_resctx(DRM_IOCTL_ARGS)
{
drm_ctx_res_t res;
drm_ctx_t ctx;
@@ -259,17 +255,17 @@ int DRM(resctx)( DRM_IOCTL_ARGS )
return 0;
}
-int DRM(addctx)( DRM_IOCTL_ARGS )
+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 );
+ 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 );
+ ctx.handle = drm_ctxbitmap_next(dev);
}
DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle == -1 ) {
@@ -278,21 +274,21 @@ int DRM(addctx)( DRM_IOCTL_ARGS )
return DRM_ERR(ENOMEM);
}
- if ( dev->fn_tbl.context_ctor && ctx.handle != DRM_KERNEL_CONTEXT )
- dev->fn_tbl.context_ctor(dev, ctx.handle);
+ if (dev->context_ctor && ctx.handle != DRM_KERNEL_CONTEXT)
+ dev->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 )
+int drm_modctx(DRM_IOCTL_ARGS)
{
/* This does nothing */
return 0;
}
-int DRM(getctx)( DRM_IOCTL_ARGS )
+int drm_getctx(DRM_IOCTL_ARGS)
{
drm_ctx_t ctx;
@@ -306,7 +302,7 @@ int DRM(getctx)( DRM_IOCTL_ARGS )
return 0;
}
-int DRM(switchctx)( DRM_IOCTL_ARGS )
+int drm_switchctx(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_ctx_t ctx;
@@ -314,10 +310,10 @@ int DRM(switchctx)( DRM_IOCTL_ARGS )
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 );
+ return drm_context_switch(dev, dev->last_context, ctx.handle);
}
-int DRM(newctx)( DRM_IOCTL_ARGS )
+int drm_newctx(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_ctx_t ctx;
@@ -325,12 +321,12 @@ int DRM(newctx)( DRM_IOCTL_ARGS )
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 );
+ drm_context_switch_complete(dev, ctx.handle);
return 0;
}
-int DRM(rmctx)( DRM_IOCTL_ARGS )
+int drm_rmctx(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_ctx_t ctx;
@@ -339,10 +335,10 @@ int DRM(rmctx)( DRM_IOCTL_ARGS )
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);
+ if (dev->context_dtor)
+ dev->context_dtor(dev, ctx.handle);
- DRM(ctxbitmap_free)( dev, ctx.handle );
+ drm_ctxbitmap_free(dev, ctx.handle);
}
return 0;
diff --git a/bsd-core/drm_dma.c b/bsd-core/drm_dma.c
index 4570a867..6446a844 100644
--- a/bsd-core/drm_dma.c
+++ b/bsd-core/drm_dma.c
@@ -32,22 +32,10 @@
#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 )
+int drm_dma_setup(drm_device_t *dev)
{
- dev->dma = DRM(calloc)(1, sizeof(*dev->dma), DRM_MEM_DRIVER);
+ dev->dma = drm_calloc(1, sizeof(*dev->dma), DRM_MEM_DRIVER);
if (dev->dma == NULL)
return DRM_ERR(ENOMEM);
@@ -56,7 +44,7 @@ int DRM(dma_setup)( drm_device_t *dev )
return 0;
}
-void DRM(dma_takedown)(drm_device_t *dev)
+void drm_dma_takedown(drm_device_t *dev)
{
drm_device_dma_t *dma = dev->dma;
int i, j;
@@ -66,7 +54,6 @@ void DRM(dma_takedown)(drm_device_t *dev)
/* 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",
@@ -75,45 +62,44 @@ void DRM(dma_takedown)(drm_device_t *dev)
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,
+ 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,
+ 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,
+ 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,
+ 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,
+ 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_free(dma->buflist, dma->buf_count * sizeof(*dma->buflist),
DRM_MEM_BUFS);
- DRM(free)(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
+ drm_free(dma->pagelist, dma->page_count * sizeof(*dma->pagelist),
DRM_MEM_PAGES);
- DRM(free)(dev->dma, sizeof(*dev->dma), DRM_MEM_DRIVER);
+ 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)
+void drm_free_buffer(drm_device_t *dev, drm_buf_t *buf)
{
if (!buf) return;
@@ -122,8 +108,7 @@ void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf)
buf->used = 0;
}
-#if !__HAVE_DMA_RECLAIM
-void DRM(reclaim_buffers)(drm_device_t *dev, DRMFILE filp)
+void drm_reclaim_buffers(drm_device_t *dev, DRMFILE filp)
{
drm_device_dma_t *dma = dev->dma;
int i;
@@ -133,7 +118,7 @@ void DRM(reclaim_buffers)(drm_device_t *dev, DRMFILE filp)
if (dma->buflist[i]->filp == filp) {
switch (dma->buflist[i]->list) {
case DRM_LIST_NONE:
- DRM(free_buffer)(dev, dma->buflist[i]);
+ drm_free_buffer(dev, dma->buflist[i]);
break;
case DRM_LIST_WAIT:
dma->buflist[i]->list = DRM_LIST_RECLAIM;
@@ -145,27 +130,3 @@ void DRM(reclaim_buffers)(drm_device_t *dev, DRMFILE filp)
}
}
}
-#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-core/drm_drawable.c b/bsd-core/drm_drawable.c
index 890de1fb..43a91045 100644
--- a/bsd-core/drm_drawable.c
+++ b/bsd-core/drm_drawable.c
@@ -32,7 +32,7 @@
#include "drmP.h"
-int DRM(adddraw)( DRM_IOCTL_ARGS )
+int drm_adddraw(DRM_IOCTL_ARGS)
{
drm_draw_t draw;
@@ -44,7 +44,7 @@ int DRM(adddraw)( DRM_IOCTL_ARGS )
return 0;
}
-int DRM(rmdraw)( DRM_IOCTL_ARGS )
+int drm_rmdraw(DRM_IOCTL_ARGS)
{
return 0; /* NOOP */
}
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 4e82ef81..b40bf1e4 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -30,173 +30,105 @@
*
*/
-/*
- * 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
+#include "drmP.h"
+#include "drm.h"
#if 1 && DRM_DEBUG_CODE
-int DRM(flags) = DRM_FLAG_DEBUG;
+int drm_flags = DRM_FLAG_DEBUG;
#else
-int DRM(flags) = 0;
+int drm_flags = 0;
#endif
-static int DRM(init)(device_t nbdev);
-static void DRM(cleanup)(drm_device_t *dev);
+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))
+ ((drm_device_t *)devclass_get_softc(drm_devclass, unit))
-#if __REALLY_HAVE_AGP
-MODULE_DEPEND(DRIVER_NAME, agp, 1, 1, 1);
-#endif
+MODULE_VERSION(drm, 1);
+MODULE_DEPEND(drm, agp, 1, 1, 1);
+MODULE_DEPEND(drm, pci, 1, 1, 1);
#endif /* __FreeBSD__ */
#ifdef __NetBSD__
#define DRIVER_SOFTC(unit) \
- ((drm_device_t *) device_lookup(&DRM(cd), unit))
+ ((drm_device_t *)device_lookup(&drm_cd, unit))
#endif /* __NetBSD__ */
-static drm_ioctl_desc_t DRM(ioctls)[] = {
- [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 },
+static drm_ioctl_desc_t drm_ioctls[256] = {
+ [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 },
+ [DRM_IOCTL_NR(DRM_IOCTL_IRQ_BUSID)] = { drm_irq_by_busid, 0, 1 },
+ [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 },
+
+ [DRM_IOCTL_NR(DRM_IOCTL_SET_SAREA_CTX)] = { drm_setsareactx, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_GET_SAREA_CTX)] = { drm_getsareactx, 1, 0 },
+
+ [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 },
+
+ [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
+ [DRM_IOCTL_NR(DRM_IOCTL_CONTROL)] = { drm_control, 1, 1 },
-#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
+ [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 },
-#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
+ [DRM_IOCTL_NR(DRM_IOCTL_SG_ALLOC)] = { drm_sg_alloc, 1, 1 },
+ [DRM_IOCTL_NR(DRM_IOCTL_SG_FREE)] = { drm_sg_free, 1, 1 },
-#if __HAVE_VBL_IRQ
- [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { DRM(wait_vblank), 0, 0 },
-#endif
-
- DRIVER_IOCTLS
+ [DRM_IOCTL_NR(DRM_IOCTL_WAIT_VBLANK)] = { drm_wait_vblank, 0, 0 },
};
-#define DRIVER_IOCTL_COUNT DRM_ARRAY_SIZE( DRM(ioctls) )
-
-const char *DRM(find_description)(int vendor, int device);
+const char *drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist);
#ifdef __FreeBSD__
-static struct cdevsw DRM(cdevsw) = {
+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,
+ .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 = "drm",
#if __FreeBSD_version >= 502103
.d_flags = D_TRACKCLOSE | D_NEEDGIANT,
#else
@@ -208,13 +140,7 @@ static struct cdevsw DRM(cdevsw) = {
#endif
};
-#include "drm_pciids.h"
-
-static drm_pci_id_list_t DRM(pciidlist)[] = {
- DRM(PCI_IDS)
-};
-
-static int DRM(probe)(device_t dev)
+int drm_probe(device_t dev, drm_pci_id_list_t *idlist)
{
const char *s = NULL;
int pciid, vendor, device;
@@ -228,7 +154,7 @@ static int DRM(probe)(device_t dev)
vendor = (pciid & 0x0000ffff);
device = (pciid & 0xffff0000) >> 16;
- s = DRM(find_description)(vendor, device);
+ s = drm_find_description(vendor, device, idlist);
if (s != NULL) {
device_set_desc(dev, s);
return 0;
@@ -237,72 +163,58 @@ static int DRM(probe)(device_t dev)
return ENXIO;
}
-static int DRM(attach)(device_t dev)
+int drm_attach(device_t dev, drm_pci_id_list_t *idlist)
{
- return DRM(init)(dev);
+ return drm_init(dev);
}
-static int DRM(detach)(device_t dev)
+int drm_detach(device_t dev)
{
- DRM(cleanup)(device_get_softc(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);
+devclass_t drm_devclass;
#elif defined(__NetBSD__)
-static struct cdevsw DRM(cdevsw) = {
- DRM(open),
- DRM(close),
- DRM(read),
+static struct cdevsw drm_cdevsw = {
+ drm_open,
+ drm_close,
+ drm_read,
nowrite,
- DRM(ioctl),
+ drm_ioctl,
nostop,
notty,
- DRM(poll),
- DRM(mmap),
+ drm_poll,
+ drm_mmap,
nokqfilter,
D_TTY
};
-int DRM(refcnt) = 0;
+int drm_refcnt = 0;
#if __NetBSD_Version__ >= 106080000
-MOD_DEV( DRIVER_NAME, DRIVER_NAME, NULL, -1, &DRM(cdevsw), CDEV_MAJOR);
+MOD_DEV("drm", DRIVER_NAME, NULL, -1, &drm_cdevsw, CDEV_MAJOR);
#else
-MOD_DEV( DRIVER_NAME, LM_DT_CHAR, CDEV_MAJOR, &DRM(cdevsw) );
+MOD_DEV("drm", 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_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_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));
+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)
+static int drm_lkmhandle(struct lkm_table *lkmtp, int cmd)
{
int j, error = 0;
#if defined(__NetBSD__) && (__NetBSD_Version__ > 106080000)
@@ -314,13 +226,13 @@ static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd)
if (lkmexists(lkmtp))
return EEXIST;
- if(DRM(modprobe)())
+ if(drm_modprobe())
return 0;
return 1;
case LKM_E_UNLOAD:
- if (DRM(refcnt) > 0)
+ if (drm_refcnt > 0)
return (EBUSY);
break;
case LKM_E_STAT:
@@ -334,21 +246,23 @@ static int DRM(lkmhandle)(struct lkm_table *lkmtp, int cmd)
return error;
}
-int DRM(modprobe)() {
+int drm_modprobe() {
struct pci_attach_args pa;
- int error = 0;
- if((error = pci_find_device(&pa, DRM(probe))) != 0)
- DRM(attach)(&pa, 0);
+ int error;
+
+ error = pci_find_device(&pa, drm_probe, idlist);
+ if (error != 0)
+ drm_attach(&pa, 0);
return error;
}
-int DRM(probe)(struct pci_attach_args *pa)
+int drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t idlist)
{
const char *desc;
- desc = DRM(find_description)(PCI_VENDOR(pa->pa_id),
- PCI_PRODUCT(pa->pa_id));
+ desc = drm_find_description(PCI_VENDOR(pa->pa_id),
+ PCI_PRODUCT(pa->pa_id), idlist);
if (desc != NULL) {
return 1;
}
@@ -356,30 +270,31 @@ int DRM(probe)(struct pci_attach_args *pa)
return 0;
}
-void DRM(attach)(struct pci_attach_args *pa, dev_t kdev)
+void drm_attach(struct pci_attach_args *pa, dev_t kdev,
+ drm_pci_id_list_t *idlist)
{
int i;
drm_device_t *dev;
- config_makeroom(kdev, &DRM(cd));
- DRM(cd).cd_devs[(kdev)] = DRM(alloc)(sizeof(drm_device_t),
+ 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);
+ DRM_INFO("%s", drm_find_description(PCI_VENDOR(pa->pa_id), PCI_PRODUCT(pa->pa_id), idlist));
+ drm_init(dev);
}
-int DRM(detach)(struct device *self, int flags)
+int drm_detach(struct device *self, int flags)
{
- DRM(cleanup)((drm_device_t *)self);
+ drm_cleanup((drm_device_t *)self);
return 0;
}
-int DRM(activate)(struct device *self, enum devact act)
+int drm_activate(struct device *self, enum devact act)
{
switch (act) {
case DVACT_ACTIVATE:
@@ -394,73 +309,43 @@ int DRM(activate)(struct device *self, enum devact act)
}
#endif /* __NetBSD__ */
-const char *DRM(find_description)(int vendor, int device) {
+const char *drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist) {
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;
+ for (i = 0; idlist[i].vendor != 0; i++) {
+ if ((idlist[i].vendor == vendor) &&
+ (idlist[i].device == device)) {
+ return idlist[i].name;
}
}
return NULL;
}
/* Initialize the DRM on first open. */
-static int DRM(setup)( drm_device_t *dev )
+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);
+ if (dev->presetup)
+ dev->presetup(dev);
dev->buf_use = 0;
-#if __HAVE_DMA
- i = DRM(dma_setup)( dev );
- if ( i != 0 )
- return i;
-#endif
+ if (dev->use_dma) {
+ i = drm_dma_setup(dev);
+ if (i != 0)
+ return i;
+ }
- dev->counters = 6 + __HAVE_COUNTERS;
+ dev->counters = 6;
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 );
@@ -485,14 +370,14 @@ static int DRM(setup)( drm_device_t *dev )
DRM_DEBUG( "\n" );
- if (dev->fn_tbl.postsetup)
- dev->fn_tbl.postsetup(dev);
+ if (dev->postsetup)
+ dev->postsetup(dev);
return 0;
}
/* Free resources associated with the DRM on the last close. */
-static int DRM(takedown)( drm_device_t *dev )
+static int drm_takedown(drm_device_t *dev)
{
drm_magic_entry_t *pt, *next;
drm_local_map_t *map;
@@ -503,17 +388,15 @@ static int DRM(takedown)( drm_device_t *dev )
DRM_DEBUG( "\n" );
- if (dev->fn_tbl.pretakedown)
- dev->fn_tbl.pretakedown(dev);
+ if (dev->pretakedown != NULL)
+ dev->pretakedown(dev);
-#if __HAVE_IRQ
if (dev->irq_enabled)
- DRM(irq_uninstall)( dev );
-#endif
+ drm_irq_uninstall(dev);
if ( dev->unique ) {
- DRM(free)( dev->unique, strlen( dev->unique ) + 1,
- DRM_MEM_DRIVER );
+ drm_free(dev->unique, strlen( dev->unique ) + 1,
+ DRM_MEM_DRIVER);
dev->unique = NULL;
dev->unique_len = 0;
}
@@ -521,60 +404,56 @@ static int DRM(takedown)( drm_device_t *dev )
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 );
+ 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. */
+ 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 );
+ 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)();
+ 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);
+ 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);
+ drm_ioremapfree(map);
/* FALLTHROUGH */
case _DRM_FRAME_BUFFER:
-#if __REALLY_HAVE_MTRR
if (map->mtrr) {
int __unused retcode;
- retcode = DRM(mtrr_del)(map->offset,
+ 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,
+ drm_free(map->handle,
map->size,
DRM_MEM_SAREA);
break;
@@ -587,14 +466,12 @@ static int DRM(takedown)( drm_device_t *dev )
break;
}
TAILQ_REMOVE(dev->maplist, list, link);
- DRM(free)(list, sizeof(*list), DRM_MEM_MAPS);
- DRM(free)(map, sizeof(*map), DRM_MEM_MAPS);
+ drm_free(list, sizeof(*list), DRM_MEM_MAPS);
+ drm_free(map, sizeof(*map), DRM_MEM_MAPS);
}
}
-#if __HAVE_DMA
- DRM(dma_takedown)( dev );
-#endif
+ drm_dma_takedown(dev);
if ( dev->lock.hw_lock ) {
dev->lock.hw_lock = NULL; /* SHM removed */
dev->lock.filp = NULL;
@@ -608,55 +485,40 @@ static int DRM(takedown)( drm_device_t *dev )
* linux/init/main.c (this is not currently supported).
* bsd: drm_init is called via the attach function per device.
*/
-static int DRM(init)( device_t nbdev )
+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);
+ if (dev->preinit != NULL)
+ dev->preinit(dev, 0);
- dev->devnode = make_dev( &DRM(cdevsw),
+ dev->devnode = make_dev(&drm_cdevsw,
unit,
DRM_DEV_UID,
DRM_DEV_GID,
DRM_DEV_MODE,
- "dri/card%d", unit );
+ "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 = 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);
-
+ if (dev->preinit != NULL)
+ dev->preinit(dev, 0);
#endif
dev->irq = pci_get_irq(dev->device);
@@ -666,61 +528,56 @@ static int DRM(init)( device_t nbdev )
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);
+ 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);
+ 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;
+ if (dev->use_agp) {
+ dev->agp = drm_agp_init();
+ if (dev->require_agp && dev->agp == NULL) {
+ DRM_ERROR("Cannot initialize the agpgart module.\n");
+ retcode = DRM_ERR(ENOMEM);
+ goto error;
+ }
+ if (dev->agp != NULL) {
+ 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;
+ if (dev->use_ctxbitmap) {
+ 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,
+ dev->driver_name,
+ dev->driver_major,
+ dev->driver_minor,
+ dev->driver_patchlevel,
+ dev->driver_date,
unit );
- if (dev->fn_tbl.postinit)
- dev->fn_tbl.postinit(dev, 0);
+ if (dev->postinit != NULL)
+ dev->postinit(dev, 0);
return 0;
error:
- DRM(sysctl_cleanup)(dev);
+ drm_sysctl_cleanup(dev);
DRM_LOCK();
- DRM(takedown)(dev);
+ drm_takedown(dev);
DRM_UNLOCK();
#ifdef __FreeBSD__
destroy_dev(dev->devnode);
@@ -728,7 +585,7 @@ error:
mtx_destroy(&dev->dev_lock);
#endif
#endif
- DRM(free)(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
+ drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
return retcode;
}
@@ -736,53 +593,51 @@ error:
* bsd: drm_cleanup is called per device at module unload time.
* FIXME: NetBSD
*/
-static void DRM(cleanup)(drm_device_t *dev)
+static void drm_cleanup(drm_device_t *dev)
{
DRM_DEBUG( "\n" );
- DRM(sysctl_cleanup)( dev );
+ 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->use_ctxbitmap)
+ drm_ctxbitmap_cleanup(dev);
+
if (dev->agp && dev->agp->mtrr) {
int __unused retcode;
- retcode = DRM(mtrr_del)(dev->agp->info.ai_aperture_base,
+ 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_takedown(dev);
DRM_UNLOCK();
-#if __REALLY_HAVE_AGP
if ( dev->agp ) {
- DRM(agp_uninit)();
- DRM(free)( dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS );
+ 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 (dev->postcleanup != NULL)
+ dev->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);
+ drm_free(dev->maplist, sizeof(*dev->maplist), DRM_MEM_MAPS);
}
-int DRM(version)( DRM_IOCTL_ARGS )
+int drm_version(DRM_IOCTL_ARGS)
{
+ DRM_DEVICE;
drm_version_t version;
int len;
@@ -797,20 +652,20 @@ int DRM(version)( DRM_IOCTL_ARGS )
return DRM_ERR(EFAULT); \
}
- version.version_major = DRIVER_MAJOR;
- version.version_minor = DRIVER_MINOR;
- version.version_patchlevel = DRIVER_PATCHLEVEL;
+ version.version_major = dev->driver_major;
+ version.version_minor = dev->driver_minor;
+ version.version_patchlevel = dev->driver_patchlevel;
- DRM_COPY( version.name, DRIVER_NAME );
- DRM_COPY( version.date, DRIVER_DATE );
- DRM_COPY( version.desc, DRIVER_DESC );
+ DRM_COPY(version.name, dev->driver_name);
+ DRM_COPY(version.date, dev->driver_date);
+ DRM_COPY(version.desc, dev->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)
+int drm_open(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
{
drm_device_t *dev = NULL;
int retcode = 0;
@@ -819,7 +674,7 @@ int DRM(open)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
DRM_DEBUG( "open_count = %d\n", dev->open_count );
- retcode = DRM(open_helper)(kdev, flags, fmt, p, dev);
+ retcode = drm_open_helper(kdev, flags, fmt, p, dev);
if ( !retcode ) {
atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
@@ -828,14 +683,14 @@ int DRM(open)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
device_busy(dev->device);
#endif
if ( !dev->open_count++ )
- retcode = DRM(setup)( dev );
+ retcode = drm_setup(dev);
DRM_UNLOCK();
}
return retcode;
}
-int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
+int drm_close(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
{
drm_file_t *priv;
DRM_DEVICE;
@@ -846,15 +701,15 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
DRM_LOCK();
- priv = DRM(find_file_by_proc)(dev, p);
+ 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);
+ if (dev->prerelease != NULL)
+ dev->prerelease(dev, filp);
/* ========================================================
* Begin inline drm_release
@@ -873,20 +728,17 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
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));
+ if (dev->release != NULL)
+ dev->release(dev, filp);
+
+ 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 ) {
+ } else if (dev->release != NULL && dev->lock.hw_lock != NULL) {
/* The lock is required to reclaim buffers */
for (;;) {
if ( !dev->lock.hw_lock ) {
@@ -894,9 +746,9 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
retcode = DRM_ERR(EINTR);
break;
}
- if ( DRM(lock_take)( &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
- dev->lock.pid = DRM_CURRENTPID;
+ if (drm_lock_take(&dev->lock.hw_lock->lock,
+ DRM_KERNEL_CONTEXT)) {
+ dev->lock.filp = filp;
dev->lock.lock_time = jiffies;
atomic_inc( &dev->counts[_DRM_STAT_LOCKS] );
break; /* Got lock */
@@ -904,7 +756,7 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
/* Contention */
#if defined(__FreeBSD__) && __FreeBSD_version > 500000
retcode = msleep((void *)&dev->lock.lock_queue,
- dev->dev_lock, PZERO | PCATCH, "drmlk2", 0);
+ &dev->dev_lock, PZERO | PCATCH, "drmlk2", 0);
#else
retcode = tsleep((void *)&dev->lock.lock_queue,
PZERO | PCATCH, "drmlk2", 0);
@@ -913,14 +765,14 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
break;
}
if (retcode == 0) {
- DRIVER_RELEASE();
- DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT );
+ dev->release(dev, filp);
+ 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 (dev->use_dma)
+ drm_reclaim_buffers(dev, (void *)(uintptr_t)priv->pid);
#if defined (__FreeBSD__) && (__FreeBSD_version >= 500000)
funsetown(&dev->buf_sigio);
@@ -932,7 +784,7 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
if (--priv->refs == 0) {
TAILQ_REMOVE(&dev->files, priv, link);
- DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES );
+ drm_free(priv, sizeof(*priv), DRM_MEM_FILES);
}
/* ========================================================
@@ -944,7 +796,7 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
device_unbusy(dev->device);
#endif
if (--dev->open_count == 0) {
- retcode = DRM(takedown)(dev);
+ retcode = drm_takedown(dev);
}
DRM_UNLOCK();
@@ -952,9 +804,9 @@ int DRM(close)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p)
return retcode;
}
-/* DRM(ioctl) is called whenever a process performs an ioctl on /dev/drm.
+/* 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,
+int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
DRM_STRUCTPROC *p)
{
DRM_DEVICE;
@@ -1005,10 +857,13 @@ int DRM(ioctl)(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
#endif /* __NetBSD__ */
}
- if (nr >= DRIVER_IOCTL_COUNT || IOCGROUP(cmd) != DRM_IOCTL_BASE)
+ if (nr >= dev->max_driver_ioctl || IOCGROUP(cmd) != DRM_IOCTL_BASE)
return EINVAL;
- ioctl = &DRM(ioctls)[nr];
+ ioctl = &drm_ioctls[nr];
+ /* It's not a core DRM ioctl, try driver-specific. */
+ if (ioctl->func == NULL)
+ ioctl = &dev->driver_ioctls[nr];
func = ioctl->func;
if (func == NULL) {
@@ -1024,7 +879,7 @@ int DRM(ioctl)(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
return DRM_ERR(retcode);
}
-int DRM(lock)( DRM_IOCTL_ARGS )
+int drm_lock(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_lock_t lock;
@@ -1042,14 +897,12 @@ int DRM(lock)( DRM_IOCTL_ARGS )
lock.context, DRM_CURRENTPID,
dev->lock.hw_lock->lock, lock.flags );
-#if __HAVE_DMA_QUEUE
- if ( lock.context < 0 )
+ if (dev->use_dma_queue && lock.context < 0)
return DRM_ERR(EINVAL);
-#endif
DRM_LOCK();
for (;;) {
- if (DRM(lock_take)(&dev->lock.hw_lock->lock, lock.context)) {
+ 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]);
@@ -1075,17 +928,14 @@ int DRM(lock)( DRM_IOCTL_ARGS )
/* XXX: Add signal blocking here */
-#if __HAVE_DMA_QUIESCENT
- if (lock.flags & _DRM_LOCK_QUIESCENT) {
- DRIVER_DMA_QUIESCENT();
- }
-#endif
+ if (dev->dma_quiescent != NULL && (lock.flags & _DRM_LOCK_QUIESCENT))
+ dev->dma_quiescent(dev);
return 0;
}
-int DRM(unlock)( DRM_IOCTL_ARGS )
+int drm_unlock(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_lock_t lock;
@@ -1101,14 +951,9 @@ int DRM(unlock)( DRM_IOCTL_ARGS )
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
+ drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT);
- if ( DRM(lock_free)( dev, &dev->lock.hw_lock->lock,
- DRM_KERNEL_CONTEXT ) ) {
+ if (drm_lock_free(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) {
DRM_ERROR( "\n" );
}
DRM_UNLOCK();
@@ -1125,21 +970,21 @@ 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),
+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));
+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)
+drm_linux_ioctl(DRM_STRUCTPROC *p, struct linux_ioctl_args* args)
{
int error;
int cmd = args->cmd;
diff --git a/bsd-core/drm_fops.c b/bsd-core/drm_fops.c
index 2c447992..072a6e22 100644
--- a/bsd-core/drm_fops.c
+++ b/bsd-core/drm_fops.c
@@ -33,7 +33,7 @@
#include "drmP.h"
-drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p)
+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;
@@ -52,8 +52,8 @@ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p)
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_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);
@@ -66,11 +66,11 @@ int DRM(open_helper)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
DRM_LOCK();
- priv = DRM(find_file_by_proc)(dev, p);
+ priv = drm_find_file_by_proc(dev, p);
if (priv) {
priv->refs++;
} else {
- priv = (drm_file_t *) DRM(alloc)(sizeof(*priv), DRM_MEM_FILES);
+ priv = (drm_file_t *)drm_alloc(sizeof(*priv), DRM_MEM_FILES);
if (priv == NULL) {
DRM_UNLOCK();
return DRM_ERR(ENOMEM);
@@ -86,12 +86,11 @@ int DRM(open_helper)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
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);
+ if (dev->open_helper)
+ dev->open_helper(dev, priv);
TAILQ_INSERT_TAIL(&dev->files, priv, link);
}
@@ -103,15 +102,15 @@ int DRM(open_helper)(struct cdev *kdev, int flags, int fmt, DRM_STRUCTPROC *p,
}
-/* The DRM(read) and DRM(poll) are stubs to prevent spurious errors
+/* 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)
+int drm_read(struct cdev *kdev, struct uio *uio, int ioflag)
{
return 0;
}
-int DRM(poll)(struct cdev *kdev, int events, DRM_STRUCTPROC *p)
+int drm_poll(struct cdev *kdev, int events, DRM_STRUCTPROC *p)
{
return 0;
}
diff --git a/bsd-core/drm_ioctl.c b/bsd-core/drm_ioctl.c
index 0952211e..014c6b4e 100644
--- a/bsd-core/drm_ioctl.c
+++ b/bsd-core/drm_ioctl.c
@@ -38,7 +38,7 @@
* 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 )
+int drm_getunique(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_unique_t u;
@@ -59,7 +59,7 @@ int DRM(getunique)( DRM_IOCTL_ARGS )
/* 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 )
+int drm_setunique(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_unique_t u;
@@ -74,7 +74,7 @@ int DRM(setunique)( DRM_IOCTL_ARGS )
return DRM_ERR(EINVAL);
dev->unique_len = u.unique_len;
- dev->unique = DRM(alloc)(u.unique_len + 1, DRM_MEM_DRIVER);
+ dev->unique = drm_alloc(u.unique_len + 1, DRM_MEM_DRIVER);
if (dev->unique == NULL)
return DRM_ERR(ENOMEM);
@@ -104,14 +104,14 @@ int DRM(setunique)( DRM_IOCTL_ARGS )
static int
-DRM(set_busid)(drm_device_t *dev)
+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);
+ dev->unique = drm_alloc(dev->unique_len + 1, DRM_MEM_DRIVER);
if (dev->unique == NULL)
return ENOMEM;
@@ -121,7 +121,7 @@ DRM(set_busid)(drm_device_t *dev)
return 0;
}
-int DRM(getmap)( DRM_IOCTL_ARGS )
+int drm_getmap(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_map_t map;
@@ -164,7 +164,7 @@ int DRM(getmap)( DRM_IOCTL_ARGS )
return 0;
}
-int DRM(getclient)( DRM_IOCTL_ARGS )
+int drm_getclient(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_client_t client;
@@ -198,7 +198,7 @@ int DRM(getclient)( DRM_IOCTL_ARGS )
return 0;
}
-int DRM(getstats)( DRM_IOCTL_ARGS )
+int drm_getstats(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_stats_t stats;
@@ -230,7 +230,7 @@ int DRM(getstats)( DRM_IOCTL_ARGS )
#define DRM_IF_MAJOR 1
#define DRM_IF_MINOR 2
-int DRM(setversion)(DRM_IOCTL_ARGS)
+int drm_setversion(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_set_version_t sv;
@@ -241,9 +241,9 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
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;
-
+ retv.drm_dd_major = dev->driver_major;
+ retv.drm_dd_minor = dev->driver_minor;
+
DRM_COPY_TO_USER_IOCTL((drm_set_version_t *)data, retv, sizeof(sv));
if (sv.drm_di_major != -1) {
@@ -256,13 +256,13 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
/*
* Version 1.1 includes tying of DRM to specific device
*/
- DRM(set_busid)(dev);
+ 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)
+ if (sv.drm_dd_major != dev->driver_major ||
+ sv.drm_dd_minor < 0 || sv.drm_dd_minor > dev->driver_minor)
return EINVAL;
#ifdef DRIVER_SETVERSION
DRIVER_SETVERSION(dev, &sv);
@@ -272,7 +272,7 @@ int DRM(setversion)(DRM_IOCTL_ARGS)
}
-int DRM(noop)(DRM_IOCTL_ARGS)
+int drm_noop(DRM_IOCTL_ARGS)
{
DRM_DEBUG("\n");
return 0;
diff --git a/bsd-core/drm_irq.c b/bsd-core/drm_irq.c
index eec6ab93..d1f0505b 100644
--- a/bsd-core/drm_irq.c
+++ b/bsd-core/drm_irq.c
@@ -28,7 +28,10 @@
*
*/
-int DRM(irq_by_busid)( DRM_IOCTL_ARGS )
+#include "drmP.h"
+#include "drm.h"
+
+int drm_irq_by_busid(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_irq_busid_t irq;
@@ -53,17 +56,17 @@ int DRM(irq_by_busid)( DRM_IOCTL_ARGS )
#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
static irqreturn_t
-DRM(irq_handler_wrap)(DRM_IRQ_ARGS)
+drm_irq_handler_wrap(DRM_IRQ_ARGS)
{
drm_device_t *dev = (drm_device_t *)arg;
DRM_SPINLOCK(&dev->irq_lock);
- DRM(irq_handler)(arg);
+ dev->irq_handler(arg);
DRM_SPINUNLOCK(&dev->irq_lock);
}
#endif
-int DRM(irq_install)(drm_device_t *dev)
+int drm_irq_install(drm_device_t *dev)
{
int retcode;
@@ -85,14 +88,10 @@ int DRM(irq_install)(drm_device_t *dev)
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 );
+ dev->irq_preinstall(dev);
/* Install handler */
#ifdef __FreeBSD__
@@ -105,10 +104,10 @@ int DRM(irq_install)(drm_device_t *dev)
}
#if __FreeBSD_version < 500000
retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY,
- DRM(irq_handler), dev, &dev->irqh);
+ dev->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);
+ drm_irq_handler_wrap, dev, &dev->irqh);
#endif
if (retcode != 0)
goto err;
@@ -118,7 +117,7 @@ int DRM(irq_install)(drm_device_t *dev)
goto err;
}
dev->irqh = pci_intr_establish(&dev->pa.pa_pc, dev->ih, IPL_TTY,
- (irqreturn_t (*)(DRM_IRQ_ARGS))DRM(irq_handler), dev);
+ (irqreturn_t (*)(DRM_IRQ_ARGS))dev->irq_handler, dev);
if (!dev->irqh) {
retcode = ENOENT;
goto err;
@@ -126,7 +125,7 @@ int DRM(irq_install)(drm_device_t *dev)
#endif
/* After installing handler */
- DRM(driver_irq_postinstall)( dev );
+ dev->irq_postinstall(dev);
return 0;
err:
@@ -147,7 +146,7 @@ err:
/* 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 drm_irq_uninstall(drm_device_t *dev)
{
int irqrid;
@@ -160,7 +159,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
- DRM(driver_irq_uninstall)( dev );
+ dev->irq_uninstall(dev);
#ifdef __FreeBSD__
bus_teardown_intr(dev->device, dev->irqr, dev->irqh);
@@ -173,7 +172,7 @@ int DRM(irq_uninstall)( drm_device_t *dev )
return 0;
}
-int DRM(control)( DRM_IOCTL_ARGS )
+int drm_control(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_control_t ctl;
@@ -183,13 +182,20 @@ int DRM(control)( DRM_IOCTL_ARGS )
switch ( ctl.func ) {
case DRM_INST_HANDLER:
+ /* Handle drivers whose DRM used to require IRQ setup but the
+ * no longer does.
+ */
+ if (!dev->use_irq)
+ return 0;
if (dev->if_version < DRM_IF_VERSION(1, 2) &&
ctl.irq != dev->irq)
return DRM_ERR(EINVAL);
- return DRM(irq_install)(dev);
+ return drm_irq_install(dev);
case DRM_UNINST_HANDLER:
+ if (!dev->use_irq)
+ return 0;
DRM_LOCK();
- err = DRM(irq_uninstall)( dev );
+ err = drm_irq_uninstall(dev);
DRM_UNLOCK();
return err;
default:
@@ -197,8 +203,7 @@ int DRM(control)( DRM_IOCTL_ARGS )
}
}
-#if __HAVE_VBL_IRQ
-int DRM(wait_vblank)( DRM_IOCTL_ARGS )
+int drm_wait_vblank(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_wait_vblank_t vblwait;
@@ -237,8 +242,8 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
#endif
ret = EINVAL;
} else {
- ret = DRM(vblank_wait)(dev, &vblwait.request.sequence);
-
+ ret = dev->vblank_wait(dev, &vblwait.request.sequence);
+
microtime(&now);
vblwait.reply.tval_sec = now.tv_sec;
vblwait.reply.tval_usec = now.tv_usec;
@@ -250,12 +255,12 @@ int DRM(wait_vblank)( DRM_IOCTL_ARGS )
return ret;
}
-void DRM(vbl_send_signals)(drm_device_t *dev)
+void drm_vbl_send_signals(drm_device_t *dev)
{
}
#if 0 /* disabled */
-void DRM(vbl_send_signals)( drm_device_t *dev )
+void drm_vbl_send_signals( drm_device_t *dev )
{
drm_vbl_sig_t *vbl_sig;
unsigned int vbl_seq = atomic_read( &dev->vbl_received );
@@ -277,5 +282,3 @@ void DRM(vbl_send_signals)( drm_device_t *dev )
}
}
#endif
-
-#endif /* __HAVE_VBL_IRQ */
diff --git a/bsd-core/drm_lock.c b/bsd-core/drm_lock.c
index a87e0a3a..843fe567 100644
--- a/bsd-core/drm_lock.c
+++ b/bsd-core/drm_lock.c
@@ -32,7 +32,7 @@
#include "drmP.h"
-int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
+int drm_lock_take(__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new;
@@ -60,7 +60,7 @@ int DRM(lock_take)(__volatile__ unsigned int *lock, unsigned int context)
/* 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,
+int drm_lock_transfer(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new;
@@ -74,7 +74,7 @@ int DRM(lock_transfer)(drm_device_t *dev,
return 1;
}
-int DRM(lock_free)(drm_device_t *dev,
+int drm_lock_free(drm_device_t *dev,
__volatile__ unsigned int *lock, unsigned int context)
{
unsigned int old, new;
diff --git a/bsd-core/drm_memory.c b/bsd-core/drm_memory.c
index 26adb085..63d9275f 100644
--- a/bsd-core/drm_memory.c
+++ b/bsd-core/drm_memory.c
@@ -33,56 +33,55 @@
#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");
+MALLOC_DEFINE(M_DRM, "drm", "DRM Data Structures");
#undef malloctype
#endif
#ifdef DEBUG_MEMORY
#include "drm_memory_debug.h"
#else
-void DRM(mem_init)(void)
+void drm_mem_init(void)
{
#ifdef __NetBSD__
- malloc_type_attach(DRM(M_DRM));
+ malloc_type_attach(M_DRM);
#endif
}
-void DRM(mem_uninit)(void)
+void drm_mem_uninit(void)
{
}
-void *DRM(alloc)(size_t size, int area)
+void *drm_alloc(size_t size, int area)
{
- return malloc(size, DRM(M_DRM), M_NOWAIT);
+ return malloc(size, M_DRM, M_NOWAIT);
}
-void *DRM(calloc)(size_t nmemb, size_t size, int area)
+void *drm_calloc(size_t nmemb, size_t size, int area)
{
- return malloc(size * nmemb, DRM(M_DRM), M_NOWAIT | M_ZERO);
+ return malloc(size * nmemb, M_DRM, M_NOWAIT | M_ZERO);
}
-void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size, int area)
+void *drm_realloc(void *oldpt, size_t oldsize, size_t size, int area)
{
void *pt;
- pt = malloc(size, DRM(M_DRM), M_NOWAIT);
+ pt = malloc(size, M_DRM, M_NOWAIT);
if (pt == NULL)
return NULL;
if (oldpt && oldsize) {
memcpy(pt, oldpt, oldsize);
- free(oldpt, DRM(M_DRM));
+ free(oldpt, M_DRM);
}
return pt;
}
-void DRM(free)(void *pt, size_t size, int area)
+void drm_free(void *pt, size_t size, int area)
{
- free(pt, DRM(M_DRM));
+ free(pt, M_DRM);
}
-void *DRM(ioremap)( drm_device_t *dev, drm_local_map_t *map )
+void *drm_ioremap(drm_device_t *dev, drm_local_map_t *map)
{
#ifdef __FreeBSD__
return pmap_mapdev(map->offset, map->size);
@@ -95,7 +94,7 @@ void *DRM(ioremap)( drm_device_t *dev, drm_local_map_t *map )
#endif
}
-void DRM(ioremapfree)(drm_local_map_t *map)
+void drm_ioremapfree(drm_local_map_t *map)
{
#ifdef __FreeBSD__
pmap_unmapdev((vm_offset_t) map->handle, map->size);
@@ -104,32 +103,29 @@ void DRM(ioremapfree)(drm_local_map_t *map)
#endif
}
-#if __REALLY_HAVE_AGP
-agp_memory *DRM(alloc_agp)(int pages, u32 type)
+agp_memory *drm_alloc_agp(int pages, u32 type)
{
- return DRM(agp_allocate_memory)(pages, type);
+ return drm_agp_allocate_memory(pages, type);
}
-int DRM(free_agp)(agp_memory *handle, int pages)
+int drm_free_agp(agp_memory *handle, int pages)
{
- return DRM(agp_free_memory)(handle);
+ return drm_agp_free_memory(handle);
}
-int DRM(bind_agp)(agp_memory *handle, unsigned int start)
+int drm_bind_agp(agp_memory *handle, unsigned int start)
{
- return DRM(agp_bind_memory)(handle, start);
+ return drm_agp_bind_memory(handle, start);
}
-int DRM(unbind_agp)(agp_memory *handle)
+int drm_unbind_agp(agp_memory *handle)
{
- return DRM(agp_unbind_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)
+drm_mtrr_add(unsigned long offset, size_t size, int flags)
{
int act;
struct mem_range_desc mrdesc;
@@ -138,12 +134,12 @@ DRM(mtrr_add)(unsigned long offset, size_t size, int flags)
mrdesc.mr_len = size;
mrdesc.mr_flags = flags;
act = MEMRANGE_SET_UPDATE;
- strlcpy(mrdesc.mr_owner, DRIVER_NAME, sizeof(mrdesc.mr_owner));
+ strlcpy(mrdesc.mr_owner, "drm", sizeof(mrdesc.mr_owner));
return mem_range_attr_set(&mrdesc, &act);
}
int
-DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
+drm_mtrr_del(unsigned long offset, size_t size, int flags)
{
int act;
struct mem_range_desc mrdesc;
@@ -152,12 +148,12 @@ DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
mrdesc.mr_len = size;
mrdesc.mr_flags = flags;
act = MEMRANGE_SET_REMOVE;
- strlcpy(mrdesc.mr_owner, DRIVER_NAME, sizeof(mrdesc.mr_owner));
+ strlcpy(mrdesc.mr_owner, "drm", 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)
+drm_mtrr_add(unsigned long offset, size_t size, int flags)
{
struct mtrr mtrrmap;
int one = 1;
@@ -170,7 +166,7 @@ DRM(mtrr_add)(unsigned long offset, size_t size, int flags)
}
int
-DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
+drm_mtrr_del(unsigned long offset, size_t size, int flags)
{
struct mtrr mtrrmap;
int one = 1;
@@ -182,6 +178,5 @@ DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
}
#endif
-#endif /* __REALLY_HAVE_MTRR */
#endif /* DEBUG_MEMORY */
diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h
index 3ae2dc0b..83542d8a 100644
--- a/bsd-core/drm_os_freebsd.h
+++ b/bsd-core/drm_os_freebsd.h
@@ -75,27 +75,10 @@
#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 "drm_linux_list.h"
#include <opt_drm.h>
#if DRM_DEBUG
@@ -104,6 +87,11 @@
#endif
#undef DRM_DEBUG
+#if defined(__amd64__)
+/* XXX: We don't have the necessary headers yet. At least. */
+#undef DRM_LINUX
+#endif
+
#if DRM_LINUX
#include <sys/file.h>
#include <sys/proc.h>
@@ -117,6 +105,8 @@
#define DRM_DEV_UID 0
#define DRM_DEV_GID 0
+#define __OS_HAS_AGP 1
+
#if __FreeBSD_version >= 500000
#define DRM_CURPROC curthread
#define DRM_STRUCTPROC struct thread
@@ -160,8 +150,8 @@ 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) )
+#define DRM_MALLOC(size) malloc(size, M_DRM, M_NOWAIT)
+#define DRM_FREE(pt,size) free(pt, 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))
@@ -188,7 +178,7 @@ do { \
return EINVAL; \
} \
DRM_LOCK(); \
- _priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
+ _priv = drm_find_file_by_proc(dev, DRM_CURPROC); \
DRM_UNLOCK(); \
if (_priv == NULL) { \
DRM_ERROR("can't find authenticator\n"); \
@@ -302,10 +292,7 @@ for ( ret = 0 ; !ret && !(condition) ; ) { \
#define M_WAITOK 0
#endif
-#define malloctype DRM(M_DRM)
-/* The macros conflicted in the MALLOC_DEFINE */
-MALLOC_DECLARE(malloctype);
-#undef malloctype
+MALLOC_DECLARE(M_DRM);
#if __FreeBSD_version < 502109
#define bus_alloc_resource_any(dev, type, rid, flags) \
@@ -426,14 +413,14 @@ find_first_zero_bit(volatile void *p, int max)
#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)
+ 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) \
+ if (drm_flags & DRM_FLAG_DEBUG) \
printf("[" DRM_NAME ":pid%d:%s] " fmt, \
DRM_CURRENTPID, __func__ , ## arg); \
} while (0)
@@ -450,22 +437,22 @@ find_first_zero_bit(volatile void *p, int max)
/* 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,
+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,
+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);
+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;
+extern int drm_mem_info DRM_SYSCTL_HANDLER_ARGS;
#endif
diff --git a/bsd-core/drm_os_netbsd.h b/bsd-core/drm_os_netbsd.h
index 832f8318..d6db0103 100644
--- a/bsd-core/drm_os_netbsd.h
+++ b/bsd-core/drm_os_netbsd.h
@@ -65,15 +65,8 @@
#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>
@@ -89,7 +82,7 @@
typedef drm_device_t *device_t;
-extern struct cfdriver DRM(cd);
+extern struct cfdriver drm_cd;
#define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */
@@ -98,6 +91,8 @@ extern struct cfdriver DRM(cd);
#define DRM_DEV_GID 0
#define CDEV_MAJOR 34
+#define __OS_HAS_AGP 1
+
#define DRM_CURPROC curproc
#define DRM_STRUCTPROC struct proc
#define DRM_SPINTYPE struct simplelock
@@ -120,16 +115,16 @@ extern struct cfdriver DRM(cd);
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))
+#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));
+MALLOC_DECLARE(M_DRM);
#else
/* XXX Make sure this works */
-extern const int DRM(M_DRM) = M_DEVBUF;
+extern const int 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_MALLOC(size) malloc(size, M_DRM, M_NOWAIT)
+#define DRM_FREE(pt,size) free(pt, 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) )
@@ -146,7 +141,7 @@ do { \
DRM_ERROR("filp doesn't match curproc\n"); \
return EINVAL; \
} \
- _priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); \
+ _priv = drm_find_file_by_proc(dev, DRM_CURPROC); \
if (_priv == NULL) { \
DRM_ERROR("can't find authenticator\n"); \
return EINVAL; \
@@ -344,13 +339,13 @@ do { \
#define DRM_MEM_ERROR(area, fmt, arg...) \
printf("error: [" DRM_NAME ":%s:%s] *ERROR* " fmt , \
- __func__, DRM(mem_stats)[area].name ,## arg)
+ __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) \
+ if (drm_flags & DRM_FLAG_DEBUG) \
printf("[" DRM_NAME ":%s] " fmt , __FUNCTION__ ,## arg); \
} while (0)
#else
@@ -360,16 +355,16 @@ do { \
/* 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,
+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,
+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);
+extern int drm_sysctl_init(drm_device_t *dev);
+extern int drm_sysctl_cleanup(drm_device_t *dev);
diff --git a/bsd-core/drm_pci.c b/bsd-core/drm_pci.c
index 1d8b593d..07b8a643 100644
--- a/bsd-core/drm_pci.c
+++ b/bsd-core/drm_pci.c
@@ -39,12 +39,12 @@
* memory block.
*/
void *
-DRM(pci_alloc)(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr,
+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,
+ vaddr = contigmalloc(size, M_DRM, M_NOWAIT, 0ul, maxaddr, align,
0);
*busaddr = vtophys(vaddr);
@@ -55,10 +55,10 @@ DRM(pci_alloc)(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr,
* \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)
+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 */
+ contigfree(vaddr, size, M_DRM); /* Not available on 4.x */
#endif
}
diff --git a/bsd-core/drm_scatter.c b/bsd-core/drm_scatter.c
index 13213227..82e6ef9a 100644
--- a/bsd-core/drm_scatter.c
+++ b/bsd-core/drm_scatter.c
@@ -33,21 +33,17 @@
#define DEBUG_SCATTER 0
-#if __REALLY_HAVE_SG
-
-void DRM(sg_cleanup)( drm_sg_mem_t *entry )
+void drm_sg_cleanup(drm_sg_mem_t *entry)
{
- free( entry->virtual, DRM(M_DRM) );
+ free(entry->virtual, M_DRM);
- DRM(free)( entry->busaddr,
+ drm_free(entry->busaddr,
entry->pages * sizeof(*entry->busaddr),
DRM_MEM_PAGES );
- DRM(free)( entry,
- sizeof(*entry),
- DRM_MEM_SGLISTS );
+ drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
}
-int DRM(sg_alloc)( DRM_IOCTL_ARGS )
+int drm_sg_alloc(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_scatter_gather_t request;
@@ -62,7 +58,7 @@ int DRM(sg_alloc)( DRM_IOCTL_ARGS )
DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data,
sizeof(request) );
- entry = DRM(alloc)( sizeof(*entry), DRM_MEM_SGLISTS );
+ entry = drm_alloc(sizeof(*entry), DRM_MEM_SGLISTS);
if ( !entry )
return ENOMEM;
@@ -73,24 +69,20 @@ int DRM(sg_alloc)( DRM_IOCTL_ARGS )
entry->pages = pages;
- entry->busaddr = DRM(alloc)( pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES );
+ entry->busaddr = drm_alloc(pages * sizeof(*entry->busaddr),
+ DRM_MEM_PAGES);
if ( !entry->busaddr ) {
- DRM(free)( entry,
- sizeof(*entry),
- DRM_MEM_SGLISTS );
+ 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 );
+ entry->virtual = malloc(pages << PAGE_SHIFT, M_DRM, M_WAITOK);
if ( !entry->virtual ) {
- DRM(free)( entry->busaddr,
+ drm_free(entry->busaddr,
entry->pages * sizeof(*entry->busaddr),
- DRM_MEM_PAGES );
- DRM(free)( entry,
- sizeof(*entry),
- DRM_MEM_SGLISTS );
+ DRM_MEM_PAGES);
+ drm_free(entry, sizeof(*entry), DRM_MEM_SGLISTS);
return ENOMEM;
}
@@ -111,11 +103,11 @@ int DRM(sg_alloc)( DRM_IOCTL_ARGS )
return 0;
- DRM(sg_cleanup)( entry );
+ drm_sg_cleanup(entry);
return ENOMEM;
}
-int DRM(sg_free)( DRM_IOCTL_ARGS )
+int drm_sg_free(DRM_IOCTL_ARGS)
{
DRM_DEVICE;
drm_scatter_gather_t request;
@@ -132,20 +124,7 @@ int DRM(sg_free)( DRM_IOCTL_ARGS )
DRM_DEBUG( "sg free virtual = %p\n", entry->virtual );
- DRM(sg_cleanup)( entry );
+ 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-core/drm_sysctl.c b/bsd-core/drm_sysctl.c
index 0897c359..41ffcf10 100644
--- a/bsd-core/drm_sysctl.c
+++ b/bsd-core/drm_sysctl.c
@@ -22,46 +22,45 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include "drmP.h"
+#include "drm.h"
+
#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
+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;
+static int drm_bufs_info DRM_SYSCTL_HANDLER_ARGS;
-struct DRM(sysctl_list) {
+struct drm_sysctl_list {
const char *name;
int (*f) DRM_SYSCTL_HANDLER_ARGS;
-} DRM(sysctl_list)[] = {
- { "name", DRM(name_info) },
+} 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) },
+ {"mem", drm_mem_info},
#endif
+ {"vm", drm_vm_info},
+ {"clients", drm_clients_info},
+ {"bufs", drm_bufs_info},
};
-#define DRM_SYSCTL_ENTRIES (sizeof(DRM(sysctl_list))/sizeof(DRM(sysctl_list)[0]))
+#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)
+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);
+ info = drm_alloc(sizeof *info, DRM_MEM_DRIVER);
if ( !info )
return 1;
bzero(info, sizeof *info);
@@ -92,11 +91,11 @@ int DRM(sysctl_init)(drm_device_t *dev)
oid = sysctl_add_oid( &info->ctx,
SYSCTL_CHILDREN(top),
OID_AUTO,
- DRM(sysctl_list)[i].name,
+ drm_sysctl_list[i].name,
CTLTYPE_INT | CTLFLAG_RD,
dev,
0,
- DRM(sysctl_list)[i].f,
+ drm_sysctl_list[i].f,
"A",
NULL);
if (!oid)
@@ -105,12 +104,12 @@ int DRM(sysctl_init)(drm_device_t *dev)
return 0;
}
-int DRM(sysctl_cleanup)(drm_device_t *dev)
+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);
+ drm_free(dev->sysctl, sizeof *dev->sysctl, DRM_MEM_DRIVER);
dev->sysctl = NULL;
return error;
@@ -124,14 +123,14 @@ do { \
goto done; \
} while (0)
-static int DRM(name_info)DRM_SYSCTL_HANDLER_ARGS
+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_SYSCTL_PRINT("%s 0x%x", dev->driver_name, dev2udev(dev->devnode));
DRM_LOCK();
if (dev->unique) {
@@ -149,7 +148,7 @@ done:
return retcode;
}
-static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS
+static int drm_vm_info DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
drm_local_map_t *map, *tempmaps;
@@ -169,7 +168,7 @@ static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS
TAILQ_FOREACH(listentry, dev->maplist, link)
mapcount++;
- tempmaps = DRM(alloc)(sizeof(drm_local_map_t) * mapcount, DRM_MEM_MAPS);
+ tempmaps = drm_alloc(sizeof(drm_local_map_t) * mapcount, DRM_MEM_MAPS);
if (tempmaps == NULL) {
DRM_UNLOCK();
return ENOMEM;
@@ -205,12 +204,11 @@ static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS
SYSCTL_OUT(req, "", 1);
done:
- DRM(free)(tempmaps, sizeof(drm_local_map_t) * mapcount, DRM_MEM_MAPS);
+ 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
+static int drm_bufs_info DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
drm_device_dma_t *dma = dev->dma;
@@ -230,7 +228,7 @@ static int DRM(bufs_info) DRM_SYSCTL_HANDLER_ARGS
}
DRM_SPINLOCK(&dev->dma_lock);
tempdma = *dma;
- templists = DRM(alloc)(sizeof(int) * dma->buf_count, DRM_MEM_BUFS);
+ 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;
@@ -262,12 +260,11 @@ static int DRM(bufs_info) DRM_SYSCTL_HANDLER_ARGS
SYSCTL_OUT(req, "", 1);
done:
- DRM(free)(templists, sizeof(int) * dma->buf_count, DRM_MEM_BUFS);
+ drm_free(templists, sizeof(int) * dma->buf_count, DRM_MEM_BUFS);
return retcode;
}
-#endif
-static int DRM(clients_info)DRM_SYSCTL_HANDLER_ARGS
+static int drm_clients_info DRM_SYSCTL_HANDLER_ARGS
{
drm_device_t *dev = arg1;
drm_file_t *priv, *tempprivs;
@@ -281,7 +278,7 @@ static int DRM(clients_info)DRM_SYSCTL_HANDLER_ARGS
TAILQ_FOREACH(priv, &dev->files, link)
privcount++;
- tempprivs = DRM(alloc)(sizeof(drm_file_t) * privcount, DRM_MEM_FILES);
+ tempprivs = drm_alloc(sizeof(drm_file_t) * privcount, DRM_MEM_FILES);
if (tempprivs == NULL) {
DRM_UNLOCK();
return ENOMEM;
@@ -306,18 +303,18 @@ static int DRM(clients_info)DRM_SYSCTL_HANDLER_ARGS
SYSCTL_OUT(req, "", 1);
done:
- DRM(free)(tempprivs, sizeof(drm_file_t) * privcount, DRM_MEM_FILES);
+ 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)
+int drm_sysctl_init(drm_device_t *dev)
{
return 0;
}
-int DRM(sysctl_cleanup)(drm_device_t *dev)
+int drm_sysctl_cleanup(drm_device_t *dev)
{
return 0;
}
diff --git a/bsd-core/drm_vm.c b/bsd-core/drm_vm.c
index e0d710fa..da6d7773 100644
--- a/bsd-core/drm_vm.c
+++ b/bsd-core/drm_vm.c
@@ -22,13 +22,16 @@
* DEALINGS IN THE SOFTWARE.
*/
+#include "drmP.h"
+#include "drm.h"
+
#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
-static int DRM(dma_mmap)(struct cdev *kdev, vm_offset_t offset,
+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)
+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)
+static paddr_t drm_dma_mmap(dev_t kdev, vm_offset_t offset, int prot)
#endif
{
DRM_DEVICE;
@@ -52,12 +55,12 @@ static paddr_t DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot)
}
#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
-int DRM(mmap)(struct cdev *kdev, vm_offset_t offset, vm_paddr_t *paddr,
+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)
+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)
+paddr_t drm_mmap(dev_t kdev, off_t offset, int prot)
#endif
{
DRM_DEVICE;
@@ -74,9 +77,9 @@ paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot)
&& offset >= 0
&& offset < ptoa(dev->dma->page_count))
#if defined(__FreeBSD__) && __FreeBSD_version >= 500102
- return DRM(dma_mmap)(kdev, offset, paddr, prot);
+ return drm_dma_mmap(kdev, offset, paddr, prot);
#else
- return DRM(dma_mmap)(kdev, offset, prot);
+ return drm_dma_mmap(kdev, offset, prot);
#endif
/* A sequential search of a linked list is
diff --git a/bsd-core/r128_drv.c b/bsd-core/r128_drv.c
index a9af3694..02fbd173 100644
--- a/bsd-core/r128_drv.c
+++ b/bsd-core/r128_drv.c
@@ -30,34 +30,88 @@
*
*/
-#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_pciids.h"
+
+/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
+static drm_pci_id_list_t r128_pciidlist[] = {
+ r128_PCI_IDS
+};
+
+extern drm_ioctl_desc_t r128_ioctls[];
+extern int r128_max_ioctl;
+
+static void r128_configure(drm_device_t *dev)
+{
+ dev->dev_priv_size = sizeof(drm_r128_buf_priv_t);
+ dev->prerelease = r128_driver_prerelease;
+ dev->pretakedown = r128_driver_pretakedown;
+ dev->vblank_wait = r128_driver_vblank_wait;
+ dev->irq_preinstall = r128_driver_irq_preinstall;
+ dev->irq_postinstall = r128_driver_irq_postinstall;
+ dev->irq_uninstall = r128_driver_irq_uninstall;
+ dev->irq_handler = r128_driver_irq_handler;
+ /* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/
+ /* XXX dev->get_map_ofs = drm_core_get_map_ofs;
+ dev->get_reg_ofs = drm_core_get_reg_ofs;*/
+ /* XXX: Postinit inlined into drm_drv
+ dev->postinit = postinit; */
-#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"
+ dev->driver_name = DRIVER_NAME;
+ dev->driver_desc = DRIVER_DESC;
+ dev->driver_date = DRIVER_DATE;
+ dev->driver_major = DRIVER_MAJOR;
+ dev->driver_minor = DRIVER_MINOR;
+ dev->driver_patchlevel = DRIVER_PATCHLEVEL;
+
+ dev->use_agp = 1;
+ dev->use_mtrr = 1;
+ dev->use_pci_dma = 1;
+ dev->use_sg = 1;
+ dev->use_dma = 1;
+ dev->use_irq = 1;
+ dev->use_vbl_irq = 1;
+}
#ifdef __FreeBSD__
-DRIVER_MODULE(r128, pci, r128_driver, r128_devclass, 0, 0);
+static int
+r128_probe(device_t dev)
+{
+ return drm_probe(dev, r128_pciidlist);
+}
+
+static int
+r128_attach(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ bzero(dev, sizeof(drm_device_t));
+ r128_configure(dev);
+ return drm_attach(nbdev, r128_pciidlist);
+}
+
+static device_method_t r128_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, r128_probe),
+ DEVMETHOD(device_attach, r128_attach),
+ DEVMETHOD(device_detach, drm_detach),
+
+ { 0, 0 }
+};
+
+static driver_t r128_driver = {
+ "drm",
+ r128_methods,
+ sizeof(drm_device_t)
+};
+
+extern devclass_t drm_devclass;
+DRIVER_MODULE(r128, pci, r128_driver, drm_devclass, 0, 0);
+MODULE_DEPEND(r128, drm, 1, 1, 1);
+
#elif defined(__NetBSD__)
CFDRIVER_DECL(r128, DV_TTY, NULL);
-#endif /* __FreeBSD__ */
+#endif
diff --git a/bsd-core/radeon_drv.c b/bsd-core/radeon_drv.c
index df941f9e..5f7014e1 100644
--- a/bsd-core/radeon_drv.c
+++ b/bsd-core/radeon_drv.c
@@ -28,34 +28,91 @@
*
*/
-#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"
+#include "drm_pciids.h"
+
+/* drv_PCI_IDs comes from drm_pciids.h, generated from drm_pciids.txt. */
+static drm_pci_id_list_t radeon_pciidlist[] = {
+ radeon_PCI_IDS
+};
+
+extern drm_ioctl_desc_t radeon_ioctls[];
+extern int radeon_max_ioctl;
+
+static void radeon_configure(drm_device_t *dev)
+{
+ dev->dev_priv_size = sizeof(drm_radeon_buf_priv_t);
+ dev->prerelease = radeon_driver_prerelease;
+ dev->pretakedown = radeon_driver_pretakedown;
+ dev->vblank_wait = radeon_driver_vblank_wait;
+ dev->irq_preinstall = radeon_driver_irq_preinstall;
+ dev->irq_postinstall = radeon_driver_irq_postinstall;
+ dev->irq_uninstall = radeon_driver_irq_uninstall;
+ dev->irq_handler = radeon_driver_irq_handler;
+ /* XXX dev->reclaim_buffers = drm_core_reclaim_buffers;*/
+ /* XXX dev->get_map_ofs = drm_core_get_map_ofs;
+ dev->get_reg_ofs = drm_core_get_reg_ofs;*/
+ /* XXX: Postinit inlined into drm_drv
+ dev->postinit = postinit; */
+
+ dev->driver_ioctls = radeon_ioctls;
+ dev->max_driver_ioctl = radeon_max_ioctl;
+
+ dev->driver_name = DRIVER_NAME;
+ dev->driver_desc = DRIVER_DESC;
+ dev->driver_date = DRIVER_DATE;
+ dev->driver_major = DRIVER_MAJOR;
+ dev->driver_minor = DRIVER_MINOR;
+ dev->driver_patchlevel = DRIVER_PATCHLEVEL;
+
+ dev->use_agp = 1;
+ dev->use_mtrr = 1;
+ dev->use_pci_dma = 1;
+ dev->use_sg = 1;
+ dev->use_dma = 1;
+ dev->use_irq = 1;
+ dev->use_vbl_irq = 1;
+}
#ifdef __FreeBSD__
-DRIVER_MODULE(DRIVER_NAME, pci, DRM(driver), DRM(devclass), 0, 0);
+static int
+radeon_probe(device_t dev)
+{
+ return drm_probe(dev, radeon_pciidlist);
+}
+
+static int
+radeon_attach(device_t nbdev)
+{
+ drm_device_t *dev = device_get_softc(nbdev);
+
+ bzero(dev, sizeof(drm_device_t));
+ radeon_configure(dev);
+ return drm_attach(nbdev, radeon_pciidlist);
+}
+
+static device_method_t radeon_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, radeon_probe),
+ DEVMETHOD(device_attach, radeon_attach),
+ DEVMETHOD(device_detach, drm_detach),
+
+ { 0, 0 }
+};
+
+static driver_t radeon_driver = {
+ "drm",
+ radeon_methods,
+ sizeof(drm_device_t)
+};
+
+extern devclass_t drm_devclass;
+DRIVER_MODULE(radeon, pci, radeon_driver, drm_devclass, 0, 0);
+MODULE_DEPEND(radeon, drm, 1, 1, 1);
+
#elif defined(__NetBSD__)
CFDRIVER_DECL(radeon, DV_TTY, NULL);
#endif /* __FreeBSD__ */