Parcourir la source

xorg-server: fix memory mapped IO for lemote

Apparently this is an update to the original fix, code taken from
http://www.gentoo-cn.org/gitweb/?p=loongson.git;a=blob_plain;f=x11-base/xorg-server/files/xorg-server-9999-loongson.patch;hb=2e5b51e34b7a7d0fe92ea9762d1aed9ac0b808c9
Phil Sutter il y a 14 ans
Parent
commit
5c63c81345

+ 55 - 0
package/xorg-server/patches/patch-hw_xfree86_common_compiler_h

@@ -0,0 +1,55 @@
+	Caller side code changes regarding memory mapped IO. This patch applies
+	for mips architectures and is used by xf86-video-siliconmotion.
+--- xorg-server-1.7.6.orig/hw/xfree86/common/compiler.h	2010-03-12 05:38:22.000000000 +0100
++++ xorg-server-1.7.6/hw/xfree86/common/compiler.h	2010-06-05 09:43:12.531809482 +0200
+@@ -713,42 +713,43 @@ xf86WriteMmio32LeNB(__volatile__ void *b
+ #     define PORT_SIZE short
+ #    endif
+ 
+-_X_EXPORT unsigned int IOPortBase;  /* Memory mapped I/O port area */
++_X_EXPORT volatile unsigned char *ioBase;  /* Memory mapped I/O port area */
++
+ 
+ static __inline__ void
+ outb(unsigned PORT_SIZE port, unsigned char val)
+ {
+-	*(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
++	*(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+ioBase) = val;
+ }
+ 
+ static __inline__ void
+ outw(unsigned PORT_SIZE port, unsigned short val)
+ {
+-	*(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
++	*(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+ioBase) = val;
+ }
+ 
+ static __inline__ void
+ outl(unsigned PORT_SIZE port, unsigned int val)
+ {
+-	*(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase) = val;
++	*(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+ioBase) = val;
+ }
+ 
+ static __inline__ unsigned int
+ inb(unsigned PORT_SIZE port)
+ {
+-	return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
++	return *(volatile unsigned char*)(((unsigned PORT_SIZE)(port))+ioBase);
+ }
+ 
+ static __inline__ unsigned int
+ inw(unsigned PORT_SIZE port)
+ {
+-	return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
++	return *(volatile unsigned short*)(((unsigned PORT_SIZE)(port))+ioBase);
+ }
+ 
+ static __inline__ unsigned int
+ inl(unsigned PORT_SIZE port)
+ {
+-	return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
++	return *(volatile unsigned int*)(((unsigned PORT_SIZE)(port))+ioBase);
+ }
+ 
+ 

+ 46 - 26
package/xorg-server/patches/patch-hw_xfree86_os-support_linux_lnx_video_c

@@ -1,15 +1,17 @@
+	Enable the ioBase mapping code for mips, too. This is needed by
+	xf86-video-siliconmotion.
 --- xorg-server-1.7.6.orig/hw/xfree86/os-support/linux/lnx_video.c	2010-03-12 05:38:22.000000000 +0100
-+++ xorg-server-1.7.6/hw/xfree86/os-support/linux/lnx_video.c	2010-05-14 19:06:06.873473002 +0200
-@@ -64,6 +64,8 @@ static Bool ExtendedEnabled = FALSE;
-       !defined(__mips__) && \
-       !defined(__arm__)
++++ xorg-server-1.7.6/hw/xfree86/os-support/linux/lnx_video.c	2010-06-05 21:46:29.659792653 +0200
+@@ -485,7 +485,7 @@ unmapVidMem(int ScreenNum, pointer Base,
+ /* I/O Permissions section                                                 */
+ /***************************************************************************/
  
-+#include "compiler.h"
-+
- /*
-  * Due to conflicts with "compiler.h", don't rely on <sys/io.h> to declare
-  * these.
-@@ -497,7 +499,7 @@ volatile unsigned char *ioBase = NULL;
+-#if defined(__powerpc__)
++#if defined(__powerpc__) || defined(__mips__)
+ volatile unsigned char *ioBase = NULL;
+ 
+ #ifndef __NR_pciconfig_iobase
+@@ -497,7 +497,7 @@ volatile unsigned char *ioBase = NULL;
  Bool
  xf86EnableIO(void)
  {
@@ -18,24 +20,42 @@
  	int fd;
  	unsigned int ioBase_phys;
  #endif
-@@ -524,6 +526,20 @@ xf86EnableIO(void)
+@@ -505,8 +505,12 @@ xf86EnableIO(void)
+ 	if (ExtendedEnabled)
+ 		return TRUE;
+ 
+-#if defined(__powerpc__)
++#if defined(__powerpc__) || defined(__mips__)
++#ifdef __powerpc__
+ 	ioBase_phys = syscall(__NR_pciconfig_iobase, 2, 0, 0);
++#else
++	ioBase_phys = 0x1fd00000;
++#endif
+ 
+ 	fd = open("/dev/mem", O_RDWR);
+ 	if (ioBase == NULL) {
+@@ -522,9 +526,10 @@ xf86EnableIO(void)
+ 		    return FALSE;
+ 		}
  #endif
++		xf86Msg(X_INFO,"%s: ioBase 0x%lx\n", (unsigned long)ioBase);
  	}
  	close(fd);
-+#elif defined(__mips__)
-+	fd = open("/dev/mem", O_RDWR);
-+	IOPortBase = (volatile unsigned char *)mmap(0, 0x20000,
-+			PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0x1fd00000);
-+	if (IOPortBase == MAP_FAILED) {
-+		xf86Msg(X_WARNING,
-+			"xf86EnableIOPorts: Failed to map iobase (%s)\n",
-+			strerror(errno));
-+		return FALSE;
-+	}
-+	close(fd);
-+	xf86Msg(X_WARNING,
-+		"xf86EnableIOPorts: map iobase (%x)\n",
-+		IOPortBase);
- #elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__)
+-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__)
++#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__sh__) && !defined(__hppa__) && !defined(__s390__) && !defined(__arm__) && !defined(__m32r__)
          if (ioperm(0, 1024, 1) || iopl(3)) {
                  if (errno == ENODEV)
+                         ErrorF("xf86EnableIOPorts: no I/O ports found\n");
+@@ -548,10 +553,10 @@ xf86DisableIO(void)
+ {
+ 	if (!ExtendedEnabled)
+ 		return;
+-#if defined(__powerpc__)
++#if defined(__powerpc__) || defined(__mips__)
+ 	munmap(ioBase, 0x20000);
+ 	ioBase = NULL;
+-#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__mips__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__)
++#elif !defined(__mc68000__) && !defined(__sparc__) && !defined(__sh__) && !defined(__hppa__) && !defined(__arm__) && !defined(__s390__) && !defined(__m32r__)
+ 	iopl(0);
+ 	ioperm(0, 1024, 0);
+ #endif