[PATCH 1/2 v2] xfree86: Fix IOPortBase to be the size of a pointer

Jeremy Huddleston jeremyhu at apple.com
Sun Oct 16 13:34:58 PDT 2011


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>
---
 hw/xfree86/common/compiler.h          |    2 +-
 hw/xfree86/os-support/bsd/arm_video.c |   21 +++++++++------------
 2 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/hw/xfree86/common/compiler.h b/hw/xfree86/common/compiler.h
index 9e00d75..9d0acaf 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..17ef541 100644
--- a/hw/xfree86/os-support/bsd/arm_video.c
+++ b/hw/xfree86/os-support/bsd/arm_video.c
@@ -392,8 +392,8 @@ xf86EnableIO()
 		base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
 				MAP_FLAGS, fd, (off_t)0x0000);
 
-		if (base != (pointer)-1) {
-			IOPortBase = base;
+		if (base != MAP_FAILED) {
+			IOPortBase = base;
 		}
 		else {
 			xf86Msg(X_WARNING,"EnableIO: failed to mmap %s (%s)\n",
@@ -459,8 +459,8 @@ int ScreenNum;
 		base = (pointer)mmap((caddr_t)0, 65536, PROT_READ | PROT_WRITE,
 				MAP_FLAGS, fd, (off_t)0x0000);
 
-		if (base != (pointer)-1) {
-			IOPortBase = base;
+		if (base != MAP_FAILED) {
+			IOPortBase = base;
 		}
 		else {
 			xf86Msg(X_ERROR,
@@ -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
 
-- 
1.7.6.1




More information about the xorg-devel mailing list