Port-newsmips archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

NWS-5000 Xserver.



I've made the X server for NWS-5000. If there are no objections,
I'd like to commit this.

diff --exclude CVS -urN 
/work2/cvsrep/dist/src/distrib/sets/lists/comp/md.newsmips 
./distrib/sets/lists/comp/md.newsmips
--- /work2/cvsrep/dist/src/distrib/sets/lists/comp/md.newsmips  2004-05-09 
06:53:23.000000000 +0900
+++ ./distrib/sets/lists/comp/md.newsmips       2004-07-26 22:58:00.000000000 
+0900
@@ -61,4 +61,5 @@
 ./usr/include/newsmips/varargs.h               comp-c-include
 ./usr/include/newsmips/vmparam.h               comp-c-include
 ./usr/include/newsmips/wchar_limits.h          comp-c-include
+./usr/include/newsmips/wsconsio.h              comp-c-include
 ./usr/include/newsmips/z8530var.h              comp-c-include
diff --exclude CVS -urN 
/work2/cvsrep/dist/src/distrib/sets/lists/xserver/md.newsmips 
./distrib/sets/lists/xserver/md.newsmips
--- /work2/cvsrep/dist/src/distrib/sets/lists/xserver/md.newsmips       
1970-01-01 09:00:00.000000000 +0900
+++ ./distrib/sets/lists/xserver/md.newsmips    2004-07-26 22:59:53.000000000 
+0900
@@ -0,0 +1,5 @@
+# $NetBSD: md.hpcsh,v 1.2 2004/03/28 06:48:43 jmc Exp $
+./usr/X11R6/bin/X
+./usr/X11R6/bin/Xnewsmips
+./usr/X11R6/man/cat1/Xnewsmips.0               -unknown-               .cat
+./usr/X11R6/man/man1/Xnewsmips.1               -unknown-               .man
diff --exclude CVS -urN /work2/cvsrep/dist/src/sys/arch/newsmips/apbus/xafb.c 
./sys/arch/newsmips/apbus/xafb.c
--- /work2/cvsrep/dist/src/sys/arch/newsmips/apbus/xafb.c       2003-11-13 
12:09:28.000000000 +0900
+++ ./sys/arch/newsmips/apbus/xafb.c    2004-07-26 22:56:25.000000000 +0900
@@ -43,7 +43,7 @@
 #include <machine/adrsmap.h>
 #include <machine/apcall.h>
 
-#include <dev/wscons/wsconsio.h>
+#include <machine/wsconsio.h>
 #include <dev/wscons/wsdisplayvar.h>
 #include <dev/rasops/rasops.h>
 
@@ -62,6 +62,7 @@
 
 struct xafb_devconfig {
        volatile u_char *dc_fbbase;     /* VRAM base address */
+       paddr_t dc_fbpaddr;             /* VRAM physical address */
        struct xafb_reg *dc_reg;        /* register address */
        struct rasops_info dc_ri;
 };
