From 1a256df4804e4e987f81226a5d8e0573363607ee Mon Sep 17 00:00:00 2001
From: Eric Anholt <anholt@freebsd.org>
Date: Tue, 8 Nov 2005 02:38:01 +0000
Subject: Catch FreeBSD up to the pcie gart changes. Required minor
 modification to     radeon_cp.c to use a drm_local_map_t-type mapping
 (drm_core_ioremap     rather than drm_ioremap), which contains private device
 mapping     information on BSD. I also changed the ati_pcigart interface to
 use     "void *" for pointers to kva rather than "unsigned long". While
 PCIGART     support appears to be broken on FreeBSD currently, I think this
 is not     new, and BusType PCI remains working on my r100 in Linux.

---
 linux-core/ati_pcigart.c | 18 +++++++++---------
 linux-core/drmP.h        |  3 ++-
 2 files changed, 11 insertions(+), 10 deletions(-)

(limited to 'linux-core')

diff --git a/linux-core/ati_pcigart.c b/linux-core/ati_pcigart.c
index 75557020..404c5b73 100644
--- a/linux-core/ati_pcigart.c
+++ b/linux-core/ati_pcigart.c
@@ -52,7 +52,7 @@
 # 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)
+static void *drm_ati_alloc_pcigart_table(void)
 {
 	unsigned long address;
 	struct page *page;
@@ -72,29 +72,29 @@ static unsigned long drm_ati_alloc_pcigart_table(void)
 	}
 
 	DRM_DEBUG("%s: returning 0x%08lx\n", __FUNCTION__, address);
-	return address;
+	return (void *)address;
 }
 
-static void drm_ati_free_pcigart_table(unsigned long address)
+static void drm_ati_free_pcigart_table(void *address)
 {
 	struct page *page;
 	int i;
 	DRM_DEBUG("%s\n", __FUNCTION__);
 
-	page = virt_to_page(address);
+	page = virt_to_page((unsigned long)address);
 
 	for (i = 0; i < ATI_PCIGART_TABLE_PAGES; i++, page++) {
 		__put_page(page);
 		ClearPageReserved(page);
 	}
 
-	free_pages(address, ATI_PCIGART_TABLE_ORDER);
+	free_pages((unsigned long)address, ATI_PCIGART_TABLE_ORDER);
 }
 
 int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info)
 {
 	drm_sg_mem_t *entry = dev->sg;
-	unsigned long address = 0;
+	void *address = NULL;
 	unsigned long pages;
 	u32 *pci_gart, page_base, bus_address = 0;
 	int i, j, ret = 0;
@@ -119,7 +119,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info)
 			goto done;
 		}
 		
-		bus_address = pci_map_single(dev->pdev, (void *)address,
+		bus_address = pci_map_single(dev->pdev, address,
 					     ATI_PCIGART_TABLE_PAGES * PAGE_SIZE,
 					     PCI_DMA_TODEVICE);
 		if (bus_address == 0) {
@@ -133,7 +133,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info)
 	{
 		address = gart_info->addr;
 		bus_address = gart_info->bus_addr;
-		DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", bus_address, address);
+		DRM_DEBUG("PCI: Gart Table: VRAM %08X mapped at %08lX\n", bus_address, (unsigned long)address);
 	}
 
 	pci_gart = (u32 *) address;
@@ -152,7 +152,7 @@ int drm_ati_pcigart_init(drm_device_t * dev, drm_ati_pcigart_info *gart_info)
 		if (entry->busaddr[i] == 0) {
 			DRM_ERROR("unable to map PCIGART pages!\n");
 			drm_ati_pcigart_cleanup(dev, gart_info);
-			address = 0;
+			address = NULL;
 			bus_address = 0;
 			goto done;
 		}
diff --git a/linux-core/drmP.h b/linux-core/drmP.h
index c0ac922f..7b344c7a 100644
--- a/linux-core/drmP.h
+++ b/linux-core/drmP.h
@@ -529,8 +529,9 @@ typedef struct drm_vbl_sig {
 typedef struct ati_pcigart_info {
 	int gart_table_location;
 	int is_pcie;
-	unsigned long addr;
+	void *addr;
 	dma_addr_t bus_addr;
+	drm_local_map_t mapping;
 } drm_ati_pcigart_info;
 
 /**
-- 
cgit v1.2.3