[Xquartz-changes] xserver: Branch 'bus-cleanup' - 2 commits

Jeremy Huddleston jeremyhu at freedesktop.org
Sun Oct 16 22:27:31 PDT 2011


Rebased ref, commits from common ancestor:
commit f1d95a9f09cfe11fd127d19baf7262b7df6ba772
Author: Matt Kraai <kraai at ftbfs.org>
Date:   Sat Oct 15 21:35:35 2011 -0700

    xfree86: Add Loongson MIPS support
    
    Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=41038
    
    Signed-off-by: Matt Kraai <kraai at ftbfs.org>
    Reviewed-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 18116bd..7cdfa1f 100644
--- a/hw/xfree86/os-support/linux/lnx_video.c
+++ b/hw/xfree86/os-support/linux/lnx_video.c
@@ -120,42 +120,43 @@ xf86OSInitVidMem(VidMemInfoPtr pVidMem)
 /***************************************************************************/
 
 #if defined(__powerpc__)
-volatile unsigned char *ioBase = NULL;
-
 #ifndef __NR_pciconfig_iobase
 #define __NR_pciconfig_iobase	200
 #endif
-
 #endif
 
 Bool
 xf86EnableIO(void)
 {
-#if defined(__powerpc__)
+#if defined(__mips__) || defined(__powerpc__)
 	int fd;
-	unsigned int ioBase_phys;
+	pointer ioBase_phys;
 #endif
 
 	if (ExtendedEnabled)
 		return TRUE;
 
-#if defined(__powerpc__)
+#if defined(__mips__) || defined(__powerpc__)
+
+# if defined(__mips__)
+	ioBase_phys = 0x1fd00000;
+# elif defined(__powerpc__)
 	ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
+# endif
 
 	fd = open("/dev/mem", O_RDWR);
-	if (ioBase == NULL) {
-		ioBase = (volatile unsigned char *)mmap(0, 0x20000,
-				PROT_READ | PROT_WRITE, MAP_SHARED, fd,
-				ioBase_phys);
-/* Should this be fatal or just a warning? */
-#if 0
-		if (ioBase == MAP_FAILED) {
-		    xf86Msg(X_WARNING,
-			    "xf86EnableIOPorts: Failed to map iobase (%s)\n",
-			    strerror(errno));
-		    return FALSE;
+	if (IOPortBase == 0) {
+		pointer base = (poiner)mmap(0, 0x20000, PROT_READ | PROT_WRITE,
+		                            MAP_SHARED, fd, ioBase_phys);
+
+		if (base == MAP_FAILED) {
+			ErrorF("xf86EnableIOPorts: Failed to map iobase (%s)\n",
+			       strerror(errno));
+			close(fd);
+			return FALSE;
 		}
-#endif
+
+		IOPortBase = base;
 	}
 	close(fd);
 #elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__) && !defined(__nds32__)
@@ -184,9 +185,9 @@ xf86DisableIO(void)
 {
 	if (!ExtendedEnabled)
 		return;
-#if defined(__powerpc__)
-	munmap(ioBase, 0x20000);
-	ioBase = NULL;
+#if defined(__powerpc__) || defined(__mips__)
+	munmap(IOPortBase, 0x20000);
+	IOPortBase = 0;
 #elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__) && !defined(__nds32__)
 	iopl(0);
 	ioperm(0, 1024, 0);
commit 48f2227d8e17bd4da1f9f241f1d50ded9269a04a
Author: Jeremy Huddleston <jeremyhu at apple.com>
Date:   Sat Oct 15 21:34:42 2011 -0700

    xfree86: Fix IOPortBase to be the size of a pointer
    
    This addresses issues on 64bit systems where the IOPortBase is higher in
    memory space.
    
    Partially fixes: https://bugs.freedesktop.org/show_bug.cgi?id=41038
    
    Signed-off-by: Jeremy Huddleston <jeremyhu at apple.com>

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 9e00d75..c44db76 100644
--- a/hw/xfree86/common/compiler.h
+++ b/hw/xfree86/common/compiler.h
@@ -714,7 +714,7 @@ xf86WriteMmio32LeNB(__volatile__ void *base, const unsigned long offset,
 #     define PORT_SIZE short
 #    endif
 
-_X_EXPORT unsigned int IOPortBase;  /* Memory mapped I/O port area */
+_X_EXPORT uintptr_t IOPortBase;  /* Memory mapped I/O port area */
 
 static __inline__ void
 outb(unsigned PORT_SIZE port, unsigned char val)
diff --git a/hw/xfree86/os-support/bsd/arm_video.c b/hw/xfree86/os-support/bsd/arm_video.c
index b59c8e0..e0ad532 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -392,7 +392,7 @@ xf86EnableIO()
 		base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
 				MAP_FLAGS, fd, (off_t)0x0000);
 
-		if (base != (pointer)-1) {
+		if (base != MAP_FAILED) {
 			IOPortBase = base;
 		}
 		else {
@@ -459,7 +459,7 @@ int ScreenNum;
 		base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
 				MAP_FLAGS, fd, (off_t)0x0000);
 
-		if (base != (pointer)-1) {
+		if (base != MAP_FAILED) {
 			IOPortBase = base;
 		}
 		else {
@@ -475,8 +475,6 @@ int ScreenNum;
 #endif
 
 #ifdef __arm32__
-	IOPortBase = (unsigned int)-1;
-
 	if((memInfoP = checkMapInfo(TRUE, MMIO_REGION)) != NULL)
 	{
 	    /* 
@@ -487,8 +485,7 @@ int ScreenNum;
 	     * actually mmap the start of the page, then the start of video
 	     * I/O space is added as an internal offset.
 	     */
-	    IOPortBase = (unsigned int)xf86MapInfoMap(memInfoP,
-						      (caddr_t)0x0, 0L) 
+	    IOPortBase = (uintptr_t)xf86MapInfoMap(memInfoP, (caddr_t)0x0, 0L)
 		- memInfoP->memInfo.u.map_info_mmap.internal_offset;
 	    ExtendedEnabled = TRUE;
 	    return TRUE;
@@ -501,11 +498,11 @@ int ScreenNum;
 	    base = (pointer)mmap((caddr_t)0, 0x400, PROT_READ | PROT_WRITE,
 				 MAP_FLAGS, devMemFd, (off_t)DEV_MEM_IOBASE);
 
-	    if (base != (pointer)-1)
-		IOPortBase = (unsigned int)base;
+	    if (base != MAP_FAILED)
+		IOPortBase = base;
 	}
 
-        if (IOPortBase == (unsigned int)-1)
+        if (IOPortBase == 0)
 	{	
 	    xf86Msg(X_WARNING,"xf86EnableIOPorts: failed to open mem device or map IO base. \n\
 Make sure you have the Aperture Driver installed, or a kernel built with the INSECURE option\n");
@@ -551,7 +548,7 @@ int ScreenNum;
 			return;
 
 	munmap((caddr_t)IOPortBase, 0x400);
-	IOPortBase = (unsigned int)-1;
+	IOPortBase = 0;
 	ExtendedEnabled = FALSE;
 #endif
 


More information about the Xquartz-changes mailing list