@@ -160,8 +161,8 @@
        } else {
                dc = malloc(sizeof(struct xafb_devconfig), M_DEVBUF, M_WAITOK);
                bzero(dc, sizeof(struct xafb_devconfig));
-
-               dc->dc_fbbase = (void *)0xb0000000;             /* XXX */
+               dc->dc_fbpaddr = (paddr_t)0x10000000;
+               dc->dc_fbbase = (void *)MIPS_PHYS_TO_KSEG1(dc->dc_fbpaddr);
                dc->dc_reg = (void *)(apa->apa_hwbase + 0x3000);
                if (xafb_common_init(dc) != 0) {
                        printf(": couldn't initialize device\n");
@@ -258,15 +259,18 @@
 {
        struct xafb_softc *sc = v;
        struct xafb_devconfig *dc = sc->sc_dc;
-       struct wsdisplay_fbinfo *wdf;
+       struct newsmips_wsdisplay_fbinfo *nwdf = (void *)data;
+       struct wsdisplay_fbinfo *wdf = (void *)data;
 
        switch (cmd) {
        case WSDISPLAYIO_GTYPE:
                *(int *)data = WSDISPLAY_TYPE_UNKNOWN;  /* XXX */
                return 0;
 
+       case NEWSMIPS_WSDISPLAYIO_GINFO:
+               nwdf->stride = dc->dc_ri.ri_stride;
+               /* FALLTHROUGH */
        case WSDISPLAYIO_GINFO:
-               wdf = (void *)data;
                wdf->height = dc->dc_ri.ri_height;
                wdf->width = dc->dc_ri.ri_width;
                wdf->depth = dc->dc_ri.ri_depth;
@@ -297,7 +301,7 @@
        if (offset >= (ri->ri_stride * ri->ri_height) || offset < 0)
                return -1;
 
-       return mips_btop((int)dc->dc_fbbase + offset);
+       return mips_btop(dc->dc_fbpaddr + offset);
 }
 
 int
@@ -359,7 +363,8 @@
        if (!xafb_is_console())
                return -1;
 
-       dc->dc_fbbase = (void *)0xb0000000;                     /* XXX */
+       dc->dc_fbpaddr = (paddr_t)0x10000000;
+       dc->dc_fbbase = (void *)MIPS_PHYS_TO_KSEG1(dc->dc_fbpaddr);
        dc->dc_reg = (void *)0xb4903000;                        /* XXX */
        xafb_common_init(dc);
 
diff --exclude CVS -urN 
/work2/cvsrep/dist/src/sys/arch/newsmips/include/Makefile 
./sys/arch/newsmips/include/Makefile
--- /work2/cvsrep/dist/src/sys/arch/newsmips/include/Makefile   2004-05-09 
06:51:50.000000000 +0900
+++ ./sys/arch/newsmips/include/Makefile        2004-07-26 22:54:05.000000000 
+0900
@@ -19,7 +19,7 @@
        setjmp.h signal.h stdarg.h \
        trap.h types.h \
        varargs.h vmparam.h \
-       wchar_limits.h \
+       wchar_limits.h wsconsio.h \
        z8530var.h
 
 .include <bsd.kinc.mk>
diff --exclude CVS -urN 
/work2/cvsrep/dist/src/sys/arch/newsmips/include/wsconsio.h 
./sys/arch/newsmips/include/wsconsio.h
--- /work2/cvsrep/dist/src/sys/arch/newsmips/include/wsconsio.h 1970-01-01 
09:00:00.000000000 +0900
+++ ./sys/arch/newsmips/include/wsconsio.h      2004-07-26 22:56:41.000000000 
+0900
@@ -0,0 +1,16 @@
+/*     $NetBSD$        */
+
+#ifndef _NEWSMIPS_WSCONSIO_H_
+#define        _NEWSMIPS_WSCONSIO_H_
+
+#include <dev/wscons/wsconsio.h>
+
+struct newsmips_wsdisplay_fbinfo {
+       struct wsdisplay_fbinfo wsdisplay_fbinfo;
+       u_int stride;
+};
+
+#define        NEWSMIPS_WSDISPLAYIO_GINFO                                      
        \
+       _IOR('n', 65, struct newsmips_wsdisplay_fbinfo)
+
+#endif /* !_NEWSMIPS_WSCONSIO_H_ */
diff --exclude CVS -urN /work2/cvsrep/dist/src/x11/Xserver/Makefile.common 
./x11/Xserver/Makefile.common
--- /work2/cvsrep/dist/src/x11/Xserver/Makefile.common  2004-04-23 
15:23:42.000000000 +0900
+++ ./x11/Xserver/Makefile.common       2004-07-26 02:48:28.000000000 +0900
@@ -37,6 +37,10 @@
 XSERVER_XDREAMCAST?=   yes
 .endif
 
+.if ${MACHINE} == "newsmips"
+XSERVER_XNEWSMIPS?=    yes
+.endif
+
 # XFree86 servers all need XFONT as well.
 .if ${MACHINE} == "i386" || ${MACHINE} == "amd64" || \
     ${MACHINE} == "macppc" || ${MACHINE} == "cats" || ${MACHINE} == "sgimips"
@@ -100,6 +104,8 @@
 XSERVER_XDECNETBSD?=   no
 # Does this platform build the Xdreamcast server?
 XSERVER_XDREAMCAST?=   no
+# Does this platform build the Xnewsmips server?
+XSERVER_XNEWSMIPS?=    no
 # Does this platform build the Xfree68 servers?
 XSERVER_XFREE68?=      no
 # Does this platform build XFree86 X server?
diff --exclude CVS -urN /work2/cvsrep/dist/src/x11/Xserver/Xserver/Makefile 
./x11/Xserver/Xserver/Makefile
--- /work2/cvsrep/dist/src/x11/Xserver/Xserver/Makefile 2004-03-29 
00:28:24.000000000 +0900
+++ ./x11/Xserver/Xserver/Makefile      2004-07-27 00:00:05.000000000 +0900
@@ -52,6 +52,10 @@
 SUBDIR+=       Xmacppc
 .endif
 
+.if ${XSERVER_XNEWSMIPS} != "no"
+SUBDIR+=       Xnewsmips
+.endif
+
 .if ${XSERVER_XPMAX} != "no"
 SUBDIR+=       Xpmax
 .endif
diff --exclude CVS -urN 
/work2/cvsrep/dist/src/x11/Xserver/Xserver/Makefile.Xserver 
./x11/Xserver/Xserver/Makefile.Xserver
--- /work2/cvsrep/dist/src/x11/Xserver/Xserver/Makefile.Xserver 2004-03-28 
23:30:38.000000000 +0900
+++ ./x11/Xserver/Xserver/Makefile.Xserver      2004-07-26 02:48:29.000000000 
+0900
@@ -11,7 +11,8 @@
                \
                hw/netbsd/macppc hw/netbsd/hpc hw/netbsd/x68k \
                hw/netbsd/mac68k hw/netbsd/amiga hw/netbsd/dec \
-               hw/netbsd/arm32vidc hw/netbsd/alpha hw/netbsd/dreamcast
+               hw/netbsd/arm32vidc hw/netbsd/alpha hw/netbsd/dreamcast \
+               hw/netbsd/newsmips
 
 .if !defined(LIBDIR.${_SL})
 LIBDIR.${_SL}!=        cd ${NETBSDSRCDIR}/x11/Xserver/${_SL} && ${PRINTOBJDIR}
diff --exclude CVS -urN 
/work2/cvsrep/dist/src/x11/Xserver/Xserver/Xnewsmips/Makefile 
./x11/Xserver/Xserver/Xnewsmips/Makefile
--- /work2/cvsrep/dist/src/x11/Xserver/Xserver/Xnewsmips/Makefile       
1970-01-01 09:00:00.000000000 +0900
+++ ./x11/Xserver/Xserver/Xnewsmips/Makefile    2004-07-26 03:32:02.000000000 
+0900
@@ -0,0 +1,31 @@
+#      $NetBSD$
+
+.include <bsd.own.mk>
+
+PROG=  Xnewsmips
+BINMODE=4711
+
+.include "../Makefile.Xserver"
+
+.PATH: ${X11SRCDIR.xc}/programs/Xserver/hw/netbsd/newsmips
+
+LDADD= ${LDADD.dix} ${LDADD.hw/netbsd/newsmips} ${LDADD.os} -lXfont \
+       -lfreetype ${LDADD.os} ${LDADD.cfb} ${LDADD.cfb16} ${LDADD.cfb} \
+       ${LDADD.mfb} ${LDADD.dix/xpstubs} ${LDADD.mi} ${LDADD.Xext/ext} \
+       ${LDADD.xkb} ${LDADD.xinput} ${LDADD.lbx} -llbxutil \
+       ${LDADD.dbe} ${LDADD.record} ${LDADD.xtrap} ${LDADD.GL/glx} \
+       ${LDADD.GL/GLcore} ${LDADD.randr} ${LDADD.render} -lXau \
+       -lXdmcp -lz -lm
+
+DPADD= ${DPADD.dix} ${DPADD.hw/netbsd/newsmips} ${LIBXFONT} \
+       ${LIBFREETYPE} ${DPADD.os} ${DPADD.cfb} ${DPADD.cfb16} \
+       ${DPADD.xkb} ${DPADD.mfb} ${DPADD.dix/xpstubs} ${DPADD.mi} \
+       ${DPADD.Xext/ext} ${DPADD.xkb} ${DPADD.xinput} ${DPADD.lbx} \
+       ${LIBLBXUTIL} ${DPADD.dbe} ${DPADD.record} ${DPADD.xtrap} \
+       ${DPADD.GL/glx} ${DPADD.GL/GLcore} ${DPADD.randr} ${DPADD.render} \
+       ${LIBXAU} ${LIBXDMCP} ${LIBZ} ${LIBM}
+
+SYMLINKS=      ${X11BINDIR}/Xnewsmips ${X11BINDIR}/X
+
+.include <bsd.x11.mk>
+.include <bsd.prog.mk>
diff --exclude CVS -urN 
/work2/cvsrep/dist/src/x11/Xserver/Xserver/Xnewsmips/Xnewsmips.c 
./x11/Xserver/Xserver/Xnewsmips/Xnewsmips.c
--- /work2/cvsrep/dist/src/x11/Xserver/Xserver/Xnewsmips/Xnewsmips.c    
1970-01-01 09:00:00.000000000 +0900
+++ ./x11/Xserver/Xserver/Xnewsmips/Xnewsmips.c 2004-06-23 04:09:53.000000000 
+0900
@@ -0,0 +1 @@
+/*     $NetBSD$        */
diff --exclude CVS -urN /work2/cvsrep/dist/src/x11/Xserver/hw/Makefile 
./x11/Xserver/hw/Makefile
--- /work2/cvsrep/dist/src/x11/Xserver/hw/Makefile      2004-02-07 
17:30:34.000000000 +0900
+++ ./x11/Xserver/hw/Makefile   2004-07-27 00:00:30.000000000 +0900
@@ -44,6 +44,10 @@
 SUBDIR+=netbsd/macppc
 .endif
 
+.if ${XSERVER_XNEWSMIPS} != "no"
+SUBDIR+=netbsd/newsmips
+.endif
+
 .if ${XSERVER_XSUN} != "no"
 SUBDIR+=sun
 .endif
diff --exclude CVS -urN 
/work2/cvsrep/dist/src/x11/Xserver/hw/netbsd/newsmips/Makefile 
./x11/Xserver/hw/netbsd/newsmips/Makefile
--- /work2/cvsrep/dist/src/x11/Xserver/hw/netbsd/newsmips/Makefile      
1970-01-01 09:00:00.000000000 +0900
+++ ./x11/Xserver/hw/netbsd/newsmips/Makefile   2004-07-26 03:15:02.000000000 
+0900
@@ -0,0 +1,32 @@
+#      $NetBSD: Makefile,v 1.2 2004/02/09 00:28:25 lukem Exp $
+
+.include "../../../Makefile.serverlib"
+
+.include <bsd.own.mk>
+
+LIB=   newsmips
+
+.PATH: ${X11SRCDIR.xc}/programs/Xserver/hw/netbsd/newsmips
+SRCS=  newsmipsInit.c newsmipsScreen.c newsmipsIo.c newsmipsKbd.c \
+       newsmipsMouse.c newsmipsFB.c newsmipsColormap.c \
+       newsmipsKeymap.c newsmipsInEx.c
+
+CPPFLAGS+=     -I${X11SRCDIR.xc}/programs/Xserver/hw/newsmips \
+               -I${X11SRCDIR.xc}/programs/Xserver \
+               -I${X11SRCDIR.xc}/programs/Xserver/mi \
+               -I${X11SRCDIR.xc}/programs/Xserver/mfb \
+               -I${X11SRCDIR.xc}/programs/Xserver/cfb \
+               -I${X11SRCDIR.xc}/programs/Xserver/cfb32 \
+               -I${X11SRCDIR.xc}/programs/Xserver/include \
+               -I${DESTDIR}${X11INCDIR}/X11 \
+               -I${X11SRCDIR.xc}/include/fonts \
+               -I${X11SRCDIR.xc}/include/extensions \
+               -I${XSERVERINCDIR}
+
+CPPFLAGS+=     -UXFree86LOADER -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+               -UXF86DRI -UXF86BIGFONT
+
+BUILDSYMLINKS= ../../../mi/miinitext.c newsmipsInEx.c
+
+.include <bsd.x11.mk>
+.include <bsd.lib.mk>
diff --exclude CVS -urN /work2/cvsrep/dist/src/x11/Xserver/xinput/Makefile 
./x11/Xserver/xinput/Makefile
--- /work2/cvsrep/dist/src/x11/Xserver/xinput/Makefile  2004-04-23 
14:56:47.000000000 +0900
+++ ./x11/Xserver/xinput/Makefile       2004-07-26 02:48:29.000000000 +0900
@@ -27,6 +27,7 @@
     ${MACHINE} == "pmax" || \
     ${MACHINE} == "sun3" || \
     ${MACHINE} == "dreamcast" || \
+    ${MACHINE} == "newsmips" || \
     ${MACHINE} == "vax"
 CPPFLAGS+=     -DXINPUT
 .endif
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/Imakefile 
./xfree/xc/programs/Xserver/hw/netbsd/newsmips/Imakefile
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/Imakefile  
    1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/Imakefile    2004-07-26 
02:51:03.000000000 +0900
@@ -0,0 +1,41 @@
+XCOMM $XConsortium: Imakefile,v 5.27 94/07/28 16:44:16 dpw Exp $
+
+#include <Server.tmpl>
+
+SRCS = newsmipsInit.c \
+       newsmipsScreen.c \
+       newsmipsIo.c \
+       newsmipsKbd.c \
+       newsmipsMouse.c \
+       newsmipsFB.c \
+       newsmipsColormap.c \
+       newsmipsKeymap.c
+
+OBJS = newsmipsInit.o \
+       newsmipsScreen.o \
+       newsmipsIo.o \
+       newsmipsKbd.o \
+       newsmipsMouse.o \
+       newsmipsFB.o \
+       newsmipsColormap.o \
+       newsmipsKeymap.o
+
+INCLUDES = -I. -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi -I$(SERVERSRC)/cfb \
+          -I$(SERVERSRC)/include -I$(SERVERSRC)/os \
+          -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+          ../mi/llib-lmi.ln ../cfb/llib-lcfb.ln
+
+NormalLibraryObjectRule()
+
+all::
+
+lintlib:
+
+NormalLibraryTarget(newsmips,$(OBJS))
+NormalLintTarget($(SRCS1))
+
+InstallManPage(Xnewsmips,$(MANDIR))
+
+DependTarget()
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/Xnewsmips.man
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/Xnewsmips.man
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/Xnewsmips.man
  1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/Xnewsmips.man        
2004-07-26 02:51:02.000000000 +0900
@@ -0,0 +1,48 @@
+.\"    $NetBSD: Xnewsmips.man,v 1.1 2004/02/07 02:39:07 rtr Exp $
+.\"
+.Dd Dec 23, 2003
+.Dt Xnewsmips 1
+.Os NetBSD
+.Sh NAME
+.Nm Xnewsmips
+.Nd X Window System Display Server for NetBSD/newsmips
+.Sh SYNOPSIS
+.Nm
+.Op Ar option ...
+.Sh DESCRIPTION
+.Nm
+is the server for Version 11 of the X Window System for 
+.Nx Ns /newsmips .
+It will normally be started by the
+.Xr xdm 1
+daemon or by a script that runs the program
+.Xr xinit 1 .
+.Sh SUPPORTED HARDWARE
+.Nm
+supports the builtin graphics controller on newsmips console,
+and it can be used as 8-bit color server.
+.Pp
+.Nm
+supports the builtin keyboard and the builtin mouse for input devices. 
+.Sh OPTIONS
+In addition to the normal server options described in the
+.Xr Xserver 1
+manual page.
+.Sh SEE ALSO
+.Xr X 1 ,
+.Xr Xserver 1 ,
+.Xr xdm 1 ,
+.Xr xinit 1 ,
+.Xr xkbcomp 1 ,
+.Xr xmodmap 1
+.Sh HISTORY
+.Nm
+was based on Xhpc server for
+.Nx Ns /hpcmips ,
+which was originally written by TAKEMURA Shin
+.Aq takemura%NetBSD.org@localhost ,
+and Xdreamcast which was ported by Yasushi Oshima
+.Aq oshimaya%sc.starcat.ne.jp@localhost .
+.Sh BUGS
+.Nm
+is still experimental, and there is no hardware acceleration support yet.
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmips.h 
./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmips.h
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmips.h 
    1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmips.h   2004-07-26 
23:25:57.000000000 +0900
@@ -0,0 +1,193 @@
+/* $XConsortium: sun.h,v 5.39.1.1 95/01/05 19:58:43 kaleb Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sun.h,v 3.2 1995/02/12 02:36:21 dawes 
Exp $ */
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+#ifndef _NEWSMIPS_H_
+#define        _NEWSMIPS_H_
+
+#include "Xos.h"
+#include "X.h"
+#include "Xproto.h"
+
+#include <stdlib.h>
+#include <termios.h>
+#include <signal.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <memory.h>
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/filio.h>
+#include <sys/ioctl.h>
+#include <sys/resource.h>
+
+#include <machine/wsconsio.h>
+#include <dev/wscons/wsdisplay_usl_io.h>
+
+extern int gettimeofday();
+
+/*
+ * Server specific headers
+ */
+#include "misc.h"
+#undef abs /* don't munge function prototypes in headers, sigh */
+#include "scrnintstr.h"
+#ifdef NEED_EVENTS
+# include "inputstr.h"
+#endif
+#include "input.h"
+#include "colormapst.h"
+#include "colormap.h"
+#include "cursorstr.h"
+#include "cursor.h"
+#include "dixstruct.h"
+#include "dix.h"
+#include "opaque.h"
+#include "resource.h"
+#include "servermd.h"
+#include "windowstr.h"
+
+/*
+ * ddx specific headers
+ */
+#ifndef PSZ
+#define        PSZ 8
+#endif
+
+#include "mipointer.h"
+
+extern int monitorResolution;
+
+/*
+ * MAXEVENTS is the maximum number of events the mouse and keyboard functions
+ * will read on a given call to their GetEvents vectors.
+ */
+#define        MAXEVENTS       32
+
+/* Given a struct timeval, convert its time into milliseconds... */
+#define        TVTOMILLI(tv)   (((tv).tv_usec/1000)+((tv).tv_sec*1000))
+#define        TSTOMILLI(ts)   (((ts).tv_nsec/1000000)+((ts).tv_sec*1000))
+
+typedef struct wscons_event newsmipsEvent;
+
+typedef struct s_newsmipsPtrPriv *newsmipsPtrPrivPtr;
+
+/*
+ * Data private to any newsmips keyboard.
+ */
+typedef struct {
+       int fd;         /* fd of device */
+       int type;       /* type of device */
+       int layout;     /* The type of the layout */
+       int click;      /* kbd click save state */
+       Leds leds;      /* last known LED state */
+} newsmipsKbdPrivRec, *newsmipsKbdPrivPtr;
+extern newsmipsKbdPrivRec newsmipsKbdPriv;
+
+/*
+ * Data private to any newsmips pointer.
+ */
+typedef struct s_newsmipsPtrPriv {
+       int fd;         /* fd of device */
+       int bmask;              /* last known button state */
+} newsmipsPtrPrivRec;
+extern newsmipsPtrPrivRec newsmipsPtrPriv;
+
+typedef struct {
+       BYTE key;
+       CARD8 modifiers;
+} newsmipsModmapRec;
+
+typedef struct {
+       unsigned char *fb;      /* Frame buffer itself */
+       int fd;                 /* frame buffer for ioctl()s, */
+       struct newsmips_wsdisplay_fbinfo info;
+       void (*EnterLeave)();   /* screen switch */
+       char *devname;          /* device name (e.g. "/dev/ttyE0") */
+} newsmipsFbRec, *newsmipsFbPtr;
+
+typedef struct {
+       ColormapPtr installedMap;
+       CloseScreenProcPtr CloseScreen;
+       void (*UpdateColormap)();
+       Bool hasHardwareCursor;
+} newsmipsScreenRec, *newsmipsScreenPtr;
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+#define        newsmipsError(str) {                                            
\
+       int mode;                                                       \
+       newsmipsSetDisplayMode(fileno(stderr),                  \
+           WSDISPLAYIO_MODE_EMUL, &mode);                              \
+       Error(str);                                                     \
+       newsmipsSetDisplayMode(fileno(stderr), mode, NULL);             \
+}
+
+#define        newsmipsErrorF(a) {                                             
\
+       int mode;                                                       \
+       newsmipsSetDisplayMode(fileno(stderr),                  \
+           WSDISPLAYIO_MODE_EMUL, &mode);                              \
+       ErrorF a;                                                       \
+       newsmipsSetDisplayMode(fileno(stderr), mode, NULL);             \
+}
+
+#define        newsmipsFatalError(a) {                                 \
+       int mode;                                                       \
+       newsmipsSetDisplayMode(fileno(stderr),                  \
+           WSDISPLAYIO_MODE_EMUL, &mode);                              \
+       FatalError a;                                                   \
+}
+
+/*
+ * newsmipsInit.c
+ */
+newsmipsFbPtr newsmipsGetScreenFb(ScreenPtr);
+
+/*
+ * newsmipsIo.c
+ */
+void newsmipsCleanupFd(int);
+void newsmipsEnqueueEvents(void);
+
+/*
+ * newsmipsKbd.c
+ */
+int newsmipsKbdProc(DeviceIntPtr, int);
+newsmipsEvent* newsmipsKbdGetEvents(newsmipsKbdPrivPtr, int *, Bool *);
+void newsmipsKbdEnqueueEvent(DeviceIntPtr, newsmipsEvent *);
+
+/*
+ * newsmipsMouse.c
+ */
+int newsmipsMouseProc(DeviceIntPtr, int);
+newsmipsEvent* newsmipsMouseGetEvents(newsmipsPtrPrivPtr, int *,
+    Bool *);
+void newsmipsMouseEnqueueEvent(DeviceIntPtr, newsmipsEvent *);
+
+/*
+ * newsmipsScreen.c
+ */
+pointer newsmipsMemoryMap(size_t, off_t, int);
+Bool newsmipsScreenInit(ScreenPtr);
+newsmipsScreenPtr newsmipsGetScreenPrivate(ScreenPtr);
+
+/*
+ * newsmipsFB.c
+ */
+Bool newsmipsFBInit(int, ScreenPtr, int, char **);
+int newsmipsSetDisplayMode(int, int, int *);
+
+#endif
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsColormap.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsColormap.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsColormap.c
     1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsColormap.c   
