About variable "IOPortBase"

belcon zhao belcon.zhao at siliconmotion.com.cn
Wed Mar 26 19:56:34 PDT 2008


Hi, all

Just find that Xorg compiled xf86EnableIO() of
hw/xfree86/os-support/linux/lnx_video.c. IOPortBase wasn't initialized
in that file. That's why IOPortBase is 0. So, it should be compiling
mistake. Did I do extra work while compile Xorg with mips?


Regards,
  Belcon


On Thu, 2008-03-27 at 10:05 +0800, belcon zhao wrote:

> Hi all,
> 
>   I  compiled Xorg server from source code. My linux distribution is
> Debians and CPU is mipsel. I have tried source packages from
> freedesktop and debians. But xorg crashed when I tried to make it
> work. I just found it happened while graphic chip driver call outb(),
> which is defined as below:
> 
> static __inline__ void
> outb(unsigned PORT_SIZE port, unsigned char val)
> {
>         *(volatile unsigned char*)(((unsigned
> PORT_SIZE)(port))+IOPortBase) = val;
> }.
> 
> IOPortBase is defined in the same head file
> "hw/xfree86/common/compiler.h"
> I had grepped IOPortBase in the whole source code and I got below:
> 
> hw/xfree86/os-support/bsd/arm_video.c:                  IOPortBase =
> base;
> hw/xfree86/os-support/bsd/arm_video.c:                  IOPortBase =
> base;
> hw/xfree86/os-support/bsd/arm_video.c:  IOPortBase = (unsigned int)-1;
> hw/xfree86/os-support/bsd/arm_video.c:       * space (e.g. 0x3B0), but
> IOPortBase is expected to map to
> hw/xfree86/os-support/bsd/arm_video.c:      IOPortBase = (unsigned
> int)xf86MapInfoMap(memInfoP,
> hw/xfree86/os-support/bsd/arm_video.c:          IOPortBase = (unsigned
> int)base;
> hw/xfree86/os-support/bsd/arm_video.c:        if (IOPortBase ==
> (unsigned int)-1)
> hw/xfree86/os-support/bsd/arm_video.c:  munmap((caddr_t)IOPortBase,
> 0x400);
> hw/xfree86/os-support/bsd/arm_video.c:  IOPortBase = (unsigned int)-1;
> 
> hw/xfree86/common/compiler.h:unsigned int IOPortBase;  /* Memory
> mapped I/O port area */
> hw/xfree86/common/compiler.h:   *(volatile unsigned char*)(((unsigned
> PORT_SIZE)(port))+IOPortBase) = val;
> hw/xfree86/common/compiler.h:   *(volatile unsigned short*)(((unsigned
> PORT_SIZE)(port))+IOPortBase) = val;
> hw/xfree86/common/compiler.h:   *(volatile unsigned int*)(((unsigned
> PORT_SIZE)(port))+IOPortBase) = val;
> hw/xfree86/common/compiler.h:   return *(volatile unsigned
> char*)(((unsigned PORT_SIZE)(port))+IOPortBase);
> hw/xfree86/common/compiler.h:   return *(volatile unsigned
> short*)(((unsigned PORT_SIZE)(port))+IOPortBase);
> hw/xfree86/common/compiler.h:   return *(volatile unsigned
> int*)(((unsigned PORT_SIZE)(port))+IOPortBase);
> 
> To the file arm_video.c, only the first line worked others are
> remarked. The first line is in the function:
> 
> #if defined(USE_ARC_MMAP) || defined(__arm32__)
> 
> Bool
> xf86EnableIO()
> {
>         int fd;
>         pointer base;
> 
>         if (ExtendedEnabled)
>                 return TRUE;
> 
>         if ((fd = open("/dev/ttyC0", O_RDWR)) >= 0) {
>                 /* Try to map a page at the pccons I/O space */
>                 base = (pointer)mmap((caddr_t)0, 65536, PROT_READ |
> PROT_WRITE,
>                                 MAP_FLAGS, fd, (off_t)0x0000);
> 
>                 if (base != (pointer)-1) {
>                         IOPortBase = base;
>                 }
>                 else {
>                         xf86Msg(X_WARNING,"EnableIO: failed to mmap %s
> (%s)\n",
>                                 "/dev/ttyC0", strerror(errno));
>                         return FALSE;
>                 }
>         }
>         else {
>                 xf86Msg("EnableIO: failed to open %s (%s)\n",
>                         "/dev/ttyC0", strerror(errno));
>                 return FALSE;
>         }
> 
>         ExtendedEnabled = TRUE;
> 
>         return TRUE;
> }
> 
> Since there is "#if defined(USE_ARC_MMAP) || defined(__arm32__)", I am
> not sure that this function had been compiled into Xorg. 
> I just test this 
> #include <stdio.h>
> int main(void)
> {
> #if defined(__mips__)
>         printf("mips\n");
> #elif defined(__arm32__)
>         printf("arm32\n");
> #else
>         printf("hehe\n");
> #endif
>         return 0;
> }
> and it just show "mips". So I am afraid that the function
> xf86EnableIO() which assigned value to IOPortBase wouldn't been
> compiled into Xorg.
> 
> IOPortBase is 0 if I use my own Xorg.
> 
> I also tried the default Xorg which works fine. IOPortBase is not 0.
> 
> I compiled Xorg with "--enable-debug --prefix=/root/belcon".
> 
> Any one has any ideas? Maybe it is just something related to
> "./configure".
> 
> Regards,
>   Belcon
> 
> 
> 
> 
> 
> 
> 
> 
> Below is gdb output:
> 
> 
> gdb hw/xfree86/Xorg 
> GNU gdb 6.4.90-debian
> Copyright (C) 2006 Free Software Foundation, Inc.
> GDB is free software, covered by the GNU General Public License, and
> you are
> welcome to change it and/or distribute copies of it under certain
> conditions.
> Type "show copying" to see the conditions.
> There is absolutely no warranty for GDB.  Type "show warranty" for
> details.
> This GDB was configured as "mipsel-linux-gnu"...Using host
> libthread_db library "/lib/libthread_db.so.1".
> 
> (gdb) run
> Starting program: /root/belcon/xorg-server-1.1.1/hw/xfree86/Xorg 
> _XSERVTransSocketOpenCOTSServer: Unable to open socket for inet6
> _XSERVTransOpen: transport open failed for inet6/debian:0
> _XSERVTransMakeAllCOTSServerListeners: failed to open listener for
> inet6
> 
> X Window System Version 7.1.1
> Release Date: 12 May 2006
> X Protocol Version 11, Revision 0, Release 7.1.1
> Build Operating System: Linux 2.6.18.1 mips64 
> Current Operating System: Linux debian 2.6.18.1 #3 Mon Sep 3 12:52:27
> CST 2007 mips64
> Build Date: 21 March 2008
>         Before reporting problems, check http://wiki.x.org
>         to make sure that you have the latest version.
> Module Loader present
> Markers: (--) probed, (**) from config file, (==) default setting,
>         (++) from command line, (!!) notice, (II) informational,
>         (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
> (==) Log file: "/root/belcon//var/log/Xorg.0.log", Time: Mon Mar 24
> 14:18:39 2008
> (==) Using config file: "/etc/X11/xorg.conf"
> [tcsetpgrp failed in terminal_inferior: 不允许的操作]
> (EE) Silicon MotionlcdWidth = 1280
> LCD Base =        0
> FBOffset is 0x0
> 
> Program received signal SIGSEGV, Segmentation fault.
> SMI_SaveScreen (pScreen=<value optimized out>, mode=<value optimized
> out>)
>     at /usr/include/xorg/compiler.h:916
> 916             *(volatile unsigned char*)(((unsigned
> PORT_SIZE)(port))+IOPortBase) = val;
> (gdb) print IOPortBase
> $1 = 0
> (gdb) bt f
> #0  SMI_SaveScreen (pScreen=<value optimized out>, mode=<value
> optimized out>)
>     at /usr/include/xorg/compiler.h:916
>         seq1 = <value optimized out>
>         pScrn = <value optimized out>
>         on = 1
>         pSmi = (SMIPtr) 0x64a280
> #1  0x0042ef10 in SaveScreens (on=2, mode=0) at window.c:3386
>         i = 0
>         what = 1
>         type = 1
> #2  0x00423d00 in main (argc=1, argv=0x7f80bab4, envp=<value optimized
> out>)
>     at main.c:434
>         pScreen = <value optimized out>
>         i = 1
>         error = 6412720
>         xauthfile = <value optimized out>
>         alwaysCheckForInput = {0, 1}
> 
> 
> _______________________________________________
> xorg mailing list
> xorg at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/xorg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg/attachments/20080327/379dd536/attachment.html>


More information about the xorg mailing list