summaryrefslogtreecommitdiff
path: root/bsd/ati_pcigart.h
diff options
context:
space:
mode:
Diffstat (limited to 'bsd/ati_pcigart.h')
-rw-r--r--bsd/ati_pcigart.h53
1 files changed, 8 insertions, 45 deletions
diff --git a/bsd/ati_pcigart.h b/bsd/ati_pcigart.h
index 28723f56..0cc63a3a 100644
--- a/bsd/ati_pcigart.h
+++ b/bsd/ati_pcigart.h
@@ -25,6 +25,8 @@
*
* Authors:
* Gareth Hughes <gareth@valinux.com>
+ *
+ * $FreeBSD: src/sys/dev/drm/ati_pcigart.h,v 1.1 2003/03/09 02:08:28 anholt Exp $
*/
#include "drmP.h"
@@ -42,25 +44,6 @@
# define ATI_MAX_PCIGART_PAGES 8192 /* 32 MB aperture, 4K pages */
# define ATI_PCIGART_PAGE_SIZE 4096 /* PCI GART page size */
-static unsigned long DRM(ati_alloc_pcigart_table)( void )
-{
- unsigned long address;
-
- DRM_DEBUG( "\n" );
-
- address = (unsigned long) malloc( (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM), M_WAITOK );
-
- DRM_DEBUG( "returning 0x%08lx\n", address );
- return address;
-}
-
-static void DRM(ati_free_pcigart_table)( unsigned long address )
-{
- DRM_DEBUG( "\n" );
-
- free( (void *)address, DRM(M_DRM));
-}
-
int DRM(ati_pcigart_init)( drm_device_t *dev,
unsigned long *addr,
dma_addr_t *bus_addr)
@@ -76,23 +59,15 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
goto done;
}
- address = DRM(ati_alloc_pcigart_table)();
+ address = (long)contigmalloc((1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE,
+ DRM(M_DRM), M_WAITOK, 0ul, 0xfffffffful, PAGE_SIZE, 0);
if ( !address ) {
DRM_ERROR( "cannot allocate PCI GART page!\n" );
goto done;
}
- /* FIXME non-vtophys==bustophys-arches */
+ /* XXX: we need to busdma this */
bus_address = vtophys( address );
- /*pci_map_single(dev->pdev, (void *)address,
- ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
- PCI_DMA_TODEVICE);*/
-/* if (bus_address == 0) {
- DRM_ERROR( "unable to map PCIGART pages!\n" );
- DRM(ati_free_pcigart_table)( (unsigned long)address );
- address = 0;
- goto done;
- }*/
pci_gart = (u32 *)address;
@@ -102,16 +77,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
bzero( pci_gart, ATI_MAX_PCIGART_PAGES * sizeof(u32) );
for ( i = 0 ; i < pages ; i++ ) {
- /* we need to support large memory configurations */
- /* FIXME non-vtophys==vtobus-arches */
entry->busaddr[i] = vtophys( entry->handle + (i*PAGE_SIZE) );
-/* if (entry->busaddr[i] == 0) {
- DRM_ERROR( "unable to map PCIGART pages!\n" );
- DRM(ati_pcigart_cleanup)( dev, (unsigned long)address, bus_address );
- address = 0;
- bus_address = 0;
- goto done;
- }*/
page_base = (u32) entry->busaddr[i];
for (j = 0; j < (PAGE_SIZE / ATI_PCIGART_PAGE_SIZE); j++) {
@@ -122,8 +88,6 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
ret = 1;
- DRM_READMEMORYBARRIER();
-
done:
*addr = address;
*bus_addr = bus_address;
@@ -142,9 +106,8 @@ int DRM(ati_pcigart_cleanup)( drm_device_t *dev,
return 0;
}
- if ( addr ) {
- DRM(ati_free_pcigart_table)( addr );
- }
-
+#if __FreeBSD_version > 500000
+ contigfree( (void *)addr, (1 << ATI_PCIGART_TABLE_ORDER) * PAGE_SIZE, DRM(M_DRM)); /* Not available on 4.x */
+#endif
return 1;
}