2004-07-26 02:51:02.000000000 +0900
@@ -0,0 +1,291 @@
+/* $XConsortium: sunCfb.c,v 1.15.1.2 95/01/12 18:54:42 kaleb Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunCfb.c,v 3.2 1995/02/12 02:36:22 
dawes Exp $ */
+/*
+Copyright (c) 1990  X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright (c) 1987 by the Regents of the University of California
+ * Copyright (c) 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from  sunCG4C.c for X11R3 by Tom Jarmolowski       */
+/****************************************************************/
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "newsmips.h"
+#include "cfb.h"
+
+#include <stdio.h>
+
+static void
+newsmipsUpdateColormap(pScreen, dex, count, rmap, gmap, bmap)
+       ScreenPtr       pScreen;
+       int             dex, count;
+       u_char  *rmap, *gmap, *bmap;
+{
+       struct wsdisplay_cmap cmap;
+       newsmipsFbPtr pFb = newsmipsGetScreenFb(pScreen);
+
+       cmap.index = dex;
+       cmap.count = count;
+       cmap.red = &rmap[dex];
+       cmap.green = &gmap[dex];
+       cmap.blue = &bmap[dex];
+
+       if (ioctl(pFb->fd, WSDISPLAYIO_PUTCMAP, &cmap) < 0) {
+               newsmipsError("UpdateColormap");
+               newsmipsFatalError(("UpdateColormap: WSDISPLAY_PUTCMAP 
failed\n"));
+       }
+}
+
+static void
+newsmipsInstallColormap(cmap)
+       ColormapPtr     cmap;
+{
+       newsmipsScreenPtr pPrivate = newsmipsGetScreenPrivate(cmap->pScreen);
+       newsmipsFbPtr pFb = newsmipsGetScreenFb(cmap->pScreen);
+       register int i;
+       register Entry *pent;
+       register VisualPtr pVisual = cmap->pVisual;
+       u_char    rmap[256], gmap[256], bmap[256];
+       unsigned long rMask, gMask, bMask;
+       int     oRed, oGreen, oBlue;
+
+       if (cmap == pPrivate->installedMap)
+               return;
+       if (pPrivate->installedMap)
+               WalkTree(pPrivate->installedMap->pScreen, TellLostMap,
+                   (pointer) &(pPrivate->installedMap->mid));
+       if ((pVisual->class | DynamicClass) == DirectColor) {
+               if (pVisual->ColormapEntries < 256) {
+                       rMask = pVisual->redMask;
+                       gMask = pVisual->greenMask;
+                       bMask = pVisual->blueMask;
+                       oRed = pVisual->offsetRed;
+                       oGreen = pVisual->offsetGreen;
+                       oBlue = pVisual->offsetBlue;
+               } else {
+                       rMask = gMask = bMask = 255;
+                       oRed = oGreen = oBlue = 0;
+               }
+               for (i = 0; i < 256; i++) {
+                       rmap[i] = cmap->red[(i & rMask) >> oRed].co.local.red 
>> 8;
+                       gmap[i] = cmap->green[(i & gMask) >> 
oGreen].co.local.green >> 8;
+                       bmap[i] = cmap->blue[(i & bMask) >> 
oBlue].co.local.blue >> 8;
+               }
+       } else {
+               for (i = 0, pent = cmap->red;
+                   i < pVisual->ColormapEntries;
+                   i++, pent++) {
+                       if (pent->fShared) {
+                               rmap[i] = pent->co.shco.red->color >> 8;
+                               gmap[i] = pent->co.shco.green->color >> 8;
+                               bmap[i] = pent->co.shco.blue->color >> 8;
+                       } else {
+                               rmap[i] = pent->co.local.red >> 8;
+                               gmap[i] = pent->co.local.green >> 8;
+                               bmap[i] = pent->co.local.blue >> 8;
+                       }
+               }
+       }
+       pPrivate->installedMap = cmap;
+       (*pPrivate->UpdateColormap) (cmap->pScreen, 0, 256, rmap, gmap, bmap);
+       WalkTree(cmap->pScreen, TellGainedMap, (pointer) &(cmap->mid));
+}
+
+static void
+newsmipsUninstallColormap(cmap)
+       ColormapPtr     cmap;
+{
+       newsmipsScreenPtr pPrivate = newsmipsGetScreenPrivate(cmap->pScreen);
+
+       if (cmap == pPrivate->installedMap) {
+               Colormap defMapID = cmap->pScreen->defColormap;
+
+               if (cmap->mid != defMapID) {
+                       ColormapPtr defMap;
+                       defMap = (ColormapPtr) LookupIDByType(defMapID, 
RT_COLORMAP);
+                       if (defMap)
+                               (*cmap->pScreen->InstallColormap)(defMap);
+                       else
+                               newsmipsErrorF(("newsmipsUninstallColormap: 
Can't find default colormap\n"));
+               }
+       }
+}
+
+static int
+newsmipsListInstalledColormaps(pScreen, pCmapList)
+       ScreenPtr       pScreen;
+       Colormap        *pCmapList;
+{
+       newsmipsScreenPtr pPrivate = newsmipsGetScreenPrivate(pScreen);
+
+       *pCmapList = pPrivate->installedMap->mid;
+       return (1);
+}
+
+static void
+newsmipsStoreColors(pmap, ndef, pdefs)
+       ColormapPtr     pmap;
+       int             ndef;
+       xColorItem      *pdefs;
+{
+       newsmipsScreenPtr pPrivate = newsmipsGetScreenPrivate(pmap->pScreen);
+       u_char  rmap[256], gmap[256], bmap[256];
+       xColorItem      expanddefs[256];
+       register int i;
+
+       if (pPrivate->installedMap != NULL && pPrivate->installedMap != pmap)
+               return;
+       if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+               ndef = cfbExpandDirectColors(pmap, ndef, pdefs, expanddefs);
+               pdefs = expanddefs;
+       }
+       while (ndef--) {
+               i = pdefs->pixel;
+               rmap[i] = pdefs->red >> 8;
+               gmap[i] = pdefs->green >> 8;
+               bmap[i] = pdefs->blue >> 8;
+               (*pPrivate->UpdateColormap) (pmap->pScreen, i, 1, rmap, gmap, 
bmap);
+               pdefs++;
+       }
+}
+
+Bool
+newsmipsInitializeColormap(pmap)
+       register ColormapPtr    pmap;
+{
+       int i;
+       VisualPtr pVisual;
+       ScreenPtr pScreen;
+       newsmipsFbPtr pFb;
+
+       pVisual = pmap->pVisual;
+       pScreen = pmap->pScreen;
+       pFb = newsmipsGetScreenFb(pScreen);
+
+       switch (pVisual->class) {
+       case StaticGray:
+       case GrayScale:
+               return FALSE;
+               break;
+       case StaticColor: {
+               struct wsdisplay_cmap cmap;
+               u_char    rmap[256], gmap[256], bmap[256];
+
+               cmap.index = 0;
+               cmap.count = 256;
+               cmap.red = rmap;
+               cmap.green = gmap;
+               cmap.blue = bmap;
+
+               if (ioctl(pFb->fd, WSDISPLAYIO_GETCMAP, &cmap) < 0) {
+                       newsmipsFatalError(("newsmipsInitialiseColormap: 
WSDISPLAY_GETCMAP failed\n"));
+               }
+               for (i = 0; i < 256; i++) {
+                       pmap->red[i].co.local.red = (long)rmap[i] << 8;
+                       pmap->red[i].co.local.green = (long)gmap[i] << 8;
+                       pmap->red[i].co.local.blue = (long)bmap[i] << 8;
+               }
+       }
+       break;
+       case PseudoColor:
+       case TrueColor:
+       case DirectColor:
+       default:
+               return FALSE;
+               break;
+       }
+}
+
+void
+newsmipsColormapInit (pScreen)
+       ScreenPtr pScreen;
+{
+       newsmipsScreenPtr pPrivate = newsmipsGetScreenPrivate(pScreen);
+       newsmipsFbPtr pFb = newsmipsGetScreenFb(pScreen);
+
+       if (pScreen->rootDepth == 8) {
+               pScreen->InstallColormap = newsmipsInstallColormap;
+               pScreen->UninstallColormap = newsmipsUninstallColormap;
+               pScreen->ListInstalledColormaps = 
newsmipsListInstalledColormaps;
+               pScreen->StoreColors = newsmipsStoreColors;
+               pPrivate->UpdateColormap = newsmipsUpdateColormap;
+       } else {
+               pScreen->InstallColormap = cfbInstallColormap;
+               pScreen->UninstallColormap = cfbUninstallColormap;
+               pScreen->ListInstalledColormaps = cfbListInstalledColormaps;
+               pScreen->StoreColors = (void (*)())NoopDDA;
+       }
+}
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsFB.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsFB.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsFB.c
   1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsFB.c 2004-07-26 
23:13:01.000000000 +0900
@@ -0,0 +1,198 @@
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to 
+distribution  of  the software  without specific prior 
+written permission. Sun and X Consortium make no 
+representations about the suitability of this software for 
+any purpose. It is provided "as is" without any express or 
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#include "newsmips.h"
+
+#define        FORCE_SEPARATE_PRIVATE
+#include "cfb.h"
+#include <stdio.h>
+
+extern BSFuncRec cfbBSFuncRec;
+Bool newsmips8ScreenInit(ScreenPtr, pointer,   int, int, int, int, int);
+
+Bool
+newsmipsFBInit(
+       int screen,             /* what screen am I going to be */
+       ScreenPtr pScreen,      /* The Screen to initialize */
+       int argc,               /* The number of the Server's arguments. */
+       char **argv             /* The arguments themselves. Don't change! */
+    )
+{
+       int res;
+       newsmipsFbPtr pFb = newsmipsGetScreenFb(pScreen);
+       unsigned char *fb = pFb->fb;
+       int rowsize;
+       struct newsmips_wsdisplay_fbinfo *nfbconf = &pFb->info;
+       struct wsdisplay_fbinfo *fbconf = &nfbconf->wsdisplay_fbinfo;
+
+       pFb->EnterLeave = (void (*)())NoopDDA;
+
+       if (!newsmipsAllocateScreenPrivate(pScreen))
+               return FALSE;
+
+       if (!fb) {
+               if (ioctl(pFb->fd, NEWSMIPS_WSDISPLAYIO_GINFO, nfbconf) < 0) {
+                       newsmipsError("ioctl(NEWSMIPS_WSDISPLAYIO_GINFO)");
+                       return FALSE;
+               }
+
+               if (newsmipsSetDisplayMode(pFb->fd, WSDISPLAYIO_MODE_MAPPED,
+                   NULL) < 0) {
+                       newsmipsError("ioctl(WSDISPLAYIO_MODE_MAPPED)");
+                       return FALSE;
+               }
+
+               fb = newsmipsMemoryMap((size_t)nfbconf->stride *
+                   fbconf->height * fbconf->depth / 8, 0, pFb->fd);
+               if (fb == NULL) {
+                       newsmipsError("can't map frame buffer.");
+                       return FALSE;
+               }
+
+               pFb->fb = fb;
+       }
+
+       switch (fbconf->depth) {
+       case 8:
+               res = newsmips8ScreenInit(pScreen, fb,
+                   fbconf->width,
+                   fbconf->height,
+                   monitorResolution, monitorResolution,
+                   nfbconf->stride);
+               break;
+       default:
+               newsmipsErrorF(("%dbpp frame buffer is not supported\n",
+                   fbconf->depth));
+               return FALSE;
+       }
+
+       if (!res)
+               return FALSE;
+
+       /*
+        * It seems that backing store can't work.
+        */
+       pScreen->backingStoreSupport = NotUseful;
+
+       newsmipsColormapInit(pScreen);
+
+       if (!newsmipsScreenInit(pScreen))
+               return FALSE;
+       (void)(*pScreen->SaveScreen)(pScreen, SCREEN_SAVER_OFF);
+
+       res = cfbCreateDefColormap(pScreen);
+
+       return res;
+}
+
+int
+newsmipsSetDisplayMode(int fd, int mode, int *prevmode)
+{
+
+       if (prevmode != NULL) {
+               if (ioctl(fd, WSDISPLAYIO_GMODE, prevmode) < 0) {
+                       newsmipsError("ioctl(WSDISPLAYIO_GMODE)");
+                       return -1;
+               }
+       }
+
+       if (prevmode == NULL || *prevmode != mode) {
+               if (ioctl(fd, WSDISPLAYIO_SMODE, &mode) < 0) {
+                       newsmipsError("ioctl(WSDISPLAYIO_SMODE)");
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+Bool
+newsmips8ScreenInit(
+       ScreenPtr pScreen,
+       pointer pbits,          /* pointer to screen bitmap */
+       int xsize, int ysize,   /* in pixels */
+       int dpix, int dpiy,     /* dots per inch */
+       int width               /* pixel width of frame buffer */
+    )
+{
+       int i, j;
+       VisualPtr visuals;
+       DepthPtr depths;
+       int nvisuals;
+       int ndepths;
+       int rootdepth;
+       VisualID defaultVisual;
+       VisualID *vid = NULL;
+
+       if (!cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width))
+               return FALSE;
+
+       ndepths = 1;
+       nvisuals = 1;
+       depths = (DepthPtr)xalloc(sizeof(DepthRec));
+       visuals = (VisualPtr)xalloc(sizeof(VisualRec));
+       vid = (VisualID *)xalloc( sizeof(VisualID));
+       if (!depths || !visuals || !vid) {
+               xfree(depths);
+               xfree(visuals);
+               xfree(vid);
+               return FALSE;
+       }
+
+       depths[0].depth = 8;
+       depths[0].numVids = 1;
+       depths[0].vids = vid;
+       visuals[0].class = PseudoColor;
+       visuals[0].bitsPerRGBValue = 8;
+       visuals[0].ColormapEntries = 256;
+       visuals[0].nplanes = 1;
+       visuals[0].vid = *vid = FakeClientID(0);
+       visuals[0].redMask   = 0x00e0;
+       visuals[0].greenMask = 0x001c;
+       visuals[0].blueMask  = 0x0003;
+       visuals[0].offsetRed   = 5;
+       visuals[0].offsetGreen = 2;
+       visuals[0].offsetBlue  = 0;
+       rootdepth = 8;
+       defaultVisual = *vid;
+
+       if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+           rootdepth, ndepths, depths, defaultVisual, nvisuals, visuals))
+               return FALSE;
+
+       /* overwrite miCloseScreen with our own */
+       pScreen->CloseScreen = cfbCloseScreen;
+
+       /* init backing store here so we can overwrite CloseScreen
+        * without stepping on the backing store wrapped version */
+       pScreen->BackingStoreFuncs = cfbBSFuncRec;
+
+       return TRUE;
+}
+
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsInit.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsInit.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsInit.c
 1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsInit.c       
2004-07-27 00:39:15.000000000 +0900
@@ -0,0 +1,401 @@
+/*     $NetBSD$        */
+
+#include "newsmips.h"
+#include "gcstruct.h"
+#include "mibstore.h"
+#include "cfb.h"
+
+#include <stdio.h>
+#include <unistd.h>
+
+#include <dev/wscons/wsksymdef.h>
+
+static Bool newsmipsDevsInited = FALSE;
+
+newsmipsKbdPrivRec newsmipsKbdPriv = {
+       -1,             /* fd */
+       -1,             /* keyboard type */
+       -1,             /* layout */
+       0,              /* click */
+       (Leds)0,        /* leds */
+};
+
+newsmipsPtrPrivRec newsmipsPtrPriv = {
+       -1,             /* fd */
+       0,              /* last known button state */
+};
+
+/*
+ * a list of devices to try if there is no environment or command
+ * line list of devices
+ */
+static char *fallbackList[] = {
+       "/dev/ttyE0", "/dev/ttyE1", "/dev/ttyE2", "/dev/ttyE3",
+};
+#define        FALLBACK_LIST_LEN       (sizeof fallbackList / sizeof 
fallbackList[0])
+
+newsmipsFbRec newsmipsFbs[MAXSCREENS];
+
+static PixmapFormatRec formats[] = {
+       { 8,    8,      BITMAP_SCANLINE_PAD },
+};
+#define        NUMFORMATS      ((sizeof formats) / (sizeof formats[0]))
+
+newsmipsFbPtr
+newsmipsGetScreenFb(ScreenPtr pScreen)
+{
+
+       return &newsmipsFbs[pScreen->myNum];
+}
+
+/*
+ * OpenFrameBuffer --
+ *     Open a frame buffer according to several rules.
+ *
+ * Results:
+ *     The fd of the framebuffer.
+ */
+static int
+OpenFrameBuffer(char *device, int screen)
+{
+       int ret = TRUE;
+
+       newsmipsFbs[screen].fd = -1;
+       newsmipsFbs[screen].devname = device;
+       if (access(device, R_OK | W_OK) == -1)
+               return FALSE;
+
+       if ((newsmipsFbs[screen].fd = open(device, O_RDWR, 0)) == -1) {
+               newsmipsError(device);
+               ret = FALSE;
+       } else {
+               int mode = WSDISPLAYIO_MODE_MAPPED;
+
+               if (ioctl(newsmipsFbs[screen].fd, WSDISPLAYIO_SMODE, &mode)
+                   == -1) {
+                       newsmipsError("unable to set frame buffer mode");
+               }
+
+               if (ioctl(newsmipsFbs[screen].fd, WSDISPLAYIO_GINFO,
+                   &newsmipsFbs[screen].info) == -1) {
+                       newsmipsError("unable to get frame buffer info");
+                       (void)close(newsmipsFbs[screen].fd);
+                       newsmipsFbs[screen].fd = -1;
+                       ret = FALSE;
+               }
+       }
+
+       if (!ret)
+               newsmipsFbs[screen].fd = -1;
+
+       return ret;
+}
+
+/*
+ * SigIOHandler --
+ *     Signal handler for SIGIO - input is available.
+ *
+ * Results:
+ *     newsmipsSigIO is set - ProcessInputEvents() will be called soon.
+ *
+ * Side Effects:
+ *     None
+ *
+ */
+static void
+SigIOHandler(int sig)
+{
+       int olderrno = errno;
+
+       newsmipsEnqueueEvents();
+       errno = olderrno;
+}
+
+static char**
+GetDeviceList(int argc, char **argv)
+{
+       int i;
+       char *envList = NULL;
+       char *cmdList = NULL;
+       char **deviceList = (char **)NULL;
+       char *ttyn = NULL;
+       char *p;
+       int ttyfd = -1;
+       char ttyE0[] = "/dev/ttyE0";
+
+       for (i = 1; i < argc; i++)
+               if (strcmp (argv[i], "-dev") == 0 && i+1 < argc) {
+                       cmdList = argv[i + 1];
+                       break;
+               }
+
+       if (!cmdList)
+               envList = getenv ("XDEVICE");
+
+       if (!cmdList && !envList) {
+               if (isatty(2))
+                       ttyfd = 2;
+               else if (isatty(0))
+                       ttyfd = 0;
+               else if (isatty(1))
+                       ttyfd = 1;
+
+               if (ttyfd >= 0) {
+                       if ((p = ttyname(ttyfd)) == NULL)
+                               ttyn = ttyE0;
+                       else if (strncmp(p, ttyE0, strlen(ttyE0)-1) == 0)
+                               ttyn = p;
+                       else
+                               ttyn = ttyE0;
+               } else
+                       ttyn = ttyE0;
+       }
+
+       if (cmdList || envList || ttyn) {
+               char *_tmpa;
+               char *_tmpb;
+               int _i1;
+               deviceList = (char **)xalloc((MAXSCREENS + 1) * sizeof(char *));
+               _tmpa = (cmdList) ? cmdList : (envList) ? envList : ttyn;
+               for (_i1 = 0; _i1 < MAXSCREENS; _i1++) {
+                       _tmpb = strtok (_tmpa, ":");
+                       if (_tmpb)
+                               deviceList[_i1] = strdup(_tmpb);
+                       else
+                               deviceList[_i1] = NULL;
+                       _tmpa = NULL;
+               }
+               deviceList[MAXSCREENS] = NULL;
+       }
+
+       return deviceList;
+}
+
+void
+OsVendorInit()
+{
+}
+
+void
+InitKbdMouse(int argc, char **argv)
+{
+       extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
+       struct wskbd_keyrepeat_data keyrepeat;
+       struct rlimit rl;
+       int maxfds, kbdtype, i;
+       char **devList;
+       static int inited;
+
+       if (inited)
+               return;
+       inited = TRUE;
+
+       /*
+        * one per client, one per screen, one per listen endpoint,
+        * keyboard, mouse, and stderr
+        */
+       maxfds = MAXCLIENTS + MAXSCREENS + 5;
+
+       if (getrlimit(RLIMIT_NOFILE, &rl) == 0) {
+               rl.rlim_cur = maxfds < rl.rlim_max ? maxfds : rl.rlim_max;
+               (void) setrlimit(RLIMIT_NOFILE, &rl);
+       }
+
+       newsmipsKbdPriv.fd = newsmipsPtrPriv.fd = -1;
+
+       /*
+        * use mouse multiplexer if it's available.
+        */
+       newsmipsKbdPriv.fd = open("/dev/wskbd", O_RDWR);
+       newsmipsPtrPriv.fd = open("/dev/wsmouse", O_RDWR);
+
+       /*
+        * try each mouse device
+        */
+       for (i = 0; i < 8; i++) {
+               char devname[16];
+
+               if (newsmipsKbdPriv.fd == -1) {
+                       sprintf(devname, "/dev/wskbd%d", i);
+                       newsmipsKbdPriv.fd = open(devname, O_RDWR);
+               }
+
+               if (newsmipsPtrPriv.fd == -1) {
+                       sprintf(devname, "/dev/wsmouse%d", i);
+                       if ((newsmipsPtrPriv.fd = open(devname, O_RDWR)) < 0)
+                               newsmipsError(devname);
+               }
+       }
+
+       if (newsmipsKbdPriv.fd == -1)
+               newsmipsFatalError(("Can't open keyboard device\n"));
+       if (newsmipsPtrPriv.fd == -1)
+               newsmipsFatalError(("Can't open pointer device\n"));
+
+       if (ioctl(newsmipsKbdPriv.fd, WSKBDIO_GTYPE, &kbdtype) == -1) {
+               newsmipsError("cannot get keyboard type\n");
+               kbdtype = -1;
+       }
+
+       /* Set keyrepeat */
+       if (ioctl(newsmipsKbdPriv.fd, WSKBDIO_GETKEYREPEAT, &keyrepeat) == -1)
+       {
+               newsmipsErrorF(("can't get keyrepeat configuration."
+                   "(not fatal)\n"));
+       } else {
+               XkbDfltRepeatDelay = keyrepeat.del1;
+               XkbDfltRepeatInterval = keyrepeat.delN;
+               newsmipsErrorF(("key repeat (%d/%d)\n", XkbDfltRepeatDelay,
+                   XkbDfltRepeatInterval));
+       }
+
+       newsmipsKbdPriv.layout = 0;     /* Now has only JP keyboard keymap */
+
+       noXkbExtension = FALSE;
+}
+
+/*
+ * InitOutput --
+ *     Initialize screenInfo for all actually accessible framebuffers.
+ *     The
+ *
+ * Results:
+ *     screenInfo init proc field set
+ *
+ * Side Effects:
+ *     None
+ */
+void
+InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
+{
+       int i, scr;
+       int nonBlockConsole = 0;
+       char **devList;
+       static int setup_on_exit = 0;
+       extern Bool RunFromSmartParent;
+       newsmipsScreenPtr pPrivate;
+
+       if (!monitorResolution)
+               monitorResolution = 75;
+       if (RunFromSmartParent)
+               nonBlockConsole = 1;
+       for (i = 1; i < argc; i++) {
+               if (!strcmp(argv[i],"-debug"))
+                       nonBlockConsole = 0;
+       }
+
+       pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+       pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+       pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+       pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+       pScreenInfo->numPixmapFormats = NUMFORMATS;
+       for (i=0; i< NUMFORMATS; i++)
+               pScreenInfo->formats[i] = formats[i];
+
+       if (!newsmipsDevsInited) {
+               /* first time ever */
+               for (scr = 0; scr < MAXSCREENS; scr++)
+                       newsmipsFbs[scr].fd = -1;
+               devList = GetDeviceList (argc, argv);
+               for (i = 0, scr = 0; devList[i] != NULL && scr < MAXSCREENS;
+                   i++) {
+                       if (OpenFrameBuffer (devList[i], scr))
+                               scr++;
+               }
+               newsmipsDevsInited = TRUE;
+               xfree (devList);
+       }
+
+       for (scr = 0; scr < MAXSCREENS; scr++)
+               if (newsmipsFbs[scr].fd != -1)
+                       (void) AddScreen (newsmipsFBInit, argc, argv);
+       (void) OsSignal(SIGWINCH, SIG_IGN);
+}
+
+/*
+ * InitInput --
+ *     Initialize all supported input devices...what else is there
+ *     besides pointer and keyboard?
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     Two DeviceRec's are allocated and registered as the system pointer
+ *     and keyboard devices.
+ */
+void
+InitInput(int argc, char **argv)
+{
+       DeviceIntPtr p, k;
+       int fd;
+       extern Bool mieqInit();
+
+       InitKbdMouse(argc, argv);
+
+       p = AddInputDevice(newsmipsMouseProc, TRUE);
+       k = AddInputDevice(newsmipsKbdProc, TRUE);
+       if (!p || !k)
+               newsmipsFatalError(("failed to create input devices"
+                   " in InitInput"));
+
+       RegisterPointerDevice(p);
+       RegisterKeyboardDevice(k);
+       miRegisterPointerDevice(screenInfo.screens[0], p);
+       mieqInit(k, p);
+       OsSignal(SIGIO, SigIOHandler);
+
+       if ((fd = newsmipsKbdPriv.fd) >= 0) {
+               if (fcntl(fd, F_SETFL, FNDELAY | FASYNC) == -1 ||
+                   fcntl(fd, F_SETOWN, getpid()) == -1) {
+                       close(fd);
+                       newsmipsKbdPriv.fd = -1;
+                       newsmipsFatalError(("Async kbd I/O failed in"
+                           " InitInput"));
+               }
+       }
+
+       if ((fd = newsmipsPtrPriv.fd) >= 0) {
+               if (fcntl(fd, F_SETFL, FNDELAY | FASYNC) == -1 ||
+                   fcntl(fd, F_SETOWN, getpid()) == -1) {
+                       close(fd);
+                       newsmipsPtrPriv.fd = -1;
+                       newsmipsFatalError(("Async mouse I/O failed in"
+                           "  InitInput"));
+               }
+       }
+}
+
+/*#ifdef DDXOSFATALERROR*/
+void OsVendorFatalError(void)
+{
+}
+/*#endif*/
+
+#ifdef DPMSExtension
+/**************************************************************
+ * DPMSSet(), DPMSGet(), DPMSSupported()
+ *
+ * stubs
+ *
+ ***************************************************************/
+void
+DPMSSet(int level)
+{
+}
+
+int
+DPMSGet(int *level)
+{
+
+       return -1;
+}
+
+Bool
+DPMSSupported ()
+{
+
+       return FALSE;
+}
+#endif /* DPMSExtension */
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsIo.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsIo.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsIo.c
   1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsIo.c 2004-07-26 
02:51:01.000000000 +0900
@@ -0,0 +1,219 @@
+/* $XConsortium: sunIo.c,v 5.26.1.3 95/01/25 23:02:33 kaleb Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sun/sunIo.c,v 3.1 1995/01/28 15:46:06 
dawes Exp $ */
+/*-
+ * sunIo.c --
+ *     Functions to handle input from the keyboard and mouse.
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#include <stdio.h>
+
+#define        NEED_EVENTS
+#include "newsmips.h"
+
+void
+newsmipsCleanupFd(int fd)
+{
+       int n;
+       char buf[100];
+
+       while (0 < (n = read(fd, buf, sizeof(buf)))) {
+               ;
+       }
+}
+
+/*
+ * ProcessInputEvents --
+ *     Retrieve all waiting input events and pass them to DIX in their
+ *     correct chronological order. Only reads from the system pointer
+ *     and keyboard.
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     Events are passed to the DIX layer.
+ */
+void
+ProcessInputEvents ()
+{
+       (void) mieqProcessInputEvents ();
+       miPointerUpdate ();
+}
+
+/*
+ * newsmipsEnqueueEvents
+ *     When a SIGIO is received, read device hard events and
+ *     enqueue them using the mi event queue
+ */
+void
+newsmipsEnqueueEvents ()
+{
+       newsmipsEvent *ptrEvents;    /* Current pointer event */
+       newsmipsEvent *kbdEvents;    /* Current keyboard event */
+       int numPtrEvents;       /* Number of remaining pointer events */
+       int numKbdEvents;       /* Number of remaining keyboard events */
+       int nPE;                /* Original number of pointer events */
+       int nKE;                /* Original number of keyboard events */
+       Bool PtrAgain;          /* need to (re)read */
+       Bool KbdAgain;          /* need to (re)read */
+       DeviceIntPtr pPointer;
+       DeviceIntPtr pKeyboard;
+       newsmipsKbdPrivPtr kbdPriv;
+       newsmipsPtrPrivPtr ptrPriv;
+
+       pPointer = (DeviceIntPtr)LookupPointerDevice();
+       pKeyboard = (DeviceIntPtr)LookupKeyboardDevice();
+       ptrPriv = (newsmipsPtrPrivPtr) pPointer->public.devicePrivate;
+       kbdPriv = (newsmipsKbdPrivPtr) pKeyboard->public.devicePrivate;
+       if (!pPointer->public.on || !pKeyboard->public.on)
+               return;
+
+       numPtrEvents = 0;
+       PtrAgain = TRUE;
+       numKbdEvents = 0;
+       KbdAgain = TRUE;
+
+       /*
+        * So long as one event from either device remains unprocess, we loop:
+        * Take the oldest remaining event and pass it to the proper module
+        * for processing. The DDXEvent will be sent to ProcessInput by the
+        * function called.
+        */
+       while (1) {
+               /*
+                * Get events from both the pointer and the keyboard,
+                * storing the number of events gotten in nPE and nKE
+                * and keeping the start of both arrays in pE and kE
+                */
+               if ((numPtrEvents == 0) && PtrAgain) {
+                       ptrEvents = newsmipsMouseGetEvents(ptrPriv, &nPE,
+                           &PtrAgain);
+                       numPtrEvents = nPE;
+               }
+               if ((numKbdEvents == 0) && KbdAgain) {
+                       kbdEvents = newsmipsKbdGetEvents(kbdPriv, &nKE,
+                           &KbdAgain);
+                       numKbdEvents = nKE;
+               }
+               if ((numPtrEvents == 0) && (numKbdEvents == 0))
+                       break;
+               if (numPtrEvents && numKbdEvents) {
+                       if (timespeccmp (&kbdEvents->time,
+                           &ptrEvents->time, <)) {
+                               newsmipsKbdEnqueueEvent(pKeyboard,
+                                   kbdEvents);
+                               numKbdEvents--;
+                               kbdEvents++;
+                       } else {
+                               newsmipsMouseEnqueueEvent(pPointer,
+                                   ptrEvents);
+                               numPtrEvents--;
+                               ptrEvents++;
+                       }
+               } else if (numKbdEvents) {
+                       newsmipsKbdEnqueueEvent(pKeyboard, kbdEvents);
+                       numKbdEvents--;
+                       kbdEvents++;
+               } else {
+                       newsmipsMouseEnqueueEvent(pPointer, ptrEvents);
+                       numPtrEvents--;
+                       ptrEvents++;
+               }
+       }
+}
+
+/*
+ * DDX - specific abort routine.  Called by AbortServer().
+ */
+void
+AbortDDX()
+{
+       int i;
+       ScreenPtr pScreen;
+       newsmipsFbPtr pFb;
+       DevicePtr devPtr;
+
+       OsSignal(SIGIO, SIG_IGN);
+       for (i = 0; i < screenInfo.numScreens; i++)
+       {
+               int mode = WSDISPLAYIO_MODE_EMUL;
+               pScreen = screenInfo.screens[i];
+               pFb = newsmipsGetScreenFb(pScreen);
+               (*pScreen->SaveScreen)(pScreen, SCREEN_SAVER_OFF);
+               ioctl(pFb->fd, WSDISPLAYIO_SMODE, &mode);
+       }
+}
+
+/* Called by GiveUp(). */
+void
+ddxGiveUp()
+{
+
+       AbortDDX ();
+}
+
+int
+ddxProcessArgument(int argc, char *argv[], int i)
+{
+       extern void UseMsg();
+
+       if (strcmp (argv[i], "-debug") == 0) {  /* -debug */
+               return 1;
+       }
+       if (strcmp (argv[i], "-dev") == 0) {    /* -dev /dev/mumble */
+               if (++i >= argc)
+                       UseMsg ();
+               return 2;
+       }
+       return 0;
+}
+
+void
+ddxUseMsg()
+{
+
+       newsmipsErrorF(("-debug              disable non-blocking"
+           " console mode\n"));
+       newsmipsErrorF(("-dev fn[:fn][:fn]   name of device[s] to open\n"));
+}
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKbd.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKbd.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKbd.c
  1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKbd.c        
2004-07-26 02:51:01.000000000 +0900
@@ -0,0 +1,229 @@
+/* $XConsortium: sunKbd.c,v 5.47 94/08/16 13:45:30 dpw Exp $ */
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#define        NEED_EVENTS
+#include "newsmips.h"
+#include "keysym.h"
+#include <stdio.h>
+#include <sys/time.h>
+#include <X11/extensions/XKB.h>
+
+extern KeySymsRec newsmipsKeySyms[];
+extern newsmipsModmapRec *newsmipsModMaps[];
+
+/*
+ * newsmipsBell --
+ *     Ring the terminal/keyboard bell
+ *
+ * Results:
+ *     Ring the keyboard bell for an amount of time proportional to
+ *     "loudness."
+ *
+ * Side Effects:
+ *     None, really...
+ */
+static void
+newsmipsBell(int percent, /* Percentage of full volume */
+    DeviceIntPtr device, pointer ctrl, int unused)
+{
+       /* None */
+}
+
+/*
+ * newsmipsKbdCtrl --
+ *     Alter some of the keyboard control parameters
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     Some...
+ */
+static void
+newsmipsKbdCtrl(DeviceIntPtr device, KeybdCtrl *ctrl)
+{
+
+       newsmipsKbdPrivPtr pPriv =
+           (newsmipsKbdPrivPtr)device->public.devicePrivate;
+
+       if (pPriv->fd < 0)
+               return;
+
+       /* Bell info change needs nothing done here. */
+}
+
+/*
+ * newsmipsKbdProc --
+ *     Handle the initialization, etc. of a keyboard.
+ *
+ * Results:
+ *     None.
+ */
+int
+newsmipsKbdProc(DeviceIntPtr  device, int what)
+{
+       int i;
+       DevicePtr pKeyboard = (DevicePtr) device;
+       newsmipsKbdPrivPtr pPriv;
+       KeybdCtrl *ctrl = &device->kbdfeed->ctrl;
+       extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
+       struct termios tkbdtty;
+
+       static CARD8 *workingModMap = NULL;
+       static KeySymsRec *workingKeySyms;
+
+       switch (what) {
+       case DEVICE_INIT:
+               if (pKeyboard != LookupKeyboardDevice()) {
+                       newsmipsErrorF(("Cannot open non-system"
+                           " keyboard\n"));
+                       return (!Success);
+               }
+
+               if (!workingKeySyms) {
+                       workingKeySyms =
+                           &newsmipsKeySyms[newsmipsKbdPriv.layout];
+                       if (workingKeySyms->minKeyCode < XkbMinLegalKeyCode) {
+                               workingKeySyms->minKeyCode +=
+                                   XkbMinLegalKeyCode;
+                               workingKeySyms->maxKeyCode +=
+                                   XkbMinLegalKeyCode;
+                       }
+               }
+
+               if (!workingModMap) {
+                       int layout = newsmipsKbdPriv.layout;
+                       newsmipsModmapRec *rec = newsmipsModMaps[layout];
+                       workingModMap=(CARD8 *)xalloc(MAP_LENGTH);
+                       memset(workingModMap, 0, MAP_LENGTH);
+                       for (i = 0; rec[i].key != 0; i++)
+                               workingModMap[rec[i].key + XkbMinLegalKeyCode] =
+                                   rec[i].modifiers;
+               }
+
+               (void) memset ((void *) defaultKeyboardControl.autoRepeats,
+                   ~0, sizeof defaultKeyboardControl.autoRepeats);
+
+               pKeyboard->devicePrivate = (pointer)&newsmipsKbdPriv;
+               pKeyboard->on = FALSE;
+
+               InitKeyboardDeviceStruct(pKeyboard,
+                   workingKeySyms, workingModMap,
+                   newsmipsBell, newsmipsKbdCtrl);
+               break;
+
+       case DEVICE_ON:
+               pPriv = (newsmipsKbdPrivPtr)pKeyboard->devicePrivate;
+               newsmipsCleanupFd(pPriv->fd);
+               AddEnabledDevice(pPriv->fd);
+               pKeyboard->on = TRUE;
+               break;
+
+       case DEVICE_CLOSE:
+       case DEVICE_OFF:
+               pPriv = (newsmipsKbdPrivPtr)pKeyboard->devicePrivate;
+               RemoveEnabledDevice(pPriv->fd);
+               pKeyboard->on = FALSE;
+               break;
+       default:
+               newsmipsFatalError(("Unknown keyboard operation\n"));
+       }
+
+       return Success;
+}
+
+/*
+ * newsmipsKbdGetEvents --
+ *     Return the events waiting in the wings for the given keyboard.
+ *
+ * Results:
+ *     A pointer to an array of newsmipsEvents or
+ *     (newsmipsEvent *)0 if no events The number of events
+ *     contained in the array.
+ *     A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ *     None.
+ */
+newsmipsEvent*
+newsmipsKbdGetEvents(newsmipsKbdPrivPtr pPriv, int *pNumEvents,
+    Bool *pAgain)
+{
+       static newsmipsEvent evBuf[MAXEVENTS];
+       int fd, n;
+       u_char c, c2;
+
+       fd = pPriv->fd;
+       if ((n = read(fd, evBuf, sizeof(evBuf))) == -1) {
+               if (errno == EWOULDBLOCK) {
+                       *pNumEvents = 0;
+                       *pAgain = FALSE;
+               } else {
+                       newsmipsError("Reading keyboard");
+                       newsmipsFatalError(("Could not read the keyboard"));
+               }
+       } else {
+               *pNumEvents = n / sizeof(newsmipsEvent);
+               *pAgain = n == sizeof(evBuf);
+       }
+
+       return evBuf;
+}
+
+void
+newsmipsKbdEnqueueEvent(DeviceIntPtr device, newsmipsEvent *fe)
+{
+       xEvent event;
+
+       event.u.keyButtonPointer.time = TSTOMILLI(fe->time);
+       event.u.u.type =
+           (fe->type == WSCONS_EVENT_KEY_UP) ? KeyRelease : KeyPress;
+       event.u.u.detail = (fe->value & 0xff) + XkbMinLegalKeyCode;
+
+       mieqEnqueue(&event);
+}
+
+Bool LegalModifier(unsigned int key, DevicePtr pDev)
+{
+
+       return TRUE;
+}
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKeymap.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKeymap.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKeymap.c
       1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsKeymap.c     
2004-07-26 20:38:33.000000000 +0900
@@ -0,0 +1,166 @@
+/* $XConsortium: sunKeyMap.c,v 4.22 94/05/18 11:16:07 kaleb Exp $ */
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to 
+distribution  of  the software  without specific prior 
+written permission. Sun and X Consortium make no 
+representations about the suitability of this software for 
+any purpose. It is provided "as is" without any express or 
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#include "newsmips.h"
+#include "keysym.h"
+
+#define        GLYPHS_PER_KEY  2
+
+static KeySym map_jpkbd[] = {
+       /* 0  */ NoSymbol,      NoSymbol,
+       /* 1  */ XK_F1,         NoSymbol,
+       /* 2  */ XK_F2,         NoSymbol,
+       /* 3  */ XK_F3,         NoSymbol,
+       /* 4  */ XK_F4,         NoSymbol,
+       /* 5  */ XK_F5,         NoSymbol,
+       /* 6  */ XK_F6,         NoSymbol,
+       /* 7  */ XK_F7,         NoSymbol,
+       /* 8  */ XK_F8,         NoSymbol,
+       /* 9  */ XK_F9,         NoSymbol,
+       /* 10 */ XK_F10,        NoSymbol,
+       /* 11 */ XK_Escape,     NoSymbol,
+       /* 12 */ XK_1,          XK_exclam,
+       /* 13 */ XK_2,          XK_at,
+       /* 14 */ XK_3,          XK_numbersign,
+       /* 15 */ XK_4,          XK_dollar,
+       /* 16 */ XK_5,          XK_percent,
+       /* 17 */ XK_6,          XK_asciicircum,
+       /* 18 */ XK_7,          XK_ampersand,
+       /* 19 */ XK_8,          XK_asterisk,
+       /* 20 */ XK_9,          XK_parenleft,
+       /* 21 */ XK_0,          XK_parenright,
+       /* 22 */ XK_minus,      XK_underscore,
+       /* 23 */ XK_equal,      XK_plus,
+       /* 24 */ XK_backslash,  XK_bar,
+       /* 25 */ XK_BackSpace,  NoSymbol,
+       /* 26 */ XK_Tab,        NoSymbol,
+       /* 27 */ XK_q,          NoSymbol,
+       /* 28 */ XK_w,          NoSymbol,
+       /* 29 */ XK_e,          NoSymbol,
+       /* 30 */ XK_r,          NoSymbol,
+       /* 31 */ XK_t,          NoSymbol,
+       /* 32 */ XK_y,          NoSymbol,
+       /* 33 */ XK_u,          NoSymbol,
+       /* 34 */ XK_i,          NoSymbol,
+       /* 35 */ XK_o,          NoSymbol,
+       /* 36 */ XK_p,          NoSymbol,
+       /* 37 */ XK_bracketleft,XK_braceleft,
+       /* 38 */ XK_bracketright, XK_braceright,
+       /* 39 */ XK_Delete,     NoSymbol,
+       /* 40 */ XK_Control_L,  NoSymbol,
+       /* 41 */ XK_a,          NoSymbol,
+       /* 42 */ XK_s,          NoSymbol,
+       /* 43 */ XK_d,          NoSymbol,
+       /* 44 */ XK_f,          NoSymbol,
+       /* 45 */ XK_g,          NoSymbol,
+       /* 46 */ XK_h,          NoSymbol,
+       /* 47 */ XK_j,          NoSymbol,
+       /* 48 */ XK_k,          NoSymbol,
+       /* 49 */ XK_l,          NoSymbol,
+       /* 50 */ XK_semicolon,  XK_colon,
+       /* 51 */ XK_apostrophe, XK_quotedbl,
+       /* 52 */ XK_grave,      XK_asciitilde,
+       /* 53 */ XK_Return,     NoSymbol,
+       /* 54 */ XK_Shift_L,    NoSymbol,
+       /* 55 */ XK_z,          NoSymbol,
+       /* 56 */ XK_x,          NoSymbol,
+       /* 57 */ XK_c,          NoSymbol,
+       /* 58 */ XK_v,          NoSymbol,
+       /* 59 */ XK_b,          NoSymbol,
+       /* 60 */ XK_n,          NoSymbol,
+       /* 61 */ XK_m,          NoSymbol,
+       /* 62 */ XK_comma,      XK_less,
+       /* 63 */ XK_period,     XK_greater,
+       /* 64 */ XK_slash,      XK_question,
+       /* 65 */ NoSymbol,      NoSymbol,
+       /* 66 */ XK_Shift_R,    NoSymbol,
+       /* 67 */ XK_Alt_L,      NoSymbol,
+       /* 68 */ XK_Caps_Lock,  NoSymbol,
+       /* 69 */ XK_Muhenkan,   NoSymbol,
+       /* 70 */ XK_space,      NoSymbol,
+       /* 71 */ XK_Henkan,     NoSymbol,
+       /* 72 */ XK_Eisu_toggle,NoSymbol,
+       /* 73 */ XK_Hiragana,   NoSymbol,
+       /* 74 */ XK_Execute,    NoSymbol,
+       /* 75 */ XK_KP_7,       NoSymbol,
+       /* 76 */ XK_KP_8,       NoSymbol,
+       /* 77 */ XK_KP_9,       NoSymbol,
+       /* 78 */ XK_KP_Subtract,NoSymbol,
+       /* 79 */ XK_KP_4,       NoSymbol,
+       /* 80 */ XK_KP_5,       NoSymbol,
+       /* 81 */ XK_KP_6,       NoSymbol,
+       /* 82 */ XK_KP_Add,     NoSymbol,
+       /* 83 */ XK_KP_1,       NoSymbol,
+       /* 84 */ XK_KP_2,       NoSymbol,
+       /* 85 */ XK_KP_3,       NoSymbol,
+       /* 86 */ XK_KP_Separator,NoSymbol,
+       /* 87 */ XK_KP_0,       NoSymbol,
+       /* 88 */ XK_KP_Up,      NoSymbol,
+       /* 89 */ XK_KP_Decimal, NoSymbol,
+       /* 90 */ XK_KP_Enter,   NoSymbol,
+       /* 91 */ XK_KP_Left,    NoSymbol,
+       /* 92 */ XK_KP_Down,    NoSymbol,
+       /* 93 */ XK_KP_Right,   NoSymbol,
+       /* 94 */ NoSymbol,      NoSymbol,
+       /* 95 */ NoSymbol,      NoSymbol,
+       /* 96 */ NoSymbol,      NoSymbol,
+       /* 97 */ NoSymbol,      NoSymbol,
+       /* 98 */ NoSymbol,      NoSymbol,
+       /* 99 */ NoSymbol,      NoSymbol,
+       /* 100 */ XK_KP_Multiply,NoSymbol,
+       /* 101 */ XK_KP_Divide, NoSymbol,
+       /* 102 */ XK_KP_Tab,    NoSymbol,
+       /* 104 */ XK_F11,       NoSymbol,
+       /* 105 */ XK_F12,       NoSymbol,
+       /* 106 */ XK_Help,      NoSymbol,
+       /* 107 */ XK_Insert,    NoSymbol,
+       /* 108 */ XK_Clear,     NoSymbol,
+       /* 109 */ XK_Prior,     NoSymbol,
+       /* 110 */ XK_Next,      NoSymbol,
+};
+
+static newsmipsModmapRec modmap_jpkbd[] = {
+       54,     ShiftMask,      /* Shift_L */
+       66,     ShiftMask,      /* Shift_R */
+       68,     LockMask,       /* CapsLock */
+       40,     ControlMask,    /* Control_L */
+       67,     Mod1Mask,       /* Alt_L */
+       73,     Mod4Mask,       /* Hiragana */
+       0,      0
+};
+
+KeySymsRec newsmipsKeySyms[] = {
+       /* map          minKC   maxKC   width */
+       map_jpkbd,      0,      110,    GLYPHS_PER_KEY,
+};
+
+newsmipsModmapRec *newsmipsModMaps[] = {
+       modmap_jpkbd,
+};
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsMouse.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsMouse.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsMouse.c
        1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsMouse.c      
2004-07-26 02:51:01.000000000 +0900
@@ -0,0 +1,340 @@
+/* $XConsortium: sunMouse.c,v 5.21 94/04/17 20:29:47 kaleb Exp $ */
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#define        NEED_EVENTS
+#include "newsmips.h"
+#include <stdio.h>
+
+static Bool newsmipsCursorOffScreen();
+static void newsmipsCrossScreen();
+static void newsmipsWarpCursor();
+
+miPointerScreenFuncRec newsmipsPointerScreenFuncs = {
+       newsmipsCursorOffScreen,
+       newsmipsCrossScreen,
+       newsmipsWarpCursor,
+};
+
+/*
+ * newsmipsMouseCtrl --
+ *     Alter the control parameters for the mouse. Since acceleration
+ *     etc. is done from the PtrCtrl record in the mouse's device record,
+ *     there's nothing to do here.
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     None.
+ */
+void
+newsmipsMouseCtrl(DeviceIntPtr device, PtrCtrl *ctrl)
+{
+
+}
+
+/*
+ * newsmipsMouseProc --
+ *     Handle the initialization, etc. of a mouse
+ *
+ * Results:
+ *     none.
+ *
+ * Side Effects:
+ */
+int
+newsmipsMouseProc(DeviceIntPtr device, int what)
+{
+       DevicePtr pMouse = (DevicePtr) device;
+       int format;
+       static int oformat;
+       BYTE map[7];
+       char *dev;
+
+       switch (what) {
+       case DEVICE_INIT:
+               if (pMouse != LookupPointerDevice()) {
+                       newsmipsErrorF (("Cannot open non-system mouse"));
+                       return !Success;
+               }
+               if (newsmipsPtrPriv.fd == -1)
+                       return !Success;
+               pMouse->devicePrivate = (pointer) &newsmipsPtrPriv;
+               pMouse->on = FALSE;
+               map[1] = 1;
+               map[2] = 2;
+               map[3] = 3;
+               map[4] = 2;
+               map[5] = 4;
+               map[6] = 5;
+               InitPointerDeviceStruct(pMouse, map, 6,
+                   miPointerGetMotionEvents, newsmipsMouseCtrl,
+                   miPointerGetMotionBufferSize());
+               break;
+
+       case DEVICE_ON:
+               newsmipsPtrPriv.bmask = 0;
+
+               AddEnabledDevice(newsmipsPtrPriv.fd);
+               pMouse->on = TRUE;
+               break;
+
+       case DEVICE_CLOSE:
+               break;
+
+       case DEVICE_OFF:
+               pMouse->on = FALSE;
+               RemoveEnabledDevice(newsmipsPtrPriv.fd);
+               break;
+       }
+       return Success;
+}
+
+/*
+ * newsmipsMouseGetEvents --
+ *     Return the events waiting in the wings for the given mouse.
+ *
+ * Results:
+ *     A pointer to an array of newsmipsEvents or
+ *     (newsmipsEvent *)0 if no events The number of events
+ *     contained in the array.
+ *
+ *     A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ *     None.
+ */
+struct wscons_event*
+newsmipsMouseGetEvents(newsmipsPtrPrivPtr pPriv, int *pNumEvents,
+    Bool *pAgain)
+{
+       static newsmipsEvent evBuf[MAXEVENTS];
+       int fd, n;
+
+       fd = pPriv->fd;
+       if ((n = read(fd, (char *)evBuf, sizeof(evBuf))) == -1) {
+               if (errno == EWOULDBLOCK) {
+                       *pNumEvents = 0;
+                       *pAgain = FALSE;
+               } else {
+                       newsmipsError("newsmipsMouseGetEvents read");
+                       newsmipsFatalError(("Could not read from mouse"));
+               }
+       } else {
+               *pNumEvents = n / sizeof(newsmipsEvent);
+               *pAgain = n == sizeof(evBuf);
+       }
+
+       return evBuf;
+}
+
+/*
+ * MouseAccelerate --
+ *     Given a delta and a mouse, return the acceleration of the delta.
+ *
+ * Results:
+ *     The corrected delta
+ *
+ * Side Effects:
+ *     None.
+ */
+static short
+MouseAccelerate(DeviceIntPtr device, int delta)
+{
+       int  sgn = sign(delta);
+       PtrCtrl *pCtrl;
+       short ret;
+
+       delta = abs(delta);
+       pCtrl = &device->ptrfeed->ctrl;
+       if (delta > pCtrl->threshold) {
+               ret = (short) sgn * (pCtrl->threshold + ((delta - 
pCtrl->threshold) *
+                   pCtrl->num) / pCtrl->den);
+       } else {
+               ret = (short) sgn * delta;
+       }
+
+       return ret;
+}
+
+/*
+ * newsmipsMouseEnqueueEvent --
+ *     Given a newsmipsEvent for a mouse, pass it off the the dix layer
+ *     properly converted...
+ *
+ * Results:
+ *     None.
+ *
+ * Side Effects:
+ *     The cursor may be redrawn...? devPrivate/x/y will be altered.
+ */
+void
+newsmipsMouseEnqueueEvent(DeviceIntPtr  device, newsmipsEvent *fe)             
/* Event to process */
+{
+       xEvent          xE;
+       newsmipsPtrPrivPtr      pPriv;  /* Private data for pointer */
+       newsmipsKbdPrivPtr      keyPriv;/* Private keyboard data for
+                                           button emul */
+       unsigned long   time;
+       int                     x, y, bmask;
+
+       pPriv = (newsmipsPtrPrivPtr)device->public.devicePrivate;
+
+       time = xE.u.keyButtonPointer.time = TSTOMILLI(fe->time);
+
+       /*
+        * Mouse buttons start at 1.
+        *
+        * Sometimes we will get two events for a single button state change.
+        * Should we get a button even which reflects the current state of
+        * affairs, that event is discarded.  In the button emulation case, we
+        * may need to generate several events from one real event.
+        *
+        * The button emulation allows WIN-1 through WIN-5 to be used as
+        * buttons one to five when the first real button is down.  If other
+        * real buttons are present, they are accounted for separately so that
+        * lifting an emulated button will not cause a button up event if the
+        * real button is down.  If the WIN button is not down, a button down
+        * event will be sent for the first button.  If the first button is
+        * pressed when just the WIN key is down, the button events will not
+        * be sent.  The allows you to move just the cursor on a touch screen.
+        * Emulated buttons are only released when the keys are released.
+        */
+
+       switch (fe->type) {
+       case WSCONS_EVENT_MOUSE_UP:
+       case WSCONS_EVENT_MOUSE_DOWN:
+               /*
+                * A button changed state. Sometimes we will get two
+                * events for a single state change. Should we get a
+                * button event which reflects the current state of
+                * affairs, that event is discarded.
+                *
+                * Mouse buttons start at 1.
+                */
+               xE.u.u.detail = fe->value + 1;
+               bmask = 1 << xE.u.u.detail;
+               if (fe->type == WSCONS_EVENT_MOUSE_UP) {
+                       if (pPriv->bmask & bmask) {
+                               xE.u.u.type = ButtonRelease;
+                               pPriv->bmask &= ~bmask;
+                       } else {
+                               return;
+                       }
+               } else {
+                       if ((pPriv->bmask & bmask) == 0) {
+                               xE.u.u.type = ButtonPress;
+                               pPriv->bmask |= bmask;
+                       } else {
+                               return;
+                       }
+               }
+               mieqEnqueue (&xE);
+               break;
+       case WSCONS_EVENT_MOUSE_DELTA_X:
+               miPointerDeltaCursor(MouseAccelerate(device,fe->value),0,time);
+               break;
+       case WSCONS_EVENT_MOUSE_DELTA_Y:
+               miPointerDeltaCursor(0,-MouseAccelerate(device,fe->value),time);
+               break;
+       case WSCONS_EVENT_MOUSE_DELTA_Z:
+               /* Ignore for now. */
+               break;
+       case WSCONS_EVENT_MOUSE_ABSOLUTE_X:
+               miPointerPosition (&x, &y);
+               miPointerAbsoluteCursor (fe->value, y, time);
+               break;
+       case WSCONS_EVENT_MOUSE_ABSOLUTE_Y:
+               miPointerPosition (&x, &y);
+               miPointerAbsoluteCursor (x, fe->value, time);
+               break;
+       case WSCONS_EVENT_MOUSE_ABSOLUTE_Z:
+               break;
+       default:
+               newsmipsFatalError(("newsmipsMouseEnqueueEvent: "
+                   "unrecognized id\n"));
+               break;
+       }
+}
+
+static Bool
+newsmipsCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+       extern Bool PointerConfinedToScreen();
+
+       if (PointerConfinedToScreen())
+               return TRUE;
+
+       return FALSE;
+}
+
+static void
+newsmipsCrossScreen(ScreenPtr pScreen, Bool entering)
+{
+       newsmipsFbPtr pFb = newsmipsGetScreenFb(pScreen);
+
+       if (pFb->EnterLeave)
+               (*pFb->EnterLeave)(pScreen, entering ? 0 : 1);
+}
+
+static void
+newsmipsWarpCursor(ScreenPtr pScreen, int x, int y)
+{
+       sigset_t newsigmask;
+
+       (void) sigemptyset (&newsigmask);
+       (void) sigaddset (&newsigmask, SIGIO);
+       (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+       miPointerWarpCursor (pScreen, x, y);
+       (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+}
diff --exclude CVS -urN 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsScreen.c
 ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsScreen.c
--- 
/work2/cvsrep/dist/xsrc/xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsScreen.c
       1970-01-01 09:00:00.000000000 +0900
+++ ./xfree/xc/programs/Xserver/hw/netbsd/newsmips/newsmipsScreen.c     
2004-07-26 02:51:00.000000000 +0900
@@ -0,0 +1,181 @@
+/* $XConsortium: sunFbs.c,v 1.8 94/08/16 13:45:30 dpw Exp $ */
+/*
+Copyright (c) 1990, 1993  X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+                    All Rights Reserved
+
+Permission  to  use,  copy,  modify,  and  distribute   this
+software  and  its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice  appear  in all copies and that both that copyright no-
+tice and this permission notice appear in  supporting  docu-
+mentation,  and  that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution  of  the software  without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO  THIS  SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE  LI-
+ABLE  FOR  ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,  DATA  OR
+PROFITS,  WHETHER  IN  AN  ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION  WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright (c) 1987 by the Regents of the University of California
+ * Copyright (c) 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies.  The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from  sunCG4C.c for X11R3 by Tom Jarmolowski       */
+/****************************************************************/
+
+#include "newsmips.h"
+#include <sys/mman.h>
+#include <stdio.h>
+
+static int newsmipsScreenIndex;
+static unsigned long generation = 0;
+
+Bool
+newsmipsAllocateScreenPrivate(ScreenPtr pScreen)
+{
+       newsmipsScreenPtr    pPrivate;
+       extern int AllocateScreenPrivateIndex();
+
+       if (generation != serverGeneration) {
+               newsmipsScreenIndex = AllocateScreenPrivateIndex();
+               if (newsmipsScreenIndex < 0)
+                       return FALSE;
+               generation = serverGeneration;
+       }
+       pPrivate = (newsmipsScreenPtr)xalloc(sizeof(newsmipsScreenRec));
+       if (!pPrivate)
+               return FALSE;
+
+       pScreen->devPrivates[newsmipsScreenIndex].ptr = (pointer) pPrivate;
+       return TRUE;
+}
+
+newsmipsScreenPtr
+newsmipsGetScreenPrivate(ScreenPtr pScreen)
+{
+
+       return ((newsmipsScreenPtr)
+           ((pScreen)->devPrivates[newsmipsScreenIndex].ptr));
+}
+
+pointer
+newsmipsMemoryMap (size_t len, off_t off, int fd)
+{
+       caddr_t addr;
+       pointer mapaddr;
+
+       len += off;
+       addr = 0;
+       /*
+        * try and make it private first, that way once we get it, an
+        * interloper, e.g. another server, can't get this frame buffer,
+        * and if another server already has it, this one won't.
+        */
+       mapaddr = (pointer)mmap(addr, len, PROT_READ | PROT_WRITE, MAP_SHARED,
+           fd, 0);
+       if (mapaddr == (pointer)-1) {
+               newsmipsError("mapping frame buffer memory");
+               (void) close(fd);
+               return NULL;
+       }
+
+       return mapaddr + off;
+}
+
+static Bool
+newsmipsSaveScreen (ScreenPtr pScreen, int on)
+{
+       int state;
+       newsmipsFbPtr pFb = newsmipsGetScreenFb(pScreen);
+
+       if (on != SCREEN_SAVER_FORCER) {
+               if (on == SCREEN_SAVER_ON)
+                       state = WSDISPLAYIO_VIDEO_OFF;
+               else
+                       state = WSDISPLAYIO_VIDEO_ON;
+               ioctl(pFb->fd, WSDISPLAYIO_SVIDEO, &state);
+       }
+
+       return TRUE;
+}
+
+static Bool
+newsmipsCloseScreen(int i, ScreenPtr pScreen)
+{
+       Bool    ret;
+       newsmipsScreenPtr pPrivate = newsmipsGetScreenPrivate(pScreen);
+       newsmipsFbPtr pFb = newsmipsGetScreenFb(pScreen);
+       int mode = WSDISPLAYIO_MODE_EMUL;
+
+       (void) OsSignal(SIGIO, SIG_IGN);
+       pScreen->CloseScreen = pPrivate->CloseScreen;
+       ret = (*pScreen->CloseScreen)(i, pScreen);
+       (void) (*pScreen->SaveScreen)(pScreen, SCREEN_SAVER_OFF);
+       ioctl(pFb->fd, WSDISPLAYIO_SMODE, &mode);
+       xfree((pointer) pPrivate);
+
+       return ret;
+}
+
+Bool
+newsmipsScreenInit(ScreenPtr pScreen)
+{
+       extern miPointerScreenFuncRec newsmipsPointerScreenFuncs;
+       newsmipsScreenPtr pPrivate;
+
+       pPrivate = newsmipsGetScreenPrivate(pScreen);
+       pPrivate->installedMap = 0;
+       pPrivate->CloseScreen = pScreen->CloseScreen;
+       pScreen->CloseScreen = newsmipsCloseScreen;
+       pScreen->SaveScreen = newsmipsSaveScreen;
+       miDCInitialize(pScreen, &newsmipsPointerScreenFuncs);
+
+       return TRUE;
+}




Home | Main Index | Thread Index | Old Index