summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2005-11-08 20:25:00 +0000
committerEric Anholt <anholt@freebsd.org>2005-11-08 20:25:00 +0000
commita10d8178e32528e0fd8a7afa24e71a35b1c0582d (patch)
treefdf902a22d38ed246b7f0bdc9943359e33e9ca8a
parent2c6308fe54c10075379cb00506d5519e0ced1076 (diff)
Initial port of savage to FreeBSD for the AGP and !ShadowStatus case. Adds
drm_mtrr_{add,del} for handling the MTRR setup. Still has a LOR issue with DRM_VERIFYAREA_READ/DRM_COPY_FROM_USER_UNCHECKED in savage_bci.c -- this won't work with the fine-grained locking in use, and just doing a single copyin to a temporary will probably work fine. Also note that the module leaks approximately 4 kb on unload.
-rw-r--r--bsd-core/Makefile2
-rw-r--r--bsd-core/drmP.h3
-rw-r--r--bsd-core/drm_bufs.c2
-rw-r--r--bsd-core/drm_drv.c2
-rw-r--r--bsd-core/drm_memory.c2
-rw-r--r--bsd-core/savage_drv.c24
-rw-r--r--linux-core/drmP.h15
-rw-r--r--shared-core/savage_bci.c27
8 files changed, 47 insertions, 30 deletions
diff --git a/bsd-core/Makefile b/bsd-core/Makefile
index a5ac952b..96b878c0 100644
--- a/bsd-core/Makefile
+++ b/bsd-core/Makefile
@@ -55,7 +55,7 @@ SHAREDFILES= drm.h \
via_verifier.h \
via_video.c
-SUBDIR = drm mach64 mga r128 radeon sis tdfx # via i915
+SUBDIR = drm mach64 mga r128 radeon savage sis tdfx # via i915
CLEANFILES+= ${SHAREDFILES}
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 0adfef93..43f24271 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -843,7 +843,7 @@ 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);
+int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);
int drm_context_switch(drm_device_t *dev, int old, int new);
int drm_context_switch_complete(drm_device_t *dev, int new);
@@ -880,6 +880,7 @@ 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);
+#define drm_core_reclaim_buffers drm_reclaim_buffers
/* IRQ support (drm_irq.c) */
int drm_irq_install(drm_device_t *dev);
diff --git a/bsd-core/drm_bufs.c b/bsd-core/drm_bufs.c
index 93bcc812..5edc6feb 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -297,7 +297,7 @@ void drm_rmmap(drm_device_t *dev, drm_local_map_t *map)
if (map->mtrr) {
int __unused retcode;
- retcode = drm_mtrr_del(map->offset, map->size,
+ retcode = drm_mtrr_del(0, map->offset, map->size,
DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d\n", retcode);
}
diff --git a/bsd-core/drm_drv.c b/bsd-core/drm_drv.c
index 6766195b..951f7462 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -576,7 +576,7 @@ static void drm_unload(drm_device_t *dev)
if (dev->agp && dev->agp->mtrr) {
int __unused retcode;
- retcode = drm_mtrr_del(dev->agp->info.ai_aperture_base,
+ retcode = drm_mtrr_del(0, dev->agp->info.ai_aperture_base,
dev->agp->info.ai_aperture_size, DRM_MTRR_WC);
DRM_DEBUG("mtrr_del = %d", retcode);
}
diff --git a/bsd-core/drm_memory.c b/bsd-core/drm_memory.c
index ea084c52..6d467e98 100644
--- a/bsd-core/drm_memory.c
+++ b/bsd-core/drm_memory.c
@@ -113,7 +113,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(int __unused handle, unsigned long offset, size_t size, int flags)
{
int act;
struct mem_range_desc mrdesc;
diff --git a/bsd-core/savage_drv.c b/bsd-core/savage_drv.c
index c9a2fb10..71b5065b 100644
--- a/bsd-core/savage_drv.c
+++ b/bsd-core/savage_drv.c
@@ -43,15 +43,15 @@ extern int savage_max_ioctl;
static void savage_configure(drm_device_t *dev)
{
dev->driver.buf_priv_size = sizeof(drm_savage_buf_priv_t);
- dev->load = savage_driver_load;
- dev->firstopen = savage_driver_firstopen;
- dev->lastclose = savage_driver_lastclose;
- dev->unload = savage_driver_unload;
- dev->reclaim_buffers = savage_reclaim_buffers;
- dev->dma_ioctl = savage_bci_buffers;
+ dev->driver.load = savage_driver_load;
+ dev->driver.firstopen = savage_driver_firstopen;
+ dev->driver.lastclose = savage_driver_lastclose;
+ dev->driver.unload = savage_driver_unload;
+ dev->driver.reclaim_buffers_locked = savage_reclaim_buffers;
+ dev->driver.dma_ioctl = savage_bci_buffers;
- dev->ioctls = savage_ioctls;
- dev->max_ioctl = savage_max_ioctl;
+ dev->driver.ioctls = savage_ioctls;
+ dev->driver.max_ioctl = savage_max_ioctl;
dev->driver.name = DRIVER_NAME;
dev->driver.desc = DRIVER_DESC;
@@ -60,10 +60,10 @@ static void savage_configure(drm_device_t *dev)
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_dma = 1;
+ dev->driver.use_agp = 1;
+ dev->driver.use_mtrr = 1;
+ dev->driver.use_pci_dma = 1;
+ dev->driver.use_dma = 1;
}
#ifdef __FreeBSD__
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index 7b344c7a..8044780b 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -763,6 +763,21 @@ static inline int drm_core_has_MTRR(struct drm_device *dev)
{
return drm_core_check_feature(dev, DRIVER_USE_MTRR);
}
+
+#define DRM_MTRR_WC MTRR_TYPE_WRCOMB
+
+static inline int drm_mtrr_add(unsigned long offset, unsigned long size,
+ unsigned int flags)
+{
+ return mtrr_add(offset, size, flags, 1);
+}
+
+static inline int drm_mtrr_del(int handle, unsigned long offset,
+ unsigned long size, unsigned int flags)
+{
+ return mtrr_del(handle, offset, size);
+}
+
#else
#define drm_core_has_MTRR(dev) (0)
#endif
diff --git a/shared-core/savage_bci.c b/shared-core/savage_bci.c
index 28ef38bb..3bc67151 100644
--- a/shared-core/savage_bci.c
+++ b/shared-core/savage_bci.c
@@ -585,19 +585,19 @@ int savage_driver_firstopen(drm_device_t *dev)
* MTRRs. */
dev_priv->mtrr[0].base = fb_base;
dev_priv->mtrr[0].size = 0x01000000;
- dev_priv->mtrr[0].handle = mtrr_add(
+ dev_priv->mtrr[0].handle = drm_mtrr_add(
dev_priv->mtrr[0].base, dev_priv->mtrr[0].size,
- MTRR_TYPE_WRCOMB, 1);
+ DRM_MTRR_WC);
dev_priv->mtrr[1].base = fb_base+0x02000000;
dev_priv->mtrr[1].size = 0x02000000;
- dev_priv->mtrr[1].handle = mtrr_add(
+ dev_priv->mtrr[1].handle = drm_mtrr_add(
dev_priv->mtrr[1].base, dev_priv->mtrr[1].size,
- MTRR_TYPE_WRCOMB, 1);
+ DRM_MTRR_WC);
dev_priv->mtrr[2].base = fb_base+0x04000000;
dev_priv->mtrr[2].size = 0x04000000;
- dev_priv->mtrr[2].handle = mtrr_add(
+ dev_priv->mtrr[2].handle = drm_mtrr_add(
dev_priv->mtrr[2].base, dev_priv->mtrr[2].size,
- MTRR_TYPE_WRCOMB, 1);
+ DRM_MTRR_WC);
} else {
DRM_ERROR("strange pci_resource_len %08lx\n",
drm_get_resource_len(dev, 0));
@@ -616,9 +616,9 @@ int savage_driver_firstopen(drm_device_t *dev)
* aperture. */
dev_priv->mtrr[0].base = fb_base;
dev_priv->mtrr[0].size = 0x08000000;
- dev_priv->mtrr[0].handle = mtrr_add(
+ dev_priv->mtrr[0].handle = drm_mtrr_add(
dev_priv->mtrr[0].base, dev_priv->mtrr[0].size,
- MTRR_TYPE_WRCOMB, 1);
+ DRM_MTRR_WC);
} else {
DRM_ERROR("strange pci_resource_len %08lx\n",
drm_get_resource_len(dev, 1));
@@ -662,9 +662,10 @@ void savage_driver_lastclose(drm_device_t *dev)
for (i = 0; i < 3; ++i)
if (dev_priv->mtrr[i].handle >= 0)
- mtrr_del(dev_priv->mtrr[i].handle,
- dev_priv->mtrr[i].base,
- dev_priv->mtrr[i].size);
+ drm_mtrr_del(dev_priv->mtrr[i].handle,
+ dev_priv->mtrr[i].base,
+ dev_priv->mtrr[i].size,
+ DRM_MTRR_WC);
}
int savage_driver_unload(drm_device_t *dev)
@@ -961,8 +962,8 @@ static int savage_bci_event_emit(DRM_IOCTL_ARGS)
event.count = savage_bci_emit_event(dev_priv, event.flags);
event.count |= dev_priv->event_wrap << 16;
- DRM_COPY_TO_USER_IOCTL(&((drm_savage_event_emit_t __user *)data)->count,
- event.count, sizeof(event.count));
+ DRM_COPY_TO_USER_IOCTL((drm_savage_event_emit_t __user *)data,
+ event, sizeof(event));
return 0;
}