diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/config/cf/Imake.cf XFree86.current/xc/config/cf/Imake.cf
--- XFree86/xc/config/cf/Imake.cf	Fri Jul 30 21:45:47 1999
+++ XFree86.current/xc/config/cf/Imake.cf	Fri Mar  2 18:13:27 2001
@@ -592,6 +592,10 @@
 #     undef __ARM_ARCH_3__
 #   endif
 # endif
+# ifdef __mips__
+#  define MipsArchitecture
+#  undef __mips__
+# endif
 #endif /* linux */
 
 #if (defined(__Lynx__) || defined(Lynx)) && (defined(i386) || defined(__i386__) || defined(__x86__) || defined(__powerpc__) || defined(__sparc__) || defined(sparc))
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/config/cf/host.def XFree86.current/xc/config/cf/host.def
--- XFree86/xc/config/cf/host.def	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/config/cf/host.def	Fri Mar  2 18:13:27 2001
@@ -0,0 +1,21 @@
+/* local setting for GSX */
+
+#define BuildScreenSaverLibrary NO
+#define BuildXF86MiscLibrary    NO
+#define BuildXF86DGALibrary     NO
+#define BuildXF86VidModeLibrary NO
+#define BuildDPMSLibrary        NO
+#define BuildXF86MiscExt                NO
+#define BuildXF86DGA                    NO
+#define BuildDPMSExt    NO
+#define BuildXF86VidModeExt    NO
+
+#undef BuildXInputExt
+#define BuildXInputExt         NO
+#undef BuildPexExt
+#define BuildPexExt            NO
+#undef BuildXIE
+#define BuildXIE               NO
+
+#undef DefaultCCOptions
+#define DefaultCCOptions
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/config/cf/linux.cf XFree86.current/xc/config/cf/linux.cf
--- XFree86/xc/config/cf/linux.cf	Mon Apr 16 15:42:05 2001
+++ XFree86.current/xc/config/cf/linux.cf	Mon Apr 16 15:40:12 2001
@@ -284,6 +284,16 @@
 #define ServerExtraDefines     -DGCCUSESGAS XFree86ServerDefines
 #endif /* Arm */
 
+#ifdef MipsArchitecture
+#define OptimizedCDebugFlags	-O2 -g
+#define LinuxMachineDefines	-D__mips__
+#define ServerOSDefines		XFree86ServerOSDefines -DDDXTIME -DPART_NET
+#define ServerExtraDefines	-DGCCUSESGAS XFree86ServerDefines
+#define SeparateSharedCompile	NO
+#undef AsCmd
+#define AsCmd			gcc -x assembler-with-cpp -c
+#endif /* MipsArchitecture */
+
 #define StandardDefines		-Dlinux LinuxMachineDefines LinuxSourceDefines
 
 #ifndef TermcapLibrary
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/config/cf/site.def XFree86.current/xc/config/cf/site.def
--- XFree86/xc/config/cf/site.def	Mon Apr 16 15:42:05 2001
+++ XFree86.current/xc/config/cf/site.def	Mon Apr 16 15:40:12 2001
@@ -130,6 +130,11 @@
 #endif
 */
 
+/* Xserver for GS */
+#define GsxServer YES
+#define ServerToInstall		Xgsx
+#define UseXserverWrapper YES
+
 #include <host.def>
 
 #endif /* AfterVendorCF */
Binary files XFree86/xc/doc/hardcopy/BDF/bdf.PS.Z and XFree86.current/xc/doc/hardcopy/BDF/bdf.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/CTEXT/ctext.PS.Z and XFree86.current/xc/doc/hardcopy/CTEXT/ctext.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/FSProtocol/fsproto.PS.Z and XFree86.current/xc/doc/hardcopy/FSProtocol/fsproto.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/ICCCM/icccm.PS.Z and XFree86.current/xc/doc/hardcopy/ICCCM/icccm.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/ICCCM/icccm.idx.PS.Z and XFree86.current/xc/doc/hardcopy/ICCCM/icccm.idx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/ICE/ICElib.PS.Z and XFree86.current/xc/doc/hardcopy/ICE/ICElib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/ICE/ice.PS.Z and XFree86.current/xc/doc/hardcopy/ICE/ice.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.1/PEXlib/PEXlib.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.1/PEXlib/PEXlib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.1/PEXlib/PEXlib.idx.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.1/PEXlib/PEXlib.idx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.1/Proto/encoding_doc.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.1/Proto/encoding_doc.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.1/Proto/encoding_toc.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.1/Proto/encoding_toc.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.1/Proto/protocol_JPN.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.1/Proto/protocol_JPN.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.1/Proto/protocol_doc.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.1/Proto/protocol_doc.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.1/Proto/protocol_toc.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.1/Proto/protocol_toc.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.2/PEXlib/pexlib_dcs3.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.2/PEXlib/pexlib_dcs3.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/PEX5/PEX5.2/Proto/pex_dcs3.PS.Z and XFree86.current/xc/doc/hardcopy/PEX5/PEX5.2/Proto/pex_dcs3.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/RX/RX.PS.Z and XFree86.current/xc/doc/hardcopy/RX/RX.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/SM/SMlib.PS.Z and XFree86.current/xc/doc/hardcopy/SM/SMlib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/SM/xsmp.PS.Z and XFree86.current/xc/doc/hardcopy/SM/xsmp.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/X11/xlib.PS.Z and XFree86.current/xc/doc/hardcopy/X11/xlib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/X11/xlib.idx.PS.Z and XFree86.current/xc/doc/hardcopy/X11/xlib.idx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XDMCP/xdmcp.PS.Z and XFree86.current/xc/doc/hardcopy/XDMCP/xdmcp.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/SI/xieSIarch.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/SI/xieSIarch.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/apa_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/apa_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/apb_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/apb_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/apc_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/apc_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch1_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch1_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch2_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch2_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch3_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch3_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch4_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch4_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch5_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch5_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch6_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch6_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch7_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch7_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch8_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch8_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/ch9_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/ch9_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/cmatch.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/cmatch.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/frnt_xie.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/frnt_xie.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIEProto/overview.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIEProto/overview.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIE/XIElib/xielib.PS.Z and XFree86.current/xc/doc/hardcopy/XIE/XIElib/xielib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XIM/xim.PS.Z and XFree86.current/xc/doc/hardcopy/XIM/xim.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XKB/XKBlib.ps.Z and XFree86.current/xc/doc/hardcopy/XKB/XKBlib.ps.Z differ
Binary files XFree86/xc/doc/hardcopy/XKB/XKBproto.ps.Z and XFree86.current/xc/doc/hardcopy/XKB/XKBproto.ps.Z differ
Binary files XFree86/xc/doc/hardcopy/XLFD/xlfd.PS.Z and XFree86.current/xc/doc/hardcopy/XLFD/xlfd.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XPRINT/xp_library.PS.Z and XFree86.current/xc/doc/hardcopy/XPRINT/xp_library.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XPRINT/xp_proto.PS.Z and XFree86.current/xc/doc/hardcopy/XPRINT/xp_proto.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XProtocol/proto.PS.Z and XFree86.current/xc/doc/hardcopy/XProtocol/proto.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/XProtocol/proto.idx.PS.Z and XFree86.current/xc/doc/hardcopy/XProtocol/proto.idx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xaw/widg.idx.PS.Z and XFree86.current/xc/doc/hardcopy/Xaw/widg.idx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xaw/widgets.PS.Z and XFree86.current/xc/doc/hardcopy/Xaw/widgets.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/AppGroup.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/AppGroup.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/bigreq.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/bigreq.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/buffer.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/buffer.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/dbe.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/dbe.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/dbelib.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/dbelib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/lbx.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/lbx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/lbxalg.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/lbxalg.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/mit-shm.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/mit-shm.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/record.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/record.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/recordlib.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/recordlib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/security.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/security.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/shape.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/shape.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/shapelib.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/shapelib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/sync.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/sync.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/synclib.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/synclib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/xc-misc.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/xc-misc.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/xtest.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/xtest.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xext/xtestlib.PS.Z and XFree86.current/xc/doc/hardcopy/Xext/xtestlib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xi/lib.PS.Z and XFree86.current/xc/doc/hardcopy/Xi/lib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xi/port.PS.Z and XFree86.current/xc/doc/hardcopy/Xi/port.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xi/proto.PS.Z and XFree86.current/xc/doc/hardcopy/Xi/proto.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xmu/xmu.PS.Z and XFree86.current/xc/doc/hardcopy/Xmu/xmu.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xserver/Xprt.PS.Z and XFree86.current/xc/doc/hardcopy/Xserver/Xprt.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xserver/analysis.PS.Z and XFree86.current/xc/doc/hardcopy/Xserver/analysis.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xserver/appgroup.PS.Z and XFree86.current/xc/doc/hardcopy/Xserver/appgroup.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xserver/ddx.PS.Z and XFree86.current/xc/doc/hardcopy/Xserver/ddx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xserver/fontlib.PS.Z and XFree86.current/xc/doc/hardcopy/Xserver/fontlib.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xserver/secint.PS.Z and XFree86.current/xc/doc/hardcopy/Xserver/secint.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xt/intr.idx.PS.Z and XFree86.current/xc/doc/hardcopy/Xt/intr.idx.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/Xt/intrinsics.PS.Z and XFree86.current/xc/doc/hardcopy/Xt/intrinsics.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/i18n/Framework.PS.Z and XFree86.current/xc/doc/hardcopy/i18n/Framework.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/i18n/LocaleDB.PS.Z and XFree86.current/xc/doc/hardcopy/i18n/LocaleDB.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/i18n/Trans.PS.Z and XFree86.current/xc/doc/hardcopy/i18n/Trans.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/man/man.PS.Z and XFree86.current/xc/doc/hardcopy/man/man.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/rstart/rstart.PS.Z and XFree86.current/xc/doc/hardcopy/rstart/rstart.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/test/xsuite/userguide.PS.Z and XFree86.current/xc/doc/hardcopy/test/xsuite/userguide.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/xfs/design.PS.Z and XFree86.current/xc/doc/hardcopy/xfs/design.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/xterm/ctlseqs.PS.Z and XFree86.current/xc/doc/hardcopy/xterm/ctlseqs.PS.Z differ
Binary files XFree86/xc/doc/hardcopy/xtrans/Xtrans.PS.Z and XFree86.current/xc/doc/hardcopy/xtrans/Xtrans.PS.Z differ
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/include/Xos.h XFree86.current/xc/include/Xos.h
--- XFree86/xc/include/Xos.h	Wed Aug 18 22:15:09 1999
+++ XFree86.current/xc/include/Xos.h	Fri Mar  9 14:57:58 2001
@@ -234,10 +234,15 @@
 #include <sys/time.h>
 #include <time.h>
 #else
+#ifdef __linux__
+#include <time.h>
+#include <sys/time.h>
+#else
 #ifndef Lynx
 #include <sys/time.h>
 #else
 #include <time.h>
+#endif /* __linux__ */
 #endif /* Lynx */
 #endif /* QNX/Nto */
 #endif /* MINIX */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Imakefile XFree86.current/xc/programs/Imakefile
--- XFree86/xc/programs/Imakefile	Mon Feb 16 09:40:24 1998
+++ XFree86.current/xc/programs/Imakefile	Sat Mar 24 21:24:39 2001
@@ -17,7 +17,7 @@
 #if BuildXKBlib
       XKBSRCDIRS = setxkbmap xkbcomp xkbevd xkbprint xkbutils
 #endif
-#if BuildScreenSaverExt
+#if BuildScreenSaverExt && BuildScreenSaverLibrary
 SCREENSAVESRCDIR = beforelight
 #endif
 #if BuildXF86VidModeExt
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/Imakefile XFree86.current/xc/programs/Xserver/Imakefile
--- XFree86/xc/programs/Xserver/Imakefile	Fri Dec  3 18:39:48 1999
+++ XFree86.current/xc/programs/Xserver/Imakefile	Fri Mar  2 18:13:27 2001
@@ -1816,6 +1816,47 @@
 #endif /* XVirtualFramebufferServer */
 
 
+#if GsxServer
+XCOMM
+XCOMM server with GSX
+XCOMM
+MFBDIR   = mfb
+CFB8DIR  = cfb
+CFB16DIR = cfb16
+CFB24DIR = cfb24
+CFB32DIR = cfb32
+DDXDIR1 = hw/gsx
+GSXDIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB24DIR) $(CFB32DIR) $(DDXDIR1) $(DEPDIRS)
+GSXOBJS = hw/gsx/common/stubs.o
+GSXINPUT = hw/gsx/common/LibraryTargetName(gsxinput)
+GSXGSOS = hw/gsx/gsos/LibraryTargetName(gsos)
+GSXCORE = hw/gsx/LibraryTargetName(gsx)
+GSXLIBS = \
+	  PreFbLibs \
+	  $(GSXCORE) \
+	  $(GSXGSOS) \
+	  $(GSXINPUT) \
+	  ./mi/libmi.a \
+	  $(CFB) \
+	  -$(XLIB) \
+	  -lm \
+	  CFBLibs
+# GSXSYSLIBS = $(FONT) $(SYSLIBS) for xtt
+GSXSYSLIBS = $(SYSLIBS)
+#if HasParallelMake
+MakeMutex($(GSXDIRS) $(GSXOBJS) $(GSXLIBS) $(GSXSYSLIBS))
+#endif
+#if HasGnuMake
+$(GSXOBJS) $(GSXLIBS) $(GSXSYSLIBS):: $(GSXDIRS)
+	@if [ -f $@ ]; then touch $@; fi
+#endif
+SetUIDServerTarget(Xgsx,$(GSXDIRS),$(GSXOBJS),$(GSXLIBS),$(GSXSYSLIBS))
+#ifndef ServerToInstall
+#define ServerToInstall Xgsx
+#endif
+#endif /* gsxrServer */
+
+
 #if UseXserverWrapper
 #if HasPam
 SetUIDProgramTarget(Xwrapper,os/wrapper.o,NullParameter,$(PAMLIBS),NullParameter)
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/Imakefile XFree86.current/xc/programs/Xserver/hw/gsx/Imakefile
--- XFree86/xc/programs/Xserver/hw/gsx/Imakefile	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/Imakefile	Fri Mar  2 18:13:27 2001
@@ -0,0 +1,48 @@
+XCOMM 
+
+#include <Server.tmpl>
+#define IHaveSubdirs
+
+SUBDIRS = common gsos
+
+SRCS =	gsxgc.c gsxcpyarea.c \
+    gsxfillarc.c gsxfillply.c gsxfillrct.c gsxfillsp.c \
+    gsxglblt.c gsximage.c gsxlop.c gsxmisc.c \
+    gsxpolyarc.c gsxpolylin.c gsxpolypnt.c gsxpolyrct.c gsxpolyseg.c \
+    gsxpushpix.c gsxtext.c gsxscrinit.c gsxinit.c gsxbstore.c gsxcmap.c \
+    gsxwindow.c
+
+OBJS =	gsxgc.o gsxcpyarea.o \
+    gsxfillarc.o gsxfillply.o gsxfillrct.o gsxfillsp.o \
+    gsxglblt.o gsximage.o gsxlop.o gsxmisc.o \
+    gsxpolyarc.o gsxpolylin.o gsxpolypnt.o gsxpolyrct.o gsxpolyseg.o \
+    gsxpushpix.o gsxtext.o gsxscrinit.o gsxinit.o gsxbstore.o gsxcmap.o \
+    gsxwindow.o
+
+GSXOBJS = $(GLSUBOBJS)
+
+SERVERSRC = ../..
+XINCLUDESRC = ../../../../include
+
+INCLUDES = -I../common -I../../mfb -I../../cfb \
+	-I../../mi -I$(SERVERSRC)/include -I$(INCLUDESRC) \
+	-I$(XINCLUDESRC)/fonts -I$(GLXINC) -I$(EXTENSIONSRC)/include \
+	-I$(XINCLUDESRC) -I./gsos
+
+#LINTLIBS = ../../../dix/llib-ldix.ln ../../../os/llib-los.ln \
+#	../../mi/llib-lmi.ln ../../mfb/llib-lmfb.ln \
+#	../../cfb/llib-lcfb.ln ../../cfb16/llib-lcfb.ln \
+#	../../cfb32/llib-lcfb.ln ../common/llib-lcommon.ln
+
+DEFINES = -DPSZ=32
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(gsx,$(OBJS))
+
+DependTarget()
+#LintLibraryTarget(gaix,$(SRCS))
+#NormalLintTarget($(SRCS))
+
+MakeSubdirs($(SUBDIRS))
+DependSubdirs($(SUBDIRS))
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/XGSConfig XFree86.current/xc/programs/Xserver/hw/gsx/XGSConfig
--- XFree86/xc/programs/Xserver/hw/gsx/XGSConfig	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/XGSConfig	Fri Mar  2 18:13:27 2001
@@ -0,0 +1,57 @@
+#
+# Sample XGSConfig File
+#
+
+Section "Files"
+   RgbPath    "/usr/X11R6/lib/X11/rgb"
+   FontPath   "/usr/X11R6/lib/X11/fonts/100dpi"
+   FontPath   "/usr/X11R6/lib/X11/fonts/75dpi"
+   FontPath   "/usr/X11R6/lib/X11/fonts/Speedo"
+   FontPath   "/usr/X11R6/lib/X11/fonts/Type1"
+   FontPath   "/usr/X11R6/lib/X11/fonts/cyrillic"
+   FontPath   "/usr/X11R6/lib/X11/fonts/local"
+   FontPath   "/usr/X11R6/lib/X11/fonts/misc"
+EndSection
+
+Section "Keyboard"
+   Protocol        "Standard"
+   AutoRepeat      500 5
+   LeftAlt         Meta
+   RightAlt        Meta
+   ScrollLock      Compose
+   RightCtl        Control
+   XkbKeycodes     "xfree86"
+   XkbTypes        "default"
+   XkbCompat       "default"
+   XkbGeometry     "pc"
+   XkbRules        "xfree86"
+   XkbSymbols      "us(pc101)"
+   XkbModel        "pc101"
+   XkbLayout       "us"
+#   XkbSymbols      "jp"
+#   XkbModel        "jp106"
+#   XkbLayout       "jp"
+   XkbOptions      "ctrl:nocaps"
+EndSection
+
+Section "Pointer"
+   Protocol        "ps/2"
+   Device          "/dev/mouse"
+   Emulate3Timeout 50
+   Emulate3Buttons
+EndSection
+
+Section "Screen"
+   Driver          "gsx"
+   Device          "Graphics Synthesizer"
+   DefaultColorDepth 16
+   FrameRate	   60
+   SubSection "Display"
+      Depth        16
+      Modes        "1024x768" "800x600" "1280x1024" "640x480"
+   EndSubSection
+   SubSection "Display"
+      Depth        24
+      Modes        "1024x768" "800x600" "640x480"
+   EndSubSection
+EndSection
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/Imakefile XFree86.current/xc/programs/Xserver/hw/gsx/common/Imakefile
--- XFree86/xc/programs/Xserver/hw/gsx/common/Imakefile	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/Imakefile	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,100 @@
+
+#include <Server.tmpl>
+
+#ifdef i386MachArchitecture
+        KBD = xf86KbdMach
+#else
+# ifdef i386BsdArchitecture
+        KBD = xf86KbdBSD
+# else
+#  ifdef LinuxArchitecture
+        KBD = xf86KbdLnx
+#  else
+        KBD = xf86Kbd
+#  endif
+# endif
+#endif
+
+#if BuildXKB
+     XKBDDXSRC = xf86XKB.c
+     XKBDDXOBJ = xf86XKB.o
+#endif
+
+  XCONFIGSRC = xf86Config
+ XCONFIGFILE = XGSConfig
+
+#if !defined(LynxOSArchitecture) && !defined(OS2Architecture)
+ PNP_MOUSE_SRC=xf86_PnPMouse.c
+ PNP_MOUSE_OBJ=xf86_PnPMouse.o
+ PNP_MOUSE_DEFINES=-DPNP_MOUSE
+#endif
+
+#ifndef XF86ExpireServer
+#define XF86ExpireServer	NO
+#endif
+
+OSSUPPORT_SRC = lnx_init.c lnx_io.c std_kbdEv.c std_mouse.c std_mseEv.c posix_tty.c VTsw_usl.c
+OSSUPPORT_OBJ = lnx_init.o lnx_io.o std_kbdEv.o std_mouse.o std_mseEv.o posix_tty.o VTsw_usl.o
+
+SRCS =	\
+	$(XF86DL_SRC) \
+	$(XCONFIGSRC).c \
+	xf86Events.c \
+	xf86Init.c \
+	xf86Io.c \
+	xf86_Mouse.c \
+	xf86_Option.c \
+	$(KBD).c \
+	$(XKBDDXSRC) \
+	$(OSSUPPORT_SRC) \
+    stubs.c
+
+OBJS = \
+	$(XF86DL_OBJ) \
+	$(XCONFIGSRC).o \
+	xf86Events.o \
+	xf86Init.o \
+	xf86Io.o \
+	xf86_Mouse.o \
+	xf86_Option.o \
+	$(KBD).o \
+	$(XKBDDXOBJ) \
+	$(OSSUPPORT_OBJ) \
+    stubs.o
+
+OFILES = \
+	xf86Events.o \
+	xf86Init.o \
+	xf86Io.o \
+	xf86_Mouse.o \
+    stubs.o
+
+   INCLUDES = -I. -I.. -I$(SERVERSRC)/mfb -I$(SERVERSRC)/mi \
+              -I$(SERVERSRC)/include -I$(SERVERSRC)/os \
+              -I$(XINCLUDESRC) -I$(EXTINCSRC)
+
+     OSNAME = OSName
+   OSVENDOR = OSVendor
+  OSNAMEDEF = -DOSNAME='"$(OSNAME)"' -DOSVENDOR='"$(OSVENDOR)"'
+CONSDEFINES = XFree86ConsoleDefines
+EXP_DEFINES = -DEXPIRY_TIME=XF86ServerExpiry $(EXP_FORCE_DEFINES)
+
+GSXDEF = -DGSXMOUSEON
+
+    DEFINES = $(XCONFIGDEFINES) $(CONSDEFINES) $(PNP_MOUSE_DEFINES) $(GSXDEF)
+
+all:: $(OBJS)
+
+SpecialObjectRule($(XCONFIGSRC).o,$(XCONFIGSRC).c,\
+'-DSERVER_CONFIG_FILE="$(LIBDIR)/$(XCONFIGFILE)"' \
+'-DXCONFIGFILE="$(XCONFIGFILE)"' \
+$(MODULEDEFINES) $(EXT_DEFINES))
+SpecialObjectRule(xf86Init.o,xf86Init.c $(ICONFIGFILES),$(OSNAMEDEF) $(EXT_DEFINES) $(BETADEFS))
+SpecialCObjectRule(xf86Events,$(ICONFIGFILES),$(EXT_DEFINES))
+
+NormalLibraryObjectRule()
+NormalLibraryTarget(gsxinput,$(OBJS))
+
+InstallLinkKitLibrary(xf86,$(LINKKITDIR)/lib86)
+
+DependTarget()
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/VTsw_usl.c XFree86.current/xc/programs/Xserver/hw/gsx/common/VTsw_usl.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/VTsw_usl.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/VTsw_usl.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,80 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/VTsw_usl.c,v 3.1 1996/12/23 06:50:57 dawes Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  David Wexelblat makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE 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.
+ *
+ */
+/* $XConsortium: VTsw_usl.c /main/3 1996/02/21 17:53:28 kaleb $ */
+
+#include "X.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86.h"
+#include "xf86Priv.h"
+#include "xf86_OSlib.h"
+
+/*
+ * Handle the VT-switching interface for OSs that use USL-style ioctl()s
+ * (the sysv, sco, and linux subdirs).
+ */
+
+/*
+ * This function is the signal handler for the VT-switching signal.  It
+ * is only referenced inside the OS-support layer.
+ */
+void xf86VTRequest(sig)
+int sig;
+{
+	signal(sig, (void(*)())xf86VTRequest);
+	xf86Info.vtRequestsPending = TRUE;
+	return;
+}
+
+Bool xf86VTSwitchPending()
+{
+	return(xf86Info.vtRequestsPending ? TRUE : FALSE);
+}
+
+Bool xf86VTSwitchAway()
+{
+	xf86Info.vtRequestsPending = FALSE;
+	if (ioctl(xf86Info.consoleFd, VT_RELDISP, 1) < 0)
+	{
+		return(FALSE);
+	}
+	else
+	{
+		return(TRUE);
+	}
+}
+
+Bool xf86VTSwitchTo()
+{
+	xf86Info.vtRequestsPending = FALSE;
+	if (ioctl(xf86Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
+	{
+		return(FALSE);
+	}
+	else
+	{
+		return(TRUE);
+	}
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/assyntax.h XFree86.current/xc/programs/Xserver/hw/gsx/common/assyntax.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/assyntax.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/assyntax.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,725 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/assyntax.h,v 3.7.2.3 1998/09/05 03:32:04 dawes Exp $ */
+#ifndef __ASSYNTAX_H__
+#define	__ASSYNTAX_H__
+
+/*
+ * Copyright 1992 Vrije Universiteit, The Netherlands
+ *
+ * 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 and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of the Vrije Universiteit not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  The Vrije Universiteit makes no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * The Vrije Universiteit DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL The Vrije Universiteit BE LIABLE 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.
+ */
+/* $XConsortium: assyntax.h /main/5 1996/02/21 17:50:49 kaleb $ */
+
+ /*
+ * assyntax.h
+ *
+ * Select the syntax appropriate to the 386 assembler being used
+ * To add support for more assemblers add more columns to the CHOICE
+ * macro.  Note that register names must also have uppercase names
+ * to avoid macro recursion. e.g., #define ah %ah recurses!
+ *
+ * NB 1.  Some of the macros for certain assemblers imply that the code is to
+ *	  run in protected mode!!  Caveat emptor.
+ *
+ * NB 2.  486 specific instructions are not included.  This is to discourage
+ *	  their accidental use in code that is intended to run on 386 and 486
+ *	  systems.
+ *
+ * Supported assemblers:
+ *
+ * (a) AT&T SysVr4 as(1):	default
+ * (b) GNU Assembler gas:	define USE_GAS or GNU_ASSEMBLER
+ * (c) Amsterdam Compiler kit:	define ACK_ASSEMBLER
+ *
+ * The following naming conventions have been used to identify the various
+ * data types:
+ *		_SR = segment register version
+ *	Integer:
+ *		_Q = quadword	= 64 bits
+ *		_L = long	= 32 bits
+ *		_W = short	= 16 bits
+ *		_B = byte	=  8 bits
+ *	Floating-point:
+ *		_X = m80real	= 80 bits
+ *		_D = double	= 64 bits
+ *		_S = single	= 32 bits
+ *
+ * Author: Gregory J. Sharp, Sept 1992
+ *         Vrije Universiteit, Amsterdam, The Netherlands
+ */
+
+#if defined(USE_GAS) && !defined(GNU_ASSEMBLER)
+#define GNU_ASSEMBLER
+#endif
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (sun) && defined (i386) && defined (SVR4) && defined (__STDC__) && !defined (__GNUC__)) 
+#define	CONCAT(x, y)	x ## y
+#else
+#define	CONCAT(x, y)	x/**/y
+#endif
+
+#ifdef ACK_ASSEMBLER
+
+/* Assume we write code for 32-bit protected mode! */
+
+/* Redefine register names for GAS & AT&T assemblers */
+#define	AL	al
+#define	AH	ah
+#define	AX	ax
+#define	EAX	ax
+#define	BL	bl
+#define	BH	bh
+#define	BX	bx
+#define	EBX	bx
+#define	CL	cl
+#define	CH	ch
+#define	CX	cx
+#define	ECX	cx
+#define	DL	dl
+#define	DH	dh
+#define	DX	dx
+#define	EDX	dx
+#define	BP	bp
+#define	EBP	bp
+#define	SI	si
+#define	ESI	si
+#define	DI	di
+#define	EDI	di
+#define	SP	sp
+#define	ESP	sp
+#define	CS	cs
+#define	SS	ss
+#define	DS	ds
+#define	ES	es
+#define	FS	fs
+#define	GS	gs
+/* Control Registers */
+#define	CR0	cr0
+#define	CR1	cr1
+#define	CR2	cr2
+#define	CR3	cr3
+/* Debug Registers */
+#define	DR0	dr0
+#define	DR1	dr1
+#define	DR2	dr2
+#define	DR3	dr3
+#define	DR4	dr4
+#define	DR5	dr5
+#define	DR6	dr6
+#define	DR7	dr7
+/* Floating-point Stack */
+#define	ST	st
+
+#define	AS_BEGIN	.sect .text; .sect .rom; .sect .data; .sect .bss; .sect .text
+
+
+#define	_WTOG		o16	/* word toggle for _W instructions */
+#define	_LTOG			/* long toggle for _L instructions */
+#define	ADDR_TOGGLE	a16
+#define	OPSZ_TOGGLE	o16
+#define	USE16		.use16
+#define	USE32		.use32
+
+#define	CHOICE(a,b,c)	c
+
+#else /* AT&T or GAS */
+
+/* Redefine register names for GAS & AT&T assemblers */
+#define	AL	%al
+#define	AH	%ah
+#define	AX	%ax
+#define	EAX	%eax
+#define	BL	%bl
+#define	BH	%bh
+#define	BX	%bx
+#define	EBX	%ebx
+#define	CL	%cl
+#define	CH	%ch
+#define	CX	%cx
+#define	ECX	%ecx
+#define	DL	%dl
+#define	DH	%dh
+#define	DX	%dx
+#define	EDX	%edx
+#define	BP	%bp
+#define	EBP	%ebp
+#define	SI	%si
+#define	ESI	%esi
+#define	DI	%di
+#define	EDI	%edi
+#define	SP	%sp
+#define	ESP	%esp
+#define	CS	%cs
+#define	SS	%ss
+#define	DS	%ds
+#define	ES	%es
+#define	FS	%fs
+#define	GS	%gs
+/* Control Registers */
+#define	CR0	%cr0
+#define	CR1	%cr1
+#define	CR2	%cr2
+#define	CR3	%cr3
+/* Debug Registers */
+#define	DR0	%db0
+#define	DR1	%db1
+#define	DR2	%db2
+#define	DR3	%db3
+#define	DR4	%db4
+#define	DR5	%db5
+#define	DR6	%db6
+#define	DR7	%db7
+/* Floating-point Stack */
+#define	ST	%st
+
+#define	AS_BEGIN
+#define	USE16
+#define	USE32
+
+#ifdef GNU_ASSEMBLER
+
+#define	ADDR_TOGGLE	aword
+#define	OPSZ_TOGGLE	word
+
+#define	CHOICE(a,b,c)	b
+
+#else
+/*
+ * AT&T ASSEMBLER SYNTAX
+ * *********************
+ */
+#define	CHOICE(a,b,c)	a
+
+#define	ADDR_TOGGLE	addr16
+#define	OPSZ_TOGGLE	data16
+
+#endif /* GNU_ASSEMBLER */
+#endif /* ACK_ASSEMBLER */
+
+
+#if defined(Lynx) || (defined(SYSV) || defined(SVR4)) && !defined(ACK_ASSEMBLER) || defined(__ELF__)
+#define GLNAME(a)       a
+#else
+#define GLNAME(a)       CONCAT(_,a)
+#endif
+
+
+	/****************************************/
+	/*					*/
+	/*	Select the various choices	*/
+	/*					*/
+	/****************************************/
+
+
+/* Redefine assembler directives */
+/*********************************/
+#define GLOBL		CHOICE(.globl, .globl, .extern)
+#define	ALIGNTEXT4	CHOICE(.align 4, .align ARG2(2,0x90), .align 4)
+#define	ALIGNTEXT2	CHOICE(.align 2, .align ARG2(1,0x90), .align 2)
+/* ALIGNTEXT4ifNOP is the same as ALIGNTEXT4, but only if the space is
+ * guaranteed to be filled with NOPs.  Otherwise it does nothing.
+ */
+#define	ALIGNTEXT4ifNOP	CHOICE(.align 4, .align ARG2(2,0x90), /*can't do it*/)
+#define	ALIGNDATA4	CHOICE(.align 4, .align ARG2(2,0x0), .align 4)
+#define	ALIGNDATA2	CHOICE(.align 2, .align ARG2(1,0x0), .align 2)
+#define	FILE(s)		CHOICE(.file s, .file s, .file s)
+#define	STRING(s)	CHOICE(.string s, .asciz s, .asciz s)
+#define	D_LONG		CHOICE(.long, .long, .data4)
+#define	D_WORD		CHOICE(.value, .short, .data2)
+#define	D_BYTE		CHOICE(.byte, .byte, .data1)
+#define	SPACE		CHOICE(.comm, .space, .space)
+#define	COMM		CHOICE(.comm, .comm, .comm)
+#define	SEG_DATA	CHOICE(.data, .data, .sect .data)
+#define	SEG_TEXT	CHOICE(.text, .text, .sect .text)
+#define	SEG_BSS		CHOICE(.bss, .bss, .sect .bss)
+
+#ifdef GNU_ASSEMBLER
+#define	D_SPACE(n)	. = . + n
+#else
+#define	D_SPACE(n)	.space n
+#endif
+
+/* Addressing Modes */
+/* Immediate Mode */
+#define	ADDR(a)		CHOICE(CONCAT($,a), CONCAT($,a), a)
+#define	CONST(a)	CHOICE(CONCAT($,a), CONCAT($,a), a)
+
+/* Indirect Mode */
+#define	CONTENT(a)	CHOICE(a, a, (a))	 /* take contents of variable */
+#define	REGIND(a)	CHOICE((a), (a), (a))	 /* Register a indirect */
+/* Register b indirect plus displacement a */
+#define	REGOFF(a, b)	CHOICE(a(b), a(b), a(b))
+/* Reg indirect Base + Index + Displacement  - this is mainly for 16-bit mode
+ * which has no scaling
+ */
+#define	REGBID(b,i,d)	CHOICE(d(b,i), d(b,i), d(b)(i))
+/* Reg indirect Base + (Index * Scale) + Displacement */
+#define	REGBISD(b,i,s,d) CHOICE(d(b,i,s), d(b,i,s), d(b)(i*s))
+/* Displaced Scaled Index: */
+#define REGDIS(d,i,s)	CHOICE(d(,i,s), d(,i,s), d(i * s))
+/* Indexed Base: */
+#define REGBI(b,i)	CHOICE((b,i), (b,i), (b)(i))
+/* Displaced Base: */
+#define REGDB(d,b)	CHOICE(d(b), d(b), d(b))
+/* Variable indirect: */
+#define VARINDIRECT(var) CHOICE(*var, *var, (var))
+/* Use register contents as jump/call target: */
+#define CODEPTR(reg)	CHOICE(*reg, *reg, reg)
+
+/* For expressions requiring bracketing
+ * eg. (CRT0_PM | CRT_EM)
+ */
+
+#define	EXPR(a)		CHOICE([a], (a), [a])
+#define	ENOT(a)		CHOICE(0!a, ~a, ~a)
+#define	EMUL(a,b)	CHOICE(a\*b, a*b, a*b)
+#define	EDIV(a,b)	CHOICE(a\/b, a/b, a/b)
+
+/*
+ * We have to beat the problem of commas within arguments to choice.
+ * eg. choice (add a,b, add b,a) will get argument mismatch.  Luckily ANSI
+ * and other known cpp definitions evaluate arguments before substitution
+ * so the following works.
+ */
+#define	ARG2(a, b)	a,b
+#define	ARG3(a,b,c)	a,b,c
+
+/* Redefine assembler commands */
+#define	AAA		CHOICE(aaa, aaa, aaa)
+#define	AAD		CHOICE(aad, aad, aad)
+#define	AAM		CHOICE(aam, aam, aam)
+#define	AAS		CHOICE(aas, aas, aas)
+#define	ADC_L(a, b)	CHOICE(adcl ARG2(a,b), adcl ARG2(a,b), _LTOG adc ARG2(b,a))
+#define	ADC_W(a, b)	CHOICE(adcw ARG2(a,b), adcw ARG2(a,b), _WTOG adc ARG2(b,a))
+#define	ADC_B(a, b)	CHOICE(adcb ARG2(a,b), adcb ARG2(a,b), adcb ARG2(b,a))
+#define	ADD_L(a, b)	CHOICE(addl ARG2(a,b), addl ARG2(a,b), _LTOG add ARG2(b,a))
+#define	ADD_W(a, b)	CHOICE(addw ARG2(a,b), addw ARG2(a,b), _WTOG add ARG2(b,a))
+#define	ADD_B(a, b)	CHOICE(addb ARG2(a,b), addb ARG2(a,b), addb ARG2(b,a))
+#define	AND_L(a, b)	CHOICE(andl ARG2(a,b), andl ARG2(a,b), _LTOG and ARG2(b,a))
+#define	AND_W(a, b)	CHOICE(andw ARG2(a,b), andw ARG2(a,b), _WTOG and ARG2(b,a))
+#define	AND_B(a, b)	CHOICE(andb ARG2(a,b), andb ARG2(a,b), andb ARG2(b,a))
+#define	ARPL(a,b)	CHOICE(arpl ARG2(a,b), arpl ARG2(a,b), arpl ARG2(b,a))
+#define	BOUND_L(a, b)	CHOICE(boundl ARG2(a,b), boundl ARG2(b,a), _LTOG bound ARG2(b,a))
+#define	BOUND_W(a, b)	CHOICE(boundw ARG2(a,b), boundw ARG2(b,a), _WTOG bound ARG2(b,a))
+#define	BSF_L(a, b)	CHOICE(bsfl ARG2(a,b), bsfl ARG2(a,b), _LTOG bsf ARG2(b,a))
+#define	BSF_W(a, b)	CHOICE(bsfw ARG2(a,b), bsfw ARG2(a,b), _WTOG bsf ARG2(b,a))
+#define	BSR_L(a, b)	CHOICE(bsrl ARG2(a,b), bsrl ARG2(a,b), _LTOG bsr ARG2(b,a))
+#define	BSR_W(a, b)	CHOICE(bsrw ARG2(a,b), bsrw ARG2(a,b), _WTOG bsr ARG2(b,a))
+#define	BT_L(a, b)	CHOICE(btl ARG2(a,b), btl ARG2(a,b), _LTOG bt ARG2(b,a))
+#define	BT_W(a, b)	CHOICE(btw ARG2(a,b), btw ARG2(a,b), _WTOG bt ARG2(b,a))
+#define	BTC_L(a, b)	CHOICE(btcl ARG2(a,b), btcl ARG2(a,b), _LTOG btc ARG2(b,a))
+#define	BTC_W(a, b)	CHOICE(btcw ARG2(a,b), btcw ARG2(a,b), _WTOG btc ARG2(b,a))
+#define	BTR_L(a, b)	CHOICE(btrl ARG2(a,b), btrl ARG2(a,b), _LTOG btr ARG2(b,a))
+#define	BTR_W(a, b)	CHOICE(btrw ARG2(a,b), btrw ARG2(a,b), _WTOG btr ARG2(b,a))
+#define	BTS_L(a, b)	CHOICE(btsl ARG2(a,b), btsl ARG2(a,b), _LTOG bts ARG2(b,a))
+#define	BTS_W(a, b)	CHOICE(btsw ARG2(a,b), btsw ARG2(a,b), _WTOG bts ARG2(b,a))
+#define	CALL(a)		CHOICE(call a, call a, call a)
+#define	CALLF(s,a)	CHOICE(lcall ARG2(s,a), lcall ARG2(s,a), callf s:a)
+#define	CBW		CHOICE(cbtw, cbw, cbw)
+#define	CWDE		CHOICE(cwtd, cwde, cwde)
+#define	CLC		CHOICE(clc, clc, clc)
+#define	CLD		CHOICE(cld, cld, cld)
+#define	CLI		CHOICE(cli, cli, cli)
+#define	CLTS		CHOICE(clts, clts, clts)
+#define	CMC		CHOICE(cmc, cmc, cmc)
+#define	CMP_L(a, b)	CHOICE(cmpl ARG2(a,b), cmpl ARG2(a,b), _LTOG cmp ARG2(b,a))
+#define	CMP_W(a, b)	CHOICE(cmpw ARG2(a,b), cmpw ARG2(a,b), _WTOG cmp ARG2(b,a))
+#define	CMP_B(a, b)	CHOICE(cmpb ARG2(a,b), cmpb ARG2(a,b), cmpb ARG2(b,a))
+#define	CMPS_L		CHOICE(cmpsl, cmpsl, _LTOG cmps)
+#define	CMPS_W		CHOICE(cmpsw, cmpsw, _WTOG cmps)
+#define	CMPS_B		CHOICE(cmpsb, cmpsb, cmpsb)
+#define	CWD		CHOICE(cwtl, cwd, cwd)
+#define	CDQ		CHOICE(cltd, cdq, cdq)
+#define	DAA		CHOICE(daa, daa, daa)
+#define	DAS		CHOICE(das, das, das)
+#define	DEC_L(a)	CHOICE(decl a, decl a, _LTOG dec a)
+#define	DEC_W(a)	CHOICE(decw a, decw a, _WTOG dec a)
+#define	DEC_B(a)	CHOICE(decb a, decb a, decb a)
+#define	DIV_L(a)	CHOICE(divl a, divl a, div a)
+#define	DIV_W(a)	CHOICE(divw a, divw a, div a)
+#define	DIV_B(a)	CHOICE(divb a, divb a, divb a)
+#define	ENTER(a,b)	CHOICE(enter ARG2(a,b), enter ARG2(a,b), enter ARG2(b,a))
+#define	HLT		CHOICE(hlt, hlt, hlt)
+#define	IDIV_L(a)	CHOICE(idivl a, idivl a, _LTOG idiv a)
+#define	IDIV_W(a)	CHOICE(idivw a, idivw a, _WTOG idiv a)
+#define	IDIV_B(a)	CHOICE(idivb a, idivb a, idivb a)
+/* More forms than this for imul!! */
+#define	IMUL_L(a, b)	CHOICE(imull ARG2(a,b), imull ARG2(a,b), _LTOG imul ARG2(b,a))
+#define	IMUL_W(a, b)	CHOICE(imulw ARG2(a,b), imulw ARG2(a,b), _WTOG imul ARG2(b,a))
+#define	IMUL_B(a)	CHOICE(imulb a, imulb a, imulb a)
+#define	IN_L		CHOICE(inl (DX), inl ARG2(DX,EAX), _LTOG in DX)
+#define	IN_W		CHOICE(inw (DX), inw ARG2(DX,AX), _WTOG in DX)
+#define	IN_B		CHOICE(inb (DX), inb ARG2(DX,AL), inb DX)
+/* Please AS code writer: use the following ONLY, if you refer to ports<256
+ * directly, but not in IN1_W(DX), for instance, even if IN1_ looks nicer
+ */
+#if defined (sun)
+#define IN1_L(a)    CHOICE(inl (a), inl ARG2(a,EAX), _LTOG in a)
+#define IN1_W(a)    CHOICE(inw (a), inw ARG2(a,AX), _WTOG in a)
+#define IN1_B(a)    CHOICE(inb (a), inb ARG2(a,AL), inb a)
+#else
+#define	IN1_L(a)	CHOICE(inl a, inl ARG2(a,EAX), _LTOG in a)
+#define	IN1_W(a)	CHOICE(inw a, inw ARG2(a,AX), _WTOG in a)
+#define	IN1_B(a)	CHOICE(inb a, inb ARG2(a,AL), inb a)
+#endif
+#define	INC_L(a)	CHOICE(incl a, incl a, _LTOG inc a)
+#define	INC_W(a)	CHOICE(incw a, incw a, _WTOG inc a)
+#define	INC_B(a)	CHOICE(incb a, incb a, incb a)
+#define	INS_L		CHOICE(insl, insl, _LTOG ins)
+#define	INS_W		CHOICE(insw, insw, _WTOG ins)
+#define	INS_B		CHOICE(insb, insb, insb)
+#define	INT(a)		CHOICE(int a, int a, int a)
+#define	INT3		CHOICE(int CONST(3), int3, int CONST(3))
+#define	INTO		CHOICE(into, into, into)
+#define	IRET		CHOICE(iret, iret, iret)
+#define	IRETD		CHOICE(iret, iret, iretd)
+#define	JA(a)		CHOICE(ja a, ja a, ja a)
+#define	JAE(a)		CHOICE(jae a, jae a, jae a)
+#define	JB(a)		CHOICE(jb a, jb a, jb a)
+#define	JBE(a)		CHOICE(jbe a, jbe a, jbe a)
+#define	JC(a)		CHOICE(jc a, jc a, jc a)
+#define	JE(a)		CHOICE(je a, je a, je a)
+#define	JG(a)		CHOICE(jg a, jg a, jg a)
+#define	JGE(a)		CHOICE(jge a, jge a, jge a)
+#define	JL(a)		CHOICE(jl a, jl a, jl a)
+#define	JLE(a)		CHOICE(jle a, jle a, jle a)
+#define	JNA(a)		CHOICE(jna a, jna a, jna a)
+#define	JNAE(a)		CHOICE(jnae a, jnae a, jnae a)
+#define	JNB(a)		CHOICE(jnb a, jnb a, jnb a)
+#define	JNBE(a)		CHOICE(jnbe a, jnbe a, jnbe a)
+#define	JNC(a)		CHOICE(jnc a, jnc a, jnc a)
+#define	JNE(a)		CHOICE(jne a, jne a, jne a)
+#define	JNG(a)		CHOICE(jng a, jng a, jng a)
+#define	JNGE(a)		CHOICE(jnge a, jnge a, jnge a)
+#define	JNL(a)		CHOICE(jnl a, jnl a, jnl a)
+#define	JNLE(a)		CHOICE(jnle a, jnle a, jnle a)
+#define	JNO(a)		CHOICE(jno a, jno a, jno a)
+#define	JNP(a)		CHOICE(jnp a, jnp a, jnp a)
+#define	JNS(a)		CHOICE(jns a, jns a, jns a)
+#define	JNZ(a)		CHOICE(jnz a, jnz a, jnz a)
+#define	JO(a)		CHOICE(jo a, jo a, jo a)
+#define	JP(a)		CHOICE(jp a, jp a, jp a)
+#define	JPE(a)		CHOICE(jpe a, jpe a, jpe a)
+#define	JPO(a)		CHOICE(jpo a, jpo a, jpo a)
+#define	JS(a)		CHOICE(js a, js a, js a)
+#define	JZ(a)		CHOICE(jz a, jz a, jz a)
+#define	JMP(a)		CHOICE(jmp a, jmp a, jmp a)
+#define	JMPF(s,a)	CHOICE(ljmp ARG2(s,a), ljmp ARG2(s,a), jmpf s:a)
+#define	LAHF		CHOICE(lahf, lahf, lahf)
+#if !defined(_REAL_MODE) && !defined(_V86_MODE)
+#define	LAR(a, b)	CHOICE(lar ARG2(a, b), lar ARG2(a, b), lar ARG2(b, a))
+#endif
+#define	LEA_L(a, b)	CHOICE(leal ARG2(a,b), leal ARG2(a,b), _LTOG lea ARG2(b,a))
+#define	LEA_W(a, b)	CHOICE(leaw ARG2(a,b), leaw ARG2(a,b), _WTOG lea ARG2(b,a))
+#define	LEAVE		CHOICE(leave, leave, leave)
+#define	LGDT(a)		CHOICE(lgdt a, lgdt a, lgdt a)
+#define	LIDT(a)		CHOICE(lidt a, lidt a, lidt a)
+#define	LDS(a, b)	CHOICE(ldsl ARG2(a,b), lds ARG2(a,b), lds ARG2(b,a))
+#define	LES(a, b)	CHOICE(lesl ARG2(a,b), les ARG2(a,b), les ARG2(b,a))
+#define	LFS(a, b)	CHOICE(lfsl ARG2(a,b), lfs ARG2(a,b), lfs ARG2(b,a))
+#define	LGS(a, b)	CHOICE(lgsl ARG2(a,b), lgs ARG2(a,b), lgs ARG2(b,a))
+#define	LSS(a, b)	CHOICE(lssl ARG2(a,b), lss ARG2(a,b), lss ARG2(b,a))
+#define	LLDT(a)		CHOICE(lldt a, lldt a, lldt a)
+#define	LMSW(a)		CHOICE(lmsw a, lmsw a, lmsw a)
+#define LOCK		CHOICE(lock, lock, lock)
+#define	LODS_L		CHOICE(lodsl, lodsl, _LTOG lods)
+#define	LODS_W		CHOICE(lodsw, lodsw, _WTOG lods)
+#define	LODS_B		CHOICE(lodsb, lodsb, lodsb)
+#define	LOOP(a)		CHOICE(loop a, loop a, loop a)
+#define	LOOPE(a)	CHOICE(loope a, loope a, loope a)
+#define	LOOPZ(a)	CHOICE(loopz a, loopz a, loopz a)
+#define	LOOPNE(a)	CHOICE(loopne a, loopne a, loopne a)
+#define	LOOPNZ(a)	CHOICE(loopnz a, loopnz a, loopnz a)
+#if !defined(_REAL_MODE) && !defined(_V86_MODE)
+#define	LSL(a, b)	CHOICE(lsl ARG2(a,b), lsl ARG2(a,b), lsl ARG2(b,a))
+#endif
+#define	LTR(a)		CHOICE(ltr a, ltr a, ltr a)
+#define	MOV_SR(a, b)	CHOICE(movw ARG2(a,b), mov ARG2(a,b), mov ARG2(b,a))
+#define	MOV_L(a, b)	CHOICE(movl ARG2(a,b), movl ARG2(a,b), _LTOG mov ARG2(b,a))
+#define	MOV_W(a, b)	CHOICE(movw ARG2(a,b), movw ARG2(a,b), _WTOG mov ARG2(b,a))
+#define	MOV_B(a, b)	CHOICE(movb ARG2(a,b), movb ARG2(a,b), movb ARG2(b,a))
+#define	MOVS_L		CHOICE(movsl, movsl, _LTOG movs)
+#define	MOVS_W		CHOICE(movsw, movsw, _WTOG movs)
+#define	MOVS_B		CHOICE(movsb, movsb, movsb)
+#define	MOVSX_BL(a, b)	CHOICE(movsbl ARG2(a,b), movsbl ARG2(a,b), movsx ARG2(b,a))
+#define	MOVSX_BW(a, b)	CHOICE(movsbw ARG2(a,b), movsbw ARG2(a,b), movsx ARG2(b,a))
+#define	MOVSX_WL(a, b)	CHOICE(movswl ARG2(a,b), movswl ARG2(a,b), movsx ARG2(b,a))
+#define	MOVZX_BL(a, b)	CHOICE(movzbl ARG2(a,b), movzbl ARG2(a,b), movzx ARG2(b,a))
+#define	MOVZX_BW(a, b)	CHOICE(movzbw ARG2(a,b), movzbw ARG2(a,b), movzx ARG2(b,a))
+#define	MOVZX_WL(a, b)	CHOICE(movzwl ARG2(a,b), movzwl ARG2(a,b), movzx ARG2(b,a))
+#define	MUL_L(a)	CHOICE(mull a, mull a, _LTOG mul a)
+#define	MUL_W(a)	CHOICE(mulw a, mulw a, _WTOG mul a)
+#define	MUL_B(a)	CHOICE(mulb a, mulb a, mulb a)
+#define	NEG_L(a)	CHOICE(negl a, negl a, _LTOG neg a)
+#define	NEG_W(a)	CHOICE(negw a, negw a, _WTOG neg a)
+#define	NEG_B(a)	CHOICE(negb a, negb a, negb a)
+#define	NOP		CHOICE(nop, nop, nop)
+#define	NOT_L(a)	CHOICE(notl a, notl a, _LTOG not a)
+#define	NOT_W(a)	CHOICE(notw a, notw a, _WTOG not a)
+#define	NOT_B(a)	CHOICE(notb a, notb a, notb a)
+#define	OR_L(a,b)	CHOICE(orl ARG2(a,b), orl ARG2(a,b), _LTOG or ARG2(b,a))
+#define	OR_W(a,b)	CHOICE(orw ARG2(a,b), orw ARG2(a,b), _WTOG or ARG2(b,a))
+#define	OR_B(a,b)	CHOICE(orb ARG2(a,b), orb ARG2(a,b), orb ARG2(b,a))
+#define	OUT_L		CHOICE(outl (DX), outl ARG2(EAX,DX), _LTOG out DX)
+#define	OUT_W		CHOICE(outw (DX), outw ARG2(AX,DX), _WTOG out DX)
+#define	OUT_B		CHOICE(outb (DX), outb ARG2(AL,DX), outb DX)
+/* Please AS code writer: use the following ONLY, if you refer to ports<256
+ * directly, but not in OUT1_W(DX), for instance, even if OUT1_ looks nicer
+ */
+#define	OUT1_L(a)	CHOICE(outl (a), outl ARG2(EAX,a), _LTOG out a)
+#define	OUT1_W(a)	CHOICE(outw (a), outw ARG2(AX,a), _WTOG out a)
+#define	OUT1_B(a)	CHOICE(outb (a), outb ARG2(AL,a), outb a)
+#define	OUTS_L		CHOICE(outsl, outsl, _LTOG outs)
+#define	OUTS_W		CHOICE(outsw, outsw, _WTOG outs)
+#define	OUTS_B		CHOICE(outsb, outsb, outsb)
+#define	POP_SR(a)	CHOICE(pop a, pop a, pop a)
+#define	POP_L(a)	CHOICE(popl a, popl a, _LTOG pop a)
+#define	POP_W(a)	CHOICE(popw a, popw a, _WTOG pop a)
+#define	POPA_L		CHOICE(popal, popal, _LTOG popa)
+#define	POPA_W		CHOICE(popaw, popaw, _WTOG popa)
+#define	POPF_L		CHOICE(popfl, popfl, _LTOG popf)
+#define	POPF_W		CHOICE(popfw, popfw, _WTOG popf)
+#define	PUSH_SR(a)	CHOICE(push a, push a, push a)
+#define	PUSH_L(a)	CHOICE(pushl a, pushl a, _LTOG push a)
+#define	PUSH_W(a)	CHOICE(pushw a, pushw a, _WTOG push a)
+#define	PUSH_B(a)	CHOICE(push a, pushb a, push a)
+#define	PUSHA_L		CHOICE(pushal, pushal, _LTOG pusha)
+#define	PUSHA_W		CHOICE(pushaw, pushaw, _WTOG pusha)
+#define	PUSHF_L		CHOICE(pushfl, pushfl, _LTOG pushf)
+#define	PUSHF_W		CHOICE(pushfw, pushfw, _WTOG pushf)
+#define	RCL_L(a, b)	CHOICE(rcll ARG2(a,b), rcll ARG2(a,b), _LTOG rcl ARG2(b,a))
+#define	RCL_W(a, b)	CHOICE(rclw ARG2(a,b), rclw ARG2(a,b), _WTOG rcl ARG2(b,a))
+#define	RCL_B(a, b)	CHOICE(rclb ARG2(a,b), rclb ARG2(a,b), rclb ARG2(b,a))
+#define	RCR_L(a, b)	CHOICE(rcrl ARG2(a,b), rcrl ARG2(a,b), _LTOG rcr ARG2(b,a))
+#define	RCR_W(a, b)	CHOICE(rcrw ARG2(a,b), rcrw ARG2(a,b), _WTOG rcr ARG2(b,a))
+#define	RCR_B(a, b)	CHOICE(rcrb ARG2(a,b), rcrb ARG2(a,b), rcrb ARG2(b,a))
+#define	ROL_L(a, b)	CHOICE(roll ARG2(a,b), roll ARG2(a,b), _LTOG rol ARG2(b,a))
+#define	ROL_W(a, b)	CHOICE(rolw ARG2(a,b), rolw ARG2(a,b), _WTOG rol ARG2(b,a))
+#define	ROL_B(a, b)	CHOICE(rolb ARG2(a,b), rolb ARG2(a,b), rolb ARG2(b,a))
+#define	ROR_L(a, b)	CHOICE(rorl ARG2(a,b), rorl ARG2(a,b), _LTOG ror ARG2(b,a))
+#define	ROR_W(a, b)	CHOICE(rorw ARG2(a,b), rorw ARG2(a,b), _WTOG ror ARG2(b,a))
+#define	ROR_B(a, b)	CHOICE(rorb ARG2(a,b), rorb ARG2(a,b), rorb ARG2(b,a))
+#define	REP		CHOICE(rep ;, rep ;, repe)
+#define	REPE		CHOICE(repz ;, repe ;, repe)
+#define	REPNE		CHOICE(repnz ;, repne ;, repne)
+#define	REPNZ		REPNE
+#define	REPZ		REPE
+#define	RET		CHOICE(ret, ret, ret)
+#define	SAHF		CHOICE(sahf, sahf, sahf)
+#define	SAL_L(a, b)	CHOICE(sall ARG2(a,b), sall ARG2(a,b), _LTOG sal ARG2(b,a))
+#define	SAL_W(a, b)	CHOICE(salw ARG2(a,b), salw ARG2(a,b), _WTOG sal ARG2(b,a))
+#define	SAL_B(a, b)	CHOICE(salb ARG2(a,b), salb ARG2(a,b), salb ARG2(b,a))
+#define	SAR_L(a, b)	CHOICE(sarl ARG2(a,b), sarl ARG2(a,b), _LTOG sar ARG2(b,a))
+#define	SAR_W(a, b)	CHOICE(sarw ARG2(a,b), sarw ARG2(a,b), _WTOG sar ARG2(b,a))
+#define	SAR_B(a, b)	CHOICE(sarb ARG2(a,b), sarb ARG2(a,b), sarb ARG2(b,a))
+#define	SBB_L(a, b)	CHOICE(sbbl ARG2(a,b), sbbl ARG2(a,b), _LTOG sbb ARG2(b,a))
+#define	SBB_W(a, b)	CHOICE(sbbw ARG2(a,b), sbbw ARG2(a,b), _WTOG sbb ARG2(b,a))
+#define	SBB_B(a, b)	CHOICE(sbbb ARG2(a,b), sbbb ARG2(a,b), sbbb ARG2(b,a))
+#define	SCAS_L		CHOICE(scasl, scasl, _LTOG scas)
+#define	SCAS_W		CHOICE(scasw, scasw, _WTOG scas)
+#define	SCAS_B		CHOICE(scasb, scasb, scasb)
+#define	SETA(a)		CHOICE(seta a, seta a, seta a)
+#define	SETAE(a)	CHOICE(setae a, setae a, setae a)
+#define	SETB(a)		CHOICE(setb a, setb a, setb a)
+#define	SETBE(a)	CHOICE(setbe a, setbe a, setbe a)
+#define	SETC(a)		CHOICE(setc a, setb a, setb a)
+#define	SETE(a)		CHOICE(sete a, sete a, sete a)
+#define	SETG(a)		CHOICE(setg a, setg a, setg a)
+#define	SETGE(a)	CHOICE(setge a, setge a, setge a)
+#define	SETL(a)		CHOICE(setl a, setl a, setl a)
+#define	SETLE(a)	CHOICE(setle a, setle a, setle a)
+#define	SETNA(a)	CHOICE(setna a, setna a, setna a)
+#define	SETNAE(a)	CHOICE(setnae a, setnae a, setnae a)
+#define	SETNB(a)	CHOICE(setnb a, setnb a, setnb a)
+#define	SETNBE(a)	CHOICE(setnbe a, setnbe a, setnbe a)
+#define	SETNC(a)	CHOICE(setnc a, setnb a, setnb a)
+#define	SETNE(a)	CHOICE(setne a, setne a, setne a)
+#define	SETNG(a)	CHOICE(setng a, setng a, setng a)
+#define	SETNGE(a)	CHOICE(setnge a, setnge a, setnge a)
+#define	SETNL(a)	CHOICE(setnl a, setnl a, setnl a)
+#define	SETNLE(a)	CHOICE(setnle a, setnle a, setnle a)
+#define	SETNO(a)	CHOICE(setno a, setno a, setno a)
+#define	SETNP(a)	CHOICE(setnp a, setnp a, setnp a)
+#define	SETNS(a)	CHOICE(setns a, setns a, setna a)
+#define	SETNZ(a)	CHOICE(setnz a, setnz a, setnz a)
+#define	SETO(a)		CHOICE(seto a, seto a, seto a)
+#define	SETP(a)		CHOICE(setp a, setp a, setp a)
+#define	SETPE(a)	CHOICE(setpe a, setpe a, setpe a)
+#define	SETPO(a)	CHOICE(setpo a, setpo a, setpo a)
+#define	SETS(a)		CHOICE(sets a, sets a, seta a)
+#define	SETZ(a)		CHOICE(setz a, setz a, setz a)
+#define	SGDT(a)		CHOICE(sgdt a, sgdt a, sgdt a)
+#define	SIDT(a)		CHOICE(sidt a, sidt a, sidt a)
+#define	SHL_L(a, b)	CHOICE(shll ARG2(a,b), shll ARG2(a,b), _LTOG shl ARG2(b,a))
+#define	SHL_W(a, b)	CHOICE(shlw ARG2(a,b), shlw ARG2(a,b), _WTOG shl ARG2(b,a))
+#define	SHL_B(a, b)	CHOICE(shlb ARG2(a,b), shlb ARG2(a,b), shlb ARG2(b,a))
+#define	SHLD_L(a,b,c)	CHOICE(shldl ARG3(a,b,c), shldl ARG3(a,b,c), _LTOG shld ARG3(c,b,a))
+#define	SHLD2_L(a,b)	CHOICE(shldl ARG2(a,b), shldl ARG3(CL,a,b), _LTOG shld ARG3(b,a,CL))
+#define	SHLD_W(a,b,c)	CHOICE(shldw ARG3(a,b,c), shldw ARG3(a,b,c), _WTOG shld ARG3(c,b,a))
+#define	SHLD2_W(a,b)	CHOICE(shldw ARG2(a,b), shldw ARG3(CL,a,b), _WTOG shld ARG3(b,a,CL))
+#define	SHR_L(a, b)	CHOICE(shrl ARG2(a,b), shrl ARG2(a,b), _LTOG shr ARG2(b,a))
+#define	SHR_W(a, b)	CHOICE(shrw ARG2(a,b), shrw ARG2(a,b), _WTOG shr ARG2(b,a))
+#define	SHR_B(a, b)	CHOICE(shrb ARG2(a,b), shrb ARG2(a,b), shrb ARG2(b,a))
+#define	SHRD_L(a,b,c)	CHOICE(shrdl ARG3(a,b,c), shrdl ARG3(a,b,c), _LTOG shrd ARG3(c,b,a))
+#define	SHRD2_L(a,b)	CHOICE(shrdl ARG2(a,b), shrdl ARG3(CL,a,b), _LTOG shrd ARG3(b,a,CL))
+#define	SHRD_W(a,b,c)	CHOICE(shrdw ARG3(a,b,c), shrdw ARG3(a,b,c), _WTOG shrd ARG3(c,b,a))
+#define	SHRD2_W(a,b)	CHOICE(shrdw ARG2(a,b), shrdw ARG3(CL,a,b), _WTOG shrd ARG3(b,a,CL))
+#define	SLDT(a)		CHOICE(sldt a, sldt a, sldt a)
+#define	SMSW(a)		CHOICE(smsw a, smsw a, smsw a)
+#define	STC		CHOICE(stc, stc, stc)
+#define	STD		CHOICE(std, std, std)
+#define	STI		CHOICE(sti, sti, sti)
+#define	STOS_L		CHOICE(stosl, stosl, _LTOG stos)
+#define	STOS_W		CHOICE(stosw, stosw, _WTOG stos)
+#define	STOS_B		CHOICE(stosb, stosb, stosb)
+#define	STR(a)		CHOICE(str a, str a, str a)
+#define	SUB_L(a, b)	CHOICE(subl ARG2(a,b), subl ARG2(a,b), _LTOG sub ARG2(b,a))
+#define	SUB_W(a, b)	CHOICE(subw ARG2(a,b), subw ARG2(a,b), _WTOG sub ARG2(b,a))
+#define	SUB_B(a, b)	CHOICE(subb ARG2(a,b), subb ARG2(a,b), subb ARG2(b,a))
+#define	TEST_L(a, b)	CHOICE(testl ARG2(a,b), testl ARG2(a,b), _LTOG test ARG2(b,a))
+#define	TEST_W(a, b)	CHOICE(testw ARG2(a,b), testw ARG2(a,b), _WTOG test ARG2(b,a))
+#define	TEST_B(a, b)	CHOICE(testb ARG2(a,b), testb ARG2(a,b), testb ARG2(b,a))
+#define	VERR(a)		CHOICE(verr a, verr a, verr a)
+#define	VERW(a)		CHOICE(verw a, verw a, verw a)
+#define	WAIT		CHOICE(wait, wait, wait)
+#define	XCHG_L(a, b)	CHOICE(xchgl ARG2(a,b), xchgl ARG2(a,b), _LTOG xchg ARG2(b,a))
+#define	XCHG_W(a, b)	CHOICE(xchgw ARG2(a,b), xchgw ARG2(a,b), _WTOG xchg ARG2(b,a))
+#define	XCHG_B(a, b)	CHOICE(xchgb ARG2(a,b), xchgb ARG2(a,b), xchgb ARG2(b,a))
+#define	XLAT		CHOICE(xlat, xlat, xlat)
+#define	XOR_L(a, b)	CHOICE(xorl ARG2(a,b), xorl ARG2(a,b), _LTOG xor ARG2(b,a))
+#define	XOR_W(a, b)	CHOICE(xorw ARG2(a,b), xorw ARG2(a,b), _WTOG xor ARG2(b,a))
+#define	XOR_B(a, b)	CHOICE(xorb ARG2(a,b), xorb ARG2(a,b), xorb ARG2(b,a))
+
+
+/* Floating Point Instructions */
+#define	F2XM1		CHOICE(f2xm1, f2xm1, f2xm1)
+#define	FABS		CHOICE(fabs, fabs, fabs)
+#define	FADD_D(a)	CHOICE(faddl a, faddl a, faddd a)
+#define	FADD_S(a)	CHOICE(fadds a, fadds a, fadds a)
+#define	FADD2(a, b)	CHOICE(fadd ARG2(a,b), fadd ARG2(a,b), fadd ARG2(b,a))
+#define	FADDP(a, b)	CHOICE(faddp ARG2(a,b), faddp ARG2(a,b), faddp ARG2(b,a))
+#define	FIADD_L(a)	CHOICE(fiaddl a, fiaddl a, fiaddl a)
+#define	FIADD_W(a)	CHOICE(fiadd a, fiadds a, fiadds a)
+#define	FBLD(a)		CHOICE(fbld a, fbld a, fbld a)
+#define	FBSTP(a)	CHOICE(fbstp a, fbstp a, fbstp a)
+#define	FCHS		CHOICE(fchs, fchs, fchs)
+#define	FCLEX		CHOICE(fclex, wait; fnclex, wait; fclex)
+#define	FNCLEX		CHOICE(fnclex, fnclex, fclex)
+#define	FCOM(a)		CHOICE(fcom a, fcom a, fcom a)
+#define	FCOM_D(a)	CHOICE(fcoml a, fcoml a, fcomd a)
+#define	FCOM_S(a)	CHOICE(fcoms a, fcoms a, fcoms a)
+#define	FCOMP(a)	CHOICE(fcomp a, fcomp a, fcomp a)
+#define	FCOMP_D(a)	CHOICE(fcompl a, fcompl a, fcompd a)
+#define	FCOMP_S(a)	CHOICE(fcomps a, fcomps a, fcomps a)
+#define	FCOMPP		CHOICE(fcompp, fcompp, fcompp)
+#define	FCOS		CHOICE(fcos, fcos, fcos)
+#define	FDECSTP		CHOICE(fdecstp, fdecstp, fdecstp)
+#define	FDIV_D(a)	CHOICE(fdivl a, fdivl a, fdivd a)
+#define	FDIV_S(a)	CHOICE(fdivs a, fdivs a, fdivs a)
+#define	FDIV2(a, b)	CHOICE(fdiv ARG2(a,b), fdiv ARG2(a,b), fdiv ARG2(b,a))
+#define	FDIVP(a, b)	CHOICE(fdivp ARG2(a,b), fdivp ARG2(a,b), fdivp ARG2(b,a))
+#define	FIDIV_L(a)	CHOICE(fidivl a, fidivl a, fidivl a)
+#define	FIDIV_W(a)	CHOICE(fidiv a, fidivs a, fidivs a)
+#define	FDIVR_D(a)	CHOICE(fdivrl a, fdivrl a, fdivrd a)
+#define	FDIVR_S(a)	CHOICE(fdivrs a, fdivrs a, fdivrs a)
+#define	FDIVR2(a, b)	CHOICE(fdivr ARG2(a,b), fdivr ARG2(a,b), fdivr ARG2(b,a))
+#define	FDIVRP(a, b)	CHOICE(fdivrp ARG2(a,b), fdivrp ARG2(a,b), fdivrp ARG2(b,a))
+#define	FIDIVR_L(a)	CHOICE(fidivrl a, fidivrl a, fidivrl a)
+#define	FIDIVR_W(a)	CHOICE(fidivr a, fidivrs a, fidivrs a)
+#define	FFREE(a)	CHOICE(ffree a, ffree a, ffree a)
+#define	FICOM_L(a)	CHOICE(ficoml a, ficoml a, ficoml a)
+#define	FICOM_W(a)	CHOICE(ficom a, ficoms a, ficoms a)
+#define	FICOMP_L(a)	CHOICE(ficompl a, ficompl a, ficompl a)
+#define	FICOMP_W(a)	CHOICE(ficomp a, ficomps a, ficomps a)
+#define	FILD_Q(a)	CHOICE(fildll a, fildq a, fildq a)
+#define	FILD_L(a)	CHOICE(fildl a, fildl a, fildl a)
+#define	FILD_W(a)	CHOICE(fild a, filds a, filds a)
+#define	FINCSTP		CHOICE(fincstp, fincstp, fincstp)
+#define	FINIT		CHOICE(finit, wait; fninit, wait; finit)
+#define	FNINIT		CHOICE(fninit, fninit, finit)
+#define	FIST_L(a)	CHOICE(fistl a, fistl a, fistl a)
+#define	FIST_W(a)	CHOICE(fist a, fists a, fists a)
+#define	FISTP_Q(a)	CHOICE(fistpll a, fistpq a, fistpq a)
+#define	FISTP_L(a)	CHOICE(fistpl a, fistpl a, fistpl a)
+#define	FISTP_W(a)	CHOICE(fistp a, fistps a, fistps a)
+#define	FLD_X(a)	CHOICE(fldt a, fldt a, fldx a) /* 80 bit data type! */
+#define	FLD_D(a)	CHOICE(fldl a, fldl a, fldd a)
+#define	FLD_S(a)	CHOICE(flds a, flds a, flds a)
+#define	FLD1		CHOICE(fld1, fld1, fld1)
+#define	FLDL2T		CHOICE(fldl2t, fldl2t, fldl2t)
+#define	FLDL2E		CHOICE(fldl2e, fldl2e, fldl2e)
+#define	FLDPI		CHOICE(fldpi, fldpi, fldpi)
+#define	FLDLG2		CHOICE(fldlg2, fldlg2, fldlg2)
+#define	FLDLN2		CHOICE(fldln2, fldln2, fldln2)
+#define	FLDZ		CHOICE(fldz, fldz, fldz)
+#define	FLDCW(a)	CHOICE(fldcw a, fldcw a, fldcw a)
+#define	FLDENV(a)	CHOICE(fldenv a, fldenv a, fldenv a)
+#define	FMUL_S(a)	CHOICE(fmuls a, fmuls a, fmuls a)
+#define	FMUL_D(a)	CHOICE(fmull a, fmull a, fmuld a)
+#define	FMUL2(a, b)	CHOICE(fmul ARG2(a,b), fmul ARG2(a,b), fmul ARG2(b,a))
+#define	FMULP(a, b)	CHOICE(fmulp ARG2(a,b), fmulp ARG2(a,b), fmulp ARG2(b,a))
+#define	FIMUL_L(a)	CHOICE(fimull a, fimull a, fimull a)
+#define	FIMUL_W(a)	CHOICE(fimul a, fimuls a, fimuls a)
+#define	FNOP		CHOICE(fnop, fnop, fnop)
+#define	FPATAN		CHOICE(fpatan, fpatan, fpatan)
+#define	FPREM		CHOICE(fprem, fprem, fprem)
+#define	FPREM1		CHOICE(fprem1, fprem1, fprem1)
+#define	FPTAN		CHOICE(fptan, fptan, fptan)
+#define	FRNDINT		CHOICE(frndint, frndint, frndint)
+#define	FRSTOR(a)	CHOICE(frstor a, frstor a, frstor a)
+#define	FSAVE(a)	CHOICE(fsave a, wait; fnsave a, wait; fsave a)
+#define	FNSAVE(a)	CHOICE(fnsave a, fnsave a, fsave a)
+#define	FSCALE		CHOICE(fscale, fscale, fscale)
+#define	FSIN		CHOICE(fsin, fsin, fsin)
+#define	FSINCOS		CHOICE(fsincos, fsincos, fsincos)
+#define	FSQRT		CHOICE(fsqrt, fsqrt, fsqrt)
+#define	FST_D(a)	CHOICE(fstl a, fstl a, fstd a)
+#define	FST_S(a)	CHOICE(fsts a, fsts a, fsts a)
+#define	FSTP_X(a)	CHOICE(fstpt a, fstpt a, fstpx a)
+#define	FSTP_D(a)	CHOICE(fstpl a, fstpl a, fstpd a)
+#define	FSTP_S(a)	CHOICE(fstps a, fstps a, fstps a)
+#define	FSTCW(a)	CHOICE(fstcw a, wait; fnstcw a, wait; fstcw a)
+#define	FNSTCW(a)	CHOICE(fnstcw a, fnstcw a, fstcw a)
+#define	FSTENV(a)	CHOICE(fstenv a, wait; fnstenv a, fstenv a)
+#define	FNSTENV(a)	CHOICE(fnstenv a, fnstenv a, fstenv a)
+#define	FSTSW(a)	CHOICE(fstsw a, wait; fnstsw a, wait; fstsw a)
+#define	FNSTSW(a)	CHOICE(fnstsw a, fnstsw a, fstsw a)
+#define	FSUB_S(a)	CHOICE(fsubs a, fsubs a, fsubs a)
+#define	FSUB_D(a)	CHOICE(fsubl a, fsubl a, fsubd a)
+#define	FSUB2(a, b)	CHOICE(fsub ARG2(a,b), fsub ARG2(a,b), fsub ARG2(b,a))
+#define	FSUBP(a, b)	CHOICE(fsubp ARG2(a,b), fsubp ARG2(a,b), fsubp ARG2(b,a))
+#define	FISUB_L(a)	CHOICE(fisubl a, fisubl a, fisubl a)
+#define	FISUB_W(a)	CHOICE(fisub a, fisubs a, fisubs a)
+#define	FSUBR_S(a)	CHOICE(fsubrs a, fsubrs a, fsubrs a)
+#define	FSUBR_D(a)	CHOICE(fsubrl a, fsubrl a, fsubrd a)
+#define	FSUBR2(a, b)	CHOICE(fsubr ARG2(a,b), fsubr ARG2(a,b), fsubr ARG2(b,a))
+#define	FSUBRP(a, b)	CHOICE(fsubrp ARG2(a,b), fsubrp ARG2(a,b), fsubrp ARG2(b,a))
+#define	FISUBR_L(a)	CHOICE(fisubrl a, fisubrl a, fisubrl a)
+#define	FISUBR_W(a)	CHOICE(fisubr a, fisubrs a, fisubrs a)
+#define	FTST		CHOICE(ftst, ftst, ftst)
+#define	FUCOM(a)	CHOICE(fucom a, fucom a, fucom a)
+#define	FUCOMP(a)	CHOICE(fucomp a, fucomp a, fucomp a)
+#define	FUCOMPP		CHOICE(fucompp, fucompp, fucompp)
+#define	FWAIT		CHOICE(wait, wait, wait)
+#define	FXAM		CHOICE(fxam, fxam, fxam)
+#define	FXCH(a)		CHOICE(fxch a, fxch a, fxch a)
+#define	FXTRACT		CHOICE(fxtract, fxtract, fxtract)
+#define	FYL2X		CHOICE(fyl2x, fyl2x, fyl2x)
+#define	FYL2XP1		CHOICE(fyl2xp1, fyl2xp1, fyl2xp1)
+
+#endif /* __ASSYNTAX_H__ */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/atKeynames.h XFree86.current/xc/programs/Xserver/hw/gsx/common/atKeynames.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/atKeynames.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/atKeynames.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,222 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/atKeynames.h,v 3.9 1996/12/23 06:43:13 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: atKeynames.h /main/11 1996/03/09 11:17:41 kaleb $ */
+
+#ifndef _ATKEYNAMES_H
+#define _ATKEYNAMES_H
+
+#define XK_TECHNICAL
+#define	XK_KATAKANA
+#include "keysym.h"
+
+#define GLYPHS_PER_KEY	4
+#define NUM_KEYCODES	150
+#define NUM_STD_KEYCODES 127
+#define MIN_KEYCODE     8
+#define MAX_KEYCODE     (NUM_KEYCODES + MIN_KEYCODE - 1)
+#define MAX_STD_KEYCODE (NUM_STD_KEYCODES + MIN_KEYCODE - 1)
+
+#define AltMask		Mod1Mask
+#define NumLockMask	Mod2Mask
+#define AltLangMask	Mod3Mask
+#define KanaMask	Mod4Mask
+#define ScrollLockMask	Mod5Mask
+
+#define KeyPressed(k) (keyc->down[k >> 3] & (1 << (k & 7)))
+#define ModifierDown(k) ((keyc->state & (k)) == (k))
+
+#define XF86XK_ModeLock	0x1008FF01                 /* Mode Switch Lock */
+
+/*
+ * NOTE: The AT/MF keyboards can generate (via the 8042) two (MF: three)
+ *       sets of scancodes. Set3 can only be generated by a MF keyboard.
+ *       Set2 sends a makecode for keypress, and the same code prefixed by a
+ *       F0 for keyrelease. This is a little bit ugly to handle. Thus we use
+ *       here for X386 the PC/XT compatible Set1. This set uses 8bit scancodes.
+ *       Bit 7 ist set if the key is released. The code E0 switches to a
+ *       different meaning to add the new MF cursorkeys, while not breaking old
+ *       applications. E1 is another special prefix. Since I assume that there
+ *       will be further versions of PC/XT scancode compatible keyboards, we
+ *       may be in trouble one day.
+ *
+ * IDEA: 1) Use Set2 on AT84 keyboards and translate it to MF Set3.
+ *       2) Use the keyboards native set and translate it to common keysyms.
+ */
+
+/*
+ * definition of the AT84/MF101/MF102 Keyboard:
+ * ============================================================
+ *       Defined             Key Cap Glyphs       Pressed value
+ *      Key Name            Main       Also       (hex)    (dec)
+ *      ----------------   ---------- -------    ------    ------
+ */
+
+#define KEY_Escape       /* Escape                0x01  */    1  
+#define KEY_1            /* 1           !         0x02  */    2 
+#define KEY_2            /* 2           @         0x03  */    3 
+#define KEY_3            /* 3           #         0x04  */    4 
+#define KEY_4            /* 4           $         0x05  */    5 
+#define KEY_5            /* 5           %         0x06  */    6 
+#define KEY_6            /* 6           ^         0x07  */    7 
+#define KEY_7            /* 7           &         0x08  */    8 
+#define KEY_8            /* 8           *         0x09  */    9 
+#define KEY_9            /* 9           (         0x0a  */   10 
+#define KEY_0            /* 0           )         0x0b  */   11 
+#define KEY_Minus        /* - (Minus)   _ (Under) 0x0c  */   12
+#define KEY_Equal        /* = (Equal)   +         0x0d  */   13 
+#define KEY_BackSpace    /* Back Space            0x0e  */   14 
+#define KEY_Tab          /* Tab                   0x0f  */   15
+#define KEY_Q            /* Q                     0x10  */   16
+#define KEY_W            /* W                     0x11  */   17
+#define KEY_E            /* E                     0x12  */   18
+#define KEY_R            /* R                     0x13  */   19
+#define KEY_T            /* T                     0x14  */   20
+#define KEY_Y            /* Y                     0x15  */   21
+#define KEY_U            /* U                     0x16  */   22
+#define KEY_I            /* I                     0x17  */   23
+#define KEY_O            /* O                     0x18  */   24
+#define KEY_P            /* P                     0x19  */   25
+#define KEY_LBrace       /* [           {         0x1a  */   26
+#define KEY_RBrace       /* ]           }         0x1b  */   27 
+#define KEY_Enter        /* Enter                 0x1c  */   28
+#define KEY_LCtrl        /* Ctrl(left)            0x1d  */   29
+#define KEY_A            /* A                     0x1e  */   30
+#define KEY_S            /* S                     0x1f  */   31
+#define KEY_D            /* D                     0x20  */   32 
+#define KEY_F            /* F                     0x21  */   33
+#define KEY_G            /* G                     0x22  */   34
+#define KEY_H            /* H                     0x23  */   35
+#define KEY_J            /* J                     0x24  */   36
+#define KEY_K            /* K                     0x25  */   37
+#define KEY_L            /* L                     0x26  */   38
+#define KEY_SemiColon    /* ;(SemiColon) :(Colon) 0x27  */   39
+#define KEY_Quote        /* ' (Apostr)  " (Quote) 0x28  */   40
+#define KEY_Tilde        /* ` (Accent)  ~ (Tilde) 0x29  */   41
+#define KEY_ShiftL       /* Shift(left)           0x2a  */   42
+#define KEY_BSlash       /* \(BckSlash) |(VertBar)0x2b  */   43
+#define KEY_Z            /* Z                     0x2c  */   44
+#define KEY_X            /* X                     0x2d  */   45
+#define KEY_C            /* C                     0x2e  */   46
+#define KEY_V            /* V                     0x2f  */   47
+#define KEY_B            /* B                     0x30  */   48
+#define KEY_N            /* N                     0x31  */   49
+#define KEY_M            /* M                     0x32  */   50
+#define KEY_Comma        /* , (Comma)   < (Less)  0x33  */   51
+#define KEY_Period       /* . (Period)  >(Greater)0x34  */   52
+#define KEY_Slash        /* / (Slash)   ?         0x35  */   53
+#define KEY_ShiftR       /* Shift(right)          0x36  */   54
+#define KEY_KP_Multiply  /* *                     0x37  */   55
+#define KEY_Alt          /* Alt(left)             0x38  */   56
+#define KEY_Space        /*   (SpaceBar)          0x39  */   57
+#define KEY_CapsLock     /* CapsLock              0x3a  */   58
+#define KEY_F1           /* F1                    0x3b  */   59
+#define KEY_F2           /* F2                    0x3c  */   60
+#define KEY_F3           /* F3                    0x3d  */   61
+#define KEY_F4           /* F4                    0x3e  */   62
+#define KEY_F5           /* F5                    0x3f  */   63
+#define KEY_F6           /* F6                    0x40  */   64
+#define KEY_F7           /* F7                    0x41  */   65
+#define KEY_F8           /* F8                    0x42  */   66
+#define KEY_F9           /* F9                    0x43  */   67
+#define KEY_F10          /* F10                   0x44  */   68
+#define KEY_NumLock      /* NumLock               0x45  */   69
+#define KEY_ScrollLock   /* ScrollLock            0x46  */   70
+#define KEY_KP_7         /* 7           Home      0x47  */   71 
+#define KEY_KP_8         /* 8           Up        0x48  */   72 
+#define KEY_KP_9         /* 9           PgUp      0x49  */   73 
+#define KEY_KP_Minus     /* - (Minus)             0x4a  */   74
+#define KEY_KP_4         /* 4           Left      0x4b  */   75
+#define KEY_KP_5         /* 5                     0x4c  */   76
+#define KEY_KP_6         /* 6           Right     0x4d  */   77
+#define KEY_KP_Plus      /* + (Plus)              0x4e  */   78
+#define KEY_KP_1         /* 1           End       0x4f  */   79
+#define KEY_KP_2         /* 2           Down      0x50  */   80
+#define KEY_KP_3         /* 3           PgDown    0x51  */   81
+#define KEY_KP_0         /* 0           Insert    0x52  */   82
+#define KEY_KP_Decimal   /* . (Decimal) Delete    0x53  */   83 
+#define KEY_SysReqest    /* SysReqest             0x54  */   84
+                         /* NOTUSED               0x55  */
+#define KEY_Less         /* < (Less)   >(Greater) 0x56  */   86
+#define KEY_F11          /* F11                   0x57  */   87
+#define KEY_F12          /* F12                   0x58  */   88
+
+#define KEY_Prefix0      /* special               0x60  */   96
+#define KEY_Prefix1      /* specail               0x61  */   97
+
+/*
+ * The 'scancodes' below are generated by the server, because the MF101/102
+ * keyboard sends them as sequence of other scancodes
+ */
+#define KEY_Home         /* Home                  0x59  */   89
+#define KEY_Up           /* Up                    0x5a  */   90
+#define KEY_PgUp         /* PgUp                  0x5b  */   91
+#define KEY_Left         /* Left                  0x5c  */   92
+#define KEY_Begin        /* Begin                 0x5d  */   93
+#define KEY_Right        /* Right                 0x5e  */   94
+#define KEY_End          /* End                   0x5f  */   95
+#define KEY_Down         /* Down                  0x60  */   96
+#define KEY_PgDown       /* PgDown                0x61  */   97
+#define KEY_Insert       /* Insert                0x62  */   98
+#define KEY_Delete       /* Delete                0x63  */   99
+#define KEY_KP_Enter     /* Enter                 0x64  */  100
+#define KEY_RCtrl        /* Ctrl(right)           0x65  */  101
+#define KEY_Pause        /* Pause                 0x66  */  102
+#define KEY_Print        /* Print                 0x67  */  103
+#define KEY_KP_Divide    /* Didive                0x68  */  104
+#define KEY_AltLang      /* AtlLang(right)        0x69  */  105
+#define KEY_Break        /* Break                 0x6a  */  106
+#define KEY_LMeta        /* Left Meta             0x6b  */  107
+#define KEY_RMeta        /* Right Meta            0x6c  */  108
+#define KEY_Menu         /* Menu                  0x6d  */  109
+#define KEY_F13          /* F13                   0x6e  */  110
+#define KEY_F14          /* F14                   0x6f  */  111
+#define KEY_F15          /* F15                   0x70  */  112
+#define KEY_F16          /* F16                   0x71  */  113
+#define KEY_F17          /* F17                   0x72  */  114
+#define KEY_KP_DEC       /* KP_DEC                0x73  */  115
+#define KEY_SN_KP_7      /* ServerNumLock 7       0x80  */  128
+#define KEY_SN_KP_8      /* ServerNumLock 8       0x81  */  129
+#define KEY_SN_KP_9      /* ServerNumLock 9       0x82  */  130
+#define KEY_SN_KP_4      /* ServerNumLock 4       0x83  */  131
+#define KEY_SN_KP_5      /* ServerNumLock 5       0x84  */  132
+#define KEY_SN_KP_6      /* ServerNumLock 6       0x85  */  133
+#define KEY_SN_KP_1      /* ServerNumLock 1       0x86  */  134
+#define KEY_SN_KP_2      /* ServerNumLock 2       0x87  */  135
+#define KEY_SN_KP_3      /* ServerNumLock 4       0x88  */  136
+#define KEY_SN_KP_0      /* ServerNumLock 0       0x89  */  137
+#define KEY_SN_KP_Dec    /* ServerNumLock Decimal 0x8a  */  138
+#define KEY_SN_KP_Home   /* ServerNumLock Home    0x8b  */  139
+#define KEY_SN_KP_Up     /* ServerNumLock Up      0x8c  */  140
+#define KEY_SN_KP_Prior  /* ServerNumLock Prior   0x8d  */  141
+#define KEY_SN_KP_Left   /* ServerNumLock Left    0x8e  */  142
+#define KEY_SN_KP_Begin  /* ServerNumLock Begin   0x8f  */  143
+#define KEY_SN_KP_Right  /* ServerNumLock Right   0x90  */  144
+#define KEY_SN_KP_End    /* ServerNumLock End     0x91  */  145
+#define KEY_SN_KP_Down   /* ServerNumLock Down    0x92  */  146
+#define KEY_SN_KP_Next   /* ServerNumLock Next    0x93  */  147
+#define KEY_SN_KP_Ins    /* ServerNumLock Ins     0x94  */  148
+#define KEY_SN_KP_Del    /* ServerNumLock Del     0x95  */  149
+
+
+#endif /* _ATKEYNAMES_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/coKeynames.h XFree86.current/xc/programs/Xserver/hw/gsx/common/coKeynames.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/coKeynames.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/coKeynames.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,172 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/coKeynames.h,v 3.3 1996/12/23 06:43:16 dawes Exp $ */
+/*
+ * This file is derived from "atKeynames.h"
+ * Written by Holger Veit (veit@du9ds3.uni-duisburg.de)
+ * Modified to provide a translation table between codrv's scancodes, and
+ * the keycodes defined in "atKeynames.h" (David Dawes)
+ */
+/* $XConsortium: coKeynames.h /main/5 1996/02/21 17:37:43 kaleb $ */
+
+#ifndef _COKEYNAMES_H
+#define _COKEYNAMES_H
+
+/*
+ * See also note in atKeynames.h
+ * This file is an experiment to standardize the three different sets of
+ * keycodes. Set1 is known to be nice, but only for AT/84 keyboards, because
+ * it delivers single byte sequences, with bit 7 set for release and reset
+ * for press. Unfortunately, the 101/102 keyboard requires an E0/E1 prefix
+ * for the additional keys. Set2 is a hack in a similiar way, but the 
+ * release code can be recognized by the byte F0 (in most cases ;-) ). 
+ * The length of a press or release sequence differs between 1 and 4 bytes,
+ * which is bad. Set3 comes close to the best solution, but is not available 
+ * with AT/84 keyboards.
+ * The optimum would be a single byte code for press and release, which is 
+ * possible for keyboards with <= 127 keys (leave one idle code).
+ * So I try out this idea: Leave the whole keyboard processing to the
+ * *NIX kernel. The kernel delivers an IBM keynumber, which has nothing to do
+ * with any scan code, but is a unique ID of a key. The IBM numbering scheme
+ * has not changed over the different keyboards, however, some keyboards
+ * have additional national keys with a unique ID.
+ *
+ * For the 386bsd CO driver the following does only hold: There is a key
+ * overloading feature, which allows mapping of national characters to
+ * the keyboard. We want to have this feature propagated into the Xserver.
+ * So the following mapping is the default mapping only. 
+ * The XF86Keyboard code uses a special keycap database to get the real 
+ * mapping (This could have been done by patching xmodmap as well).
+ */
+
+/*
+ * -hv- Warning: This table has a totally different coding from
+ * atKeynames.h, but uses the same names
+ * I didn't want to rewrite the whole xf86 for this :=)
+ *
+ * definition of the AT84/MF101/MF102 Keyboard:
+ * ============================================================
+ * Defined             Key Cap Glyphs       Pressed value
+ * Key Name            Main       Also       (hex)    (dec)
+ * ----------------   ---------- -------    ------    ------
+ */
+
+unsigned char xf86CodrvMap[128] = {
+ 0,
+ KEY_Tilde,       /* ` (Accent)  ~ (Tilde) 0x01      1 */
+ KEY_1,           /* 1           !         0x02      2 */
+ KEY_2,           /* 2           @         0x03      3 */
+ KEY_3,           /* 3           #         0x04      4 */
+ KEY_4,           /* 4           $         0x05      5 */
+ KEY_5,           /* 5           %         0x06      6 */
+ KEY_6,           /* 6           ^         0x07      7 */
+ KEY_7,           /* 7           &         0x08      8 */
+ KEY_8,           /* 8           *         0x09      9 */
+ KEY_9,           /* 9           (         0x0a     10 */
+ KEY_0,           /* 0           )         0x0b     11 */
+ KEY_Minus,       /* - (Minus)   _ (Under) 0x0c     12 */
+ KEY_Equal,       /* = (Equal)   +         0x0d     13 */
+ 0,
+ KEY_BackSpace,   /* Back Space            0x0f     15 */
+ KEY_Tab,         /* Tab                   0x10     16 */
+ KEY_Q,           /* Q                     0x11     17 */
+ KEY_W,           /* W                     0x12     18 */
+ KEY_E,           /* E                     0x13     19 */
+ KEY_R,           /* R                     0x14     20 */
+ KEY_T,           /* T                     0x15     21 */
+ KEY_Y,           /* Y                     0x16     22 */
+ KEY_U,           /* U                     0x17     23 */
+ KEY_I,           /* I                     0x18     24 */
+ KEY_O,           /* O                     0x19     25 */
+ KEY_P,           /* P                     0x1a     26 */
+ KEY_LBrace,      /* [           {         0x1b     27 */
+ KEY_RBrace,      /* ]           }         0x1c     28 */
+ KEY_BSlash,      /* \(BckSlash) |(VertBar)0x1d     29 */
+ KEY_CapsLock,    /* CapsLock              0x1e     30 */
+ KEY_A,           /* A                     0x1f     31 */
+ KEY_S,           /* S                     0x20     32 */
+ KEY_D,           /* D                     0x21     33 */
+ KEY_F,           /* F                     0x22     34 */
+ KEY_G,           /* G                     0x23     35 */
+ KEY_H,           /* H                     0x24     36 */
+ KEY_J,           /* J                     0x25     37 */
+ KEY_K,           /* K                     0x26     38 */
+ KEY_L,           /* L                     0x27     39 */
+ KEY_SemiColon,   /* ;(SemiColon) :(Colon) 0x28     40 */
+ KEY_Quote,       /* ' (Apostr)  " (Quote) 0x29     41 */
+ 0,
+ KEY_Enter,       /* Enter                 0x2b     43 */
+ KEY_ShiftL,      /* Shift(left)           0x2c     44 */
+ 0,
+ KEY_Z,           /* Z                     0x2e     46 */
+ KEY_X,           /* X                     0x2f     47 */
+ KEY_C,           /* C                     0x30     48 */
+ KEY_V,           /* V                     0x31     49 */
+ KEY_B,           /* B                     0x32     50 */
+ KEY_N,           /* N                     0x33     51 */
+ KEY_M,           /* M                     0x34     52 */
+ KEY_Comma,       /* , (Comma)   < (Less)  0x35     53 */
+ KEY_Period,      /* . (Period)  >(Greater)0x36     54 */
+ KEY_Slash,       /* / (Slash)   ?         0x37     55 */
+ 0,
+ KEY_ShiftR,      /* Shift(right)          0x39     57 */
+ KEY_LCtrl,       /* Ctrl(left)            0x3a     58 */
+ 0,
+ KEY_Alt,         /* Alt(left)             0x3c     60 */
+ KEY_Space,       /*   (SpaceBar)          0x3d     61 */
+ KEY_AltLang,     /* AltLang(right)        0x3e     62 */
+ 0,
+ KEY_RCtrl,       /* Ctrl(right)           0x40     64 */
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ KEY_Insert,      /* Insert                0x4b     75 */
+ KEY_Delete,      /* Delete                0x4c     76 */
+ 0, 0,
+ KEY_Left,        /* Left                  0x4f     79 */
+ KEY_Home,        /* Home                  0x50     80 */
+ KEY_End,         /* End                   0x51     81 */
+ 0,
+ KEY_Up,          /* Up                    0x53     83 */
+ KEY_Down,        /* Down                  0x54     84 */
+ KEY_PgUp,        /* PgUp                  0x55     85 */
+ KEY_PgDown,      /* PgDown                0x56     86 */
+ 0, 0,
+ KEY_Right,       /* Right                 0x59     89 */
+ KEY_NumLock,     /* NumLock               0x5a     90 */
+ KEY_KP_7,        /* 7           Home      0x5b     91 */
+ KEY_KP_4,        /* 4           Left      0x5c     92 */
+ KEY_KP_1,        /* 1           End       0x5d     93 */
+ 0,
+ KEY_KP_Divide,   /* Divide                0x5f     95 */
+ KEY_KP_8,        /* 8           Up        0x60     96 */
+ KEY_KP_5,        /* 5                     0x61     97 */
+ KEY_KP_2,        /* 2           Down      0x62     98 */
+ KEY_KP_0,        /* 0           Insert    0x63     99 */
+ KEY_KP_Multiply, /* *                     0x64    100 */
+ KEY_KP_9,        /* 9           PgUp      0x65    101 */
+ KEY_KP_6,        /* 6           Right     0x66    102 */
+ KEY_KP_3,        /* 3           PgDown    0x67    103 */
+ KEY_KP_Decimal,  /* . (Decimal) Delete    0x68    104 */
+ KEY_KP_Minus,    /* - (Minus)             0x69    105 */
+ KEY_KP_Plus,     /* + (Plus)              0x6a    106 */
+ 0,
+ KEY_KP_Enter,    /* Enter                 0x6b    108 */
+ 0,
+ KEY_Escape,      /* Escape                0x6d    110 */
+ 0,
+ KEY_F1,          /* F1                    0x6e    112 */
+ KEY_F2,          /* F2                    0x6f    113 */
+ KEY_F3,          /* F3                    0x70    114 */
+ KEY_F4,          /* F4                    0x71    115 */
+ KEY_F5,          /* F5                    0x72    116 */
+ KEY_F6,          /* F6                    0x73    117 */
+ KEY_F7,          /* F7                    0x74    118 */
+ KEY_F8,          /* F8                    0x75    119 */
+ KEY_F9,          /* F9                    0x76    120 */
+ KEY_F10,         /* F10                   0x77    121 */
+ KEY_F11,         /* F11                   0x78    122 */
+ KEY_F12,         /* F12                   0x79    123 */
+ KEY_Print,       /* Print                 0x7a    124 */
+ KEY_ScrollLock,  /* ScrollLock            0x7b    125 */
+ KEY_SysReqest,   /* SysReqest             0x7c    126 */
+ 0
+};
+
+#endif /* _COKEYNAMES_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/compiler.h XFree86.current/xc/programs/Xserver/hw/gsx/common/compiler.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/compiler.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/compiler.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,1471 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/compiler.h,v 3.24.2.4 1998/10/18 20:42:10 hohndel Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: compiler.h /main/16 1996/10/25 15:38:34 kaleb $ */
+
+#ifndef _COMPILER_H
+#define _COMPILER_H
+
+#ifndef __STDC__
+# ifdef signed
+#  undef signed
+# endif
+# ifdef volatile
+#  undef volatile
+# endif
+# ifdef const
+#  undef const
+# endif
+# define signed /**/
+# ifdef __GNUC__
+#  define volatile __volatile__
+#  define const __const__
+#  ifdef PC98
+#   undef NO_INLINE
+#  endif
+# else
+#  define const /**/
+#  ifdef PC98
+#   define __inline__ /**/
+#  endif
+# endif /* __GNUC__ */
+#endif /* !__STDC__ */
+
+#if defined(IODEBUG) && defined(__GNUC__)
+#define outb RealOutb
+#define outw RealOutw
+#define outl RealOutl
+#define inb RealInb
+#define inw RealInw
+#define inl RealInl
+#endif
+
+#ifdef NO_INLINE
+
+extern void outb();
+extern void outw();
+extern void outl();
+extern unsigned int inb();
+extern unsigned int inw();
+extern unsigned int inl();
+#if NeedFunctionPrototypes
+extern unsigned char rdinx(unsigned short int, unsigned char);
+extern void wrinx(unsigned short int, unsigned char, unsigned char);
+extern void modinx(unsigned short int, unsigned char, unsigned char, unsigned char);
+extern int testrg(unsigned short int, unsigned char);
+extern int testinx2(unsigned short int, unsigned char, unsigned char);
+extern int testinx(unsigned short int, unsigned char);
+#else /* NeedFunctionProtoypes */
+extern unsigned char rdinx();
+extern void wrinx();
+extern void modinx();
+extern int testrg();
+extern int testinx2();
+extern int testinx();
+#endif /* NeedFunctionProtoypes */
+
+#else /* NO_INLINE */
+
+#ifdef __GNUC__
+
+#if defined(__alpha__)
+# if defined(linux)
+/* for Linux on Alpha, we use the LIBC _inx/_outx routines */
+/* note that the appropriate setup via "ioperm" needs to be done */
+/*  *before* any inx/outx is done. */
+
+static __inline__ void
+outb(port, val)
+     unsigned short port;
+     char val;
+{
+    extern void _outb(char val, unsigned short port);
+    _outb(val, port);
+}
+
+static __inline__ void
+outw(port, val)
+     unsigned short port;
+     short val;
+{
+    extern void _outw(short val, unsigned short port);
+    _outw(val, port);
+}
+
+static __inline__ void
+outl(port, val)
+     unsigned short port;
+     int val;
+{
+    extern void _outl(int val, unsigned short port);
+    _outl(val, port);
+}
+
+static __inline__ unsigned int
+inb(port)
+     unsigned short port;
+{
+  extern unsigned int _inb(unsigned short port);
+  return _inb(port);
+}
+
+static __inline__ unsigned int
+inw(port)
+     unsigned short port;
+{
+  extern unsigned int _inw(unsigned short port);
+  return _inw(port);
+}
+
+static __inline__ unsigned int
+inl(port)
+     unsigned short port;
+{
+  extern unsigned int _inl(unsigned short port);
+  return _inl(port);
+}
+
+# else /* defined(linux) */
+
+#define outb(a, b)             /* NOP */
+#define outw(a, b)             /* NOP */
+#define outl(a, b)             /* NOP */
+#define inb(a)         0       /* NOP */
+#define inw(a)         0       /* NOP */
+#define inl(a)         0       /* NOP */
+
+# endif 
+
+/*
+ * inline functions to do unaligned accesses
+ * from linux/include/asm-alpha/unaligned.h
+ */
+
+static __inline__ unsigned long ldq_u(unsigned long * r11)
+{
+	unsigned long r1,r2;
+	__asm__("ldq_u %0,%3\n\t"
+		"ldq_u %1,%4\n\t"
+		"extql %0,%2,%0\n\t"
+		"extqh %1,%2,%1\n\t"
+		"bis %1,%0,%0"
+		:"=&r" (r1), "=&r" (r2)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(7+(char *) r11)));
+	return r1;
+}
+
+static __inline__ unsigned long ldl_u(unsigned int * r11)
+{
+	unsigned long r1,r2;
+	__asm__("ldq_u %0,%3\n\t"
+		"ldq_u %1,%4\n\t"
+		"extll %0,%2,%0\n\t"
+		"extlh %1,%2,%1\n\t"
+		"bis %1,%0,%0"
+		:"=&r" (r1), "=&r" (r2)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(3+(char *) r11)));
+	return r1;
+}
+
+static __inline__ unsigned long ldw_u(unsigned short * r11)
+{
+	unsigned long r1,r2;
+	__asm__("ldq_u %0,%3\n\t"
+		"ldq_u %1,%4\n\t"
+		"extwl %0,%2,%0\n\t"
+		"extwh %1,%2,%1\n\t"
+		"bis %1,%0,%0"
+		:"=&r" (r1), "=&r" (r2)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(1+(char *) r11)));
+	return r1;
+}
+
+static __inline__ void stq_u(unsigned long r5, unsigned long * r11)
+{
+	unsigned long r1,r2,r3,r4;
+
+	__asm__("ldq_u %3,%1\n\t"
+		"ldq_u %2,%0\n\t"
+		"insqh %6,%7,%5\n\t"
+		"insql %6,%7,%4\n\t"
+		"mskqh %3,%7,%3\n\t"
+		"mskql %2,%7,%2\n\t"
+		"bis %3,%5,%3\n\t"
+		"bis %2,%4,%2\n\t"
+		"stq_u %3,%1\n\t"
+		"stq_u %2,%0"
+		:"=m" (*r11),
+		 "=m" (*(unsigned long *)(7+(char *) r11)),
+		 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
+		:"r" (r5), "r" (r11));
+}
+
+static __inline__ void stl_u(unsigned long r5, unsigned int * r11)
+{
+	unsigned long r1,r2,r3,r4;
+
+	__asm__("ldq_u %3,%1\n\t"
+		"ldq_u %2,%0\n\t"
+		"inslh %6,%7,%5\n\t"
+		"insll %6,%7,%4\n\t"
+		"msklh %3,%7,%3\n\t"
+		"mskll %2,%7,%2\n\t"
+		"bis %3,%5,%3\n\t"
+		"bis %2,%4,%2\n\t"
+		"stq_u %3,%1\n\t"
+		"stq_u %2,%0"
+		:"=m" (*r11),
+		 "=m" (*(unsigned long *)(3+(char *) r11)),
+		 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
+		:"r" (r5), "r" (r11));
+}
+
+static __inline__ void stw_u(unsigned long r5, unsigned short * r11)
+{
+	unsigned long r1,r2,r3,r4;
+
+	__asm__("ldq_u %3,%1\n\t"
+		"ldq_u %2,%0\n\t"
+		"inswh %6,%7,%5\n\t"
+		"inswl %6,%7,%4\n\t"
+		"mskwh %3,%7,%3\n\t"
+		"mskwl %2,%7,%2\n\t"
+		"bis %3,%5,%3\n\t"
+		"bis %2,%4,%2\n\t"
+		"stq_u %3,%1\n\t"
+		"stq_u %2,%0"
+		:"=m" (*r11),
+		 "=m" (*(unsigned long *)(1+(char *) r11)),
+		 "=&r" (r1), "=&r" (r2), "=&r" (r3), "=&r" (r4)
+		:"r" (r5), "r" (r11));
+}
+
+#define mem_barrier()        __asm__ __volatile__("mb"  : : : "memory")
+#ifdef __ELF__
+#define write_mem_barrier()  __asm__ __volatile__("wmb" : : : "memory")
+#else  /*  ECOFF gas 2.6 doesn't know "wmb" :-(  */
+#define write_mem_barrier()  mem_barrier()
+#endif
+
+#else /* defined(__alpha__) */
+#if defined(__mips__)
+
+unsigned int IOPortBase;  /* Memory mapped I/O port area */
+
+static __inline__ void
+outb(port, val)
+     short port;
+     char val;
+{
+	*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outw(port, val)
+     short port;
+     short val;
+{
+	*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase) = val;
+}
+
+static __inline__ void
+outl(port, val)
+     short port;
+     int val;
+{
+	*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase) = val;
+}
+
+static __inline__ unsigned int
+inb(port)
+     short port;
+{
+	return(*(volatile unsigned char*)(((unsigned short)(port))+IOPortBase));
+}
+
+static __inline__ unsigned int
+inw(port)
+     short port;
+{
+	return(*(volatile unsigned short*)(((unsigned short)(port))+IOPortBase));
+}
+
+static __inline__ unsigned int
+inl(port)
+     short port;
+{
+	return(*(volatile unsigned long*)(((unsigned short)(port))+IOPortBase));
+}
+
+
+static __inline__ unsigned long ldq_u(unsigned long * r11)
+{
+	unsigned long r1;
+	__asm__("lwr %0,%2\n\t"
+		"lwl %0,%3\n\t"
+		:"=&r" (r1)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(3+(char *) r11)));
+	return r1;
+}
+
+static __inline__ unsigned long ldl_u(unsigned int * r11)
+{
+	unsigned long r1;
+	__asm__("lwr %0,%2\n\t"
+		"lwl %0,%3\n\t"
+		:"=&r" (r1)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(3+(char *) r11)));
+	return r1;
+}
+
+static __inline__ unsigned long ldw_u(unsigned short * r11)
+{
+	unsigned long r1;
+	__asm__("lwr %0,%2\n\t"
+		"lwl %0,%3\n\t"
+		:"=&r" (r1)
+		:"r" (r11),
+		 "m" (*r11),
+		 "m" (*(unsigned long *)(1+(char *) r11)));
+	return r1;
+}
+
+#define stq_u(v,p)	stl_u(v,p)
+#define stl_u(v,p)	((unsigned char *)(p)) = (v); \
+			((unsigned char *)(p)+1) = ((v) >> 8);  \
+			((unsigned char *)(p)+2) = ((v) >> 16); \
+			((unsigned char *)(p)+3) = ((v) >> 24)
+
+#define stw_u(v,p)	((unsigned char *)(p)) = (v); \
+			((unsigned char *)(p)+1) = ((v) >> 8)
+
+#define mem_barrier()   /* NOP */
+
+#else /* defined(mips) */
+
+#define ldq_u(p)	(*((unsigned long  *)(p)))
+#define ldl_u(p)	(*((unsigned int   *)(p)))
+#define ldw_u(p)	(*((unsigned short *)(p)))
+#define stq_u(v,p)	((unsigned long  *)(p)) = (v)
+#define stl_u(v,p)	((unsigned int   *)(p)) = (v)
+#define stw_u(v,p)	((unsigned short *)(p)) = (v)
+#define mem_barrier()   /* NOP */
+#define write_mem_barrier()   /* NOP */
+
+#if !defined(FAKEIT) && !defined(__mc68000__) && !defined(__powerpc__)
+#ifdef GCCUSESGAS
+
+/*
+ * If gcc uses gas rather than the native assembler, the syntax of these
+ * inlines has to be different.		DHD
+ */
+#ifndef PC98
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outb(
+unsigned short int port,
+unsigned char val)
+#else
+outb(port, val)
+unsigned short int port;
+unsigned char val;
+#endif /* NeedFunctionPrototypes */
+{
+   __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outw(
+unsigned short int port,
+unsigned short int val)
+#else
+outw(port, val)
+unsigned short int port;
+unsigned short int val;
+#endif /* NeedFunctionPrototypes */
+{
+   __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outl(
+unsigned short int port,
+unsigned int val)
+#else
+outl(port, val)
+unsigned short int port;
+unsigned int val;
+#endif /* NeedFunctionPrototypes */
+{
+   __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inb(
+unsigned short int port)
+#else
+inb(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+   unsigned char ret;
+   __asm__ __volatile__("inb %1,%0" :
+       "=a" (ret) :
+       "d" (port));
+   return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inw(
+unsigned short int port)
+#else
+inw(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+   unsigned short int ret;
+   __asm__ __volatile__("inw %1,%0" :
+       "=a" (ret) :
+       "d" (port));
+   return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inl(
+unsigned short int port)
+#else
+inl(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+   unsigned int ret;
+   __asm__ __volatile__("inl %1,%0" :
+       "=a" (ret) :
+       "d" (port));
+   return ret;
+}
+
+#else /* PC98 */
+
+static __inline__ void
+#if NeedFunctionPrototypes
+_outb(
+unsigned short int port,
+unsigned char val)
+#else
+_outb(port, val)
+unsigned short int port;
+unsigned char val;
+#endif /* NeedFunctionPrototypes */
+{
+     __asm__ __volatile__("outb %0,%1" ::"a" (val), "d" (port));
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+_outw(
+unsigned short int port,
+unsigned short int val)
+#else
+_outw(port, val)
+unsigned short int port;
+unsigned short int val;
+#endif /* NeedFunctionPrototypes */
+{
+     __asm__ __volatile__("outw %0,%1" ::"a" (val), "d" (port));
+}
+ 
+static __inline__ void
+#if NeedFunctionPrototypes
+_outl(
+unsigned short int port,
+unsigned int val)
+#else
+_outl(port, val)
+unsigned short int port;
+unsigned int val;
+#endif /* NeedFunctionPrototypes */
+{
+   __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+}
+
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+_inb(
+unsigned short int port)
+#else
+_inb(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+     unsigned char ret;
+     __asm__ __volatile__("inb %1,%0" :
+                          "=a" (ret) :
+                          "d" (port));
+     return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+_inw(
+unsigned short int port)
+#else
+_inw(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+     unsigned short ret;
+     __asm__ __volatile__("inw %1,%0" :
+                          "=a" (ret) :
+                          "d" (port));
+     return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+_inl(
+unsigned short int port)
+#else
+_inl(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+   unsigned int ret;
+   __asm__ __volatile__("inl %1,%0" :
+       "=a" (ret) :
+       "d" (port));
+   return ret;
+}
+
+
+#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968)
+#define PW_PORT 0x600
+extern short chipID;
+#if NeedFunctionPrototypes
+extern void *mmioBase;
+#else
+extern unsigned char *mmioBase;
+#endif
+extern unsigned short _port_tbl[];
+#define	port_convert(x)	_port_tbl[(unsigned short)x]
+#endif 
+
+#if defined(PC98_WAB) ||  defined(PC98_GANB_WAP)
+static __inline__ unsigned short
+port_convert(unsigned short port)
+{
+     port <<= 8;
+     port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
+     port |= 0xE0;
+     return port;
+}
+#endif /* PC98_WAB || PC98_GANB_WAP */
+ 
+#if defined(PC98_WABEP)
+static __inline__ unsigned short
+port_convert(unsigned short port)
+{
+     port &= 0x7f; /* Mask 0000 0000 0111 1111 */
+     port |= 0x0f00;
+     return port;
+}
+#endif /* PC98_WABEP */
+
+#ifdef PC98_WSNA
+static __inline__ unsigned short
+port_convert(unsigned short port)
+{
+     port <<= 8;
+     port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
+     port |= 0xE2;
+     return port;
+}
+#endif /* PC98_WSNA */
+
+#ifdef PC98_NKVNEC
+#ifdef	PC98_NEC_CIRRUS2
+static __inline__ unsigned short
+port_convert(unsigned short port)
+{
+     port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
+     return port;
+}
+#else
+static __inline__ unsigned short
+port_convert(unsigned short port)
+{
+     port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
+     return port;
+}
+#endif /* PC98_NEC_CIRRUS2 */
+#endif /* PC98_NKVNEC */
+
+#if defined(PC98_TGUI) || defined(PC98_MGA)
+#if NeedFunctionPrototypes
+extern void *mmioBase;
+#else
+extern unsigned char *mmioBase;
+#endif
+#endif
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outb(
+unsigned short port,
+unsigned char val)
+#else
+outb(port, val)
+unsigned short port;
+unsigned char val;
+#endif /* NeedFunctionPrototypes */
+{
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
+#else
+   __asm__ __volatile__("outb %0,%1" : :"a" (val), "d" (port));
+#endif
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outw(
+unsigned short port,
+unsigned short val)
+#else
+outw(port, val)
+unsigned short port;
+unsigned short val;
+#endif /* NeedFunctionPrototypes */
+{
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
+#else
+   __asm__ __volatile__("outw %0,%1" : :"a" (val), "d" (port));
+#endif
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outl(
+unsigned short port,
+unsigned int val)
+#else
+outl(port, val)
+unsigned short port;
+unsigned int val;
+#endif /* NeedFunctionPrototypes */
+{
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
+#else
+   __asm__ __volatile__("outl %0,%1" : :"a" (val), "d" (port));
+#endif
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inb(
+unsigned short port)
+#else
+inb(port)
+unsigned short port;
+#endif /* NeedFunctionPrototypes */
+{
+   unsigned char ret;
+
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   ret =*(volatile unsigned char *)((char *)mmioBase+(port));
+#else
+   __asm__ __volatile__("inb %1,%0" :
+       "=a" (ret) :
+       "d" (port));
+#endif
+   return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inw(
+unsigned short port)
+#else
+inw(port)
+unsigned short port;
+#endif /* NeedFunctionPrototypes */
+{
+   unsigned short ret;
+
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   ret =*(volatile unsigned short *)((char *)mmioBase+(port));
+#else
+   __asm__ __volatile__("inw %1,%0" :
+       "=a" (ret) :
+       "d" (port));
+#endif
+   return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inl(
+unsigned short port)
+#else
+inl(port)
+unsigned short port;
+#endif /* NeedFunctionPrototypes */
+{
+   unsigned int ret;
+
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   ret =*(volatile unsigned int *)((char *)mmioBase+(port));
+#else
+   __asm__ __volatile__("inl %1,%0" :
+       "=a" (ret) :
+       "d" (port));
+#endif
+   return ret;
+}
+
+#endif /* PC98 */
+
+#else	/* GCCUSESGAS */
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outb(
+unsigned short int port,
+unsigned char val)
+#else
+outb(port, val)
+unsigned short int port;
+unsigned char val;
+#endif /* NeedFunctionPrototypes */
+{
+  __asm__ __volatile__("out%B0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outw(
+unsigned short int port,
+unsigned short int val)
+#else
+outw(port, val)
+unsigned short int port;
+unsigned short int val;
+#endif /* NeedFunctionPrototypes */
+{
+  __asm__ __volatile__("out%W0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outl(
+unsigned short int port,
+unsigned int val)
+#else
+outl(port, val)
+unsigned short int port;
+unsigned int val;
+#endif /* NeedFunctionPrototypes */
+{
+  __asm__ __volatile__("out%L0 (%1)" : :"a" (val), "d" (port));
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inb(
+unsigned short int port)
+#else
+inb(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+  unsigned char ret;
+  __asm__ __volatile__("in%B0 (%1)" :
+		   "=a" (ret) :
+		   "d" (port));
+  return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inw(
+unsigned short int port)
+#else
+inw(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+  unsigned short int ret;
+  __asm__ __volatile__("in%W0 (%1)" :
+		   "=a" (ret) :
+		   "d" (port));
+  return ret;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inl(
+unsigned short int port)
+#else
+inl(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+  unsigned int ret;
+  __asm__ __volatile__("in%L0 (%1)" :
+                   "=a" (ret) :
+                   "d" (port));
+  return ret;
+}
+
+#endif /* GCCUSESGAS */
+
+#else /* !defined(FAKEIT) && !defined(__mc68000__) && !defined(__powerpc__) */
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outb(
+unsigned short int port,
+unsigned char val)
+#else
+outb(port, val)
+unsigned short int port;
+unsigned char val;
+#endif /* NeedFunctionPrototypes */
+{
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outw(
+unsigned short int port,
+unsigned short int val)
+#else
+outw(port, val)
+unsigned short int port;
+unsigned short int val;
+#endif /* NeedFunctionPrototypes */
+{
+}
+
+static __inline__ void
+#if NeedFunctionPrototypes
+outl(
+unsigned short int port,
+unsigned int val)
+#else
+outl(port, val)
+unsigned short int port;
+unsigned int val;
+#endif /* NeedFunctionPrototypes */
+{
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inb(
+unsigned short int port)
+#else
+inb(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+  return 0;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inw(
+unsigned short int port)
+#else
+inw(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+  return 0;
+}
+
+static __inline__ unsigned int
+#if NeedFunctionPrototypes
+inl(
+unsigned short int port)
+#else
+inl(port)
+unsigned short int port;
+#endif /* NeedFunctionPrototypes */
+{
+  return 0;
+}
+
+#endif /* FAKEIT */
+
+#endif /* defined(mips) */
+#endif /* defined(AlphaArchitecture) && defined(LinuxArchitecture) */
+
+#else /* __GNUC__ */
+#if !defined(AMOEBA) && !defined(MINIX)
+# if defined(__STDC__) && (__STDC__ == 1)
+#  ifndef asm
+#   define asm __asm
+#  endif
+# endif
+# ifdef SVR4
+#  include <sys/types.h>
+#  ifndef __HIGHC__
+#   ifndef __USLC__
+#    define __USLC__
+#   endif
+#  endif
+# endif
+# ifndef PC98
+#  ifndef SCO325
+#   include <sys/inline.h>
+#  else
+#   include "scoasm.h"
+#  endif
+# else
+#if defined(PC98_PW) || defined(PC98_XKB) || defined(PC98_NEC) || defined(PC98_PWLB) || defined(PC98_GA968)
+#define PW_PORT 0x600
+extern short chipID;
+#if NeedFunctionPrototypes
+extern void *mmioBase;
+#else
+extern unsigned char *mmioBase;
+#endif
+extern unsigned short _port_tbl[];
+#define	port_convert(x)	_port_tbl[(unsigned short)x]
+#endif 
+
+#if defined(PC98_TGUI) || defined(PC98_MGA)
+#if NeedFunctionPrototypes
+extern void *mmioBase;
+#else
+extern unsigned char *mmioBase;
+#endif
+#endif
+
+asm     void _outl(port,val)
+{
+%reg	port,val;
+	movl	port, %edx
+	movl	val, %eax
+	outl	(%dx)
+%reg	port; mem	val;
+	movl	port, %edx
+	movl    val, %eax
+	outl	(%dx)
+%mem	port; reg	val;
+	movw	port, %dx
+	movl	val, %eax
+	outl	(%dx)
+%mem	port,val;
+	movw	port, %dx
+	movl    val, %eax
+	outl	(%dx)
+}
+
+asm	void _outw(port,val)
+{
+%reg	port,val;
+	movl	port, %edx
+	movl	val, %eax
+	data16
+	outl	(%dx)
+%reg	port; mem	val;
+	movl	port, %edx
+	movw	val, %ax
+	data16
+	outl	(%dx)
+%mem	port; reg	val;
+	movw	port, %dx
+	movl	val, %eax
+	data16
+	outl	(%dx)
+%mem	port,val;
+	movw	port, %dx
+	movw	val, %ax
+	data16
+	outl	(%dx)
+}
+
+asm	void _outb(port,val)
+{
+%reg	port,val;
+	movl	port, %edx
+	movl	val, %eax
+	outb	(%dx)
+%reg	port; mem	val;
+	movl	port, %edx
+	movb	val, %al
+	outb	(%dx)
+%mem	port; reg	val;
+	movw	port, %dx
+	movl	val, %eax
+	outb	(%dx)
+%mem	port,val;
+	movw	port, %dx
+	movb	val, %al
+	outb	(%dx)
+}
+
+asm     int _inl(port)
+{
+%reg	port;
+	movl	port, %edx
+	inl	(%dx)
+%mem	port;
+	movw	port, %dx
+	inl	(%dx)
+}
+
+asm	int _inw(port)
+{
+%reg	port;
+	subl    %eax, %eax
+	movl	port, %edx
+	data16
+	inl	(%dx)
+%mem	port;
+	subl    %eax, %eax
+	movw	port, %dx
+	data16
+	inl	(%dx)
+}
+
+asm	int _inb(port)
+{
+%reg	port;
+	subl    %eax, %eax
+	movl	port, %edx
+	inb	(%dx)
+%mem	port;
+	subl    %eax, %eax
+	movw	port, %dx
+	inb	(%dx)
+}
+
+#if defined(PC98_WAB) ||  defined(PC98_GANB_WAP)
+static unsigned short
+port_convert(unsigned short port)
+{
+     port <<= 8;
+     port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
+     port |= 0xE0;
+     return port;
+}
+#endif /* PC98_WAB || PC98_GANB_WAP */
+
+#if defined(PC98_WABEP)
+static unsigned short
+port_convert(unsigned short port)
+{
+     port &= 0x7f; /* Mask 0000 0000 0111 1111 */
+     port |= 0x0f00;
+     return port;
+}
+#endif /* PC98_WABEP */
+
+#ifdef PC98_WSNA
+static unsigned short
+port_convert(unsigned short port)
+{
+     port <<= 8;
+     port &= 0x7f00; /* Mask 0111 1111 0000 0000 */
+     port |= 0xE2;
+     return port;
+}
+#endif /* PC98_WSNA */
+
+#ifdef PC98_NKVNEC
+#ifdef	PC98_NEC_CIRRUS2
+static unsigned short
+port_convert(unsigned short port)
+{
+     port = (port & 0xf) + ((port & 0xf0) << 4) + 0x0050;
+     return port;
+}
+#else
+static unsigned short
+port_convert(unsigned short port)
+{
+     port = (port & 0xf) + ((port & 0xf0) << 4) + 0x00a0;
+     return port;
+}
+#endif /* PC98_NEC_CIRRUS2 */
+#endif /* PC98_NKVNEC */
+
+static void outl(port,val)
+{
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   *(volatile unsigned int *)((char *)mmioBase+(port)) = (unsigned int)(val);
+#else
+   _outl(port,val);
+#endif
+}
+
+static void outw(port,val)
+{
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   *(volatile unsigned short *)((char *)mmioBase+(port)) = (unsigned short)(val);
+#else
+   _outw(port,val);
+#endif
+}
+
+static void outb(port,val)
+{
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   *(volatile unsigned char *)((char *)mmioBase+(port)) = (unsigned char)(val);
+#else
+   _outb(port,val);
+#endif
+}
+
+static int inl(port)
+{
+   unsigned int ret;
+
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   ret =*(volatile unsigned int *)((char *)mmioBase+(port));
+#else
+   ret = _inl(port);
+#endif
+   return ret;
+}
+
+static int inw(port)
+{
+   unsigned short ret;
+
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   ret =*(volatile unsigned short *)((char *)mmioBase+(port));
+#else
+   ret = _inw(port);
+#endif
+   return ret;
+}
+
+static int inb(port)
+{
+   unsigned char ret;
+
+#if defined(PC98_GANB_WAP) || defined(PC98_NKVNEC) || defined(PC98_WAB) || \
+    defined(PC98_WABEP) || defined(PC98_WSNA) || defined(PC98_PW) || \
+    defined(PC98_XKB) || defined(PC98_NEC)
+   unsigned short tmp;
+   tmp=port_convert(port);
+   port=tmp;
+#endif
+
+#if defined(PC98_NEC)||defined(PC98_PWLB)||defined(PC98_TGUI)||defined(PC98_MGA)
+   ret =*(volatile unsigned char *)((char *)mmioBase+(port));
+#else
+   ret = _inb(port);
+#endif
+   return ret;
+}
+
+
+# endif /* PC98 */
+# if !defined(__HIGHC__) && !defined(SCO325)
+#  pragma asm partial_optimization outl
+#  pragma asm partial_optimization outw
+#  pragma asm partial_optimization outb
+#  pragma asm partial_optimization inl
+#  pragma asm partial_optimization inw
+#  pragma asm partial_optimization inb
+# endif
+#endif
+#define ldq_u(p)	(*((unsigned long  *)(p)))
+#define ldl_u(p)	(*((unsigned int   *)(p)))
+#define ldw_u(p)	(*((unsigned short *)(p)))
+#define stq_u(v,p)	((unsigned long  *)(p)) = (v)
+#define stl_u(v,p)	((unsigned int   *)(p)) = (v)
+#define stw_u(v,p)	((unsigned short *)(p)) = (v)
+#define mem_barrier()   /* NOP */
+#define write_mem_barrier()   /* NOP */
+#endif /* __GNUC__ */
+
+#if defined(IODEBUG) && defined(__GNUC__)
+#undef inb
+#undef inw
+#undef inl
+#undef outb
+#undef outw
+#undef outl
+#define inb(a) __extension__ ({unsigned char __c=RealInb(a); ErrorF("inb(0x%03x) = 0x%02x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+#define inw(a) __extension__ ({unsigned short __c=RealInw(a); ErrorF("inw(0x%03x) = 0x%04x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+#define inl(a) __extension__ ({unsigned long __c=RealInl(a); ErrorF("inl(0x%03x) = 0x%08x\t@ line %4d, file %s\n", a, __c, __LINE__, __FILE__);__c;})
+
+#define outb(a,b) (ErrorF("outb(0x%03x, 0x%02x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutb(a,b))
+#define outw(a,b) (ErrorF("outw(0x%03x, 0x%04x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutw(a,b))
+#define outl(a,b) (ErrorF("outl(0x%03x, 0x%08x)\t@ line %4d, file %s\n", a, b, __LINE__, __FILE__),RealOutl(a,b))
+#endif
+
+/*
+ * This header sometimes gets included where is isn't needed, and on some
+ * OSs this causes problems because the following functions generate
+ * references to inb() and outb() which can't be resolved.  Defining
+ * NO_COMPILER_H_EXTRAS avoids this problem.
+ */
+
+#ifndef NO_COMPILER_H_EXTRAS
+/*
+ *-----------------------------------------------------------------------
+ * Port manipulation convenience functions
+ *-----------------------------------------------------------------------
+ */
+
+#ifndef __GNUC__
+#define __inline__ /**/
+#endif
+
+/*
+ * rdinx - read the indexed byte port 'port', index 'ind', and return its value
+ */
+static __inline__ unsigned char 
+#ifdef __STDC__
+rdinx(unsigned short int port, unsigned char ind)
+#else
+rdinx(port, ind)
+unsigned short int port;
+unsigned char ind;
+#endif
+{
+	if (port == 0x3C0)		/* reset attribute flip-flop */
+		(void) inb(0x3DA);
+	outb(port, ind);
+	return(inb(port+1));
+}
+
+/*
+ * wrinx - write 'val' to port 'port', index 'ind'
+ */
+static __inline__ void 
+#ifdef __STDC__
+wrinx(unsigned short int port, unsigned char ind, unsigned char val)
+#else
+wrinx(port, ind, val)
+unsigned short int port;
+unsigned char ind, val;
+#endif
+{
+	outb(port, ind);
+	outb(port+1, val);
+}
+
+/*
+ * modinx - in register 'port', index 'ind', set the bits in 'mask' as in 'new';
+ *	    the other bits are unchanged.
+ */
+static __inline__ void
+#ifdef __STDC__
+modinx(unsigned short int port, unsigned char ind, 
+       unsigned char mask, unsigned char new)
+#else
+modinx(port, ind, mask, new)
+unsigned short int port;
+unsigned char ind, mask, new;
+#endif
+{
+	unsigned char tmp;
+
+	tmp = (rdinx(port, ind) & ~mask) | (new & mask);
+	wrinx(port, ind, tmp);
+}
+
+/*
+ * tstrg - returns true iff the bits in 'mask' of register 'port' are
+ *	   readable & writable.
+ */
+
+static __inline__ int
+#ifdef __STDC__
+testrg(unsigned short int port, unsigned char mask)
+#else
+tstrg(port, mask)
+unsigned short int port;
+unsigned char mask;
+#endif
+{
+	unsigned char old, new1, new2;
+
+	old = inb(port);
+	outb(port, old & ~mask);
+	new1 = inb(port) & mask;
+	outb(port, old | mask);
+	new2 = inb(port) & mask;
+	outb(port, old);
+	return((new1 == 0) && (new2 == mask));
+}
+
+/*
+ * testinx2 - returns true iff the bits in 'mask' of register 'port', index
+ *	      'ind' are readable & writable.
+ */
+static __inline__ int
+#ifdef __STDC__
+testinx2(unsigned short int port, unsigned char ind, unsigned char mask)
+#else
+testinx2(port, ind, mask)
+unsigned short int port;
+unsigned char ind, mask;
+#endif
+{
+	unsigned char old, new1, new2;
+
+	old = rdinx(port, ind);
+	wrinx(port, ind, old & ~mask);
+	new1 = rdinx(port, ind) & mask;
+	wrinx(port, ind, old | mask);
+	new2 = rdinx(port, ind) & mask;
+	wrinx(port, ind, old);
+	return((new1 == 0) && (new2 == mask));
+}
+
+/*
+ * testinx - returns true iff all bits of register 'port', index 'ind' are 
+ *     	     readable & writable.
+ */
+static __inline__ int
+#ifdef __STDC__
+testinx(unsigned short int port, unsigned char ind)
+#else
+testinx(port, ind, mask)
+unsigned short int port;
+unsigned char ind;
+#endif
+{
+	return(testinx2(port, ind, 0xFF));
+}
+#endif /* NO_COMPILER_H_EXTRAS */
+
+#endif /* NO_INLINE */
+#endif /* _COMPILER_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/lnx_init.c XFree86.current/xc/programs/Xserver/hw/gsx/common/lnx_init.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/lnx_init.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/lnx_init.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,244 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_init.c,v 3.7.2.5 1998/10/18 20:42:24 hohndel Exp $ */
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Wexelblat 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Orest Zborowski
+ * and David Wexelblat make no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD 
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID WEXELBLAT BE LIABLE 
+ * 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.
+ *
+ */
+/* $XConsortium: lnx_init.c /main/7 1996/10/23 18:46:30 kaleb $ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+#ifdef USE_DEV_FB
+extern char *getenv(const char *);
+#include <linux/fb.h>
+char *fb_dev_name = NULL;
+#endif
+
+static Bool KeepTty = FALSE;
+static int VTnum = -1;
+static int activeVT = -1;
+
+extern void xf86VTRequest(
+#if NeedFunctionPrototypes
+	int
+#endif
+);
+
+
+void xf86OpenConsole()
+{
+#ifdef GSXMOUSEON
+    int i, fd;
+    struct vt_mode VT;
+    char vtname[11];
+    struct vt_stat vts;
+#ifdef USE_DEV_FB
+    struct fb_var_screeninfo var;
+    int fbfd;
+#endif
+
+    if (serverGeneration == 1) 
+    {
+	/* check if we're run with euid==0 */
+	if (geteuid() != 0)
+	{
+	    FatalError("xf86OpenConsole: Server must be running with root "
+	        "permissions\n"
+		"You should be using Xwrapper to start the server or xdm.\n"
+		"We strongly advise against making the server SUID root!\n");
+	}
+
+	/*
+	 * setup the virtual terminal manager
+	 */
+	if (VTnum != -1)
+	{
+	    xf86Info.vtno = VTnum;
+	}
+	else 
+	{
+	    if ((fd = open("/dev/tty0",O_WRONLY,0)) < 0) 
+	    {
+		FatalError(
+		    "xf86OpenConsole: Cannot open /dev/tty0 (%s)\n",
+		    strerror(errno));
+	    }
+	    if ((ioctl(fd, VT_OPENQRY, &xf86Info.vtno) < 0) ||
+		(xf86Info.vtno == -1))
+	    {
+		FatalError("xf86OpenConsole: Cannot find a free VT\n");
+	    }
+	    close(fd);
+	}
+
+	ErrorF("(using VT number %d)\n\n", xf86Info.vtno);
+
+	sprintf(vtname,"/dev/tty%d",xf86Info.vtno); /* /dev/tty1-64 */
+
+	xf86Config(FALSE); /* Read XF86Config */
+
+#ifdef USE_DEV_FB
+	if (fb_dev_name) {
+	    if ((fbfd = open(fb_dev_name, O_RDONLY)) < 0) 
+		FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+			    fb_dev_name, strerror(errno));
+	    if (ioctl(fbfd, FBIOGET_VSCREENINFO, &var))
+		FatalError("xf86OpenConsole: Unable to get screen info\n");
+	}
+#endif
+
+	if (!KeepTty)
+	{
+	    setpgrp();
+	}
+
+	if ((xf86Info.consoleFd = open(vtname, O_RDWR|O_NDELAY, 0)) < 0)
+	{
+	    FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+		       vtname, strerror(errno));
+	}
+
+	/* change ownership of the vt */
+	chown(vtname, getuid(), getgid());
+
+	/*
+	 * the current VT device we're running on is not "console", we want
+	 * to grab all consoles too
+	 *
+	 * Why is this needed?
+	 */
+	chown("/dev/tty0", getuid(), getgid());
+
+	/*
+	 * Linux doesn't switch to an active vt after the last close of a vt,
+	 * so we do this ourselves by remembering which is active now.
+	 */
+	if (ioctl(xf86Info.consoleFd, VT_GETSTATE, &vts) == 0)
+	{
+	    activeVT = vts.v_active;
+	}
+
+	if (!KeepTty)
+	{
+	    /*
+	     * Detach from the controlling tty to avoid char loss
+	     */
+	    if ((i = open("/dev/tty",O_RDWR)) >= 0)
+	    {
+		ioctl(i, TIOCNOTTY, 0);
+		close(i);
+	    }
+	}
+
+	/*
+	 * now get the VT
+	 */
+	if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+	{
+	    ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+	}
+	if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+	{
+	    ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
+	}
+	if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) < 0) 
+	{
+	    FatalError ("xf86OpenConsole: VT_GETMODE failed\n");
+	}
+
+	signal(SIGUSR1, xf86VTRequest);
+
+	VT.mode = VT_PROCESS;
+	VT.relsig = SIGUSR1;
+	VT.acqsig = SIGUSR1;
+	if (ioctl(xf86Info.consoleFd, VT_SETMODE, &VT) < 0) 
+	{
+	    FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+	}
+	if (ioctl(xf86Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+	{
+	    FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+	}
+#ifdef USE_DEV_FB
+	if (fb_dev_name) {
+	    /* copy info to new console */
+	    var.yoffset=0;
+	    var.xoffset=0;
+	    if (ioctl(fbfd, FBIOPUT_VSCREENINFO, &var))
+		FatalError("Unable to set screen info\n");
+	    close(fbfd);
+	}
+#endif
+    }
+    else 
+    {
+	/* serverGeneration != 1 */
+	/*
+	 * now get the VT
+	 */
+	if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno) != 0)
+	{
+	    ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+	}
+	if (ioctl(xf86Info.consoleFd, VT_WAITACTIVE, xf86Info.vtno) != 0)
+	{
+	    ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
+	}
+    }
+#endif /* GSXMOUSEON */
+    return;
+}
+
+void xf86CloseConsole()
+{
+    struct vt_mode   VT;
+
+#if 0
+    ioctl(xf86Info.consoleFd, VT_ACTIVATE, xf86Info.vtno);
+    ioctl(xf86Info.consoleFd, VT_WAITACTIVE, 0);
+#endif
+    ioctl(xf86Info.consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode ... */
+    if (ioctl(xf86Info.consoleFd, VT_GETMODE, &VT) != -1)
+    {
+	VT.mode = VT_AUTO;
+	ioctl(xf86Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+    }
+    /*
+     * Perform a switch back to the active VT when we were started
+     */
+    if (activeVT >= 0)
+    {
+	ioctl(xf86Info.consoleFd, VT_ACTIVATE, activeVT);
+	activeVT = -1;
+    }
+    close(xf86Info.consoleFd);                /* make the vt-manager happy */
+    return;
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/lnx_io.c XFree86.current/xc/programs/Xserver/hw/gsx/common/lnx_io.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/lnx_io.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/lnx_io.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,143 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/lnx_io.c,v 3.3.2.1 1998/09/13 12:29:06 hohndel Exp $ */
+/*
+ * Copyright 1992 by Orest Zborowski <obz@Kodak.com>
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Orest Zborowski and David Dawes 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Orest Zborowski
+ * and David Dawes make no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * OREST ZBOROWSKI AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD 
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL OREST ZBOROWSKI OR DAVID DAWES BE LIABLE 
+ * 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.
+ *
+ */
+/* $XConsortium: lnx_io.c /main/8 1996/10/19 18:06:28 kaleb $ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+
+void xf86SoundKbdBell(loudness, pitch, duration)
+int loudness;
+int pitch;
+int duration;
+{
+	if (loudness && pitch)
+	{
+		ioctl(xf86Info.consoleFd, KDMKTONE,
+		      ((1193190 / pitch) & 0xffff) |
+		      (((unsigned long)duration *
+			loudness / 50) << 16));
+	}
+}
+
+void xf86SetKbdLeds(leds)
+int leds;
+{
+	ioctl(xf86Info.consoleFd, KDSETLED, leds);
+}
+
+int xf86GetKbdLeds()
+{
+	int leds;
+
+	ioctl(xf86Info.consoleFd, KDGETLED, &leds);
+	return(leds);
+}
+
+#if NeedFunctionPrototypes
+void xf86SetKbdRepeat(char rad)
+#else
+void xf86SetKbdRepeat(rad)
+char rad;
+#endif
+{
+	return;
+}
+
+static int kbdtrans;
+static struct termios kbdtty;
+
+void xf86KbdInit()
+{
+	ioctl (xf86Info.consoleFd, KDGKBMODE, &kbdtrans);
+	tcgetattr (xf86Info.consoleFd, &kbdtty);
+}
+
+int xf86KbdOn()
+{
+	struct termios nTty;
+
+#if USE_MEDIUMRAW_KBD
+	ioctl(xf86Info.consoleFd, KDSKBMODE, K_MEDIUMRAW);
+#else
+	ioctl(xf86Info.consoleFd, KDSKBMODE, K_RAW);
+#endif
+	nTty = kbdtty;
+	nTty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+	nTty.c_oflag = 0;
+	nTty.c_cflag = CREAD | CS8;
+	nTty.c_lflag = 0;
+	nTty.c_cc[VTIME]=0;
+	nTty.c_cc[VMIN]=1;
+	cfsetispeed(&nTty, 9600);
+	cfsetospeed(&nTty, 9600);
+	tcsetattr(xf86Info.consoleFd, TCSANOW, &nTty);
+	return(xf86Info.consoleFd);
+}
+
+int xf86KbdOff()
+{
+	ioctl(xf86Info.consoleFd, KDSKBMODE, kbdtrans);
+	tcsetattr(xf86Info.consoleFd, TCSANOW, &kbdtty);
+	return(xf86Info.consoleFd);
+}
+
+void xf86MouseInit(mouse)
+MouseDevPtr mouse;
+{
+	return;
+}
+
+int xf86MouseOn(mouse)
+MouseDevPtr mouse;
+{
+#ifdef GSXMOUSEON
+	if ((mouse->mseFd = open(mouse->mseDevice, O_RDWR | O_NDELAY)) < 0)
+	{
+		if (xf86AllowMouseOpenFail) {
+			ErrorF("Cannot open mouse (%s) - Continuing...\n",
+				strerror(errno));
+			return(-2);
+		}
+		FatalError("Cannot open mouse (%s) %s\n", strerror(errno), mouse->mseDevice);
+	}
+
+	xf86SetupMouse(mouse);
+
+	/* Flush any pending input */
+	tcflush(mouse->mseFd, TCIFLUSH);
+
+#endif
+	return(mouse->mseFd);
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/posix_tty.c XFree86.current/xc/programs/Xserver/hw/gsx/common/posix_tty.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/posix_tty.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/posix_tty.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,174 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/posix_tty.c,v 3.8.2.1 1998/02/07 14:27:25 dawes Exp $ */
+/*
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Dawes 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.
+ * David Dawes makes no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL DAVID DAWES BE LIABLE 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.
+ *
+ */
+/* $XConsortium: posix_tty.c /main/7 1996/10/19 18:07:47 kaleb $ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86_Config.h"
+
+static Bool not_a_tty = FALSE;
+
+void xf86SetMouseSpeed(mouse, old, new, cflag)
+MouseDevPtr mouse;
+int old;
+int new;
+unsigned cflag;
+{
+	struct termios tty;
+	char *c;
+
+	if (not_a_tty)
+		return;
+
+	if (tcgetattr(mouse->mseFd, &tty) < 0)
+	{
+		not_a_tty = TRUE;
+		ErrorF("Warning: %s unable to get status of mouse fd (%s)\n",
+		       mouse->mseDevice, strerror(errno));
+		return;
+	}
+
+	/* this will query the initial baudrate only once */
+	if (mouse->oldBaudRate < 0) { 
+	   switch (cfgetispeed(&tty)) 
+	      {
+	      case B9600: 
+		 mouse->oldBaudRate = 9600;
+		 break;
+	      case B4800: 
+		 mouse->oldBaudRate = 4800;
+		 break;
+	      case B2400: 
+		 mouse->oldBaudRate = 2400;
+		 break;
+	      case B1200: 
+	      default:
+		 mouse->oldBaudRate = 1200;
+		 break;
+	      }
+	}
+
+	tty.c_iflag = IGNBRK | IGNPAR;
+	tty.c_oflag = 0;
+	tty.c_lflag = 0;
+	tty.c_cflag = (tcflag_t)cflag;
+	tty.c_cc[VTIME] = 0;
+	tty.c_cc[VMIN] = 1;
+
+	switch (old)
+	{
+	case 9600:
+		cfsetispeed(&tty, B9600);
+		cfsetospeed(&tty, B9600);
+		break;
+	case 4800:
+		cfsetispeed(&tty, B4800);
+		cfsetospeed(&tty, B4800);
+		break;
+	case 2400:
+		cfsetispeed(&tty, B2400);
+		cfsetospeed(&tty, B2400);
+		break;
+	case 1200:
+	default:
+		cfsetispeed(&tty, B1200);
+		cfsetospeed(&tty, B1200);
+	}
+
+	if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
+	{
+		if (xf86AllowMouseOpenFail) {
+			ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
+			       strerror(errno));
+			return;
+		}
+		xf86FatalError("Unable to set status of mouse fd (%s)\n",
+			       strerror(errno));
+	}
+
+	switch (new)
+	{
+	case 9600:
+		c = "*q";
+		cfsetispeed(&tty, B9600);
+		cfsetospeed(&tty, B9600);
+		break;
+	case 4800:
+		c = "*p";
+		cfsetispeed(&tty, B4800);
+		cfsetospeed(&tty, B4800);
+		break;
+	case 2400:
+		c = "*o";
+		cfsetispeed(&tty, B2400);
+		cfsetospeed(&tty, B2400);
+		break;
+	case 1200:
+	default:
+		c = "*n";
+		cfsetispeed(&tty, B1200);
+		cfsetospeed(&tty, B1200);
+	}
+
+	if (mouse->mseType == P_LOGIMAN || mouse->mseType == P_LOGI)
+	{
+		if (write(mouse->mseFd, c, 2) != 2)
+		{
+			if (xf86AllowMouseOpenFail) {
+				ErrorF("Unable to write to mouse fd (%s) - Continuing...\n",
+				       strerror(errno));
+				return;
+			}
+			xf86FatalError("Unable to write to mouse fd (%s)\n",
+				       strerror(errno));
+		}
+	}
+	usleep(100000);
+
+	if (tcsetattr(mouse->mseFd, TCSADRAIN, &tty) < 0)
+	{
+		if (xf86AllowMouseOpenFail) {
+			ErrorF("Unable to set status of mouse fd (%s) - Continuing...\n",
+			       strerror(errno));
+			return;
+		}
+		xf86FatalError("Unable to set status of mouse fd (%s)\n",
+			       strerror(errno));
+	}
+}
+
+int
+xf86FlushInput(fd)
+int fd;
+{
+	return tcflush(fd, TCIFLUSH);
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/std_kbdEv.c XFree86.current/xc/programs/Xserver/hw/gsx/common/std_kbdEv.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/std_kbdEv.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/std_kbdEv.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,49 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_kbdEv.c,v 3.1 1996/12/23 06:51:02 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Thomas Roell and
+ * David Dawes makes no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE 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.
+ *
+ */
+/* $XConsortium: std_kbdEv.c /main/4 1996/03/11 10:47:33 kaleb $ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+void xf86KbdEvents()
+{
+	unsigned char rBuf[64];
+	int nBytes, i;
+
+	if ((nBytes = read( xf86Info.consoleFd, (char *)rBuf, sizeof(rBuf)))
+	    > 0)
+	{
+		for (i = 0; i < nBytes; i++)
+			xf86PostKbdEvent(rBuf[i]);
+	}
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/std_mouse.c XFree86.current/xc/programs/Xserver/hw/gsx/common/std_mouse.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/std_mouse.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/std_mouse.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,61 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_mouse.c,v 3.6 1996/12/23 06:51:03 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Thomas Roell and
+ * David Dawes makes no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE 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.
+ *
+ */
+/* $XConsortium: std_mouse.c /main/5 1996/03/11 10:47:40 kaleb $ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86_Config.h"
+
+int xf86MouseOff(mouse, doclose)
+MouseDevPtr mouse;
+Bool doclose;
+{
+	int oldfd;
+
+	if ((oldfd = mouse->mseFd) >= 0)
+	{
+		if (mouse->mseType == P_LOGI)
+		{
+			write(mouse->mseFd, "U", 1);
+		}
+		if (mouse->oldBaudRate > 0) {
+		    xf86SetMouseSpeed(mouse,
+				      mouse->baudRate,
+				      mouse->oldBaudRate,
+				      xf86MouseCflags[mouse->mseType]);
+		}
+		close(mouse->mseFd);
+		oldfd = mouse->mseFd;
+		mouse->mseFd = -1;
+	}
+	return(oldfd);
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/std_mseEv.c XFree86.current/xc/programs/Xserver/hw/gsx/common/std_mseEv.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/std_mseEv.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/std_mseEv.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,48 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/shared/std_mseEv.c,v 3.1 1996/12/23 06:51:04 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Thomas Roell and
+ * David Dawes makes no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE 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.
+ *
+ */
+/* $XConsortium: std_mseEv.c /main/4 1996/03/11 10:47:48 kaleb $ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+void xf86MouseEvents(mouse)
+    MouseDevPtr	mouse;
+{
+	unsigned char rBuf[64];
+	int nBytes;
+
+	if ((nBytes = read(mouse->mseFd, (char *)rBuf, sizeof(rBuf))) > 0)
+	{
+		xf86MouseProtocol(mouse->device, rBuf, nBytes);
+	}
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/stubs.c XFree86.current/xc/programs/Xserver/hw/gsx/common/stubs.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/stubs.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/stubs.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,320 @@
+/* $XConsortium: stubs.c,v 1.10 94/07/18 16:25:03 gildea Exp $ */
+/* $XFree86: xc/programs/Xserver/Xi/stubs.c,v 3.1 1996/03/30 05:25:21 dawes Exp $ */
+
+/************************************************************
+
+Copyright (c) 1989  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 (c) 1989 by Hewlett-Packard Company, Palo Alto, California.
+
+			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 notice appear in all copies and that
+both that copyright notice and this permission notice appear in
+supporting documentation, and that the name of Hewlett-Packard not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+HEWLETT-PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+HEWLETT-PACKARD BE LIABLE 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.
+
+********************************************************/
+
+/*
+ * stubs.c -- stub routines for the X server side of the XINPUT
+ * extension.  This file is mainly to be used only as documentation.
+ * There is not much code here, and you can't get a working XINPUT
+ * server just using this.
+ * The Xvfb server uses this file so it will compile with the same
+ * object files as the real X server for a platform that has XINPUT.
+ * Xnest could do the same thing.
+ */
+
+#define	 NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "XI.h"
+#include "XIproto.h"
+#include "XIstubs.h"
+
+/***********************************************************************
+ *
+ * Caller:	ProcXChangeKeyboardDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the keyboard device.
+ *
+ * The X keyboard device has a FocusRec.  If the device that has been 
+ * made into the new X keyboard did not have a FocusRec, 
+ * ProcXChangeKeyboardDevice will allocate one for it.
+ *
+ * If you do not want clients to be able to focus the old X keyboard
+ * device, call DeleteFocusClassDeviceStruct to free the FocusRec.
+ *
+ * If you support input devices with keys that you do not want to be 
+ * used as the X keyboard, you need to check for them here and return 
+ * a BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you do want
+ * clients to be able to focus the old X keyboard).  The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+ChangeKeyboardDevice (old_dev, new_dev)
+    DeviceIntPtr	old_dev;
+    DeviceIntPtr	new_dev;
+    {
+    /***********************************************************************
+     DeleteFocusClassDeviceStruct(old_dev);	 * defined in xchgptr.c *
+    **********************************************************************/
+    return BadMatch;
+    }
+
+
+/***********************************************************************
+ *
+ * Caller:	ProcXChangePointerDevice
+ *
+ * This procedure does the implementation-dependent portion of the work
+ * needed to change the pointer device.
+ *
+ * The X pointer device does not have a FocusRec.  If the device that
+ * has been made into the new X pointer had a FocusRec, 
+ * ProcXChangePointerDevice will free it.
+ *
+ * If you want clients to be able to focus the old pointer device that
+ * has now become accessible through the input extension, you need to 
+ * add a FocusRec to it here.
+ *
+ * The XChangePointerDevice protocol request also allows the client
+ * to choose which axes of the new pointer device are used to move 
+ * the X cursor in the X- and Y- directions.  If the axes are different
+ * than the default ones, you need to keep track of that here.
+ *
+ * If you support input devices with valuators that you do not want to be 
+ * used as the X pointer, you need to check for them here and return a 
+ * BadDevice error.
+ *
+ * The default implementation is to do nothing (assume you don't want
+ * clients to be able to focus the old X pointer).  The commented-out
+ * sample code shows what you might do if you don't want the default.
+ *
+ */
+
+int
+#if NeedFunctionPrototypes
+ChangePointerDevice (
+    DeviceIntPtr	old_dev,
+    DeviceIntPtr	new_dev,
+    unsigned char	x,
+    unsigned char	y)
+#else
+ChangePointerDevice (old_dev, new_dev, x, y)
+    DeviceIntPtr	old_dev, new_dev;
+    unsigned char	x, y;
+#endif
+    {
+    /***********************************************************************
+    InitFocusClassDeviceStruct(old_dev);	* allow focusing old ptr*
+
+    x_axis = x;					* keep track of new x-axis*
+    y_axis = y;					* keep track of new y-axis*
+    if (x_axis != 0 || y_axis != 1)
+	axes_changed = TRUE;			* remember axes have changed*
+    else
+	axes_changed = FALSE;
+    *************************************************************************/
+    return BadMatch;
+    }
+
+/***********************************************************************
+ *
+ * Caller:	ProcXCloseDevice
+ *
+ * Take care of implementation-dependent details of closing a device.
+ * Some implementations may actually close the device, others may just
+ * remove this clients interest in that device.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ *
+ */
+
+void
+CloseInputDevice (d, client)
+    DeviceIntPtr d;
+    ClientPtr client;
+    {
+    }
+
+/***********************************************************************
+ *
+ * Caller:	ProcXListInputDevices
+ *
+ * This is the implementation-dependent routine to initialize an input 
+ * device to the point that information about it can be listed.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them.  Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request.  If some other process has the device open, the
+ * server may not be able to get information about the device to list it.
+ *
+ * This procedure should be used by implementations that do not initialize
+ * all input devices at server startup.  It should do device-dependent
+ * initialization for any devices not previously initialized, and call
+ * AddInputDevice for each of those devices so that a DeviceIntRec will be 
+ * created for them.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are initialized during X server initialization and kept open).
+ * The commented-out sample code shows what you might do if you don't want 
+ * the default.
+ *
+ */
+
+void
+AddOtherInputDevices ()
+    {
+    /**********************************************************************
+     for each uninitialized device, do something like: 
+
+    DeviceIntPtr dev;
+    DeviceProc deviceProc;
+    pointer private;
+
+    dev = (DeviceIntPtr) AddInputDevice(deviceProc, TRUE);
+    dev->public.devicePrivate = private;
+    RegisterOtherDevice(dev);
+    dev->inited = ((*dev->deviceProc)(dev, DEVICE_INIT) == Success);
+    ************************************************************************/
+
+    }
+
+/***********************************************************************
+ *
+ * Caller:	ProcXOpenDevice
+ *
+ * This is the implementation-dependent routine to open an input device.
+ * Some implementations open all input devices when the server is first
+ * initialized, and never close them.  Other implementations open only
+ * the X pointer and keyboard devices during server initialization,
+ * and only open other input devices when some client makes an
+ * XOpenDevice request.  This entry point is for the latter type of 
+ * implementation.
+ *
+ * If the physical device is not already open, do it here.  In this case,
+ * you need to keep track of the fact that one or more clients has the
+ * device open, and physically close it when the last client that has
+ * it open does an XCloseDevice.
+ *
+ * The default implementation is to do nothing (assume all input devices
+ * are opened during X server initialization and kept open).
+ *
+ */
+
+void
+OpenInputDevice (dev, client, status)
+    DeviceIntPtr dev;
+    ClientPtr client;
+    int *status;
+    {
+    }
+
+/****************************************************************************
+ *
+ * Caller:	ProcXSetDeviceMode
+ *
+ * Change the mode of an extension device.
+ * This function is used to change the mode of a device from reporting
+ * relative motion to reporting absolute positional information, and
+ * vice versa.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceMode (client, dev, mode)
+    register	ClientPtr	client;
+    DeviceIntPtr dev;
+    int		mode;
+    {
+    return BadMatch;
+    }
+
+/****************************************************************************
+ *
+ * Caller:	ProcXSetDeviceValuators
+ *
+ * Set the value of valuators on an extension input device.
+ * This function is used to set the initial value of valuators on
+ * those input devices that are capable of reporting either relative
+ * motion or an absolute position, and allow an initial position to be set.
+ * The default implementation below is that no such devices are supported.
+ *
+ */
+
+int
+SetDeviceValuators (client, dev, valuators, first_valuator, num_valuators)
+    register	ClientPtr	client;
+    DeviceIntPtr dev;
+    int		*valuators;
+    int		first_valuator;
+    int		num_valuators;
+    {
+    return BadMatch;
+    }
+
+/****************************************************************************
+ *
+ * Caller:	ProcXChangeDeviceControl
+ *
+ * Change the specified device controls on an extension input device.
+ *
+ */
+
+int
+ChangeDeviceControl (client, dev, control)
+    register	ClientPtr	client;
+    DeviceIntPtr dev;
+    xDeviceCtl	*control;
+    {
+    switch (control->control)
+	{
+	case DEVICE_RESOLUTION:
+	    return (BadMatch);
+	default:
+	    return (BadMatch);
+	}
+    }
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,721 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86.h,v 3.47.2.9 1998/10/18 20:42:10 hohndel Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86.h /main/28 1996/10/23 18:43:15 kaleb $ */
+
+#ifndef _XF86_H
+#define _XF86_H
+
+#include "misc.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "xf86_Option.h"
+
+/*
+ * structure common for all modes
+ */
+typedef struct _DispM {
+  struct _DispM	*prev,*next;
+  char		*name;              /* identifier of this mode */
+  /* These are the values that the user sees/provides */
+  int		Clock;              /* pixel clock */
+  int           HDisplay;           /* horizontal timing */
+  int           HSyncStart;
+  int           HSyncEnd;
+  int           HTotal;
+  int           HSkew;
+  int           VDisplay;           /* vertical timing */
+  int           VSyncStart;
+  int           VSyncEnd;
+  int           VTotal;
+  int           Flags;
+  /* These are the values the hardware uses */
+  int		SynthClock;         /* Actual clock freq to be programmed */
+  int		CrtcHDisplay;
+  int		CrtcHSyncStart;
+  int		CrtcHSyncEnd;
+  int		CrtcHTotal;
+  int		CrtcHSkew;
+  int		CrtcVDisplay;
+  int		CrtcVSyncStart;
+  int		CrtcVSyncEnd;
+  int		CrtcVTotal;
+  Bool		CrtcHAdjusted;
+  Bool		CrtcVAdjusted;
+  int		PrivSize;
+  INT32 	*Private;
+} DisplayModeRec, *DisplayModePtr;
+
+#define V_PHSYNC    0x0001
+#define V_NHSYNC    0x0002
+#define V_PVSYNC    0x0004
+#define V_NVSYNC    0x0008
+#define V_INTERLACE 0x0010
+#define V_DBLSCAN   0x0020
+#define V_CSYNC     0x0040
+#define V_PCSYNC    0x0080
+#define V_NCSYNC    0x0100
+#define V_HSKEW     0x0200	/* hskew provided */
+#define V_BCAST     0x0400
+#define V_PIXMUX    0x1000
+#define V_DBLCLK    0x2000
+#define V_CLKDIV2   0x4000
+
+/* The monitor description */
+
+#define MAX_HSYNC 8
+#define MAX_VREFRESH 8
+
+typedef struct { float hi, lo; } range;
+
+typedef struct {
+   char *id;
+   char *vendor;
+   char *model;
+   float EMPTY;
+   int n_hsync;
+   range hsync[MAX_HSYNC];       
+   int n_vrefresh;                  
+   range vrefresh[MAX_VREFRESH];
+   DisplayModePtr Modes, Last; /* Start and end of monitor's mode list */
+} MonRec, *MonPtr;
+
+#define MAXCLOCKS   128
+#define MAXDACSPEEDS  4  /* for <= 8, 16, 24, 32bpp */
+
+/* Set default max allowed clock to 90MHz */
+#define DEFAULT_MAX_CLOCK	90000
+
+/*
+ * the graphic device
+ */
+typedef struct {
+  Bool           configured;
+  int            tmpIndex;
+  int            scrnIndex;
+  Bool           (* Probe)(
+#if NeedNestedPrototypes
+    void
+#endif
+);
+  Bool           (* Init)(
+#if NeedNestedPrototypes
+    int          scr_index,
+    ScreenPtr    pScreen,
+    int          argc,
+    char         **argv
+#endif
+);
+  int            (* ValidMode)(
+#if NeedNestedPrototypes
+    DisplayModePtr target,
+    Bool verbose,
+    int flag
+#endif
+);
+  void           (* EnterLeaveVT)(
+#if NeedNestedPrototypes
+    int,
+    int
+#endif
+);
+  void           (* EnterLeaveMonitor)(
+#if NeedNestedPrototypes
+    int
+#endif
+);
+  void           (* EnterLeaveCursor)(
+#if NeedNestedPrototypes
+    int
+#endif
+);
+  void           (* AdjustFrame)(
+#if NeedNestedPrototypes
+    int x,
+    int y
+#endif
+);
+  Bool           (* SwitchMode)(
+#if NeedNestedPrototypes
+    DisplayModePtr modes
+#endif
+);
+  void           (* DPMSSet)(
+#if NeedNestedPrototypes
+    int level
+#endif
+);
+  void           (* PrintIdent)(
+#if NeedNestedPrototypes
+    void
+#endif
+);
+  int            depth;
+  xrgb		 weight;
+  int            bitsPerPixel;
+  int            defaultVisual;
+  int            virtualX,virtualY; 
+  int		 displayWidth;
+  int            frameX0, frameY0, frameX1, frameY1;
+  OFlagSet       options;
+  OFlagSet       clockOptions;
+  OFlagSet	 xconfigFlag;
+  char           *chipset;
+  char           *ramdac;
+  int            dacSpeeds[MAXDACSPEEDS];
+  int            dacSpeedBpp;
+  int            clocks;
+  int            clock[MAXCLOCKS];
+  int            maxClock;
+  int            videoRam;
+  int            BIOSbase;                 /* Base address of video BIOS */
+  unsigned long  MemBase;                  /* Frame buffer base address */
+  int            width, height;            /* real display dimensions */
+  unsigned long  speedup;                  /* Use SpeedUp code */
+  DisplayModePtr modes;
+  MonPtr         monitor;
+  char           *clockprog;
+  int            textclock;
+  Bool           bankedMono;	  /* display supports banking for mono server */
+  char           *name;
+  xrgb           blackColour;
+  xrgb           whiteColour;
+  int            *validTokens;
+  char           *patchLevel;
+  unsigned int   IObase;          /* AGX - video card I/O reg base        */
+  unsigned int   DACbase;         /* AGX - dac I/O reg base               */
+  unsigned long  COPbase;         /* AGX - coprocessor memory base        */
+  unsigned int   POSbase;         /* AGX - I/O address of POS regs        */
+  int            instance;        /* AGX - XGA video card instance number */
+  int            s3Madjust;
+  int            s3Nadjust;
+  int            s3MClk;
+  int            chipID;
+  int            chipRev;
+  unsigned long  VGAbase;         /* AGX - 64K aperture memory address    */
+  int            s3RefClk;
+  int            s3BlankDelay;
+  int            textClockFreq;
+  char          *DCConfig;
+  char          *DCOptions;
+  int            MemClk;          /* General flag used for memory clocking */
+  int            LCDClk;
+#ifdef XFreeXDGA
+  int            directMode;
+  void           (*setBank)(
+#if NeedNestedPrototypes
+    int
+#endif
+  );
+  unsigned long  physBase;
+  int            physSize;
+#endif
+#ifdef XF86SETUP
+  void           *device;	/* This should be GDevPtr, but it causes
+				   problems with include file order */
+#endif
+} ScrnInfoRec, *ScrnInfoPtr;
+
+typedef struct {
+  int           token;                /* id of the token */
+  char          *name;                /* pointer to the LOWERCASED name */
+} SymTabRec, *SymTabPtr;
+
+#define VGA_DRIVER  1
+#define V256_DRIVER 2
+#define WGA_DRIVER  3
+#define XGA_DRIVER  4
+
+#define ENTER       1
+#define LEAVE       0
+
+/* These are possible return values for xf86CheckMode() and ValidMode() */
+#define MODE_OK	    0
+#define MODE_HSYNC  1		/* hsync out of range */
+#define MODE_VSYNC  2		/* vsync out of range */
+#define MODE_BAD    255		/* unspecified reason */
+
+/* These are the possible flags for ValidMode */
+#define MODE_USED	1	/* this mode is really being used in the */
+				/* modes line of the Display Subsection  */
+#define MODE_SUGGESTED	2	/* this mode is included in the available*/
+				/* modes in the Monitor Section */
+#define MODE_VID	3	/* this is called from the VidMode extension */
+
+/* Indicates the level of DPMS support */
+typedef enum {
+    DPMSSupportUnknown,
+    DPMSNotSupported,
+    DPMSFullSupport
+} DPMSSupportStatus;
+
+/* flags for xf86LookupMode */
+#define LOOKUP_DEFAULT		0	/* Use default mode lookup method */
+#define LOOKUP_BEST_REFRESH	1	/* Pick modes with best refresh */
+#define LOOKUP_NO_INTERLACED	2	/* Ignore interlaced modes */
+#define LOOKUP_FORCE_DEFAULT	4	/* Force default lookup method */
+
+#define INTERLACE_REFRESH_WEIGHT	1.5
+
+/* SpeedUp options */
+
+#define SPEEDUP_FILLBOX		1
+#define SPEEDUP_FILLRECT	2
+#define	SPEEDUP_BITBLT		4
+#define SPEEDUP_LINE		8
+#define SPEEDUP_TEGBLT8      0x10
+#define SPEEDUP_RECTSTIP     0x20
+
+/*
+ * This is the routines where SpeedUp is quicker than fXF86.  The problem is
+ * that the SpeedUp fillbox is better for drawing vertical and horizontal
+ * line segments, and the fXF86 version is significantly better for
+ * more general lines
+ */
+#define SPEEDUP_BEST		(SPEEDUP_FILLRECT | SPEEDUP_BITBLT | \
+				 SPEEDUP_LINE | SPEEDUP_TEGBLT8 | \
+				 SPEEDUP_RECTSTIP)
+/*
+#define SPEEDUP_BEST		(SPEEDUP_FILLBOX | SPEEDUP_FILLRECT | \
+				 SPEEDUP_BITBLT | SPEEDUP_LINE | \
+                                 SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP)
+*/
+
+/*
+ * SpeedUp routines which are not dependent on the screen virtual resolution
+ */
+#ifndef SPEEDUP_ANYWIDTH
+#define SPEEDUP_ANYWIDTH	(SPEEDUP_FILLRECT | SPEEDUP_BITBLT | \
+                                 SPEEDUP_LINE | SPEEDUP_FILLBOX)
+#endif
+
+/*
+ * SpeedUp routines which are not dependent on ET4000
+ */
+#ifndef SPEEDUP_ANYCHIPSET
+#define SPEEDUP_ANYCHIPSET	(SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP)
+#endif
+
+/* All SpeedUps */
+#define SPEEDUP_ALL		(SPEEDUP_FILLBOX | SPEEDUP_FILLRECT | \
+				 SPEEDUP_BITBLT | SPEEDUP_LINE | \
+                                 SPEEDUP_TEGBLT8 | SPEEDUP_RECTSTIP)
+
+/* SpeedUp flags used if SpeedUp is not in XF86Config */
+#define SPEEDUP_DEFAULT		SPEEDUP_ALL
+
+extern Bool        xf86VTSema;
+
+/* Mouse device private record */
+
+#define MSE_MAPTOX		(-1)
+#define MSE_MAPTOY		(-2)
+#define MSE_MAXBUTTONS		12
+#define MSE_DFLTBUTTONS		3
+
+typedef struct _MouseDevRec {
+    DeviceProc    mseProc;              /* procedure for initializing */
+    void          (* mseEvents)(
+#if NeedNestedPrototypes
+			struct _MouseDevRec *
+#endif
+				);      /* proc for processing events */
+    DeviceIntPtr  device;
+    int           mseFd;
+    char          *mseDevice;
+    int           mseType;
+    int           mseModel;
+    int           baudRate;
+    int           oldBaudRate;
+    int           sampleRate;
+    int           lastButtons;
+    int           threshold, num, den;  /* acceleration */
+    int           buttons;		/* # of buttons */
+    int           emulateState;         /* automata state for 2 button mode */
+    Bool          emulate3Buttons;
+    int           emulate3Timeout;      /* Timeout for 3 button emulation */
+    Bool          chordMiddle;
+    int           mouseFlags;		/* Flags to Clear after opening mouse dev */
+    int		  truebuttons;		/* Arg to maintain before emulate3buttons timer callback */
+
+    int           resolution;
+    int           negativeZ;
+    int           positiveZ;
+#ifndef MOUSE_PROTOCOL_IN_KERNEL
+    unsigned char protoPara[7];
+#endif
+    
+#ifndef CSRG_BASED
+    /* xque part */
+    int           xquePending;		/* was xqueFd, but nothing uses that */
+    int           xqueSema;
+#endif
+} MouseDevRec, *MouseDevPtr;
+
+#define MOUSE_DEV(dev) (MouseDevPtr) (dev)->public.devicePrivate
+
+/* Global data */
+/* xf86Init.c */
+extern double xf86rGamma, xf86gGamma, xf86bGamma;
+
+#ifdef XF86VIDMODE
+extern Bool xf86VidModeEnabled;
+extern Bool xf86VidModeAllowNonLocal;
+#endif
+#ifdef XF86MISC
+extern Bool xf86MiscModInDevEnabled;
+extern Bool xf86MiscModInDevAllowNonLocal;
+#endif
+
+/* PCI probe flags */
+
+
+typedef enum {
+    PCIProbe1 = 0,
+    PCIProbe2,
+    PCIForceConfig1,
+    PCIForceConfig2
+} PciProbeType;
+
+extern PciProbeType xf86PCIFlags;
+
+/* Function Prototypes */
+#ifndef _NO_XF86_PROTOTYPES
+
+/* xf86Init.c */
+void InitOutput(
+#if NeedFunctionPrototypes
+    ScreenInfo *pScreenInfo,
+    int argc,
+    char **argv
+#endif
+);
+
+void InitInput(
+#if NeedFunctionPrototypes
+    int argc,
+    char **argv
+#endif
+);
+
+void ddxGiveUp(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+void AbortDDX(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+int ddxProcessArgument(
+#if NeedFunctionPrototypes
+    int argc,
+    char *argv[],
+    int i
+#endif
+);
+
+void ddxUseMsg(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+/* xf86Config.c */
+unsigned int StrToUL(
+#if NeedFunctionPrototypes
+    char *str
+#endif
+);
+
+#ifndef CONFIG_RETURN_TYPE
+#ifdef XF86SETUP
+#define CONFIG_RETURN_TYPE int
+#else
+#define CONFIG_RETURN_TYPE void
+#endif
+#endif
+
+CONFIG_RETURN_TYPE xf86Config(
+#if NeedFunctionPrototypes
+    int vtopen
+#endif
+);
+
+Bool xf86LookupMode(
+#if NeedFunctionPrototypes
+    DisplayModePtr target,
+    ScrnInfoPtr driver,
+    int flags
+#endif
+);
+
+void xf86VerifyOptions(
+#if NeedFunctionPrototypes
+    OFlagSet *allowedOptions,
+    ScrnInfoPtr driver
+#endif
+);
+
+int xf86CheckMode(
+#if NeedFunctionPrototypes
+    ScrnInfoPtr scrp,
+    DisplayModePtr dispmp,
+    MonPtr monp,
+    int verbose
+#endif
+);
+
+int xf86GetNearestClock(
+#if NeedFunctionPrototypes
+    ScrnInfoPtr Screen,
+    int Frequency
+#endif
+);
+
+/* xf86Cursor.c */
+void xf86InitViewport(
+#if NeedFunctionPrototypes
+    ScrnInfoPtr pScr
+#endif
+);
+
+void xf86SetViewport(
+#if NeedFunctionPrototypes
+    ScreenPtr pScreen,
+    int x,
+    int y
+#endif
+);
+
+void xf86LockZoom(
+#if NeedFunctionPrototypes
+    ScreenPtr pScreen,
+    int lock
+#endif
+);
+
+void xf86ZoomViewport(
+#if NeedFunctionPrototypes
+    ScreenPtr pScreen,
+    int zoom
+#endif
+);
+
+/* xf86Dl.c */
+void*
+xf86LoadModule(
+#if NeedFunctionPrototypes
+	const char *	file,
+	const char *	path
+#endif
+);
+
+/* xf86Events.c */
+int TimeSinceLastInputEvent(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+void SetTimeSinceLastInputEvent(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+void ProcessInputEvents(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+void xf86PostKbdEvent(
+#if NeedFunctionPrototypes
+    unsigned key
+#endif
+);
+
+void xf86PostMseEvent(
+#if NeedFunctionPrototypes
+    DeviceIntPtr device,
+    int buttons,
+    int dx,
+    int dy
+#endif
+);
+
+void xf86Block(
+#if NeedFunctionPrototypes
+    pointer blockData,
+    OSTimePtr pTimeout,
+    pointer pReadmask
+#endif
+);
+
+void xf86Wakeup(
+#if NeedFunctionPrototypes
+    pointer blockData,
+    int err,
+    pointer pReadmask
+#endif
+);
+
+void xf86SigHandler(
+#if NeedFunctionPrototypes
+    int signo
+#endif
+);
+
+/* xf86Io.c */
+void xf86KbdBell(
+#if NeedFunctionPrototypes
+    int percent,
+    DeviceIntPtr pKeyboard,
+    pointer ctrl,
+    int unused
+#endif
+);
+
+void xf86KbdLeds(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+void xf86KbdCtrl(
+#if NeedFunctionPrototypes
+    DevicePtr pKeyboard,
+    KeybdCtrl *ctrl
+#endif
+);
+
+void xf86InitKBD(
+#if NeedFunctionPrototypes
+    Bool init
+#endif
+);
+
+int xf86KbdProc(
+#if NeedFunctionPrototypes
+    DeviceIntPtr pKeyboard,
+    int what
+#endif
+);
+
+void xf86MseCtrl(
+#if NeedFunctionPrototypes
+    DevicePtr pPointer,
+    PtrCtrl *ctrl
+#endif
+);
+
+int GetMotionEvents(
+#if NeedFunctionPrototypes
+    DeviceIntPtr,
+    xTimecoord *,
+    unsigned long,
+    unsigned long,
+    ScreenPtr
+#endif
+);
+
+int xf86MseProc(
+#if NeedFunctionPrototypes
+    DeviceIntPtr pPointer,
+    int what
+#endif
+);
+
+void xf86MseEvents(
+#if NeedFunctionPrototypes
+        MouseDevPtr mouse
+#endif
+);
+
+CARD32 GetTimeInMillis(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+void OsVendorInit(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+
+/* xf86_Mouse.c */
+Bool xf86MouseSupported(
+#if NeedFunctionPrototypes
+    int mousetype
+#endif
+);
+
+void xf86SetupMouse(
+#if NeedFunctionPrototypes
+    MouseDevPtr mouse
+#endif
+);
+
+void xf86MouseProtocol(
+#if NeedFunctionPrototypes
+    DeviceIntPtr device,
+    unsigned char *rBuf,
+    int nBytes
+#endif
+);
+
+
+/* xf86_PnPMouse.c */
+int xf86GetPnPMouseProtocol(
+#if NeedFunctionPrototypes
+    MouseDevPtr mouse
+#endif
+);
+
+/* xf86Kbd.c */
+Bool LegalModifier(
+#if NeedFunctionPrototypes
+    unsigned int key,
+    DevicePtr pDev
+#endif
+);
+
+void xf86KbdGetMapping(
+#if NeedFunctionPrototypes
+    KeySymsPtr pKeySyms,
+    CARD8 *pModMap
+#endif
+);
+#endif /* _NO_XF86_PROTOTYPES */
+
+/* End of Prototypes */
+
+#endif /* _XF86_H */
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Config.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Config.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Config.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Config.c	Wed Mar 14 21:17:24 2001
@@ -0,0 +1,2039 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Config.c,v 3.113.2.19 1998/10/18 20:42:11 hohndel Exp $
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ */
+/* $XConsortium: xf86Config.c /main/58 1996/12/28 14:46:17 kaleb $ */
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+extern double atof();
+extern char *getenv();
+#endif
+
+#define NEED_EVENTS 1
+#include "X.h"
+#include "Xproto.h"
+#include "Xmd.h"
+#include "input.h"
+#include "servermd.h"
+#include "scrnintstr.h"
+
+#ifdef DPMSExtension
+#include "opaque.h"
+#endif
+
+#define NO_COMPILER_H_EXTRAS
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+
+#define INIT_CONFIG
+#include "xf86_Config.h"
+
+#ifdef XKB
+#include "inputstr.h"
+#include "XKBsrv.h"
+#endif
+
+#ifdef XINPUT
+#include "xf86Xinput.h"
+
+extern DeviceAssocRec	mouse_assoc;
+#endif
+
+#ifdef NEED_RETURN_VALUE
+#define HANDLE_RETURN(xx)	if (xx == RET_ERROR) return RET_ERROR
+#else
+#define HANDLE_RETURN(xx)	xx
+#endif
+
+#define CONFIG_BUF_LEN     1024
+
+static FILE * configFile   = NULL;
+static int    configStart  = 0;           /* start of the current token */
+static int    configPos    = 0;           /* current readers position */
+static int    configLineNo = 0;           /* linenumber */
+static char   *configBuf,*configRBuf;     /* buffer for lines */
+static char   *configPath;                /* path to config file */
+static char   *fontPath = NULL;           /* font path */
+static int    pushToken = LOCK_TOKEN;
+static LexRec val;                        /* global return value */
+static char   DCerr;  
+static int scr_index = 0;
+
+extern char *defaultFontPath;
+extern char *rgbPath;
+
+extern Bool xf86fpFlag, xf86coFlag, xf86sFlag;
+extern Bool xf86ScreensOpen;
+
+extern int defaultColorVisualClass;
+extern CARD32 defaultScreenSaverTime, ScreenSaverTime;
+
+/* gsxinit.c */
+extern void SetGSXScreen(int , int , int , int);
+extern void SetGSXFrameRate(int, int);
+extern int checkResolution(int, int);
+
+char *xf86VisualNames[] = {
+    "StaticGray",
+    "GrayScale",
+    "StaticColor",
+    "PseudoColor",
+    "TrueColor",
+    "DirectColor"
+};
+
+static CONFIG_RETURN_TYPE configFilesSection(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+static CONFIG_RETURN_TYPE configKeyboardSection(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+static CONFIG_RETURN_TYPE configScreenSection(
+#if NeedFunctionPrototypes
+    void
+#endif
+);
+static CONFIG_RETURN_TYPE configDisplaySubsection(
+#if NeedFunctionPrototypes
+    DispPtr disp
+#endif
+);
+static CONFIG_RETURN_TYPE configPointerSection(
+#if NeedFunctionPrototypes
+  MouseDevPtr	mouse_dev,
+  int		end_tag,
+  char		**devicename
+#endif
+);
+
+static
+CONFIG_RETURN_TYPE findConfigFile(
+#if NeedFunctionPrototypes
+      char *filename,
+      FILE **fp
+#endif
+);
+static int getScreenIndex(
+#if NeedFunctionPrototypes
+     int token
+#endif
+);
+static int getStringToken(
+#if NeedFunctionPrototypes
+     SymTabRec tab[]
+#endif
+);
+static CONFIG_RETURN_TYPE readVerboseMode(
+#if NeedFunctionPrototypes
+    MonPtr monp
+#endif
+);
+static Bool validateGraphicsToken(
+#if NeedFunctionPrototypes
+     int *validTokens,
+     int token
+#endif
+);
+extern char * xf86GetPathElem(
+#if NeedFunctionPrototypes
+     char **pnt
+#endif
+);
+static DisplayModePtr xf86PruneModes(
+#if NeedFunctionPrototypes
+    MonPtr monp,
+    DisplayModePtr allmodes,
+    ScrnInfoPtr scrp,
+    Bool card
+#endif
+);
+static char * xf86ValidateFontPath(
+#if NeedFunctionPrototypes
+     char * /* path */
+#endif
+);
+#ifdef XINPUT
+extern CONFIG_RETURN_TYPE xf86ConfigExtendedInputSection(
+#if NeedFunctionPrototypes
+    LexPtr      pval
+#endif
+);
+#endif
+
+#ifdef XKB
+extern char *XkbInitialMap;
+#endif
+
+#define DIR_FILE	"/fonts.dir"
+
+/*
+ * xf86GetPathElem --
+ *	Extract a single element from the font path string starting at
+ *	pnt.  The font path element will be returned, and pnt will be
+ *	updated to point to the start of the next element, or set to
+ *	NULL if there are no more.
+ */
+char *
+xf86GetPathElem(pnt)
+     char **pnt;
+{
+  char *p1;
+
+  p1 = *pnt;
+  *pnt = index(*pnt, ',');
+  if (*pnt != NULL) {
+    **pnt = '\0';
+    *pnt += 1;
+  }
+  return(p1);
+}
+
+/*
+ * StrToUL --
+ *
+ *	A portable, but restricted, version of strtoul().  It only understands
+ *	hex, octal, and decimal.  But it's good enough for our needs.
+ */
+unsigned int StrToUL(str)
+char *str;
+{
+  int base = 10;
+  char *p = str;
+  unsigned int tot = 0;
+
+  if (*p == '0') {
+    p++;
+    if (*p == 'x') {
+      p++;
+      base = 16;
+    }
+    else
+      base = 8;
+  }
+  while (*p) {
+    if ((*p >= '0') && (*p <= ((base == 8)?'7':'9'))) {
+      tot = tot * base + (*p - '0');
+    }
+    else if ((base == 16) && (*p >= 'a') && (*p <= 'f')) {
+      tot = tot * base + 10 + (*p - 'a');
+    }
+    else if ((base == 16) && (*p >= 'A') && (*p <= 'F')) {
+      tot = tot * base + 10 + (*p - 'A');
+    }
+    else {
+      return(tot);
+    }
+    p++;
+  }
+  return(tot);
+}
+
+/*
+ * xf86ValidateFontPath --
+ *	Validates the user-specified font path.  Each element that
+ *	begins with a '/' is checked to make sure the directory exists.
+ *	If the directory exists, the existence of a file named 'fonts.dir'
+ *	is checked.  If either check fails, an error is printed and the
+ *	element is removed from the font path.
+ */
+#define CHECK_TYPE(mode, type) ((S_IFMT & (mode)) == (type))
+static char *
+xf86ValidateFontPath(path)
+     char *path;
+{
+  char *tmp_path, *out_pnt, *path_elem, *next, *p1, *dir_elem;
+  struct stat stat_buf;
+  int flag;
+  int dirlen;
+
+  tmp_path = (char *)xcalloc(1,strlen(path)+1);
+  out_pnt = tmp_path;
+  path_elem = NULL;
+  next = path;
+  while (next != NULL) {
+    path_elem = xf86GetPathElem(&next);
+#ifndef __EMX__
+    if (*path_elem == '/') {
+      dir_elem = (char *)xcalloc(1, strlen(path_elem) + 1);
+      if ((p1 = strchr(path_elem, ':')) != 0)
+#else
+    /* OS/2 must prepend X11ROOT */
+    if (*path_elem == '/') {
+      path_elem = (char*)__XOS2RedirRoot(path_elem);
+      dir_elem = (char*)xcalloc(1, strlen(path_elem) + 1);
+      if (p1 = strchr(path_elem+2, ':'))
+#endif
+	dirlen = p1 - path_elem;
+      else
+	dirlen = strlen(path_elem);
+      strncpy(dir_elem, path_elem, dirlen);
+      dir_elem[dirlen] = '\0';
+      flag = stat(dir_elem, &stat_buf);
+      if (flag == 0)
+	if (!CHECK_TYPE(stat_buf.st_mode, S_IFDIR))
+	  flag = -1;
+      if (flag != 0) {
+        ErrorF("Warning: The directory \"%s\" does not exist.\n", dir_elem);
+	ErrorF("         Entry deleted from font path.\n");
+	continue;
+      }
+      else {
+	p1 = (char *)xalloc(strlen(dir_elem)+strlen(DIR_FILE)+1);
+	strcpy(p1, dir_elem);
+	strcat(p1, DIR_FILE);
+	flag = stat(p1, &stat_buf);
+	if (flag == 0)
+	  if (!CHECK_TYPE(stat_buf.st_mode, S_IFREG))
+	    flag = -1;
+#ifndef __EMX__
+	xfree(p1);
+#endif
+	if (flag != 0) {
+	  ErrorF("Warning: 'fonts.dir' not found (or not valid) in \"%s\".\n", 
+		 dir_elem);
+	  ErrorF("          Entry deleted from font path.\n");
+	  ErrorF("          (Run 'mkfontdir' on \"%s\").\n", dir_elem);
+	  continue;
+	}
+      }
+      xfree(dir_elem);
+    }
+
+    /*
+     * Either an OK directory, or a font server name.  So add it to
+     * the path.
+     */
+    if (out_pnt != tmp_path)
+      *out_pnt++ = ',';
+    strcat(out_pnt, path_elem);
+    out_pnt += strlen(path_elem);
+  }
+  return(tmp_path);
+}
+
+/*
+ * xf86GetToken --
+ *      Read next Token form the config file. Handle the global variable
+ *      pushToken.
+ */
+int
+xf86GetToken(tab)
+     SymTabRec tab[];
+{
+  int          c, i;
+
+  /*
+   * First check whether pushToken has a different value than LOCK_TOKEN.
+   * In this case rBuf[] contains a valid STRING/TOKEN/NUMBER. But in the other
+   * case the next token must be read from the input.
+   */
+  if (pushToken == EOF) return(EOF);
+  else if (pushToken == LOCK_TOKEN)
+    {
+      
+      c = configBuf[configPos];
+      
+      /*
+       * Get start of next Token. EOF is handled, whitespaces & comments are
+       * skipped. 
+       */
+      do {
+	if (!c)  {
+	  if (fgets(configBuf,CONFIG_BUF_LEN-1,configFile) == NULL)
+	    {
+	      return( pushToken = EOF );
+	    }
+	  configLineNo++;
+	  configStart = configPos = 0;
+	}
+#ifndef __EMX__
+	while (((c=configBuf[configPos++])==' ') || ( c=='\t') || ( c=='\n'));
+#else
+	while (((c=configBuf[configPos++])==' ') || ( c=='\t') || ( c=='\n') 
+		|| (c=='\r'));
+#endif
+	if (c == '#') c = '\0'; 
+      } while (!c);
+      
+      /* GJA -- handle '-' and ',' 
+       * Be careful: "-hsync" is a keyword.
+       */
+      if ( (c == ',') && !isalpha(configBuf[configPos]) ) {
+         configStart = configPos; return COMMA;
+      } else if ( (c == '-') && !isalpha(configBuf[configPos]) ) {
+         configStart = configPos; return DASH;
+      }
+
+      configStart = configPos;
+      /*
+       * Numbers are returned immediately ...
+       */
+      if (isdigit(c))
+	{
+	  int base;
+
+	  if (c == '0')
+	    if ((configBuf[configPos] == 'x') || 
+		(configBuf[configPos] == 'X'))
+	      base = 16;
+	    else
+	      base = 8;
+	  else
+	    base = 10;
+
+	  configRBuf[0] = c; i = 1;
+	  while (isdigit(c = configBuf[configPos++]) || 
+		 (c == '.') || (c == 'x') || 
+		 ((base == 16) && (((c >= 'a') && (c <= 'f')) ||
+				   ((c >= 'A') && (c <= 'F')))))
+            configRBuf[i++] = c;
+          configPos--; /* GJA -- one too far */
+	  configRBuf[i] = '\0';
+	  val.num = StrToUL(configRBuf);
+          val.realnum = atof(configRBuf);
+	  return(NUMBER);
+	}
+      
+      /*
+       * All Strings START with a \" ...
+       */
+      else if (c == '\"')
+	{
+	  i = -1;
+	  do {
+	    configRBuf[++i] = (c = configBuf[configPos++]);
+#ifndef __EMX__
+	  } while ((c != '\"') && (c != '\n') && (c != '\0'));
+#else
+	  } while ((c != '\"') && (c != '\n') && (c != '\r') && (c != '\0'));
+#endif
+	  configRBuf[i] = '\0';
+	  val.str = (char *)xalloc(strlen(configRBuf) + 1);
+	  strcpy(val.str, configRBuf);      /* private copy ! */
+	  return(STRING);
+	}
+      
+      /*
+       * ... and now we MUST have a valid token.  The search is
+       * handled later along with the pushed tokens.
+       */
+      else
+	{
+          configRBuf[0] = c;
+          i = 0;
+	  do {
+	    configRBuf[++i] = (c = configBuf[configPos++]);;
+#ifndef __EMX__
+	  } while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\0'));
+#else
+	  } while ((c != ' ') && (c != '\t') && (c != '\n') && (c != '\r') && (c != '\0') );
+#endif
+	  configRBuf[i] = '\0'; i=0;
+	}
+      
+    }
+  else
+    {
+    
+      /*
+       * Here we deal with pushed tokens. Reinitialize pushToken again. If
+       * the pushed token was NUMBER || STRING return them again ...
+       */
+      int temp = pushToken;
+      pushToken = LOCK_TOKEN;
+    
+      if (temp == COMMA || temp == DASH) return(temp);
+      if (temp == NUMBER || temp == STRING) return(temp);
+    }
+  
+  /*
+   * Joop, at last we have to lookup the token ...
+   */
+  if (tab)
+    {
+      i = 0;
+      while (tab[i].token != -1)
+	if (StrCaseCmp(configRBuf,tab[i].name) == 0)
+	  return(tab[i].token);
+	else
+	  i++;
+    }
+  
+  return(ERROR_TOKEN);       /* Error catcher */
+}
+
+/*
+ * xf86GetToken --
+ *	Lookup a string if it is actually a token in disguise.
+ */
+static int
+getStringToken(tab)
+     SymTabRec tab[];
+{
+  int i;
+
+  for ( i = 0 ; tab[i].token != -1 ; i++ ) {
+    if ( ! StrCaseCmp(tab[i].name,val.str) ) return tab[i].token;
+  }
+  return(ERROR_TOKEN);
+}
+
+/*
+ * xf86TokenToString --
+ *	returns the string corresponding to token
+ */
+char *
+xf86TokenToString(table, token)
+     SymTabPtr table;
+     int token;
+{
+  int i;
+
+  for (i = 0; table[i].token >= 0 && table[i].token != token; i++)
+    ;
+  if (table[i].token < 0)
+    return("unknown");
+  else
+    return(table[i].name);
+}
+ 
+/*
+ * xf86StringToToken --
+ *	returns the string corresponding to token
+ */
+int
+xf86StringToToken(table, string)
+     SymTabPtr table;
+     char *string;
+{
+  int i;
+
+  for (i = 0; table[i].token >= 0 && StrCaseCmp(string, table[i].name); i++)
+    ;
+  return(table[i].token);
+}
+ 
+/*
+ * xf86ConfigError --
+ *      Print a READABLE ErrorMessage!!!  All information that is 
+ *      interesting is printed.  Even a pointer to the erroneous place is
+ *      printed.  Maybe our e-mail will be less :-)
+ */
+void
+xf86ConfigError(msg)
+     char *msg;
+{
+  int i,j;
+
+  ErrorF( "\nConfig Error: %s:%d\n\n%s", configPath, configLineNo, configBuf);
+  for (i = 1, j = 1; i < configStart; i++, j++) 
+    if (configBuf[i-1] != '\t')
+      ErrorF(" ");
+    else
+      do
+	ErrorF(" ");
+      while (((j++)%8) != 0);
+  for (i = configStart; i <= configPos; i++) ErrorF("^");
+  ErrorF("\n%s\n", msg);
+#ifdef NEED_RETURN_VALUE
+  return RET_ERROR;
+#else
+  exit(-1);                 /* simple exit ... */
+#endif
+}
+
+/*
+ * findConfigFile --
+ * 	Locate the SERVER_CONFIG_FILE file.  Abort if not found.
+ */
+static
+CONFIG_RETURN_TYPE
+findConfigFile(filename, fp)
+      char *filename;
+      FILE **fp;
+{
+#define configFile (*fp)
+#define MAXPTRIES   6
+  char           *home = NULL;
+  char           *xconfig = NULL;
+  char           *xwinhome = NULL;
+  char           *configPaths[MAXPTRIES];
+  int            pcount = 0, idx;
+
+  /*
+   * First open if necessary the config file.
+   * If the -xf86config flag was used, use the name supplied there (root only).
+   * If $XF86CONFIG is a pathname, use it as the name of the config file (root)
+   * If $XF86CONFIG is set but doesn't contain a '/', append it to 'XF86Config'
+   *   and search the standard places (root only).
+   * If $XF86CONFIG is not set, just search the standard places.
+   */
+  while(!configFile) {
+    
+    /*
+     * configPaths[0]			is used as a buffer for -xf86config
+     *					and $XF86CONFIG if it contains a path
+     * configPaths[1...MAXPTRIES-1]	is used to store the paths of each of
+     *					the other attempts
+     */
+    for(pcount = idx = 0; idx < MAXPTRIES; idx++) {
+      configPaths[idx] = NULL;
+    }
+
+    /*
+     * First check if the -xgsconfig option was used.
+     */
+    configPaths[pcount] = (char *)xalloc(PATH_MAX);
+    if(getuid() == 0 && xf86ConfigFile[0]) {
+      strcpy(configPaths[pcount], xf86ConfigFile);
+      if ((configFile = fopen(configPaths[pcount], "r")) != 0) {
+        break;
+      } else {
+        FatalError(
+             "Cannot read file \"%s\" specified by the -xgsconfig flag\n",
+             configPaths[pcount]);
+      }
+    }
+    /*
+     * Check if XCONFIGFILE is set.
+     */
+    if(getuid() == 0 &&
+       (xconfig = getenv(CONFIG_ENV_NAME)) != 0 && index(xconfig, '/')) {
+      strcpy(configPaths[pcount], xconfig);
+      if ((configFile = fopen(configPaths[pcount], "r")) != 0) {
+	break;
+      } else {
+	FatalError("Cannot read file \"%s\" specified by %s variable\n",
+		   configPaths[pcount], XCONFIGFILE);
+      }
+    }
+
+    /*
+     * ~/XCONFIGFILE ...
+     */
+    if(getuid() == 0 && (home = getenv("HOME"))) {
+      configPaths[++pcount] = (char *)xalloc(PATH_MAX);
+      strcpy(configPaths[pcount],home);
+      strcat(configPaths[pcount],"/");
+      strcat(configPaths[pcount],XCONFIGFILE);
+      if(xconfig) {
+	strcat(configPaths[pcount],xconfig);
+      }
+      if((configFile = fopen( configPaths[pcount], "r" )) != 0) {
+	break;
+      }
+    }
+    
+    /*
+     * /etc/XCONFIGFILE
+     */
+    configPaths[++pcount] = (char *)xalloc(PATH_MAX);
+    strcpy(configPaths[pcount], "/etc/");
+    strcat(configPaths[pcount], XCONFIGFILE);
+    if(xconfig) {
+      strcat(configPaths[pcount],xconfig);
+    }
+    if((configFile = fopen( configPaths[pcount], "r" )) != 0) {
+      break;
+    }
+    
+    /*
+     * $(LIBDIR)/SERVER_CONFIG_FILE.<hostname>
+     */
+    configPaths[++pcount] = (char *)xalloc(PATH_MAX);
+    if(getuid() == 0 && (xwinhome = getenv("XWINHOME")) != NULL) {
+      sprintf(configPaths[pcount], "%s/lib/X11/%s",
+	      xwinhome, SERVER_CONFIG_FILE);
+    } else {
+      strcpy(configPaths[pcount], SERVER_CONFIG_FILE);
+    }
+    if(getuid() == 0 && xconfig) {
+      strcat(configPaths[pcount],xconfig);
+    }
+    strcat(configPaths[pcount], ".");
+    gethostname(configPaths[pcount]+strlen(configPaths[pcount]),
+                MAXHOSTNAMELEN);
+    if((configFile = fopen( configPaths[pcount], "r" )) != 0) {
+      break;
+    }
+    
+    /*
+     * $(LIBDIR)/SERVER_CONFIG_FILE
+     */
+    configPaths[++pcount] = (char *)xalloc(PATH_MAX);
+    if(getuid() == 0 && xwinhome) {
+      sprintf(configPaths[pcount], "%s/lib/X11/%s",
+	      xwinhome, XCONFIGFILE);
+    } else {
+      strcpy(configPaths[pcount], SERVER_CONFIG_FILE);
+    }
+    if(getuid() == 0 && xconfig) {
+      strcat(configPaths[pcount],xconfig);
+    }
+
+    if((configFile = fopen( configPaths[pcount], "r" )) != 0) {
+      break;
+    }
+    
+    ErrorF("\nCould not find config file!\n");
+    ErrorF("- Tried:\n");
+    for(idx = 1; idx <= pcount; idx++) {
+      if(configPaths[idx] != NULL) {
+	ErrorF("      %s\n", configPaths[idx]);
+      }
+    }
+    FatalError("No config file found!\n%s", getuid() == 0 ? "" :
+      "Note, the X server no longer looks for XCONFIGFILE in $HOME");
+  }
+  strcpy(filename, configPaths[pcount]);
+  if(xf86Verbose) {
+    ErrorF("%s: %s\n", XCONFIGFILE, filename);
+    ErrorF("%s stands for supplied, %s stands for probed/default values\n",
+	   XCONFIG_GIVEN, XCONFIG_PROBED);
+  }
+  for(idx = 0; idx <= pcount; idx++) {
+    if(configPaths[idx] != NULL) {
+      xfree(configPaths[idx]);
+    }
+  }
+#undef configFile
+#undef MAXPTRIES
+#ifdef NEED_RETURN_VALUE
+  return RET_OKAY;
+#endif
+}
+
+static DisplayModePtr pNew, pLast;
+static Bool graphFound = FALSE;
+
+/*
+ * xf86GetNearestClock --
+ *	Find closest clock to given frequency (in kHz).  This assumes the
+ *	number of clocks is greater than zero.
+ */
+int
+xf86GetNearestClock(Screen, Frequency)
+	ScrnInfoPtr Screen;
+	int Frequency;
+{
+  int NearestClock = 0;
+  int MinimumGap = abs(Frequency - Screen->clock[0]);
+  int i;
+  for (i = 1;  i < Screen->clocks;  i++)
+  {
+    int Gap = abs(Frequency - Screen->clock[i]);
+    if (Gap < MinimumGap)
+    {
+      MinimumGap = Gap;
+      NearestClock = i;
+    }
+  }
+  return NearestClock;
+}
+
+/*
+ * xf86Config --
+ *	Fill some internal structure with userdefined setups. Many internal
+ *      Structs are initialized.  The drivers are selected and initialized.
+ *	if (! vtopen), XF86Config is read, but devices are not probed.
+ *	if (vtopen), devices are probed (and modes resolved).
+ *	The vtopen argument was added so that XF86Config information could be
+ *	made available before the VT is opened.
+ */
+CONFIG_RETURN_TYPE
+xf86Config (vtopen)
+     int vtopen;
+{
+  int            token;
+  int            i, j;
+#if defined(SYSV) || defined(linux)
+  int            xcpipe[2];
+#endif
+#ifdef XINPUT
+  LocalDevicePtr	local;
+#endif
+  
+ if (!vtopen)
+ {
+
+  OFLG_ZERO(&GenericXF86ConfigFlag);
+  configBuf  = (char*)xalloc(CONFIG_BUF_LEN);
+  configRBuf = (char*)xalloc(CONFIG_BUF_LEN);
+  configPath = (char*)xalloc(PATH_MAX);
+  
+  configBuf[0] = '\0';                    /* sanity ... */
+  
+  /*
+   * Read the XF86Config file with the real uid to avoid security problems
+   *
+   * For SYSV we fork, and send the data back to the parent through a pipe
+   */
+#if defined(SYSV) || defined(linux)
+  if (getuid() != 0) {
+    if (pipe(xcpipe))
+      FatalError("Pipe failed (%s)\n", strerror(errno));
+    switch (fork()) {
+      case -1:
+        FatalError("Fork failed (%s)\n", strerror(errno));
+        break;
+      case 0:   /* child */
+        close(xcpipe[0]);
+        setuid(getuid());  
+        HANDLE_RETURN(findConfigFile(configPath, &configFile));
+        {
+          unsigned char pbuf[CONFIG_BUF_LEN];
+          int nbytes;
+
+          /* Pass the filename back as the first line */
+          strcat(configPath, "\n");
+          if (write(xcpipe[1], configPath, strlen(configPath)) < 0)
+            FatalError("Child error writing to pipe (%s)\n", strerror(errno));
+          while ((nbytes = fread(pbuf, 1, CONFIG_BUF_LEN, configFile)) > 0)
+            if (write(xcpipe[1], pbuf, nbytes) < 0)
+              FatalError("Child error writing to pipe (%s)\n", strerror(errno));
+        }
+        close(xcpipe[1]);
+        fclose(configFile);
+        exit(0);
+        break;
+      default: /* parent */
+        close(xcpipe[1]);
+        configFile = (FILE *)fdopen(xcpipe[0], "r");
+        if (fgets(configPath, PATH_MAX, configFile) == NULL)
+          FatalError("Error reading config file\n");
+        configPath[strlen(configPath) - 1] = '\0';
+    }
+  }
+  else {
+    HANDLE_RETURN(findConfigFile(configPath, &configFile));
+  }
+#else /* ! (SYSV || linux) */
+  {
+    int real_uid = getuid();
+
+    if (real_uid) {
+      setruid(0);
+      seteuid(real_uid);
+    }
+
+    HANDLE_RETURN(findConfigFile(configPath, &configFile));
+    if (real_uid) {
+      seteuid(0);
+      setruid(real_uid);
+    }
+  }
+#endif /* SYSV || linux */
+  xf86Info.sharedMonitor = FALSE;
+  xf86Info.kbdProc = NULL;
+  xf86Info.notrapSignals = FALSE;
+  xf86Info.caughtSignal = FALSE;
+
+  /* Allocate mouse device */
+#if defined(XINPUT) && !defined(XF86SETUP)
+  local = mouse_assoc.device_allocate();
+  xf86Info.mouseLocal = (pointer) local;
+  xf86Info.mouseDev = (MouseDevPtr) local->private;
+  xf86Info.mouseDev->mseProc = NULL;
+#else
+  xf86Info.mouseDev = (MouseDevPtr) xcalloc(1, sizeof(MouseDevRec));
+#endif
+  
+  while ((token = xf86GetToken(TopLevelTab)) != EOF) {
+      switch(token) {
+      case SECTION:
+	  if (xf86GetToken(NULL) != STRING)
+	      xf86ConfigError("section name string expected");
+	  if ( StrCaseCmp(val.str, "files") == 0 ) {
+	      HANDLE_RETURN(configFilesSection());
+	  } else if ( StrCaseCmp(val.str, "keyboard") == 0 ) {
+	      HANDLE_RETURN(configKeyboardSection());
+	  } else if ( StrCaseCmp(val.str, "pointer") == 0 ) {
+	      HANDLE_RETURN(configPointerSection(xf86Info.mouseDev, ENDSECTION, NULL));
+	  } else if ( StrCaseCmp(val.str, "screen") == 0 ) {
+	      HANDLE_RETURN(configScreenSection());
+#ifdef XINPUT
+	  } else if ( StrCaseCmp(val.str, "xinput") == 0 ) {
+	      HANDLE_RETURN(xf86ConfigExtendedInputSection(&val));
+#endif
+	  } else {
+	      xf86ConfigError("not a recognized section name");
+	  }
+	  break;
+      }
+  }
+  
+  fclose(configFile);
+  xfree(configBuf);
+  xfree(configRBuf);
+  xfree(configPath);
+
+#if defined(SYSV) || defined(linux)
+  if (getuid() != 0) {
+    /* Wait for the child */
+    wait(NULL);
+  }
+#endif
+  
+  /* Try XF86Config FontPath first */
+  if (!xf86fpFlag)
+    if (fontPath) {
+      char *f = xf86ValidateFontPath(fontPath);
+      if (*f)
+        defaultFontPath = f;
+      else
+        ErrorF(
+        "Warning: FontPath is completely invalid.  Using compiled-in default.\n"
+              );
+      xfree(fontPath);
+      fontPath = (char *)NULL;
+    }
+    else
+      ErrorF("Warning: No FontPath specified, using compiled-in default.\n");
+  else    /* Use fontpath specified with '-fp' */
+  {
+    OFLG_CLR (XCONFIG_FONTPATH, &GenericXF86ConfigFlag);
+    if (fontPath)
+    {
+      xfree(fontPath);
+      fontPath = (char *)NULL;
+    }
+  }
+  if (!fontPath) {
+    /* xf86ValidateFontPath will write into it's arg, but defaultFontPath
+       could be static, so we make a copy. */
+    char *f = (char *)xalloc(strlen(defaultFontPath) + 1);
+    f[0] = '\0';
+    strcpy (f, defaultFontPath);
+    defaultFontPath = xf86ValidateFontPath(f);
+    xfree(f);
+  }
+  else
+    xfree(fontPath);
+
+  /* If defaultFontPath is still empty, exit here */
+
+  if (! *defaultFontPath)
+    FatalError("No valid FontPath could be found\n");
+  if (xf86Verbose)
+    ErrorF("%s FontPath set to \"%s\"\n", 
+      OFLG_ISSET(XCONFIG_FONTPATH, &GenericXF86ConfigFlag) ? XCONFIG_GIVEN :
+      XCONFIG_PROBED, defaultFontPath);
+
+  if (!xf86Info.kbdProc)
+    FatalError("You must specify a keyboard in %s", XCONFIGFILE);
+  if (!xf86Info.mouseDev->mseProc)
+    FatalError("You must specify a mouse in %s", XCONFIGFILE);
+
+ }
+
+  RegisterBlockAndWakeupHandlers( xf86Block, xf86Wakeup, (void *)0 ) ;
+
+#ifdef NEED_RETURN_VALUE
+ return RET_OKAY;
+#endif
+}
+
+static char* prependRoot(char *pathname) 
+{
+#ifndef __EMX__
+	return pathname;
+#else
+	/* XXXX caveat: multiple path components in line */
+	return (char*)__XOS2RedirRoot(pathname);
+#endif
+}
+    
+static CONFIG_RETURN_TYPE
+configFilesSection()
+{
+  int            token;
+  int            i, j;
+  int            k, l;
+  char           *str;
+
+  while ((token = xf86GetToken(FilesTab)) != ENDSECTION) {
+    switch (token) {
+    case FONTPATH:
+      OFLG_SET(XCONFIG_FONTPATH,&GenericXF86ConfigFlag);
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("Font path component expected");
+      }
+      j = FALSE;
+      str = prependRoot(val.str);
+      if(fontPath == NULL) {
+	fontPath = (char *)xalloc(1);
+	fontPath[0] = '\0';
+	i = strlen(str) + 1;
+      } else {
+	i = strlen(fontPath) + strlen(str) + 1;
+	if(fontPath[strlen(fontPath)-1] != ',') {
+	  i++;
+	  j = TRUE;
+	}
+      }
+      fontPath = (char *)xrealloc(fontPath, i);
+      if(j) {
+        strcat(fontPath, ",");
+      }
+
+      strcat(fontPath, str);
+      xfree(val.str);
+      break;
+      
+    case RGBPATH:
+      OFLG_SET(XCONFIG_RGBPATH, &GenericXF86ConfigFlag);
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("RGB path expected");
+      }
+      if(!xf86coFlag) {
+        rgbPath = val.str;
+      }
+      break;
+
+    case EOF:
+      FatalError("Unexpected EOF (missing EndSection?)");
+      break; /* :-) */
+    default:
+      xf86ConfigError("File section keyword expected");
+      break;
+    }
+  }
+#ifdef NEED_RETURN_VALUE
+  return RET_OKAY;
+#endif
+}
+
+
+static CONFIG_RETURN_TYPE
+configKeyboardSection()
+{
+  int            token, ntoken;
+ 
+  /* Initialize defaults */
+  xf86Info.serverNumLock = FALSE;
+  xf86Info.xleds         = 0L;
+  xf86Info.kbdDelay      = 500;
+  xf86Info.kbdRate       = 30;
+  xf86Info.kbdProc       = (DeviceProc)0;
+  xf86Info.vtinit        = NULL;
+  xf86Info.vtSysreq      = VT_SYSREQ_DEFAULT;
+  xf86Info.specialKeyMap = (int *)xalloc((RIGHTCTL - LEFTALT + 1) *
+                                            sizeof(int));
+  xf86Info.specialKeyMap[LEFTALT - LEFTALT] = KM_META;
+  xf86Info.specialKeyMap[RIGHTALT - LEFTALT] = KM_META;
+  xf86Info.specialKeyMap[SCROLLLOCK - LEFTALT] = KM_COMPOSE;
+  xf86Info.specialKeyMap[RIGHTCTL - LEFTALT] = KM_CONTROL;
+#ifdef XKB
+  xf86Info.xkbkeymap   = NULL;
+  xf86Info.xkbtypes    = "default";
+  xf86Info.xkbcompat   = "default";
+  xf86Info.xkbkeycodes = "xfree86";
+  xf86Info.xkbsymbols  = "us(pc101)";
+  xf86Info.xkbgeometry = "pc";
+  xf86Info.xkbcomponents_specified    = False;
+  xf86Info.xkbrules    = "xfree86";
+  xf86Info.xkbmodel    = NULL;
+  xf86Info.xkblayout   = NULL;
+  xf86Info.xkbvariant  = NULL;
+  xf86Info.xkboptions  = NULL;
+#endif
+
+  while((token = xf86GetToken(KeyboardTab)) != ENDSECTION) {
+    switch(token) {
+    case KPROTOCOL:
+      if(xf86GetToken(NULL) != STRING) {
+        xf86ConfigError("Keyboard protocol name expected");
+      }
+      if(StrCaseCmp(val.str,"standard") == 0) {
+         xf86Info.kbdProc    = xf86KbdProc;
+         xf86Info.kbdEvents  = xf86KbdEvents;
+      } else if(StrCaseCmp(val.str,"xqueue") == 0) {
+#ifdef XQUEUE
+        xf86Info.kbdProc = xf86XqueKbdProc;
+        xf86Info.kbdEvents = xf86XqueEvents;
+        xf86Info.mouseDev->xqueSema  = 0;
+        if (xf86Verbose) {
+          ErrorF("%s Xqueue selected for keyboard input\n", XCONFIG_GIVEN);
+	}
+#endif
+      } else {
+        xf86ConfigError("Not a valid keyboard protocol name");
+      }
+      break;
+    case AUTOREPEAT:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Autorepeat delay expected");
+      }
+      xf86Info.kbdDelay = val.num;
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Autorepeat rate expected");
+      }
+      xf86Info.kbdRate = val.num;
+      break;
+    case SERVERNUM:
+      xf86Info.serverNumLock = TRUE;
+      break;
+
+    case XLEDS:
+      while((token= xf86GetToken(NULL)) == NUMBER) {
+	xf86Info.xleds |= 1L << (val.num-1);
+      }
+      pushToken = token;
+      break;
+    case LEFTALT:
+    case RIGHTALT:
+    case SCROLLLOCK:
+    case RIGHTCTL:
+      ntoken = xf86GetToken(KeyMapTab);
+      if((ntoken == EOF) || (ntoken == STRING) || (ntoken == NUMBER)) {
+	xf86ConfigError("KeyMap type token expected");
+      } else {
+	switch(ntoken) {
+	case KM_META:
+	case KM_COMPOSE:
+	case KM_MODESHIFT:
+	case KM_MODELOCK:
+	case KM_SCROLLLOCK:
+	case KM_CONTROL:
+          xf86Info.specialKeyMap[token - LEFTALT] = ntoken;
+	  break;
+	default:
+	  xf86ConfigError("Illegal KeyMap type");
+	  break;
+	}
+      }
+      break;
+    case VTINIT:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("VTInit string expected");
+      }
+      xf86Info.vtinit = val.str;
+      if(xf86Verbose) {
+        ErrorF("%s VTInit: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case VTSYSREQ:
+#ifdef USE_VT_SYSREQ
+      xf86Info.vtSysreq = TRUE;
+      if(xf86Verbose && !VT_SYSREQ_DEFAULT) {
+        ErrorF("%s VTSysReq enabled\n", XCONFIG_GIVEN);
+      }
+#else
+      xf86ConfigError("VTSysReq not supported on this OS");
+#endif
+      break;
+
+#ifdef XKB
+    case XKBDISABLE:
+      noXkbExtension = TRUE;
+      if(xf86Verbose) {
+        ErrorF("%s XKB: disabled\n", XCONFIG_GIVEN);
+      }
+      break;
+
+    case XKBKEYMAP:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBKeymap string expected");
+      }
+      xf86Info.xkbkeymap = val.str;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: keymap: \"%s\" (overrides other XKB settings)\n",
+	       XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBCOMPAT:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBCompat string expected");
+      }
+      xf86Info.xkbcompat = val.str;
+      xf86Info.xkbcomponents_specified = True;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: compat: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBTYPES:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBTypes string expected");
+      }
+      xf86Info.xkbtypes = val.str;
+      xf86Info.xkbcomponents_specified = True;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: types: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBKEYCODES:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBKeycodes string expected");
+      }
+      xf86Info.xkbkeycodes = val.str;
+      xf86Info.xkbcomponents_specified = True;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: keycodes: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBGEOMETRY:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBGeometry string expected");
+      }
+      xf86Info.xkbgeometry = val.str;
+      xf86Info.xkbcomponents_specified = True;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: geometry: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBSYMBOLS:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBSymbols string expected");
+      }
+      xf86Info.xkbsymbols = val.str;
+      xf86Info.xkbcomponents_specified = True;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: symbols: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBRULES:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBRules string expected");
+      }
+      xf86Info.xkbrules = val.str;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: rules: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBMODEL:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBModel string expected");
+      }
+      xf86Info.xkbmodel = val.str;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: model: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBLAYOUT:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBLayout string expected");
+      }
+      xf86Info.xkblayout = val.str;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: layout: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBVARIANT:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBVariant string expected");
+      }
+      xf86Info.xkbvariant = val.str;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: variant: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+
+    case XKBOPTIONS:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("XKBOptions string expected");
+      }
+      xf86Info.xkboptions = val.str;
+      if(xf86Verbose && !XkbInitialMap) {
+        ErrorF("%s XKB: options: \"%s\"\n", XCONFIG_GIVEN, val.str);
+      }
+      break;
+#endif
+
+    case EOF:
+      FatalError("Unexpected EOF (missing EndSection?)");
+      break; /* :-) */
+
+    default:
+      xf86ConfigError("Keyboard section keyword expected");
+      break;
+    }
+  }
+  if(xf86Info.kbdProc == (DeviceProc)0) {
+    xf86ConfigError("No keyboard device given");
+  }
+#ifdef NEED_RETURN_VALUE
+  return RET_OKAY;
+#endif
+}
+      
+static CONFIG_RETURN_TYPE
+configPointerSection(
+  MouseDevPtr	mouse_dev,
+  int		end_tag,
+  char		**devicename) /* used by extended device */
+{
+  int            token;
+  int		 mtoken;
+  int            i;
+  char *mouseType = "unknown";
+
+  /* Set defaults */
+  mouse_dev->baudRate        = 1200;
+  mouse_dev->oldBaudRate     = -1;
+  mouse_dev->sampleRate      = 0;
+  mouse_dev->resolution      = 0;
+  mouse_dev->buttons         = MSE_DFLTBUTTONS;
+  mouse_dev->emulate3Buttons = FALSE;
+  mouse_dev->emulate3Timeout = 50;
+  mouse_dev->chordMiddle     = FALSE;
+  mouse_dev->mouseFlags      = 0;
+  mouse_dev->mseProc         = (DeviceProc)0;
+  mouse_dev->mseDevice       = NULL;
+  mouse_dev->mseType         = -1;
+  mouse_dev->mseModel        = 0;
+  mouse_dev->negativeZ       = 0;
+  mouse_dev->positiveZ       = 0;
+      
+  while((token = xf86GetToken(PointerTab)) != end_tag) {
+    switch (token) {
+
+    case PROTOCOL:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("Mouse name expected");
+      }
+#ifdef XQUEUE
+      if ( StrCaseCmp(val.str,"xqueue") == 0 ) {
+        mouse_dev->mseProc   = xf86XqueMseProc;
+        mouse_dev->mseEvents = (void(*)(MouseDevPtr))xf86XqueEvents;
+        mouse_dev->xqueSema  = 0;
+        if (xf86Verbose)
+          ErrorF("%s Xqueue selected for mouse input\n",
+	         XCONFIG_GIVEN);
+        break;
+      }
+#endif
+
+      mouseType = (char *)strdup(val.str); /* GJA -- should we free this? */
+
+      mtoken = getStringToken(MouseTab); /* Which mouse? */
+      mouse_dev->mseProc    = xf86MseProc;
+      mouse_dev->mseEvents  = xf86MseEvents;
+
+      mouse_dev->mseType    = mtoken - MICROSOFT;
+      if(!xf86MouseSupported(mouse_dev->mseType)) {
+        xf86ConfigError("Mouse type not supported by this OS");
+      }
+      break;
+
+    case PDEVICE:
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("Mouse device expected");
+      }
+      mouse_dev->mseDevice  = val.str;
+      break;
+    case BAUDRATE:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Baudrate expected");
+      }
+      if(mouse_dev->mseType + MICROSOFT == LOGIMAN) {
+	if ((val.num != 1200) && (val.num != 9600))
+	  xf86ConfigError("Only 1200 or 9600 Baud are supported by MouseMan");
+      } else if (val.num%1200 != 0 || val.num < 1200 || val.num > 9600) {
+	xf86ConfigError("Baud rate must be one of 1200, 2400, 4800, or 9600");
+      }
+      mouse_dev->baudRate = val.num;
+      break;
+
+    case SAMPLERATE:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Sample rate expected");
+      }
+      mouse_dev->sampleRate = val.num;
+      break;
+
+    case PRESOLUTION:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Resolution expected");
+      }
+      if(val.num <= 0) {
+	xf86ConfigError("Resolution must be a positive value");
+      }
+      mouse_dev->resolution = val.num;
+      break;
+
+    case EMULATE3:
+      if (mouse_dev->chordMiddle)
+        xf86ConfigError("Can't use Emulate3Buttons with ChordMiddle");
+      mouse_dev->emulate3Buttons = TRUE;
+      break;
+
+    case EM3TIMEOUT:
+      if(xf86GetToken(NULL) != NUMBER) {
+        xf86ConfigError("3 button emulation timeout expected");
+      }
+      mouse_dev->emulate3Timeout = val.num;
+      break;
+
+    case CHORDMIDDLE:
+      if (mouse_dev->mseType + MICROSOFT == MICROSOFT ||
+          mouse_dev->mseType + MICROSOFT == LOGIMAN) {
+        if (mouse_dev->emulate3Buttons) {
+          xf86ConfigError("Can't use ChordMiddle with Emulate3Buttons");
+	}
+        mouse_dev->chordMiddle = TRUE;
+      } else {
+        xf86ConfigError("ChordMiddle is only supported for Microsoft and MouseMan");
+      }
+      break;
+
+    case CLEARDTR:
+      xf86ConfigError("ClearDTR not supported on this OS");
+      break;
+
+    case CLEARRTS:
+      xf86ConfigError("ClearRTS not supported on this OS");
+      break;
+
+    case DEVICE_NAME:
+      if(!devicename) {	/* not called for an extended device */
+	xf86ConfigError("Pointer section keyword expected");
+      }
+
+      if(xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("Option string expected");
+      }
+      *devicename = strdup(val.str);
+      break;
+
+#ifdef XINPUT
+    case ALWAYSCORE:
+      xf86AlwaysCore(mouse_dev->local, TRUE);
+      break;
+#endif
+	
+    case ZAXISMAPPING:
+      switch (xf86GetToken(ZMapTab)) {
+      case NUMBER:
+        if(val.num <= 0 || val.num > MSE_MAXBUTTONS) {
+	  xf86ConfigError("Button number (1..12) expected");
+	}
+        mouse_dev->negativeZ = 1 << (val.num - 1);
+        if(xf86GetToken(NULL) != NUMBER || 
+	   val.num <= 0 || val.num > MSE_MAXBUTTONS) {
+	  xf86ConfigError("Button number (1..12) expected");
+	}
+        mouse_dev->positiveZ = 1 << (val.num - 1);
+        break;
+      case XAXIS:
+        mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOX;
+	break;
+      case YAXIS:
+        mouse_dev->negativeZ = mouse_dev->positiveZ = MSE_MAPTOY;
+	break;
+      default:
+	xf86ConfigError("Button number (1..12), X or Y expected");
+      }
+      break;
+
+    case PBUTTONS:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Number of buttons (1..12) expected");
+      }
+      if(val.num <= 0 || val.num > MSE_MAXBUTTONS) {
+	xf86ConfigError("Number of buttons must be a positive value (1..12)");
+      }
+      mouse_dev->buttons = val.num;
+      break;
+
+    case EOF:
+      FatalError("Unexpected EOF (missing EndSection?)");
+      break; /* :-) */
+      
+    default:
+      xf86ConfigError("Pointer section keyword expected");
+      break;
+    }
+
+  }
+  /* Print log and make sanity checks */
+
+  if(mouse_dev->mseProc == (DeviceProc)0) {
+    xf86ConfigError("No mouse protocol given");
+  }
+  
+  /*
+   * if mseProc is set and mseType isn't, then using Xqueue or OSmouse.
+   * Otherwise, a mouse device is required.
+   */
+  if(mouse_dev->mseType >= 0 && !mouse_dev->mseDevice) {
+    xf86ConfigError("No mouse device given");
+  }
+
+  switch (mouse_dev->negativeZ) {
+  case 0: /* none */
+  case MSE_MAPTOX:
+  case MSE_MAPTOY:
+    break;
+  default: /* buttons */
+    for (i = 0; mouse_dev->negativeZ != (1 << i); ++i)
+      ;
+    if(i + 1 > mouse_dev->buttons) {
+      mouse_dev->buttons = i + 1;
+    }
+    for (i = 0; mouse_dev->positiveZ != (1 << i); ++i)
+      ;
+    if(i + 1 > mouse_dev->buttons) {
+      mouse_dev->buttons = i + 1;
+    }
+    break;
+  }
+
+  if(xf86Verbose && mouse_dev->mseType >= 0)
+  {
+    Bool formatFlag = FALSE;
+    ErrorF("%s Mouse: type: %s, device: %s", 
+	   XCONFIG_GIVEN, mouseType, mouse_dev->mseDevice);
+    if (mouse_dev->mseType != P_BM
+	&& mouse_dev->mseType != P_PS2
+	&& mouse_dev->mseType != P_IMPS2
+	&& mouse_dev->mseType != P_THINKINGPS2
+	&& mouse_dev->mseType != P_MMANPLUSPS2
+	&& mouse_dev->mseType != P_GLIDEPOINTPS2
+	&& mouse_dev->mseType != P_NETPS2
+	&& mouse_dev->mseType != P_NETSCROLLPS2
+	&& mouse_dev->mseType != P_SYSMOUSE) {
+      formatFlag = TRUE;
+      ErrorF(", baudrate: %d", mouse_dev->baudRate);
+    }
+    if(mouse_dev->sampleRate) {
+      ErrorF(formatFlag ? "\n%s Mouse: samplerate: %d" : "%ssamplerate: %d", 
+	     formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->sampleRate);
+      formatFlag = !formatFlag;
+    }
+    if(mouse_dev->resolution) {
+      ErrorF(formatFlag ? "\n%s Mouse: resolution: %d" : "%sresolution: %d", 
+	     formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->resolution);
+      formatFlag = !formatFlag;
+    }
+    ErrorF(formatFlag ? "\n%s Mouse: buttons: %d" : "%sbuttons: %d",
+	   formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->buttons);
+    formatFlag = !formatFlag;
+    if(mouse_dev->emulate3Buttons) {
+      ErrorF(formatFlag ? "\n%s Mouse: 3 button emulation (timeout: %dms)" :
+	                  "%s3 button emulation (timeout: %dms)",
+             formatFlag ? XCONFIG_GIVEN : ", ", mouse_dev->emulate3Timeout);
+      formatFlag = !formatFlag;
+    }
+    if(mouse_dev->chordMiddle) {
+      ErrorF(formatFlag ? "\n%s Mouse: Chorded middle button" : 
+                          "%sChorded middle button",
+             formatFlag ? XCONFIG_GIVEN : ", ");
+    }
+    ErrorF("\n");
+
+    switch (mouse_dev->negativeZ) {
+    case 0: /* none */
+      break;
+    case MSE_MAPTOX:
+      ErrorF("%s Mouse: zaxismapping: X\n", XCONFIG_GIVEN);
+      break;
+    case MSE_MAPTOY:
+      ErrorF("%s Mouse: zaxismapping: Y\n", XCONFIG_GIVEN);
+      break;
+    default: /* buttons */
+      for (i = 0; mouse_dev->negativeZ != (1 << i); ++i)
+	;
+      ErrorF("%s Mouse: zaxismapping: (-)%d", XCONFIG_GIVEN, i + 1);
+      for (i = 0; mouse_dev->positiveZ != (1 << i); ++i)
+	;
+      ErrorF(" (+)%d\n", i + 1);
+      break;
+    }
+  }
+#ifdef NEED_RETURN_VALUE
+  return RET_OKAY;
+#endif
+}
+      
+
+
+static CONFIG_RETURN_TYPE
+configScreenSection()
+{
+  int i, j;
+  int driverno;
+  int had_monitor = 0, had_device = 0;
+  int dispIndex = 0;
+  int numDisps = 0;
+  DispPtr dispList = NULL;
+  DispPtr dispp;
+  int depth = 0;
+  int screenno = 0;
+  int scrn_width = 0, scrn_height = 0;
+  int framerate = 0;
+      
+  int token;
+  ScrnInfoPtr screen = NULL;
+  int textClockValue = -1;
+
+  token = xf86GetToken(ScreenTab);
+  if(token != DRIVER) {
+    xf86ConfigError("The screen section must begin with the 'driver' line");
+  }
+  if(xf86GetToken(NULL) != STRING) {
+    xf86ConfigError("Driver name expected");
+  }
+  driverno = getStringToken(DriverTab);
+  switch(driverno) {
+  case GS:
+    break;
+  default:
+    xf86ConfigError("Not a recognized driver name");
+  }
+
+  while((token = xf86GetToken(ScreenTab)) != ENDSECTION) {
+    switch(token) {
+    case DEFBPP:
+      if (xf86GetToken(NULL) != NUMBER) {
+        xf86ConfigError("Default color depth expected");
+      }
+      depth = val.num;
+      break;
+
+    case SCREENNO:
+      if (xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Screen number expected");
+      }
+      screenno = val.num;
+      break;
+
+    case SUBSECTION:
+      if((xf86GetToken(NULL) != STRING) ||
+	 (StrCaseCmp(val.str, "display") != 0)) {
+        xf86ConfigError("You must say \"Display\" here");
+      }
+      if (dispList == NULL) {
+        dispList = (DispPtr)xalloc(sizeof(DispRec));
+      } else {
+        dispList = (DispPtr)xrealloc(dispList,
+				     (numDisps + 1) * sizeof(DispRec));
+      }
+      dispp = dispList + numDisps;
+      numDisps++;
+      dispp->depth = -1;
+      dispp->modes = NULL;
+      dispp->defaultVisual = -1;
+
+      configDisplaySubsection(dispp);
+      break;
+
+    case EOF:
+      FatalError("Unexpected EOF (missing EndSection?)");
+      break; /* :-) */
+
+    case MDEVICE:
+      if (xf86GetToken(NULL) != STRING) {
+	xf86ConfigError("Device name expected");
+      }
+      break;
+    case STANDBYTIME:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Screensaver standby time expected");
+      }
+#ifdef DPMSExtension
+      defaultDPMSStandbyTime = DPMSStandbyTime = val.num * MILLI_PER_MIN;
+#endif
+      break;
+
+    case SUSPENDTIME:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Screensaver suspend time expected");
+      }
+#ifdef DPMSExtension
+        defaultDPMSSuspendTime = DPMSSuspendTime = val.num * MILLI_PER_MIN;
+#endif
+      break;
+
+    case OFFTIME:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("Screensaver off time expected");
+      }
+#ifdef DPMSExtension
+      defaultDPMSOffTime = DPMSOffTime = val.num * MILLI_PER_MIN;
+#endif
+      break;
+    case FRAMERATE:
+      if(xf86GetToken(NULL) != NUMBER) {
+	xf86ConfigError("FrameRate is 60Hz or 75Hz");
+      }
+      framerate = val.num;
+      break;
+
+    default:
+      xf86ConfigError("Screen section keyword expected");
+      break;
+    }
+  }
+
+  if(dispList == NULL) {
+    FatalError(
+	"A \"Display\" subsection is required in each \"Screen\" section\n");
+  }
+
+  if (xf86bpp < 0) { 
+    if (numDisps == 1) {
+      if(dispList[0].depth > 0) {
+	depth = dispList[0].depth;
+      }
+      dispIndex = 0;
+    } else {
+      /* Look for a section which matches the driver's default depth */
+      for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
+	if (dispList[dispIndex].depth == depth)
+	  break;
+      }
+      if (dispIndex == numDisps) {
+	/* No match.  This time, allow 15/16 and 24/32 to match */
+	for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
+	  if ((depth == 15 && dispList[dispIndex].depth == 16) ||
+	      (depth == 16 && dispList[dispIndex].depth == 15) ||
+	      (depth == 24 && dispList[dispIndex].depth == 32) ||
+	      (depth == 32 && dispList[dispIndex].depth == 24))
+	    break;
+	}
+      }
+      if (dispIndex == numDisps) {
+	/* Still no match, so exit */
+	FatalError("No \"Display\" subsection for default depth %d\n",
+		   depth);
+      }
+    }
+  } else {
+#if 0	/* enable command line option */
+    /* xf86bpp is set */
+    if (numDisps == 1 && dispList[0].depth < 0) {
+      dispIndex = 0;
+    } else {
+      /* find Display subsection matching xf86bpp */
+      for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
+	if (dispList[dispIndex].depth == xf86bpp)
+	  break;
+      }
+      if (dispIndex == numDisps) {
+	/* No match.  This time, allow 15/16 and 24/32 to match */
+	for (dispIndex = 0; dispIndex < numDisps; dispIndex++) {
+	  if ((xf86bpp == 15 && dispList[dispIndex].depth == 16) ||
+	      (xf86bpp == 16 && dispList[dispIndex].depth == 15) ||
+	      (xf86bpp == 24 && dispList[dispIndex].depth == 32) ||
+	      (xf86bpp == 32 && dispList[dispIndex].depth == 24))
+	    break;
+	}
+      }
+    }
+#endif
+  }
+
+  /* Now copy the info across to the screen rec */
+  dispp = dispList + dispIndex;
+  if(xf86bpp <= 0) {	/* xf86bpp > 0 is enable command line option */
+    if (dispp->depth > 0) {
+      depth = dispp->depth;
+    }
+    if(sscanf(dispp->modes->name, "%dx%d", &scrn_width, &scrn_height) != 2) {
+      FatalError("A \"Display\" subsection: Illegale Modes Format");
+    }
+    if(checkResolution(scrn_width, scrn_height)<0) {
+      FatalError("Can't Support Resolution");
+    }
+    SetGSXScreen(screenno, scrn_width, scrn_height, depth);
+  }
+
+  if(framerate > 0) {
+    SetGSXFrameRate(screenno, framerate);
+  }
+  /* Don't need them any more */
+  xfree(dispList);
+
+#ifdef NEED_RETURN_VALUE
+    return RET_OKAY;
+#endif
+}
+
+static CONFIG_RETURN_TYPE
+configDisplaySubsection(disp)
+DispPtr disp;
+{
+  int token;
+  int i;
+
+  while ((token = xf86GetToken(DisplayTab)) != ENDSUBSECTION) {
+    switch (token) {
+    case DEPTH:
+      if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("Display depth expected");
+      disp->depth = val.num;
+      break;
+
+    case MODES:
+      for (pLast=NULL; (token = xf86GetToken(NULL)) == STRING; pLast = pNew)
+	{
+	  pNew = (DisplayModePtr)xalloc(sizeof(DisplayModeRec));
+	  pNew->name = val.str;
+	  pNew->PrivSize = 0;
+	  pNew->Private = NULL;
+
+	  if (pLast) 
+	    {
+	      pLast->next = pNew;
+	      pNew->prev  = pLast;
+	    }
+	  else
+	    disp->modes = pNew;
+	}
+      /* Make sure at least one mode was present */
+      if (!pLast)
+	 xf86ConfigError("Mode name expected");
+      pNew->next = disp->modes;
+      disp->modes->prev = pLast;
+      pushToken = token;
+      break;
+
+    case BLACK:
+    case WHITE:
+      {
+        unsigned char rgb[3];
+        int ii;
+        
+        for (ii = 0; ii < 3; ii++)
+        {
+          if (xf86GetToken(NULL) != NUMBER) xf86ConfigError("RGB value expected");
+          rgb[ii] = val.num & 0x3F;
+        }
+        if (token == BLACK)
+        {
+          disp->blackColour.red = rgb[0];
+          disp->blackColour.green = rgb[1];
+          disp->blackColour.blue = rgb[2];
+        }
+        else
+        {
+          disp->whiteColour.red = rgb[0];
+          disp->whiteColour.green = rgb[1];
+          disp->whiteColour.blue = rgb[2];
+        }
+      }
+      break;
+
+    case EOF:
+      FatalError("Unexpected EOF (missing EndSubSection)");
+      break; /* :-) */
+
+    default:
+      xf86ConfigError("Display subsection keyword expected");
+      break;
+    }
+  }
+#ifdef NEED_RETURN_VALUE
+  return RET_OKAY;
+#endif
+}
+
+/* Note: (To keep me [GJA] from getting confused)
+ * We have two mode-related datastructures:
+ * 1. A doubly linked mode name list, with ends marked by self-pointers.
+ * 2. A doubly linked mode structure list.
+ * We are operating here on the second structure.
+ * Initially this is just singly linked.
+ */
+static DisplayModePtr
+xf86PruneModes(monp, allmodes, scrp, card)
+     MonPtr monp;		/* Monitor specification */
+     DisplayModePtr allmodes;	/* List to be pruned */
+     ScrnInfoPtr scrp;
+     Bool card;			/* TRUE => do driver validity check */
+{
+	DisplayModePtr dispmp;	/* To walk the list */
+	DisplayModePtr olddispmp; /* The one being freed. */
+	DisplayModePtr remainder; /* The first one retained. */
+
+	dispmp = allmodes;
+
+	/* The first modes to be deleted require that the pointer to the
+	 * mode list is updated. Also, they have no predecessor in the list.
+	 */
+	while (dispmp &&
+	       (card ?
+		 ((scrp->ValidMode)(dispmp, xf86Verbose, MODE_SUGGESTED) 
+		 	!= MODE_OK) :
+		 (xf86CheckMode(scrp, dispmp, monp, xf86Verbose) != MODE_OK))) {
+		olddispmp = dispmp;
+		dispmp = dispmp->next;
+		xfree(olddispmp->name);
+		xfree(olddispmp);
+	}
+	/* Now we either have a mode that fits, or no mode at all */
+	if ( ! dispmp ) { /* No mode at all */
+		return NULL;
+	}
+	remainder = dispmp;
+	while ( dispmp->next ) {
+		if (card ?
+		     ((scrp->ValidMode)(dispmp->next,xf86Verbose,MODE_SUGGESTED)
+		     		!= MODE_OK) :
+		     (xf86CheckMode(scrp, dispmp->next, monp, xf86Verbose) !=
+                      MODE_OK)) {
+			olddispmp = dispmp->next;
+			dispmp->next = dispmp->next->next;
+			xfree(olddispmp->name);
+			xfree(olddispmp);
+		} else {
+			dispmp = dispmp->next;
+		}
+	}
+	return remainder; /* Return pointer to {the first / the list } */
+}
+
+/*
+ * Return MODE_OK if the mode pointed to by dispmp agrees with all constraints
+ * we can make up for the monitor pointed to by monp.
+ */
+int
+xf86CheckMode(scrp, dispmp, monp, verbose)
+     ScrnInfoPtr scrp;
+     DisplayModePtr dispmp;
+     MonPtr monp;
+     Bool verbose;
+{
+	int i;
+	float dotclock, hsyncfreq, vrefreshrate;
+	char *scrname = scrp->name;
+
+	/* Sanity checks */
+	if ((0 >= dispmp->HDisplay) ||
+	    (dispmp->HDisplay > dispmp->HSyncStart) ||
+	    (dispmp->HSyncStart >= dispmp->HSyncEnd) ||
+	    (dispmp->HSyncEnd >= dispmp->HTotal))
+	{
+		ErrorF(
+                  "%s %s: Invalid horizontal timing for mode \"%s\". Deleted.\n",
+		  XCONFIG_PROBED, scrname, dispmp->name);
+		return MODE_HSYNC;
+	}
+
+	if ((0 >= dispmp->VDisplay) ||
+	    (dispmp->VDisplay > dispmp->VSyncStart) ||
+	    (dispmp->VSyncStart >= dispmp->VSyncEnd) ||
+	    (dispmp->VSyncEnd >= dispmp->VTotal))
+	{
+		ErrorF(
+		  "%s %s: Invalid vertical timing for mode \"%s\". Deleted.\n",
+		  XCONFIG_PROBED, scrname, dispmp->name);
+		return MODE_VSYNC;
+	}
+
+	/* Deal with the dispmp->Clock being a frequency or index */
+	if (dispmp->Clock > MAXCLOCKS) {
+		dotclock = (float)dispmp->Clock;
+	} else {
+		dotclock = (float)scrp->clock[dispmp->Clock];
+	}
+	hsyncfreq = dotclock / (float)(dispmp->HTotal);
+	for ( i = 0 ; i < monp->n_hsync ; i++ )
+		if ( (hsyncfreq > 0.999 * monp->hsync[i].lo) &&
+		     (hsyncfreq < 1.001 * monp->hsync[i].hi) )
+			break; /* In range. */
+
+	/* Now see whether we ran out of sync frequencies */
+	if ( i == monp->n_hsync ) {
+	    if (verbose) {
+		ErrorF(
+		  "%s %s: Mode \"%s\" needs hsync freq of %.2f kHz. Deleted.\n",
+		  XCONFIG_PROBED, scrname, dispmp->name, hsyncfreq);
+	    }
+	    return MODE_HSYNC;
+	}
+			
+	vrefreshrate = dotclock * 1000.0 /
+			((float)(dispmp->HTotal) * (float)(dispmp->VTotal)) ;
+	if ( dispmp->Flags & V_INTERLACE ) vrefreshrate *= 2.0;
+	if ( dispmp->Flags & V_DBLSCAN ) vrefreshrate /= 2.0;
+	for ( i = 0 ; i < monp->n_vrefresh ; i++ )
+		if ( (vrefreshrate > 0.999 * monp->vrefresh[i].lo) &&
+		     (vrefreshrate < 1.001 * monp->vrefresh[i].hi) )
+			break; /* In range. */
+
+	/* Now see whether we ran out of refresh rates */
+	if ( i == monp->n_vrefresh ) {
+	    if (verbose) {
+		ErrorF(
+		  "%s %s: Mode \"%s\" needs vert refresh rate of %.2f Hz. Deleted.\n",
+		  XCONFIG_PROBED, scrname, dispmp->name, vrefreshrate);
+	    }
+	    return MODE_VSYNC;
+	}
+
+	/* Interlaced modes should have an odd VTotal */
+	if (dispmp->Flags & V_INTERLACE)
+	    dispmp->CrtcVTotal = dispmp->VTotal |= 1;
+
+	/* Passed every test. */
+	return MODE_OK;
+}
+
+
+/* Note, the characters '_', ' ', and '\t' are ignored in the comparison */
+int
+StrCaseCmp(s1, s2)
+     const char *s1, *s2;
+{
+  char c1, c2;
+
+  if (*s1 == 0)
+    if (*s2 == 0)
+      return(0);
+    else
+      return(1);
+  while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+    s1++;
+  while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+    s2++;
+  c1 = (isupper(*s1) ? tolower(*s1) : *s1);
+  c2 = (isupper(*s2) ? tolower(*s2) : *s2);
+  while (c1 == c2)
+    {
+      if (c1 == '\0')
+	return(0);
+      s1++; s2++;
+      while (*s1 == '_' || *s1 == ' ' || *s1 == '\t')
+	s1++;
+      while (*s2 == '_' || *s2 == ' ' || *s2 == '\t')
+	s2++;
+      c1 = (isupper(*s1) ? tolower(*s1) : *s1);
+      c2 = (isupper(*s2) ? tolower(*s2) : *s2);
+    }
+  return(c1 - c2);
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Events.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Events.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Events.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Events.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,1157 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Events.c,v 3.42.2.6 1998/11/06 09:46:25 hohndel Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86Events.c /main/46 1996/10/25 11:36:30 kaleb $ */
+
+/* [JCH-96/01/21] Extended std reverse map to four buttons. */
+
+#include <math.h>
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "Xpoll.h"
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86_Config.h"
+#include "atKeynames.h"
+
+
+
+#include "mipointer.h"
+#include "dixevents.h"
+#include "opaque.h"
+#ifdef DPMSExtension
+#include "extensions/dpms.h"
+#endif
+
+
+#define XE_POINTER  1
+#define XE_KEYBOARD 2
+
+#ifdef XTESTEXT1
+
+#define	XTestSERVER_SIDE
+#include "xtestext1.h"
+extern short xtest_mousex;
+extern short xtest_mousey;
+extern int   on_steal_input;          
+extern Bool  XTestStealKeyData();
+extern void  XTestStealMotionData();
+
+#define ENQUEUE(ev, code, direction, dev_type) \
+  (ev)->u.u.detail = (code); \
+  (ev)->u.u.type   = (direction); \
+  if (!on_steal_input ||  \
+      XTestStealKeyData((ev)->u.u.detail, (ev)->u.u.type, dev_type, \
+			xtest_mousex, xtest_mousey)) \
+  mieqEnqueue((ev))
+
+#define MOVEPOINTER(dx, dy, time) \
+  if (on_steal_input) \
+    XTestStealMotionData(dx, dy, XE_POINTER, xtest_mousex, xtest_mousey); \
+  miPointerDeltaCursor (dx, dy, time)
+
+#else /* ! XTESTEXT1 */
+
+#define ENQUEUE(ev, code, direction, dev_type) \
+  (ev)->u.u.detail = (code); \
+  (ev)->u.u.type   = (direction); \
+  mieqEnqueue((ev))
+#define MOVEPOINTER(dx, dy, time) \
+  miPointerDeltaCursor (dx, dy, time)
+
+#endif
+
+Bool xf86VTSema = TRUE;
+
+/*
+ * The first of many hack's to get VT switching to work under
+ * Solaris 2.1 for x86. The basic problem is that Solaris is supposed
+ * to be SVR4. It is for the most part, except where the video interface
+ * is concerned.  These hacks work around those problems.
+ * See the comments for Linux, and SCO. 
+ *
+ * This is a toggleling variable:
+ *  FALSE = No VT switching keys have been pressed last time around
+ *  TRUE  = Possible VT switch Pending
+ * (DWH - 12/2/93)
+ *
+ * This has been generalised to work with Linux and *BSD+syscons (DHD)
+ */
+
+#ifdef USE_VT_SYSREQ
+static Bool VTSysreqToggle = FALSE;
+#endif /* !USE_VT_SYSREQ */
+static Bool VTSwitchEnabled = TRUE;   /* Allows run-time disabling for *BSD */
+
+extern fd_set EnabledDevices;
+
+#if defined(CODRV_SUPPORT)
+extern unsigned char xf86CodrvMap[];
+#endif
+
+#if defined(XQUEUE) && !defined(XQUEUE_ASYNC)
+extern void xf86XqueRequest(
+#if NeedFunctionPrototypes
+	void
+#endif
+	);
+#endif
+
+static void xf86VTSwitch(
+#if NeedFunctionPrototypes
+        void
+#endif
+        );
+
+static CARD32 buttonTimer(
+#if NeedFunctionPrototypes
+	OsTimerPtr timer,
+	CARD32 now,
+	pointer arg
+#endif
+     	);
+
+/*
+ * Lets create a simple finite-state machine:
+ *
+ *   state[?][0]: action1
+ *   state[?][1]: action2
+ *   state[?][2]: next state
+ *
+ *   action > 0: ButtonPress
+ *   action = 0: nothing
+ *   action < 0: ButtonRelease
+ *
+ * Why this stuff ??? Normally you cannot press both mousebuttons together, so
+ * the mouse reports both pressed at the same time ...
+ */
+
+static signed char stateTab[48][3] = {
+
+/* nothing pressed */
+  {  0,  0,  0 },	
+  {  0,  0,  8 },	/* 1 right -> delayed right */
+  {  0,  0,  0 },       /* 2 nothing */
+  {  0,  0,  8 },	/* 3 right -> delayed right */
+  {  0,  0, 16 },	/* 4 left -> delayed left */
+  {  2,  0, 24 },       /* 5 left & right (middle press) -> middle pressed */
+  {  0,  0, 16 },	/* 6 left -> delayed left */
+  {  2,  0, 24 },       /* 7 left & right (middle press) -> middle pressed */
+
+/* delayed right */
+  {  1, -1,  0 },	/* 8 nothing (right event) -> init */
+  {  1,  0, 32 },       /* 9 right (right press) -> right pressed */
+  {  1, -1,  0 },	/* 10 nothing (right event) -> init */
+  {  1,  0, 32 },       /* 11 right (right press) -> right pressed */
+  {  1, -1, 16 },       /* 12 left (right event) -> delayed left */
+  {  2,  0, 24 },       /* 13 left & right (middle press) -> middle pressed */
+  {  1, -1, 16 },       /* 14 left (right event) -> delayed left */
+  {  2,  0, 24 },       /* 15 left & right (middle press) -> middle pressed */
+
+/* delayed left */
+  {  3, -3,  0 },	/* 16 nothing (left event) -> init */
+  {  3, -3,  8 },       /* 17 right (left event) -> delayed right */
+  {  3, -3,  0 },	/* 18 nothing (left event) -> init */
+  {  3, -3,  8 },       /* 19 right (left event) -> delayed right */
+  {  3,  0, 40 },	/* 20 left (left press) -> pressed left */
+  {  2,  0, 24 },	/* 21 left & right (middle press) -> pressed middle */
+  {  3,  0, 40 },	/* 22 left (left press) -> pressed left */
+  {  2,  0, 24 },	/* 23 left & right (middle press) -> pressed middle */
+
+/* pressed middle */
+  { -2,  0,  0 },	/* 24 nothing (middle release) -> init */
+  { -2,  0,  0 },	/* 25 right (middle release) -> init */
+  { -2,  0,  0 },	/* 26 nothing (middle release) -> init */
+  { -2,  0,  0 },	/* 27 right (middle release) -> init */
+  { -2,  0,  0 },	/* 28 left (middle release) -> init */
+  {  0,  0, 24 },	/* 29 left & right -> pressed middle */
+  { -2,  0,  0 },	/* 30 left (middle release) -> init */
+  {  0,  0, 24 },	/* 31 left & right -> pressed middle */
+
+/* pressed right */
+  { -1,  0,  0 },	/* 32 nothing (right release) -> init */
+  {  0,  0, 32 },	/* 33 right -> pressed right */
+  { -1,  0,  0 },	/* 34 nothing (right release) -> init */
+  {  0,  0, 32 },	/* 35 right -> pressed right */
+  { -1,  0, 16 },	/* 36 left (right release) -> delayed left */
+  { -1,  2, 24 },	/* 37 left & right (r rel, m prs) -> middle pressed */
+  { -1,  0, 16 },	/* 38 left (right release) -> delayed left */
+  { -1,  2, 24 },	/* 39 left & right (r rel, m prs) -> middle pressed */
+
+/* pressed left */
+  { -3,  0,  0 },	/* 40 nothing (left release) -> init */
+  { -3,  0,  8 },	/* 41 right (left release) -> delayed right */
+  { -3,  0,  0 },	/* 42 nothing (left release) -> init */
+  { -3,  0,  8 },	/* 43 right (left release) -> delayed right */
+  {  0,  0, 40 },	/* 44 left -> left pressed */
+  { -3,  2, 24 },	/* 45 left & right (l rel, mprs) -> middle pressed */
+  {  0,  0, 40 },	/* 46 left -> left pressed */
+  { -3,  2, 24 },	/* 47 left & right (l rel, mprs) -> middle pressed */
+};
+
+
+/*
+ * Table to allow quick reversal of natural button mapping to correct mapping
+ */
+
+/*
+ * [JCH-96/01/21] The ALPS GlidePoint pad extends the MS protocol
+ * with a fourth button activated by tapping the PAD.
+ * The 2nd line corresponds to 4th button on; the drv sends
+ * the buttons in the following map (MSBit described first) :
+ * 0 | 4th | 1st | 2nd | 3rd
+ * And we remap them (MSBit described first) :
+ * 0 | 4th | 3rd | 2nd | 1st
+ */
+static char reverseMap[32] = { 0,  4,  2,  6,  1,  5,  3,  7,
+			       8, 12, 10, 14,  9, 13, 11, 15,
+			      16, 20, 18, 22, 17, 21, 19, 23,
+			      24, 28, 26, 30, 25, 29, 27, 31};
+
+
+static char hitachMap[16] = {  0,  2,  1,  3, 
+			       8, 10,  9, 11,
+			       4,  6,  5,  7,
+			      12, 14, 13, 15 };
+
+
+/*
+ * TimeSinceLastInputEvent --
+ *      Function used for screensaver purposes by the os module. Retruns the
+ *      time in milliseconds since there last was any input.
+ */
+
+int
+TimeSinceLastInputEvent()
+{
+  if (xf86Info.lastEventTime == 0) {
+    xf86Info.lastEventTime = GetTimeInMillis();
+  }
+  return GetTimeInMillis() - xf86Info.lastEventTime;
+}
+
+
+
+/*
+ * SetTimeSinceLastInputEvent --
+ *      Set the lastEventTime to now.
+ */
+
+void
+SetTimeSinceLastInputEvent()
+{
+  xf86Info.lastEventTime = GetTimeInMillis();
+}
+
+
+
+/*
+ * ProcessInputEvents --
+ *      Retrieve all waiting input events and pass them to DIX in their
+ *      correct chronological order. Only reads from the system pointer
+ *      and keyboard.
+ */
+
+void
+ProcessInputEvents ()
+{
+  int x, y;
+#ifdef INHERIT_LOCK_STATE
+  static int generation = 0;
+#endif
+
+#ifdef AMOEBA
+#define MAXEVENTS	    32
+#define BUTTON_PRESS	    0x1000
+#define MAP_BUTTON(ev,but)  (((ev) == EV_ButtonPress) ? \
+			     ((but) | BUTTON_PRESS) : ((but) & ~BUTTON_PRESS))
+#define KEY_RELEASE	    0x80
+#define MAP_KEY(ev, key)    (((ev) == EV_KeyReleaseEvent) ? \
+			     ((key) | KEY_RELEASE) : ((key) & ~KEY_RELEASE))
+
+    register IOPEvent  *e, *elast;
+    IOPEvent		events[MAXEVENTS];
+    int			dx, dy, nevents;
+#endif
+
+    /*
+     * With INHERIT_LOCK_STATE defined, the initial state of CapsLock, NumLock
+     * and ScrollLock will be set to match that of the VT the server is
+     * running on.
+     */
+#ifdef INHERIT_LOCK_STATE
+    if (generation != serverGeneration) {
+      xEvent kevent;
+      DevicePtr pKeyboard = xf86Info.pKeyboard;
+      extern unsigned int xf86InitialCaps, xf86InitialNum, xf86InitialScroll;
+
+      generation = serverGeneration;
+      kevent.u.keyButtonPointer.time = GetTimeInMillis();
+      kevent.u.keyButtonPointer.rootX = 0;
+      kevent.u.keyButtonPointer.rootY = 0;
+      kevent.u.u.type = KeyPress;
+
+
+      if (xf86InitialCaps) {
+        kevent.u.u.detail = xf86InitialCaps;
+        (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1);
+        xf86InitialCaps = 0;
+      }
+      if (xf86InitialNum) {
+        kevent.u.u.detail = xf86InitialNum;
+        (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1);
+        xf86InitialNum = 0;
+      }
+      if (xf86InitialScroll) {
+        kevent.u.u.detail = xf86InitialScroll;
+        (* pKeyboard->processInputProc)(&kevent, (DeviceIntPtr)pKeyboard, 1);
+        xf86InitialScroll = 0;
+      }
+    }
+#endif
+
+  xf86Info.inputPending = FALSE;
+
+  mieqProcessInputEvents();
+  miPointerUpdate();
+
+  miPointerPosition(&x, &y);
+}
+
+
+
+/*
+ * xf86PostKbdEvent --
+ *	Translate the raw hardware KbdEvent into an XEvent, and tell DIX
+ *	about it. Scancode preprocessing and so on is done ...
+ *
+ *  OS/2 specific xf86PostKbdEvent(key) has been moved to os-support/os2/os2_kbd.c
+ *  as some things differ, and I did not want to scatter this routine with
+ *  ifdefs further (hv).
+ */
+
+#ifdef ASSUME_CUSTOM_KEYCODES
+extern u_char SpecialServerMap[];
+#endif /* ASSUME_CUSTOM_KEYCODES */
+
+#if !defined(__EMX__)
+void
+xf86PostKbdEvent(key)
+     unsigned key;
+{
+  int         scanCode = (key & 0x7f);
+  int         specialkey;
+  Bool        down = (key & 0x80 ? FALSE : TRUE);
+  KeyClassRec *keyc = ((DeviceIntPtr)xf86Info.pKeyboard)->key;
+  Bool        updateLeds = FALSE;
+  Bool        UsePrefix = FALSE;
+  Bool        Direction = FALSE;
+  xEvent      kevent;
+  KeySym      *keysym;
+  int         keycode;
+  static int  lockkeys = 0;
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+  static Bool first_time = TRUE;
+#endif
+
+#if defined(CODRV_SUPPORT)
+  if (xf86Info.consType == CODRV011 || xf86Info.consType == CODRV01X)
+    scanCode = xf86CodrvMap[scanCode];
+#endif
+
+#if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+  if (first_time)
+  {
+    first_time = FALSE;
+    VTSwitchEnabled = (xf86Info.consType == SYSCONS)
+	    || (xf86Info.consType == PCVT);
+  }
+#endif
+
+#ifndef ASSUME_CUSTOM_KEYCODES
+  /*
+   * First do some special scancode remapping ...
+   */
+  if (xf86Info.scanPrefix == 0) {
+
+    switch (scanCode) {
+      
+    case KEY_Prefix0:
+    case KEY_Prefix1:
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+      if (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
+	  || xf86Info.consType == PCVT) {
+#endif
+        xf86Info.scanPrefix = scanCode;  /* special prefixes */
+        return;
+#if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+      }
+      break;
+#endif
+    }
+    if (xf86Info.serverNumLock) {
+     if ((!xf86Info.numLock && ModifierDown(ShiftMask)) ||
+         (xf86Info.numLock && !ModifierDown(ShiftMask))) {
+      /*
+       * Hardwired numlock handling ... (Some applications break if they have
+       * these keys double defined, like twm)
+       */
+      switch (scanCode) {
+      case KEY_KP_7:        scanCode = KEY_SN_KP_7;   break;  /* curs 7 */
+      case KEY_KP_8:        scanCode = KEY_SN_KP_8;   break;  /* curs 8 */
+      case KEY_KP_9:        scanCode = KEY_SN_KP_9;   break;  /* curs 9 */
+      case KEY_KP_4:        scanCode = KEY_SN_KP_4;   break;  /* curs 4 */
+      case KEY_KP_5:        scanCode = KEY_SN_KP_5;   break;  /* curs 5 */
+      case KEY_KP_6:        scanCode = KEY_SN_KP_6;   break;  /* curs 6 */
+      case KEY_KP_1:        scanCode = KEY_SN_KP_1;   break;  /* curs 1 */
+      case KEY_KP_2:        scanCode = KEY_SN_KP_2;   break;  /* curs 2 */
+      case KEY_KP_3:        scanCode = KEY_SN_KP_3;   break;  /* curs 3 */
+      case KEY_KP_0:        scanCode = KEY_SN_KP_0;   break;  /* curs 0 */
+      case KEY_KP_Decimal:  scanCode = KEY_SN_KP_Dec; break;  /* curs decimal */
+      }
+     } else {
+      switch (scanCode) {
+      case KEY_KP_7:        scanCode = KEY_SN_KP_Home;  break;  /* curs home */
+      case KEY_KP_8:        scanCode = KEY_SN_KP_Up  ;  break;  /* curs up */
+      case KEY_KP_9:        scanCode = KEY_SN_KP_Prior; break;  /* curs pgup */
+      case KEY_KP_4:        scanCode = KEY_SN_KP_Left;  break;  /* curs left */
+      case KEY_KP_5:        scanCode = KEY_SN_KP_Begin; break;  /* curs begin */
+      case KEY_KP_6:        scanCode = KEY_SN_KP_Right; break;  /* curs right */
+      case KEY_KP_1:        scanCode = KEY_SN_KP_End;   break;  /* curs end */
+      case KEY_KP_2:        scanCode = KEY_SN_KP_Down;  break;  /* curs down */
+      case KEY_KP_3:        scanCode = KEY_SN_KP_Next;  break;  /* curs pgdn */
+      case KEY_KP_0:        scanCode = KEY_SN_KP_Ins;   break;  /* curs ins */
+      case KEY_KP_Decimal:  scanCode = KEY_SN_KP_Del;   break;  /* curs del */
+      }
+     }
+    }
+  }
+
+  else if (
+#ifdef CSRG_BASED
+           (xf86Info.consType == PCCONS || xf86Info.consType == SYSCONS
+	    || xf86Info.consType == PCVT) &&
+#endif
+           (xf86Info.scanPrefix == KEY_Prefix0)) {
+    xf86Info.scanPrefix = 0;
+	  
+    switch (scanCode) {
+    case KEY_KP_7:        scanCode = KEY_Home;      break;  /* curs home */
+    case KEY_KP_8:        scanCode = KEY_Up;        break;  /* curs up */
+    case KEY_KP_9:        scanCode = KEY_PgUp;      break;  /* curs pgup */
+    case KEY_KP_4:        scanCode = KEY_Left;      break;  /* curs left */
+    case KEY_KP_5:        scanCode = KEY_Begin;     break;  /* curs begin */
+    case KEY_KP_6:        scanCode = KEY_Right;     break;  /* curs right */
+    case KEY_KP_1:        scanCode = KEY_End;       break;  /* curs end */
+    case KEY_KP_2:        scanCode = KEY_Down;      break;  /* curs down */
+    case KEY_KP_3:        scanCode = KEY_PgDown;    break;  /* curs pgdown */
+    case KEY_KP_0:        scanCode = KEY_Insert;    break;  /* curs insert */
+    case KEY_KP_Decimal:  scanCode = KEY_Delete;    break;  /* curs delete */
+    case KEY_Enter:       scanCode = KEY_KP_Enter;  break;  /* keypad enter */
+    case KEY_LCtrl:       scanCode = KEY_RCtrl;     break;  /* right ctrl */
+    case KEY_KP_Multiply: scanCode = KEY_Print;     break;  /* print */
+    case KEY_Slash:       scanCode = KEY_KP_Divide; break;  /* keyp divide */
+    case KEY_Alt:         scanCode = KEY_AltLang;   break;  /* right alt */
+    case KEY_ScrollLock:  scanCode = KEY_Break;     break;  /* curs break */
+    case 0x5b:            scanCode = KEY_LMeta;     break;
+    case 0x5c:            scanCode = KEY_RMeta;     break;
+    case 0x5d:            scanCode = KEY_Menu;      break;
+    case KEY_F3:          scanCode = KEY_F13;       break;
+    case KEY_F4:          scanCode = KEY_F14;       break;
+    case KEY_F5:          scanCode = KEY_F15;       break;
+    case KEY_F6:          scanCode = KEY_F16;       break;
+    case KEY_F7:          scanCode = KEY_F17;       break;
+    case KEY_KP_Plus:     scanCode = KEY_KP_DEC;    break;
+      /*
+       * Ignore virtual shifts (E0 2A, E0 AA, E0 36, E0 B6)
+       */
+    default:
+      return;                                  /* skip illegal */
+    }
+  }
+  
+  else if (xf86Info.scanPrefix == KEY_Prefix1)
+    {
+      xf86Info.scanPrefix = (scanCode == KEY_LCtrl) ? KEY_LCtrl : 0;
+      return;
+    }
+  
+  else if (xf86Info.scanPrefix == KEY_LCtrl)
+    {
+      xf86Info.scanPrefix = 0;
+      if (scanCode != KEY_NumLock) return;
+      scanCode = KEY_Pause;       /* pause */
+    }
+#endif /* !ASSUME_CUSTOM_KEYCODES */
+
+  /*
+   * and now get some special keysequences
+   */
+
+#ifdef ASSUME_CUSTOM_KEYCODES
+  specialkey = SpecialServerMap[scanCode];
+#else /* ASSUME_CUSTOM_KEYCODES */
+  specialkey = scanCode;
+#endif /* ASSUME_CUSTOM_KEYCODES */
+
+  if ((ModifierDown(ControlMask | AltMask)) ||
+      (ModifierDown(ControlMask | AltLangMask)))
+    {
+      
+      switch (specialkey) {
+	
+      case KEY_BackSpace:
+	if (!xf86Info.dontZap) {
+	 GiveUp(0);
+        }
+	break;
+	
+	/*
+	 * The idea here is to pass the scancode down to a list of
+	 * registered routines. There should be some standard conventions
+	 * for processing certain keys.
+	 */
+      case KEY_KP_Minus:   /* Keypad - */
+	break;
+	
+      case KEY_KP_Plus:   /* Keypad + */
+	break;
+
+#if defined(linux) || (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT))) || defined(SCO)
+	/*
+	 * Under Linux, the raw keycodes are consumed before the kernel
+	 * does any processing on them, so we must emulate the vt switching
+	 * we want ourselves.
+	 */
+      case KEY_F1:
+      case KEY_F2:
+      case KEY_F3:
+      case KEY_F4:
+      case KEY_F5:
+      case KEY_F6:
+      case KEY_F7:
+      case KEY_F8:
+      case KEY_F9:
+      case KEY_F10:
+        if (VTSwitchEnabled && !xf86Info.vtSysreq
+#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)))
+	    && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+#endif
+	    )
+        {
+	  if (down)
+            ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F1 + 1);
+          return;
+        }
+	break;
+      case KEY_F11:
+      case KEY_F12:
+        if (VTSwitchEnabled && !xf86Info.vtSysreq
+#if (defined(CSRG_BASED) && (defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)))
+	    && (xf86Info.consType == SYSCONS || xf86Info.consType == PCVT)
+#endif
+	    )
+        {
+	  if (down)
+            ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey - KEY_F11 + 11);
+          return;
+        }
+	break;
+#endif /* linux || BSD with VTs */
+
+      /* just worth mentioning here: any 386bsd keyboard driver
+       * (pccons.c or co_kbd.c) catches CTRL-ALT-DEL and CTRL-ALT-ESC
+       * before any application (e.g. XF86) will see it
+       * OBS: syscons does not, nor does pcvt !
+       */
+      } 
+    }
+
+    /*
+     * Start of actual Solaris VT switching code.  
+     * This should pretty much emulate standard SVR4 switching keys.
+     * 
+     * DWH 12/2/93
+     */
+
+#ifdef USE_VT_SYSREQ
+    if (VTSwitchEnabled && xf86Info.vtSysreq)
+    {
+      switch (specialkey)
+      {
+      case KEY_F1:
+      case KEY_F2:
+      case KEY_F3:
+      case KEY_F4:
+      case KEY_F5:
+      case KEY_F6:
+      case KEY_F7:
+      case KEY_F8:
+      case KEY_F9:
+      case KEY_F10:
+	if (VTSysreqToggle && down)
+	{
+          if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey-KEY_F1 + 1) < 0)
+            ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+          VTSysreqToggle = FALSE;
+          return;
+        }
+	break;
+
+      case KEY_F11:
+      case KEY_F12:
+	if (VTSysreqToggle && down)
+	{
+          if (ioctl(xf86Info.consoleFd, VT_ACTIVATE, specialkey-KEY_F11 + 11) < 0)
+            ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
+          VTSysreqToggle = FALSE;
+          return;
+        }
+	break;
+
+      /* Ignore these keys -- ie don't let them cancel an alt-sysreq */
+      case KEY_Alt:
+      case KEY_AltLang:
+	break;
+
+      case KEY_SysReqest:
+        if (down && (ModifierDown(AltMask) || ModifierDown(AltLangMask)))
+          VTSysreqToggle = TRUE;
+	break;
+
+      default:
+        if (VTSysreqToggle)
+	{
+	  /*
+	   * We only land here when Alt-SysReq is followed by a
+	   * non-switching key.
+	   */
+          VTSysreqToggle = FALSE;
+
+        }
+      }
+    }
+
+#endif /* USE_VT_SYSREQ */
+
+  /*
+   * Now map the scancodes to real X-keycodes ...
+   */
+  keycode = scanCode + MIN_KEYCODE;
+  keysym = (keyc->curKeySyms.map +
+	    keyc->curKeySyms.mapWidth * 
+	    (keycode - keyc->curKeySyms.minKeyCode));
+  /*
+   * Filter autorepeated caps/num/scroll lock keycodes.
+   */
+#define CAPSFLAG 0x01
+#define NUMFLAG 0x02
+#define SCROLLFLAG 0x04
+#define MODEFLAG 0x08
+  if( down ) {
+    switch( keysym[0] ) {
+        case XK_Caps_Lock :
+          if (lockkeys & CAPSFLAG)
+              return;
+	  else
+	      lockkeys |= CAPSFLAG;
+          break;
+
+        case XK_Num_Lock :
+          if (lockkeys & NUMFLAG)
+              return;
+	  else
+	      lockkeys |= NUMFLAG;
+          break;
+
+        case XK_Scroll_Lock :
+          if (lockkeys & SCROLLFLAG)
+              return;
+	  else
+	      lockkeys |= SCROLLFLAG;
+          break;
+    }
+    if (keysym[1] == XF86XK_ModeLock)
+    {
+      if (lockkeys & MODEFLAG)
+          return;
+      else
+          lockkeys |= MODEFLAG;
+    }
+      
+  }
+  else {
+    switch( keysym[0] ) {
+        case XK_Caps_Lock :
+            lockkeys &= ~CAPSFLAG;
+            break;
+
+        case XK_Num_Lock :
+            lockkeys &= ~NUMFLAG;
+            break;
+
+        case XK_Scroll_Lock :
+            lockkeys &= ~SCROLLFLAG;
+            break;
+    }
+    if (keysym[1] == XF86XK_ModeLock)
+      lockkeys &= ~MODEFLAG;
+  }
+
+  /*
+   * LockKey special handling:
+   * ignore releases, toggle on & off on presses.
+   * Don't deal with the Caps_Lock keysym directly, but check the lock modifier
+   */
+  if (keyc->modifierMap[keycode] & LockMask ||
+      keysym[0] == XK_Scroll_Lock ||
+      keysym[1] == XF86XK_ModeLock ||
+      keysym[0] == XK_Num_Lock)
+    {
+      Bool flag;
+
+      if (!down) return;
+      if (KeyPressed(keycode)) {
+	down = !down;
+	flag = FALSE;
+      }
+      else
+	flag = TRUE;
+
+      if (keyc->modifierMap[keycode] & LockMask)   xf86Info.capsLock   = flag;
+      if (keysym[0] == XK_Num_Lock)    xf86Info.numLock    = flag;
+      if (keysym[0] == XK_Scroll_Lock) xf86Info.scrollLock = flag;
+      if (keysym[1] == XF86XK_ModeLock)   xf86Info.modeSwitchLock = flag;
+      updateLeds = TRUE;
+    }
+
+#ifndef ASSUME_CUSTOM_KEYCODES
+  /*
+   * normal, non-keypad keys
+   */
+  if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
+#if !defined(CSRG_BASED) && !defined(MACH386) && !defined(MINIX) && !defined(__OSF__)
+    /*
+     * magic ALT_L key on AT84 keyboards for multilingual support
+     */
+    if (xf86Info.kbdType == KB_84 &&
+	ModifierDown(AltMask) &&
+	keysym[2] != NoSymbol)
+      {
+	UsePrefix = TRUE;
+	Direction = TRUE;
+      }
+#endif /* !CSRG_BASED && !MACH386 && !MINIX && !__OSF__ */
+  }
+#endif /* !ASSUME_CUSTOM_KEYCODES */
+  if (updateLeds) xf86KbdLeds();
+
+  /*
+   * check for an autorepeat-event
+   */
+  if ((down && KeyPressed(keycode)) &&
+      (xf86Info.autoRepeat != AutoRepeatModeOn || keyc->modifierMap[keycode]))
+    return;
+
+  xf86Info.lastEventTime = kevent.u.keyButtonPointer.time = GetTimeInMillis();
+  /*
+   * And now send these prefixes ...
+   * NOTE: There cannot be multiple Mode_Switch keys !!!!
+   */
+  if (UsePrefix)
+    {
+      ENQUEUE(&kevent,
+	      keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
+	      (Direction ? KeyPress : KeyRelease),
+	      XE_KEYBOARD);
+      ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
+      ENQUEUE(&kevent,
+	      keyc->modifierKeyMap[keyc->maxKeysPerModifier*7],
+	      (Direction ? KeyRelease : KeyPress),
+	      XE_KEYBOARD);
+    }
+  else 
+    {
+      {
+         ENQUEUE(&kevent, keycode, (down ? KeyPress : KeyRelease), XE_KEYBOARD);
+
+      }
+    }
+}
+#endif /* !__EMX__ */
+
+
+static CARD32
+buttonTimer(timer, now, arg)
+     OsTimerPtr timer;
+     CARD32 now;
+     pointer arg;
+{
+    MouseDevPtr	priv = MOUSE_DEV((DeviceIntPtr) arg);
+
+    xf86PostMseEvent(((DeviceIntPtr) arg), priv->truebuttons, 0, 0);
+    return(0);
+}
+
+/*      
+ * xf86PostMseEvent --
+ *	Translate the raw hardware MseEvent into an XEvent(s), and tell DIX
+ *	about it. Perform a 3Button emulation if required.
+ */
+
+void
+xf86PostMseEvent(device, buttons, dx, dy)
+    DeviceIntPtr device;
+    int buttons, dx, dy;
+{
+  static OsTimerPtr timer = NULL;
+  MouseDevPtr private = MOUSE_DEV(device);
+  int         id, change;
+  int         truebuttons;
+  xEvent      mevent[2];
+
+  float mult;
+  static float dxremaind = 0.0, dyremaind = 0.0;
+
+  xf86Info.lastEventTime = mevent->u.keyButtonPointer.time = GetTimeInMillis();
+
+  truebuttons = buttons;
+  if (private->mseType == P_MMHIT)
+    buttons = hitachMap[buttons];
+  else
+    buttons = reverseMap[buttons];
+
+  if (dx || dy) {
+
+    /*
+     * The accelaration stuff is now done in xf86Xinput.c when XInput
+     * support is enabled.
+     */
+    /*
+     * accelerate the baby now if sqrt(dx*dx + dy*dy) > threshold !
+     * but do some simpler arithmetic here...
+     */
+
+      if ( private->threshold ) 
+      {
+	  if ((abs(dx) + abs(dy)) >= private->threshold) {
+	      dx = (dx * private->num) / private->den;
+	      dy = (dy * private->num)/ private->den;
+	  }
+      }
+      else
+      {
+#if 0
+	  mult = sqrt((float)(dx*dx+dy*dy)) *
+	      (float)(private->num) / (float)(private->den) + 0.5;
+#else
+	  mult = pow((float)(dx*dx+dy*dy), (float)(private->num) /
+		     (float)(private->den) / 2.0) / 2.0;
+#endif
+	  if ( dx )
+	  {
+	      dxremaind = mult * (float)dx + dxremaind;
+	      dx = (int)dxremaind;
+	      dxremaind = dxremaind - (float)dx;
+	  }
+	  if ( dy )
+	  {
+	      dyremaind = mult * (float)dy + dyremaind;
+	      dy = (int)dyremaind;
+	      dyremaind = dyremaind - (float)dy;
+	  }
+      }
+
+	{
+	  MOVEPOINTER(dx, dy, mevent->u.keyButtonPointer.time);
+	}
+  }
+
+  if (private->emulate3Buttons)
+    {
+
+      /*
+       * Hack to operate the middle button even with Emulate3Buttons set.
+       * Modifying the state table to keep track of the middle button state
+       * would nearly double its size, so I'll stick with this fix.  - TJW
+       */
+      if (private->mseType == P_MMHIT)
+        change = buttons ^ hitachMap[private->lastButtons];
+      else
+        change = buttons ^ reverseMap[private->lastButtons];
+      if (change & 02)
+	{
+	  ENQUEUE(mevent,
+		  2, (buttons & 02) ? ButtonPress : ButtonRelease,
+		  XE_POINTER);
+	}
+      
+      /*
+       * emulate the third button by the other two
+       */
+      if ((id = stateTab[buttons + private->emulateState][0]) != 0)
+	{
+            ENQUEUE(mevent,
+                    abs(id), (id < 0 ? ButtonRelease : ButtonPress), 
+                    XE_POINTER);
+	}
+
+      if ((id = stateTab[buttons + private->emulateState][1]) != 0)
+	{
+            ENQUEUE(mevent,
+                    abs(id), (id < 0 ? ButtonRelease : ButtonPress), 
+                    XE_POINTER);
+	}
+
+      private->emulateState = stateTab[buttons + private->emulateState][2];
+      if (stateTab[buttons + private->emulateState][0] ||
+          stateTab[buttons + private->emulateState][1])
+        {
+	    private->truebuttons = truebuttons;
+	    timer = TimerSet(timer, 0, private->emulate3Timeout, buttonTimer,
+			     (pointer)device);
+        }
+      else
+        {
+          if (timer)
+            {
+              TimerFree(timer);
+              timer = NULL;
+            }
+        }
+    }
+  else
+    {
+      /*
+       * real three button event
+       * Note that xf86Info.lastButtons has the hardware button mapping which
+       * is the reverse of the button mapping reported to the server.
+       */
+      if (private->mseType == P_MMHIT)
+        change = buttons ^ hitachMap[private->lastButtons];
+      else
+        change = buttons ^ reverseMap[private->lastButtons];
+      while (change)
+	{
+	  id = ffs(change);
+	  change &= ~(1 << (id-1));
+            ENQUEUE(mevent,
+                    id, (buttons&(1<<(id-1)))? ButtonPress : ButtonRelease,
+                    XE_POINTER);
+	}
+    }
+    private->lastButtons = truebuttons;
+}
+
+
+
+/*
+ * xf86Block --
+ *      Os block handler.
+ */
+
+/* ARGSUSED */
+void
+xf86Block(blockData, pTimeout, pReadmask)
+     pointer blockData;
+     OSTimePtr pTimeout;
+     pointer  pReadmask;
+{
+}
+
+
+/*
+ * xf86Wakeup --
+ *      Os wakeup handler.
+ */
+
+/* ARGSUSED */
+void
+xf86Wakeup(blockData, err, pReadmask)
+     pointer blockData;
+     int err;
+     pointer pReadmask;
+{
+
+#ifndef __EMX__
+  fd_set* LastSelectMask = (fd_set*)pReadmask;
+  fd_set devicesWithInput;
+
+  if ((int)err >= 0) {
+    XFD_ANDSET(&devicesWithInput, LastSelectMask, &EnabledDevices);
+    if (XFD_ANYSET(&devicesWithInput))
+      {
+	(xf86Info.kbdEvents)();
+	(xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
+      }
+  }
+#else   /* __EMX__ */
+
+	(xf86Info.kbdEvents)();  /* Under OS/2, always call */
+	(xf86Info.mouseDev->mseEvents)(xf86Info.mouseDev);
+
+#endif  /* __EMX__ */
+
+  if (xf86VTSwitchPending()) xf86VTSwitch();
+
+  if (xf86Info.inputPending) ProcessInputEvents();
+}
+
+
+
+/*
+ * xf86SigHandler --
+ *    Catch unexpected signals and exit cleanly.
+ */
+void
+xf86SigHandler(signo)
+     int signo;
+{
+  signal(signo,SIG_IGN);
+  xf86Info.caughtSignal = TRUE;
+  FatalError("Caught signal %d.  Server aborting\n", signo);
+}
+
+/*
+ * xf86VTSwitch --
+ *      Handle requests for switching the vt.
+ */
+static void
+xf86VTSwitch()
+{
+  int j;
+
+#ifdef XFreeXDGA
+  /*
+   * Not ideal, but until someone adds DGA events to the DGA client we
+   * should protect the machine
+   */
+  if (((ScrnInfoPtr)(xf86Info.currentScreen->devPrivates[xf86ScreenIndex].ptr))->directMode&XF86DGADirectGraphics) {
+   xf86Info.vtRequestsPending = FALSE;
+   return;
+  }
+#endif
+  if (xf86VTSema) {
+
+#ifndef __EMX__
+    DisableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+    DisableDevice((DeviceIntPtr)xf86Info.pMouse);
+#endif
+
+    if (!xf86VTSwitchAway()) {
+      /*
+       * switch failed 
+       */
+      SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+#ifdef DPMSExtension
+      if (DPMSEnabled)
+        DPMSSet(DPMSModeOn);
+#endif
+
+#ifndef __EMX__
+      EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+      EnableDevice((DeviceIntPtr)xf86Info.pMouse);
+#endif
+
+    } else {
+      xf86VTSema = FALSE;
+    }
+  } else {
+    if (!xf86VTSwitchTo()) return;
+      
+    xf86VTSema = TRUE;
+      
+    /* Turn screen saver off when switching back */
+    SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverReset);
+#ifdef DPMSExtension
+    if (DPMSEnabled)
+      DPMSSet(DPMSModeOn);
+#endif
+
+#ifndef __EMX__
+    EnableDevice((DeviceIntPtr)xf86Info.pKeyboard);
+    EnableDevice((DeviceIntPtr)xf86Info.pMouse);
+#endif
+
+  }
+}
+
+
+#ifdef XTESTEXT1
+
+void
+XTestGetPointerPos(fmousex, fmousey)
+     short *fmousex;
+     short *fmousey;
+{
+  int x,y;
+
+  miPointerPosition(&x, &y);
+  *fmousex = x;
+  *fmousey = y;
+}
+
+
+
+void
+XTestJumpPointer(jx, jy, dev_type)
+     int jx;
+     int jy;
+     int dev_type;
+{
+  miPointerAbsoluteCursor(jx, jy, GetTimeInMillis() );
+}
+
+
+
+void
+XTestGenerateEvent(dev_type, keycode, keystate, mousex, mousey)
+     int dev_type;
+     int keycode;
+     int keystate;
+     int mousex;
+     int mousey;
+{
+  xEvent tevent;
+  
+  tevent.u.u.type = (dev_type == XE_POINTER) ?
+    (keystate == XTestKEY_UP) ? ButtonRelease : ButtonPress :
+      (keystate == XTestKEY_UP) ? KeyRelease : KeyPress;
+  tevent.u.u.detail = keycode;
+  tevent.u.keyButtonPointer.rootX = mousex;
+  tevent.u.keyButtonPointer.rootY = mousey;
+  tevent.u.keyButtonPointer.time = xf86Info.lastEventTime = GetTimeInMillis();
+  mieqEnqueue(&tevent);
+  xf86Info.inputPending = TRUE;               /* virtual event */
+}
+
+#endif /* XTESTEXT1 */
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Init.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Init.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Init.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Init.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,141 @@
+/*
+ * $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Init.c,v 3.66.2.4 1998/10/11 12:35:37 hohndel Exp $
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ */
+/* $XConsortium: xf86Init.c /main/37 1996/10/23 18:43:39 kaleb $ */
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+extern int atoi();
+#endif
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xmd.h"
+#include "Xproto.h"
+#include "input.h"
+#include "servermd.h"
+#include "scrnintstr.h"
+#include "site.h"
+
+#include "compiler.h"
+
+#include "xf86.h"
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86Version.h"
+#include "mipointer.h"
+
+#include "inputstr.h"
+
+#include "opaque.h"
+
+#ifdef XTESTEXT1
+#include "atKeynames.h"
+extern int xtest_command_key;
+#endif /* XTESTEXT1 */
+
+/* xf86Exiting is set while the screen is shutting down (even on a reset) */
+Bool xf86Exiting = FALSE;
+Bool xf86Resetting = FALSE;
+Bool xf86ProbeFailed = TRUE;
+Bool xf86FlipPixels = FALSE;
+#ifdef XF86VIDMODE
+Bool xf86VidModeEnabled = TRUE;
+Bool xf86VidModeAllowNonLocal = FALSE;
+#endif
+#ifdef XF86MISC
+Bool xf86MiscModInDevEnabled = TRUE;
+Bool xf86MiscModInDevAllowNonLocal = FALSE;
+#endif
+Bool xf86AllowMouseOpenFail = FALSE;
+PciProbeType xf86PCIFlags = PCIProbe1;
+Bool xf86ScreensOpen = FALSE;
+int xf86Verbose = 1;
+Bool xf86fpFlag = FALSE;
+Bool xf86coFlag = FALSE;
+Bool xf86sFlag = FALSE;
+Bool xf86ProbeOnly = FALSE;
+char xf86ConfigFile[PATH_MAX] = "";
+int  xf86bpp = -1;
+xrgb xf86weight = { 0, 0, 0 } ;	/* RGB weighting at 16 bpp */
+double xf86rGamma=1.0, xf86gGamma=1.0, xf86bGamma=1.0;
+unsigned char xf86rGammaMap[256], xf86gGammaMap[256], xf86bGammaMap[256];
+char *xf86ServerName = NULL;
+Bool xf86BestRefresh = FALSE;
+
+
+xf86InfoRec xf86Info;
+
+/*
+ * InitInput --
+ *      Initialize all supported input devices...what else is there
+ *      besides pointer and keyboard? Two DeviceRec's are allocated and
+ *      registered as the system pointer and keyboard devices.
+ */
+
+void
+InitInput(argc, argv)
+     int     	  argc;
+     char    	  **argv;
+{
+  xf86Info.vtRequestsPending = FALSE;
+  xf86Info.inputPending = FALSE;
+#ifdef XTESTEXT1
+  xtest_command_key = KEY_Begin + MIN_KEYCODE;
+#endif /* XTESTEXT1 */
+
+  xf86Info.pKeyboard = AddInputDevice(xf86Info.kbdProc, TRUE); 
+  xf86Info.pMouse =  AddInputDevice(xf86Info.mouseDev->mseProc, TRUE);
+  RegisterKeyboardDevice(xf86Info.pKeyboard); 
+  RegisterPointerDevice(xf86Info.pMouse); 
+
+  (xf86Info.pMouse)->public.devicePrivate = (pointer) xf86Info.mouseDev;
+  
+  miRegisterPointerDevice(screenInfo.screens[0], xf86Info.pMouse);
+  mieqInit (xf86Info.pKeyboard, xf86Info.pMouse);
+}
+
+
+#ifdef DPMSExtension
+/*
+ * DPMSSet --
+ *	Device dependent DPMS mode setting hook.  This is called whenever
+ *	the DPMS mode is to be changed.
+ */
+void
+DPMSSet(CARD16 level)
+{
+}
+
+/*
+ * DPMSSupported --
+ *	Return TRUE if any screen supports DPMS.
+ */
+Bool
+DPMSSupported(void)
+{
+    return FALSE;
+}
+#endif /* DPMSExtension */
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Io.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Io.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Io.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Io.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,539 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Io.c,v 3.28.2.7 1998/11/04 08:01:51 hohndel Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86Io.c /main/27 1996/10/19 17:58:55 kaleb $ */
+/* Patch for PS/2 Intellimouse - Tim Goodwin 1997-11-06. */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86_Config.h"
+
+#include "mipointer.h"
+
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+extern KeybdCtrl defaultKeyboardControl;
+
+unsigned int xf86InitialCaps = 0;
+unsigned int xf86InitialNum = 0;
+unsigned int xf86InitialScroll = 0;
+
+#include "atKeynames.h"
+
+extern int miPointerGetMotionEvents(DeviceIntPtr pPtr, xTimecoord *coords,
+				    unsigned long start, unsigned long stop,
+				    ScreenPtr pScreen);
+
+/*
+ * xf86KbdBell --
+ *	Ring the terminal/keyboard bell for an amount of time proportional to
+ *      "loudness".
+ */
+
+void
+xf86KbdBell(percent, pKeyboard, ctrl, unused)
+     int           percent;          /* Percentage of full volume */
+     DeviceIntPtr  pKeyboard;        /* Keyboard to ring */
+     pointer	   ctrl;	
+     int	   unused;	
+{
+  xf86SoundKbdBell(percent, xf86Info.bell_pitch, xf86Info.bell_duration);
+}
+
+void
+xf86KbdLeds ()
+{
+  int leds = 0;
+#ifdef XKB
+  if (!noXkbExtension) {
+    XkbEventCauseRec cause;
+    XkbSetCauseUnknown(&cause);
+    XkbUpdateIndicators((DeviceIntPtr)xf86Info.pKeyboard,
+             XkbAllIndicatorsMask, False, NULL, &cause);
+    return;
+  }
+#endif
+#ifdef LED_CAP
+  if (xf86Info.capsLock && !(xf86Info.xleds & XLED1))
+    leds |= LED_CAP;
+
+  if (xf86Info.numLock && !(xf86Info.xleds & XLED2))
+    leds |= LED_NUM;
+
+  if ((xf86Info.scrollLock || 
+       xf86Info.modeSwitchLock || 
+       xf86Info.composeLock) && 
+      !(xf86Info.xleds & XLED3))
+    leds |= LED_SCR;
+
+  if ((xf86Info.leds & xf86Info.xleds) & XLED1) leds |= LED_CAP;
+  if ((xf86Info.leds & xf86Info.xleds) & XLED2) leds |= LED_NUM;
+  if ((xf86Info.leds & xf86Info.xleds) & XLED3) leds |= LED_SCR;
+
+  xf86SetKbdLeds(leds);
+#endif /* LED_CAP */
+}
+
+/*
+ * xf86KbdCtrl --
+ *      Alter some of the keyboard control parameters. All special protocol
+ *      values are handled by dix (ProgChangeKeyboardControl)
+ */
+
+void
+xf86KbdCtrl (pKeyboard, ctrl)
+     DevicePtr     pKeyboard;        /* Keyboard to alter */
+     KeybdCtrl     *ctrl;
+{
+  xf86Info.bell_pitch    = ctrl->bell_pitch;
+  xf86Info.bell_duration = ctrl->bell_duration;
+  xf86Info.autoRepeat    = ctrl->autoRepeat;
+  xf86Info.leds          = (ctrl->leds & ~(XCAPS | XNUM | XSCR));
+
+  xf86Info.composeLock   = (ctrl->leds & XCOMP) ? TRUE : FALSE;
+
+  xf86KbdLeds();
+}
+
+/*
+ * xf86InitKBD --
+ *      Reinitialize the keyboard. Only set Lockkeys accrding to ours leds.
+ *      Depress all other keys.
+ */
+
+void
+xf86InitKBD(init)
+Bool init;
+{
+  char            leds = 0, rad;
+  unsigned int    i;
+  xEvent          kevent;
+  DeviceIntPtr    pKeyboard = xf86Info.pKeyboard;
+  KeyClassRec     *keyc = xf86Info.pKeyboard->key;
+  KeySym          *map = keyc->curKeySyms.map;
+
+  kevent.u.keyButtonPointer.time = GetTimeInMillis();
+  kevent.u.keyButtonPointer.rootX = 0;
+  kevent.u.keyButtonPointer.rootY = 0;
+
+  /*
+   * Hmm... here is the biggest hack of every time !
+   * It may be possible that a switch-vt procedure has finished BEFORE
+   * you released all keys neccessary to do this. That peculiar behavior
+   * can fool the X-server pretty much, cause it assumes that some keys
+   * were not released. TWM may stuck alsmost completly....
+   * OK, what we are doing here is after returning from the vt-switch
+   * exeplicitely unrelease all keyboard keys before the input-devices
+   * are reenabled.
+   */
+  for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
+       i < keyc->curKeySyms.maxKeyCode;
+       i++, map += keyc->curKeySyms.mapWidth)
+    if (KeyPressed(i))
+      {
+        switch (*map) {
+	/* Don't release the lock keys */
+        case XK_Caps_Lock:
+        case XK_Shift_Lock:
+        case XK_Num_Lock:
+        case XK_Scroll_Lock:
+        case XK_Kana_Lock:
+	  break;
+        default:
+	  kevent.u.u.detail = i;
+	  kevent.u.u.type = KeyRelease;
+	  (* pKeyboard->public.processInputProc)(&kevent, pKeyboard, 1);
+        }
+      }
+  
+  xf86Info.scanPrefix      = 0;
+
+  if (init)
+    {
+      /*
+       * we must deal here with the fact, that on some cases the numlock or
+       * capslock key are enabled BEFORE the server is started up. So look
+       * here at the state on the according LEDS to determine whether a
+       * lock-key is already set.
+       */
+
+      xf86Info.capsLock        = FALSE;
+      xf86Info.numLock         = FALSE;
+      xf86Info.scrollLock      = FALSE;
+      xf86Info.modeSwitchLock  = FALSE;
+      xf86Info.composeLock     = FALSE;
+    
+#ifdef LED_CAP
+#ifdef INHERIT_LOCK_STATE
+      leds = xf86Info.leds;
+
+      for (i = keyc->curKeySyms.minKeyCode, map = keyc->curKeySyms.map;
+           i < keyc->curKeySyms.maxKeyCode;
+           i++, map += keyc->curKeySyms.mapWidth)
+
+        switch(*map) {
+
+        case XK_Caps_Lock:
+        case XK_Shift_Lock:
+          if (leds & LED_CAP) 
+	    {
+	      xf86InitialCaps = i;
+	      xf86Info.capsLock = TRUE;
+	    }
+          break;
+
+        case XK_Num_Lock:
+          if (leds & LED_NUM)
+	    {
+	      xf86InitialNum = i;
+	      xf86Info.numLock = TRUE;
+	    }
+          break;
+
+        case XK_Scroll_Lock:
+        case XK_Kana_Lock:
+          if (leds & LED_SCR)
+	    {
+	      xf86InitialScroll = i;
+	      xf86Info.scrollLock = TRUE;
+	    }
+          break;
+        }
+#endif /* INHERIT_LOCK_STATE */
+      xf86SetKbdLeds(leds);
+#endif /* LED_CAP */
+
+      if      (xf86Info.kbdDelay <= 375) rad = 0x00;
+      else if (xf86Info.kbdDelay <= 625) rad = 0x20;
+      else if (xf86Info.kbdDelay <= 875) rad = 0x40;
+      else                               rad = 0x60;
+    
+      if      (xf86Info.kbdRate <=  2)   rad |= 0x1F;
+      else if (xf86Info.kbdRate >= 30)   rad |= 0x00;
+      else                               rad |= ((58 / xf86Info.kbdRate) - 2);
+    
+      xf86SetKbdRepeat(rad);
+    }
+}
+
+/*
+ * xf86KbdProc --
+ *	Handle the initialization, etc. of a keyboard.
+ */
+
+int
+xf86KbdProc (pKeyboard, what)
+     DeviceIntPtr pKeyboard;	/* Keyboard to manipulate */
+     int       what;	    	/* What to do to it */
+{
+  KeySymsRec           keySyms;
+  CARD8                modMap[MAP_LENGTH];
+  int                  kbdFd;
+
+  switch (what) {
+
+  case DEVICE_INIT:
+    /*
+     * First open and find the current state of the keyboard.
+     */
+
+    xf86KbdInit();
+
+    xf86KbdGetMapping(&keySyms, modMap);
+    
+
+#ifndef XKB
+    defaultKeyboardControl.leds = xf86GetKbdLeds();
+#else
+    defaultKeyboardControl.leds = 0;
+#endif
+
+    /*
+     * Perform final initialization of the system private keyboard
+     * structure and fill in various slots in the device record
+     * itself which couldn't be filled in before.
+     */
+
+    pKeyboard->public.on = FALSE;
+
+#ifndef XKB
+    InitKeyboardDeviceStruct((DevicePtr)xf86Info.pKeyboard,
+			     &keySyms,
+			     modMap,
+			     xf86KbdBell,
+			     (KbdCtrlProcPtr)xf86KbdCtrl);
+#else
+  {
+    XkbComponentNamesRec names;
+    if (XkbInitialMap) {
+        if ((xf86Info.xkbkeymap = strchr(XkbInitialMap, '/')) != NULL)
+	        xf86Info.xkbkeymap++;
+        else
+	        xf86Info.xkbkeymap = XkbInitialMap;
+    }
+    if (xf86Info.xkbkeymap) {
+        names.keymap = xf86Info.xkbkeymap;
+        names.keycodes = NULL;
+        names.types = NULL;
+        names.compat = NULL;
+        names.symbols = NULL;
+        names.geometry = NULL;
+    } else {
+        names.keymap = NULL;
+        names.keycodes = xf86Info.xkbkeycodes;
+        names.types = xf86Info.xkbtypes;
+        names.compat = xf86Info.xkbcompat;
+        names.symbols = xf86Info.xkbsymbols;
+        names.geometry = xf86Info.xkbgeometry;
+    }
+    if ((xf86Info.xkbkeymap || xf86Info.xkbcomponents_specified)
+       && (xf86Info.xkbmodel == NULL || xf86Info.xkblayout == NULL)) {
+        xf86Info.xkbrules = NULL;
+    }
+    XkbSetRulesDflts(xf86Info.xkbrules, xf86Info.xkbmodel,
+             xf86Info.xkblayout, xf86Info.xkbvariant,
+             xf86Info.xkboptions);
+    XkbInitKeyboardDeviceStruct(pKeyboard,
+                    &names,
+                    &keySyms,
+                    modMap,
+                    xf86KbdBell,
+                    (KbdCtrlProcPtr)xf86KbdCtrl);
+  }
+#endif
+    
+    xf86InitKBD(TRUE);
+    break;
+    
+  case DEVICE_ON:
+    /*
+     * Set the keyboard into "direct" mode and turn on
+     * event translation.
+     */
+
+    kbdFd = xf86KbdOn();
+    /*
+     * Discard any pending input after a VT switch to prevent the server
+     * passing on parts of the VT switch sequence.
+     */
+    sleep(1);
+    if (kbdFd != -1) {
+	char buf[16];
+	read(kbdFd, buf, 16);
+    }
+
+#ifndef __EMX__  /* Under EMX, keyboard cannot be select()'ed */
+    if (kbdFd != -1)
+      AddEnabledDevice(kbdFd);
+#endif  /* __EMX__ */
+
+    pKeyboard->public.on = TRUE;
+    xf86InitKBD(FALSE);
+    break;
+    
+  case DEVICE_CLOSE:
+  case DEVICE_OFF:
+    /*
+     * Restore original keyboard directness and translation.
+     */
+
+    kbdFd = xf86KbdOff();
+
+    if (kbdFd != -1)
+      RemoveEnabledDevice(kbdFd);
+
+    pKeyboard->public.on = FALSE;
+    break;
+
+  }
+  return (Success);
+}
+
+/*
+ * xf86MseCtrl --
+ *      Alter the control parameters for the mouse. Note that all special
+ *      protocol values are handled by dix.
+ */
+
+void
+xf86MseCtrl(pPointer, ctrl)
+     DevicePtr pPointer;
+     PtrCtrl   *ctrl;
+{
+    MouseDevPtr	mouse = MOUSE_DEV((DeviceIntPtr) pPointer);
+
+    mouse->num       = ctrl->num;
+    mouse->den       = ctrl->den;
+    mouse->threshold = ctrl->threshold;
+}
+
+/*
+ * xf86MseProc --
+ *      Handle the initialization, etc. of a mouse
+ */
+
+int
+xf86MseProc(pPointer, what)
+     DeviceIntPtr pPointer;
+     int        what;
+{
+  MouseDevPtr                  mouse = MOUSE_DEV(pPointer);
+
+  mouse->device = pPointer;
+  
+  return xf86MseProcAux(pPointer, what, mouse, NULL,
+			(PtrCtrlProcPtr)xf86MseCtrl);
+}
+
+
+int  
+xf86MseProcAux(pPointer, what, mouse, fd, ctrl)
+     DeviceIntPtr	pPointer;
+     int		what;
+     MouseDevPtr	mouse;
+     int		*fd;
+     PtrCtrlProcPtr	ctrl;
+{
+  unsigned char                map[MSE_MAXBUTTONS + 1];
+  int                          nbuttons;
+  int                          mousefd;
+
+  switch (what)
+    {
+    case DEVICE_INIT: 
+      pPointer->public.on = FALSE;
+ 
+      /* WARNING! WARNING! WARNING!
+       * If you change something here, also fix the same thing in 
+       * xf86OsMouseProc (os-support/xxx/xxx_mouse.c) and 
+       * xf86XqueMseProc (os-support/xxx/xqueue.c)
+       * otherwise you will break support for these pointer devices
+       */
+
+      /*
+       * [KAZU-241097] We don't know exactly how many buttons the
+       * device has...
+       */
+      for (nbuttons = 0; nbuttons < MSE_MAXBUTTONS; ++nbuttons)
+        map[nbuttons + 1] = nbuttons + 1;
+
+      InitPointerDeviceStruct((DevicePtr)pPointer, 
+			      map, 
+			      min(mouse->buttons, MSE_MAXBUTTONS),
+			      miPointerGetMotionEvents,
+			      ctrl, 
+			      miPointerGetMotionBufferSize());
+      xf86MouseInit(mouse);
+
+      break;
+      
+    case DEVICE_ON:
+
+      mousefd = xf86MouseOn(mouse);
+
+      if (fd)
+ 	  *fd = mousefd;
+
+      if (mousefd != -1) {
+	  if (mousefd == -2) {
+	      if (fd)
+		  *fd = -1;
+	  } else {
+	      if (mouse->mseType == P_PS2)
+	          write(mousefd, "\364", 1);
+	  
+	      AddEnabledDevice(mousefd);
+	  }
+	  mouse->lastButtons = 0;
+	  mouse->emulateState = 0;
+	  pPointer->public.on = TRUE;
+      } else {
+	  return !Success;
+      }
+
+      break;
+      
+    case DEVICE_OFF:
+    case DEVICE_CLOSE:
+
+      mousefd = xf86MouseOff(mouse, what == DEVICE_CLOSE);
+
+      if (mousefd != -1)
+        RemoveEnabledDevice(mousefd);
+
+      pPointer->public.on = FALSE;
+      usleep(300000);
+      break;
+    }
+  return Success;
+}
+
+/*
+ * xf86MseEvents --
+ *      Read the new events from the device, and pass them to the eventhandler.
+ *      This should is not used if there is only an OS_MOUSE driver.
+ */
+#ifndef OSMOUSE_ONLY
+void
+xf86MseEvents(mouse)
+    MouseDevPtr	mouse;
+{
+  xf86MouseEvents(mouse);
+}
+#endif
+
+#if !defined(AMOEBA) && !(defined (sun) && defined(i386) && defined (SVR4)) && !defined(MINIX) && !defined(__mips__)
+/*
+ * These are getting tossed in here until I can think of where
+ * they really belong
+ */
+CARD32
+GetTimeInMillis()
+{
+    struct timeval  tp;
+
+    gettimeofday(&tp, 0);
+    return(tp.tv_sec * 1000) + (tp.tv_usec / 1000);
+}
+#else    /* from os/util.c */
+CARD32 GetTimeInMillis()
+{
+    struct timeval tp ;
+
+    X_GETTIMEOFDAY(&tp);
+    return (tp.tv_sec*1000)+(tp.tv_usec/1000);
+}
+#endif /* !AMOEBA && !(sun || SVR4) && !MINIX */
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86KbdLnx.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86KbdLnx.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86KbdLnx.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86KbdLnx.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,696 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86KbdLnx.c,v 3.12 1996/12/23 06:43:31 dawes Exp $ */
+/*
+ * Linux version of keymapping setup. The kernel (since 0.99.14) has support
+ * for fully remapping the keyboard, but there are some differences between
+ * the Linux map and the SVR4 map (esp. in the extended keycodes). We also
+ * remove the restriction on what keycodes can be remapped.
+ * Orest Zborowski.
+ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86KbdLnx.c /main/7 1996/10/19 17:59:00 kaleb $ */
+
+#include "X.h"
+#include "Xmd.h"
+#include "input.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "atKeynames.h"
+#include "xf86_Config.h"
+
+#include "xf86Keymap.h"
+#include "DECkeysym.h"
+
+/*
+ * LegalModifier --
+ *      determine whether a key is a legal modifier key, i.e send a
+ *      press/release sequence.
+ */
+
+/*ARGSUSED*/
+Bool
+LegalModifier(unsigned int key, DevicePtr pDev)
+{
+  return (TRUE);
+}
+
+/*
+ * xf86KbdGetMapping --
+ *	Get the national keyboard mapping. The keyboard type is set, a new map
+ *      and the modifiermap is computed.
+ */
+
+static void readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap);
+
+void
+xf86KbdGetMapping (KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+  KeySym        *k;
+  char          type;
+  int           i, j;
+
+  readKernelMapping(pKeySyms, pModMap);
+
+  /*
+   * Apply the special key mapping specified in XF86Config 
+   */
+  for (k = map, i = MIN_KEYCODE;
+       i < (NUM_KEYCODES + MIN_KEYCODE);
+       i++, k += 4) {
+    switch (k[0]) {
+      case XK_Alt_L:
+        j = K_INDEX_LEFTALT;
+        break;
+      case XK_Alt_R:
+        j = K_INDEX_RIGHTALT;
+        break;
+      case XK_Scroll_Lock:
+        j = K_INDEX_SCROLLLOCK;
+        break;
+      case XK_Control_R:
+        j = K_INDEX_RIGHTCTL;
+        break;
+      default:
+        j = -1;
+    }
+    if (j >= 0)
+      switch (xf86Info.specialKeyMap[j]) {
+        case KM_META:
+          if (k[0] == XK_Alt_R)
+            k[1] = XK_Meta_R;
+          else {
+            k[0] = XK_Alt_L;
+            k[1] = XK_Meta_L;
+          }
+          break;
+        case KM_COMPOSE:
+          k[0] = XK_Multi_key;
+          break;
+        case KM_MODESHIFT:
+          k[0] = XK_Mode_switch;
+          k[1] = NoSymbol;
+          break;
+        case KM_MODELOCK:
+          k[0] = XK_Mode_switch;
+          k[1] = XF86XK_ModeLock;
+          break;
+        case KM_SCROLLLOCK:
+          k[0] = XK_Scroll_Lock;
+          break;
+        case KM_CONTROL:
+          k[0] = XK_Control_R;
+          break;
+      }
+  }
+
+  /*
+   * compute the modifier map
+   */
+  for (i = 0; i < MAP_LENGTH; i++)
+    pModMap[i] = NoSymbol;  /* make sure it is restored */
+  
+  for (k = map, i = MIN_KEYCODE;
+       i < (NUM_KEYCODES + MIN_KEYCODE);
+       i++, k += 4)
+    
+    switch(*k) {
+      
+    case XK_Shift_L:
+    case XK_Shift_R:
+      pModMap[i] = ShiftMask;
+      break;
+      
+    case XK_Control_L:
+    case XK_Control_R:
+      pModMap[i] = ControlMask;
+      break;
+      
+    case XK_Caps_Lock:
+      pModMap[i] = LockMask;
+      break;
+      
+    case XK_Alt_L:
+    case XK_Alt_R:
+      pModMap[i] = AltMask;
+      break;
+      
+    case XK_Num_Lock:
+      if (!xf86Info.serverNumLock) pModMap[i] = NumLockMask;
+      break;
+
+    case XK_Scroll_Lock:
+      pModMap[i] = ScrollLockMask;
+      break;
+
+      /* kana support */
+    case XK_Kana_Lock:
+    case XK_Kana_Shift:
+      pModMap[i] = KanaMask;
+      break;
+
+      /* alternate toggle for multinational support */
+    case XK_Mode_switch:
+      pModMap[i] = AltLangMask;
+      break;
+
+    }
+  
+  xf86Info.kbdType =
+    ioctl(xf86Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
+
+  pKeySyms->map        = map;
+  pKeySyms->mapWidth   = GLYPHS_PER_KEY;
+  pKeySyms->minKeyCode = MIN_KEYCODE;
+  if (xf86Info.serverNumLock)
+    pKeySyms->maxKeyCode = MAX_KEYCODE; 
+  else
+    pKeySyms->maxKeyCode = MAX_STD_KEYCODE;
+
+}
+
+#include <linux/keyboard.h>
+
+static KeySym linux_to_x[256] = {
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_BackSpace,	XK_Tab,		XK_Linefeed,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	XK_Escape,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_space,	XK_exclam,	XK_quotedbl,	XK_numbersign,
+	XK_dollar,	XK_percent,	XK_ampersand,	XK_apostrophe,
+	XK_parenleft,	XK_parenright,	XK_asterisk,	XK_plus,
+	XK_comma,	XK_minus,	XK_period,	XK_slash,
+	XK_0,		XK_1,		XK_2,		XK_3,
+	XK_4,		XK_5,		XK_6,		XK_7,
+	XK_8,		XK_9,		XK_colon,	XK_semicolon,
+	XK_less,	XK_equal,	XK_greater,	XK_question,
+	XK_at,		XK_A,		XK_B,		XK_C,
+	XK_D,		XK_E,		XK_F,		XK_G,
+	XK_H,		XK_I,		XK_J,		XK_K,
+	XK_L,		XK_M,		XK_N,		XK_O,
+	XK_P,		XK_Q,		XK_R,		XK_S,
+	XK_T,		XK_U,		XK_V,		XK_W,
+	XK_X,		XK_Y,		XK_Z,		XK_bracketleft,
+	XK_backslash,	XK_bracketright,XK_asciicircum,	XK_underscore,
+	XK_grave,	XK_a,		XK_b,		XK_c,
+	XK_d,		XK_e,		XK_f,		XK_g,
+	XK_h,		XK_i,		XK_j,		XK_k,
+	XK_l,		XK_m,		XK_n,		XK_o,
+	XK_p,		XK_q,		XK_r,		XK_s,
+	XK_t,		XK_u,		XK_v,		XK_w,
+	XK_x,		XK_y,		XK_z,		XK_braceleft,
+	XK_bar,		XK_braceright,	XK_asciitilde,	XK_Delete,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+	XK_nobreakspace,XK_exclamdown,	XK_cent,	XK_sterling,
+	XK_currency,	XK_yen,		XK_brokenbar,	XK_section,
+	XK_diaeresis,	XK_copyright,	XK_ordfeminine,	XK_guillemotleft,
+	XK_notsign,	XK_hyphen,	XK_registered,	XK_macron,
+	XK_degree,	XK_plusminus,	XK_twosuperior,	XK_threesuperior,
+	XK_acute,	XK_mu,		XK_paragraph,	XK_periodcentered,
+	XK_cedilla,	XK_onesuperior,	XK_masculine,	XK_guillemotright,
+	XK_onequarter,	XK_onehalf,	XK_threequarters,XK_questiondown,
+	XK_Agrave,	XK_Aacute,	XK_Acircumflex,	XK_Atilde,
+	XK_Adiaeresis,	XK_Aring,	XK_AE,		XK_Ccedilla,
+	XK_Egrave,	XK_Eacute,	XK_Ecircumflex,	XK_Ediaeresis,
+	XK_Igrave,	XK_Iacute,	XK_Icircumflex,	XK_Idiaeresis,
+	XK_ETH,		XK_Ntilde,	XK_Ograve,	XK_Oacute,
+	XK_Ocircumflex,	XK_Otilde,	XK_Odiaeresis,	XK_multiply,
+	XK_Ooblique,	XK_Ugrave,	XK_Uacute,	XK_Ucircumflex,
+	XK_Udiaeresis,	XK_Yacute,	XK_THORN,	XK_ssharp,
+	XK_agrave,	XK_aacute,	XK_acircumflex,	XK_atilde,
+	XK_adiaeresis,	XK_aring,	XK_ae,		XK_ccedilla,
+	XK_egrave,	XK_eacute,	XK_ecircumflex,	XK_ediaeresis,
+	XK_igrave,	XK_iacute,	XK_icircumflex,	XK_idiaeresis,
+	XK_eth,		XK_ntilde,	XK_ograve,	XK_oacute,
+	XK_ocircumflex,	XK_otilde,	XK_odiaeresis,	XK_division,
+	XK_oslash,	XK_ugrave,	XK_uacute,	XK_ucircumflex,
+	XK_udiaeresis,	XK_yacute,	XK_thorn,	XK_ydiaeresis
+};
+
+#ifndef ASSUME_CUSTOM_KEYCODES
+
+/*
+ * Maps the AT keycodes to Linux keycodes
+ */
+static unsigned char at2lnx[] =
+{
+	0x01,	/* KEY_Escape */	0x02,	/* KEY_1 */
+	0x03,	/* KEY_2 */		0x04,	/* KEY_3 */
+	0x05,	/* KEY_4 */		0x06,	/* KEY_5 */
+	0x07,	/* KEY_6 */		0x08,	/* KEY_7 */
+	0x09,	/* KEY_8 */		0x0a,	/* KEY_9 */
+	0x0b,	/* KEY_0 */		0x0c,	/* KEY_Minus */
+	0x0d,	/* KEY_Equal */		0x0e,	/* KEY_BackSpace */
+	0x0f,	/* KEY_Tab */		0x10,	/* KEY_Q */
+	0x11,	/* KEY_W */		0x12,	/* KEY_E */
+	0x13,	/* KEY_R */		0x14,	/* KEY_T */
+	0x15,	/* KEY_Y */		0x16,	/* KEY_U */
+	0x17,	/* KEY_I */		0x18,	/* KEY_O */
+	0x19,	/* KEY_P */		0x1a,	/* KEY_LBrace */
+	0x1b,	/* KEY_RBrace */	0x1c,	/* KEY_Enter */
+	0x1d,	/* KEY_LCtrl */		0x1e,	/* KEY_A */
+	0x1f,	/* KEY_S */		0x20,	/* KEY_D */
+	0x21,	/* KEY_F */		0x22,	/* KEY_G */
+	0x23,	/* KEY_H */		0x24,	/* KEY_J */
+	0x25,	/* KEY_K */		0x26,	/* KEY_L */
+	0x27,	/* KEY_SemiColon */	0x28,	/* KEY_Quote */
+	0x29,	/* KEY_Tilde */		0x2a,	/* KEY_ShiftL */
+	0x2b,	/* KEY_BSlash */	0x2c,	/* KEY_Z */
+	0x2d,	/* KEY_X */		0x2e,	/* KEY_C */
+	0x2f,	/* KEY_V */		0x30,	/* KEY_B */
+	0x31,	/* KEY_N */		0x32,	/* KEY_M */
+	0x33,	/* KEY_Comma */		0x34,	/* KEY_Period */
+	0x35,	/* KEY_Slash */		0x36,	/* KEY_ShiftR */
+	0x37,	/* KEY_KP_Multiply */	0x38,	/* KEY_Alt */
+	0x39,	/* KEY_Space */		0x3a,	/* KEY_CapsLock */
+	0x3b,	/* KEY_F1 */		0x3c,	/* KEY_F2 */
+	0x3d,	/* KEY_F3 */		0x3e,	/* KEY_F4 */
+	0x3f,	/* KEY_F5 */		0x40,	/* KEY_F6 */
+	0x41,	/* KEY_F7 */		0x42,	/* KEY_F8 */
+	0x43,	/* KEY_F9 */		0x44,	/* KEY_F10 */
+	0x45,	/* KEY_NumLock */	0x46,	/* KEY_ScrollLock */
+	0x47,	/* KEY_KP_7 */		0x48,	/* KEY_KP_8 */
+	0x49,	/* KEY_KP_9 */		0x4a,	/* KEY_KP_Minus */
+	0x4b,	/* KEY_KP_4 */		0x4c,	/* KEY_KP_5 */
+	0x4d,	/* KEY_KP_6 */		0x4e,	/* KEY_KP_Plus */
+	0x4f,	/* KEY_KP_1 */		0x50,	/* KEY_KP_2 */
+	0x51,	/* KEY_KP_3 */		0x52,	/* KEY_KP_0 */
+	0x53,	/* KEY_KP_Decimal */	0x54,	/* KEY_SysReqest */
+	0x00,	/* 0x55 */		0x56,	/* KEY_Less */
+	0x57,	/* KEY_F11 */		0x58,	/* KEY_F12 */
+	0x66,	/* KEY_Home */		0x67,	/* KEY_Up */
+	0x68,	/* KEY_PgUp */		0x69,	/* KEY_Left */
+	0x5d,	/* KEY_Begin */		0x6a,	/* KEY_Right */
+	0x6b,	/* KEY_End */		0x6c,	/* KEY_Down */
+	0x6d,	/* KEY_PgDown */	0x6e,	/* KEY_Insert */
+	0x6f,	/* KEY_Delete */	0x60,	/* KEY_KP_Enter */
+	0x61,	/* KEY_RCtrl */		0x77,	/* KEY_Pause */
+	0x63,	/* KEY_Print */		0x62,	/* KEY_KP_Divide */
+	0x64,	/* KEY_AltLang */	0x65,	/* KEY_Break */
+	0x00,	/* KEY_LMeta */		0x00,	/* KEY_RMeta */
+	0x7A,	/* KEY_Menu/FOCUS_PF11*/0x00,	/* 0x6e */
+	0x7B,	/* FOCUS_PF12 */	0x00,	/* 0x70 */
+	0x00,	/* 0x71 */		0x00,	/* 0x72 */
+	0x59,	/* FOCUS_PF2 */		0x78,	/* FOCUS_PF9 */
+	0x00,	/* 0x75 */		0x00,	/* 0x76 */
+	0x5A,	/* FOCUS_PF3 */		0x5B,	/* FOCUS_PF4 */
+	0x5C,	/* FOCUS_PF5 */		0x5D,	/* FOCUS_PF6 */
+	0x5E,	/* FOCUS_PF7 */		0x5F,	/* FOCUS_PF8 */
+	0x7C,	/* JAP_86 */		0x79,	/* FOCUS_PF10 */
+	0x00,	/* 0x7f */
+	/* the following are for ServerNumLock handling */
+	0x47,	/* KEY_SN_KP_7 */	0x48,	/* KEY_SN_KP_8 */
+	0x49,	/* KEY_SN_KP_9 */	0x4b,	/* KEY_SN_KP_4 */
+	0x4c,	/* KEY_SN_KP_5 */	0x4d,	/* KEY_SN_KP_6 */
+	0x4f,	/* KEY_SN_KP_1 */	0x50,	/* KEY_SN_KP_2 */
+	0x51,	/* KEY_SN_KP_3 */	0x52,	/* KEY_SN_KP_0 */
+	0x53,	/* KEY_SN_KP_Decimal */	0x66,	/* KEY_SN_Home */
+	0x67,	/* KEY_SN_Up */		0x68,	/* KEY_SN_Prior */
+	0x69,	/* KEY_SN_Left */	0x5d,	/* KEY_SN_Begin */
+	0x6a,	/* KEY_SN_Right */	0x6b,	/* KEY_SN_End */
+	0x6c,	/* KEY_SN_Down */	0x6d,	/* KEY_SN_Next */
+	0x6e,	/* KEY_SN_Ins */	0x6f	/* KEY_SN_Del */
+};
+#define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
+
+#else /* !ASSUME_CUSTOM_KEYCODES */
+
+#define NUM_AT2LNX	NR_KEYS
+
+u_char SpecialServerMap[NR_KEYS];
+
+#endif /* !ASSUME_CUSTOM_KEYCODES */
+
+static void
+readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
+{
+  KeySym        *k;
+  int           i;
+  static unsigned char tbl[GLYPHS_PER_KEY] =
+  {
+	0,	/* unshifted */
+	1,	/* shifted */
+	0,	/* modeswitch unshifted */
+	0	/* modeswitch shifted */
+  };
+
+  /*
+   * Read the mapping from the kernel.
+   * Since we're still using the XFree86 scancode->AT keycode mapping
+   * routines, we need to convert the AT keycodes to Linux keycodes,
+   * then translate the Linux keysyms into X keysyms.
+   *
+   * First, figure out which tables to use for the modeswitch columns
+   * above, from the XF86Config fields.
+   */
+  if (xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODESHIFT ||
+      xf86Info.specialKeyMap[K_INDEX_RIGHTCTL] == KM_MODELOCK)
+    tbl[2] = 4;	/* control */
+  else if (xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODESHIFT ||
+           xf86Info.specialKeyMap[K_INDEX_RIGHTALT] == KM_MODELOCK)
+    tbl[2] = 2;	/* AltGr */
+  else
+    tbl[2] = 8;	/* alt */
+  tbl[3] = tbl[2] | 1;
+
+#ifndef ASSUME_CUSTOM_KEYCODES
+  for (i = 0, k = map+GLYPHS_PER_KEY; i < NUM_AT2LNX; ++i)
+#else /* !ASSUME_CUSTOM_KEYCODES */
+  for (i = 0, k = map; i < NUM_AT2LNX; ++i)
+#endif /* !ASSUME_CUSTOM_KEYCODES */
+  {
+    struct kbentry kbe;
+    int j;
+
+#ifndef ASSUME_CUSTOM_KEYCODES
+    kbe.kb_index = at2lnx[i];
+#else /* !ASSUME_CUSTOM_KEYCODES */
+    kbe.kb_index = i;
+#endif /* !ASSUME_CUSTOM_KEYCODES */
+
+    for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
+    {
+      unsigned short kval;
+
+      *k = NoSymbol;
+
+      kbe.kb_table = tbl[j];
+      if (
+#ifndef ASSUME_CUSTOM_KEYCODES
+	  kbe.kb_index == 0 ||
+#endif /* !ASSUME_CUSTOM_KEYCODES */
+	  ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
+	continue;
+      kval = KVAL(kbe.kb_value);
+      switch (KTYP(kbe.kb_value))
+      {
+      case KT_LATIN:
+      case KT_LETTER:
+	*k = linux_to_x[kval];
+	break;
+
+      case KT_FN:
+	if (kval <= 19)
+	  *k = XK_F1 + kval;
+	else switch (kbe.kb_value)
+	{
+	case K_FIND:
+	  *k = XK_Home; /* or XK_Find */
+	  break;
+	case K_INSERT:
+	  *k = XK_Insert;
+	  break;
+	case K_REMOVE:
+	  *k = XK_Delete;
+	  break;
+	case K_SELECT:
+	  *k = XK_End; /* or XK_Select */
+	  break;
+	case K_PGUP:
+	  *k = XK_Prior;
+	  break;
+	case K_PGDN:
+	  *k = XK_Next;
+	  break;
+	case K_HELP:
+	  *k = XK_Help;
+	  break;
+	case K_DO:
+	  *k = XK_Execute;
+	  break;
+	case K_PAUSE:
+	  *k = XK_Pause;
+	  break;
+	case K_MACRO:
+	  *k = XK_Menu;
+	  break;
+	default:
+	  break;
+	}
+	break;
+
+      case KT_SPEC:
+	switch (kbe.kb_value)
+	{
+	case K_ENTER:
+	  *k = XK_Return;
+	  break;
+	case K_BREAK:
+	  *k = XK_Break;
+	  break;
+	case K_CAPS:
+	  *k = XK_Caps_Lock;
+	  break;
+	case K_NUM:
+	  *k = XK_Num_Lock;
+	  break;
+	case K_HOLD:
+	  *k = XK_Scroll_Lock;
+	  break;
+	case K_COMPOSE:
+          *k = XK_Multi_key;
+	  break;
+	default:
+	  break;
+	}
+	break;
+
+      case KT_PAD:
+	switch (kbe.kb_value)
+	{
+	case K_PPLUS:
+	  *k = XK_KP_Add;
+	  break;
+	case K_PMINUS:
+	  *k = XK_KP_Subtract;
+	  break;
+	case K_PSTAR:
+	  *k = XK_KP_Multiply;
+	  break;
+	case K_PSLASH:
+	  *k = XK_KP_Divide;
+	  break;
+	case K_PENTER:
+	  *k = XK_KP_Enter;
+	  break;
+	case K_PCOMMA:
+	  *k = XK_KP_Separator;
+	  break;
+	case K_PDOT:
+	  *k = XK_KP_Decimal;
+	  break;
+	case K_PPLUSMINUS:
+	  *k = XK_KP_Subtract;
+	  break;
+	default:
+	  if (kval <= 9)
+	    *k = XK_KP_0 + kval;
+	  break;
+	}
+	break;
+
+      /*
+       * KT_DEAD keys are for accelerated diacritical creation.
+       */
+      case KT_DEAD:
+	switch (kbe.kb_value)
+	  {
+	  case K_DGRAVE:
+	    *k = XK_dead_grave;
+	    break;
+	  case K_DACUTE:
+	    *k = XK_dead_acute;
+	    break;
+	  case K_DCIRCM:
+	    *k = XK_dead_circumflex;
+	    break;
+	  case K_DTILDE:
+	    *k = XK_dead_tilde;
+	    break;
+	  case K_DDIERE:
+	    *k = XK_dead_diaeresis;
+	    break;
+	  }
+	break;
+
+      case KT_CUR:
+	switch (kbe.kb_value)
+	{
+	case K_DOWN:
+	  *k = XK_Down;
+	  break;
+	case K_LEFT:
+	  *k = XK_Left;
+	  break;
+	case K_RIGHT:
+	  *k = XK_Right;
+	  break;
+	case K_UP:
+	  *k = XK_Up;
+	  break;
+	}
+	break;
+
+      case KT_SHIFT:
+	switch (kbe.kb_value)
+	{
+	case K_ALTGR:
+	  *k = XK_Alt_R;
+	  break;
+	case K_ALT:
+	  *k = (kbe.kb_index == 0x64 ?
+		XK_Alt_R : XK_Alt_L);
+	  break;
+	case K_CTRL:
+	  *k = (kbe.kb_index == 0x61 ?
+		XK_Control_R : XK_Control_L);
+	  break;
+        case K_CTRLL:
+	  *k = XK_Control_L;
+	  break;
+        case K_CTRLR:
+	  *k = XK_Control_R;
+	  break;
+	case K_SHIFT:
+	  *k = (kbe.kb_index == 0x36 ?
+		XK_Shift_R : XK_Shift_L);
+	  break;
+        case K_SHIFTL:
+	  *k = XK_Shift_L;
+	  break;
+        case K_SHIFTR:
+	  *k = XK_Shift_R;
+	  break;
+	default:
+	  break;
+	}
+	break;
+
+      /*
+       * KT_ASCII keys accumulate a 3 digit decimal number that gets
+       * emitted when the shift state changes. We can't emulate that.
+       */
+      case KT_ASCII:
+	break;
+
+      case KT_LOCK:
+	if (kbe.kb_value == K_SHIFTLOCK)
+	  *k = XK_Shift_Lock;
+	break;
+
+      default:
+	break;
+      }
+    }
+
+    if (k[-1] == k[-2]) k[-1] = NoSymbol;
+    if (k[-2] == k[-3]) k[-2] = NoSymbol;
+    if (k[-3] == k[-4]) k[-3] = NoSymbol;
+    if (k[-4] == k[-2] && k[-3] == k[-1]) k[-2] = k[-1] = NoSymbol;
+    if (k[-1] == k[-4] && k[-2] == k[-3] && k[-2] == NoSymbol) k[-1] =NoSymbol;
+  }
+#ifdef ASSUME_CUSTOM_KEYCODES
+  /*
+   * Find the Mapping for the special server functions
+   */
+  for (i = 0; i < NR_KEYS; ++i) {
+    struct kbentry kbe;
+    int special = 0;
+
+    kbe.kb_index = i;
+    kbe.kb_table = 0; /* Plain map */
+    if (!ioctl(xf86Info.consoleFd, KDGKBENT, &kbe))
+      switch (kbe.kb_value) {
+	case K(KT_LATIN,0x7f):	/* This catches DEL too... But who cares? */
+	  special = KEY_BackSpace;
+	  break;
+	case K_PMINUS:
+	  special = KEY_KP_Minus;
+	  break;
+	case K_PPLUS:
+	  special = KEY_KP_Plus;
+	  break;
+	case K_F1:
+	  special = KEY_F1;
+	  break;
+	case K_F2:
+	  special = KEY_F2;
+	  break;
+	case K_F3:
+	  special = KEY_F3;
+	  break;
+	case K_F4:
+	  special = KEY_F4;
+	  break;
+	case K_F5:
+	  special = KEY_F5;
+	  break;
+	case K_F6:
+	  special = KEY_F6;
+	  break;
+	case K_F7:
+	  special = KEY_F7;
+	  break;
+	case K_F8:
+	  special = KEY_F8;
+	  break;
+	case K_F9:
+	  special = KEY_F9;
+	  break;
+	case K_F10:
+	  special = KEY_F10;
+	  break;
+	case K_F11:
+	  special = KEY_F11;
+	  break;
+	case K_F12:
+	  special = KEY_F12;
+	  break;
+	case K_ALT:
+	  special = KEY_Alt;
+	  break;
+	case K_ALTGR:
+	  special = KEY_AltLang;
+	  break;
+	case K_CONS:
+	  special = KEY_SysReqest;
+	  break;
+      }
+    SpecialServerMap[i] = special;
+  }
+#endif /* ASSUME_CUSTOM_KEYCODES */
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Keymap.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Keymap.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Keymap.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Keymap.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,319 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Keymap.h,v 3.9 1996/12/23 06:43:35 dawes Exp $ */
+/*
+ *
+ * For Scancodes see notes in atKeynames.h  !!!!
+ *
+ */
+/* $XConsortium: xf86Keymap.h /main/14 1996/02/21 17:38:47 kaleb $ */
+
+static KeySym map[NUM_KEYCODES * GLYPHS_PER_KEY] = { 
+    /* 0x00 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x01 */  XK_Escape,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x02 */  XK_1,           XK_exclam,	NoSymbol,	NoSymbol,
+    /* 0x03 */  XK_2,           XK_at,		NoSymbol,	NoSymbol,
+    /* 0x04 */  XK_3,           XK_numbersign,	NoSymbol,	NoSymbol,
+    /* 0x05 */  XK_4,           XK_dollar,	NoSymbol,	NoSymbol,
+    /* 0x06 */  XK_5,           XK_percent,	NoSymbol,	NoSymbol,
+    /* 0x07 */  XK_6,           XK_asciicircum,	NoSymbol,	NoSymbol,
+    /* 0x08 */  XK_7,           XK_ampersand,	NoSymbol,	NoSymbol,
+    /* 0x09 */  XK_8,           XK_asterisk,	NoSymbol,	NoSymbol,
+    /* 0x0a */  XK_9,           XK_parenleft,	NoSymbol,	NoSymbol,
+    /* 0x0b */  XK_0,           XK_parenright,	NoSymbol,	NoSymbol,
+    /* 0x0c */  XK_minus,       XK_underscore,	NoSymbol,	NoSymbol,
+    /* 0x0d */  XK_equal,       XK_plus,	NoSymbol,	NoSymbol,
+    /* 0x0e */  XK_BackSpace,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0f */  XK_Tab,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x10 */  XK_Q,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x11 */  XK_W,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x12 */  XK_E,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x13 */  XK_R,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x14 */  XK_T,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x15 */  XK_Y,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x16 */  XK_U,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x17 */  XK_I,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x18 */  XK_O,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x19 */  XK_P,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1a */  XK_bracketleft, XK_braceleft,	NoSymbol,	NoSymbol,
+    /* 0x1b */  XK_bracketright,XK_braceright,	NoSymbol,	NoSymbol,
+    /* 0x1c */  XK_Return,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1d */  XK_Control_L,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1e */  XK_A,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1f */  XK_S,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x20 */  XK_D,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x21 */  XK_F,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x22 */  XK_G,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x23 */  XK_H,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x24 */  XK_J,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x25 */  XK_K,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x26 */  XK_L,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x27 */  XK_semicolon,   XK_colon,	NoSymbol,	NoSymbol,
+    /* 0x28 */  XK_quoteright,  XK_quotedbl,	NoSymbol,	NoSymbol,
+    /* 0x29 */  XK_quoteleft,	XK_asciitilde,	NoSymbol,	NoSymbol,
+    /* 0x2a */  XK_Shift_L,     NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2b */  XK_backslash,   XK_bar,		NoSymbol,	NoSymbol,
+    /* 0x2c */  XK_Z,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2d */  XK_X,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2e */  XK_C,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2f */  XK_V,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x30 */  XK_B,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x31 */  XK_N,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x32 */  XK_M,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x33 */  XK_comma,       XK_less,	NoSymbol,	NoSymbol,
+    /* 0x34 */  XK_period,      XK_greater,	NoSymbol,	NoSymbol,
+    /* 0x35 */  XK_slash,       XK_question,	NoSymbol,	NoSymbol,
+    /* 0x36 */  XK_Shift_R,     NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x37 */  XK_KP_Multiply, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x38 */  XK_Alt_L,	XK_Meta_L,	NoSymbol,	NoSymbol,
+    /* 0x39 */  XK_space,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3a */  XK_Caps_Lock,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3b */  XK_F1,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3c */  XK_F2,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3d */  XK_F3,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3e */  XK_F4,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3f */  XK_F5,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x40 */  XK_F6,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x41 */  XK_F7,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x42 */  XK_F8,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x43 */  XK_F9,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x44 */  XK_F10,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x45 */  XK_Num_Lock,    NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x46 */  XK_Scroll_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x47 */  XK_KP_Home,	XK_KP_7,	NoSymbol,	NoSymbol,
+    /* 0x48 */  XK_KP_Up,	XK_KP_8,	NoSymbol,	NoSymbol,
+    /* 0x49 */  XK_KP_Prior,	XK_KP_9,	NoSymbol,	NoSymbol,
+    /* 0x4a */  XK_KP_Subtract, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4b */  XK_KP_Left,	XK_KP_4,	NoSymbol,	NoSymbol,
+    /* 0x4c */  NoSymbol,	XK_KP_5,	NoSymbol,	NoSymbol,
+    /* 0x4d */  XK_KP_Right,	XK_KP_6,	NoSymbol,	NoSymbol,
+    /* 0x4e */  XK_KP_Add,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4f */  XK_KP_End,	XK_KP_1,	NoSymbol,	NoSymbol,
+    /* 0x50 */  XK_KP_Down,	XK_KP_2,	NoSymbol,	NoSymbol,
+    /* 0x51 */  XK_KP_Next,	XK_KP_3,	NoSymbol,	NoSymbol,
+    /* 0x52 */  XK_KP_Insert,	XK_KP_0,	NoSymbol,	NoSymbol,
+    /* 0x53 */  XK_KP_Delete,	XK_KP_Decimal,	NoSymbol,	NoSymbol,
+    /* 0x54 */  XK_Sys_Req,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x55 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x56 */  XK_less,	XK_greater,	NoSymbol,	NoSymbol,
+    /* 0x57 */  XK_F11,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x58 */  XK_F12,		NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* 0x59 */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5a */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5b */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5c */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5d */  XK_Begin,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5e */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5f */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x60 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x61 */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x62 */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x63 */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x64 */  XK_KP_Enter,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x65 */  XK_Control_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x66 */  XK_Pause,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x67 */  XK_Print,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x68 */  XK_KP_Divide,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x69 */  XK_Alt_R,	XK_Meta_R,	NoSymbol,	NoSymbol,
+    /* 0x6a */  XK_Break,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6b */  XK_Meta_L,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6c */  XK_Meta_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6d */  XK_Menu,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x70 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x71 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x72 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x73 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x74 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x75 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x76 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x77 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x78 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x79 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* These are for ServerNumLock handling */
+    /* 0x80 */  XK_KP_7,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x81 */  XK_KP_8,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x82 */  XK_KP_9,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x83 */  XK_KP_4,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x84 */  XK_KP_5,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x85 */  XK_KP_6,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x86 */  XK_KP_1,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x87 */  XK_KP_2,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x88 */  XK_KP_3,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x89 */  XK_KP_0,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8a */  XK_KP_Decimal,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8b */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8c */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8d */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8e */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8f */  XK_Begin,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x90 */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x91 */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x92 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x93 */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x94 */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x95 */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
+};
+
+static KeySym map84[NUM_KEYCODES * GLYPHS_PER_KEY] = { 
+    /* 0x00 */  NoSymbol,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x01 */  XK_Escape,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x02 */  XK_1,           XK_exclam,	NoSymbol,	NoSymbol,
+    /* 0x03 */  XK_2,           XK_at,		NoSymbol,	NoSymbol,
+    /* 0x04 */  XK_3,           XK_numbersign,	NoSymbol,	NoSymbol,
+    /* 0x05 */  XK_4,           XK_dollar,	NoSymbol,	NoSymbol,
+    /* 0x06 */  XK_5,           XK_percent,	NoSymbol,	NoSymbol,
+    /* 0x07 */  XK_6,           XK_asciicircum,	NoSymbol,	NoSymbol,
+    /* 0x08 */  XK_7,           XK_ampersand,	NoSymbol,	NoSymbol,
+    /* 0x09 */  XK_8,           XK_asterisk,	NoSymbol,	NoSymbol,
+    /* 0x0a */  XK_9,           XK_parenleft,	NoSymbol,	NoSymbol,
+    /* 0x0b */  XK_0,           XK_parenright,	NoSymbol,	NoSymbol,
+    /* 0x0c */  XK_minus,       XK_underscore,	NoSymbol,	NoSymbol,
+    /* 0x0d */  XK_equal,       XK_plus,	NoSymbol,	NoSymbol,
+    /* 0x0e */  XK_BackSpace,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x0f */  XK_Tab,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x10 */  XK_Q,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x11 */  XK_W,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x12 */  XK_E,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x13 */  XK_R,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x14 */  XK_T,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x15 */  XK_Y,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x16 */  XK_U,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x17 */  XK_I,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x18 */  XK_O,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x19 */  XK_P,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1a */  XK_bracketleft, XK_braceleft,	NoSymbol,	NoSymbol,
+    /* 0x1b */  XK_bracketright,XK_braceright,	NoSymbol,	NoSymbol,
+    /* 0x1c */  XK_Return,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1d */  XK_Control_L,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1e */  XK_A,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x1f */  XK_S,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x20 */  XK_D,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x21 */  XK_F,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x22 */  XK_G,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x23 */  XK_H,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x24 */  XK_J,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x25 */  XK_K,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x26 */  XK_L,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x27 */  XK_semicolon,   XK_colon,	NoSymbol,	NoSymbol,
+    /* 0x28 */  XK_quoteright,  XK_quotedbl,	NoSymbol,	NoSymbol,
+    /* 0x29 */  XK_quoteleft,	XK_asciitilde,	NoSymbol,	NoSymbol,
+    /* 0x2a */  XK_Shift_L,     NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2b */  XK_backslash,   XK_bar,		NoSymbol,	NoSymbol,
+    /* 0x2c */  XK_Z,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2d */  XK_X,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2e */  XK_C,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x2f */  XK_V,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x30 */  XK_B,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x31 */  XK_N,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x32 */  XK_M,           NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x33 */  XK_comma,       XK_less,	NoSymbol,	NoSymbol,
+    /* 0x34 */  XK_period,      XK_greater,	NoSymbol,	NoSymbol,
+    /* 0x35 */  XK_slash,       XK_question,	NoSymbol,	NoSymbol,
+    /* 0x36 */  XK_Shift_R,     NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x37 */  XK_KP_Multiply, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x38 */  XK_Alt_L,	XK_Meta_L,	NoSymbol,	NoSymbol,
+    /* 0x39 */  XK_space,       NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3a */  XK_Caps_Lock,   NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3b */  XK_F1,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3c */  XK_F2,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3d */  XK_F3,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3e */  XK_F4,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x3f */  XK_F5,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x40 */  XK_F6,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x41 */  XK_F7,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x42 */  XK_F8,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x43 */  XK_F9,          NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x44 */  XK_F10,         NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x45 */  XK_Num_Lock,    NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x46 */  XK_Scroll_Lock,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x47 */  XK_KP_Home,	XK_KP_7,	NoSymbol,	NoSymbol,
+    /* 0x48 */  XK_KP_Up,	XK_KP_8,	NoSymbol,	NoSymbol,
+    /* 0x49 */  XK_KP_Prior,	XK_KP_9,	NoSymbol,	NoSymbol,
+    /* 0x4a */  XK_KP_Subtract, NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4b */  XK_KP_Left,	XK_KP_4,	NoSymbol,	NoSymbol,
+    /* 0x4c */  NoSymbol,	XK_KP_5,	NoSymbol,	NoSymbol,
+    /* 0x4d */  XK_KP_Right,	XK_KP_6,	NoSymbol,	NoSymbol,
+    /* 0x4e */  XK_KP_Add,      NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x4f */  XK_KP_End,	XK_KP_1,	NoSymbol,	NoSymbol,
+    /* 0x50 */  XK_KP_Down,	XK_KP_2,	NoSymbol,	NoSymbol,
+    /* 0x51 */  XK_KP_Next,	XK_KP_3,	NoSymbol,	NoSymbol,
+    /* 0x52 */  XK_KP_Insert,	XK_KP_0,	NoSymbol,	NoSymbol,
+    /* 0x53 */  XK_KP_Delete,	XK_KP_Decimal,	NoSymbol,	NoSymbol,
+    /* 0x54 */  XK_Sys_Req,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x55 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x56 */  XK_less,	XK_greater,	NoSymbol,	NoSymbol,
+    /* 0x57 */  XK_F11,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x58 */  XK_F12,		NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* 0x59 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x5f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x60 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x61 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x62 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x63 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x64 */  XK_KP_Enter,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x65 */  XK_Control_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x66 */  XK_Pause,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x67 */  XK_Print,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x68 */  XK_KP_Divide,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x69 */  XK_Alt_R,	XK_Meta_R,	NoSymbol,	NoSymbol,
+    /* 0x6a */  XK_Break,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6b */  XK_Meta_L,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6c */  XK_Meta_R,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6d */  XK_Menu,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x6f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x70 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x71 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x72 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x73 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x74 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x75 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x76 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x77 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x78 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x79 */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7a */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7b */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7c */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7d */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7e */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x7f */  NoSymbol,	NoSymbol,	NoSymbol,	NoSymbol,
+
+    /* These are for ServerNumLock handling */
+    /* 0x80 */  XK_KP_7,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x81 */  XK_KP_8,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x82 */  XK_KP_9,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x83 */  XK_KP_4,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x84 */  XK_KP_5,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x85 */  XK_KP_6,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x86 */  XK_KP_1,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x87 */  XK_KP_2,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x88 */  XK_KP_3,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x89 */  XK_KP_0,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8a */  XK_KP_Decimal,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8b */  XK_Home,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8c */  XK_Up,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8d */  XK_Prior,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8e */  XK_Left,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x8f */  XK_Begin,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x90 */  XK_Right,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x91 */  XK_End,		NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x92 */  XK_Down,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x93 */  XK_Next,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x94 */  XK_Insert,	NoSymbol,	NoSymbol,	NoSymbol,
+    /* 0x95 */  XK_Delete,	NoSymbol,	NoSymbol,	NoSymbol,
+};
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Priv.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Priv.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Priv.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Priv.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,156 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Priv.h,v 3.24.2.1 1998/02/01 16:04:47 robin Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86Priv.h /main/18 1996/10/25 11:36:38 kaleb $ */
+
+#ifndef _XF86PRIV_H
+#define _XF86PRIV_H
+
+#ifndef _XF86VIDMODE_SERVER_
+#include "Xproto.h"
+#include "xf86_OSproc.h"
+#endif
+
+typedef struct {
+
+  /* keyboard part */
+  DeviceIntPtr  pKeyboard;
+  DeviceProc    kbdProc;              /* procedure for initializing */
+  void          (* kbdEvents)(        /* proc for processing events */
+#if NeedNestedPrototypes && !defined(__OSF__)
+                void
+#endif
+                );
+  int           consoleFd;
+  int           vtno;
+  int           kbdType;              /* AT84 / AT101 */
+  int           kbdRate;
+  int           kbdDelay;
+  int           bell_pitch;
+  int           bell_duration;
+  Bool          autoRepeat;
+  unsigned long leds;
+  unsigned long xleds;
+  char          *vtinit;
+  int           *specialKeyMap;
+  int           scanPrefix;           /* scancode-state */
+  Bool          capsLock;
+  Bool          numLock;
+  Bool          scrollLock;
+  Bool          modeSwitchLock;
+  Bool          serverNumLock;
+  Bool          composeLock;
+  Bool          vtSysreq;
+
+  /* mouse part */
+  DeviceIntPtr  pMouse;
+  MouseDevPtr	mouseDev;
+
+  /* event handler part */
+  int           lastEventTime;
+  Bool          vtRequestsPending;
+  Bool          inputPending;
+  Bool          dontZap;
+  Bool		dontZoom;
+  Bool          notrapSignals;           /* don't exit cleanly - die at fault */
+  Bool          caughtSignal;
+
+  /* graphics part */
+  Bool          sharedMonitor;
+  ScreenPtr     currentScreen;
+#ifdef CSRG_BASED
+  int           screenFd;	/* fd for memory mapped access to vga card */
+  int		consType;	/* Which console driver? */
+#endif
+
+#ifdef XKB
+/*
+ * would like to use an XkbComponentNamesRec here but can't without
+ * pulling in a bunch of header files. :-(
+*/
+  char      *xkbkeymap;
+  char      *xkbkeycodes;
+  char      *xkbtypes;
+  char      *xkbcompat;
+  char      *xkbsymbols;
+  char      *xkbgeometry;
+  Bool      xkbcomponents_specified;
+  char      *xkbrules;
+  char      *xkbmodel;
+  char      *xkblayout;
+  char      *xkbvariant;
+  char      *xkboptions;
+#endif
+
+} xf86InfoRec, *xf86InfoPtr;
+
+extern xf86InfoRec xf86Info;
+
+/* ISC's cc can't handle ~ of UL constants, so explicitly type cast them. */
+#define XLED1   ((unsigned long) 0x00000001)
+#define XLED2   ((unsigned long) 0x00000002)
+#define XLED3   ((unsigned long) 0x00000004)
+#define XCAPS   ((unsigned long) 0x20000000)
+#define XNUM    ((unsigned long) 0x40000000)
+#define XSCR    ((unsigned long) 0x80000000)
+#define XCOMP	((unsigned long) 0x00008000)
+
+/* 386BSD console driver types (consType) */
+#ifdef CSRG_BASED
+#define PCCONS		   0
+#define CODRV011	   1
+#define CODRV01X	   2
+#define SYSCONS		   8
+#define PCVT		  16
+#endif
+
+/* Values of xf86Info.mouseFlags */
+#define MF_CLEAR_DTR       1
+#define MF_CLEAR_RTS       2
+
+
+extern int xf86MaxScreens;
+extern ScrnInfoPtr xf86Screens[];
+extern int xf86ScreenNames[];
+
+extern char xf86ConfigFile[];
+extern int xf86Verbose;
+extern Bool xf86ProbeOnly, xf86ProbeFailed;
+extern unsigned short xf86MouseCflags[];
+extern Bool xf86SupportedMouseTypes[];
+extern int xf86NumMouseTypes;
+extern int xf86bpp;
+extern xrgb xf86weight;
+extern Bool xf86AllowMouseOpenFail;
+extern Bool xf86BestRefresh;
+
+extern Bool xf86FlipPixels;
+#define XF86FLIP_PIXELS() \
+	if (xf86FlipPixels) { \
+		pScreen->whitePixel = (pScreen->whitePixel) ? 0 : 1; \
+		pScreen->blackPixel = (pScreen->blackPixel) ? 0 : 1; \
+	}
+
+#endif /* _XF86PRIV_H */
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Procs.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Procs.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Procs.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Procs.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,305 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86Procs.h,v 3.10 1996/12/23 06:43:38 dawes Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Thomas Roell not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Thomas Roell makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS ROELL BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86Procs.h /main/9 1996/10/19 17:59:14 kaleb $ */
+
+#ifndef _XF86PROCS_H
+#define _XF86PROCS_H
+
+#include <X11/Xfuncproto.h>
+#include "xf86.h"
+#include "xf86Priv.h"
+
+_XFUNCPROTOBEGIN
+
+/* xf86Config.c */
+extern void xf86CheckBeta(
+#if NeedFunctionPrototypes
+	int			/* extraDays */,
+	char *			/* key */
+#endif 
+);
+
+/* xf86Config.c */
+
+#ifndef CONFIG_RETURN_TYPE
+#ifdef XF86SETUP
+#define CONFIG_RETURN_TYPE int
+#else
+#define CONFIG_RETURN_TYPE void
+#endif
+#endif
+
+extern CONFIG_RETURN_TYPE xf86Config(
+#if NeedFunctionPrototypes
+    int vtopen
+#endif
+);
+
+extern Bool xf86LookupMode(
+#if NeedFunctionPrototypes
+	DisplayModePtr,		/* target */
+	ScrnInfoPtr,		/* driver */
+	int			/* flags */
+#endif 
+);
+
+extern void xf86VerifyOptions(
+#if NeedFunctionPrototypes
+	OFlagSet *,		/* allowedOptions */
+	ScrnInfoPtr		/* driver */
+#endif
+);
+
+extern void xf86DeleteMode(
+#if NeedFunctionPrototypes
+	ScrnInfoPtr,		/* infoptr */
+	DisplayModePtr		/* dispmp */
+#endif
+);
+
+extern int xf86GetToken(
+#if NeedFunctionPrototypes
+	SymTabPtr		/* table */
+#endif
+);
+
+extern char *xf86TokenToString(
+#if NeedFunctionPrototypes
+	SymTabPtr,		/* table */
+	int			/* token */
+#endif
+);
+
+extern int xf86StringToToken(
+#if NeedFunctionPrototypes
+	SymTabPtr,		/* table */
+	char *			/* string */
+#endif
+);
+
+extern void xf86ConfigError(
+#if NeedFunctionPrototypes
+	char *			/* msg */
+#endif
+)
+#if __GNUC__
+__attribute__((noreturn))
+#endif
+;
+
+/* xf86Cursor.c */
+
+extern void xf86InitViewport(
+#if NeedFunctionPrototypes
+	ScrnInfoPtr		/* pScr */
+#endif 
+);
+
+extern void xf86SetViewport(
+#if NeedFunctionPrototypes
+	ScreenPtr,		/* pScreen */
+	int,			/* x */
+	int			/* y */
+#endif 
+);
+
+extern void xf86ZoomViewport(
+#if NeedFunctionPrototypes
+	ScreenPtr,		/* pScreen */
+	int			/* zoom */
+#endif 
+);
+
+
+/* xf86Events.c */
+
+extern void ProcessInputEvents(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+
+extern void xf86PostKbdEvent(
+#if NeedFunctionPrototypes
+	unsigned		/* key */
+#endif 
+);
+
+extern void xf86PostMseEvent(
+#if NeedFunctionPrototypes
+        DeviceIntPtr,		/* device */
+	int,			/* buttons */
+	int,			/* dx */
+	int			/* dy */
+#endif
+);
+
+extern void xf86Block(
+#if NeedFunctionPrototypes
+	pointer,		/* blockData */
+	OSTimePtr,		/* pTimeout */
+	pointer			/* pReadmask */
+#endif
+);
+
+extern void xf86Wakeup(
+#if NeedFunctionPrototypes
+	pointer,		/* blockData */
+	int,			/* err */
+	pointer			/* pReadmask */
+#endif
+);
+
+extern void xf86VTRequest(
+#if NeedFunctionPrototypes
+	int			/* signo */
+#endif
+);
+
+extern void xf86SigHandler(
+#if NeedFunctionPrototypes
+	int		       /* signo */
+#endif
+);
+
+/* xf86Io.c */
+
+extern void xf86KbdLeds(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+
+extern void xf86InitKBD(
+#if NeedFunctionPrototypes
+	Bool			/* init */
+#endif
+);
+
+#ifdef NEED_EVENTS
+extern void xf86KbdBell(
+#if NeedFunctionPrototypes
+	int,			/* loudness */
+	DeviceIntPtr, 		/* pKeyboard */
+	pointer, 		/* ctrl */
+	int
+#endif
+);
+#endif
+
+extern void xf86KbdCtrl(
+#if NeedFunctionPrototypes
+	DevicePtr,		/* pKeyboard */
+	KeybdCtrl *		/* ctrl */
+#endif
+);
+
+extern int  xf86KbdProc(
+#if NeedFunctionPrototypes
+	DeviceIntPtr,		/* pKeyboard */
+	int			/* what */
+#endif
+);
+
+extern void xf86KbdEvents(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+
+extern void xf86MseCtrl(
+#if NeedFunctionPrototypes
+	DevicePtr,		/* pPointer */
+	PtrCtrl*		/* ctrl */
+#endif
+);
+
+extern int  xf86MseProc(
+#if NeedFunctionPrototypes
+	DeviceIntPtr,		/* pPointer */
+	int			/* what */
+#endif
+);
+
+extern int  
+xf86MseProcAux(
+#if NeedFunctionPrototypes
+       DeviceIntPtr,		/* pPointer */
+       int,			/* what */
+       MouseDevPtr,		/* mouse */
+       int*,                    /* fd */
+       PtrCtrlProcPtr		/* ctrl */
+#endif
+	       );
+
+extern void xf86MseEvents(
+#if NeedFunctionPrototypes
+        MouseDevPtr		/* mouse */
+#endif
+);
+
+/* xf86_Mouse.c */
+
+extern Bool xf86MouseSupported(
+#if NeedFunctionPrototypes
+	int			/* mousetype */
+#endif
+);
+
+extern void xf86SetupMouse(
+#if NeedFunctionPrototypes
+	MouseDevPtr
+#endif
+);
+
+extern void xf86MouseProtocol(
+#if NeedFunctionPrototypes
+        DeviceIntPtr,		/* device */
+	unsigned char *,	/* rBuf */
+	int			/* nBytes */
+#endif
+);
+
+
+/* xf86Kbd.c */
+
+extern void xf86KbdGetMapping(
+#if NeedFunctionPrototypes
+	KeySymsRec *,		/* pKeySyms */
+	CARD8 *			/* pModMap */
+#endif
+);
+
+/* xf86XKB.c */
+extern void xf86InitXkb(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XF86PROCS_H */
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86Version.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Version.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86Version.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86Version.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,23 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/xf86Version.h,v 3.236.2.70 1998/11/18 16:42:22 hohndel Exp $ */
+
+#define XF86_VERSION " 3.3.3 "
+
+/* The finer points in versions... */
+#define XF86_VERSION_MAJOR	3
+#define XF86_VERSION_MINOR	3
+#define XF86_VERSION_SUBMINOR	3
+#define XF86_VERSION_BETA	0	/* 0="", 1="A", 2="B", etc... */
+#define XF86_VERSION_ALPHA	0	/* 0="", 1="a", 2="b", etc... */
+
+#define XF86_VERSION_NUMERIC(major,minor,subminor,beta,alpha)	\
+   ((((((((major << 7) | minor) << 7) | subminor) << 5) | beta) << 5) | alpha)
+#define XF86_VERSION_CURRENT					\
+   XF86_VERSION_NUMERIC(XF86_VERSION_MAJOR,			\
+			XF86_VERSION_MINOR,			\
+			XF86_VERSION_SUBMINOR,			\
+			XF86_VERSION_BETA,			\
+			XF86_VERSION_ALPHA)
+
+#define XF86_DATE	"November 18 1998"
+
+/* $XConsortium: xf86Version.h /main/78 1996/10/28 05:42:10 kaleb $ */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86XKB.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86XKB.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86XKB.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86XKB.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,118 @@
+/* $XConsortium: xf86XKB.c /main/4 1996/02/04 09:28:04 kaleb $ */
+/************************************************************
+Copyright (c) 1993 by Silicon Graphics Computer Systems, Inc.
+
+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 and that both that copyright
+notice and this permission notice appear in supporting
+documentation, and that the name of Silicon Graphics not be 
+used in advertising or publicity pertaining to distribution 
+of the software without specific prior written permission.
+Silicon Graphics makes no representation about the suitability 
+of this software for any purpose. It is provided "as is"
+without any express or implied warranty.
+
+SILICON GRAPHICS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS 
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON
+GRAPHICS BE LIABLE 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.
+
+********************************************************/
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86XKB.c,v 3.6 1996/12/28 11:14:43 dawes Exp $ */
+
+#include <stdio.h>
+#define	NEED_EVENTS 1
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "inputstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "XI.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86_Config.h"
+
+#include "XKBsrv.h"
+
+#ifdef AMOEBA
+#define LED_CAP	IOP_LED_CAP
+#define LED_NUM	IOP_LED_NUM
+#define LED_SCR	IOP_LED_SCROLL
+#endif
+
+#ifdef MINIX
+#define LED_CAP KBD_LEDS_CAPS
+#define LED_NUM KBD_LEDS_NUM
+#define LED_SCR KBD_LEDS_SCROLL
+#endif
+
+void
+xf86InitXkb()
+{
+}
+
+void
+#if NeedFunctionPrototypes
+XkbDDXUpdateIndicators(DeviceIntPtr pXDev,CARD32 new)
+#else
+XkbDDXUpdateIndicators(pXDev,new)
+    DeviceIntPtr  pXDev;
+    CARD32 new;
+#endif
+{
+    CARD32 old;
+#ifdef DEBUG
+/*    if (xkbDebugFlags)*/
+        ErrorF("XkbDDXUpdateIndicators(...,0x%x) -- XFree86 version\n",new);
+#endif
+#ifdef LED_CAP
+    old= new;
+    new= 0;
+    if (old&XLED1)	new|= LED_CAP;
+    if (old&XLED2)	new|= LED_NUM;
+    if (old&XLED3)	new|= LED_SCR;
+#endif
+    xf86SetKbdLeds(new);
+    return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbDDXUpdateDeviceIndicators(	DeviceIntPtr		dev,
+				XkbSrvLedInfoPtr 	sli,
+				CARD32 			new)
+#else
+XkbDDXUpdateDeviceIndicators(dev,sli,new)
+    DeviceIntPtr  	dev;
+    XkbSrvLedInfoPtr	sli;
+    CARD32 		new;
+#endif
+{
+    if (sli->fb.kf==dev->kbdfeed)
+	XkbDDXUpdateIndicators(dev,new);
+    else if (sli->class==KbdFeedbackClass) {
+	KbdFeedbackPtr	kf;
+	kf= sli->fb.kf;
+	if (kf && kf->CtrlProc) {
+	    (*kf->CtrlProc)(dev,&kf->ctrl);
+	}
+    }
+    else if (sli->class==LedFeedbackClass) {
+	LedFeedbackPtr	lf;
+	lf= sli->fb.lf;
+	if (lf && lf->CtrlProc) {
+	    (*lf->CtrlProc)(dev,&lf->ctrl);
+	}
+    }
+    return;
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Config.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Config.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Config.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Config.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,632 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86_Config.h,v 3.59.2.9 1998/10/18 20:42:13 hohndel Exp $ */
+/*
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  Thomas Roell and
+ * David Dawes makes no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIMS ALL WARRANTIES WITH REGARD TO 
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86_Config.h /main/25 1996/10/25 11:36:49 kaleb $ */
+
+#ifndef _xf86_config_h
+#define _xf86_config_h
+
+#ifndef XCONFIG_FLAGS_ONLY
+
+#define CLOCK_TOLERANCE 2000         /* Clock matching tolerance (2MHz) */
+
+#ifdef BLACK
+#undef BLACK
+#endif
+#ifdef WHITE
+#undef WHITE
+#endif
+#ifdef SCROLLLOCK
+#undef SCROLLLOCK
+#endif
+#ifdef MONO
+#undef MONO
+#endif
+
+typedef struct {
+  int           num;                  /* returned number */
+  char          *str;                 /* private copy of the return-string */
+  double        realnum;              /* returned number as a real */
+} LexRec, *LexPtr;
+
+typedef struct {
+   char *identifier;
+   char *vendor;
+   char *board;
+   char *chipset;
+   OFlagSet options;
+   OFlagSet xconfigFlag;
+   int videoRam;
+   int chipID;
+   int chipRev;
+   char *DCConfig;
+   char *DCOptions;
+} GDevRec, *GDevPtr;
+
+typedef struct {
+   int depth;
+   DisplayModePtr modes;
+   xrgb whiteColour;
+   xrgb blackColour;
+   int defaultVisual;
+} DispRec, *DispPtr;
+
+/*
+ * We use the convention that tokens >= 1000 or < 0 do not need to be
+ * present in a screen's list of valid tokens in order to be valid.
+ * Also, each token should have a unique value regardless of the section
+ * it is used in.
+ */
+
+#define LOCK_TOKEN  -3
+#define ERROR_TOKEN -2
+#define NUMBER		10000                  
+#define STRING		10001
+
+/* GJA -- gave those high numbers since they occur in many sections. */
+#define SECTION		10002
+#define SUBSECTION	10003  /* Only used at one place now. */
+#define ENDSECTION	10004
+#define ENDSUBSECTION	10005
+#define IDENTIFIER	10006
+#define VENDOR		10007
+#define DASH		10008
+#define COMMA		10009
+
+#ifdef INIT_CONFIG
+static SymTabRec TopLevelTab[] = {
+    { SECTION,   "section" },
+    { -1,         "" },
+};
+#endif /* INIT_CONFIG */
+
+#define HRZ	1001	/* Silly name to avoid conflict with linux/param.h */
+#define KHZ	1002
+#define MHZ	1003
+
+#ifdef INIT_CONFIG
+static SymTabRec UnitTab[] = {
+  { HRZ,	"hz" },
+  { KHZ,	"khz" },
+  { MHZ,	"mhz" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define SVGA	1010
+#define VGA2	1011
+#define MONO	1012
+#define VGA16	1013
+#define ACCEL	1014
+#define FBDEV	1015
+
+#define GS      1016
+
+#ifdef INIT_CONFIG
+static SymTabRec DriverTab[] = {
+  { GS,		"gsx" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define MICROSOFT	1020
+#define MOUSESYS	1021
+#define MMSERIES	1022
+#define LOGITECH	1023
+#define BUSMOUSE	1024
+#define LOGIMAN		1025
+#define PS_2		1026
+#define MMHITTAB	1027
+#define GLIDEPOINT	1028
+#define IMSERIAL	1029
+#define THINKING	1030
+#define IMPS2		1031
+#define THINKINGPS2	1032
+#define MMANPLUSPS2	1033
+#define GLIDEPOINTPS2	1034
+#define NETPS2		1035
+#define NETSCROLLPS2	1036
+#define SYSMOUSE	1037
+#define AUTOMOUSE	1038
+#define ACECAD		1039
+#define XQUE      	1040
+#define OSMOUSE   	1041
+
+#ifdef INIT_CONFIG
+static SymTabRec MouseTab[] = {
+  { MICROSOFT,	"microsoft" },
+  { MOUSESYS,	"mousesystems" },
+  { MMSERIES,	"mmseries" },
+  { LOGITECH,	"logitech" },
+  { BUSMOUSE,	"busmouse" },
+  { LOGIMAN,	"mouseman" },
+  { PS_2,	"ps/2" },
+  { MMHITTAB,	"mmhittab" },
+  { GLIDEPOINT,	"glidepoint" },
+  { IMSERIAL,	"intellimouse" },
+  { THINKING,	"thinkingmouse" },
+  { IMPS2,	"imps/2" },
+  { THINKINGPS2,"thinkingmouseps/2" },
+  { MMANPLUSPS2,"mousemanplusps/2" },
+  { GLIDEPOINTPS2,"glidepointps/2" },
+  { NETPS2,	"netmouseps/2" },
+  { NETSCROLLPS2,"netscrollps/2" },
+  { SYSMOUSE,	"sysmouse" },
+  { AUTOMOUSE,	"auto" },
+  { ACECAD,	"acecad" },
+  { XQUE,	"xqueue" },
+  { OSMOUSE,	"osmouse" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define FONTPATH	1045
+#define RGBPATH		1046
+#define MODULEPATH	1047
+
+#ifdef INIT_CONFIG
+static SymTabRec FilesTab[] = {
+  { ENDSECTION,	"endsection"},
+  { FONTPATH,	"fontpath" },
+  { RGBPATH,	"rgbpath" },
+  { MODULEPATH,	"modulepath" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define NOTRAPSIGNALS		1050
+#define DONTZAP			1051
+#define DONTZOOM		1052
+#define DISABLEVIDMODE		1054
+#define ALLOWNONLOCAL		1055
+#define DISABLEMODINDEV		1056
+#define MODINDEVALLOWNONLOCAL	1057
+#define ALLOWMOUSEOPENFAIL	1058
+#define PCIPROBE1		1059
+#define PCIPROBE2		1060
+#define PCIFORCECONFIG1		1061
+#define PCIFORCECONFIG2		1062
+
+#ifdef INIT_CONFIG
+static SymTabRec ServerFlagsTab[] = {
+  { ENDSECTION, "endsection"},
+  { -1,         "" },
+};
+#endif /* INIT_CONFIG */
+
+#define DISPLAYSIZE	1070
+#define MODELINE	1071
+#define MODEL		1072
+#define BANDWIDTH	1073
+#define HORIZSYNC	1074
+#define VERTREFRESH	1075
+#define MODE		1076
+#define GAMMA		1077
+
+#ifdef INIT_CONFIG
+static SymTabRec MonitorTab[] = {
+  { ENDSECTION,	"endsection"},
+  { IDENTIFIER,	"identifier"}, 
+  { VENDOR,	"vendorname"},
+  { MODEL,	"modelname"}, 
+  { MODELINE,	"modeline"},
+  { DISPLAYSIZE,"displaysize" },
+  { BANDWIDTH,	"bandwidth" },
+  { HORIZSYNC,	"horizsync" },
+  { VERTREFRESH,"vertrefresh" },
+  { MODE,	"mode" },
+  { GAMMA,	"gamma" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define DOTCLOCK	1090
+#define HTIMINGS	1091
+#define VTIMINGS	1092
+#define FLAGS		1093
+#define HSKEW		1094
+#define ENDMODE		1095
+
+#ifdef INIT_CONFIG
+static SymTabRec ModeTab[] = {
+  { DOTCLOCK,	"dotclock"},
+  { HTIMINGS,	"htimings"}, 
+  { VTIMINGS,	"vtimings"},
+  { FLAGS,	"flags"}, 
+  { HSKEW,	"hskew"},
+  { ENDMODE,	"endmode"},
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define DRIVER		1110
+#define MDEVICE		1111
+#define MONITOR		1112
+#define SCREENNO	1113
+#define BLANKTIME	1114
+#define STANDBYTIME	1115
+#define SUSPENDTIME	1116
+#define OFFTIME		1117
+#define DEFBPP		1118
+#define FRAMERATE       1119
+
+#ifdef INIT_CONFIG
+static SymTabRec ScreenTab[] = {
+  { ENDSECTION, "endsection"},
+  { DRIVER,	"driver" },
+  { MDEVICE,	"device" },
+  { MONITOR,	"monitor" },
+  { SCREENNO,	"screenno" },
+  { BLANKTIME,	"blanktime" },
+  { STANDBYTIME,"standbytime" },
+  { SUSPENDTIME,"suspendtime" },
+  { OFFTIME,	"offtime" },
+  { SUBSECTION,	"subsection" },
+  { DEFBPP,	"defaultcolordepth" },
+  { FRAMERATE,  "framerate" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+/* Mode timing keywords */
+#define TT_INTERLACE	1130
+#define TT_PHSYNC	1131
+#define TT_NHSYNC	1132
+#define TT_PVSYNC	1133
+#define TT_NVSYNC	1134
+#define TT_CSYNC	1135
+#define TT_PCSYNC	1136
+#define TT_NCSYNC	1137
+#define TT_DBLSCAN	1138
+#define TT_HSKEW	1139
+#define TT_BCAST	1140
+
+#ifdef INIT_CONFIG
+SymTabRec TimingTab[] = {
+  { TT_INTERLACE,	"interlace"},
+  { TT_PHSYNC,		"+hsync"},
+  { TT_NHSYNC,		"-hsync"},
+  { TT_PVSYNC,		"+vsync"},
+  { TT_NVSYNC,		"-vsync"},
+  { TT_CSYNC,		"composite"},
+  { TT_PCSYNC,		"+csync"},
+  { TT_NCSYNC,		"-csync"},
+  { TT_DBLSCAN,		"doublescan"},
+  { TT_HSKEW,		"hskew"},
+  { TT_BCAST,		"bcast"},
+  { -1,			"" },
+};
+#else  /* defined(INIT_CONFIG) */
+
+extern SymTabRec TimingTab[];
+
+#endif /* !defined(INIT_CONFIG) */
+
+#define LOAD		2000
+
+#ifdef INIT_CONFIG
+SymTabRec ModuleTab[] = {
+  { ENDSECTION,	"endsection"},
+  { LOAD,	"load"},
+  { -1,		"" },
+};
+#endif  /* defined(INIT_CONFIG) */
+
+/* Indexes for the specialKeyMap array */
+#define K_INDEX_LEFTALT		0
+#define K_INDEX_RIGHTALT	1
+#define K_INDEX_SCROLLLOCK	2
+#define K_INDEX_RIGHTCTL	3
+
+/* Values for the specialKeyMap array */
+#define KM_META		0
+#define KM_COMPOSE	1
+#define KM_MODESHIFT	2
+#define KM_MODELOCK	3
+#define KM_SCROLLLOCK	4
+#define KM_CONTROL	5
+
+#ifdef INIT_CONFIG
+static SymTabRec KeyMapTab[] = {
+  { KM_META,		"meta" },
+  { KM_COMPOSE,		"compose" },
+  { KM_MODESHIFT,	"modeshift" },
+  { KM_MODELOCK,	"modelock" },
+  { KM_SCROLLLOCK,	"scrolllock" },
+  { KM_CONTROL,		"control" },
+  { -1,			"" },
+};
+#endif /* INIT_CONFIG */
+
+#define CHIPSET		10
+#define CLOCKS		11
+#define OPTION		12
+#define VIDEORAM	13
+#define BOARD		14
+#define IOBASE		15
+#define DACBASE		16
+#define COPBASE		17
+#define POSBASE		18
+#define INSTANCE	19
+#define RAMDAC		20
+#define DACSPEED	21
+#define SPEEDUP		22
+#define NOSPEEDUP	23
+#define CLOCKPROG	24
+#define BIOSBASE	25
+#define MEMBASE		26
+#define CLOCKCHIP	27
+#define S3MNADJUST	28
+#define S3MCLK		29
+#define CHIPID		30
+#define CHIPREV		31
+#define MEMCLOCK        32
+#define LCDCLOCK        33
+#define VGABASEADDR    100
+#define S3REFCLK       101
+#define S3BLANKDELAY   102
+#define TEXTCLOCKFRQ   103
+
+#ifdef INIT_CONFIG
+SymTabRec DeviceTab[] = {
+  { ENDSECTION, "endsection"},
+  { IDENTIFIER, "identifier"},
+  { VENDOR, 	"vendorname"},
+  { BOARD, 	"boardname"},
+  { CHIPSET,	"chipset" },
+  { RAMDAC,	"ramdac" },
+  { DACSPEED,	"dacspeed"},
+  { OPTION,	"option" },
+  { VIDEORAM,	"videoram" },
+  { -1,		"" },
+};
+#else
+
+extern SymTabRec DeviceTab[];
+
+#endif /* INIT_CONFIG */
+
+/* Keyboard keywords */
+#define AUTOREPEAT	30
+#define SERVERNUM	31
+#define XLEDS		32
+#define VTINIT		33
+#define LEFTALT		34
+#define RIGHTALT	35
+#define SCROLLLOCK	36
+#define RIGHTCTL	37
+#define VTSYSREQ	38
+#define KPROTOCOL	39
+#define XKBKEYMAP	40
+#define XKBCOMPAT	41
+#define XKBTYPES	42
+#define XKBKEYCODES	43
+#define XKBGEOMETRY	44
+#define XKBSYMBOLS	45
+#define XKBDISABLE	46
+#define PANIX106	47
+#define XKBRULES	110
+#define XKBMODEL	111
+#define XKBLAYOUT	112
+#define XKBVARIANT	113
+#define XKBOPTIONS	114
+
+#ifdef INIT_CONFIG
+static SymTabRec KeyboardTab[] = {
+  { ENDSECTION,	"endsection"},
+  { KPROTOCOL,	"protocol" },
+  { AUTOREPEAT,	"autorepeat" },
+  { SERVERNUM,	"servernumlock" },
+  { XLEDS,	"xleds" },
+  { VTINIT,	"vtinit" },
+  { LEFTALT,	"leftalt" },
+  { RIGHTALT,	"rightalt" },
+  { RIGHTALT,	"altgr" },
+  { SCROLLLOCK,	"scrolllock" },
+  { RIGHTCTL,	"rightctl" },
+  { VTSYSREQ,	"vtsysreq" },
+  { PANIX106,	"panix106" },
+  { XKBKEYMAP,	"xkbkeymap" },
+  { XKBCOMPAT,	"xkbcompat" },
+  { XKBTYPES,	"xkbtypes" },
+  { XKBKEYCODES,"xkbkeycodes" },
+  { XKBGEOMETRY,"xkbgeometry" },
+  { XKBSYMBOLS,	"xkbsymbols" },
+  { XKBDISABLE, "xkbdisable" },
+  { XKBRULES,	"xkbrules" },
+  { XKBMODEL,	"xkbmodel" },
+  { XKBLAYOUT,	"xkblayout" },
+  { XKBVARIANT,	"xkbvariant" },
+  { XKBOPTIONS,	"xkboptions" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define P_MS		0			/* Microsoft */
+#define P_MSC		1			/* Mouse Systems Corp */
+#define P_MM		2			/* MMseries */
+#define P_LOGI		3			/* Logitech */
+#define P_BM		4			/* BusMouse ??? */
+#define P_LOGIMAN	5			/* MouseMan / TrackMan
+						   [CHRIS-211092] */
+#define P_PS2		6			/* PS/2 mouse */
+#define P_MMHIT		7			/* MM_HitTab */
+#define P_GLIDEPOINT	8		/* ALPS serial GlidePoint */
+#define P_IMSERIAL	9		/* Microsoft serial IntelliMouse */
+#define P_THINKING	10		/* Kensington serial ThinkingMouse */
+#define P_IMPS2		11		/* Microsoft PS/2 IntelliMouse */
+#define P_THINKINGPS2	12		/* Kensington PS/2 ThinkingMouse */
+#define P_MMANPLUSPS2	13		/* Logitech PS/2 MouseMan+ */
+#define P_GLIDEPOINTPS2	14		/* ALPS PS/2 GlidePoint */
+#define P_NETPS2	15		/* Genius PS/2 NetMouse */
+#define P_NETSCROLLPS2	16		/* Genius PS/2 NetScroll */
+#define P_SYSMOUSE	17		/* SysMouse */
+#define P_AUTO		18		/* automatic */
+#define P_ACECAD	19		/* ACECAD protocol */
+
+#define EMULATE3	50
+#define BAUDRATE	51
+#define SAMPLERATE	52
+#define CLEARDTR	53
+#define CLEARRTS	54
+#define CHORDMIDDLE	55
+#define PROTOCOL	56
+#define PDEVICE		57
+#define EM3TIMEOUT	58
+/* This should be removed soon */
+#define REPEATEDMIDDLE	59
+#define DEVICE_NAME	60
+#define ALWAYSCORE	61
+#define PRESOLUTION	62
+#define ZAXISMAPPING	63
+#define PBUTTONS	64
+
+#ifdef INIT_CONFIG
+static SymTabRec PointerTab[] = {
+  { PROTOCOL,	"protocol" },
+  { EMULATE3,	"emulate3buttons" },
+  { EM3TIMEOUT,	"emulate3timeout" },
+  { ENDSUBSECTION, "endsubsection"},
+  { ENDSECTION,	"endsection"},
+#ifndef OSMOUSE_ONLY
+  { PDEVICE,	"device"},
+  { PDEVICE,	"port"},
+  { BAUDRATE,	"baudrate" },
+  { SAMPLERATE,	"samplerate" },
+  { CLEARDTR,	"cleardtr" },
+  { CLEARRTS,	"clearrts" },
+  { CHORDMIDDLE,"chordmiddle" },
+  { REPEATEDMIDDLE,"repeatedmiddle" },
+  { PRESOLUTION,"resolution" },
+#endif
+  { DEVICE_NAME,"devicename" },
+  { ZAXISMAPPING, "zaxismapping" },
+  { PBUTTONS,	"buttons" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+#define XAXIS		68
+#define YAXIS		69
+
+#ifdef INIT_CONFIG
+static SymTabRec ZMapTab[] = {
+  { XAXIS,	"x" },
+  { YAXIS,	"y" },
+  { -1,		"" },
+};
+#endif /* INIT_CONFIG */
+
+/* OPTION is defined to 12 above */
+#define MODES		70
+#define VIRTUAL		71
+#define VIEWPORT	72
+#define VISUAL		73
+#define BLACK		74
+#define WHITE		75
+#define DEPTH		76
+#define WEIGHT		77
+#define INVERTVCLK	78
+#define BLANKDELAY	79
+#define EARLYSC		80
+
+#ifdef INIT_CONFIG
+static SymTabRec DisplayTab[] = {
+  { ENDSUBSECTION,	"endsubsection" },
+  { MODES,		"modes" },
+  { BLACK,		"black" },
+  { WHITE,		"white" },
+  { DEPTH,		"depth" },
+  { OPTION,		"option" },
+  { -1,			"" },
+};
+#endif /* INIT_CONFIG */
+
+/* Graphics keywords */
+#define STATICGRAY	90
+#define GRAYSCALE	91
+#define STATICCOLOR	92
+#define PSEUDOCOLOR	93
+#define TRUECOLOR	94
+#define DIRECTCOLOR	95
+
+#ifdef INIT_CONFIG
+static SymTabRec VisualTab[] = {
+  { TRUECOLOR,	"truecolor" },
+  { -1,         "" },
+};
+#endif /* INIT_CONFIG */
+
+#endif /* XCONFIG_FLAGS_ONLY */
+
+#define S3_MODEPRIV_SIZE	4
+#define S3_INVERT_VCLK		1
+#define S3_BLANK_DELAY		2
+#define S3_EARLY_SC		3
+
+/* 
+ * XF86Config flags to record which options were defined in the XF86Config file
+ */
+#define XCONFIG_FONTPATH        1       /* Commandline/XF86Config or default  */
+#define XCONFIG_RGBPATH         2       /* XF86Config or default */
+#define XCONFIG_CHIPSET         3       /* XF86Config or probed */
+#define XCONFIG_CLOCKS          4       /* XF86Config or probed */
+#define XCONFIG_DISPLAYSIZE     5       /* XF86Config or default/calculated */
+#define XCONFIG_VIDEORAM        6       /* XF86Config or probed */
+#define XCONFIG_VIEWPORT        7       /* XF86Config or default */
+#define XCONFIG_VIRTUAL         8       /* XF86Config or default/calculated */
+#define XCONFIG_SPEEDUP         9       /* XF86Config or default/calculated */
+#define XCONFIG_NOMEMACCESS     10      /* set if forced on */
+#define XCONFIG_INSTANCE        11      /* XF86Config or default */
+#define XCONFIG_RAMDAC          12      /* XF86Config or default */
+#define XCONFIG_DACSPEED        13      /* XF86Config or default */
+#define XCONFIG_BIOSBASE        14      /* XF86Config or default */
+#define XCONFIG_MEMBASE         15      /* XF86Config or default */
+#define XCONFIG_IOBASE          16      /* XF86Config or default */
+#define XCONFIG_DACBASE         17      /* XF86Config or default */
+#define XCONFIG_COPBASE         18      /* XF86Config or default */
+#define XCONFIG_POSBASE         19      /* XF86Config or default */
+#define XCONFIG_VGABASE         20      /* XF86Config or default */
+#define XCONFIG_MODULEPATH      21      /* XF86Config or default */
+#define XCONFIG_MEMCLOCK        22      /* XF86Config or default */
+#define XCONFIG_LCDCLOCK        23      /* XF86Config or default */
+
+#define XCONFIG_GIVEN		"(**)"
+#define XCONFIG_PROBED		"(--)"
+
+#ifdef INIT_CONFIG
+
+OFlagSet  GenericXF86ConfigFlag;
+
+#else
+
+extern OFlagSet  GenericXF86ConfigFlag;
+
+#endif  /* INIT_CONFIG */
+
+/* XGSConfig file Environment Variable name */
+#define CONFIG_ENV_NAME         "XGSCONFIG"
+
+#endif /* _xf86_config_h */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Mouse.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Mouse.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Mouse.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Mouse.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,842 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86_Mouse.c,v 3.21.2.16 1998/11/12 11:32:07 dawes Exp $ */
+/*
+ *
+ * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of Thomas Roell and David Dawes not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.  Thomas Roell
+ * and David Dawes makes no representations about the suitability of this
+ * software for any purpose.  It is provided "as is" without express or
+ * implied warranty.
+ *
+ * THOMAS ROELL AND DAVID DAWES DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THOMAS ROELL OR DAVID DAWES BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86_Mouse.c /main/21 1996/10/27 11:05:32 kaleb $ */
+
+/*
+ * [JCH-96/01/21] Added fourth button support for P_GLIDEPOINT mouse protocol.
+ */
+
+/*
+ * [TVO-97/03/05] Added microsoft IntelliMouse support
+ */
+
+#define NEED_EVENTS
+#include "X.h"
+#include "Xproto.h"
+#include "inputstr.h"
+#include "scrnintstr.h"
+
+#include "compiler.h"
+
+#include "xf86Procs.h"
+#include "xf86_OSlib.h"
+#include "xf86_Config.h"
+
+#ifndef MOUSE_PROTOCOL_IN_KERNEL
+/*
+ * List of mouse types supported by xf86MouseProtocol()
+ *
+ * For systems which do the mouse protocol translation in the kernel,
+ * this list should be defined in the appropriate *_io.c file under
+ * xf86/os-support.
+ */
+Bool xf86SupportedMouseTypes[] =
+{
+	TRUE,	/* Microsoft */
+	TRUE,	/* MouseSystems */
+	TRUE,	/* MMSeries */
+	TRUE,	/* Logitech */
+	TRUE,	/* BusMouse */
+	TRUE,	/* MouseMan */
+	TRUE,	/* PS/2 */
+	TRUE,	/* Hitachi Tablet */
+	TRUE,	/* ALPS GlidePoint (serial) */
+	TRUE,   /* Microsoft IntelliMouse (serial) */
+	TRUE,	/* Kensington ThinkingMouse (serial) */
+#if !defined(__FreeBSD__) && !defined(Lynx)
+	TRUE,   /* Microsoft IntelliMouse (PS/2) */
+	TRUE,	/* Kensington ThinkingMouse (PS/2) */
+	TRUE,	/* Logitech MouseMan+ (PS/2) */
+	TRUE,	/* ALPS GlidePoint (PS/2) */
+	TRUE,	/* Genius NetMouse (PS/2) */
+	TRUE,	/* Genius NetScroll (PS/2) */
+#else
+	FALSE,	/* Microsoft IntelliMouse (PS/2) */
+	FALSE,	/* Kensington ThinkingMouse (PS/2) */
+	FALSE,	/* Logitech MouseMan+ (PS/2) */
+	FALSE,	/* ALPS GlidePoint (PS/2) */
+	FALSE,	/* Genius NetMouse (PS/2) */
+	FALSE,	/* Genius NetScroll (PS/2) */
+#endif /* __FreeBSD__ */
+	TRUE,	/* sysmouse */
+#ifdef PNP_MOUSE
+	TRUE,	/* auto */
+#else
+	FALSE,	/* auto */
+#endif
+	TRUE,	/* ACECAD */
+};
+
+int xf86NumMouseTypes = sizeof(xf86SupportedMouseTypes) /
+			sizeof(xf86SupportedMouseTypes[0]);
+
+/*
+ * termio[s] c_cflag settings for each mouse type.
+ *
+ * For systems which do the mouse protocol translation in the kernel,
+ * this list should be defined in the appropriate *_io.c under
+ * xf86/os-support if it is required.
+ */
+
+unsigned short xf86MouseCflags[] =
+{
+	(CS7                   | CREAD | CLOCAL | HUPCL ),   /* MicroSoft */
+	(CS8 | CSTOPB          | CREAD | CLOCAL | HUPCL ),   /* MouseSystems */
+	(CS8 | PARENB | PARODD | CREAD | CLOCAL | HUPCL ),   /* MMSeries */
+	(CS8 | CSTOPB          | CREAD | CLOCAL | HUPCL ),   /* Logitech */
+	0,						     /* BusMouse */
+	(CS7                   | CREAD | CLOCAL | HUPCL ),   /* MouseMan,
+                                                              [CHRIS-211092] */
+	0,						     /* PS/2 */
+	(CS8                   | CREAD | CLOCAL | HUPCL ),   /* mmhitablet */
+	(CS7                   | CREAD | CLOCAL | HUPCL ),   /* GlidePoint */
+	(CS7                   | CREAD | CLOCAL | HUPCL ),   /* IntelliMouse */
+	(CS7                   | CREAD | CLOCAL | HUPCL ),   /* ThinkingMouse */
+							     /* PS/2 variants */
+	0,						     /* IntelliMouse */
+	0,						     /* ThinkingMouse */
+	0,						     /* MouseMan+ */
+	0,						     /* GlidePoint */
+	0,						     /* NetMouse */
+	0,						     /* NetScroll */
+
+	(CS8 | CSTOPB          | CREAD | CLOCAL | HUPCL ),   /* sysmouse */
+	0,						     /* auto */
+	(CS8 | PARENB | PARODD | CREAD | CLOCAL | HUPCL ),   /* ACECAD */
+};
+#endif /* ! MOUSE_PROTOCOL_IN_KERNEL */
+
+
+/*
+ * xf86MouseSupported --
+ *	Returns true if OS supports mousetype
+ */
+
+Bool
+xf86MouseSupported(mousetype)
+     int mousetype;
+{
+    if (mousetype < 0 || mousetype >= xf86NumMouseTypes)
+    {
+	return(FALSE);
+    }
+    return(xf86SupportedMouseTypes[mousetype]);
+}
+
+/*
+ * xf86SetupMouse --
+ *	Sets up the mouse parameters
+ */
+
+#ifndef MOUSE_PROTOCOL_IN_KERNEL
+static unsigned char proto[][7] = {
+  /* hd_mask hd_id dp_mask dp_id bytes b4_mask b4_id */
+  {  0x40,   0x40, 0x40,   0x00, 3,   ~0x23,   0x00 },  /* MicroSoft */
+  {  0xf8,   0x80, 0x00,   0x00, 5,    0x00,   0xff },  /* MouseSystems */
+  {  0xe0,   0x80, 0x80,   0x00, 3,    0x00,   0xff },  /* MMSeries */
+  {  0xe0,   0x80, 0x80,   0x00, 3,    0x00,   0xff },  /* Logitech */
+  {  0xf8,   0x80, 0x00,   0x00, 5,    0x00,   0xff },  /* BusMouse */
+  {  0x40,   0x40, 0x40,   0x00, 3,   ~0x23,   0x00 },  /* MouseMan */
+  {  0xc0,   0x00, 0x00,   0x00, 3,    0x00,   0xff },  /* PS/2 mouse */
+  {  0xe0,   0x80, 0x80,   0x00, 3,    0x00,   0xff },  /* MM_HitTablet */
+  {  0x40,   0x40, 0x40,   0x00, 3,   ~0x33,   0x00 },  /* GlidePoint */
+  {  0x40,   0x40, 0x40,   0x00, 3,   ~0x3f,   0x00 },  /* IntelliMouse */
+  {  0x40,   0x40, 0x40,   0x00, 3,   ~0x33,   0x00 },  /* ThinkingMouse */
+							/* PS/2 variants */
+  {  0xc0,   0x00, 0x00,   0x00, 4,    0x00,   0xff },  /* IntelliMouse */
+  {  0x80,   0x80, 0x00,   0x00, 3,    0x00,   0xff },  /* ThinkingMouse */
+  {  0x08,   0x08, 0x00,   0x00, 3,    0x00,   0xff },  /* MouseMan+ */
+  {  0xc0,   0x00, 0x00,   0x00, 3,    0x00,   0xff },  /* GlidePoint */
+  {  0xc0,   0x00, 0x00,   0x00, 4,    0x00,   0xff },  /* NetMouse */
+  {  0xc0,   0x00, 0x00,   0x00, 6,    0x00,   0xff },  /* NetScroll */
+
+  {  0xf8,   0x80, 0x00,   0x00, 5,    0x00,   0xff },  /* sysmouse */
+  {  0xf8,   0x80, 0x00,   0x00, 5,    0x00,   0xff },  /* dummy entry for auto - used only to fill space */
+  {  0x80,   0x80, 0x80,   0x00, 3,    0x00,   0xff },  /* ACECAD */
+};
+#endif /* ! MOUSE_PROTOCOL_IN_KERNEL */
+
+void
+xf86SetupMouse(mouse)
+MouseDevPtr mouse;
+{
+#if !defined(MOUSE_PROTOCOL_IN_KERNEL) || defined(MACH386)
+      /*
+      ** The following lines take care of the Logitech MouseMan protocols.
+      **
+      ** NOTE: There are different versions of both MouseMan and TrackMan!
+      **       Hence I add another protocol P_LOGIMAN, which the user can
+      **       specify as MouseMan in his XF86Config file. This entry was
+      **       formerly handled as a special case of P_MS. However, people
+      **       who don't have the middle button problem, can still specify
+      **       Microsoft and use P_MS.
+      **
+      ** By default, these mice should use a 3 byte Microsoft protocol
+      ** plus a 4th byte for the middle button. However, the mouse might
+      ** have switched to a different protocol before we use it, so I send
+      ** the proper sequence just in case.
+      **
+      ** NOTE: - all commands to (at least the European) MouseMan have to
+      **         be sent at 1200 Baud.
+      **       - each command starts with a '*'.
+      **       - whenever the MouseMan receives a '*', it will switch back
+      **	 to 1200 Baud. Hence I have to select the desired protocol
+      **	 first, then select the baud rate.
+      **
+      ** The protocols supported by the (European) MouseMan are:
+      **   -  5 byte packed binary protocol, as with the Mouse Systems
+      **      mouse. Selected by sequence "*U".
+      **   -  2 button 3 byte MicroSoft compatible protocol. Selected
+      **      by sequence "*V".
+      **   -  3 button 3+1 byte MicroSoft compatible protocol (default).
+      **      Selected by sequence "*X".
+      **
+      ** The following baud rates are supported:
+      **   -  1200 Baud (default). Selected by sequence "*n".
+      **   -  9600 Baud. Selected by sequence "*q".
+      **
+      ** Selecting a sample rate is no longer supported with the MouseMan!
+      ** Some additional lines in xf86Config.c take care of ill configured
+      ** baud rates and sample rates. (The user will get an error.)
+      **               [CHRIS-211092]
+      */
+
+      unsigned char *param;
+      int paramlen;
+      int ps2param;
+      int i;
+
+      if (mouse->mseType != P_AUTO)
+	memcpy(mouse->protoPara, proto[mouse->mseType], 
+	       sizeof(mouse->protoPara));
+      else
+	memset(mouse->protoPara, 0, sizeof(mouse->protoPara));
+
+      param = NULL;
+      paramlen = 0;
+      ps2param = FALSE;
+      switch (mouse->mseType) {
+
+      case P_AUTO:
+	if (!xf86AllowMouseOpenFail)
+	  FatalError("xf86SetupMouse: Cannot determine the mouse protocol\n");
+	else
+	  ErrorF("xf86SetupMouse: Cannot determine the mouse protocol\n");
+	break;
+
+      case P_LOGI:		/* Logitech Mice */
+        /* 
+	 * The baud rate selection command must be sent at the current
+	 * baud rate; try all likely settings 
+	 */
+	xf86SetMouseSpeed(mouse, 9600, mouse->baudRate,
+                          xf86MouseCflags[mouse->mseType]);
+	xf86SetMouseSpeed(mouse, 4800, mouse->baudRate, 
+                          xf86MouseCflags[mouse->mseType]);
+	xf86SetMouseSpeed(mouse, 2400, mouse->baudRate,
+                          xf86MouseCflags[mouse->mseType]);
+	xf86SetMouseSpeed(mouse, 1200, mouse->baudRate,
+                          xf86MouseCflags[mouse->mseType]);
+        /* select MM series data format */
+	write(mouse->mseFd, "S", 1);
+	xf86SetMouseSpeed(mouse, mouse->baudRate, mouse->baudRate,
+                          xf86MouseCflags[P_MM]);
+        /* select report rate/frequency */
+	if      (mouse->sampleRate <=   0)  write(mouse->mseFd, "O", 1);
+	else if (mouse->sampleRate <=  15)  write(mouse->mseFd, "J", 1);
+	else if (mouse->sampleRate <=  27)  write(mouse->mseFd, "K", 1);
+	else if (mouse->sampleRate <=  42)  write(mouse->mseFd, "L", 1);
+	else if (mouse->sampleRate <=  60)  write(mouse->mseFd, "R", 1);
+	else if (mouse->sampleRate <=  85)  write(mouse->mseFd, "M", 1);
+	else if (mouse->sampleRate <= 125)  write(mouse->mseFd, "Q", 1);
+	else                                write(mouse->mseFd, "N", 1);
+	break;
+
+      case P_LOGIMAN:
+        xf86SetMouseSpeed(mouse, 1200, 1200, xf86MouseCflags[mouse->mseType]);
+        write(mouse->mseFd, "*X", 2);
+        xf86SetMouseSpeed(mouse, 1200, mouse->baudRate,
+                          xf86MouseCflags[mouse->mseType]);
+        break;
+
+      case P_MMHIT:		/* MM_HitTablet */
+	{
+	  char speedcmd;
+
+	  xf86SetMouseSpeed(mouse, mouse->baudRate, mouse->baudRate,
+                            xf86MouseCflags[mouse->mseType]);
+	  /*
+	   * Initialize Hitachi PUMA Plus - Model 1212E to desired settings.
+	   * The tablet must be configured to be in MM mode, NO parity,
+	   * Binary Format.  mouse->sampleRate controls the sensativity
+	   * of the tablet.  We only use this tablet for it's 4-button puck
+	   * so we don't run in "Absolute Mode"
+	   */
+	  write(mouse->mseFd, "z8", 2);	/* Set Parity = "NONE" */
+	  usleep(50000);
+	  write(mouse->mseFd, "zb", 2);	/* Set Format = "Binary" */
+	  usleep(50000);
+	  write(mouse->mseFd, "@", 1);	/* Set Report Mode = "Stream" */
+	  usleep(50000);
+	  write(mouse->mseFd, "R", 1);	/* Set Output Rate = "45 rps" */
+	  usleep(50000);
+	  write(mouse->mseFd, "I\x20", 2);	/* Set Incrememtal Mode "20" */
+	  usleep(50000);
+	  write(mouse->mseFd, "E", 1);	/* Set Data Type = "Relative */
+	  usleep(50000);
+	  /* These sample rates translate to 'lines per inch' on the Hitachi
+	     tablet */
+	  if      (mouse->sampleRate <=   40) speedcmd = 'g';
+	  else if (mouse->sampleRate <=  100) speedcmd = 'd';
+	  else if (mouse->sampleRate <=  200) speedcmd = 'e';
+	  else if (mouse->sampleRate <=  500) speedcmd = 'h';
+	  else if (mouse->sampleRate <= 1000) speedcmd = 'j';
+	  else                                speedcmd = 'd';
+	  write(mouse->mseFd, &speedcmd, 1);
+	  usleep(50000);
+	  write(mouse->mseFd, "\021", 1);	/* Resume DATA output */
+	}
+        break;
+
+      case P_THINKING:		/* ThinkingMouse */
+        {
+	  fd_set fds;
+          char *s;
+          char c;
+
+          xf86SetMouseSpeed(mouse, 1200, mouse->baudRate, 
+                            xf86MouseCflags[mouse->mseType]);
+          /* this mouse may send a PnP ID string, ignore it */
+	  usleep(200000);
+	  xf86FlushInput(mouse->mseFd);
+          /* send the command to initialize the beast */
+          for (s = "E5E5"; *s; ++s) {
+            write(mouse->mseFd, s, 1);
+	    FD_ZERO(&fds);
+	    FD_SET(mouse->mseFd, &fds);
+	    if (select(FD_SETSIZE, &fds, NULL, NULL, NULL) <= 0)
+	      break;
+            read(mouse->mseFd, &c, 1);
+            if (c != *s)
+              break;
+          }
+        }
+	break;
+
+      case P_MSC:		/* MouseSystems Corp */
+	xf86SetMouseSpeed(mouse, mouse->baudRate, mouse->baudRate,
+                          xf86MouseCflags[mouse->mseType]);
+#ifdef CLEARDTR_SUPPORT
+        if (mouse->mouseFlags & MF_CLEAR_DTR)
+          {
+            i = TIOCM_DTR;
+            ioctl(mouse->mseFd, TIOCMBIC, &i);
+          }
+        if (mouse->mouseFlags & MF_CLEAR_RTS)
+          {
+            i = TIOCM_RTS;
+            ioctl(mouse->mseFd, TIOCMBIC, &i);
+          }
+#endif
+        break;
+
+      case P_ACECAD:
+	  xf86SetMouseSpeed(mouse, 9600, mouse->baudRate,
+			    xf86MouseCflags[mouse->mseType]);
+	  /* initialize */
+	  /* a nul charactor resets */
+	  write(mouse->mseFd, "", 1);
+	  usleep(50000);
+	  /* stream out relative mode high resolution increments of 1 */
+	  write(mouse->mseFd, "@EeI!", 5);
+	  break;
+
+      case P_SYSMOUSE:
+	xf86SetMouseSpeed(mouse, mouse->baudRate, mouse->baudRate,
+                          xf86MouseCflags[mouse->mseType]);
+	break;
+
+      case P_PS2:		/* standard PS/2 mouse */
+	ps2param = TRUE;
+	break;
+
+      case P_BM:		/* bus/InPort mouse */
+	break;
+
+      case P_IMPS2:		/* IntelliMouse */
+	{
+	  static unsigned char s[] = { 243, 200, 243, 100, 243, 80, };
+
+	  param = s;
+	  paramlen = sizeof(s);
+	  ps2param = TRUE;
+	}
+	break;
+
+      case P_NETPS2:		/* NetMouse, NetMouse Pro, Mie Mouse */
+      case P_NETSCROLLPS2:	/* NetScroll */
+	{
+	  static unsigned char s[] = { 232, 3, 230, 230, 230, };
+
+	  param = s;
+	  paramlen = sizeof(s);
+	  ps2param = TRUE;
+	}
+	break;
+
+      case P_MMANPLUSPS2:	/* MouseMan+, FirstMouse+ */
+	{
+	  static unsigned char s[] = { 230, 232, 0, 232, 3, 232, 2, 232, 1,
+				       230, 232, 3, 232, 1, 232, 2, 232, 3, };
+	  param = s;
+	  paramlen = sizeof(s);
+	  ps2param = TRUE;
+	}
+	break;
+
+      case P_GLIDEPOINTPS2:	/* GlidePoint */
+	ps2param = TRUE;
+	break;
+
+      case P_THINKINGPS2:	/* ThinkingMouse */
+	{
+	  static unsigned char s[] = { 243, 10, 232,  0, 243, 20, 243, 60,
+				       243, 40, 243, 20, 243, 20, 243, 60,
+				       243, 40, 243, 20, 243, 20, };
+	  param = s;
+	  paramlen = sizeof(s);
+	  ps2param = TRUE;
+	}
+	break;
+
+      default:
+	xf86SetMouseSpeed(mouse, mouse->baudRate, mouse->baudRate,
+                          xf86MouseCflags[mouse->mseType]);
+        break;
+      }
+
+      if (paramlen > 0)
+	{
+#ifdef EXTMOUSEDEBUG
+	  char c[2];
+	  for (i = 0; i < paramlen; ++i)
+	    {
+	      if (write(mouse->mseFd, &param[i], 1) != 1)
+		ErrorF("xf86SetupMouse: Write to mouse failed (%s)\n",
+		       strerror(errno));
+	      usleep(30000);
+	      read(mouse->mseFd, c, 1);
+	      ErrorF("xf86SetupMouse: got %02x\n", c[0]);
+	    }
+#else
+	  if (write(mouse->mseFd, param, paramlen) != paramlen)
+	    ErrorF("xf86SetupMouse: Write to mouse failed (%s)\n",
+	    	   strerror(errno));
+#endif
+ 	  usleep(30000);
+ 	  xf86FlushInput(mouse->mseFd);
+	}
+      if (ps2param)
+	{
+	  unsigned char c[2];
+
+	  c[0] = 246;		/* default settings */
+	  write(mouse->mseFd, c, 1);
+	  c[0] = 230;		/* 1:1 scaling */
+	  write(mouse->mseFd, c, 1);
+	  c[0] = 244;		/* enable mouse */
+	  write(mouse->mseFd, c, 1);
+	  if (mouse->sampleRate > 0) 
+	    {
+	      c[0] = 243;	/* set sampling rate */
+ 	      if (mouse->sampleRate >= 200)
+ 		c[1] = 200;
+ 	      else if (mouse->sampleRate >= 100)
+ 		c[1] = 100;
+ 	      else if (mouse->sampleRate >= 60)
+ 		c[1] = 60;
+ 	      else if (mouse->sampleRate >= 40)
+ 		c[1] = 40;
+ 	      else
+ 		c[1] = 20;
+	      write(mouse->mseFd, c, 2);
+	    }
+	  if (mouse->resolution > 0) 
+	    {
+	      c[0] = 232;	/* set device resolution */
+	      if (mouse->resolution >= 200)
+		c[1] = 3;
+	      else if (mouse->resolution >= 100)
+		c[1] = 2;
+	      else if (mouse->resolution >= 50)
+		c[1] = 1;
+	      else
+		c[1] = 0;
+	      write(mouse->mseFd, c, 2);
+	    }
+	  usleep(30000);
+	  xf86FlushInput(mouse->mseFd);
+	}
+
+#endif /* !MOUSE_PROTOCOL_IN_KERNEL || MACH386 */
+}
+ 
+#ifndef MOUSE_PROTOCOL_IN_KERNEL
+void
+xf86MouseProtocol(device, rBuf, nBytes)
+    DeviceIntPtr device;
+    unsigned char *rBuf;
+    int nBytes;
+{
+  int                  i, buttons, dx, dy, dz;
+  static int           pBufP = 0;
+  static unsigned char pBuf[8];
+  MouseDevPtr          mouse = MOUSE_DEV(device);
+  
+#ifdef EXTMOUSEDEBUG
+    ErrorF("received %d bytes ",nBytes);
+    for ( i=0; i < nBytes; i++)
+    	ErrorF("%2x ",rBuf[i]);
+    ErrorF("\n");
+#endif
+  for ( i=0; i < nBytes; i++) {
+    /*
+     * Hack for resyncing: We check here for a package that is:
+     *  a) illegal (detected by wrong data-package header)
+     *  b) invalid (0x80 == -128 and that might be wrong for MouseSystems)
+     *  c) bad header-package
+     *
+     * NOTE: b) is a voilation of the MouseSystems-Protocol, since values of
+     *       -128 are allowed, but since they are very seldom we can easily
+     *       use them as package-header with no button pressed.
+     * NOTE/2: On a PS/2 mouse any byte is valid as a data byte. Furthermore,
+     *         0x80 is not valid as a header byte. For a PS/2 mouse we skip
+     *         checking data bytes.
+     *         For resyncing a PS/2 mouse we require the two most significant
+     *         bits in the header byte to be 0. These are the overflow bits,
+     *         and in case of an overflow we actually lose sync. Overflows
+     *         are very rare, however, and we quickly gain sync again after
+     *         an overflow condition. This is the best we can do. (Actually,
+     *         we could use bit 0x08 in the header byte for resyncing, since
+     *         that bit is supposed to be always on, but nobody told
+     *         Microsoft...)
+     */
+    if (pBufP != 0 &&
+#if !defined(__NetBSD__)
+	mouse->mseType != P_PS2 &&
+#endif
+	((rBuf[i] & mouse->protoPara[2]) != mouse->protoPara[3] 
+	 || rBuf[i] == 0x80))
+      {
+	pBufP = 0;          /* skip package */
+      }
+
+    if (pBufP == 0 && (rBuf[i] & mouse->protoPara[0]) != mouse->protoPara[1])
+      continue;
+
+    if (pBufP >= mouse->protoPara[4] 
+	&& (rBuf[i] & mouse->protoPara[0]) != mouse->protoPara[1])
+      {
+	/*
+	 * Hack for Logitech MouseMan Mouse - Middle button
+	 *
+	 * Unfortunately this mouse has variable length packets: the standard
+	 * Microsoft 3 byte packet plus an optional 4th byte whenever the
+	 * middle button status changes.
+	 *
+	 * We have already processed the standard packet with the movement
+	 * and button info.  Now post an event message with the old status
+	 * of the left and right buttons and the updated middle button.
+	 */
+
+        /*
+	 * Even worse, different MouseMen and TrackMen differ in the 4th
+         * byte: some will send 0x00/0x20, others 0x01/0x21, or even
+         * 0x02/0x22, so I have to strip off the lower bits. [CHRIS-211092]
+         *
+         * [JCH-96/01/21]
+         * HACK for ALPS "fourth button". (It's bit 0x10 of the "fourth byte"
+         * and it is activated by tapping the glidepad with the finger! 8^)
+         * We map it to bit bit3, and the reverse map in xf86Events just has
+         * to be extended so that it is identified as Button 4. The lower
+         * half of the reverse-map may remain unchanged.
+	 */
+
+        /*
+	 * [KAZU-030897]
+	 * Receive the fourth byte only when preceeding three bytes have
+	 * been detected (pBufP >= mouse->protoPara[4]).  In the previous
+	 * versions, the test was pBufP == 0; we may have mistakingly
+	 * received a byte even if we didn't see anything preceeding 
+	 * the byte.
+	 */
+
+	if ((rBuf[i] & mouse->protoPara[5]) != mouse->protoPara[6])
+	  {
+	    pBufP = 0;
+	    continue;
+	  }
+
+	dx = dy = dz = 0;
+	buttons = 0;
+	switch(mouse->mseType) {
+
+	/*
+	 * [KAZU-221197]
+	 * IntelliMouse, NetMouse (including NetMouse Pro) and Mie Mouse
+	 * always send the fourth byte, whereas the fourth byte is
+	 * optional for GlidePoint and ThinkingMouse. The fourth byte 
+	 * is also optional for MouseMan+ and FirstMouse+ in their 
+	 * native mode. It is always sent if they are in the IntelliMouse 
+	 * compatible mode.
+	 */ 
+	case P_IMSERIAL:	/* IntelliMouse, NetMouse, Mie Mouse, 
+				   MouseMan+ */
+          dz = (rBuf[i] & 0x08) ? (rBuf[i] & 0x0f) - 16 : (rBuf[i] & 0x0f);
+	  buttons |=  ((int)(rBuf[i] & 0x10) >> 3) 
+		    | ((int)(rBuf[i] & 0x20) >> 2) 
+		    | (mouse->lastButtons & 0x05);
+	  break;
+
+	case P_GLIDEPOINT:
+	case P_THINKING:
+	  buttons |= ((int)(rBuf[i] & 0x10) >> 1);
+	  /* fall through */
+
+	default:
+	  buttons |= ((int)(rBuf[i] & 0x20) >> 4) | (mouse->lastButtons & 0x05);
+	  break;
+	}
+        pBufP = 0;
+	goto post_event;
+      }
+
+    if (pBufP >= mouse->protoPara[4])
+      pBufP = 0;
+    pBuf[pBufP++] = rBuf[i];
+    if (pBufP != mouse->protoPara[4]) continue;
+
+    /*
+     * assembly full package
+     */
+    dz = 0;
+#ifdef EXTMOUSEDEBUG
+    ErrorF("packet %2x %2x %2x %2x\n",pBuf[0],pBuf[1],pBuf[2],pBuf[3]);
+#endif
+    switch(mouse->mseType) {
+      
+    case P_LOGIMAN:	    /* MouseMan / TrackMan   [CHRIS-211092] */
+    case P_MS:              /* Microsoft */
+      if (mouse->chordMiddle)
+	buttons = (((int) pBuf[0] & 0x30) == 0x30) ? 2 :
+		  ((int)(pBuf[0] & 0x20) >> 3)
+		  | ((int)(pBuf[0] & 0x10) >> 4);
+      else
+        buttons = (mouse->lastButtons & 2)
+		  | ((int)(pBuf[0] & 0x20) >> 3)
+		  | ((int)(pBuf[0] & 0x10) >> 4);
+      dx = (char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
+      dy = (char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
+      break;
+
+    case P_GLIDEPOINT:      /* ALPS GlidePoint */
+    case P_THINKING:        /* ThinkingMouse */
+    case P_IMSERIAL:        /* IntelliMouse, NetMouse, Mie Mouse, MouseMan+ */
+      buttons =  (mouse->lastButtons & (8 + 2))
+		| ((int)(pBuf[0] & 0x20) >> 3)
+		| ((int)(pBuf[0] & 0x10) >> 4);
+      dx = (char)(((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F));
+      dy = (char)(((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F));
+      break;
+
+    case P_MSC:             /* Mouse Systems Corp */
+      buttons = (~pBuf[0]) & 0x07;
+      dx =    (char)(pBuf[1]) + (char)(pBuf[3]);
+      dy = - ((char)(pBuf[2]) + (char)(pBuf[4]));
+      break;
+      
+    case P_MMHIT:           /* MM_HitTablet */
+      buttons = pBuf[0] & 0x07;
+      if (buttons != 0)
+        buttons = 1 << (buttons - 1);
+      dx = (pBuf[0] & 0x10) ?   pBuf[1] : - pBuf[1];
+      dy = (pBuf[0] & 0x08) ? - pBuf[2] :   pBuf[2];
+      break;
+
+    case P_ACECAD:	    /* ACECAD */
+	/* ACECAD is almost exactly like MM but the buttons are different */
+      buttons = (pBuf[0] & 0x02) | ((pBuf[0] & 0x04) >> 2) | ((pBuf[0] & 1) << 2);
+      dx = (pBuf[0] & 0x10) ?   pBuf[1] : - pBuf[1];
+      dy = (pBuf[0] & 0x08) ? - pBuf[2] :   pBuf[2];
+      break;
+
+    case P_MM:              /* MM Series */
+    case P_LOGI:            /* Logitech Mice */
+      buttons = pBuf[0] & 0x07;
+      dx = (pBuf[0] & 0x10) ?   pBuf[1] : - pBuf[1];
+      dy = (pBuf[0] & 0x08) ? - pBuf[2] :   pBuf[2];
+      break;
+      
+    case P_BM:              /* BusMouse */
+      buttons = (~pBuf[0]) & 0x07;
+      dx =   (char)pBuf[1];
+      dy = - (char)pBuf[2];
+      break;
+
+    case P_PS2:             /* PS/2 mouse */
+      buttons = (pBuf[0] & 0x04) >> 1 |       /* Middle */
+	        (pBuf[0] & 0x02) >> 1 |       /* Right */
+		(pBuf[0] & 0x01) << 2;        /* Left */
+      dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
+      dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
+      break;
+
+    /* PS/2 mouse variants */
+    case P_IMPS2:           /* IntelliMouse PS/2 */
+    case P_NETPS2:          /* NetMouse PS/2 */
+      buttons = (pBuf[0] & 0x04) >> 1 |       /* Middle */
+	        (pBuf[0] & 0x02) >> 1 |       /* Right */
+		(pBuf[0] & 0x01) << 2;        /* Left */
+      dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
+      dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
+      dz = (char)pBuf[3];
+      break;
+
+    case P_MMANPLUSPS2:     /* MouseMan+ PS/2 */
+      if ((pBuf[0] & ~0x07) == 0xc8) {
+	/* extended data packet */
+        buttons = (pBuf[0] & 0x04) >> 1 |       /* Middle */
+	          (pBuf[0] & 0x02) >> 1 |       /* Right */
+		  (pBuf[0] & 0x01) << 2 |       /* Left */
+		  ((pBuf[2] & 0x10) ? 0x08 : 0);/* fourth button */
+	dx = dy = 0;
+	dz = (pBuf[1] & 0x08) ? (pBuf[2] & 0x0f) - 16 : (pBuf[2] & 0x0f);
+      } else {
+        buttons = (pBuf[0] & 0x04) >> 1 |     /* Middle */
+	          (pBuf[0] & 0x02) >> 1 |     /* Right */
+		  (pBuf[0] & 0x01) << 2 |     /* Left */
+		  (mouse->lastButtons & ~0x07);
+        dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
+        dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
+      }
+      break;
+
+    case P_GLIDEPOINTPS2:   /* GlidePoint PS/2 */
+      buttons = (pBuf[0] & 0x04) >> 1 |       /* Middle */
+	        (pBuf[0] & 0x02) >> 1 |       /* Right */
+		(pBuf[0] & 0x01) << 2 |       /* Left */
+		((pBuf[0] & 0x08) ? 0 : 0x08);/* fourth button */
+      dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
+      dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
+      break;
+
+    case P_NETSCROLLPS2:    /* NetScroll PS/2 */
+      buttons = (pBuf[0] & 0x04) >> 1 |       /* Middle */
+	        (pBuf[0] & 0x02) >> 1 |       /* Right */
+		(pBuf[0] & 0x01) << 2 |       /* Left */
+		((pBuf[3] & 0x02) ? 0x08 : 0);/* fourth button */
+      dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
+      dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
+      dz = (pBuf[3] & 0x10) ? pBuf[4] - 256 : pBuf[4];
+      break;
+
+    case P_THINKINGPS2:     /* ThinkingMouse PS/2 */
+      buttons = (pBuf[0] & 0x04) >> 1 |       /* Middle */
+	        (pBuf[0] & 0x02) >> 1 |       /* Right */
+		(pBuf[0] & 0x01) << 2 |       /* Left */
+		((pBuf[0] & 0x08) ? 0x08 : 0);/* fourth button */
+      dx = (pBuf[0] & 0x10) ?    pBuf[1]-256  :  pBuf[1];
+      dy = (pBuf[0] & 0x20) ?  -(pBuf[2]-256) : -pBuf[2];
+      break;
+
+    case P_SYSMOUSE:        /* sysmouse */
+      buttons = (~pBuf[0]) & 0x07;
+      dx =    (char)(pBuf[1]) + (char)(pBuf[3]);
+      dy = - ((char)(pBuf[2]) + (char)(pBuf[4]));
+      /* FreeBSD sysmouse sends additional data bytes */
+      if (mouse->protoPara[4] >= 8)
+	{
+          dz = ((char)(pBuf[5] << 1) + (char)(pBuf[6] << 1))/2;
+          buttons |= (int)(~pBuf[7] & 0x07) << 3;
+	}
+      break;
+
+    default: /* There's a table error */
+      continue;
+    }
+
+post_event:
+    /* map the Z axis movement */
+    switch (mouse->negativeZ) {
+    case 0:	/* do nothing */
+      break;
+    case MSE_MAPTOX:
+      if (dz != 0)
+	{
+	  dx = dz;
+	  dz = 0;
+	}
+      break;
+    case MSE_MAPTOY:
+      if (dz != 0)
+	{
+	  dy = dz;
+	  dz = 0;
+	}
+      break;
+    default:	/* buttons */
+      buttons &= ~(mouse->negativeZ | mouse->positiveZ);
+      if (dz < 0)
+	buttons |= mouse->negativeZ;
+      else if (dz > 0)
+	buttons |= mouse->positiveZ;
+      dz = 0;
+      break;
+    }
+
+    /* post an event */
+    xf86PostMseEvent(device, buttons, dx, dy);
+
+    /* 
+     * If dz has been mapped to a button `down' event, we need to cook
+     * up a corresponding button `up' event.
+     */
+    if ((mouse->negativeZ > 0) 
+	&& (buttons & (mouse->negativeZ | mouse->positiveZ)))
+      {
+	buttons &= ~(mouse->negativeZ | mouse->positiveZ);
+        xf86PostMseEvent(device, buttons, 0, 0);
+      }
+
+    /* 
+     * We don't reset pBufP here yet, as there may be an additional data
+     * byte in some protocols. See above.
+     */
+  }
+}
+#endif /* MOUSE_PROTOCOL_IN_KERNEL */
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86_OSlib.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_OSlib.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86_OSlib.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_OSlib.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,540 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSlib.h,v 3.36.2.6 1998/09/27 12:58:58 hohndel Exp $ */
+/*
+ * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1992 by David Dawes <dawes@XFree86.org>
+ * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu>
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
+ * Copyright 1992 by Orest Zborowski <obz@eskimo.com>
+ * Copyright 1993 by Vrije Universiteit, The Netherlands
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
+ * Copyright 1994, 1995 by The XFree86 Project, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holders 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  The above listed
+ * copyright holders make no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD 
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE 
+ * LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86_OSlib.h /main/22 1996/10/27 11:06:31 kaleb $ */
+
+#ifndef _XF86_OSLIB_H
+#define _XF86_OSLIB_H
+
+#include <X11/Xos.h>
+#include <X11/Xfuncproto.h>
+
+#include "compiler.h"
+
+#if defined(MACH386) || defined(__OSF__)
+# undef NULL
+#endif /* MACH386 || __OSF__ */
+
+#include <stdio.h>
+#include <ctype.h>
+
+/**************************************************************************/
+/* SYSV386 (SVR3, SVR4)                                                   */
+/**************************************************************************/
+#if defined(SYSV) || defined(SVR4)
+# ifdef SCO325
+#  define _SVID3
+# endif
+# include <sys/ioctl.h>
+# include <signal.h>
+# include <termio.h>
+# include <sys/stat.h>
+# include <sys/types.h>
+# if defined(SCO) || defined(ISC)
+# include <sys/param.h>
+# endif
+
+# include <errno.h>
+
+# if defined(_NEED_SYSI86)
+#  include <sys/immu.h>
+#  if !(defined (sun) && defined (i386) && defined (SVR4))
+#    include <sys/region.h>
+#  endif
+#  include <sys/proc.h>
+#  include <sys/tss.h>
+#  include <sys/sysi86.h>
+#  if defined(SVR4) && !defined(sun)
+#   include <sys/seg.h>
+#  endif /* SVR4 && !sun */
+#  include <sys/v86.h>
+#  if defined(sun) && defined (i386) && defined (SVR4)
+#    include <sys/psw.h>
+#  endif
+# endif /* _NEED_SYSI86 */
+
+#if defined(HAS_SVR3_MMAPDRV)
+# include <sys/sysmacros.h>
+# if !defined(_NEED_SYSI86)
+#  include <sys/immu.h>
+#  include <sys/region.h>
+# endif
+# include <sys/mmap.h>		/* MMAP driver header */
+#endif
+
+# define HAS_USL_VTS
+# if !defined(sun)
+#  include <sys/emap.h>
+# endif
+# if defined(SCO)
+#  include <sys/vtkd.h>
+#  include <sys/console.h>
+#  include <sys/keyboard.h>
+#  include <sys/vid.h>
+#  define LED_CAP 0x01
+#  define LED_NUM 0x02
+#  define LED_SCR 0x04
+# else /* SCO */
+#  include <sys/at_ansi.h>
+#  include <sys/kd.h>
+#  include <sys/vt.h>
+# endif /* SCO */
+
+# if !defined(VT_ACKACQ)
+#  define VT_ACKACQ 2
+# endif /* !VT_ACKACQ */
+
+# if defined(SCO)
+#  include <sys/sysmacros.h>
+#  define POSIX_TTY
+# endif /* SCO */
+
+# if defined(SVR4) || defined(SCO325)
+#  include <sys/mman.h>
+#  if !(defined(sun) && defined (i386) && defined (SVR4))
+#    define DEV_MEM "/dev/pmem"
+#  endif
+#  ifdef SCO325
+#   undef DEV_MEM
+#   define DEV_MEM "/dev/mem"
+#  endif
+#  define CLEARDTR_SUPPORT
+#  define POSIX_TTY
+# endif /* SVR4 */
+
+# ifdef ISC
+#  include <termios.h>
+#  define POSIX_TTY
+# endif
+
+# if defined(sun) && defined (i386) && defined (SVR4)
+#  define USE_VT_SYSREQ
+#  define VT_SYSREQ_DEFAULT TRUE
+# endif
+
+# if defined(ATT) && !defined(i386)
+#  define i386 /* note defined in ANSI C mode */
+# endif /* ATT && !i386 */
+
+# if (defined(ATT) || defined(SVR4)) && !(defined(sun) && defined (i386) && defined (SVR4)) && !defined(SCO325)
+#  define XQUEUE
+#  include <sys/xque.h>
+# endif /* ATT || SVR4 */
+
+/* Hack on SVR3 and SVR4 to avoid linking in Xenix or BSD support */
+#if defined (sun) && defined (i386) && defined (SVR4)
+extern int xf86_solx86usleep(unsigned long);
+# define usleep(usec) xf86_solx86usleep(usec) 
+#else
+# define usleep(usec) syscall(3112, (usec) / 1000 + 1)
+#endif /* sun && i386 && SVR4 */
+
+# ifdef SYSV
+#  if !defined(ISC) || defined(ISC202) || defined(ISC22)
+#   define NEED_STRERROR
+#  endif
+# endif
+
+#ifndef NULL
+# define NULL 0
+#endif
+
+#endif /* SYSV || SVR4 */
+
+/**************************************************************************/
+/* Linux                                                                  */
+/**************************************************************************/
+#if defined(linux)
+# include <sys/ioctl.h>
+# include <signal.h>
+# include <termio.h>
+
+# include <errno.h>
+extern int errno;
+
+# include <sys/stat.h>
+
+# define HAS_USL_VTS
+# include <sys/mman.h>
+# include <sys/kd.h>
+# include <sys/vt.h>
+# define LDGMAP GIO_SCRNMAP
+# define LDSMAP PIO_SCRNMAP
+# define LDNMAP LDSMAP
+
+# define CLEARDTR_SUPPORT
+# define USE_VT_SYSREQ
+
+# define POSIX_TTY
+
+#endif /* linux */
+
+/**************************************************************************/
+/* LynxOS AT                                                              */
+/**************************************************************************/
+#if defined(Lynx)
+ 
+# include <termio.h>
+# include <sys/ioctl.h>
+# include <param.h>
+# include <signal.h>
+# include <kd.h>
+# include <vt.h>
+# include <sys/stat.h>
+
+# include <errno.h>
+extern int errno;
+ 
+/* smem_create et.al. to access physical memory */ 
+# include <smem.h>
+ 
+/* keyboard types */
+# define KB_84		1
+# define KB_101 	2
+# define KB_OTHER	3
+
+/* atc drivers ignores argument to VT_RELDISP ioctl */
+# define VT_ACKACQ	2
+
+# include <termios.h>
+# define POSIX_TTY
+
+/* LynxOS 2.5.1 has these */
+# ifdef LED_NUMLOCK
+#  define LED_CAP     LED_CAPSLOCK
+#  define LED_NUM     LED_NUMLOCK
+#  define LED_SCR     LED_SCROLLOCK
+# endif
+
+#endif /* Lynx */
+
+/**************************************************************************/
+/* 386BSD and derivatives,  BSD/386                                       */
+/**************************************************************************/
+
+#if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__))
+# undef __386BSD__
+#endif
+
+#ifdef CSRG_BASED
+# include <sys/ioctl.h>
+# if defined(__OpenBSD__) && defined(_status)
+#  undef _status
+# endif
+# include <signal.h>
+
+# include <termios.h>
+# define termio termios
+# define POSIX_TTY
+
+# include <errno.h>
+extern int errno;
+
+# if !defined(LINKKIT)
+  /* Don't need this stuff for the Link Kit */
+#  if defined(__bsdi__)
+#   include <i386/isa/pcconsioctl.h>
+#   define CONSOLE_X_MODE_ON PCCONIOCRAW
+#   define CONSOLE_X_MODE_OFF PCCONIOCCOOK
+#   define CONSOLE_X_BELL PCCONIOCBEEP
+#  else /* __bsdi__ */
+#   if defined(__OpenBSD__)
+#     ifdef PCCONS_SUPPORT
+#       include <machine/pccons.h>
+#       undef CONSOLE_X_MODE_ON
+#       undef CONSOLE_X_MODE_OFF
+#       undef CONSOLE_X_BELL
+#     endif
+#   endif
+#   ifdef CODRV_SUPPORT
+#    define COMPAT_CO011
+#    if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#     include <machine/ioctl_pc.h>
+#    else
+#     include <sys/ioctl_pc.h>
+#    endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
+#   endif /* CODRV_SUPPORT */
+#   ifdef SYSCONS_SUPPORT
+#    define COMPAT_SYSCONS
+#    if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#     include <machine/console.h>
+#    else
+#     include <sys/console.h>
+#    endif /* __FreeBSD__ || __NetBSD__ || defined(__OpenBSD__) */
+#   endif /* SYSCONS_SUPPORT */
+#   if defined(PCVT_SUPPORT)
+#    if !defined(SYSCONS_SUPPORT)
+      /* no syscons, so include pcvt specific header file */
+#     if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+#      include <machine/pcvt_ioctl.h>
+#     else
+#      include <sys/pcvt_ioctl.h>
+#     endif /* __FreeBSD__ || __NetBSD__ || __OpenBSD__ */
+#    else /* pcvt and syscons: hard-code the ID magic */
+#     define VGAPCVTID _IOWR('V',113, struct pcvtid)
+      struct pcvtid {
+	char name[16];
+	int rmajor, rminor;
+      };
+#    endif /* PCVT_SUPPORT && SYSCONS_SUPPORT */
+#   endif /* PCVT_SUPPORT */
+#   if defined(__FreeBSD__)
+#    undef MOUSE_GETINFO
+#    include <machine/mouse.h>
+#   endif
+    /* Include these definitions in case ioctl_pc.h didn't get included */
+#   ifndef CONSOLE_X_MODE_ON
+#    define CONSOLE_X_MODE_ON _IO('t',121)
+#   endif
+#   ifndef CONSOLE_X_MODE_OFF
+#    define CONSOLE_X_MODE_OFF _IO('t',122)
+#   endif
+#   ifndef CONSOLE_X_BELL
+#    define CONSOLE_X_BELL _IOW('t',123,int[2])
+#   endif
+#  endif /* __bsdi__ */
+# endif /* !LINKKIT */
+
+# include <sys/types.h>
+# include <sys/mman.h>
+# include <sys/stat.h>
+
+# if defined(__bsdi__)
+#  include <sys/param.h>
+# if (_BSDI_VERSION < 199510)
+#  include <i386/isa/vgaioctl.h>
+# endif
+# endif /* __bsdi__ */
+
+# define CLEARDTR_SUPPORT
+
+# if defined(SYSCONS_SUPPORT) || defined(PCVT_SUPPORT)
+#  define USE_VT_SYSREQ
+# endif
+
+# ifndef NULL
+#   define NULL 0
+# endif
+
+#endif /* CSRG_BASED */
+
+/**************************************************************************/
+/* Mach and OSF/1                                                         */
+/**************************************************************************/
+#if defined(MACH386) || defined(__OSF__)
+# include <sys/ioctl.h>
+
+# include <signal.h>
+
+# include <errno.h>
+extern int errno;
+
+# if defined(__OSF__)
+#  include <sys/param.h>
+#  include <machine/kd.h>
+# else /* __OSF__ */
+#  if !defined(__STDC__)
+#   define __STDC__ 1
+#   include <i386at/kd.h>
+#   include <i386at/kd_queue.h>
+#   undef __STDC__
+#  else /* !__STDC__ */
+#   include <i386at/kd.h>
+#   include <i386at/kd_queue.h>
+#  endif /* !__STDC__ */
+#  include <sys/file.h>
+#  define SEEK_SET L_SET
+# endif /* __OSF__ */
+
+# ifdef MACH386
+#  define NEED_STRERROR
+# endif
+
+# include <sys/mman.h>
+# include <sys/stat.h>
+# define MOUSE_PROTOCOL_IN_KERNEL
+
+#endif /* MACH386 || __OSF__ */
+
+/**************************************************************************/
+/* Minix                                                                  */
+/**************************************************************************/
+#if defined(MINIX)
+# include <sys/ioctl.h>
+# include <signal.h>
+
+# include <termios.h>
+# define termio termios
+# define POSIX_TTY
+
+# include <errno.h>
+
+# include <assert.h>
+# include <limits.h>
+# include <sys/memio.h>
+# include <sys/kbdio.h>
+
+# include <sys/stat.h>
+
+#endif /* MINIX */
+
+/**************************************************************************/
+/* Amoeba                                                                 */
+/**************************************************************************/
+#if defined(AMOEBA)
+# define port am_port_t
+# include <amoeba.h>
+# include <cmdreg.h>
+# include <stderr.h>
+# include <ampolicy.h>
+# include <proc.h>
+# include <signal.h>
+# include <server/iop/iop.h>
+# include <errno.h>
+# undef port
+
+# undef _POSIX_SOURCE    /* to get the BSD-compatible symbols */
+# include <sys/stat.h>
+
+  /* keyboard types */
+# define KB_84                   1
+# define KB_101                  2
+# define KB_OTHER                3
+
+extern capability iopcap;
+# define MOUSE_PROTOCOL_IN_KERNEL
+
+#endif /* AMOEBA */
+
+/**************************************************************************/
+/* OS/2                                                                   */
+/**************************************************************************/
+/* currently OS/2 with EMX/GCC compiler only */
+#if defined(__EMX__)
+# include <signal.h>
+# include <errno.h>
+# include <sys/stat.h>
+
+/* I would have liked to have this included here always, but
+ * it causes clashes for BYTE and BOOL with Xmd.h, which is too dangerous. 
+ * So I'll include it in place where I know it does no harm.
+ */
+#if defined(I_NEED_OS2_H)
+# undef BOOL
+# undef BYTE
+# include <os2.h>
+#endif
+
+  /* keyboard types */
+# define KB_84                   1
+# define KB_101                  2
+/* could detect more keyboards */
+# define KB_OTHER                3
+
+  /* LEDs */
+#  define LED_CAP 0x40
+#  define LED_NUM 0x20
+#  define LED_SCR 0x10
+
+  /* mouse driver */
+# define OSMOUSE_ONLY
+# define MOUSE_PROTOCOL_IN_KERNEL
+
+extern char* __XOS2RedirRoot(char*);
+
+#endif
+
+/**************************************************************************/
+/* Generic                                                                */
+/**************************************************************************/
+
+/* 
+ * Hack originally for ISC 2.2 POSIX headers, but may apply elsewhere,
+ * and it's safe, so just do it.
+ */
+#if !defined(O_NDELAY) && defined(O_NONBLOCK)
+# define O_NDELAY O_NONBLOCK
+#endif /* !O_NDELAY && O_NONBLOCK */
+
+#if !defined(MAXHOSTNAMELEN)
+# define MAXHOSTNAMELEN 32
+#endif /* !MAXHOSTNAMELEN */
+
+#if !defined(X_NOT_POSIX)
+# if defined(_POSIX_SOURCE)
+#  include <limits.h>
+# else
+#  define _POSIX_SOURCE
+#  include <limits.h>
+#  undef _POSIX_SOURCE
+# endif /* _POSIX_SOURCE */
+#endif /* !X_NOT_POSIX */
+#if !defined(PATH_MAX)
+# if defined(MAXPATHLEN)
+#  define PATH_MAX MAXPATHLEN
+# else
+#  define PATH_MAX 1024
+# endif /* MAXPATHLEN */
+#endif /* !PATH_MAX */
+
+#ifdef NEED_STRERROR
+# ifndef strerror
+extern char *sys_errlist[];
+extern int sys_nerr;
+#  define strerror(n) \
+     ((n) >= 0 && (n) < sys_nerr) ? sys_errlist[n] : "unknown error"
+# endif /* !strerror */
+#endif /* NEED_STRERROR */
+
+#if defined(ISC) || defined(Lynx)
+#define rint(x) RInt(x)
+double RInt(
+#if NeedFunctionPrototypes
+	double x
+#endif
+);
+#endif
+
+#ifndef VT_SYSREQ_DEFAULT
+#define VT_SYSREQ_DEFAULT FALSE
+#endif
+
+#ifdef OSMOUSE_ONLY
+# ifndef MOUSE_PROTOCOL_IN_KERNEL
+#  define MOUSE_PROTOCOL_IN_KERNEL
+# endif
+#endif
+
+#include "xf86_OSproc.h"
+
+#endif /* _XF86_OSLIB_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86_OSproc.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_OSproc.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86_OSproc.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_OSproc.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,393 @@
+/*
+ * Copyright 1990, 1991 by Thomas Roell, Dinkelscherben, Germany
+ * Copyright 1992 by David Dawes <dawes@XFree86.org>
+ * Copyright 1992 by Jim Tsillas <jtsilla@damon.ccs.northeastern.edu>
+ * Copyright 1992 by Rich Murphey <Rich@Rice.edu>
+ * Copyright 1992 by Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
+ * Copyright 1992 by Orest Zborowski <obz@eskimo.com>
+ * Copyright 1993 by Vrije Universiteit, The Netherlands
+ * Copyright 1993 by David Wexelblat <dwex@XFree86.org>
+ * Copyright 1994, 1996 by Holger Veit <Holger.Veit@gmd.de>
+ * Copyright 1994, 1995 by The XFree86 Project, Inc
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the names of the above listed copyright holders 
+ * not be used in advertising or publicity pertaining to distribution of 
+ * the software without specific, written prior permission.  The above listed
+ * copyright holders make no representations about the suitability of this 
+ * software for any purpose.  It is provided "as is" without express or 
+ * implied warranty.
+ *
+ * THE ABOVE LISTED COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD 
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 
+ * AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDERS BE 
+ * LIABLE 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.
+ *
+ */
+
+/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86_OSproc.h,v 3.0.2.1 1998/02/07 14:27:24 dawes Exp $ */
+
+#ifndef _XF86_OSPROC_H
+#define _XF86_OSPROC_H
+
+/*
+ * The actual prototypes have been pulled into this seperate file so
+ * that they can can be used without pulling in all of the OS specific
+ * stuff like sys/stat.h, etc. This casues problem for loadable modules.
+ */ 
+
+/* The Region arg to xf86[Un]Map* */
+#define NUM_REGIONS 4
+#define VGA_REGION 0
+#define LINEAR_REGION 1
+#define EXTENDED_REGION 2
+#define MMIO_REGION 3
+
+#ifndef NO_OSLIB_PROTOTYPES
+/*
+ * This is to prevent re-entrancy to FatalError() when aborting.
+ * Anything that can be called as a result of AbortDDX() should use this
+ * instead of FatalError(). (xf86Exiting gets set to TRUE the first time
+ * AbortDDX() is called.)
+ */
+
+extern Bool xf86Exiting;
+
+#define xf86FatalError(a, b) \
+	if (xf86Exiting) { \
+		ErrorF(a, b); \
+		return; \
+	} else FatalError(a, b)
+
+/***************************************************************************/
+/* Prototypes                                                              */
+/***************************************************************************/
+
+#include <X11/Xfuncproto.h>
+
+_XFUNCPROTOBEGIN
+
+/* xf86_Util.c */
+extern int StrCaseCmp(
+#if NeedFunctionPrototypes
+	const char *,
+	const char *
+#endif
+);
+
+/* OS-support layer */
+extern void xf86OpenConsole(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern void xf86CloseConsole(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern Bool xf86VTSwitchPending(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern Bool xf86VTSwitchAway(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern Bool xf86VTSwitchTo(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern Bool xf86LinearVidMem(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern pointer xf86MapVidMem(
+#if NeedFunctionPrototypes
+	int,
+	int,
+	pointer,
+	unsigned long
+#endif
+);
+extern void xf86UnMapVidMem(
+#if NeedFunctionPrototypes
+	int,
+	int,
+	pointer,
+	unsigned long
+#endif
+);
+#if defined(__alpha__)
+/* entry points for SPARSE memory access routines */
+extern pointer xf86MapVidMemSparse(
+#if NeedFunctionPrototypes
+	int,
+	int,
+	pointer,
+	unsigned long
+#endif
+);
+extern void xf86UnMapVidMemSparse(
+#if NeedFunctionPrototypes
+	int,
+	int,
+	pointer,
+	unsigned long
+#endif
+);
+extern int xf86ReadSparse8(
+#if NeedFunctionPrototypes
+	pointer,
+	unsigned long
+#endif
+);
+extern int xf86ReadSparse16(
+#if NeedFunctionPrototypes
+	pointer,
+	unsigned long
+#endif
+);
+extern int xf86ReadSparse32(
+#if NeedFunctionPrototypes
+	pointer,
+	unsigned long
+#endif
+);
+extern void xf86WriteSparse8(
+#if NeedFunctionPrototypes
+	int,
+	pointer,
+	unsigned long
+#endif
+);
+extern void xf86WriteSparse16(
+#if NeedFunctionPrototypes
+	int,
+	pointer,
+	unsigned long
+#endif
+);
+extern void xf86WriteSparse32(
+#if NeedFunctionPrototypes
+	int,
+	pointer,
+	unsigned long
+#endif
+);
+#endif /* __alpha__ */
+extern void xf86MapDisplay(
+#if NeedFunctionPrototypes
+	int,
+	int
+#endif
+);
+extern void xf86UnMapDisplay(
+#if NeedFunctionPrototypes
+	int,
+	int
+#endif
+);
+extern int xf86ReadBIOS(
+#if NeedFunctionPrototypes
+	unsigned long,
+	unsigned long,
+	unsigned char *,
+	int
+#endif
+);
+extern void xf86ClearIOPortList(
+#if NeedFunctionPrototypes
+	int
+#endif
+);
+extern void xf86AddIOPorts(
+#if NeedFunctionPrototypes
+	int,
+	int,
+	unsigned *
+#endif
+);
+void xf86EnableIOPorts(
+#if NeedFunctionPrototypes
+	int
+#endif
+);
+void xf86DisableIOPorts(
+#if NeedFunctionPrototypes
+	int
+#endif
+);
+void xf86DisableIOPrivs(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern Bool xf86DisableInterrupts(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern void xf86EnableInterrupts(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern int xf86ProcessArgument(
+#if NeedFunctionPrototypes
+	int,
+	char **,
+	int
+#endif
+);
+extern void xf86UseMsg(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern void xf86SoundKbdBell(
+#if NeedFunctionPrototypes
+	int,
+	int,
+	int
+#endif
+);
+extern void xf86SetKbdLeds(
+#if NeedFunctionPrototypes
+	int
+#endif
+);
+extern int xf86GetKbdLeds(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern void xf86SetKbdRepeat(
+#if NeedFunctionPrototypes
+	char
+#endif
+);
+extern void xf86KbdInit(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern int xf86KbdOn(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern int xf86KbdOff(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern void xf86KbdEvents(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern void xf86SetMouseSpeed(
+#if NeedFunctionPrototypes
+        MouseDevPtr,
+	int,
+	int,
+	unsigned
+#endif
+);
+extern void xf86MouseInit(
+#if NeedFunctionPrototypes
+        MouseDevPtr
+#endif
+);
+extern int xf86MouseOn(
+#if NeedFunctionPrototypes
+        MouseDevPtr
+#endif
+);
+extern int xf86MouseOff(
+#if NeedFunctionPrototypes
+        MouseDevPtr,
+	Bool
+#endif
+);
+extern void xf86MouseEvents(
+#if NeedFunctionPrototypes
+        MouseDevPtr
+#endif
+);
+extern int xf86FlushInput(
+#if NeedFunctionPrototypes
+	int
+#endif
+);
+extern int  xf86XqueKbdProc(
+#if NeedFunctionPrototypes
+	DeviceIntPtr,
+	int
+#endif
+);
+extern int  xf86XqueMseProc(
+#if NeedFunctionPrototypes
+	DeviceIntPtr,
+	int
+#endif
+);
+extern void xf86XqueEvents(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+
+
+/* These are privates */
+extern void xf86InitPortLists(
+#if NeedFunctionPrototypes
+	unsigned **,
+	int *,
+	Bool *,
+	Bool *,
+	int
+#endif
+);
+extern Bool xf86CheckPorts(
+#if NeedFunctionPrototypes
+	unsigned,
+	unsigned **,
+	int *,
+	Bool *,
+	int
+#endif
+);
+extern int  xf86OsMouseProc(
+#if NeedFunctionPrototypes
+	DeviceIntPtr,
+	int
+#endif
+);
+extern void xf86OsMouseEvents(
+#if NeedFunctionPrototypes
+	void
+#endif
+);
+extern void xf86OsMouseOption(
+#if NeedFunctionPrototypes
+	int,
+	pointer /* gets cast to LexPtr later, saves include file hassles */
+#endif
+);
+
+_XFUNCPROTOEND
+#endif /* NO_OSLIB_PROTOTYPES */
+
+#endif /* _XF86_OSPROC_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Option.c XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Option.c
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Option.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Option.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,14 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86_Option.c,v 3.1 1996/12/23 06:43:45 dawes Exp $ */
+/*
+ *
+ * The purpose of this file is to initialise the xf86_OptionTab[] which
+ * is setup in xf86_Option.h
+ */
+/* $XConsortium: xf86_Option.c /main/3 1996/02/21 17:39:22 kaleb $ */
+
+#define INIT_OPTIONS
+#define _NO_XF86_PROTOTYPES
+
+#include "X.h"
+#include "os.h"
+#include "xf86.h"
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Option.h XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Option.h
--- XFree86/xc/programs/Xserver/hw/gsx/common/xf86_Option.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/common/xf86_Option.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,299 @@
+/* $XFree86: xc/programs/Xserver/hw/xfree86/common/xf86_Option.h,v 3.65.2.16 1998/09/27 12:58:54 hohndel Exp $ */
+/*
+ * Copyright 1993 by David Wexelblat <dwex@goblin.org>
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of David Wexelblat not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  David Wexelblat makes no representations
+ * about the suitability of this software for any purpose.  It is provided
+ * "as is" without express or implied warranty.
+ *
+ * DAVID WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL DAVID WEXELBLAT BE LIABLE 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.
+ *
+ */
+/* $XConsortium: xf86_Option.h /main/26 1996/10/27 18:07:36 kaleb $ */
+
+#ifndef _XF86_OPTION_H
+#define _XF86_OPTION_H
+
+/*
+ * Structures and macros for handling option flags.
+ *
+ * MAX_OFLAGS should be a multiple of FLAGBITS
+ */
+#define MAX_OFLAGS	256
+#define FLAGBITS	(8 * sizeof(CARD32))
+typedef struct {
+	CARD32 flag_bits[MAX_OFLAGS/FLAGBITS];
+} OFlagSet;
+
+#define OFLG_SET(f,p)	((p)->flag_bits[(f)/FLAGBITS] |= (1 << ((f)%FLAGBITS)))
+#define OFLG_CLR(f,p)	((p)->flag_bits[(f)/FLAGBITS] &= ~(1 << ((f)%FLAGBITS)))
+#define OFLG_ISSET(f,p)	((p)->flag_bits[(f)/FLAGBITS] & (1 << ((f)%FLAGBITS)))
+#define OFLG_ZERO(p)	memset((char *)(p), 0, sizeof(*(p)))
+
+/*
+ * Option flags.  Define these in numeric order.
+ */
+/* SVGA clock-related options */
+#define OPTION_LEGEND		 0  /* Legend board with 32 clocks */
+#define OPTION_SWAP_HIBIT	 1  /* WD90Cxx-swap high-order clock sel bit */
+#define OPTION_8CLKS		 2  /* Probe 8 clocks instead of 4 (PVGA1) */
+#define OPTION_16CLKS		 3  /* probe for 16 clocks instead of 8 */
+#define OPTION_PROBE_CLKS	 4  /* Force clock probe for cards where a
+				       set of preset clocks is used */
+#define OPTION_HIBIT_HIGH	 5  /* Initial state of high order clock bit */
+#define OPTION_HIBIT_LOW	 6
+#define OPTION_CLKDIV2		 7  /* allow using clocks divided by 2 
+				       in addition to bare clocks */
+#define OPTION_HW_CLKS		 8  /* (ct) Hardware clocks */
+#define OPTION_FORCE_VCLK1	 9  /* (ct) Use VClk1 as programmable clock */
+
+/* Laptop display options */
+#define OPTION_INTERN_DISP	15  /* Laptops - enable internal display (WD)*/
+#define OPTION_EXTERN_DISP	16  /* Laptops - enable external display (WD)*/
+#define OPTION_CLGD6225_LCD	17  /* Option to avoid setting the DAC to */
+				   /* white on a clgd6225 with the LCD */
+				   /* enabled */
+#define OPTION_STN              18  /* DSTN option (CT)*/
+#define OPTION_EXT_FRAM_BUF     19 /* external frame accelerator (CT) */
+#define OPTION_LCD_STRETCH      20 /* disable LCD stretching */
+#define OPTION_LCD_CENTER	21 /* enable LCD centering */
+#define OPTION_PANEL_SIZE	22 /* (CT) Fix wrong panel size set in registers */
+
+/* Memory options */
+#define OPTION_FAST_DRAM	30 /* fast DRAM (for ET4000, S3, AGX) */
+#define OPTION_MED_DRAM		31 /* medium speed DRAM (for S3, AGX) */
+#define OPTION_SLOW_DRAM	32 /* slow DRAM (for Cirrus, S3, AGX) */
+#define OPTION_NO_MEM_ACCESS	33 /* Unable to access video ram directly */
+#define OPTION_NOLINEAR_MODE	34 /* chipset has broken linear access mode */
+#define OPTION_INTEL_GX		35 /* Linear fb on an Intel GX/Pro (Mach32) */
+#define OPTION_NO_2MB_BANKSEL	36 /* For cirrus cards with 512kx8 memory */
+#define OPTION_FIFO_CONSERV	37 /* (cirrus) (agx) */
+#define OPTION_FIFO_AGGRESSIVE	38 /* (cirrus) (agx) */
+#define OPTION_MMIO		39 /* Use MMIO for Cirrus 543x */
+#define OPTION_LINEAR		40 /* Use linear fb for Cirrus */
+#define OPTION_FIFO_MODERATE  	41 /* (agx) */
+#define OPTION_SLOW_VRAM	42 /* (s3) */
+#define OPTION_SLOW_DRAM_REFRESH 43 /* (s3) */
+#define OPTION_FAST_VRAM	44 /* (s3) */
+#define OPTION_PCI_BURST_ON	45 /* W32/SVGA */
+#define OPTION_PCI_BURST_OFF	46 /* W32/SVGA */
+#define OPTION_W32_INTERLEAVE_ON  47 /* W32/SVGA */
+#define OPTION_W32_INTERLEAVE_OFF 48 /* W32/SVGA */
+#define OPTION_SLOW_EDODRAM	49 /* slow EDO-DRAM (for S3) */
+#define OPTION_EARLY_RAS_PRECHARGE	50 /* shift RAS prechange signal (for S3) */
+#define OPTION_LATE_RAS_PRECHARGE	51 /* shift RAS prechange signal (for S3) */
+
+/* Accel/cursor features */
+#define OPTION_NOACCEL		60 /* Disable accel support in SVGA server */
+#define OPTION_HW_CURSOR	61 /* Turn on HW cursor */
+#define OPTION_SW_CURSOR	62 /* Turn off HW cursor (Mach32) */
+#define OPTION_NO_BITBLT	63 /* Disable hardware bitblt (cirrus) */
+#define OPTION_FAVOUR_BITBLT	64 /* Favour use of BitBLT (cirrus) */
+#define OPTION_NO_IMAGEBLT	65 /* Avoid system-to-video BitBLT (cirrus) */
+#define OPTION_NO_FONT_CACHE	66 /* Don't enable the font cache */
+#define OPTION_NO_PIXMAP_CACHE	67 /* Don't enable the pixmap cache */
+#define OPTION_TRIO32_FC_BUG	68 /* Workaround Trio32 font cache bug */
+#define OPTION_S3_968_DASH_BUG	69 /* Workaround S3 968 dashed line bug */
+
+/* RAMDAC options */
+#define OPTION_BT485_CURS	80 /* Override Bt485 RAMDAC probe */
+#define OPTION_TI3020_CURS	81 /* Use 3020 RAMDAC cursor (default) */
+#define OPTION_NO_TI3020_CURS	82 /* Override 3020 RAMDAC cursor use */
+#define OPTION_DAC_8_BIT	83 /* 8-bit DAC operation */
+#define OPTION_SYNC_ON_GREEN	84 /* Set Sync-On-Green in RAMDAC */
+#define OPTION_BT482_CURS       85 /* Use Bt482 RAMDAC cursor */
+#define OPTION_S3_964_BT485_VCLK	86 /* probe/invert VCLK for 964 + Bt485 */
+#define OPTION_TI3026_CURS	87 /* Use 3026 RAMDAC cursor (default) */
+#define OPTION_IBMRGB_CURS	88 /* Use IBM RGB52x RAMDAC cursor (default) */
+#define OPTION_DAC_6_BIT	89 /* 6-bit DAC operation */
+
+/* Vendor specific options */
+#define OPTION_SPEA_MERCURY	100 /* pixmux for SPEA Mercury (S3) */
+#define OPTION_NUMBER_NINE	101 /* pixmux for #9 with Bt485 (S3) */
+#define OPTION_STB_PEGASUS	102 /* pixmux for STB Pegasus (S3) */
+#define OPTION_ELSA_W1000PRO	103 /* pixmux for ELSA Winner 1000PRO (S3) */
+#define OPTION_ELSA_W2000PRO	104 /* pixmux for ELSA Winner 2000PRO (S3) */
+#define OPTION_DIAMOND		105 /* Diamond boards (S3) */
+#define OPTION_GENOA		106 /* Genoa boards (S3) */
+#define OPTION_STB		107 /* STB boards (S3) */
+#define OPTION_HERCULES		108 /* Hercules boards (S3) */
+#define OPTION_MIRO_MAGIC_S4	109 /* miroMagic S4 with (S3) 928 and BT485 */
+#define OPTION_ELSA_W2000PRO_X8	110 /* clock/phase_detect for ELSA Winner 2000PRO/X-8 (S3) */
+#define OPTION_MIRO_80SV	111 /* clock/phase_detect for MIRO 80SV (S3) */
+#define OPTION_AST_MACH32       112 /* AST's soldered-in SVGA motherboard (Mach32) */
+
+/* Misc options */
+#define OPTION_CSYNC		120 /* Composite sync */
+#define OPTION_SECONDARY	121 /* Use secondary address (HGC1280) */
+#define OPTION_PCI_HACK		122 /* (S3) */
+#define OPTION_POWER_SAVER	123 /* Enable DPMS Power Saving */
+#define OPTION_OVERRIDE_BIOS	124 /* Override BIOS for Mach64 */
+#define OPTION_NO_BLOCK_WRITE	125 /* No block write mode for Mach64 */
+#define OPTION_BLOCK_WRITE	126 /* Block write mode for Mach64 */
+#define OPTION_NO_BIOS_CLOCKS	127 /* Override BIOS clocks for Mach64 */
+#define OPTION_S3_INVERT_VCLK	128 /* invert VLCK (CR67:0) (S3) */
+#define OPTION_NO_PROGRAM_CLOCKS 129 /* Turn off clock programming */
+#define OPTION_NO_PCI_PROBE	130 /* Disable PCI probe (VGA) */
+#define OPTION_TRIO64VP_BUG1	131 /* Trio64V+ bug hack #1 */
+#define OPTION_TRIO64VP_BUG2	132 /* Trio64V+ bug hack #2 */
+#define OPTION_TRIO64VP_BUG3	133 /* Trio64V+ bug hack #3 */
+#define OPTION_USE_MODELINE	134 /* use modeline for LCD instead of preset (ct)*/
+#define OPTION_SUSPEND_HACK	135 /* (CT) Use different suspend/resume scheme */
+#define OPTION_18_BIT_BUS	136 /* (CT) Use 18bit TFT bus for 24bpp mode */
+#define OPTION_PCI_RETRY	137 /* Use PCI-retry instead of busy-waiting */
+#define OPTION_NO_PCI_DISC	138 /* Disable PCI disconnect (S3) */
+#define OPTION_NO_SPLIT_XFER	139 /* Disable split VRAM transfers to avoid pixel wrapping (S3) */
+#define OPTION_MGA_24BPP_FIX	140 /* change PLL for higher clocks at 24bpp */
+#define OPTION_MGA_SDRAM	141 /* MGA equipped with SDRAM */
+
+/* Debugging options */
+#define OPTION_SHOWCACHE	150 /* Allow cache to be seen (S3) */
+#define OPTION_FB_DEBUG		151 /* Linear fb debug for S3 */
+
+/* Some AGX Tuning/Debugging options -- several are for development testing */
+#define OPTION_8_BIT_BUS        160 /* Force 8-bit CPU interface - MR1:0 */
+#define OPTION_WAIT_STATE       161 /* Force 1 bus wait state - MR1:1<-1 */
+#define OPTION_NO_WAIT_STATE    162 /* Force no bus wait state - MR:1<-0 */
+#define OPTION_CRTC_DELAY       163 /* Select XGA Mode Delay - MR1:3 */
+#define OPTION_VRAM_128         164 /* VRAM shift every 128 cycles - MR2:0 */
+#define OPTION_VRAM_256         165 /* VRAM shift every 256 cycles - MR2:0 */
+#define OPTION_REFRESH_20       166 /* # clocks between scr refreshs - MR3:5 */
+#define OPTION_REFRESH_25       167 /* # clocks between scr refreshs - MR3:5 */
+#define OPTION_VLB_A            168 /* VESA VLB transaction type A   - MR7:2 */
+#define OPTION_VLB_B            169 /* VESA VLB transaction type B   - MR7:2 */
+#define OPTION_SPRITE_REFRESH   170 /* Sprite refresh every hsync    - MR8:4 */
+#define OPTION_SCREEN_REFRESH   171 /* Screen refresh during blank   - MR8:5 */
+#define OPTION_VRAM_DELAY_LATCH	172 /* Delay Latch                   - MR7:3 */
+#define OPTION_VRAM_DELAY_RAS	173 /* Delay RAS signal              - MR7:4 */
+#define OPTION_VRAM_EXTEND_RAS  174 /* Extend the RAS signal         - MR8:6 */
+#define OPTION_ENGINE_DELAY     175 /* Wait state for some VLB's     - MR5:3 */
+
+/* Some options for oti087, debugging and fine tunning */
+#define OPTION_CLOCK_50         180
+#define OPTION_CLOCK_66         181
+#define OPTION_NO_WAIT          182
+#define OPTION_FIRST_WWAIT      183
+#define OPTION_WRITE_WAIT       184
+#define OPTION_ONE_WAIT         185
+#define OPTION_READ_WAIT        186
+#define OPTION_ALL_WAIT         187
+#define OPTION_ENABLE_BITBLT    188
+
+
+/* #ifdef PC98 */
+#define OPTION_PCSKB		 190 /* SELECT EPSON PCSKB for S3 Server */
+#define OPTION_PCSKB4		 191 /* SELECT EPSON PCSKB for S3 Server */
+#define OPTION_PCHKB		 192 /* SELECT EPSON PCHKB for S3 Server */
+#define OPTION_NECWAB		 193 /* SELECT NEC WAB-A/B for S3 Server */
+#define OPTION_PW805I		 194 /* SELECT Canopus PW805i for S3 Server */
+#define OPTION_PWLB		 195 /* SELECT Canopus PW_LB for S3 Server */
+#define OPTION_PW968		 196 /* SELECT Canopus PW968 for S3 Server */
+#define OPTION_GA98NB1           190 /* SELECT IO DATA GA-98NB1 for SVGA */
+#define OPTION_GA98NB2           201 /* SELECT IO DATA GA-98NB2 for SVGA */
+#define OPTION_GA98NB4           202 /* SELECT IO DATA GA-98NB4 for SVGA */
+#define OPTION_WAP               203 /* SELECT MELCO WAP-2000/4000 for SVGA */
+#define OPTION_NEC_CIRRUS        204 /* SELECT NEC Internal Server for SVGA */
+#define OPTION_EPSON_MEM_WIN	 205 /* ENABLE mem-window 0xF00000 for EPSON */
+#define OPTION_PW_MUX            206 /* ENABLE MUX on PW928II */
+#define OPTION_NOINIT		 207 /* Not Initialize SDAC & VGA Registers */
+#define OPTION_PC98TGUI		 208 /* SELECT NEC TGUI9660 */
+/* #endif */
+
+#define OPTION_TGUI_PCI_READ_ON  211 /* Trident TGUI PCI burst read */
+#define OPTION_TGUI_PCI_WRITE_ON 212 /* Trident TGUI PCI burst write */
+#define OPTION_TGUI_TVOUT	 213 /* Trident TV output force */
+#define OPTION_CYBER_SHADOW	 214 /* Trident Cyber Shadow registers */
+#define OPTION_TGUI_MCLK_66	 215 /* Trident MCLK at 66MHz */
+
+/* more Memory options */
+#define OPTION_FPM_VRAM		220 /* (s3v) */
+#define OPTION_EDO_VRAM		221 /* (s3v) */
+#define OPTION_NO_MMIO		222 /* Disable MMIO (Cirrus 543x/4x) */
+
+/* XAA options */
+#define OPTION_XAA_BENCHMARK	230 /* Perform start-up benchmarks */
+#define OPTION_XAA_NO_COL_EXP	231 /* Disable color expansion. */
+  
+/* options for Glint server */
+#define OPTION_FIREGL3000       232 /* Assume a Fire GL 3000 card */
+#define OPTION_OVERCLOCK_MEM	233 /* run the memory faster than it should */
+
+/* options for sis server */
+#define OPTION_HOST_BUS		240
+#define OPTION_EXT_ENG_QUEUE	241
+
+/* NeoMagic options */
+#define OPTION_PROG_LCD_MODE_REGS       245 /* Enable lcd mode programming */
+#define OPTION_NO_PROG_LCD_MODE_REGS    246 /* Disable lcd mode programming */
+#define OPTION_PROG_LCD_MODE_STRETCH    247 /* Enable lcd mode programming when */
+					    /* stretch mode is enabled */
+#define OPTION_NO_PROG_LCD_MODE_STRETCH 248 /* Disable lcd mode programming when */
+					    /* stretch mode is enabled */
+#define OPTION_OVERRIDE_VALIDATE_MODE   249 /* Skip mode validation for LCD panels */
+
+/*
+ *  MAX flag value is 256.  If larger is needed, remember to update
+ *  MAX_OFLAGS at the top of this file.
+ */
+
+
+#define CLOCK_OPTION_PROGRAMABLE 0 /* has a programable clock */
+#define CLOCK_OPTION_ICD2061A	 1 /* use ICD 2061A programable clocks      */
+#define CLOCK_OPTION_SC11412     3 /* use SC11412 programmable clocks */
+#define CLOCK_OPTION_S3GENDAC    4 /* use S3 Gendac programmable clocks */
+#define CLOCK_OPTION_TI3025      5 /* use TI3025 programmable clocks */
+#define CLOCK_OPTION_ICS2595     6 /* use ICS2595 programmable clocks */
+#define CLOCK_OPTION_CIRRUS      7 /* use Cirrus programmable clocks */
+#define CLOCK_OPTION_CH8391      8 /* use Chrontel 8391 programmable clocks */
+#define CLOCK_OPTION_ICS5342     9 /* use ICS 5342 programmable clocks */
+#define CLOCK_OPTION_S3TRIO     10 /* use S3 Trio32/64 programmable clocks */
+#define CLOCK_OPTION_TI3026     11 /* use TI3026 programmable clocks */
+#define CLOCK_OPTION_IBMRGB     12 /* use IBM RGB52x programmable clocks */
+#define CLOCK_OPTION_STG1703    13 /* use STG1703 programmable clocks */
+#define CLOCK_OPTION_ICS5341    14 /* use ICS 5341 (ET4000W32p) */
+#define CLOCK_OPTION_TRIDENT    15 /* use programmable clock on TGUI */
+#define CLOCK_OPTION_ATT409     16 /* use ATT20C409 programmable clock */
+#define CLOCK_OPTION_CH8398     17 /* use Chrontel 8398 programmable clock */
+#define CLOCK_OPTION_GLORIA8    18 /* use ELSA Gloria-8 TVP3030/ICS9161 clock */
+#define CLOCK_OPTION_ET6000     19 /* use ET6000 built-in programmable clock */
+#define CLOCK_OPTION_ICS1562    20 /* used for TGA server */
+#define CLOCK_OPTION_S3AURORA   21 /* use S3 Aurora64V+ programmable clocks */
+#define CLOCK_OPTION_S3TRIO64V2 22 /* use S3 Trio64V2 or ViRGE/DX/GX 170MHz clocks */
+#define CLOCK_OPTION_ICS5301    23 /* use ICS 5301 (ET4000W32i) */
+
+/*
+ * Table to map option strings to tokens.
+ */
+typedef struct {
+  char *name;
+  int  token;
+} OptFlagRec, *OptFlagPtr;
+
+#ifdef INIT_OPTIONS
+OptFlagRec xf86_OptionTab[] = {
+  { "",			-1 },
+};
+
+OptFlagRec xf86_ClockOptionTab [] = {
+  { "",			-1 },
+};
+
+#else
+extern OptFlagRec xf86_OptionTab[];
+extern OptFlagRec xf86_ClockOptionTab[];
+#endif
+
+#endif /* _XF86_OPTION_H */
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsos/Imakefile XFree86.current/xc/programs/Xserver/hw/gsx/gsos/Imakefile
--- XFree86/xc/programs/Xserver/hw/gsx/gsos/Imakefile	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsos/Imakefile	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,22 @@
+RAPINC = 
+RAPLIB =
+
+#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
+
+SRCS = gsos.c
+OBJS = gsos.o
+LIB = gsos
+INCL = gsos.h
+
+DEFINES = -DPSZ=32
+
+INCLUDES = -I. -I.. $(RAPINC)
+LOCAL_LDFLAGS =
+CDEBUGFLAGS = -g -Wall -DDEBUG -DJDEBUG -Dlint
+
+NormalLibraryObjectRule()
+NormalLibraryTarget($(LIB), $(OBJS))
+NormalLintTarget( $(SRCS) )
+DependTarget()
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos.c XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos.c	Mon Apr 16 15:33:36 2001
@@ -0,0 +1,284 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsos.h"
+
+#include <stdio.h>
+
+#include <assert.h>
+#define AssertGsosCommandBufferExecuted() assert(ps2count==0)
+    // assert command buffer in gsos is flushed
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/fcntl.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+#include <linux/ps2/dev.h>
+
+#define GSOS_MAXPACKETSIZE (64 * 1024)
+
+ 
+GSOSbit64 *ps2lastgiftag = NULL ;    /* last giftag ptr */
+
+int ps2gsfd = -1 ;         /* file pointer for driver */
+static int ps2memfd = -1 ;        /* file pointer for driver */
+static GSOSbit64 *ps2buf = NULL ; /* DMA buffer */
+GSOSbit64 *ps2dbp[2] ;     /* double buffered DMA base pointer */
+int ps2dbf = 0 ;           /* double buffer flag */
+
+GSOSbit64 *ps2cur = NULL ;        /* current pointer of DMA buffer */
+int ps2count = 0 ;                /* counter for DMA buffer */
+struct ps2_screeninfo consoleinfo ;
+
+int gsos_maxpacket_size;
+
+static void gsosClearFrameBuffer(int w, int h, int fbp, int psm);
+
+int gsosOpen()
+{
+    gsos_maxpacket_size = GSOS_MAXPACKETSIZE / 2;
+
+    /* open driver */
+    ps2gsfd = open( PS2_DEV_GS, O_RDWR ) ;
+    if( ps2gsfd < 0 ){
+	fprintf (stderr,"gsosOpen: can't open driver(" PS2_DEV_GS ")\n" ) ;
+        return -1 ;
+    }
+
+    /* open driver */
+    ps2memfd = open( PS2_DEV_MEM, O_RDWR ) ;
+    if( ps2memfd < 0 ){
+	fprintf (stderr,"gsosOpen: can't open driver(" PS2_DEV_MEM ")\n" ) ;
+        return -1 ;
+    }
+
+    /* memory allocation for DMA buffer */
+    if( ps2buf == NULL ){
+        ps2buf = (GSOSbit64 *)mmap( NULL, GSOS_MAXPACKETSIZE,
+            PROT_READ | PROT_WRITE, MAP_SHARED, ps2memfd, 0 ) ;
+        if( ps2buf == NULL ){
+	    fprintf (stderr,"gsosOpen: memory allocateion error\n");
+            close(ps2gsfd) ;
+            close(ps2memfd) ;
+            return -1 ;
+        }
+    }
+    ps2dbp[0] = ps2buf;
+    ps2dbp[1] = (GSOSbit64 *)((unsigned long)ps2buf + gsos_maxpacket_size);
+    ps2dbf = 0;
+    ps2count = 0 ;
+    ps2cur = ps2dbp[ps2dbf];
+    ps2lastgiftag = NULL;
+
+    ioctl( ps2gsfd, PS2IOC_GSCREENINFO, &consoleinfo ) ;
+
+    return 0 ;
+}
+
+int gsosClose()
+{
+    munmap( (void *)ps2buf, GSOS_MAXPACKETSIZE ) ;
+    ps2buf = NULL;
+    if( ps2gsfd >= 0 ){
+        ioctl( ps2gsfd, PS2IOC_SSCREENINFO, &consoleinfo ) ;
+        close( ps2gsfd ) ;
+        ps2gsfd = -1 ;
+    }
+    if( ps2memfd >= 0 ){
+        close( ps2memfd ) ;
+        ps2memfd = -1 ;
+    }
+    return 0 ;
+}
+
+void gsosSetScreen( int mode, int res, int w, int h, int fbp, int psm,
+			int alpha, int dx, int dy)
+{
+
+    int interlace;
+    struct ps2_screeninfo info ;
+    struct ps2_dispfb ch1;
+    struct ps2_display d1;
+    struct ps2_pmode pmode;
+    struct ps2_displayd1;
+    struct ps2_crtmode crtmode;
+
+    info.mode = mode ;
+    info.res = res ;
+    info.w = w ;
+    info.h = h ;
+    info.fbp = fbp ;
+    info.psm = psm ;
+    ioctl( ps2gsfd, PS2IOC_SSCREENINFO, &info ) ;
+
+    interlace = (((mode == PS2_GS_NTSC || mode == PS2_GS_PAL) &&
+    			(res & PS2_GS_INTERLACE) )||
+		       (mode == PS2_GS_DTV && res == PS2_GS_1080I));
+
+    if (interlace && alpha != 0xff && alpha != 0) {
+
+	ch1.ch=0;
+        ioctl( ps2gsfd, PS2IOC_GDISPFB, &ch1);
+	ch1.ch = 1;
+        ioctl( ps2gsfd, PS2IOC_SDISPFB, &ch1);
+
+        d1.ch = 0;
+        ioctl( ps2gsfd, PS2IOC_GDISPLAY, &d1);
+        d1.ch = 1;
+	d1.dy += 1;
+        ioctl( ps2gsfd, PS2IOC_SDISPLAY, &d1);
+
+        ioctl( ps2gsfd, PS2IOC_GPMODE, &pmode);
+        pmode.sw = 3;
+        pmode.alp = alpha;
+        pmode.amod = 0;
+        pmode.mmod = 1; // use ALP as alpha
+        pmode.slbg = 0; // use OUT2
+        ioctl( ps2gsfd, PS2IOC_SPMODE, &pmode);
+
+    }
+    gsosClearFrameBuffer(w+dx, h+dy, fbp, psm);
+}
+
+
+int gsosReadImage( 
+int x, int y, int w, int h,
+unsigned int bp,
+int bw, int psm,
+GSOSuchar *pPix )
+{
+    struct ps2_image img;
+    size_t size;
+    int nlines;
+    int maxlines;
+    int txfline;
+    int linebytewidth;
+
+    assert (ps2count == 0);
+
+    linebytewidth = (psm == 2) ? w*2 : w*4;
+    maxlines = gsos_maxpacket_size / linebytewidth;
+    img.ptr = ps2dbp[ps2dbf] ;
+    img.fbp = bp ;
+    img.fbw = bw ;
+    img.psm = psm ;
+    img.x = x ;
+    img.w = w ;
+    nlines = h;
+    while(nlines > 0) {
+      txfline = (maxlines < nlines) ? maxlines : nlines;
+      img.y = y ;
+      img.h = txfline ;
+      if (ioctl(ps2gsfd, PS2IOC_STOREIMAGE, &img) < 0)
+	return -1;
+   
+      size = txfline * linebytewidth;
+      memcpy((void *)pPix, (void *)ps2dbp[ps2dbf], size) ;
+      y += txfline;
+      nlines -= txfline;
+      pPix += size;
+    }
+    return 0 ;
+}
+
+int gsosWriteImage( 
+  int x, int y, int w, int h,
+  unsigned int bp,
+  int bw, int psm,
+  GSOSuchar *pPix )
+{
+    struct ps2_image img;
+    size_t size;
+    int nlines;
+    int maxlines;
+    int txfline;
+    int linebytewidth;
+
+    assert (ps2count == 0);
+
+    img.ptr = ps2dbp[ps2dbf];
+    img.fbp = bp;
+    img.fbw = bw;
+    img.psm = psm;
+    img.x = x;
+    img.w = w;
+    nlines = h;
+    linebytewidth = (psm == 2) ? w*2 : w*4;
+    maxlines = gsos_maxpacket_size / linebytewidth;
+    while(nlines > 0) {
+      txfline = (maxlines < nlines) ? maxlines : nlines;
+      size = txfline * linebytewidth;
+      memcpy((void *)ps2dbp[ps2dbf], (void *)pPix, size);
+
+      img.y = y ;
+      img.h = txfline ;
+      if(ioctl(ps2gsfd, PS2IOC_LOADIMAGEA, &img) < 0)
+	return -1;
+      y += txfline;
+      nlines -= txfline;
+      pPix += size;
+
+      ioctl( ps2gsfd, PS2IOC_SENDQCT, (nlines > 0) ? 2 : 1 );
+      ps2dbf = 1 - ps2dbf;
+      ps2cur = ps2dbp[ps2dbf]; 
+      img.ptr = ps2dbp[ps2dbf];
+    }
+    return 0 ;
+}
+
+
+
+static void gsosClearFrameBuffer(int w, int h, int fbp, int psm)
+{
+    struct ps2_image img;
+    int y;
+    int linebytewidth;
+    int maxlines;
+
+    memset((void *)ps2buf, 0x00, GSOS_MAXPACKETSIZE);
+    img.ptr = ps2buf;
+    img.fbp = fbp;
+    img.fbw = w / 64;
+    img.psm = psm;
+    img.x = 0;
+    img.w = w;
+    linebytewidth = (psm == 2) ? w*2 : w*4;
+    maxlines = GSOS_MAXPACKETSIZE / linebytewidth;
+    img.h = maxlines;
+    for(y = 0; y < h; y += maxlines) {
+      img.y = y ;
+      if(ioctl(ps2gsfd, PS2IOC_LOADIMAGE, &img) < 0) {
+	ErrorF("gsosClearFrameBuffer: ioctl Error(%d)\n", y);
+	return;
+      }
+    }
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos.h XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos.h
--- XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos.h	Wed Mar 14 21:17:25 2001
@@ -0,0 +1,296 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#ifndef GSOS_H
+#define GSOS_H
+
+#include "gsostypes.h"
+#include "gsosregs.h"
+#include <sys/ioctl.h>
+#include <linux/ps2/dev.h>
+
+#define GSOS_GIFTAG_SIZE       (128/8)
+
+#define GSOS_GIF_EOP_CONTINUE  0
+#define GSOS_GIF_EOP_TERMINATE 1
+#define GSOS_GIF_PRE_IGNORE    0
+#define GSOS_GIF_PRE_ENABLE    1
+#define GSOS_GIF_PRI_IIP       (1<<3)
+#define GSOS_GIF_PRI_TME       (1<<4)
+#define GSOS_GIF_PRI_FGE       (1<<5)
+#define GSOS_GIF_PRI_ABE       (1<<6)
+#define GSOS_GIF_PRI_AA1       (1<<7)
+#define GSOS_GIF_PRI_FST       (1<<8)
+#define GSOS_GIF_PRI_CTXT      (1<<9)
+#define GSOS_GIF_PRI_FIX       (1<<10)
+#define GSOS_GIF_FLG_PACKED    0
+#define GSOS_GIF_FLG_REGLIST   1
+#define GSOS_GIF_FLG_IMAGE     2
+
+#define GSOS_GIF_REG_PRIM      0x0
+#define GSOS_GIF_REG_RGBAQ     0x1
+#define GSOS_GIF_REG_ST        0x2
+#define GSOS_GIF_REG_UV        0x3
+#define GSOS_GIF_REG_XYZF2     0x4
+#define GSOS_GIF_REG_XYZ2      0x5
+#define GSOS_GIF_REG_TEX0_1    0x6
+#define GSOS_GIF_REG_TEX0_2    0x7
+#define GSOS_GIF_REG_CLAMP_1   0x8
+#define GSOS_GIF_REG_CLAMP_2   0x9
+#define GSOS_GIF_REG_FOG       0xa
+#define GSOS_GIF_REG_XYZF3     0xc
+#define GSOS_GIF_REG_XYZ3      0xd
+#define GSOS_GIF_REG_AD        0xe
+#define GSOS_GIF_REG_NOP       0xf
+
+#define GSOS_PRIM_POINT    0x0
+#define GSOS_PRIM_LINE     0x1
+#define GSOS_PRIM_LSTRIP   0x2
+#define GSOS_PRIM_TRIANGLE 0x3
+#define GSOS_PRIM_TSTRIP   0x4
+#define GSOS_PRIM_TFAN     0x5
+#define GSOS_PRIM_SPRITE   0x6
+
+
+/* GIFTag (EE User's Man. P139) */
+#define EOP_SHIFT (15)
+#define EOP_MASK (1 << EOP_SHIFT)
+
+#define PRE_SHIFT (46)
+#define PRE_MASK (1 << PRE_SHIFT)
+
+#define PRIM_SHIFT (47)
+#define PRIM_MASK (0x3FF << PRIM_SHIFT)
+
+#define FLG_SHIFT (58)
+#define FLG_MASK (3 << FLG_SHIFT)
+
+int gsosOpen();
+int gsosClose();
+void gsosSetScreen(int mode, int res, int w, int h, int fbp, int psm, int alpha, int dx, int dy);
+int gsosReadImage( int x, int y, int w, int h, unsigned int bp, int bw, int psm, GSOSuchar *pPix );
+int gsosWriteImage( int x, int y, int w, int h, unsigned int bp, int bw, int psm, GSOSuchar *pPix );
+
+
+#define gsosFlush() do {;  } while (0)
+
+extern int gsos_maxpacket_size;
+extern GSOSbit64 *ps2dbp[2]; /* double buffered DMA base pointer */
+extern GSOSbit64 *ps2cur;    /* current pointer of DMA buffer */
+extern int ps2dbf;           /* double buffer flag */
+extern int ps2count;         /* counter for DMA buffer */
+extern int ps2gsfd ;         /* file pointer for driver */
+extern GSOSbit64 *ps2lastgiftag;  /* last giftag ptr */
+
+static inline void gsosSetEOPTerminate(void)
+{
+  if(ps2lastgiftag) {
+    *ps2lastgiftag = (GSOS_GIF_EOP_TERMINATE << EOP_SHIFT)
+      | (*ps2lastgiftag & ~EOP_MASK);
+  }
+  ps2lastgiftag = 0;
+}
+
+static
+inline
+int gsosCalcPrimSize(int nreg, int flag)
+{
+  static int datatype_size[] = {16,8,16,16};
+  return nreg * datatype_size[flag & 3];
+}
+
+static
+inline
+int gsosCalcPacketSize(int nloop, int nreg, int flag)
+{
+  return nloop * gsosCalcPrimSize(nreg, flag);
+}
+
+static
+inline
+int gsosRemainBufSize()
+{
+  int n;
+  n = (int)((char *)ps2cur - (char *)ps2dbp[ps2dbf]);
+  if(gsos_maxpacket_size < n) {
+    ErrorF("gsosRemainBufSize:n=%d,ps2cur=%x,ps2buf=%x\n", n, ps2cur, ps2dbp[ps2dbf]);
+    return 0;
+  }
+  return gsos_maxpacket_size - n;
+}
+
+static
+inline
+int gsosCalcPacketCount(int nreg, int flag)
+{
+  int packetSize;
+  int bufferSize;
+  packetSize = gsosCalcPrimSize(nreg, flag);
+  bufferSize = gsosRemainBufSize() - GSOS_GIFTAG_SIZE;
+  if(bufferSize <= 0) {
+    return 0;	/* can't allocate GIFTag */
+  }
+  return (bufferSize > packetSize) ? (bufferSize / packetSize) : 0;
+}
+
+static
+inline
+void gsosStoreQword(GSOSbit128 *addr, GSOSbit128 val)
+{
+    GSOSQword src;
+
+    src.ti = val;
+    __asm__ __volatile__(
+        ".set push\n"
+        "       .set    mips3\n"
+        "       pextlw  $8, %1, %0\n"
+        "       pextlw  $9, %3, %2\n"
+        "       pcpyld  $8, $9, $8\n"
+        "       sq      $8, (%4)\n"
+        "       .set    pop"
+        : /* no output */
+        : "r"(src.si.lo0), "r"(src.si.lo1),
+            "r"(src.si.hi0), "r"(src.si.hi1),
+            "r" (addr) : "$8", "$9");
+}
+
+static
+inline
+void gsosSetPacketAddrData(
+    GSOSbit64 addr, GSOSbit64 data)
+{
+    GSOSQword cnv;
+    cnv.di.lo=data;
+    cnv.di.hi=addr;
+    gsosStoreQword ((GSOSbit128 *) ps2cur, cnv.ti);
+    ps2cur += 2;
+    ps2count += 2;
+}
+
+static
+inline
+void gsosSetPacket2(
+    GSOSbit64 d1, GSOSbit64 d2)
+{
+    GSOSQword cnv;
+    cnv.di.lo=d1;
+    cnv.di.hi=d2;
+    gsosStoreQword ((GSOSbit128 *) ps2cur, cnv.ti);
+    ps2cur += 2;
+    ps2count += 2;
+}
+
+static
+inline
+void gsosSetPacket4(
+    unsigned int d1, unsigned int d2, unsigned int d3, unsigned int d4)
+{
+    GSOSQword cnv;
+    cnv.si.lo0=d1;
+    cnv.si.lo1=d2;
+    cnv.si.hi0=d3;
+    cnv.si.hi1=d4;
+
+    gsosStoreQword ((GSOSbit128 *) ps2cur, cnv.ti);
+    ps2cur += 2;
+    ps2count += 2;
+}
+
+static
+inline
+void gsosSetPacketAddrData4(
+    unsigned int addr, 
+    unsigned short d1, unsigned short d2, unsigned short d3, unsigned short d4)
+{
+    GSOSQword cnv;
+    cnv.hi.lo_lo0 = d1;
+    cnv.hi.lo_lo1 = d2;
+    cnv.hi.lo_hi0 = d3;
+    cnv.hi.lo_hi1 = d4;
+    cnv.di.hi = addr;
+
+    gsosStoreQword ((GSOSbit128 *) ps2cur, cnv.ti);
+    ps2cur += 2;
+    ps2count += 2;
+
+}
+
+static
+inline
+void gsosExec()
+{
+    struct ps2_packet pkt ;
+
+    if( ps2count ){
+        gsosSetEOPTerminate();
+        pkt.ptr = ps2dbp[ps2dbf] ;
+        pkt.len = (int)((char *)ps2cur - (char *)ps2dbp[ps2dbf]) ;
+        ioctl( ps2gsfd, PS2IOC_SENDA, &pkt ) ;
+	ioctl( ps2gsfd, PS2IOC_SENDQCT, 2 ) ;
+    }
+    ps2dbf = 1 - ps2dbf ;
+    ps2cur = ps2dbp[ps2dbf] ;
+    ps2count = 0 ;
+}
+
+static 
+inline
+int gsosMakeGiftag(
+	unsigned short nloop,	/* repeat num */
+	unsigned char eop,		/* IGNORED: end of packet */
+	unsigned char pre,		/* prim field enable */
+	unsigned char prim,		/* prim date set to PRIM register */
+	unsigned char flg,		/* 0:PACKED 1:REGLIST 2:IMAGE */
+	unsigned char nreg,		/* number of regs(MAX=16) */
+	GSOSbit64 regs)	/* register description */
+{
+  int ps;
+  int rs;
+
+  /* Now gsosSetEOPTerminate() sets eop, so ignore eop param here */
+
+  ps = gsosCalcPacketSize(nloop, nreg, flg);
+  rs = gsosRemainBufSize();
+  if(rs < ps) {	/* buffer small -> flash buffer*/
+    gsosExec();
+    rs = gsos_maxpacket_size;
+  }
+  if(rs < ps) {
+    /* Packet too large */
+    ErrorF("Packet too large\n");
+    return 1;
+  }
+  ps2lastgiftag = ps2cur;	/* save giftag ptr */
+  *ps2cur++ = (GSOSbit64)nloop |  ((GSOSbit64)pre<<46) | ((GSOSbit64)prim<<47)
+            | ((GSOSbit64)flg<<58) | ((GSOSbit64)nreg<<60) ;
+  *ps2cur++ = regs ;
+  ps2count += 2;
+  return 0 ;
+}
+
+#endif /* GSOS_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos_en.txt XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos_en.txt
--- XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos_en.txt	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos_en.txt	Wed Apr 11 13:13:00 2001
@@ -0,0 +1,487 @@
+       Copyright (C) 2000  Sony Computer Entertainment Inc.
+                     All Rights Reserved.
+
+----------------------------------------------------------------------
+Purpose
+----------------------------------------------------------------------
+
+To develop the Xserver for Linux, it is necessary to implement the ddx block 
+dependent on hardware.  As the device to support the ddx development, 
+hardware is operated through the device driver.  The use of this GSOS 
+interface allows hiding the device driver I/F, duplexing the DMA transfer 
+buffers and increasing the efficiency of using the device driver.
+
+                 Xserver
+          +--------------------+
+          |        dix         |
+          +--------------------+
+          |      hw(=ddx)      |
+          +--------------------+
+
+          +--------------------+
+          |        gsos        |
+          +--------------------+
+          +--------------------+
+          |       driver       |
+          +--------------------+
+          +--------------------+
+          |      EE-GS hw      |
+          +--------------------+
+
+
+----------------------------------------------------------------------
+How to use the device
+----------------------------------------------------------------------
+
+[1] Initialization
+
+        // Initializing gsos
+        gsosOpen();
+	// Setting the screen mode
+	gsosSetScreen(0, (fr<<8) | res, xsize, ysize, GSX_FRAME_BASE, psm);
+
+[2] Setting the DMA data and the DMA transfer
+
+        // Setting Giftag
+        gsosMakeGiftag(1, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+                0, GSOS_GIF_PACKED, 1, GSOS_GIF_REG_AD);
+
+        // Setting the packet data
+        gsosSetPacketAddrData(GSOS_PRIM, GSOS_PRIM_POINT);
+
+        // Setting Giftag
+        gsosMakeGiftag(nloop, GSOS_GIF_EOP_TERMINATE,
+                GSOS_GIF_PRE_IGNORE, 0, GSOS_GIF_PACKED, 2,
+                (GSOS_XYZ2 << 4) | GSOS_RGBA);
+
+        // Setting the packet data
+        for(lp = 0 ; lp < nloop ; lp++){
+            gsosSetPacket4(r[lp], g[lp], b[lp], a[lp]);
+            gsosSetPacket4(x[lp], y[lp], z[lp], 0);
+        }
+
+        // Opening the DMA transfer
+        gsosExec();
+
+[3] Closing process
+
+        // Closing gsos
+        gsosClose();
+
+----------------------------------------------------------------------
+TYPE
+----------------------------------------------------------------------
+
+    GSOSint        int
+    GSOSuint       unsigned int
+    GSOSshort      short
+    GSOSushort     unsigned short
+    GSOSchar       char
+    GSOSuchar      unsigned char
+    GSOSfloat      float
+    GSOSdouble     double
+    GSOSbit64      unsigned long long
+
+----------------------------------------------------------------------
+GSOSpacket                    Packet structure
+----------------------------------------------------------------------
+
+    typedef struct {
+        GSOSbit64    u64[2];
+        GSOSuint     u32[4];
+    } GSOSpacket;
+
+----------------------------------------------------------------------
+gsosOpen                      It opens GSOS.
+----------------------------------------------------------------------
+
+[Format]
+        int gsosOpen()
+
+[Return values]
+        0:    Normal termination
+        Except 0: Error
+
+[Description]
+	It initializes GSOS.
+	It opens the GS device and the memory device, reserves the DMA transfer 
+	buffer and stores the current screen mode.
+
+----------------------------------------------------------------------
+gsosClose                     It closes GSOS.
+----------------------------------------------------------------------
+
+[Format]
+        int gsosClose()
+
+[Return values]
+        0:    Normal termination
+        Except 0: Error
+
+[Description]
+       	It finishes GSOS.
+	It releases the reserved DMA transfer buffer and closes the device 
+	after restoring the screen mode.
+
+----------------------------------------------------------------------
+gsosSetScreen		It sets the screen mode.
+----------------------------------------------------------------------
+
+[Format]
+	void gsosSetScreen(
+	         int	mode,
+	         int	res,
+	         int	w,
+		 int	h,
+	         int	fbp,
+	         int	psm,
+		 int	alpha,
+		 int	dx,
+		 int	dy)
+
+[Arguments]
+	mode:		Video signal mode
+	res:		Resolution/interlace mode
+	w:		Width of the display area
+	h:		Height of the display area
+	fbp:		Flame buffer base pointer
+	psm:		Pixel format
+	alpha:		odd-even line mixing raito
+	dx:		x margin
+	dy:		y margin
+
+[Description]
+	It sets the screen mode of the GS Console and clears the flame buffer.
+
+----------------------------------------------------------------------
+gsosMakeGiftag                It sets Giftag.
+----------------------------------------------------------------------
+
+[Format]
+        int gsosMakeGiftag(
+                GSOSbit64    nloop,
+                GSOSbit64    eop,
+                GSOSbit64    pre,
+                GSOSbit64    prim,
+                GSOSbit64    flg,
+                GSOSbit64    nreg,
+                GSOSbit64    *regs)
+
+[Arguments]
+        nloop   Number of loops
+        eop     End of packet
+                    GSOS_GIF_EOP_CONTINUE : Subsequent primitives exist.
+                    GSOS_GIF_EOP_TERMINATE: Subsequent primitives do not 
+exist.
+		It is not used due to the change that sets eop with gsosExec().
+
+        pre     PRIM field enable
+                    GSOS_GIF_PRIM_IGNORE: It ignores the PRIM field.
+                    GSOS_GIF_PRIM_ENABLE: 
+			It sets the value of the PRIM field to the 
+			PRIM register.
+        prim    Data to be set to the PRIM register of the GS
+        flg     Data format
+                    GSOS_GIF_FLG_PACKED : PACKED mode
+                    GSOS_GIF_FLG_REGLIST: REGLIST mode
+                    GSOS_GIF_FLG_IMAGE  : IMAGE mode
+        nreg    Number of register descriptors.  0 represents 16 pieces.
+        regs    Register descriptor (4 bits, maximum 16 pieces)
+                    GSOS_GIF_REG_PRIM
+                    GSOS_GIF_REG_RGBAQ
+                    GSOS_GIF_REG_ST
+                    GSOS_GIF_REG_UV
+                    GSOS_GIF_REG_XYZF2
+                    GSOS_GIF_REG_XYZ2
+                    GSOS_GIF_REG_TEX0_1
+                    GSOS_GIF_REG_TEX0_2
+                    GSOS_GIF_REG_CLAMP_1
+                    GSOS_GIF_REG_CLAMP_2
+                    GSOS_GIF_REG_FOG
+                    GSOS_GIF_REG_XYZF3
+                    GSOS_GIF_REG_XYZ3
+                    GSOS_GIF_REG_AD
+                    GSOS_GIF_REG_NOP
+
+[Return values]
+        0:    Normal termination
+        Except 0: Error
+
+[Description]
+	It sets GIFtag to the current DMA transfer buffer.  When the GIF 
+	packet cannot be stored in the current buffer, gsosExec() is executed.  
+	If the GIF packet cannot be stored yet, an error returns.
+
+----------------------------------------------------------------------
+gsosSetPacket2                It sets data to a packet.
+----------------------------------------------------------------------
+
+[Format]
+        void gsosSetPacket2(
+                GSOSbit64    data1,
+                GSOSbit64    data2)
+
+[Arguments]
+        data1   Data 1(Low)
+        data2   Data 2(High)
+
+[Description]
+        It sets the DMA transfer data to the current DMA transfer buffer.
+        128        96        64        32        0
+         +---------+---------+---------+---------+
+         |       data2       |       data1       |
+         +---------+---------+---------+---------+
+
+----------------------------------------------------------------------
+gsosSetPacket4                It sets data to a packet.
+----------------------------------------------------------------------
+
+[Format]
+        void gsosSetPacket4(
+                GSOSbit64    data1,
+                GSOSbit64    data2,
+                GSOSbit64    data3,
+                GSOSbit64    data4)
+
+[Arguments]
+        data1   Data 1
+        data2   Data 2
+        data3   Data 3
+        data4   Data 4
+
+[Description]
+        It sets the DMA transfer data to the current DMA transfer buffer.
+        128        96        64        32        0
+         +---------+---------+---------+---------+
+         |  data4  |  data3  |  data2  |  data1  |
+         +---------+---------+---------+---------+
+
+
+----------------------------------------------------------------------
+gsosSetPacketAddrData        It sets data to a packet.
+----------------------------------------------------------------------
+
+[Format]
+        void gsosSetPacketAddrData(
+                GSOSbit64    addr,
+                GSOSbit64    data)
+
+[Arguments]
+        addr    Data (Addr)
+        data    Data (Data)
+
+[Description]
+        It sets the DMA transfer data to the current DMA transfer buffer.
+        128        96        64        32        0
+         +---------+---------+---------+---------+
+         |       data        |       addr        |
+         +---------+---------+---------+---------+
+
+----------------------------------------------------------------------
+gsosSetPacketAddrData4       It sets data to a packet.
+----------------------------------------------------------------------
+
+[Format]
+        void gsosSetPacketAddrData4(
+                GSOSbit64    addr,
+                GSOSbit64    data1,
+                GSOSbit64    data2,
+                GSOSbit64    data3,
+                GSOSbit64    data4)
+
+[Arguments]
+        addr    Data (Addr)
+        data1   Data 1
+        data2   Data 2
+        data3   Data 3
+        data4   Data 4
+
+[Description]
+        It sets the DMA transfer data to the current DMA transfer buffer.
+        128        96        64        32        0
+         +---------+---------+----+----+----+----+
+         |       addr        |dat4|dat3|dat2|dat1|
+         +---------+---------+----+----+----+----+
+
+----------------------------------------------------------------------
+gsosExec                      It starts the DMA transfer.
+----------------------------------------------------------------------
+
+[Format]
+        void gsosExec()
+
+[Arguments]
+        None
+
+[Description]
+        It executes the DMA transfer of the data set to the current DMA 
+	transfer buffer.  Eop of GIFtag is set to 1 at this time.  It 
+	switches the buffer after the transfer.
+
+----------------------------------------------------------------------
+gsosReadImage                 It reads an image.
+----------------------------------------------------------------------
+
+[Format]
+        int gsosReadImage(
+                int          x,
+                int          y,
+                int          w,
+                int          h,
+                unsigned int bp,
+                int          bw,
+                int          psm,
+                GSOSuchar     *pPix)
+
+[Arguments]
+        x       x coordinate
+        y       y coordinate
+        w       Width
+        h       Height
+        bp      Base pointer of the buffer
+        bw      Width of the buffer
+        psm     Pixel format
+        pPix    Buffer that stores the read data
+
+[Return values]
+        0:    Normal termination
+        Except 0: Error
+
+[Description]
+        It reads the image data of pPix in the width of w and in the height 
+	of h from (x,y) of pDraw.
+
+----------------------------------------------------------------------
+gsosWriteImage                It writes an image.
+----------------------------------------------------------------------
+
+[Format]
+        int gsosWriteImage(
+                int          x,
+                int          y,
+                int          w,
+                int          h,
+                unsigned int bp,
+                int          bw,
+                int          psm,
+                GSOSuchar     *pPix)
+
+[Arguments]
+        pGC     GC
+        pDraw   Drawable to be written
+        x       x coordinate
+        y       y coordinate
+        w       Width
+        h       Height
+        bp      Base pointer of the buffer
+        bw      Width of the buffer
+        psm     Pixel format
+        pPix    Buffer that stores the data to be written
+
+[Return values]
+        0:    Normal termination
+        Except 0: Error
+
+[Description]
+        It writes the image data of pPix in the width of w and in the height 
+	of h to (x,y) of pDraw.
+
+----------------------------------------------------------------------
+gsosCalcPrimSize	It calculates the primitive size (number of bytes).
+----------------------------------------------------------------------
+
+[Format]
+	int gsosCalcPrimSize(int nreg, int flag)
+
+[Arguments]
+	nreg:		Number of using registers
+	flag:		Data format
+
+[Return value]
+	It is the number of bytes that one primitive uses.
+
+[Description]
+        It calculates the buffer size that the primitive uses from the number 
+	of using registers and the data format.
+
+----------------------------------------------------------------------
+gsosCalcPacketSize	It calculates the GIF packet size.
+----------------------------------------------------------------------
+
+[Format]
+	int gsosCalcPacketSize(int nloop, int nreg, int flag)
+
+[Arguments]
+	nloop:		Number of loops
+	nreg:		Number of using registers
+	flag:		Data format
+
+[Return value]
+	It is a GIF packet size.
+
+[Description]
+	It calculates the size of a GIF packet.
+
+----------------------------------------------------------------------
+gsosRemainBufSize	It returns the remaining size of the DMA buffer.
+----------------------------------------------------------------------
+
+[Format]
+	int gsosRemainBufSize()
+
+
+[Return value]
+	It is the number of the remaining bytes of a buffer.
+
+[Description]
+	It returns the remaining size of the current DMA transfer buffer.
+
+----------------------------------------------------------------------
+gsosCalcPacketCount	It returns the number of packets that can be stored 
+in a buffer.
+----------------------------------------------------------------------
+
+[Format]
+	int gsosCalcPacketCount(int nreg, int flag)
+
+[Arguments]
+	nreg:		Number of using registers
+	flag:		Data format
+
+[Return value]
+	It is the number of packets.
+
+[Description]
+	It returns the number of packets that can be stored in the current 
+	DMA transfer buffer.
+
+----------------------------------------------------------------------
+gsosSetEOPTerminate	It sets 1 to eop of GIFtag.
+----------------------------------------------------------------------
+
+[Format]
+	static void gsosSetEOPTerminate(void)
+
+[Description]
+	It sets 1 to the eop bit of GIFtag set last.
+	It is used in gsos.
+
+----------------------------------------------------------------------
+gsosClearFrameBuffer
+----------------------------------------------------------------------
+
+[Format]
+	static void gsosClearFrameBuffer(int w, int h, int fbp, int psm)
+
+[Arguments]
+	w:		Width of the display area
+	h:		Height of the display area
+	fbp:		Base pointer of the flame buffer
+	psm:		Pixel format
+
+[Description]
+	It clears the flame buffer to 0.
+	It is used in gsos.
+
+----------------------------------------------------------------------
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos_jp.txt XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos_jp.txt
--- XFree86/xc/programs/Xserver/hw/gsx/gsos/gsos_jp.txt	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsos_jp.txt	Wed Apr 11 13:13:00 2001
@@ -0,0 +1,479 @@
+       Copyright (C) 2000  Sony Computer Entertainment Inc.
+                     All Rights Reserved.
+
+----------------------------------------------------------------------
+$BL\E*(B
+----------------------------------------------------------------------
+
+Linux$BMQ(BXserver$B$r3+H/$9$k$?$a$K$O(BH/W$B0MB8$N(Bddx$BIt$r<BAu$9$kI,MW$,$"$k!#(B
+ddx$B3+H/$r%5%]!<%H$9$k$?$a$N5!9=$H$7$F!"%G%P%$%9%I%i%$%P$rDL$7$F(BH/W$B$r(B
+$B6nF0$9$k!#$3$N(BGSOS$B%$%s%?!<%U%'!<%9$r;HMQ$9$k$3$H$K$h$j!"%G%P%$%9%I%i(B
+$B%$%P(BI/F$B$N1#JC$H(BDMA$BE>AwMQ%P%C%U%!$N(B2$B=E2=$r9T$$!"%G%P%$%9%I%i%$%P$NMxMQ(B
+$B8zN($r9b$/$9$k$3$H$,$G$-$k!#(B
+
+                 Xserver
+          +--------------------+
+          |        dix         |
+          +--------------------+
+          |      hw(=ddx)      |
+          +--------------------+
+
+          +--------------------+
+          |        gsos        |
+          +--------------------+
+          +--------------------+
+          |       driver       |
+          +--------------------+
+          +--------------------+
+          |      EE-GS hw      |
+          +--------------------+
+
+
+----------------------------------------------------------------------
+$B;HMQJ}K!(B
+----------------------------------------------------------------------
+
+[1] $B=i4|2==hM}(B
+
+        // gsos$B$r=i4|2=$9$k(B
+        gsosOpen();
+	// $B2hLL%b!<%I$r@_Dj$9$k(B
+	gsosSetScreen(0, (fr<<8) | res, xsize, ysize, GSX_FRAME_BASE, psm);
+
+[2] DMA$B%G!<%?$N@_Dj!"(BDMA$BE>Aw(B
+
+        // Giftag$B@_Dj(B
+        gsosMakeGiftag(1, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+                0, GSOS_GIF_PACKED, 1, GSOS_GIF_REG_AD);
+
+        // $B%Q%1%C%H%G!<%?@_Dj(B
+        gsosSetPacketAddrData(GSOS_PRIM, GSOS_PRIM_POINT);
+
+        // Giftag$B@_Dj(B
+        gsosMakeGiftag(nloop, GSOS_GIF_EOP_TERMINATE, 
+                GSOS_GIF_PRE_IGNORE, 0, GSOS_GIF_PACKED, 2,
+                (GSOS_XYZ2 << 4) | GSOS_RGBA);
+
+        // $B%Q%1%C%H%G!<%?@_Dj(B
+        for(lp = 0 ; lp < nloop ; lp++){
+            gsosSetPacket4(r[lp], g[lp], b[lp], a[lp]);
+            gsosSetPacket4(x[lp], y[lp], z[lp], 0);
+        }
+
+        // DMA$BE>Aw5/F0(B
+        gsosExec();
+
+[3] $B=*N;=hM}(B
+
+        // gsos$B$r=*N;$9$k(B
+        gsosClose();
+
+----------------------------------------------------------------------
+TYPE
+----------------------------------------------------------------------
+
+    GSOSint        int
+    GSOSuint       unsigned int
+    GSOSshort      short
+    GSOSushort     unsigned short
+    GSOSchar       char
+    GSOSuchar      unsigned char
+    GSOSfloat      float
+    GSOSdouble     double
+    GSOSbit64      unsigned long long
+
+----------------------------------------------------------------------
+GSOSpacket                    $B%Q%1%C%H9=B$BN(B
+----------------------------------------------------------------------
+
+    typedef struct {
+        GSOSbit64    u64[2];
+        GSOSuint     u32[4];
+    } GSOSpacket;
+
+----------------------------------------------------------------------
+gsosOpen                      GSOS$B3+;O(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        int gsosOpen()
+
+[$BLa$jCM(B]
+        0:    $B@5>o=*N;(B
+        0$B0J30(B:$B%(%i!<(B
+
+[$B2r@b(B]
+        GSOS$B=i4|2==hM}!#(B
+	GS$B%G%P%$%9$H%a%b%j%G%P%$%9$r%*!<%W%s$7!"(BDMA$BE>Aw%P%C%U%!$r(B
+	$B3NJ]$7!"8=:_2hLL%b!<%I$rJ]B8$9$k!#(B
+
+----------------------------------------------------------------------
+gsosClose                     GSOS$B=*N;(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        int gsosClose()
+
+[$BLa$jCM(B]
+        0:    $B@5>o=*N;(B
+        0$B0J30(B:$B%(%i!<(B
+
+[$B2r@b(B]
+        GSOS$B=*N;=hM}!#(B
+	$B3NJ]$7$?(BDMA$BE>Aw%P%C%U%!$r3+J|$7!"2hLL%b!<%I$rI|858e!"%G%P%$%9$r(B
+	$B%/%m!<%:$9$k!#(B
+
+----------------------------------------------------------------------
+gsosSetScreen		$B2hLL%b!<%I$N@_Dj$r9T$&(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+	void gsosSetScreen(
+	         int	mode,
+	         int	res,
+	         int	w,
+		 int	h,
+	         int	fbp,
+	         int	psm,
+		 int	alpha,
+		 int	dx,
+		 int	dy)
+
+[$B0z?t(B]
+	mode:		$B%S%G%*?.9f%b!<%I(B
+	res:		$B2rA|EY(B/$B%$%s%?!<%l!<%9%b!<%I(B
+	w:		$BI=<(NN0h$NI}(B
+	h:		$BI=<(NN0h$N9b$5(B
+	fbp:		$B%U%l!<%`%P%C%U%!%Y!<%9%]%$%s%?(B
+	psm:		$B%T%/%;%k%U%)!<%^%C%H(B
+	alpha:		$B%$%s%?!<%l!<%9;~$K4q?t$H6v?t%i%$%s$r(B
+			$B%i%$%s$r%_%C%/%9$9$k$H$-$N&ACM(B
+	dx:		x$B$N%^!<%8%s(B
+	dy:		y$B$N%^!<%8%s(B
+
+[$B2r@b(B]
+	GS Console$B$N2hLL%b!<%I$r@_Dj$7!"%U%l!<%`%P%C%U%!$r%/%j%"$9$k!#(B
+
+----------------------------------------------------------------------
+gsosMakeGiftag                Giftag$B@_Dj(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        int gsosMakeGiftag(
+                GSOSbit64    nloop,
+                GSOSbit64    eop,
+                GSOSbit64    pre,
+                GSOSbit64    prim,
+                GSOSbit64    flg,
+                GSOSbit64    nreg,
+                GSOSbit64    *regs)
+
+[$B0z?t(B]
+        nloop   $B7+$jJV$72s?t(B
+        eop     $B%?!<%_%M!<%7%g%s>pJs(B(End of Packet)
+                    GSOS_GIF_EOP_CONTINUE : $B8eB3%W%j%_%F%#%V$"$j(B
+                    GSOS_GIF_EOP_TERMINATE: $B8eB3%W%j%_%F%#%V$J$7(B
+		$B"((BgsosExec()$B$G(Beop$B$r@_Dj$9$k$h$&$KJQ99$5$l$?$N$GL$;HMQ(B
+        pre     PRIM$B%U%#!<%k%I(BEnable
+                    GSOS_GIF_PRIM_IGNORE: PRIM$B%U%#!<%k%I$rL5;k(B
+                    GSOS_GIF_PRIM_ENABLE:
+                              PRIM$B%U%#!<%k%I$NCM$r(BPRIM$B%l%8%9%?$K@_Dj(B
+        prim    GS$B$N(BPRIM$B%l%8%9%?$X@_Dj$9$k%G!<%?(B
+        flg     $B%G!<%?7A<0(B
+                    GSOS_GIF_FLG_PACKED : PACKED$B%b!<%I(B
+                    GSOS_GIF_FLG_REGLIST: REGLIST$B%b!<%I(B
+                    GSOS_GIF_FLG_IMAGE  : IMAGE$B%b!<%I(B
+        nreg    $B%l%8%9%?5-=R;R?t!#(B0$B$O(B16$B8D(B
+        regs    $B%l%8%9%?5-=R;R(B(4bit*$B:GBg(B16$B8D(B)
+                    GSOS_GIF_REG_PRIM
+                    GSOS_GIF_REG_RGBAQ
+                    GSOS_GIF_REG_ST
+                    GSOS_GIF_REG_UV
+                    GSOS_GIF_REG_XYZF2
+                    GSOS_GIF_REG_XYZ2
+                    GSOS_GIF_REG_TEX0_1
+                    GSOS_GIF_REG_TEX0_2
+                    GSOS_GIF_REG_CLAMP_1
+                    GSOS_GIF_REG_CLAMP_2
+                    GSOS_GIF_REG_FOG
+                    GSOS_GIF_REG_XYZF3
+                    GSOS_GIF_REG_XYZ3
+                    GSOS_GIF_REG_AD
+                    GSOS_GIF_REG_NOP
+
+[$BLa$jCM(B]
+        0:    $B@5>o=*N;(B
+        0$B0J30(B:$B%(%i!<(B
+
+[$B2r@b(B]
+        $B8=:_$N(BDMA$BE>AwMQ%P%C%U%!$K(BGIFtag$B$r@_Dj$9$k!"$3$N;~(BGIF$B%Q%1%C%H$,(B
+	$B8=:_$N%P%C%U%!$K<}$^$i$J$$;~$O(BgsosExec()$B$r<B9T$9$k!#$=$l$G$b(B
+	$B%P%C%U%!$K<}$^$i$J$$>l9g$K$O%(%i!<$H$9$k!#(B
+
+----------------------------------------------------------------------
+gsosSetPacket2                $B%Q%1%C%H$X$N%G!<%?@_Dj(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        void gsosSetPacket2(
+                GSOSbit64    data1,
+                GSOSbit64    data2)
+
+[$B0z?t(B]
+        data1   $B%G!<%?(B1(Low)
+        data2   $B%G!<%?(B2(High)
+
+[$B2r@b(B]
+        DMA$BE>Aw$9$k%G!<%?$r8=:_$N(BDMA$BE>AwMQ%P%C%U%!$K%;%C%H$9$k!#(B
+        128        96        64        32        0
+         +---------+---------+---------+---------+
+         |       data2       |       data1       |
+         +---------+---------+---------+---------+
+
+----------------------------------------------------------------------
+gsosSetPacket4                $B%Q%1%C%H$X$N%G!<%?@_Dj(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        void gsosSetPacket4(
+                GSOSbit64    data1,
+                GSOSbit64    data2,
+                GSOSbit64    data3,
+                GSOSbit64    data4)
+
+[$B0z?t(B]
+        data1   $B%G!<%?(B1
+        data2   $B%G!<%?(B2
+        data3   $B%G!<%?(B3
+        data4   $B%G!<%?(B4
+
+[$B2r@b(B]
+        DMA$BE>Aw$9$k%G!<%?$r8=:_$N(BDMA$BE>AwMQ%P%C%U%!$K%;%C%H$9$k!#(B
+        128        96        64        32        0
+         +---------+---------+---------+---------+
+         |  data4  |  data3  |  data2  |  data1  |
+         +---------+---------+---------+---------+
+
+
+----------------------------------------------------------------------
+gsosSetPacketAddrData        $B%Q%1%C%H$X$N%G!<%?@_Dj(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        void gsosSetPacketAddrData(
+                GSOSbit64    addr,
+                GSOSbit64    data)
+
+[$B0z?t(B]
+        addr    $B%G!<%?(B(Addr)
+        data    $B%G!<%?(B(Data)
+
+[$B2r@b(B]
+        DMA$BE>Aw$9$k%G!<%?$r8=:_$N(BDMA$BE>AwMQ%P%C%U%!$K%;%C%H$9$k!#(B
+        128        96        64        32        0
+         +---------+---------+---------+---------+
+         |       data        |       addr        |
+         +---------+---------+---------+---------+
+
+----------------------------------------------------------------------
+gsosSetPacketAddrData4       $B%Q%1%C%H$X$N%G!<%?@_Dj(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        void gsosSetPacketAddrData4(
+                GSOSbit64    addr,
+                GSOSbit64    data1,
+                GSOSbit64    data2,
+                GSOSbit64    data3,
+                GSOSbit64    data4)
+
+[$B0z?t(B]
+        addr    $B%G!<%?(B(Addr)
+        data1   $B%G!<%?(B1
+        data2   $B%G!<%?(B2
+        data3   $B%G!<%?(B3
+        data4   $B%G!<%?(B4
+
+[$B2r@b(B]
+        DMA$BE>Aw$9$k%G!<%?$r8=:_$N(BDMA$BE>AwMQ%P%C%U%!$K%;%C%H$9$k!#(B
+        128        96        64        32        0
+         +---------+---------+----+----+----+----+
+         |       addr        |dat4|dat3|dat2|dat1|
+         +---------+---------+----+----+----+----+
+
+----------------------------------------------------------------------
+gsosExec                      DMA$BE>Aw5/F0(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        void gsosExec()
+
+[$B0z?t(B]
+        $B$J$7(B
+
+[$B2r@b(B]
+        $B8=:_$N(BDMA$BE>AwMQ%P%C%U%!$K%;%C%H$5$l$?%G!<%?$r(BDMA$BE>Aw$9$k!"(B
+	$B$3$N;~(BGIFtag$B$N(Beop$B$O(B1$B$K@_Dj$5$l$k!"E>Aw8e%P%C%U%!$r@Z$jBX$($k!#(B
+
+----------------------------------------------------------------------
+gsosReadImage                 $B%$%a!<%8$NFI9~$_(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        int gsosReadImage(
+                int          x,
+                int          y,
+                int          w,
+                int          h,
+                unsigned int bp,
+                int          bw,
+                int          psm,
+                GSOSuchar     *pPix)
+
+[$B0z?t(B]
+        x       x$B:BI8(B
+        y       y$B:BI8(B
+        w       $BI}(B
+        h       $B9b$5(B
+        bp      $B%P%C%U%!$N%Y!<%9%]%$%s%?(B
+        bw      $B%P%C%U%!$NI}(B
+        psm     $B%T%/%;%k%U%)!<%^%C%H(B
+        pPix    $BFI$_9~$s$G$-$?%G!<%?$r3JG<$9$k%P%C%U%!(B
+
+[$BLa$jCM(B]
+        0:    $B@5>o=*N;(B
+        0$B0J30(B:$B%(%i!<(B
+
+[$B2r@b(B]
+        pDraw$B$N(B(x,y)$B$+$iI}(Bw$B9b$5(Bh$B$N(BpPix$B$X%$%a!<%8%G!<%?$rFI$_9~$`!#(B
+
+----------------------------------------------------------------------
+gsosWriteImage                $B%$%a!<%8$N=q$-9~$_(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+        int gsosWriteImage(
+                int          x,
+                int          y,
+                int          w,
+                int          h,
+                unsigned int bp,
+                int          bw,
+                int          psm,
+                GSOSuchar     *pPix)
+
+[$B0z?t(B]
+        pGC     GC
+        pDraw   $B=q$-=P$9(BDrawable
+        x       x$B:BI8(B
+        y       y$B:BI8(B
+        w       $BI}(B
+        h       $B9b$5(B
+        bp      $B%P%C%U%!$N%Y!<%9%]%$%s%?(B
+        bw      $B%P%C%U%!$NI}(B
+        psm     $B%T%/%;%k%U%)!<%^%C%H(B
+        pPix    $B=q$-9~$`%G!<%?$,3JG<$5$l$?%P%C%U%!(B
+
+[$BLa$jCM(B]
+        0:    $B@5>o=*N;(B
+        0$B0J30(B:$B%(%i!<(B
+
+[$B2r@b(B]
+        pDraw$B$N(B(x,y)$B$XI}(Bw$B9b$5(Bh$B$N(BpPix$B$X%$%a!<%8%G!<%?$r=q$-9~$`!#(B
+
+----------------------------------------------------------------------
+gsosCalcPrimSize	$B%W%j%_%F%#%V%5%$%:(B($B%P%$%H?t(B)$B$N7W;;(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+	int gsosCalcPrimSize(int nreg, int flag)
+
+[$B0z?t(B]
+	nreg:		$B;HMQ%l%8%9%??t(B
+	flag:		$B%G!<%?7A<0(B
+
+[$BLa$jCM(B]
+	$B0l$D$N%W%j%_%F%#%V$,;H$&%P%$%H?t(B
+
+[$B2r@b(B]
+        $B;HMQ%l%8%9%??t$H%G!<%?7A<0$+$i%W%j%_%F%#%V$N;H$&%P%C%U%!%5%$%:(B
+	$B$r7W;;$9$k!#(B
+
+----------------------------------------------------------------------
+gsosCalcPacketSize	GIF $B%Q%C%1%C%H%5%$%:$N7W;;(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+	int gsosCalcPacketSize(int nloop, int nreg, int flag)
+
+[$B0z?t(B]
+	nloop:		$B7+$jJV$7?t(B
+	nreg:		$B;HMQ%l%8%9%??t(B
+	flag:		$B%G!<%?7A<0(B
+
+[$BLa$jCM(B]
+	GIF $B%Q%C%1%C%H%5%$%:(B
+
+[$B2r@b(B]
+	GIF$B%Q%1%C%H$NBg$-$5$r7W;;$9$k!#(B
+
+----------------------------------------------------------------------
+gsosRemainBufSize	DMA$B%P%C%U%!$N;D$j%5%$%:$rJV$9(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+	int gsosRemainBufSize()
+
+
+[$BLa$jCM(B]
+	$B%P%C%U%!$N;D$j%P%$%H?t(B
+
+[$B2r@b(B]
+	$B8=:_$N(BDMA$BE>AwMQ%P%C%U%!$N;D$j%5%$%:$rJV$9!#(B
+
+----------------------------------------------------------------------
+gsosCalcPacketCount	$B%P%C%U%!$K<}$^$k%Q%1%C%H?t$rJV$9(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+	int gsosCalcPacketCount(int nreg, int flag)
+
+[$B0z?t(B]
+	nreg:		$B;HMQ%l%8%9%??t(B
+	flag:		$B%G!<%?7A<0(B
+
+[$BLa$jCM(B]
+	$B%Q%1%C%H?t(B
+
+[$B2r@b(B]
+	$B8=:_$N(BDMA$BE>AwMQ%P%C%U%!$K<}$a$k$3$H$,$G$-$k%Q%1%C%H$N?t$rJV$9!#(B
+
+----------------------------------------------------------------------
+gsosSetEOPTerminate	GIFtag$B$N(Beop$B$K(B1$B$r@_Dj$9$k(B
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+	static void gsosSetEOPTerminate(void)
+
+[$B2r@b(B]
+	$B:G8e$K@_Dj$5$l$?(BGIFtag$B$N(Beop$B%S%C%H$r(B1$B$K$9$k!#(B
+	gsos$BFb$G;HMQ!#(B
+
+----------------------------------------------------------------------
+gsosClearFrameBuffer
+----------------------------------------------------------------------
+
+[$B=q<0(B]
+	static void gsosClearFrameBuffer(int w, int h, int fbp, int psm)
+
+[$B0z?t(B]
+	w:		$BI=<(NN0h$NI}(B
+	h:		$BI=<(NN0h$N9b$5(B
+	fbp:		$B%U%l!<%`%P%C%U%!%Y!<%9%]%$%s%?(B
+	psm:		$B%T%/%;%k%U%)!<%^%C%H(B
+
+[$B2r@b(B]
+	$B%U%l!<%`%P%C%U%!$r%<%m%/%j%"$9$k!#(B
+	gsos$BFb$G;HMQ!#(B
+
+----------------------------------------------------------------------
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsos/gsosregs.h XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsosregs.h
--- XFree86/xc/programs/Xserver/hw/gsx/gsos/gsosregs.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsosregs.h	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,549 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#ifndef _include_gsosregs_h_
+#define _include_gsosregs_h_
+
+/*---- Register Address Map --------------------------------*/
+enum GsosRegAddr {
+
+	/*-- vertex info. reg --*/
+    GSOS_PRIM			= 0x000,
+	GSOS_RGBAQ			= 0x001,
+	GSOS_ST				= 0x002,
+	GSOS_UV				= 0x003,
+	GSOS_XYZF2			= 0x004,
+	GSOS_XYZ2           = 0x005,
+	GSOS_XYZF			= 0x00a,
+	GSOS_XYZF3			= 0x00c,
+	GSOS_XYZ3			= 0x00d,
+	GSOS_RGBAQ2			= 0x011,
+	GSOS_ST2			= 0x012,
+	GSOS_UV2			= 0x013,
+	GSOS_XYOFFSET_1		= 0x018,
+	GSOS_XYOFFSET_2		= 0x019,
+	GSOS_PRMODECONT		= 0x01a,
+
+	/*-- drawing attribute reg. --*/
+	GSOS_PRMODE			= 0x01b,
+	GSOS_TEX0_1			= 0x006,
+	GSOS_TEX0_2			= 0x007,
+	GSOS_TEX1_1			= 0x014,
+	GSOS_TEX1_2			= 0x015,
+	GSOS_TEX2_1			= 0x016,
+	GSOS_TEX2_2			= 0x017,
+	GSOS_TEXCLUT        = 0x01c,
+	GSOS_SCANMSK		= 0x022,
+	GSOS_MIPTBP1_1		= 0x034,
+	GSOS_MIPTBP1_2		= 0x035,
+	GSOS_MIPTBP2_1		= 0x036,
+	GSOS_MIPTBP2_2		= 0x037,
+	GSOS_CLAMP_1		= 0x008,
+	GSOS_CLAMP_2		= 0x009,
+	GSOS_TEXA			= 0x03b,
+	GSOS_FOGCOL			= 0x03d,
+	GSOS_CACHEINVLD		= 0x03f,
+
+	/*-- pixel operation reg. --*/
+	GSOS_SCISSOR_1		= 0x040,
+	GSOS_SCISSOR_2		= 0x041,
+	GSOS_ALPHA_1		= 0x042,
+	GSOS_ALPHA_2		= 0x043,
+	GSOS_DIMX			= 0x044,
+	GSOS_DTHE			= 0x045,
+	GSOS_COLCLAMP		= 0x046,
+	GSOS_TEST_1			= 0x047,
+	GSOS_TEST_2			= 0x048,
+	GSOS_PABE			= 0x049,
+	GSOS_FBA_1			= 0x04a,
+	GSOS_FBA_2			= 0x04b,
+
+	/*-- buffer reg. --*/
+	GSOS_FRAME_1		= 0x04c,
+	GSOS_FRAME_2		= 0x04d,
+	GSOS_ZBUF_1			= 0x04e,
+	GSOS_ZBUF_2			= 0x04f,
+
+	/*-- inter-buffer transfer reg. --*/
+	GSOS_BITBLTBUF      = 0x050,
+	GSOS_TRXPOS			= 0x051,
+	GSOS_TRXREG			= 0x052,
+	GSOS_TRXDIR			= 0x053,
+	GSOS_HWREG			= 0x054,
+
+	/*-- other reg. --*/
+	GSOS_SIGNAL			= 0x060,
+	GSOS_FINISH			= 0x061,
+
+	/*-- PCRTC reg. (privilege port) --*/
+	GSOS_PMODE			= 0x080,
+	GSOS_SMODE1			= 0x081,
+        GSOS_SMODE2                     = 0x082,    
+        GSOS_RFSH                       = 0x083,
+	GSOS_SYNCH1			= 0x084,
+	GSOS_SYNCH2			= 0x085,
+	GSOS_SYNCV			= 0x086,
+	GSOS_DISPFB1			= 0x087,
+	GSOS_DISPLAY1			= 0x088,
+	GSOS_DISPFB2			= 0x089,
+	GSOS_DISPLAY2			= 0x08a,
+	GSOS_EXTBUF			= 0x08b,
+	GSOS_EXTDATA			= 0x08c,
+	GSOS_EXTWRITE			= 0x08d,
+	GSOS_BGCOLOR			= 0x08e,
+
+	/*-- host I/F reg. (privilege port) --*/
+	GSOS_CSR			= 0x0c0,
+	GSOS_IMR			= 0x0c1,
+	GSOS_BUSDIR			= 0x0c4,
+	GSOS_SIGID			= 0x0c8,
+        GSOS_LABELID                    = 0x0c9,
+        GSOS_SYSCNT                     = 0x0cf,
+        /*-- pseudo register for simulation */
+        GSOS_SIMU_DISPLAY = 0x100, 
+        GSOS_SIMU_PCRTC   = 0x101 
+} ;
+
+ 
+/*****************************************************************
+ */
+
+#define GsM(l) (unsigned)( ((GSOSbit64)1 << (l)) - 1)
+#define GsLLong(d,s,m) (GSOSbit64)((GSOSbit64)((d)&GsM((m)))<<(s))
+#define GsLL2I(d,s,m) (unsigned)(((unsigned)((GSOSbit64)(d)>>(s)))&GsM((m)))
+
+/*****************************************************************
+ */
+
+#define GsosPrimData( prim, iip, tme, fge, abe, aa1, fst, ctxt, fix ) \
+    GsLLong((prim),0,3) | GsLLong((iip),3,1) | GsLLong((tme),4,1) | \
+    GsLLong((fge),5,3) | GsLLong((abe),6,1) | GsLLong((aa1),7,1) | \
+    GsLLong((fst),8,3) | GsLLong((ctxt),9,1) | GsLLong((fix),10,1)
+#define GsosPrimPrim( d ) (unsigned)(GsLL2I((d),0,3))
+#define GsosPrimIip( d ) (unsigned)(GsLL2I((d),3,1))
+#define GsosPrimTme( d ) (unsigned)(GsLL2I((d),4,1))
+#define GsosPrimFge( d ) (unsigned)(GsLL2I((d),5,1))
+#define GsosPrimAbe( d ) (unsigned)(GsLL2I((d),6,1))
+#define GsosPrimAa1( d ) (unsigned)(GsLL2I((d),7,1))
+#define GsosPrimFst( d ) (unsigned)(GsLL2I((d),8,1))
+#define GsosPrimCtxt( d ) (unsigned)(GsLL2I((d),9,1))
+#define GsosPrimFix( d ) (unsigned)(GsLL2I((d),10,1))
+
+#define GsosXyzfData( x, y, z, f ) \
+    GsLLong((x),0,16) | GsLLong((y),16,16) | \
+    GsLLong((z),32,24) | GsLLong((f),56,8)
+#define GsosXyzfX( d ) (unsigned)(GsLL2I((d),0,16))
+#define GsosXyzfY( d ) (unsigned)(GsLL2I((d),16,16))
+#define GsosXyzfZ( d ) (unsigned)(GsLL2I((d),32,24))
+#define GsosXyzfF( d ) (unsigned)(GsLL2I((d),56,8))
+
+#define GsosRgbaqData( r, g, b, a, q ) \
+    GsLLong((r),0,8) | GsLLong((g),8,8) | GsLLong((b),16,8) | \
+    GsLLong((a),24,8) | GsLLong((q),32,32)
+#define GsosRgbaqR( d ) (unsigned)(GsLL2I((d),0,8))
+#define GsosRgbaqG( d ) (unsigned)(GsLL2I((d),8,8))
+#define GsosRgbaqB( d ) (unsigned)(GsLL2I((d),16,8))
+#define GsosRgbaqA( d ) (unsigned)(GsLL2I((d),24,8))
+#define GsosRgbaqQ( d ) (unsigned)(GsLL2I((d),32,32))
+
+#define GsosStData( s, t ) \
+    GsLLong((s),0,32) | GsLLong((t),32,32)
+#define GsosStS( d ) (unsigned)(GsLL2I((d),0,32))
+#define GsosStT( d ) (unsigned)(GsLL2I((d),32,32))
+
+#define GsosUvData( u, v ) \
+    GsLLong((u),0,14) | GsLLong((v),16,14)
+#define GsosUvU( d ) (unsigned)(GsLL2I((d),0,14))
+#define GsosUvV( d ) (unsigned)(GsLL2I((d),16,14))
+
+#define GsosXyoffsetData( xoffset, yoffset ) \
+    GsLLong((xoffset),0,16) | GsLLong((yoffset),32,16) 
+#define GsosXyoffsetX( d ) (unsigned)(GsLL2I((d),0,16))
+#define GsosXyoffsetY( d ) (unsigned)(GsLL2I((d),32,16))
+
+#define GsosXyzData( x, y, z ) \
+    GsLLong((x),0,16) | GsLLong((y),16,16) | GsLLong((z),32,32)
+#define GsosXyzX( d ) (unsigned)(GsLL2I((d),0,16))
+#define GsosXyzY( d ) (unsigned)(GsLL2I((d),16,16))
+#define GsosXyzZ( d ) (unsigned)(GsLL2I((d),32,32))
+
+#define GsosPrmodecontData( ac ) GsLLong((ac),0,1) 
+#define GsosPrmodecontAc( d ) (unsigned)(GsLL2I(d,0,1))
+
+#define GsosPrmodeData( iip, tme, fge, abe, aa1, fst, ctxt, fix ) \
+    GsLLong((iip),3,1) | GsLLong((tme),4,1) | GsLLong((fge),5,1) | \
+    GsLLong((abe),6,1) | GsLLong((aa1),7,1) | GsLLong((fst),8,1) | \
+    GsLLong((ctxt),9,1) | GsLLong((fix),10,1)
+#define GsosPrmodeIip( d ) (unsigned)(GsLL2I(d,3,1))
+#define GsosPrmodeTme( d ) (unsigned)(GsLL2I(d,4,1))
+#define GsosPrmodeFge( d ) (unsigned)(GsLL2I(d,5,1))
+#define GsosPrmodeAbe( d ) (unsigned)(GsLL2I(d,6,1))
+#define GsosPrmodeAa1( d ) (unsigned)(GsLL2I(d,7,1))
+#define GsosPrmodeFst( d ) (unsigned)(GsLL2I(d,8,1))
+#define GsosPrmodeCtxt( d ) (unsigned)(GsLL2I(d,9,1))
+#define GsosPrmodeFix( d ) (unsigned)(GsLL2I(d,10,1))
+
+#define GsosScanmskData( msk ) GsLLong((msk),0,2) 
+#define GsosScanmskMsk( d ) (unsigned)(GsLL2I(d,0,2))
+
+#define GsosTex0Data( tbp0,tbw,psm,tw,th,tcc,tfx,cbp,cpsm,csm,csa,cld ) \
+    GsLLong((tbp0),0,14) | GsLLong((tbw),14,6) | GsLLong((psm),20,6) | \
+    GsLLong((tw),26,4) | GsLLong((th),30,4) | GsLLong((tcc),34,1) | \
+    GsLLong((tfx),35,2) | GsLLong((cbp),37,14) | GsLLong((cpsm),51,4) | \
+    GsLLong((csm),55,1) | GsLLong((csa),56,5) | GsLLong((cld),61,3) 
+#define GsosTex0Tbp0( d ) (unsigned)(GsLL2I(d,0,14))
+#define GsosTex0Tbw( d ) (unsigned)(GsLL2I(d,14,6))
+#define GsosTex0Psm( d ) (unsigned)(GsLL2I(d,20,6))
+#define GsosTex0Tw( d ) (unsigned)(GsLL2I(d,26,4))
+#define GsosTex0Th( d ) (unsigned)(GsLL2I(d,30,4))
+#define GsosTex0Tcc( d ) (unsigned)(GsLL2I(d,34,1))
+#define GsosTex0Tfx( d ) (unsigned)(GsLL2I(d,35,2))
+#define GsosTex0Cbp( d ) (unsigned)(GsLL2I(d,37,14))
+#define GsosTex0Cpsm( d ) (unsigned)(GsLL2I(d,51,4))
+#define GsosTex0Csm( d ) (unsigned)(GsLL2I(d,55,1))
+#define GsosTex0Csa( d ) (unsigned)(GsLL2I(d,56,5))
+#define GsosTex0Cld( d ) (unsigned)(GsLL2I(d,61,3))
+
+#define GsosTex1Data( lcm, mxl, mmag, mmin, mtba, l, k ) \
+    GsLLong((lcm),0,1) | GsLLong((mxl),2,3) | \
+    GsLLong((mmag),5,1) | GsLLong((mmin),6,3) | \
+    GsLLong((mtba),9,1) | GsLLong((l),19,2) | GsLLong( (k), 32, 12 ) 
+#define GsosTex1Lcm( d ) (unsigned)(GsLL2I(d,0,1))
+#define GsosTex1Mxl( d ) (unsigned)(GsLL2I(d,2,3))
+#define GsosTex1Mmag( d ) (unsigned)(GsLL2I(d,5,1))
+#define GsosTex1Mmin( d ) (unsigned)(GsLL2I(d,6,3))
+#define GsosTex1Mtba( d ) (unsigned)(GsLL2I(d,9,1))
+#define GsosTex1L( d ) (unsigned)(GsLL2I(d,19,2))
+#define GsosTex1K( d ) (unsigned)(GsLL2I(d,32,12))
+
+#define GsosTex2Data( psm, cbp, cpsm, csm, csa, cld ) \
+    GsLLong((psm),20,6) | GsLLong((cbp),37,14) | GsLLong((cpsm),51,4) | \
+    GsLLong((csm),55,1) | GsLLong((csa),56,5) | GsLLong((cld),61,3)
+#define GsosTex2Psm( d ) (unsigned)(GsLL2I(d,20,6))
+#define GsosTex2Cbp( d ) (unsigned)(GsLL2I(d,37,14))
+#define GsosTex2Cpsm( d ) (unsigned)(GsLL2I(d,51,4))
+#define GsosTex2Csm( d ) (unsigned)(GsLL2I(d,55,1))
+#define GsosTex2Csa( d ) (unsigned)(GsLL2I(d,56,5))
+#define GsosTex2Cld( d ) (unsigned)(GsLL2I(d,61,3))
+
+#define GsosTexclutData( cbw, cou, cov ) \
+    GsLLong((cbw),0,6) | GsLLong((cou),6,6) | GsLLong((cov),12,10)
+#define GsosTexclutCbw( d ) (unsigned)(GsLL2I(d,0,6))
+#define GsosTexclutCou( d ) (unsigned)(GsLL2I(d,6,6))
+#define GsosTexclutCov( d ) (unsigned)(GsLL2I(d,12,10))
+
+#define GsosMiptbp1Data( tbp1, tbw1, tbp2, tbw2, tbp3, tbw3 ) \
+    GsLLong((tbp1),0,14) | GsLLong((tbw1),14,6) | \
+    GsLLong((tbp2),20,14) | GsLLong((tbw2),34,6) | \
+    GsLLong((tbp3),40,14) | GsLLong((tbw3),54,6)
+#define GsosMiptbp1Tbp1( d ) (unsigned)(GsLL2I(d,0,14))
+#define GsosMiptbp1Tbw1( d ) (unsigned)(GsLL2I(d,14,6))
+#define GsosMiptbp1Tbp2( d ) (unsigned)(GsLL2I(d,20,14))
+#define GsosMiptbp1Tbw2( d ) (unsigned)(GsLL2I(d,34,6))
+#define GsosMiptbp1Tbp3( d ) (unsigned)(GsLL2I(d,40,14))
+#define GsosMiptbp1Tbw3( d ) (unsigned)(GsLL2I(d,54,6))
+
+#define GsosMiptbp2Data( tbp4, tbw4, tbp5, tbw5, tbp6, tbw6 ) \
+    GsLLong((tbp4),0,14) | GsLLong((tbw4),14,6) | \
+    GsLLong((tbp5),20,14) | GsLLong((tbw5),34,6) | \
+    GsLLong((tbp6),40,14) | GsLLong((tbw6),54,6)
+#define GsosMiptbp2Tbp4( d ) (unsigned)(GsLL2I(d,0,14))
+#define GsosMiptbp2Tbw4( d ) (unsigned)(GsLL2I(d,14,6))
+#define GsosMiptbp2Tbp5( d ) (unsigned)(GsLL2I(d,20,14))
+#define GsosMiptbp2Tbw5( d ) (unsigned)(GsLL2I(d,34,6))
+#define GsosMiptbp2Tbp6( d ) (unsigned)(GsLL2I(d,40,14))
+#define GsosMiptbp2Tbw6( d ) (unsigned)(GsLL2I(d,54,6))
+
+#define GsosTexaData( ta0, aem, ta1 ) \
+    GsLLong((ta0),0,8) | GsLLong((aem),15,1) | GsLLong((ta1),32,8) 
+#define GsosTexaTa0( d ) (unsigned)(GsLL2I(d,0,8))
+#define GsosTexaAem( d ) (unsigned)(GsLL2I(d,15,1))
+#define GsosTexaTa1( d ) (unsigned)(GsLL2I(d,32,8))
+
+#define GsosClampData( wms, wmt, minu, maxu, minv, maxv ) \
+    GsLLong((wms),0,2) | GsLLong((wmt),2,2) | GsLLong((minu),4,10) | \
+    GsLLong((maxu),14,10) | GsLLong((minv),24,10) | GsLLong((maxv),34,10)
+#define GsosClampWms( d ) (unsigned)(GsLL2I(d,0,2))
+#define GsosClampWmt( d ) (unsigned)(GsLL2I(d,2,2))
+#define GsosClampMinu( d ) (unsigned)(GsLL2I(d,4,10))
+#define GsosClampMaxu( d ) (unsigned)(GsLL2I(d,14,10))
+#define GsosClampMinv( d ) (unsigned)(GsLL2I(d,24,10))
+#define GsosClampMaxv( d ) (unsigned)(GsLL2I(d,34,10))
+#define GsosClampUmsk( d ) (unsigned)(GsLL2I(d,4,10))
+#define GsosClampUfix( d ) (unsigned)(GsLL2I(d,14,10))
+#define GsosClampVmsk( d ) (unsigned)(GsLL2I(d,24,10))
+#define GsosClampVfix( d ) (unsigned)(GsLL2I(d,34,10))
+
+#define GsosFogcolData( fcr, fcg, fcb ) \
+    GsLLong((fcr),0,8) | GsLLong((fcg),8,8) | GsLLong((fcb),16,8) 
+#define GsosFogcolFcr( d ) (unsigned)(GsLL2I(d,0,8))
+#define GsosFogcolFcg( d ) (unsigned)(GsLL2I(d,8,8))
+#define GsosFogcolFcb( d ) (unsigned)(GsLL2I(d,16,8))
+
+#define GsosScissorData( scax0, scax1, scay0, scay1 ) \
+    GsLLong((scax0),0,11) | GsLLong((scax1),16,11) | \
+    GsLLong((scay0),32,11) | GsLLong((scay1),48,11)
+#define GsosScissorScax0( d ) (unsigned)(GsLL2I(d,0,11))
+#define GsosScissorScax1( d ) (unsigned)(GsLL2I(d,16,11))
+#define GsosScissorScay0( d ) (unsigned)(GsLL2I(d,32,11))
+#define GsosScissorScay1( d ) (unsigned)(GsLL2I(d,48,11))
+
+#define GsosTestData( ate, atst, aref, afail, date, datm, zte, ztst ) \
+    GsLLong((ate),0,1) | GsLLong((atst),1,3) | GsLLong((aref),4,8) | \
+    GsLLong((afail),12,2) | GsLLong((date),14,1) | GsLLong((datm),15,1) | \
+    GsLLong((zte),16,1) | GsLLong((ztst),17,2)
+#define GsosTestAte( d ) (unsigned)(GsLL2I(d,0,1))
+#define GsosTestAtst( d ) (unsigned)(GsLL2I(d,1,3))
+#define GsosTestAref( d ) (unsigned)(GsLL2I(d,4,8))
+#define GsosTestAfail( d ) (unsigned)(GsLL2I(d,12,2))
+#define GsosTestDate( d ) (unsigned)(GsLL2I(d,14,1))
+#define GsosTestDatm( d ) (unsigned)(GsLL2I(d,15,1))
+#define GsosTestZte( d ) (unsigned)(GsLL2I(d,16,1))
+#define GsosTestZtst( d ) (unsigned)(GsLL2I(d,17,2))
+
+#define GsosAlphaData( a, b, c, d, fix ) \
+    GsLLong((a),0,2) | GsLLong((b),2,2) | GsLLong((c),4,2) | \
+    GsLLong((d),6,2) | GsLLong((fix),32,8)
+#define GsosAlphaA( d ) (unsigned)(GsLL2I(d,0,2))
+#define GsosAlphaB( d ) (unsigned)(GsLL2I(d,2,2))
+#define GsosAlphaC( d ) (unsigned)(GsLL2I(d,4,2))
+#define GsosAlphaD( d ) (unsigned)(GsLL2I(d,6,2))
+#define GsosAlphaFix( d ) (unsigned)(GsLL2I(d,32,8))
+
+#define GsosPabeData( pabe ) GsLLong((pabe),0,1)
+#define GsosPabePabe( d ) (unsigned)(GsLL2I(d,0,1))
+
+#define GsosDimxData( dimx00, dimx01, dimx02, dimx03, dimx10, dimx11, dimx12, dimx13, dimx20, dimx21, dimx22, dimx23, dimx30, dimx31, dimx32, dimx33 ) \
+    GsLLong((dimx00),0,3) | GsLLong((dimx01),4,3) | GsLLong((dimx02),8,3) | \
+    GsLLong((dimx03),12,3) | GsLLong((dimx10),16,3) | GsLLong((dimx11),20,3) | \
+    GsLLong((dimx12),24,3) | GsLLong((dimx13),28,3) | GsLLong((dimx20),32,3) | \
+    GsLLong((dimx21),36,3) | GsLLong((dimx22),40,3) | GsLLong((dimx23),44,3) | \
+    GsLLong((dimx30),48,3) | GsLLong((dimx31),52,3) | GsLLong((dimx32),56,3) | \
+    GsLLong((dimx33),60,3) 
+#define GsosDimxDimx00( d ) (unsigned)(GsLL2I(d,0,3))
+#define GsosDimxDimx01( d ) (unsigned)(GsLL2I(d,4,3))
+#define GsosDimxDimx02( d ) (unsigned)(GsLL2I(d,8,3))
+#define GsosDimxDimx03( d ) (unsigned)(GsLL2I(d,12,3))
+#define GsosDimxDimx10( d ) (unsigned)(GsLL2I(d,16,3))
+#define GsosDimxDimx11( d ) (unsigned)(GsLL2I(d,20,3))
+#define GsosDimxDimx12( d ) (unsigned)(GsLL2I(d,24,3))
+#define GsosDimxDimx13( d ) (unsigned)(GsLL2I(d,28,3))
+#define GsosDimxDimx20( d ) (unsigned)(GsLL2I(d,32,3))
+#define GsosDimxDimx21( d ) (unsigned)(GsLL2I(d,36,3))
+#define GsosDimxDimx22( d ) (unsigned)(GsLL2I(d,40,3))
+#define GsosDimxDimx23( d ) (unsigned)(GsLL2I(d,44,3))
+#define GsosDimxDimx30( d ) (unsigned)(GsLL2I(d,48,3))
+#define GsosDimxDimx31( d ) (unsigned)(GsLL2I(d,52,3))
+#define GsosDimxDimx32( d ) (unsigned)(GsLL2I(d,56,3))
+#define GsosDimxDimx33( d ) (unsigned)(GsLL2I(d,60,3))
+
+#define GsosDtheData( dthe ) GsLLong((dthe),0,1)
+#define GsosDtheDthe( d ) (unsigned)(GsLL2I(d,0,1))
+
+#define GsosColclampData( clamp ) GsLLong((clamp),0,1)
+#define GsosColclampClamp( d ) (unsigned)(GsLL2I(d,0,1))
+
+#define GsosFbaData( fba ) GsLLong((fba),0,1) ;
+#define GsosFbaFba( d ) (unsigned)(GsLL2I(d,0,1))
+
+#define GsosFrameData( fbp, fbw, psm, fbmsk ) \
+    GsLLong((fbp),0,9) | GsLLong((fbw),16,6) | \
+    GsLLong((psm),24,6) | GsLLong((fbmsk),32,32) 
+#define GsosFrameFbp( d ) (unsigned)(GsLL2I(d,0,9))
+#define GsosFrameFbw( d ) (unsigned)(GsLL2I(d,16,6))
+#define GsosFramePsm( d ) (unsigned)(GsLL2I(d,24,6))
+#define GsosFrameFbmsk( d ) (unsigned)(GsLL2I(d,32,32))
+
+#define GsosZbufData( zbp, psm, zmsk ) \
+    GsLLong((zbp),0,8) | GsLLong((psm),24,4) | GsLLong((zmsk),32,1) 
+#define GsosZbufZbp( d ) (unsigned)(GsLL2I(d,0,8))
+#define GsosZbufPsm( d ) (unsigned)(GsLL2I(d,24,4))
+#define GsosZbufZmsk( d ) (unsigned)(GsLL2I(d,32,1))
+
+#define GsosBitbltbufData( sbp, sbw, spsm, dbp, dbw, dpsm ) \
+    GsLLong((sbp),0,14) | GsLLong((sbw),16,6) | GsLLong((spsm),24,6) | \
+    GsLLong((dbp),32,14) | GsLLong((dbw),48,6) | GsLLong((dpsm),56,6)
+#define GsosBitbltbufSbp( d ) (unsigned)(GsLL2I(d,0,14))
+#define GsosBitbltbufSbw( d ) (unsigned)(GsLL2I(d,16,6))
+#define GsosBitbltbufSpsm( d ) (unsigned)(GsLL2I(d,24,6))
+#define GsosBitbltbufDbp( d ) (unsigned)(GsLL2I(d,32,14))
+#define GsosBitbltbufDbw( d ) (unsigned)(GsLL2I(d,48,6))
+#define GsosBitbltbufDpsm( d ) (unsigned)(GsLL2I(d,56,6))
+
+#define GsosTrxposData( ssax, ssay, dsax, dsay, dir ) \
+    GsLLong((ssax),0,11) | GsLLong((ssay),16,11) | \
+    GsLLong((dsax),32,11) | GsLLong((dsay),48,11) | GsLLong((dir),59,2)
+#define GsosTrxposSsax( d ) (unsigned)(GsLL2I(d,0,11))
+#define GsosTrxposSsay( d ) (unsigned)(GsLL2I(d,16,11))
+#define GsosTrxposDsax( d ) (unsigned)(GsLL2I(d,32,11))
+#define GsosTrxposDsay( d ) (unsigned)(GsLL2I(d,48,11))
+#define GsosTrxposDir( d ) (unsigned)(GsLL2I(d,59,2))
+
+#define GsosTrxregData( rrw, rrh ) \
+    GsLLong((rrw),0,12) | GsLLong((rrh),32,12)
+#define GsosTrxregRrw( d ) (unsigned)(GsLL2I(d,0,12))
+#define GsosTrxregRrh( d ) (unsigned)(GsLL2I(d,32,12))
+
+#define GsosTrxdirData( xdir ) GsLLong((xdir),0,2)
+#define GsosTrxdirXdir( d ) (unsigned)(GsLL2I(d,0,2))
+
+#define GsosPmodeData( en1, en2, crtmd, mmod, amod, slbg, alp, nfld, exvwins, exvwine, exsyncmd ) \
+    GsLLong((en1),0,1) | GsLLong((en2),1,1) | GsLLong((crtmd),2,3) | \
+    GsLLong((mmod),5,1) | GsLLong((amod),6,1) | GsLLong((slbg),7,1) | \
+    GsLLong((alp),8,8) | GsLLong((nfld),16,1) | GsLLong((exvwins),32,10) | \
+    GsLLong((exvwine),42,10) | GsLLong((exsyncmd),52,1)
+#define GsosPmodeEn1( d ) (unsigned)(GsLL2I(d,0,1))
+#define GsosPmodeEn2( d ) (unsigned)(GsLL2I(d,1,1))
+#define GsosPmodeCrtmd( d ) (unsigned)(GsLL2I(d,2,3))
+#define GsosPmodeMmod( d ) (unsigned)(GsLL2I(d,5,1))
+#define GsosPmodeAmod( d ) (unsigned)(GsLL2I(d,6,1))
+#define GsosPmodeSlbg( d ) (unsigned)(GsLL2I(d,7,1))
+#define GsosPmodeAlp( d ) (unsigned)(GsLL2I(d,8,8))
+#define GsosPmodeNfld( d ) (unsigned)(GsLL2I(d,16,1))
+#define GsosPmodeExvwins( d ) (unsigned)(GsLL2I(d,32,10))
+#define GsosPmodeExvwine( d ) (unsigned)(GsLL2I(d,42,10))
+#define GsosPmodeExsyncmd( d ) (unsigned)(GsLL2I(d,52,1))
+
+#define GsosSmode1Data( rc, lc, t1248, slck, cmod, ex, vhp, prst, sint, xpck, pck2, spml, gcont, phs, pvs, pehs, pevs ) \
+    GsLLong((rc),0,3) | GsLLong((lc),3,7) | GsLLong((t1248),10,2) | \
+    GsLLong((slck),12,1) | GsLLong((cmod),13,2) | GsLLong((ex),15,1) | \
+    GsLLong((vhp),16,1) | GsLLong((prst),17,1) | GsLLong((sint),18,1) | \
+    GsLLong((xpck),19,1) | GsLLong((pck2),20,2) | GsLLong((spml),22,4) | \
+    GsLLong((gcont),26,1) | GsLLong((phs),27,1) | GsLLong((pvs),28,1) | \
+    GsLLong((pehs),29,1) | GsLLong((pevs),30,1)
+#define GsosSmode1Rc( d ) (unsigned)(GsLL2I(d,0,3))
+#define GsosSmode1Lc( d ) (unsigned)(GsLL2I(d,3,7))
+#define GsosSmode1T1248( d ) (unsigned)(GsLL2I(d,10,2))
+#define GsosSmode1Slck( d ) (unsigned)(GsLL2I(d,12,1))
+#define GsosSmode1Cmod( d ) (unsigned)(GsLL2I(d,13,2))
+#define GsosSmode1Ex( d ) (unsigned)(GsLL2I(d,15,1))
+#define GsosSmode1Vhp( d ) (unsigned)(GsLL2I(d,16,1))
+#define GsosSmode1Prst( d ) (unsigned)(GsLL2I(d,17,1))
+#define GsosSmode1Sint( d ) (unsigned)(GsLL2I(d,18,1))
+#define GsosSmode1Xpck( d ) (unsigned)(GsLL2I(d,19,1))
+#define GsosSmode1Pck2( d ) (unsigned)(GsLL2I(d,20,2))
+#define GsosSmode1Spml( d ) (unsigned)(GsLL2I(d,22,4))
+#define GsosSmode1Gcont( d ) (unsigned)(GsLL2I(d,26,1))
+#define GsosSmode1Phs( d ) (unsigned)(GsLL2I(d,27,1))
+#define GsosSmode1Pvs( d ) (unsigned)(GsLL2I(d,28,1))
+#define GsosSmode1Pehs( d ) (unsigned)(GsLL2I(d,29,1))
+#define GsosSmode1Pevs( d ) (unsigned)(GsLL2I(d,30,1))
+
+#define GsosSmode2Data( iint, ffmd, dpms ) \
+    GsLLong((iint),0,1) | GsLLong((ffmd),1,1) | GsLLong((dpms),2,2)
+#define GsosSmode2Int( d ) (unsigned)(GsLL2I(d,0,1))
+#define GsosSmode2Ffmd( d ) (unsigned)(GsLL2I(d,1,1))
+#define GsosSmode2Dpms( d ) (unsigned)(GsLL2I(d,2,2))
+
+#define GsosSrfshData( rfsh ) GsLLong((xdir),0,5)
+#define GsosSrfshRfsh( d ) (unsigned)(GsLL2I(d,0,5))
+
+#define GsosSynch1Data( hfp, hbp, hseq, hsvs, hs ) \
+    GsLLong((hfp),0,11) | GsLLong((hbp),11,11) | GsLLong((hseq),22,10) | \
+    GsLLong((hsvs),32,11) | GsLLong((hs),43,10)
+#define GsosSynch1Hfp( d ) (unsigned)(GsLL2I(d,0,11))
+#define GsosSynch1Hbp( d ) (unsigned)(GsLL2I(d,11,11))
+#define GsosSynch1Hseq( d ) (unsigned)(GsLL2I(d,22,10))
+#define GsosSynch1Hsvs( d ) (unsigned)(GsLL2I(d,32,11))
+#define GsosSynch1Hs( d ) (unsigned)(GsLL2I(d,42,10))
+
+#define GsosSynch2Data( hf, hb ) \
+    GsLLong((hf),0,11) | GsLLong((hb),11,11)
+#define GsosSynch2Hf( d ) (unsigned)(GsLL2I(d,0,11))
+#define GsosSynch2Hb( d ) (unsigned)(GsLL2I(d,11,11))
+
+#define GsosSyncvData( vfp, vfpe, vbp, vbpe, vdp, vs ) \
+    GsLLong((vfp),0,10) | GsLLong((vfpe),10,10) | GsLLong((vbp),20,10) | \
+    GsLLong((vbpe),32,10) | GsLLong((vdp),42,10) | GsLLong((vs),52,10)
+#define GsosSyncvVfp( d ) (unsigned)(GsLL2I(d,0,10))
+#define GsosSyncvVfpe( d ) (unsigned)(GsLL2I(d,10,10))
+#define GsosSyncvVbp( d ) (unsigned)(GsLL2I(d,20,10))
+#define GsosSyncvVbpe( d ) (unsigned)(GsLL2I(d,32,10))
+#define GsosSyncvVdp( d ) (unsigned)(GsLL2I(d,42,10))
+#define GsosSyncvVs( d ) (unsigned)(GsLL2I(d,52,10))
+
+#define GsosDispfbData( fbp, fbw, psm, dbx, dby ) \
+    GsLLong((fbp),0,9) | GsLLong((fbw),9,6) | GsLLong((psm),15,5) | \
+    GsLLong((dbx),32,11) | GsLLong((dby),43,11)
+#define GsosDispfbFbp( d ) (unsigned)(GsLL2I(d,0,9))
+#define GsosDispfbFbw( d ) (unsigned)(GsLL2I(d,9,6))
+#define GsosDispfbPsm( d ) (unsigned)(GsLL2I(d,15,6))
+#define GsosDispfbDbx( d ) (unsigned)(GsLL2I(d,32,11))
+#define GsosDispfbDby( d ) (unsigned)(GsLL2I(d,43,11))
+
+#define GsosDisplayData( dx, dy, magh, magv, dw, dh ) \
+    GsLLong((dx),0,12) | GsLLong((dy),12,11) | GsLLong((magh),23,4) | \
+    GsLLong((magv),27,2) | GsLLong((dw),32,12) | GsLLong((dh),44,11)
+#define GsosDisplayDx( d ) (unsigned)(GsLL2I(d,0,12))
+#define GsosDisplayDy( d ) (unsigned)(GsLL2I(d,12,11))
+#define GsosDisplayMagh( d ) (unsigned)(GsLL2I(d,23,4))
+#define GsosDisplayMagv( d ) (unsigned)(GsLL2I(d,27,2))
+#define GsosDisplayDw( d ) (unsigned)(GsLL2I(d,32,12))
+#define GsosDisplayDh( d ) (unsigned)(GsLL2I(d,44,11))
+
+#define GsosExtbufData( exbp, exbw, fbin, wffmd, emoda, emodc, wdx, wdy ) \
+    GsLLong((exbp),0,14) | GsLLong((exbw),14,6) | GsLLong((fbin),20,2) | \
+    GsLLong((wffmd),22,1) | GsLLong((emoda),23,2) | GsLLong((emodc),25,2) | \
+    GsLLong((magv),32,11) | GsLLong((dh),43,11)
+#define GsosExtbufExbp( d ) (unsigned)(GsLL2I(d,0,14))
+#define GsosExtbufExbw( d ) (unsigned)(GsLL2I(d,14,6))
+#define GsosExtbufFbin( d ) (unsigned)(GsLL2I(d,20,2))
+#define GsosExtbufWffmd( d ) (unsigned)(GsLL2I(d,22,1))
+#define GsosExtbufEmoda( d ) (unsigned)(GsLL2I(d,23,2))
+#define GsosExtbufEmodc( d ) (unsigned)(GsLL2I(d,25,2))
+#define GsosExtbufWdx( d ) (unsigned)(GsLL2I(d,32,11))
+#define GsosExtbufWdy( d ) (unsigned)(GsLL2I(d,43,11))
+
+#define GsosExtdataData( sx, dy, smph, smpv, ww, wh ) \
+    GsLLong((sx),0,12) | GsLLong((sy),12,11) | GsLLong((smph),23,4) | \
+    GsLLong((smpw),27,2) | GsLLong((ww),32,12) | GsLLong((wh),44,11)
+#define GsosExtdataSx( d ) (unsigned)(GsLL2I(d,0,12))
+#define GsosExtdataSy( d ) (unsigned)(GsLL2I(d,12,11))
+#define GsosExtdataSmph( d ) (unsigned)(GsLL2I(d,23,4))
+#define GsosExtdataSmpv( d ) (unsigned)(GsLL2I(d,27,2))
+#define GsosExtdataWw( d ) (unsigned)(GsLL2I(d,32,12))
+#define GsosExtdataWh( d ) (unsigned)(GsLL2I(d,44,11))
+
+#define GsosExtwriteData( rfsh ) GsLLong((write),0,1)
+#define GsosExtwriteWrite( d ) (unsigned)(GsLL2I(d,0,1))
+
+#define GsosBgcolorData( r, g, b ) \
+    GsLLong((r),0,8) | GsLLong((g),8,8) | GsLLong((b),16,8)
+#define GsosBgcolorR( d ) (unsigned)(GsLL2I(d,0,8))
+#define GsosBgcolorG( d ) (unsigned)(GsLL2I(d,8,8))
+#define GsosBgcolorB( d ) (unsigned)(GsLL2I(d,16,8))
+
+/*****************************************************************
+ *  utilities
+ *****************************************************************
+ */
+#define GSOS_XYOFFSET    1024
+#define GSOS_SUBPIX_OFST(x) (((GSOSbit64)(x) + GSOS_XYOFFSET)<<4)
+#define GSOS_SUBTEX_OFST(x) (((GSOSbit64)(x)<<4)+0x8)
+
+#endif
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsos/gsostypes.h XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsostypes.h
--- XFree86/xc/programs/Xserver/hw/gsx/gsos/gsostypes.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsos/gsostypes.h	Mon Mar 12 18:46:47 2001
@@ -0,0 +1,60 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#ifndef GSOSTYPES_H
+#define GSOSTYPES_H
+
+typedef int                GSOSint ;
+typedef unsigned int       GSOSuint ;
+typedef short              GSOSshort ;
+typedef unsigned short     GSOSushort ;
+typedef char               GSOSchar ;
+typedef unsigned char      GSOSuchar ;
+typedef long               GSOSlong ;
+typedef unsigned long      GSOSulong ;
+typedef float              GSOSfloat ;
+typedef double             GSOSdouble ;
+typedef unsigned long long GSOSbit64 ;
+typedef unsigned int 	   GSOSbit128 __attribute__((mode(TI)));
+
+
+typedef union {
+    GSOSbit64 ul64[2];
+    GSOSuint  ui32[4];
+} GSOSpacket ;
+
+typedef union {
+	struct { unsigned short 
+		lo_lo0, lo_lo1, lo_hi0, lo_hi1,
+		hi_lo0, hi_lo1, hi_hi0, hi_hi1; } hi;
+	struct { unsigned int lo0, lo1, hi0, hi1; } si;
+	struct { GSOSbit64 lo, hi; } di;
+	GSOSbit128 ti;
+} GSOSQword;
+
+#endif /* GSOSTYPES_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsx.h XFree86.current/xc/programs/Xserver/hw/gsx/gsx.h
--- XFree86/xc/programs/Xserver/hw/gsx/gsx.h	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsx.h	Wed Mar 14 21:17:24 2001
@@ -0,0 +1,296 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#ifndef GSX_H
+#define GSX_H
+
+#include "scrnintstr.h"
+
+/*
+** optimize switchs
+*/
+#define GSX_BLOCK_FLUSH FALSE   /* flush in block handler */
+#define GSX_HATCH1_FILL FALSE   /* use hatch when small pattern */
+
+/* for debug */
+#define _GSXFlush()    gsosFlush()
+
+/*
+** constant
+*/
+#define GSX_ENABLE        1
+#define GSX_DISABLE       0
+#define GSX_FBA_VALUE0    0
+#define GSX_FBA_VALUE1    1
+#define GSX_COLMASK_ALL   0
+#define GSX_COLMASK_ASHUT 1
+#define GSX_COLMASK_AONLY 2
+
+#define GSX_FRAME_BASE    (0x0 / 64)
+#define GSX_ZBUF_BASE     0x0	/* unused */
+#define GSX_TEX0_BASE     0x0	/* unused */
+
+#define GSX_HATCH_MAX_WIDTH  1024
+#define GSX_HATCH_MAX_HEIGHT 1024
+
+/*
+ * GSX LOCAL
+ */
+#include "X.h"
+#include "Xproto.h"
+#include "gcstruct.h"
+#include "dixfontstr.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+
+#include "gsos.h"
+
+typedef int GSXint ;
+typedef unsigned int GSXuint ;
+typedef short GSXshort ;
+typedef unsigned short GSXushort ;
+typedef char GSXchar ;
+typedef unsigned char GSXuchar ;
+typedef long GSXlong ;
+typedef unsigned long GSXulong ;
+typedef float GSXfloat ;
+typedef double GSXdouble ;
+typedef int GSXWindowID ;
+
+typedef struct {
+    unsigned short  width, height;  /* screen size */
+    Pixel blackPixel;
+    Pixel whitePixel;
+    VisualID *pVisualIDs;
+    int framerate;
+    int depth;			/* hw depth */
+    int mode;
+    int res;
+    int interlace;
+    int alpha;
+    int dx,dy;
+} gsxScreenPrivate, *gsxScreenPtr;
+
+#define gsxGetScreenPriv(s) \
+    ((gsxScreenPtr)(s)->devPrivates[gsxScreenIndex].ptr)
+
+
+/* private field of window */
+typedef struct {
+    unsigned    char fastBorder; /* non-zero if border is 32 bits wide */
+    unsigned    char fastBackground;
+    unsigned short unused; /* pad for alignment with Sun compiler */
+    DDXPointRec oldRotate;
+    PixmapPtr   pRotatedBackground;
+    PixmapPtr   pRotatedBorder;
+
+    Bool  allowBS; /* allow backing store */
+} gsxWindowPrivate, *gsxWindowPtr;
+
+#define gsxGetWindowPriv(w) \
+    ((gsxWindowPtr)(w)->devPrivates[gsxWindowIndex].ptr)
+
+typedef struct {
+    unsigned char       rop;            /* special case rop values */
+    /* next two values unused in cfb, included for compatibility with mfb */
+    unsigned char       ropOpStip;      /* rop for opaque stipple */
+    /* this value is ropFillArea in mfb, usurped for cfb */
+    unsigned char       oneRect;    /*  drawable has one clip rect */
+    unsigned        fExpose:1;  /* callexposure handling ? */
+    unsigned        freeCompClip:1;
+    PixmapPtr       pRotatedPixmap;
+    RegionPtr       pCompositeClip; /* FREE_CC or REPLACE_CC */
+    unsigned long   xor, and;   /* reduced rop values */
+
+    /* gsx privates */
+    GSXuint     pixelMask;  /* buffer available bits */
+    GCFuncs     *funcs;
+    GCOps       *mops;      /* ops for pixmap */
+    GCOps       *wops;      /* ops for window */
+    GCOps       ops;        /* private ops buffer */
+    Mask        changes;    /* changes while DRAWABLE_PIXMAP */
+
+    unsigned short  patW, patH; /* size of tile or stipple */
+    unsigned short  patX, patY; /* 0 <= patX(patY) < patW(patH) */
+
+    char        fillStyle;
+    char        lineStyle;
+
+    /* copy of each register */
+    GSOSbit64   xyoffset_1 ;
+    GSOSbit64   frame_1 ;   /* copy of register FRAME_1 */
+    GSOSbit64   zbuf_1 ;
+    GSOSbit64   prmodecont ;
+    GSOSbit64   tex0_1 ;    /* copy of register TEX0_1 */
+    GSOSbit64   tex1_1 ;
+    GSOSbit64   tex2_1 ;
+    GSOSbit64   clamp_1 ;
+    GSOSbit64   miptbp1_1 ;
+    GSOSbit64   miptbp2_1 ;
+    GSOSbit64   scissor_1 ;
+    GSOSbit64   alpha_1 ;
+    GSOSbit64   test_1 ;
+    GSOSbit64   fba_1 ;
+    GSOSbit64   prmode ;
+    GSOSbit64   texclut ;
+    GSOSbit64   texa ;
+    GSOSbit64   dimx ;
+    GSOSbit64   dthe ;
+    GSOSbit64   colclamp ;
+    GSOSbit64   pabe ;
+
+} gsxGCPrivate, *gsxGCPtr;
+
+#define gsxGetGCPriv(gc) \
+    ((gsxGCPtr)(gc)->devPrivates[gsxGCIndex].ptr)
+
+#define GSXCHANGEGC( g, m, v )  \
+    { \
+        XID val = (v) ; \
+        DoChangeGC( (g), (m), &(val), 0 ) ; \
+    }
+
+#define GSXVALIDATEGC( d, g )  ValidateGC( (d), (g) )
+
+
+/*
+ * gsx private index
+ */
+extern int gsxScreenIndex;
+extern int gsxGCIndex;
+extern int gsxWindowIndex;
+
+
+/*
+ * gsx screen functions
+ */
+extern Bool gsxCloseScreen();
+extern void gsxQueryBestSize();
+extern void gsxCrossScreen();
+extern Bool gsxSaveScreen();
+extern void gsxGetImage();
+extern void gsxGetSpans();
+extern Bool gsxCreateWindow();
+extern Bool gsxDestroyWindow();
+extern Bool gsxPositionWindow();
+extern Bool gsxChangeWindowAttributes();
+extern Bool gsxMapWindow();
+extern Bool gsxUnmapWindow();
+extern void gsxPaintWindow();
+extern void gsxCopyWindow();
+extern Bool gsxCreateGC();
+
+
+/*
+ * GC functions
+ */
+extern void gsxValidateGC();
+extern void gsxChangeGC();
+extern void gsxCopyGC();
+extern void gsxDestroyGC();
+extern void gsxChangeClip();
+extern void gsxDestroyClip();
+extern void gsxCopyClip();
+
+/*
+ * GC ops
+ */
+extern RegionPtr gsxCopyAreaLop() ;
+extern RegionPtr gsxCopyAreaGxcpy() ;
+extern RegionPtr gsxCopyAreaGxcpyPm() ;
+extern RegionPtr gsxCopyPlaneLop() ;
+extern RegionPtr gsxCopyPlaneGxcpy() ;
+extern RegionPtr gsxCopyPlaneGxcpyPm() ;
+extern void gsxDoBitBlt() ;
+extern void gsxPolyPointSoft() ;
+extern void gsxPolyPointGxcpy() ;
+extern void gsxPolyLinesSoft() ;
+extern void gsxPolyLinesGxcpy() ;
+extern void gsxPolySegmentSoft() ;
+extern void gsxPolySegmentGxcpy() ;
+extern void gsxPolyRectangleSoft() ;
+extern void gsxPolyArcSoft() ;
+extern void gsxFillPolygonSoft() ;
+extern void gsxPolyFillRectSoft() ;
+extern void gsxPolyFillRectGxcpy() ;
+extern void gsxPolyFillArcSoft() ;
+extern void gsxImageText8Cached() ;
+extern GSXint gsxPolyText8Cached() ;
+extern void gsxFillSpansSoft() ;
+extern void gsxFillSpansGxcpy() ;
+extern void gsxSetSpansSoft() ;
+extern void gsxSetSpansGxcpy() ;
+extern void gsxGetSpans() ;
+extern void gsxImageGlyphBltSoft();
+extern void gsxImageGlyphBltGxcpy();
+extern void gsxPolyGlyphBltSoft();
+extern void gsxPushPixelsSoft();
+extern void gsxPutImage();
+extern void gsxPolyRectangleGxcpy() ;
+
+/*
+ * gsx functions
+ */
+extern Bool gsxScreenInit();
+extern Bool gsxSetupScreen();
+extern Bool gsxFinishScreenInit();
+extern int gsxCreateVisuals();
+extern Bool gsxCreateDefColormap();
+extern VisualPtr gsxGetVisual();
+
+extern void gsxCalcDrawRegion( DDXPointPtr pPoint, int n, int mode, xRectangle *pRect ) ;
+extern void gsxCalcDrawRegionSeg( xSegment *pSegments, int n, xRectangle *pRect ) ;
+extern void gsxCalcDrawRegionSpan( DDXPointPtr pPoints, int *pWidths, int n, xRectangle *pRect ) ;
+extern void gsxCalcDrawRegionRect( xRectangle *pSrcRect, int n, xRectangle *pRect ) ;
+extern void gsxCalcDrawRegionArc( xArc *pArc, int n, xRectangle *pRect ) ;
+extern void gsxSetColormask( GCPtr pGC, unsigned int mask ) ;
+extern void gsxSetFBA( GCPtr pGC, unsigned int mask ) ;
+extern int gsxIsPlanemask( GCPtr pGC ) ;
+extern void gsxSetTexfunc( gsxGCPtr pPriv, int tfunc ) ;
+extern void gsxGetRgbaWithBitsPerPixel( int bitsPerPixel, unsigned int rgb, int *r, int *g, int *b, int *a ) ;
+extern void gsxGetRgba( GCPtr pGC, unsigned int rgb, int *r, int *g, int *b, int *a ) ;
+extern void gsxFlushGC( gsxGCPtr pPriv ) ;
+extern void gsxCacheInvalid( void ) ;
+extern int gsxGetPsmFromBpp( int bpp ) ;
+extern void gsxPixmapToFill( GCPtr pGC ) ;
+extern int gsxBytePerPixel(int bpp);
+extern void gsxFrameInit(int screenWidth, int depth);
+
+/* Logical Operation functions */
+extern void gsxPreLop( GCPtr pGC, DrawablePtr pDraw, xRectangle *pRect, PixmapPtr dstLop ) ;
+extern void gsxPostLopCopy( GCPtr pGC, DrawablePtr pDraw, xRectangle *pRect, PixmapPtr dstLop, DrawablePtr pSrc, int srcx, int srcy, RegionPtr pRegionDst ) ;
+
+/* ReadImage & WriteImage wrapper */
+extern int gsxReadImage(int x, int y, int w, int h, unsigned int bp, int bw, int psm,PixmapPtr pPix);
+extern int gsxWriteImage(int x, int y, int w, int h, unsigned int bp, int bw, int psm, PixmapPtr pPix);
+
+/* Debug */
+extern void gsxPixmapDump(PixmapPtr pPix, int image);
+extern void gsxImageDump(void *p, int w, int h, int bsz, int image);
+
+#endif /* GSX_H */
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxbstore.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxbstore.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxbstore.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxbstore.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,42 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+#include "mibstore.h"
+
+extern void gsxSaveAreas(), gsxRestoreAreas();
+
+miBSFuncRec gsxBSFuncs = {
+    gsxSaveAreas,      // in gsxcpyarea.c
+    gsxRestoreAreas,   // in gsxcpyarea.c
+    (void (*)()) NULL,
+    (PixmapPtr (*)()) NULL,
+    (PixmapPtr (*)()) NULL
+};
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxcmap.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxcmap.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxcmap.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxcmap.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,227 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+
+typedef struct {
+    char *name;
+    char class;
+    char depth;
+    char type;
+} gsxVisualType;
+
+#define GSX_NUM_VISUAL 1
+static gsxVisualType gsxVisualTypes15[] = {
+{"TrueColor16", TrueColor,  16,TrueColor},
+};
+
+static gsxVisualType gsxVisualTypes24[] = {
+{"TrueColor24", TrueColor,  24,TrueColor},
+};
+
+static int gsxGetVisualTypes(gsxVisualType **pVisualtypes, int depth)
+{
+    int i;
+    int nvisual;
+    gsxVisualType *vtp;
+
+    if(depth == 15 || depth == 16) {
+      nvisual = (sizeof(gsxVisualTypes15)/sizeof(gsxVisualType));
+      vtp = gsxVisualTypes15;
+    } else {
+      nvisual = (sizeof(gsxVisualTypes24)/sizeof(gsxVisualType));
+      vtp = gsxVisualTypes24;
+    }
+    for (i = 0; i < nvisual; ++i)
+        pVisualtypes[i] = &vtp[i];
+    return i;
+}
+
+
+int gsxCreateVisuals( ScreenPtr pScreen,
+       VisualPtr *ppVisuals, int *pnVisuals,
+       DepthPtr  *ppDepths,  int *pnDepths )
+{
+    int i,j;
+    int r,g,b,d;
+    int nVisuals;
+    int nDepths;
+    unsigned int haveDepth;
+    gsxVisualType *vtypes[GSX_NUM_VISUAL];
+    VisualPtr pVisuals;
+    DepthPtr  pDepths;
+    VisualID  *pVisualIDs;
+
+    nVisuals = gsxGetVisualTypes(vtypes, gsxGetScreenPriv(pScreen)->depth);
+    *pnVisuals = nVisuals;
+
+    haveDepth = 1;
+    for (i = 0; i < nVisuals; ++i)
+        haveDepth |= 1<<(vtypes[i]->depth-1);
+    
+    nDepths = 0;
+    for (i = 0; i < 32; ++i)
+        if (haveDepth & (1<<i)) nDepths++;
+    *pnDepths = nDepths;
+
+    // allocation 
+    d = sizeof(VisualID)  * nVisuals
+      + sizeof(VisualRec) * nVisuals
+      + sizeof(DepthRec)  * nDepths ;
+    pVisualIDs = (VisualID *)xalloc(sizeof(VisualID)  * nVisuals +
+                                    sizeof(VisualRec) * nVisuals +
+                                    sizeof(DepthRec)  * nDepths );
+
+    if (!pVisualIDs) return 0;
+    gsxGetScreenPriv(pScreen)->pVisualIDs = pVisualIDs;
+    *ppVisuals = (VisualRec *)(pVisualIDs + nVisuals);
+    *ppDepths  = (DepthRec  *)(*ppVisuals + nVisuals);
+
+    // setting for depth
+    pDepths = *ppDepths;
+    pVisuals = *ppVisuals;
+    for (i = 31; i > 1; --i)
+        if (haveDepth & 1<<i) {
+            pDepths->depth = i+1;
+            pDepths->numVids = 0;
+            pDepths->vids = pVisualIDs;
+            for (j = 0; j < nVisuals; ++j)
+                if (vtypes[j]->depth == pDepths->depth) {
+                    pVisuals[j].vid = *pVisualIDs++ = FakeClientID(0);
+                    ++pDepths->numVids;
+                }
+            ++pDepths;
+        }
+    // i = 1
+    pDepths->depth = 1;
+    pDepths->numVids = 0;
+    pDepths->vids = NULL;
+    
+    // setting for visual
+    for (i = 0; i < nVisuals; ++i, ++pVisuals) {
+        pVisuals->class = vtypes[i]->class;
+        pVisuals->nplanes = vtypes[i]->depth;
+        pVisuals->bitsPerRGBValue = 8;
+        pVisuals->ColormapEntries = 256;
+
+        switch (pVisuals->class) {
+        case DirectColor:
+        case TrueColor:
+        case StaticColor:
+            d = pVisuals->nplanes;
+            r = (d + 2) / 3;
+            g = (d - r + 1) / 2;
+            b = d - r - g;
+            if (pVisuals->nplanes == 15 || pVisuals->nplanes == 16) {
+	      pVisuals->bitsPerRGBValue = 5;
+	      pVisuals->ColormapEntries = 32;
+	      if(r > 5) r = 5;
+	      pVisuals->redMask = (1<<r)-1;
+	      pVisuals->greenMask = ((1<<g)-1)<<r;
+	      pVisuals->blueMask = ((1<<b)-1)<<(r+g);
+	      pVisuals->offsetRed = 0;
+	      pVisuals->offsetGreen = r;
+	      pVisuals->offsetBlue = r+g;
+            } else {		/* pVisuals->nplanes == 32 */
+	      pVisuals->redMask = (1<<r)-1;
+	      pVisuals->greenMask = ((1<<g)-1)<<r;
+	      pVisuals->blueMask = ((1<<b)-1)<<(r+g);
+	      pVisuals->offsetRed = 0;
+	      pVisuals->offsetGreen = r;
+	      pVisuals->offsetBlue = r+g;
+            }
+            break;
+
+        case PseudoColor:
+        case GrayScale:
+        case StaticGray:
+            pVisuals->redMask = 0;
+            pVisuals->greenMask = 0;
+            pVisuals->blueMask = 0;
+            pVisuals->offsetRed = 0;
+            pVisuals->offsetGreen = 0;
+            pVisuals->offsetBlue = 0;
+            break;
+        }
+    }
+    
+    return nVisuals;
+}
+
+VisualPtr gsxGetVisual(int nVisuals,VisualPtr pVisuals,int class,int depth)
+{
+    VisualPtr   pVisual = NULL;
+
+    while (nVisuals--) {
+        if (pVisuals->class == class) {
+            if (pVisuals->nplanes == depth) return pVisuals;
+            if (!pVisual || pVisuals->nplanes > pVisual->nplanes)
+                 pVisual = pVisuals;
+        }
+        pVisuals ++;
+    }
+    return (depth == -1)? pVisual:0;
+}
+
+Bool gsxCreateDefColormap(ScreenPtr pScreen)
+{
+    unsigned short      zero = 0, ones = ~0;
+    VisualPtr   pVisual;
+    ColormapPtr pCmap;
+
+    /* get rootVisual */
+    for (pVisual = pScreen->visuals; pVisual->vid != pScreen->rootVisual;
+         pVisual++)
+        ;
+
+    if (CreateColormap(pScreen->defColormap, pScreen, pVisual,
+        &pCmap, (pVisual->class & DynamicClass) ? AllocNone : AllocAll, 0)
+        != Success) {
+            return FALSE;
+    }
+
+    pScreen->blackPixel = (Pixel)0;
+    pScreen->whitePixel = (Pixel)1;
+
+    if (AllocColor(pCmap,&ones,&ones,&ones,&(pScreen->whitePixel),0)
+        != Success) {
+            return FALSE;
+    }
+    if (AllocColor(pCmap, &zero, &zero, &zero, &(pScreen->blackPixel), 0)
+        != Success) {
+            return FALSE;
+    }
+
+#ifdef CRTCTRL
+    RegisterCrtCtrlFuncs(pScreen, gsxCrtCtrlFunc);
+#endif /* CRTCTRL */
+    (*pScreen->InstallColormap)(pCmap);
+    return TRUE;
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxcpyarea.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxcpyarea.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxcpyarea.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxcpyarea.c	Wed Apr 11 13:12:59 2001
@@ -0,0 +1,980 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+#include "cfb.h"
+#include "mi.h"
+
+static GSXuint gsxFg, gsxBg;
+
+static void gsxDoBitbltWW();
+static void gsxDoBitbltMW();
+static void gsxDoBitbltWM();
+static void gsxGetBitmap();
+static void gsxPutBitmap();
+
+/*
+ * BitBlt Window to Window
+ */
+static void
+gsxDoBitbltWW(pSrc,pDst,alu,nbox,pbox,pptSrc,planemask,bitPlane)
+    DrawablePtr     pSrc, pDst;
+    int         alu;
+    int         nbox;
+    BoxPtr      pbox;
+    DDXPointPtr     pptSrc;
+    unsigned long   planemask, bitPlane;
+{
+  PixmapPtr pPix ;
+  int w, h ;
+  unsigned int bp ;
+  int sbw, dbw, psm ;
+  int depth;
+
+  bp = GSX_FRAME_BASE ;
+  sbw = (pSrc->pScreen->width +63) /64 ;
+  dbw = (pDst->pScreen->width +63) /64 ;
+  psm = gsxGetPsmFromBpp( pDst->bitsPerPixel ) ;
+  depth = pDst->depth;
+
+  if( bitPlane == 0 ){    /* ordinary copy area */
+
+    while (--nbox >= 0) {
+      GSOSbit64 r;
+
+      w = pbox->x2 - pbox->x1 ;
+      h = pbox->y2 - pbox->y1 ;
+
+      gsosMakeGiftag(4, GSOS_GIF_EOP_CONTINUE, 
+		     GSOS_GIF_PRE_IGNORE, 0, GSOS_GIF_FLG_PACKED, 1,
+		     GSOS_GIF_REG_AD);
+
+      r = ( bp |
+	    (sbw<<16) |
+	    ((unsigned long long) bp  << 32)  |
+	    ((unsigned long long) dbw << 48) |
+	    ((unsigned long long) psm << 24) |
+	    ((unsigned long long) psm << 56) );
+      gsosSetPacketAddrData(GSOS_BITBLTBUF, r);
+
+      r = (pptSrc->x |
+	   (pptSrc->y << 16) |
+	   ((unsigned long long)pbox->x1 << 32) |
+	   ((unsigned long long)pbox->y1 << 48) );
+      if ( pptSrc->y  > pbox->y1 || 
+	   (pptSrc->y  == pbox->y1 && pptSrc->x > pbox->x1 ) )
+	;
+      else
+	r |= (3ULL << 59);
+      gsosSetPacketAddrData(GSOS_TRXPOS, r);
+
+      r = w | ((unsigned long long) h << 32);
+      gsosSetPacketAddrData(GSOS_TRXREG, r);
+
+      gsosSetPacketAddrData(GSOS_TRXDIR, 2);
+
+
+      pbox++;
+      pptSrc++;
+    }
+    gsosExec();
+    gsosFlush();
+
+  } else {              /* copy plane */
+
+    if(depth > 1) {
+      /* Dst is Pixmap */
+      GSXulong  *ulds, *uldd;
+      GSXushort *usds, *usdd;
+      GSXuchar  *sbuf, *dbuf;
+      int i ;
+      int x, y ;
+      GSXulong fg,bg;
+      int srclinesize, dstlinesize;
+      int bytepp;
+
+      fg = gsxFg & planemask;
+      bg = gsxBg & planemask;
+      dstlinesize = ((PixmapPtr)pDst)->devKind / bytepp;
+      bytepp = gsxBytePerPixel(pDst->bitsPerPixel);
+
+      while (--nbox >= 0) {
+	w = pbox->x2 - pbox->x1;
+	h = pbox->y2 - pbox->y1;
+	dstlinesize = srclinesize = w * bytepp;
+	dbuf = ALLOCATE_LOCAL(srclinesize * h);
+	sbuf = ALLOCATE_LOCAL(srclinesize * h);
+	uldd = (GSXulong *)dbuf;
+	usdd = (GSXushort *)ulds;
+	ulds = (GSXulong*)dbuf;
+	usdd = (GSXushort *)uldd;
+	srclinesize = pPix->devKind / bytepp;
+	gsosReadImage(pptSrc->x, pptSrc->y,w,h,bp,dbw,psm,sbuf);
+	if(depth <= 16) {	/* RGBA16 */
+	  for(y = 0; y < h; y++) {
+	    for(x = 0; x < w; x++) {
+	      if(usds[x] & bitPlane) {
+		usdd[x] = usdd[x] & ~planemask | fg;
+	      } else {
+		usdd[x] = usdd[x] & ~planemask | bg;
+	      }
+	    }
+	    usds += srclinesize;
+	    usdd += dstlinesize;
+	  }
+	} else {		/* RGBA32 */
+	  for(y = 0 ; y < h; y++) {
+	    for(x = 0; x < w; x++) {
+	      if(ulds[x] & bitPlane) {
+		uldd[x] = uldd[x] & ~planemask | fg;
+	      } else {
+		uldd[x] = uldd[x] & ~planemask | bg;
+	      }
+	    }
+	    ulds += srclinesize;
+	    uldd += dstlinesize;
+	  }
+	}
+	gsosWriteImage(pbox->x1, pbox->y1, w, h, bp, dbw, psm, dbuf);
+	DEALLOCATE_LOCAL(sbuf);
+	DEALLOCATE_LOCAL(dbuf);
+	pbox++;
+	pptSrc++;
+      }
+    }
+  }
+}
+
+/*
+ * BitBlt Pixmap to Window
+ */
+static void
+gsxDoBitbltMW(pSrc,pDst,alu,nbox,pbox,pptSrc,planemask,bitPlane)
+    DrawablePtr     pSrc, pDst;
+    int         alu;
+    int         nbox;
+    BoxPtr      pbox;
+    DDXPointPtr     pptSrc;
+    unsigned long   planemask, bitPlane;
+{
+  GSXuchar *data, *d ;
+  int y, w, h ;
+  unsigned char depth ;
+  unsigned int bp ;
+  int bw, psm ;
+  int bytepp;
+
+  depth = pDst->depth ;
+  bp = GSX_FRAME_BASE ;
+  bw = (pDst->pScreen->width +63) /64 ;
+  psm = gsxGetPsmFromBpp( pDst->bitsPerPixel ) ;
+  bytepp = gsxBytePerPixel(pDst->bitsPerPixel);
+
+  data = (GSXuchar*)((PixmapPtr)pSrc)->devPrivate.ptr;
+
+  if( bitPlane == 0 ){    /* ordinary copy area */
+
+    if(depth <= 16) {
+      while (--nbox >= 0) {
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1 ;
+
+	d = data + pptSrc->x * bytepp + ((PixmapPtr)pSrc)->devKind * pptSrc->y;
+	{
+	  GSXuchar *buf;
+	  GSXuchar *dd;
+	  int      DstdevKind;
+
+	  DstdevKind = w * bytepp;
+	  buf = ALLOCATE_LOCAL(DstdevKind * h);
+	  dd = buf;
+	  for( y = 0 ; y < h ; y++ ){
+	    memcpy(dd, d, DstdevKind);
+	    d += ((PixmapPtr)pSrc)->devKind ;
+	    dd += DstdevKind ;
+	  }
+	  gsosWriteImage(pbox->x1, pbox->y1, w, h, bp, bw, psm, buf);
+	  DEALLOCATE_LOCAL(buf);
+	}
+	pbox++;
+	pptSrc++;
+      }
+    } else {
+      while (--nbox >= 0) {
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1 ;
+	d = data + pptSrc->x * bytepp + ((PixmapPtr)pSrc)->devKind * pptSrc->y;
+	{
+	  PixmapPtr pPix = (*pSrc->pScreen->CreatePixmap)
+	    (pSrc->pScreen, w, h, depth ) ;
+	  GSXuchar *dd = (GSXuchar*)pPix->devPrivate.ptr ;
+	  GSXuchar *d0 = dd;
+	  for( y = 0 ; y < h ; y++ ){
+	    memcpy( dd, d, PixmapBytePad( w, depth )) ;
+	    d += ((PixmapPtr)pSrc)->devKind ;
+	    dd += pPix->devKind ;
+	  }
+	  gsxWriteImage(pbox->x1, pbox->y1, w, h, bp, bw, psm, pPix);
+	  (*pSrc->pScreen->DestroyPixmap)( pPix ) ;
+	}
+	pbox++;
+	pptSrc++;
+      }
+    }
+
+  } else {              /* copy plane */
+
+    if(pSrc->depth > 1) {
+      PixmapPtr pPix ;
+      GSXulong  *ulds, *uldd;
+      GSXushort *usds, *usdd;
+      int i;
+      int x, y ;
+      GSXulong fg,bg;
+      int srclinesize, dstlinesize;
+
+      fg = gsxFg & planemask;
+      bg = gsxBg & planemask;
+      srclinesize = ((PixmapPtr)pSrc)->devKind / bytepp;
+
+      while( --nbox >= 0 ){
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1 ;
+	pPix = (*pDst->pScreen->CreatePixmap)(pDst->pScreen, w, h, depth);
+	ulds = (GSXulong *)(data + pptSrc->x * bytepp +
+			    ((PixmapPtr)pSrc)->devKind * pptSrc->y);
+	usds = (GSXushort *)ulds;
+	uldd = (GSXulong *)pPix->devPrivate.ptr;
+	usdd = (GSXushort *)uldd;
+	dstlinesize = ((PixmapPtr)pPix)->devKind / bytepp;
+	if(depth <= 16) {	/* RGBA16 */
+	  for(y = 0; y < h; y++) {
+	    for(x = 0; x < w; x++) {
+	      if(usds[x] & bitPlane) {
+		usdd[x] = usdd[x] & ~planemask | fg;
+	      } else {
+		usdd[x] = usdd[x] & ~planemask | bg;
+	      }
+	    }
+	    usds += srclinesize;
+	    usdd += dstlinesize;
+	  }
+	} else {		/* RGBA32 */
+	  for(y = 0; y < h; y++) {
+	    for(x = 0; x < w; x++) {
+	      if(ulds[x] & bitPlane) {
+		uldd[x] = uldd[x] & ~planemask | fg;
+	      } else {
+		uldd[x] = uldd[x] & ~planemask | bg;
+	      }
+	    }
+	    ulds += srclinesize;
+	    uldd += dstlinesize;
+	  }
+	}
+	gsxWriteImage(pbox->x1, pbox->y1, w, h, bp, bw, psm, pPix);
+	(*pSrc->pScreen->DestroyPixmap)(pPix);
+	pbox++;
+	pptSrc++;
+      }
+
+    } else {
+      /* from Bitmap */
+      while( --nbox >= 0 ){
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1 ;
+	gsxPutBitmap(pSrc, pDst,
+		     pptSrc->x, pptSrc->y,
+		     w, h,
+		     pbox->x1, pbox->y1,
+		     gsxFg, gsxBg);
+	pbox++;
+	pptSrc++;
+      }
+    }
+  }
+
+}
+
+/*
+ * BitBlt Window to Pixmap
+ */
+static void
+gsxDoBitbltWM(pSrc,pDst,alu,nbox,pbox,pptSrc,planemask,bitPlane)
+    DrawablePtr     pSrc, pDst;
+    int             alu;
+    int             nbox;
+    BoxPtr          pbox;
+    DDXPointPtr     pptSrc;
+    unsigned long   planemask, bitPlane;
+{
+  GSXuchar *data, *d;
+  int y, w, h;
+  unsigned char src_depth;
+  unsigned char dst_depth;
+  unsigned int bp;
+  int bw, psm;
+  int bytepp;
+
+  src_depth = pSrc->depth;
+  dst_depth = pDst->depth;
+  bp = GSX_FRAME_BASE;
+  bw = (pSrc->pScreen->width + 63) / 64;
+  psm = gsxGetPsmFromBpp(pSrc->bitsPerPixel);
+  bytepp = gsxBytePerPixel(pDst->bitsPerPixel);
+
+  data = (GSXuchar*)((PixmapPtr)pDst)->devPrivate.ptr;
+
+  if(bitPlane == 0) {    /* ordinary copy area */
+
+    if(src_depth <= 16) {
+      while(--nbox >= 0) {
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1;
+	d = data + pbox->x1 * bytepp + ((PixmapPtr)pDst)->devKind * pbox->y1;
+	{
+	  int devKind;
+	  GSXuchar *buf;
+	  GSXuchar *dd;
+
+	  devKind = w * bytepp;
+	  buf = ALLOCATE_LOCAL(devKind * h);
+	  gsosReadImage(pptSrc->x, pptSrc->y, w, h, bp, bw, psm, buf);
+
+	  dd = buf;
+	  for(y = 0 ; y < h ; y++) {
+	    memcpy(d, dd, devKind);
+	    dd += devKind;
+	    d += ((PixmapPtr)pDst)->devKind;
+	  }
+	  DEALLOCATE_LOCAL(buf);
+	}
+	pbox++;
+	pptSrc++;
+      }
+    } else { 
+      while(--nbox >= 0) {
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1;
+	d = data + pbox->x1 * bytepp + ((PixmapPtr)pDst)->devKind * pbox->y1;
+	{
+	  int devKind;
+	  PixmapPtr pPix;
+	  GSXuchar *dd;
+
+	  pPix = (*pSrc->pScreen->CreatePixmap)
+	    (pSrc->pScreen, w, h, dst_depth );
+	  dd = (GSXuchar*)pPix->devPrivate.ptr;
+	  gsxReadImage(pptSrc->x, pptSrc->y, w, h, bp, bw, psm, pPix);
+	  devKind = ((PixmapPtr)pDst)->devKind;
+	  for(y = 0 ; y < h ; y++) {
+	    memcpy(d, dd, PixmapBytePad(w, dst_depth));
+	    dd += pPix->devKind;
+	    d += ((PixmapPtr)pDst)->devKind;
+	  }
+	  (*pSrc->pScreen->DestroyPixmap)(pPix);
+	}
+	pbox++;
+	pptSrc++;
+      }
+    }
+  } else {              /* copy plane */
+
+    if(dst_depth > 1) {
+      /* Dst is Pixmap */
+      PixmapPtr pPix ;
+      GSXulong  *ulds, *uldd;
+      GSXushort *usds, *usdd;
+      int i ;
+      int x, y ;
+      GSXulong fg,bg;
+      int srclinesize, dstlinesize;
+
+      fg = gsxFg & planemask;
+      bg = gsxBg & planemask;
+      dstlinesize = ((PixmapPtr)pDst)->devKind / bytepp;
+
+      while (--nbox >= 0) {
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1 ;
+	uldd = (GSXulong *)(data + pbox->x1 * bytepp +
+			    ((PixmapPtr)pDst)->devKind * pbox->y1);
+	usdd = (GSXushort *)ulds;
+	pPix = (*pSrc->pScreen->CreatePixmap)(pSrc->pScreen, w, h, dst_depth);
+	ulds = (GSXulong*)pPix->devPrivate.ptr ;
+	usdd = (GSXushort *)uldd;
+	srclinesize = pPix->devKind / bytepp;
+	gsosReadImage(pptSrc->x, pptSrc->y,w,h,bp,bw,psm,(GSXuchar*)ulds);
+	if(dst_depth <= 16) {	/* RGBA16 */
+	  for(y = 0; y < h; y++) {
+	    for(x = 0; x < w; x++) {
+	      if(usds[x] & bitPlane) {
+		usdd[x] = usdd[x] & ~planemask | fg;
+	      } else {
+		usdd[x] = usdd[x] & ~planemask | bg;
+	      }
+	    }
+	    usds += srclinesize;
+	    usdd += dstlinesize;
+	  }
+	} else {		/* RGBA32 */
+	  for(y = 0 ; y < h; y++) {
+	    for(x = 0; x < w; x++) {
+	      if(ulds[x] & bitPlane) {
+		uldd[x] = uldd[x] & ~planemask | fg;
+	      } else {
+		uldd[x] = uldd[x] & ~planemask | bg;
+	      }
+	    }
+	    ulds += srclinesize;
+	    uldd += dstlinesize;
+	  }
+	}
+	(*pSrc->pScreen->DestroyPixmap)(pPix);
+	pbox++;
+	pptSrc++;
+      }
+
+    } else {
+
+      /* Dst is Bitmap */
+      while( --nbox >= 0 ){
+	w = pbox->x2 - pbox->x1 ;
+	h = pbox->y2 - pbox->y1 ;
+	gsxGetBitmap
+	  (pSrc,pDst,pptSrc->x,pptSrc->y,w,h,pbox->x1,pbox->y1,bitPlane);
+	pbox++;
+	pptSrc++;
+      }
+
+    }
+  }
+}
+
+/*
+ * BitBlt
+ */
+void gsxDoBitBlt(pSrc,pDst,alu,prgnDst,pptSrc,planemask,bitPlane)
+     DrawablePtr     pSrc, pDst;
+     int             alu;
+     RegionPtr       prgnDst;
+     DDXPointPtr     pptSrc;
+     unsigned long   planemask;
+{
+  register BoxPtr pbox = REGION_RECTS(prgnDst);
+  register int    nbox = REGION_NUM_RECTS(prgnDst);
+  BoxPtr      pboxTmp, pboxNext, pboxBase;
+  /* temporaries for shuffling rectangles */
+  BoxPtr      pboxNew1 = NULL, pboxNew2 = NULL;
+  DDXPointPtr     pptTmp, pptNew1 = NULL, pptNew2 = NULL;
+
+  if (nbox == 0 || planemask == 0)
+    return;
+
+  if (pSrc->type == pDst->type) {         /* WIN -> WIN */
+    if (pptSrc->y < pbox->y1) {
+      /* walk source botttom to top */
+      /* keep ordering in each band, reverse order of bands */
+      pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+      pptNew1 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+      if(!pboxNew1 || !pptNew1) {
+        if (pboxNew1) DEALLOCATE_LOCAL(pboxNew1);
+        if (pptNew1) DEALLOCATE_LOCAL(pptNew1);
+        return;
+      }
+      pboxBase = pboxNext = pbox+nbox-1;
+      while (pboxBase >= pbox) {
+        while ((pboxNext >= pbox) && 
+	       (pboxBase->y1 == pboxNext->y1))
+	  pboxNext--;
+        pboxTmp = pboxNext+1;
+        pptTmp = pptSrc + (pboxTmp - pbox);
+        while (pboxTmp <= pboxBase)
+	  {
+	    *pboxNew1++ = *pboxTmp++;
+	    *pptNew1++ = *pptTmp++;
+	  }
+        pboxBase = pboxNext;
+      }
+      pboxNew1 -= nbox;
+      pbox = pboxNew1;
+      pptNew1 -= nbox;
+      pptSrc = pptNew1;
+    }
+
+    if (pptSrc->x < pbox->x1) {
+      /* walk source right to left */
+      /* reverse order of rects in each band */
+      pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+      pptNew2 = (DDXPointPtr)ALLOCATE_LOCAL(sizeof(DDXPointRec) * nbox);
+      if(!pboxNew2 || !pptNew2) {
+        if (pptNew2) DEALLOCATE_LOCAL(pptNew2);
+        if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+        if (pboxNew1) {
+	  DEALLOCATE_LOCAL(pptNew1);
+	  DEALLOCATE_LOCAL(pboxNew1);
+        }
+        return;
+      }
+      pboxBase = pboxNext = pbox;
+      while (pboxBase < pbox+nbox) {
+        while ((pboxNext < pbox+nbox) &&
+	       (pboxNext->y1 == pboxBase->y1))
+	  pboxNext++;
+        pboxTmp = pboxNext;
+        pptTmp = pptSrc + (pboxTmp - pbox);
+        while (pboxTmp != pboxBase)
+	  {
+	    *pboxNew2++ = *--pboxTmp;
+	    *pptNew2++ = *--pptTmp;
+	  }
+        pboxBase = pboxNext;
+      }
+      pboxNew2 -= nbox;
+      pbox = pboxNew2;
+      pptNew2 -= nbox;
+      pptSrc = pptNew2;
+    }
+  }         /* WIN -> WIN */
+
+  if (nbox) {
+    if (pSrc->type == pDst->type) {         /* WIN -> WIN */
+      gsxDoBitbltWW(pSrc,pDst,alu,nbox,pbox,pptSrc,planemask,bitPlane);
+    } else if (pDst->type != DRAWABLE_PIXMAP) { /* MEM -> WIN */
+      gsxDoBitbltMW(pSrc,pDst,alu,nbox,pbox,pptSrc,planemask,bitPlane);
+    } else {                    /* WIN -> MEM */
+      gsxDoBitbltWM(pSrc,pDst,alu,nbox,pbox,pptSrc,planemask,bitPlane);
+    }
+  }
+
+  /* free up stuff */
+  if (pboxNew2) {
+    DEALLOCATE_LOCAL(pptNew2);
+    DEALLOCATE_LOCAL(pboxNew2);
+  }
+  if (pboxNew1) {
+    DEALLOCATE_LOCAL(pptNew1);
+    DEALLOCATE_LOCAL(pboxNew1);
+  }
+}
+
+/*
+ * Get Bitmap From Window
+ */
+static void gsxGetBitmap(pSrc,pDst,srcx,srcy,w,h,dstx,dsty,bitPlane)
+    DrawablePtr pSrc, pDst ;
+    int srcx, srcy, w, h, dstx, dsty ;
+    GSXulong bitPlane ;
+{
+    PixmapPtr pPix ;
+    int bp, bw, psm ;
+    GSXuchar *ds, *dd ;
+    int bytepp, component, id ;
+    int x, y ;
+    GSXulong pmask ;
+    GSXuchar mask ;
+
+    pPix = (*pSrc->pScreen->CreatePixmap)(pSrc->pScreen, w, h, pSrc->depth ) ;
+    bp = GSX_FRAME_BASE ;
+    bw = (pSrc->pScreen->width +63) /64 ;
+    psm = gsxGetPsmFromBpp( pSrc->bitsPerPixel ) ;
+    gsxReadImage(srcx, srcy, w, h, bp, bw, psm, pPix);
+
+    bytepp = gsxBytePerPixel(pDst->bitsPerPixel);
+    if( bitPlane & 0x000000ffL ){
+        component = 0 ;
+        pmask = bitPlane & 0xff ;
+    }else if( bitPlane & 0x0000ff00L ){
+        component = 1 ;
+        pmask = (bitPlane >> 8) & 0xff ;
+    }else if( bitPlane & 0x00ff0000L ){
+        component = 2 ;
+        pmask = (bitPlane >> 16) & 0xff ;
+    }else if( bitPlane & 0xff000000L ){
+        component = 3 ;
+        pmask = (bitPlane >> 24) & 0xff ;
+    }
+    ds = (GSXuchar *)pPix->devPrivate.ptr ;
+    dd = (GSXuchar *)((PixmapPtr)pDst)->devPrivate.ptr 
+       + ((PixmapPtr)pDst)->devKind * dsty ;
+    for( y=0 ; y < h ; y++ ){
+        for( x=0 ; x < w ; x++ ){
+            id = (dstx + x) / 8 ;
+            mask = (GSXuchar)1 << ((dstx +x) % 8) ;
+            if( ds[(srcx+x)*bytepp+component] & pmask ){
+                dd[id] = ( dd[id] & ~mask ) | ( 0xff & mask ) ;       
+            }else{
+                dd[id] = ( dd[id] & ~mask ) | ( 0 & mask ) ;       
+            }
+        }
+        ds += pPix->devKind ;
+        dd += ((PixmapPtr)pDst)->devKind ;
+    }
+    (*pSrc->pScreen->DestroyPixmap)( pPix ) ;
+}
+
+/*
+ * Put Bitmap to Window
+ */
+static void gsxPutBitmap(pSrc,pDst,srcx,srcy,w,h,dstx,dsty,fg,bg)
+    DrawablePtr pSrc,pDst ;
+    int srcx, srcy, w, h, dstx, dsty ;
+    GSXuint fg, bg ;
+{
+    PixmapPtr pPix ;
+    int bp, bw, psm ;
+    GSXuchar *ds, *dd ;
+    int bytepp, i ;
+    int x, y ;
+    GSXuchar mask ;
+
+    pPix = (*pDst->pScreen->CreatePixmap)(pDst->pScreen, w, h, pDst->depth ) ;
+
+    bytepp = gsxBytePerPixel(pDst->bitsPerPixel);
+    ds = (GSXuchar *)((PixmapPtr)pSrc)->devPrivate.ptr
+       + ((PixmapPtr)pSrc)->devKind * srcy ;
+    dd = (GSXuchar *)pPix->devPrivate.ptr ;
+    for( y=0 ; y < h ; y++ ){
+        for( x=0 ; x < w ; x++ ){
+            mask = (GSXuchar)1 << ((srcx +x) % 8) ;
+            if( ds[(srcx+x)/8] & mask ){
+                for( i=0 ; i < bytepp ; i++ ){
+                    dd[x*bytepp+i] = (gsxFg >> (i*8)) & 0xffL ;
+                }
+            }else{
+                for( i=0 ; i < bytepp ; i++ ){
+                    dd[x*bytepp+i] = (gsxBg >> (i*8)) & 0xffL ;
+                }
+            }
+        }
+        ds += ((PixmapPtr)pSrc)->devKind ;
+        dd += pPix->devKind ;
+    }
+    bp = GSX_FRAME_BASE ;
+    bw = (pDst->pScreen->width +63) /64 ;
+    psm = gsxGetPsmFromBpp( pDst->bitsPerPixel ) ;
+    gsxWriteImage(dstx, dsty, w, h, bp, bw, psm, pPix);
+
+    (*pSrc->pScreen->DestroyPixmap)( pPix ) ;
+}
+
+/*
+ * Copy Area with Logical Operation
+ */
+RegionPtr gsxCopyAreaLop( src,dst,pGC,srcx,srcy,w,h,dstx,dsty )
+    DrawablePtr src, dst;
+    GCPtr   pGC;
+    int     srcx, srcy, w, h, dstx, dsty ;
+{
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    RegionPtr dstRegion ;
+
+    if( src->type == DRAWABLE_PIXMAP && dst->type == DRAWABLE_PIXMAP ){
+        return (*gsxGetGCPriv(pGC)->mops->CopyArea)
+           (src, dst, pGC, srcx, srcy, w, h, dstx, dsty ) ;
+    }
+
+    /* get region for LOP */
+    aRect.x = dstx + dst->x ;
+    aRect.y = dsty + dst->y ;
+    aRect.width = w ;
+    aRect.height = h ;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return NULL ;
+    }
+    /* pre-process for LOP (read from dst to dstLop)*/
+    gsxPreLop( pGC, dst, &aRect, dstLop ) ;
+
+    /* get dstRegion */
+    dstRegion = miHandleExposures(src,dst,pGC,srcx,srcy,w,h,dstx,dsty,0);
+
+    /* post-proccess for LOP (src LOP dstLop -> dst)*/
+    gsxPostLopCopy( pGC, dst, &aRect, dstLop, src, srcx, srcy, dstRegion ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+    return dstRegion ;
+}
+
+/*
+ * Copy Area GXcopy
+ */
+RegionPtr gsxCopyAreaGxcpy( src,dst,pGC,srcx,srcy,w,h,dstx,dsty )
+    DrawablePtr src, dst;
+    GCPtr   pGC;
+    int     srcx, srcy, w, h, dstx, dsty ;
+{
+    RegionPtr rgn ;
+
+    if( src->type == DRAWABLE_PIXMAP && dst->type == DRAWABLE_PIXMAP ){
+        return (*gsxGetGCPriv(pGC)->mops->CopyArea)
+           (src, dst, pGC, srcx, srcy, w, h, dstx, dsty ) ;
+    }
+    /* DoBitblt */
+    rgn = (RegionPtr)cfbBitBlt( src, dst, pGC, 
+        srcx, srcy, w, h, dstx, dsty, gsxDoBitBlt, 0L ) ;
+
+    return rgn ;
+}
+
+/*
+ * Pixmap Copy Plane for gsxCopyPlaneLop
+ */
+static void gsxDoCopyPlaneTo24(pSrcPix, pDstPix, w, h, plane)
+     DrawablePtr pSrcPix, pDstPix;
+     int     w, h;
+     unsigned long    plane;
+{
+  GSXuchar *ds, *dd ;
+  GSXulong *ulds, *uldd;
+  int bytepp, i ;
+  int x, y ;
+  GSXuchar mask ;
+  int srclinesize, dstlinesize;
+
+  bytepp = gsxBytePerPixel(pDstPix->bitsPerPixel);
+  ds = (GSXuchar *)((PixmapPtr)pSrcPix)->devPrivate.ptr;
+  dd = (GSXuchar *)((PixmapPtr)pDstPix)->devPrivate.ptr;
+  srclinesize = ((PixmapPtr)pSrcPix)->devKind;
+  dstlinesize = ((PixmapPtr)pDstPix)->devKind;
+
+  if(pSrcPix->depth > 1) {
+    /* src is pixmap(24bit planes) */
+    srclinesize /= bytepp;
+    dstlinesize /= bytepp;
+    ulds = (GSXulong *)ds;
+    uldd = (GSXulong *)dd;
+    for(y = 0; y < h; y++) {
+      for(x = 0; x < w; x++) {
+	if(ulds[x] & plane) {
+	  uldd[x] = gsxFg;
+	} else {
+	  uldd[x] = gsxBg;
+	}
+      }
+      ulds += srclinesize;
+      uldd += dstlinesize;
+    }
+  } else {
+    /* src is bitmap */
+    for(y = 0 ; y < h ; y++) {
+      for(x = 0 ; x < w ; x++) {
+	mask = (GSXuchar)1 << (x % 8);
+	if(ds[x / 8] & mask) {
+	  for(i = 0 ; i < bytepp; i++) {
+	    dd[x * bytepp + i] = (gsxFg >> (i * 8)) & 0xffL;
+	  }
+	}else{
+	  for(i = 0 ; i < bytepp ; i++) {
+	    dd[x * bytepp + i] = (gsxBg >> (i * 8)) & 0xffL;
+	  }
+	}
+      }
+      ds += srclinesize;
+      dd += dstlinesize;
+    }
+  }
+}
+
+/*
+ * Copy Plane with Logical Operation
+ */
+RegionPtr gsxCopyPlaneLop(src,dst,pGC,srcx,srcy,w,h,dstx,dsty,plane)
+    DrawablePtr src, dst;
+    GCPtr   pGC;
+    int     srcx, srcy;
+    int     w, h;
+    int     dstx, dsty;
+    long    plane;
+{
+  xRectangle aRect ;
+  PixmapPtr srcLop, dstLop;
+  PixmapPtr pPix;
+  RegionPtr dstRegion;
+
+  if( src->type == DRAWABLE_PIXMAP && dst->type == DRAWABLE_PIXMAP ){
+    return (*gsxGetGCPriv(pGC)->mops->CopyPlane)
+      (src, dst, pGC, srcx, srcy, w, h, dstx, dsty, plane ) ;
+  }
+  dstLop = (*dst->pScreen->CreatePixmap)
+    (dst->pScreen, w, h, dst->depth ) ;
+  if( !dstLop ){
+    return NULL ;
+  }
+
+  pPix = (*dst->pScreen->CreatePixmap)
+    (dst->pScreen, w, h, dst->depth ) ;
+  if( !pPix ){
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+    return NULL ;
+  }
+
+  srcLop = (PixmapPtr)src;
+
+  /*
+   * Pattenize stage
+   */
+  /* pre-process for LOP */
+  aRect.x = dstx + dst->x ;
+  aRect.y = dsty + dst->y ;
+  aRect.width = w ;
+  aRect.height = h ;
+  gsxPreLop( pGC, dst, &aRect, dstLop ) ;
+
+  /* duplicate dst */
+  (*gsxGetGCPriv(pGC)->mops->CopyArea)
+    ((DrawablePtr)dstLop, (DrawablePtr)pPix, pGC, 0, 0, w, h, 0, 0);
+
+  /* do copy plane */
+  gsxFg = pGC->fgPixel;
+  gsxBg = pGC->bgPixel;
+  gsxDoCopyPlaneTo24((DrawablePtr)srcLop, (DrawablePtr)pPix, w, h, plane);
+
+  /* 
+   * rasterize stage
+   */
+  /* get exposure region */
+  dstRegion = miHandleExposures(src,dst,pGC,srcx,srcy,w,h,dstx, dsty,plane);
+
+  /* post-proccess for LOP (src LOP dstLop -> dst)*/
+  gsxPostLopCopy(pGC, dst, &aRect, dstLop, (DrawablePtr)pPix, 0, 0, dstRegion);
+
+  (*dst->pScreen->DestroyPixmap)(dstLop) ;
+  (*dst->pScreen->DestroyPixmap)(pPix) ;
+
+  return dstRegion ;
+}
+
+/*
+ * Copy Plane for GXcopy
+ */
+RegionPtr gsxCopyPlaneGxcpy(src,dst,pGC,srcx,srcy,w,h,dstx,dsty,plane)
+    DrawablePtr src, dst;
+    GCPtr   pGC;
+    int     srcx, srcy;
+    int     w, h;
+    int     dstx, dsty;
+    long    plane;
+{
+    PixmapPtr   pBitmap = NULL;
+    GCPtr       pGC1;
+    RegionPtr   ret;
+    GSXuint     pmask;
+
+    if (dst->type==DRAWABLE_PIXMAP && src->type==DRAWABLE_PIXMAP) {
+        return (*gsxGetGCPriv(pGC)->mops->CopyPlane)
+                (src,dst,pGC,srcx,srcy,w,h,dstx,dsty,plane);
+    }
+    pmask = gsxGetGCPriv(pGC)->pixelMask;
+    /* use CopyPlane Fg/Bg colors */
+    gsxFg = pGC->fgPixel & pmask;
+    gsxBg = pGC->bgPixel & pmask;
+    ret = (RegionPtr)cfbBitBlt
+       (src,dst,pGC,srcx,srcy,w,h,dstx,dsty,gsxDoBitBlt,plane);
+    return ret;
+}
+
+/*
+ * SaveAreas for Backing Store
+ */
+void
+gsxSaveAreas(pPixmap, prgnSave, xorg, yorg, pWin)
+    PixmapPtr    pPixmap;        /* Backing pixmap */
+    RegionPtr    prgnSave;       /* Region to save (pixmap-relative) */
+    int          xorg;           /* X origin of region */
+    int          yorg;           /* Y origin of region */
+    WindowPtr    pWin;
+{
+    register DDXPointPtr pPt;
+    DDXPointPtr         pPtsInit;
+    register BoxPtr     pBox;
+    register int        i;
+
+    i = REGION_NUM_RECTS(prgnSave);
+    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i * sizeof(DDXPointRec));
+    if (!pPtsInit)
+        return;
+
+    pBox = REGION_RECTS(prgnSave);
+    pPt = pPtsInit;
+    while (--i >= 0) {
+        pPt->x = pBox->x1 + xorg;
+        pPt->y = pBox->y1 + yorg;
+        pPt++;
+        pBox++;
+    }
+
+    gsxDoBitBlt(&pWin->drawable, (DrawablePtr)pPixmap,
+                    GXcopy, prgnSave, pPtsInit, ~0L, 0);
+
+    DEALLOCATE_LOCAL (pPtsInit);
+}
+
+/*
+ * RestoreAreas for Backing Store
+ */
+void
+gsxRestoreAreas(pPixmap, prgnRestore, xorg, yorg, pWin)
+    PixmapPtr    pPixmap;        /* Backing pixmap */
+    RegionPtr    prgnRestore;    /* Region to restore (screen-relative)*/
+    int          xorg;           /* X origin of window */
+    int          yorg;           /* Y origin of window */
+    WindowPtr    pWin;
+{
+    register DDXPointPtr pPt;
+    DDXPointPtr         pPtsInit;
+    register BoxPtr     pBox;
+    register int        i;
+
+    i = REGION_NUM_RECTS(prgnRestore);
+    pPtsInit = (DDXPointPtr)ALLOCATE_LOCAL(i*sizeof(DDXPointRec));
+    if (!pPtsInit)
+        return;
+
+    pBox = REGION_RECTS(prgnRestore);
+    pPt = pPtsInit;
+    while (--i >= 0) {
+        pPt->x = pBox->x1 - xorg;
+        pPt->y = pBox->y1 - yorg;
+        pPt++;
+        pBox++;
+    }
+
+    gsxDoBitBlt((DrawablePtr)pPixmap, &pWin->drawable,
+                    GXcopy, prgnRestore, pPtsInit, ~0L, 0);
+
+    DEALLOCATE_LOCAL (pPtsInit);
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxfillarc.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillarc.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxfillarc.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillarc.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,104 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+void gsxPolyFillArcSoft(dst,pGC,n,pArc)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xArc    *pArc;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int lineWidth;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!n) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegionArc( pArc, n, &aRect ) ;
+    drawRegion_x = aRect.x;
+    drawRegion_y = aRect.y;
+    lineWidth = pGC->lineWidth;
+    lineWidth = (((lineWidth < 2) ? 2 : lineWidth) + 1);
+    aRect.x += dst->x;
+    aRect.y += dst->y;
+    aRect.width  += lineWidth;
+    aRect.height += lineWidth;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* adjust pattern origin */
+    if (pGC->fillStyle != FillSolid) {
+      pGC1->patOrg.x = pGC1->patOrg.x + (pPriv->patW - drawRegion_x % pPriv->patW);
+      pGC1->patOrg.y = pGC1->patOrg.y + (pPriv->patH - drawRegion_y % pPriv->patH);
+    }
+
+    /* draw Arcs */
+    for( nn = 0 ; nn < n ; nn++ ) {
+        pArc[nn].x -= drawRegion_x;
+        pArc[nn].y -= drawRegion_y;
+    }
+    (*pGC1->ops->PolyFillArc)( (DrawablePtr)dstLop, pGC1, n, pArc ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxfillply.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillply.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxfillply.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillply.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,108 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+void gsxFillPolygonSoft(dst,pGC,shape,mode,count,pPoint)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     shape, mode, count;
+    DDXPointPtr pPoint;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int lineWidth;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!count) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegion( pPoint, count, mode, &aRect ) ;
+    drawRegion_x = aRect.x;
+    drawRegion_y = aRect.y;
+    lineWidth = pGC->lineWidth;
+    lineWidth = (((lineWidth < 2) ? 2 : lineWidth) + 1);
+    aRect.x += dst->x;
+    aRect.y += dst->y;
+    aRect.width  += lineWidth;
+    aRect.height += lineWidth;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* adjust pattern origin */
+    if (pGC->fillStyle != FillSolid) {
+      pGC1->patOrg.x = pGC1->patOrg.x + (pPriv->patW - drawRegion_x % pPriv->patW);
+      pGC1->patOrg.y = pGC1->patOrg.y + (pPriv->patH - drawRegion_y % pPriv->patH);
+    }
+
+    /* draw polygon */
+    if( mode == CoordModePrevious ){
+        pPoint[0].x -= drawRegion_x;
+        pPoint[0].y -= drawRegion_y;
+    }else{
+        for( nn = 0 ; nn < count ; nn++ ) {
+            pPoint[nn].x -= drawRegion_x;
+            pPoint[nn].y -= drawRegion_y;
+        }
+    }
+    (*pGC1->ops->FillPolygon)( (DrawablePtr)dstLop, pGC1, shape, mode, count, pPoint ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxfillrct.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillrct.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxfillrct.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillrct.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,194 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+static void doPolyFillRect( DrawablePtr dst, GCPtr pGC, int n, xRectangle *pRect) ;
+extern void gsxImageDump(void *p, int w, int h, int bsz, int image);
+
+void gsxPolyFillRectSoft(dst,pGC,n,pRect)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xRectangle  *pRect;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int lineWidth;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!n) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegionRect( pRect, n, &aRect ) ;
+    drawRegion_x = aRect.x;
+    drawRegion_y = aRect.y;
+    lineWidth = pGC->lineWidth;
+    lineWidth = (((lineWidth < 2) ? 2 : lineWidth) + 1);
+    aRect.x += dst->x;
+    aRect.y += dst->y;
+    aRect.width  += lineWidth;
+    aRect.height += lineWidth;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* adjust pattern origin */
+    if (pGC->fillStyle != FillSolid) {
+      pGC1->patOrg.x = pGC1->patOrg.x + (pPriv->patW - drawRegion_x % pPriv->patW);
+      pGC1->patOrg.y = pGC1->patOrg.y + (pPriv->patH - drawRegion_y % pPriv->patH);
+    }
+
+    /* draw Rectangles */
+    for( nn = 0 ; nn < n ; nn++ ) {
+        pRect[nn].x -= drawRegion_x;
+        pRect[nn].y -= drawRegion_y;
+    }
+    (*pGC1->ops->PolyFillRect)( (DrawablePtr)dstLop, pGC1, n, pRect ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxPolyFillRectGxcpy(dst,pGC,n,pRect)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xRectangle  *pRect;
+{
+
+    doPolyFillRect( dst, pGC, n, pRect ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+
+static void doPolyFillRect(dst,pGC,n,pRect)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xRectangle  *pRect;
+{
+    gsxGCPtr        pPriv = gsxGetGCPriv(pGC);
+    BoxPtr      pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    BoxPtr      plast = pbox + REGION_NUM_RECTS(pPriv->pCompositeClip);
+    int xorg = dst->x, yorg = dst->y;
+    xRectangle *p = pRect, *rectLast = pRect + n;
+    int rgb, r, g, b, a ;
+    GSOSbit64 eop ;
+    GSOSbit64 oldtex0_1 ;
+    int i;
+    int nCount;
+    int pc;
+    int packets;
+    int result;
+    int depth;
+    int scrn_w, psm;
+    GSOSbit64    frame;
+    GSOSbit64    mask;
+
+    if (!n) return;
+
+    gsxFrameInit(dst->pScreen->width, dst->depth);
+
+    eop = GSOS_GIF_EOP_CONTINUE;
+
+    rgb = pGC->fgPixel & pPriv->pixelMask ;
+    gsxGetRgba( pGC, rgb, &r, &g, &b, &a ) ;
+
+    pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    while (pbox < plast) {
+        gsosMakeGiftag(2, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+            0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD);
+        /* set SCISSOR rect */
+        gsosSetPacketAddrData4( GSOS_SCISSOR_1,
+            (GSOSbit64)pbox->x1, (GSOSbit64)pbox->x2-1,
+            (GSOSbit64)pbox->y1, (GSOSbit64)pbox->y2-1 );
+        gsosSetPacketAddrData( GSOS_PRIM, GSOS_PRIM_SPRITE ) ;
+
+	p = pRect;
+	nCount = n;
+	while(nCount > 0) {
+	  pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED) / 2;
+	  if(pc == 0) {	/* can't allocate buffer */
+	    gsosExec();		/* flush DMA */
+	    pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED) / 2;
+	  }
+	  packets = (nCount < pc) ? nCount : pc;
+	  result = gsosMakeGiftag(packets * 2, eop, GSOS_GIF_PRE_IGNORE, 0,
+				  GSOS_GIF_FLG_PACKED, 2,
+				  (GSOS_GIF_REG_XYZ2  << 4) |
+				  (GSOS_GIF_REG_RGBAQ << 0));
+	  if(result) break;
+	  for(i = 0; i < packets; i++, p++) {
+            gsosSetPacket4(r, g, b, a ) ;
+            gsosSetPacket4(GSOS_SUBPIX_OFST(p->x + xorg),
+			   GSOS_SUBPIX_OFST(p->y + yorg), 0, 0);
+
+            gsosSetPacket4(r, g, b, a);
+            gsosSetPacket4(GSOS_SUBPIX_OFST(p->x + p->width  + xorg), 
+			   GSOS_SUBPIX_OFST(p->y + p->height + yorg), 0, 0);
+	  }
+	  nCount -= packets;
+	}
+        pbox++;
+    }
+    gsosExec() ;
+
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxfillsp.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillsp.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxfillsp.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxfillsp.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,199 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+static void doFillSpans( DrawablePtr dst, GCPtr pGC, int nSpans, DDXPointPtr pPoints, int *pWidths, int sortd) ;
+
+void gsxFillSpansSoft(dst,pGC,nSpans,pPoints,pWidths,sorted)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     nSpans;
+    DDXPointPtr pPoints;
+    int     *pWidths;
+    int     sorted;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!nSpans) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegionSpan( pPoints, pWidths, nSpans, &aRect ) ;
+    drawRegion_x = aRect.x;
+    drawRegion_y = aRect.y;
+    aRect.x += dst->x;
+    aRect.y += dst->y;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* draw spans */
+    for( nn = 0 ; nn < nSpans ; nn++ ) {
+        pPoints[nn].x -= drawRegion_x;
+        pPoints[nn].y -= drawRegion_y;
+    }
+    (*pGC1->ops->FillSpans)( (DrawablePtr)dstLop, pGC1, nSpans, pPoints, pWidths, sorted ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+
+void gsxFillSpansGxcpy(dst,pGC,nSpans,pPoints,pWidths,sorted)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     nSpans;
+    DDXPointPtr pPoints;
+    int     *pWidths;
+    int     sorted;
+{
+    doFillSpans( dst, pGC, nSpans, pPoints, pWidths, sorted ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+static void doFillSpans(dst,pGC,nSpans,pPoint,pWidths,sorted)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     nSpans;
+    DDXPointPtr pPoint;
+    int     *pWidths;
+    int     sorted;
+{
+    gsxGCPtr        pPriv = gsxGetGCPriv(pGC);
+    BoxPtr      pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    int         numRects = REGION_NUM_RECTS(pPriv->pCompositeClip);
+    BoxPtr      plast = pbox + REGION_NUM_RECTS(pPriv->pCompositeClip);
+    int xorg = dst->x, yorg = dst->y;
+    DDXPointPtr p = pPoint, pLast = pPoint + nSpans;
+    int rgb, r, g, b, a;
+    int i;
+    int j;
+    GSOSbit64 eop = GSOS_GIF_EOP_CONTINUE;
+    GSOSbit64 oldtex0_1;
+    int result;
+    int nSpansCount;
+    int prim_size2;
+    int pc, sc;
+
+    if (!nSpans) return;
+
+    if( pGC->miTranslate ){  /* not need to tranlate here */
+        xorg = 0 ;
+        yorg = 0 ;
+    }
+
+    gsxFrameInit(dst->pScreen->width, dst->depth);
+
+    /*
+        if fillStyle == FillOpaqueStippled,
+        draw spans with background color at first
+    */
+    rgb = pGC->fgPixel & pPriv->pixelMask ;
+    gsxGetRgba( pGC, rgb, &r, &g, &b, &a ) ;
+
+    pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    numRects = REGION_NUM_RECTS(pPriv->pCompositeClip);
+    while (numRects--) {
+        gsosMakeGiftag(2, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+		       0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD);
+        /* set SCISSOR rect */
+        gsosSetPacketAddrData4( GSOS_SCISSOR_1,
+            (GSOSbit64)pbox->x1, (GSOSbit64)pbox->x2-1, 
+            (GSOSbit64)pbox->y1, (GSOSbit64)pbox->y2-1 );
+        /*
+           draw lines
+           actually we should consider capStyle == CapNotLast
+        */
+        gsosSetPacketAddrData( GSOS_PRIM, GSOS_PRIM_LINE ) ;
+	p = pPoint ;
+	i = 0;
+	nSpansCount = nSpans;
+	while(nSpansCount > 0) {
+	  pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED) / 2;
+	  if(pc == 0) {	/* can't allocate buffer */
+	    gsosExec();		/* flush DMA */
+	    pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED) / 2;
+	  }
+	  sc = (nSpansCount < pc) ? nSpansCount : pc;
+	  result = gsosMakeGiftag(sc * 2, eop, GSOS_GIF_PRE_IGNORE, 0,
+				  GSOS_GIF_FLG_PACKED, 2,
+				  (GSOS_GIF_REG_XYZ2  << 4) |
+				  (GSOS_GIF_REG_RGBAQ << 0));
+	  if(result) break;
+	  for(j = 0; j < sc; j++, i++, p++) {
+	    gsosSetPacket4(r, g, b, a) ;
+	    gsosSetPacket4(GSOS_SUBPIX_OFST(p->x +xorg),
+			   GSOS_SUBPIX_OFST(p->y +yorg), 0, 0);
+
+	    gsosSetPacket4(r, g, b, a) ;
+	    gsosSetPacket4(GSOS_SUBPIX_OFST(p->x + pWidths[i] + xorg),
+			   GSOS_SUBPIX_OFST(p->y + yorg), 0, 0);
+	  }
+	  nSpansCount -= sc;
+	}
+        pbox++;
+    }
+    gsosExec() ;
+
+}
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxgc.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxgc.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxgc.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxgc.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,637 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+#include "font.h"
+#include "servermd.h"
+#include "pixmap.h"
+#include "mi.h"
+#include "cfb.h"
+
+#define GC_FUNC_PROLOGUE(pGC) \
+    gsxGCPtr pGCPriv = (gsxGCPtr)(pGC)->devPrivates[gsxGCIndex].ptr ; \
+    GCOpsPtr oldOps = (pGC)->ops ; \
+    (pGC)->funcs = pGCPriv->funcs ; \
+    if( pGCPriv->mops ) (pGC)->ops = pGCPriv->mops ;
+
+#define GC_FUNC_EPILOGUE(pGC) \
+    pGCPriv->funcs = (pGC)->funcs ; \
+    (pGC)->funcs = &gsxFuncs ; \
+    if( pGCPriv->mops ){ \
+        pGCPriv->mops = (pGC)->ops ; \
+        (pGC)->ops = oldOps ; \
+    }
+
+int gsxGCIndex = 0 ;
+int gsxScreenIndex = 0 ;
+
+
+GCFuncs gsxFuncs = {
+    gsxValidateGC,
+    gsxChangeGC,
+    gsxCopyGC,
+    gsxDestroyGC,
+    gsxChangeClip,
+    gsxDestroyClip,
+    gsxCopyClip
+};
+
+static
+int mopsPolyText8(dst, pGC, x, y, count, chars)
+    DrawablePtr     dst;
+    GCPtr       pGC;
+    int         x, y;
+    int         count;
+    char        *chars;
+{
+    return 
+    (*gsxGetGCPriv(pGC)->mops->PolyText8)(dst, pGC, x, y, count, chars);
+}
+
+static
+void mopsImageText8(dst, pGC, x, y, count, chars)
+    DrawablePtr     dst;
+    GCPtr       pGC;
+    int         x, y;
+    int         count;
+    char        *chars;
+{
+    (*gsxGetGCPriv(pGC)->mops->ImageText8)(dst, pGC, x, y, count, chars);
+}
+
+
+static void mopsFillSpans(dst,pGC,nSpans,pPoints,pWidths,sorted)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		nSpans;
+    xPoint	*pPoints;
+    int		*pWidths;
+    int		sorted;
+{
+    (*gsxGetGCPriv(pGC)->mops->FillSpans)(dst,pGC,nSpans,pPoints,pWidths,sorted);
+}
+
+static void mopsSetSpans(dst,pGC,pSrc,pPoints,pWidths,nSpans,sorted)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    unsigned char *pSrc;
+    xPoint	*pPoints;
+    int		*pWidths;
+    int		nSpans;
+    int		sorted;
+{
+    (*gsxGetGCPriv(pGC)->mops->SetSpans)(dst,pGC,pSrc,pPoints,pWidths,nSpans,sorted);
+}
+
+static void mopsPutImage(dst,pGC,depth,x,y,w,h,leftPad,format,pBinImage)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		depth;
+    int		x, y, w, h;
+    int		leftPad;
+    unsigned int format;
+    char	*pBinImage;
+{
+    (*gsxGetGCPriv(pGC)->mops->PutImage)(dst,pGC,depth,x,y,w,h,leftPad,format,pBinImage);
+}
+
+static void mopsPolyPoint(dst,pGC,mode,n,pPoint)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		mode;
+    int		n;
+    xPoint	*pPoint;
+{
+    (*gsxGetGCPriv(pGC)->mops->PolyPoint)(dst,pGC,mode,n,pPoint);
+}
+
+static void mopsPolylines(dst,pGC,mode,n,pPoint)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		mode;
+    int		n;
+    xPoint	*pPoint;
+{
+    (*gsxGetGCPriv(pGC)->mops->Polylines)(dst,pGC,mode,n,pPoint);
+}
+
+static void mopsPolySegment(dst,pGC,n,pSegments)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		n;
+    xSegment	*pSegments;
+{
+    (*gsxGetGCPriv(pGC)->mops->PolySegment)(dst,pGC,n,pSegments);
+}
+
+static void mopsPolyRectangle(dst,pGC,n,pRect)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		n;
+    xRectangle	*pRect;
+{
+    (*gsxGetGCPriv(pGC)->mops->PolyRectangle)(dst,pGC,n,pRect);
+}
+
+static void mopsPolyArc(dst,pGC,n,pArc)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		n;
+    xArc	*pArc;
+{
+    (*gsxGetGCPriv(pGC)->mops->PolyArc)(dst,pGC,n,pArc);
+}
+
+static void mopsFillPolygon(dst,pGC,shape,mode,count,pPoint)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		shape;
+    int		mode;
+    int		count;
+    xPoint	*pPoint;
+{
+    (*gsxGetGCPriv(pGC)->mops->FillPolygon)(dst,pGC,shape,mode,count,pPoint);
+}
+
+static void mopsPolyFillRect(dst,pGC,n,pRect)
+    DrawablePtr dst;
+    GCPtr       pGC;
+    int         n;
+    xRectangle  *pRect;
+{
+    (*gsxGetGCPriv(pGC)->mops->PolyFillRect)(dst,pGC,n,pRect);
+}
+
+static void mopsPolyFillArc(dst,pGC,n,pArc)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		n;
+    xArc	*pArc;
+{
+    (*gsxGetGCPriv(pGC)->mops->PolyFillArc)(dst,pGC,n,pArc);
+}
+
+static void mopsImageGlyphBlt(dst,pGC,x,y,nglyph,ppci,pglyphBase)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		x;
+    int		y;
+    unsigned int nglyph;
+    CharInfoPtr	*ppci;
+    char	*pglyphBase;
+{
+    (*gsxGetGCPriv(pGC)->mops->ImageGlyphBlt)(dst,pGC,x,y,nglyph,ppci,pglyphBase);
+}
+
+static void mopsPolyGlyphBlt(dst,pGC,x,y,nglyph,ppci,pglyphBase)
+    DrawablePtr	dst;
+    GCPtr	pGC;
+    int		x;
+    int		y;
+    unsigned int nglyph;
+    CharInfoPtr	*ppci;
+    char	*pglyphBase;
+{
+    (*gsxGetGCPriv(pGC)->mops->PolyGlyphBlt)(dst,pGC,x,y,nglyph,ppci,pglyphBase);
+}
+
+static void mopsPushPixels(pGC,pBitMap,dst,dx,dy,xOrg,yOrg)
+    GCPtr	pGC;
+    PixmapPtr	pBitMap;
+    DrawablePtr	dst;
+    int		dx;
+    int		dy;
+    int		xOrg;
+    int		yOrg;
+{
+    (*gsxGetGCPriv(pGC)->mops->PushPixels)(pGC,pBitMap,dst,dx,dy,xOrg,yOrg);
+}
+
+static void gsxLineHelper()
+{
+    FatalError("gsxLineHelper called\n");
+}
+
+GCOps mopsOps = {
+    mopsFillSpans,
+    mopsSetSpans,
+    mopsPutImage,
+    gsxCopyAreaGxcpy,
+    gsxCopyPlaneGxcpy,
+    mopsPolyPoint,
+    mopsPolylines,
+    mopsPolySegment,
+    mopsPolyRectangle,
+    mopsPolyArc,
+    mopsFillPolygon,
+    mopsPolyFillRect,
+    mopsPolyFillArc,
+    mopsPolyText8,
+    miPolyText16,
+    mopsImageText8,
+    miImageText16,
+    mopsImageGlyphBlt,
+    mopsPolyGlyphBlt,
+    mopsPushPixels,
+    gsxLineHelper,
+};
+
+
+GCOps gsxLopOps = {
+    gsxFillSpansSoft,
+    gsxSetSpansSoft,
+    gsxPutImage,
+    gsxCopyAreaLop,
+    gsxCopyPlaneLop,
+    gsxPolyPointSoft,
+    gsxPolyLinesSoft,
+    gsxPolySegmentSoft,
+    gsxPolyRectangleSoft,
+    gsxPolyArcSoft,
+    gsxFillPolygonSoft,
+    gsxPolyFillRectSoft,
+    gsxPolyFillArcSoft,
+    miPolyText8,
+    miPolyText16,
+    miImageText8,
+    miImageText16,
+    gsxImageGlyphBltSoft,
+    gsxPolyGlyphBltSoft,
+    gsxPushPixelsSoft,
+    gsxLineHelper,
+};
+
+
+GCOps gsxGxcpyOps = {
+    gsxFillSpansGxcpy,
+    gsxSetSpansGxcpy,
+    gsxPutImage,
+    gsxCopyAreaGxcpy,
+    gsxCopyPlaneGxcpy,
+    gsxPolyPointGxcpy,
+    gsxPolyLinesSoft,
+    gsxPolySegmentSoft,
+    gsxPolyRectangleGxcpy,
+    gsxPolyArcSoft,
+    gsxFillPolygonSoft,
+    gsxPolyFillRectGxcpy,
+    gsxPolyFillArcSoft,
+    miPolyText8,
+    miPolyText16,
+    miImageText8,
+    miImageText16,
+    gsxImageGlyphBltGxcpy,
+    gsxPolyGlyphBltSoft,
+    gsxPushPixelsSoft,
+    gsxLineHelper,
+};
+
+
+void
+gsxValidateGC(pGC, changes, dst)
+    register GCPtr	pGC;
+    Mask		changes;
+    DrawablePtr		dst;
+{
+    gsxGCPtr		pPriv = gsxGetGCPriv(pGC);
+    Mask		mask, index;
+    Bool		new_patt = FALSE, new_fill = FALSE, new_line = FALSE;
+    Bool		new_lop = FALSE;
+
+    pGC->ops = pPriv->mops;
+    (*pPriv->funcs->ValidateGC)(pGC, changes, dst);
+    pPriv->mops = pGC->ops;
+
+    if (dst->type == DRAWABLE_PIXMAP) {
+        pGC->ops = &mopsOps;
+        pPriv->changes |= changes;
+        return;
+    }
+
+    mask = changes | pPriv->changes;
+    pPriv->changes = 0;
+
+    while (mask) {
+        index = lowbit (mask);
+        mask &= ~index;
+
+        switch (index) {
+        case GCFunction:
+            new_lop = TRUE ;
+            break;
+
+        case GCForeground:
+            break;
+
+        case GCPlaneMask:
+            new_lop = TRUE ;
+            break;
+
+        case GCBackground:
+            break;
+
+        case GCLineWidth:
+            new_line = TRUE;
+            break;
+
+        case GCJoinStyle:
+        case GCCapStyle:
+            break;
+
+        case GCLineStyle:
+            new_line = TRUE;
+            break;
+
+        case GCFillStyle:
+            new_fill = TRUE;
+            if (pGC->fillStyle != FillSolid)
+                new_patt = TRUE;
+            break;
+
+        case GCFillRule:
+            break;
+
+        case GCTile:
+            if (pGC->fillStyle==FillTiled)
+                new_fill = new_patt = TRUE;
+            break;
+
+        case GCStipple:
+            if (pGC->fillStyle==FillStippled
+                || pGC->fillStyle==FillOpaqueStippled)
+                new_fill = new_patt = TRUE;
+            break;
+
+        case GCTileStipXOrigin:
+        case GCTileStipYOrigin:
+            if (pGC->fillStyle != FillSolid)
+                new_patt = TRUE;
+            break;
+
+        case GCFont:
+        case GCSubwindowMode:
+        case GCGraphicsExposures:
+        case GCClipXOrigin:
+        case GCClipYOrigin:
+        case GCClipMask:
+            break;
+
+        case GCDashOffset:
+        case GCDashList:
+            new_line = TRUE;
+            break;
+
+        case GCArcMode:
+        default:
+            break;
+        }
+    }
+
+    if (new_patt) {
+      if (pGC->fillStyle != FillTiled) {
+	pPriv->patW = pGC->stipple->drawable.width;
+	pPriv->patH = pGC->stipple->drawable.height;
+      } else if (pGC->tileIsPixel) {
+	pPriv->patW = 1;
+	pPriv->patH = 1;
+      } else {
+	pPriv->patW = pGC->tile.pixmap->drawable.width;
+	pPriv->patH = pGC->tile.pixmap->drawable.height;
+      }
+      pPriv->patX = pGC->patOrg.x;
+      pPriv->patY = pGC->patOrg.y;
+    }
+
+    if (new_fill) {
+        pPriv->fillStyle = pGC->fillStyle ;
+    }else{
+        pGC->ops = pPriv->wops ;
+    }
+
+    if (new_line || new_fill || new_lop) {
+        if (pGC->ops != &pPriv->ops) {
+            pPriv->ops = *pGC->ops;
+            pGC->ops = &pPriv->ops;
+        }
+
+        *pGC->ops = gsxLopOps ;
+        if( pGC->alu == GXcopy  && pGC->fillStyle == FillSolid){
+
+            *pGC->ops = gsxGxcpyOps ;
+            if( gsxIsPlanemask( pGC ) ){
+	      pGC->ops->CopyArea = gsxCopyAreaLop ;
+                pGC->ops->CopyPlane = gsxCopyPlaneLop ;
+                pGC->ops->ImageGlyphBlt = gsxImageGlyphBltSoft ;
+                pGC->ops->PolyFillRect = gsxPolyFillRectSoft ;
+		/* pGC->ops->PolyRectangle = gsxPolyRectangleGxcpy; */
+            }
+	}
+        if( pGC->alu == GXcopy) {
+            if( pGC->fillStyle == FillSolid
+                    	|| pGC->fillStyle == FillStippled ){
+                pGC->ops->ImageText8 = gsxImageText8Cached ;
+                pGC->ops->PolyText8 = gsxPolyText8Cached ;
+            }
+            if(pGC->lineStyle == LineSolid &&
+	       pGC->fillStyle == FillSolid){
+                if( pGC->lineWidth <= 1 ){
+                    pGC->ops->Polylines = gsxPolyLinesGxcpy ;
+                    pGC->ops->PolySegment = gsxPolySegmentGxcpy ;
+		}
+	    }
+        }
+        pPriv->lineStyle = pGC->lineStyle ;
+
+    }else{    /* if GC is not changed */
+        pGC->ops = pPriv->wops ;
+    }
+#if 0	/* may be feature */
+    gsxFlushGC(pPriv) ;
+#endif
+
+    pPriv->wops = pGC->ops;
+}
+
+static void initPrivateRegisters( pGC )
+    GCPtr pGC ;
+{
+    gsxGCPtr	pPriv = gsxGetGCPriv(pGC);
+    int psm ;
+    unsigned int pixmask ;
+    GSOSulong texbase;
+
+    psm = gsxGetPsmFromBpp( BitsPerPixel(pGC->depth) ) ;
+    switch (BitsPerPixel(pGC->depth)) {
+    case 1:
+        pixmask = 0xff000000;
+        break;
+    case 8:
+        pixmask = 0xff000000;
+        break;
+    case 16:
+        pixmask = 0x80000000;
+        break;
+    case 32:
+        pixmask = 0xff000000;
+        break;
+    default:
+        ErrorF("initPrivateRegisters: illegal bits per pixel\n");
+        return ;
+    }
+
+    /* GSX_TEX0_BASE */
+#if 1
+    texbase = GSX_TEX0_BASE;	/* unused */
+#else
+    texbase = (pGC->pScreen->width * (pGC->depth / 8) *
+	       pGC->pScreen->height + 63) / 64;
+#endif
+
+    pPriv->xyoffset_1 = GsosXyoffsetData( GSOS_XYOFFSET<<4, GSOS_XYOFFSET<<4);
+    pPriv->frame_1 = 
+        GsosFrameData( GSX_FRAME_BASE, (pGC->pScreen->width +63)/64,
+            psm, pixmask ) ;
+    pPriv->zbuf_1 = GsosZbufData( GSX_ZBUF_BASE, 0, 0 ) ;
+    pPriv->prmodecont = GsosPrmodecontData( 0 ) ;
+    pPriv->tex0_1 = 
+        GsosTex0Data(
+        texbase, 1, psm,
+        6, 6,        /* 64x64 */
+        1,           /* RGBA */
+        0,           /* MODULATE */
+        0, 0, 0, 0, 0 ) ;
+    pPriv->tex1_1 = GsosTex1Data( 0, 0, 0, 0, 0, 0, 0 ) ;
+    pPriv->tex2_1 = GsosTex2Data( 0, 0, 0, 0, 0, 0 ) ;
+    pPriv->clamp_1 = GsosClampData( 0, 0, 0, 0, 0, 0 ) ;
+    pPriv->miptbp1_1 = GsosMiptbp1Data( 0, 0, 0, 0, 0, 0 ) ;
+    pPriv->miptbp2_1 = GsosMiptbp2Data( 0, 0, 0, 0, 0, 0 ) ;
+    pPriv->scissor_1 =
+        GsosScissorData( 0, pGC->pScreen->width, 0, pGC->pScreen->height ) ;
+    pPriv->alpha_1 = GsosAlphaData( 0, 0, 0, 0, 0 ) ;
+    /* alpha test enable */
+    pPriv->test_1 = GsosTestData( 1, 1, 0, 0, 0, 0, 0, 0 ) ;
+    pPriv->fba_1 = GsosFbaData( 0 ) ;
+    /* use UV */
+    pPriv->prmode = GsosPrmodeData( 0, 0, 0, 0, 0, 1, 0, 0 ) ;
+    pPriv->texclut = GsosTexclutData( 0, 0, 0 ) ;
+    pPriv->texa = GsosTexaData( 0, 0, 0x80 ) ;
+    pPriv->dimx = GsosDimxData( 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 ) ;
+    pPriv->dthe = GsosDtheData( 0 ) ;
+    pPriv->colclamp = GsosColclampData( 0 ) ;
+    pPriv->pabe = GsosPabeData( 0 ) ;
+
+    gsxFlushGC( pPriv ) ;
+}
+
+Bool
+gsxCreateGC(pGC)
+    register GCPtr	pGC;
+{
+    gsxGCPtr	pPriv = gsxGetGCPriv(pGC);
+
+    switch (BitsPerPixel(pGC->depth)) {
+    case 1:
+        if (! mfbCreateGC(pGC)) return FALSE;
+    case 8:
+        if (! cfbCreateGC(pGC)) return FALSE;
+        break;
+    case 16:
+        if (! cfb16CreateGC(pGC)) return FALSE;
+        break;
+    case 32:
+        if (! cfb32CreateGC(pGC)) return FALSE;
+        break;
+    default:
+        ErrorF("gsxCreteGC: illegal bits per pixel\n");
+        return FALSE;
+    }
+
+    pPriv->pixelMask = (1 << pGC->depth) - 1;
+    if( pGC->depth == 32 ) pPriv->pixelMask = 0xffffffff ;
+    pPriv->changes = 0;
+    pPriv->fillStyle = FillSolid;
+    pPriv->lineStyle = LineSolid;
+
+    pPriv->funcs = pGC->funcs;
+    pPriv->mops = pGC->ops;
+    pPriv->wops = &gsxGxcpyOps;
+
+    pGC->funcs = &gsxFuncs;
+    pGC->ops = pPriv->wops;
+
+    initPrivateRegisters( pGC ) ;
+    gsxSetColormask( pGC, GSX_COLMASK_ASHUT ) ;
+
+    return TRUE;
+}
+
+void gsxChangeGC(pGC,mask)
+    GCPtr	pGC;
+    BITS32	mask;
+{
+    (*gsxGetGCPriv(pGC)->funcs->ChangeGC)(pGC,mask);
+}
+
+void gsxCopyGC(pGC,changes,pGCdst)
+    GCPtr	pGC;
+    Mask	changes;
+    GCPtr	pGCdst;
+{
+    (*gsxGetGCPriv(pGC)->funcs->CopyGC)(pGC,changes,pGCdst);
+}
+
+void gsxDestroyGC(pGC)
+    GCPtr	pGC;
+{
+    GC_FUNC_PROLOGUE( pGC ) ;
+    (*pGC->funcs->DestroyGC)(pGC) ;
+    GC_FUNC_EPILOGUE( pGC ) ;
+}
+
+void gsxChangeClip(pGC,type,pvalues,nrects)
+    GCPtr	pGC;
+    unsigned int type;
+    pointer	pvalues;
+    int		nrects;
+{
+    (*gsxGetGCPriv(pGC)->funcs->ChangeClip)(pGC,type,pvalues,nrects);
+}
+
+void gsxDestroyClip(pGC)
+    GCPtr	pGC;
+{
+    (*gsxGetGCPriv(pGC)->funcs->DestroyClip)(pGC);
+}
+
+void gsxCopyClip(pGC,pGCdst)
+    GCPtr	pGC;
+    GCPtr	pGCdst;
+{
+    (*gsxGetGCPriv(pGC)->funcs->CopyClip)(pGC,pGCdst);
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxglblt.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxglblt.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxglblt.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxglblt.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,288 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+void gsxImageGlyphBltSoft(dst,pGC,x,y,nglyph,ppci,pglyphBase)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     x, y;
+    unsigned int nglyph;
+    CharInfoRec **ppci;
+    pointer pglyphBase;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle backrect ;
+    xRectangle pmrect ;
+    PixmapPtr dstLop ;
+    GCPtr pGC1;
+    int ascent;
+    int dstx, dsty;
+    ExtentInfoRec info;
+    XID gcvals[3];
+    int oldAlu, oldFS;
+    unsigned long oldFG;
+
+    if(!nglyph) return ;
+
+    QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+    if (info.overallWidth >= 0) {
+      backrect.x = x;
+      backrect.width = info.overallWidth;
+    } else {
+      backrect.x = x + info.overallWidth;
+      backrect.width = -info.overallWidth;
+    }
+    ascent = FONTASCENT(pGC->font);
+    backrect.y = y - ascent;
+    backrect.height = ascent + FONTDESCENT(pGC->font);
+
+    /* Pixmap rect */
+    pmrect.x = 0;
+    pmrect.y = 0;
+    pmrect.width = backrect.width;
+    pmrect.height = backrect.height;
+
+    dstx = dst->x;
+    backrect.x += dstx;
+    dsty = dst->y;
+    backrect.y += dsty;
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, pmrect.width, pmrect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* pixmap fill from framebuffer */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(backrect.x, backrect.y, backrect.width, backrect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop) ;
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+#if 0
+    oldAlu = pGC1->alu;
+    oldFG = pGC1->fgPixel;
+    oldFS = pGC1->fillStyle;
+
+    /* fill in the background */
+    gcvals[0] = GXcopy;
+    gcvals[1] = pGC1->bgPixel;
+    gcvals[2] = FillSolid;
+    DoChangeGC(pGC1, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
+    ValidateGC((DrawablePtr)dstLop, pGC1);
+    (*pGC1->ops->PolyFillRect)((DrawablePtr)dstLop, pGC1, 1, &pmrect);
+
+    /* restore fg */
+    gcvals[0] = oldFG;
+    DoChangeGC(pGC1, GCForeground, gcvals, 0);
+    ValidateGC((DrawablePtr)dstLop, pGC1);
+#endif
+
+    /* draw  */
+    (*pGC1->ops->ImageGlyphBlt)( (DrawablePtr)dstLop, pGC1, 
+        0, ascent, nglyph, ppci, pglyphBase ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0,
+	backrect.width, backrect.height,
+        backrect.x - dstx, backrect.y - dsty, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxImageGlyphBltGxcpy(dst,pGC,x,y,nglyph,ppci,pglyphBase)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     x, y;
+    unsigned int nglyph;
+    CharInfoRec **ppci;
+    pointer pglyphBase;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC);
+    GSOSbit64 frame_1;
+    xRectangle backrect;
+    xRectangle pmrect;
+    PixmapPtr dstLop;
+    GCPtr pGC1;
+    int ascent;
+    ExtentInfoRec info;
+    XID gcvals[3];
+    int oldAlu, oldFS;
+    unsigned long oldFG;
+
+    if(!nglyph) return ;
+
+    QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+    if (info.overallWidth >= 0) {
+      backrect.x = x;
+      backrect.width = info.overallWidth;
+    } else {
+      backrect.x = x + info.overallWidth;
+      backrect.width = -info.overallWidth;
+    }
+    ascent = FONTASCENT(pGC->font);
+    backrect.y = y - ascent;
+    backrect.height = ascent + FONTDESCENT(pGC->font);
+
+    /* Pixmap rect */
+    pmrect.x = 0;
+    pmrect.y = 0;
+    pmrect.width = backrect.width;
+    pmrect.height = backrect.height;
+
+    /* */
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, pmrect.width, pmrect.height, dst->depth );
+    if(!dstLop){
+        return ;
+    }
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+#if 0
+    oldAlu = pGC1->alu;
+    oldFG = pGC1->fgPixel;
+    oldFS = pGC1->fillStyle;
+
+    /* fill in the background */
+    gcvals[0] = GXcopy;
+    gcvals[1] = pGC1->bgPixel;
+    gcvals[2] = FillSolid;
+    DoChangeGC(pGC1, GCFunction|GCForeground|GCFillStyle, gcvals, 0);
+    ValidateGC((DrawablePtr)dstLop, pGC1);
+    (*pGC1->ops->PolyFillRect)((DrawablePtr)dstLop, pGC1, 1, &pmrect);
+
+    /* restore fg */
+    gcvals[0] = oldFG;
+    DoChangeGC(pGC1, GCForeground, gcvals, 0);
+    ValidateGC((DrawablePtr)dstLop, pGC1);
+#endif
+
+    /* draw  */
+    (*pGC1->ops->ImageGlyphBlt)((DrawablePtr)dstLop, pGC1, 
+        0, ascent, nglyph, ppci, pglyphBase);
+
+    FreeScratchGC(pGC1);
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0,
+	backrect.width, backrect.height,
+        backrect.x, backrect.y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxPolyGlyphBltSoft(dst,pGC,x,y,nglyph,ppci,pglyphBase)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     x, y;
+    unsigned int nglyph;
+    CharInfoRec **ppci;
+    pointer pglyphBase;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle backrect ;
+    PixmapPtr dstLop ;
+    GCPtr pGC1;
+    int ascent;
+    int dstx, dsty;
+    ExtentInfoRec info;
+
+    if(!nglyph) return ;
+
+    QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+
+    if (info.overallWidth >= 0) {
+      backrect.x = x;
+      backrect.width = info.overallWidth;
+    } else {
+      backrect.x = x + info.overallWidth;
+      backrect.width = -info.overallWidth;
+    }
+    ascent = FONTASCENT(pGC->font);
+    backrect.y = y - ascent;
+    backrect.height = ascent + FONTDESCENT(pGC->font);
+    dstx = dst->x;
+    backrect.x += dstx;
+    dsty = dst->y;
+    backrect.y += dsty;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, backrect.width, backrect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* pixmap fill from framebuffer */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(backrect.x, backrect.y, backrect.width, backrect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop) ;
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* draw  */
+    (*pGC1->ops->PolyGlyphBlt)( (DrawablePtr)dstLop, pGC1, 
+        0, ascent, nglyph, ppci, pglyphBase ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0,
+	backrect.width, backrect.height,
+        backrect.x - dstx, backrect.y - dsty, gsxDoBitBlt, 0 ) ;
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsximage.c XFree86.current/xc/programs/Xserver/hw/gsx/gsximage.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsximage.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsximage.c	Thu Apr 12 12:21:50 2001
@@ -0,0 +1,290 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+#include "servermd.h"
+
+#include "pixmap.h"
+#include "mi.h"
+#include "cfb.h"
+
+static void doSetSpans( DrawablePtr dst, GCPtr pGC, char *pSrc, DDXPointPtr pPoints, int *pWidths, int nSpans, int sortd) ;
+
+void
+gsxGetImage(src, x, y, w, h, format, planeMask, pBinImage)
+    DrawablePtr     src;
+    int         x, y, w, h;
+    unsigned int    format;
+    unsigned long   planeMask;
+    char *pBinImage ;
+{
+    PixmapPtr aPix;
+    unsigned int bp;
+    int bw, psm;
+
+    if (w == 0 || h == 0) return;
+
+    if (src->type == DRAWABLE_PIXMAP) {
+        switch (src->bitsPerPixel) {
+        case 1:
+            mfbGetImage(src,x,y,w,h,format,planeMask,pBinImage);
+            return;
+        case 8:
+            cfbGetImage(src,x,y,w,h,format,planeMask,pBinImage);
+            return;
+        case 16:
+            cfb16GetImage(src,x,y,w,h,format,planeMask,pBinImage);
+            return;
+        case 32:
+            cfb32GetImage(src,x,y,w,h,format,planeMask,pBinImage);
+            return;
+        }
+        return;
+    } else {
+        bp = GSX_FRAME_BASE ;
+        bw = (src->pScreen->width + 63) / 64 ;
+        psm = gsxGetPsmFromBpp(src->bitsPerPixel);
+        /* get pixel data from FB */
+        aPix = (*src->pScreen->CreatePixmap)
+            (src->pScreen, w, h, src->depth ) ;
+        if( aPix == NULL ){
+            return ;
+        }
+	gsxReadImage(x + src->x, y + src->y, w, h, bp, bw, psm, aPix);
+
+        switch (src->bitsPerPixel) {
+        case 1:
+            mfbGetImage(&aPix->drawable,0,0,w,h,format,planeMask,pBinImage);
+            break;
+        case 8:
+            cfbGetImage(&aPix->drawable,0,0,w,h,format,planeMask,pBinImage);
+            break;
+        case 16:
+            cfb16GetImage(&aPix->drawable,0,0,w,h,format,planeMask,pBinImage);
+            break;
+        case 32:
+            cfb32GetImage(&aPix->drawable,0,0,w,h,format,planeMask,pBinImage);
+            break;
+        }
+        (*src->pScreen->DestroyPixmap)( aPix ) ;
+    }
+}
+
+
+void
+gsxGetSpans(src, wMax, ppt, pwidth, nspans, pdstStart)
+    DrawablePtr     src;
+    int         wMax;
+    DDXPointPtr     ppt;
+    int         *pwidth;
+    int         nspans;
+    unsigned long   *pdstStart;
+{
+    DDXPointPtr pptLast = ppt + nspans;
+    int     xorg = src->x, yorg = src->y;
+    GSXuchar    *data;
+    int     depth = src->depth;
+
+    data = (GSXuchar*)pdstStart;
+    while(ppt < pptLast) {
+        (*src->pScreen->GetImage)
+            (src, ppt->x-xorg, ppt->y-yorg, *pwidth, 1, 
+            ZPixmap, 0xffffffff, data );
+        data += PixmapBytePad(*pwidth,depth);
+        ppt++;
+        pwidth++;
+    }
+}
+
+
+void gsxSetSpansSoft(dst, pGC, pSrc, pPoints, pWidths, nSpans, sorted)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    char *pSrc;
+    DDXPointPtr pPoints;
+    int     *pWidths;
+    int     nSpans;
+    int     sorted;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+
+    if(!nSpans) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegionSpan( pPoints, pWidths, nSpans, &aRect ) ;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* draw lines */
+    for( nn = 0 ; nn < nSpans ; nn++ ) {
+        pPoints[nn].x -= (aRect.x -dst->x) ;
+        pPoints[nn].y -= (aRect.y -dst->y) ;
+    }
+    (*pGC1->ops->SetSpans)( (DrawablePtr)dstLop, pGC1, pSrc, pPoints, pWidths, nSpans, sorted ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        aRect.x-dst->x, aRect.y-dst->y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxSetSpansGxcpy(dst, pGC, pSrc, pPoints, pWidths, nSpans, sorted)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    char *pSrc;
+    DDXPointPtr pPoints;
+    int     *pWidths;
+    int     nSpans;
+    int     sorted;
+{
+    doSetSpans( dst, pGC, pSrc, pPoints, pWidths, nSpans, sorted ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+static void doSetSpans(dst, pGC, pSrc, pPoints, pWidths, nSpans, sorted)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    char *pSrc;
+    DDXPointPtr pPoints;
+    int     *pWidths;
+    int     nSpans;
+    int     sorted;
+{
+    gsxGCPtr     pPriv = gsxGetGCPriv(pGC);
+    BoxPtr       pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    BoxPtr       plast = pbox + REGION_NUM_RECTS(pPriv->pCompositeClip);
+    DDXPointPtr  p = pPoints, pLast = pPoints + nSpans;
+    int          i, ps, pw ;
+    GSXuchar     *pDat, *pd ;
+    GSOSbit64    frame_1 ;
+    unsigned int fbp ;
+    int          fbw, psm ;
+
+    if (!nSpans) return;
+
+    frame_1 = pPriv->frame_1 ;
+    fbp = GsosFrameFbp( frame_1 ) ;
+    fbw = GsosFrameFbw( frame_1 ) ;
+    psm = GsosFramePsm( frame_1 ) ;
+    while (pbox < plast) {
+        i = 0 ;
+        pDat = pSrc ;
+        p = pPoints ;
+        while( p < pLast ){
+            if( p->y >= pbox->y1 && p->y <= pbox->y2 ){
+                ps = p->x ;
+                pw = pWidths[i] ;
+                pd = pDat ;
+                if( p->x < pbox->x1 ){
+                    ps = pbox->x1 ;
+                    pw -= pbox->x1 - p->x ;
+                    pd += PixmapBytePad( pbox->x1 - p->x, pGC->depth ) ;
+                }
+                if( p->x + pWidths[i] - 1 > pbox->x2 ){
+                    pw -= p->x + pWidths[i] - pbox->x2 ;
+                }
+                if( pw > 0 ){
+                    gsosWriteImage( ps, p->y, pw, 1, fbp, fbw, psm, pd ) ;
+                }
+            }
+            pDat += PixmapBytePad( pWidths[i], pGC->depth ) ;
+            i++;
+            p++;
+        }
+        pbox++;
+    }
+
+}
+
+void gsxPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage)
+    DrawablePtr pDraw;
+    GCPtr	pGC;
+    int		depth, x, y, w, h;
+    int		leftPad;
+    int		format;
+    char 	*pImage;
+{
+    int		bitsPerPixel;
+    PixmapPtr   pPixmap;
+
+    if ((w == 0) || (h == 0))
+	return;
+
+    if (format != XYPixmap)
+    {
+	pPixmap = GetScratchPixmapHeader(pDraw->pScreen, w+leftPad, h, depth,
+		      BitsPerPixel(depth), PixmapBytePad(w+leftPad, depth),
+		      (pointer)pImage);
+	if (!pPixmap)
+	    return;
+	
+        if (format == ZPixmap)
+            (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC,
+					leftPad, 0, w, h, x, y);
+	else
+	    (void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, pDraw, pGC,
+					 leftPad, 0, w, h, x, y, 1);
+        FreeScratchPixmapHeader(pPixmap);
+    }
+    else
+    {
+	miPutImage(pDraw, pGC, depth, x, y, w, h, leftPad, format, pImage);
+    }
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxinit.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxinit.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxinit.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxinit.c	Fri Mar 30 15:45:44 2001
@@ -0,0 +1,761 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+#include "common/xf86.h"
+#include "common/xf86Procs.h"
+#include "common/xf86_OSproc.h"
+#include "common/xf86_OSlib.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#include <linux/ps2/gs.h>
+
+int gsxScreenIndex; // reference from gsxGetScreenPtr(s) in gsx.h
+unsigned long gsxGeneration = 0;
+
+extern int monitorResolution;
+
+
+#include <X11/XWDFile.h>
+
+#define VFB_DEFAULT_INDEX 2
+#define VFB_DEFAULT_DEPTH  24
+
+#define VFB_DEFAULT_WHITEPIXEL 0
+#define VFB_DEFAULT_BLACKPIXEL 1
+#define VFB_DEFAULT_LINEBIAS 0
+#define XWD_WINDOW_NAME_LEN 60
+
+#define DEFAULT_ALPHA ((int)(0.35f * 255.0f))
+
+#define TV_MERGIN_X(x) ((x/20) > 31 ? 31 : (x/20))
+#define TV_MERGIN_Y(y) (y/20)
+
+#define DTV_MERGIN_X(x) ((x/20) > 31 ? 31 : (x/20))
+#define DTV_MERGIN_Y(y) (y/20)
+
+
+typedef struct
+{
+    int scrnum;
+    int width;
+    int paddedWidth;
+    int height;
+    int depth;
+    int bitsPerPixel;
+    int sizeInBytes;
+    int ncolors;
+    char *pfbMemory;
+    XWDColor *pXWDCmap;
+    XWDFileHeader *pXWDHeader;
+    Pixel blackPixel;
+    Pixel whitePixel;
+    unsigned int lineBias;
+    int framerate;
+    int res;
+    int mode;
+    int interlace;
+    int alpha;
+    int dx,dy;
+
+} gsxScreenInfo, *gsxScreenInfoPtr;
+
+static int gsxNumScreens;
+static gsxScreenInfo gsxScreens[MAXSCREENS];
+static Bool gsxPixmapDepths[33];
+
+struct vesa_restab {
+  int w;
+  int h;
+  int res;
+};
+
+static struct vesa_restab restab[]={
+    { 640, 480, PS2_GS_640x480},
+    { 800, 600, PS2_GS_800x600},
+    {1024, 768, PS2_GS_1024x768},
+    {1280, 1024,PS2_GS_1280x1024}
+};
+
+int checkResolution(int width, int height)
+{
+  int i;
+  for(i = 0; i < sizeof(restab) / sizeof(struct vesa_restab); i++) {
+    if(restab[i].w == width &&
+       restab[i].h == height) {
+      return restab[i].res;
+    }
+  }
+  return -1;
+}
+
+void SetGSXFrameRate(int scrn, int framerate)
+{
+ if(scrn < 0 || scrn >= gsxNumScreens) {
+    return;
+  }
+  if(framerate != 60) {
+    framerate = 75;
+  }
+  if(gsxScreens[scrn].framerate <= 0) {
+    gsxScreens[scrn].framerate = 
+    	(framerate == 75) ? PS2_GS_75Hz : PS2_GS_60Hz;
+  }
+}
+
+void SetGSXScreen(int scrn, int width, int height, int depth)
+{
+  if(scrn < 0 || scrn >= gsxNumScreens) {
+    return;
+  }
+  gsxScreens[scrn].width  = width;
+  gsxScreens[scrn].height = height;
+  gsxScreens[scrn].depth  = depth;
+  gsxScreens[scrn].res    = checkResolution (width, height);
+}
+
+static void
+gsxInitializePixmapDepths()
+{
+    int i;
+    gsxPixmapDepths[1] = TRUE; /* always need bitmaps */
+    for (i = 2; i <= 32; i++)
+	gsxPixmapDepths[i] = FALSE;
+}
+
+static void
+gsxInitializeDefaultScreens()
+{
+    int i;
+
+    for (i = 0; i < MAXSCREENS; i++)
+    {
+	gsxScreens[i].scrnum = i;
+	gsxScreens[i].mode = PS2_GS_VESA;
+	gsxScreens[i].width  = restab[VFB_DEFAULT_INDEX].w;
+	gsxScreens[i].height = restab[VFB_DEFAULT_INDEX].h;
+	gsxScreens[i].res =  restab[VFB_DEFAULT_INDEX].res;
+
+	gsxScreens[i].depth  = VFB_DEFAULT_DEPTH;
+	gsxScreens[i].blackPixel = VFB_DEFAULT_BLACKPIXEL;
+	gsxScreens[i].whitePixel = VFB_DEFAULT_WHITEPIXEL;
+	gsxScreens[i].lineBias = VFB_DEFAULT_LINEBIAS;
+	gsxScreens[i].pfbMemory = NULL;
+	gsxScreens[i].framerate = -1;
+	gsxScreens[i].alpha = DEFAULT_ALPHA;
+	gsxScreens[i].dx =0;
+	gsxScreens[i].dy =0;
+	gsxScreens[i].interlace  = 0;
+    }
+    gsxNumScreens = 1;
+}
+
+static int
+gsxBitsPerPixel(depth)
+    int depth;
+{
+    if (depth == 1) return 1;
+    else if (depth <= 8) return 8;
+    else if (depth <= 16) return 16;
+    else return 32;
+}
+
+void
+ddxGiveUp()
+{
+    xf86CloseConsole() ;
+    gsosClose() ;
+}
+
+void
+AbortDDX()
+{
+    ddxGiveUp();
+}
+
+void
+OsVendorInit()
+{
+}
+
+void
+OsVendorFatalError()
+{
+}
+
+void
+ddxUseMsg()
+{
+  ErrorF("\n");
+  ErrorF("\n");
+  ErrorF("Device Dependent Usage\n");
+  ErrorF("-screen n [VESA,]WxHxD  set VESA screen's width, height, depth\n");
+  ErrorF("-screen n NTSC[,xD][,inter|,nointer]\n\
+  	set NTSC screen's config\n");
+  ErrorF("-screen n PAL[,xD][,inter|,nointer]\n\
+  	set PAL screen's config\n");
+  ErrorF("-screen n DTV[,xD][,480p|,720p|1080i\n\
+	set DTV screen's config.\n");
+  ErrorF("-interlace-mix [0-100]   set odd-even line mixing raito (default:35).\n");
+  if (getuid() == 0) {
+    ErrorF("-xgsconfig file        specify a configuration file\n");
+  }
+#if 0
+  ErrorF("-linebias n            adjust thin line pixelization\n");
+#endif
+  ErrorF("-blackpixel n          pixel value for black\n");
+  ErrorF("-whitepixel n          pixel value for white\n");
+  ErrorF("-framerate n           set frame-rate in Hz (n: 60, 75)\n");
+}
+
+
+static int 
+get_dtv_params (char *p, int *width, int *height, 
+		int *depth, int *res)
+{
+	/* [xD][,480p|,720p|,1080i] */
+	int cnt, r;
+	char *q, c;
+
+	r = 480;
+	c = 'p';
+	*depth = 24;
+	if (!p) goto out;
+
+	*depth = -1;
+
+	p ++;
+	if (*p=='x') {
+	    p++;
+	    *depth = strtol(p, &q, 10);
+	    if (p != q ) {
+	      if (*depth != 24 && *depth != 16)
+	        return -1;
+	      p = q;
+	      if (!*p) goto out;
+	      if (*p != ',') return -1;
+	    }
+	    p++;
+	}
+        cnt = sscanf(p, "%d%c", &r, &c);
+	if (cnt != 2 ) {
+	      return -1;
+	}  
+    out:
+	if (c!='p' && c!='i') return -1;
+	switch (r) {
+	  case 480:
+	    if (c!='p') return -1;
+	    *res = PS2_GS_480P;
+	    *width = 720; *height = 480; 
+	    if (*depth == -1) *depth=24;
+	    break;
+	  case 720:
+	    if (c!='p') return -1;
+	    *res = PS2_GS_720P;
+	    *width = 1024; *height = 720; 
+	    if (*depth == -1) *depth=24;
+	    break;
+	  case 1080:
+	    if (c!='i') return -1;
+	    *res = PS2_GS_1080I;
+ 	    *width = 1920; *height = 1080; 
+	    if (*depth == -1) *depth=16;
+	    if (*depth != 16) return -1;
+	    break;
+	}
+	return 0;
+}
+
+static int 
+get_tv_params (int mode, char *p, int *width, int *height, 
+		int *depth, int *interlace)
+{
+	/* [xD,][nointer|inter] */
+	int cnt;
+	char *q;
+
+	*interlace = PS2_GS_INTERLACE;
+	*depth = 24;
+	if (!p) goto out;
+
+	p ++;
+	if (*p=='x') {
+	    p++;
+	    *depth = strtol(p, &q, 10);
+	    if (p != q) {
+	      if (*depth != 24 && *depth != 16)
+	        return -1;
+	      p = q;
+	      if (!*p) goto out;
+	      if (*p != ',') return -1;
+	    }
+	    p++;
+	}
+
+	if (tolower(*p) == 'n' ) {
+	  *interlace = PS2_GS_NOINTERLACE;
+	} else if (tolower(*p) !='i' ) {
+	  return -1;
+	}
+
+out:
+	*width = 640;
+	*height = (mode == PS2_GS_NTSC) ? 448 : 512;
+
+	if (*interlace == PS2_GS_NOINTERLACE) {
+	  *height /= 2;
+	}
+	return 0;
+}
+
+static 
+int get_vesa_params( char *p, 
+	int *width, int *height, int *depth, int *framerate, int *res)
+{
+	int cnt;
+	int fr;
+	/* WxHxD[,fr] */
+
+	fr = 60;
+	cnt = sscanf(p, "%dx%dx%d,%d", 
+		width, height, depth, &fr);
+	if ( cnt==4 && (fr!=60 && fr!=75) ) {
+	  return -1;
+	} else if ( cnt <= 0 ) {
+	  cnt = sscanf(p, "%dx%dx%d", width, height, depth);
+	  if (cnt != 3)
+	    return -1;
+	}
+	*framerate = fr==75 ? PS2_GS_75Hz : PS2_GS_60Hz;
+	*res = checkResolution(*width, *height);
+	if(*res<0) {
+	  return -1;
+	}
+	switch(*depth) {
+	case 16:
+	  break;
+	case 24:
+	  if(*width != 1280)
+	    break;
+	  /* fall throught */
+	default:
+	  return -1;
+	}
+	return 0;
+}
+
+static int lastScreen = -1;
+int
+ddxProcessArgument (argc, argv, i)
+    int argc;
+    char *argv[];
+    int i;
+{
+    static Bool firstTime = TRUE;
+
+    if (firstTime)
+    {
+	gsxInitializeDefaultScreens();
+	gsxInitializePixmapDepths();
+        firstTime = FALSE;
+    }
+
+    if(getuid() == 0 && strcmp(argv[i], "-xgsconfig") == 0) {
+      if(!argv[i+1]) {
+	return 0;
+      }
+      if(strlen(argv[i+1]) >= PATH_MAX) {
+	FatalError("XGSConfig path name too long\n");
+      }
+      strcpy(xf86ConfigFile, argv[i+1]);
+      ErrorF("xf86ConfigFile=%s\n", xf86ConfigFile);
+      return 2;
+    }
+
+
+    if (strcmp (argv[i], "-screen") == 0)	/* -screen n WxHxD */
+    {
+	int screenNum;
+	int width, height, depth;
+	int framerate;
+	int interlace=0;
+	int res=0;
+	int mode;
+	char *p;
+	int dx,dy;
+
+	dx=dy=0;
+
+	if (i + 2 >= argc) {
+	  UseMsg();
+	  exit(1);
+	}
+
+	/* screen number */
+	if(!isdigit(*argv[i+1])) {
+	    ErrorF("Invalid screen number %s\n", argv[i+1]);
+	    UseMsg();
+	    exit(1);
+	}
+	screenNum = atoi(argv[i+1]);
+	if (screenNum < 0 || screenNum >= MAXSCREENS) {
+	    ErrorF("Invalid screen number %d\n", screenNum);
+	    UseMsg();
+	    exit(1);
+	}
+
+	p = argv[i+2];
+
+	mode = ~PS2_GS_NTSC;
+	switch (tolower(*p)) {
+	  
+	  case 'n':
+	    /* NTSC */
+	    mode = PS2_GS_NTSC;
+	    /* fallthrough */
+	  case 'p':
+	    /* PAL */
+	    if (mode != PS2_GS_NTSC)
+	      mode = PS2_GS_PAL;
+	    p = strchr(p,',');
+	    if (get_tv_params (mode, p, &width, &height, 
+				&depth, &interlace)<0)
+	      goto errout;
+
+	    dx = TV_MERGIN_X(width);
+	    dy = TV_MERGIN_Y(height);
+	    width -= 2*dx;
+	    height -= 2*dy;
+	    break;
+
+	  case 'd':
+	    /* DTV */
+	    mode = PS2_GS_DTV;
+	    p = strchr(p,',');
+	    if (get_dtv_params (p, &width, &height, 
+				&depth, &res)<0)
+	      goto errout;
+
+	    dx = TV_MERGIN_X(width);
+	    dy = TV_MERGIN_Y(height);
+	    width -= 2*dx;
+	    height -= 2*dy;
+	    break;
+
+	  default:
+	    if ( !isdigit(*p) && (tolower(*p) != 'v') ) {
+	errout:
+	      ErrorF("Invalid screen configuration %s\n", argv[i+2]);
+	      UseMsg();
+	      exit(1);
+	    }
+	    /* VESA */
+	    if (tolower(*p) == 'v') {
+	      p = strchr(p,',');
+	      if (!p) goto errout;
+	      p++;
+	    }
+	    mode = PS2_GS_VESA;
+	    if (get_vesa_params (p, &width, &height, 
+					&depth, &framerate, &res)<0)
+	      goto errout;
+	}
+
+	gsxScreens[screenNum].width  = width;
+	gsxScreens[screenNum].height = height;
+	gsxScreens[screenNum].depth  = depth;
+	gsxScreens[screenNum].framerate = framerate;
+	gsxScreens[screenNum].res  = res;
+	gsxScreens[screenNum].mode  = mode;
+	gsxScreens[screenNum].interlace  = interlace;
+	gsxScreens[screenNum].dx  = dx;
+	gsxScreens[screenNum].dy  = dy;
+	xf86bpp = depth;
+
+	if (screenNum >= gsxNumScreens)
+	    gsxNumScreens = screenNum + 1;
+	lastScreen = screenNum;
+
+	return 3;
+    }
+    if (strcmp (argv[i], "-interlace-mix") == 0)	
+    				/* -interlace-mix n [0-100] */
+    {
+      unsigned int alpha;
+      if (++i >= argc) UseMsg();
+      alpha = atoi(argv[i]);
+      if (alpha > 100) {
+	    UseMsg();
+	    exit(1);
+      }
+      alpha  = (int) (alpha * 1.0f /100.0f * 255.0f);
+      if (-1 == lastScreen)
+	{
+	    int i;
+	    for (i = 0; i < MAXSCREENS; i++)
+	    {
+		gsxScreens[i].alpha = alpha;
+	    }
+	}
+      else
+	{
+	    gsxScreens[lastScreen].alpha = alpha;
+	}
+      return 2;
+    }
+    if (strcmp (argv[i], "-blackpixel") == 0)	/* -blackpixel n */
+    {
+	Pixel pix;
+	if (++i >= argc) UseMsg();
+	pix = atoi(argv[i]);
+	if (-1 == lastScreen)
+	{
+	    int i;
+	    for (i = 0; i < MAXSCREENS; i++)
+	    {
+		gsxScreens[i].blackPixel = pix;
+	    }
+	}
+	else
+	{
+	    gsxScreens[lastScreen].blackPixel = pix;
+	}
+	return 2;
+    }
+
+    if (strcmp (argv[i], "-whitepixel") == 0)	/* -whitepixel n */
+    {
+	Pixel pix;
+	if (++i >= argc) UseMsg();
+	pix = atoi(argv[i]);
+	if (-1 == lastScreen)
+	{
+	    int i;
+	    for (i = 0; i < MAXSCREENS; i++)
+	    {
+		gsxScreens[i].whitePixel = pix;
+	    }
+	}
+	else
+	{
+	    gsxScreens[lastScreen].whitePixel = pix;
+	}
+	return 2;
+    }
+#if 0
+    if (strcmp (argv[i], "-linebias") == 0)	/* -linebias n */
+    {
+	unsigned int linebias;
+	if (++i >= argc) UseMsg();
+	linebias = atoi(argv[i]);
+	if (-1 == lastScreen)
+	{
+	    int i;
+	    for (i = 0; i < MAXSCREENS; i++)
+	    {
+		gsxScreens[i].lineBias = linebias;
+	    }
+	}
+	else
+	{
+	    gsxScreens[lastScreen].lineBias = linebias;
+	}
+	return 2;
+    }
+#endif
+    if (strcmp (argv[i], "-framerate") == 0)	/* -framerate n */
+    {
+	unsigned int framerate;
+	if (++i >= argc) UseMsg();
+	framerate = atoi(argv[i]);
+	if ( framerate != 60 && framerate != 75 )
+	{
+	    UseMsg();
+	}
+	else if (-1 == lastScreen)
+	{
+	    int i;
+	    for (i = 0; i < MAXSCREENS; i++)
+	    {
+		gsxScreens[i].framerate = framerate;
+	    }
+	}
+	else
+	{
+	    gsxScreens[lastScreen].framerate = framerate;
+	}
+	return 2;
+    }
+
+    return 0;
+}
+
+
+static Bool gsxProbe()
+{
+    return TRUE ;
+}
+
+static Bool gsxServerReset()
+{
+    gsxScreenIndex= AllocateScreenPrivateIndex();
+    if (gsxScreenIndex < 0)
+        return FALSE;
+#if GSX_BLOCK_FLUSH
+    if (!RegisterBlockAndWakeupHandlers(xf86Block,xf86Wakeup,NULL))
+        return FALSE;
+#endif
+    return TRUE;
+}
+
+
+static Bool gsxScreenPrivateInit(int scrIndex, ScreenPtr pScreen )
+{
+    gsxScreenPtr pScreenPriv = gsxGetScreenPriv(pScreen);
+    // initialize ScreenPrivate
+
+    // Get width & height from device
+    pScreenPriv->width  = gsxScreens[scrIndex].width;
+    pScreenPriv->height = gsxScreens[scrIndex].height;
+    // Set Black & White pixel
+    pScreenPriv->blackPixel = gsxScreens[scrIndex].blackPixel;
+    pScreenPriv->whitePixel = gsxScreens[scrIndex].whitePixel;
+
+    //
+    pScreenPriv->framerate = gsxScreens[scrIndex].framerate;
+    pScreenPriv->depth = gsxScreens[scrIndex].depth;
+    //
+    pScreenPriv->mode = gsxScreens[scrIndex].mode;
+    pScreenPriv->res = gsxScreens[scrIndex].res;
+    pScreenPriv->interlace = gsxScreens[scrIndex].interlace;
+    pScreenPriv->alpha = gsxScreens[scrIndex].alpha;
+
+    //
+    pScreenPriv->dx = gsxScreens[scrIndex].dx;
+    pScreenPriv->dy = gsxScreens[scrIndex].dy;
+    //
+
+    return TRUE;
+}
+
+
+static Bool gsxInit(int index, ScreenPtr pScreen, int argc, char **argv)
+{
+    gsxScreenPtr pScreenPriv;
+
+    // open GS
+    if (0 != gsosOpen()) {
+        ErrorF("gsxInit: gsosOpen failed\n");
+        return FALSE;
+    }
+
+    // allocation of gsxScreen private
+    pScreenPriv = (gsxScreenPtr)xalloc(sizeof(gsxScreenPrivate));
+    if (0 != pScreenPriv) {
+        pScreen->devPrivates[gsxScreenIndex].ptr = (pointer)pScreenPriv;
+
+        // Initialize ScreenPrivate
+        if (TRUE == gsxScreenPrivateInit(index,pScreen)) {
+
+            if (TRUE == gsxScreenInit(pScreen,monitorResolution)) {
+                return TRUE;
+       	    }
+            // fail in gsxScreenInit
+        }
+        // fail to initialize screen
+        xfree(pScreenPriv);
+    }
+
+    // close GS (fail to alloc or initialize screen)
+    gsosClose();
+
+    return FALSE;
+}
+
+void InitOutput(pScreenInfo, argc, argv)
+    ScreenInfo 	  *pScreenInfo;
+    int     	  argc;
+    char    	  **argv;
+{
+    int i;
+    int NumFormats = 0;
+
+    if (serverGeneration == 1) {
+        gsxProbe();
+    }
+    xf86Config(TRUE) ;
+    xf86OpenConsole() ;
+
+#ifdef XKB
+    xf86InitXkb();
+#endif
+
+    if (!monitorResolution)
+	monitorResolution = 100;
+
+    /* must have a pixmap depth to match every screen depth */
+    for (i = 0; i < gsxNumScreens; i++)
+    {
+	gsxPixmapDepths[gsxScreens[i].depth] = TRUE;
+    }
+
+    for (i = 1; i <= 32; i++)
+    {
+	if (gsxPixmapDepths[i])
+	{
+	    if (NumFormats >= MAXFORMATS)
+		FatalError ("MAXFORMATS is too small for this server\n");
+	    pScreenInfo->formats[NumFormats].depth = i;
+	    pScreenInfo->formats[NumFormats].bitsPerPixel = gsxBitsPerPixel(i);
+	    pScreenInfo->formats[NumFormats].scanlinePad = BITMAP_SCANLINE_PAD;
+	    NumFormats++;
+	}
+    }
+
+    pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+    pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+    pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+    pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+    pScreenInfo->numPixmapFormats = NumFormats;
+
+    // Reset serer
+    if (gsxGeneration != serverGeneration) {
+        gsxGeneration = serverGeneration;
+        gsxServerReset();
+    }
+
+    for (i = 0; i < gsxNumScreens; i++) {
+        if (-1 == AddScreen(gsxInit, argc, argv)) {
+            FatalError("Couldn't add screen %d", i);
+        }
+    }
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxlop.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxlop.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxlop.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxlop.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,410 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+#include "cfb.h"
+
+static void doLop16( GSXuchar *ps, GSXuchar *pd, int n, GSXuchar alu, GSXulong planemask ) ;
+static void doLop32( GSXuchar *ps, GSXuchar *pd, int n, GSXuchar alu, GSXulong planemask ) ;
+
+/*
+    gsxPreLop
+
+    - read destination data for LOP from FB
+    - clear Drawable alpha
+    - FBA_1.FBA = 1
+*/
+void gsxPreLop( pGC, pDraw, pRect, dstLop )
+    GCPtr pGC ;
+    DrawablePtr pDraw ;
+    xRectangle *pRect ; /* Regtion to get (screen relative) */
+    PixmapPtr dstLop ;  /* destinatoin data for LOP from FB */
+{
+    int x, y, w, h ;
+    GSOSbit64 frame_1 ;
+
+    x = pRect->x ;
+    y = pRect->y ;
+    w = pRect->width ;
+    h = pRect->height ;
+    frame_1 = gsxGetGCPriv(pGC)->frame_1 ;
+
+    /* get destinaton data for LOP from FB */
+    if( pDraw->type == DRAWABLE_WINDOW ){
+        gsxReadImage(x, y, w, h, 
+            GsosFrameFbp( frame_1 ),
+            GsosFrameFbw( frame_1 ),
+            GsosFramePsm( frame_1 ),
+            dstLop);
+    }else{
+        (*gsxGetGCPriv(pGC)->mops->CopyArea)
+            ( pDraw, (DrawablePtr)dstLop, pGC, x, y, w, h, 0, 0 ) ;
+    }
+
+}
+
+/*
+    gsxPostLopCopy:     post proccess for LOP. used by CopyArea, CopyPlane
+    
+    - do LOP
+    - FBA_1.FBA = 0
+    - write result pixels toward FB
+*/
+void gsxPostLopCopy( pGC, pDraw, pRect, dstLop, pSrc, srcx, srcy, pRegionDst )
+    GCPtr pGC ;
+    DrawablePtr pDraw ;
+    xRectangle *pRect ; /* Regtion to get (screen relative) */
+    PixmapPtr dstLop ;  /* destinatoin data for LOP from FB */
+    DrawablePtr pSrc ;  /* source data for LOP */
+    int srcx, srcy ;
+    RegionPtr pRegionDst ; /* clip region not to do LOP */
+{
+    int x, y, w, h;
+    PixmapPtr srcLop;
+    GSXuchar *ps, *pd;
+    int n;
+    BoxPtr pbox;
+    BoxRec abox;
+    int nbox;
+    int pt, dw, dh;
+    GSOSbit64 frame_1;
+    unsigned int fbp;
+    int fbw, psm;
+    int i, loop;
+    int srcLopf;
+
+    x = pRect->x ;
+    y = pRect->y ;
+    w = pRect->width ;
+    h = pRect->height ;
+    frame_1 = gsxGetGCPriv(pGC)->frame_1 ;
+    fbp = GsosFrameFbp( frame_1 ) ;
+    fbw = GsosFrameFbw( frame_1 ) ;
+    psm = GsosFramePsm( frame_1 ) ;
+    /* suppose pbox is relative to screen */
+    if( pRegionDst == NULL ){
+        pbox = NULL ;
+        nbox = 0 ;
+    }else{
+        pbox = REGION_RECTS( pRegionDst ) ;
+        nbox = REGION_NUM_RECTS( pRegionDst ) ;
+    }
+
+    /* get source data for LOP from FB */
+    if( pSrc->type == DRAWABLE_WINDOW ){
+      srcLop = (*pDraw->pScreen->CreatePixmap)
+        (pDraw->pScreen, w, h, pDraw->depth ) ;
+      if( !srcLop ){
+	ErrorF("gsxPostLopCopy: CreatePixmap Error\n");
+        return ;
+      }
+      gsxReadImage(srcx, srcy, w, h, fbp, fbw, psm, srcLop);
+      srcLopf = TRUE;
+    }else{
+      srcLop = pSrc;
+      srcLopf = FALSE;
+    }
+    /*
+        Do Logical Operation
+          - for the rest regions of pRegionDst
+          - for each pixel which alpha of SRC is 0x1
+          - using SRC's alpha
+          
+        algorithm:
+          - copy DST to aPix
+          - copy all from SRC to DST with LOP
+          - copy dstRegion from aPix to DST
+    */
+    ps = ((PixmapPtr)srcLop)->devPrivate.ptr ;
+    pd = ((PixmapPtr)dstLop)->devPrivate.ptr ;
+    n = dstLop->devKind * h ;
+
+    if( BitsPerPixel(pGC->depth) == 16 ){
+        if( gsxIsPlanemask(pGC)) {
+            doLop16( ps, pd, n, pGC->alu, pGC->planemask) ;
+        }else{
+            doLop16( ps, pd, n, pGC->alu, 0xffff ) ;
+        }
+    }else{
+        if( gsxIsPlanemask(pGC)) {
+            doLop32( ps, pd, n, pGC->alu, pGC->planemask ) ;
+        }else{
+            doLop32( ps, pd, n, pGC->alu, 0xffffffff ) ;
+        }
+    }
+
+#if 0
+    /* Set alpha that is drawn to FB */
+    gsxSetFBA( pGC, GSX_FBA_VALUE0 ) ;
+#endif
+
+    /* Write result pixels toward FB */
+    if( pDraw->type == DRAWABLE_WINDOW ){
+        gsosWriteImage( x, y, w, h, fbp, fbw, psm, dstLop->devPrivate.ptr ) ;
+    }else{
+        (*gsxGetGCPriv(pGC)->mops->CopyArea)
+            ( (DrawablePtr)dstLop, pDraw, pGC, 0, 0, w, h, x, y ) ;
+    }
+    if(srcLopf) {
+      (*pDraw->pScreen->DestroyPixmap)( srcLop );
+    }
+}
+
+/*
+     do logical operation
+*/
+static void doLop32(ps, pd, n, alu, planemask)
+    GSXuchar *ps, *pd;		/* src and dst buffer */
+    int      n;			/* num of buffers */
+    GSXuchar alu;
+    GSXulong planemask;
+{
+    GSXulong amsk;
+    GSXulong *psl, *pdl;
+    GSXulong pm;
+    int      loop;
+
+    psl = (GSXulong *)ps;
+    pdl = (GSXulong *)pd;
+    amsk = (GSXulong)0xff000000;
+    pm = (GSXulong)planemask & ~amsk;
+    loop = n / 4 ;		/* uchar(8bit) -> ulong(32bit) */
+
+    switch(alu){
+    case GXclear:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (0 & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXand:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (*psl & *pdl & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXandReverse:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (*psl & ~(*pdl) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXandInverted:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (~(*psl) & *pdl & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXnoop:
+        break;
+    case GXxor:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | ((*psl ^ *pdl) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXor:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | ((*psl | *pdl) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXnor:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | ((~(*psl) & ~(*pdl)) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXequiv:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | ((~(*psl) ^ (*pdl)) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXinvert:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (~(*pdl) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXorReverse:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | ((*psl | ~(*pdl)) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXcopyInverted:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (~(*psl) & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXorInverted:
+        while(loop > 0) {
+            *pdl = (*(pdl)&~pm) | ((~(*psl)|(*pdl)) &pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXnand:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | ((~(*psl) | ~(*pdl)) &pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    case GXset:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (0xffffffff & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    default:
+    case GXcopy:
+        while(loop > 0) {
+            *pdl = (*(pdl) & ~pm) | (*psl & pm);
+            psl++; pdl++; loop--;
+        }
+        break;
+    }
+}
+
+
+static void doLop16(ps, pd, n, alu, planemask)
+    GSXuchar *ps, *pd;		/* src and dst buffer */
+    int      n;			/* num of buffers */
+    GSXuchar alu;
+    GSXulong planemask;
+{
+    GSXushort amsk;
+    GSXushort *pss, *pds;
+    GSXushort pm;
+    int       loop;
+
+    pss = (GSXushort *)ps;
+    pds = (GSXushort *)pd;
+    amsk = 0x8000;
+    pm = (GSXushort)planemask & ~amsk;
+    loop = n / 2 ;     /* uchar(8bit) -> ushort(16bit) */
+
+    switch(alu) {
+    case GXclear:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (0 & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXand:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (*pss & *pds & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXandReverse:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (*pss & ~(*pds) & pm );
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXandInverted:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (~(*pss) & *pds & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXnoop:
+        break;
+    case GXxor:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | ((*pss ^ *pds) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXor:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | ((*pss | *pds) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXnor:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | ((~(*pss) & ~(*pds)) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXequiv:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | ((~(*pss) ^ (*pds)) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXinvert:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (~(*pds) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXorReverse:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | ((*pss | ~(*pds)) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXcopyInverted:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (~(*pss) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXorInverted:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | ((~(*pss) | (*pds)) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXnand:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | ((~(*pss) | ~(*pds)) & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    case GXset:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (0xffff & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    default:
+    case GXcopy:
+        while(loop > 0) {
+            *pds = (*(pds) & ~pm) | (*pss & pm);
+            pss++; pds++; loop--;
+        }
+        break;
+    }
+}
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxmisc.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxmisc.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxmisc.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxmisc.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,925 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+#include "pixmapstr.h"
+#include "cfb.h"
+
+void gsxCalcDrawRegion( pPoint, n, mode, pRect )
+    DDXPointPtr pPoint;
+    int n;
+    int mode;
+    xRectangle *pRect;
+{
+    int x, y;
+    int minx, miny, maxx, maxy;
+    int i;
+
+    if( !n ){
+        pRect->x = 0;
+        pRect->y = 0;
+        pRect->width = 0;
+        pRect->height = 0;
+    }
+    x = minx = maxx = pPoint[0].x ;
+    y = miny = maxy = pPoint[0].y ;
+    for( i=1; i < n ; i++ ){
+        if( mode == CoordModePrevious ){
+            x += pPoint[i].x ;
+            y += pPoint[i].y ;
+        }else{
+            x = pPoint[i].x ;
+            y = pPoint[i].y ;
+        }
+        if( x < minx ){
+            minx = x ;
+        }
+        if( y < miny ){
+            miny = y ;
+        }
+        if( x > maxx ){
+            maxx = x ;
+        }
+        if( y > maxy ){
+            maxy = y ;
+        }
+    }
+    pRect->x = minx ;
+    pRect->y = miny ;
+    pRect->width = maxx - minx + 1;
+    pRect->height = maxy - miny + 1;
+}
+
+void gsxCalcDrawRegionSeg( pSegments, n, pRect )
+    xSegment *pSegments;
+    int n;
+    xRectangle *pRect;
+{
+    int minx, miny, maxx, maxy;
+    int i;
+
+    if( !n ){
+        pRect->x = 0;
+        pRect->y = 0;
+        pRect->width = 0;
+        pRect->height = 0;
+    }
+    minx = maxx = pSegments[0].x1 ;
+    miny = maxy = pSegments[0].y1 ;
+    for( i=0; i < n ; i++ ){
+        if( pSegments[i].x1 < minx ){
+            minx = pSegments[i].x1 ;
+        }
+        if( pSegments[i].y1 < miny ){
+            miny = pSegments[i].y1 ;
+        }
+        if( pSegments[i].x1 > maxx ){
+            maxx = pSegments[i].x1 ;
+        }
+        if( pSegments[i].y1 > maxy ){
+            maxy = pSegments[i].y1 ;
+        }
+        if( pSegments[i].x2 < minx ){
+            minx = pSegments[i].x2 ;
+        }
+        if( pSegments[i].y2 < miny ){
+            miny = pSegments[i].y2 ;
+        }
+        if( pSegments[i].x2 > maxx ){
+            maxx = pSegments[i].x2 ;
+        }
+        if( pSegments[i].y2 > maxy ){
+            maxy = pSegments[i].y2 ;
+        }
+    }
+    pRect->x = minx ;
+    pRect->y = miny ;
+    pRect->width = maxx - minx + 1;
+    pRect->height = maxy - miny + 1;
+}
+
+void gsxCalcDrawRegionSpan( pPoint, pWidths, n, pRect )
+    DDXPointPtr pPoint;
+    int *pWidths;
+    int n;
+    xRectangle *pRect;
+{
+    int minx, miny, maxx, maxy;
+    int i;
+
+    if( !n ){
+        pRect->x = 0;
+        pRect->y = 0;
+        pRect->width = 0;
+        pRect->height = 0;
+    }
+    minx = pPoint[0].x ;
+    maxx = pPoint[0].x + pWidths[0] ;
+    miny = maxy = pPoint[0].y ;
+    for( i=1; i < n ; i++ ){
+        if( pPoint[i].x < minx ){
+            minx = pPoint[i].x ;
+        }
+        if( pPoint[i].y < miny ){
+            miny = pPoint[i].y ;
+        }
+        if( pPoint[i].x + pWidths[i] > maxx ){
+            maxx = pPoint[i].x + pWidths[i] ;
+        }
+        if( pPoint[i].y > maxy ){
+            maxy = pPoint[i].y ;
+        }
+    }
+    pRect->x = minx ;
+    pRect->y = miny ;
+    pRect->width = maxx - minx +1 ;
+    pRect->height = maxy - miny +1 ;
+}
+
+void gsxCalcDrawRegionRect( pSrcRect, n, pRect )
+    xRectangle *pSrcRect;
+    int n;
+    xRectangle *pRect;
+{
+  int minx, miny, maxx, maxy;
+  int i;
+  int tx, ty;
+
+  if(n == 0){
+    pRect->x = 0;
+    pRect->y = 0;
+    pRect->width = 0;
+    pRect->height = 0;
+  }
+  minx = pSrcRect[0].x;
+  maxx = pSrcRect[0].x + pSrcRect[0].width;
+  miny = pSrcRect[0].y;
+  maxy = pSrcRect[0].y + pSrcRect[0].height;
+  for(i = 1; i < n; i++) {
+    if( pSrcRect[i].x < minx ) {
+      minx = pSrcRect[i].x ;
+    }
+    if( pSrcRect[i].y < miny ) {
+      miny = pSrcRect[i].y ;
+    }
+    tx = pSrcRect[i].x + pSrcRect[i].width;
+    if(tx > maxx) {
+      maxx = tx;
+    }
+    ty = pSrcRect[i].y + pSrcRect[i].height;
+    if(ty > maxy) {
+      maxy = ty;
+    }
+  }
+  pRect->x = minx ;
+  pRect->y = miny ;
+  tx = maxx - minx;
+  if(tx <= 0) {
+    tx++;
+  }
+  ty = maxy - miny;
+  if(ty <= 0) {
+    ty++;
+  }
+  pRect->width = tx;
+  pRect->height = ty;
+}
+    
+void gsxCalcDrawRegionArc( pArc, n, pRect )
+    xArc *pArc;
+    int n;
+    xRectangle *pRect;
+{
+    int minx, miny, maxx, maxy;
+    int i;
+
+    if( !n ){
+        pRect->x = 0;
+        pRect->y = 0;
+        pRect->width = 0;
+        pRect->height = 0;
+    }
+    minx = pArc[0].x ;
+    maxx = pArc[0].x + pArc[0].width ;
+    miny = pArc[0].y ;
+    maxy = pArc[0].y + pArc[0].height ;
+    for( i=1; i < n ; i++ ){
+        if( pArc[i].x < minx ){
+            minx = pArc[i].x ;
+        }
+        if( pArc[i].y < miny ){
+            miny = pArc[i].y ;
+        }
+        if( pArc[i].x + pArc[i].width > maxx ){
+            maxx = pArc[i].x + pArc[i].width ;
+        }
+        if( pArc[i].y + pArc[i].height > maxy ){
+            maxy = pArc[i].y + pArc[i].height ;
+        }
+    }
+    pRect->x = minx ;
+    pRect->y = miny ;
+    pRect->width = maxx - minx ;
+    pRect->height = maxy - miny ;
+}
+    
+void gsxSetColormask( pGC, kind )
+    GCPtr pGC;
+    unsigned int kind;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 data ;
+    GSOSbit64 mask ;
+
+    switch( kind ){
+    case GSX_COLMASK_ASHUT:
+        if( BitsPerPixel(pGC->depth) == 16 ){
+            mask = ((0x1f & (pGC->planemask >> 0 )) << 3 )
+                 | ((0x1f & (pGC->planemask >> 5 )) << 11)
+                 | ((0x1f & (pGC->planemask >> 10)) << 19)
+                 | (0x0 << 31) ;
+        }else{
+            mask = 0x00ffffff & pGC->planemask ;
+        }
+        break ;
+    case GSX_COLMASK_AONLY:
+        if( BitsPerPixel(pGC->depth) == 16 ){
+            mask = 0x80000000 ;
+        }else{
+            mask = 0xff000000 ;
+        }
+        break ;
+    case GSX_COLMASK_ALL:
+    default:
+        if( BitsPerPixel(pGC->depth) == 16 ){
+            mask = 0x00008000 | pGC->planemask ;
+            mask = ((0x1f & (pGC->planemask >> 0 )) << 3 )
+                 | ((0x1f & (pGC->planemask >> 5 )) << 11)
+                 | ((0x1f & (pGC->planemask >> 10)) << 19)
+                 | (0x01 << 31) ;
+        }else{
+            mask = 0xff000000 | pGC->planemask ;
+        }
+        break ;
+    }
+    gsosMakeGiftag( 1, GSOS_GIF_EOP_TERMINATE, GSOS_GIF_PRE_IGNORE,
+        0, GSOS_GIF_FLG_PACKED, 1,
+        GSOS_GIF_REG_AD );
+    data = pPriv->frame_1 ;
+    pPriv->frame_1 = GsosFrameData( GsosFrameFbp(data),
+        GsosFrameFbw(data), GsosFramePsm(data),
+        ~mask ) ;    /* in GS, 1:write disable */
+    gsosSetPacketAddrData( GSOS_FRAME_1, pPriv->frame_1 ) ;
+    gsosExec() ;
+}
+
+#if 0
+void gsxSetFBA( pGC, value )
+    GCPtr pGC;
+    unsigned int value;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+
+    gsosMakeGiftag( 1, GSOS_GIF_EOP_TERMINATE, GSOS_GIF_PRE_IGNORE,
+        0, GSOS_GIF_FLG_PACKED, 1,
+        GSOS_GIF_REG_AD );
+    pPriv->fba_1 = GsosFbaData( value ) ;
+    gsosSetPacketAddrData( GSOS_FBA_1, pPriv->fba_1 ) ;
+    gsosExec() ;
+}
+#endif
+
+int gsxIsPlanemask( pGC )
+    GCPtr pGC ;
+{
+    unsigned int mask ;
+    unsigned int planemask ;
+
+    planemask = pGC->planemask ;
+    if( BitsPerPixel(pGC->depth) == 16 ){
+        mask = 0x00007fff ;
+    }else{
+        mask = 0x00ffffff ;
+    }
+    if( ~planemask & mask ){
+        return 1;
+    }else{
+        return 0;
+    }
+}
+
+#if 0
+void gsxSetTexfunc( pPriv, tfunc )
+    gsxGCPtr pPriv;
+    int tfunc;
+{
+    GSOSbit64 data;
+
+    data = pPriv->tex0_1;
+    pPriv->tex0_1 = GsosTex0Data( GsosTex0Tbp0(data), GsosTex0Tbw(data),
+        GsosTex0Psm(data), GsosTex0Tw(data), GsosTex0Th(data), 
+        GsosTex0Tcc(data), 
+        tfunc,
+        GsosTex0Cbp(data), GsosTex0Cpsm(data), GsosTex0Csm(data), 
+        GsosTex0Csa(data), GsosTex0Cld(data)) ; 
+}
+#endif
+
+void gsxGetRgba( pGC, rgb, r, g, b, a )
+    GCPtr pGC ;
+    unsigned int rgb ;
+    int *r ;
+    int *g ;
+    int *b ;
+    int *a ;
+{
+    gsxGetRgbaWithBitsPerPixel(BitsPerPixel(pGC->depth),rgb,r,g,b,a);
+}
+
+void gsxGetRgbaWithBitsPerPixel( bitsPerPixel, rgb, r, g, b, a)
+    int bitsPerPixel ;
+    unsigned int rgb ;
+    int *r ;
+    int *g ;
+    int *b ;
+    int *a ;
+{
+    switch ( bitsPerPixel ){
+    case 16:
+        *r = ((rgb >> 0) & 0x1f) << 3 | ((rgb >> 2) & 0x7) ;
+        *g = ((rgb >> 5) & 0x1f) << 3 | ((rgb >> 7) & 0x7) ;
+        *b = ((rgb >> 10) & 0x1f) << 3 | ((rgb >> 12) & 0x7) ;
+        *a = 0x80 ;
+        break ;
+    case 32:
+        *r = (rgb >> 0) & 0xff ;
+        *g = (rgb >> 8) & 0xff ;
+        *b = (rgb >> 16) & 0xff ;
+        *a = 0x80 ;
+        break ;
+    default:
+        ErrorF( "gsxGetRgbaWithBitsPerPixel: illegal color\n" ) ;
+        break ;
+    }
+}
+
+void gsxFrameInit(int screenWidth, int depth)
+{
+    int          result;
+    int          psm;
+    GSOSbit64    frame;
+    GSOSbit64    mask;
+
+    psm    = (depth <= 16) ? 2 : 0;
+    mask   = (depth <= 16) ? 0x80000000 : 0xff000000; /* mask alpha bit */
+    result = gsosMakeGiftag(2, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+		   0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD );
+    /* Frame */
+    frame = GsosFrameData(GSX_FRAME_BASE,
+			  (screenWidth + 63) / 64,
+			  psm,
+			  mask);
+    gsosSetPacketAddrData(GSOS_FRAME_1, frame);
+    /* XYOFFSET */
+    gsosSetPacketAddrData(GSOS_XYOFFSET_1,
+			  GsosXyoffsetData(GSOS_XYOFFSET<<4,GSOS_XYOFFSET<<4));
+    gsosExec() ;
+}
+
+void gsxFlushGC( pPriv )
+    gsxGCPtr pPriv ;
+{
+    gsosMakeGiftag( 21, GSOS_GIF_EOP_TERMINATE, GSOS_GIF_PRE_IGNORE,
+        0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD ) ;
+    gsosSetPacketAddrData( GSOS_XYOFFSET_1, pPriv->xyoffset_1 ) ;
+    gsosSetPacketAddrData( GSOS_FRAME_1, pPriv->frame_1 ) ;
+    gsosSetPacketAddrData( GSOS_ZBUF_1, pPriv->zbuf_1 ) ;
+    gsosSetPacketAddrData( GSOS_PRMODECONT, pPriv->prmodecont ) ;
+    gsosSetPacketAddrData( GSOS_TEX0_1, pPriv->tex0_1 ) ;
+    gsosSetPacketAddrData( GSOS_CLAMP_1, pPriv->clamp_1 ) ;
+    gsosSetPacketAddrData( GSOS_TEX1_1, pPriv->tex1_1 ) ;
+    gsosSetPacketAddrData( GSOS_TEX2_1, pPriv->tex2_1 ) ;
+    gsosSetPacketAddrData( GSOS_MIPTBP1_1, pPriv->miptbp1_1 ) ;
+    gsosSetPacketAddrData( GSOS_MIPTBP2_1, pPriv->miptbp2_1 ) ;
+    gsosSetPacketAddrData( GSOS_SCISSOR_1, pPriv->scissor_1 ) ;
+    gsosSetPacketAddrData( GSOS_ALPHA_1, pPriv->alpha_1 ) ;
+    gsosSetPacketAddrData( GSOS_TEST_1, pPriv->test_1 ) ;
+    gsosSetPacketAddrData( GSOS_FBA_1, pPriv->fba_1 ) ;
+    gsosSetPacketAddrData( GSOS_PRMODE, pPriv->prmode ) ;
+    gsosSetPacketAddrData( GSOS_TEXCLUT, pPriv->texclut ) ;
+    gsosSetPacketAddrData( GSOS_TEXA, pPriv->texa ) ;
+    gsosSetPacketAddrData( GSOS_DIMX, pPriv->dimx ) ;
+    gsosSetPacketAddrData( GSOS_DTHE, pPriv->dthe ) ;
+    gsosSetPacketAddrData( GSOS_COLCLAMP, pPriv->colclamp ) ;
+    gsosSetPacketAddrData( GSOS_PABE, pPriv->pabe ) ;
+
+    gsosExec() ;
+}
+
+void gsxCacheInvalid()
+{
+    gsosMakeGiftag( 1, GSOS_GIF_EOP_TERMINATE, GSOS_GIF_PRE_IGNORE,
+        0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD );
+    gsosSetPacketAddrData( GSOS_CACHEINVLD, 0 ) ;
+    gsosExec() ;
+}
+
+int gsxBytePerPixel(int bpp)
+{
+  if(bpp <= 16)
+    return 16/8;	/* RGBA16 */
+  else
+    return 32/8;	/* RGBA32 */
+}
+
+int gsxGetPsmFromBpp( int bpp )
+{
+    int psm ;
+
+    switch( bpp ){
+    case 1:
+        psm = 0 ;
+        break ;
+    case 8:
+        psm = 0 ;
+        break ;
+    case 16:
+        psm = 2 ;
+        break ;
+    case 32:
+    default:
+        psm = 0 ;
+        break ;
+    }
+    return psm ;
+}
+
+#if 0
+void gsxPixmapToFill(pGC)
+    GCPtr pGC ;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    PixmapPtr pPixmap ;
+    int w, h, lw, dw, psize, i, j ;
+    pointer pSrc, pDst ;
+    int nw, nh, psm ;
+    GSOSbit64 reg ;
+
+    if( pPriv->fillStyle == FillSolid ){
+        return ;
+    }
+
+#define COPY_HATCH( sType, dType, stippleOrTile ) \
+                { \
+                    unsigned dType *pd = (unsigned dType *)pDst ; \
+                    for(i=0; i < h ; i++){ \
+                        unsigned sType *ps = (unsigned sType *)pSrc ; \
+                        for(j=0; j < w ; j++){ \
+                            if( stippleOrTile == FillTiled ){ \
+                                *pd = (unsigned dType)*ps ; \
+                            }else{ \
+                                if( *ps ) \
+                                    *pd = 0x80808080 ; \
+                                else \
+                                    *pd = 0x00808080 ; \
+                            } \
+                            ps ++ ; \
+                            pd ++ ; \
+                        } \
+                        pSrc += lw ; \
+                    } \
+                }
+
+#define COPY_HATCH16( sType, dType, stippleOrTile ) \
+                { \
+                    unsigned dType *pd = (unsigned dType *)pDst ; \
+                    for(i=0; i < h ; i++){ \
+                        unsigned sType *ps = (unsigned sType *)pSrc ; \
+                        for(j=0; j < w ; j++){ \
+                            if( stippleOrTile == FillTiled ){ \
+                                *pd = (unsigned dType)*ps ; \
+                            }else{ \
+                                if( *ps ) \
+                                    *pd = 0xc210 ; \
+                                else \
+                                    *pd = 0x4210 ; \
+                            } \
+                            ps ++ ; \
+                            pd ++ ; \
+                        } \
+                        pSrc += lw ; \
+                    } \
+                }
+
+    if( pPriv->fillStyle == FillTiled && pGC->tileIsPixel ){
+        w = 64 ;
+        h = 64 ;
+        dw = 64 ;
+        if( BitsPerPixel(pGC->depth) == 16 ){ psize = sizeof(short) ;
+        }else{ psize = sizeof(long); }
+        pDst = (pointer)xalloc( psize * w * h ) ;
+        if( pDst == NULL ){
+            return ;
+        }
+        switch( BitsPerPixel(pGC->depth) ){
+        case 16:
+            {
+                unsigned short *pd = (unsigned short *)pDst ;
+                for(i=0; i < h ; i++){
+                    for(j=0; j < w ; j++){
+                        *pd = pGC->tile.pixel & 0xffff ;
+                    }
+                }
+            }
+            break ;
+        default:
+            {
+                unsigned long *pd = (unsigned long *)pDst ;
+                for(i=0; i < h ; i++){
+                    for(j=0; j < w ; j++){
+                        *pd = (unsigned long)(pGC->tile.pixel &0xffffffff);
+                    }
+                }
+            }
+            break ;
+        }
+    }else{
+        if( pPriv->fillStyle == FillTiled ){
+            pPixmap = pGC->tile.pixmap ;
+        }else{
+            pPixmap = pGC->stipple ;
+        }
+        w = pPixmap->drawable.width ;
+        h = pPixmap->drawable.height ;
+        lw = pPixmap->devKind ;
+        dw = ((w+63)/64) *64 ;
+        if( BitsPerPixel(pGC->depth) == 16 ){ psize = sizeof(short) ;
+        }else{ psize = sizeof(long); }
+        pSrc = pPixmap->devPrivate.ptr ;
+        pDst = (pointer)xalloc( psize * w * h ) ;
+        if( pDst == NULL ){
+            return ;
+        }
+        switch( pPixmap->drawable.bitsPerPixel ){
+        case 1:
+            switch( BitsPerPixel(pGC->depth) ){
+            case 16:
+                {
+                    unsigned short *pd = (unsigned short *)pDst ;
+                    for(i=0; i < h ; i++){
+                       unsigned long *ps = (unsigned long *)pSrc ;
+                       for(j=0; j < w ; j++){
+                            if( *ps & (0x1U << j) ){
+                                *pd = 0xc210 ;
+                            }else{
+                                *pd = 0x4210 ;
+                            }
+                            pd++;
+                        }
+                        pSrc += lw ;
+                    }
+                }
+                break ;
+            default:
+                {
+                    unsigned long *pd = (unsigned long *)pDst ;
+                    for(i=0; i < h ; i++){
+                        unsigned long *ps = (unsigned long *)pSrc ;
+                        for(j=0; j < w ; j++){
+                            if( *ps & (0x1U << j) ){
+                                *pd = 0x80808080 ;
+                            }else{
+                                *pd = 0x00808080 ;
+                            }
+                            pd++;
+                        }
+                        pSrc += lw ;
+                    }
+                }
+                break ;
+            }
+            break ;
+        case 8:
+            switch( BitsPerPixel(pGC->depth) ){
+            case 16:
+                COPY_HATCH16( char, short, pPriv->fillStyle ) ;
+                break ;
+            default:
+                COPY_HATCH( char, long, pPriv->fillStyle ) ;
+                break ;
+            }
+            break ;
+        case 16:
+            switch( BitsPerPixel(pGC->depth) ){
+            case 16:
+                COPY_HATCH16( short, short, pPriv->fillStyle ) ;
+                break ;
+            default:
+                COPY_HATCH( short, long, pPriv->fillStyle ) ;
+                break ;
+            }
+            break ;
+        case 32:
+            switch( BitsPerPixel(pGC->depth) ){
+            case 16:
+                COPY_HATCH16( long, short, pPriv->fillStyle ) ;
+                break ;
+            default:
+                COPY_HATCH( long, long, pPriv->fillStyle ) ;
+                break ;
+            }
+            break ;
+        }
+    }
+
+    /* Load data as Texture */
+    reg = pPriv->tex0_1 ;
+    switch( BitsPerPixel(pGC->depth) ){
+    case 16:
+        psm = 2 ;
+        break ;
+    default:
+        psm = 0 ;
+        break ;
+    }
+    nw = 0 ;
+    nh = 0 ;
+    while( (1<<nw) < w ) nw++;
+    while( (1<<nh) < h ) nh++;
+    pPriv->tex0_1 = GsosTex0Data( 
+        GsosTex0Tbp0(reg),
+        dw/64,
+        psm,
+        nw,
+        nh,
+        GsosTex0Tcc(reg), GsosTex0Tfx(reg),
+        GsosTex0Cbp(reg), GsosTex0Cpsm(reg),
+        GsosTex0Csm(reg), GsosTex0Csa(reg), GsosTex0Cld(reg));
+    pPriv->clamp_1 = GsosClampData( 3, 3, (1<<nw)-1, 0, (1<<nh)-1, 0 ) ;
+    gsxFlushGC(pPriv) ;
+    gsosWriteImage( 0, 0, w, h, 
+        GsosTex0Tbp0(reg), dw/64, psm, 
+        (GSOSuchar *)pDst ) ;
+    gsxCacheInvalid() ;
+
+    xfree( pDst ) ;
+
+}
+#endif
+
+/*ARGSUSED*/
+void
+gsxQueryBestSize(class, pwidth, pheight, pScreen)
+int class;
+unsigned short *pwidth;
+unsigned short *pheight;
+ScreenPtr pScreen;
+{
+    unsigned width, test;
+
+    switch(class)
+    {
+      case CursorShape:
+          if (*pwidth > pScreen->width)
+             *pwidth = pScreen->width;
+          if (*pheight > pScreen->height)
+             *pheight = pScreen->height;
+          break;
+      case TileShape:
+      case StippleShape:
+          width = *pwidth;
+          if (!width) break;
+          /* Return the closes power of two not less than what they gave me */
+          test = 0x80000000;
+          /* Find the highest 1 bit in the width given */
+          while(!(test & width))
+             test >>= 1;
+          /* If their number is greater than that, bump up to the next
+           *  power of two */
+          if((test - 1) & width)
+             test <<= 1;
+          *pwidth = test;
+          if(test <= GSX_HATCH_MAX_WIDTH) { 
+             test = 0x80000000;
+             while(!(test & width))
+                test >>= 1;
+             /* If their number is greater than that, bump up to the next
+              *  power of two */
+             if((test - 1) & width)
+                test <<= 1;
+             if(test <= GSX_HATCH_MAX_HEIGHT)
+                *pheight = test;
+          } else {
+          	/* We don't care what height they use */
+          }
+          break;
+    }
+}
+
+
+Bool
+gsxSaveScreen (pScreen, on)
+    ScreenPtr   pScreen;
+    int         on;
+{
+
+    if (on != SCREEN_SAVER_FORCER)
+    {
+        if (on == SCREEN_SAVER_ON) {
+            /* save screen */
+        } else {
+            /* enable screen */
+        }
+    }
+    return( TRUE );
+}
+
+#if 0
+Bool
+gsxCopyPixmap(Pixmap *psrc, Pixmap *pdst)
+{
+  if(psrc->depth > 16 && pdst->depth > 16) {         /* 32bit to 32bit*/
+  } else if(psrc->depth > 16 && pdst->depth <= 16) { /* 32bit to 16bit */
+  } else if(pdst->depth > 16) {	                     /* 16bit to 32bit */
+  } else if(pdst->depth <= 16) {                     /* 16bit to 16bit */
+  } else {
+    ErrorF("gsxCopyPixFrame Not Support depth\n");
+    return FAILE;
+  }
+  return TRUE;
+}
+#endif
+
+int gsxReadImage( 
+int x, int y, int w, int h,
+unsigned int bp,
+int bw, int psm,
+PixmapPtr pPix)
+{
+  if(psm == 2) {	/* RGBA16 */
+    int d;
+    d = pPix->devKind - w * 2;
+    if(d > 0) {
+      w += d / 2;
+    }
+  }
+  return gsosReadImage(x, y, w, h, bp, bw, psm, pPix->devPrivate.ptr);
+}
+
+int gsxWriteImage( 
+  int x, int y, int w, int h,
+  unsigned int bp,
+  int bw, int psm,
+  PixmapPtr pPix )
+{
+  int      line;
+  GSXuchar *sp, *dp, *buf;
+  int      DstdevKind;
+  int      SrcdevKind;
+  int      bufsize;
+
+  DstdevKind = w * 2;
+  SrcdevKind = pPix->devKind;
+  if(psm == 0 || SrcdevKind == DstdevKind) {	/* RGBA32 or ...*/
+    return gsosWriteImage(x, y, w, h, bp, bw, psm, pPix->devPrivate.ptr);
+  }
+  bufsize = DstdevKind * h;
+  buf = ALLOCATE_LOCAL(bufsize);
+  memset(buf, 0x00, bufsize);
+  dp = buf;
+  sp = (GSXuchar *)pPix->devPrivate.ptr;
+  for(line = 0; line < h; line++) {
+    memcpy(dp, sp, DstdevKind);
+    dp += DstdevKind;
+    sp += SrcdevKind;
+  }
+  gsosWriteImage(x, y, w, h, bp, bw, psm, buf);
+  DEALLOCATE_LOCAL(buf);
+  return 0;
+}
+
+/*
+ * Dump image for DEBUG
+ */
+#if 0
+void gsxImageDump(void *p, int w, int h, int bsz, int image)
+{
+  GSXuchar  *dc;
+  GSXushort *ds;
+  GSXulong  *dl;
+  int x, y;
+
+  dc = (GSXuchar *)p;
+  ds = (GSXushort *)p;
+  dl = (GSXulong *)p;
+  /*  ErrorF("%08x:", dc); */
+  for(y = 0; y < h; y++) {
+    for(x = 0; x < w; x++) {
+      switch(bsz) {
+      case 1:
+	if(image) {
+	  if(*dc++ == 0) ErrorF("."); else ErrorF("X");
+	} else {
+	  ErrorF("%02x ", *dc++);
+	}
+	break;
+      case 2:
+	if(image) {
+	  if(*ds++ == 0) ErrorF("."); else ErrorF("X");
+	} else {
+	  ErrorF("%04x ", *ds++);
+	}
+	break;
+      case 4:
+	if(image) {
+	  if(*dl++ == 0) ErrorF("."); else ErrorF("X");
+	} else {
+	  ErrorF("%08x ", *dl++);
+	}
+      }
+    }
+    ErrorF("\n");
+  }
+}
+
+void gsxPixmapDump(PixmapPtr pPix, int image)
+{
+  GSXuchar  *line_top;
+  int x, y;
+  int w, h;
+  int bpp;
+
+  line_top = (GSXuchar *)pPix->devPrivate.ptr;
+  w = ((DrawablePtr )pPix)->width;
+  h = ((DrawablePtr )pPix)->height;
+  bpp = BitsPerPixel(((DrawablePtr )pPix)->depth);
+  ErrorF("gsxPixmapDump: w=%d, h=%d, bpp=%d\n", w, h, bpp);
+  for(y = 0; y < h; y++) {
+    GSXuchar  *dc;
+    GSXushort *ds;
+    GSXulong  *dl;
+    dc = (GSXuchar  *)line_top;
+    ds = (GSXushort *)line_top;
+    dl = (GSXulong  *)line_top;
+    for(x = 0; x < w; x++) {
+      switch(bpp) {
+      case 1:
+	if(image) {
+	  if(*dc++ == 0) ErrorF("."); else ErrorF("X");
+	} else {
+	  if(*dc == 0) ErrorF(".."); else ErrorF("%02x ", *dc);
+	  dc++;
+	}
+	break;
+      case 16:
+	if(image) {
+	  if(*ds++ == 0) ErrorF("."); else ErrorF("X");
+	} else {
+	  if(*ds == 0) ErrorF("...."); else ErrorF("%04x ", *ds);
+	  ds++;
+	}
+	break;
+      case 24:
+      case 32:
+	if(image) {
+	  if(*dl++ == 0) ErrorF("."); else ErrorF("X");
+	} else {
+	  if(*dl == 0) ErrorF("...."); else ErrorF("%08x ", *dl);
+	  dl++;
+	}
+	break;
+      default:
+	ErrorF("Unknown depth=%d\n", bpp);
+	return;
+      }
+    }
+    line_top += pPix->devKind;
+    ErrorF("\n");
+  }
+}
+#endif
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxpolyarc.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolyarc.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxpolyarc.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolyarc.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,103 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+void gsxPolyArcSoft(dst,pGC,n,pArc)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xArc    *pArc;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int lineWidth;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!n) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegionArc( pArc, n, &aRect ) ;
+    lineWidth = pGC->lineWidth;
+    lineWidth = (((lineWidth < 2) ? 2 : lineWidth) + 1);
+    aRect.x += dst->x - lineWidth;
+    aRect.y += dst->y - lineWidth;
+    aRect.width  += lineWidth * 2;
+    aRect.height += lineWidth * 2;
+    drawRegion_x = aRect.x - dst->x;
+    drawRegion_y = aRect.y - dst->y;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage( aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* adjust pattern origin */
+    if (pGC->fillStyle != FillSolid) {
+      pGC1->patOrg.x = pGC1->patOrg.x + (pPriv->patW - drawRegion_x % pPriv->patW);
+      pGC1->patOrg.y = pGC1->patOrg.y + (pPriv->patH - drawRegion_y % pPriv->patH);
+    }
+
+    /* draw arcs */
+    for( nn = 0 ; nn < n ; nn++ ) {
+        pArc[nn].x -= drawRegion_x;
+        pArc[nn].y -= drawRegion_y;
+    }
+    (*pGC1->ops->PolyArc)( (DrawablePtr)dstLop, pGC1, n, pArc ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxpolylin.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolylin.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxpolylin.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolylin.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,212 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+static void doPolyLines( DrawablePtr dst, GCPtr pGC, int mode, int n, DDXPointPtr pPoint) ;
+
+void gsxPolyLinesSoft(dst,pGC,mode,n,pPoint)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     mode;
+    int     n;
+    DDXPointPtr pPoint;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int lineWidth;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!n) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegion( pPoint, n, mode, &aRect ) ;
+    lineWidth = pGC->lineWidth;
+    lineWidth = (((lineWidth < 2) ? 2 : lineWidth) + 1);
+    aRect.x += dst->x - lineWidth;
+    aRect.y += dst->y - lineWidth;
+    aRect.width  += lineWidth * 2;
+    aRect.height += lineWidth * 2;
+    drawRegion_x = aRect.x - dst->x;
+    drawRegion_y = aRect.y - dst->y;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop) ;
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* adjust pattern origin */
+    if (pGC->fillStyle != FillSolid) {
+      pGC1->patOrg.x = pGC1->patOrg.x + (pPriv->patW - drawRegion_x % pPriv->patW);
+      pGC1->patOrg.y = pGC1->patOrg.y + (pPriv->patH - drawRegion_y % pPriv->patH);
+    }
+
+    /* draw lines */
+    if( mode == CoordModePrevious ){
+        pPoint[0].x -= drawRegion_x;
+        pPoint[0].y -= drawRegion_y;
+    }else{
+        for( nn = 0 ; nn < n ; nn++ ) {
+            pPoint[nn].x -= drawRegion_x;
+            pPoint[nn].y -= drawRegion_y;
+        }
+    }
+
+    (*pGC1->ops->Polylines)( (DrawablePtr)dstLop, pGC1, mode, n, pPoint ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxPolyLinesGxcpy(dst,pGC,mode,n,pPoint)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     mode;
+    int     n;
+    DDXPointPtr pPoint;
+{
+    doPolyLines( dst, pGC, mode, n, pPoint ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+static void doPolyLines(dst,pGC,mode,n,pPoint)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     mode;
+    int     n;
+    DDXPointPtr pPoint;
+{
+    gsxGCPtr    pPriv = gsxGetGCPriv(pGC);
+    BoxPtr      pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    BoxPtr      plast = pbox + REGION_NUM_RECTS(pPriv->pCompositeClip);
+    int xorg = dst->x, yorg = dst->y;
+    DDXPointPtr p = pPoint, pLast = pPoint + n;
+    int x = p->x, y = p->y ;
+    int rgb, r, g, b, a ;
+    int i;
+    int nCount;
+    int pc;
+    int packets;
+    int result;
+    int morepacket;
+    int oldx, oldy;
+
+    if (!n) return;
+
+    if (mode == CoordModePrevious) {
+        while (++p < pLast) {
+            x = p->x += x;
+            y = p->y += y;
+        }
+    }
+
+    gsxFrameInit(dst->pScreen->width, dst->depth);
+
+    rgb = pGC->fgPixel & pPriv->pixelMask ;
+    gsxGetRgba( pGC, rgb, &r, &g, &b, &a ) ;
+
+    pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    while (pbox < plast) {
+        gsosMakeGiftag(2, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+		       0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD);
+        /* set SCISSOR rect */
+        gsosSetPacketAddrData4( GSOS_SCISSOR_1,
+            (GSOSbit64)pbox->x1, (GSOSbit64)pbox->x2-1,
+            (GSOSbit64)pbox->y1, (GSOSbit64)pbox->y2-1 );
+        /*
+           draw lines
+           actually we should consider capStyle == CapNotLast
+        */
+        gsosSetPacketAddrData( GSOS_PRIM, GSOS_PRIM_LSTRIP ) ;
+
+	p = pPoint;
+	nCount = n;
+	morepacket = 0;
+	while(nCount > 0) {
+	  pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED) - morepacket;
+	  if(pc <= 0) {	/* can't allocate buffer */
+	    gsosExec();		/* flush DMA */
+	    pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED) - morepacket;
+	  }
+	  packets = (nCount < pc) ? nCount : pc;
+	  result = gsosMakeGiftag(packets + morepacket,
+				  GSOS_GIF_EOP_CONTINUE,
+				  GSOS_GIF_PRE_IGNORE, 0,
+				  GSOS_GIF_FLG_PACKED, 2,
+				  (GSOS_GIF_REG_XYZ2  << 4) |
+				  (GSOS_GIF_REG_RGBAQ << 0));
+	  if(result) break;
+	  if(morepacket == 1) {
+	    gsosSetPacket4(r, g, b, a) ;
+	    gsosSetPacket4(GSOS_SUBPIX_OFST(oldx + xorg),
+			   GSOS_SUBPIX_OFST(oldy + yorg), 0, 0) ;
+	  }
+	  for(i = 0; i < packets; i++, p++) {
+            gsosSetPacket4(r, g, b, a ) ;
+            gsosSetPacket4(GSOS_SUBPIX_OFST(p->x + xorg),
+			   GSOS_SUBPIX_OFST(p->y + yorg), 0, 0);
+	    oldx = p->x; oldy = p->y;
+	  }
+	  nCount -= packets;
+	  morepacket = 1;
+	}
+        pbox++;
+    }
+    gsosExec() ;
+
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxpolypnt.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolypnt.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxpolypnt.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolypnt.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,195 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+static void doPolyPoint( DrawablePtr dst, GCPtr pGC, int mode, int n, DDXPointPtr pPoint ) ;
+
+void gsxPolyPointSoft(dst,pGC,mode,n,pPoint)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     mode;
+    int     n;
+    DDXPointPtr pPoint;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if (!n) return;
+
+    /* get region for LOP */
+    gsxCalcDrawRegion( pPoint, n, mode, &aRect ) ;
+    drawRegion_x = aRect.x;
+    drawRegion_y = aRect.y;
+    aRect.x += dst->x ;
+    aRect.y += dst->y ;
+    
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* draw points */
+    if( mode == CoordModePrevious ){
+        pPoint[0].x -= drawRegion_x;
+        pPoint[0].y -= drawRegion_y;
+    }else{
+        for( nn=0 ; nn < n ; nn++ ){
+            pPoint[nn].x -= drawRegion_x;
+            pPoint[nn].y -= drawRegion_y;
+        }
+    }
+    (*pGC1->ops->PolyPoint)( (DrawablePtr)dstLop, pGC1, mode, n, pPoint ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxPolyPointGxcpy(dst,pGC,mode,n,pPoint)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     mode;
+    int     n;
+    DDXPointPtr pPoint;
+{
+    doPolyPoint( dst, pGC, mode, n, pPoint ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+static void doPolyPoint(dst, pGC, mode, n, pPoint)
+    DrawablePtr dst; 
+    GCPtr pGC; 
+    int mode; 
+    int n; 
+    DDXPointPtr pPoint ;
+{
+    gsxGCPtr    pPriv = gsxGetGCPriv(pGC);
+    BoxPtr      pbox = REGION_RECTS(pPriv->pCompositeClip);
+    int         numRects = REGION_NUM_RECTS(pPriv->pCompositeClip);
+    BoxPtr      plast = pbox + numRects;
+    int xorg = dst->x, yorg = dst->y;
+    DDXPointPtr p = pPoint, pLast = pPoint + n;
+    int x = p->x, y = p->y;
+    int rgb, r, g, b, a ;
+    GSOSbit64 eop ;
+    int i;
+    int nCount;
+    int pc;
+    int packets;
+    int result;
+    
+    if (!n) return;
+
+    if (mode == CoordModePrevious) {
+        while (++p < pLast) {
+            x = p->x += x;
+            y = p->y += y;
+        }
+    }
+
+    gsxFrameInit(dst->pScreen->width, dst->depth);
+
+    rgb = pGC->fgPixel & pPriv->pixelMask ;
+    gsxGetRgba( pGC, rgb, &r, &g, &b, &a ) ;
+
+    eop = GSOS_GIF_EOP_CONTINUE;
+    while (pbox < plast) {
+        gsosMakeGiftag( 4, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+            0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD );
+        /* alpha test ALWAYS */
+        gsosSetPacketAddrData( GSOS_TEST_1, 
+            GsosTestData( 1, 1, 0, 0, 0, 0, 0, 0 ) ) ;
+        /* set SCISSOR rect */
+        gsosSetPacketAddrData4( GSOS_SCISSOR_1, 
+            (GSOSbit64)pbox->x1, (GSOSbit64)pbox->x2-1,
+            (GSOSbit64)pbox->y1, (GSOSbit64)pbox->y2-1 ) ;
+
+        /* draw points */
+        /* texture disabled */
+        gsosSetPacketAddrData( GSOS_PRMODE, 
+            GsosPrmodeData( 0, 0, 0, 0, 0, 0, 0, 0 )) ;
+        gsosSetPacketAddrData( GSOS_PRIM, GSOS_PRIM_POINT ) ;
+
+	p = pPoint;
+	nCount = n;
+	while(nCount > 0) {
+	  pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED);
+	  if(pc == 0) {	/* can't allocate buffer */
+	    gsosExec();		/* flush DMA */
+	    pc = gsosCalcPacketCount(2, GSOS_GIF_FLG_PACKED);
+	  }
+	  packets = (nCount < pc) ? nCount : pc;
+	  
+	  result = gsosMakeGiftag(packets, eop, GSOS_GIF_PRE_IGNORE, 0,
+				  GSOS_GIF_FLG_PACKED, 2,
+				  (GSOS_GIF_REG_XYZ2 << 4) |
+				  GSOS_GIF_REG_RGBAQ);
+	  if(result) break;
+	  for(i = 0; i < packets; i++, p++) {
+            gsosSetPacket4(r, g, b, a);
+            gsosSetPacket4(GSOS_SUBPIX_OFST(p->x + xorg), 
+			   GSOS_SUBPIX_OFST(p->y + yorg), 0, 0);
+	  }
+	  nCount -= packets;
+	}
+        pbox++;
+    }
+    gsosExec() ;
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxpolyrct.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolyrct.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxpolyrct.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolyrct.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,127 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+void gsxPolyRectangleSoft(dst,pGC,n,pRect)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xRectangle  *pRect;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int lineWidth;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!n) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegionRect( pRect, n, &aRect ) ;
+    lineWidth = pGC->lineWidth;
+    lineWidth = (((lineWidth < 2) ? 2 : lineWidth) + 1);
+    aRect.x += dst->x - lineWidth;
+    aRect.y += dst->y - lineWidth;
+    aRect.width  += lineWidth * 2;
+    aRect.height += lineWidth * 2;
+    drawRegion_x = aRect.x - dst->x;
+    drawRegion_y = aRect.y - dst->y;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* adjust pattern origin */
+    if (pGC->fillStyle != FillSolid) {
+      pGC1->patOrg.x = pGC1->patOrg.x + (pPriv->patW - drawRegion_x % pPriv->patW);
+      pGC1->patOrg.y = pGC1->patOrg.y + (pPriv->patH - drawRegion_y % pPriv->patH);
+    }
+
+    /* draw lines */
+    for( nn = 0 ; nn < n ; nn++ ) {
+        pRect[nn].x -= drawRegion_x;
+        pRect[nn].y -= drawRegion_y;
+    }
+    (*pGC1->ops->PolyRectangle)( (DrawablePtr)dstLop, pGC1, n, pRect ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxPolyRectangleGxcpy(dst,pGC,n,pRect)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xRectangle  *pRect;
+{
+  int i;
+  DDXPointRec points[5];
+
+  for(i = 0; i < n; i++, pRect++) {
+    points[0].x = pRect->x;
+    points[0].y = pRect->y;
+    points[1].x = pRect->x + pRect->width;
+    points[1].y = points[0].y;
+    points[2].x = points[1].x;
+    points[2].y = pRect->y + pRect->height;
+    points[3].x = points[0].x;
+    points[3].y = points[2].y;
+    points[4].x = pRect->x;
+    points[4].y = pRect->y;
+    gsxPolyLinesGxcpy(dst, pGC, CoordModeOrigin, 5, points);
+  }
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxpolyseg.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolyseg.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxpolyseg.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxpolyseg.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,193 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+static void doPolySegment( DrawablePtr dst, GCPtr pGC, int n, xSegment *pSegments) ;
+
+void gsxPolySegmentSoft(dst,pGC,n,pSegments)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xSegment *pSegments;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC1;
+    int lineWidth;
+    int drawRegion_x;
+    int drawRegion_y;
+
+    if(!n) return ;
+
+    /* get region for LOP */
+    gsxCalcDrawRegionSeg( pSegments, n, &aRect ) ;
+    lineWidth = pGC->lineWidth;
+    lineWidth = (((lineWidth < 2) ? 2 : lineWidth) + 1);
+    aRect.x += dst->x - lineWidth;
+    aRect.y += dst->y - lineWidth;
+    aRect.width  += lineWidth * 2;
+    aRect.height += lineWidth * 2;
+    drawRegion_x = aRect.x - dst->x;
+    drawRegion_y = aRect.y - dst->y;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* adjust pattern origin */
+    if (pGC->fillStyle != FillSolid) {
+      pGC1->patOrg.x = pGC1->patOrg.x + (pPriv->patW - drawRegion_x % pPriv->patW);
+      pGC1->patOrg.y = pGC1->patOrg.y + (pPriv->patH - drawRegion_y % pPriv->patH);
+    }
+
+    /* draw */
+    for( nn = 0 ; nn < n ; nn++ ) {
+        pSegments[nn].x1 -= drawRegion_x;
+        pSegments[nn].x2 -= drawRegion_x;
+        pSegments[nn].y1 -= drawRegion_y;
+        pSegments[nn].y2 -= drawRegion_y;
+    }
+    (*pGC1->ops->PolySegment)( (DrawablePtr)dstLop, pGC1, n, pSegments ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        drawRegion_x, drawRegion_y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+void gsxPolySegmentGxcpy(dst,pGC,n,pSegments)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xSegment    *pSegments;
+{
+    doPolySegment( dst, pGC, n, pSegments ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+static void doPolySegment(dst,pGC,n,pSegments)
+    DrawablePtr dst;
+    GCPtr   pGC;
+    int     n;
+    xSegment    *pSegments;
+{
+    gsxGCPtr    pPriv = gsxGetGCPriv(pGC);
+    BoxPtr      pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    BoxPtr      plast = pbox + REGION_NUM_RECTS(pPriv->pCompositeClip);
+    int xorg = dst->x, yorg = dst->y;
+    xSegment *p = pSegments, *pLast = pSegments + n;
+    int rgb, r, g, b, a ;
+    int i;
+    int nCount;
+    int pc;
+    int packets;
+    int result;
+
+    if (!n) return;
+
+    /*    endp = (pGC->capStyle==CapNotLast)? GSX_DISABLE:GSX_ENABLE; */
+
+    gsxFrameInit(dst->pScreen->width, dst->depth);
+
+    rgb = pGC->fgPixel & pPriv->pixelMask ;
+    gsxGetRgba( pGC, rgb, &r, &g, &b, &a ) ;
+
+    pbox  = REGION_RECTS(pPriv->pCompositeClip);
+    while (pbox < plast) {
+        gsosMakeGiftag(2, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+		       0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD);
+        /* set SCISSOR rect */
+        gsosSetPacketAddrData4( GSOS_SCISSOR_1,
+            (GSOSbit64)pbox->x1, (GSOSbit64)pbox->x2-1,
+            (GSOSbit64)pbox->y1, (GSOSbit64)pbox->y2-1 );
+        /*
+           draw lines
+           actually we should consider capStyle == CapNotLast
+        */
+        gsosSetPacketAddrData( GSOS_PRIM, GSOS_PRIM_LINE ) ;
+
+        p = pSegments ;
+	nCount = n;
+	while(nCount > 0) {
+	  pc = gsosCalcPacketCount(3, GSOS_GIF_FLG_PACKED) / 2;
+	  if(pc == 0) {	/* can't allocate buffer */
+	    gsosExec();		/* flush DMA */
+	    pc = gsosCalcPacketCount(3, GSOS_GIF_FLG_PACKED) / 2;
+	  }
+	  packets = (nCount < pc) ? nCount : pc;
+
+	  result = gsosMakeGiftag(packets * 2, GSOS_GIF_EOP_CONTINUE,
+				  GSOS_GIF_PRE_IGNORE, 0,
+				  GSOS_GIF_FLG_PACKED, 2,
+				  (GSOS_GIF_REG_XYZ2  << 4) |
+				  (GSOS_GIF_REG_RGBAQ << 0));
+	  if(result) break;
+	  for(i = 0; i < packets; i++, p++) {
+            gsosSetPacket4(r, g, b, a);
+            gsosSetPacket4(GSOS_SUBPIX_OFST(p->x1 + xorg), 
+			   GSOS_SUBPIX_OFST(p->y1 + yorg), 0, 0);
+	    
+            gsosSetPacket4(r, g, b, a);
+            gsosSetPacket4(GSOS_SUBPIX_OFST(p->x2 + xorg), 
+			   GSOS_SUBPIX_OFST(p->y2 + yorg), 0, 0);
+	  }
+	  nCount -= packets;
+	}
+        pbox++;
+    }
+    gsosExec() ;
+
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxpushpix.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxpushpix.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxpushpix.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxpushpix.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,84 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+void gsxPushPixelsSoft(pGC,pBitmap,dst,dx,dy,xOrg,yOrg)
+    GCPtr   pGC;
+    PixmapPtr pBitmap;
+    DrawablePtr dst;
+    int     dx, dy, xOrg, yOrg;
+{
+    gsxGCPtr pPriv = gsxGetGCPriv(pGC) ;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    GCPtr pGC1;
+
+    if(!dx*dy) return ;
+
+    /* get region for LOP */
+    aRect.x = xOrg ;
+    aRect.y = yOrg ;
+    aRect.width = dx ;
+    aRect.height = dy ;
+
+    dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+    if( !dstLop ){
+        return ;
+    }
+    /* copy destination */
+    frame_1 = pPriv->frame_1 ;
+    gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+        GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+
+    /* ValidateGC( destination = PIXMAP ) */
+    pGC1 = GetScratchGC(dst->depth, pGC->pScreen);
+    CopyGC(pGC, pGC1, ~GCClipMask);
+    GSXVALIDATEGC( (DrawablePtr)dstLop, pGC1 ) ;
+
+    /* draw lines */
+    (*pGC1->ops->PushPixels)( pGC1, pBitmap, (DrawablePtr)dstLop, 
+        dx, dy, xOrg-(aRect.x-dst->x), yOrg-(aRect.y-dst->y) ) ;
+
+    FreeScratchGC(pGC1);
+
+    /* ValidateGC( destination = WINDOW ) */
+    GSXVALIDATEGC( dst, pGC ) ;
+
+    /* post-proccess for LOP */
+    cfbBitBlt( (DrawablePtr)dstLop, dst, pGC, 0, 0, aRect.width, aRect.height,
+        aRect.x-dst->x, aRect.y-dst->y, gsxDoBitBlt, 0 ) ;
+
+    (*dst->pScreen->DestroyPixmap)(dstLop) ;
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxscrinit.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxscrinit.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxscrinit.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxscrinit.c	Wed Mar 14 21:17:24 2001
@@ -0,0 +1,242 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+#include "cfb.h"
+#include "mi.h"
+#include "mipointer.h"
+
+#include <linux/ps2/gs.h>
+
+extern int disableBackingStore;
+extern miBSFuncRec gsxBSFuncs;
+
+int gsxWindowIndex; // reference from gsxGetWindowPriv(w) in gsx.h
+
+static Bool gsxCursorOffScreen (ppScreen, x, y)
+    ScreenPtr   *ppScreen;
+    int         *x, *y;
+{
+    return FALSE;
+}
+
+static void gsxCrossScreen (pScreen, entering)
+    ScreenPtr   pScreen;
+    Bool        entering;
+{
+}
+
+static miPointerScreenFuncRec gsxPointerCursorFuncs =
+{
+    gsxCursorOffScreen,
+    gsxCrossScreen,
+    miPointerWarpCursor
+};
+
+
+Bool gsxSetupScreen( ScreenPtr pScreen )
+{
+    if (!mfbAllocatePrivates(pScreen, &gsxWindowIndex, &gsxGCIndex))
+        return FALSE;
+    if (!cfbAllocatePrivates(pScreen, &gsxWindowIndex, &gsxGCIndex))
+        return FALSE;
+    if (!cfb16AllocatePrivates(pScreen, &gsxWindowIndex, &gsxGCIndex))
+        return FALSE;
+    if (!cfb32AllocatePrivates(pScreen, &gsxWindowIndex, &gsxGCIndex))
+        return FALSE;
+
+    if (!AllocateWindowPrivate(pScreen, gsxWindowIndex,
+         sizeof(gsxWindowPrivate)) ||
+        !AllocateGCPrivate(pScreen, gsxGCIndex,
+         sizeof(gsxGCPrivate)) )
+                return FALSE;
+
+    // setting pScreen methods in cfbSetupScreen
+    pScreen->defColormap = FakeClientID(0);
+    /* let CreateDefColormap do whatever it wants for pixels */
+    pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
+
+    pScreen->CloseScreen = gsxCloseScreen;
+    pScreen->QueryBestSize = gsxQueryBestSize;
+    pScreen->SaveScreen = gsxSaveScreen;
+    pScreen->GetImage = gsxGetImage;
+    pScreen->GetSpans = gsxGetSpans;
+    pScreen->CreateWindow = gsxCreateWindow;
+    pScreen->DestroyWindow = gsxDestroyWindow;
+    pScreen->PositionWindow = gsxPositionWindow;
+    pScreen->ChangeWindowAttributes = gsxChangeWindowAttributes;
+    pScreen->RealizeWindow = gsxMapWindow;
+    pScreen->UnrealizeWindow = gsxUnmapWindow;
+    pScreen->PaintWindowBackground = gsxPaintWindow;
+    pScreen->PaintWindowBorder = gsxPaintWindow;
+    pScreen->CopyWindow = gsxCopyWindow;
+    pScreen->CreatePixmap = cfbCreatePixmap;
+    pScreen->DestroyPixmap = cfbDestroyPixmap;
+    pScreen->RealizeFont = mfbRealizeFont;
+    pScreen->UnrealizeFont = mfbUnrealizeFont;
+    pScreen->CreateGC = gsxCreateGC;
+    pScreen->CreateColormap = cfbInitializeColormap;
+    pScreen->DestroyColormap = (void (*)())NoopDDA;
+    pScreen->InstallColormap = cfbInstallColormap;
+    pScreen->UninstallColormap = cfbUninstallColormap;
+    pScreen->ListInstalledColormaps = cfbListInstalledColormaps;
+    pScreen->StoreColors = (void (*)())NoopDDA;
+    pScreen->ResolveColor = cfbResolveColor;
+    pScreen->BitmapToRegion = mfbPixmapToRegion;
+
+    mfbRegisterCopyPlaneProc(pScreen, miCopyPlane);
+//    mfbRegisterCopyPlaneProc(pScreen, cfbCopyPlane);
+
+    return TRUE;
+}
+
+Bool gsxFinishScreenInit( ScreenPtr pScreen, int xsize, int ysize,
+                          int dpix, int dpiy)
+{
+    VisualPtr pVisuals;
+    int       nVisuals; 
+    DepthPtr  pDepths;
+    int       nDepths;
+    VisualPtr pVisual;
+    VisualID  defaultVisualID;
+    int       rootDepth = 0;
+    int       rtn;
+    int       psm;
+    int       res;
+    int       frIndex;
+    int       fr;
+    int       hwdepth;
+    int       mode;
+
+    hwdepth = gsxGetScreenPriv(pScreen)->depth;
+    // Initialize Visual
+    rtn = gsxCreateVisuals(pScreen,&pVisuals,&nVisuals,&pDepths,&nDepths);
+    if (!rtn)	return FALSE;
+    pVisual = gsxGetVisual(nVisuals,pVisuals,TrueColor,hwdepth);
+    if (pVisual) {
+        defaultVisualID = pVisual->vid;
+        rootDepth = pVisual->nplanes;
+    } else {
+      return FALSE;
+    }
+
+    // Initialize mi
+    // We call miScreenInit with pixelWidth=0,
+    // so pScreen->CloseScreen is not changed to miCloseScreen in it.
+    if (!miScreenInit(pScreen,0/* pointer to screen bitmap */,
+                      xsize,ysize,dpix,dpiy,
+                      0/* pixel width of frame buffer */,
+                      rootDepth,nDepths,pDepths, 
+                      defaultVisualID,nVisuals,pVisuals,
+                      &gsxBSFuncs))
+        return FALSE;
+
+    // Initialize Display Cursors
+    miDCInitialize(pScreen, &gsxPointerCursorFuncs);
+
+    // Set Black & White Pixel
+    pScreen->blackPixel = gsxGetScreenPriv(pScreen)->blackPixel;
+    pScreen->whitePixel = gsxGetScreenPriv(pScreen)->whitePixel;    
+
+    psm = (hwdepth <= 16) ? PS2_GS_PSMCT16 : PS2_GS_PSMCT32;
+
+    mode = gsxGetScreenPriv(pScreen)->mode;
+    switch (mode) {
+      case PS2_GS_VESA:
+      	res = gsxGetScreenPriv(pScreen)->res | 
+		gsxGetScreenPriv(pScreen)->framerate;
+	break;
+      case PS2_GS_PAL:
+      case PS2_GS_NTSC:
+        res =  gsxGetScreenPriv(pScreen)->interlace ;
+	break;
+      default: /* PS2_GS_DTV */
+      	res = gsxGetScreenPriv(pScreen)->res;
+	break;
+    }
+
+    gsosSetScreen(
+        mode,
+        res,   
+        xsize, ysize,
+        GSX_FRAME_BASE,
+        psm,  
+	gsxGetScreenPriv(pScreen)->alpha,
+	gsxGetScreenPriv(pScreen)->dx,
+	gsxGetScreenPriv(pScreen)->dy);
+
+    // Create Default Colormap
+    return gsxCreateDefColormap(pScreen);
+
+}
+
+
+Bool gsxScreenInit( ScreenPtr pScreen, int dpixy)
+{
+  // Allocate Window & GC private
+  // setup the pScreen methods
+  if (TRUE == gsxSetupScreen(pScreen)) {
+    int w,h;
+    w = gsxGetScreenPriv(pScreen)->width;
+    h = gsxGetScreenPriv(pScreen)->height;
+    if (TRUE == gsxFinishScreenInit(pScreen, w, h, dpixy, dpixy)) {
+      return TRUE;
+    }
+    // fail in gsxFinishScreenInit
+    // Reset gsxSetupScreen
+  }
+  // fail in gsxSetupScreen
+  return FALSE;
+}
+
+
+Bool
+gsxCloseScreen (index, pScreen)
+    int         index;
+    ScreenPtr   pScreen;
+{
+    gsxScreenPrivate *pScreenPriv = gsxGetScreenPriv(pScreen);
+
+    /* save screen */
+    (void)(*pScreen->SaveScreen)(pScreen, SCREEN_SAVER_OFF);
+
+    /* clean visualIDs & visuals & depths */
+    /* VisualIDs & Visuals & Depths are in the pVisualIDs area */
+    xfree (pScreenPriv->pVisualIDs);
+
+    /* clean screen private */
+    xfree (pScreenPriv);
+
+    gsosClose();
+    return TRUE;
+}
+
+
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxtext.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxtext.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxtext.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxtext.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,68 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "gsx.h"
+
+
+void
+gsxImageText8Cached(dst, pGC, x, y, count, chars)
+    DrawablePtr     dst;
+    GCPtr       pGC;
+    int         x, y;
+    int         count;
+    char        *chars;
+{
+
+    miImageText8( dst, pGC, x, y, count, chars ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+}
+
+int
+gsxPolyText8Cached(dst, pGC, x, y, count, chars)
+    DrawablePtr     dst;
+    GCPtr       pGC;
+    int         x, y;
+    int         count;
+    char        *chars;
+{
+    int ret ;
+
+    ret = miPolyText8( dst, pGC, x, y, count, chars ) ;
+
+#if !GSX_BLOCK_FLUSH
+    _GSXFlush();
+#endif
+
+    return ret;
+}
+
+
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/gsx/gsxwindow.c XFree86.current/xc/programs/Xserver/hw/gsx/gsxwindow.c
--- XFree86/xc/programs/Xserver/hw/gsx/gsxwindow.c	Thu Jan  1 09:00:00 1970
+++ XFree86.current/xc/programs/Xserver/hw/gsx/gsxwindow.c	Fri Mar  2 18:13:28 2001
@@ -0,0 +1,406 @@
+/*
+
+Copyright (C) 2000  Sony Computer Entertainment Inc.
+
+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, FIT-
+NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+AUTHOR 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 
+Sony Computer Entertainment Inc. 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 Sony Computer Entertainment Inc.
+
+*/
+
+#include "X.h"
+#include "scrnintstr.h"
+#include "windowstr.h"
+#include "mistruct.h"
+#include "regionstr.h"
+#include "cfbmskbits.h"
+#include "pixmap.h"
+
+#include "gsx.h"
+
+extern WindowPtr *WindowTable;
+
+Bool gsxCreateWindow(pWin)
+    WindowPtr pWin;
+{
+    gsxWindowPtr pPrivWin;
+
+    pPrivWin = gsxGetWindowPriv(pWin);
+    pPrivWin->pRotatedBorder = NullPixmap;
+    pPrivWin->pRotatedBackground = NullPixmap;
+    pPrivWin->fastBackground = FALSE;
+    pPrivWin->fastBorder = FALSE;
+
+    return TRUE;
+}
+
+Bool gsxDestroyWindow(pWin)
+    WindowPtr pWin;
+{
+    gsxWindowPtr pPrivWin;
+
+    pPrivWin = gsxGetWindowPriv(pWin);
+
+    if (pPrivWin->pRotatedBorder)
+	cfbDestroyPixmap(pPrivWin->pRotatedBorder);
+    if (pPrivWin->pRotatedBackground)
+	cfbDestroyPixmap(pPrivWin->pRotatedBackground);
+    return(TRUE);
+}
+
+/*ARGSUSED*/
+Bool
+gsxMapWindow(pWindow)
+    WindowPtr pWindow;
+{
+    return(TRUE);
+}
+
+/* (x, y) is the upper left corner of the window on the screen 
+   do we really need to pass this?  (is it a;ready in pWin->absCorner?)
+   we only do the rotation for pixmaps that are 32 bits wide
+   (padded or otherwise.)
+   cfbChangeWindowAttributes() has already put a copy of the pixmap
+   in pPrivWin->pRotated*
+*/
+/*ARGSUSED*/
+Bool gsxPositionWindow(pWin, x, y)
+    WindowPtr pWin;
+    int x, y;
+{
+    return (TRUE);
+}
+
+/*ARGSUSED*/
+Bool gsxUnmapWindow(pWindow)
+    WindowPtr pWindow;
+{
+    return (TRUE);
+}
+
+Bool
+gsxChangeWindowAttributes(pWin, mask)
+    WindowPtr pWin;
+    unsigned long mask;
+{
+    return (TRUE);
+}
+
+void
+gsxPaintWindowSolid(pWin, pRegion, what, pixel)
+    WindowPtr   pWin;
+    RegionPtr   pRegion;
+    int         what;
+    Pixel       pixel;
+{
+    int          nbox = REGION_NUM_RECTS(pRegion);
+    BoxPtr       pbox = REGION_RECTS(pRegion);
+    int          r,g,b,a;
+    unsigned int rgb = pixel;
+
+    gsxFrameInit(pWin->drawable.pScreen->width, pWin->drawable.depth);
+
+    /*** color of fill ***/
+    gsxGetRgbaWithBitsPerPixel(pWin->drawable.bitsPerPixel,rgb,&r,&g,&b,&a);
+
+    /*** drawing ***/
+    while (nbox--) {
+      gsosMakeGiftag(2, GSOS_GIF_EOP_CONTINUE, GSOS_GIF_PRE_IGNORE,
+		     0, GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD);
+
+      /* set SCISSOR rect */
+      gsosSetPacketAddrData4(GSOS_SCISSOR_1,
+			      (GSOSbit64)pbox->x1, (GSOSbit64)pbox->x2-1,
+			      (GSOSbit64)pbox->y1, (GSOSbit64)pbox->y2-1);
+      gsosSetPacketAddrData(GSOS_PRIM, GSOS_PRIM_SPRITE);
+
+      gsosMakeGiftag(2, GSOS_GIF_EOP_CONTINUE,
+		     GSOS_GIF_PRE_IGNORE, 0,
+		     GSOS_GIF_FLG_PACKED, 2,
+		     (GSOS_GIF_REG_XYZ2  << 4) |
+		     (GSOS_GIF_REG_RGBAQ << 0));
+      gsosSetPacket4( r, g, b, a ) ;
+      gsosSetPacket4(GSOS_SUBPIX_OFST(pbox->x1),
+		     GSOS_SUBPIX_OFST(pbox->y1),0,0);
+
+      gsosSetPacket4( r, g, b, a ) ;
+      gsosSetPacket4(GSOS_SUBPIX_OFST(pbox->x2),
+		     GSOS_SUBPIX_OFST(pbox->y2),0,0);
+
+      pbox++;
+    }
+    gsosExec() ;
+    gsosFlush();
+}
+
+void
+gsxPaintWindowTiled(pWin, pRegion, what, pTile)
+    WindowPtr   pWin;
+    RegionPtr   pRegion;
+    int         what;
+    PixmapPtr   pTile;
+{
+    int        n;
+    BoxPtr     pbox;
+    gsxGCPtr   pPriv;
+    GSOSbit64 frame_1 ;
+    xRectangle aRect ;
+    PixmapPtr dstLop ;
+    int nn ;
+    GCPtr pGC;
+    GCPtr pGC1;
+    ChangeGCVal v[2];
+    DrawablePtr dst;
+    xRectangle rct;
+
+
+    n = REGION_NUM_RECTS(pRegion);
+    if(!n) return ;
+
+    dst = &(pWin->drawable);
+    pGC = GetScratchGC(dst->depth,dst->pScreen);
+
+    pbox  = REGION_RECTS(pRegion);
+
+    for(nn = 0; nn < n; nn++, pbox++) {
+      aRect.x = pbox->x1;
+      aRect.y = pbox->y1;
+      aRect.width  = pbox->x2 - pbox->x1;
+      aRect.height = pbox->y2 - pbox->y1;
+
+      dstLop = (*dst->pScreen->CreatePixmap)
+        (dst->pScreen, aRect.width, aRect.height, dst->depth ) ;
+      if( !dstLop ){
+        return ;
+      }
+
+      /* ValidateGC( destination = PIXMAP ) */
+      pGC1 = GetScratchGC(dst->depth, dst->pScreen);
+      v[0].val = FillTiled;
+      v[1].ptr = pTile;
+      DoChangeGC(pGC1, GCFillStyle|GCTile, (XID*)v, TRUE);
+      GSXVALIDATEGC((DrawablePtr)dstLop, pGC1);
+
+      /* copy destination */
+      pPriv = gsxGetGCPriv(pGC1);
+      frame_1 = pPriv->frame_1 ;
+      gsxReadImage(aRect.x, aRect.y, aRect.width, aRect.height,
+	   GsosFrameFbp(frame_1), GsosFrameFbw(frame_1), GsosFramePsm(frame_1),
+        dstLop);
+      
+      /* draw Rectangles */
+      /* adjust screen to pixmap */
+      rct.x = 0;
+      rct.y = 0;
+      rct.width  = aRect.width;
+      rct.height = aRect.height;
+
+      pGC1->patOrg.x = -(aRect.x - dst->x);
+      pGC1->patOrg.y = -(aRect.y - dst->y);
+      (*pGC1->ops->PolyFillRect)((DrawablePtr)dstLop, pGC1, 1, &rct);
+
+      FreeScratchGC(pGC1);
+
+      /* ValidateGC( destination = WINDOW ) */
+      GSXVALIDATEGC(dst, pGC);
+
+      /* post-proccess for LOP */
+      cfbBitBlt( (DrawablePtr)dstLop, dst, pGC,
+		 0, 0,aRect.width, aRect.height,
+		 aRect.x - dst->x, aRect.y - dst->y, gsxDoBitBlt, 0 ) ;
+      (*dst->pScreen->DestroyPixmap)(dstLop);
+    }
+    FreeScratchGC(pGC);
+}
+
+void
+gsxPaintWindow(pWin, pRegion, what)
+    WindowPtr   pWin;
+    RegionPtr   pRegion;
+    int         what;
+{
+    if (what == PW_BACKGROUND) {
+        while (pWin->backgroundState == ParentRelative)
+            pWin = pWin->parent;
+
+        switch (pWin->backgroundState) {
+        case None:
+            break;
+
+        case BackgroundPixmap:
+            gsxPaintWindowTiled(pWin,pRegion,what,
+                                pWin->background.pixmap);
+            break;
+
+        case BackgroundPixel:
+            gsxPaintWindowSolid(pWin,pRegion,what,
+                                pWin->background.pixel);
+            break;
+        }
+    } else {
+        if (pWin->borderIsPixel) {
+            gsxPaintWindowSolid(pWin,pRegion,what,
+                                pWin->border.pixel);
+        } else {
+            gsxPaintWindowTiled(pWin,pRegion,what,
+                                pWin->border.pixmap);
+        }
+    }
+}
+
+
+static void gsxCopyBuffer(pDraw, prgnDst, dx, dy)
+    DrawablePtr pDraw;
+    RegionPtr   prgnDst;
+    int         dx, dy;
+{
+  register int        nbox = REGION_NUM_RECTS(prgnDst);
+  register BoxPtr     pbox = REGION_RECTS(prgnDst);
+  BoxPtr              pboxNew1 = NULL, pboxNew2 = NULL;
+  BoxPtr              pboxTmp, pboxNext, pboxBase;
+  int                 w,h;
+  PixmapPtr           pPix;
+  int                 bp = GSX_FRAME_BASE;
+  int                 bw = (pDraw->pScreen->width +63)/64;
+  int                 psm = (pDraw->depth <= 16)? 2: 0;
+  int                 depth;
+  int                 result;
+  GSOSbit64           frame;
+  GSOSbit64           mask;
+  int                 screen_width, screen_height;
+
+  if (!nbox)
+    return;
+
+  if (dy < 0) {
+    /* walk source botttom to top */
+    /* keep ordering in each band, reverse order of bands */
+    pboxNew1 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+    if(!pboxNew1)
+      return;
+    pboxBase = pboxNext = pbox+nbox-1;
+    while (pboxBase >= pbox) {
+      while ((pboxNext >= pbox) &&
+	     (pboxBase->y1 == pboxNext->y1))
+	pboxNext--;
+      pboxTmp = pboxNext+1;
+      while (pboxTmp <= pboxBase) *pboxNew1++ = *pboxTmp++;
+      pboxBase = pboxNext;
+    }
+    pboxNew1 -= nbox;
+    pbox = pboxNew1;
+  }
+
+  if (dx < 0) {
+    /* walk source right to left */
+    /* reverse order of rects in each band */
+    pboxNew2 = (BoxPtr)ALLOCATE_LOCAL(sizeof(BoxRec) * nbox);
+    if(!pboxNew2) {
+      if (pboxNew1) DEALLOCATE_LOCAL(pboxNew1);
+      return;
+    }
+    pboxBase = pboxNext = pbox;
+    while (pboxBase < pbox+nbox) {
+      while ((pboxNext < pbox+nbox) &&
+	     (pboxNext->y1 == pboxBase->y1))
+	pboxNext++;
+      pboxTmp = pboxNext;
+      while (pboxTmp != pboxBase) *pboxNew2++ = *--pboxTmp;
+      pboxBase = pboxNext;
+    }
+    pboxNew2 -= nbox;
+    pbox = pboxNew2;
+  }
+
+  screen_width  = pDraw->pScreen->width;
+  screen_height = pDraw->pScreen->height;
+
+  /*** initialize ***/
+  gsxFrameInit(screen_width, pDraw->depth);
+
+  while (--nbox >= 0) {
+    GSOSbit64 r;
+    int srcx, srcy, dstx, dsty;
+    int mx, my;
+
+    srcx = pbox->x1 + dx;
+    srcy = pbox->y1 + dy;
+    dstx = pbox->x1;
+    dsty = pbox->y1;
+    w    = pbox->x2 - dstx;
+    h    = pbox->y2 - dsty;
+
+    gsosMakeGiftag(4, GSOS_GIF_EOP_CONTINUE, 
+		   GSOS_GIF_PRE_IGNORE, 0,
+		   GSOS_GIF_FLG_PACKED, 1, GSOS_GIF_REG_AD);
+
+    r = ( bp |
+	  (bw<<16) |
+	  ((unsigned long long) bp << 32)  |
+	  ((unsigned long long) bw << 48) |
+	  ((unsigned long long) psm << 24) |
+	  ((unsigned long long) psm << 56) );
+    gsosSetPacketAddrData(GSOS_BITBLTBUF, r);
+
+    r = (srcx |
+	 (srcy << 16) |
+	 ((unsigned long long)dstx << 32) |
+	 ((unsigned long long)dsty << 48) );
+    if(srcy > dsty || (srcy == dsty && srcx > dstx))
+      ;
+    else
+      r |= (3ULL << 59);
+    gsosSetPacketAddrData(GSOS_TRXPOS, r);
+
+    r = w | ((unsigned long long) h << 32);
+    gsosSetPacketAddrData(GSOS_TRXREG, r);
+
+    gsosSetPacketAddrData(GSOS_TRXDIR, 2);
+
+
+    pbox++;
+  }
+  gsosExec();
+  gsosFlush();
+
+  /* free up stuff */
+  if (pboxNew2) DEALLOCATE_LOCAL(pboxNew2);
+  if (pboxNew1) DEALLOCATE_LOCAL(pboxNew1);
+}
+
+
+void gsxCopyWindow(pWin, ptOldOrg, prgnSrc)
+    WindowPtr   pWin;
+    DDXPointRec ptOldOrg;
+    RegionPtr   prgnSrc;
+{
+    ScreenPtr   pScreen = pWin->drawable.pScreen;
+    int         dx = ptOldOrg.x - pWin->drawable.x;
+    int         dy = ptOldOrg.y - pWin->drawable.y;
+    RegionRec   rgnDst;
+
+    (*pScreen->RegionInit)(&rgnDst, NullBox, 0);
+    (*pScreen->TranslateRegion)(prgnSrc, -dx, -dy);
+    (*pScreen->Intersect)(&rgnDst, &pWin->borderClip, prgnSrc);
+    gsxCopyBuffer(&pWin->drawable, &rgnDst, dx, dy);
+    (*pScreen->RegionUninit)(&rgnDst);
+}
+
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/xfree86/doc/Japanese/VideoModes.doc XFree86.current/xc/programs/Xserver/hw/xfree86/doc/Japanese/VideoModes.doc
--- XFree86/xc/programs/Xserver/hw/xfree86/doc/Japanese/VideoModes.doc	Fri Dec  3 18:42:42 1999
+++ XFree86.current/xc/programs/Xserver/hw/xfree86/doc/Japanese/VideoModes.doc	Fri Mar  2 15:01:45 2001
@@ -1188,7 +1188,7 @@
   # Do `modeplot -?' to see the control options.
   # `modeplot -?' と入力すると制御オプションを見ることができます。
   #
-  # ($Id: VidModes.sgml,v 1.1 1999/08/29 15:25:21 fujiwara Exp $)
+  # ($Id: VideoModes.doc,v 1.1.1.1 2001/03/02 06:01:45 katton Exp $)
 
   # Monitor description. Bandwidth in MHz, horizontal frequencies in kHz
   # and vertical frequencies in Hz.
@@ -1245,7 +1245,7 @@
   modeplot ツールは Eric S. Raymond <esr@thyrsus.com> が
    Martin Lottermoser <Martin.Lottermoser@mch.sni.de> による
   分析と一から書いたコードを元に作成しました。
-  This is modeplot $Revision: 1.1 $
+  This is modeplot $Revision: 1.1.1.1 $
   EOF
                   exit;;
           esac
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/xfree86/doc/Japanese/modelines.txt XFree86.current/xc/programs/Xserver/hw/xfree86/doc/Japanese/modelines.txt
--- XFree86/xc/programs/Xserver/hw/xfree86/doc/Japanese/modelines.txt	Wed Jun  2 16:51:06 1999
+++ XFree86.current/xc/programs/Xserver/hw/xfree86/doc/Japanese/modelines.txt	Fri Mar  2 15:01:46 2001
@@ -1,6 +1,6 @@
 Author: Taketoshi Sano <kgh12351@nifty.ne.jp>
 Title: Modeline in XF86Config
-$Revision: 1.9 $, ($Date: 1999/05/11 00:09:43 $)
+$Revision: 1.1.1.1 $, ($Date: 2001/03/02 06:01:46 $)
 
 $B!V(B"Modeline" $B9T$K$D$$$F!W(B
 
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/VidModes.sgml XFree86.current/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/VidModes.sgml
--- XFree86/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/VidModes.sgml	Fri Dec  3 18:42:53 1999
+++ XFree86.current/xc/programs/Xserver/hw/xfree86/doc/Japanese/sgml/VidModes.sgml	Fri Mar  2 15:01:49 2001
@@ -2380,7 +2380,7 @@
 # Do `modeplot -?' to see the control options.
 # `modeplot -?' と入力すると制御オプションを見ることができます。
 #
-# ($Id: VidModes.sgml,v 3.2.2.2 1999/05/25 12:00:33 hohndel Exp $)
+# ($Id: VidModes.sgml,v 1.1.1.1 2001/03/02 06:01:49 katton Exp $)
 
 # Monitor description. Bandwidth in MHz, horizontal frequencies in kHz
 # and vertical frequencies in Hz.
@@ -2438,7 +2438,7 @@
  Martin Lottermoser <Martin.Lottermoser@mch.sni.de> による
 分析と一から書いたコードを元に作成しました。
 
-This is modeplot $Revision: 3.2.2.2 $
+This is modeplot $Revision: 1.1.1.1 $
 EOF
 		exit;;
 	esac
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/xfree86/doc/VideoModes.doc XFree86.current/xc/programs/Xserver/hw/xfree86/doc/VideoModes.doc
--- XFree86/xc/programs/Xserver/hw/xfree86/doc/VideoModes.doc	Fri Jun 25 19:49:11 1999
+++ XFree86.current/xc/programs/Xserver/hw/xfree86/doc/VideoModes.doc	Fri Mar  2 15:01:43 2001
@@ -1123,7 +1123,7 @@
      #
      # Do `modeplot -?' to see the control options.
      #
-     # ($Id: VidModes.sgml,v 3.11.2.2 1998/02/20 23:10:30 dawes Exp $)
+     # ($Id: VideoModes.doc,v 1.1.1.1 2001/03/02 06:01:43 katton Exp $)
 
      # Monitor description. Bandwidth in MHz, horizontal frequencies in kHz
      # and vertical frequencies in Hz.
@@ -1162,7 +1162,7 @@
      The modeplot tool was created by Eric S. Raymond <esr@thyrsus.com> based on
      analysis and scratch code by Martin Lottermoser <Martin.Lottermoser@mch.sni.de>
 
-     This is modeplot $Revision: 3.11.2.2 $
+     This is modeplot $Revision: 1.1.1.1 $
      EOF
                exit;;
           esac
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/hw/xfree86/doc/sgml/VidModes.sgml XFree86.current/xc/programs/Xserver/hw/xfree86/doc/sgml/VidModes.sgml
--- XFree86/xc/programs/Xserver/hw/xfree86/doc/sgml/VidModes.sgml	Sun Feb 22 10:35:16 1998
+++ XFree86.current/xc/programs/Xserver/hw/xfree86/doc/sgml/VidModes.sgml	Fri Mar  2 15:01:53 2001
@@ -1196,7 +1196,7 @@
 #
 # Do `modeplot -?' to see the control options.
 #
-# ($Id: video-modes.sgml,v 1.2 1997/08/08 15:07:24 esr Exp $)
+# ($Id: VidModes.sgml,v 1.1.1.1 2001/03/02 06:01:53 katton Exp $)
 
 # Monitor description. Bandwidth in MHz, horizontal frequencies in kHz
 # and vertical frequencies in Hz.
@@ -1235,7 +1235,7 @@
 The modeplot tool was created by Eric S. Raymond <esr@thyrsus.com> based on
 analysis and scratch code by Martin Lottermoser <Martin.Lottermoser@mch.sni.de>
 
-This is modeplot $Revision: 1.2 $
+This is modeplot $Revision: 1.1.1.1 $
 EOF
 		exit;;
 	esac
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/Xserver/include/misc.h XFree86.current/xc/programs/Xserver/include/misc.h
--- XFree86/xc/programs/Xserver/include/misc.h	Mon Dec 23 16:09:29 1996
+++ XFree86.current/xc/programs/Xserver/include/misc.h	Thu Mar  8 18:03:49 2001
@@ -158,11 +158,11 @@
 
 #define min(a, b) (((a) < (b)) ? (a) : (b))
 #define max(a, b) (((a) > (b)) ? (a) : (b))
-#if !defined(AMOEBA) && !defined(__EMX__)
+#if !defined(AMOEBA) && !defined(__EMX__) && !defined(__linux__)
 #ifndef abs
 #define abs(a) ((a) > 0 ? (a) : -(a))
 #endif
-#else /* AMOEBA || __EMX__ */
+#else /* AMOEBA || __EMX__ || __linux__ */
 /* abs() is a function, not a macro; include the file declaring
  * it in case we haven't done that yet.
  */  
diff -uNr --exclude=CVS --exclude=.cvsignore --exclude *.orig --exclude *.rej XFree86/xc/programs/xfs/include/misc.h XFree86.current/xc/programs/xfs/include/misc.h
--- XFree86/xc/programs/xfs/include/misc.h	Wed Jun 14 16:54:54 1995
+++ XFree86.current/xc/programs/xfs/include/misc.h	Thu Mar  8 19:03:55 2001
@@ -79,7 +79,11 @@
 
 #define	min(a, b)	(((a) < (b)) ? (a) : (b))
 #define	max(a, b)	(((a) > (b)) ? (a) : (b))
+#ifdef __linux__
+#include <stdlib.h>
+#else
 #define	abs(a)		((a) > 0 ? (a) : -(a))
+#endif
 
 #include	"os.h"
 
