summaryrefslogtreecommitdiff
path: root/sys/dev/pci
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/pci')
-rw-r--r--sys/dev/pci/drm/drm_agpsupport.c44
-rw-r--r--sys/dev/pci/drm/drm_bufs.c125
-rw-r--r--sys/dev/pci/drm/drm_context.c8
-rw-r--r--sys/dev/pci/drm/drm_drawable.c14
-rw-r--r--sys/dev/pci/drm/drm_drv.c296
-rw-r--r--sys/dev/pci/drm/drm_fops.c30
-rw-r--r--sys/dev/pci/drm/drm_irq.c101
-rw-r--r--sys/dev/pci/drm/drm_memory.c55
-rw-r--r--sys/dev/pci/drm/drm_pci.c56
-rw-r--r--sys/dev/pci/drm/drm_scatter.c17
10 files changed, 3 insertions, 743 deletions
diff --git a/sys/dev/pci/drm/drm_agpsupport.c b/sys/dev/pci/drm/drm_agpsupport.c
index f81fd56de81..eb1ce1fd1fe 100644
--- a/sys/dev/pci/drm/drm_agpsupport.c
+++ b/sys/dev/pci/drm/drm_agpsupport.c
@@ -35,11 +35,6 @@
#include "drmP.h"
-#ifdef __FreeBSD__
-#include <pci/agpreg.h>
-#include <dev/pci/pcireg.h>
-#endif
-
int drm_device_find_capability(drm_device_t *, int);
struct drm_agp_mem *drm_agp_lookup_entry(drm_device_t *, void *);
@@ -47,47 +42,8 @@ struct drm_agp_mem *drm_agp_lookup_entry(drm_device_t *, void *);
int
drm_device_find_capability(drm_device_t *dev, int cap)
{
-#ifdef __FreeBSD__
-#if __FreeBSD_version >= 602102
-
- return (pci_find_extcap(dev->device, cap, NULL) == 0);
-#else
- /* Code taken from agp.c. IWBNI that was a public interface. */
- u_int32_t status;
- u_int8_t ptr, next;
-
- /*
- * Check the CAP_LIST bit of the PCI status register first.
- */
- status = pci_read_config(dev->device, PCIR_STATUS, 2);
- if (!(status & 0x10))
- return 0;
-
- /*
- * Traverse the capabilities list.
- */
- for (ptr = pci_read_config(dev->device, AGP_CAPPTR, 1);
- ptr != 0; ptr = next) {
- u_int32_t capid = pci_read_config(dev->device, ptr, 4);
- next = AGP_CAPID_GET_NEXT_PTR(capid);
-
- /*
- * If this capability entry ID is cap, then we are done.
- */
- if (AGP_CAPID_GET_CAP_ID(capid) == cap)
- return 1;
- }
-
- return 0;
-#endif
-#else
-#if defined(__NetBSD__) || defined (__OpenBSD__)
return pci_get_capability(dev->pa.pa_pc, dev->pa.pa_tag, cap,
NULL, NULL);
-#endif
- /* XXX: fill me in for non-FreeBSD */
- return 1;
-#endif
}
int
diff --git a/sys/dev/pci/drm/drm_bufs.c b/sys/dev/pci/drm/drm_bufs.c
index ae3a50fb351..4ac51ef6548 100644
--- a/sys/dev/pci/drm/drm_bufs.c
+++ b/sys/dev/pci/drm/drm_bufs.c
@@ -78,24 +78,12 @@ drm_alloc_resource(drm_device_t *dev, int resource)
return 0;
}
-#if defined (__FreeBSD__)
- dev->pcirid[resource] = PCIR_BAR(resource);
- dev->pcir[resource] = bus_alloc_resource_any(dev->device,
- SYS_RES_MEMORY, &dev->pcirid[resource], RF_SHAREABLE);
-
- DRM_LOCK();
- if (dev->pcir[resource] == NULL) {
- DRM_ERROR("Couldn't find resource 0x%x\n", resource);
- return 1;
- }
-#elif defined (__OpenBSD__)
dev->pcir[resource] = vga_pci_bar_info(dev->vga_softc, resource);
DRM_LOCK();
if (dev->pcir[resource] == NULL) {
DRM_ERROR("Can't get bar info for resource 0x%x\n", resource);
return 1;
}
-#endif
return 0;
}
@@ -107,11 +95,7 @@ drm_get_resource_start(drm_device_t *dev, unsigned int resource)
if (drm_alloc_resource(dev, resource) != 0)
return 0;
-#ifdef __FreeBSD__
- return rman_get_start(dev->pcir[resource]);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
return dev->pcir[resource]->base;
-#endif
}
unsigned long
@@ -120,11 +104,7 @@ drm_get_resource_len(drm_device_t *dev, unsigned int resource)
if (drm_alloc_resource(dev, resource) != 0)
return 0;
-#ifdef __FreeBSD__
- return rman_get_size(dev->pcir[resource]);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
return dev->pcir[resource]->maxsize;
-#endif
}
int
@@ -223,32 +203,6 @@ drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
map->mtrr = 1;
#endif
break;
-#ifndef __OpenBSD__
- case _DRM_SHM:
- map->handle = malloc(map->size, M_DRM, M_NOWAIT);
- DRM_DEBUG( "%lu %d %p\n",
- map->size, drm_order(map->size), map->handle );
- if ( !map->handle ) {
- free(map, M_DRM);
- DRM_LOCK();
- return ENOMEM;
- }
- map->offset = (unsigned long)map->handle;
- if ( map->flags & _DRM_CONTAINS_LOCK ) {
- /* Prevent a 2nd X Server from creating a 2nd lock */
- DRM_LOCK();
- if (dev->lock.hw_lock != NULL) {
- DRM_UNLOCK();
- free(map->handle, M_DRM);
- free(map, M_DRM);
- DRM_LOCK();
- return EBUSY;
- }
- dev->lock.hw_lock = map->handle; /* Pointer to lock */
- DRM_UNLOCK();
- }
- break;
-#endif
case _DRM_AGP:
/*valid = 0;*/
/* In some cases (i810 driver), user space may have already
@@ -295,9 +249,7 @@ drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
}
map->offset = map->offset + dev->sg->handle;
break;
-#ifdef __OpenBSD__
case _DRM_SHM:
-#endif
case _DRM_CONSISTENT:
/* Unfortunately, we don't get any alignment specification from
* the caller, so we have to guess. drm_pci_alloc requires
@@ -316,7 +268,6 @@ drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
}
map->handle = map->dmah->vaddr;
map->offset = map->dmah->busaddr;
-#ifdef __OpenBSD__
if (map->type == _DRM_SHM &&
map->flags & _DRM_CONTAINS_LOCK) {
DRM_LOCK();
@@ -331,7 +282,6 @@ drm_addmap(drm_device_t * dev, unsigned long offset, unsigned long size,
dev->lock.hw_lock = map->handle;
DRM_UNLOCK();
}
-#endif
break;
default:
DRM_ERROR("Bad map type %d\n", map->type);
@@ -378,9 +328,6 @@ drm_addmap_ioctl(drm_device_t *dev, void *data, struct drm_file *file_priv)
request->mtrr = map->mtrr;
request->handle = map->handle;
-#ifndef __OpenBSD__
- if (request->type != _DRM_SHM)
-#endif
request->handle = (void *)map->mm->start;
return 0;
@@ -395,10 +342,7 @@ drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
switch (map->type) {
case _DRM_REGISTERS:
-#ifdef __FreeBSD__
- if (map->bsr == NULL)
-#endif
- drm_ioremapfree(map);
+ drm_ioremapfree(map);
/* FALLTHROUGH */
case _DRM_FRAME_BUFFER:
#ifndef DRM_NO_MTRR
@@ -411,17 +355,10 @@ drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
}
#endif
break;
-#ifndef __OpenBSD__
- case _DRM_SHM:
- free(map->handle, M_DRM);
- break;
-#endif
case _DRM_AGP:
case _DRM_SCATTER_GATHER:
break;
-#ifdef __OpenBSD__
case _DRM_SHM:
-#endif
case _DRM_CONSISTENT:
drm_pci_free(dev, map->dmah);
break;
@@ -430,13 +367,6 @@ drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
break;
}
-#ifdef __FreeBSD__
- if (map->bsr != NULL) {
- bus_release_resource(dev->device, SYS_RES_MEMORY, map->rid,
- map->bsr);
- }
-#endif
-
drm_memrange_put_block(map->mm);
free(map, M_DRM);
@@ -605,16 +535,10 @@ drm_do_addbufs_agp(drm_device_t *dev, drm_buf_desc_t *request)
DRM_DEBUG( "byte_count: %d\n", byte_count );
-#if defined(__OpenBSD__)
/* OpenBSD lacks realloc in kernel */
temp_buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM );
-#else
- temp_buflist = realloc(dma->buflist,
- (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
- M_NOWAIT);
-#endif
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
@@ -759,15 +683,9 @@ drm_do_addbufs_pci(drm_device_t *dev, drm_buf_desc_t *request)
byte_count += PAGE_SIZE << page_order;
}
-#if defined(__OpenBSD__)
temp_buflist = drm_realloc( dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM);
-#else
- temp_buflist = realloc(dma->buflist,
- (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
- M_NOWAIT);
-#endif
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
@@ -882,15 +800,9 @@ drm_do_addbufs_sg(drm_device_t *dev, drm_buf_desc_t *request)
DRM_DEBUG( "byte_count: %d\n", byte_count );
-#if defined(__OpenBSD__)
temp_buflist = drm_realloc(dma->buflist,
dma->buf_count * sizeof(*dma->buflist),
(dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM);
-#else
- temp_buflist = realloc(dma->buflist,
- (dma->buf_count + entry->buf_count) * sizeof(*dma->buflist), M_DRM,
- M_NOWAIT);
-#endif
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
drm_cleanup_buf_error(dev, entry);
@@ -1157,33 +1069,18 @@ drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
const int zero = 0;
vm_offset_t address;
struct vmspace *vms;
-#ifdef __FreeBSD__
- vm_ooffset_t foff;
- vm_size_t size;
- vm_offset_t vaddr;
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
struct vnode *vn;
voff_t foff;
vsize_t size;
-#ifdef __NetBSD__
- vsize_t rsize;
-#endif
vaddr_t vaddr;
-#endif /* __NetBSD__ || __OpenBSD__ */
drm_buf_map_t *request = data;
int i;
-#if defined(__NetBSD__) || defined(__OpenBSD__)
if (!vfinddev(dev->kdev, VCHR, &vn))
return EINVAL;
-#endif /* __NetBSD__ || __OpenBSD__ */
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
- vms = DRM_CURPROC->td_proc->p_vmspace;
-#else
vms = DRM_CURPROC->p_vmspace;
-#endif
DRM_SPINLOCK(&dev->dma_lock);
dev->buf_use++; /* Can't allocate more after this call */
@@ -1208,30 +1105,10 @@ drm_mapbufs(drm_device_t *dev, void *data, struct drm_file *file_priv)
foff = 0;
}
-#ifdef __FreeBSD__
- vaddr = round_page((vm_offset_t)vms->vm_daddr + MAXDSIZ);
-#if __FreeBSD_version >= 600023
- retcode = vm_mmap(&vms->vm_map, &vaddr, size, PROT_READ | PROT_WRITE,
- VM_PROT_ALL, MAP_SHARED, OBJT_DEVICE, dev->devnode, foff);
-#else
- retcode = vm_mmap(&vms->vm_map, &vaddr, size, PROT_READ | PROT_WRITE,
- VM_PROT_ALL, MAP_SHARED, SLIST_FIRST(&dev->devnode->si_hlist),
- foff);
-#endif
-#elif defined(__NetBSD__)
- vaddr = p->l_proc->p_emul->e_vm_default_addr(p->l_proc,
- (vaddr_t)vms->vm_daddr, size);
- rsize = round_page(size);
- DRM_DEBUG("mmap %lx/%ld\n", vaddr, rsize);
- retcode = uvm_mmap(&vms->vm_map, &vaddr, rsize,
- UVM_PROT_READ | UVM_PROT_WRITE, UVM_PROT_ALL, MAP_SHARED,
- &vn->v_uobj, foff, p->l_proc->p_rlimit[RLIMIT_MEMLOCK].rlim_cur);
-#else /* __OpenBSD__ */
vaddr = round_page((vaddr_t)vms->vm_daddr + MAXDSIZ);
retcode = uvm_mmap(&vms->vm_map, &vaddr, size,
UVM_PROT_READ | UVM_PROT_WRITE, UVM_PROT_ALL, MAP_SHARED,
(caddr_t)vn, foff, DRM_CURPROC->p_rlimit[RLIMIT_MEMLOCK].rlim_cur,DRM_CURPROC);
-#endif /* __NetBSD__ || __OpenBSD__ */
if (retcode) {
DRM_DEBUG("uvm_mmap failed\n");
goto done;
diff --git a/sys/dev/pci/drm/drm_context.c b/sys/dev/pci/drm/drm_context.c
index cb0516205ae..0813bf1907f 100644
--- a/sys/dev/pci/drm/drm_context.c
+++ b/sys/dev/pci/drm/drm_context.c
@@ -73,22 +73,14 @@ drm_ctxbitmap_next(drm_device_t *dev)
set_bit(bit, dev->ctx_bitmap);
DRM_DEBUG("drm_ctxbitmap_next bit : %d\n", bit);
if ((bit+1) > dev->max_context) {
-#if defined(__OpenBSD__)
int old_context = dev->max_context;
-#endif
dev->max_context = (bit+1);
if (dev->context_sareas != NULL) {
drm_local_map_t **ctx_sareas;
-#if defined(__OpenBSD__)
ctx_sareas = drm_realloc(dev->context_sareas,
old_context * sizeof(*dev->context_sareas),
dev->max_context * sizeof(*dev->context_sareas), M_DRM);
-#else
- ctx_sareas = realloc(dev->context_sareas,
- dev->max_context * sizeof(*dev->context_sareas),
- M_DRM, M_NOWAIT);
-#endif
if (ctx_sareas == NULL) {
clear_bit(bit, dev->ctx_bitmap);
DRM_UNLOCK();
diff --git a/sys/dev/pci/drm/drm_drawable.c b/sys/dev/pci/drm/drm_drawable.c
index fb4ae3f0690..5b8a42b7a3a 100644
--- a/sys/dev/pci/drm/drm_drawable.c
+++ b/sys/dev/pci/drm/drm_drawable.c
@@ -44,10 +44,8 @@ void drm_drawable_free(struct drm_device *dev,
struct bsd_drm_drawable_info *
drm_get_drawable(struct drm_device *, unsigned int);
-#ifdef __OpenBSD__
RB_PROTOTYPE(drawable_tree, bsd_drm_drawable_info, tree,
drm_drawable_compare);
-#endif /* __OpenBSD__ */
struct bsd_drm_drawable_info {
struct drm_drawable_info info;
@@ -66,13 +64,8 @@ drm_drawable_compare(struct bsd_drm_drawable_info *a,
return 0;
};
-#ifdef __FreeBSD__
-RB_GENERATE_STATIC(drawable_tree, bsd_drm_drawable_info, tree,
- drm_drawable_compare);
-#else
RB_GENERATE(drawable_tree, bsd_drm_drawable_info, tree,
drm_drawable_compare);
-#endif
struct bsd_drm_drawable_info *
drm_get_drawable(struct drm_device *dev, unsigned int handle)
@@ -105,11 +98,7 @@ drm_adddraw(drm_device_t *dev, void *data, struct drm_file *file_priv)
if (info == NULL)
return ENOMEM;
-#ifdef __FreeBSD__
- info->handle = alloc_unr(dev->drw_unrhdr);
-#else
info->handle = ++dev->drw_no;
-#endif
DRM_SPINLOCK(&dev->drw_lock);
RB_INSERT(drawable_tree, &dev->drw_head, info);
draw->handle = info->handle;
@@ -192,9 +181,6 @@ drm_drawable_free(struct drm_device *dev, struct bsd_drm_drawable_info *draw)
drm_free(draw->info.rects,
sizeof(*draw->info.rects) * draw->info.num_rects,
DRM_MEM_DRAWABLE);
-#ifdef __FreeBSD__
- free_unr(dev->drw_unrhdr, draw->info->handle);
-#endif
drm_free(draw, sizeof(*draw),
DRM_MEM_DRAWABLE);
}
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index 8b11eb8145d..e5d64077e56 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -37,9 +37,7 @@
#include "drmP.h"
#include "drm.h"
#include "drm_sarea.h"
-#ifdef __OpenBSD__
#include <sys/ttycom.h> /* for TIOCSGRP */
-#endif
#ifdef DRM_DEBUG_DEFAULT_ON
int drm_debug_flag = 1;
@@ -54,15 +52,6 @@ drm_pci_id_list_t *drm_find_description(int , int ,
int drm_firstopen(drm_device_t *);
int drm_lastclose(drm_device_t *);
-#ifdef __FreeBSD__
-MODULE_VERSION(drm, 1);
-MODULE_DEPEND(drm, agp, 1, 1, 1);
-MODULE_DEPEND(drm, pci, 1, 1, 1);
-#if __FreeBSD_version > 502127
-MODULE_DEPEND(drm, mem, 1, 1, 1);
-#endif
-#endif /* __FreeBSD__ */
-
static drm_ioctl_desc_t drm_ioctls[256] = {
DRM_IOCTL_DEF(DRM_IOCTL_VERSION, drm_version, 0),
DRM_IOCTL_DEF(DRM_IOCTL_GET_UNIQUE, drm_getunique, 0),
@@ -125,124 +114,6 @@ static drm_ioctl_desc_t drm_ioctls[256] = {
DRM_IOCTL_DEF(DRM_IOCTL_UPDATE_DRAW, drm_update_draw, DRM_AUTH|DRM_MASTER|DRM_ROOT_ONLY),
};
-#ifdef __FreeBSD__
-static struct cdevsw drm_cdevsw = {
-#if __FreeBSD_version >= 502103
- .d_version = D_VERSION,
-#endif
- .d_open = drm_open,
- .d_close = drm_close,
- .d_read = drm_read,
- .d_ioctl = drm_ioctl,
- .d_poll = drm_poll,
- .d_mmap = drm_mmap,
- .d_name = "drm",
-#if __FreeBSD_version >= 502103
- .d_flags = D_TRACKCLOSE | D_NEEDGIANT,
-#else
- .d_maj = 145,
- .d_flags = D_TRACKCLOSE,
-#endif
-#if __FreeBSD_version < 500000
- .d_bmaj = -1
-#endif
-};
-
-int
-drm_probe(device_t dev, drm_pci_id_list_t *idlist)
-{
- drm_pci_id_list_t *id_entry;
- int vendor, device;
-#if __FreeBSD_version < 700010
- device_t realdev;
-
- if (!strcmp(device_get_name(dev), "drmsub"))
- realdev = device_get_parent(dev);
- else
- realdev = dev;
- vendor = pci_get_vendor(realdev);
- device = pci_get_device(realdev);
-#else
- vendor = pci_get_vendor(dev);
- device = pci_get_device(dev);
-#endif
-
- id_entry = drm_find_description(vendor, device, idlist);
- if (id_entry != NULL) {
- device_set_desc(dev, id_entry->name);
- return 0;
- }
-
- return ENXIO;
-}
-
-int
-drm_attach(device_t nbdev, drm_pci_id_list_t *idlist)
-{
- drm_device_t *dev;
- drm_pci_id_list_t *id_entry;
- int unit;
-
- unit = device_get_unit(nbdev);
- dev = device_get_softc(nbdev);
-
-#if __FreeBSD_version < 700010
- if (!strcmp(device_get_name(nbdev), "drmsub"))
- dev->device = device_get_parent(nbdev);
- else
- dev->device = nbdev;
-#else
- dev->device = nbdev;
-#endif
- dev->devnode = make_dev(&drm_cdevsw,
- unit,
- DRM_DEV_UID,
- DRM_DEV_GID,
- DRM_DEV_MODE,
- "dri/card%d", unit);
-#if __FreeBSD_version >= 500000
- mtx_init(&dev->dev_lock, "drm device", NULL, MTX_DEF);
- mtx_init(&dev->drw_lock, "drmdrw", NULL, MTX_DEF);
-#endif
-
- id_entry = drm_find_description(pci_get_vendor(dev->device),
- pci_get_device(dev->device), idlist);
- dev->id_entry = id_entry;
-
- return drm_load(dev);
-}
-
-int
-drm_detach(device_t dev)
-{
- drm_unload(device_get_softc(dev));
- return 0;
-}
-
-#ifndef DRM_DEV_NAME
-#define DRM_DEV_NAME "drm"
-#endif
-
-devclass_t drm_devclass;
-
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
-
-#if defined(__NetBSD__)
-static struct cdevsw drm_cdevsw = {
- drm_open,
- drm_close,
- drm_read,
- nowrite,
- drm_ioctl,
- nostop,
- notty,
- drm_poll,
- drm_mmap,
- nokqfilter,
- D_TTY
-};
-#endif
-
drm_device_t *drm_units[DRM_MAXUNITS];
static int init_units = 1;
@@ -331,7 +202,6 @@ drm_activate(struct device *self, enum devact act)
}
return (0);
}
-#endif /* __NetBSD__ || __OpenBSD__ */
drm_pci_id_list_t *
drm_find_description(int vendor, int device, drm_pci_id_list_t *idlist)
@@ -391,11 +261,7 @@ drm_firstopen(drm_device_t *dev)
dev->last_context = 0;
dev->if_version = 0;
-#ifdef __FreeBSD__
- dev->buf_sigio = NULL;
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
dev->buf_pgid = 0;
-#endif
DRM_DEBUG( "\n" );
@@ -457,13 +323,9 @@ drm_lastclose(drm_device_t *dev)
dev->sg = NULL;
}
-#ifdef __FreeBSD__
- TAILQ_FOREACH_SAFE(map, &dev->maplist, link, mapsave) {
-#else
for (map = TAILQ_FIRST(&dev->maplist); map != TAILQ_END(&dev->maplist);
map = mapsave) {
mapsave = TAILQ_NEXT(map, link);
-#endif
if (!(map->flags & _DRM_DRIVER))
drm_rmmap(dev, map);
}
@@ -485,20 +347,6 @@ drm_load(drm_device_t *dev)
DRM_DEBUG( "\n" );
-#ifdef __FreeBSD__
- dev->irq = pci_get_irq(dev->device);
-#if defined(__FreeBSD__) && __FreeBSD_version >= 700053
- dev->pci_domain = pci_get_domain(dev->device);
-#else
- dev->pci_domain = 0;
-#endif
- dev->pci_bus = pci_get_bus(dev->device);
- dev->pci_slot = pci_get_slot(dev->device);
- dev->pci_func = pci_get_function(dev->device);
-
- dev->pci_vendor = pci_get_vendor(dev->device);
- dev->pci_device = pci_get_device(dev->device);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
dev->irq = dev->pa.pa_intrline;
dev->pci_domain = 0;
dev->pci_bus = dev->pa.pa_bus;
@@ -507,14 +355,10 @@ drm_load(drm_device_t *dev)
dev->pci_vendor = PCI_VENDOR(dev->pa.pa_id);
dev->pci_device = PCI_PRODUCT(dev->pa.pa_id);
-#endif
TAILQ_INIT(&dev->maplist);
drm_mem_init();
-#ifdef __FreeBSD__
- drm_sysctl_init(dev);
-#endif
TAILQ_INIT(&dev->files);
/*
@@ -560,13 +404,6 @@ drm_load(drm_device_t *dev)
DRM_ERROR("Cannot allocate memory for context bitmap.\n");
goto error;
}
-#ifdef __FreeBSD__
- dev->drw_unrhdr = new_unrhdr(1, INT_MAX, NULL);
- if (dev->drw_unrhdr == NULL) {
- DRM_ERROR("Couldn't allocate drawable number allocator\n");
- goto error;
- }
-#endif
DRM_INFO("Initialized %s %d.%d.%d %s\n",
dev->driver.name,
dev->driver.major,
@@ -581,9 +418,6 @@ error:
DRM_LOCK();
drm_lastclose(dev);
DRM_UNLOCK();
-#ifdef __FreeBSD__
- destroy_dev(dev->devnode);
-#endif
DRM_SPINUNINIT(&dev->dev_lock);
return retcode;
}
@@ -591,13 +425,6 @@ error:
void
drm_unload(drm_device_t *dev)
{
-#ifdef __FreeBSD__
- int i;
-
-
- drm_sysctl_cleanup(dev);
- destroy_dev(dev->devnode);
-#endif
DRM_DEBUG( "\n" );
@@ -619,21 +446,6 @@ drm_unload(drm_device_t *dev)
drm_lastclose(dev);
DRM_UNLOCK();
- /* Clean up PCI resources allocated by drm_bufs.c. We're not really
- * worried about resource consumption while the DRM is inactive (between
- * lastclose and firstopen or unload) because these aren't actually
- * taking up KVA, just keeping the PCI resource allocated.
- */
-#ifdef __FreeBSD__
- for (i = 0; i < DRM_MAX_PCI_RESOURCE; i++) {
- if (dev->pcir[i] == NULL)
- continue;
- bus_release_resource(dev->device, SYS_RES_MEMORY,
- dev->pcirid[i], dev->pcir[i]);
- dev->pcir[i] = NULL;
- }
-#endif
-
if ( dev->agp ) {
free(dev->agp, M_DRM);
dev->agp = NULL;
@@ -642,11 +454,6 @@ drm_unload(drm_device_t *dev)
if (dev->driver.unload != NULL)
dev->driver.unload(dev);
-#ifdef __FreeBSD__
- delete_unrhdr(dev->drw_unrhdr);
-
-#endif
-
drm_mem_uninit();
DRM_SPINUNINIT(&dev->dev_lock);
}
@@ -688,9 +495,7 @@ drm_open(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
if (dev == NULL)
return (ENXIO);
-#ifdef __OpenBSD__
dev->kdev = kdev; /* hack for now */
-#endif
DRM_DEBUG( "open_count = %d\n", dev->open_count );
@@ -699,9 +504,6 @@ drm_open(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
if ( !retcode ) {
atomic_inc( &dev->counts[_DRM_STAT_OPENS] );
DRM_LOCK();
-#ifdef __FreeBSD__
- device_busy(dev->device);
-#endif
if ( !dev->open_count++ )
retcode = drm_firstopen(dev);
DRM_UNLOCK();
@@ -721,11 +523,7 @@ drm_close(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
DRM_LOCK();
-#ifdef __OpenBSD__
file_priv = drm_find_file_by_minor(dev, minor(kdev));
-#else
- file_priv = drm_find_file_by_proc(dev, p);
-#endif
if (!file_priv) {
DRM_UNLOCK();
DRM_ERROR("can't find authenticator\n");
@@ -743,13 +541,8 @@ drm_close(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
* Begin inline drm_release
*/
-#ifdef __FreeBSD__
- DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
- DRM_CURRENTPID, (long)dev->device, dev->open_count );
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n",
DRM_CURRENTPID, (long)&dev->device, dev->open_count);
-#endif
if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)
&& dev->lock.file_priv == file_priv) {
@@ -798,13 +591,7 @@ drm_close(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
if (dev->driver.use_dma && !dev->driver.reclaim_buffers_locked)
drm_reclaim_buffers(dev, file_priv);
-#if defined (__FreeBSD__) && (__FreeBSD_version >= 500000)
- funsetown(&dev->buf_sigio);
-#elif defined(__FreeBSD__)
- funsetown(dev->buf_sigio);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
dev->buf_pgid = 0;
-#endif /* __NetBSD__ || __OpenBSD__ */
if (dev->driver.postclose != NULL)
dev->driver.postclose(dev, file_priv);
@@ -817,9 +604,6 @@ drm_close(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p)
done:
atomic_inc( &dev->counts[_DRM_STAT_CLOSES] );
-#ifdef __FreeBSD__
- device_unbusy(dev->device);
-#endif
if (--dev->open_count == 0) {
retcode = drm_lastclose(dev);
}
@@ -847,11 +631,7 @@ drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags,
return ENODEV;
DRM_LOCK();
-#ifdef __OpenBSD__
file_priv = drm_find_file_by_minor(dev, minor(kdev));
-#else
- file_priv = drm_find_file_by_proc(dev, p);
-#endif
DRM_UNLOCK();
if (file_priv == NULL) {
DRM_ERROR("can't find authenticator\n");
@@ -861,44 +641,15 @@ drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags,
atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] );
++file_priv->ioctl_count;
-#ifdef __FreeBSD__
- DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
- DRM_CURRENTPID, cmd, nr, (long)dev->device,
- file_priv->authenticated );
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n",
DRM_CURRENTPID, cmd, nr, (long)&dev->device,
file_priv->authenticated );
-#endif
switch (cmd) {
case FIONBIO:
case FIOASYNC:
return 0;
-#ifdef __FreeBSD__
- case FIOSETOWN:
- return fsetown(*(int *)data, &dev->buf_sigio);
-
- case FIOGETOWN:
-#if (__FreeBSD_version >= 500000)
- *(int *) data = fgetown(&dev->buf_sigio);
-#else
- *(int *) data = fgetown(dev->buf_sigio);
-#endif
- return 0;
-#endif /* __FreeBSD__ */
-#if defined(__NetBSD__)
- case SIOCSPGRP:
- case TIOCSPGRP:
- case FIOSETOWN:
- return fsetown(p->l_proc, &dev->buf_pgid, cmd, data);
-
- case SIOCGPGRP:
- case TIOCGPGRP:
- case FIOGETOWN:
- return fgetown(p->l_proc, dev->buf_pgid, cmd, data);
-#elif defined(__OpenBSD__)
case TIOCSPGRP:
dev->buf_pgid = *(int *)data;
return 0;
@@ -906,7 +657,6 @@ drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags,
case TIOCGPGRP:
*(int *)data = dev->buf_pgid;
return 0;
-#endif /* __NetBSD__ */
}
if (IOCGROUP(cmd) != DRM_IOCTL_BASE) {
@@ -934,18 +684,12 @@ drm_ioctl(DRM_CDEV kdev, u_long cmd, caddr_t data, int flags,
return EINVAL;
}
-#ifdef __OpenBSD__
/*
* master must be root, and all ioctls that are ROOT_ONLY are
* also DRM_MASTER.
*/
if (((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) ||
((ioctl->flags & DRM_MASTER) && !file_priv->master))
-#else
- if (((ioctl->flags & DRM_ROOT_ONLY) && !DRM_SUSER(p)) ||
- ((ioctl->flags & DRM_AUTH) && !file_priv->authenticated) ||
- ((ioctl->flags & DRM_MASTER) && !file_priv->master))
-#endif
return EACCES;
if (is_driver_ioctl) {
@@ -976,43 +720,3 @@ drm_getsarea(drm_device_t *dev)
return NULL;
}
-
-#if DRM_LINUX
-
-#include <sys/sysproto.h>
-
-MODULE_DEPEND(DRIVER_NAME, linux, 1, 1, 1);
-
-#define LINUX_IOCTL_DRM_MIN 0x6400
-#define LINUX_IOCTL_DRM_MAX 0x64ff
-
-static linux_ioctl_function_t drm_linux_ioctl;
-static struct linux_ioctl_handler drm_handler = {drm_linux_ioctl,
- LINUX_IOCTL_DRM_MIN, LINUX_IOCTL_DRM_MAX};
-
-SYSINIT(drm_register, SI_SUB_KLD, SI_ORDER_MIDDLE,
- linux_ioctl_register_handler, &drm_handler);
-SYSUNINIT(drm_unregister, SI_SUB_KLD, SI_ORDER_MIDDLE,
- linux_ioctl_unregister_handler, &drm_handler);
-
-/* The bits for in/out are switched on Linux */
-#define LINUX_IOC_IN IOC_OUT
-#define LINUX_IOC_OUT IOC_IN
-
-static int
-drm_linux_ioctl(DRM_STRUCTPROC *p, struct linux_ioctl_args* args)
-{
- int error;
- int cmd = args->cmd;
-
- args->cmd &= ~(LINUX_IOC_IN | LINUX_IOC_OUT);
- if (cmd & LINUX_IOC_IN)
- args->cmd |= IOC_IN;
- if (cmd & LINUX_IOC_OUT)
- args->cmd |= IOC_OUT;
-
- error = ioctl(p, (struct ioctl_args *)args);
-
- return error;
-}
-#endif /* DRM_LINUX */
diff --git a/sys/dev/pci/drm/drm_fops.c b/sys/dev/pci/drm/drm_fops.c
index 6c7334eb727..3dcff9d8700 100644
--- a/sys/dev/pci/drm/drm_fops.c
+++ b/sys/dev/pci/drm/drm_fops.c
@@ -36,8 +36,6 @@
#include "drmP.h"
-#ifdef __OpenBSD__
-
drm_file_t *
drm_find_file_by_minor(struct drm_device *dev, int minor)
{
@@ -51,25 +49,6 @@ drm_find_file_by_minor(struct drm_device *dev, int minor)
return (NULL);
}
-#else
-
-drm_file_t *
-drm_find_file_by_proc(drm_device_t *dev, DRM_STRUCTPROC *p)
-{
- uid_t uid = DRM_UID(p);
- pid_t pid = DRM_PID(p);
-
- drm_file_t *priv;
-
- DRM_SPINLOCK_ASSERT(&dev->dev_lock);
-
- TAILQ_FOREACH(priv, &dev->files, link)
- if (priv->pid == pid && priv->uid == uid)
- return priv;
- return NULL;
-}
-#endif
-
/* drm_open_helper is called whenever a process opens /dev/drm. */
int
drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p,
@@ -86,11 +65,7 @@ drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p,
DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m);
DRM_LOCK();
-#ifdef __OpenBSD__
priv = drm_find_file_by_minor(dev, m);
-#else
- priv = drm_find_file_by_proc(dev, p);
-#endif
if (priv) {
priv->refs++;
} else {
@@ -120,22 +95,17 @@ drm_open_helper(DRM_CDEV kdev, int flags, int fmt, DRM_STRUCTPROC *p,
}
/* first opener automatically becomes master if root */
-#ifdef __OpenBSD__
if (TAILQ_EMPTY(&dev->files) && !DRM_SUSER(p)) {
free(priv, M_DRM);
DRM_UNLOCK();
return (EPERM);
}
-#endif
priv->master = TAILQ_EMPTY(&dev->files);
TAILQ_INSERT_TAIL(&dev->files, priv, link);
}
DRM_UNLOCK();
-#ifdef __FreeBSD__
- kdev->si_drv1 = dev;
-#endif
return 0;
}
diff --git a/sys/dev/pci/drm/drm_irq.c b/sys/dev/pci/drm/drm_irq.c
index 1c3e60089f0..721a44893d6 100644
--- a/sys/dev/pci/drm/drm_irq.c
+++ b/sys/dev/pci/drm/drm_irq.c
@@ -37,12 +37,7 @@
irqreturn_t drm_irq_handler_wrap(DRM_IRQ_ARGS);
void vblank_disable(void *);
-
-#ifdef __OpenBSD__
void drm_locked_task(void *context, void *pending);
-#else
-void drm_locked_task(void *context, int pending __unused);
-#endif
int
drm_irq_by_busid(drm_device_t *dev, void *data, struct drm_file *file_priv)
@@ -63,36 +58,6 @@ drm_irq_by_busid(drm_device_t *dev, void *data, struct drm_file *file_priv)
return 0;
}
-#if defined(__FreeBSD__) && __FreeBSD_version >= 500000
-static irqreturn_t
-drm_irq_handler_wrap(DRM_IRQ_ARGS)
-{
- drm_device_t *dev = (drm_device_t *)arg;
-
- DRM_SPINLOCK(&dev->irq_lock);
- dev->driver.irq_handler(arg);
- DRM_SPINUNLOCK(&dev->irq_lock);
-}
-#endif
-
-#ifdef __NetBSD__
-static irqreturn_t
-drm_irq_handler_wrap(DRM_IRQ_ARGS)
-{
- int s;
- irqreturn_t ret;
- drm_device_t *dev = (drm_device_t *)arg;
-
- s = spldrm();
- DRM_SPINLOCK(&dev->irq_lock);
- ret = dev->driver.irq_handler(arg);
- DRM_SPINUNLOCK(&dev->irq_lock);
- splx(s);
- return ret;
-}
-#endif
-
-#ifdef __OpenBSD__
irqreturn_t
drm_irq_handler_wrap(DRM_IRQ_ARGS)
{
@@ -105,16 +70,13 @@ drm_irq_handler_wrap(DRM_IRQ_ARGS)
return ret;
}
-#endif
int
drm_irq_install(drm_device_t *dev)
{
int retcode;
-#if defined(__NetBSD__) || defined(__OpenBSD__)
pci_intr_handle_t ih;
const char *istr;
-#endif
if (dev->irq == 0 || dev->dev_private == NULL)
return EINVAL;
@@ -130,76 +92,36 @@ drm_irq_install(drm_device_t *dev)
dev->context_flag = 0;
-#ifdef __OpenBSD__
mtx_init(&dev->irq_lock, IPL_BIO);
-#else
- DRM_SPININIT(&dev->irq_lock, "DRM IRQ lock");
-#endif
/* Before installing handler */
dev->driver.irq_preinstall(dev);
DRM_UNLOCK();
/* Install handler */
-#ifdef __FreeBSD__
- dev->irqrid = 0;
- dev->irqr = bus_alloc_resource_any(dev->device, SYS_RES_IRQ,
- &dev->irqrid, RF_SHAREABLE);
- if (!dev->irqr) {
- retcode = ENOENT;
- goto err;
- }
-#if __FreeBSD_version >= 700031
- retcode = bus_setup_intr(dev->device, dev->irqr,
- INTR_TYPE_TTY | INTR_MPSAFE,
- NULL, drm_irq_handler_wrap, dev, &dev->irqh);
-#else
- retcode = bus_setup_intr(dev->device, dev->irqr,
- INTR_TYPE_TTY | INTR_MPSAFE,
- drm_irq_handler_wrap, dev, &dev->irqh);
-#endif
- if (retcode != 0)
- goto err;
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
if (pci_intr_map(&dev->pa, &ih) != 0) {
retcode = ENOENT;
goto err;
}
istr = pci_intr_string(dev->pa.pa_pc, ih);
-#if defined(__OpenBSD__)
dev->irqh = pci_intr_establish(dev->pa.pa_pc, ih, IPL_BIO,
drm_irq_handler_wrap, dev,
dev->device.dv_xname);
-#else
- dev->irqh = pci_intr_establish(dev->pa.pa_pc, ih, IPL_BIO,
- drm_irq_handler_wrap, dev);
-#endif
if (!dev->irqh) {
retcode = ENOENT;
goto err;
}
DRM_DEBUG("%s: interrupting at %s\n", dev->device.dv_xname, istr);
-#endif
/* After installing handler */
DRM_LOCK();
dev->driver.irq_postinstall(dev);
DRM_UNLOCK();
-#ifdef __FreeBSD__
- TASK_INIT(&dev->locked_task, 0, drm_locked_task, dev);
-#endif
return 0;
err:
DRM_LOCK();
dev->irq_enabled = 0;
-#ifdef ___FreeBSD__
- if (dev->irqrid != 0) {
- bus_release_resource(dev->device, SYS_RES_IRQ, dev->irqrid,
- dev->irqr);
- dev->irqrid = 0;
- }
-#endif
DRM_SPINUNINIT(&dev->irq_lock);
DRM_UNLOCK();
return retcode;
@@ -208,31 +130,18 @@ err:
int
drm_irq_uninstall(drm_device_t *dev)
{
-#ifdef __FreeBSD__
- int irqrid;
-#endif
if (!dev->irq_enabled)
return EINVAL;
dev->irq_enabled = 0;
-#ifdef __FreeBSD__
- irqrid = dev->irqrid;
- dev->irqrid = 0;
-#endif
DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, dev->irq );
dev->driver.irq_uninstall(dev);
-#ifdef __FreeBSD__
- DRM_UNLOCK();
- bus_teardown_intr(dev->device, dev->irqr, dev->irqh);
- bus_release_resource(dev->device, SYS_RES_IRQ, irqrid, dev->irqr);
- DRM_LOCK();
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
pci_intr_disestablish(dev->pa.pa_pc, dev->irqh);
-#endif
+
drm_vblank_cleanup(dev);
DRM_SPINUNINIT(&dev->irq_lock);
@@ -606,11 +515,7 @@ drm_handle_vblank(struct drm_device *dev, int crtc)
}
void
-#ifdef __OpenBSD__
drm_locked_task(void *context, void *pending)
-#else
-drm_locked_task(void *context, int pending __unused)
-#endif
{
drm_device_t *dev = context;
@@ -646,10 +551,6 @@ void
drm_locked_tasklet(drm_device_t *dev, void (*tasklet)(drm_device_t *dev))
{
dev->locked_task_call = tasklet;
-#ifdef __FreeBSD__
- taskqueue_enqueue(taskqueue_swi, &dev->locked_task);
-#else
if (workq_add_task(NULL, 0, drm_locked_task, dev, NULL) == ENOMEM)
DRM_ERROR("error adding task to workq\n");
-#endif
}
diff --git a/sys/dev/pci/drm/drm_memory.c b/sys/dev/pci/drm/drm_memory.c
index 5900b431d17..8562b83068e 100644
--- a/sys/dev/pci/drm/drm_memory.c
+++ b/sys/dev/pci/drm/drm_memory.c
@@ -38,18 +38,9 @@
#include "drmP.h"
-#ifndef __OpenBSD__
-MALLOC_DEFINE(M_DRM, "drm", "DRM Data Structures");
-#endif
-
void
drm_mem_init(void)
{
-#if defined(__NetBSD__)
-/*
- malloc_type_attach(M_DRM);
-*/
-#endif
}
void
@@ -94,9 +85,6 @@ drm_free(void *pt, size_t size, int area)
void *
drm_ioremap(drm_device_t *dev, drm_local_map_t *map)
{
-#ifdef __FreeBSD__
- return pmap_mapdev(map->offset, map->size);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
struct vga_pci_bar *bar = NULL;
int i;
@@ -140,23 +128,17 @@ drm_ioremap(drm_device_t *dev, drm_local_map_t *map)
done:
/* handles are still supposed to be kernel virtual addresses */
return bus_space_vaddr(map->bst, map->bsh);
-#endif
}
void
drm_ioremapfree(drm_local_map_t *map)
{
-#ifdef __FreeBSD__
- pmap_unmapdev((vm_offset_t) map->handle, map->size);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
if (map != NULL && map->bsr != NULL)
vga_pci_bar_unmap(map->bsr);
else
bus_space_unmap(map->bst, map->bsh, map->size);
-#endif
}
-#if defined(__FreeBSD__) || defined(__OpenBSD__)
int
drm_mtrr_add(unsigned long offset, size_t size, int flags)
{
@@ -192,40 +174,3 @@ drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
return 0;
#endif
}
-#elif defined(__NetBSD__)
-int
-drm_mtrr_add(unsigned long offset, size_t size, int flags)
-{
-#ifndef DRM_NO_MTRR
- struct mtrr mtrrmap;
- int one = 1;
-
- DRM_DEBUG("offset=%lx size=%ld\n", (long)offset, (long)size);
- mtrrmap.base = offset;
- mtrrmap.len = size;
- mtrrmap.type = flags;
- mtrrmap.flags = MTRR_VALID;
- return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-#else
- return 0;
-#endif
-}
-
-int
-drm_mtrr_del(int __unused handle, unsigned long offset, size_t size, int flags)
-{
-#ifndef DRM_NO_MTRR
- struct mtrr mtrrmap;
- int one = 1;
-
- DRM_DEBUG("offset=%lx size=%ld\n", (long)offset, (long)size);
- mtrrmap.base = offset;
- mtrrmap.len = size;
- mtrrmap.type = flags;
- mtrrmap.flags = 0;
- return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-#else
- return 0;
-#endif
-}
-#endif
diff --git a/sys/dev/pci/drm/drm_pci.c b/sys/dev/pci/drm/drm_pci.c
index 4adcd27e9c1..c988c7917e8 100644
--- a/sys/dev/pci/drm/drm_pci.c
+++ b/sys/dev/pci/drm/drm_pci.c
@@ -34,20 +34,6 @@
/** \name PCI memory */
/*@{*/
-#if defined(__FreeBSD__)
-static void
-drm_pci_busdma_callback(void *arg, bus_dma_segment_t *segs, int nsegs, int error)
-{
- drm_dma_handle_t *dmah = arg;
-
- if (error != 0)
- return;
-
- KASSERT(nsegs == 1, ("drm_pci_busdma_callback: bad dma segment count"));
- dmah->busaddr = segs[0].ds_addr;
-}
-#endif
-
/**
* \brief Allocate a physically contiguous DMA-accessible consistent
* memory block.
@@ -56,10 +42,7 @@ drm_dma_handle_t *
drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr)
{
drm_dma_handle_t *dmah;
- int ret;
-#if defined(__NetBSD__) || defined(__OpenBSD__)
- int nsegs;
-#endif
+ int ret, nsegs;
/* Need power-of-two alignment, so fail the allocation if it isn't. */
if ((align & (align - 1)) != 0) {
@@ -72,37 +55,6 @@ drm_pci_alloc(drm_device_t *dev, size_t size, size_t align, dma_addr_t maxaddr)
if (dmah == NULL)
return NULL;
-#ifdef __FreeBSD__
- ret = bus_dma_tag_create(NULL, align, 0, /* tag, align, boundary */
- maxaddr, BUS_SPACE_MAXADDR, /* lowaddr, highaddr */
- NULL, NULL, /* filtfunc, filtfuncargs */
- size, 1, size, /* maxsize, nsegs, maxsegsize */
- BUS_DMA_ALLOCNOW, NULL, NULL, /* flags, lockfunc, lockfuncargs */
- &dmah->tag);
- if (ret != 0) {
- free(dmah, M_DRM);
- return NULL;
- }
-
- ret = bus_dmamem_alloc(dmah->tag, &dmah->vaddr, BUS_DMA_NOWAIT,
- &dmah->map);
- if (ret != 0) {
- bus_dma_tag_destroy(dmah->tag);
- free(dmah, M_DRM);
- return NULL;
- }
-
- ret = bus_dmamap_load(dmah->tag, dmah->map, dmah->vaddr, size,
- drm_pci_busdma_callback, dmah, 0);
- if (ret != 0) {
- bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
- bus_dma_tag_destroy(dmah->tag);
- free(dmah, M_DRM);
- return NULL;
- }
-
- return dmah;
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
if (bus_dmamap_create(dev->pa.pa_dmat, size, 1, size, 0,
BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, &dmah->dmamap) != 0)
goto dmahfree;
@@ -145,7 +97,6 @@ dmahfree:
free(dmah, M_DRM);
return (NULL);
-#endif
}
@@ -158,15 +109,10 @@ drm_pci_free(drm_device_t *dev, drm_dma_handle_t *dmah)
if (dmah == NULL)
return;
-#if defined(__FreeBSD__)
- bus_dmamem_free(dmah->tag, dmah->vaddr, dmah->map);
- bus_dma_tag_destroy(dmah->tag);
-#elif defined(__NetBSD__) || defined(__OpenBSD__)
bus_dmamap_unload(dev->pa.pa_dmat, dmah->dmamap);
bus_dmamem_unmap(dev->pa.pa_dmat, dmah->vaddr, dmah->size);
bus_dmamem_free(dev->pa.pa_dmat, &dmah->seg, 1);
bus_dmamap_destroy(dev->pa.pa_dmat, dmah->dmamap);
-#endif
free(dmah, M_DRM);
}
diff --git a/sys/dev/pci/drm/drm_scatter.c b/sys/dev/pci/drm/drm_scatter.c
index 705604c46a0..fd594c9c3b7 100644
--- a/sys/dev/pci/drm/drm_scatter.c
+++ b/sys/dev/pci/drm/drm_scatter.c
@@ -35,7 +35,6 @@
*/
#include "drmP.h"
-#define DEBUG_SCATTER 0
struct drm_sg_dmamem *drm_sg_dmamem_alloc(drm_device_t *, size_t);
void drm_sg_dmamem_free(struct drm_sg_dmamem *);
@@ -43,13 +42,10 @@ void
drm_sg_cleanup(drm_sg_mem_t *entry)
{
if (entry) {
-#ifdef __OpenBSD__
if (entry->mem)
drm_sg_dmamem_free(entry->mem);
-#else
if (entry->handle)
free((void *)entry->handle, M_DRM);
-#endif
if (entry->busaddr)
free(entry->busaddr, M_DRM);
free(entry, M_DRM);
@@ -82,7 +78,6 @@ drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request)
return ENOMEM;
}
-#ifdef __OpenBSD__
if ((entry->mem = drm_sg_dmamem_alloc(dev, pages)) == NULL) {
drm_sg_cleanup(entry);
return ENOMEM;
@@ -92,18 +87,6 @@ drm_sg_alloc(drm_device_t * dev, drm_scatter_gather_t * request)
for (i = 0; i < pages; i++)
entry->busaddr[i] = entry->mem->sg_map->dm_segs[i].ds_addr;
-#else
- entry->handle = (long)malloc(pages << PAGE_SHIFT, M_DRM,
- M_WAITOK | M_ZERO);
- if (entry->handle == NULL) {
- drm_sg_cleanup(entry);
- return ENOMEM;
- }
-
- for (i = 0; i < pages; i++) {
- entry->busaddr[i] = vtophys(entry->handle + i * PAGE_SIZE);
- }
-#endif
DRM_DEBUG( "sg alloc handle = %08lx\n", entry->handle );