summaryrefslogtreecommitdiff
path: root/bsd-core
diff options
context:
space:
mode:
Diffstat (limited to 'bsd-core')
-rw-r--r--bsd-core/drmP.h2
-rw-r--r--bsd-core/drm_bufs.c53
-rw-r--r--bsd-core/drm_drv.c70
-rw-r--r--bsd-core/drm_memory.c57
-rw-r--r--bsd-core/drm_os_freebsd.h2
-rw-r--r--bsd-core/drm_os_netbsd.h2
6 files changed, 90 insertions, 96 deletions
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 67915374..b2e045e6 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -403,6 +403,8 @@ extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
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);
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index cdd2359d..0dc923d7 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -115,25 +115,12 @@ int DRM(addmap)( DRM_IOCTL_ARGS )
#if __REALLY_HAVE_MTRR
if ( map->type == _DRM_FRAME_BUFFER ||
(map->flags & _DRM_WRITE_COMBINING) ) {
-#ifdef __FreeBSD__
- int retcode = 0, act;
- struct mem_range_desc mrdesc;
- mrdesc.mr_base = map->offset;
- mrdesc.mr_len = map->size;
- mrdesc.mr_flags = MDF_WRITECOMBINE;
- act = MEMRANGE_SET_UPDATE;
- bcopy(DRIVER_NAME, &mrdesc.mr_owner, strlen(DRIVER_NAME));
- retcode = mem_range_attr_set(&mrdesc, &act);
- map->mtrr=1;
-#elif defined __NetBSD__
- struct mtrr mtrrmap;
- int one = 1;
- mtrrmap.base = map->offset;
- mtrrmap.len = map->size;
- mtrrmap.type = MTRR_TYPE_WC;
- mtrrmap.flags = MTRR_VALID;
- map->mtrr = mtrr_set( &mtrrmap, &one, p, MTRR_GETSET_KERNEL );
-#endif
+ int mtrr;
+
+ mtrr = DRM(mtrr_add)(map->offset, map->size,
+ DRM_MTRR_WC);
+ if (mtrr == 0)
+ map->mtrr = 1;
}
#endif /* __REALLY_HAVE_MTRR */
DRM_IOREMAP(map, dev);
@@ -235,29 +222,11 @@ int DRM(rmmap)( DRM_IOCTL_ARGS )
case _DRM_FRAME_BUFFER:
#if __REALLY_HAVE_MTRR
if (map->mtrr >= 0) {
- int retcode;
-#ifdef __FreeBSD__
- int act;
- struct mem_range_desc mrdesc;
- mrdesc.mr_base = map->offset;
- mrdesc.mr_len = map->size;
- mrdesc.mr_flags = MDF_WRITECOMBINE;
- act = MEMRANGE_SET_REMOVE;
- bcopy(DRIVER_NAME, &mrdesc.mr_owner,
- strlen(DRIVER_NAME));
- retcode = mem_range_attr_set(&mrdesc, &act);
-#elif defined __NetBSD__
- struct mtrr mtrrmap;
- int one = 1;
- mtrrmap.base = map->offset;
- mtrrmap.len = map->size;
- mtrrmap.type = 0;
- mtrrmap.flags = 0;
- mtrrmap.owner = p->p_pid;
- retcode = mtrr_set(&mtrrmap, &one, p,
- MTRR_GETSET_KERNEL);
- DRM_DEBUG("mtrr_del = %d\n", retcode);
-#endif
+ int __unused mtrr;
+
+ mtrr = DRM(mtrr_del)(map->offset, map->size,
+ DRM_MTRR_WC);
+ DRM_DEBUG("mtrr_del = %d\n", mtrr);
}
#endif
DRM(ioremapfree)(map);
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 731f31da..269f4225 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -565,28 +565,11 @@ static int DRM(takedown)( drm_device_t *dev )
case _DRM_FRAME_BUFFER:
#if __REALLY_HAVE_MTRR
if ( map->mtrr >= 0 ) {
- int retcode;
-#ifdef __FreeBSD__
- int act;
- struct mem_range_desc mrdesc;
- mrdesc.mr_base = map->offset;
- mrdesc.mr_len = map->size;
- mrdesc.mr_flags = MDF_WRITECOMBINE;
- act = MEMRANGE_SET_REMOVE;
- bcopy(DRIVER_NAME, &mrdesc.mr_owner, strlen(DRIVER_NAME));
- retcode = mem_range_attr_set(&mrdesc, &act);
- map->mtrr=1;
-#elif defined __NetBSD__
- struct mtrr mtrrmap;
- int one = 1;
- mtrrmap.base = map->offset;
- mtrrmap.len = map->size;
- mtrrmap.type = MTRR_TYPE_WC;
- mtrrmap.flags = 0;
- retcode = mtrr_set( &mtrrmap, &one,
- DRM_CURPROC, MTRR_GETSET_KERNEL);
-#endif
- DRM_DEBUG( "mtrr_del=%d\n", retcode );
+ int __unused mtrr;
+
+ mtrr = DRM(mtrr_del)(map->offset,
+ map->size, DRM_MTRR_WC);
+ DRM_DEBUG("mtrr_del=%d\n", mtrr);
}
#endif
DRM(ioremapfree)( map );
@@ -680,25 +663,12 @@ static int DRM(init)( device_t nbdev )
#endif /* __MUST_HAVE_AGP */
#if __REALLY_HAVE_MTRR
if (dev->agp) {
-#ifdef __FreeBSD__
- int retcode = 0, act;
- struct mem_range_desc mrdesc;
- mrdesc.mr_base = dev->agp->info.ai_aperture_base;
- mrdesc.mr_len = dev->agp->info.ai_aperture_size;
- mrdesc.mr_flags = MDF_WRITECOMBINE;
- act = MEMRANGE_SET_UPDATE;
- bcopy(DRIVER_NAME, &mrdesc.mr_owner, strlen(DRIVER_NAME));
- retcode = mem_range_attr_set(&mrdesc, &act);
- dev->agp->agp_mtrr=1;
-#elif defined __NetBSD__
- struct mtrr mtrrmap;
- int one = 1;
- mtrrmap.base = dev->agp->info.ai_aperture_base;
- mtrrmap.len = dev->agp->info.ai_aperture_size;
- mtrrmap.type = MTRR_TYPE_WC;
- mtrrmap.flags = MTRR_VALID;
- dev->agp->agp_mtrr = mtrr_set( &mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-#endif /* __NetBSD__ */
+ int retcode;
+
+ retcode = DRM(mtrr_add)(dev->agp->info.ai_aperture_base,
+ dev->agp->info.ai_aperture_size, DRM_MTRR_WC);
+ if (retcode == 0)
+ dev->agp->agp_mtrr=1;
}
#endif /* __REALLY_HAVE_MTRR */
#endif /* __REALLY_HAVE_AGP */
@@ -742,12 +712,6 @@ error:
*/
static void DRM(cleanup)(drm_device_t *dev)
{
-#ifdef __NetBSD__
-#if __REALLY_HAVE_MTRR
- struct mtrr mtrrmap;
- int one = 1;
-#endif /* __REALLY_HAVE_MTRR */
-#endif /* __NetBSD__ */
DRM_DEBUG( "\n" );
@@ -761,13 +725,11 @@ static void DRM(cleanup)(drm_device_t *dev)
#if __REALLY_HAVE_AGP && __REALLY_HAVE_MTRR
if ( dev->agp && dev->agp->agp_mtrr >= 0) {
-#if defined(__NetBSD__)
- mtrrmap.base = dev->agp->info.ai_aperture_base;
- mtrrmap.len = dev->agp->info.ai_aperture_size;
- mtrrmap.type = 0;
- mtrrmap.flags = 0;
- mtrr_set( &mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
-#endif
+ int __unused mtrr;
+
+ mtrr = DRM(mtrr_del)(dev->agp->info.ai_aperture_base,
+ dev->agp->info.ai_aperture_size, DRM_MTRR_WC);
+ DRM_DEBUG("mtrr_del=%d\n", mtrr);
}
#endif
diff --git a/bsd-core/drm_memory.c b/bsd-core/drm_memory.c
index dc0d3753..a50e6c47 100644
--- a/bsd-core/drm_memory.c
+++ b/bsd-core/drm_memory.c
@@ -124,5 +124,62 @@ int DRM(unbind_agp)(agp_memory *handle)
{
return DRM(agp_unbind_memory)(handle);
}
+
+#ifdef __FreeBSD__
+int
+DRM(mtrr_add)(unsigned long offset, size_t size, int flags)
+{
+ int act;
+ struct mem_range_desc mrdesc;
+
+ mrdesc.mr_base = offset;
+ mrdesc.mr_len = size;
+ mrdesc.mr_flags = flags;
+ act = MEMRANGE_SET_UPDATE;
+ bcopy(DRIVER_NAME, &mrdesc.mr_owner, strlen(DRIVER_NAME));
+ return mem_range_attr_set(&mrdesc, &act);
+}
+
+int
+DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
+{
+ int act;
+ struct mem_range_desc mrdesc;
+
+ mrdesc.mr_base = offset;
+ mrdesc.mr_len = size;
+ mrdesc.mr_flags = flags;
+ act = MEMRANGE_SET_REMOVE;
+ bcopy(DRIVER_NAME, &mrdesc.mr_owner, strlen(DRIVER_NAME));
+ return mem_range_attr_set(&mrdesc, &act);
+}
+#elif defined(__NetBSD__)
+int
+DRM(mtrr_add)(unsigned long offset, size_t size, int flags)
+{
+ struct mtrr mtrrmap;
+ int one = 1;
+
+ mtrrmap.base = offset;
+ mtrrmap.len = size;
+ mtrrmap.type = flags;
+ mtrrmap.flags = MTRR_VALID;
+ return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
+}
+
+int
+DRM(mtrr_del)(unsigned long offset, size_t size, int flags)
+{
+ struct mtrr mtrrmap;
+ int one = 1;
+
+ mtrrmap.base = offset;
+ mtrrmap.len = size;
+ mtrrmap.type = flags;
+ mtrrmap.flags = 0;
+ return mtrr_set(&mtrrmap, &one, NULL, MTRR_GETSET_KERNEL);
+}
+#endif
+
#endif /* __REALLY_HAVE_AGP */
#endif /* DEBUG_MEMORY */
diff --git a/bsd-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h
index 320db342..33bdcd20 100644
--- a/bsd-core/drm_os_freebsd.h
+++ b/bsd-core/drm_os_freebsd.h
@@ -171,6 +171,8 @@ typedef void irqreturn_t;
#define DRM_AGP_FIND_DEVICE() agp_find_device()
#define DRM_ERR(v) v
+#define DRM_MTRR_WC MDF_WRITECOMBINE
+
#define LOCK_TEST_WITH_RETURN(dev, filp) \
do { \
if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
diff --git a/bsd-core/drm_os_netbsd.h b/bsd-core/drm_os_netbsd.h
index 7653b05e..1554d24d 100644
--- a/bsd-core/drm_os_netbsd.h
+++ b/bsd-core/drm_os_netbsd.h
@@ -136,6 +136,8 @@ extern const int DRM(M_DRM) = M_DEVBUF;
#define DRM_WRITE8(map, offset, val) bus_space_write_1( (map)->iot, (map)->ioh, (offset), (val) )
#define DRM_WRITE32(map, offset, val) bus_space_write_4( (map)->iot, (map)->ioh, (offset), (val) )
+#define DRM_MTRR_WC MTRR_TYPE_WC
+
#define DRM_AGP_FIND_DEVICE() agp_find_device(0)
#define LOCK_TEST_WITH_RETURN(dev, filp) \