[PATCH 2/2] xfree86: Add Loongson MIPS support

Jeremy Huddleston jeremyhu at apple.com
Sun Oct 16 13:37:14 PDT 2011


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>
---

Ok, so I really don't understand why ppc had its own ioBase in os-support/linux/lnx_video.c rather than using IOPortBase.  In any event, I want to nuke this code rather than waste any more of my time fixing it (especially without being able to test it).  If this doesn't work, Matt, can you please finish massaging them.

 hw/xfree86/os-support/linux/lnx_video.c |   43 ++++++++++++++++---------------
 1 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/hw/xfree86/os-support/linux/lnx_video.c b/hw/xfree86/os-support/linux/lnx_video.c
index 18116bd..f31063d 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);
-- 
1.7.6.1




More information about the xorg-devel mailing list