Prereq: 2.0

diff -c mit/server/ddx/x386/x386Version.h:2.44 mit/server/ddx/x386/x386Version.h:2.64
*** mit/server/ddx/x386/x386Version.h:2.44	Fri Mar 11 23:35:51 1994
--- mit/server/ddx/x386/x386Version.h	Fri Mar 11 23:35:51 1994
***************
*** 1,3 ****
! /* $XFree86: mit/server/ddx/x386/x386Version.h,v 2.44 1993/10/18 12:16:19 dawes Exp $ */
  
! #define X386_VERSION " 2.0 "
--- 1,3 ----
! /* $XFree86: mit/server/ddx/x386/x386Version.h,v 2.64 1994/03/08 04:46:31 dawes Exp $ */
  
! #define X386_VERSION " 2.1 "
diff -c mit/server/ddx/cfb/cfbrrop.h:1.1.1.1 mit/server/ddx/cfb/cfbrrop.h:2.0
*** mit/server/ddx/cfb/cfbrrop.h:1.1.1.1	Fri Mar 11 23:35:07 1994
--- mit/server/ddx/cfb/cfbrrop.h	Fri Mar 11 23:35:07 1994
***************
*** 1,4 ****
--- 1,5 ----
  /*
+  * $XFree86: mit/server/ddx/cfb/cfbrrop.h,v 2.0 1993/12/10 14:33:58 dawes Exp $
   * $XConsortium: cfbrrop.h,v 1.6 91/04/10 11:42:06 keith Exp $
   *
   * Copyright 1989 Massachusetts Institute of Technology
***************
*** 128,134 ****
      }
  #endif
  
! #if __STDC__ && !defined(UNIXCPP)
  #define RROP_NAME_CAT(prefix,suffix)	prefix##suffix
  #else
  #define RROP_NAME_CAT(prefix,suffix)	prefix/**/suffix
--- 129,135 ----
      }
  #endif
  
! #if (__STDC__ && !defined(UNIXCPP)) || (defined (SOLX86) && defined (__STDC__) && !defined (__GNUC__))
  #define RROP_NAME_CAT(prefix,suffix)	prefix##suffix
  #else
  #define RROP_NAME_CAT(prefix,suffix)	prefix/**/suffix
diff -c mit/server/ddx/mfb/maskbits.h:1.6 mit/server/ddx/mfb/maskbits.h:2.0
*** mit/server/ddx/mfb/maskbits.h:1.6	Fri Mar 11 23:35:12 1994
--- mit/server/ddx/mfb/maskbits.h	Fri Mar 11 23:35:13 1994
***************
*** 22,28 ****
  SOFTWARE.
  
  ******************************************************************/
! /* $XFree86: mit/server/ddx/mfb/maskbits.h,v 1.6 1993/03/27 09:00:31 dawes Exp $ */
  /* $XConsortium: maskbits.h,v 1.26 91/07/09 19:44:24 keith Exp $ */
  #include "X.h"
  #include "Xmd.h"
--- 22,28 ----
  SOFTWARE.
  
  ******************************************************************/
! /* $XFree86: mit/server/ddx/mfb/maskbits.h,v 2.0 1993/11/24 12:32:34 dawes Exp $ */
  /* $XConsortium: maskbits.h,v 1.26 91/07/09 19:44:24 keith Exp $ */
  #include "X.h"
  #include "Xmd.h"
***************
*** 400,407 ****
--- 400,409 ----
  	int m = 32-(x); \
  	*MAPW(pdst) = ((*MAPR(pdst)) & endtab[x]) | (t2 & starttab[x]); \
  	t1 = SCRLEFT((src), m); \
+ 	CHECKRWONEXT(pdst); \
  	DoRop(t2, rop, t1, *MAPR(&((pdst)[1]))); \
  	*MAPW(&((pdst)[1])) = ((*MAPR(&((pdst)[1]))) & starttab[n]) | (t2 & endtab[n]); \
+ 	CHECKRWU(pdst); \
      } \
  }
  
diff -c mit/server/ddx/mfb/mergerop.h:1.1.1.1 mit/server/ddx/mfb/mergerop.h:2.0
*** mit/server/ddx/mfb/mergerop.h:1.1.1.1	Fri Mar 11 23:35:13 1994
--- mit/server/ddx/mfb/mergerop.h	Fri Mar 11 23:35:13 1994
***************
*** 1,4 ****
--- 1,5 ----
  /*
+  * $XFree86: mit/server/ddx/mfb/mergerop.h,v 2.0 1993/12/10 14:34:07 dawes Exp $
   * $XConsortium: mergerop.h,v 1.7 91/07/18 22:54:58 keith Exp $
   *
   * Copyright 1989 Massachusetts Institute of Technology
***************
*** 176,182 ****
  #define MROP_PREBUILT_MASK(src,dst,mask)    MROP_MASK(src,dst,mask)
  #endif
  
! #if __STDC__ && !defined(UNIXCPP)
  #define MROP_NAME_CAT(prefix,suffix)	prefix##suffix
  #else
  #define MROP_NAME_CAT(prefix,suffix)	prefix/**/suffix
--- 177,183 ----
  #define MROP_PREBUILT_MASK(src,dst,mask)    MROP_MASK(src,dst,mask)
  #endif
  
! #if (__STDC__ && !defined(UNIXCPP)) || (defined (SOLX86) && defined (__STDC__) && !defined (__GNUC__))
  #define MROP_NAME_CAT(prefix,suffix)	prefix##suffix
  #else
  #define MROP_NAME_CAT(prefix,suffix)	prefix/**/suffix
diff -c mit/server/ddx/mfb/mfbmap.h:1.3 mit/server/ddx/mfb/mfbmap.h:2.0
*** mit/server/ddx/mfb/mfbmap.h:1.3	Fri Mar 11 23:35:13 1994
--- mit/server/ddx/mfb/mfbmap.h	Fri Mar 11 23:35:14 1994
***************
*** 1,6 ****
! /* $XFree86: mit/server/ddx/mfb/mfbmap.h,v 1.3 1993/02/27 04:31:11 dawes Exp $ */
  
! #if __STDC__ && !defined(UNIXCPP)
  #define CATNAME(prefix,subname) prefix##subname
  #else
  #define CATNAME(prefix,subname) prefix/**/subname
--- 1,6 ----
! /* $XFree86: mit/server/ddx/mfb/mfbmap.h,v 2.0 1993/12/10 14:34:08 dawes Exp $ */
  
! #if (__STDC__ && !defined(UNIXCPP)) || (defined (SOLX86) && defined (__STDC__) && !defined (__GNUC__))
  #define CATNAME(prefix,subname) prefix##subname
  #else
  #define CATNAME(prefix,subname) prefix/**/subname
diff -c mit/server/ddx/mi/cbrt.c:1.1.1.1 mit/server/ddx/mi/cbrt.c:2.0
*** mit/server/ddx/mi/cbrt.c:1.1.1.1	Fri Mar 11 23:35:21 1994
--- mit/server/ddx/mi/cbrt.c	Fri Mar 11 23:35:21 1994
***************
*** 1,3 ****
--- 1,4 ----
+ /* $XFree86: mit/server/ddx/mi/cbrt.c,v 2.0 1994/03/06 06:42:53 dawes Exp $ */
  /* $XConsortium: cbrt.c,v 1.0 90/09/29 10:24:02 rws Exp $ */
  
  /* simple cbrt, in case your math library doesn't have a good one */
***************
*** 8,12 ****
  cbrt(x)
      double x;
  {
!     return pow(x, 1.0/3.0);
  }
--- 9,16 ----
  cbrt(x)
      double x;
  {
!     if (x > 0.0)
! 	return pow(x, 1.0/3.0);
!     else
! 	return -pow(-x, 1.0/3.0);
  }
diff -c mit/server/ddx/x386/CHANGELOG:2.91 mit/server/ddx/x386/CHANGELOG:2.141
*** mit/server/ddx/x386/CHANGELOG:2.91	Fri Mar 11 23:35:29 1994
--- mit/server/ddx/x386/CHANGELOG	Fri Mar 11 23:35:30 1994
***************
*** 1,3 ****
--- 1,261 ----
+ XFree86 2.1 (11 March 1994)
+ 151. OS README updates (affect individual OSs only)
+ 150. Fix AltGr handling for Linux (affects Linux only)
+ 149. Comment out the unused s3Save() and s3Restore() functions -- a typo in
+      some unreachable code may cause problems with some compilers (should not
+      affect any OSs)
+ 148. Linux compile-time fix for fonts/PEX/lex.l (affects Linux only)
+ 147. Late cirrus fix for large tiles
+ 146. Fix for LinkKit site.def and Imakefile (remove dbm references)
+ 
+ XFree86 2.0Z (8 March 1994)
+ 145. Fix text/graphics mode switching for pixmux with SPEA Mercury.  This
+      code is now reasonably stable (interlace support is still absent though)
+      (Norbert Distler)
+ 144. Fix for cirrus stipple fill when virtual width is not a multiple of 32
+ 143. Linux keyboard updates
+ 
+ XFree86 2.0Ce (7 March 1994)
+ 142. Preliminary support for Bt485 pixel multiplexing on the SPEA Mercury
+      card (Norbert Distler)
+ 141. More documentation updates
+ 140. SuperProbe updates (ATI and Weitek fixes)
+ 139. Fix for second MB cirrus BitBLT but -- BitBLT now turned back on for
+      2MB cards (Wolfgang Jung)
+ 
+ XFree86 2.0Cd (6 March 1994)
+ 138. Default to building shared libs for FreeBSD
+ 137. Updates to cirrus driver: (Harm Hanemaayer)
+       New Option flag "no_2mb_banksel" for cards that have 2MB in the form
+         of 512kx8 DRAMS (4 chips)
+       Disable BitBLT engine use when using more than 1MB because there
+         are problems
+       New text bitmap transfer code
+ 136. Documentation updates
+ 135. Fix mi/cbrt.c so it handles negative arguments.
+ 
+ XFree86 2.0Cc (5 March 1994)
+ 134. Update x386/etc/console.h to current version
+ 133. Some documentation updates (including removing README.XS3)
+ 132. Updates to cirrus driver: (Harm Hanemaayer)
+       New option flags "fifo_conservative" and "fifo_aggressive" to
+         control the CRTC fifo threshold.
+       Reduce clock limit for the 5420
+       Remove accelerated PolyGlyphBlt -- it causes problems
+ 131. Modify pvga1 driver to detect the 90C24 and treat it as a 90C30
+ 130. Support for the SC15025 RAMDAC in 8-bit/RGB mode (requires
+      the "sc15025" and "dac_8_bit" options) (Helmut Geyer)
+ 129. Fix vga colourmap save/restore when using a RAMDAC in 8-bit mode (Helmut
+      Geyer)
+ 
+ XFree86 2.0Cb (3 March 1994)
+ 128. Fix for "snow" problems on WD90C3x cards with 80MHz clock (Anders Bostrom)
+ 127. Fixes for compilation problems on Mach and ISC
+ 126. Support for 8-bit/RGB for the AT&T 20C490/491 ramdacs (S3 server).
+      There is no auto-detect, so the "att_20c490_1" Option must be
+      specified (together with the "dac_8_bit" Option)
+ 125. Added some sample patches from Gertjan Akkerman which document some
+      useful changes which could me made to the VGA16 server (these are
+      in x386/vga16/doc/).
+ 124. Fix Mach8 and Mach32 server hang when run on a card with no Mach chip
+ 123. Update xterm's terminfo file
+ 122. Install mit/config/README in lib/X11/config
+ 121. Modify Trident driver to recognise the 9000i, 9200CX, 9100B and 9420
+      chipsets.  The first is treated as a 9000, and the last three are
+      treated as a 8900CL.
+ 
+ XFree86 2.0Ca (2 March 1994)
+ 120. Fix CR60 setting for clocks > 100MHz (S3 server)
+ 119. Fix cirrus compilation on SVR4, and bsd_init.c typo
+ 118. Enable Home/End esc sequences for xterm on all OSs
+ 117. SuperProbe register unlock fixes
+ 
+ XFree86 2.0C (1 March 1994)
+ 116. Allow the MIT-SHM extension to be disabled at run-time on BSD systems
+      when kernel support for sysv-shm isn't present
+ 115. Enable Home/End esc sequences for xterm (Linux only -- should this be
+      extended?)
+ 114. Set default xterm tty parameters to reasonable values (fixes problems
+      seen when using xdm)
+ 113. gccmakedep fix (David McCullough)
+ 112. Special-case code for lines where this is one rectangle in the clip
+      region -- for Mach32 (Craig Groeschel)
+ 111. Update to compaq probe code -- hopefully this will reduce the number
+      of false positives
+ 110. Major updates to SuperProbe
+ 109. Cirrus driver patches
+ 
+ XFree86 2.0Bb (27 February 1994)
+ 108. Removed experimental "cr60=..." options (S3), and made CR60=0xFF
+      the default setting.  The "dram_{slow,med,fast}" options still remain
+      as un-documented options (just in case).
+ 107. Manual page updates
+ 106. Support for linear fb location on Mach32 PCI cards
+ 105. Include Solaris x86 "aperture driver" (Doug Anson and David Holland)
+ 104. Updated Thomas Wolfram's SVR3 mmap driver to version 2.2.3
+ 103. Allow the MemBase setting in Xconfig specify the high 5 bits of the
+      4MB aperture address for the Mach32 server, and the high 6 bits of
+      the LAW address for the S3 server
+ 
+ XFree86 2.0Ba (25 February 1994)
+ 102. Fix/speedup for window->pixmap part of CopyPlane() in the accel servers
+ 101. Fix bits per RGB reported for S3 server when using 8bpRGB
+ 100. Modify code for determining when pixel multiplexing is required for
+      the S3 server, and restrict the DisplayWidth to either 1024 or 2048 when
+      pixel multiplexing is used
+  99. Preliminary support for the SC11412 clock chip used on the SPEA Mercury
+      (S3).  Use 'Clocks "sc11412"' to select this (Norbert Distler)
+  98. "icd2061a" now uses the "icd2061a_slow" clock setting algorithm.
+      The name "icd2061a_slow" will be dropped in the release after 2.1
+  97. Fixes for zero-width arcs for the VGA16 server (Gertjan Akkerman)
+  96. Support for David Holland's "aperture driver" for linear fbs on Solaris
+  95. Fix Solaris panic when no free VTs are available
+  94. Much-enhanced accelerated support for Cirrus chips (Harm Hanemaayer)
+  93. Support for up to 17 clocks on WD90C3x cards (Anders Bostrom)
+  92. Fix for Compaq avga driver
+  91. Keyboard updates to handle Linux' key remapping (Orest Zborowski)
+  90. README for Solaris (David Holland)
+ 
+ XFree86 2.0B (21 February 1994)
+  89. Possible fix for Bt probe problem that some people see
+ 
+ XFree86 2.0Ab (19 February 1994)
+  88. Combine DRAM and non-DRAM mach8 image assembler code into single files
+      with #ifdefs
+  87. Fix for hga2 driver to prevent it from blanking MDA displays when
+      swithching back to text mode
+  86. Code to explicitly recognise the *BSD PCVT console driver
+  85. Preliminary support for the S3 805i in interleaved mode
+  85. Fix for single-bank SVGA bitblt code (Giovanni Novelli)
+  84. Fix alu usage in mach32CopyArea() (Craig Groeschel)
+  83. Fix dash line support in Mach32 server (Mike Bernson)
+ 
+ XFree86 2.0Aa (13 February 1994)
+  82. S3 "No_Bt485" and "No_Ti3020" options have been replaced by "Normal_DAC",
+      and a "20C505" option has been added
+  81. ATI text restore fixes for Mach32 server (Ton van Rosmalen)
+  80. Planemask fixes for Mach32GetImage() (Craig Groeschel)
+  79. Prevent S3 Ti cursor from being turned on when the screen is blanked
+  78. No longer define __386BSD__ for BSD/386, NetBSD, FreeBSD.  Change
+      the FreeBSD define from -DFreeBSD to -D__FreeBSD__.  Code outside
+      ddx/x386 now uses the value of BSD (from <sys/param.h>) and for
+      code below ddx/x386, __BSD__ is defined for all the x86 BSD OSs
+  77. Rewrite of Mach32 memory detection code (Mark Weaver)
+  76. Set clock-doubler cut-in to 67.5MHz for Bt485 and 90MHz for AT&T 20C505
+  75. Add ClearRTS option (some mice seem to need it)
+  74. Mach8 server now uses a 1024 line pitch (regardless of virtualX) for
+      cards with 1MB
+  73. Support for bank switching with the VGA16 server. Staticgray and
+      Grayscale visuals added to the VGA16 server (Gertjan Akkerman)
+  72. Slowed down image routines for DRAM based Mach8 cards (Hans Nasten)
+  71. Improvements to solx86 in/out assembler code, and removal of the
+      broken ProworksMOption
+ 
+ XFree86 2.0A (15 January 1994)
+  70. Increase Bt485 clock-doubler cut-in point from 67.5MHz to 90MHz.  This
+      should fix the "flashing pixel" problem many have reported
+  69. Mach8 font cache performance updates
+  68. Update assembler code and SuperProbe Makefile.std for the ProWorks
+      compile on Solaris x86
+  67. Ti3020 probe code for SuperProbe (Robin Cutshaw)
+  66. Fix Mach32 server to recognise PCI cards
+ 
+ XFree86 2.0g (9 January 1994)
+  65. Clock probe code for Mach32 server
+  64. Support for TI3020 ramdac for S3 server (Robin Cutshaw)
+  63. Fix server crash problem if reset occurs when VT switched away
+  62. Make accel servers honour the -dpi flag
+  61. Mach8 font cache updates
+  60. Support for the ProWorks compiler on Solarix x86
+  59. Add memory probe to SuperProbe (only for a couple of chipsets so far)
+  58. Support for display widths of 640, 800 and 2048 with S3 server
+  57. Generalise S3 HW cursor memory allocation -- fixes problems that showed
+      up with some virtualY/displaywidth combinations, and will work for
+      display widths < 1024
+ 
+ XFree86 2.0f (27 December 1993)
+  56. Fix mach32RecolorCursor() SIGSEGV when VT switched away
+  55. Possible fix for cases where the S3 linear fb probe fails the first
+      time the server is started but succeeds on subsequent times
+  54. Updates to Mach32 memory probe
+  53. Fixes for ATI SVGA save/restore code (Ton van Rosmalen)
+  52. Fix xman's handling of nroff bullets and bolding (Rich Murphey)
+  51. Mach8 font cache updates (Hans Nasten)
+  50. Mach32 HW cursor fixes (Mark Weaver)
+  49. Change "makedepend" for systems with gcc to use "gcc -M" (based on
+      code from Hongjiu Lu).  This is much slower than the other version,
+      and maybe should be disabled by default for !UseInstalled
+ 
+ XFree86 2.0e (18 December 1993)
+  48. SuperProbe updates (details in SuperProbe/ChangeLog)
+  47. Imake updates for NetBSD
+  46. Ramdac multiplexing for Mach32 cards with TLC34075 (and ATI68875?)
+      ramdacs (Mike Bernson)
+  45. Imake changes to allow easy building of just the servers with a
+      cut-down source tree
+  44. Fix ClearDTR -- now it clears *only* the DTR line
+ 
+ XFree86 2.0d (11 December 1993)
+  43. Xconfig keyboard option: VTSysReq to enable SVR4-style VT switching
+      sequence on Linux and *BSD+syscons
+  42. Solaris 2.x x86 support (David Holland, Doug Anson)
+  41. Accelerated dline and dseg for Mach32 (Mike Bernson)
+  40. Accelerated non-cache text code for Mach8 (Hans Nasten)
+  39. VirtualY limit removed for Mach8 (cache can be disabled)
+  38. Dynamic allocation for font cache for Mach8 (Hans Nasten)
+  37. New GetImage for Mach32 (Mike Bernson)
+  36. Support for linear fb on *BSD with mmapable /dev/mem
+  35. Preliminary support for 1152 width on Rev C 801 and Rev E 928, and
+      1600 width on Rev E 928 in S3 server
+ 
+ XFree86 2.0c (3 December 1993)
+  34. Support for 8-bit/gun for Mach32 server (Craig Groeschel)
+  33. New GetImage() for Mach8 and 8514
+  32. Fix error message printed when no appropriate graphics sections are
+      present in Xconfig
+  31. Add a "fb_debug" option to the S3 server
+  30. MemBase Xconfig parameter added to allow the fb base address to be
+      specified.  This is currently used only by some bdm2 drivers
+  29. Support added to bdm2 for Visa board (untested)
+  28. HGC-1280 now supported on both primary and secondary addresses
+  27. Sigma L-View driver tested and works now
+  26. Code from ATI to work around memory probing problems with some Mach32
+      chips (untested)
+  25. Workaround for some 2MB DRAM ATI cards (eg, CLX).  This allows the
+      VideoRam amount specified in Xconfig to override the detected value
+  24. Support for NetBSD/FreeBSD shared libraries (John Brezak & ??)
+  23. Add option "intel_gx" to handle linear fb on Intel GX/Pro (Mach32)
+  22. Composite sync support for Mach8
+  21. Allow linear fb for EISA S3 cards
+  20. Fix s3RecolorCursor() SIGSEGV when VT switched away
+ 
+ XFree86 2.0b (14 November 1993)
+  19. Add virtualY <= 896 check to Mach8 server
+  18. Restore settings for VGA aperture mapping if linear fb access fails for,
+      S3.  Also restore those registers at exit
+  17. Merge in MIT fix-26 (mainly xterm security patch)
+  16. Fix S3 interlaced modes with VTotal > 1025.
+  15. Hack for 1280x1024 on S3 801 with 110MHz clock
+  14. Composite sync support for Mach32 (Todd Pfaff)
+ 
+ XFree86 2.0a (9 November 1993)
+  13. Speedup for aligned <=16 bit wide stipple ops for Mach8 and 8514
+  12. Fix NULL dereference when ModeDB is empty (Bill Metzenthen)
+  11. make mit/rgb consistent with the server's usage of it.  showrgb can now
+      read rgb.txt directly, and [sng]dbm is no longer required
+  10. Attempt to clean up strerror() vs sys_errlist[] usage outside ddx/x386
+   9. Disable saving the Tek screen to a file in xterm -- a quick hack to
+      get around another security problem.  An official X Consortium fix
+      should be available soon
+   8. Fix vgaFasm.h so it works for gcc2 with '-traditional'
+   7. Fix clock probing problem in pvga1 driver
+   6. Fix typo in xf86_OSlib.h
+   5. Fix ClockProg informational message
+   4. Truncate clock values to MHz resolution when checking against the limit
+   3. Fix bug in LinkKit Imakefile
+   2. Fix malloc problem in the PEX font reader
+   1. Some documentation fixes
+ 
  XFree86 2.0 (24 October 1993)
  247. Documentation finalised
  246. Fix for VT switching problem with Mach32 server
diff -c mit/server/ddx/x386/INSTALL:2.4 mit/server/ddx/x386/INSTALL:2.7
*** mit/server/ddx/x386/INSTALL:2.4	Fri Mar 11 23:35:31 1994
--- mit/server/ddx/x386/INSTALL	Fri Mar 11 23:35:31 1994
***************
*** 1,5 ****
  
!                  Installation Guide for XFree86 2.0
                   ----------------------------------
  
  Contents
--- 1,5 ----
  
!                  Installation Guide for XFree86 2.1
                   ----------------------------------
  
  Contents
***************
*** 28,34 ****
        An additional 20-30MB (for OSs with shared libraries) or 30-50MB
        (for OSs without shared libraries) is required to install the built
        binaries, fonts, etc,
!     - MIT X11R5 distribution with fixes 01-25 applied.  If you want to
        minimise disk usage, you can remove some or all of the following
        directories:
  
--- 28,34 ----
        An additional 20-30MB (for OSs with shared libraries) or 30-50MB
        (for OSs without shared libraries) is required to install the built
        binaries, fonts, etc,
!     - MIT X11R5 distribution with fixes 01-26 applied.  If you want to
        minimise disk usage, you can remove some or all of the following
        directories:
  
***************
*** 54,84 ****
  
           k14.bdf             hang*.bdf         jiskan*.bdf
  
!     - XFree86-2.0.diff.gz, XFree86-2.0.tar.gz, sdbm.tar.gz (for SVR4 and
!       some SVR3), and optionally Type1.tar.gz, Type1.patch1.gz,
!       Type1.patch2.gz if you wish to built the Adobe Type-1 font renderer.
! 
!     - If you are upgrading from XFree86 version 1.3, you will only need
!       1.3-2.0.diff.gz.
! 
! 2. If you need to use libsdbm.a, extract sdbm.tar.gz somewhere and build
!    it.  Install libsdbm.a in a directory your ld searches.  (You could use
!    /usr/local/lib, and with SVR4 add it to your LD_LIBRARY_PATH.)  Install
!    sdbm.h in /usr/include.
  
! 3. If you are starting from the stock MIT PL25 distribution, go to the
     directory above your 'mit' directory, and run:
  
        rm -fr mit/server/ddx/x386
  
!    then extract XFree86-2.0.tar.gz:
  
!       gzip -d < XFree86-2.0.tar.gz | tar vxf -
  
!    This tar file contains the XFree86 2.0 version of mit/server/ddx/x386.
     Then apply the patch:
     
!       gzip -d < XFree86-2.0.diff.gz | patch -p
  
     If you are installing in an unmodified tree there shouldn't be any
     problems.  Check for any patch rejections and resolve them. If you've
--- 54,92 ----
  
           k14.bdf             hang*.bdf         jiskan*.bdf
  
!     - It is possible to configure a cut-down source tree for building only
!       the XFree86 servers.  Building from a cut-down source tree requires
!       about 30-35MB of disk space.  Such a source tree can be obtained by
!       additionally removing the following directories:
!  
!         mit/clients                     mit/demos
!         mit/extensions/lib              mit/fonts/bdf
!         mit/fonts/clients               mit/fonts/scaled
!         mit/fonts/server                mit/lib/X
!         mit/lib/Xaw                     mit/lib/Xmu
!         mit/lib/Xt                      mit/lib/nls
!         mit/man                      
!         
!     - XFree86-2.1.diff.gz, XFree86-2.1.tar.gz, and optionally
!       Type1.tar.gz, Type1.patch1.gz, Type1.patch2.gz if you wish to
!       built the Adobe Type-1 font renderer.
  
!     - If you are upgrading from XFree86 version 2.0, you will only need
!       2.0-2.1.diff.gz.
! 
! 2. If you are starting from the stock MIT PL26 distribution, go to the
     directory above your 'mit' directory, and run:
  
        rm -fr mit/server/ddx/x386
  
!    then extract XFree86-2.1.tar.gz:
  
!       gzip -d < XFree86-2.1.tar.gz | tar vxf -
  
!    This tar file contains the XFree86 2.1 version of mit/server/ddx/x386.
     Then apply the patch:
     
!       gzip -d < XFree86-2.1.diff.gz | patch -p
  
     If you are installing in an unmodified tree there shouldn't be any
     problems.  Check for any patch rejections and resolve them. If you've
***************
*** 90,99 ****
     If you are patching a tree that you've previously used, make sure you
     run 'make clean' from the 'mit' directory before applying the diffs.
  
! 4. If you are upgrading your source tree from XFree86 version 1.3, go to
     the directory above your 'mit' directory, and run:
  
!       gzip -d < 1.3-2.0.diff.gz | patch -p -E
  
     If your version of 'patch' doesn't support the '-E' flag, get a newer
     version before patching.  The use of the '-E' flag is important because
--- 98,107 ----
     If you are patching a tree that you've previously used, make sure you
     run 'make clean' from the 'mit' directory before applying the diffs.
  
! 3. If you are upgrading your source tree from XFree86 version 2.0, go to
     the directory above your 'mit' directory, and run:
  
!       gzip -d < 2.0-2.1.diff.gz | patch -p -E
  
     If your version of 'patch' doesn't support the '-E' flag, get a newer
     version before patching.  The use of the '-E' flag is important because
***************
*** 103,114 ****
     If you are installing in an unmodified tree there shouldn't be any
     problems.  Check for any patch rejections and resolve them. If you've
     modified some files (e.g. x386.cf, site.def) you should rename them, and
!    restore the 1.3 versions before patching.
  
     If you are patching a tree that you've previously used, make sure you
     run 'make clean' from the 'mit' directory before applying the diffs.
  
! 5. If you want to include the Type1 font code, extract Type1.tar.gz in
     mit/fonts/lib/font, and then apply the Type1 patches.  Some contributed
     fonts can be found on ftp.x.org in:
  
--- 111,122 ----
     If you are installing in an unmodified tree there shouldn't be any
     problems.  Check for any patch rejections and resolve them. If you've
     modified some files (e.g. x386.cf, site.def) you should rename them, and
!    restore the 2.0 versions before patching.
  
     If you are patching a tree that you've previously used, make sure you
     run 'make clean' from the 'mit' directory before applying the diffs.
  
! 4. If you want to include the Type1 font code, extract Type1.tar.gz in
     mit/fonts/lib/font, and then apply the Type1 patches.  Some contributed
     fonts can be found on ftp.x.org in:
  
***************
*** 115,121 ****
         /pub/R5untarred/contrib/fonts/scaled/Type1
         /pub/R5untarred/contrib/fonts/Utopia
  
! 6. Have a look at config/site.def.  Set the various parameters to suit your
     configuration.  If it is your first build, you should set BuildFonts,
     InstallXdmConfig, InstallXinitConfig to YES (as well as InstallFSConfig
     if you are building the Font Server).  If you have installed
--- 123,129 ----
         /pub/R5untarred/contrib/fonts/scaled/Type1
         /pub/R5untarred/contrib/fonts/Utopia
  
! 5. Have a look at config/site.def.  Set the various parameters to suit your
     configuration.  If it is your first build, you should set BuildFonts,
     InstallXdmConfig, InstallXinitConfig to YES (as well as InstallFSConfig
     if you are building the Font Server).  If you have installed
***************
*** 122,129 ****
     Type1.tar.gz, set BuildType1 to YES.  If you want to build the large
     fonts in mit/fonts/bdf/misc set BuildLargeMiscFonts to YES.  If you want
     to build the 100dpi fonts as well as the 75dpi fonts set Build100Dpi to
!    YES.  Make sure both HasNdbm and HasSdbm are set correctly for the
!    [n]dbm library you are using.
  
     Set the defines to specify which server(s) you want to build:
  
--- 130,139 ----
     Type1.tar.gz, set BuildType1 to YES.  If you want to build the large
     fonts in mit/fonts/bdf/misc set BuildLargeMiscFonts to YES.  If you want
     to build the 100dpi fonts as well as the 75dpi fonts set Build100Dpi to
!    YES.
! 
!    If you are using a cut-down source tree for building only the servers,
!    set BuildServersOnly to YES.
  
     Set the defines to specify which server(s) you want to build:
  
***************
*** 157,163 ****
  
     The VGA16 and VGA2 screens both have `generic' drivers, and these should
     always be last in the list because their probe will succeed for any VGA
!    card.  Similarly, the S3 server has a 'generic_s3' driver which will
     function with any S3 card.
  
     Note:
--- 167,173 ----
  
     The VGA16 and VGA2 screens both have `generic' drivers, and these should
     always be last in the list because their probe will succeed for any VGA
!    card.  Similarly, the S3 server has a 's3_generic' driver which will
     function with any S3 card.
  
     Note:
***************
*** 164,170 ****
          it is not possible to have both the monochrome and colour drivers
          in the same server executable.
  
! 7. The following server connection defaults are set up by x386.cf, and
     there should be little reason to change them.  For an explanation of how
     these connection modes are used, refer to the XFree86(1) manual page.
  
--- 174,180 ----
          it is not possible to have both the monochrome and colour drivers
          in the same server executable.
  
! 6. The following server connection defaults are set up by x386.cf, and
     there should be little reason to change them.  For an explanation of how
     these connection modes are used, refer to the XFree86(1) manual page.
  
***************
*** 191,197 ****
       #undef ConnectionFlags
       #define ConnectionFlags   YOUR_CHOICE_OF_FLAGS
  
! 8. Before building the distribution, read through the OS-specific README
     file in mit/server/ddx/x386 that is relevant to you.  Once those
     OS-specific details have been taken care of, go the 'mit' directory
     and:
--- 201,207 ----
       #undef ConnectionFlags
       #define ConnectionFlags   YOUR_CHOICE_OF_FLAGS
  
! 7. Before building the distribution, read through the OS-specific README
     file in mit/server/ddx/x386 that is relevant to you.  Once those
     OS-specific details have been taken care of, go the 'mit' directory
     and:
***************
*** 204,209 ****
--- 214,223 ----
  
       make World BOOTSTRAPCFLAGS='-DSVR4 -DSYSV386 -DNCR' > World.Log 2>&1 &
  
+    For Solaris, run:
+ 
+      make World BOOTSTRAPCFLAGS='-DSVR4 -DSYSV386 -DSOLX86' > World.Log 2>&1 &
+ 
     For 386BSD, NetBSD, BSD/386, Mach386, OSF/1, Linux, Minix-386 and
     Amoeba, run:
  
***************
*** 211,217 ****
       
     For FreeBSD, run:
  
!      make World BOOTSTRAPCFLAGS=-DFreeBSD > World.Log 2>&1 &
     
     For SVR3, run:
  
--- 225,231 ----
       
     For FreeBSD, run:
  
!      make World BOOTSTRAPCFLAGS=-D__FreeBSD__ > World.Log 2>&1 &
     
     For SVR3, run:
  
***************
*** 242,248 ****
       make World BOOTSTRAPCFLAGS='-DSYSV -DSYSV386 -DSCO -DSCO324' > \
          World.Log 2>&1 &
  
! 9. If all goes well, that will finish successfully in anything from two to
     eight hours depending on your CPU/RAM/OS/compiler/disks.  You should
     check World.Log to see if there were any problems.  If there weren't any
     then you can do a 'make install' and a 'make install.man'.  Make sure
--- 256,262 ----
       make World BOOTSTRAPCFLAGS='-DSYSV -DSYSV386 -DSCO -DSCO324' > \
          World.Log 2>&1 &
  
! 8. If all goes well, that will finish successfully in anything from two to
     eight hours depending on your CPU/RAM/OS/compiler/disks.  You should
     check World.Log to see if there were any problems.  If there weren't any
     then you can do a 'make install' and a 'make install.man'.  Make sure
***************
*** 363,369 ****
     Note: the ordering of drivers determines the order in which the probing
     is done.  The 'generic' driver should be the last one included in the
     monochrome and 16 colour servers because its probe always succeeds.  The
!    'generic_s3' driver should be the last one included in the S3 servers
     for similar reasons.
  
  2. If you are including a driver that it not part of the standard
--- 377,383 ----
     Note: the ordering of drivers determines the order in which the probing
     is done.  The 'generic' driver should be the last one included in the
     monochrome and 16 colour servers because its probe always succeeds.  The
!    's3_generic' driver should be the last one included in the S3 servers
     for similar reasons.
  
  2. If you are including a driver that it not part of the standard
***************
*** 392,395 ****
  
  
  
! $XFree86: mit/server/ddx/x386/INSTALL,v 2.4 1993/10/24 13:43:55 dawes Exp $
--- 406,409 ----
  
  
  
! $XFree86: mit/server/ddx/x386/INSTALL,v 2.7 1994/03/05 08:22:22 dawes Exp $
diff -c mit/server/ddx/x386/Imakefile:2.18 mit/server/ddx/x386/Imakefile:2.21
*** mit/server/ddx/x386/Imakefile:2.18	Fri Mar 11 23:35:32 1994
--- mit/server/ddx/x386/Imakefile	Fri Mar 11 23:35:32 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/Imakefile,v 2.18 1993/10/24 13:43:56 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:57:37 gildea Exp $
  #include <Server.tmpl>
  #define IHaveSubdirs
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/Imakefile,v 2.21 1994/03/06 14:53:41 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:57:37 gildea Exp $
  #include <Server.tmpl>
  #define IHaveSubdirs
***************
*** 40,50 ****
  SUBDIRS = common common_hw os-support $(SCREENS) $(ACCELDIRS) etc LinkKit \
            VGADriverDoc $(SUPERPROBE)
  
  #if i386Bsd
  # ifdef i386Bsdi
  EXTRAREADME = README.Bsdi
  # else
! EXTRAREADME = README.BSD
  # endif
  #endif
  #if i386Mach
--- 40,53 ----
  SUBDIRS = common common_hw os-support $(SCREENS) $(ACCELDIRS) etc LinkKit \
            VGADriverDoc $(SUPERPROBE)
  
+ /* FreeBSD's README is handled separately because of name length limits */
  #if i386Bsd
  # ifdef i386Bsdi
  EXTRAREADME = README.Bsdi
  # else
! #  ifdef i386NetBsd
! EXTRAREADME = README.NetBSD
! #  endif
  # endif
  #endif
  #if i386Mach
***************
*** 51,57 ****
--- 54,64 ----
  EXTRAREADME = README.Mach
  #endif
  #if SystemV4
+ # ifdef i386SVR4Solarisx86
+ EXTRAREADME = README.SOLX86
+ # else
  EXTRAREADME = README.SVR4
+ # endif
  #endif
  #if SystemV
  # ifdef i386Sco
***************
*** 150,155 ****
--- 157,165 ----
  InstallManPageLong(XF86kbd,$(MANDIR),XFree86kbd)
  InstallNamedNonExec(Xconfig,Xconfig.sample,$(LIBDIR))
  InstallMultipleDestFlags(install,$(FILES),$(LIBDIR)/etc,$(INSTDATFLAGS))
+ #ifdef i386FreeBsd
+ InstallNamedNonExec(READ.FreeBSD,README.FreeBSD,$(LIBDIR)/etc)
+ #endif
  
  MakeSubdirs($(SUBDIRS))
  DependSubdirs($(SUBDIRS))
diff -c /dev/null mit/server/ddx/x386/READ.FreeBSD:2.10
*** /dev/null	Fri Mar 11 23:35:32 1994
--- mit/server/ddx/x386/READ.FreeBSD	Fri Mar 11 23:35:33 1994
***************
*** 0 ****
--- 1,362 ----
+                    README for XFree86 2.1 on FreeBSD 1.1
+                    -------------------------------------
+ 
+ Contents
+ --------
+     1) What and Where is XFree86?
+     2) Bug Reports for This Document
+     3) Installing The Binaries
+     4) Installing Xdm, the display manager
+     5) Configuring X for Your Hardware
+     6) Running X
+     7) Kernel Support for X
+     8) Rebuilding the XFree86 Distribution
+     9) Building New X Clients
+ 
+ 
+ 1 - What and Where is XFree86?
+ ------------------------------
+   XFree86 is a port of X11R5 that supports several versions of
+ Intel-based Unix.  It is derived from X386 1.2, which was the X server
+ distributed with X11R5.  This release consists of many new features
+ and performance improvements as well as many bug fixes.  The release
+ is available as source patches against the MIT X11R5 code, as well as
+ binary distributions for many architectures.
+ 
+ The sources for XFree86 are available by anonymous ftp from:
+ 
+     ftp.x.org:/contrib/XFree86
+     ftp.physics.su.oz.au:/XFree86.
+ 
+ Binaries for XFree86 on FreeBSD will be available from:
+ 
+     XFree86.cdrom.com:/pub/XFree86/FreeBSD/XFree86-2.1
+ 
+ On US ftp sites note 00README-Legal-Rules-Regs or
+ README.export-control which state that ftp users outside the U.S.
+ should not copy XFree86-2.1-xdm-des.tar.gz from sites within the U.S.
+ because it employs DES encryption.
+ 
+ 2 - Bug Reports for This Document
+ ---------------------------------
+   Send email to Rich-Murphey@Rice.edu or XFree86@physics.su.oz.au if
+ you have comments or suggestions about this file and we'll revise it.
+ 
+ 3 - Installing the Binaries
+ ---------------------------
+ 
+   The binary distribution is composed of a number of tar archives
+ which are the executables, servers, fonts, libraries, include files,
+ man pages, config files, and server link kit.  The full distribution
+ takes 23Mb.
+ 
+ At a minimum you need to unpack the required bin, fonts, doc, lib,
+ config archives and a server that matches your vga card.  But if you
+ are unsure you can can safely just install all of them.
+ 
+ REQUIRED:
+ 
+ bin		- all the executable X client applications and shared libs
+ fonts		- the misc and 75 dpi fonts (required)
+ doc		- READMEs, install scripts, and XFree86 specific man pages
+ lib		- data files needed at runtime (required)
+ config		- customizable xinit, xdm and fs runtime configuration files
+ 
+ CHOOSE ONE (or more):
+ 
+ 8514		- server for IBM 8514/A boards
+ Mach32		- server for ATI Mach32 graphic accelerator boards
+ Mach8		- server for ATI Mach8 graphic accelerator boards
+ Mono		- monochrome server for VGA, Super-VGA, Hercules, and others
+ S3		- server for S3 based boards
+ SVGA		- 8-bit pseudocolor server for Super-VGA cards
+ VGA16		- 4-bit pseudocolor server for VGA and Super-VGA cards
+ 
+ OPTIONAL:
+ 
+ man		- man pages except XFree86 specific ones in etc archive
+ fonts-100dpi	- optional 100dpi fonts
+ fonts-scaled	- optional Speedo and Type1 fonts
+ prog		- lib*.a and *.h files needed only for compiling
+ xdm-des		- xdm executable with des encryption
+ xdm-nodes	- xdm executable with no encryption
+ linkkit		- optional X server reconfiguration kit
+ fontserver	- the font server and it's man page
+ pex		- pex clients, libraries, header files and data.
+ 
+ 
+ First find a partition that has enough space: 10Mb for the required
+ for the run-time binaries only, 23Mb for the complete binaries.
+ 
+ For a FULL INSTALL, unpack everything (assuming you are using csh):
+ 
+     foreach i (XFree86-2.1-*.tar.gz)
+         tar -xzf $i
+     end
+ 
+ For a MINIMAL INSTALL, unpack the required files and a server (e.g. SVGA):
+ 
+     foreach i (XFree86-2.1-{bin,fonts,doc,lib,config}.tar.gz)
+         tar -xzf $i
+     end
+     tar -xzf XFree86-2.1-S3.tar.gz
+ 
+ After unpacking the archives, run the installation script, x386install
+ from the directory where you just unpacked everything.  It creates
+ links so that the distribution appears to be in /usr/X386, and adds
+ /usr/X386/bin to the default path for sh in /etc/profile and for csh
+ in /etc/csh.login.
+ 
+  ./X386/lib/X11/etc/x386install
+ 
+ Next, create a symbolic link for the server that matches your vga
+ card.  For example, if you have an ET4000 based SVGA card, then you
+ want a symbolic link for the SVGA server:
+ 
+   cd /usr/X386/bin; rm X; ln -s XF86_SVGA X
+ 
+ Also make sure you add /usr/X386/bin to your shell's `path' variable.
+ 
+ If X was already installed and you have have customized your xinit or
+ xdm runtime configuration scripts, omit the config archive or unpack
+ it elsewhere and merge in your customizations.  The fonts-scaled and
+ fonts-100dpi archives are optional and can be omitted if you are short
+ on space.  The optional linkkit archive which allows you to
+ reconfigure and link a server.  The optional the prog archive is
+ needed only for writing or compiling X applications.  The optional pex
+ archive contains pex clients and libraries for writing pex
+ applications.
+ 
+ NOTE: Do not uncompress the font files without subsequently rerunning
+ mkfontdir in the corresponding font directory; otherwise your server
+ will abort with the message "could not open default font 'fixed'".
+ 
+ 4 - Installing Xdm, the display manager
+ ---------------------------------------
+   Export restrictions prevent us from providing support for DES
+ encryption outside the US.  If you have not installed FreeBSD's
+ optional securedist/des, then passwords in /etc/passwd.master are
+ unencrypted and you should install the version of xdm without DES
+ encryption:
+ 
+  tar xzf XFree86-2.1-xdm-nodes.tar.gz
+  cd /usr/X386/bin; ln -s xdm-nodes xdm
+ 
+ The xdm-nodes binary uses the *BSD dummy crypt routine that prints the
+ message 'Crypt not present in system' in the xdm-errors file each time
+ a user logs in.  You can ignore this.  It just means
+ /etc/passwd.master is unencrypted.  If you install xdm-des by mistake
+ xdm will not accept any passwords.
+ 
+ If you have installed the optional securedist/des package on your
+ system then you are using DES encryption on passwords and you should
+ install xdm-des:
+ 
+  tar xzf XFree86-2.1-xdm-des.tar.gz
+  cd /usr/X386/bin; ln -s xdm-des xdm
+ 
+ To start the display manager, log in as root on the console and type
+ `xdm -nodaemon'.
+ 
+ You can start xdm automatically on bootup by disabling the console
+ getty adding the following code to /etc/rc.local:
+ 
+   if [ -x /usr/X386/bin/xdm ]; then
+     echo -n ' xdm'; /usr/X386/bin/xdm
+   fi
+ 
+ To disable the console getty, change 'on' to 'off' in the ttyv0
+ entry in /etc/ttys:
+ 
+     ttyv0	"/usr/libexec/getty Pc"	pc3	off secure
+ 
+ When using the syscons console driver, it is recommended that xdm be
+ started by adding the following to /etc/rc.local:
+ 
+   if [ -x /usr/X386/bin/xdm ]; then
+     echo -n ' xdm'; (sleep 5; /usr/X386/bin/xdm)&
+   fi
+ 
+ Check /etc/ttys to make sure there are some ttyv? devices which don't
+ have gettys enabled.  The default is to have 4 devices configured to
+ run gettys.  If your kernel was configured with more than 4 VTs this
+ is fine.
+ 
+ 5 - Configuring X for Your Hardware
+ -----------------------------------
+   You *must* create /usr/X386/lib/X11/Xconfig to suit your hardware.
+ See README.Config for step-by-step instructions for setting it up.
+ 
+ The Xconfig file tells the X server what kind of monitor, adapter and
+ mouse you have.  In addition to README.Config, the server manual pages
+ (XF86_Accel, XF86_Mono, XF86_SVGA, and XF86_VGA16) describe the
+ options specific to each type of board.
+ 
+ Read README.Config, and look in /usr/X386/lib/X11/etc/modeDB.txt and
+ /usr/X386/lib/X11/etc/AccelCards to find Clocks and ModeDB entries to
+ your specific monitor and graphics card.  If you can find them there,
+ grab the Clocks and ModeDB lines and put them in your Xconfig.  If
+ not, read /usr/X386/lib/X11/etc/VideoModes.doc for instructions on how
+ to create the video timing values given your vga card and monitor
+ specs.  The manual for your monitor and adapter should have these
+ values.  The tuner program (on FreeBSD.cdrom.com
+ /pub/386BSD/0.1-ports/XFree86-2.0) can calculate a rough guess about a
+ ModeDB line given the dot clock rate and horizontal frequency of your
+ monitor.
+ 
+ The X server (except the 8514 server) will print out the Clocks values
+ for your card if you leave them our of your Xconfig file when you run:
+ 
+     X -probeonly >& x.out
+ 
+ You can take these values and edit them to put them in your Xconfig
+ file; although you MUST include all the clock values, AND leave them
+ in the same order.
+ 
+ If your mouse does not work try using kermit or tip to connect to the
+ mouse serial port and verify that it does indeed generate characters.
+ 
+ 6 - Running X
+ -------------
+   8mb of memory is a recommended minimum for running X.  The server,
+ window manager and an xterm take about 2.5 Mb of memory themselves.
+ On a 4Mb system that would leave very little left over for other
+ applications like gcc that expect a few meg free.  X will work with
+ 4Mb of memory, but in practice compilation while running X can take 5
+ or 10 times as long due to constant paging.
+ 
+ The easiest way for new users to start X windows is to type 'startx >&
+ startx.log'.  Error messages are lost unless you redirect them because
+ the server takes over the screen.
+ 
+ To get out of X windows, type 'exit' in the console xterm.  You can
+ customize your X by creating .xinitrc, .xserverrc, and .twmrc files in
+ your home directory as described in the xinit and startx man pages.
+ 
+ 7 - Kernel Support for X
+ ------------------------
+   The server supports several console drivers: pccons, syscons, codrv
+ and pcvt.  They are detected at runtime and no configuration of the
+ server itself is required.
+ 
+ The pccons driver is the most widely tested and is the console driver
+ contained in the FreeBSD binary distribution's kernels.
+ 
+ In order to instead use the syscons driver, you must reconfigure,
+ compile and install a new kernel from the FreeBSD sources.  For a
+ general description of BSD kernel configuration get smm.02.config.ps.Z
+ from gatekeeper.dec.com (16.1.0.2) in /pub/BSD/manuals.  It is a ready
+ postscript copy of the kernel configuration chapter from the systems
+ maintainers manual.
+ 
+ Do not remove the two lines below from your kernel configuration file
+ (in /sys/arch/i386/conf).  They are both required for X support:
+ 
+ options		XSERVER			#Xserver
+ options		UCONSOLE		#X Console support
+ 
+ To use syscons with FreeBSD, add the following in place of the pc0
+ entry, as in /sys/i386/conf/SYSCONS:
+ 
+ device		sc0	at isa? port "IO_KBD" tty irq 1 vector scintr
+ 
+ The number of virtual consoles can be set by adding a line like:
+ 
+ options		"NCONS=8"		#8 virtual consoles
+ 
+ to your kernel config file (the default without a line like this is 12).
+ It recommended that you have more then 4 when using X.
+ 
+ The codrv console driver is not bundled with FreeBSD.  It is available
+ from ftp.uni-duisburg.de in /pub/unix/386bsd-0.1/unofficial/codrv and
+ from bsd386.first.gmd.de in ~veit/codrv (no ANON FTP, login with
+ 'guest'/'guest', cd to ~veit/codrv).
+ 
+ The pcvt console driver is also not bundled with FreeBSD.  A "ports"
+ version of pcvt for FreeBSD versions 1.0.2 through FreeBSD 1.1 may be
+ obtained from:
+ 
+ 	FreeBSD.cdrom.com:~ftp/pub/FreeBSD/FreeBSD-1.1/ports/util/pcvt
+ 
+ Refer to the README.FreeBSD file for complete installation
+ instructions.
+ 
+ The XFree86 servers include support for the MIT-SHM extension.  If you
+ want to make use of this, you will need a kernel configured with SYSV
+ shared memory support.  To do this, add the following line to your
+ kernel config file:
+ 
+ options		SYSVSHM			#System V shared memory support
+ 
+ 
+ 8 - Rebuilding the XFree86 Distribution
+ ---------------------------------------
+   The server link kit allow you to rebuild just the X server with a
+ minimum amount of disk space.  Just unpack it, make the appropriate
+ changes to the site.def, type './mkmf' and 'make' to link the server.
+ See /usr/X386/lib/Server/README for more info.
+ 
+ See /usr/X386/lib/X11/etc/INSTALL for instructions on unbundling and
+ building the source distribution.  The source tree takes approximately
+ 82Mb before compiling and 170Mb after 'make World'.  You should
+ configure the distribution by editing mit/site.def before compiling.
+ Note that by default, the config files are set up to build shared
+ libraries.  If you are running a version of FreeBSD that doesn't
+ include shared library support, add the following line to site.def:
+ 
+ #define BuildBsdSharedLibs		NO
+ 
+ If your system doesn't have support or SYSV shared memory (for
+ example, if you don't have the <sys/shm.h> header), you should disable
+ the MIT-SHM extension by adding the following line to site.def:
+ 
+ #define HasShm				NO
+ 
+ To compile the sources:
+ 
+ If you are running an older version of FreeBSD (pre 1.1), then type
+ 
+     make World BOOTSTRAPCFLAGS=-D__FreeBSD__
+ 
+ in the mit directory.  Otherwise, a simple 'make World' will suffice.
+ 
+ 9 - Building New X Clients
+ --------------------------
+   The easiest way to build a new client (X application) is to use
+ xmkmf if an Imakefile is included in the sources.  Type 'xmkmf -a' to
+ create the Makefiles, check the configuration if necessary and type
+ 'make'.  Whenever you install additional man pages you should update
+ whatis.db by running 'makewhatis /usr/X386/man'.  To avoid the
+ `Virtual memory exhausted' message from cc while compiling, increase
+ the data and stack size limits (in csh type `limit datasize 32M' and
+ `limit stacksize 16M').
+ 
+ Note:  Starting with XFree86 2.1 and FreeBSD 1.1, the symbol "__386BSD__"
+ no longer gets defined either by the compiler or via the X config files
+ for FreeBSD systems.  When porting clients to BSD systems, make use of the
+ symbol "BSD" for code which is truly BSD-specific.  The value of the
+ symbol can be used to distinguish different BSD releases.  For example,
+ code specific to the Net-2 and later releases can use:
+ 
+ #if (BSD >= 199103)
+ 
+ To ensure that this symbol is correctly defined, include either
+ <X11/Xos.h> (best) or <sys/param.h> in the source that requires it.
+ For code that really is specific to a particular i386 BSD port, use
+ __FreeBSD__ for FreeBSD, __NetBSD__ for NetBSD, __386BSD__ for 386BSD,
+ and __bsdi__ for BSD/386.
+ 
+ 
+ Many thanks to
+ - Pace Willison for providing the initial port to 386BSD.
+ - Amancio Hasty for fixing cursor restoration, mouse bugs and many others.
+ - Christoph Robitschko for fixing com.c and thus select().
+ - Nate Williams for the patchkit support for X.
+ - Rod Grimes and Jack Velte of Walnut Creek Cdrom for use
+   of their machines in preparing the FreeBSD binary release.
+ 
+ Rich  Murphey
+ David Dawes
+ 
+ 
+ $XFree86: mit/server/ddx/x386/READ.FreeBSD,v 2.10 1994/03/11 03:08:35 dawes Exp $
diff -c mit/server/ddx/x386/README:2.8 mit/server/ddx/x386/README:2.13
*** mit/server/ddx/x386/README:2.8	Fri Mar 11 23:35:34 1994
--- mit/server/ddx/x386/README	Fri Mar 11 23:35:34 1994
***************
*** 1,10 ****
  
!                          README for XFree86 2.0
!                          ----------------------
  Contents
  --------
      1) What is XFree86?
!     2) What's new in XFree86 2.0?
      3) XFree86 features
      4) Systems XFree86 has been tested on
      5) Supported video-card chip-sets
--- 1,10 ----
  
!                          README for XFree86[TM] 2.1
!                          --------------------------
  Contents
  --------
      1) What is XFree86?
!     2) What's new in XFree86 2.1?
      3) XFree86 features
      4) Systems XFree86 has been tested on
      5) Supported video-card chip-sets
***************
*** 12,19 ****
      7) Bugs known fixed in XFree86 vs stock X11R5
      8) Known bugs in XFree86
      9) Credits
!    10) Contact information
!    11) Source and binary archive sites
  
  1 - What is XFree86?
  --------------------
--- 12,20 ----
      7) Bugs known fixed in XFree86 vs stock X11R5
      8) Known bugs in XFree86
      9) Credits
!    10) The XFree86 Project, Inc.
!    11) Contact information
!    12) Source and binary archive sites
  
  1 - What is XFree86?
  --------------------
***************
*** 24,93 ****
  as many bug fixes.  The release is available as source patches against the
  MIT X11R5 code, as well as binary distributions for many architectures.
  
- XFree86 2.0 is a major step forward in capability compared to previous
- XFree86 releases.  There is a massive amount of new code, including 
- several completely new servers, and many other enhancements.  The vast 
- majority of this code was developed by a handful of developers, listed
- in the credits section, below.  All XFree86 users owe a large debt of
- gratitude to these individuals.  The performance of the XFree86 2.0 
- accelerated servers is on a par with commercial servers for most of 
- the supported hardware; a $200 graphics accelerator now gives 
- workstation-class performance.  This has been a difficult release to 
- complete, and not everything we hoped to get done for it is done.  But 
- we expect that there is enough here to satisfy the hungriest freeware 
- user.
- 
  Note that while the source and installation trees retain the 'X386'
  name (for simplicity of maintenance of the source tree), there is no
! connection between XFree86 and the commercial X386 product sold by SGCS.
! The XFree86 Core Team maintains technical contacts with SGCS in an effort
! to keep user-affecting changes to the workings of the products from
! diverging too radically.  There is no direct involvement of either group
! in the workings of the other.
  
! 2 - What's new in XFree86 2.0?
  ------------------------------
! The following items have been added since XFree86 1.3 was released in
! June 1993:
! 
!     1) Support for the following accelerated chipsets has been added:
! 		IBM 8514/A and true compatibles
! 		ATI Mach8, Mach32
! 		S3 86C911, 86C924, 86C801, 86C805, 86C928
! 		Cirrus 5426, 5428
! 		WD 90C31
!        (see the file AccelCards for information on which specific cards
!        have been tested).
!     2) Support for the following SVGA chipsets has been added:
! 		Cirrus 62x5
! 		OAK OTI067, OTI077
!     3) A 16 colour generic VGA server (this server is still experimental
!        but quite usable at this stage).
!     4) Support for "banked dumb monochrome" boards.  Currently the
!        Hyundai HGC1280 is supported.
!     5) Support for the following operating systems has been added:
! 		OSF/1
! 		BSD/386 1.0
! 		NetBSD 0.9
! 		FreeBSD 1.0
!        In addition, an OS porting layer has been defined inside the
!        device-dependent layer of the server to make further OS ports
!        simpler and to ensure that all future servers are supported
!        on all OS platforms.
!     6) Support for the syscons driver (with VT switching) for 386BSD,
!        FreeBSD and NetBSD.
!     7) Support for the Hitachi Puma Plus tablet as an input device.
!     8) The SuperProbe program introduced with XFree86 1.3 has been updated
!        to detect many more chipsets and to be more reliable overall.
!     9) A new README.Config file is included with step-by-step instructions
!        for setting up the Xconfig file.  This file includes a list of
!        generic video mode settings which should provide working modes
!        for most video displays.
!    10) Several dozen bug fixes for problems detected and reported for
!        XFree86 1.3.
!    11) Hard limits for the maximum dot-clock frequency used are introduced.
!        These provide a rudimentary means of protecting the graphic boards
!        from overclocking. (See the Known Bugs section for some more details).
  
  Plus a number of other small things.  Refer to the CHANGELOG file in the
  source distribution for full details.
--- 25,105 ----
  as many bug fixes.  The release is available as source patches against the
  MIT X11R5 code, as well as binary distributions for many architectures.
  
  Note that while the source and installation trees retain the 'X386'
  name (for simplicity of maintenance of the source tree), there is no
! connection between XFree86 and the commercial X386 product formerly
! sold by SGCS.  The XFree86 Core Team has maintained technical contacts 
! with SGCS in an effort to keep user-affecting changes to the workings 
! of the products from diverging too radically (although this has happened
! anyhow over the course of time).  There is no direct involvement of either 
! group in the workings of the other.
! 
! 			****News Flash****
! 
! At this time, the XFree86 Core Team is pursuing the legal work to complete
! the formation of The XFree86 Project, Inc, a not-for-profit corporation.
! The paperwork is with the lawyers, and this incorporation should be
! complete in the near future.  See the section on The XFree86 Project, Inc,
! later in this document for more information.
  
! 2 - What's new in XFree86 2.1?
  ------------------------------
! XFree86 2.1 is not a huge release compared to prior XFree86 releases.  There
! are a number of reasons for this, including the fact that two of the Core
! Team members have moved and started new employment, significantly cutting into
! their time for XFree86 work.  In addition, we are hard at work on merging
! XFree86 with the upcoming X11R6.  Many new features have been put on hold
! while this integration is done, so that a stable and viable X11R6 release
! can be developed.  XFree86 3.0 will be released on the X11R6 contributed
! software distribution, and it is our intention that many of these features
! will be present in that release.
! 
! The following items have been added since XFree86 2.0 was released in
! October 1993:
! 
!     1) The X Consortium's fix-26 is included.
!     2) Support for pixel multiplexing has been added for Mach32 boards
!        with ATI68875, TLC34075 or Bt885 RAMDACs.  This allows dot clocks
!        up to 135MHz to be used with these boards.
!     3) Support for the TI ViewPoint 3020 RAMDAC used on the #9 GXe
!        Level 14 and 16 cards has been added, supporting dot clocks up to
!        135MHz and 200MHz respectively.
!     4) Support for pixel multiplexing (and thus dot clocks up to 135MHz)
!        has been added for the SPEA Mercury cards (S3 928 + Bt485).  This
!        has *not* been tested on other 928 + Bt485 cards.
!     5) Performance improvements for some of the accelerated servers.
!     6) Support has been added for all the display widths available with
!        the S3 chips.  In addition to the 1024 and 1280 widths supported
!        by XFree86 2.0, there is now support for 640, 800 and 2048 with
!        all 801, 805 and 928 chips.  1152 is supported with 801/5 chips
!        at revision C or later.  1152 and 1600 are supported with 928
!        chips at revision E or later.  Note that this change should make
!        XFree86 viable on 512k boards.
!     7) Support for 8-bit resolution RGB values (as opposed to the
!        standard VGA 6-bit resolution) for S3 cards with AT&T20C490/1,
!        Sierra SC15025 or Ti3020 RAMDACs, and for Mach32 cards with
!        ATI68875, TLC34075 or Bt885 RAMDACs.
!     8) Support for DRAM based S3 cards using slow memory has been
!        improved.
!     9) Accelerated support for the Cirrus chipsets has been enhanced and
!        extended to include the lower-end chipsets (5420, 5422, 5424).
!    10) The pvga1 driver can now access all the clocks on boards using the
!        WD90C30 and WD90C31 chips.
!    11) The 16 colour generic VGA server has been extended to include
!        banked memory support on selected chipsets.  This allows it to
!        make full use of the available video memory on these boards.  This
!        server now includes support for GrayScale and StaticGray visuals
!        which makes for better use on many laptops.
!    12) Support for the Sigma LaserView and Visa monochrome boards has
!        been added to the bdm2 driver in the Mono server.
!    13) Support for Solaris x86 2.1 has been added.
!    14) Support is included for shared libraries on FreeBSD-1.1 and
!        NetBSD-current (0.9 based) systems.
!    15) The SuperProbe program introduced with XFree86 1.3 has been updated
!        to detect more chipsets, to detect installed video memory,  and to 
!        be more reliable overall.
!    16) Several dozen bug fixes for problems detected and reported for
!        XFree86 2.0.
  
  Plus a number of other small things.  Refer to the CHANGELOG file in the
  source distribution for full details.
***************
*** 116,129 ****
      5) Support for the Hercules mono card in the monochrome server, and 
         with it the ability to support a "two headed" server - one mono 
         VGA, and one Hercules.
!     6) Support for Hyundai HGC1280 monochrome graphics card in the
!        monochrome server.
!     7) An (experimental) 16-color VGA server is included, which supports
!        generic VGA hardware.
      8) SVR3 shared libraries, tested under ISC SVR3 2.0.2, 2.2, 3.0.1 and
         4.0; SCO 3.2.2, 3.2.4.
      9) Support for Linux, 386BSD, NetBSD, FreeBSD, BSD/386, Mach, OSF/1,
!        SVR4.2, SCO, Amoeba, and Minix-386. Including Linux shared libraries.
     10) Support for LOCALCONN.  This support is for both SVR3.2 and SVR4.
         For SVR4.0.4 with the 'Advanced Compatibility Package' and on
         SVR4.2, local connections from SCO XSight/ODT clients are supported.
--- 128,142 ----
      5) Support for the Hercules mono card in the monochrome server, and 
         with it the ability to support a "two headed" server - one mono 
         VGA, and one Hercules.
!     6) Support for Hyundai HGC1280, Sigma LaserView and Visa monochrome
!        graphics card in the monochrome server.
!     7) A 16-color VGA server is included, which supports generic VGA
!        hardware.
      8) SVR3 shared libraries, tested under ISC SVR3 2.0.2, 2.2, 3.0.1 and
         4.0; SCO 3.2.2, 3.2.4.
      9) Support for Linux, 386BSD, NetBSD, FreeBSD, BSD/386, Mach, OSF/1,
!        SVR4.2, SCO, Solaris 2.1, Amoeba, and Minix-386. Including shared
!        libraries for Linux, FreeBSD and NetBSD.
     10) Support for LOCALCONN.  This support is for both SVR3.2 and SVR4.
         For SVR4.0.4 with the 'Advanced Compatibility Package' and on
         SVR4.2, local connections from SCO XSight/ODT clients are supported.
***************
*** 154,160 ****
  4 - Systems XFree86 has been tested on
  --------------------------------------
      SVR4.0:
! 	Esix: 4.0.3A, 4.0.4
  	Microport: 2.2, 3.1, 4.1, 4.2
  	Dell: 2.1, 2.2
  	UHC: 2.0, 3.6
--- 167,173 ----
  4 - Systems XFree86 has been tested on
  --------------------------------------
      SVR4.0:
! 	Esix: 4.0.3A, 4.0.4, 4.0.4.1
  	Microport: 2.2, 3.1, 4.1, 4.2
  	Dell: 2.1, 2.2
  	UHC: 2.0, 3.6
***************
*** 163,168 ****
--- 176,182 ----
  	ISC: 4.0.3
  	AT&T: 2.1, 4.0
  	NCR: MP-RAS
+ 	SunSoft: Solaris x86 2.1
  
      SVR4.2:
  	Consensys
***************
*** 174,195 ****
  	AT&T: 3.2.2
  
      Others:
! 	386BSD 0.1, NetBSD 0.9, FreeBSD 1.0
  	BSD/386 1.0
  	Mach 386
  	OSF/1
! 	Linux 0.99pl13
  	Amoeba
  	Minix-386
  
  5 - Supported video-card chipsets
  ---------------------------------
! At this time, XFree86 2.0 supports the following accelerated chipsets:
  
      8514/A (and true clones)
      ATI Mach8, Mach32
!     Cirrus CLGD5426, CLGD5428
!     S3 86C911, 86C924, 86C801, 86C805, 86C928
      Western Digital WD90C31
  
  The Cirrus and Western Digital accelerators are supported in the SVGA
--- 188,209 ----
  	AT&T: 3.2.2
  
      Others:
! 	386BSD 0.1, NetBSD 0.9, FreeBSD 1.1(beta)
  	BSD/386 1.0
  	Mach 386
  	OSF/1
! 	Linux 0.99pl15h
  	Amoeba
  	Minix-386
  
  5 - Supported video-card chipsets
  ---------------------------------
! At this time, XFree86 2.1 supports the following accelerated chipsets:
  
      8514/A (and true clones)
      ATI Mach8, Mach32
!     Cirrus CLGD5420, CLGD5422, CLGD5424, CLGD5426, CLGD5428
!     S3 86C911, 86C924, 86C801, 86C805, 86C805i, 86C928
      Western Digital WD90C31
  
  The Cirrus and Western Digital accelerators are supported in the SVGA
***************
*** 196,215 ****
  server; the other chipsets each have their own server.  A list of cards
  on which the accelerated servers have been tested is included in the file
  AccelCards.  They may well work on other cards, but we cannot guarantee it.
- Linux and BSD users of the XS3 server are referred to the README.XS3
- file for information on the differences between XS3 and the XFree86 S3
- server. Xconfig files must be changed when using XF86_S3 instead of XS3.
    
  In addition, the following SVGA chipsets are supported:
      
      Tseng ET3000, ET4000AX, ET4000/W32
      Western Digital/Paradise PVGA1
!     Western Digital WD90C00, WD90C10, WD90C11, WD90C30, WD90C31
      Genoa GVGA
!     Trident TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000
      ATI 28800-4, 28800-5, 28800-a
!     NCR 77C22, 77C22E
!     Cirrus Logic CLGD5420, CLGD5422, CLGD5424, CLGD5426, CLGD5428, 
  		 CLGD6205, CLGD6215, CLGD6225, CLGD6235
      Compaq AVGA
      OAK OTI067, OTI077
--- 210,227 ----
  server; the other chipsets each have their own server.  A list of cards
  on which the accelerated servers have been tested is included in the file
  AccelCards.  They may well work on other cards, but we cannot guarantee it.
    
  In addition, the following SVGA chipsets are supported:
      
      Tseng ET3000, ET4000AX, ET4000/W32
      Western Digital/Paradise PVGA1
!     Western Digital WD90C00, WD90C10, WD90C11, WD90C24, WD90C30, WD90C31
      Genoa GVGA
!     Trident TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000,
! 	    TVGA9000i, TVGA9100B, TVGA9200CX, TVGA9320, TVGA9400CX, TVGA9420
      ATI 28800-4, 28800-5, 28800-a
!     NCR 77C22, 77C22E, 77C22E+
!     Cirrus Logic CLGD5420, CLGD5422, CLGD5424, CLGD5426, CLGD5428
  		 CLGD6205, CLGD6215, CLGD6225, CLGD6235
      Compaq AVGA
      OAK OTI067, OTI077
***************
*** 222,250 ****
  Digital, ATI, and Trident) for more information about using those chipsets.
  
  The monochrome server also supports generic VGA cards, using 64k of video
! memory in a single bank, the Hercules card, and the Hynudai HGC1280 card.
! On the Compaq AVGA, only 64k of video memory is supported for the monochrome
! server, and the GVGA has not been tested with more than 64k.
! 
! XFree86 2.0 includes an experimental 16-color generic VGA server.  This
! server has not been as extensively tested and debugged as the others, but
! it should work rather well (but slowly) on most hardware.  At this time,
! it does not support banking, hence display is currently limited to 64k
! of memory (approximately 800x600).
  
    Note
    ----
! It appears that some of the SVGA card manufacturers are going to
! non-traditional mechanisms for selecting pixel-clock frequencies.  To
! avoid having to modify the server to accommodate these schemes XFree86 1.2
! added support for using an external program to select the pixel clock.
! This allows programs to be written as new mechanisms are discovered.
! Refer to the README.clkprog file for information on how these programs
! work, if you need to write one.  If you do develop such a program, we
! would be interested in including it with future XFree86 releases.
  
  NOTE: The Diamond SpeedStar 24 (and possibly recent SpeedStar+) boards are
!       NOT supported, even though they use the ET4000. The same is valid
        for all of Diamond's S3 boards. The reason for this is that
        Diamond has changed the mechanism used to select pixel clock 
        frequencies, and will only release programming information under
--- 234,264 ----
  Digital, ATI, and Trident) for more information about using those chipsets.
  
  The monochrome server also supports generic VGA cards, using 64k of video
! memory in a single bank, the Hercules monochrome card, the Hyundai
! HGC1280, Sigma LaserView and Visa monochrome cards.  On the Compaq AVGA,
! only 64k of video memory is supported for the monochrome server, and the
! GVGA has not been tested with more than 64k.
! 
! The VGA16 server has not been as extensively tested and debugged as the
! others, but it should work rather well (but slowly) on most hardware.
! This server supports memory banking with the ET4000 and Trident chipsets
! allowing virtual display sizes up to about 1600x1200 (with 1MB of video
! memory).  For other chipsets the display size is limited to approximately
! 800x600.
  
    Note
    ----
! Some of the SVGA card manufacturers are using non-traditional mechanisms 
! for selecting pixel-clock frequencies.  To avoid having to modify the 
! server to accommodate these schemes XFree86 1.2 added support for using 
! an external program to select the pixel clock.  This allows programs to 
! be written as new mechanisms are discovered.  Refer to the README.clkprog 
! file for information on how these programs work, if you need to write one.
! If you do develop such a program, we would be interested in including it 
! with future XFree86 releases.
  
  NOTE: The Diamond SpeedStar 24 (and possibly recent SpeedStar+) boards are
!       NOT supported, even though they use the ET4000. The same is true
        for all of Diamond's S3 boards. The reason for this is that
        Diamond has changed the mechanism used to select pixel clock 
        frequencies, and will only release programming information under
***************
*** 256,261 ****
--- 270,279 ----
        DOES NOT SUPPORT DIAMOND HARDWARE.  It is possible to make some
        of it work, but we will not assist in doing this.
  
+       Diamond's Cirrus-based boards should work with XFree86 because they
+       use the standard Cirrus clock synthesiser.  This includes the
+       SpeedStar Pro and possibly the SpeedStar 64.
+ 
  6 - Where to get more information
  ---------------------------------
  Additional documentation is available in the XFree86(1), Xconfig(4/5),
***************
*** 277,283 ****
  If you are totally at a loss, you can contact the XFree86 Core Team at
  the electronic mail address below.
  
! There exists a Usenet news group comp.windows.x.i386unix that contains
  mostly discussions about XFree86 and related topics. Many questions can
  be answered there. The answers to common questions are found in the
  corresponding FAQ.
--- 295,301 ----
  If you are totally at a loss, you can contact the XFree86 Core Team at
  the electronic mail address below.
  
! There is a Usenet news group comp.windows.x.i386unix that contains
  mostly discussions about XFree86 and related topics. Many questions can
  be answered there. The answers to common questions are found in the
  corresponding FAQ.
***************
*** 321,332 ****
         believe that we have worked around this problem, but have not yet
         solved the root cause.
      2) While not strictly a bug, there is currently a limitation on the
!        dot-clock frequencies allowed in the S3 and Mach32 servers.  For
!        S3 cards with the Bt485 RAMDAC (e.g. #9 GXe), the limit is 85Mhz.
!        For Mach32 boards, the limit is 80Mhz.  There is some special
!        programming required to use these RAMDACs at higher dot-clocks,
!        and we were not able to get it fully developed in time.  We intend
!        to release a patch with these updates in the near future.
  
  We welcome reports of bugs sent to the electronic mail address listed
  below.
--- 339,350 ----
         believe that we have worked around this problem, but have not yet
         solved the root cause.
      2) While not strictly a bug, there is currently a limitation on the
!        dot-clock frequencies allowed with the S3 server.  For S3 cards
!        with the Bt485 RAMDAC (e.g. #9 GXe), the limit is 85Mhz.  There
!        is some special programming required to use these RAMDACs at higher
!        dot-clocks, and we were not able to get it fully developed in
!        time.  An exception to this is the SPEA Mercury card which is
!        supported at dot clocks up to 135MHz.
  
  We welcome reports of bugs sent to the electronic mail address listed
  below.
***************
*** 359,364 ****
--- 377,385 ----
  BSD/386 support by:
         Hans Nasten <nasten@everyware.se>
         Paul Vixie <paul@vix.com>
+ Solaris support by:
+        Doug Anson <danson@lgc.com>
+        David Holland <davidh@use.com>
  SVR3 shared libraries by:
         Thomas Wolfram <wolf@prz.tu-berlin.de>
  Linux shared libraries by:
***************
*** 372,377 ****
--- 393,399 ----
         Jon Tombs <jon@gtex02.us.es>
         David Wexelblat <dwex@goblin.org> <dwex@aib.com>
         David Dawes <dawes@physics.su.oz.au>
+        Robin Cutshaw <robin@paros.com>
         Amancio Hasty <hasty@netcom.com>
  Mach32 accelerated code by:
         Kevin Martin <martin@cs.unc.edu>
***************
*** 378,383 ****
--- 400,406 ----
         Rik Faith <faith@cs.unc.edu>
         Mike Bernson <mike@mbsun.mlb.org>
         Mark Weaver <Mark_Weaver@brown.edu>
+        Craig Groeschel <craig@adikia.sccsi.com>
  Mach8, 8514 accelerated code by:
         Kevin Martin <martin@cs.unc.edu>
         Rik Faith <faith@cs.unc.edu>
***************
*** 386,391 ****
--- 409,415 ----
         Scott Laird <lair@midway.uchicago.edu>
  Cirrus accelerated code by:
         Simon Cooper <scooper@vizlab.rutgers.edu>
+        Harm Hanemaayer <hhanemaa@cs.ru.nl>
         Bill Reynolds <bill@goshawk.lanl.gov>
  Western Digital accelerated code by:
         Mike Tierney <floyd@pepsi.eng.umd.edu>
***************
*** 394,400 ****
         Gertjan Akkerman <akkerman@dutiba.twi.tudelft.nl>
  
  ATI SVGA driver by:
!        Rik Faith <faith@cs.unc.edu>
  Trident SVGA driver by:
         Alan Hourihane <alanh@metro.co.uk>
  NCR SVGA driver by:
--- 418,425 ----
         Gertjan Akkerman <akkerman@dutiba.twi.tudelft.nl>
  
  ATI SVGA driver by:
!        Per Lindqvist <pgd@compuram.bbt.se> and Doug Evans <dje@cygnus.com>
!        Ported to X11R5 by Rik Faith <faith@cs.unc.edu>
  Trident SVGA driver by:
         Alan Hourihane <alanh@metro.co.uk>
  NCR SVGA driver by:
***************
*** 410,416 ****
  
  Configurable MFB and Hercules driver by:
         Davor Matic <dmatic@Athena.MIT.EDU>
! Banked Dumb Monochrome and Hyundai drivers by:
         Pascal Haible <haible@izfm.uni-stuttgart.de>
  
  X386 1.2, and moral support from:
--- 435,441 ----
  
  Configurable MFB and Hercules driver by:
         Davor Matic <dmatic@Athena.MIT.EDU>
! Banked Dumb Monochrome and related drivers by:
         Pascal Haible <haible@izfm.uni-stuttgart.de>
  
  X386 1.2, and moral support from:
***************
*** 430,451 ****
  Ongoing development planning and support is coordinated by the XFree86
  Core Team.  At this time the Core Team consists of (in alphabetical order):
  
-        Robert Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
         David Dawes <dawes@physics.su.oz.au>
         Dirk Hohndel <hohndel@informatik.uni-wuerzburg.de>
-        Glenn Lai <glenn@cs.utexas.edu>
         Rich Murphey <Rich@Rice.edu>
         Jon Tombs <jon@gtex02.us.es>
         David Wexelblat <dwex@goblin.org>, <dwex@aib.com>
-        Thomas Wolfram <wolf@prz.tu-berlin.de>
-        Orest Zborowski <orestz@microsoft.com>
  
  E-mail sent to <xfree86@physics.su.oz.au> will reach the Core Team.
  
! 11 - Source and binary archive sites
  ------------------------------------
  Source patches based on X11R5 PL25, from MIT, and as an upgrade from
! XFree86 1.3 are available via anonymous FTP from:
  
         ftp.x.org (under /contrib/XFree86)
         ftp.physics.su.oz.au (under /XFree86)
--- 455,551 ----
  Ongoing development planning and support is coordinated by the XFree86
  Core Team.  At this time the Core Team consists of (in alphabetical order):
  
         David Dawes <dawes@physics.su.oz.au>
         Dirk Hohndel <hohndel@informatik.uni-wuerzburg.de>
         Rich Murphey <Rich@Rice.edu>
         Jon Tombs <jon@gtex02.us.es>
         David Wexelblat <dwex@goblin.org>, <dwex@aib.com>
  
  E-mail sent to <xfree86@physics.su.oz.au> will reach the Core Team.
  
! 11 - The XFree86 Project, Inc.
! ------------------------------
! The XFree86 Project, Inc, has been founded to accomplish two major goals:
! 
! 	1) To provide a vehicle by which XFree86 can be represented in
! 	   X Consortium, Inc, the organization responsible for the
! 	   design, development, and release of The X Window System.
! 	2) To provide some basic funding for acquisition of facilities for
! 	   ongoing XFree86 development, largly to consist of new video
! 	   hardware and basic computing facilities.
! 
! The first of these was the primary motivation.  We have held discussions
! with the X Consortium on and off for many months, attempting to find an
! avenue by which our loosely-organized free software project could be
! given a voice within the X Consortium.  The bylaws of the Consortium
! would not recognize such an organization.  After an initial investigation
! about funding, we decided to form our own corporation to provide the
! avenue we needed to meet the requirements of the X Consortium bylaws.
! 
! By doing this, we are able to be involved in the beta-test interval for
! X11R6, and will be contributing the majority of XFree86 to the X11R6 core
! release.  The next full-featured release of XFree86, version 3.0, will
! be present on the X11R6 contributed software tape, with full X11R6
! support, and (hopefully) a host of new features.  As time goes on, 
! XFree86 will be involved with more of the development of The X Window 
! System, as a full Consortium member.  How exactly this will evolve is
! still being determined.
! 
! An additional benefit of this incorporation is that The XFree86 Project,
! Inc has obtained outside financial support for our work.  This will
! hopefully give us the freedom to be more proactive in obtaining new
! video hardware, and enable us to release better products more quickly,
! as we will be able to go and get what we need, and get it into the hands
! of the people who can do the work.
! 
! The initial Board of Directors and Officers of the The XFree86 Project,
! Inc, are the same XFree86 Core Team as is listed above. Our bylaws have 
! been crafted in such a way to ensure that XFree86 is and always will 
! be a free software project.  There is no personal financial benefit 
! to any member of the Core Team or any other XFree86 participant.  All 
! assets of the corporation remain with the corporation, and, in the event 
! of the dissolution of the corporation, all assets will be turned over 
! to the X Consortium, Inc.  It is hoped that by doing this, our corporation 
! will be merely a formalization of what we have been doing in the past, 
! rather than something entirely new.
! 
! Here is a list of the organizations and individuals who have provided
! sponsorship to The XFree86 Project, Inc, either by financial contribution
! or by the donation of equipment and resources.  The XFree86 Project, Inc
! gratefully acknowledges these contributions, and hopes that we can do
! justice to them by continuing to release high-quality free software for
! the betterment of the Internet community as a whole.
! 
! 	UUNET Communications Services, Inc.
! 
! UUNET Communications Services, Inc, deserves special mention.  This
! organization stepped forward and contributed the entire 1994 X Consortium
! membership fee on a moment's notice.  This single act ensured XFree86's
! involvement in X11R6.
! 
! 	AIB Software Corporation
! 	American Micro Group
! 	AT&T Global Information Services (formerly NCR)
! 	BSDI
! 	InfoMagic
! 	LunetIX
! 	Frank & Paige McCormick
! 	Prime Time Freeware
! 	Red Hat Software
! 
! The XFree86 Project, Inc, welcomes the additional contribution of funding
! and/or equipment.  Such contributions should be tax-deductible; we will
! know for certain when the lawyers get finished with the papers.  For more 
! information, contact The XFree86 Project, Inc, at <xfree86@physics.su.oz.au>
! 
! We are in the process of establishing our own Internet domain, XFree86.Org.
! Most of the pieces are in place, and we hope to be online within a few
! more weeks.  We will post an announcement when this is ready for use.
! 
! 12 - Source and binary archive sites
  ------------------------------------
  Source patches based on X11R5 PL25, from MIT, and as an upgrade from
! XFree86 2.0 are available via anonymous FTP from:
  
         ftp.x.org (under /contrib/XFree86)
         ftp.physics.su.oz.au (under /XFree86)
***************
*** 478,486 ****
         tsx-11.mit.edu                  - Linux binaries
                  under /pub/linux/packages/X11
         ftp.unipi.it                    - Linux binaries
! 		under /pub/linux/XFree86_2.0
         XFree86.cdrom.com               - FreeBSD binaries
! 		under /pub/XFree86/FreeBSD/XFree86-2.0
         gil.physik.rwth-aachen.de       - FreeBSD binaries
  		under /pub/XFree86
         agate.berkeley.edu              - NetBSD 0.9 binaries
--- 578,586 ----
         tsx-11.mit.edu                  - Linux binaries
                  under /pub/linux/packages/X11
         ftp.unipi.it                    - Linux binaries
! 		under /pub/linux/XFree86_2.1
         XFree86.cdrom.com               - FreeBSD binaries
! 		under /pub/XFree86/FreeBSD/XFree86-2.1
         gil.physik.rwth-aachen.de       - FreeBSD binaries
  		under /pub/XFree86
         agate.berkeley.edu              - NetBSD 0.9 binaries
***************
*** 489,503 ****
  		under /pub/NetBSD/ports
         ftp.cs.mcgill.ca	               - NetBSD 0.9 binaries
  	        under /pub/NetBSD/XFree86
-        ftp.cs.uwm.edu                  - Mach386 binaries
-                 under /i386
  
! Ensure that you are getting XFree86 2.0 - some of these sites may archive
  older releases as well.  Each binary distribution will contain a README
  file that describes what files you need to take from the archive, and
  which compile-time option selections were made when building the
  distribution.
  
! 23 October, 1993
  
! $XFree86: mit/server/ddx/x386/README,v 2.8 1993/10/24 13:43:59 dawes Exp $
--- 589,601 ----
  		under /pub/NetBSD/ports
         ftp.cs.mcgill.ca	               - NetBSD 0.9 binaries
  	        under /pub/NetBSD/XFree86
  
! Ensure that you are getting XFree86 2.1 - some of these sites may archive
  older releases as well.  Each binary distribution will contain a README
  file that describes what files you need to take from the archive, and
  which compile-time option selections were made when building the
  distribution.
  
! 6 March 1994
  
! $XFree86: mit/server/ddx/x386/README,v 2.13 1994/03/08 08:07:02 dawes Exp $
diff -c mit/server/ddx/x386/README.Amoeba:2.0 mit/server/ddx/x386/README.Amoeba:2.1
*** mit/server/ddx/x386/README.Amoeba:2.0	Fri Mar 11 23:35:36 1994
--- mit/server/ddx/x386/README.Amoeba	Fri Mar 11 23:35:36 1994
***************
*** 80,88 ****
  
  	make World BOOTSTRAPCFLAGS='-DCROSS_COMPILE' >BuildX.i80386 2>&1 &
  
! - When this has finished succesfully, the client and server binaries,
    scripts, and other support files can be installed from Unix to Amoeba
    by means of the command "make install" in the X11R5/mit config tree.
  
  
! $XFree86: mit/server/ddx/x386/README.Amoeba,v 2.0 1993/10/24 13:44:01 dawes Exp $
--- 80,88 ----
  
  	make World BOOTSTRAPCFLAGS='-DCROSS_COMPILE' >BuildX.i80386 2>&1 &
  
! - When this has finished successfully, the client and server binaries,
    scripts, and other support files can be installed from Unix to Amoeba
    by means of the command "make install" in the X11R5/mit config tree.
  
  
! $XFree86: mit/server/ddx/x386/README.Amoeba,v 2.1 1994/03/08 08:07:05 dawes Exp $
diff -c mit/server/ddx/x386/README.BSD:2.3 mit/server/ddx/x386/README.BSD:removed
*** mit/server/ddx/x386/README.BSD:2.3	Fri Mar 11 23:35:36 1994
--- mit/server/ddx/x386/README.BSD	Fri Mar 11 23:35:36 1994
***************
*** 1,471 ****
-            README for XFree86 2.0 on FreeBSD 1.0 and NetBSD 0.9
-            ----------------------------------------------------
- 
- Contents
- --------
-     0) Notes
-     1) What and Where is XFree86?
-     2) Bug Reports for This Document
-     3) Installing The Binaries
-     4) Installing Xdm, the display manager
-     5) Configuring X for Your Hardware
-     6) Running X
-     7) Kernel Support for X
-     8) Rebuilding the XFree86 Distribution
-     9) Building New X Clients
- 
- 
- 0 - Notes
- ---------
-   Unless indicated otherwise, *BSD refers to both FreeBSD 1.0 and NetBSD
- 0.9.  A binary distribution is not available for 386BSD 0.1.  The XFree86
- 2.0 source code supports 386BSD 0.1, but future version probably will not.
- 
- 1 - What and Where is XFree86?
- ------------------------------
-   XFree86 is a port of X11R5 that supports several versions of Intel-based
- Unix.  It is derived from X386 1.2, which was the X server distributed
- with X11R5.  This release consists of many new features and performance
- improvements as well as many bug fixes.  The release is available as
- source patches against the MIT X11R5 code, as well as binary distributions
- for many architectures.
- 
- The sources for XFree86 are available by anonymous ftp from:
- 
-     ftp.x.org:/contrib/XFree86
-     ftp.physics.su.oz.au:/XFree86.
- 
- Binaries for XFree86 on FreeBSD will be available from:
- 
-     XFree86.cdrom.com:/pub/XFree86/FreeBSD/XFree86-2.0
-     gil.physik.rwth-aachen.de:/pub/XFree86
- 
- Binaries for NetBSD 0.9 will be available from:
- 
-     ftp.cs.mcgill.ca:/pub/NetBSD
-     agate.berkeley.edu:/pub/NetBSD/ports
-     sun-lamp.cs.berkeley.edu:/pub/NetBSD/ports
- 
- On US ftp sites note 00README-Legal-Rules-Regs or README.export-control 
- which state that ftp users outside the U.S. should not copy 
- XFree86-2.0-xdm-des.tar.gz from sites within the U.S. because it employs 
- DES encryption.
- 
- 2 - Bug Reports for This Document
- ---------------------------------
-   Send email to Rich-Murphey@Rice.edu or XFree86@physics.su.oz.au
- if you have comments or suggestions about this file and we'll revise it.
- NetBSD specific issues should be sent to Marc Wandschneider, 
- storm@cs.mcgill.ca
- 
- 3 - Installing the Binaries
- ---------------------------
- 
-   FreeBSD:
-   =------=
-   The binary distribution is composed of a number of tar archives
- which are the executables, servers, fonts, libraries, include files,
- man pages, config files, and server link kit.  The full distribution
- takes 43Mb.  The bin archive is split into 1 meg pieces.
- 
- The contents of the archives are:
- 
- Required:
- 
- bin		- all the executable X client applications (required)
- fonts		- the misc and 75 dpi fonts (required)
- doc		- READMEs, install scripts, and XFree86 specific man pages
- lib		- data files needed at runtime (required)
- config		- customizable xinit, xdm and fs runtime configuration files
- 
- Choose at least one matching your video hardware:
- 
- 8514		- server for IBM 8514/A boards
- Mach32		- server for ATI Mach32 graphic accelerator boards
- Mach8		- server for ATI Mach8 graphic accelerator boards
- Mono		- monochrome server for VGA, Super-VGA, Hercules, and others
- S3		- server for S3 based boards
- SVGA		- 8-bit pseudocolor server for Super-VGA cards
- VGA16		- 4-bit pseudocolor server for VGA and Super-VGA cards
- 
- Optional:
- 
- man		- man pages except XFree86 specific ones in etc archive
- fonts-100dpi	- optional 100dpi fonts
- fonts-scaled	- optional Speedo and Type1 fonts
- prog		- lib*.a and *.h files needed only for compiling
- xdm-des		- xdm executable with des encryption
- xdm-nodes	- xdm executable with no encryption
- linkkit		- optional X server reconfiguration kit
- fontserver	- the font server and it's man page
- pex		- pex clients, libraries, header files and data.
- 
- If this is your first time, you can safely just install all of them.
- 
- But at a minimum you need to unpack the following: bin, fonts, doc,
- lib, config and a server archive that matches your vga card.
- 
- To unpack the archives use:
- 
-  cat XFree86-2.0-bin.tar.gz.*		| gunzip | tar xf -
-  cat XFree86-2.0-etc.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-fonts-100dpi.tar.gz	| gunzip | tar xf -
-  cat XFree86-2.0-fonts-scaled.tar.gz	| gunzip | tar xf -
-  cat XFree86-2.0-fonts.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-fontserver.tar.gz	| gunzip | tar xf -
-  cat XFree86-2.0-lib.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-linkkit.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-man.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-pex.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-prog.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-xdm-des.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-xdm-nodes.tar.gz	| gunzip | tar xf -
-  cat XFree86-2.0-config.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-8514.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-Mach32.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-Mach8.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-Mono.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-S3.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-SVGA.tar.gz		| gunzip | tar xf -
-  cat XFree86-2.0-VGA16.tar.gz		| gunzip | tar xf -
- 
- After unpacking the archives, run the installation script,
- x386install, it creates links so that the distribution appears to be
- in /usr/X386, checks the /dev and /etc/ttys entries, and adds
- /usr/X386/bin to the default path in /etc/csh.login.
- 
-  ./X386/lib/X11/etc/x386install
- 
- Create a symbolic link for the server that matches your vga card.  For
- example, if you have an ET4000 based SVGA card, then you want a
- symbolic link for the SVGA server:
- 
-   cd /usr/X386/bin; rm X; ln -s XF86_SVGA X
- 
- Also make sure to add /usr/X386/bin to your shell's `path' variable.
- 
- If X was already installed and you have have customized your xinit or
- xdm runtime configuration scripts, omit the config archive or unpack
- it elsewhere and merge in your customizations.  The fonts-scaled and
- fonts-100dpi archives are optional and can be omitted if you are short
- on space.  The optional linkkit archive which allows you to
- reconfigure and link a server.  The optional the prog archive is
- needed only for writing or compiling X applications.  The optional pex
- archive contains pex clients and libraries for writing pex applications.
- 
- NOTE: Do not uncompress the font files without subsequently rerunning
- mkfontdir in the corresponding font directory; otherwise your server
- will abort with the message "could not open default font 'fixed'".
- 
- 
-   NetBSD:
-   =-----=
-     The binary distribution is composed of a number of split tar archives
- which are the executables, servers, fonts, libraries, include files,
- man pages, config files, and the server link kit.  The full distribution
- takes over 40MB of disk space.  The large archives are split into
- smaller chunks.
- 
-     The contents of the archives are:
- 
-     bin         - all of the executable X client applications (except xdm)
-     include     - the include/X11 header files
-     fonts       - the misc, 75dpi, 100dpi, and scaled fonts
-     doc         - READMEs, install scripts, and XFree86 specific man pages.
-     lib         - X11 libraries, and data files needed at runtime
-     config      - customizable xinit, xdm, and fs runtime configuration files.
- 
-     Choose at least one of the following to match your hardware:
- 
-     8514        - the X server for IBM 8514/A and compatible boards
-     Mach8       - the X server for ATI Mach8 graphics accelerator boards
-     Mach32      - the X server for ATI Mach32 graphics accelerator boards
-     S3          - the X server for S3 based boards
-     SVGA        - the 8-bit pseudo-color X server for Super VGA cards
-     VGA16       - the 4-bit pseudo-color X server for VGA & SVGA cards.
-     Mono        - the Monochrome X Server
- 
-     OPTIONAL:
- 
-     man         - man pages except XFree86 specific ones in the etc archive
-     xdm-des     - xdm executable with DES encryption
-     xdm-no-des  - xdm executable without DES encryption
-     linkkit     - optional X server reconfiguration kit
-     pex         - pex clients, libraries, header files and data
- 
- 
-     If this is your first time, then you should be able to safely
- install all of the packages.  If you're going to be installing the
- source as well, then you might not want to bother with the linkkit and
- pex archives.  As a minimal install, you'll need bin, include, fonts
- doc, lib, config, and one X server.
- 
-     To unpack and install the archives:
- 
-     1. create some destination directory in which you'd like the
-        X distribution to live.  /usr/X386 is recommended, but if that
-        partiton is full (as it is on my machine), then just create an
-        alternate directory, and sym-link /usr/X386 to this place.
- 
-     ie, on my machine, I do the following:
- 
-     % cd /usr/local
-     % mkdir X11
-     % ln -s /usr/local/X11 /usr/X386
- 
- 
-     2. Assuming that the destination directory for XFree86 2.0 is /usr/X386,
-        run the following from whereever all the archive files are (replace
-        /usr/X386 with wherever you wish them to go if that isn't the place):
- 
-     % cat XFree86-2.0-bin.tar.gz.*          | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-include.tar.gz.*      | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-fonts.tar.gz.*        | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-doc.tar.gz            | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-lib.tar.gz.*          | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-config.tar.gz         | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-man.tar.gz            | gunzip | (cd /usr/X386; tar xf -)
- 
-     # Choose only one of the following two
-     % cat XFree86-2.0-xdm-des.tar.gz        | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-xdm-no-des.tar.gz     | gunzip | (cd /usr/X386; tar xf -)
- 
-     % cat XFree86-2.0-linkkit.tar.gz.*      | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-pex.tar.gz            | gunzip | (cd /usr/X386; tar xf -)
- 
-     # Choose one ore more servers to install
-     % cat XFree86-2.0-8514.tar.gz           | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-Mach8.tar.gz          | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-Mach32.tar.gz         | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-S3.tar.gz             | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-SVGA.tar.gz           | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-VGA16.tar.gz          | gunzip | (cd /usr/X386; tar xf -)
-     % cat XFree86-2.0-Mono.tar.gz           | gunzip | (cd /usr/X386; tar xf -)
- 
- 
-     3. You should now run the script x386install.netbsd from lib/X11/etc.
-        It is invoked as follows (assuming we are in the top level dir of
-        where we installed X to):
- 
-     % lib/X11/etc/x386install.netbsd $DIRNAME
- 
-        where $DIRNAME is this top level dir (ie /usr/X386, /usr/local/X386,
-        /usr/local/X11, or wherever)
- 
-        This script verifies that /usr/X386 points to the correct place,
-        checks the /dev/ and /etc/ttys entries, and adds /usr/X386/bin to the
-        default path in /etc/csh.login.
- 
-        You should also add /usr/X386/bin to your own shell's path variable.
- 
- 
-     If X was already installed on your machine and you have customized your
- xinit or xdm runtime configuation scripts, omit the config archive or unpack
- it elsewhere and extract only that which you need.
- 
-     NOTE: Do not uncompress the font files in lib/X11/fonts without
-     subsequently running 'mkfontdir' in the corresponding font directory;
-     otherwise, your server will abort with the message "could not open default
-     font 'fixed'".
- 
- 4 - Installing Xdm, the display manager
- ---------------------------------------
-   Export restrictions prevent us from providing support for DES
- encryption outside the US.  If you have not installed FreeBSD's
- optional securedist/des, then passwords in /etc/passwd.master are
- unencrypted and you should install the version of xdm without DES
- encryption:
- 
- 
-  FreeBSD:
-  =------=
-  cat XFree86-2.0-xdm-nodes.tar.gz	| gunzip | tar xf -
-  cd /usr/X386/bin; ln -s xdm-nodes xdm
- 
-  NetBSD:
-  =-----=
-  % cat XFree86-2.0-xdm-no-des.tar.gz    | gunzip | (cd /usr/X386; tar xf -)
- 
- The xdm-nodes binary uses the *BSD  dummy crypt routine that
- prints the message 'Crypt not present in system' in the xdm-errors
- file each time a user logs in.  You can ignore this.  It just means
- /etc/passwd.master is unencrypted.  If you install xdm-des by mistake
- xdm will not accept any passwords.
- 
- If you have installed the optional securedist/des (secr09 for NetBSD) package
- on your system then you are using DES encryption on passwords and you should
- install xdm-des:
- 
-  FreeBSD:
-  =------=
-  cat XFree86-2.0-xdm-des.tar.gz	| gunzip | tar xf -
-  cd /usr/X386/bin; ln -s xdm-des xdm
- 
-  NetBSD:
-  =------=
-  % cat XFree86-2.0-xdm-des.tar.gz       | gunzip | (cd /usr/X386; tar xf -)
- 
- To start the display manager, log in as root on the console and type
- `xdm -nodaemon'.
- 
- You can start xdm automatically on bootup by disabling the console getty
- adding the following code to /etc/rc.local:
- 
-   if [ -x /usr/X386/bin/xdm ]; then
-     echo -n ' xdm'; /usr/X386/bin/xdm
-   fi
- 
- To disable the console getty, change 'on' to 'off' in the console
- entry in /etc/ttys:
- 
-     console	"/usr/libexec/getty Pc"	cons25	off secure
- 
- 5 - Configuring X for Your Hardware
- -----------------------------------
-   You *must* create /usr/X386/lib/X11/Xconfig to suit your hardware.
- See README.Config for step-by-step instructions for setting it up.
- 
- The Xconfig file tells the X server what kind of monitor, adapter and
- mouse you have.  In addition to README.Config, the server manual pages
- (XF86_Accel, XF86_Mono, XF86_SVGA, and XF86_VGA16) describe the
- options specific to each type of board.
- 
- Read README.Config, and look in /usr/X386/lib/X11/etc/modeDB.txt and
- /usr/X386/lib/X11/etc/AccelCards to find Clocks and ModeDB entries to your
- specific monitor and graphics card.  If you can find them there, grab the
- Clocks and ModeDB lines and put them in your Xconfig.  If not, read
- /usr/X386/lib/X11/etc/VideoModes.doc for instructions on how to create the
- video timing values given your vga card and monitor specs.  The manual for
- your monitor and adapter should have these values.  The tuner program (on
- FreeBSD.cdrom.com /pub/386BSD/0.1-ports/XFree86-2.0) can calculate a rough
- guess about a ModeDB line given the dot clock rate and horizontal
- frequency of your monitor.
- 
- Note: 386BSD, FreeBSD, and NetBSD do not support memory mapping of video
- memory on vesa local bus cards.  For these cards the server will respond
- 'Direct memory accessing has been disabled', which is normal.
- 
- The X server (except the 8514 and Mach32 servers)  will print out the
- Clocks values for your card if you leave them our of your Xconfig file
- when you run:
- 
-     X -probeonly >& x.out
- 
- You can take these values and edit them to put them in your Xconfig file;
- although you MUST include all the clock values, AND leave them in the same
- order.
- 
- If your mouse does not work try using kermit or tip to connect to the
- mouse serial port and verify that it does indeed generate characters.
- 
- For NetBSD 0.9, Microsoft BusMouse users will find that the following
- line should work:
- 
- BusMouse	"/dev/mms0"
- 
- 6 - Running X
- -------------
-   8mb of memory is a recommended minimum for running X.  The server,
- window manager and an xterm take about 2.5 Mb of memory themselves.  On a
- 4Mb system that would leave very little left over for other applications
- like gcc that expect a few meg free.  X will work with 4Mb of memory, but
- in practice compilation while running X can take 5 or 10 times as long due
- to constant paging.
- 
- The easiest way for new users to start X windows is to type 'startx >&
- startx.log'.  Error messages are lost unless you redirect them because
- the server takes over the screen.
- 
- To get out of X windows, type 'exit' in the console xterm.  You can
- customize your X by creating .xinitrc, .xserverrc, and .twmrc files in
- your home directory as described in the xinit and startx man pages.
- 
- 7 - Kernel Support for X
- ------------------------
-   The server supports several console drivers: pccons, syscons, codrv
- and pcvt.  They are detected at runtime and no configuration of the
- server itself is required.
- 
- The pccons driver is the most widely tested and is the console driver
- contained in the FreeBSD binary distribution's kernels, as well as
- that shipped with the GENERICAHA kernels in NetBSD 0.9.
- 
- In order to insead use the syscons driver, you must reconfigure,
- compile and install a new kernel from the FreeBSD sources.  For a
- general description of BSD kernel configuration get smm.02.config.ps.Z
- from gatekeeper.dec.com (16.1.0.2) in /pub/BSD/manuals.  It is a ready
- postscript copy of the kernel configuration chapter from the systems
- maintainers manual.
- 
- To make sure X support is enabled under NetBSD 0.9, the following
- line must be in your config file in /sys/arch/i386/conf:
- 
- options XSERVER, UCONSOLE
- 
- To use syscons 0.1 with NetBSD 0.9, obtain the syscons 0.1 package,
- and apply the patches in the file syscons-0.1.patch, available from
- ftp.cs.mcgill.ca:/pub/NetBSD/ports.
- 
- The codrv console driver is not bundled with FreeBSD, nor with NetBSD. 
- It is available from ftp.uni-duisburg.de in 
- /pub/unix/386bsd-0.1/unofficial/codrv and from bsd386.first.gmd.de in 
- ~veit/codrv (no ANON FTP, login with 'guest'/'guest', cd to ~veit/codrv).
- It is not clear that anybody has attempted to get this working with
- NetBSD 0.9
- 
- The pcvt console driver is also not bundled with *BSD.  There are
- patches available for pcvt version 2.10 to make it compatible with
- XFree86. Recent pcvt sources along with these patches can be found on
- irzr11.inf.tu-dresden.de (141.76.4.11) in /pub/unix/386bsd/pcvt.
- Refer to the file README.X-PATCHES there for more information. The
- pcvt X mode is compatible with the pccons driver X mode.
- 
- 8 - Rebuilding the XFree86 Distribution
- ---------------------------------------
-   The server link kit allow you to rebuild just the X server with a
- minimum amount of disk space.  Just unpack it, make the appropriate
- changes to the site.def, type './mkmf' and 'make' to link the server.
- See /usr/X386/lib/Server/README for more info.
- 
- See /usr/X386/lib/X11/etc/INSTALL for instructions on unbundling and
- building the source distribution.  You should configure the
- distribution by editing mit/site.def before compiling.  To compile the
- sources, invoke 
- 
-     FreeBSD:
-     =------=
-     make World BOOTSTRAPCFLAGS=-DFreeBSD
- 
-     NetBSD:
-     =-----=
-     make World BOOTSTRAPCFLAGS= 
-     # _NOT_ -DNetBSD!!!!!, just empty.
- 
- in the mit directory.
- 
- 9 - Building New X Clients
- --------------------------
-   The easiest way to build a new client (X application) is to use
- xmkmf if an Imakefile is included in the sources.  Type 'xmkmf -a' to
- create the Makefiles, check the configuration if necessary and type
- 'make'.  Whenever you install additional man pages you should update
- whatis.db by running 'makewhatis /usr/X386/man'.  To avoid the
- `Virtual memory exhausted' message from cc while compiling, increase
- the data and stack size limits (in csh type `limit datasize 32M' and
- `limit stacksize 16M').
- 
- 
- Many thanks to
- - Pace Willison for providing the initial port to 386BSD.
- - Amancio Hasty for fixing cursor restoration, mouse bugs and many others.
- - Christoph Robitschko for fixing com.c and thus select().
- - Nate Williams for the patchkit support for X.
- - Rod Grimes and Jack Velte of Walnut Creek Cdrom for use
-   of their machines in preparing the FreeBSD binary release.
- 
- Rich  Murphey
- David Dawes
- Marc  Wandschneider
- 
- 
- $XFree86: mit/server/ddx/x386/README.BSD,v 2.3 1993/10/24 13:44:04 dawes Exp $
--- 0 ----
diff -c mit/server/ddx/x386/README.Bsdi:2.3 mit/server/ddx/x386/README.Bsdi:2.4
*** mit/server/ddx/x386/README.Bsdi:2.3	Fri Mar 11 23:35:37 1994
--- mit/server/ddx/x386/README.Bsdi	Fri Mar 11 23:35:37 1994
***************
*** 1,4 ****
!                README for XFree86 2.0 on BSDI 1.0
                 ----------------------------------
  
  Contents
--- 1,4 ----
!                README for XFree86 2.1 on BSDI 1.0
                 ----------------------------------
  
  Contents
***************
*** 75,81 ****
  4 - Rebuilding the XFree86 Distribution
  ---------------------------------------
  
!   The INSTALL file describes how to create and build the XFree86-2.0 source
  distribution.
    When building for BSD/386, the default compiler is gcc-1.40. If you want to
  use gcc-2.4.5, define "#define HasGcc2 YES" in config/site.def. The compiler
--- 75,81 ----
  4 - Rebuilding the XFree86 Distribution
  ---------------------------------------
  
!   The INSTALL file describes how to create and build the XFree86-2.1 source
  distribution.
    When building for BSD/386, the default compiler is gcc-1.40. If you want to
  use gcc-2.4.5, define "#define HasGcc2 YES" in config/site.def. The compiler
***************
*** 87,95 ****
  config/site.def. The default is to skip the font creation.
  
    If you are using X when doing "make World", keep the number of open windows
! to a minimum or you may get "Can't fork" errors from make.
    The make program distributed with BSD/386 1.0 has been seen doing
  recompilations in the wrong order. When that happens, you can usually restart
! the make and it will complete OK. Gnu Make 3.67 or higher works much better.
  
! $XFree86: mit/server/ddx/x386/README.Bsdi,v 2.3 1993/10/24 13:44:05 dawes Exp $
--- 87,99 ----
  config/site.def. The default is to skip the font creation.
  
    If you are using X when doing "make World", keep the number of open windows
! to a minimum or you may get "Can't fork" errors from make. Another way to
! avoid this problem is to raise your process limit to 64. If you are using
! bash the command is "ulimit -u 64". With csh use "limit maxproc 64".
! 
    The make program distributed with BSD/386 1.0 has been seen doing
  recompilations in the wrong order. When that happens, you can usually restart
! the make and it will complete OK. Gnu Make 3.70 works much better and builds
! without problems on BSD/386 1.0.
  
! $XFree86: mit/server/ddx/x386/README.Bsdi,v 2.4 1994/03/05 11:54:56 dawes Exp $
diff -c mit/server/ddx/x386/README.Config:2.3 mit/server/ddx/x386/README.Config:2.4
*** mit/server/ddx/x386/README.Config:2.3	Fri Mar 11 23:35:38 1994
--- mit/server/ddx/x386/README.Config	Fri Mar 11 23:35:38 1994
***************
*** 61,69 ****
  server binaries are:
  
  	XF86_SVGA:   256-color Super-VGA server.  Contains accelerated
! 		     support for Cirrus 542{6,8} and Western Digital 90C31
! 		     chipsets, unaccelerated for the rest of the supported
! 		     chipsets.
  	XF86_Mono:   (S)VGA monochrome, optionally Hercules or other
  		     monochrome hardware support is linked in.
  	XF86_VGA16:  Generic VGA 16-color server (experimental).
--- 61,69 ----
  server binaries are:
  
  	XF86_SVGA:   256-color Super-VGA server.  Contains accelerated
! 		     support for Cirrus 542{0,2,4,6,8} and Western
! 		     Digital 90C31 chipsets, unaccelerated for the rest
! 		     of the supported chipsets.
  	XF86_Mono:   (S)VGA monochrome, optionally Hercules or other
  		     monochrome hardware support is linked in.
  	XF86_VGA16:  Generic VGA 16-color server (experimental).
***************
*** 449,452 ****
   "1280x1024"  135     1280 1312 1456 1712   1024 1027 1030 1064
  
  
! $XFree86: mit/server/ddx/x386/README.Config,v 2.3 1993/10/24 13:44:07 dawes Exp $
--- 449,452 ----
   "1280x1024"  135     1280 1312 1456 1712   1024 1027 1030 1064
  
  
! $XFree86: mit/server/ddx/x386/README.Config,v 2.4 1994/03/05 08:22:39 dawes Exp $
diff -c mit/server/ddx/x386/README.Linux:2.4 mit/server/ddx/x386/README.Linux:2.8
*** mit/server/ddx/x386/README.Linux:2.4	Fri Mar 11 23:35:39 1994
--- mit/server/ddx/x386/README.Linux	Fri Mar 11 23:35:39 1994
***************
*** 5,130 ****
  ----------
  	1) Linux versions on which XFree86 has been tested
  	2) Running XFree86
! 	3) Compiling XFree86
! 	4) Compiling a PEX server
! 	5) Omissions
  
  1 - Linux versions on which XFree86 has been tested
  ---------------------------------------------------
! 	XFree86 has been tested with Linux version 0.99pl13. It should work
  with any later version without change. The binaries and libraries are based
! on the 4.4.1 DLL C libraries. The DLL X libraries are produced with the 2.9
! dll-tools by Eric Youngdale. 
  
- !!!  TO USE THE BINARIES YOU NEED DAVID ENGEL'S SHARED DYNAMIC LINKER ld.so
- !!!  INSTALLED !!!
- 
- You should include /usr/X386/lib in /etc/ld.so.conf (it is in there by
- default) or in your LD_LIBRARY_PATH environment variable.
- 
  2 - Running XFree86
  -------------------
  	XFree86 is installed in /usr/X386. It requires about 4mb of virtual
  memory to run, although having 8mb of RAM is probably the minimum comfortable
  configuration. A 387 coprocessor is helpful for 386 machines, although
! greater gains in interactive performace are obtained with an increase in
  physical memory. Also, a faster graphics card, bus or RAM, will improve
  server performance.
  
! 	After unpacking the tar files, you need to include /usr/X386/lib in
! /etc/ld.so.conf (where it should already be by default) or in your
  LD_LIBRARY_PATH environment variable. Also, the configuration file
! /usr/X386/lib/X11/Xconfig *MUST* be modified based on the host setup.
! You may damage your hardware if you use a wrong Xconfig file, so 
! READ THE DOCS, especially the man pages and the other README files in
! /usr/X386/lib/X11/etc.   
! 
! 	Old binaries (linked to XFree86-1.2 or XFree86-1.3 libraries)
! will continue to work, but may need an explicit symlink from
! /lib/libX{11,t,aw}.so.3 to /usr/X386/lib/libX{11,t,aw}.so.3. Linking
! with ld.so against the XView 3L5 distribution will give problems with
! pre-1.3 versions of ld.so, since the XView libraries contain the
! absolute path to the shared images, which is discuraged with ld.so. A
! tempoary fix is including  / in /etc/ld.so.config, better recompile
! XView with relative library names or get a newer ld.so. 
! 
  	XFree86 has the ability to perform VT switching to and from the X
  server. When first started, XFree86 will automatically locate the first
! available VT (one that hasn't been opened by any process), and run on that VT.
! If there isn't one available, XFree86 will terminate with an error message.
! The server can be run on a specific VT by using the "vt<nn>" option, where
! <nn> is the number of an available VT (starting from 1).
! 
! 	Once running inside X, switching to another VT is accomplished
! by pressing Ctrl-Alt-<Fnn> where nn is the number of the VT to switch
! to. To return to the server, press the proper key-combination that
! moves you back to the VT that XFree86 is using: by default, this is
! Alt-<Fmm>, where mm is the number of the VT the server is running on
! (this number is printed when the server is started).  Note that this is
! NOT the VT from which the server was started.
! 
  NOTE: you can redefine the text-mode keybindings with the 'loadkeys'
! command found in the kbd-0.81.tar.gz archive.  With this, you can (for
! example) make Ctrl-Alt-<Fmm> work from text mode the same way it works
! under the XFree86 server. 
! 
! CAUTION: There are versions of the Linux Kernel (including some pl12
! and pl13 releases), that don't restore the status of the Ctrl and Alt 
! key correctly when switching to a VT. This can be solved by pressing 
! and releasing the CTRL and ALT key after switching (or by upgrading 
! to a newer kernel...). This will be fixed in the next kernel version. 
! 
! 	When the server is exited, it will return to the original VT it was
! started from, unless it dies unexpectedly, when the switch must be done
! manually. 
! 
  	There are some quirks that may need some fixing depending on your
! configuration. In the past, Linux xload used the BSD method of obtaining the 
! load average from the running kernel. In the XFree86-1.3 release, that has 
! been replaced by reading the information from /proc/loadavg instead, which 
! should be forward-compatible with future kernel releases. Xman has also been 
! changed to support the GNU groff family instead of the BSD nroff family. A 
! quick edit and recompile restores BSD conventions. The server has been modified
! to provide better console redirection support for clients, which includes
! changing the ownership of /dev/console and /dev/tty0 as well as the VT used
! to run on. Unfortunately, the kernel requires that a process be setuid root
! to perform console redirection, so xterm and xconsole must be setuid root.
  
! 3 - Compiling XFree86
  ---------------------
  	There are no special instructions required for compiling XFree86.
! This version was compiled with gcc-2.4.5, the 4.4.1 DLL libraries and the
! 1.3 shared, dynamic linker ld.so. The tools-2.9 DLL package was used to
! generate the shared libraries. The server has been compiled with -m486,
! which optimizes it for the 486 processor, but the binary will run on the
! 386 processor (there is a slight increase in binary size over using -m386,
! but no loss of performance).
  
  	The distribution is very large, but it is possible to compile
  XFree86 on a single 64mb partition, if the source tree is carefully
! trimmed (no manpages, PEX or large clients). Simply run "make World" to
! create the Makefiles, then stop the make and run each piece individually. It
! is not necessary to run "make depend" as well, which saves some space.
! Having 100mb available makes compiling XFree86 a lot easier. You will need
! about 10mb of virtual memory to compile the entire server. 
! 
! 	There is an external problem with compiling the server. The
! makedepend program does not search the private gcc include directory for
! headers (i.e. float.h), so there are lots of warnings generated during the
! make depend phase. These can be safely ignored, or the private headers can
! be symlinked to /usr/include. A better solution which involves cpp directly
! is being investigated.  
  
  	There is support now for creating X DLL libraries. By default,
  certain libraries are compiled into both static and shared form, but this
  can be changed by editing mit/config/lnuxLib.rules. The new shared library
  symlinks no longer need to be moved to /lib, as starting with XFree86-2.0
! the shared, dynamic linker ld.so is used. 
  
! 	If patches are applied which change the libraries, modified
! jump_xxx files will be needed. Those can be generated according to
! instructions given in the dll tools package, and will be made
! available as XFree86 patches.  
  
  	Thanks to Dirk Hohndel (hohndel@informatik.uni-wuerzburg.de) for
  working out all the details and doing all the work in creating the first
--- 5,144 ----
  ----------
  	1) Linux versions on which XFree86 has been tested
  	2) Running XFree86
! 	3) Backwards Compatibility
! 	4) Compiling XFree86
! 	5) Compiling a PEX server
! 	6) Omissions
  
  1 - Linux versions on which XFree86 has been tested
  ---------------------------------------------------
! 	XFree86 has been tested with Linux version 0.99pl15h. It should work
  with any later version without change. The binaries and libraries are based
! on the 4.5.21 DLL C libraries, and the 1.4.3 dynamic linker ld.so. The DLL X
! libraries are produced with the 2.11 DLL-tools by Eric Youngdale.
  
  2 - Running XFree86
  -------------------
  	XFree86 is installed in /usr/X386. It requires about 4mb of virtual
  memory to run, although having 8mb of RAM is probably the minimum comfortable
  configuration. A 387 coprocessor is helpful for 386 machines, although
! greater gains in interactive performance are obtained with an increase in
  physical memory. Also, a faster graphics card, bus or RAM, will improve
  server performance.
  
! 	After unpacking the tar files, you need to include /usr/X386/lib
! in /etc/ld.so.conf (where it should already be by default) or in your
  LD_LIBRARY_PATH environment variable. Also, the configuration file
! /usr/X386/lib/X11/Xconfig *MUST* be properly filled out based on the host
! setup using Xconfig.sample as a starting point and README.Config as
! guideline.  You may damage your hardware if you use a wrong Xconfig file,
! so READ THE DOCS, especially the man pages and the other README files in
! /usr/X386/lib/X11/etc.
!  
  	XFree86 has the ability to perform VT switching to and from the X
  server. When first started, XFree86 will automatically locate the first
! available VT (one that hasn't been opened by any process), and run on that
! VT.  If there isn't one available, XFree86 will terminate with an error
! message.  The server can be run on a specific VT by using the "vt<nn>"
! option, where <nn> is the number of an available VT (starting from 1). If
! you don't have a free VT XFree86 cannot run. You can increase the number
! of available VTs by increasing the value of NR_CONSOLES in
! include/linux/tty.h and recompiling the kernel.
! 
! 	Once running inside X, switching to another VT is accomplished by
! pressing Ctrl-Alt-<Fnn> where nn is the number of the VT to switch to. To
! return to the server, press the proper key-combination that moves you back
! to the VT that XFree86 is using: by default, this is Alt-<Fmm>, where mm
! is the number of the VT the server is running on (this number is printed
! when the server is started).  Note that this is NOT the VT from which the
! server was started.
!  
  NOTE: you can redefine the text-mode keybindings with the 'loadkeys'
! command found in the kbd-0.81.tar.gz archive (or a later version thereof).
! With this, you can (for example) make Ctrl-Alt-<Fmm> work from text mode
! the same way it works under the XFree86 server.
!   
! 	When the server is exited, it will return to the original VT it
! was started from, unless it dies unexpectedly, when the switch must be
! done manually. There still seem to be wierd combinations of graphic cards
! and motherboards that have problems to restore the textfont when returning
! from XFree86 to the text mode. In these cases using the runx script from
! the svgalib distribution might help.
!  
!  	The XFree86 server now queries the kernel to obtain the key
! binding in effect at startup. These bindings are either the default map in
! place when the kernel was compiled, or reloaded using the 'loadkeys'
! utility. Not all keys are bound: kernel-specific, multiple keysym, and
! dead keys are not handled by the server. All others are translated to
! their X equivalents. Note that the XFree86 server only allows for four
! modifier maps: unshifted, shifted, modeswitch unshifted and modeswitch
! shifted.  Depending on what the modeswitch key is (it is settable in your
! Xconfig and defaults to Alt), XFree86 will read those tables into its
! keymaps.  This means if you use certain keys, like left-Control, for Linux
! modeswitch, that will not be mappable to X. Read the manpage XFree86kbd
! for more information about X keyboard handling.
!  
  	There are some quirks that may need some fixing depending on your
! configuration. In the past, Linux xload used the BSD method of obtaining
! the load average from the running kernel. In the XFree86-1.3 release, that
! has been replaced by reading the information from /proc/loadavg instead,
! which should be forward-compatible with future kernel releases. Xman has
! also been changed to support the GNU groff family instead of the BSD nroff
! family. A quick edit and recompile restores BSD conventions. The server
! has been modified to provide better console redirection support for
! clients, which includes changing the ownership of /dev/console and
! /dev/tty0 as well as the VT used to run on. Unfortunately, the kernel
! requires that a process be setuid root to perform console redirection, so
! xterm and xconsole must be setuid root.  As xconsole is not designed with
! running setuid root in mind, this opens a big security problem.
! 
! 3 - Backwards Compatibility
! ---------------------------
! 
! 	Old binaries (linked to XFree86-1.2, XFree86-1.3 or XFree86-2.0
! libraries) will continue to work, but may need an explicit symlink from
! /lib/libX{11,t,aw}.so.3 to /usr/X386/lib/libX{11,t,aw}.so.3.  Linking with
! ld.so against the XView3L5 distribution will give problems with pre-1.3
! versions of ld.so, since the XView libraries contain the absolute path to
! the shared images, which is discouraged with ld.so. A temporary fix is
! including / in /etc/ld.so.config, better recompile XView with relative
! library names or get a newer ld.so.
  
! 4 - Compiling XFree86
  ---------------------
  	There are no special instructions required for compiling XFree86.
! This version was compiled with gcc-2.5.8, the 4.4.21 DLL libraries and the
! 1.4.3 shared, dynamic linker ld.so. The tools-2.11 DLL package was used to
! generate the shared libraries. Using newer versions of these tools should
! definitely work, as should slightly older versions. The server has been
! compiled with -m486, which optimizes it for the 486 processor, but the
! binary will run on the 386 processor (there is a slight increase in binary
! size over using -m386, but no loss of performance).
  
  	The distribution is very large, but it is possible to compile
  XFree86 on a single 64mb partition, if the source tree is carefully
! trimmed (no manpages, PEX or large clients). Simply run "make Makefiles"
! to create the Makefiles, then stop the make and run each piece
! individually. It is not necessary to run "make depend" as well, which
! saves some space.  Having 100mb available makes compiling XFree86 a lot
! easier. You will need about 10mb of virtual memory to compile the entire
! server.
  
  	There is support now for creating X DLL libraries. By default,
  certain libraries are compiled into both static and shared form, but this
  can be changed by editing mit/config/lnuxLib.rules. The new shared library
  symlinks no longer need to be moved to /lib, as starting with XFree86-2.0
! the shared, dynamic linker ld.so is used.
  
! 	If patches are applied which significantly change the libraries,
! modified jump_xxx files will be needed. Those can be generated according to
! instructions given in the DLL tools package, and will be made available as
! XFree86 patches.
! 
! 	The JUMP_xxx defines used to compile the X libraries can also
! be used to compile external X shared libraries, like Xaw3d. Detailed
! instructions are provided in /usr/X386/lib/X11/config/lnuxLib.rules,
! where the X library definitions are provided, as an example.
  
  	Thanks to Dirk Hohndel (hohndel@informatik.uni-wuerzburg.de) for
  working out all the details and doing all the work in creating the first
***************
*** 131,137 ****
  set of XFree86 DLL libs, on which the current method (developed by Orest
  Zborowski (orestz@microsoft.com)) is based.
  
! 4 - Compiling a PEX server
  --------------------------
  
  	PEX is now a part of the XFree86 source distribution and including
--- 145,151 ----
  set of XFree86 DLL libs, on which the current method (developed by Orest
  Zborowski (orestz@microsoft.com)) is based.
  
! 5 - Compiling a PEX server
  --------------------------
  
  	PEX is now a part of the XFree86 source distribution and including
***************
*** 143,154 ****
  produce a server including PEX. See the relevant docs in
  /usr/X386/lib/Server/README.
  
! 5 - Omissions
  -------------
  
  	With each release there are fewer omissions from the basic X11R5
! offering. Starting with XFree86-2.0 the MITSHM (shared memory) extensions 
  are included. Now only the XINPUT extension is missing.
  
  
! $XFree86: mit/server/ddx/x386/README.Linux,v 2.4 1993/10/24 13:44:08 dawes Exp $
--- 157,168 ----
  produce a server including PEX. See the relevant docs in
  /usr/X386/lib/Server/README.
  
! 6 - Omissions
  -------------
  
  	With each release there are fewer omissions from the basic X11R5
! offering. Starting with XFree86-2.0 the MITSHM (shared memory) extensions
  are included. Now only the XINPUT extension is missing.
  
  
! $XFree86: mit/server/ddx/x386/README.Linux,v 2.8 1994/03/09 11:16:13 dawes Exp $
diff -c mit/server/ddx/x386/README.Mach:2.0 mit/server/ddx/x386/README.Mach:2.2
*** mit/server/ddx/x386/README.Mach:2.0	Fri Mar 11 23:35:40 1994
--- mit/server/ddx/x386/README.Mach	Fri Mar 11 23:35:40 1994
***************
*** 1,4 ****
!                   README for XFree86 2.0 on Mach
                    ------------------------------
  
  All XFree86 client binaries should work with not only the Mach 2.5
--- 1,4 ----
!                   README for XFree86 2.1 on Mach
                    ------------------------------
  
  All XFree86 client binaries should work with not only the Mach 2.5
***************
*** 54,60 ****
  	1	for microsoft mouse
  	2	for ps2 mouse
  	3	for no real mouse at all
! 	4	for logitek mouse man (M+ or V type)
  
  We have implemented a neat hack for notebooks so that they don't have
  to be saddled with a HUGE external mouse.  Scroll lock toggles a mode
--- 54,60 ----
  	1	for microsoft mouse
  	2	for ps2 mouse
  	3	for no real mouse at all
! 	4	for logitech mouse man (M+ or V type)
  
  We have implemented a neat hack for notebooks so that they don't have
  to be saddled with a HUGE external mouse.  Scroll lock toggles a mode
***************
*** 127,130 ****
  for read/write.  There are many ways to achieve this effect.
  
  
! $XFree86: mit/server/ddx/x386/README.Mach,v 2.0 1993/10/21 15:53:54 dawes Exp $
--- 127,130 ----
  for read/write.  There are many ways to achieve this effect.
  
  
! $XFree86: mit/server/ddx/x386/README.Mach,v 2.2 1994/03/08 08:07:08 dawes Exp $
diff -c mit/server/ddx/x386/README.Minix:1.1 mit/server/ddx/x386/README.Minix:2.0
*** mit/server/ddx/x386/README.Minix:1.1	Fri Mar 11 23:35:40 1994
--- mit/server/ddx/x386/README.Minix	Fri Mar 11 23:35:40 1994
***************
*** 17,23 ****
  following features required for the X server and clients:
  
  	- TCP/IP server
! 	- Asynchronous I/O (instead of Berkely-like "select()")
  	- Ptys
  	- New ioctls to configure the keyboard, screen, etc. devices
  
--- 17,23 ----
  following features required for the X server and clients:
  
  	- TCP/IP server
! 	- Asynchronous I/O (instead of Berkeley-like "select()")
  	- Ptys
  	- New ioctls to configure the keyboard, screen, etc. devices
  
***************
*** 105,108 ****
    your cross development system) or by copying them to floppy/tape.
  
  
! $XFree86: mit/server/ddx/x386/README.Minix,v 1.1 1993/03/23 13:58:02 dawes Exp $
--- 105,108 ----
    your cross development system) or by copying them to floppy/tape.
  
  
! $XFree86: mit/server/ddx/x386/README.Minix,v 2.0 1994/03/08 08:07:09 dawes Exp $
diff -c /dev/null mit/server/ddx/x386/README.NetBSD:2.9
*** /dev/null	Fri Mar 11 23:35:40 1994
--- mit/server/ddx/x386/README.NetBSD	Fri Mar 11 23:35:41 1994
***************
*** 0 ****
--- 1,436 ----
+            README for XFree86 2.1 on NetBSD 0.9 and NetBSD-current
+            -------------------------------------------------------
+ 
+ Contents
+ --------
+     0) Notes
+     1) What and Where is XFree86?
+     2) Bug Reports for This Document
+     3) Installing The Binaries
+     4) Installing Xdm, the display manager
+     5) Configuring X for Your Hardware
+     6) Running X
+     7) Kernel Support for X
+     8) Rebuilding the XFree86 Distribution
+     9) Building New X Clients
+ 
+ 
+ 1 - What and Where is XFree86?
+ ------------------------------
+   XFree86 is a port of X11R5 that supports several versions of Intel-based
+ Unix.  It is derived from X386 1.2, which was the X server distributed
+ with X11R5.  This release consists of many new features and performance
+ improvements as well as many bug fixes.  The release is available as
+ source patches against the MIT X11R5 code, as well as binary distributions
+ for many architectures.
+ 
+ The sources for XFree86 are available by anonymous ftp from:
+ 
+     ftp.x.org:/contrib/XFree86
+     ftp.physics.su.oz.au:/XFree86.
+ 
+ [I don't know if someone will do specific NetBSD 0.9 binary distribution.
+  perhaps static -current binaries will run on 0.9 ?]
+ Binaries for NetBSD 0.9 will be available from:
+ 
+     ftp.cs.mcgill.ca:/pub/NetBSD
+     agate.berkeley.edu:/pub/NetBSD/ports
+     sun-lamp.cs.berkeley.edu:/pub/NetBSD/ports
+ 
+ Binaries for NetBSD-Current will be available from:
+ 
+     ftp.laas.fr:/pub/NetBSD
+ 
+ On US ftp sites note 00README-Legal-Rules-Regs or README.export-control 
+ which state that ftp users outside the U.S. should not copy 
+ XFree86-2.1-xdm-des.tar.gz from sites within the U.S. because it employs 
+ DES encryption.
+ 
+ 2 - Bug Reports for This Document
+ ---------------------------------
+   Send email to matthieu@laas.fr (Matthieu Herrb) or XFree86@physics.su.oz.au
+ if you have comments or suggestions about this file and we'll revise it.
+ 
+ 3 - Installing the Binaries
+ ---------------------------
+ 
+     The binary distribution is composed of a number of split tar archives
+ which are the executables, servers, fonts, libraries, include files,
+ man pages, config files, and the server link kit.  The full distribution
+ takes over 40MB of disk space.  The large archives are split into
+ smaller chunks.
+ 
+     The contents of the archives are:
+ 
+     bin         - all of the executable X client applications (except xdm)
+     include     - the include/X11 header files
+     fonts       - the misc, 75dpi, 100dpi, and scaled fonts
+     doc         - READMEs, install scripts, and XFree86 specific man pages.
+     lib         - X11 libraries, and data files needed at runtime
+     config      - customizable xinit, xdm, and fs runtime configuration files.
+ 
+     Choose at least one of the following to match your hardware:
+ 
+     8514        - the X server for IBM 8514/A and compatible boards
+     Mach8       - the X server for ATI Mach8 graphics accelerator boards
+     Mach32      - the X server for ATI Mach32 graphics accelerator boards
+     S3          - the X server for S3 based boards
+     SVGA        - the 8-bit pseudo-color X server for Super VGA cards
+     VGA16       - the 4-bit pseudo-color X server for VGA & SVGA cards.
+     Mono        - the Monochrome X Server
+ 
+     OPTIONAL:
+ 
+     man         - man pages except XFree86 specific ones in the etc archive
+     xdm-des     - xdm executable with DES encryption
+     xdm-no-des  - xdm executable without DES encryption
+     linkkit     - optional X server reconfiguration kit
+     pex         - pex clients, libraries, header files and data
+ 
+ 
+     If this is your first time, then you should be able to safely
+ install all of the packages.  If you're going to be installing the
+ source as well, then you might not want to bother with the linkkit and
+ pex archives.  As a minimal install, you'll need bin, include, fonts
+ doc, lib, config, and one X server.
+ 
+     To unpack and install the archives:
+ 
+     1. create some destination directory in which you'd like the
+        X distribution to live.  /usr/X386 is recommended, but if that
+        partition is full (as it is on my machine), then just create an
+        alternate directory, and sym-link /usr/X386 to this place.
+ 
+     ie, on my machine, I do the following:
+ 
+     % cd /usr/local
+     % mkdir X11
+     % ln -s /usr/local/X11 /usr/X386
+ 
+ 
+     2. Assuming that the destination directory for XFree86 2.1 is /usr/X386,
+        run the following from wherever all the archive files are (replace
+        /usr/X386 with wherever you wish them to go if that isn't the place):
+ 
+     % cat XFree86-2.1-bin.tar.gz.*          | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-include.tar.gz.*      | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-fonts.tar.gz.*        | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-doc.tar.gz            | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-lib.tar.gz.*          | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-config.tar.gz         | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-man.tar.gz            | gunzip | (cd /usr/X386; tar xf -)
+ 
+     # Choose only one of the following two
+     % cat XFree86-2.1-xdm-des.tar.gz        | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-xdm-no-des.tar.gz     | gunzip | (cd /usr/X386; tar xf -)
+ 
+     % cat XFree86-2.1-linkkit.tar.gz.*      | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-pex.tar.gz            | gunzip | (cd /usr/X386; tar xf -)
+ 
+     # Choose one ore more servers to install
+     % cat XFree86-2.1-8514.tar.gz           | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-Mach8.tar.gz          | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-Mach32.tar.gz         | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-S3.tar.gz             | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-SVGA.tar.gz           | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-VGA16.tar.gz          | gunzip | (cd /usr/X386; tar xf -)
+     % cat XFree86-2.1-Mono.tar.gz           | gunzip | (cd /usr/X386; tar xf -)
+ 
+     3. Set the XWINHOME environment variable to the path where you
+        installed XFree86. Under csh  type:
+ 		
+ 		setenv XWINHOME /usr/X386
+ 
+        under sh  type
+ 
+ 		XWINHOME=/usr/X386 
+ 		export XWINHOME
+ 
+ 	(Replace /usr/X386 by the appropriate dir if necessary).
+ 
+        Also, don't forget to include these lines in your .login or
+        .profile for permanent use.
+ 
+     4. You should now run the script x386install from lib/X11/etc.
+        It is invoked as follows (assuming we are in the top level dir of
+        where we installed X to):
+ 
+        % lib/X11/etc/x386install
+ 
+        This script verifies that ${XWINHOME} points to the correct
+        place, checks the /dev/ and /etc/ttys entries, and adds
+        ${XWINHOME}/bin to the default path in /etc/csh.login.
+ 
+        You should also add ${XWINHOME}/bin to your own shell's path
+        variable.
+ 
+     5. If needed, reboot your machine to take all previous
+        modifications into account.
+ 
+     6. Finally, run the ConfigXF86 script from ${XWINHOME}/lib/X11/etc
+        in order to build a Xconfig file. See README.ConfigXF86 for
+        details. 
+ 
+     If X was already installed on your machine and you have customized your
+ xinit or xdm runtime configuration scripts, omit the config archive or unpack
+ it elsewhere and extract only that which you need.
+ 
+     NOTE: Do not uncompress the font files in lib/X11/fonts without
+     subsequently running 'mkfontdir' in the corresponding font directory;
+     otherwise, your server will abort with the message "could not open default
+     font 'fixed'".
+ 
+     Using shared libraries with NetBSD-current:
+ 
+     The binary distribution for NetBSD-current uses shared libraries.
+     In order to get it running you need to make sure that either:
+ 
+ 	o XWINHOME is set to /usr/X386. In this case ld.so will
+ 	  find your libraries automagically 
+         o you added ${XWINHOME}/lib to the arguments of the
+           ``ldconfig'' command in /etc/rc. (See ldconfig(8) in the
+           manual for details)
+         o you have a LD_LIBRARY_PATH environment variable that
+           includes the path to your XFree86 libraries. (In this latter
+           case setuid executables won't run).
+ 
+     If XWINHOME is not /usr/X386 and you have an older version with
+     shared libraries in /usr/X386, be warned that the libraries in
+     /usr/X386/lib will probably take precedence over the one in
+     XWINHOME because ld has a hard-coded path to /usr/X386/lib.
+ 
+ 
+ 
+ 4 - Installing Xdm, the display manager
+ ---------------------------------------
+   Export restrictions prevent us from providing support for DES
+ encryption outside the US.  If you have not installed NetBSD's
+ optional secr09, then passwords in /etc/passwd.master are
+ unencrypted and you should install the version of xdm without DES
+ encryption:
+ 
+  % cat XFree86-2.1-xdm-no-des.tar.gz    | gunzip | (cd /usr/X386; tar xf -)
+ 
+ The xdm-nodes binary uses the *BSD  dummy crypt routine that
+ prints the message 'Crypt not present in system' in the xdm-errors
+ file each time a user logs in.  You can ignore this.  It just means
+ /etc/passwd.master is unencrypted.  If you install xdm-des by mistake
+ xdm will not accept any passwords.
+ 
+ If you have installed the optional securedist/des (secr09 for NetBSD) package
+ on your system then you are using DES encryption on passwords and you should
+ install xdm-des:
+ 
+  % cat XFree86-2.1-xdm-des.tar.gz       | gunzip | (cd /usr/X386; tar xf -)
+ 
+ To start the display manager, log in as root on the console and type
+ `xdm -nodaemon'.
+ 
+ You can start xdm automatically on bootup by disabling the console getty
+ adding the following code to /etc/rc.local:
+ 
+   if [ -x /usr/X386/bin/xdm ]; then
+     echo -n ' xdm'; /usr/X386/bin/xdm
+   fi
+ 
+ To disable the console getty, change 'on' to 'off' in the console
+ entry in /etc/ttys:
+ 
+     console	"/usr/libexec/getty Pc"	cons25	off secure
+ 
+ 5 - Configuring X for Your Hardware
+ -----------------------------------
+   You *must* create /usr/X386/lib/X11/Xconfig to suit your hardware.
+ See README.Config for step-by-step instructions for setting it up.
+ 
+ The Xconfig file tells the X server what kind of monitor, adapter and
+ mouse you have.  In addition to README.Config, the server manual pages
+ (XF86_Accel, XF86_Mono, XF86_SVGA, and XF86_VGA16) describe the
+ options specific to each type of board.
+ 
+ Read README.Config, and look in /usr/X386/lib/X11/etc/modeDB.txt and
+ /usr/X386/lib/X11/etc/AccelCards to find Clocks and ModeDB entries to your
+ specific monitor and graphics card.  If you can find them there, grab the
+ Clocks and ModeDB lines and put them in your Xconfig.  If not, read
+ /usr/X386/lib/X11/etc/VideoModes.doc for instructions on how to create the
+ video timing values given your vga card and monitor specs.  The manual for
+ your monitor and adapter should have these values.  The tuner program (on
+ FreeBSD.cdrom.com /pub/386BSD/0.1-ports/XFree86-2.1) can calculate a rough
+ guess about a ModeDB line given the dot clock rate and horizontal
+ frequency of your monitor.
+ 
+ Note: 386BSD, FreeBSD, and NetBSD do not support memory mapping of video
+ memory on vesa local bus cards.  For these cards the server will respond
+ 'Direct memory accessing has been disabled', which is normal.
+ 
+ The X server (except the 8514 and Mach32 servers)  will print out the
+ Clocks values for your card if you leave them our of your Xconfig file
+ when you run:
+ 
+     X -probeonly >& x.out
+ 
+ You can take these values and edit them to put them in your Xconfig file;
+ although you MUST include all the clock values, AND leave them in the same
+ order.
+ 
+ If your mouse does not work try using kermit or tip to connect to the
+ mouse serial port and verify that it does indeed generate characters.
+ 
+ For NetBSD 0.9, Microsoft BusMouse users will find that the following
+ line should work:
+ 
+ BusMouse	"/dev/mms0"
+ 
+ 6 - Running X
+ -------------
+   8mb of memory is a recommended minimum for running X.  The server,
+ window manager and an xterm take about 2.5 Mb of memory themselves.  On a
+ 4Mb system that would leave very little left over for other applications
+ like gcc that expect a few meg free.  X will work with 4Mb of memory, but
+ in practice compilation while running X can take 5 or 10 times as long due
+ to constant paging.
+ 
+ The easiest way for new users to start X windows is to type 'startx >&
+ startx.log'.  Error messages are lost unless you redirect them because
+ the server takes over the screen.
+ 
+ To get out of X windows, type 'exit' in the console xterm.  You can
+ customize your X by creating .xinitrc, .xserverrc, and .twmrc files in
+ your home directory as described in the xinit and startx man pages.
+ 
+ 7 - Kernel Support for X
+ ------------------------
+   The server supports several console drivers: pccons, syscons, codrv
+ and pcvt.  They are detected at runtime and no configuration of the
+ server itself is required.
+ 
+ The pccons driver is the most widely tested and is the console driver
+ contained in the GENERICAHA kernels in NetBSD 0.9 and NetBSD-current
+ 
+ In order to instead use the syscons driver, you must reconfigure,
+ compile and install a new kernel from the NetBSD sources.  For a
+ general description of BSD kernel configuration look in
+ /usr/src/share/doc/smm/02.config.  After running 'make' it contains a
+ ready postscript copy of the kernel configuration chapter from the
+ systems maintainers manual.
+ 
+ To make sure X support is enabled under NetBSD, the following
+ line must be in your config file in /sys/arch/i386/conf:
+ 
+ options XSERVER, UCONSOLE
+ 
+ The syscons console driver is not bundled with FreeBSD or NetBSD.
+ Current version is 1.2 and supports XFree86-2.1.
+ 
+ The codrv console driver is not bundled with FreeBSD, nor with NetBSD. 
+ It is available from ftp.uni-duisburg.de in 
+ /pub/unix/386bsd-0.1/unofficial/codrv and from bsd386.first.gmd.de in 
+ ~veit/codrv (no ANON FTP, login with 'guest'/'guest', cd to ~veit/codrv).
+ It is not clear that anybody has attempted to get this working with
+ NetBSD 0.9
+ 
+ The pcvt console driver is also not bundled with *BSD.  Version 3.0
+ has just been posted to comp.sources.misc. The pcvt X mode is
+ compatible with the pccons driver X mode.
+ 
+     MIT-SHM
+     =-----= 
+ 
+ NetBSD-current supports System V shared memory. If XFree86 2.1 detects
+ this support in your kernel, it will support the MIT-SHM extension.
+ 
+     Under NetBSD-current, use the following to add shared memory
+     support to your kernel:
+ 
+     To add support for system V shared memory to your kernel add the
+     lines:
+ 
+ 	# System V-like IPC
+ 	options         SYSVMSG
+ 	options         SYSVSEM
+ 	options         SYSVSHM
+  
+     to your kernel config file. Then from /sys/arch/i386/config, type
+ 
+ 	# rm -f ../compile/<KERNEL-NAME>/*
+ 	# config <KERNEL-NAME>
+ 	# cd ../compile/<KERNEL-NAME>
+ 	# make depend 
+ 	# make
+ 
+     Then install your new kernel and re-boot:
+ 
+ 	# cp /netbsd /onetbsd
+ 	# cp netbsd /
+ 	# reboot
+ 
+ 
+ 8 - Rebuilding the XFree86 Distribution
+ ---------------------------------------
+   The server link kit allow you to rebuild just the X server with a
+ minimum amount of disk space.  Just unpack it, make the appropriate
+ changes to the site.def, type './mkmf' and 'make' to link the server.
+ See /usr/X386/lib/Server/README for more info.
+ 
+ See /usr/X386/lib/X11/etc/INSTALL for instructions on unbundling and
+ building the source distribution.
+ 
+ If you don't already have the header files 'console.h' and 'pccons.h'
+ installed in /usr/include/machine (or /usr/include/sys for 386BSD), then
+ install the copies that are supplied in mit/server/ddx/x386/etc/.
+ 
+ You should configure the distribution by editing mit/site.def before
+ compiling.  To compile the sources, invoke 
+ 
+     make World
+ 
+ in the mit directory.
+ 
+     Support for shared libs under NetBSD-current
+     =------------------------------------------=
+ 
+     If you're running NetBSD-current, you can enable the build of
+     shared libraries by uncommenting the appropriate line in
+     'config/site.def'.
+ 
+ 9 - Building New X Clients
+ --------------------------
+   The easiest way to build a new client (X application) is to use
+ xmkmf if an Imakefile is included in the sources.  Type 'xmkmf -a' to
+ create the Makefiles, check the configuration if necessary and type
+ 'make'.  Whenever you install additional man pages you should update
+ whatis.db by running 'makewhatis /usr/X386/man'.  To avoid the
+ `Virtual memory exhausted' message from cc while compiling, increase
+ the data and stack size limits (in csh type `limit datasize 32M' and
+ `limit stacksize 16M').
+ 
+ Note:  Starting with XFree86 2.1 and NetBSD-current, the symbol "__386BSD__"
+ no longer gets defined either by the compiler or via the X config files
+ for FreeBSD systems.  When porting clients to BSD systems, make use of the
+ symbol "BSD" for code which is truly BSD-specific.  The value of the
+ symbol can be used to distinguish different BSD releases.  For example,
+ code specific to the Net-2 and later releases can use:
+                    
+ #if (BSD >= 199103)
+ 
+ To ensure that this symbol is correctly defined, include either
+ <X11/Xos.h> (best) or <sys/param.h> in the source that requires it.
+ For code that really is specific to a particular i386 BSD port, use
+ __FreeBSD__ for FreeBSD, __NetBSD__ for NetBSD, __386BSD__ for 386BSD,
+ and __bsdi__ for BSD/386.
+ 
+ 
+ Many thanks to
+ - Pace Willison for providing the initial port to 386BSD.
+ - Amancio Hasty for fixing cursor restoration, mouse bugs and many others.
+ - Christoph Robitschko for fixing com.c and thus select().
+ - Nate Williams for the patchkit support for X.
+ - Rod Grimes and Jack Velte of Walnut Creek Cdrom for use
+   of their machines in preparing the FreeBSD binary release.
+ 
+ Rich  Murphey
+ David Dawes
+ Marc  Wandschneider
+ Matthieu Herrb
+ 
+ $XFree86: mit/server/ddx/x386/README.NetBSD,v 2.9 1994/03/08 08:07:12 dawes Exp $
diff -c mit/server/ddx/x386/README.SCO:2.2 mit/server/ddx/x386/README.SCO:2.5
*** mit/server/ddx/x386/README.SCO:2.2	Fri Mar 11 23:35:42 1994
--- mit/server/ddx/x386/README.SCO	Fri Mar 11 23:35:42 1994
***************
*** 123,129 ****
  mapping in high memory when accessing the card. The dmmap driver comes in
  two forms, a binary archive which is supplied with the full binary
  distribution and a source archive which is located in /usr/X386/lib/X11/etc.
! Both distributions provide instuctions for installation/removal within the
  README file. 
  
  
--- 123,129 ----
  mapping in high memory when accessing the card. The dmmap driver comes in
  two forms, a binary archive which is supplied with the full binary
  distribution and a source archive which is located in /usr/X386/lib/X11/etc.
! Both distributions provide instructions for installation/removal within the
  README file. 
  
  
***************
*** 176,184 ****
  
  The defaults are set such that you should only require minimal changes to
  the site.def file.  The BOOTSTRAPCFLAGS do most of the work for you. The
! defaults will use gcc 2 or above and the sdbm library.  They also compile
! for shared libraries and setup formatted man pages using compression. The
! most likely Parameters you will be interested in changing are:
  
      1.  What Fonts etc get compiled.
      2.  What gets installed (XdmConfig, FSConfig, ...)
--- 176,184 ----
  
  The defaults are set such that you should only require minimal changes to
  the site.def file.  The BOOTSTRAPCFLAGS do most of the work for you. The
! defaults will use gcc 2 or above.  They also compile for shared libraries
! and setup formatted man pages using compression. The most likely
! Parameters you will be interested in changing are:
  
      1.  What Fonts etc get compiled.
      2.  What gets installed (XdmConfig, FSConfig, ...)
***************
*** 224,236 ****
      #include </usr/include/sys/time.h>
      #endif /* _SYS_TIME_H_ */
  
- Get a copy of the sdbm library, SCO has one but its operation is a
- little different to other OS's.  Set HasNdbm and HasSdbm in site.def
- to YES, put libsdbm.a in /lib or /usr/lib and sdbm.h in /usr/include.
- Compile sdbm with "cc" and do not enable the optimiser.  There were
- some problems early on when using sdbm compiled with gcc or with the
- optimisation enabled.  These may have been fixed.
- 
  To compile from here, follow the XFree86 README, basically after
  obtaining X11r5, applying the XFree86 patches and completing the above
  changes you should only need to run:
--- 224,229 ----
***************
*** 298,315 ****
  A)  Create the "net/errno.h" and "sys/bsdtypes.h" as per the 3.2.2
      instructions above.
  
! B)  Get and compile the "sdbm" as per the 3.2.2 instructions above.
!     Be sure not to use gcc or optimisation when compiling sdbm.
! 
! C)  Check that you have a "sys/uio.h" as there have been reports of
      system which have it and systems which don't!  If you already have
      one it need not be changed.
  
! D)  Edit the gnu "unistd.h" include file and remove the non prototyped
      version of close (Look for "close()" and remove that line), do not
      remove the prototyped declaration.
  
! E)  Create a "sys/stat.h" under the gnu include directory containing
      this:
  
      #ifndef _XFREE86_STAT
--- 291,305 ----
  A)  Create the "net/errno.h" and "sys/bsdtypes.h" as per the 3.2.2
      instructions above.
  
! B)  Check that you have a "sys/uio.h" as there have been reports of
      system which have it and systems which don't!  If you already have
      one it need not be changed.
  
! C)  Edit the gnu "unistd.h" include file and remove the non prototyped
      version of close (Look for "close()" and remove that line), do not
      remove the prototyped declaration.
  
! D)  Create a "sys/stat.h" under the gnu include directory containing
      this:
  
      #ifndef _XFREE86_STAT
***************
*** 325,333 ****
  
      #endif /* _XFREE86_STAT */
      
! F)  Check the paragraph on site.def in the compiling for 3.2.2 section.
  
! G)  Add a -DSCO324 to the BOOTSTRAPCFLAGS when you do the make World.
  
          make BOOTSTRAPCFLAGS="-DSYSV -DSYSV386 -DSCO -DSCO324" World
      
--- 315,323 ----
  
      #endif /* _XFREE86_STAT */
      
! E)  Check the paragraph on site.def in the compiling for 3.2.2 section.
  
! F)  Add a -DSCO324 to the BOOTSTRAPCFLAGS when you do the make World.
  
          make BOOTSTRAPCFLAGS="-DSYSV -DSYSV386 -DSCO -DSCO324" World
      
***************
*** 337,343 ****
      - The default compile line will contain -D_NO_PROTOTYPE instead
        of -DNO_PROTOTYPE as this is what 3.2.4 expects.
  
! H)  If you have problems with mkshlib reporting an error like
  
          mkshlib: : cannot exec /bin/sh
      
--- 327,333 ----
      - The default compile line will contain -D_NO_PROTOTYPE instead
        of -DNO_PROTOTYPE as this is what 3.2.4 expects.
  
! G)  If you have problems with mkshlib reporting an error like
  
          mkshlib: : cannot exec /bin/sh
      
***************
*** 451,457 ****
      corrupted especially when scrolling.
  Causes:
      1) You are running an original 1.3 distribution of XFree86.  Update
!        to 2.0.
      2) You have resized the window and not ran "eval `resize`" before using
         your application.  The SCO operating system does not support dynamic
         resizing or xterms fully so this command must be run after resizing
--- 441,447 ----
      corrupted especially when scrolling.
  Causes:
      1) You are running an original 1.3 distribution of XFree86.  Update
!        to 2.1.
      2) You have resized the window and not ran "eval `resize`" before using
         your application.  The SCO operating system does not support dynamic
         resizing or xterms fully so this command must be run after resizing
***************
*** 518,521 ****
  ftp site for the binary distribution.
  
      
! $XFree86: mit/server/ddx/x386/README.SCO,v 2.2 1993/10/24 13:44:10 dawes Exp $
--- 508,511 ----
  ftp site for the binary distribution.
  
      
! $XFree86: mit/server/ddx/x386/README.SCO,v 2.5 1994/03/08 08:31:20 dawes Exp $
diff -c /dev/null mit/server/ddx/x386/README.SOLX86:2.2
*** /dev/null	Fri Mar 11 23:35:42 1994
--- mit/server/ddx/x386/README.SOLX86	Fri Mar 11 23:35:43 1994
***************
*** 0 ****
--- 1,214 ----
+ 		Information for Solaris for x86 Users
+ 		-------------------------------------
+ 
+ Contents
+ --------
+ 	 1) Solaris versions on which XFree86[TM] has been tested.
+ 	 2) The VT-switching sub-system on Solaris x86
+ 	 3) Notes for building XFree86 on Solaris x86
+ 	 4) Notes for running XFree86 on Solaris x86
+ 	 5) Building non-core clients with Solaris x86
+ 	 6) Known bugs, and workarounds with Solaris x86
+ 
+ 1 - Solaris versions on which XFree86 has been tested
+ -----------------------------------------------------
+ 
+    XFree86 has been actively tested on Solaris 2.1 for x86. 
+ 
+    It is improbable that XFree86 will work on the soon to 
+    be released Solaris 2.3.2 for x86. (Due to the probable
+    absense of Virtual Terminals under 2.3.2)
+ 
+    However, if 2.3.2 still has VT's, XFree86 "MAY" work under
+    it.  All we can say is, if XFree86 doesn't run under 2.3.2, 
+    we'll generate patches for 2.3.2 as soon as we can after we 
+    obtain a copy of 2.3.2.
+ 
+ 2 - The VT-switching sub-system on Solaris x86
+ ----------------------------------------------
+ 
+    The virtual terminal subsystem in Solaris x86 is a undocumented, 
+    and unsupported feature of Solaris 2.1 for x86.  Therefore if
+    you use Virtual Terminals, you use them at YOUR OWN RISK.
+ 
+    The virtual terminals of Solaris work basically the same way as
+    most other Intel based SVR4 VT sub-systems.  However, there
+    are a number of limitations documented below.
+ 
+    The keys used for VT switching are as follows:
+ 
+    Alt-SysReq-F1 through Alt-SysReq-F7 enables VT screens 1-7 respectively.
+    Alt-SysReq-n enables the next active VT screen.
+    Alt-SysReq-p enables the previous active VT screen.
+    Alt-SysReq-h returns to the console.
+ 
+    To enable VT's on a Solaris 2.1 system the following lines (as root) 
+    to the file /etc/inittab:
+  
+    (Note do NOT make a mistake here, you could lock yourself out of the system)
+ 
+ --------------------------->Snip Snip<-----------------------------------------
+ v1:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` VT01 login: " -T AT386 -d /dev/vt01 -l console
+ v2:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` VT02 login: " -T AT386 -d /dev/vt02 -l console
+ v3:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` VT03 login: " -T AT386 -d /dev/vt03 -l console
+ v4:234:respawn:/usr/lib/saf/ttymon -g -h -p "`uname -n` VT04 login: " -T AT386 -d /dev/vt04 -l console
+ -------------------------->End here<-------------------------------------------
+ 
+    These four lines enable are what I use to enable 4 VT's on Alt-SysReq-F1
+    through Alt-SysReq-F4.
+ 
+    Then (as root) execute the command 'init q' to immediately enable the
+    virtual terminals.
+ 
+    You must leave at least one free virtual terminal for use under
+    Solaris 2.1 for the Xserver.
+ 
+ Limitations of the Virtual Terminal sub-system under Solaris 2.1 for x86:
+ 
+ 1. There are only a total of 8 login windows (7 VT's + 1 console)
+    not the usual 15.  If you have all 8 allocated, and you attempt
+    allocate a additional VT you will immediately panic the system.
+    (This bug is worked around in the Solaris 2.1 Xserver)
+ 
+ 2. From a programming stand point, they work pretty much as documented
+    in the AT&T Unix System V/386 Release 4 Integrated Software Development
+    Guide, however a number of ioctl()'s are broken.
+ 
+ 
+ 3 - Notes for building XFree86 on Solaris x86
+ ---------------------------------------------
+ 
+ 1. Both GCC, and ProWorks are supported by XFree86. GCC-2.4.5 is
+    suggested, later versions are untested.  You also need to set
+    HasGcc, and HasGcc2 appropriately in site.def.
+ 
+ 2. If you are using ProWorks to compile the XFree86 distribution, you
+    should modify your PATH appropriately so the ProWorks tools are
+    available.
+ 
+ 3. You MUST put /usr/ccs/bin at the front of your PATH.  There are known
+    problems with some GNU replacements for the utilities found there, so
+    the /usr/ccs/bin versions of these programs must be found before any
+    other possible GNU versions. (Most notably GNU 'ar' does not work during 
+    the build.)
+ 
+ 4. If you wish to use the "memory aperture" of the S3, or Mach32 servers
+    you need to compile, and install the Solaris x86 aperture driver for
+    memory mapped I/O support.
+ 
+    The source for this driver should be included in 
+    ~mit/server/ddx/x386/etc/apSolx86.shar.  Building and installing 
+    the driver is relatively straight forward. Please read its accompanying
+    README file.
+ 
+    You also need to set HasSolx86apertureDrv to YES in ~mit/config/site.def.
+ 
+ 5. The BOOTSTRAPCFLAGS for Solaris x86 is:
+ 
+      "-DSVR4 -DSYSV386 -DSOLX86"
+ 
+ 6. You will also need to add CC=gcc to your 'make World' command
+    if you are using gcc.  You may possibly get a warning about 
+    unknown option '-Xc' while compiling imake, however the warning can
+    be safely ignored.
+ 
+ 4 - Notes for running XFree86 on Solaris x86
+ --------------------------------------------
+ 
+ 1. For Solaris, you will probably want to set your LD_LIBRARY_PATH
+    to /usr/X386/lib:/usr/openwin/lib, setting LD_LIBRARY_PATH to include
+    /usr/X386/lib is not necessary providing that clients are build with 
+    LD_RUN_PATH set properly.  
+ 
+    Including /usr/openwin/lib in the LD_LIBRARY_PATH, is recommended
+    because some Sun supplied binaries were not compiled with LD_RUN_PATH
+    set properly. (Wabi 1.0 is a good example.)
+ 
+ 3. Xqueue is NOT supported under Solaris. The includes necessary for 
+    Xqueue are available, however, the driver does not seem to be.
+    (Go figure)
+ 
+ 4. If you want to use xdm with Solaris, extract the files from the shar file
+    in /usr/X386/lib/X11/etc/XdmConf.svr4 into a temporary directory.  The
+    README file tells where the individual files should be installed.  Be
+    sure to read through each file and make any site-specific changes that
+    you need.
+ 
+ 5 - Building non-core clients with Solaris x86
+ ----------------------------------------------
+ 
+ 1. A lot of clients (even some which have explicit SVR4 support) require
+    -DSYSV when building under SVR4.  This will not be set when using the
+    default x386.cf and site.def.  A quick fix is to add something like the
+    following to the client's Imakefile:
+ 
+       #if SystemV4
+            DEFINES = -DSYSV OTHER_CLIENT_DEPENDENT_DEFINES
+       #endif
+ 
+    The best solution is to modify the code so it compiles correctly
+    without -DSYSV.
+ 
+ 2. The default compiler options include '-ansi' for gcc, and '-Xc' for cc.
+    A consequence of this is __STDC__ gets #defined to '1'.  There are a
+    number of functions which will not have prototypes declared unless
+    either __STDC__ is not defined, or
+ 
+ 	__STDC__ == 0 || defined(_POSIX_SOURCE) || defined(_XOPEN_SOURCE)
+ 
+    Possible solutions are to change the definition of ANSICCOPTIONS by
+    adding a line to the Imakefile, or to add the required prototypes to
+    the source.
+ 
+ 3. A lot of clients make use of BSD functions like bcopy(), etc.  The
+    default configuration files are set up to link with libXbsd.a which
+    contains emulation for bcopy(), bzero(), bcmp(), ffs(), random(),
+    seed().  ffs() is not required (it is already in libnsl.so), and a
+    better way of providing the 'b' functions is to include <X11/Xfuncs.h>
+    in source files that call them.  Xfuncs.h provides macro definitions
+    for these in terms of the SYSV 'mem' functions.  If you require more
+    efficient versions of random(), seed() you should supply your own macro
+    definitions.  If you are linking with a vendor supplied library which
+    calls some of these functions, then you should link with libXbsd.a
+ 
+    If you want to change this default, you can edit your x386.cf file.  If
+    you want to change the behavior on a per client basis, you can add a
+    line to the clients Imakefile which redefines XBSDLIB.  To eliminate
+    the use of that library use something like:
+ 
+      XBSDLIB =
+ 
+    If you find you need some other BSD functions, you could link with
+    libucb.a by using something like:
+ 
+      XBSDLIB = -lc -L/usr/ucblib -lucb
+ 
+    WARNING: be *very* careful blindly linking with libucb.a.
+ 
+ 6 - Known bugs, and workarounds with Solaris x86
+ ------------------------------------------------
+ 
+ 1. Wabi 1.0 tickles a obscure bug in the Mach32 hardware cursor code.  The 
+    hardware cursor shows up as a multicolored square while inside of Wabi 
+    windows.
+ 
+    The workaround, add:
+ 
+        Option "sw_cursor"
+ 
+    to your Xconfig.
+ 
+ 2. The Solaris 2.1 for x86 OpenWindows filemgr does not work against  
+    Sparc Solaris MIT X11R5 Xserver, nor XFree86. Attempting to 
+    'Drag and Drop' a file causes the filemgr to abort with a 'X error'.  
+ 
+    There is no known workaround.
+ 
+ Many thanks to the original authors of README.SVR4, and README.SVR3
+ upon which this document is based a large part upon.
+ 
+ (Somebody clue me in on the appropriate names to stick in here will you?)
+ 
+ Id: README.SOLX86,v 1.2 1994/02/24 04:56:49 davidh Exp
+ 
+ $XFree86: mit/server/ddx/x386/README.SOLX86,v 2.2 1994/03/11 03:05:26 dawes Exp $
diff -c mit/server/ddx/x386/README.SVR3:2.1 mit/server/ddx/x386/README.SVR3:2.5
*** mit/server/ddx/x386/README.SVR3:2.1	Fri Mar 11 23:35:43 1994
--- mit/server/ddx/x386/README.SVR3	Fri Mar 11 23:35:44 1994
***************
*** 54,93 ****
  the Hercules driver in the monochrom server) the lkit archive is required.
  It contains also a tutorial how to add an (S)VGA driver to XFree86
  including stub driver code.
! The non-server PEX stuff is seperated in the pex archive.
  
!   bin-2.0tz.??		- Executables, including target shared libraries.
  
  			  The XFree86 server binaries:
!   SVGA-2.0tz.?		- XF86_SVGA:   256-color Super-VGA server. Contains
  			  accelerated support for Cirrus 542{6,8} and Western
  			  Digital 90C31 chipsets, unaccelerated for the rest
  			  of the supported chipsets.
!   Mono-2.0tz.?		- XF86_Mono:   (S)VGA monochrome, optionally Hercules
  			  or other monochrome hardware support is linked in
  			  (not in the binary distribution).
!   VGA16-2.0tz.?		- XF86_VGA16:  Generic VGA 16-color server
  			  (experimental).
  
!   8514-2.0tz.?		- XF86_8514:   8514/A 256-color accelerated server.
!   Mach32-2.0tz.?	- XF86_Mach32: ATI Mach32 256-color accelerated server.
!   Mach8-2.0tz.?		- XF86_Mach8:  ATI Mach8 256-color accelerated server.
!   S3-2.0tz.?		- XF86_S3:     S3 256-color accelerated server.
! 
!   misc-2.0tz		- Application default files, bitmaps, etc.
!   cfg-2.0tz             - Default xinit, xdm and fs config files.
! 
!   font-2.0tz.??		- Fonts (misc, 75dpi, 100dpi, Speedo).
!   man-2.0tz.??		- Formatted X11R5 manual pages.
!   doc-2.0tz		- Documentation including XFree86-specific man pages.
! 
!   lib-2.0tz.??		- Libraries, configuration and header files.
!   lkit-2.0tz.??		- LinkKit, including PEX support.
!   pex-2.0tz.??		- The non-server parts of PEX (clients, libs,
  			  headers, etc.).
    gpc.tz.??		- The Graphics Performance Characterization
  			  suite of PEX. (Files needed for the
! 			  'plbpex' program.) It's seperated because
  			  unpacked it needs ~9MB! It's unchanged
  			  since 1.3.
  
--- 54,93 ----
  the Hercules driver in the monochrom server) the lkit archive is required.
  It contains also a tutorial how to add an (S)VGA driver to XFree86
  including stub driver code.
! The non-server PEX stuff is separated in the pex archive.
  
!   bin-2.1tz.??		- Executables, including target shared libraries.
  
  			  The XFree86 server binaries:
!   SVGA-2.1tz.?		- XF86_SVGA:   256-color Super-VGA server. Contains
  			  accelerated support for Cirrus 542{6,8} and Western
  			  Digital 90C31 chipsets, unaccelerated for the rest
  			  of the supported chipsets.
!   Mono-2.1tz.?		- XF86_Mono:   (S)VGA monochrome, optionally Hercules
  			  or other monochrome hardware support is linked in
  			  (not in the binary distribution).
!   VGA16-2.1tz.?		- XF86_VGA16:  Generic VGA 16-color server
  			  (experimental).
  
!   8514-2.1tz.?		- XF86_8514:   8514/A 256-color accelerated server.
!   Mach32-2.1tz.?	- XF86_Mach32: ATI Mach32 256-color accelerated server.
!   Mach8-2.1tz.?		- XF86_Mach8:  ATI Mach8 256-color accelerated server.
!   S3-2.1tz.?		- XF86_S3:     S3 256-color accelerated server.
! 
!   misc-2.1tz		- Application default files, bitmaps, etc.
!   cfg-2.1tz             - Default xinit, xdm and fs config files.
! 
!   font-2.1tz.??		- Fonts (misc, 75dpi, 100dpi, Speedo).
!   man-2.1tz.??		- Formatted X11R5 manual pages.
!   doc-2.1tz		- Documentation including XFree86-specific man pages.
! 
!   lib-2.1tz.??		- Libraries, configuration and header files.
!   lkit-2.1tz.??		- LinkKit, including PEX support.
!   pex-2.1tz.??		- The non-server parts of PEX (clients, libs,
  			  headers, etc.).
    gpc.tz.??		- The Graphics Performance Characterization
  			  suite of PEX. (Files needed for the
! 			  'plbpex' program.) It's separated because
  			  unpacked it needs ~9MB! It's unchanged
  			  since 1.3.
  
***************
*** 98,104 ****
  binary distribution for SVR3 on ftp.prz.tu-berlin.de under /pub/pc/isc/gzip.
  
  If you want to use the "memory aperture" feature which S3 and Mach32
! servers provide you need also the SVR3 mmap driver (at least v2.2.2)
  for memory mapped I/O support (i.e. accessing the frame buffer in a
  linear address space).
  The source of this driver is included in the binary distribution
--- 98,104 ----
  binary distribution for SVR3 on ftp.prz.tu-berlin.de under /pub/pc/isc/gzip.
  
  If you want to use the "memory aperture" feature which S3 and Mach32
! servers provide you need also the SVR3 mmap driver (at least v2.2.3)
  for memory mapped I/O support (i.e. accessing the frame buffer in a
  linear address space).
  The source of this driver is included in the binary distribution
***************
*** 114,120 ****
  
    1. Login as root
  
!   2. If you have previously installed XFree86 1.2, note that 2.0 contains
       an incompatible new revision of the shared Xlib (libX11.5.0.1). If
       you're using other X clients then the core stuff (like the actual
       XView 3.0 binary distribution from Thomas J. Wu on ftp.prz.tu-berlin.de)
--- 114,120 ----
  
    1. Login as root
  
!   2. If you have previously installed XFree86 1.2, note that 2.1 contains
       an incompatible new revision of the shared Xlib (libX11.5.0.1). If
       you're using other X clients then the core stuff (like the actual
       XView 3.0 binary distribution from Thomas J. Wu on ftp.prz.tu-berlin.de)
***************
*** 122,128 ****
       on-line.
       If you have previously installed XFree86 1.3 there should be no problems.
       Clients which are linked with the 1.3 shared libraries should also
!      work with the installed shared libraries from 2.0.
  
       As for XView 3.0: if you plan to link XView clients with the XView
       shared libraries you must keep also the host shared libraries
--- 122,128 ----
       on-line.
       If you have previously installed XFree86 1.3 there should be no problems.
       Clients which are linked with the 1.3 shared libraries should also
!      work with the installed shared libraries from 2.1.
  
       As for XView 3.0: if you plan to link XView clients with the XView
       shared libraries you must keep also the host shared libraries
***************
*** 147,162 ****
         # /usr/X11R5/bin/mkdirhier /usr/X386/lib/X11/shlib
         # ln /usr/X11R5/lib/X11/shlib/* /usr/X386/lib/X11/shlib
  
!   3. Unpack the distribution (assume splitted archives are in /usr/tmp
       and a S3 video card):
  
         # cd /usr/X386
!        # cat /usr/tmp/bin-2.0tz.??  | gunzip | tar xfp -
!        # cat /usr/tmp/S3-2.0.tz.?   | gunzip | tar xfp -
!        # cat /usr/tmp/misc-2.0tz    | gunzip | tar xfp -
!        # cat /usr/tmp/font-2.0tz.?? | gunzip | tar xfp -
!        # cat /usr/tmp/man-2.0tz.??  | gunzip | tar xfp -
!        # cat /usr/tmp/doc-2.0tz     | gunzip | tar xfp -
  
       NOTE: Don't forget that p option for tar! Some programs (X servers
             itself, xterm, xload) must be setuid-root and p restores
--- 147,162 ----
         # /usr/X11R5/bin/mkdirhier /usr/X386/lib/X11/shlib
         # ln /usr/X11R5/lib/X11/shlib/* /usr/X386/lib/X11/shlib
  
!   3. Unpack the distribution (assume split archives are in /usr/tmp
       and a S3 video card):
  
         # cd /usr/X386
!        # cat /usr/tmp/bin-2.1tz.??  | gunzip | tar xfp -
!        # cat /usr/tmp/S3-2.1.tz.?   | gunzip | tar xfp -
!        # cat /usr/tmp/misc-2.1tz    | gunzip | tar xfp -
!        # cat /usr/tmp/font-2.1tz.?? | gunzip | tar xfp -
!        # cat /usr/tmp/man-2.1tz.??  | gunzip | tar xfp -
!        # cat /usr/tmp/doc-2.1tz     | gunzip | tar xfp -
  
       NOTE: Don't forget that p option for tar! Some programs (X servers
             itself, xterm, xload) must be setuid-root and p restores
***************
*** 163,184 ****
             the original permissions.
  
       If this is not your first installation of XFree86 you should be
!      carefull if you want to unpack the cfg archive, it contains the
       default xinit, xdm and fs config files. If you have customized
       them already you may want to save them before you type:
  
!        # cat /usr/tmp/cfg-2.0tz | gunzip | tar xfp -
  
       If you want to install the libraries and/or linkkit and/or PEX,
       same applies:
  
!        # cat /usr/tmp/lib-2.0tz.??  | gunzip | tar xfp -
!        # cat /usr/tmp/lkit-2.0tz.?? | gunzip | tar xfp -
!        # cat /usr/tmp/pex-2.0tz.??  | gunzip | tar xfp -
  
       If you want the GPC stuff for PEX:
  
!        # cat /usr/tmp/gpc-2.0tz.?? | gunzip | tar xfp -
  
       If you want PEX you need also the linkkit to get a server with
       PEX support.
--- 163,184 ----
             the original permissions.
  
       If this is not your first installation of XFree86 you should be
!      careful if you want to unpack the cfg archive, it contains the
       default xinit, xdm and fs config files. If you have customized
       them already you may want to save them before you type:
  
!        # cat /usr/tmp/cfg-2.1tz | gunzip | tar xfp -
  
       If you want to install the libraries and/or linkkit and/or PEX,
       same applies:
  
!        # cat /usr/tmp/lib-2.1tz.??  | gunzip | tar xfp -
!        # cat /usr/tmp/lkit-2.1tz.?? | gunzip | tar xfp -
!        # cat /usr/tmp/pex-2.1tz.??  | gunzip | tar xfp -
  
       If you want the GPC stuff for PEX:
  
!        # cat /usr/tmp/gpc-2.1tz.?? | gunzip | tar xfp -
  
       If you want PEX you need also the linkkit to get a server with
       PEX support.
***************
*** 224,231 ****
      using the linkkit in /usr/X386/lib/Server. Informations how to do
      it you'll find also in /usr/X386/lib/X11/etc/INSTALL in section
      "Reconfiguring the server (binary distribution)".
!     Note: Installing libsdbm.a is not needed on ISC, ISC's libdbm.a works.
!           If you don't use gcc anyway, you may also need to install
            libgcc.a in /lib or /usr/lib and set "NeedLibGcc" to
            YES in site.def (/usr/X386/lib/Server/site.def !).
  
--- 224,230 ----
      using the linkkit in /usr/X386/lib/Server. Informations how to do
      it you'll find also in /usr/X386/lib/X11/etc/INSTALL in section
      "Reconfiguring the server (binary distribution)".
!     Note: If you don't use gcc anyway, you may also need to install
            libgcc.a in /lib or /usr/lib and set "NeedLibGcc" to
            YES in site.def (/usr/X386/lib/Server/site.def !).
  
***************
*** 381,393 ****
     in your base OS.  We are working in fixing the source tree to not
     depend on TCP/IP, but it is a fundamental piece of the MIT architecture,
     and all the problems have not yet been resolved.
! 3. ISC no longer requires a separate dbm library.  It works fine with the
!    existing dbm library (libdbm.a).  Set HasNdbm to NO in site.def.
! 4. Note for ISC: A limit in the hash table with ISC's 'make' will cause
     it to die in the middle of mit/lib/X.  This can be overcome by
     uncommenting the MakeHashTableBug line in site.def. But a better
     alternative is to use GNU make.
! 5. If you want to compile XDM Authorization-1 in you must applying
     following patch to mit/lib/Xdmcp/Wraphelp.c:
  
  ---cut here---------------------------------------------------------------
--- 380,390 ----
     in your base OS.  We are working in fixing the source tree to not
     depend on TCP/IP, but it is a fundamental piece of the MIT architecture,
     and all the problems have not yet been resolved.
! 3. Note for ISC: A limit in the hash table with ISC's 'make' will cause
     it to die in the middle of mit/lib/X.  This can be overcome by
     uncommenting the MakeHashTableBug line in site.def. But a better
     alternative is to use GNU make.
! 4. If you want to compile XDM Authorization-1 in you must applying
     following patch to mit/lib/Xdmcp/Wraphelp.c:
  
  ---cut here---------------------------------------------------------------
***************
*** 409,421 ****
  
     for using in the shared Xlib. For information how to obtain a copy of
     mit/lib/Xdmcp/Wraphelp.c look into mit/RELNOTES.TXT.
! 6. We highly recommend gcc 2.4.5 to build XFree86. It fixes several bugs of
!    previous versions. Whether gcc 2.5.0 or newer works is not tested yet.
!    See also 'SVR3 shared libraries' and /usr/X386/lib/X11/etc/INSTALL.
!    You should have ran the `fixincludes' script from the gcc distribution,
!    otherwise some non-ANSI-compilant declarations in ISC's <sys/sioctl.h>
!    will cause generating of false arguments for the SIOCIFCONF, etc.
!    ioctl's which will affect the server and xdm.
  
  
  9 - SVR3 shared libraries
--- 406,418 ----
  
     for using in the shared Xlib. For information how to obtain a copy of
     mit/lib/Xdmcp/Wraphelp.c look into mit/RELNOTES.TXT.
! 6. We highly recommend gcc 2.4.5 or a recent 2.5.x version to build XFree86.
!    It fixes several bugs of previous versions.  See also 'SVR3 shared
!    libraries' and /usr/X386/lib/X11/etc/INSTALL.  You should have ran the
!    `fixincludes' script from the gcc distribution, otherwise some
!    non-ANSI-compliant declarations in ISC's <sys/sioctl.h> will cause
!    generating of false arguments for the SIOCIFCONF, etc.  ioctl's which
!    will affect the server and xdm.
  
  
  9 - SVR3 shared libraries
***************
*** 501,505 ****
  - Rich Murphey for writing README.386BSD which this README is based on
  - All the ISC users who have been patient for all these months
  
! $XFree86: mit/server/ddx/x386/README.SVR3,v 2.1 1993/10/24 13:44:11 dawes Exp $
  
--- 498,502 ----
  - Rich Murphey for writing README.386BSD which this README is based on
  - All the ISC users who have been patient for all these months
  
! $XFree86: mit/server/ddx/x386/README.SVR3,v 2.5 1994/03/08 08:31:23 dawes Exp $
  
diff -c mit/server/ddx/x386/README.SVR4:2.1 mit/server/ddx/x386/README.SVR4:2.2
*** mit/server/ddx/x386/README.SVR4:2.1	Fri Mar 11 23:35:45 1994
--- mit/server/ddx/x386/README.SVR4	Fri Mar 11 23:35:45 1994
***************
*** 23,29 ****
    XFree86 has been tested on the following versions of SVR4.0:
  
  	Microport: 2.2, 3.1, 4.1, 4.2
! 	Esix: 4.0.3A, 4.0.4
  	Dell: 2.1, 2.2
  	UHC: 2.0, 3.6
  	Consensys: 1.2
--- 23,29 ----
    XFree86 has been tested on the following versions of SVR4.0:
  
  	Microport: 2.2, 3.1, 4.1, 4.2
! 	Esix: 4.0.3A, 4.0.4, 4.0.4.1
  	Dell: 2.1, 2.2
  	UHC: 2.0, 3.6
  	Consensys: 1.2
***************
*** 121,127 ****
  4 - Notes for building XFree86 on SVR4
  --------------------------------------
  1. If you are using gcc-2.0 or 2.1 with SVR4, we highly recommend that you
!    upgrade to the latest release (currently gcc-2.4.5).  If this is not
     possible, you MUST apply the following patch to 'fixinc.svr4', and
     rerun it.  This problem is fixed in gcc-2.2.
  
--- 121,127 ----
  4 - Notes for building XFree86 on SVR4
  --------------------------------------
  1. If you are using gcc-2.0 or 2.1 with SVR4, we highly recommend that you
!    upgrade to gcc-2.4.5 (or a later stable release).  If this is not
     possible, you MUST apply the following patch to 'fixinc.svr4', and
     rerun it.  This problem is fixed in gcc-2.2.
  
***************
*** 278,290 ****
  3. A lot of clients make use of BSD functions like bcopy(), etc.  The
     default configuration files are set up to link with libXbsd.a which
     contains emulation for bcopy(), bzero(), bcmp(), ffs(), random(),
!    seed().  ffs() is not required (it is already in libnsl.so), and a
!    better way of providing the 'b' functions is to include <X11/Xfuncs.h>
!    in source files that call them.  Xfuncs.h provides macro definitions
!    for these in terms of the SYSV 'mem' functions.  If you require more
!    efficient versions of random(), seed() you should supply your own macro
!    definitions.  If you are linking with a vendor supplied library which
!    calls some of these functions, then you should link with libXbsd.a
  
     If you want to change this default, you can edit your x386.cf file.  If
     you want to change the behaviour on a per client basis, you can add a
--- 278,294 ----
  3. A lot of clients make use of BSD functions like bcopy(), etc.  The
     default configuration files are set up to link with libXbsd.a which
     contains emulation for bcopy(), bzero(), bcmp(), ffs(), random(),
!    seed(), str[n]casecmp() and a fully BSD-compatible select().  ffs()
!    is not required (it is already in libnsl.so), and a better way of
!    providing the 'b' functions is to include <X11/Xfuncs.h> in source
!    files that call them.  Xfuncs.h provides macro definitions for
!    these in terms of the SYSV 'mem' functions.  To make use of the
!    select() in libXbsd, <X11/Xfuncs.h> must be included after defining
!    X_BSDSELECT.  This is not required on most SVR4 versions.  If you
!    require more efficient versions of random(), seed() you should
!    supply your own macro definitions.  If you are linking with a
!    vendor supplied library which calls some of these functions, then
!    you should link with libXbsd.a
  
     If you want to change this default, you can edit your x386.cf file.  If
     you want to change the behaviour on a per client basis, you can add a
***************
*** 409,412 ****
  information.
  
  
! $XFree86: mit/server/ddx/x386/README.SVR4,v 2.1 1993/10/24 13:44:13 dawes Exp $
--- 413,416 ----
  information.
  
  
! $XFree86: mit/server/ddx/x386/README.SVR4,v 2.2 1994/03/05 08:22:43 dawes Exp $
diff -c mit/server/ddx/x386/XF86_Acc.man:2.11 mit/server/ddx/x386/XF86_Acc.man:2.16
*** mit/server/ddx/x386/XF86_Acc.man:2.11	Fri Mar 11 23:35:46 1994
--- mit/server/ddx/x386/XF86_Acc.man	Fri Mar 11 23:35:46 1994
***************
*** 1,6 ****
! .\" $XFree86: mit/server/ddx/x386/XF86_Acc.man,v 2.11 1993/10/21 15:53:56 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_Accel 1 "Version 2.0"  "XFree86"
  .SH NAME
  XF86_Accel - 8 bit accelerated X Window System servers for UNIX on x86
  platforms with an S3, Mach8, Mach32 or 8514/A accelerator board
--- 1,6 ----
! .\" $XFree86: mit/server/ddx/x386/XF86_Acc.man,v 2.16 1994/03/08 04:46:29 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_Accel 1 "Version 2.1"  "XFree86"
  .SH NAME
  XF86_Accel - 8 bit accelerated X Window System servers for UNIX on x86
  platforms with an S3, Mach8, Mach32 or 8514/A accelerator board
***************
*** 64,74 ****
  .PP
  For S3 virtual resolutions up to (approximately)
  1152x800 are supported, using  (up to) 1Mb of display memory
! (the S3 uses an internal width of 1280, hence 1Mb can't support
! 1152x900).
! Physical resolutions up to 1280x1024 are possible using 2Mb or
! more of display memory (virtual resolution is dependent solely on the
! amount of memory installed).
  Similar resolutions are supported on the Mach32.
  For the Mach32, the maximum virtual width is 1536, and the maximum virtual
  height is 1280.
--- 64,75 ----
  .PP
  For S3 virtual resolutions up to (approximately)
  1152x800 are supported, using  (up to) 1Mb of display memory
! (the S3 uses an internal width of 1280 except for new revisions of some of
! the chips, hence 1Mb can't support 1152x900).
! Physical resolutions up to 1280x1024 (1600x1280 on some cards) are
! possible using 2Mb or more of display memory (virtual resolution is
! dependent solely on the amount of memory installed, with the maximum
! virtual width being 2048, and max virtual height is 4096).
  Similar resolutions are supported on the Mach32.
  For the Mach32, the maximum virtual width is 1536, and the maximum virtual
  height is 1280.
***************
*** 107,113 ****
  XF86_S3:
  .RS 1.5i
  .TP 12
! generic_s3
  (for a standard IO driven server) 
  .TP 12
  mmio_928
--- 108,114 ----
  XF86_S3:
  .RS 1.5i
  .TP 12
! s3_generic
  (for a standard IO driven server) 
  .TP 12
  mmio_928
***************
*** 146,175 ****
  is important.  It must match the order in which they are selected on the
  graphics board.  Multiple \fBclocks\fP lines may be specified.
  For programmable clock chips the name  of the clockchip  is given.
! Possible values include \fB"icd2061a"\fP and \fB"icd2061a_slow"\fP.  These
  are currently only supported by the S3 server.
  .TP 8
  .B option \fI"optionstring"\fP
  allows the user to select certain options provided by the drivers.  Currently 
  the following strings are recognized:
  .sp
! \fBnomemaccess\fP - (S3) disable direct access to video memory.  This is the
! default for localbus cards when linear mapping is not possible.
  .sp
- \fBmemaccess\fP - (S3) prevent direct video memory access being disabled
- for localbus cards when linear mapping is not possible.
- .sp
  \fBnolinear\fP - (S3 and Mach32) disable use of a linear-mapped framebuffer.
  .sp
  \fBbt485\fP - (S3) Card has a BrookTree Bt485 RAMDAC.  This option is required
  if the server fails to detect the Bt485.
  .sp
! \fBno_bt485\fP - (S3) Card does not have a BrookTree Bt485 RAMDAC.  This
! option is only required if the server detects a Bt485 when none is present.
  .sp
! \fBbt485_curs\fP - (S3) Enables the Bt485's internal HW cursor.
  .sp
  \fBsw_cursor\fP - (Mach32) Disable the hardware cursor.
  .PP
  Note that \fIXFree86\fP has some internal capabilities to determine
  what hardware
--- 147,232 ----
  is important.  It must match the order in which they are selected on the
  graphics board.  Multiple \fBclocks\fP lines may be specified.
  For programmable clock chips the name  of the clockchip  is given.
! Possible values include \fB"icd2061a"\fP and \fB"sc11412"\fP.  These
  are currently only supported by the S3 server.
  .TP 8
+ .B membase \fImemaddress\fP
+ specifies the hard-wired part of the linear framebuffer base address.  This
+ option is only used by the S3 and Mach32 servers (and only when using a
+ linear framebuffer).  For the S3 server, the hard-wired part is the high
+ 6 bits of the 32-bit address (ie \fImemaddress\fP is masked with
+ \fI0xFC000000\fP).  For the Mach32 server, the mask is \fI0xF8000000\fP
+ (except for PCI cards, where the membase setting is ignored).
+ .sp
+ Note: The S3 server will normally probe for this address automatically.
+ Setting this option overrides that probe.  This is not normally recommended
+ because the failure of the server's probe usually indicates problems in
+ using the linear framebuffer.
+ .TP 8
  .B option \fI"optionstring"\fP
  allows the user to select certain options provided by the drivers.  Currently 
  the following strings are recognized:
  .sp
! \fBnomemaccess\fP - (S3) disable direct access to video memory.
  .sp
  \fBnolinear\fP - (S3 and Mach32) disable use of a linear-mapped framebuffer.
  .sp
+ \fBnormal_dac\fP - (S3) Card does not have one of the other RAMDACs mentioned
+ here.  This option is only required if the server incorrectly detects one
+ of those other RAMDACs.
+ .sp
+ \fBatt_20c490_1\fP - (S3) Card has an AT&T 20C490 or AT&T 20C491 RAMDAC.
+ This option when combined with the \fBdac_8_bit\fP option allows these
+ RAMDACs to be operated in 8 bit per RGB mode.  There is currently no
+ auto-detection for these RAMDACs.  Note that 8 bit per RGB mode does not
+ appear to work with the Winbond 82C490 RAMDACs (which SuperProbe identifies
+ as AT&T 20C492).
+ .sp
+ \fBsc15025\fP - (S3) Card has a Sierra SC15025 or SC15026 RAMDAC.
+ This option when combined with the \fBdac_8_bit\fP option allows these
+ RAMDACs to be operated in 8 bit per RGB mode.  There is currently no
+ auto-detection for these RAMDACs.
+ .sp
  \fBbt485\fP - (S3) Card has a BrookTree Bt485 RAMDAC.  This option is required
  if the server fails to detect the Bt485.
  .sp
! \fB20c505\fP - (S3) Card has an AT&T 20C505 RAMDAC.  This option is required
! either if the server fails to detect the 20C505, or if the card has a Bt485
! RAMDAC and there are problems using clocks higher than 67.5Mhz.
! .sp
! \fBbt485_curs\fP - (S3) Enables the Bt485's internal HW cursor.  This option
! may be used for cards with Bt485 or AT&T 20C505 RAMDACs.
  .sp
! \fBti3020\fP - (S3) Card has a TI ViewPoint Ti3020 135MHz RAMDAC.  This option
! is required if the server fails to detect the Ti3020.  This is the default if
! a Ti3020 RAMDAC is detected and the ti3020_fast option is not set.  Note that
! pixel multiplexing will be used for this RAMDAC if any mode requires a
! dot clock higher than 70MHz.  Pixel multiplexing with this RAMDAC does not
! support physical mode widths less than 1024 or interlaced modes.  Also, the
! only logical line widths that work when operating in pixel multiplex mode
! are 1024 and 2048.
  .sp
+ \fBti3020_fast\fP - (S3) Card has a TI ViewPoint Ti3020 200MHz RAMDAC.
+ .sp
+ \fBti3020_curs\fP - (S3) Enables the Ti3020's internal HW cursor. (Default)
+ .sp
+ \fBno_ti3020_curs\fP - (S3) Disables the Ti3020's internal HW cursor.
+ .sp
  \fBsw_cursor\fP - (Mach32) Disable the hardware cursor.
+ .sp
+ \fBdac_8_bit\fP - (S3, Mach32) Enables 8-bit per RGB.  Currently only
+ supported with the Ti3020, AT&T 20C490/1, Sierra SC15025/6 (S3 server)
+ and ATI68875/TLC34075/Bt885 (Mach32 server) RAMDACs.
+ .sp
+ \fBintel_gx\fP - (Mach32) Sets the hard-wired offset for the linear
+ framebuffer correctly for the Intel GX Pro cards.  This option is equivalent
+ to setting the \fBmembase\fP to \fI0x78000000\fP.
+ .sp
+ \fBspea_mercury\fP - (S3) Enables pixel multiplex support for SPEA Mercury
+ cards (928 + Bt485 RAMDAC).  For these cards, pixel multiplexing is required
+ in order to use dot clocks higher than 67.5 MHz and to access more than
+ 1MB of video memory.  Pixel multiplexing is currently supported only for
+ non-interlaced modes, and modes with a physical width no smaller than 1024.
  .PP
  Note that \fIXFree86\fP has some internal capabilities to determine
  what hardware
***************
*** 183,190 ****
  \fBIt is recommended that all parameters, especially Clock values,
  be specified in the Xconfig file.\fP
  .PP
- Note: the Mach32 server will not auto-detect the clocks.
- .PP
  The last section is the \fBTABLE OF VIDEO MODES\fP which starts with the
  keyword \fBmodedb\fP.   This is covered in the
  .I Xconfig(4/5) 
--- 240,245 ----
***************
*** 236,241 ****
--- 291,297 ----
  David Wexelblat, \fIdwex@goblin.org\fP, \fIdwex@aib.com\fP
  David Dawes,     \fIdawes@physics.su.oz.au\fP
  Amancio Hasty,   \fIhasty@netcom.com\fP
+ Robin Cutshaw,   \fIrobin@paros.com\fP
  .fi
  .RS 8
  Development and improvement of the S3 specific code.
***************
*** 257,262 ****
--- 313,319 ----
  Rik Faith,       \fIfaith@cs.unc.edu\fP
  Mike Bernson,    \fImike@mbsun.mlb.org\fP
  Mark Weaver,     \fIMark_Weaver@brown.edu\fP
+ Craig Groeschel, \fIcraig@adikia.sccsi.com\fP
  .fi
  .RS 8
  Development and improvement of the Mach32 specific code.
***************
*** 267,273 ****
  manual page.
  .SH BUGS
  .PP
! S3 cards with Bt485 ramdacs and ATI cards are currently restricted to
  dot-clocks less than 85MHz.  This restriction is because the servers don't
  yet support operating the ramdacs in multiplexed mode.
  .SH CONTACT INFO
--- 324,330 ----
  manual page.
  .SH BUGS
  .PP
! S3 cards with Bt485 ramdacs are currently restricted to
  dot-clocks less than 85MHz.  This restriction is because the servers don't
  yet support operating the ramdacs in multiplexed mode.
  .SH CONTACT INFO
diff -c mit/server/ddx/x386/XF86_Mono.man:2.9 mit/server/ddx/x386/XF86_Mono.man:2.10
*** mit/server/ddx/x386/XF86_Mono.man:2.9	Fri Mar 11 23:35:46 1994
--- mit/server/ddx/x386/XF86_Mono.man	Fri Mar 11 23:35:46 1994
***************
*** 1,6 ****
! .\" $XFree86: mit/server/ddx/x386/XF86_Mono.man,v 2.9 1993/10/18 12:16:10 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_Mono 1 "Version 2.0"  "XFree86"
  .SH NAME
  XF86_Mono - 1 bit non-accelerated X Window System servers for UNIX on
  x86 platforms
--- 1,6 ----
! .\" $XFree86: mit/server/ddx/x386/XF86_Mono.man,v 2.10 1994/02/27 05:17:21 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_Mono 1 "Version 2.1"  "XFree86"
  .SH NAME
  XF86_Mono - 1 bit non-accelerated X Window System servers for UNIX on
  x86 platforms
***************
*** 50,57 ****
  .RE
  .PP
  Additionally it
! supports generic VGA cards, Hercules monochrome graphics cards, and the Hyundai
! HGC1280 card.
  .PP
  On supported SVGA chipsets, 
  .I XF86_Mono
--- 50,57 ----
  .RE
  .PP
  Additionally it
! supports generic VGA cards, Hercules monochrome graphics cards, the Hyundai
! HGC1280 card, Sigma LaserView, and Visa monochrome cards.
  .PP
  On supported SVGA chipsets, 
  .I XF86_Mono
***************
*** 145,150 ****
--- 145,156 ----
  .TP 4
  Hyundai:
  hgc1280
+ .TP 4
+ Sigma:
+ sigmalview
+ .TP 4
+ Visa:
+ visa6845
  .RE
  .TP 8
  .B clocks \fIclock\fP  ...
***************
*** 153,158 ****
--- 159,170 ----
  stored internally to the nearest kHz.  The ordering of the clocks
  is important.  It must match the order in which they are selected on the
  graphics board.  Multiple \fBclocks\fP lines may be specified.
+ .TP 8
+ .B membase \fImemaddress\fP
+ specifies the base address of the video memory.  This option is only used
+ for the Sigma LaserView cards.  Valid addresses for these cards are
+ \fI0xA0000\fP, \fI0xB0000\fP, \fI0xC0000\fP, \fI0xD0000\fP, \fI0xE0000\fP.
+ The default is \fI0xE0000\fP.
  .TP 8
  .B black \fIred green blue\fP
  sets the ``black'' colour to the rgb values specified.  These values must be
diff -c mit/server/ddx/x386/XF86_SVGA.man:2.7 mit/server/ddx/x386/XF86_SVGA.man:2.10
*** mit/server/ddx/x386/XF86_SVGA.man:2.7	Fri Mar 11 23:35:47 1994
--- mit/server/ddx/x386/XF86_SVGA.man	Fri Mar 11 23:35:47 1994
***************
*** 1,6 ****
! .\" $XFree86: mit/server/ddx/x386/XF86_SVGA.man,v 2.7 1993/10/21 15:53:57 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_SVGA 1 "Version 2.0"  "XFree86"
  .SH NAME
  XF86_SVGA - 8 bit non-accelerated X Window System servers for UNIX on 
  x86 platforms
--- 1,6 ----
! .\" $XFree86: mit/server/ddx/x386/XF86_SVGA.man,v 2.10 1994/03/06 13:04:17 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_SVGA 1 "Version 2.1"  "XFree86"
  .SH NAME
  XF86_SVGA - 8 bit non-accelerated X Window System servers for UNIX on 
  x86 platforms
***************
*** 62,68 ****
  OTI067, OTI077
  .RE
  .PP
! Accelerated support is included for the Cirrus CLGD5426, CLGD5428, and
  the Western Digital WD90C31 chipsets.  Accelerated support for the
  ET4000/W32 is NOT yet implemented.  Users of boards based on ATI's
  Mach8 and Mach32 chipsets should refer to the \fIXF86_Mach8(1)\fP and
--- 62,68 ----
  OTI067, OTI077
  .RE
  .PP
! Accelerated support is included for most of the Cirrus chipsets, and for
  the Western Digital WD90C31 chipsets.  Accelerated support for the
  ET4000/W32 is NOT yet implemented.  Users of boards based on ATI's
  Mach8 and Mach32 chipsets should refer to the \fIXF86_Mach8(1)\fP and
***************
*** 174,179 ****
--- 174,193 ----
  .sp
  \fBnoaccel\fP - for Cirrus and WD chipsets.  This option disables the
  accelerated features for the clgd5426, clgd5428 and wd90c31 chipsets.
+ .sp
+ \fBfifo_conservative\fP - for Cirrus chipsets.  This option sets the CRT
+ FIFO threshold to a conservative value for dot clocks above 65MHz.  This
+ reduces performance, but may help in eliminating problems with ``streaks''
+ on the screen during BitBLT operations
+ .sp
+ \fBfifo_aggressive\fP - for Cirrus chipsets.  This option sets the CRT
+ FIFO threshold to an aggressive value for dot clocks above 65MHz.  This
+ increases performance, and is probably only appropriate for the clgd5434
+ chip.
+ .sp
+ \fBno_2mb_banksel\fP - for Cirrus chipsets.  This option is required for
+ Cirrus cards with 2MB of videoram which is in the form of 512kx8 DRAMs
+ (4 chips) rather than 256kx4 DRAMs (16 chips).
  .ig
  intern_disp (use internal display for laptops -- WD90C2x)
  extern_disp (use external display for laptops -- WD90C2x)
diff -c mit/server/ddx/x386/XF86_VGA16.man:2.3 mit/server/ddx/x386/XF86_VGA16.man:2.5
*** mit/server/ddx/x386/XF86_VGA16.man:2.3	Fri Mar 11 23:35:47 1994
--- mit/server/ddx/x386/XF86_VGA16.man	Fri Mar 11 23:35:48 1994
***************
*** 1,6 ****
! .\" $XFree86: mit/server/ddx/x386/XF86_VGA16.man,v 2.3 1993/10/18 12:16:13 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_VGA16 1 "Version 2.0"  "XFree86"
  .SH NAME
  XF86_VGA16 - 4 bit non-accelerated X Window System server for UNIX on
  x86 platforms
--- 1,6 ----
! .\" $XFree86: mit/server/ddx/x386/XF86_VGA16.man,v 2.5 1994/03/07 13:55:45 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XF86_VGA16 1 "Version 2.1"  "XFree86"
  .SH NAME
  XF86_VGA16 - 4 bit non-accelerated X Window System server for UNIX on
  x86 platforms
***************
*** 32,37 ****
--- 32,40 ----
  .TP 4
  Tseng:
  ET4000
+ .TP 4
+ Trident:
+ TVGA8800CS, TVGA8900B, TVGA8900C, TVGA8900CL, TVGA9000
  .RE
  .PP
  Additionally it
***************
*** 38,46 ****
  supports generic VGA cards.
  .PP
  .I XF86_VGA16
- will use up to 256Kb of display memory which yields a
- maximum virtual resolution of (approximately) 800x650.
- .I XF86_VGA16
  does not support the accelerated functions of the supported chipsets.
  .SH OPTIONS
  In addition to the normal server options described in the \fIXserver(1)\fP
--- 41,46 ----
***************
*** 76,81 ****
--- 76,84 ----
  .TP 4
  Tseng:
  et4000
+ .TP 4
+ Trident:
+ tvga8800cs, tvga8900b, tvga8900c, tvga8900cl, tvga9000
  .TP 4
  Generic VGA:
  generic 
diff -c mit/server/ddx/x386/XF86kbd.man:2.1 mit/server/ddx/x386/XF86kbd.man:2.2
*** mit/server/ddx/x386/XF86kbd.man:2.1	Fri Mar 11 23:35:48 1994
--- mit/server/ddx/x386/XF86kbd.man	Fri Mar 11 23:35:48 1994
***************
*** 1,7 ****
  '\" t
! '\" $XFree86: mit/server/ddx/x386/XF86kbd.man,v 2.1 1993/10/21 15:53:59 dawes Exp $
  '\"
! .TH XFree86kbd 1 "Version 2.0"  "XFree86"
  .SH NAME
  XFree86kbd - Description of keymapping capabilities of XFree86 servers
  .SH DESCRIPTION
--- 1,7 ----
  '\" t
! '\" $XFree86: mit/server/ddx/x386/XF86kbd.man,v 2.2 1994/02/27 05:17:26 dawes Exp $
  '\"
! .TH XFree86kbd 1 "Version 2.1"  "XFree86"
  .SH NAME
  XFree86kbd - Description of keymapping capabilities of XFree86 servers
  .SH DESCRIPTION
diff -c mit/server/ddx/x386/XFree86.man:2.9 mit/server/ddx/x386/XFree86.man:2.11
*** mit/server/ddx/x386/XFree86.man:2.9	Fri Mar 11 23:35:49 1994
--- mit/server/ddx/x386/XFree86.man	Fri Mar 11 23:35:49 1994
***************
*** 1,6 ****
! .\" $XFree86: mit/server/ddx/x386/XFree86.man,v 2.9 1993/10/21 15:54:01 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XFree86 1 "Version 2.0"  "XFree86"
  .SH NAME
  XFree86 - X11R5 Enhancement Package for UNIX on x86 platforms
  .SH DESCRIPTION
--- 1,6 ----
! .\" $XFree86: mit/server/ddx/x386/XFree86.man,v 2.11 1994/03/08 08:07:18 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH XFree86 1 "Version 2.1"  "XFree86"
  .SH NAME
  XFree86 - X11R5 Enhancement Package for UNIX on x86 platforms
  .SH DESCRIPTION
***************
*** 30,37 ****
  .br
  -- SVR4.2: Consensys, Univel (UnixWare)
  .br
! -- 386BSD version 0.1, FreeBSD 1.0, NetBSD 0.9 (i386 port only)
  .br
  -- BSD/386 version 1.0
  .br
  -- Mach (from CMU)
--- 30,39 ----
  .br
  -- SVR4.2: Consensys, Univel (UnixWare)
  .br
! -- Solaris (x86) 2.1
  .br
+ -- 386BSD version 0.1, FreeBSD 1.0, 1.1, NetBSD 0.9 (i386 port only)
+ .br
  -- BSD/386 version 1.0
  .br
  -- Mach (from CMU)
***************
*** 302,307 ****
--- 304,315 ----
  Orest Zborowski,   \fIorestz@microsoft.com\fP
  Ported to \fBLinux\fP.
  .TP 8
+ Doug Anson,        \fIdanson@lgc.com\fP
+ Ported to \fBSolaris x86\fP.
+ .TP 8
+ David Holland,     \fIdavidh@use.com\fP
+ Ported to \fBSolaris x86\fP.
+ .TP 8
  David McCullough,  \fIdavidm@stallion.oz.au\fP
  Ported to \fBSCO SVR3\fP.
  .TP 8
***************
*** 321,326 ****
--- 329,337 ----
  Jon Tombs,         \fIjon@gtex02.us.es\fP
  S3 server and accelerated server coordination.
  .TP 8
+ Robin Cutshaw,     \fIrobin@paros.com\fP
+ S3 server ramdac support.
+ .TP 8
  Kevin Martin,      \fImartin@cs.unc.edu\fP
  Overall work on the base accelerated servers (ATI and 8514/A).
  .TP 8
***************
*** 339,346 ****
--- 350,363 ----
  Mark Weaver,       \fIMark_Weaver@brown.edu\fP
  Mach32 server development.
  .TP 8
+ Craig Groeschel,   \fIcraig@adikia.sccsi.com\fP
+ Mach32 server development.
+ .TP 8
  Simon Cooper,      \fIscooper@vizlab.rutgers.edu\fP
  Cirrus accelerated code (based on work by Bill Reynolds).
+ .TP 8
+ Harm Hanemaayer,   \fIhhanemaa@cs.ruu.nl\fP
+ Cirrus accelerated code.
  .TP 8
  Mike Tierney,      \fIfloyd@eng.umd.edu\fP
  WD accelerated code.
diff -c mit/server/ddx/x386/Xconfig.man:2.5 mit/server/ddx/x386/Xconfig.man:2.9
*** mit/server/ddx/x386/Xconfig.man:2.5	Fri Mar 11 23:35:50 1994
--- mit/server/ddx/x386/Xconfig.man	Fri Mar 11 23:35:50 1994
***************
*** 1,6 ****
! .\" $XFree86: mit/server/ddx/x386/Xconfig.man,v 2.5 1993/10/18 12:16:17 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH Xconfig 4/5 "Version 2.0"  "XFree86"
  .SH NAME
  Xconfig - Configuration File for XFree86
  .SH DESCRIPTION
--- 1,6 ----
! .\" $XFree86: mit/server/ddx/x386/Xconfig.man,v 2.9 1994/03/08 08:07:19 dawes Exp $
  .\" $XConsortium: X386.man,v 1.3 91/08/26 15:31:19 gildea Exp $
! .TH Xconfig 4/5 "Version 2.1"  "XFree86"
  .SH NAME
  Xconfig - Configuration File for XFree86
  .SH DESCRIPTION
***************
*** 124,129 ****
--- 124,133 ----
  makes \fIled\fP available for clients instead of using the traditional function
  (Scroll Lock, Caps Lock & Num Lock)
  .TP 8
+ .B vtsysreq
+ enables the SYSV-style VT switch sequence for non-SYSV systems which support
+ VT switching.  This sequence is Alt-SysRq followed by a function key (Fn).
+ .TP 8
  .B vtinit \fI"command"\fP
  Runs \fIcommand\fP after the VT used by the server has been opened.  The
  command string is passed to "/bin/sh -c", and is run with the real user's id
***************
*** 186,195 ****
  currently only supported for logitech mice.
  .TP 8
  .B cleardtr
! This options clears the DTR line on the serial port used by the mouse.  This
  option is only valid for a mouse using the \fBmousesystems\fP protocol.
  Some dual-protocol mice require DTR to be cleared to operate in mousesystems
! mode.
  .PP
  The \fBGRAPHICS DRIVER SETUP\fP section depends on the actually used
  server. Here only the general features are explained, for more detail
--- 190,208 ----
  currently only supported for logitech mice.
  .TP 8
  .B cleardtr
! This option clears the DTR line on the serial port used by the mouse.  This
  option is only valid for a mouse using the \fBmousesystems\fP protocol.
  Some dual-protocol mice require DTR to be cleared to operate in mousesystems
! mode.  Note, in versions of XFree86 prior to 2.1, this option also cleared
! the RTS line.  A separate \fBclearrts\fP option has been added for mice
! which require this.
! .TP 8
! .B clearrts
! This option clears the RTS line on the serial port used by the mouse.  This
! option is only valid for a mouse using the \fBmousesystems\fP protocol.
! Some dual-protocol mice require both DTR and RTS to be cleared to operate
! in mousesystems mode.  Both the \fBcleardtr\fP and \fBclearrts\fP options
! should be used for such mice.
  .PP
  The \fBGRAPHICS DRIVER SETUP\fP section depends on the actually used
  server. Here only the general features are explained, for more detail
***************
*** 210,216 ****
  .B staticgray,grayscale,staticcolor,pseudocolor,truecolor,directcolor
  sets the visual class for the root window of the screen.  Note that the
  monochrome server only supports a \fIstaticgray\fP visual, and the 16 colour
! VGA server only supports a \fIpseudocolor\fP visual.
  .br
  .ne 3i
  .TP 8
--- 223,230 ----
  .B staticgray,grayscale,staticcolor,pseudocolor,truecolor,directcolor
  sets the visual class for the root window of the screen.  Note that the
  monochrome server only supports a \fIstaticgray\fP visual, and the 16 colour
! VGA server only supports \fIpseudocolor\fP, \fIstaticgray\fP and
! \fIgrayscale\fP visuals.
  .br
  .ne 3i
  .TP 8
diff -c mit/server/ddx/x386/LinkKit/Imakefile.LK:2.15 mit/server/ddx/x386/LinkKit/Imakefile.LK:2.17
*** mit/server/ddx/x386/LinkKit/Imakefile.LK:2.15	Fri Mar 11 23:35:54 1994
--- mit/server/ddx/x386/LinkKit/Imakefile.LK	Fri Mar 11 23:35:54 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/LinkKit/Imakefile.LK,v 2.15 1993/10/02 07:13:55 dawes Exp $
  /*
   * Server Makefile for Link Kit
   */
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/LinkKit/Imakefile.LK,v 2.17 1994/03/09 02:18:34 dawes Exp $
  /*
   * Server Makefile for Link Kit
   */
***************
*** 47,63 ****
     EXTRASYSLIBS = /usr/misc/.mach/lib/libmach.a
  #endif
  #endif
- #if HasSdbm
-          DBMLIB = -lsdbm
- #else
- #if !i386Bsd
-          DBMLIB = -ldbm
- #endif
- #endif
  #if NeedLibGcc
           GCCLIB = -lgcc
  #endif
!         SYSLIBS = -lm $(DBMLIB) $(MALLOCLIBS) $(EXTRASYSLIBS) $(GCCLIB)
             CBRT = lib/cbrt.o
  
         IRULESRC = $(CONFIGDIR)
--- 47,56 ----
     EXTRASYSLIBS = /usr/misc/.mach/lib/libmach.a
  #endif
  #endif
  #if NeedLibGcc
           GCCLIB = -lgcc
  #endif
!         SYSLIBS = -lm $(MALLOCLIBS) $(EXTRASYSLIBS) $(GCCLIB)
             CBRT = lib/cbrt.o
  
         IRULESRC = $(CONFIGDIR)
***************
*** 323,329 ****
  #endif
  
  /* Only these servers have subdirs */
! #if XF86SVGAServer || XF86MonoServer
  
  SUBDIRS = $(SUBDIRS0) $(SUBDIRS1) $(SUBDIRS2) $(SUBDIRS3) $(SUBDIRS4) $(SUBDIRS5) $(SUBDIRS6)
  
--- 316,322 ----
  #endif
  
  /* Only these servers have subdirs */
! #if XF86SVGAServer || XF86MonoServer || XF86VGA16Server || XF86S3Server
  
  SUBDIRS = $(SUBDIRS0) $(SUBDIRS1) $(SUBDIRS2) $(SUBDIRS3) $(SUBDIRS4) $(SUBDIRS5) $(SUBDIRS6)
  
***************
*** 339,344 ****
  
  DependTarget()
  
! #endif /* XF86SVGAServer || XF86MonoServer */
  
  #endif /* Init */
--- 332,337 ----
  
  DependTarget()
  
! #endif /* XF86SVGAServer || XF86MonoServer || XF86VGA16Server || XF86S3Server */
  
  #endif /* Init */
diff -c mit/server/ddx/x386/LinkKit/site.def.LK:2.9 mit/server/ddx/x386/LinkKit/site.def.LK:2.10
*** mit/server/ddx/x386/LinkKit/site.def.LK:2.9	Fri Mar 11 23:35:54 1994
--- mit/server/ddx/x386/LinkKit/site.def.LK	Fri Mar 11 23:35:54 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/LinkKit/site.def.LK,v 2.9 1993/10/16 17:30:15 dawes Exp $
  
  /* Configuration file for Server Link Kit */
  
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/LinkKit/site.def.LK,v 2.10 1994/03/09 02:18:36 dawes Exp $
  
  /* Configuration file for Server Link Kit */
  
***************
*** 53,58 ****
--- 53,59 ----
  #define FontRenderers		Speedo Type1
  #define X386Vga2Drivers		et4000 et3000 pvga1 gvga tvga8900 ncr \
  				compaq oak generic
+ #define X386Vga16Drivers	et4000 tvga8900 generic
  #define X386Vga256Drivers	et4000 et3000 pvga1 gvga ati tvga8900 cirrus \
  				ncr compaq oak
  #define X386Hga2Drivers		/**/
***************
*** 63,72 ****
   * To include the generic banked monochrome driver in the monochrome server,
   * uncomment this with one of the following low level drivers
   * 	hgc1280		[Hyundai HGC-1280 1280x1024]
   *	...
   *	(list is subject to grow)
   */
! /* #define X386Bdm2Drivers	hgc1280 */
  
  /* #define XF86S3Drivers		mmio_928 s3_generic */
  /*
--- 64,75 ----
   * To include the generic banked monochrome driver in the monochrome server,
   * uncomment this with one of the following low level drivers
   * 	hgc1280		[Hyundai HGC-1280 1280x1024]
+  *	sigma		[Sigma L-View]
+  *	visa		[???]
   *	...
   *	(list is subject to grow)
   */
! /* #define X386Bdm2Drivers	hgc1280 sigma visa */
  
  /* #define XF86S3Drivers		mmio_928 s3_generic */
  /*
diff -c mit/server/ddx/x386/SuperProbe/00README:2.4 mit/server/ddx/x386/SuperProbe/00README:2.8
*** mit/server/ddx/x386/SuperProbe/00README:2.4	Fri Mar 11 23:36:01 1994
--- mit/server/ddx/x386/SuperProbe/00README	Fri Mar 11 23:36:02 1994
***************
*** 1,6 ****
  			README file for SuperProbe
  			--------------------------
! 			    Version 1.0
  
  			    David E Wexelblat
  			    dwex@goblin.org
--- 1,6 ----
  			README file for SuperProbe
  			--------------------------
! 			    Version 2.0
  
  			    David E Wexelblat
  			    dwex@goblin.org
***************
*** 9,19 ****
  -----------
  SuperProbe is a program for Intel-based Unix machines.  It is used to 
  determine the type of video hardware installed in the machine, including, 
! where it can be determined, which specific chipset.  The current version 
! supports EISA/ISA machines running SVR3, SVR4, Linux, 386BSD, Minix-386,
! and Mach (MicroChannel machines are not currently supported; hopefully 
! this support will be included in a future release.  These may work
! anyhow, though, with the -no_bios option).  Adding support for other 
  operating systems should be fairly trivial, as the OS dependencies are 
  isolated to a single file for each OS.
  
--- 9,20 ----
  -----------
  SuperProbe is a program for Intel-based Unix machines.  It is used to 
  determine the type of video hardware installed in the machine, including, 
! where it can be determined, which specific chipset, what type of 
! RAMDAC is attached, and how much video memory resides on the board.
! The current version supports EISA/ISA/VLB machines running SVR3, 
! SVR4, Linux, *BSD*, Minix-386, and Mach (MicroChannel and PCI machines 
! are believed to work as well, although the BIOS checking may need to 
! be disabled via the '-no_bios' option).  Adding support for other 
  operating systems should be fairly trivial, as the OS dependencies are 
  isolated to a single file for each OS.
  
***************
*** 47,55 ****
  Credits
  -------
  Finn Thoegersen
! 	For providing the vgadoc2.zip video hardware documentation package
! 	and sample code, and for allowing me to port his code to the Unix
! 	environment.
  
  David Dawes <dawes@physics.su.oz.au>
  	For lots of help on the initial design, and writing the 386BSD OS
--- 48,56 ----
  Credits
  -------
  Finn Thoegersen
! 	For providing the vgadoc2.zip and vgadoc3.zip video hardware 
! 	documentation packages and sample code, and for allowing me 
! 	to port his code to the Unix environment.
  
  David Dawes <dawes@physics.su.oz.au>
  	For lots of help on the initial design, and writing the 386BSD OS
***************
*** 72,75 ****
  	For helping test and debug this software.
  
  
! $XFree86: mit/server/ddx/x386/SuperProbe/00README,v 2.4 1993/10/07 13:54:42 dawes Exp $
--- 73,76 ----
  	For helping test and debug this software.
  
  
! $XFree86: mit/server/ddx/x386/SuperProbe/00README,v 2.8 1994/03/02 08:04:48 dawes Exp $
diff -c mit/server/ddx/x386/SuperProbe/8514.c:2.1 mit/server/ddx/x386/SuperProbe/8514.c:2.3
*** mit/server/ddx/x386/SuperProbe/8514.c:2.1	Fri Mar 11 23:36:02 1994
--- mit/server/ddx/x386/SuperProbe/8514.c	Fri Mar 11 23:36:02 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/8514.c,v 2.1 1993/09/21 15:20:23 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/8514.c,v 2.3 1994/02/28 14:09:09 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 33,38 ****
--- 33,40 ----
  static Word Ports[] = {SUBSYS_CNTL,ERR_TERM};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_8514 __STDCARGS((int));
+ 
  Chip_Descriptor IBM8514_Descriptor = {
  	"8514/A",
  	Probe_8514,
***************
*** 40,54 ****
  	NUMPORTS,
  	TRUE,
  	FALSE,
! 	FALSE
  };
  
- #ifdef __STDC__
- Bool Probe_8514(int *Chipset)
- #else
  Bool Probe_8514(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  
--- 42,53 ----
  	NUMPORTS,
  	TRUE,
  	FALSE,
! 	FALSE,
! 	MemProbe_8514,
  };
  
  Bool Probe_8514(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  
***************
*** 74,80 ****
  		outpw(ERR_TERM, 0x5555);
  		if (inpw(ERR_TERM) == 0x5555)
  		{
! 			*Chipset = CHIP_8514;
  			result = TRUE;
  		}
  	}
--- 73,86 ----
  		outpw(ERR_TERM, 0x5555);
  		if (inpw(ERR_TERM) == 0x5555)
  		{
! 			if (tstrg(EXT_CONF_3, 0xF0))
! 			{
! 				*Chipset = CHIP_CT480;
! 			}
! 			else
! 			{
! 				*Chipset = CHIP_8514;
! 			}
  			result = TRUE;
  		}
  	}
***************
*** 81,84 ****
--- 87,111 ----
  
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ /* ARGSUSED */
+ static int MemProbe_8514(Chipset)
+ int Chipset;
+ {
+ 	int Mem;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	if (inpw(SUBSYS_CNTL) & 0x0080)
+ 	{
+ 		Mem = 1024;
+ 	}
+ 	else
+ 	{
+ 		Mem = 512;
+ 	}
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/AL.c:2.1 mit/server/ddx/x386/SuperProbe/AL.c:2.4
*** mit/server/ddx/x386/SuperProbe/AL.c:2.1	Fri Mar 11 23:36:03 1994
--- mit/server/ddx/x386/SuperProbe/AL.c	Fri Mar 11 23:36:03 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,50 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/AL.c,v 2.1 1993/09/21 15:20:24 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, 0x8286, 0x3CE, 0x3CF};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor AL_Descriptor = {
  	"AL",
  	Probe_AL,
  	Ports,
  	NUMPORTS,
! 	TRUE,
  	FALSE,
! 	FALSE
  };
  
- #ifdef __STDC__
- Bool Probe_AL(int *Chipset)
- #else
  Bool Probe_AL(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  
  	/* Add CRTC to enabled ports */
--- 21,50 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/AL.c,v 2.4 1994/03/02 08:04:51 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_AL __STDCARGS((int));
+ 
  Chip_Descriptor AL_Descriptor = {
  	"AL",
  	Probe_AL,
  	Ports,
  	NUMPORTS,
! 	FALSE,
  	FALSE,
! 	FALSE,
! 	MemProbe_AL,
  };
  
  Bool Probe_AL(Chipset)
  int *Chipset;
  {
+ 	Byte old;
  	Bool result = FALSE;
  
  	/* Add CRTC to enabled ports */
***************
*** 51,63 ****
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
! 	if (testinx2(CRTC_IDX, 0x1F, 0x3B) &&
! 	    testinx2(0x3CE, 0x0D, 0x0F) &&
! 	    tstrg(0x8286, 0xFF))
  	{
! 		result = TRUE;
! 		*Chipset = CHIP_AL2101;
  	}
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
--- 51,114 ----
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
! 
! 	old = rdinx(CRTC_IDX, 0x1A);
! 	clrinx(CRTC_IDX, 0x1A, 0x10);
! 	if (!testinx(CRTC_IDX, 0x19))
  	{
! 		setinx(CRTC_IDX, 0x1A, 0x10);
! 		if ((testinx(CRTC_IDX, 0x19) && 
! 		    (testinx2(CRTC_IDX, 0x1A, 0x3F))))
! 		{
! 			result = TRUE;
! 			*Chipset = CHIP_AL2101;
! 		}
  	}
+ 	wrinx(CRTC_IDX, 0x1A, old);
+ 
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ /* ARGSUSED */
+ static int MemProbe_AL(Chipset)
+ int Chipset;
+ {
+ 	Byte old;
+ 	int Mem;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Unlock
+ 	 */
+ 	old = rdinx(CRTC_IDX, 0x1A);
+ 	setinx(CRTC_IDX, 0x1A, 0x10);
+ 
+ 	/*
+ 	 * Check
+ 	 */
+ 	switch (rdinx(CRTC_IDX, 0x1E) & 0x03)
+ 	{
+ 	case 0x00:
+ 		Mem = 256;
+ 		break;
+ 	case 0x01:
+ 		Mem = 512;
+ 		break;
+ 	case 0x02:
+ 		Mem = 1024;
+ 		break;
+ 	case 0x03:
+ 		Mem = 2048;
+ 		break;
+ 	}
+ 
+ 	/*
+ 	 * Lock
+ 	 */
+ 	wrinx(CRTC_IDX, 0x1A, old);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/ATI.c:2.3 mit/server/ddx/x386/SuperProbe/ATI.c:2.7
*** mit/server/ddx/x386/SuperProbe/ATI.c:2.3	Fri Mar 11 23:36:03 1994
--- mit/server/ddx/x386/SuperProbe/ATI.c	Fri Mar 11 23:36:03 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,30 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/ATI.c,v 2.3 1993/09/27 12:23:11 dawes Exp $ */
  
  #include "Probe.h"
  
  Chip_Descriptor ATI_Descriptor = {
  	"ATI",
  	Probe_ATI,
--- 21,32 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/ATI.c,v 2.7 1994/03/07 13:56:04 dawes Exp $ */
  
  #include "Probe.h"
  
+ static int MemProbe_ATI __STDCARGS((int));
+ 
  Chip_Descriptor ATI_Descriptor = {
  	"ATI",
  	Probe_ATI,
***************
*** 32,38 ****
  	0,
  	FALSE,
  	TRUE,
! 	TRUE
  };
  
  #ifdef __STDC__
--- 34,41 ----
  	0,
  	FALSE,
  	TRUE,
! 	TRUE,
! 	MemProbe_ATI,
  };
  
  #ifdef __STDC__
***************
*** 45,50 ****
--- 48,54 ----
  	Bool result = FALSE;
  	Byte bios[10];
  	Byte *signature = (Byte *)"761295520";
+ 	Word GUP;
  
  	if (ReadBIOS(0x31, bios, 9) != 9)
  	{
***************
*** 80,89 ****
  				*Chipset = CHIP_ATI28800_5;
  				break;
  			case 'a':
! 				*Chipset = CHIP_ATI28800_A;
! 				break;
  			case 'c':
! 				*Chipset = CHIP_ATI28800_C; /* XLR? */
  				break;
  			default:
  				Chip_data = bios[3];
--- 84,122 ----
  				*Chipset = CHIP_ATI28800_5;
  				break;
  			case 'a':
! 			case 'b':
  			case 'c':
! 				/*
! 				 * 68800-??
! 				 *
! 				 * Chipset ID encoded as:
! 				 *	Bits 0-4 - low letter
! 				 *	Bits 5-9 - high letter
! 				 *  Add 0x41 to each to get ascii letter.
! 				 *
! 				 * Started at 68800-6, so 0 shows up for the
! 				 * 68800-3.
! 				 */
! 				GUP = inpw(CHIP_ID);
! 				switch (GUP & 0x03FF)
! 				{
! 				case 0x0000:
! 					*Chipset = CHIP_ATI68800_3;
! 					break;
! 				case 0x02F7:	/* XX */
! 					*Chipset = CHIP_ATI68800_6;
! 					break;
! 				case 0x0177:	/* LX */
! 					*Chipset = CHIP_ATI68800LX;
! 					break;
! 				case 0x0017:	/* AX */
! 					*Chipset = CHIP_ATI68800AX;
! 					break;
! 				default:
! 					Chip_data = ((GUP >> 5) & 0x1F) + 0x41;
! 					*Chipset = CHIP_ATI_UNK;
! 					break;
! 				}
  				break;
  			default:
  				Chip_data = bios[3];
***************
*** 93,96 ****
--- 126,209 ----
  		}
  	}
  	return(result);
+ }
+ 
+ static int MemProbe_ATI(Chipset)
+ int Chipset;
+ {
+ 	Word Ports[3] = {0x000, 0x000, MISC_OPTIONS};
+ 	Byte bios[20];
+ 	int Mem = 0;
+ 
+ 	if (ReadBIOS(0x40, bios, 20) != 20)
+ 	{
+ 		fprintf(stderr, "%s: Failed to read ATI BIOS data\n", MyName);
+ 		return(0);
+ 	}
+ 	Ports[0] = *((Word *)bios + 0x08);
+ 	Ports[1] = Ports[0] + 1;
+ 	EnableIOPorts(3, Ports);
+ 
+ 	switch (Chipset)
+ 	{
+ 	case CHIP_ATI18800:
+ 	case CHIP_ATI18800_1:
+ 		if (rdinx(Ports[0], 0xBB) & 0x20)
+ 		{
+ 			Mem = 512;
+ 		}
+ 		else
+ 		{
+ 			Mem = 256;
+ 		}
+ 		break;
+ 	case CHIP_ATI28800_2:
+ 		if (rdinx(Ports[0], 0xB0) & 0x10)
+ 		{
+ 			Mem = 512;
+ 		}
+ 		else
+ 		{
+ 			Mem = 256;
+ 		}
+ 		break;
+ 	case CHIP_ATI28800_4:
+ 	case CHIP_ATI28800_5:
+ 		switch (rdinx(Ports[0], 0xB0) & 0x18)
+ 		{
+ 		case 0x00:
+ 			Mem = 256;
+ 			break;
+ 		case 0x10:
+ 			Mem = 512;
+ 			break;
+ 		case 0x08:
+ 		case 0x18:
+ 			Mem = 1024;
+ 			break;
+ 		}
+ 		break;
+ 	default:
+ 		/* GUP */
+ 		switch ((inpw(MISC_OPTIONS) & 0x000C) >> 2)
+ 		{
+ 		case 0x00:
+ 			Mem = 512;
+ 			break;
+ 		case 0x01:
+ 			Mem = 1024;
+ 			break;
+ 		case 0x02:
+ 			Mem = 2048;
+ 			break;
+ 		case 0x03:
+ 			Mem = 4096;
+ 			break;
+ 		}
+ 		break;
+ 	}
+ 
+ 	DisableIOPorts(3, Ports);
+ 	return(Mem);
+ 
  }
diff -c mit/server/ddx/x386/SuperProbe/ATIMach.c:2.3 mit/server/ddx/x386/SuperProbe/ATIMach.c:2.7
*** mit/server/ddx/x386/SuperProbe/ATIMach.c:2.3	Fri Mar 11 23:36:04 1994
--- mit/server/ddx/x386/SuperProbe/ATIMach.c	Fri Mar 11 23:36:04 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,33 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/ATIMach.c,v 2.3 1993/09/25 05:01:39 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {ROM_ADDR_1,DESTX_DIASTP,READ_SRC_X};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor ATIMach_Descriptor = {
  	"ATI_Mach",
  	Probe_ATIMach,
--- 21,36 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/ATIMach.c,v 2.7 1994/03/07 13:56:07 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {ROM_ADDR_1,DESTX_DIASTP,READ_SRC_X,
! 		       CONFIG_STATUS_1,MISC_OPTIONS};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_ATIMach __STDCARGS((int));
+ 
  Chip_Descriptor ATIMach_Descriptor = {
  	"ATI_Mach",
  	Probe_ATIMach,
***************
*** 35,41 ****
  	NUMPORTS,
  	TRUE,
  	FALSE,
! 	FALSE
  };
  
  #define WaitIdleEmpty() { int i; \
--- 38,45 ----
  	NUMPORTS,
  	TRUE,
  	FALSE,
! 	FALSE,
! 	MemProbe_ATIMach,
  };
  
  #define WaitIdleEmpty() { int i; \
***************
*** 44,55 ****
  					break; \
  			}
  
- #ifdef __STDC__
- Bool Probe_ATIMach(int *Chipset)
- #else
  Bool Probe_ATIMach(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Word tmp;
--- 48,55 ----
***************
*** 124,127 ****
--- 124,166 ----
  
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ static int MemProbe_ATIMach(Chipset)
+ int Chipset;
+ {
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 	if (Chipset == CHIP_MACH8)
+ 	{
+ 		if (inpw(CONFIG_STATUS_1) & 0x0020)
+ 		{
+ 			Mem = 1024;
+ 		}
+ 		else
+ 		{
+ 			Mem = 512;
+ 		}
+ 	}
+ 	else
+ 	{
+ 		switch ((inpw(MISC_OPTIONS) & 0x000C) >> 2)
+ 		{
+ 		case 0x00:
+ 			Mem = 512;
+ 			break;
+ 		case 0x01:
+ 			Mem = 1024;
+ 			break;
+ 		case 0x02:
+ 			Mem = 2048;
+ 			break;
+ 		case 0x03:
+ 			Mem = 4096;
+ 			break;
+ 		}
+ 	}
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/AcuMos.c:2.1 mit/server/ddx/x386/SuperProbe/AcuMos.c:removed
*** mit/server/ddx/x386/SuperProbe/AcuMos.c:2.1	Fri Mar 11 23:36:04 1994
--- mit/server/ddx/x386/SuperProbe/AcuMos.c	Fri Mar 11 23:36:04 1994
***************
*** 1,62 ****
- /*
-  * 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.
-  *
-  */
- 
- /* $XFree86: mit/server/ddx/x386/SuperProbe/AcuMos.c,v 2.1 1993/09/21 15:20:27 dawes Exp $ */
- 
- #include "Probe.h"
- 
- static Word Ports[] = {0x3C4, 0x3C5, 0x3CE, 0x3CF};
- #define NUMPORTS (sizeof(Ports)/sizeof(Word))
- 
- Chip_Descriptor AcuMos_Descriptor = {
- 	"AcuMos",
- 	Probe_AcuMos,
- 	Ports,
- 	NUMPORTS,
- 	FALSE,
- 	FALSE,
- 	TRUE
- };
- 
- #ifdef __STDC__
- Bool Probe_AcuMos(int *Chipset)
- #else
- Bool Probe_AcuMos(Chipset)
- int *Chipset;
- #endif
- {
- 	Bool result = FALSE;
- 	Byte old;
- 
- 	EnableIOPorts(NUMPORTS, Ports);
- 	old = rdinx(0x3C4, 0x06);
- 	wrinx(0x3C4, 0x06, 0x12);
- 	if (testinx2(0x3CE, 0x09, 0x30))
- 	{
- 		result = TRUE;
- 		*Chipset = CHIP_ACUMOS;
- 	}
- 	wrinx(0x3C4, 0x06, old);
- 	DisableIOPorts(NUMPORTS, Ports);
- 	return(result);
- }
--- 0 ----
diff -c mit/server/ddx/x386/SuperProbe/Ahead.c:2.2 mit/server/ddx/x386/SuperProbe/Ahead.c:2.5
*** mit/server/ddx/x386/SuperProbe/Ahead.c:2.2	Fri Mar 11 23:36:05 1994
--- mit/server/ddx/x386/SuperProbe/Ahead.c	Fri Mar 11 23:36:05 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,33 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Ahead.c,v 2.2 1993/09/27 12:23:12 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x3CE, 0x3CF};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Ahead_Descriptor = {
  	"Ahead",
  	Probe_Ahead,
--- 21,35 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Ahead.c,v 2.5 1994/03/02 08:04:53 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {GRC_IDX, GRC_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_Ahead __STDCARGS((int));
+ 
  Chip_Descriptor Ahead_Descriptor = {
  	"Ahead",
  	Probe_Ahead,
***************
*** 35,63 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Ahead(int *Chipset)
- #else
  Bool Probe_Ahead(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte old, tmp;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 	old = rdinx(0x3CE, 0x0F);
! 	wrinx(0x3CE, 0x0F, 0);
! 	if (!testinx2(0x3CE, 0x0C, 0xFB))
  	{
! 		wrinx(0x3CE, 0x0F, 0x20);
! 		if (testinx2(0x3CE, 0x0C, 0xFB))
  		{
  			result = TRUE;
! 			tmp = rdinx(0x3CE, 0x0F) & 0x0F;
  			switch (tmp)
  			{
  			case 0x01:
--- 37,62 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_Ahead,
  };
  
  Bool Probe_Ahead(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  	Byte old, tmp;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 	old = rdinx(GRC_IDX, 0x0F);
! 	wrinx(GRC_IDX, 0x0F, 0);
! 	if (!testinx2(GRC_IDX, 0x0C, 0xFB))
  	{
! 		wrinx(GRC_IDX, 0x0F, 0x20);
! 		if (testinx2(GRC_IDX, 0x0C, 0xFB))
  		{
  			result = TRUE;
! 			tmp = rdinx(GRC_IDX, 0x0F) & 0x0F;
  			switch (tmp)
  			{
  			case 0x01:
***************
*** 73,79 ****
  			}
  		}
  	}
! 	wrinx(0x3CE, 0x0F, old);
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
--- 72,118 ----
  			}
  		}
  	}
! 	wrinx(GRC_IDX, 0x0F, old);
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ /* ARGSUSED */
+ static int MemProbe_Ahead(Chipset)
+ int Chipset;
+ {
+ 	Byte old;
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Unlock
+ 	 */
+ 	old = rdinx(GRC_IDX, 0x0F);
+ 	setinx(GRC_IDX, 0x0F, 0x20);
+ 
+ 	/*
+ 	 * Check
+ 	 */
+ 	switch (rdinx(GRC_IDX, 0x1F) & 0x03)
+ 	{
+ 	case 0x00:
+ 		Mem = 256;
+ 		break;
+ 	case 0x01:
+ 		Mem = 512;
+ 		break;
+ 	case 0x03:
+ 		Mem = 1024;
+ 		break;
+ 	}
+ 
+ 	/*
+ 	 * Lock
+ 	 */
+ 	wrinx(GRC_IDX, 0x0F, old);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/Amake.srclist:1.1 mit/server/ddx/x386/SuperProbe/Amake.srclist:2.1
*** mit/server/ddx/x386/SuperProbe/Amake.srclist:1.1	Fri Mar 11 23:36:05 1994
--- mit/server/ddx/x386/SuperProbe/Amake.srclist	Fri Mar 11 23:36:05 1994
***************
*** 1,10 ****
! # $XFree86: mit/server/ddx/x386/SuperProbe/Amake.srclist,v 1.1 1993/05/04 10:16:47 dawes Exp $
  
  X11R5_MIT_SERVER_DDX_X386_SUPERPROBE=
  {
  	$PWD/AL.c,
  	$PWD/ATI.c,
! 	$PWD/AcuMos.c,
  	$PWD/Ahead.c,
  	$PWD/CGA.c,
  	$PWD/ChipsTech.c,
--- 1,11 ----
! # $XFree86: mit/server/ddx/x386/SuperProbe/Amake.srclist,v 2.1 1994/02/28 14:09:16 dawes Exp $
  
  X11R5_MIT_SERVER_DDX_X386_SUPERPROBE=
  {
+ 	$PWD/8514.c,
  	$PWD/AL.c,
  	$PWD/ATI.c,
! 	$PWD/ATIMach.c,
  	$PWD/Ahead.c,
  	$PWD/CGA.c,
  	$PWD/ChipsTech.c,
***************
*** 12,20 ****
--- 13,23 ----
  	$PWD/Compaq.c,
  	$PWD/Genoa.c,
  	$PWD/Herc.c,
+ 	$PWD/HMC.c,
  	$PWD/MDA.c,
  	$PWD/MX.c,
  	$PWD/Main.c,
+ 	$PWD/MemProbe.c,
  	$PWD/NCR.c,
  	$PWD/OS_Minix.c,
  	$PWD/Oak.c,
***************
*** 25,33 ****
--- 28,38 ----
  	$PWD/S3.c,
  	$PWD/Trident.c,
  	$PWD/Tseng.c,
+ 	$PWD/UMC.c,
  	$PWD/Utils.c,
  	$PWD/VGA.c,
  	$PWD/Video7.c,
  	$PWD/WD.c,
+ 	$PWD/Weitek.c,
  	$PWD/Yamaha.c,
  };
diff -c mit/server/ddx/x386/SuperProbe/CGA.c:1.2 mit/server/ddx/x386/SuperProbe/CGA.c:2.0
*** mit/server/ddx/x386/SuperProbe/CGA.c:1.2	Fri Mar 11 23:36:06 1994
--- mit/server/ddx/x386/SuperProbe/CGA.c	Fri Mar 11 23:36:06 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/CGA.c,v 1.2 1993/05/04 10:16:49 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/CGA.c,v 2.0 1994/02/28 14:09:17 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 33,44 ****
  static Word Ports[] = {0x3D4, 0x3D5};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
- #ifdef __STDC__
- Bool Probe_CGA(int *Chipset)
- #else
  Bool Probe_CGA(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte tmp;
--- 33,40 ----
diff -c mit/server/ddx/x386/SuperProbe/ChangeLog:2.8 mit/server/ddx/x386/SuperProbe/ChangeLog:2.12
*** mit/server/ddx/x386/SuperProbe/ChangeLog:2.8	Fri Mar 11 23:36:06 1994
--- mit/server/ddx/x386/SuperProbe/ChangeLog	Fri Mar 11 23:36:06 1994
***************
*** 64,66 ****
--- 64,92 ----
  Version 1.0
  	- Add in Cirrus 62x5, 642x chipsets
  	- Call it "done" for XFree86 2.0
+ 
+ Version 1.1
+ 	- Add AT&T 20C505/504 checks to the RAMDAC probe
+ 	- Add Solaris x86 support (from David Holland <davidh@dorite.use.com>)
+ 	- Add -no_dac option to skip RAMDAC probe, in case it's nuking things.
+ 	- Long and short RamDac names.
+ 	- If the video BIOS can't be located, don't fail.  Assume that there's
+ 	  no EGA/VGA, and probe for old hardware.
+ 	- Put architecture in place for doing installed memory probes.
+ 
+ Version 1.2 - Jan 2, 1994
+ 	- More work on memory probes.  Add support for probing memory
+ 	  by mapping 0xA0000-0xAFFFF and switching banks.  Support
+ 	  memory probe via this mechanism for Trident and ET4000AX.
+ 	- Add probes for Trident 9200CXr, 9400CXi.
+ 	- Add support for USL-style VTs on bsd-du-jour (from J"org Wunsch).
+ 	- Add -no_mem option to skip memory probe
+ 
+ Version 2.0 - Feb 27, 1994
+ 	- Add memory probes for everything that can be accomplished by
+ 	  reading registers.  Nothing is currently using the physical
+ 	  memory probe.
+ 	- Bazillions of changes from vgadoc3.zip (thanks, Finn).  Added
+ 	  HMC, UMC, Weitek probes.  Added more chipsets for Cirrus,
+ 	  NCR, Oak, RealTek, S3, Trident, Tseng, Video7, WD.  Made some
+ 	  changes to the probes for ATI & Compaq.
diff -c mit/server/ddx/x386/SuperProbe/ChipsTech.c:2.2 mit/server/ddx/x386/SuperProbe/ChipsTech.c:2.4
*** mit/server/ddx/x386/SuperProbe/ChipsTech.c:2.2	Fri Mar 11 23:36:07 1994
--- mit/server/ddx/x386/SuperProbe/ChipsTech.c	Fri Mar 11 23:36:07 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/ChipsTech.c,v 2.2 1993/09/27 12:23:15 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/ChipsTech.c,v 2.4 1994/02/28 14:09:20 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 28,33 ****
--- 28,35 ----
  static Word Ports[] = {0x3D6, 0x3D7};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_CT __STDCARGS((int));
+ 
  Chip_Descriptor CT_Descriptor = {
  	"CT",
  	Probe_CT,
***************
*** 36,41 ****
--- 38,44 ----
  	FALSE,
  	FALSE,
  	TRUE,
+ 	MemProbe_CT,
  };
  
  #ifdef __STDC__
***************
*** 96,99 ****
--- 99,179 ----
  	}
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ static int MemProbe_CT(Chipset)
+ int Chipset;
+ {
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	switch (Chipset)
+ 	{
+ 	case CHIP_CT450:
+ 	case CHIP_CT456:
+ 		if (rdinx(0x3D6, 0x04) & 0x01)
+ 		{
+ 			Mem = 512;
+ 		}
+ 		else
+ 		{
+ 			Mem = 256;
+ 		}
+ 		break;
+ 	case CHIP_CT451:
+ 	case CHIP_CT455:
+ 	case CHIP_CT457:
+ 		Mem = 256;
+ 		break;
+ 	case CHIP_CT452:
+ 		switch (rdinx(0x3D6, 0x04) & 0x03)
+ 		{
+ 		case 0x00:
+ 			Mem = 256;
+ 			break;
+ 		case 0x01:
+ 			Mem = 512;
+ 			break;
+ 		case 0x02:
+ 			Mem = 1024;
+ 			break;
+ 		}
+ 		break;
+ 	case CHIP_CT453:
+ 		switch ((rdinx(0x3D6, 0x24) >> 1) & 0x03)
+ 		{
+ 		case 0x01:
+ 			Mem = 512;
+ 			break;
+ 		case 0x02:
+ 			Mem = 1024;
+ 			break;
+ 		case 0x03:
+ 			Mem = 256;
+ 			break;
+ 		}
+ 		break;
+ 	case CHIP_CTF65510:
+ 		Mem = 512;
+ 		break;
+ 	case CHIP_CTF65520:
+ 	case CHIP_CTF65530:
+ 		switch (rdinx(0x3D6, 0x04) & 0x03)
+ 		{
+ 		case 0x00:
+ 			Mem = 256;
+ 			break;
+ 		case 0x01:
+ 			Mem = 512;
+ 			break;
+ 		case 0x03:
+ 			Mem = 1024;
+ 			break;
+ 		}
+ 		break;
+ 	}
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/Cirrus.c:2.4 mit/server/ddx/x386/SuperProbe/Cirrus.c:2.7
*** mit/server/ddx/x386/SuperProbe/Cirrus.c:2.4	Fri Mar 11 23:36:07 1994
--- mit/server/ddx/x386/SuperProbe/Cirrus.c	Fri Mar 11 23:36:07 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,31 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Cirrus.c,v 2.4 1993/10/07 13:54:45 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, 0x3C4, 0x3C5, 0x3CE, 0x3CF};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Cirrus_Descriptor = {
--- 21,31 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Cirrus.c,v 2.7 1994/03/02 08:04:54 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, SEQ_IDX, SEQ_REG, GRC_IDX, GRC_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Cirrus_Descriptor = {
***************
*** 35,197 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
  #ifdef __STDC__
! Bool Probe_Cirrus(int *Chipset)
  #else
  Bool Probe_Cirrus(Chipset)
  int *Chipset;
! #endif
  {
  	Bool result = FALSE;
! 	Byte old, old1, tmp;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
! 	/*
! 	 * First the old Cirrus chips.
! 	 */
! 	old = rdinx(CRTC_IDX, 0x0C);
! 	old1 = rdinx(0x3C4, 0x06);
! 	wrinx(CRTC_IDX,0x0C,0);
! 	tmp = rdinx(CRTC_IDX, 0x1F);
! 	wrinx(0x3C4, 0x06, (tmp >> 4) | (tmp << 4));
! 	if (inp(0x3C5) == 0)
! 	{
! 		outp(0x3C5, tmp);
! 		if (inp(0x3C5) == 1)
! 		{
! 			result = TRUE;
! 			switch (tmp)
! 			{
! 			case 0xEC:
! 				*Chipset = CHIP_CL510;
! 				break;
! 			case 0xCA:
! 				*Chipset = CHIP_CL610;
! 				break;
! 			case 0xEA:
! 				*Chipset = CHIP_CLV7;
! 				break;
! 			default:
! 				Chip_data = tmp;
! 				*Chipset = CHIP_CL_UNKNOWN;
! 				break;
! 			}
! 		}
! 	}
! 	wrinx(0x3C4, 0x06, old1);
! 	wrinx(CRTC_IDX, 0x0C, old);
! 	/*
! 	 * Now the new Cirrus chips
! 	 */
! 	if (!result)
  	{
! 		old = rdinx(0x3C4, 0x06);
! 		wrinx(0x3C4, 0x06, 0x12);
! 		if ((rdinx(0x3C4, 0x06) == 0x12) &&
! 		    (testinx2(0x3C4, 0x1E, 0x3F)) &&
! 		    (testinx2(CRTC_IDX, 0x1B, 0xE3)))
  		{
! 			result = TRUE;
! 			if (testinx(CRTC_IDX, 0x21))
  			{
! 				/* 62x5 */
! 				tmp = rdinx(CRTC_IDX, 0x27);
! 				switch ((tmp & 0xF0) >> 4)
  				{
! 				case 0x00:
! 					*Chipset = CHIP_CL6205;
  					break;
! 				case 0x08:
! 					*Chipset = CHIP_CL6215;
! 					break;
! 				case 0x0C:
! 					*Chipset = CHIP_CL6225;
  					break;
! 				case 0x01:
! 					*Chipset = CHIP_CL6235;
  					break;
  				default:
! 					Chip_data = tmp;
  					*Chipset = CHIP_CL_UNKNOWN;
  					break;
  				}
  			}
! 			else
  			{
! 				/* 542x */
! 				tmp = rdinx(CRTC_IDX, 0x27);
! 				switch ((tmp & 0xFC) >> 2)
  				{
! 				case 0x22:
! 					switch (tmp & 0x03)
  					{
  					case 0x00:
! 						*Chipset = CHIP_CL5402;
  						break;
  					case 0x01:
! 						*Chipset = CHIP_CL5402R1;
  						break;
  					case 0x02:
! 						*Chipset = CHIP_CL5420;
  						break;
  					case 0x03:
! 						*Chipset = CHIP_CL5420R1;
  						break;
  					}
  					break;
! 				case 0x23:
! 					*Chipset = CHIP_CL5422;
  					break;
! 				case 0x25:
! 					*Chipset = CHIP_CL5424;
  					break;
! 				case 0x24:
! 					*Chipset = CHIP_CL5426;
  					break;
! 				case 0x26:
! 					*Chipset = CHIP_CL5428;
  					break;
  				default:
! 					Chip_data = tmp;
  					*Chipset = CHIP_CL_UNKNOWN;
  					break;
  				}
  			}
  		}
! 		wrinx(0x3C4, 0x06, old);
  	}
! 	if (!result)
  	{
! 		old = rdinx(0x3CE, 0x0A);
! 		wrinx(0x3CE, 0x0A, 0xEC);
! 		if (rdinx(0x3CE, 0x0A) == 0x01)
  		{
! 			result = TRUE;
! 			if (rdinx(0x3CE, 0xAB) == 0x6F)
! 			{
! 				/* 6420 */
! 				if (testinx2(0x3CE, 0x87, 0x90))
! 				{
! 					*Chipset = CHIP_CL6420B;
! 				}
! 				else
! 				{
! 					*Chipset = CHIP_CL6420A;
! 				}
! 			}
! 			else
! 			{
! 				*Chipset = CHIP_CL6410;	/* I think */
! 			}
  		}
! 		wrinx(0x3CE, 0x0A, old);
  	}
  	DisableIOPorts(NUMPORTS, Ports);
! 	return(result);
  }
--- 35,376 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	NULL,
  };
  
+ static int MemProbe_Cirrus54 __STDCARGS((int));
+ 
+ Chip_Descriptor Cirrus54_Descriptor = {
+ 	"Cirrus54",
+ 	Probe_Cirrus54,
+ 	Ports,
+ 	NUMPORTS,
+ 	FALSE,
+ 	FALSE,
+ 	TRUE,
+ 	MemProbe_Cirrus54,
+ };
+ 
+ static int MemProbe_Cirrus64 __STDCARGS((int));
+ 
+ Chip_Descriptor Cirrus64_Descriptor = {
+ 	"Cirrus64",
+ 	Probe_Cirrus64,
+ 	Ports,
+ 	NUMPORTS,
+ 	FALSE,
+ 	FALSE,
+ 	TRUE,
+ 	MemProbe_Cirrus64,
+ };
+ 
+ #define CLASS_OLD	0
+ #define CLASS_54XX	1
+ #define CLASS_64XX	2
+ 
  #ifdef __STDC__
! static Bool Probe_Cirrus_Class(int *, int);
  #else
+ static Bool Probe_Cirrus_Class();
+ #endif
+ 
  Bool Probe_Cirrus(Chipset)
  int *Chipset;
! {
! 	return(Probe_Cirrus_Class(Chipset, CLASS_OLD));
! }
! 
! Bool Probe_Cirrus54(Chipset)
! int *Chipset;
! {
! 	return(Probe_Cirrus_Class(Chipset, CLASS_54XX));
! }
! 
! Bool Probe_Cirrus64(Chipset)
! int *Chipset;
! {
! 	return(Probe_Cirrus_Class(Chipset, CLASS_64XX));
! }
! 
! static Bool Probe_Cirrus_Class(Chipset, Class)
! int *Chipset;
! int Class;
  {
  	Bool result = FALSE;
! 	Byte old, old1, Ver;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
! 
! 	if (Class == CLASS_OLD)
  	{
! 		old = rdinx(CRTC_IDX, 0x0C);
! 		old1 = rdinx(SEQ_IDX, 0x06);
! 		wrinx(CRTC_IDX,0x0C,0);
! 		Ver = rdinx(CRTC_IDX, 0x1F);
! 		wrinx(SEQ_IDX, 0x06, (Ver >> 4) | (Ver << 4));
! 		if (inp(SEQ_REG) == 0)
  		{
! 			outp(SEQ_REG, Ver);
! 			if (inp(SEQ_REG) == 1)
  			{
! 				result = TRUE;
! 				switch (Ver)
  				{
! 				case 0xEC:
! 					*Chipset = CHIP_CL510;
  					break;
! 				case 0xCA:
! 					*Chipset = CHIP_CL610;
  					break;
! 				case 0xEA:
! 					*Chipset = CHIP_CLV7;
  					break;
  				default:
! 					Chip_data = Ver;
  					*Chipset = CHIP_CL_UNKNOWN;
  					break;
  				}
  			}
! 		}
! 		wrinx(SEQ_IDX, 0x06, old1);
! 		wrinx(CRTC_IDX, 0x0C, old);
! 	}
! 	else if (Class == CLASS_54XX)
! 	{
! 		/*
! 		 * Cirrus 542x, 543x, 62x5 chips
! 	 	 */
! 		old = rdinx(SEQ_IDX, 0x06);
! 		wrinx(SEQ_IDX, 0x06, 0x00);
! 		if (rdinx(SEQ_IDX, 0x06) == 0x0F)
! 		{
! 			wrinx(SEQ_IDX, 0x06, 0x12);
! 			if ((rdinx(SEQ_IDX, 0x06) == 0x12) &&
! 		    	    (testinx2(SEQ_IDX, 0x1E, 0x3F)))
  			{
! 				result = TRUE;
! 				Ver = rdinx(CRTC_IDX, 0x27);
! 				if (testinx(CRTC_IDX, 0x09))
! 				{
! 					/* 542x */
! 					switch ((Ver & 0xFC) >> 2)
! 					{
! 					case 0x02:
! 						*Chipset = CHIP_CLAVGA2;
! 						break;
! 					case 0x22:
! 						switch (Ver & 0x03)
! 						{
! 						case 0x00:
! 							*Chipset=CHIP_CL5402;
! 							break;
! 						case 0x01:
! 							*Chipset=CHIP_CL5402R1;
! 							break;
! 						case 0x02:
! 							*Chipset=CHIP_CL5420;
! 							break;
! 						case 0x03:
! 							*Chipset=CHIP_CL5420R1;
! 							break;
! 						}
! 						break;
! 					case 0x23:
! 						*Chipset = CHIP_CL5422;
! 						break;
! 					case 0x25:
! 						*Chipset = CHIP_CL5424;
! 						break;
! 					case 0x24:
! 						*Chipset = CHIP_CL5426;
! 						break;
! 					case 0x26:
! 						*Chipset = CHIP_CL5428;
! 						break;
! 					case 0x29:
! 						*Chipset = CHIP_CL543X;
! 						break;
! 					default:
! 						Chip_data = Ver;
! 						*Chipset = CHIP_CL_UNKNOWN;
! 						break;
! 					}
! 				}
! 				else if (testinx(SEQ_IDX, 0x19))
  				{
! 					/* 62x5 */
! 					switch ((Ver & 0xC0) >> 6)
  					{
  					case 0x00:
! 						*Chipset = CHIP_CL6205;
  						break;
  					case 0x01:
! 						*Chipset = CHIP_CL6235;
  						break;
  					case 0x02:
! 						*Chipset = CHIP_CL6215;
  						break;
  					case 0x03:
! 						*Chipset = CHIP_CL6225;
  						break;
  					}
+ 				}
+ 				else
+ 				{
+ 					*Chipset = CHIP_CLAVGA2;
+ 				}
+ 			}
+ 		}
+ 		wrinx(SEQ_IDX, 0x06, old);
+ 	}
+ 	else
+ 	{
+ 		/*
+ 		 * The Cirrus 64xx chips.
+ 	 	 */
+ 		old = rdinx(GRC_IDX, 0x0A);
+ 		wrinx(GRC_IDX, 0x0A, 0xCE);
+ 		if (rdinx(GRC_IDX, 0x0A) == 0x00)
+ 		{
+ 			wrinx(GRC_IDX, 0x0A, 0xEC);
+ 			if (rdinx(GRC_IDX, 0x0A) == 0x01)
+ 			{
+ 				result = TRUE;
+ 				Ver = rdinx(GRC_IDX, 0xAA);
+ 				switch ((Ver & 0xF0) >> 4)
+ 				{
+ 				case 0x04:
+ 					*Chipset = CHIP_CL6440;
  					break;
! 				case 0x05:
! 					*Chipset = CHIP_CL6412;
  					break;
! 				case 0x06:
! 					*Chipset = CHIP_CL5410;
  					break;
! 				case 0x07:
! 					if (testinx2(0x3CE, 0x87, 0x90))
! 					{
! 						*Chipset = CHIP_CL6420B;
! 					}
! 					else
! 					{
! 						*Chipset = CHIP_CL6420A;
! 					}
  					break;
! 				case 0x08:
! 					*Chipset = CHIP_CL6410;	
  					break;
  				default:
! 					Chip_data = Ver;
  					*Chipset = CHIP_CL_UNKNOWN;
  					break;
  				}
  			}
  		}
! 		wrinx(GRC_IDX, 0x0A, old);
  	}
! 
! 	DisableIOPorts(NUMPORTS, Ports);
! 	return(result);
! }
! 
! static int MemProbe_Cirrus54(Chipset)
! int Chipset;
! {
! 	Byte old;
! 	int Mem = 0;
! 
! 	EnableIOPorts(NUMPORTS, Ports);
! 
! 	/*
! 	 * Unlock
! 	 */
! 	old = rdinx(SEQ_IDX, 0x06);
! 	wrinx(SEQ_IDX, 0x06, 0x12);
! 
! 	/*
! 	 * Check
! 	 */
! 	switch (Chipset)
  	{
! 	case CHIP_CL6205:
! 	case CHIP_CL6215:
! 	case CHIP_CL6225:
! 	case CHIP_CL6235:
! 		Mem = 512;
! 		break;
! 	default:
! 		switch ((rdinx(SEQ_IDX, 0x0A) & 0x18) >> 3)
  		{
! 		case 0x00:
! 			Mem = 256;
! 			break;
! 		case 0x01:
! 			Mem = 512;
! 			break;
! 		case 0x02:
! 			Mem = 1024;
! 			break;
! 		case 0x03:
! 			Mem = 2048;
! 			break;
  		}
! 		break;
  	}
+ 
+ 	/*
+ 	 * Lock
+ 	 */
+ 	wrinx(SEQ_IDX, 0x06, old);
+ 
  	DisableIOPorts(NUMPORTS, Ports);
! 	return(Mem);
! }
! 
! /* ARGSUSED */
! static int MemProbe_Cirrus64(Chipset)
! int Chipset;
! {
! 	Byte old;
! 	int Mem = 0;
! 
! 	EnableIOPorts(NUMPORTS, Ports);
! 
! 	/*
! 	 * Unlock
! 	 */
! 	old = rdinx(GRC_IDX, 0x0A);
! 	wrinx(GRC_IDX, 0x0A, 0xEC);
! 
! 	/*
! 	 * Check
! 	 */
! 	switch (rdinx(GRC_IDX, 0xBB) >> 6)
! 	{
! 	case 0x00:
! 		Mem = 256;
! 		break;
! 	case 0x01:
! 		Mem = 512;
! 		break;
! 	case 0x02:
! 		Mem = 768;
! 		break;
! 	case 0x03:
! 		Mem = 1024;
! 		break;
! 	}
! 
! 	/*
! 	 * Lock
! 	 */
! 	wrinx(GRC_IDX, 0x0A, old);
! 
! 	DisableIOPorts(NUMPORTS, Ports);
! 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/Compaq.c:2.3 mit/server/ddx/x386/SuperProbe/Compaq.c:2.6
*** mit/server/ddx/x386/SuperProbe/Compaq.c:2.3	Fri Mar 11 23:36:08 1994
--- mit/server/ddx/x386/SuperProbe/Compaq.c	Fri Mar 11 23:36:08 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,136 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Compaq.c,v 2.3 1993/09/27 12:23:17 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x3CE, 0x3CF, 0x33C8, 0x53C8};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Compaq_Descriptor = {
  	"Compaq",
  	Probe_Compaq,
  	Ports,
  	NUMPORTS,
! 	TRUE,
! 	TRUE,
! 	FALSE
  };
  
- #ifdef __STDC__
- Bool Probe_Compaq(int *Chipset)
- #else
  Bool Probe_Compaq(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
! 	Byte addr, bios[6];
! 	Byte *signature = (Byte *)"COMPAQ";
! 	Byte old, old1, old2, old3;
! 	Byte tmp, tmp1;
! 	Word port;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 	if (ReadBIOS(0x02, &addr, 1) != 1)
! 	{
! 		fprintf(stderr, "%s: Failed to find get Compaq BIOS address\n",
! 			MyName);
! 		return(FALSE);
! 	}
! 	if (addr > 64)
! 	{
! 		/* Out of range */
! 		return(FALSE);
! 	}
! 	if (ReadBIOS((unsigned)((addr<<9)-0x16), bios, 6) != 6)
! 	{
! 		fprintf(stderr, "%s: Failed to read Compaq BIOS signature\n",
! 			MyName);
! 		return(FALSE);
! 	}
! 	if (memcmp(bios, signature, 6) == 0)
  	{
! 		old = rdinx(0x3CE, 0x00);
! 		old1 = rdinx(0x3CE, 0x03);
! 		old2 = rdinx(0x3CE, 0x0F);
! 		wrinx(0x3CE, 0x0F, 0x05);
! 		old3 = rdinx(0x3CE, 0x10);
! 		tmp = old3 & 0x0F; 
! 		wrinx(0x3CE, 0x00, ~old);
! 		tmp1 = rdinx(0x3CE, 0x10) & 0x0F;
! 		if ((tmp != old) || (tmp1 != ~old))
  		{
! 			wrinx(0x3CE, 0x10, old3 | 0x08);
! 			port = (old3 & 0x04) ? 0x53C8 : 0x33C8;
! 			tmp = inp(port);
! 			wrinx(0x3CE, 0x03, (~old1 & 0x07));
! 			tmp1 = inp(port);
! 			if (tmp == (old1 & 0x07) && (tmp1 == (~old1 & 0x07)))
  			{
! 				/*
! 				 * OK.  It's an AVGA or QVision.  Let's
! 				 * see which one.
! 				 */
! 				result = TRUE;
! 				tmp = rdinx(0x3CE, 0x0C);
! 				tmp1 = (tmp & 0xF8) >> 3;
! 				switch (tmp1)
  				{
- 				case 0x05:
- 				case 0x10:
- 					*Chipset = CHIP_CPQ_AVGA;
- 					break;
- 				case 0x06:
  					*Chipset = CHIP_CPQ_Q1024;
- 					break;
- 				case 0x0E:
- 					/*
- 					 * QVision.  Now see which one.
- 					 */
- 					tmp = rdinx(0x3CE, 0x56);
- 					if (tmp & 0x04)
- 					{
- 						*Chipset = CHIP_CPQ_Q1280;
- 					}
- 					else
- 					{
- 						*Chipset = CHIP_CPQ_Q1024;
- 					}
- 					break;
- 				default:
- 					Chip_data = tmp1;
- 					*Chipset = CHIP_CPQ_UNK;
- 					break;
  				}
  			}
  		}
- 		wrinx(0x3CE, 0x10, old3);
- 		wrinx(0x3CE, 0x0F, old2);
- 		wrinx(0x3CE, 0x03, old1);
- 		wrinx(0x3CE, 0x00, old);
  	}
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
--- 21,152 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Compaq.c,v 2.6 1994/03/02 08:04:55 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {GRC_IDX, GRC_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_Compaq __STDCARGS((int));
+ 
  Chip_Descriptor Compaq_Descriptor = {
  	"Compaq",
  	Probe_Compaq,
  	Ports,
  	NUMPORTS,
! 	FALSE,
! 	FALSE,
! 	FALSE,
! 	MemProbe_Compaq,
  };
  
  Bool Probe_Compaq(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
! 	Byte old, ver;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 
! 	old = rdinx(GRC_IDX, 0x0F);
! 	wrinx(GRC_IDX, 0x0F, 0x00);
! 	if (!testinx(GRC_IDX, 0x45))
  	{
! 		wrinx(GRC_IDX, 0x0F, 0x05);
! 		if (testinx(GRC_IDX, 0x45))
  		{
! 			result = TRUE;
! 			ver = rdinx(GRC_IDX, 0x0C) >> 3;
! 			switch (ver)
  			{
! 			case 0x03:
! 				*Chipset = CHIP_CPQ_IVGS;
! 				break;
! 			case 0x05:
! 				*Chipset = CHIP_CPQ_AVGA;
! 				break;
! 			case 0x06:
! 				*Chipset = CHIP_CPQ_Q1024;
! 				break;
! 			case 0x0E:
! 				if (rdinx(GRC_IDX, 0x56) & 0x04)
! 				{
! 					*Chipset = CHIP_CPQ_Q1280;
! 				}
! 				else
  				{
  					*Chipset = CHIP_CPQ_Q1024;
  				}
+ 				break;
+ 			case 0x10:
+ 				*Chipset = CHIP_CPQ_AVGA_P;
+ 				break;
+ 			default:
+ 				Chip_data = ver >> 3;
+ 				*Chipset = CHIP_CPQ_UNK;
+ 				break;
  			}
  		}
  	}
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ static int MemProbe_Compaq(Chipset)
+ int Chipset;
+ {
+ 	Byte old, temp;
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Unlock.
+ 	 */
+ 	old = rdinx(GRC_IDX, 0x0F);
+ 	wrinx(GRC_IDX, 0x0F, 0x05);
+ 
+ 	/*
+ 	 * Check
+ 	 */
+ 	switch (Chipset)
+ 	{
+ 	case CHIP_CPQ_IVGS:
+ 		Mem = 256;
+ 		break;
+ 	case CHIP_CPQ_AVGA:
+ 	case CHIP_CPQ_AVGA_P:
+ 		Mem = 512;
+ 		break;
+ 	case CHIP_CPQ_Q1024:
+ 	case CHIP_CPQ_Q1280:
+ 		temp = rdinx(GRC_IDX, 0x0F);
+ 		wrinx(GRC_IDX, 0x0F, 0x05);
+ 		switch (rdinx(GRC_IDX, 0x54))
+ 		{
+ 		case 0x00:
+ 			Mem = 1024;
+ 			break;
+ 		case 0x02:
+ 			Mem = 512;
+ 			break;
+ 		case 0x04:
+ 			Mem = 1024;
+ 			break;
+ 		case 0x08:
+ 			Mem = 2048;
+ 			break;
+ 		}
+ 		wrinx(GRC_IDX, 0x0F, temp);
+ 		break;
+ 	}
+ 
+ 	/*
+ 	 * Lock 
+ 	 */
+ 	wrinx(GRC_IDX, 0x0F, 0x05);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/Genoa.c:2.1 mit/server/ddx/x386/SuperProbe/Genoa.c:2.3
*** mit/server/ddx/x386/SuperProbe/Genoa.c:2.1	Fri Mar 11 23:36:09 1994
--- mit/server/ddx/x386/SuperProbe/Genoa.c	Fri Mar 11 23:36:09 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,30 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Genoa.c,v 2.1 1993/09/21 15:20:33 dawes Exp $ */
  
  #include "Probe.h"
  
  Chip_Descriptor Genoa_Descriptor = {
  	"Genoa",
  	Probe_Genoa,
--- 21,32 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Genoa.c,v 2.3 1994/02/28 14:09:23 dawes Exp $ */
  
  #include "Probe.h"
  
+ static int MemProbe_Genoa __STDCARGS((int));
+ 
  Chip_Descriptor Genoa_Descriptor = {
  	"Genoa",
  	Probe_Genoa,
***************
*** 32,46 ****
  	0,
  	FALSE,
  	TRUE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Genoa(int *Chipset)
- #else
  Bool Probe_Genoa(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte addr, data[4];
--- 34,45 ----
  	0,
  	FALSE,
  	TRUE,
! 	TRUE,
! 	MemProbe_Genoa,
  };
  
  Bool Probe_Genoa(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  	Byte addr, data[4];
***************
*** 82,85 ****
--- 81,103 ----
  		}
  	}
  	return(result);
+ }
+ 
+ static int MemProbe_Genoa(Chipset)
+ int Chipset;
+ {
+ 	int Mem = 0;
+ 
+ 	switch (Chipset)
+ 	{
+ 	case CHIP_G_6100:
+ 	case CHIP_G_6200:
+ 		Mem = 256;
+ 		break;
+ 	case CHIP_G_6400:
+ 		Mem = 512;
+ 		break;
+ 	}
+ 
+ 	return(Mem);
  }
diff -c /dev/null mit/server/ddx/x386/SuperProbe/HMC.c:2.0
*** /dev/null	Fri Mar 11 23:36:09 1994
--- mit/server/ddx/x386/SuperProbe/HMC.c	Fri Mar 11 23:36:09 1994
***************
*** 0 ****
--- 1,80 ----
+ /*
+  * Copyright 1994 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/SuperProbe/HMC.c,v 2.0 1994/02/28 14:09:25 dawes Exp $ */
+ 
+ #include "Probe.h"
+ 
+ static Word Ports[] = {SEQ_IDX, SEQ_REG};
+ #define NUMPORTS (sizeof(Ports)/sizeof(Word))
+ 
+ static int MemProbe_HMC __STDCARGS((int));
+ 
+ Chip_Descriptor HMC_Descriptor = {
+ 	"HMC",
+ 	Probe_HMC,
+ 	Ports,
+ 	NUMPORTS,
+ 	FALSE,
+ 	FALSE,
+ 	TRUE,
+ 	MemProbe_HMC,
+ };
+ 
+ Bool Probe_HMC(Chipset)
+ int *Chipset;
+ {
+ 	Bool result = FALSE;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	if (testinx(SEQ_IDX, 0xE7) && testinx(SEQ_IDX, 0xEE))
+ 	{
+ 		result = TRUE;
+ 		*Chipset = CHIP_HM86304;
+ 	}
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(result);
+ }
+ 
+ /* ARGSUSED */
+ static int MemProbe_HMC(Chipset)
+ int Chipset;
+ {
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	if (rdinx(SEQ_IDX, 0xE7) & 0x10)
+ 	{
+ 		Mem = 512;
+ 	}
+ 	else
+ 	{
+ 		Mem = 256;
+ 	}
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
+ }
diff -c mit/server/ddx/x386/SuperProbe/Herc.c:1.2 mit/server/ddx/x386/SuperProbe/Herc.c:2.0
*** mit/server/ddx/x386/SuperProbe/Herc.c:1.2	Fri Mar 11 23:36:10 1994
--- mit/server/ddx/x386/SuperProbe/Herc.c	Fri Mar 11 23:36:10 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Herc.c,v 1.2 1993/05/04 10:16:55 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Herc.c,v 2.0 1994/02/28 14:09:26 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 31,42 ****
  #define DSP_VSYNC_MASK 0x80
  #define DSP_ID_MASK 0x70
  
- #ifdef __STDC__
- Bool Probe_Herc(int *Chipset)
- #else
  Bool Probe_Herc(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	int i, cnt = 0;
--- 31,38 ----
diff -c mit/server/ddx/x386/SuperProbe/Imakefile:2.0 mit/server/ddx/x386/SuperProbe/Imakefile:2.4
*** mit/server/ddx/x386/SuperProbe/Imakefile:2.0	Fri Mar 11 23:36:10 1994
--- mit/server/ddx/x386/SuperProbe/Imakefile	Fri Mar 11 23:36:10 1994
***************
*** 1,8 ****
! XCOMM $XFree86: mit/server/ddx/x386/SuperProbe/Imakefile,v 2.0 1993/07/25 05:49:03 dawes Exp $
  
  #if defined(i386SVR3Architecture) || defined(i386SVR4Architecture)
  # define OSModule OS_SYSV
  #endif
  #if defined(LinuxArchitecture)
  # define OSModule OS_Linux
  #endif
--- 1,13 ----
! XCOMM $XFree86: mit/server/ddx/x386/SuperProbe/Imakefile,v 2.4 1994/02/28 14:09:27 dawes Exp $
  
  #if defined(i386SVR3Architecture) || defined(i386SVR4Architecture)
  # define OSModule OS_SYSV
  #endif
+ #if defined(i386SVR4Solarisx86) && !HasGcc
+ # include <Server.tmpl>
+   OS_IO_SRC = SolX86IO.s
+   OS_IO_OBJ = SolX86IO.o
+ #endif
  #if defined(LinuxArchitecture)
  # define OSModule OS_Linux
  #endif
***************
*** 22,37 ****
  # define OSModule OS_Mach
  #endif
  
! OS_SRC = OSModule.c
! OS_OBJ = OSModule.o
! BASE_SRC = MDA.c Herc.c CGA.c VGA.c RamDac.c 
! BASE_OBJ = MDA.o Herc.o CGA.o VGA.o RamDac.o 
  SVGA_SRC = Tseng.c WD.c ChipsTech.c Video7.c Genoa.c Trident.c Oak.c \
! 	   Cirrus.c Ahead.c ATI.c S3.c AL.c Yamaha.c NCR.c AcuMos.c MX.c \
! 	   RealTek.c Primus.c Compaq.c
  SVGA_OBJ = Tseng.o WD.o ChipsTech.o Video7.o Genoa.o Trident.o Oak.o \
! 	   Cirrus.o Ahead.o ATI.o S3.o AL.o Yamaha.o NCR.o AcuMos.o MX.o \
! 	   RealTek.o Primus.o Compaq.o
  COPROC_SRC = 8514.c ATIMach.c
  COPROC_OBJ = 8514.o ATIMach.o
  SRCS = Main.c $(SVGA_SRC) $(COPROC_SRC) $(BASE_SRC) Print.c Utils.c $(OS_SRC)
--- 27,42 ----
  # define OSModule OS_Mach
  #endif
  
! OS_SRC = OSModule.c $(OS_IO_SRC)
! OS_OBJ = OSModule.o $(OS_IO_OBJ)
! BASE_SRC = MDA.c Herc.c CGA.c VGA.c RamDac.c MemProbe.c
! BASE_OBJ = MDA.o Herc.o CGA.o VGA.o RamDac.o MemProbe.o
  SVGA_SRC = Tseng.c WD.c ChipsTech.c Video7.c Genoa.c Trident.c Oak.c \
! 	   Cirrus.c Ahead.c ATI.c S3.c AL.c Yamaha.c NCR.c MX.c \
! 	   RealTek.c Primus.c Compaq.c HMC.c UMC.c Weitek.c
  SVGA_OBJ = Tseng.o WD.o ChipsTech.o Video7.o Genoa.o Trident.o Oak.o \
! 	   Cirrus.o Ahead.o ATI.o S3.o AL.o Yamaha.o NCR.o MX.o \
! 	   RealTek.o Primus.o Compaq.o HMC.o UMC.o Weitek.o
  COPROC_SRC = 8514.c ATIMach.c
  COPROC_OBJ = 8514.o ATIMach.o
  SRCS = Main.c $(SVGA_SRC) $(COPROC_SRC) $(BASE_SRC) Print.c Utils.c $(OS_SRC)
diff -c mit/server/ddx/x386/SuperProbe/MDA.c:1.2 mit/server/ddx/x386/SuperProbe/MDA.c:2.0
*** mit/server/ddx/x386/SuperProbe/MDA.c:1.2	Fri Mar 11 23:36:11 1994
--- mit/server/ddx/x386/SuperProbe/MDA.c	Fri Mar 11 23:36:11 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/MDA.c,v 1.2 1993/05/04 10:16:57 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/MDA.c,v 2.0 1994/02/28 14:09:28 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 33,44 ****
  static Word Ports[] = {0x3B4, 0x3B5};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
- #ifdef __STDC__
- Bool Probe_MDA(int *Chipset)
- #else
  Bool Probe_MDA(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte tmp;
--- 33,40 ----
diff -c mit/server/ddx/x386/SuperProbe/MX.c:2.1 mit/server/ddx/x386/SuperProbe/MX.c:2.4
*** mit/server/ddx/x386/SuperProbe/MX.c:2.1	Fri Mar 11 23:36:11 1994
--- mit/server/ddx/x386/SuperProbe/MX.c	Fri Mar 11 23:36:11 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,33 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/MX.c,v 2.1 1993/09/21 15:20:34 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x3C4, 0x3C5};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor MX_Descriptor = {
  	"MX",
  	Probe_MX,
--- 21,35 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/MX.c,v 2.4 1994/03/02 08:04:56 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {SEQ_REG, SEQ_IDX};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_MX __STDCARGS((int));
+ 
  Chip_Descriptor MX_Descriptor = {
  	"MX",
  	Probe_MX,
***************
*** 35,66 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_MX(int *Chipset)
- #else
  Bool Probe_MX(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte old;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 	old = rdinx(0x3C4, 0xA7);
! 	wrinx(0x3C4, 0xA7, 0x00);
! 	if (!testinx(0x3C4, 0xC5))
  	{
! 		wrinx(0x3C4, 0xA7, 0x87);
! 		if (testinx(0x3C4, 0xC5))
  		{
  			result = TRUE;
! 			*Chipset = CHIP_MX68010;
  		}
  	}
! 	wrinx(0x3C4, 0xA7, old);
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
--- 37,114 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_MX,
  };
  
  Bool Probe_MX(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  	Byte old;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 
! 	old = rdinx(SEQ_IDX, 0xA7);
! 	wrinx(SEQ_IDX, 0xA7, 0x00);
! 	if (!testinx(SEQ_IDX, 0xC5))
  	{
! 		wrinx(SEQ_IDX, 0xA7, 0x87);
! 		if (testinx(SEQ_IDX, 0xC5))
  		{
  			result = TRUE;
! 			if ((rdinx(SEQ_IDX, 0x26) & 0x01) == 0)
! 			{
! 				*Chipset = CHIP_MX68010;
! 			}
! 			else
! 			{
! 				*Chipset = CHIP_MX68000;
! 			}
  		}
  	}
! 	wrinx(SEQ_IDX, 0xA7, old);
! 
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ /* ARGSUSED */
+ static int MemProbe_MX(Chipset)
+ int Chipset;
+ {
+ 	Byte old;
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Unlock
+ 	 */
+ 	old = rdinx(SEQ_IDX, 0xA7);
+ 	wrinx(SEQ_IDX, 0xA7, 0x87);
+ 
+ 	/*
+ 	 * Check
+ 	 */
+ 	switch ((rdinx(SEQ_IDX, 0xC2) >> 2) & 0x03)
+ 	{
+ 	case 0x00:
+ 		Mem = 256;
+ 		break;
+ 	case 0x01:
+ 		Mem = 512;
+ 		break;
+ 	case 0x02:	
+ 		Mem = 1024;
+ 		break;
+ 	}
+ 
+ 	/*
+ 	 * Lock
+ 	 */
+ 	wrinx(SEQ_IDX, 0xA7, old);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/Main.c:2.4 mit/server/ddx/x386/SuperProbe/Main.c:2.7
*** mit/server/ddx/x386/SuperProbe/Main.c:2.4	Fri Mar 11 23:36:12 1994
--- mit/server/ddx/x386/SuperProbe/Main.c	Fri Mar 11 23:36:12 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Main.c,v 2.4 1993/10/07 13:54:46 dawes Exp $ */
  
  #include "Probe.h"
  #include "PatchLevel.h"
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Main.c,v 2.7 1994/03/05 01:58:46 dawes Exp $ */
  
  #include "Probe.h"
  #include "PatchLevel.h"
***************
*** 44,68 ****
  static Chip_Descriptor *SVGA_Descriptors[] = {
      &WD_Descriptor,
      &Video7_Descriptor,
      &Genoa_Descriptor,
      &Trident_Descriptor,
      &ATI_Descriptor,
      &Ahead_Descriptor,
      &NCR_Descriptor,
      &S3_Descriptor,
!     &Cirrus_Descriptor,
!     &MX_Descriptor,
!     &AcuMos_Descriptor,
      &Tseng_Descriptor,
      &RealTek_Descriptor,
      &Primus_Descriptor,
      &Yamaha_Descriptor,
      &Oak_Descriptor,
      &Compaq_Descriptor,
      &CT_Descriptor, /* I think this is screwing people up, so put it last */
- #if 0
-     &AL_Descriptor, /* I think this is dangerous, & no one has heard of it */
- #endif
      NULL
  };
  
--- 44,70 ----
  static Chip_Descriptor *SVGA_Descriptors[] = {
      &WD_Descriptor,
      &Video7_Descriptor,
+     &MX_Descriptor,
      &Genoa_Descriptor,
+     &UMC_Descriptor,
      &Trident_Descriptor,
      &ATI_Descriptor,
      &Ahead_Descriptor,
      &NCR_Descriptor,
      &S3_Descriptor,
!     &AL_Descriptor,
!     &Cirrus54_Descriptor,
!     &Cirrus64_Descriptor,
!     &Weitek_Descriptor,
      &Tseng_Descriptor,
      &RealTek_Descriptor,
      &Primus_Descriptor,
      &Yamaha_Descriptor,
      &Oak_Descriptor,
+     &Cirrus_Descriptor,
      &Compaq_Descriptor,
+     &HMC_Descriptor,
      &CT_Descriptor, /* I think this is screwing people up, so put it last */
      NULL
  };
  
***************
*** 72,77 ****
--- 74,85 ----
      NULL
  };
  
+ static int num_tokens __STDCARGS((char *, char));
+ static void ParseExclusionList __STDCARGS((Range *, char *));
+ static Bool TestChip __STDCARGS((Chip_Descriptor *, int *));
+ static void PrintInfo __STDCARGS((void));
+ static Byte *FindBios __STDCARGS((void));
+ 
  #ifdef __STDC__
  static int num_tokens(char *list, char delim)
  #else
***************
*** 91,103 ****
      return(cnt);
  }
  
- #ifdef __STDC__
- static void ParseExclusionList(Range *excl_list, char *list)
- #else
  static void ParseExclusionList(excl_list, list)
  Range *excl_list;
  char *list;
- #endif
  {
      char *p = list, *p1, c;
      Bool done = FALSE, lo = TRUE;
--- 99,107 ----
***************
*** 170,182 ****
      excl_list[i].lo = (Word)-1;
  }
  
- #ifdef __STDC__
- static Bool TestChip(Chip_Descriptor *chip_p, int *Chipset)
- #else
  static Bool TestChip(chip_p, Chipset)
  Chip_Descriptor *chip_p;
  int *Chipset;
- #endif
  {
      char *p, *p1, name[64];
  
--- 174,182 ----
***************
*** 247,257 ****
      return(FALSE);
  }
  
- #ifdef __STDC__
- static void PrintInfo(void)
- #else
  static void PrintInfo()
- #endif
  {
      Chip_Descriptor *chip_p;
      int i, len;
--- 247,253 ----
***************
*** 291,303 ****
          printf("%s, ", chip_p->name);
      }
      putchar('\n');
  }
  
- #ifdef __STDC__
- static Byte *FindBios(void)
- #else
  static Byte *FindBios()
- #endif
  {
      int i, score[7];
      Byte buf[3];
--- 287,309 ----
          printf("%s, ", chip_p->name);
      }
      putchar('\n');
+     printf("%s can detect the following RAMDACs:\n", MyName);
+     len = 0;
+     putchar('\t');
+     for (i=0; i < DAC_MAX; i++)
+     {
+ 	len += strlen(RamDac_Names[i+1].Short) + 2;
+ 	if (len > 70)
+ 	{
+ 	    printf("\n\t");
+ 	    len = strlen(RamDac_Names[i+1].Short) + 2;
+ 	}
+         printf("%s, ", RamDac_Names[i+1].Short);
+     }
+     putchar('\n');
  }
  
  static Byte *FindBios()
  {
      int i, score[7];
      Byte buf[3];
***************
*** 329,341 ****
      return(base);
  }
  
- #ifdef __STDC__
- int main(int argc, char *argv[])
- #else
  int main(argc, argv)
  int argc;
  char *argv[];
- #endif
  {
      char *p, *order = NULL;
      Byte copyright[3];
--- 335,343 ----
***************
*** 344,351 ****
--- 346,359 ----
      int Secondary = -1;
      int RamDac = -1;
      int CoProc = -1;
+     int MemVGA = -1;
+     int MemCoProc = -1;
      int i, cnt;
      Chip_Descriptor *chip_p, *matched;
+     Bool Probe_DAC = TRUE;
+     Bool Probe_Mem = TRUE;
+     Bool NoEGA = FALSE;
+     Bool Check_CoProc;
      Bool flag;
  
      p = strrchr(argv[0], '/');
***************
*** 444,449 ****
--- 452,465 ----
  	{
  	    NoBIOS = TRUE;
  	}
+ 	else if (strncmp(argv[i], "-no_dac", 7) == 0)
+ 	{
+ 	    Probe_DAC = FALSE;
+ 	}
+ 	else if (strncmp(argv[i], "-no_mem", 7) == 0)
+ 	{
+ 	    Probe_Mem = FALSE;
+ 	}
  	else if (strncmp(argv[i], "-in", 3) == 0)
  	{
  	    PrintInfo();
***************
*** 464,469 ****
--- 480,487 ----
  	    printf("\t-noprobe list\tDon't probe for any chipsets specified\n");
  	    printf("\t-bios base\tSet BIOS base address to 'base'\n");
  	    printf("\t-no_bios\tDon't read BIOS & assume EGA/VGA as primary\n");
+ 	    printf("\t-no_dac\t\tDon't probe for RAMDAC type\n");
+ 	    printf("\t-no_mem\t\tDon't probe for video memory\n");
  	    printf("\t-info\t\tPrint a list of the capabilities of %s\n",
  		   MyName);
  	    printf("\nRefer to the manual page '%s.1' for complete details\n",
***************
*** 478,510 ****
      }
  
      PRINT_VERSION;
!     printf("\tCopyright 1993 by David Wexelblat <dwex@goblin.org>\n");
!     printf("\n\tThis work is derived from the 'vgadoc2.zip' documentation\n");
!     printf("\tpackage produced by Finn Thoergersen, and released with\n");
!     printf("\tall appropriate permissions having been obtained.  Additional\n");
!     printf("\tinformation obtained from 'Programmer's Guide to the EGA and\n");
!     printf("\tVGA, 2nd ed', by Richard Ferraro, and from manufacturer's\n");
!     printf("\tdata books\n\n");
      printf("The author welcomes bug reports and other comments mailed to\n");
      printf("the electronic mail address above.  In particular, reports of\n");
      printf("chipsets that this program fails to correctly detect are\n");
!     printf("appreciated\n\n");
  
  {
      FILE *f;
      
      f = fopen("/dev/tty", "w");
!     putc('\007', f);
!     putc('\007', f);
!     putc('\007', f);
!     fprintf(f, "WARNING - THIS SOFTWARE COULD HANG YOUR MACHINE.\n");
!     fprintf(f, "          READ THE SUPERPROBE.1 MANUAL PAGE BEFORE RUNNING.\n");
!     fprintf(f, "          INTERRUPT WITHIN FIVE SECONDS TO ABORT!\n\n");
!     putc('\007', f);
!     putc('\007', f);
!     putc('\007', f);
!     fflush(f);
!     sleep(5);
  }
  
      if (OpenVideo() < 0)
--- 496,532 ----
      }
  
      PRINT_VERSION;
!     printf("\tCopyright 1993,1994 by David Wexelblat <dwex@goblin.org>\n");
!     printf("\n\tThis work is derived from the 'vgadoc2.zip' and\n");
!     printf("\t'vgadoc3.zip' documentation packages produced by Finn\n");
!     printf("\tThoergersen, and released with all appropriate permissions\n");
!     printf("\thaving been obtained.  Additional information obtained from\n");
!     printf("\t'Programmer's Guide to the EGA and VGA, 2nd ed', by Richard\n");
!     printf("\tFerraro, and from manufacturer's data books\n\n");
      printf("The author welcomes bug reports and other comments mailed to\n");
      printf("the electronic mail address above.  In particular, reports of\n");
      printf("chipsets that this program fails to correctly detect are\n");
!     printf("appreciated.\n\n");
  
  {
      FILE *f;
      
      f = fopen("/dev/tty", "w");
!     if (f != (FILE *)NULL)
!     {
!         putc('\007', f);
!         putc('\007', f);
!         putc('\007', f);
!         fprintf(f, "WARNING - THIS SOFTWARE COULD HANG YOUR MACHINE.\n");
!         fprintf(f, "          READ THE SuperProbe.1 MANUAL PAGE BEFORE\n");
!         fprintf(f, "          RUNNING THIS PROGRAM.\n\n");
!         fprintf(f, "          INTERRUPT WITHIN FIVE SECONDS TO ABORT!\n\n");
!         putc('\007', f);
!         putc('\007', f);
!         putc('\007', f);
!         fflush(f);
!         sleep(5);
!     }
  }
  
      if (OpenVideo() < 0)
***************
*** 520,528 ****
  	    Bios_Base = FindBios();
  	    if (Bios_Base == (Byte *)0)
  	    {
! 		fprintf(stderr, "%s: Could not determine BIOS base address\n",
! 			MyName);
! 		return(-1);
  	    }
  	}
      }
--- 542,554 ----
  	    Bios_Base = FindBios();
  	    if (Bios_Base == (Byte *)0)
  	    {
! 		if (Verbose)
! 		{
! 		    printf("%s: Could not determine BIOS base address; %s",
! 			   MyName, " assuming no EGA/VGA present\n");
! 		    fflush(stdout);
! 		}
! 		NoEGA = TRUE;
  	    }
  	}
      }
***************
*** 534,545 ****
  	}
  	else
  	{
! 	    printf("BIOS Base address = 0x%x\n\n", (int)Bios_Base);
  	}
  	fflush(stdout);
      }
  
!     if (!NoBIOS)
      {
          /*
           * Look for 'IBM' at Bios_Base+0x1E of the BIOS.  It will be there for
--- 560,571 ----
  	}
  	else
  	{
! 	    printf("BIOS Base address = 0x%X\n\n", (int)Bios_Base);
  	}
  	fflush(stdout);
      }
  
!     if ((!NoBIOS) && (!NoEGA))
      {
          /*
           * Look for 'IBM' at Bios_Base+0x1E of the BIOS.  It will be there for
***************
*** 548,560 ****
          if (ReadBIOS(COPYRIGHT_BASE, copyright, 3) < 0)
          {
      	    fprintf(stderr, "%s: Failed to read BIOS\n", MyName);
      	    return(1);
          }
      }
!     if ((NoBIOS) ||
!         ((copyright[0] == 'I') && 
!          (copyright[1] == 'B') &&
!          (copyright[2] == 'M')))
      {
      	/*
      	 * It's an EGA or VGA
--- 574,588 ----
          if (ReadBIOS(COPYRIGHT_BASE, copyright, 3) < 0)
          {
      	    fprintf(stderr, "%s: Failed to read BIOS\n", MyName);
+     	    CloseVideo();
      	    return(1);
          }
      }
!     if ((!NoEGA) &&
! 	((NoBIOS) ||
!          ((copyright[0] == 'I') && 
!           (copyright[1] == 'B') &&
!           (copyright[2] == 'M'))))
      {
      	/*
      	 * It's an EGA or VGA
***************
*** 583,588 ****
--- 611,617 ----
      	if (!Probe_VGA(&Primary))
      	{
      	    Primary = CHIP_EGA;
+ 	    Check_CoProc = TRUE;
      	}
      
      	/*
***************
*** 652,657 ****
--- 681,706 ----
      	    	    p = order;
      	        }
      	    }
+ 
+ 	    Check_CoProc = matched->check_coproc;
+ 
+ 	    if (Probe_Mem)
+ 	    {
+ 	    	if (matched->memcheck != (MemCheckFunc)NULL)
+ 	    	{
+ 		    MemVGA = (*matched->memcheck)(Primary);
+ 	    	}
+ 		else if (Verbose)
+ 		{
+ 		    printf("Memory probe not supported for this chipset.\n");
+ 		    fflush(stdout);
+ 		}
+ 	    }
+ 	    else if (Verbose)
+ 	    {
+ 		printf("Skipping memory probe\n");
+ 		fflush(stdout);
+ 	    }
      	}
  
  	/*
***************
*** 658,664 ****
  	 * If this chipset doesn't exclude probing for a coprocessor,
  	 * then look for one.
  	 */
! 	if (matched->check_coproc)
  	{
  	    if (Verbose)
  	    {
--- 707,713 ----
  	 * If this chipset doesn't exclude probing for a coprocessor,
  	 * then look for one.
  	 */
! 	if (Check_CoProc)
  	{
  	    if (Verbose)
  	    {
***************
*** 673,678 ****
--- 722,748 ----
      	    	    break;
      	    	}
  	    }
+ 	    if (CoProc_Descriptors[i] != NULL)
+ 	    {
+ 	    	if (Probe_Mem)
+ 	    	{
+ 	    	    if (matched->memcheck != (MemCheckFunc)NULL)
+ 	    	    {
+ 		        MemCoProc = (*matched->memcheck)(CoProc);
+ 	    	    }
+ 		    else if (Verbose)
+ 		    {
+ 		        printf("Memory probe not supported ");
+ 			printf("for this chipset.\n");
+ 		        fflush(stdout);
+ 		    }
+ 	        }
+ 	        else if (Verbose)
+ 	        {
+ 		    printf("Skipping memory probe\n");
+ 		    fflush(stdout);
+ 	        }
+ 	    }
  	}
      }
      else if (Probe_MDA(&Primary))
***************
*** 725,737 ****
      	{
      	    printf("Super-VGA\n");
      	    Print_SVGA_Name(Primary);
!     	    Probe_RamDac(Primary, &RamDac);
!     	    Print_RamDac_Name(RamDac);
      	}
  	if (CoProc != -1)
  	{
  	    printf("\tAttached graphics coprocessor:\n");
  	    Print_CoProc_Name(CoProc);
  	}
      }
      if (Secondary != -1)
--- 795,822 ----
      	{
      	    printf("Super-VGA\n");
      	    Print_SVGA_Name(Primary);
! 	    if (MemVGA > -1)
! 	    {
! 		printf("\tMemory:  %d Kbytes\n", MemVGA);
! 	    }
! 	    if (Probe_DAC)
! 	    {
!     	        Probe_RamDac(Primary, &RamDac);
!     	        Print_RamDac_Name(RamDac);
! 	    }
! 	    else if (Verbose)
! 	    {
! 		printf("Skipping RAMDAC probe\n");
! 	    }
      	}
  	if (CoProc != -1)
  	{
  	    printf("\tAttached graphics coprocessor:\n");
  	    Print_CoProc_Name(CoProc);
+ 	    if (MemCoProc > -1)
+ 	    {
+ 		printf("\t\tMemory:  %d Kbytes\n", MemCoProc);
+ 	    }
  	}
      }
      if (Secondary != -1)
diff -c mit/server/ddx/x386/SuperProbe/Makefile.std:2.3 mit/server/ddx/x386/SuperProbe/Makefile.std:2.8
*** mit/server/ddx/x386/SuperProbe/Makefile.std:2.3	Fri Mar 11 23:36:13 1994
--- mit/server/ddx/x386/SuperProbe/Makefile.std	Fri Mar 11 23:36:13 1994
***************
*** 1,4 ****
! # $XFree86: mit/server/ddx/x386/SuperProbe/Makefile.std,v 2.3 1993/09/17 16:13:27 dawes Exp $
  #
  # Installation parameters
  #
--- 1,4 ----
! # $XFree86: mit/server/ddx/x386/SuperProbe/Makefile.std,v 2.8 1994/02/28 14:09:32 dawes Exp $
  #
  # Installation parameters
  #
***************
*** 15,41 ****
  #OS_DEF = -DSYSV
  #OS_DEF = -DSYSV -DSCO
  #OS_DEF = -DSYSV -DESIX
  OS_DEF = -DSYSV -DSVR4
  OS_SRC = OS_SYSV.c
  OS_OBJ = OS_SYSV.o
  # Linux
  #OS_DEF = -Dlinux -DGCCUSESGAS
  #OS_SRC = OS_Linux.c
  #OS_OBJ = OS_Linux.o
  # 386BSD
! #OS_DEF = -D__386BSD__ -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # NetBSD
! #OS_DEF = -D__386BSD__ -D__NetBSD__ -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # FreeBSD
! #OS_DEF = -D__386BSD__ -DFreeBSD -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # BSD/386
! #OS_DEF = -D__386BSD__ -D__bsdi__ -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # Minix
--- 15,45 ----
  #OS_DEF = -DSYSV
  #OS_DEF = -DSYSV -DSCO
  #OS_DEF = -DSYSV -DESIX
+ #OS_DEF = -DSYSV -DSVR4 -DSOLX86
  OS_DEF = -DSYSV -DSVR4
  OS_SRC = OS_SYSV.c
  OS_OBJ = OS_SYSV.o
+ # For Solarix x86 with ProWorks compiler only
+ #IO_SRC = SolX86IO.s
+ #IO_OBJ = SolX86IO.o
  # Linux
  #OS_DEF = -Dlinux -DGCCUSESGAS
  #OS_SRC = OS_Linux.c
  #OS_OBJ = OS_Linux.o
  # 386BSD
! #OS_DEF = -D__BSD__ -D__386BSD__ -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # NetBSD
! #OS_DEF = -D__BSD__ -D__NetBSD__ -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # FreeBSD
! #OS_DEF = -D__BSD__ -D__FreeBSD__ -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # BSD/386
! #OS_DEF = -D__BSD__ -D__bsdi__ -DGCCUSESGAS
  #OS_SRC = OS_386BSD.c
  #OS_OBJ = OS_386BSD.o
  # Minix
***************
*** 54,80 ****
  #OS_LIB = /usr/misc/.mach/lib/libmach.a
  
  HDRS = Probe.h
! BASE_SRC = MDA.c Herc.c CGA.c VGA.c RamDac.c
! BASE_OBJ = MDA.o Herc.o CGA.o VGA.o RamDac.o
  SVGA_SRC = Tseng.c WD.c ChipsTech.c Video7.c Genoa.c Trident.c Oak.c \
! 	   Cirrus.c Ahead.c ATI.c S3.c AL.c Yamaha.c NCR.c AcuMos.c MX.c \
! 	   RealTek.c Primus.c Compaq.c
  SVGA_OBJ = Tseng.o WD.o ChipsTech.o Video7.o Genoa.o Trident.o Oak.o \
! 	   Cirrus.o Ahead.o ATI.o S3.o AL.o Yamaha.o NCR.o AcuMos.o MX.o \
! 	   RealTek.o Primus.o Compaq.o
  COPROC_SRC = 8514.c ATIMach.c
  COPROC_OBJ = 8514.o ATIMach.o
! SRCS = Main.c $(SVGA_SRC) $(COPROC_SRC) $(BASE_SRC) Print.c Utils.c $(OS_SRC)
! OBJS = Main.o $(SVGA_OBJ) $(COPROC_OBJ) $(BASE_OBJ) Print.o Utils.o $(OS_OBJ)
  LIBS = $(OS_LIB)
  
  PROG = SuperProbe
  
  CC = gcc
  CCOPTS = -m486 -ansi -pedantic
  DEBUG_OR_OPT = -g -Wall
  #DEBUG_OR_OPT = -O2
  CFLAGS = $(CCOPTS) $(DEBUG_OR_OPT) $(OS_DEF)
  
  all: $(PROG)
  
--- 58,105 ----
  #OS_LIB = /usr/misc/.mach/lib/libmach.a
  
  HDRS = Probe.h
! BASE_SRC = MDA.c Herc.c CGA.c VGA.c RamDac.c MemProbe.c
! BASE_OBJ = MDA.o Herc.o CGA.o VGA.o RamDac.o MemProbe.o
  SVGA_SRC = Tseng.c WD.c ChipsTech.c Video7.c Genoa.c Trident.c Oak.c \
! 	   Cirrus.c Ahead.c ATI.c S3.c AL.c Yamaha.c NCR.c MX.c \
! 	   RealTek.c Primus.c Compaq.c HMC.c UMC.c Weitek.c
  SVGA_OBJ = Tseng.o WD.o ChipsTech.o Video7.o Genoa.o Trident.o Oak.o \
! 	   Cirrus.o Ahead.o ATI.o S3.o AL.o Yamaha.o NCR.o MX.o \
! 	   RealTek.o Primus.o Compaq.o HMC.o UMC.o Weitek.o
  COPROC_SRC = 8514.c ATIMach.c
  COPROC_OBJ = 8514.o ATIMach.o
! SRCS = Main.c $(SVGA_SRC) $(COPROC_SRC) $(BASE_SRC) Print.c \
!        Utils.c $(OS_SRC) $(IO_SRC)
! OBJS = Main.o $(SVGA_OBJ) $(COPROC_OBJ) $(BASE_OBJ) Print.o \
!        Utils.o $(OS_OBJ) $(IO_OBJ)
  LIBS = $(OS_LIB)
  
  PROG = SuperProbe
  
+ # Options for gcc
  CC = gcc
  CCOPTS = -m486 -ansi -pedantic
  DEBUG_OR_OPT = -g -Wall
  #DEBUG_OR_OPT = -O2
+ 
+ # Options for ProWorks compiler on Solaris 2.x
+ #PROWORKSHOME = /opt/SUNWspro
+ #CC = $(PROWORKSHOME)/bin/cc
+ #AS = /usr/ccs/bin/as
+ #CCOPTS = -Xa
+ #DEBUG_OR_OPT = -g
+ #DEBUG_OR_OPT = -O
+ 
  CFLAGS = $(CCOPTS) $(DEBUG_OR_OPT) $(OS_DEF)
+ 
+ #
+ # Assemblier -> object format rule (Solaris x86 ProWorks compiler only)
+ # NOTE: AS must be defined to the assemblier to be used. Currently only
+ #       the default assemblier supplied with Solaris/ProWorks is supported
+ #
+ .s.o:
+ 	$(RM) $@
+ 	$(AS) -o $*.o $*.s
  
  all: $(PROG)
  
diff -c /dev/null mit/server/ddx/x386/SuperProbe/MemProbe.c:2.1
*** /dev/null	Fri Mar 11 23:36:13 1994
--- mit/server/ddx/x386/SuperProbe/MemProbe.c	Fri Mar 11 23:36:13 1994
***************
*** 0 ****
--- 1,147 ----
+ /*
+  * Copyright 1993,1994 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/SuperProbe/MemProbe.c,v 2.1 1994/02/28 14:09:34 dawes Exp $ */
+ 
+ #include "Probe.h"
+ 
+ static Word Ports[] = {SEQ_IDX, SEQ_REG, GRC_IDX, GRC_REG};
+ #define NUMPORTS (sizeof(Ports)/sizeof(Ports[0]))
+ 
+ #define SAVESIZE	100
+ #define BYTE_AT(s,i,j)	(*((s)+((i)*SAVESIZE)+(j)))
+ #define TAG		"SuperProbe"
+ 
+ int Probe_Mem(Check)
+ MemCheck_Descriptor Check;
+ {
+ 	Byte Save256;
+ 	Byte SaveMap;
+ 	Byte SaveSeq;
+ 	Byte SaveMask;
+ 	Byte *Mem;
+ 	Byte *Store;
+ 	int BankNum;
+ 	register int i, j;
+ 	Bool IsMem = TRUE;
+ 	int SaveRBank;
+ 	int SaveWBank;
+ 	int Total;
+ 
+ 	Store = (Byte *)malloc((Check.max_bank+1)*SAVESIZE);
+ 	if (Store == (Byte *)0)
+ 	{
+ 		return(0);
+ 	}
+ 	Mem = MapVGA();
+ 	if (Mem == (Byte *)0)
+ 	{
+ 		return(0);
+ 	}
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 	Save256 = rdinx(GRC_IDX, 0x05);
+ 	SaveMap = rdinx(GRC_IDX, 0x06);
+ 	SaveMask = rdinx(SEQ_IDX, 0x02);
+ 	SaveSeq = rdinx(SEQ_IDX, 0x04);
+ 	wrinx(GRC_IDX, 0x05, ((Save256 & 0x0F) | 0x40));
+ 	wrinx(GRC_IDX, 0x06, (SaveMap & 0xF0) | 0x05);
+ 	wrinx(SEQ_IDX, 0x02, (SaveMask & 0xF0) | 0x0F);
+ 	wrinx(SEQ_IDX, 0x04, (SaveSeq | 0x0E));
+ 	Check.get_bank(Check.chipset, &SaveRBank, &SaveWBank);
+ 	for (BankNum = 0; ((BankNum <= Check.max_bank) && (IsMem)); BankNum++)
+ 	{
+ 		Check.set_bank(Check.chipset, BankNum, BankNum);
+ 		/*
+ 		 * See if this bank is tagged.
+ 		 */
+ 		if (strncmp((char *)Mem, TAG, strlen(TAG)) == 0)
+ 		{
+ 			break;
+ 		}
+ 		for (i=0; i < SAVESIZE; i++)
+ 		{
+ 			BYTE_AT(Store,BankNum,i) = Mem[i];
+ 			Mem[i] ^= 0xAA;
+ 		}
+ 		IsMem = TRUE;
+ 		for (i=0; i < SAVESIZE; i++)
+ 		{
+ 			if (Mem[i] != (BYTE_AT(Store,BankNum,i) ^ 0xAA))
+ 			{
+ 				IsMem = FALSE;
+ 				break;
+ 			}
+ 		}
+ 		for (i = 0; i < SAVESIZE; i++)
+ 		{
+ 			Mem[i] = BYTE_AT(Store,BankNum,i);
+ 		}
+ 		if (IsMem)
+ 		{
+ 			for (i=0; i < SAVESIZE; i++)
+ 			{
+ 				Mem[i] ^= 0x55;
+ 			}
+ 			IsMem = TRUE;
+ 			for (i=0; i < SAVESIZE; i++)
+ 			{
+ 				if (Mem[i] != (BYTE_AT(Store,BankNum,i) ^ 0x55))
+ 				{
+ 					IsMem = FALSE;
+ 					break;
+ 				}
+ 			}
+ 			for (i = 0; i < SAVESIZE; i++)
+ 			{
+ 				Mem[i] = BYTE_AT(Store,BankNum,i);
+ 			}
+ 		}
+ 		if (IsMem)
+ 		{
+ 			/*
+ 			 * Tag this bank
+ 			 */
+ 			strcpy((char *)Mem, TAG);
+ 		}
+ 	}
+ 	Total = (BankNum * Check.bank_size) / 1024; 
+ 
+ 	for (j=0; j < BankNum; j++)
+ 	{
+ 		Check.set_bank(Check.chipset, j, j);
+ 		for (i=0; i < SAVESIZE; i++)
+ 		{
+ 			Mem[i] = BYTE_AT(Store,j,i);
+ 		}
+ 	}
+ 
+ 	Check.set_bank(Check.chipset, SaveRBank, SaveWBank);
+ 	wrinx(SEQ_IDX, 0x04, SaveSeq);
+ 	wrinx(SEQ_IDX, 0x02, SaveMask);
+ 	wrinx(GRC_IDX, 0x06, SaveMap);
+ 	wrinx(GRC_IDX, 0x05, Save256);
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	UnMapVGA(Mem);
+ 
+ 	return(Total);
+ }
diff -c mit/server/ddx/x386/SuperProbe/NCR.c:2.2 mit/server/ddx/x386/SuperProbe/NCR.c:2.4
*** mit/server/ddx/x386/SuperProbe/NCR.c:2.2	Fri Mar 11 23:36:14 1994
--- mit/server/ddx/x386/SuperProbe/NCR.c	Fri Mar 11 23:36:14 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,31 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/NCR.c,v 2.2 1993/09/27 12:23:19 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x3C4, 0x3C5};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor NCR_Descriptor = {
--- 21,31 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/NCR.c,v 2.4 1994/02/28 14:09:35 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {SEQ_IDX, SEQ_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor NCR_Descriptor = {
***************
*** 35,65 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_NCR(int *Chipset)
- #else
  Bool Probe_NCR(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte old, tmp;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 	if (testinx2(0x3C4, 0x05, 0x05))
  	{
! 		old = rdinx(0x3C4, 0x05);
  		wrinx(0x3C4, 0x05, 0x00);
! 		if (!testinx2(0x3C4, 0x10, 0xFF))
  		{
! 			wrinx(0x3C4, 0x05, 0x01);
! 			if (testinx2(0x3C4, 0x10, 0xFF))
  			{
  				result = TRUE;
! 				tmp = rdinx(0x3C4, 0x08) >> 4;
  				if (tmp == 0)
  				{
  					*Chipset = CHIP_NCR77C22;
--- 35,63 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	NULL,
  };
  
  Bool Probe_NCR(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  	Byte old, tmp;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 
! 	if (testinx2(SEQ_IDX, 0x05, 0x05))
  	{
! 		old = rdinx(SEQ_IDX, 0x05);
  		wrinx(0x3C4, 0x05, 0x00);
! 		if (!testinx2(SEQ_IDX, 0x10, 0xFF))
  		{
! 			wrinx(SEQ_IDX, 0x05, 0x01);
! 			if (testinx2(SEQ_IDX, 0x10, 0xFF))
  			{
  				result = TRUE;
! 				tmp = rdinx(SEQ_IDX, 0x08) >> 4;
  				if (tmp == 0)
  				{
  					*Chipset = CHIP_NCR77C22;
***************
*** 72,77 ****
--- 70,79 ----
  				{
  					*Chipset = CHIP_NCR77C22E;
  				}
+ 				else if (tmp == 3)
+ 				{
+ 					*Chipset = CHIP_NCR77C32B;
+ 				}
  				else if ((tmp >= 8) && (tmp <= 15))
  				{
  					*Chipset = CHIP_NCR77C22EP;
***************
*** 83,90 ****
  				}
  			}
  		}
! 		wrinx(0x3C4, 0x05, old);
  	}
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
--- 85,93 ----
  				}
  			}
  		}
! 		wrinx(SEQ_IDX, 0x05, old);
  	}
+ 
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
diff -c mit/server/ddx/x386/SuperProbe/OS_386BSD.c:2.4 mit/server/ddx/x386/SuperProbe/OS_386BSD.c:2.7
*** mit/server/ddx/x386/SuperProbe/OS_386BSD.c:2.4	Fri Mar 11 23:36:14 1994
--- mit/server/ddx/x386/SuperProbe/OS_386BSD.c	Fri Mar 11 23:36:14 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_386BSD.c,v 2.4 1993/10/03 10:24:31 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_386BSD.c,v 2.7 1994/02/28 14:09:36 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 28,33 ****
--- 28,34 ----
  #include <fcntl.h>
  #include <sys/ioctl.h>
  #include <errno.h>
+ #include <sys/mman.h>
  
  #ifdef __bsdi__
  # include <i386/isa/pcconsioctl.h>
***************
*** 35,42 ****
  # define CONSOLE_X_MODE_OFF PCCONIOCCOOK
  #else
    /* This header is part of codrv */
! # if defined(FreeBSD) || defined(__NetBSD__)
  #  include <machine/ioctl_pc.h>
  # else
  #  include <sys/ioctl_pc.h>
  # endif
--- 36,45 ----
  # define CONSOLE_X_MODE_OFF PCCONIOCCOOK
  #else
    /* This header is part of codrv */
! # if defined(__FreeBSD__) || defined(__NetBSD__)
  #  include <machine/ioctl_pc.h>
+ /* both, Free and NetBSD have syscons */
+ #  include <machine/console.h>
  # else
  #  include <sys/ioctl_pc.h>
  # endif
***************
*** 50,55 ****
--- 53,59 ----
  static int BIOS_fd = -1;
  
  static Bool HasCodrv = FALSE;
+ static Bool HasUslVt = FALSE;
  
  /*
   * OpenVideo --
***************
*** 58,68 ****
   * IO protection, since this is currently the only way to access any
   * IO registers.
   */
- #ifdef __STDC__
- int OpenVideo(void)
- #else
  int OpenVideo()
- #endif
  {
  	if (geteuid() != 0)
  	{
--- 62,68 ----
***************
*** 107,115 ****
  			    " and try again\n");
  			return(-1);
  		}
! 		if ((CONS_fd = open("/dev/vga", O_RDWR, 0)) < 0)
  		{
! 			fprintf(stderr, "%s: Cannot open /dev/vga\n", 
  				MyName);
  			return(-1);
  		}
--- 107,117 ----
  			    " and try again\n");
  			return(-1);
  		}
! 		if ((CONS_fd = open("/dev/vga", O_RDWR, 0)) < 0
! 		    && (CONS_fd = open("/dev/ttyv0", O_RDWR, 0)) < 0)
  		{
! 			fprintf(stderr,
! 				"%s: Cannot open /dev/vga nor /dev/ttyv0\n", 
  				MyName);
  			return(-1);
  		}
***************
*** 143,150 ****
  		ioctl(CONS_fd, VGATAKECTRL, 0);
  	}
  	else
  #endif
! 		if (ioctl(CONS_fd, CONSOLE_X_MODE_ON, 0) < 0)
  		{
  			fprintf(stderr, "%s: CONSOLE_X_MODE_ON failed\n",
  				MyName);
--- 145,171 ----
  		ioctl(CONS_fd, VGATAKECTRL, 0);
  	}
  	else
+ 	{
+ 		/*
+ 		 * not codrv and not BSDI; first look if we have a console
+ 		 * driver that understands USL-style VT commands
+ 		 */
+ 		int vt_num;
+ 		
+ 		if (ioctl(CONS_fd, VT_GETACTIVE, &vt_num) == 0)
+ 		{
+ 			/* yes, so we don't use the old stuff */
+ 			HasUslVt = TRUE;
+ 			if (ioctl(CONS_fd, KDENABIO, 0) < 0)
+ 			{
+ 				fprintf(stderr, "%s: KDENABIO failed\n",
+ 					MyName);
+ 				return(-1);
+ 			}
+ 		}
+ 		else
  #endif
! 			if (ioctl(CONS_fd, CONSOLE_X_MODE_ON, 0) < 0)
  		{
  			fprintf(stderr, "%s: CONSOLE_X_MODE_ON failed\n",
  				MyName);
***************
*** 152,157 ****
--- 173,180 ----
  		}
  #ifdef __bsdi__
  	ioctl(CONS_fd, PCCONENABIOPL, 0);
+ #else
+ 	}
  #endif
  	return(CONS_fd);
  }
***************
*** 162,172 ****
   * Disable access to the video hardware.  For 386BSD, we re-enable
   * IO protection.
   */
- #ifdef __STDC__
- void CloseVideo(void)
- #else
  void CloseVideo()
- #endif
  {
  	if (CONS_fd != -1)
  	{
--- 185,191 ----
***************
*** 178,183 ****
--- 197,204 ----
  			ioctl(CONS_fd, VGAGIVECTRL, 0);
  			ioctl(CONS_fd, CONSOLE_X_MODE, &onoff);
  		}
+ 		else if(HasUslVt)
+ 			ioctl(CONS_fd, KDDISABIO, 0);
  		else
  #endif
  			ioctl(CONS_fd, CONSOLE_X_MODE_OFF, 0);
***************
*** 192,210 ****
  }
  
  /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
- #ifdef __STDC__
- int ReadBIOS(const unsigned Offset, Byte *Buffer, const int Len)
- #else
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
- #endif
  {
  	Word tmp;
  	Byte *Base = Bios_Base + Offset;
--- 213,265 ----
  }
  
  /*
+  * MapVGA --
+  *
+  * Map the VGA memory window (0xA0000-0xAFFFF) as read/write memory for
+  * the process for use in probing memory.
+  */
+ Byte *MapVGA()
+ {
+ 	int fd;
+ 	Byte *base;
+ 
+ 	if ((fd = open("/dev/vga", O_RDWR)) < 0)
+ 	{
+ 		fprintf(stderr, "%s: Failed to open /dev/vga\n", MyName);
+ 		return((Byte *)0);
+ 	}
+ 	base = (Byte *)mmap((caddr_t)0, 0x10000, PROT_READ|PROT_WRITE,
+ 			    MAP_FILE, fd, 0);
+ 	close(fd);
+ 	if ((long)base == -1)
+ 	{
+ 		fprintf(stderr, "%s: Failed to mmap framebuffer\n", MyName);
+ 		return((Byte *)0);
+ 	}
+ 	return(base);
+ }
+ 
+ /*
+  * UnMapVGA --
+  *
+  * Unmap the VGA memory window.
+  */
+ void UnMapVGA(base)
+ Byte *base;
+ {
+ 	munmap((caddr_t)base, 0x10000);
+ }
+ 
+ /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
  {
  	Word tmp;
  	Byte *Base = Bios_Base + Offset;
***************
*** 251,265 ****
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For 386BSD, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
- /*ARGSUSED*/
- int EnableIOPorts(const int NumPorts, const Word *Ports)
- #else
  /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! int NumPorts;
! Word *Ports;
! #endif
  {
  	return(0);
  }
--- 306,315 ----
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For 386BSD, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! CONST int NumPorts;
! CONST Word *Ports;
  {
  	return(0);
  }
***************
*** 270,284 ****
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For 386BSD, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
  /*ARGSUSED*/
- int DisableIOPorts(const int NumPorts, const Word *Port)
- #else
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! int NumPorts;
! Word *Port;
! #endif
  {
  	return(0);
  }
--- 320,330 ----
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For 386BSD, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! CONST int NumPorts;
! CONST Word *Port;
  {
  	return(0);
  }
***************
*** 288,299 ****
   *
   * Sleep for the number of milliseconds specified in 'Delay'.
   */
- #ifdef __STDC__
- void ShortSleep(const int Delay)
- #else
  void ShortSleep(Delay)
  int Delay;
- #endif
  {
  	usleep(Delay * 1000);
  }
--- 334,341 ----
diff -c mit/server/ddx/x386/SuperProbe/OS_Linux.c:2.0 mit/server/ddx/x386/SuperProbe/OS_Linux.c:2.3
*** mit/server/ddx/x386/SuperProbe/OS_Linux.c:2.0	Fri Mar 11 23:36:15 1994
--- mit/server/ddx/x386/SuperProbe/OS_Linux.c	Fri Mar 11 23:36:15 1994
***************
*** 1,5 ****
  /*
!  * Copyright 1993 by Orest Zborowski <obz@Kodak.COM>
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
   * documentation for any purpose is hereby granted without fee, provided that
--- 1,5 ----
  /*
!  * Copyright 1993,1994 by Orest Zborowski <obz@Kodak.COM>
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
   * documentation for any purpose is hereby granted without fee, provided that
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_Linux.c,v 2.0 1993/08/30 15:20:31 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_Linux.c,v 2.3 1994/02/28 14:09:37 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 28,33 ****
--- 28,34 ----
  #include <fcntl.h>
  #include <sys/kd.h>
  #include <sys/vt.h>
+ #include <sys/mman.h>
  
  static int VT_fd = -1;
  static int VT_num = -1;
***************
*** 41,51 ****
   * VT, and disable IO protection, since we may need to get at extended 
   * registers (full 16-bit decoding).
   */
- #ifdef __STDC__
- int OpenVideo(void)
- #else
  int OpenVideo()
- #endif
  {
  	int fd;
  	char fn[20];
--- 42,48 ----
***************
*** 121,131 ****
   * Disable access to the video hardware.  For Linux, close the VT, and
   * re-enable IO protection.
   */
- #ifdef __STDC__
- void CloseVideo(void)
- #else
  void CloseVideo()
- #endif
  {
  	int fd;
  
--- 118,124 ----
***************
*** 145,163 ****
  }
  
  /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
- #ifdef __STDC__
- int ReadBIOS(const unsigned Offset, Byte *Buffer, const int Len)
- #else
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
- #endif
  {
  	Word tmp;
  	Byte *Base = Bios_Base + Offset;
--- 138,191 ----
  }
  
  /*
+  * MapVGA --
+  *
+  * Map the VGA memory window (0xA0000-0xAFFFF) as read/write memory for
+  * the process for use in probing memory.
+  */
+ Byte *MapVGA()
+ {
+ 	int fd;
+ 	Byte *base;
+ 
+ 	if ((fd = open("/dev/mem", O_RDWR)) < 0)
+ 	{
+ 		fprintf(stderr, "%s: Failed to open /dev/mem\n", MyName);
+ 		return((Byte *)0);
+ 	}
+ 	base = (Byte *)mmap((caddr_t)0, 0x10000, PROT_READ|PROT_WRITE,
+ 			    MAP_SHARED, fd, (off_t)0xA0000);
+ 	close(fd);
+ 	if ((long)base == -1)
+ 	{
+                 fprintf(stderr, "%s: Failed to mmap framebuffer\n", MyName);
+ 		return((Byte *)0);
+ 	}
+ 	return(base);
+ }
+ 
+ /*
+  * UnMapVGA --
+  *
+  * Unmap the VGA memory window.
+  */
+ void UnMapVGA(base)
+ Byte *base;
+ {
+ 	munmap((caddr_t)base, 0x10000);
+ 	return;
+ }
+ 
+ /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
  {
  	Word tmp;
  	Byte *Base = Bios_Base + Offset;
***************
*** 204,218 ****
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For Linux, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
  /*ARGSUSED*/
- int EnableIOPorts(const int NumPorts, const Word *Ports)
- #else
- /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! int NumPorts;
! Word *Ports;
! #endif
  {
  	return(0);
  }
--- 232,241 ----
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For Linux, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! CONST int NumPorts;
! CONST Word *Ports;
  {
  	return(0);
  }
***************
*** 223,237 ****
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For Linux, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
- /*ARGSUSED*/
- int DisableIOPorts(const int NumPorts, const Word *Port)
- #else
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! int NumPorts;
! Word *Port;
! #endif
  {
  	return(0);
  }
--- 246,255 ----
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For Linux, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! CONST int NumPorts;
! CONST Word *Port;
  {
  	return(0);
  }
***************
*** 241,252 ****
   *
   * Sleep for the number of milliseconds specified in 'Delay'.
   */
- #ifdef __STDC__
- void ShortSleep(const int Delay)
- #else
  void ShortSleep(Delay)
  int Delay;
- #endif
  {
  	usleep(Delay * 1000);
  }
--- 259,266 ----
diff -c mit/server/ddx/x386/SuperProbe/OS_Mach.c:2.1 mit/server/ddx/x386/SuperProbe/OS_Mach.c:2.4
*** mit/server/ddx/x386/SuperProbe/OS_Mach.c:2.1	Fri Mar 11 23:36:16 1994
--- mit/server/ddx/x386/SuperProbe/OS_Mach.c	Fri Mar 11 23:36:16 1994
***************
*** 1,5 ****
  /*
!  * Copyright 1993 by Robert V. Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
   * documentation for any purpose is hereby granted without fee, provided that
--- 1,5 ----
  /*
!  * Copyright 1993,1994 by Robert V. Baron <Robert.Baron@ernst.mach.cs.cmu.edu>
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
   * documentation for any purpose is hereby granted without fee, provided that
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_Mach.c,v 2.1 1993/10/16 17:30:37 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_Mach.c,v 2.4 1994/02/28 14:09:39 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 49,59 ****
   */
  int screen_addr;
  
- #ifdef	__STDC__
- int OpenVideo(void)
- #else
  int OpenVideo()
- #endif
  {
  	int ret;
  #define C /*Bios_Base*/ 0xc0000
--- 49,55 ----
***************
*** 84,94 ****
   * Disable access to the video hardware.  For Mach, we re-enable
   * IO protection.
   */
- #ifdef __STDC__
- void CloseVideo(void)
- #else
  void CloseVideo()
- #endif
  {
  	if (KERN_SUCESS != vm_deallocate(task_self(), screen_addr, S)) {
  		fprintf(stderr, "Failed vmdeallocate %x\n", S);
--- 80,86 ----
***************
*** 97,115 ****
  }
  
  /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
- #ifdef __STDC__
- int ReadBIOS(const unsigned Offset, Byte *Buffer, const int Len)
- #else
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
- #endif
  {
  	Word tmp;
  	Byte *Base = (Byte *)(screen_addr + Bios_Base + Offset);
--- 89,125 ----
  }
  
  /*
+  * MapVGA --
+  *
+  * Map the VGA memory window (0xA0000-0xAFFFF) as read/write memory for
+  * the process for use in probing memory.
+  */
+ Byte *MapVGA()
+ {
+         return((Byte *)0);
+ }
+ 
+ /*
+  * UnMapVGA --
+  *
+  * Unmap the VGA memory window.
+  */
+ void UnMapVGA(base)
+ Byte *base;
+ {
+ 	return;
+ }
+ 
+ /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
  {
  	Word tmp;
  	Byte *Base = (Byte *)(screen_addr + Bios_Base + Offset);
***************
*** 133,147 ****
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For Mach, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
  /*ARGSUSED*/
- int EnableIOPorts(const int NumPorts, const Word *Ports)
- #else
- /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! int NumPorts;
! Word *Ports;
! #endif
  {
  	return(0);
  }
--- 143,152 ----
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For Mach, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! CONST int NumPorts;
! CONST Word *Ports;
  {
  	return(0);
  }
***************
*** 152,166 ****
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For Mach, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
- /*ARGSUSED*/
- int DisableIOPorts(const int NumPorts, const Word *Port)
- #else
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! int NumPorts;
! Word *Port;
! #endif
  {
  	return(0);
  }
--- 157,166 ----
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For Mach, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! CONST int NumPorts;
! CONST Word *Port;
  {
  	return(0);
  }
***************
*** 170,181 ****
   *
   * Sleep for the number of milliseconds specified in 'Delay'.
   */
- #ifdef __STDC__
- void ShortSleep(const int Delay)
- #else
  void ShortSleep(Delay)
  int Delay;
- #endif
  {
  #ifdef MACH3
  	struct trial {
--- 170,177 ----
diff -c mit/server/ddx/x386/SuperProbe/OS_Minix.c:1.2 mit/server/ddx/x386/SuperProbe/OS_Minix.c:2.1
*** mit/server/ddx/x386/SuperProbe/OS_Minix.c:1.2	Fri Mar 11 23:36:16 1994
--- mit/server/ddx/x386/SuperProbe/OS_Minix.c	Fri Mar 11 23:36:16 1994
***************
*** 1,5 ****
  /*
!  * Copyright 1993 by Philip Homburg <philip@cs.vu.nl>
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
   * documentation for any purpose is hereby granted without fee, provided that
--- 1,5 ----
  /*
!  * Copyright 1993,1994 by Philip Homburg <philip@cs.vu.nl>
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
   * documentation for any purpose is hereby granted without fee, provided that
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_Minix.c,v 1.2 1993/05/04 15:01:47 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_Minix.c,v 2.1 1994/02/28 14:09:40 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 39,49 ****
   * Enable access to the installed video hardware.  This also gives us 
   * access to all I/O registers and the interrupt enable/disable bit.
   */
- #ifdef __STDC__
- int OpenVideo(void)
- #else
  int OpenVideo()
- #endif
  {
  	void *base;
  	u32_t aligned_base;
--- 39,45 ----
***************
*** 91,101 ****
   * Disable access to the video hardware.  For Minix, this removes access
   * to I/O registers.
   */
- #ifdef __STDC__
- void CloseVideo(void)
- #else
  void CloseVideo()
- #endif
  {
  	if (CONS_fd > 0)
  	{
--- 87,93 ----
***************
*** 105,123 ****
  }
  
  /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
- #ifdef __STDC__
- int ReadBIOS(const unsigned Offset, Byte *Buffer, const int Len)
- #else
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
- #endif
  {
  	Word tmp;
  	Byte *Base = Bios_Base + Offset;
--- 97,133 ----
  }
  
  /*
+  * MapVGA --
+  *
+  * Map the VGA memory window (0xA0000-0xAFFFF) as read/write memory for
+  * the process for use in probing memory.
+  */
+ Byte *MapVGA()
+ {
+         return((Byte *)0);
+ }
+ 
+ /*
+  * UnMapVGA --
+  *
+  * Unmap the VGA memory window.
+  */
+ void UnMapVGA(base)
+ Byte *base;
+ {
+         return;
+ }
+ 
+ /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
  {
  	Word tmp;
  	Byte *Base = Bios_Base + Offset;
***************
*** 164,178 ****
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For Minix,
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
- /*ARGSUSED*/
- int EnableIOPorts(const int NumPorts, const Word *Ports)
- #else
  /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! int NumPorts;
! Word *Ports;
! #endif
  {
  	if (CONS_fd == -1) abort();
  
--- 174,183 ----
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For Minix,
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! CONST int NumPorts;
! CONST Word *Ports;
  {
  	if (CONS_fd == -1) abort();
  
***************
*** 185,199 ****
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For Minix, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
- /*ARGSUSED*/
- int DisableIOPorts(const int NumPorts, const Word *Port)
- #else
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! int NumPorts;
! Word *Port;
! #endif
  {
  	return(0);
  }
--- 190,199 ----
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For Minix, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! CONST int NumPorts;
! CONST Word *Port;
  {
  	return(0);
  }
***************
*** 203,214 ****
   *
   * Sleep for the number of milliseconds specified in 'Delay'.
   */
- #ifdef __STDC__
- void ShortSleep(const int Delay)
- #else
  void ShortSleep(Delay)
  int Delay;
- #endif
  {
  	usleep(Delay * 1000);
  }
--- 203,210 ----
diff -c mit/server/ddx/x386/SuperProbe/OS_SYSV.c:2.3 mit/server/ddx/x386/SuperProbe/OS_SYSV.c:2.8
*** mit/server/ddx/x386/SuperProbe/OS_SYSV.c:2.3	Fri Mar 11 23:36:17 1994
--- mit/server/ddx/x386/SuperProbe/OS_SYSV.c	Fri Mar 11 23:36:17 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_SYSV.c,v 2.3 1993/09/21 15:20:38 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/OS_SYSV.c,v 2.8 1994/03/01 09:51:12 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 40,51 ****
  #endif
  #ifdef SCO
  # include <sys/vtkd.h>
  #else
  # include <sys/kd.h>
  # include <sys/vt.h>
  #endif
  #include <sys/immu.h>
! #include <sys/region.h>
  #include <sys/proc.h>
  #include <sys/tss.h>
  #include <sys/sysi86.h>
--- 40,56 ----
  #endif
  #ifdef SCO
  # include <sys/vtkd.h>
+ # include <sys/console.h>
  #else
  # include <sys/kd.h>
+ #ifndef SOLX86
  # include <sys/vt.h>
  #endif
+ #endif
  #include <sys/immu.h>
! #ifndef SOLX86
! # include <sys/region.h>
! #endif
  #include <sys/proc.h>
  #include <sys/tss.h>
  #include <sys/sysi86.h>
***************
*** 53,58 ****
--- 58,66 ----
  # include <sys/seg.h>
  #endif
  #include <sys/v86.h>
+ #ifdef SOLX86
+ # include <sys/psw.h>
+ #endif
  
  #ifdef __STDC__
  int sysi86(int, ...);
***************
*** 66,72 ****
  
  #ifdef SVR4
  # include <sys/mman.h>
! # define DEV_MEM 	"/dev/pmem"
  #else
  # define DEV_MEM	"/dev/mem"
  #endif
--- 74,84 ----
  
  #ifdef SVR4
  # include <sys/mman.h>
! # ifdef SOLX86
! #  define DEV_MEM	"/dev/fb"
! # else
! #  define DEV_MEM 	"/dev/pmem"
! # endif
  #else
  # define DEV_MEM	"/dev/mem"
  #endif
***************
*** 82,92 ****
   * VT if not running on a VT.  Also, disable IO protection, since we may
   * need to get at extended registers.
   */
- #ifdef __STDC__
- int OpenVideo(void)
- #else
  int OpenVideo()
- #endif
  {
  	int fd;
  	char fn[20];
--- 94,100 ----
***************
*** 104,110 ****
  	}
  	else 
  	{
! 		if ((fd = open("/dev/console", O_WRONLY, 0)) < 0)
  		{
  			fprintf(stderr, "%s: Cannot open /dev/console\n", 
  				MyName);
--- 112,120 ----
  	}
  	else 
  	{
! 
! #ifndef SOLX86
! 		if ((fd = open("/dev/console", O_RDWR, 0)) < 0)
  		{
  			fprintf(stderr, "%s: Cannot open /dev/console\n", 
  				MyName);
***************
*** 117,122 ****
--- 127,136 ----
  		}
  		close(fd);
  		sprintf(fn, "/dev/vt%02d", VT_num);
+ #else
+ 		sprintf(fn, "/dev/fb");
+ #endif
+ 
  		if ((VT_fd = open(fn, O_RDWR|O_NDELAY, 0)) < 0)
  		{
  			fprintf(stderr, "%s: Could not open VT %s\n", 
***************
*** 123,129 ****
  				MyName, fn);
  			return(-1);
  		}
! #ifndef SCO
  		if (ioctl(VT_fd, VT_WAITACTIVE, VT_num) != 0)
  		{
  			fprintf(stderr, "%s: VT_WAITACTIVE failed!\n", MyName);
--- 137,143 ----
  				MyName, fn);
  			return(-1);
  		}
! #if !defined(SCO) && !defined(SOLX86)
  		if (ioctl(VT_fd, VT_WAITACTIVE, VT_num) != 0)
  		{
  			fprintf(stderr, "%s: VT_WAITACTIVE failed!\n", MyName);
***************
*** 145,155 ****
   * Disable access to the video hardware.  For SYSV, close the VT if it's open.
   * Also, re-enable IO protection.
   */
- #ifdef __STDC__
- void CloseVideo(void)
- #else
  void CloseVideo()
- #endif
  {
  	if (VT_fd != -1)
  	{
--- 159,165 ----
***************
*** 162,180 ****
  }
  
  /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
- #ifdef __STDC__
- int ReadBIOS(const unsigned Offset, Byte *Buffer, const int Len)
- #else
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
- #endif
  {
  #ifndef SVR4
  	Word tmp;
--- 172,257 ----
  }
  
  /*
+  * MapVGA --
+  *
+  * Map the VGA memory window (0xA0000-0xAFFFF) as read/write memory for
+  * the process for use in probing memory.
+  */
+ Byte *MapVGA()
+ {
+ #if defined(SVR4)
+ 	int fd;
+ 	Byte *base;
+ 
+ 	if ((fd = open(DEV_MEM, O_RDWR)) < 0)
+ 	{
+ 		fprintf(stderr, "%s: Failed to open %s\n", MyName, DEV_MEM);
+ 		return((Byte *)0);
+ 	}
+ 	base = (Byte *)mmap((caddr_t)0, 0x10000, PROT_READ|PROT_WRITE,
+ 			    MAP_SHARED, fd, (off_t)0xA0000);
+ 	close(fd);
+ 	if ((long)base == -1)
+ 	{
+ 		fprintf(stderr, "%s: Failed to mmap framebuffer\n", MyName);
+ 		return((Byte *)0);
+ 	}
+ #elif defined(SCO)
+ 	static Byte *base = (Byte *)0;
+ 	ioctl(VT_fd, KDSETMODE, KD_GRAPHICS);
+ 	if (base == (Byte *) 0)
+ 		base = (Byte *) ioctl(VT_fd, MAPCONS, 0L);
+ #else /* SVR4 */
+ 	static Byte *base = (Byte *)0;
+ 	static struct kd_memloc vgaDSC;
+ 
+ 	ioctl(VT_fd, KDSETMODE, KD_GRAPHICS);
+ 	if (base == (Byte *)0)
+ 	{
+ 		base = (Byte *)(((unsigned int)malloc(0x11000) & ~0xFFF) 
+ 			+ 0x1000);
+ 		vgaDSC.vaddr = (char *)base;
+ 		vgaDSC.physaddr = (char *)0xA0000;
+ 		vgaDSC.length = 0x10000;
+ 		vgaDSC.ioflg = 1;
+ 	}
+ 	if (ioctl(VT_fd, KDMAPDISP, &vgaDSC) < 0)
+ 	{
+ 		fprintf(stderr, "%s: Failed to mmap framebuffer\n", MyName);
+ 		return((Byte *)0);
+ 	}
+ #endif /* SVR4 */
+ 	return(base);
+ }
+ 
+ /*
+  * UnMapVGA --
+  *
+  * Unmap the VGA memory window.
+  */
+ void UnMapVGA(base)
+ Byte *base;
+ {
+ #ifdef SVR4
+ 	munmap((caddr_t)base, 0x10000);
+ #else /* SVR4 */
+ # ifndef SCO
+ 	ioctl(VT_fd, KDUNMAPDISP, 0);
+ # endif
+ 	ioctl(VT_fd, KDSETMODE, KD_TEXT);
+ #endif
+ }
+ 
+ /*
   * ReadBIOS --
   *
   * Read 'Len' bytes from the video BIOS at address 'Bios_Base'+'Offset' into 
   * buffer 'Buffer'.
   */
  int ReadBIOS(Offset, Buffer, Len)
  unsigned Offset;
  Byte *Buffer;
  int Len;
  {
  #ifndef SVR4
  	Word tmp;
***************
*** 271,285 ****
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For SYSV, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
  /*ARGSUSED*/
- int EnableIOPorts(const int NumPorts, const Word *Ports)
- #else
- /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! int NumPorts;
! Word *Ports;
! #endif
  {
  	return(0);
  }
--- 348,357 ----
   * Enable access to 'NumPorts' IO ports listed in array 'Ports'.  For SYSV, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int EnableIOPorts(NumPorts, Ports)
! CONST int NumPorts;
! CONST Word *Ports;
  {
  	return(0);
  }
***************
*** 290,304 ****
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For SYSV, 
   * we've disabled IO protections so this is a no-op.
   */
- #ifdef __STDC__
- /*ARGSUSED*/
- int DisableIOPorts(const int NumPorts, const Word *Port)
- #else
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! int NumPorts;
! Word *Port;
! #endif
  {
  	return(0);
  }
--- 362,371 ----
   * Disable access to 'NumPorts' IO ports listed in array  'Ports'.  For SYSV, 
   * we've disabled IO protections so this is a no-op.
   */
  /*ARGSUSED*/
  int DisableIOPorts(NumPorts, Port)
! CONST int NumPorts;
! CONST Word *Port;
  {
  	return(0);
  }
***************
*** 308,319 ****
   *
   * Sleep for the number of milliseconds specified in 'Delay'.
   */
- #ifdef __STDC__
- void ShortSleep(const int Delay)
- #else
  void ShortSleep(Delay)
  int Delay;
- #endif
  {
  	syscall(3112, Delay);
  }
--- 375,382 ----
diff -c mit/server/ddx/x386/SuperProbe/Oak.c:2.3 mit/server/ddx/x386/SuperProbe/Oak.c:2.5
*** mit/server/ddx/x386/SuperProbe/Oak.c:2.3	Fri Mar 11 23:36:18 1994
--- mit/server/ddx/x386/SuperProbe/Oak.c	Fri Mar 11 23:36:18 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Oak.c,v 2.3 1993/09/27 12:23:20 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Oak.c,v 2.5 1994/02/28 14:09:43 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 28,33 ****
--- 28,35 ----
  static Word Ports[] = {0x3DE, 0x3DF};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_Oak __STDCARGS((int));
+ 
  Chip_Descriptor Oak_Descriptor = {
  	"Oak",
  	Probe_Oak,
***************
*** 35,69 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Oak(int *Chipset)
- #else
  Bool Probe_Oak(Chipset)
  int *Chipset;
- #endif
  {
  	Byte temp;
  	Bool result = FALSE;
  
  	EnableIOPorts(NUMPORTS, Ports);
  	if (testinx2(0x3DE, 0x0D, 0x38))
  	{
  		result = TRUE;
! 		if (testinx2(0x3DE, 0x11, 0x77))
  		{
! 			temp = inp(0x3DE) & 0xE0;
  			switch (temp)
  			{
! 			case 0x40:
  				*Chipset = CHIP_OAK067;
  				break;
! 			case 0xA0:
  				*Chipset = CHIP_OAK077;
  				break;
! 			case 0xE0:
  				*Chipset = CHIP_OAK057;
  				break;
  			default:
--- 37,83 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_Oak,
  };
  
  Bool Probe_Oak(Chipset)
  int *Chipset;
  {
  	Byte temp;
  	Bool result = FALSE;
  
  	EnableIOPorts(NUMPORTS, Ports);
+ 
  	if (testinx2(0x3DE, 0x0D, 0x38))
  	{
  		result = TRUE;
! 		if (testinx2(0x3DE, 0x23, 0x1F))
! 		{
! 			if ((rdinx(0x3DE, 0x00) & 0x02) == 0x00)
! 			{
! 				*Chipset = CHIP_OAK087;
! 			}
! 			else
! 			{
! 				*Chipset = CHIP_OAK083;
! 			}
! 		}
! 		else 
  		{
! 			temp = inp(0x3DE) >> 5;
  			switch (temp)
  			{
! 			case 0x00:
! 				*Chipset = CHIP_OAK037C;
! 				break;
! 			case 0x02:
  				*Chipset = CHIP_OAK067;
  				break;
! 			case 0x05:
  				*Chipset = CHIP_OAK077;
  				break;
! 			case 0x07:
  				*Chipset = CHIP_OAK057;
  				break;
  			default:
***************
*** 72,82 ****
  				break;
  			}
  		}
! 		else
  		{
! 			*Chipset = CHIP_OAK037C;
  		}
  	}
  	DisableIOPorts(NUMPORTS, Ports);
! 	return(result);
  }
--- 86,141 ----
  				break;
  			}
  		}
! 	}
! 
! 	DisableIOPorts(NUMPORTS, Ports);
! 	return(result);
! }
! 
! static int MemProbe_Oak(Chipset)
! int Chipset;
! {
! 	int Mem = 0;
! 
! 	EnableIOPorts(NUMPORTS, Ports);
! 
! 	switch (Chipset)
! 	{
! 	case CHIP_OAK083:
! 	case CHIP_OAK087:
! 		switch (rdinx(0x3DE, 0x02) & 0x06)
! 		{
! 		case 0x00:
! 			Mem = 256;
! 			break;
! 		case 0x02:
! 			Mem = 512;
! 			break;
! 		case 0x04:
! 			Mem = 1024;
! 			break;
! 		case 0x06:
! 			Mem = 2048;
! 			break;
! 		}
! 		break;
! 	default:
! 		switch (rdinx(0x3DE, 0x0D) >> 6)
  		{
! 		case 0x00:
! 			Mem = 256;
! 			break;
! 		case 0x02:
! 			Mem = 512;
! 			break;
! 		case 0x01:
! 		case 0x03:
! 			Mem = 1024;
! 			break;
  		}
+ 		break;
  	}
+ 
  	DisableIOPorts(NUMPORTS, Ports);
! 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/PatchLevel.h:2.6 mit/server/ddx/x386/SuperProbe/PatchLevel.h:2.9
*** mit/server/ddx/x386/SuperProbe/PatchLevel.h:2.6	Fri Mar 11 23:36:18 1994
--- mit/server/ddx/x386/SuperProbe/PatchLevel.h	Fri Mar 11 23:36:18 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,28 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/PatchLevel.h,v 2.6 1993/10/07 13:54:47 dawes Exp $ */
  
! #define VERSION 	1
  #define PATCHLEV 	0
  #define PRINT_VERSION	printf("\n%s Version %d.%d\n",MyName,VERSION,PATCHLEV)
--- 21,28 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/PatchLevel.h,v 2.9 1994/02/28 14:09:44 dawes Exp $ */
  
! #define VERSION 	2
  #define PATCHLEV 	0
  #define PRINT_VERSION	printf("\n%s Version %d.%d\n",MyName,VERSION,PATCHLEV)
diff -c mit/server/ddx/x386/SuperProbe/Primus.c:2.1 mit/server/ddx/x386/SuperProbe/Primus.c:2.3
*** mit/server/ddx/x386/SuperProbe/Primus.c:2.1	Fri Mar 11 23:36:19 1994
--- mit/server/ddx/x386/SuperProbe/Primus.c	Fri Mar 11 23:36:19 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,31 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Primus.c,v 2.1 1993/09/21 15:20:41 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x3CE, 0x3CF, 0x3D6, 0x3D7};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Primus_Descriptor = {
--- 21,31 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Primus.c,v 2.3 1994/02/28 14:09:45 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {GRC_IDX, GRC_REG, 0x3D6, 0x3D7};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Primus_Descriptor = {
***************
*** 35,54 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Primus(int *Chipset)
- #else
  Bool Probe_Primus(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 	if (testinx2(0x3CE, 0x3D, 0x3F) &&
  	    tstrg(0x3D6, 0x1F) &&
  	    tstrg(0x3D7, 0x1F))
  	{
--- 35,52 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	NULL,
  };
  
  Bool Probe_Primus(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  
  	EnableIOPorts(NUMPORTS, Ports);
! 
! 	if (testinx2(GRC_IDX, 0x3D, 0x3F) &&
  	    tstrg(0x3D6, 0x1F) &&
  	    tstrg(0x3D7, 0x1F))
  	{
***************
*** 55,60 ****
--- 53,59 ----
  		result = TRUE;
  		*Chipset = CHIP_P2000;
  	}
+ 
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
diff -c mit/server/ddx/x386/SuperProbe/Print.c:2.9 mit/server/ddx/x386/SuperProbe/Print.c:2.14
*** mit/server/ddx/x386/SuperProbe/Print.c:2.9	Fri Mar 11 23:36:20 1994
--- mit/server/ddx/x386/SuperProbe/Print.c	Fri Mar 11 23:36:20 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,46 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Print.c,v 2.9 1993/10/07 13:54:49 dawes Exp $ */
  
  #include "Probe.h"
  
- #ifdef __STDC__
- # define CONST const
- #else
- # define CONST
- #endif
- 
  static CONST char *SVGA_Names[NUM_VENDORS+1][CHPS_PER_VENDOR] = 
  {
  /* dummy */	{ "" },	
- /* AcuMos */	{ "AcuMos AVGA2" },
  /* Ahead */	{ "Ahead (chipset unknown)",
  		  "Ahead V5000 Version A", "Ahead V5000 Version B" },
  /* ATI */	{ "ATI (chipset unknown)", 
  		  "ATI 18800", "ATI 18800-1",
  		  "ATI 28800-2", "ATI 28800-4", "ATI 28800-5", 
! 		  "ATI 28800-A", "ATI 28800-C" },
  /* AL */	{ "Avance Logic 2101" },
  /* CT */	{ "Chips & Tech (chipset unknown)",
  		  "Chips & Tech 82c450", "Chips & Tech 82c451", 
--- 21,40 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Print.c,v 2.14 1994/02/28 14:09:47 dawes Exp $ */
  
  #include "Probe.h"
  
  static CONST char *SVGA_Names[NUM_VENDORS+1][CHPS_PER_VENDOR] = 
  {
  /* dummy */	{ "" },	
  /* Ahead */	{ "Ahead (chipset unknown)",
  		  "Ahead V5000 Version A", "Ahead V5000 Version B" },
  /* ATI */	{ "ATI (chipset unknown)", 
  		  "ATI 18800", "ATI 18800-1",
  		  "ATI 28800-2", "ATI 28800-4", "ATI 28800-5", 
! 		  "ATI 68800-3", "ATI 68800-6", 
! 		  "ATI 68800-LX", "ATI 68800-AX" },
  /* AL */	{ "Avance Logic 2101" },
  /* CT */	{ "Chips & Tech (chipset unknown)",
  		  "Chips & Tech 82c450", "Chips & Tech 82c451", 
***************
*** 51,99 ****
  /* Cirrus */	{ "Cirrus (chipset unknown)",
  		  "Cirrus CL-GD 510/520", "Cirrus CL-GD 610/620",
  		  "Cirrus Video7 OEM",
  		  "Cirrus CL-GD5402", "Cirrus CL-GD5402 Rev 1",
  		  "Cirrus CL-GD5420", "Cirrus CL-GD5420 Rev 1",
  		  "Cirrus CL-GD5422", "Cirrus CL-GD5424", 
  		  "Cirrus CL-GD5426", "Cirrus CL-GD5428",
  		  "Cirrus CL-GD6205", "Cirrus CL-GD6215",
  		  "Cirrus CL-GD6225", "Cirrus CL-GD6235",
! 		  "Cirrus CL-GD6410", 
! 		  "Cirrus CL-GD6420A", "Cirrus CL-GD6420B" },
  /* Compaq */	{ "Compaq (chipset unknown)",
  		  "Compaq Advanced VGA", 
! 		  "Compaq QVision/1024", "Compaq QVision/1280" },
  /* Genoa */	{ "Genoa GVGA 6100",
  		  "Genoa GVGA 6200/6300", "Genoa GVGA 6400/6600" },
! /* MX */	{ "MX 68010" },
  /* NCR */	{ "NCR (chipset unknown)",
! 		  "NCR 77C21", "NCR 77C22", "NCR 77C22E", "NCR 77C22E+" },
  /* Oak */	{ "Oak (chipset unknown)",
  		  "Oak OTI037C", 
! 		  "Oak OTI-057", "Oak OTI-067", "Oak OTI-077" },
  /* Primus */	{ "Primus P2000" },
! /* Realtek */	{ "Realtek RT 3106" },
  /* S3 */	{ "S3 (chipset unknown)",
  		  "S3 86C911", "S3 86C924",
  		  "S3 86C801, A or B-step", 
! 		  "S3 86C801, C-step", "S3 86C801, D-step",
  		  "S3 86C805, A or B-step", 
  		  "S3 86C805, C-step", "S3 86C805, D-step",
  		  "S3 86C928, A,B,C, or D-step", "S3 86C928, E-step",
  		  "S3 86C928PCI" },
  /* Trident */	{ "Trident (chipset unknown)",
  		  "Trident 8800BR", "Trident 8800CS",
! 		  "Trident 8900B", "Trident 8900C", "Trident 8900CL",
! 		  "Trident 9000", "Trident LCD9100", "Trident LX9200" },
! /* Tseng */	{ "Tseng ET3000", "Tseng ET4000", "Tseng ET4000/W32" },
  /* Video7 */	{ "Video7 (chipset unknown)",
! 		  "Video7 VEGA", "Video7 FastWrite/VRAM",
! 		  "Video7 VRAM II", "Video7 1024i" },
! /* WD */	{ "WD/Paradise PVGA1", "WD/Paradise 90C00", 
  		  "WD/Paradise 90C10", "WD/Paradise 90C11",
  		  "WD/Paradise 90C20", "WD/Paradise 90C20A",
  		  "WD/Paradise 90C22", "WD/Paradise 90C24", 
  		  "WD/Paradise 90C26",
! 		  "WD/Paradise 90C30", "WD/Paradise 90C31" },
  /* Yamaha */	{ "Yamaha 6388 VPDC" },
  };
  
--- 45,119 ----
  /* Cirrus */	{ "Cirrus (chipset unknown)",
  		  "Cirrus CL-GD 510/520", "Cirrus CL-GD 610/620",
  		  "Cirrus Video7 OEM",
+ 		  "Cirrus/AcuMos AVGA2",
  		  "Cirrus CL-GD5402", "Cirrus CL-GD5402 Rev 1",
  		  "Cirrus CL-GD5420", "Cirrus CL-GD5420 Rev 1",
  		  "Cirrus CL-GD5422", "Cirrus CL-GD5424", 
  		  "Cirrus CL-GD5426", "Cirrus CL-GD5428",
+ 		  "Cirrus CL-GD543x",
  		  "Cirrus CL-GD6205", "Cirrus CL-GD6215",
  		  "Cirrus CL-GD6225", "Cirrus CL-GD6235",
! 		  "Cirrus CL-GD5410",
! 		  "Cirrus CL-GD6410", "Cirrus CL-GD6412",
! 		  "Cirrus CL-GD6420A", "Cirrus CL-GD6420B" 
! 		  "Cirrus CL-GD6440" },
  /* Compaq */	{ "Compaq (chipset unknown)",
+ 		  "Compaq Int. Vid. Graphics Sys.",
  		  "Compaq Advanced VGA", 
! 		  "Compaq QVision/1024", "Compaq QVision/1280",
! 		  "Compaq Advanced VGA, Portable" },
  /* Genoa */	{ "Genoa GVGA 6100",
  		  "Genoa GVGA 6200/6300", "Genoa GVGA 6400/6600" },
! /* HMC */	{ "HMC HM86304" },
! /* MX */	{ "MX 68000", "MX 68010" },
  /* NCR */	{ "NCR (chipset unknown)",
! 		  "NCR 77C21", "NCR 77C22", "NCR 77C22E", "NCR 77C22E+",
! 		  "NCR 77C32BLT" },
  /* Oak */	{ "Oak (chipset unknown)",
  		  "Oak OTI037C", 
! 		  "Oak OTI-057", "Oak OTI-067", "Oak OTI-077",
! 		  "Oak OTI-083", "Oak OTI-087" },
  /* Primus */	{ "Primus P2000" },
! /* Realtek */	{ "Realtek (chipset unknown)",
! 		  "Realtek RT-3103", "Realtek RT-3105", "Realtek RT-3106" },
  /* S3 */	{ "S3 (chipset unknown)",
  		  "S3 86C911", "S3 86C924",
  		  "S3 86C801, A or B-step", 
! 		  "S3 86C801, C-step", "S3 86C801, D-step", 
! 		  "S3 86C801i",
  		  "S3 86C805, A or B-step", 
  		  "S3 86C805, C-step", "S3 86C805, D-step",
+ 		  "S3 86C805i",
  		  "S3 86C928, A,B,C, or D-step", "S3 86C928, E-step",
  		  "S3 86C928PCI" },
  /* Trident */	{ "Trident (chipset unknown)",
+ 		  "Trident LX8200",
  		  "Trident 8800BR", "Trident 8800CS",
! 		  "Trident 8900B", "Trident 8900C", "Trident 8900CL/8900D",
! 		  "Trident 9000", "Trident 9000i",
! 		  "Trident LCD9100B", "Trident 9200CXr", "Trident LCD9320", 
! 		  "Trident 9400CXi", "Trident GUI9420" },
! /* Tseng */	{ "Tseng (chipset unknown(",
! 		  "Tseng ET3000", "Tseng ET4000", 
! 		  "Tseng ET4000/W32", 
! 		  "Tseng ET4000/W32i", "Tseng ET4000/W32p" },
! /* UMC */	{ "UMC 85c408" },
  /* Video7 */	{ "Video7 (chipset unknown)",
! 		  "Video7 FastWrite/VRAM (HT208)", "Video7 1024i (HT208A)",
! 		  "Video7 VRAM II (HT208B)", "Video7 VRAM II (HT208C,D)",
! 		  "Video7 HT216B,C", "Video7 HT216D",
! 		  "Video7 HT216E", "Video7 HT216E",
! 		  "Video7 VEGA" },
! /* WD */	{ "WD/Paradise (chipset unknown)",
! 		  "WD/Paradise PVGA1", "WD/Paradise 90C00", 
  		  "WD/Paradise 90C10", "WD/Paradise 90C11",
  		  "WD/Paradise 90C20", "WD/Paradise 90C20A",
  		  "WD/Paradise 90C22", "WD/Paradise 90C24", 
  		  "WD/Paradise 90C26",
! 		  "WD/Paradise 90C30", "WD/Paradise 90C31",
! 		  "WD/Paradise 90C33" },
! /* Weitek */	{ "Weitek (chipset unknown)",
! 		  "Weitek 5086", "Weitek 5186", "Weitek 5286" },
  /* Yamaha */	{ "Yamaha 6388 VPDC" },
  };
  
***************
*** 105,127 ****
  	"InColor",
  };
  
! static CONST char *RamDac_Names[] =
  {
! 	"Generic 8-bit pseudo-color",
! 	"Avance Logc ALG1101",
! 	"Diamond SS2410",
! 	"Sierra 15-bit HiColor",
! 	"Sierra 15/16-bit HiColor",
! 	"AcuMos ADAC1 15/16/24-bit DAC",
! 	"ATI 68830/75 15/16/24-bit DAC",
! 	"Cirrus Logic Built-in 8-bit pseudo-color DAC",
! 	"Cirrus Logic Built-in 15/16/24-bit DAC",
! 	"AT&T 20C490 15/16/24-bit DAC",
! 	"AT&T 20C491 15/16/24-bit DAC with gamma correction",
! 	"AT&T 20C492 15/16/18-bit DAC with gamma correction",
! 	"AT&T 20C493 15/16/18-bit DAC",
! 	"AT&T 20C497 24-bit wide, 8-bit pseudo-color DAC",
! 	"BrookTree Bt485 24-bit TrueColor DAC w/cursor,pixel-interleave"
  };
  
  static CONST char *CoProc_Names[NUM_CP_TYPES][CHPS_PER_CPTYPE] = 
--- 125,162 ----
  	"InColor",
  };
  
! struct RamDac_Name RamDac_Names[] =
  {
! 	{ "Unknown", "Non-standard but unknown DAC" },
! 	{ "Generic", "Generic 8-bit pseudo-color DAC" },
! 	{ "ALG1101", "Avance Logc ALG1101" },
! 	{ "SS2410", "Diamond SS2410 15/16/24-bit DAC" },
! 	{ "Sierra15", "Sierra SC1148{1,6,8} 15-bit HiColor DAC" },
! 	{ "Sierra16", 
! 	  "Sierra SC1148{2,3,4} 15-bit or SC1148{5,7,9} 15/16-bit HiColor" },
! 	{ "Sierra24", "Sierra 1502{5,6} 15/16/24-bit DAC" },
! 	{ "MU9C4870", "MUSIC MU9C4870 15/16-bit HiColor DAC" },
! 	{ "MU9C4910", "MUSIC MU9C4910 15/16/24-bit DAC" },
! 	{ "ADAC1", "AcuMos ADAC1 15/16/24-bit DAC" },
! 	{ "68830", "ATI 68830 15/16-bit HiColor DAC" },
! 	{ "68860", "ATI 68860 15/15/24-bit DAC w/pixel-mux" },
! 	{ "68875", "ATI-68875/Bt885/TLC34075 15/16/24-bit DAC w/pixel-mux" },
! 	{ "ATIMisc", 
! 	  "ATI Misc 3rd-party {AT&T, BT, Sierra} 15/16/24-bit DAC" },
! 	{ "Cirrus8", "Cirrus Logic Built-in 8-bit pseudo-color DAC" },
! 	{ "Cirrus24B", "Cirrus Logic Built-in 15/16/24-bit DAC" },
! 	{ "Cirrus24", "Cirrus Logic 15/16/24-bit DAC" },
! 	{ "20C490", "AT&T 20C490 15/16/24-bit DAC" },
! 	{ "20C491", "AT&T 20C491 15/16/24-bit DAC with gamma correction" },
! 	{ "20C492", "AT&T 20C492 15/16/18-bit DAC with gamma correction" },
! 	{ "20C493", "AT&T 20C493 15/16/18-bit DAC" },
! 	{ "20C497", "AT&T 20C497 24-bit wide, 8-bit pseudo-color DAC" },
! 	{ "Bt485", "BrookTree Bt485 24-bit TrueColor DAC w/cursor,pixel-mux" },
! 	{ "20C504", "AT&T 20C504 24-bit TrueColor DAC w/cursor,pixel-mux" },
! 	{ "20C505", "AT&T 20C505 24-bit TrueColor DAC w/cursor,pixel-mux" },
! 	{ "TVP3020",
! 	  "TI ViewPoint3020 24-bit TrueColor DAC w/cursor,pixel-mux" },
! 	{ "EDSUN", "EDSUN CEG DAC" },
  };
  
  static CONST char *CoProc_Names[NUM_CP_TYPES][CHPS_PER_CPTYPE] = 
***************
*** 128,142 ****
  {
  /* 8514 */	{ "8514/A (or true clone)",
  		  "ATI Mach-8", "ATI Mach-32",
! 		  "Chips & Technologies 82C480" },
  };
  
- #ifdef __STDC__
- void Print_SVGA_Name(int Chipset)
- #else
  void Print_SVGA_Name(Chipset)
  int Chipset;
- #endif
  {
  	int vendor = SVGA_VENDOR(Chipset);
  	int chip = SVGA_CHIP(Chipset);
--- 163,173 ----
  {
  /* 8514 */	{ "8514/A (or true clone)",
  		  "ATI Mach-8", "ATI Mach-32",
! 		  "Chips & Technologies 82C480 (8514/A clone)" },
  };
  
  void Print_SVGA_Name(Chipset)
  int Chipset;
  {
  	int vendor = SVGA_VENDOR(Chipset);
  	int chip = SVGA_CHIP(Chipset);
***************
*** 148,172 ****
  	}
  }
  
- #ifdef __STDC__
- void Print_Herc_Name(int Chipset)
- #else
  void Print_Herc_Name(Chipset)
  int Chipset;
- #endif
  {
  	int chip = HERC_CHIP(Chipset);
  	printf("\tChipset: %s\n", Herc_Names[chip]);
  }
  
- #ifdef __STDC__
- void Print_RamDac_Name(int RamDac)
- #else
  void Print_RamDac_Name(RamDac)
  int RamDac;
- #endif
  {
! 	printf("\tRAMDAC:  %s\n", RamDac_Names[DAC_CHIP(RamDac)]);
  	if (RamDac & DAC_8BIT)
  	{
  		printf("\t\t (with 8-bit wide lookup tables)\n");
--- 179,195 ----
  	}
  }
  
  void Print_Herc_Name(Chipset)
  int Chipset;
  {
  	int chip = HERC_CHIP(Chipset);
  	printf("\tChipset: %s\n", Herc_Names[chip]);
  }
  
  void Print_RamDac_Name(RamDac)
  int RamDac;
  {
! 	printf("\tRAMDAC:  %s\n", RamDac_Names[DAC_CHIP(RamDac)].Long);
  	if (RamDac & DAC_8BIT)
  	{
  		printf("\t\t (with 8-bit wide lookup tables)\n");
***************
*** 182,193 ****
  	}
  }
  
- #ifdef __STDC__ 
- void Print_CoProc_Name(int CoProc)
- #else
  void Print_CoProc_Name(CoProc)
  int CoProc;
- #endif
  {
  	int class = COPROC_CLASS(CoProc);
  	int chip = COPROC_CHIP(CoProc);
--- 205,212 ----
diff -c mit/server/ddx/x386/SuperProbe/Probe.h:2.9 mit/server/ddx/x386/SuperProbe/Probe.h:2.14
*** mit/server/ddx/x386/SuperProbe/Probe.h:2.9	Fri Mar 11 23:36:21 1994
--- mit/server/ddx/x386/SuperProbe/Probe.h	Fri Mar 11 23:36:21 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Probe.h,v 2.9 1993/10/07 13:54:50 dawes Exp $ */
  
  /*
   * Includes
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Probe.h,v 2.14 1994/02/28 14:09:49 dawes Exp $ */
  
  /*
   * Includes
***************
*** 51,56 ****
--- 51,64 ----
  #endif /* _MINIX */
  #endif
  
+ #ifdef __STDC__
+ # define CONST const
+ # define __STDCARGS(a)	a
+ #else
+ # define CONST
+ # define __STDCARGS(a)	()
+ #endif
+ 
  /*
   * Types
   */
***************
*** 60,72 ****
  typedef int Bool;
  #define FALSE 0
  #define TRUE 1
  
  typedef struct {
  	Word	lo, hi;
  } Range;
  
! typedef Bool (*ProbeFunc)(int *);
  typedef struct {
  	char		*name;		/* Chipset vendor/class name 	*/
  	ProbeFunc	f;		/* Probe function		*/
  	Word		*ports;		/* List of ports used by probe	*/
--- 68,94 ----
  typedef int Bool;
  #define FALSE 0
  #define TRUE 1
+ #ifndef NULL
+ # define NULL	(void *)0
+ #endif
+ 
  
  typedef struct {
  	Word	lo, hi;
  } Range;
  
! typedef Bool (*ProbeFunc) __STDCARGS((int *));
! typedef int (*MemCheckFunc) __STDCARGS((int));
! typedef void (*SetBank) __STDCARGS((int, int, int));
! typedef void (*GetBank) __STDCARGS((int, int *, int *));
  typedef struct {
+ 	int		chipset;	/* Chipset for bank operations	*/
+ 	SetBank		set_bank;	/* Set a read/write bank	*/
+ 	GetBank		get_bank;	/* Get the current bank number	*/
+ 	int		bank_size;	/* Size of a memory bank	*/
+ 	int		max_bank;	/* Maximum bank number 		*/
+ } MemCheck_Descriptor;
+ typedef struct {
  	char		*name;		/* Chipset vendor/class name 	*/
  	ProbeFunc	f;		/* Probe function		*/
  	Word		*ports;		/* List of ports used by probe	*/
***************
*** 74,79 ****
--- 96,102 ----
  	Bool		bit16;		/* Does probe use 16-bit ports?	*/
  	Bool		uses_bios;	/* Does probe read the BIOS?	*/
  	Bool		check_coproc;	/* Check for attached coprocessor */
+ 	MemCheckFunc	memcheck;	/* For doing memory check	*/
  } Chip_Descriptor;
  
  /*
***************
*** 81,218 ****
   */
  
  /* OS_xxxx.c */
! #ifdef __STDC__
! int OpenVideo(void);
! void CloseVideo(void);
! int ReadBIOS(const unsigned, Byte *, const int);
! int EnableIOPorts(const int, const Word *);
! int DisableIOPorts(const int, const Word *);
! void ShortSleep(const int Delay);
! #else /* __STDC__ */
! int OpenVideo();
! void CloseVideo();
! int ReadBIOS();
! int EnableIOPorts();
! int DisableIOPorts();
! void ShortSleep();
! #endif /* __STDC__ */
  
  /* Utils.c */
! #ifdef __STDC__
! Byte inp(Word);
! Word inpw(Word);
! void outp(Word, Byte);
! void outpw(Word, Word);
! Byte rdinx(Word, Byte);
! void wrinx(Word, Byte, Byte);
! void modinx(Word, Byte, Byte, Byte);
! Bool tstrg(Word, Byte);
! Bool testinx2(Word, Byte, Byte);
! Bool testinx(Word, Byte);
! void dactopel(void);
! Byte dactocomm(void);
! Bool Excluded(Range *, Chip_Descriptor *, Bool);
! int StrCaseCmp(char *, char *);
! unsigned int StrToUL(const char *);
! #else /* __STDC__ */
! Byte inp();
! Word inpw();
! void outp();
! void outpw();
! Byte rdinx();
! void wrinx();
! void modinx();
! Bool tstrg();
! Bool testinx2();
! Bool testinx();
! void dactopel();
! Byte dactocomm();
! Bool Excluded();
! int StrCaseCmp();
! unsigned int StrToUL();
! #endif /* __STDC__ */
  
  /*
   * Ident functions
   */
! #ifdef __STDC__
! void Probe_RamDac(int, int *);
! Bool Probe_MDA(int *);
! Bool Probe_Herc(int *);
! Bool Probe_CGA(int *);
! Bool Probe_VGA(int *);
! /* SVGA */
! Bool Probe_Tseng(int *);
! Bool Probe_WD(int *);
! Bool Probe_CT(int *);
! Bool Probe_Video7(int *);
! Bool Probe_Genoa(int *);
! Bool Probe_Trident(int *);
! Bool Probe_Oak(int *);
! Bool Probe_Cirrus(int *);
! Bool Probe_Ahead(int *);
! Bool Probe_ATI(int *);
! Bool Probe_S3(int *);
! Bool Probe_AL(int *);
! Bool Probe_Yamaha(int *);
! Bool Probe_NCR(int *);
! Bool Probe_AcuMos(int *);
! Bool Probe_MX(int *);
! Bool Probe_Primus(int *);
! Bool Probe_RealTek(int *);
! Bool Probe_Compaq(int *);
! /* CoProc */
! Bool Probe_8514(int *);
! Bool Probe_ATIMach(int *);
! #else /* __STDC__ */
! void Probe_RamDac();
! Bool Probe_MDA();
! Bool Probe_Herc();
! Bool Probe_CGA();
! Bool Probe_VGA();
  /* SVGA */
! Bool Probe_Tseng();
! Bool Probe_WD();
! Bool Probe_CT();
! Bool Probe_Video7();
! Bool Probe_Genoa();
! Bool Probe_Trident();
! Bool Probe_Oak();
! Bool Probe_Cirrus();
! Bool Probe_Ahead();
! Bool Probe_ATI();
! Bool Probe_S3();
! Bool Probe_AL();
! Bool Probe_Yamaha();
! Bool Probe_NCR();
! Bool Probe_AcuMos();
! Bool Probe_MX();
! Bool Probe_Primus();
! Bool Probe_RealTek();
! Bool Probe_Compaq();
  /* CoProc */
! Bool Probe_8514();
! Bool Probe_ATIMach();
! #endif /* __STDC__ */
  
  /*
   * Print functions
   */
! #ifdef __STDC__
! void Print_SVGA_Name(int);
! void Print_Herc_Name(int);
! void Print_RamDac_Name(int);
! void Print_CoProc_Name(int);
! #else /* __STDC__ */
! void Print_SVGA_Name();
! void Print_Herc_Name();
! void Print_RamDac_Name();
! void Print_CoProc_Name();
! #endif /* __STDC__ */
! 
! #ifndef __STDC__
! #define const /**/
! #endif
  
  /*
   * Globals
--- 104,189 ----
   */
  
  /* OS_xxxx.c */
! int OpenVideo __STDCARGS((void));
! void CloseVideo __STDCARGS((void));
! Byte *MapVGA __STDCARGS((void));
! void UnMapVGA __STDCARGS((Byte *));
! int ReadBIOS __STDCARGS((const unsigned, Byte *, const int));
! int EnableIOPorts __STDCARGS((const int, const Word *));
! int DisableIOPorts __STDCARGS((const int, const Word *));
! void ShortSleep __STDCARGS((const int Delay));
  
  /* Utils.c */
! Byte inp __STDCARGS((Word));
! Word inpw __STDCARGS((Word));
! void outp __STDCARGS((Word, Byte));
! void outpw __STDCARGS((Word, Word));
! Byte rdinx __STDCARGS((Word, Byte));
! void wrinx __STDCARGS((Word, Byte, Byte));
! void wrinx2 __STDCARGS((Word, Byte, Word));
! void wrinx3 __STDCARGS((Word, Byte, Long));
! void wrinx2m __STDCARGS((Word, Byte, Word));
! void wrinx3m __STDCARGS((Word, Byte, Long));
! void modinx __STDCARGS((Word, Byte, Byte, Byte));
! void modreg __STDCARGS((Word, Byte, Byte));
! void setinx __STDCARGS((Word, Byte, Byte));
! void clrinx __STDCARGS((Word, Byte, Byte));
! Bool tstrg __STDCARGS((Word, Byte));
! Bool testinx2 __STDCARGS((Word, Byte, Byte));
! Bool testinx __STDCARGS((Word, Byte));
! void dactopel __STDCARGS((void));
! Byte trigdac __STDCARGS((void));
! Byte dactocomm __STDCARGS((void));
! Byte getdaccomm __STDCARGS((void));
! void waitforretrace __STDCARGS((void));
! Bool Excluded __STDCARGS((Range *, Chip_Descriptor *, Bool));
! int StrCaseCmp __STDCARGS((char *, char *));
! unsigned int StrToUL __STDCARGS((const char *));
  
  /*
   * Ident functions
   */
! int Probe_Mem __STDCARGS((MemCheck_Descriptor));
! void Probe_RamDac __STDCARGS((int, int *));
! Bool Probe_MDA __STDCARGS((int *));
! Bool Probe_Herc __STDCARGS((int *));
! Bool Probe_CGA __STDCARGS((int *));
! Bool Probe_VGA __STDCARGS((int *));
  /* SVGA */
! Bool Probe_Tseng __STDCARGS((int *));
! Bool Probe_WD __STDCARGS((int *));
! Bool Probe_CT __STDCARGS((int *));
! Bool Probe_Video7 __STDCARGS((int *));
! Bool Probe_Genoa __STDCARGS((int *));
! Bool Probe_Trident __STDCARGS((int *));
! Bool Probe_Oak __STDCARGS((int *));
! Bool Probe_Cirrus __STDCARGS((int *));
! Bool Probe_Cirrus54 __STDCARGS((int *));
! Bool Probe_Cirrus64 __STDCARGS((int *));
! Bool Probe_Ahead __STDCARGS((int *));
! Bool Probe_ATI __STDCARGS((int *));
! Bool Probe_S3 __STDCARGS((int *));
! Bool Probe_AL __STDCARGS((int *));
! Bool Probe_Yamaha __STDCARGS((int *));
! Bool Probe_NCR __STDCARGS((int *));
! Bool Probe_MX __STDCARGS((int *));
! Bool Probe_Primus __STDCARGS((int *));
! Bool Probe_RealTek __STDCARGS((int *));
! Bool Probe_Compaq __STDCARGS((int *));
! Bool Probe_HMC __STDCARGS((int *));
! Bool Probe_UMC __STDCARGS((int *));
! Bool Probe_Weitek __STDCARGS((int *));
  /* CoProc */
! Bool Probe_8514 __STDCARGS((int *));
! Bool Probe_ATIMach __STDCARGS((int *));
  
  /*
   * Print functions
   */
! void Print_SVGA_Name __STDCARGS((int));
! void Print_Herc_Name __STDCARGS((int));
! void Print_RamDac_Name __STDCARGS((int));
! void Print_CoProc_Name __STDCARGS((int));
  
  /*
   * Globals
***************
*** 228,239 ****
  
  extern Chip_Descriptor AL_Descriptor;
  extern Chip_Descriptor ATI_Descriptor;
- extern Chip_Descriptor AcuMos_Descriptor;
  extern Chip_Descriptor Ahead_Descriptor;
  extern Chip_Descriptor CT_Descriptor;
  extern Chip_Descriptor Cirrus_Descriptor;
  extern Chip_Descriptor Compaq_Descriptor;
  extern Chip_Descriptor Genoa_Descriptor;
  extern Chip_Descriptor MX_Descriptor;
  extern Chip_Descriptor NCR_Descriptor;
  extern Chip_Descriptor Oak_Descriptor;
--- 199,212 ----
  
  extern Chip_Descriptor AL_Descriptor;
  extern Chip_Descriptor ATI_Descriptor;
  extern Chip_Descriptor Ahead_Descriptor;
  extern Chip_Descriptor CT_Descriptor;
  extern Chip_Descriptor Cirrus_Descriptor;
+ extern Chip_Descriptor Cirrus54_Descriptor;
+ extern Chip_Descriptor Cirrus64_Descriptor;
  extern Chip_Descriptor Compaq_Descriptor;
  extern Chip_Descriptor Genoa_Descriptor;
+ extern Chip_Descriptor HMC_Descriptor;
  extern Chip_Descriptor MX_Descriptor;
  extern Chip_Descriptor NCR_Descriptor;
  extern Chip_Descriptor Oak_Descriptor;
***************
*** 242,249 ****
--- 215,224 ----
  extern Chip_Descriptor S3_Descriptor;
  extern Chip_Descriptor Trident_Descriptor;
  extern Chip_Descriptor Tseng_Descriptor;
+ extern Chip_Descriptor UMC_Descriptor;
  extern Chip_Descriptor Video7_Descriptor;
  extern Chip_Descriptor WD_Descriptor;
+ extern Chip_Descriptor Weitek_Descriptor;
  extern Chip_Descriptor Yamaha_Descriptor;
  
  extern Chip_Descriptor IBM8514_Descriptor;
***************
*** 256,263 ****
--- 231,251 ----
  #define COPYRIGHT_BASE	(0x1E)
  #define CRTC_IDX	(vgaIOBase+0x04)
  #define CRTC_REG	(vgaIOBase+0x05)
+ #define GRC_IDX		(0x3CE)
+ #define GRC_REG		(0x3CF)
+ #define SEQ_IDX		(0x3C4)
+ #define SEQ_REG		(0x3C5)
+ #define ATR_IDX		(0x3C0)
+ #define ATR_REG_W	(0x3C0)
+ #define ATR_REG_R	(0x3C1)
+ #define MISC_OUT_W	(0x3C2)
+ #define MISC_OUT_R	(0x3CC)
  /* 8514 */
+ #define CONFIG_STATUS_1	0x12EE
+ #define MISC_OPTIONS	0x36EE
+ #define CHIP_ID		0xFAEE
  #define SUBSYS_CNTL	0x42E8
+ #define EXT_CONF_3	0x5EE8
  #define ERR_TERM	0x92E8
  #define GPCTRL_ENAB	0x4000
  #define GPCTRL_RESET	0x8000
***************
*** 271,291 ****
  /*
   * RAMDAC Types
   */
! #define DAC_STANDARD	0	/* Standard 8-bit pseudo-color DAC */
! #define DAC_ALG1101	1	/* Avance Logic ALG1101 */
! #define DAC_SS24	2	/* Diamond SS2410 */
! #define DAC_SIERRA15	3	/* Sierra 15-bit HiColor */
! #define DAC_SIERRA15_16	4	/* Sierra 15/16-bit HiColor */
! #define DAC_ACUMOS	5	/* AcuMos ADAC1 15/16/24-bit DAC */
! #define DAC_ATI		6	/* ATI 68830/75 15/16/24-bit DAC */
! #define DAC_CIRRUSA	7	/* Cirrus 5420 8-bit pseudo-color DAC */
! #define DAC_CIRRUSB	8	/* Cirrus 542{2,4,6} 15/16/24-bit DAC */
! #define DAC_ATT490	9	/* AT&T 20C490 15/16/24-bit DAC */
! #define DAC_ATT491	10	/* AT&T 20C491 15/16/24-bit DAC w/gamma corr */
! #define DAC_ATT492	11	/* AT&T 20C492 15/16/18-bit DAC w/gamma corr */
! #define DAC_ATT493	12	/* AT&T 20C493 15/16/18-bit DAC */
! #define DAC_ATT497	13	/* AT&T 20C497 8-bit PseudoColor,24-bit wide */
! #define DAC_BT485	14	/* BrookTree 485 RAMDAC */
  
  #define DAC_6_8_PROGRAM	0x40	/* RAMDAC programmable for 6/8-bit tables */
  #define DAC_8BIT	0x80	/* RAMDAC with 8-bit wide lookup tables */
--- 259,293 ----
  /*
   * RAMDAC Types
   */
! #define DAC_UNKNOWN	0	/* Non-standard, but unknown */
! #define DAC_STANDARD	1	/* Standard 8-bit pseudo-color DAC */
! #define DAC_ALG1101	2	/* Avance Logic ALG1101 */
! #define DAC_SS24	3	/* Diamond SS2410 */
! #define DAC_SIERRA15	4	/* Sierra 15-bit HiColor */
! #define DAC_SIERRA15_16	5	/* Sierra 15/16-bit HiColor */
! #define DAC_SIERRA24	6	/* Sierra 15/16/24-bit DAC */
! #define DAC_MUSIC4870	7	/* MUSIC 15/16-bit HiColor DAC */
! #define DAC_MUSIC4910	8	/* MUSIC 15/16/24-bit DAC */
! #define DAC_ACUMOS	9	/* AcuMos ADAC1 15/16/24-bit DAC */
! #define DAC_ATI68830	10	/* ATI 68830 15/16-bit DAC */
! #define DAC_ATI68860	11	/* ATI 68860 15/16/24-bit DAC, mux */
! #define DAC_ATI68875	12	/* ATI 68875 15/16/24-bit DAC, mux */
! #define DAC_ATIMISC24	13	/* ATI Miscellaneous 3'rd party DACs */
! #define DAC_CIRRUSA	14	/* Cirrus 5420 8-bit pseudo-color DAC */
! #define DAC_CIRRUSB	15	/* Cirrus 542{2,4,6,8} 15/16/24-bit DAC */
! #define DAC_CIRRUS24	16	/* Cirrus 15/16/24-bit separate DAC */
! #define DAC_ATT490	17	/* AT&T 20C490 15/16/24-bit DAC */
! #define DAC_ATT491	18	/* AT&T 20C491 15/16/24-bit DAC w/gamma corr */
! #define DAC_ATT492	19	/* AT&T 20C492 15/16/18-bit DAC w/gamma corr */
! #define DAC_ATT493	20	/* AT&T 20C493 15/16/18-bit DAC */
! #define DAC_ATT497	21	/* AT&T 20C497 8-bit PseudoColor,24-bit wide */
! #define DAC_BT485	22	/* BrookTree 485 RAMDAC */
! #define DAC_ATT504	23	/* AT&T 20C504 (Bt484 clone, I think) */
! #define DAC_ATT505	24	/* AT&T 20C505 (Bt485 clone) */
! #define DAC_TVP3020	25	/* TI ViewPoint TVP3020 RAMDAC */
! #define DAC_EDSUN	26	/* EDSUN CEG DAC */
! 
! #define DAC_MAX		DAC_EDSUN	/* UPDATE THIS! */
  
  #define DAC_6_8_PROGRAM	0x40	/* RAMDAC programmable for 6/8-bit tables */
  #define DAC_8BIT	0x80	/* RAMDAC with 8-bit wide lookup tables */
***************
*** 294,299 ****
--- 296,311 ----
  
  
  /*
+  * RAMDAC names
+  */
+ 
+ struct RamDac_Name {
+ 	CONST char *Short;
+ 	CONST char *Long;
+ };
+ extern struct RamDac_Name RamDac_Names[];
+ 
+ /*
   * Base chipset classes
   */
  #define CHIP_MDA	0	/* Monochrome Display Adapter */
***************
*** 316,329 ****
   * SVGA cards
   */
  #define SVGA_TYPE(v,n)	(((v) << 16) | ((n) << 8) | CHIP_VGA)
! #define V_ACUMOS	1
! #define V_AHEAD		2
! #define V_ATI		3
! #define V_AL		4
! #define V_CT		5
! #define V_CIRRUS	6
! #define V_COMPAQ	7
! #define V_GENOA		8
  #define V_MX		9
  #define V_NCR		10
  #define V_OAK		11
--- 328,341 ----
   * SVGA cards
   */
  #define SVGA_TYPE(v,n)	(((v) << 16) | ((n) << 8) | CHIP_VGA)
! #define V_AHEAD		1
! #define V_ATI		2
! #define V_AL		3
! #define V_CT		4
! #define V_CIRRUS	5
! #define V_COMPAQ	6
! #define V_GENOA		7
! #define V_HMC		8
  #define V_MX		9
  #define V_NCR		10
  #define V_OAK		11
***************
*** 332,345 ****
  #define V_S3		14
  #define V_TRIDENT	15
  #define V_TSENG		16
! #define V_VIDEO7	17
! #define V_WD		18
! #define V_YAMAHA	19
  
! #define NUM_VENDORS	19
! #define CHPS_PER_VENDOR	20
  
- #define CHIP_ACUMOS	SVGA_TYPE(V_ACUMOS,0)	/* AcuMos AVGA2 	*/
  #define CHIP_AHEAD_UNK	SVGA_TYPE(V_AHEAD,0)	/* Ahead unknown	*/
  #define CHIP_AHEAD_A	SVGA_TYPE(V_AHEAD,1)	/* Ahead V5000 Version A*/
  #define CHIP_AHEAD_B	SVGA_TYPE(V_AHEAD,2)	/* Ahead V5000 Version B*/
--- 344,358 ----
  #define V_S3		14
  #define V_TRIDENT	15
  #define V_TSENG		16
! #define V_UMC		17
! #define V_VIDEO7	18
! #define V_WD		19
! #define V_WEITEK	20
! #define V_YAMAHA	21
  
! #define NUM_VENDORS	21
! #define CHPS_PER_VENDOR	25
  
  #define CHIP_AHEAD_UNK	SVGA_TYPE(V_AHEAD,0)	/* Ahead unknown	*/
  #define CHIP_AHEAD_A	SVGA_TYPE(V_AHEAD,1)	/* Ahead V5000 Version A*/
  #define CHIP_AHEAD_B	SVGA_TYPE(V_AHEAD,2)	/* Ahead V5000 Version B*/
***************
*** 349,356 ****
  #define CHIP_ATI28800_2	SVGA_TYPE(V_ATI,3)	/* ATI 28800-2 		*/
  #define CHIP_ATI28800_4	SVGA_TYPE(V_ATI,4)	/* ATI 28800-4		*/
  #define CHIP_ATI28800_5	SVGA_TYPE(V_ATI,5)	/* ATI 28800-5		*/
! #define CHIP_ATI28800_A	SVGA_TYPE(V_ATI,6)	/* ATI 28800-A		*/
! #define CHIP_ATI28800_C	SVGA_TYPE(V_ATI,7)	/* ATI 28800-C (XLR?)	*/
  #define CHIP_AL2101	SVGA_TYPE(V_AL,0)	/* Avance Logic 2101	*/
  #define CHIP_CT_UNKNOWN	SVGA_TYPE(V_CT,0)	/* C&T unknown		*/
  #define CHIP_CT450	SVGA_TYPE(V_CT,1)	/* C&T 82c450		*/
--- 362,371 ----
  #define CHIP_ATI28800_2	SVGA_TYPE(V_ATI,3)	/* ATI 28800-2 		*/
  #define CHIP_ATI28800_4	SVGA_TYPE(V_ATI,4)	/* ATI 28800-4		*/
  #define CHIP_ATI28800_5	SVGA_TYPE(V_ATI,5)	/* ATI 28800-5		*/
! #define CHIP_ATI68800_3	SVGA_TYPE(V_ATI,6)	/* ATI 68800-3		*/
! #define CHIP_ATI68800_6	SVGA_TYPE(V_ATI,7)	/* ATI 68800-6 		*/
! #define CHIP_ATI68800LX	SVGA_TYPE(V_ATI,8)	/* ATI 68800-LX		*/
! #define CHIP_ATI68800AX	SVGA_TYPE(V_ATI,9)	/* ATI 68800-AX		*/
  #define CHIP_AL2101	SVGA_TYPE(V_AL,0)	/* Avance Logic 2101	*/
  #define CHIP_CT_UNKNOWN	SVGA_TYPE(V_CT,0)	/* C&T unknown		*/
  #define CHIP_CT450	SVGA_TYPE(V_CT,1)	/* C&T 82c450		*/
***************
*** 367,407 ****
  #define CHIP_CL510	SVGA_TYPE(V_CIRRUS,1)	/* Cirrus CL-GD 510/520	*/
  #define CHIP_CL610	SVGA_TYPE(V_CIRRUS,2)	/* Cirrus CL-GD 610/620	*/
  #define CHIP_CLV7	SVGA_TYPE(V_CIRRUS,3)	/* Cirrus Video 7 OEM	*/
! #define CHIP_CL5402	SVGA_TYPE(V_CIRRUS,4)	/* Cirrus 5402		*/
! #define CHIP_CL5402R1	SVGA_TYPE(V_CIRRUS,5)	/* Cirrus 5402 rev 1	*/
! #define CHIP_CL5420	SVGA_TYPE(V_CIRRUS,6)	/* Cirrus 5420		*/
! #define CHIP_CL5420R1	SVGA_TYPE(V_CIRRUS,7)	/* Cirrus 5420 rev 1	*/
! #define CHIP_CL5422	SVGA_TYPE(V_CIRRUS,8)	/* Cirrus 5422		*/
! #define CHIP_CL5424	SVGA_TYPE(V_CIRRUS,9)	/* Cirrus 5424		*/
! #define CHIP_CL5426	SVGA_TYPE(V_CIRRUS,10)	/* Cirrus 5426		*/
! #define CHIP_CL5428	SVGA_TYPE(V_CIRRUS,11)	/* Cirrus 5428		*/
! #define CHIP_CL6205	SVGA_TYPE(V_CIRRUS,12)	/* Cirrus 6205		*/
! #define CHIP_CL6215	SVGA_TYPE(V_CIRRUS,13)	/* Cirrus 6215		*/
! #define CHIP_CL6225	SVGA_TYPE(V_CIRRUS,14)	/* Cirrus 6225		*/
! #define CHIP_CL6235	SVGA_TYPE(V_CIRRUS,15)	/* Cirrus 6235		*/
! #define CHIP_CL6410	SVGA_TYPE(V_CIRRUS,16)	/* Cirrus 6410		*/
! #define CHIP_CL6420A	SVGA_TYPE(V_CIRRUS,17)	/* Cirrus 6420A		*/
! #define CHIP_CL6420B	SVGA_TYPE(V_CIRRUS,18)	/* Cirrus 6420B		*/
  #define CHIP_CPQ_UNK	SVGA_TYPE(V_COMPAQ,0)	/* Compaq unknown	*/
! #define CHIP_CPQ_AVGA	SVGA_TYPE(V_COMPAQ,1)	/* Compaq Advanced VGA	*/
! #define CHIP_CPQ_Q1024	SVGA_TYPE(V_COMPAQ,2)	/* Compaq QVision/1024	*/
! #define CHIP_CPQ_Q1280	SVGA_TYPE(V_COMPAQ,3)	/* Compaq QVision/1280	*/
  #define CHIP_G_6100	SVGA_TYPE(V_GENOA,0)	/* Genoa GVGA 6100	*/
  #define CHIP_G_6200	SVGA_TYPE(V_GENOA,1)	/* Genoa GVGA 6200	*/
  #define CHIP_G_6400	SVGA_TYPE(V_GENOA,2)	/* Genoa GVGA 6400	*/
! #define CHIP_MX68010	SVGA_TYPE(V_MX,0)	/* MX 68010		*/
  #define CHIP_NCR_UNK	SVGA_TYPE(V_NCR,0)	/* NCR unknown		*/
  #define CHIP_NCR77C21	SVGA_TYPE(V_NCR,1)	/* NCR 77C21		*/
  #define CHIP_NCR77C22	SVGA_TYPE(V_NCR,2)	/* NCR 77C22		*/
  #define CHIP_NCR77C22E	SVGA_TYPE(V_NCR,3)	/* NCR 77C22E		*/
  #define CHIP_NCR77C22EP	SVGA_TYPE(V_NCR,4)	/* NCR 77C22E+		*/
  #define CHIP_OAK_UNK	SVGA_TYPE(V_OAK,0)	/* OAK unknown		*/
  #define CHIP_OAK037C	SVGA_TYPE(V_OAK,1)	/* OAK OTI037C		*/
  #define CHIP_OAK057	SVGA_TYPE(V_OAK,2)	/* OAK OTI-057		*/
  #define CHIP_OAK067	SVGA_TYPE(V_OAK,3)	/* OAK OTI-067		*/
  #define CHIP_OAK077	SVGA_TYPE(V_OAK,4)	/* OAK OTI-077		*/
  #define CHIP_P2000	SVGA_TYPE(V_PRIMUS,0)	/* Primus P2000		*/
! #define CHIP_REALTEK	SVGA_TYPE(V_REALTEK,0)	/* Realtek RT 3106	*/
  #define CHIP_S3_UNKNOWN	SVGA_TYPE(V_S3,0)	/* S3 unknown		*/
  #define CHIP_S3_911	SVGA_TYPE(V_S3,1)	/* S3 86c911		*/
  #define CHIP_S3_924	SVGA_TYPE(V_S3,2)	/* S3 86c924 or 911A	*/
--- 382,437 ----
  #define CHIP_CL510	SVGA_TYPE(V_CIRRUS,1)	/* Cirrus CL-GD 510/520	*/
  #define CHIP_CL610	SVGA_TYPE(V_CIRRUS,2)	/* Cirrus CL-GD 610/620	*/
  #define CHIP_CLV7	SVGA_TYPE(V_CIRRUS,3)	/* Cirrus Video 7 OEM	*/
! #define CHIP_CLAVGA2	SVGA_TYPE(V_CIRRUS,4)	/* Cirrus/AcuMos AVGA2	*/
! #define CHIP_CL5402	SVGA_TYPE(V_CIRRUS,5)	/* Cirrus 5402		*/
! #define CHIP_CL5402R1	SVGA_TYPE(V_CIRRUS,6)	/* Cirrus 5402 rev 1	*/
! #define CHIP_CL5420	SVGA_TYPE(V_CIRRUS,7)	/* Cirrus 5420		*/
! #define CHIP_CL5420R1	SVGA_TYPE(V_CIRRUS,8)	/* Cirrus 5420 rev 1	*/
! #define CHIP_CL5422	SVGA_TYPE(V_CIRRUS,9)	/* Cirrus 5422		*/
! #define CHIP_CL5424	SVGA_TYPE(V_CIRRUS,10)	/* Cirrus 5424		*/
! #define CHIP_CL5426	SVGA_TYPE(V_CIRRUS,11)	/* Cirrus 5426		*/
! #define CHIP_CL5428	SVGA_TYPE(V_CIRRUS,12)	/* Cirrus 5428		*/
! #define CHIP_CL543X	SVGA_TYPE(V_CIRRUS,13)	/* Cirrus 543x		*/
! #define CHIP_CL6205	SVGA_TYPE(V_CIRRUS,14)	/* Cirrus 6205		*/
! #define CHIP_CL6215	SVGA_TYPE(V_CIRRUS,15)	/* Cirrus 6215		*/
! #define CHIP_CL6225	SVGA_TYPE(V_CIRRUS,16)	/* Cirrus 6225		*/
! #define CHIP_CL6235	SVGA_TYPE(V_CIRRUS,17)	/* Cirrus 6235		*/
! #define CHIP_CL5410	SVGA_TYPE(V_CIRRUS,18)	/* Cirrus 6510		*/
! #define CHIP_CL6410	SVGA_TYPE(V_CIRRUS,19)	/* Cirrus 6410		*/
! #define CHIP_CL6412	SVGA_TYPE(V_CIRRUS,20)	/* Cirrus 6412		*/
! #define CHIP_CL6420A	SVGA_TYPE(V_CIRRUS,21)	/* Cirrus 6420A		*/
! #define CHIP_CL6420B	SVGA_TYPE(V_CIRRUS,22)	/* Cirrus 6420B		*/
! #define CHIP_CL6440	SVGA_TYPE(V_CIRRUS,23)	/* Cirrus 6440		*/
  #define CHIP_CPQ_UNK	SVGA_TYPE(V_COMPAQ,0)	/* Compaq unknown	*/
! #define CHIP_CPQ_IVGS	SVGA_TYPE(V_COMPAQ,1)	/* Compaq Int Vid Gr Sys*/
! #define CHIP_CPQ_AVGA	SVGA_TYPE(V_COMPAQ,2)	/* Compaq Advanced VGA	*/
! #define CHIP_CPQ_Q1024	SVGA_TYPE(V_COMPAQ,3)	/* Compaq QVision/1024	*/
! #define CHIP_CPQ_Q1280	SVGA_TYPE(V_COMPAQ,4)	/* Compaq QVision/1280	*/
! #define CHIP_CPQ_AVGA_P	SVGA_TYPE(V_COMPAQ,5)	/* Compaq AVGA Portable	*/
  #define CHIP_G_6100	SVGA_TYPE(V_GENOA,0)	/* Genoa GVGA 6100	*/
  #define CHIP_G_6200	SVGA_TYPE(V_GENOA,1)	/* Genoa GVGA 6200	*/
  #define CHIP_G_6400	SVGA_TYPE(V_GENOA,2)	/* Genoa GVGA 6400	*/
! #define CHIP_HM86304	SVGA_TYPE(V_HMC,0)	/* HMC HM86304		*/
! #define CHIP_MX68000	SVGA_TYPE(V_MX,0)	/* MX 68000		*/
! #define CHIP_MX68010	SVGA_TYPE(V_MX,1)	/* MX 68010		*/
  #define CHIP_NCR_UNK	SVGA_TYPE(V_NCR,0)	/* NCR unknown		*/
  #define CHIP_NCR77C21	SVGA_TYPE(V_NCR,1)	/* NCR 77C21		*/
  #define CHIP_NCR77C22	SVGA_TYPE(V_NCR,2)	/* NCR 77C22		*/
  #define CHIP_NCR77C22E	SVGA_TYPE(V_NCR,3)	/* NCR 77C22E		*/
  #define CHIP_NCR77C22EP	SVGA_TYPE(V_NCR,4)	/* NCR 77C22E+		*/
+ #define CHIP_NCR77C32B	SVGA_TYPE(V_NCR,5)	/* NCR 77C32BLT		*/
  #define CHIP_OAK_UNK	SVGA_TYPE(V_OAK,0)	/* OAK unknown		*/
  #define CHIP_OAK037C	SVGA_TYPE(V_OAK,1)	/* OAK OTI037C		*/
  #define CHIP_OAK057	SVGA_TYPE(V_OAK,2)	/* OAK OTI-057		*/
  #define CHIP_OAK067	SVGA_TYPE(V_OAK,3)	/* OAK OTI-067		*/
  #define CHIP_OAK077	SVGA_TYPE(V_OAK,4)	/* OAK OTI-077		*/
+ #define CHIP_OAK083	SVGA_TYPE(V_OAK,5)	/* OAK OTI-083		*/
+ #define CHIP_OAK087	SVGA_TYPE(V_OAK,6)	/* OAK OTI-087		*/
  #define CHIP_P2000	SVGA_TYPE(V_PRIMUS,0)	/* Primus P2000		*/
! #define CHIP_RT_UNK	SVGA_TYPE(V_REALTEK,0)	/* Realtek unknown	*/
! #define CHIP_RT_3103	SVGA_TYPE(V_REALTEK,1)	/* Realtek RT3103	*/
! #define CHIP_RT_3105	SVGA_TYPE(V_REALTEK,2)	/* Realtek RT3105	*/
! #define CHIP_RT_3106	SVGA_TYPE(V_REALTEK,3)	/* Realtek RT3106	*/
  #define CHIP_S3_UNKNOWN	SVGA_TYPE(V_S3,0)	/* S3 unknown		*/
  #define CHIP_S3_911	SVGA_TYPE(V_S3,1)	/* S3 86c911		*/
  #define CHIP_S3_924	SVGA_TYPE(V_S3,2)	/* S3 86c924 or 911A	*/
***************
*** 408,447 ****
  #define CHIP_S3_801B	SVGA_TYPE(V_S3,3)	/* S3 86c801 A-B step	*/
  #define CHIP_S3_801C	SVGA_TYPE(V_S3,4)	/* S3 86c801 C step	*/
  #define CHIP_S3_801D	SVGA_TYPE(V_S3,5)	/* S3 86c801 D step	*/
! #define CHIP_S3_805B	SVGA_TYPE(V_S3,6)	/* S3 86c805 A-B step	*/
! #define CHIP_S3_805C	SVGA_TYPE(V_S3,7)	/* S3 86c805 C step	*/
! #define CHIP_S3_805D	SVGA_TYPE(V_S3,8)	/* S3 86c805 D step	*/
! #define CHIP_S3_928D	SVGA_TYPE(V_S3,9)	/* S3 86c928 A-D step	*/
! #define CHIP_S3_928E	SVGA_TYPE(V_S3,10)	/* S3 86c928 E-step	*/
! #define CHIP_S3_928P	SVGA_TYPE(V_S3,11)	/* S3 86c928PCI		*/
  #define CHIP_TVGA_UNK	SVGA_TYPE(V_TRIDENT,0)	/* Trident unknown	*/
! #define CHIP_TVGA8800BR	SVGA_TYPE(V_TRIDENT,1)	/* Trident 8800BR	*/
! #define CHIP_TVGA8800CS	SVGA_TYPE(V_TRIDENT,2)	/* Trident 8800CS	*/
! #define CHIP_TVGA8900B	SVGA_TYPE(V_TRIDENT,3)	/* Trident 8900B	*/
! #define CHIP_TVGA8900C	SVGA_TYPE(V_TRIDENT,4)	/* Trident 8900C	*/
! #define CHIP_TVGA8900CL	SVGA_TYPE(V_TRIDENT,5)	/* Trident 8900CL	*/
! #define CHIP_TVGA9000	SVGA_TYPE(V_TRIDENT,6)	/* Trident 9000		*/
! #define CHIP_TVGA9100	SVGA_TYPE(V_TRIDENT,7)	/* Trident LCD9100	*/
! #define CHIP_TVGA9200	SVGA_TYPE(V_TRIDENT,8)	/* Trident LX9200	*/
! #define CHIP_ET3000	SVGA_TYPE(V_TSENG,0)	/* Tseng ET3000		*/
! #define CHIP_ET4000	SVGA_TYPE(V_TSENG,1)	/* Tseng ET4000		*/
! #define CHIP_ET4000_W32	SVGA_TYPE(V_TSENG,2)	/* Tseng ET4000/W32	*/
  #define CHIP_V7_UNKNOWN	SVGA_TYPE(V_VIDEO7,0)	/* Video7 unknown	*/
! #define CHIP_V7_VEGA	SVGA_TYPE(V_VIDEO7,1)	/* Video7 VEGA		*/
! #define CHIP_V7_FWRITE	SVGA_TYPE(V_VIDEO7,2)	/* Video7 Fastwrite/VRAM*/
! #define CHIP_V7_VRAM2	SVGA_TYPE(V_VIDEO7,3)	/* Video7 VRAM II	*/
! #define CHIP_V7_1024i	SVGA_TYPE(V_VIDEO7,4)	/* Video7 1024i		*/
! #define CHIP_WD_PVGA1	SVGA_TYPE(V_WD,0)	/* WD PVGA1		*/
! #define CHIP_WD_90C00	SVGA_TYPE(V_WD,1)	/* WD 90C00		*/
! #define CHIP_WD_90C10	SVGA_TYPE(V_WD,2)	/* WD 90C10		*/
! #define CHIP_WD_90C11	SVGA_TYPE(V_WD,3)	/* WD 90C11		*/
! #define CHIP_WD_90C20	SVGA_TYPE(V_WD,4)	/* WD 90C20		*/
! #define CHIP_WD_90C20A	SVGA_TYPE(V_WD,5)	/* WD 90C20A		*/
! #define CHIP_WD_90C22	SVGA_TYPE(V_WD,6)	/* WD 90C22		*/
! #define CHIP_WD_90C24	SVGA_TYPE(V_WD,7)	/* WD 90C24		*/
! #define CHIP_WD_90C26	SVGA_TYPE(V_WD,8)	/* WD 90C26		*/
! #define CHIP_WD_90C30	SVGA_TYPE(V_WD,9)	/* WD 90C30		*/
! #define CHIP_WD_90C31	SVGA_TYPE(V_WD,10)	/* WD 90C31		*/
  #define CHIP_YAMAHA6388	SVGA_TYPE(V_YAMAHA,0)	/* Yamaha 6388 VPDC	*/
  
  /*
--- 438,499 ----
  #define CHIP_S3_801B	SVGA_TYPE(V_S3,3)	/* S3 86c801 A-B step	*/
  #define CHIP_S3_801C	SVGA_TYPE(V_S3,4)	/* S3 86c801 C step	*/
  #define CHIP_S3_801D	SVGA_TYPE(V_S3,5)	/* S3 86c801 D step	*/
! #define CHIP_S3_801I	SVGA_TYPE(V_S3,6)	/* S3 86c801i (?)	*/
! #define CHIP_S3_805B	SVGA_TYPE(V_S3,7)	/* S3 86c805 A-B step	*/
! #define CHIP_S3_805C	SVGA_TYPE(V_S3,8)	/* S3 86c805 C step	*/
! #define CHIP_S3_805D	SVGA_TYPE(V_S3,9)	/* S3 86c805 D step	*/
! #define CHIP_S3_805I	SVGA_TYPE(V_S3,10)	/* S3 86c805i		*/
! #define CHIP_S3_928D	SVGA_TYPE(V_S3,11)	/* S3 86c928 A-D step	*/
! #define CHIP_S3_928E	SVGA_TYPE(V_S3,12)	/* S3 86c928 E-step	*/
! #define CHIP_S3_928P	SVGA_TYPE(V_S3,13)	/* S3 86c928PCI		*/
  #define CHIP_TVGA_UNK	SVGA_TYPE(V_TRIDENT,0)	/* Trident unknown	*/
! #define CHIP_TVGA8200	SVGA_TYPE(V_TRIDENT,1)	/* Trident LX8200	*/
! #define CHIP_TVGA8800BR	SVGA_TYPE(V_TRIDENT,2)	/* Trident 8800BR	*/
! #define CHIP_TVGA8800CS	SVGA_TYPE(V_TRIDENT,3)	/* Trident 8800CS	*/
! #define CHIP_TVGA8900B	SVGA_TYPE(V_TRIDENT,4)	/* Trident 8900B	*/
! #define CHIP_TVGA8900C	SVGA_TYPE(V_TRIDENT,5)	/* Trident 8900C	*/
! #define CHIP_TVGA8900CL	SVGA_TYPE(V_TRIDENT,6)	/* Trident 8900CL	*/
! #define CHIP_TVGA9000	SVGA_TYPE(V_TRIDENT,7)	/* Trident 9000		*/
! #define CHIP_TVGA9000I	SVGA_TYPE(V_TRIDENT,8)	/* Trident 9000i	*/
! #define CHIP_TVGA9100B	SVGA_TYPE(V_TRIDENT,9)	/* Trident LCD9100B	*/
! #define CHIP_TVGA9200CX	SVGA_TYPE(V_TRIDENT,10)	/* Trident 9200CXr	*/
! #define CHIP_TVGA9320	SVGA_TYPE(V_TRIDENT,11)	/* Trident LCD9320	*/
! #define CHIP_TVGA9400CX	SVGA_TYPE(V_TRIDENT,12)	/* Trident 9400CXi	*/
! #define CHIP_TVGA9420	SVGA_TYPE(V_TRIDENT,13)	/* Trident GUI9420	*/
! #define CHIP_TSENG_UNK	SVGA_TYPE(V_TSENG,0)	/* Tseng unknown	*/
! #define CHIP_ET3000	SVGA_TYPE(V_TSENG,1)	/* Tseng ET3000		*/
! #define CHIP_ET4000	SVGA_TYPE(V_TSENG,2)	/* Tseng ET4000		*/
! #define CHIP_ET4000W32	SVGA_TYPE(V_TSENG,3)	/* Tseng ET4000/W32	*/
! #define CHIP_ET4000W32I	SVGA_TYPE(V_TSENG,4)	/* Tseng ET4000/W32i	*/
! #define CHIP_ET4000W32P	SVGA_TYPE(V_TSENG,5)	/* Tseng ET4000/W32p	*/
! #define CHIP_UMC_408	SVGA_TYPE(V_UMC,0)	/* UMC 85c408		*/
  #define CHIP_V7_UNKNOWN	SVGA_TYPE(V_VIDEO7,0)	/* Video7 unknown	*/
! #define CHIP_V7_FWRITE	SVGA_TYPE(V_VIDEO7,1)	/* Video7 Fastwrite/VRAM*/
! #define CHIP_V7_1024i	SVGA_TYPE(V_VIDEO7,2)	/* Video7 1024i		*/
! #define CHIP_V7_VRAM2_B	SVGA_TYPE(V_VIDEO7,3)	/* Video7 VRAM II (B)	*/
! #define CHIP_V7_VRAM2_C	SVGA_TYPE(V_VIDEO7,4)	/* Video7 VRAM II (C,D)	*/
! #define CHIP_HT216BC	SVGA_TYPE(V_VIDEO7,5)	/* Video7 HT216B,C	*/
! #define CHIP_HT216D	SVGA_TYPE(V_VIDEO7,6)	/* Video7 HT216D	*/
! #define CHIP_HT216E	SVGA_TYPE(V_VIDEO7,7)	/* Video7 HT216E	*/
! #define CHIP_HT216F	SVGA_TYPE(V_VIDEO7,8)	/* Video7 HT216F	*/
! #define CHIP_V7_VEGA	SVGA_TYPE(V_VIDEO7,9)	/* Video7 VEGA		*/
! #define CHIP_WD_UNK	SVGA_TYPE(V_WD,0)	/* WD unknown		*/
! #define CHIP_WD_PVGA1	SVGA_TYPE(V_WD,1)	/* WD PVGA1		*/
! #define CHIP_WD_90C00	SVGA_TYPE(V_WD,2)	/* WD 90C00		*/
! #define CHIP_WD_90C10	SVGA_TYPE(V_WD,3)	/* WD 90C10		*/
! #define CHIP_WD_90C11	SVGA_TYPE(V_WD,4)	/* WD 90C11		*/
! #define CHIP_WD_90C20	SVGA_TYPE(V_WD,5)	/* WD 90C20		*/
! #define CHIP_WD_90C20A	SVGA_TYPE(V_WD,6)	/* WD 90C20A		*/
! #define CHIP_WD_90C22	SVGA_TYPE(V_WD,7)	/* WD 90C22		*/
! #define CHIP_WD_90C24	SVGA_TYPE(V_WD,8)	/* WD 90C24		*/
! #define CHIP_WD_90C26	SVGA_TYPE(V_WD,9)	/* WD 90C26		*/
! #define CHIP_WD_90C30	SVGA_TYPE(V_WD,10)	/* WD 90C30		*/
! #define CHIP_WD_90C31	SVGA_TYPE(V_WD,11)	/* WD 90C31		*/
! #define CHIP_WD_90C33	SVGA_TYPE(V_WD,12)	/* WD 90C33		*/
! #define CHIP_WEIT_UNK	SVGA_TYPE(V_WEITEK,0)	/* Weitek unknown	*/
! #define CHIP_WEIT_5086	SVGA_TYPE(V_WEITEK,1)	/* Weitek 5086		*/
! #define CHIP_WEIT_5186	SVGA_TYPE(V_WEITEK,2)	/* Weitek 5186		*/
! #define CHIP_WEIT_5286	SVGA_TYPE(V_WEITEK,3)	/* Weitek 5286		*/
  #define CHIP_YAMAHA6388	SVGA_TYPE(V_YAMAHA,0)	/* Yamaha 6388 VPDC	*/
  
  /*
***************
*** 458,466 ****
  #define CHIP_MACH8	COPROC_TYPE(C_8514,1)	/* ATI Mach-8		*/
  #define CHIP_MACH32	COPROC_TYPE(C_8514,2)	/* ATI Mach-32		*/
  #define CHIP_CT480	COPROC_TYPE(C_8514,3)	/* C&T 82c480		*/
- 
- #define NUM_COPROC_TYPE	1
- #define CHPS_PER_TYPE	6
  
  /*
   * Useful macros
--- 510,515 ----
diff -c mit/server/ddx/x386/SuperProbe/RamDac.c:2.3 mit/server/ddx/x386/SuperProbe/RamDac.c:2.10
*** mit/server/ddx/x386/SuperProbe/RamDac.c:2.3	Fri Mar 11 23:36:22 1994
--- mit/server/ddx/x386/SuperProbe/RamDac.c	Fri Mar 11 23:36:23 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,39 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/RamDac.c,v 2.3 1993/09/27 12:23:25 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0, 0, 0x3C6, 0x3C7, 0x3C8, 0x3C9};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
! #if __STDC__
! static Bool Width8Check(void)
  #else
  static Bool Width8Check()
  #endif
  {
  	int i;
  	Byte save[3];
  	Bool result = FALSE;
--- 21,650 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/RamDac.c,v 2.10 1994/03/05 01:58:49 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, 0x3C6, 0x3C7, 0x3C8, 0x3C9};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
! #define RED	0
! #define GREEN	1
! #define BLUE	2
! 
! static void ReadPelReg __STDCARGS((Byte, Byte *));
! static void WritePelReg __STDCARGS((Byte, Byte *));
! static Byte SetComm __STDCARGS((Byte));
! static Bool Width8Check __STDCARGS((void));
! static Bool TestDACBit __STDCARGS((Byte, Byte, Byte));
! static Bool S3_Bt485Check __STDCARGS((int *));
! static Bool S3_TVP3020Check __STDCARGS((int *));
! static void CheckMach32 __STDCARGS((int *));
! 
! #ifdef __STDC__
! static void ReadPelReg(Byte Index, Byte *Pixel)
! #else
! static void ReadPelReg(Index, Pixel)
! Byte Index;
! Byte *Pixel;
! #endif
! {
! 	outp(0x3C7, Index);
! 	Pixel[RED] = inp(0x3C9);
! 	Pixel[GREEN] = inp(0x3C9);
! 	Pixel[BLUE] = inp(0x3C9);
! 
! 	return;
! }
! 
! #ifdef __STDC__
! static void WritePelReg(Byte Index, Byte *Pixel)
! #else
! static void WritePelReg(Index, Pixel)
! Byte Index;
! Byte *Pixel;
! #endif
! {
! 	outp(0x3C8, Index);
! 	outp(0x3C9, Pixel[RED]);
! 	outp(0x3C9, Pixel[GREEN]);
! 	outp(0x3C9, Pixel[BLUE]);
! 	return;
! }
! 
! #ifdef __STDC__
! static Byte SetComm(Byte Comm)
  #else
+ static Byte SetComm(Comm)
+ Byte Comm;
+ #endif
+ {
+ 	(void) dactocomm();
+ 	outp(0x3C6, Comm);
+ 	(void) dactocomm();
+ 	return(inp(0x3C6));
+ }
+ 
  static Bool Width8Check()
+ {
+ 	Byte old, x, v;
+ 	Byte pix[3];
+ 
+ 	old = inp(0x3C8);
+ 	ReadPelReg(0xFF, pix);
+ 	v = pix[RED];
+ 	pix[RED]= 0xFF;
+ 	WritePelReg(0xFF, pix);
+ 	ReadPelReg(0xFF, pix);
+ 	x = pix[RED];
+ 	pix[RED] = v;
+ 	WritePelReg(0xFF, pix);
+ 	outp(0x3C8, old);
+ 	return(x == 0xFF);
+ }
+ 
+ #ifdef __STDC__
+ static Bool TestDACBit(Byte Bit, Byte OldComm, Byte OldPel)
+ #else
+ static Bool TestDACBit(Bit, OldComm, OldPel)
+ Byte Bit;
+ Byte OldComm;
+ Byte OldPel;
  #endif
  {
+ 	Byte tmp;
+ 
+ 	dactopel();
+ 	outp(0x3C6, OldPel & (Bit ^ 0xFF));
+ 	(void) dactocomm();
+ 	outp(0x3C6, OldComm | Bit);
+ 	tmp = inp(0x3C6);
+ 	outp(0x3C6, tmp & (Bit ^ 0xFF));
+ 	return((tmp & Bit) != 0);
+ }
+ 
+ static Bool S3_Bt485Check(RamDac)
+ int *RamDac;
+ {
+ 	Byte old1, old2, old3, old4;
+ 	Byte lock1, lock2;
+ 	Bool Found = FALSE;
+ 	Bool DoChecks = FALSE;
+ 
+ 	lock1 = rdinx(CRTC_IDX, 0x38);
+ 	lock2 = rdinx(CRTC_IDX, 0x39);
+ 	wrinx(CRTC_IDX, 0x38, 0x48);
+ 	wrinx(CRTC_IDX, 0x39, 0xA5);
+ 
+ 	old1 = inp(0x3C6);
+ 	old2 = rdinx(CRTC_IDX, 0x55);
+ 	outp(0x3C6, 0x0F);
+ 	wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x02);
+ 	old3 = inp(0x3C6);
+ 	if ((old3 & 0x80) == 0x80)
+ 	{
+ 		Found = TRUE;
+ 		if ((old3 & 0xC0) == 0x80)
+ 		{
+ 			*RamDac = DAC_BT485;
+ 			DoChecks = TRUE;
+ 		}
+ 		else if ((old3 & 0xF0) == 0xD0)
+ 		{
+ 			DoChecks = TRUE;
+ 			*RamDac = DAC_ATT505;
+ 		}
+ 		else
+ 		{
+ 			*RamDac = DAC_UNKNOWN;
+ 		}
+ 	}
+ 	else if ((old3 & 0xF0) == 0x40)
+ 	{
+ 		Found = TRUE;
+ 		*RamDac = DAC_ATT504;
+ 		DoChecks = TRUE;
+ 	}
+ 	else
+ 	{
+ 		/* Perhaps status reg is hidden behind CR3 */
+ 		wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x01);
+ 		old3 = inp(0x3C6);
+ 		if ((old3 & 0x80) == 0x80)
+ 		{
+ 			/* OK.  CR3 is active... */
+ 			wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x00);
+ 			old3 = inp(0x3C8);
+ 			outp(0x3C8, 0x00);
+ 			wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x02);
+ 			old4 = inp(0x3C6);
+ 			if ((old4 & 0x80) == 0x80)
+ 			{
+ 				Found = TRUE;
+ 				if ((old4 & 0xC0) == 0x80)
+ 				{
+ 					*RamDac = DAC_BT485;
+ 				}
+ 				else if ((old4 & 0xF0) == 0xD0)
+ 				{
+ 					*RamDac = DAC_ATT505;
+ 				}
+ 				else
+ 				{
+ 					*RamDac = DAC_UNKNOWN;
+ 				}
+ 			}
+ 			else if ((old4 & 0xF0) == 0x40)
+ 			{
+ 				Found = TRUE;
+ 				*RamDac = DAC_ATT504;
+ 			}
+ 			if ((Found) && (*RamDac != DAC_UNKNOWN))
+ 			{
+ 				*RamDac |= DAC_6_8_PROGRAM;
+ 				if (Width8Check())
+ 				{
+ 					*RamDac |= DAC_8BIT;
+ 				}
+ 			}
+ 			wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x00);
+ 			outp(0x3C8, old3);
+ 		}
+ 	}
+ 	if (DoChecks)
+ 	{
+ 		*RamDac |= DAC_6_8_PROGRAM;
+ 		if (Width8Check())
+ 		{
+ 			*RamDac |= DAC_8BIT;
+ 		}
+ 	}
+ 	wrinx(CRTC_IDX, 0x55, old2);
+ 	outp(0x3C6, old1);
+ 
+ 	wrinx(CRTC_IDX, 0x39, lock2);
+ 	wrinx(CRTC_IDX, 0x38, lock1);
+ 
+ 	return(Found);
+ }
+ 
+ static Bool S3_TVP3020Check(RamDac)
+ int *RamDac;
+ {
+ 	Byte old1, old2, old3, old4;
+ 	Byte lock1, lock2;
+ 	Bool Found = FALSE;
+ 
+ 	/*
+ 	 * TI ViewPoint TVP3020 support - Robin Cutshaw
+ 	 *
+ 	 * The 3020 has 8 direct registers accessed through standard
+ 	 * VGA registers 0x3C8, 0x3C9, 0x3C6, and 0x3C7.  Bit 0 of
+ 	 * CR55 is used to map these four register to the low four
+ 	 * or high four direct 3020 registers.  The high register set
+ 	 * includes index and data registers which are used to address
+ 	 * indirect registers 0x00-0x3F and 0xFF.  Indirect register
+ 	 * 0x3F is the chip ID register which will always return 0x20.
+ 	 */
+ 
+ 	lock1 = rdinx(CRTC_IDX, 0x38);
+ 	lock2 = rdinx(CRTC_IDX, 0x39);
+ 	wrinx(CRTC_IDX, 0x38, 0x48);
+ 	wrinx(CRTC_IDX, 0x39, 0xA5);
+ 
+ 	old1 = inp(0x3C6);
+ 	old2 = rdinx(CRTC_IDX, 0x55);
+ 
+ 	wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x01); /* high four registers */
+ 	old3 = inp(0x3C6);             /* read current index register value */
+ 
+ 	outp(0x3C6, 0x3F);     /* write ID register index to index register */
+ 	old4 = inp(0x3C7);     /* read ID register from data register       */
+ 	if (old4 == 0x20) {
+ 		Found = TRUE;
+ 		*RamDac = DAC_TVP3020;
+ 		*RamDac |= DAC_6_8_PROGRAM;
+ 		wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x00); /* regular VGA */
+ 		if (Width8Check())
+ 		{
+ 			*RamDac |= DAC_8BIT;
+ 		}
+ 	}
+ 
+ 	wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x01); /* high four registers */
+ 	outp(0x3C6, old3);                  /* restore index register value */
+ 
+ 	wrinx(CRTC_IDX, 0x55, old2);
+ 	outp(0x3C6, old1);
+ 
+ 	wrinx(CRTC_IDX, 0x39, lock2);
+ 	wrinx(CRTC_IDX, 0x38, lock1);
+ 
+ 	return(Found);
+ }
+ 
+ static void CheckMach32(RamDac)
+ int *RamDac;
+ {
+ 	Word Port = CONFIG_STATUS_1;
+ 
+ 	EnableIOPorts(1, &Port);
+ 
+ 	switch ((inpw(CONFIG_STATUS_1) & 0x0E00) >> 9)
+ 	{
+ 	case 0x00:
+ 		*RamDac = DAC_ATI68830;
+ 		break;
+ 	case 0x01:
+ 		*RamDac = DAC_SIERRA15_16;
+ 		break;
+ 	case 0x02:
+ 		*RamDac = DAC_ATI68875;
+ 		*RamDac |= DAC_6_8_PROGRAM;
+ 		if (Width8Check())
+ 		{
+ 			*RamDac |= DAC_8BIT;
+ 		}
+ 		break;
+ 	case 0x03:
+ 		*RamDac = DAC_STANDARD;
+ 		break;
+ 	case 0x04:
+ 		*RamDac = DAC_ATIMISC24;
+ 		*RamDac |= DAC_6_8_PROGRAM;
+ 		if (Width8Check())
+ 		{
+ 			*RamDac |= DAC_8BIT;
+ 		}
+ 		break;
+ 	case 0x05:
+ 		*RamDac = DAC_ATI68860;
+ 		*RamDac |= DAC_6_8_PROGRAM;
+ 		if (Width8Check())
+ 		{
+ 			*RamDac |= DAC_8BIT;
+ 		}
+ 		break;
+ 	default:
+ 		*RamDac = DAC_UNKNOWN;
+ 		break;
+ 	}
+ 
+ 	DisableIOPorts(1, &Port);
+ 	return;
+ }
+ 
+ void Probe_RamDac(Chipset, RamDac)
+ int Chipset;
+ int *RamDac;
+ {
+ 	Byte x, y, z, u, v, oldcomm, oldpel, notcomm;
+ 	Bool dac8, dac8now;
+ 
+ 	*RamDac = DAC_STANDARD;
+ 	Ports[0] = CRTC_IDX;
+ 	Ports[1] = CRTC_REG;
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Handle special cases.
+ 	 */
+ 	if (Chipset == CHIP_AL2101)
+ 	{
+ 	    *RamDac = DAC_ALG1101;
+ 	    if (Width8Check())
+ 	    {
+ 		*RamDac |= DAC_8BIT;
+ 	    }
+ 	    DisableIOPorts(NUMPORTS, Ports);
+ 	    return;
+ 	}
+ 	else if (SVGA_VENDOR(Chipset) == V_ATI)
+ 	{
+ 	    if (Chipset < CHIP_ATI68800_3)
+ 	    {
+ 		if (ReadBIOS(0x44, &x, 1) != 1)
+ 		{
+ 		    fprintf(stderr, "%s: Failed to read ATI BIOS data\n",
+ 			    MyName);
+ 		    DisableIOPorts(NUMPORTS, Ports);
+ 		    return;
+ 		}
+ 		if (x & 0x80)
+ 		{
+ 		    *RamDac = DAC_ATI68830;
+ 		    if (Width8Check())
+ 		    {
+ 			*RamDac |= DAC_8BIT;
+ 		    }
+ 		    DisableIOPorts(NUMPORTS, Ports);
+ 		    return;
+ 		}
+ 	    }
+ 	    else
+ 	    {
+ 		CheckMach32(RamDac);
+ 		DisableIOPorts(NUMPORTS, Ports);
+ 		return;
+ 	    }
+ 	}
+ 	else if ((SVGA_VENDOR(Chipset) == V_CIRRUS) &&
+ 		 (Chipset >= CHIP_CL5420))
+ 	{
+ 	    if ((Chipset == CHIP_CL5420) || (Chipset >= CHIP_CL5410))
+ 	    {
+ 		*RamDac = DAC_CIRRUSA;
+ 	    }
+ 	    else
+ 	    {
+ 		*RamDac = DAC_CIRRUSB;
+ 	    }
+ 	    if (Width8Check())
+ 	    {
+ 		*RamDac |= DAC_8BIT;
+ 	    }
+ 	    DisableIOPorts(NUMPORTS, Ports);
+ 	    return;
+ 	}
+ 	else if ((SVGA_VENDOR(Chipset) == V_S3) && (Chipset >= CHIP_S3_928D))
+ 	{
+ 	    if (S3_Bt485Check(RamDac))
+ 	    {
+ 		DisableIOPorts(NUMPORTS, Ports);
+ 		return;
+ 	    }
+ 	    if (S3_TVP3020Check(RamDac))
+ 	    {
+ 		DisableIOPorts(NUMPORTS, Ports);
+ 		return;
+ 	    }
+ 	}
+ 
+ 	/*
+ 	 * Save current state.
+ 	 */
+ 	(void) dactocomm();
+ 	oldcomm = inp(0x3C6);
+ 	dactopel();
+ 	oldpel = inp(0x3C6);
+ 
+ 	/*
+ 	 * Do 8-bit-wide check.
+ 	 */
+ 	(void) dactocomm();
+ 	outp(0x3C6, 0x00);
+ 	dac8 = Width8Check();
+ 	dactopel();
+ 
+ 	/*
+ 	 * Check whether this DAC has a HiColor-style command register.
+ 	 */
+ 	notcomm = ~oldcomm;
+ 	outp(0x3C6, notcomm);
+ 	(void) dactocomm();
+ 	v = inp(0x3C6);
+ 	if (v != notcomm)
+ 	{
+ 	    /*
+ 	     * Check for early-generation HiColor-style DAC.
+ 	     */
+ 	    if ((SetComm(0xE0) & 0xE0) != 0xE0)
+ 	    {
+ 		dactopel();
+ 		x = inp(0x3C6);
+ 		do
+ 		{
+ 		    /*
+ 		     * Wait for same value twice.
+ 		     */
+ 		    y = x;
+ 		    x = inp(0x3C6);
+ 		}
+ 		while (x != y);
+ 		z = x;
+ 		u = dactocomm();
+ 		if (u != 0x8E)
+ 		{
+ 		    /*
+ 		     * If command register is 0x8E, we've got an SS24;
+ 		     */
+ 		    y = 8;
+ 		    do
+ 		    {
+ 			x = inp(0x3C6);
+ 			y--;
+ 		    }
+ 		    while ((x != 0x8E) && (y != 0));
+ 		}
+ 		else
+ 		{
+ 		    x = u;
+ 		}
+ 		if (x == 0x8E)
+ 		{
+ 		    *RamDac = DAC_SS24;
+ 		}
+ 		else
+ 		{
+ 		    /*
+ 		     * Sierra SC11486
+ 		     */
+ 		    *RamDac = DAC_SIERRA15;
+ 		}
+ 		dactopel();
+ 	    }
+ 	    else
+ 	    {
+ 		/*
+ 		 * New generation of advanced DACs
+ 		 */
+ 		if ((SetComm(0x60) & 0xE0) == 0x00)
+ 		{
+ 		    /*
+ 		     * AT&T 20C490/20C493
+ 		     */
+ 		    if ((SetComm(0x02) & 0x02) != 0x00)
+ 		    {
+ 			*RamDac = DAC_ATT490;
+ 			*RamDac |= DAC_6_8_PROGRAM;
+ 		    }
+ 		    else
+ 		    {
+ 			*RamDac = DAC_ATT493;
+ 		    }
+ 		}
+ 		else
+ 		{
+ 		    x = SetComm(oldcomm);
+ 		    if (inp(0x3C6) == notcomm)
+ 		    {
+ 			if (SetComm(0xFF) != 0xFF)
+ 			{
+ 			    *RamDac = DAC_ACUMOS;
+ 			}
+ 			else
+ 			{
+ 			    dactocomm();
+ 			    outp(0x3C6, (oldcomm | 0x02) & 0xFE);
+ 			    dac8now = Width8Check();
+ 			    if (dac8now)
+ 			    {
+ 				if (Width8Check())
+ 				{
+ 					*RamDac = DAC_ATT491;
+ 					*RamDac |= DAC_6_8_PROGRAM;
+ 				}
+ 				else
+ 				{
+ 					*RamDac = DAC_CIRRUS24;
+ 				}
+ 			    }
+ 			    else
+ 			    {
+ 				*RamDac = DAC_ATT492;
+ 			    }
+ 			}
+ 		    }
+ 		    else
+ 		    {
+ 			if (trigdac() == notcomm)
+ 			{
+ 				*RamDac = DAC_CIRRUS24;
+ 			}
+ 			else
+ 			{
+ 			    dactopel();
+ 			    outp(0x3C6, 0xFF);
+ 			    switch (trigdac())
+ 			    {
+ 			    case 0x44:
+ 				*RamDac = DAC_MUSIC4870;
+ 				break;
+ 			    case 0x82:
+ 				*RamDac = DAC_MUSIC4910;
+ 				break;
+ 			    case 0x8E:
+ 				*RamDac = DAC_SS24;
+ 				break;
+ 			    default:
+ 				if (TestDACBit(0x10,oldcomm,oldpel))
+ 				{
+ 					*RamDac = DAC_SIERRA24;
+ 					*RamDac |= DAC_6_8_PROGRAM;
+ 				}
+ 				else if (TestDACBit(0x04,oldcomm,oldpel))
+ 				{
+ 					*RamDac = DAC_UNKNOWN;
+ 				}
+ 				else
+ 				{
+ 					*RamDac = DAC_SIERRA15_16;
+ 				}
+ 				break;
+ 			    }
+ 			}
+ 		    }
+ 		}
+ 	    }
+ 	    dactocomm();
+ 	    outp(0x3C6, oldcomm);
+ 	}
+ 	dactopel();
+ 	outp(0x3C6, oldpel);
+ 
+ 	/*
+ 	 * If no special DAC found, check for the EDSUN DAC.
+ 	 */
+ 	if (*RamDac == DAC_STANDARD)
+ 	{
+ 	    /*
+ 	     * Write "CEGEDSUN" + mode to DAC index 0xDE (222)
+ 	     */
+ 	    waitforretrace();
+ 	    outp(0x3C8, 0xDE);
+ 	    outp(0x3C9, (Byte)'C');
+ 	    outp(0x3C9, (Byte)'E');
+ 	    outp(0x3C9, (Byte)'G');
+ 	    outp(0x3C8, 0xDE);
+ 	    outp(0x3C9, (Byte)'E');
+ 	    outp(0x3C9, (Byte)'D');
+ 	    outp(0x3C9, (Byte)'S');
+ 	    outp(0x3C8, 0xDE);
+ 	    outp(0x3C9, (Byte)'U');
+ 	    outp(0x3C9, (Byte)'N');
+ 	    outp(0x3C9, (Byte)'\n');
+ 	    /*
+ 	     * Should be in CEG mode now.
+ 	     */
+ 	    outp(0x3C6, 0xFF);
+ 	    x = (inp(0x3C6) >> 4) & 0x07;
+ 	    if (x < 0x07)
+ 	    {
+ 		*RamDac = DAC_EDSUN;
+ 		waitforretrace();
+ 		outp(0x3C8, 0xDF);
+ 		outp(0x3C9, 0x00);
+ 	    }
+ 	}
+ 
+ 	/*
+ 	 * Remember if DAC was in 8-bit mode.
+ 	 */
+ 	if (dac8)
+ 	{
+ 		*RamDac |= DAC_8BIT;
+ 	}
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return;
+ }
+ 
+ #ifdef OLD_DAC_CODE /* { */
+ 
+ static void CheckATT __STDCARGS((int *));
+ 
+ static Bool Width8Check()
+ {
  	int i;
  	Byte save[3];
  	Bool result = FALSE;
***************
*** 69,80 ****
  	return(result);
  }
  
- #ifdef __STDC__
- static void CheckATT(int *RamDac)
- #else
  static void CheckATT(RamDac)
  int *RamDac;
- #endif
  {
  	Byte savecomm, tmp;
  
--- 680,687 ----
***************
*** 130,209 ****
  	outp(0x3C6, savecomm);
  }
  
- #ifdef __STDC__
- static Bool S3_Bt485Check(int *RamDac)
- #else
- static Bool S3_Bt485Check(RamDac)
- int *RamDac;
- #endif
- {
- 	Byte old1, old2, old3, old4;
- 	Byte lock1, lock2;
- 	Bool Found = FALSE;
- 
- 	lock1 = rdinx(CRTC_IDX, 0x38);
- 	lock2 = rdinx(CRTC_IDX, 0x39);
- 	wrinx(CRTC_IDX, 0x38, 0x48);
- 	wrinx(CRTC_IDX, 0x39, 0xA5);
- 
- 	old1 = inp(0x3C6);
- 	old2 = rdinx(CRTC_IDX, 0x55);
- 	outp(0x3C6, 0xFF);
- 	wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x02);
- 	old3 = inp(0x3C6);
- 	if ((old3 & 0xC0) == 0x80)
- 	{
- 		Found = TRUE;
- 		*RamDac = DAC_BT485;
- 		*RamDac |= DAC_6_8_PROGRAM;
- 		if (Width8Check())
- 		{
- 			*RamDac |= DAC_8BIT;
- 		}
- 	}
- 	else
- 	{
- 		/* Perhaps status reg is hidden behind CR3 */
- 		wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x01);
- 		old3 = inp(0x3C6);
- 		if ((old3 & 0x80) == 0x80)
- 		{
- 			/* OK.  CR3 is active... */
- 			wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x00);
- 			old3 = inp(0x3C8);
- 			outp(0x3C8, 0x00);
- 			wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x02);
- 			old4 = inp(0x3C6);
- 			if ((old4 & 0xC0) == 0x80)
- 			{
- 				Found = TRUE;
- 				*RamDac = DAC_BT485;
- 				*RamDac |= DAC_6_8_PROGRAM;
- 				if (Width8Check())
- 				{
- 					*RamDac |= DAC_8BIT;
- 				}
- 			}
- 			wrinx(CRTC_IDX, 0x55, (old2 & 0xFC) | 0x00);
- 			outp(0x3C8, old3);
- 		}
- 	}
- 	wrinx(CRTC_IDX, 0x55, old2);
- 	outp(0x3C6, old1);
- 
- 	wrinx(CRTC_IDX, 0x39, lock2);
- 	wrinx(CRTC_IDX, 0x38, lock1);
- 
- 	return(Found);
- }
- 
- #ifdef __STDC__
- void Probe_RamDac(int Chipset, int *RamDac)
- #else
  void Probe_RamDac(Chipset, RamDac)
  int Chipset;
  int *RamDac;
- #endif
  {
  	Byte x, y, z, v, oldcommreg, oldpelreg;
  
--- 737,745 ----
***************
*** 233,239 ****
  		}
  		if (x & 0x80)
  		{
! 			*RamDac = DAC_ATI;
  			if (Width8Check())
  			{
  				*RamDac |= DAC_8BIT;
--- 769,775 ----
  		}
  		if (x & 0x80)
  		{
! 			*RamDac = DAC_ATI68830;
  			if (Width8Check())
  			{
  				*RamDac |= DAC_8BIT;
***************
*** 268,273 ****
--- 804,814 ----
  			DisableIOPorts(NUMPORTS, Ports);
  			return;
  		}
+ 		if (S3_TVP3020Check(RamDac))
+ 		{
+ 			DisableIOPorts(NUMPORTS, Ports);
+ 			return;
+ 		}
  	}
  	dactopel();
  	x = inp(0x3C6);
***************
*** 357,359 ****
--- 898,902 ----
  	DisableIOPorts(NUMPORTS, Ports);
  	return;
  }
+ 
+ #endif /* OLD_DAC_CODE } */
diff -c mit/server/ddx/x386/SuperProbe/RealTek.c:2.1 mit/server/ddx/x386/SuperProbe/RealTek.c:2.3
*** mit/server/ddx/x386/SuperProbe/RealTek.c:2.1	Fri Mar 11 23:36:24 1994
--- mit/server/ddx/x386/SuperProbe/RealTek.c	Fri Mar 11 23:36:24 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/RealTek.c,v 2.1 1993/09/21 15:20:45 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/RealTek.c,v 2.3 1994/02/28 14:09:53 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 28,33 ****
--- 28,35 ----
  static Word Ports[] = {0x000, 0x000, 0x3D6, 0x3D7};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_RealTek __STDCARGS((int));
+ 
  Chip_Descriptor RealTek_Descriptor = {
  	"RealTek",
  	Probe_RealTek,
***************
*** 35,41 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
  #ifdef __STDC__
--- 37,44 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_RealTek,
  };
  
  #ifdef __STDC__
***************
*** 46,63 ****
  #endif
  {
  	Bool result = FALSE;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
  	if (testinx2(CRTC_IDX, 0x1F, 0x3F) &&
  	    tstrg(0x3D6, 0x0F) &&
  	    tstrg(0x3D7, 0x0F))
  	{
  		result = TRUE;
! 		*Chipset = CHIP_REALTEK;
  	}
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
  }
--- 49,135 ----
  #endif
  {
  	Bool result = FALSE;
+ 	Byte ver;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
+ 
  	if (testinx2(CRTC_IDX, 0x1F, 0x3F) &&
  	    tstrg(0x3D6, 0x0F) &&
  	    tstrg(0x3D7, 0x0F))
  	{
  		result = TRUE;
! 		ver = rdinx(CRTC_IDX, 0x1A) >> 6;
! 		switch (ver)
! 		{
! 		case 0x00:
! 			*Chipset = CHIP_RT_3103;
! 			break;
! 		case 0x01:
! 			*Chipset = CHIP_RT_3105;
! 			break;
! 		case 0x02:
! 			*Chipset = CHIP_RT_3106;
! 			break;
! 		default:
! 			Chip_data = ver;
! 			*Chipset = CHIP_RT_UNK;
! 			break;
! 		}
  	}
+ 
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ static int MemProbe_RealTek(Chipset)
+ int Chipset;
+ {
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	switch (Chipset)
+ 	{
+ 	case CHIP_RT_3103:
+ 		switch (rdinx(CRTC_IDX, 0x1E) & 0x03)
+ 		{
+ 		case 0x00:
+ 			Mem = 256;
+ 			break;
+ 		case 0x01:
+ 			Mem = 512;
+ 			break;
+ 		case 0x02:
+ 			Mem = 768;
+ 			break;
+ 		case 0x03:
+ 			Mem = 1024;
+ 			break;
+ 		}
+ 		break;
+ 	case CHIP_RT_3105:
+ 	case CHIP_RT_3106:
+ 		switch (rdinx(CRTC_IDX, 0x1E) & 0x03)
+ 		{
+ 		case 0x00:
+ 			Mem = 256;
+ 			break;
+ 		case 0x01:
+ 			Mem = 512;
+ 			break;
+ 		case 0x02:
+ 			Mem = 1024;
+ 			break;
+ 		case 0x03:
+ 			Mem = 2048;
+ 			break;
+ 		}
+ 		break;
+ 	}
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c mit/server/ddx/x386/SuperProbe/S3.c:2.4 mit/server/ddx/x386/SuperProbe/S3.c:2.6
*** mit/server/ddx/x386/SuperProbe/S3.c:2.4	Fri Mar 11 23:36:24 1994
--- mit/server/ddx/x386/SuperProbe/S3.c	Fri Mar 11 23:36:25 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/S3.c,v 2.4 1993/09/27 12:23:26 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/S3.c,v 2.6 1994/02/28 14:10:50 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 28,33 ****
--- 28,35 ----
  static Word Ports[] = {0x000, 0x000};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_S3 __STDCARGS((int));
+ 
  Chip_Descriptor S3_Descriptor = {
  	"S3",
  	Probe_S3,
***************
*** 35,49 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	FALSE
  };
  
- #ifdef __STDC__
- Bool Probe_S3(int *Chipset)
- #else
  Bool Probe_S3(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte old, tmp, rev;
--- 37,48 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	FALSE,
! 	MemProbe_S3,
  };
  
  Bool Probe_S3(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  	Byte old, tmp, rev;
***************
*** 102,107 ****
--- 101,109 ----
  					case 0x05:
  						*Chipset = CHIP_S3_805D;
  						break;
+ 					case 0x08:
+ 						*Chipset = CHIP_S3_805I;
+ 						break;
  					default:
  						/* Call >0x05 D step for now */
  						*Chipset = CHIP_S3_805D;
***************
*** 127,132 ****
--- 129,137 ----
  					case 0x05:
  						*Chipset = CHIP_S3_801D;
  						break;
+ 					case 0x08:
+ 						*Chipset = CHIP_S3_801I;
+ 						break;
  					default:
  						/* Call >0x05 D step for now */
  						*Chipset = CHIP_S3_801D;
***************
*** 181,184 ****
--- 186,243 ----
  	wrinx(CRTC_IDX, 0x38, old);
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ static int MemProbe_S3(Chipset)
+ int Chipset;
+ {
+ 	Byte config, old;
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	old = rdinx(CRTC_IDX, 0x38);
+ 	wrinx(CRTC_IDX, 0x38, 0x00);
+ 	if (!testinx2(CRTC_IDX, 0x35, 0x0F))
+ 	{
+ 		wrinx(CRTC_IDX, 0x38, 0x48);
+ 		if (testinx2(CRTC_IDX, 0x35, 0x0F))
+ 		{
+ 			config = rdinx(CRTC_IDX, 0x36);
+ 			if ((config & 0x20) != 0)
+ 			{
+ 				Mem = 512;
+ 			}
+ 			else
+ 			{
+ 				if ((Chipset == CHIP_S3_911) || 
+ 				    (Chipset == CHIP_S3_924))
+ 				{
+ 					Mem = 1024;
+ 				}
+ 				else
+ 				{
+ 					switch((config & 0xC0) >> 6)
+ 					{
+ 					case 0:
+ 						Mem = 4096;
+ 						break;
+ 					case 1:
+ 						Mem = 3072;
+ 						break;
+ 					case 2:
+ 						Mem = 2048;
+ 						break;
+ 					case 3:
+ 						Mem = 1024;
+ 						break;
+ 					}
+ 				}
+ 			}
+ 		}
+ 	}
+ 	wrinx(CRTC_IDX, 0x38, old);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c /dev/null mit/server/ddx/x386/SuperProbe/SolX86IO.s:2.2
*** /dev/null	Fri Mar 11 23:36:25 1994
--- mit/server/ddx/x386/SuperProbe/SolX86IO.s	Fri Mar 11 23:36:25 1994
***************
*** 0 ****
--- 1,99 ----
+ /
+ / File: SolX86IO.s
+ /
+ / Purpose: Provide inb(), inw(), inl(), outb(), outw(), outl() functions
+ /          for Solaris x86 using the ProWorks compiler by SunPro
+ /
+ / Author:  Installed into XFree86 SuperProbe by Doug Anson (danson@lgc.com)
+ /          Portions donated to XFree86 by Steve Dever (Steve.Dever@Eng.Sun.Com)
+ /
+ / Synopsis: (c callable external declarations)
+ /          extern unsigned char inb(int port);
+ /          extern unsigned short inw(int port);
+ /          extern unsigned long inl(int port);
+ /          extern void outb(int port, unsigned char value);
+ /          extern void outw(int port, unsigned short value);
+ /          extern void outl(int port, unsigned long value);
+ /
+ / $XFree86: mit/server/ddx/x386/SuperProbe/SolX86IO.s,v 2.2 1994/02/01 13:51:04 dawes Exp $
+ 
+ .file "SolX86IO.s"
+ .text
+ 
+ .globl  inb
+ .globl  inw
+ .globl  inl
+ .globl  outb
+ .globl  outw
+ .globl  outl
+ 
+ /
+ / unsigned char inb(int port);
+ /
+ .align	4
+ inb:
+         movl 4(%esp),%edx
+         subl %eax,%eax
+         inb  (%dx)
+ 		ret
+ .type	inb,@function
+ .size	inb,.-inb
+ 
+ /
+ / unsigned short inw(int port);
+ /
+ .align	4
+ inw:
+         movl 4(%esp),%edx
+         subl %eax,%eax
+         inw  (%dx)
+ 		ret
+ .type	inw,@function
+ .size	inw,.-inw
+ 
+ /
+ / unsigned long inl(int port);
+ /
+ .align	4
+ inl:
+         movl 4(%esp),%edx
+         inl  (%dx)
+ 		ret
+ .type	inl,@function
+ .size	inl,.-inl
+ 
+ /
+ /     void outb(int port, unsigned char value);
+ /
+ .align	4
+ outb:
+         movl 4(%esp),%edx
+         movl 8(%esp),%eax
+         outb (%dx)
+ 		ret
+ .type	outb,@function
+ .size	outb,.-outb
+ 
+ /
+ /     void outw(int port, unsigned short value);
+ /
+ .align	4
+ outw:
+         movl 4(%esp),%edx
+         movl 8(%esp),%eax
+         outw (%dx)
+ 	    ret
+ .type	outw,@function
+ .size	outw,.-outw
+ 
+ /
+ /     void outl(int port, unsigned long value);
+ /
+ .align	4
+ outl:
+         movl 4(%esp),%edx
+         movl 8(%esp),%eax
+         outl (%dx)
+ 	    ret
+ .type	outl,@function
+ .size	outl,.-outl
diff -c mit/server/ddx/x386/SuperProbe/SuperProbe.man:2.4 mit/server/ddx/x386/SuperProbe/SuperProbe.man:2.8
*** mit/server/ddx/x386/SuperProbe/SuperProbe.man:2.4	Fri Mar 11 23:36:26 1994
--- mit/server/ddx/x386/SuperProbe/SuperProbe.man	Fri Mar 11 23:36:26 1994
***************
*** 1,5 ****
! .\" $XFree86: mit/server/ddx/x386/SuperProbe/SuperProbe.man,v 2.4 1993/10/07 13:54:52 dawes Exp $
! .TH SuperProbe 1 "Version 1.0" ""
  .SH NAME
  SuperProbe - probe for and identify installed video hardware.
  .SH SYNOPSIS
--- 1,5 ----
! .\" $XFree86: mit/server/ddx/x386/SuperProbe/SuperProbe.man,v 2.8 1994/03/05 08:23:05 dawes Exp $
! .TH SuperProbe 1 "Version 2.0" ""
  .SH NAME
  SuperProbe - probe for and identify installed video hardware.
  .SH SYNOPSIS
***************
*** 6,29 ****
  .B SuperProbe
  [-verbose] [-no16] [-excl \fIlist\fP] [-mask10] 
  .if n .br
! [-order \fIlist\fP] [-noprobe \fIlist\fP] [-bios \fIbase\fP] 
  .br
! [-no_bios] [-info]
  .SH DESCRIPTION
  .PP
  .I SuperProbe
  is a a program that will attempt to determine the type of video hardware
! installed in an EISA/ISA-bus system by checking for known registers in various
! combinations at various locations (MicroChannel machines are not currently
! supported).  This is an error-prone process, especially on Unix (which 
  usually has a lot more esoteric hardware installed than MS-DOS system do), so 
  SuperProbe may likely need help from the user.
  .PP
  .I SuperProbe 
! runs on SVR3, SVR4, Linux, 386BSD, Minix-386, and Mach.  It should be trivial
! to extend it to work on any other Unix-like operating system, and even 
! non-Unix operating systems.  All of the OS dependencies are isolated to a 
! single file for each OS.
  .PP
  At this time,
  .I SuperProbe
--- 6,31 ----
  .B SuperProbe
  [-verbose] [-no16] [-excl \fIlist\fP] [-mask10] 
  .if n .br
! 	[-order \fIlist\fP] [-noprobe \fIlist\fP] [-bios \fIbase\fP] 
  .br
! 	[-no_bios] [-no_dac] [-no_mem] [-info]
  .SH DESCRIPTION
  .PP
  .I SuperProbe
  is a a program that will attempt to determine the type of video hardware
! installed in an EISA/ISA/VLB-bus system by checking for known registers 
! in various combinations at various locations (MicroChannel and PCI machines 
! may not be fully supported; many work with the use of the
! .B -no_bios
! option).  This is an error-prone process, especially on Unix (which 
  usually has a lot more esoteric hardware installed than MS-DOS system do), so 
  SuperProbe may likely need help from the user.
  .PP
  .I SuperProbe 
! runs on SVR3, SVR4, Linux, 386BSD/FreeBSD/NetBSD, Minix-386, and Mach.  It
! should be trivial to extend it to work on any other Unix-like operating 
! system, and even non-Unix operating systems.  All of the OS dependencies 
! are isolated to a single file for each OS.
  .PP
  At this time,
  .I SuperProbe
***************
*** 31,37 ****
  SVGA chipsets (see the
  .I -info
  option, below).  It can also identify several HiColor/True-color RAMDACs
! in use on SVGA boards.  It can identify 8514/A and some derivatives, but
  not XGA, or PGC (although the author intends to add those capabilities).
  Nor can it identify other esoteric video hardware (like Targa, TIGA, or 
  Microfield boards).
--- 33,40 ----
  SVGA chipsets (see the
  .I -info
  option, below).  It can also identify several HiColor/True-color RAMDACs
! in use on SVGA boards, and the amount of video memory installed (for many
! chipsets).  It can identify 8514/A and some derivatives, but
  not XGA, or PGC (although the author intends to add those capabilities).
  Nor can it identify other esoteric video hardware (like Targa, TIGA, or 
  Microfield boards).
***************
*** 119,128 ****
  option can be used to specify the base.
  .TP 8
  .B "-no_bios"
! Disallow reading of the video BIOS and
! sssume that an EGA or later (VGA, SVGA) board is present as the primary
! video hardware.  
  .TP 8
  .B "-info"
  .I SuperProbe
  will print out a listing of all the video hardware that it knows how to
--- 122,136 ----
  option can be used to specify the base.
  .TP 8
  .B "-no_bios"
! Disallow reading of the video BIOS and assume that an EGA or later 
! (VGA, SVGA) board is present as the primary video hardware.  
  .TP 8
+ .B "-no_dac"
+ Skip probing for the RAMDAC type when an (S)VGA is identified.
+ .TP 8
+ .B "-no_mem"
+ Skip probing for the amount of installed video memory.
+ .TP 8
  .B "-info"
  .I SuperProbe
  will print out a listing of all the video hardware that it knows how to
***************
*** 185,191 ****
  .SH SEE ALSO
  .PP
  The
! .I vgadoc2.zip
  documentation package by Finn Thoegersen, available in the MS-DOS archives
  of many FTP repositories.
  .PP
--- 193,199 ----
  .SH SEE ALSO
  .PP
  The
! .I vgadoc3.zip
  documentation package by Finn Thoegersen, available in the MS-DOS archives
  of many FTP repositories.
  .PP
diff -c mit/server/ddx/x386/SuperProbe/Trident.c:2.2 mit/server/ddx/x386/SuperProbe/Trident.c:2.5
*** mit/server/ddx/x386/SuperProbe/Trident.c:2.2	Fri Mar 11 23:36:26 1994
--- mit/server/ddx/x386/SuperProbe/Trident.c	Fri Mar 11 23:36:26 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,33 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Trident.c,v 2.2 1993/09/27 12:23:28 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x3C4, 0x3C5};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Trident_Descriptor = {
  	"Trident",
  	Probe_Trident,
--- 21,35 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Trident.c,v 2.5 1994/02/28 14:09:56 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, SEQ_IDX, SEQ_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_Trident __STDCARGS((int));
+ 
  Chip_Descriptor Trident_Descriptor = {
  	"Trident",
  	Probe_Trident,
***************
*** 35,61 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Trident(int *Chipset)
- #else
  Bool Probe_Trident(Chipset)
  int *Chipset;
- #endif
  {
          Bool result = FALSE;
  	Byte chip, old, old1, val;
  
          EnableIOPorts(NUMPORTS, Ports);
! 	old = rdinx(0x3C4, 0x0B);
! 	wrinx(0x3C4, 0x0B, 0x00);
! 	chip = inp(0x3C5);
! 	old1 = rdinx(0x3C4, 0x0E);
! 	outp(0x3C5, 0);
! 	val = inp(0x3C5);
! 	outp(0x3C5, (old1 ^ 0x02));
  	wrinx(0x3C4, 0x0B, old);
  	if ((val & 0x0F) == 2)
  	{
--- 37,63 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_Trident,
  };
  
  Bool Probe_Trident(Chipset)
  int *Chipset;
  {
          Bool result = FALSE;
  	Byte chip, old, old1, val;
  
+ 	Ports[0] = CRTC_IDX;
+ 	Ports[1] = CRTC_REG;
          EnableIOPorts(NUMPORTS, Ports);
! 
! 	old = rdinx(SEQ_IDX, 0x0B);
! 	wrinx(SEQ_IDX, 0x0B, 0x00);
! 	chip = inp(SEQ_REG);
! 	old1 = rdinx(SEQ_IDX, 0x0E);
! 	outp(SEQ_REG, 0);
! 	val = inp(SEQ_REG);
! 	outp(SEQ_REG, (old1 ^ 0x02));
  	wrinx(0x3C4, 0x0B, old);
  	if ((val & 0x0F) == 2)
  	{
***************
*** 62,68 ****
  		result = TRUE;
  		switch (chip)
  		{
! 		case 0x01:
  			*Chipset = CHIP_TVGA8800BR;
  			break;
  		case 0x02:
--- 64,70 ----
  		result = TRUE;
  		switch (chip)
  		{
! 		case 0x01:		/* Can't happen - no "new mode" */
  			*Chipset = CHIP_TVGA8800BR;
  			break;
  		case 0x02:
***************
*** 81,92 ****
  		case 0x33:
  			*Chipset = CHIP_TVGA8900CL;
  			break;
  		case 0x83:
! 			*Chipset = CHIP_TVGA9200;
  			break;
  		case 0x93:
! 			*Chipset = CHIP_TVGA9100;
  			break;
  		default:
  			Chip_data = chip;
  			*Chipset = CHIP_TVGA_UNK;
--- 83,110 ----
  		case 0x33:
  			*Chipset = CHIP_TVGA8900CL;
  			break;
+ 		case 0x43:
+ 			*Chipset = CHIP_TVGA9000I;
+ 			break;
+ 		case 0x53:
+ 			*Chipset = CHIP_TVGA9200CX;
+ 			break;
+ 		case 0x63:
+ 			*Chipset = CHIP_TVGA9100B;
+ 			break;
+ 		case 0x73:
+ 		case 0xF3:
+ 			*Chipset = CHIP_TVGA9420;
+ 			break;
  		case 0x83:
! 			*Chipset = CHIP_TVGA8200;
  			break;
  		case 0x93:
! 			*Chipset = CHIP_TVGA9400CX;
  			break;
+ 		case 0xA3:
+ 			*Chipset = CHIP_TVGA9320;
+ 			break;
  		default:
  			Chip_data = chip;
  			*Chipset = CHIP_TVGA_UNK;
***************
*** 93,99 ****
--- 111,168 ----
  			break;
  		}
  	}
+ 	else if ((chip == 1) && (testinx2(SEQ_IDX, 0x0E, 0x06)))
+ 	{
+ 		result = TRUE;
+ 		*Chipset = CHIP_TVGA8800BR;
+ 	}
+ 
          DisableIOPorts(NUMPORTS, Ports);
          return(result);
  }
  
+ static int MemProbe_Trident(Chipset)
+ int Chipset;
+ {
+ 	int Mem = 0;
+ 
+         EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	switch (Chipset)
+ 	{
+ 	case CHIP_TVGA8800BR:
+ 	case CHIP_TVGA8800CS:
+ 		if (rdinx(CRTC_IDX, 0x1F) & 0x02)
+ 		{
+ 			Mem = 512;
+ 		}
+ 		else
+ 		{
+ 			Mem = 256;
+ 		}
+ 		break;
+ 	default:
+ 		switch (rdinx(CRTC_IDX, 0x1F) & 0x07)
+ 		{
+ 		case 0x00:
+ 			Mem = 256;
+ 			break;
+ 		case 0x01:
+ 			Mem = 512;
+ 			break;
+ 		case 0x02:
+ 			Mem = 768;
+ 			break;
+ 		case 0x03:
+ 			Mem = 1024;
+ 			break;
+ 		case 0x07:
+ 			Mem = 2048;
+ 			break;
+ 		}
+ 		break;
+ 	}
+ 
+         DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
+ }
diff -c mit/server/ddx/x386/SuperProbe/Tseng.c:2.2 mit/server/ddx/x386/SuperProbe/Tseng.c:2.6
*** mit/server/ddx/x386/SuperProbe/Tseng.c:2.2	Fri Mar 11 23:36:27 1994
--- mit/server/ddx/x386/SuperProbe/Tseng.c	Fri Mar 11 23:36:27 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,33 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Tseng.c,v 2.2 1993/09/21 15:20:50 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, 0x000, 0x3BF, 0x3CD};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Tseng_Descriptor = {
  	"Tseng",
  	Probe_Tseng,
--- 21,36 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Tseng.c,v 2.6 1994/03/02 08:04:57 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, 0x000, 0x3BF, 0x3CB, 0x3CD, 
! 		       ATR_IDX, ATR_REG_R, SEQ_IDX, SEQ_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_Tseng __STDCARGS((int));
+ 
  Chip_Descriptor Tseng_Descriptor = {
  	"Tseng",
  	Probe_Tseng,
***************
*** 35,58 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Tseng(int *Chipset)
- #else
  Bool Probe_Tseng(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
! 	Byte old, old1;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
! 	Ports[2] = inp(0x3CC) & 0x01 ? 0x3D8 : 0x3B8;
  	EnableIOPorts(NUMPORTS, Ports);
  	old = inp(0x3BF);
  	old1 = inp(Ports[2]);
  	outp(0x3BF, 0x03);
--- 38,59 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_Tseng,
  };
  
  Bool Probe_Tseng(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
! 	Byte old, old1, ver;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
! 	Ports[2] = inp(MISC_OUT_R) & 0x01 ? 0x3D8 : 0x3B8;
  	EnableIOPorts(NUMPORTS, Ports);
+ 
  	old = inp(0x3BF);
  	old1 = inp(Ports[2]);
  	outp(0x3BF, 0x03);
***************
*** 59,74 ****
  	outp(Ports[2], 0xA0);
  	if (tstrg(0x3CD, 0x3F)) 
  	{
- 		/* 
- 		 * It is a Tseng; now figure out which one, and
- 		 * set Chipset.
- 		 */
  		result = TRUE;
! 		if (!testinx(CRTC_IDX, 0x1B))
  		{
! 			if (testinx2(CRTC_IDX, 0x30, 0x1F))
  			{
! 				*Chipset = CHIP_ET4000_W32;
  			}
  			else
  			{
--- 60,87 ----
  	outp(Ports[2], 0xA0);
  	if (tstrg(0x3CD, 0x3F)) 
  	{
  		result = TRUE;
! 		if (testinx2(CRTC_IDX, 0x33, 0x0F))
  		{
! 			if (tstrg(0x3CB, 0x33))
  			{
! 				ver = rdinx(0x217A, 0xEC);
! 				switch (ver >> 4)
! 				{
! 				case 0x00:
! 					*Chipset = CHIP_ET4000W32;
! 					break;
! 				case 0x02:
! 					*Chipset = CHIP_ET4000W32P;
! 					break;
! 				case 0x03:
! 					*Chipset = CHIP_ET4000W32I;
! 					break;
! 				default:
! 					Chip_data = ver >> 4;
! 					*Chipset = CHIP_TSENG_UNK;
! 					break;
! 				}
  			}
  			else
  			{
***************
*** 82,87 ****
--- 95,173 ----
  	}
  	outp(Ports[2], old1);
  	outp(0x3BF, old);
+ 
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ static int MemProbe_Tseng(Chipset)
+ int Chipset;
+ {
+ 	Byte Save[2];
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/* 
+ 	 * Unlock 
+ 	 */
+ 	Save[0] = inp(0x3BF);
+ 	Save[1] = inp(vgaIOBase + 8);
+ 	outp(0x3BF, 0x03);
+ 	outp(vgaIOBase + 8, 0xA0);
+ 
+ 	/*
+ 	 * Check
+ 	 */
+ 	switch (Chipset)
+ 	{
+ 	case CHIP_ET4000:
+ 		switch (rdinx(CRTC_IDX, 0x37) & 0x0B)
+ 		{
+ 		case 0x03:
+ 		case 0x05:
+ 			Mem = 256;
+ 			break;
+ 		case 0x0A:
+ 			Mem = 512;
+ 			break;
+ 		case 0x0B:
+ 			Mem = 1024;
+ 			break;
+ 		}
+ 		break;
+ 	case CHIP_ET4000W32:
+ 	case CHIP_ET4000W32I:
+ 	case CHIP_ET4000W32P:
+ 		switch (rdinx(CRTC_IDX, 0x37) & 0x09)
+ 		{
+ 		case 0x00:
+ 			Mem = 2048;
+ 			break;
+ 		case 0x01:
+ 			Mem = 4096;
+ 			break;
+ 		case 0x08:
+ 			Mem = 512;
+ 			break;
+ 		case 0x09:
+ 			Mem = 1024;
+ 			break;
+ 		}
+ 		if ((Chipset != CHIP_ET4000W32) &&
+ 		    (rdinx(CRTC_IDX, 0x32) & 0x80))
+ 		{
+ 			Mem *= 2;
+ 		}
+ 		break;
+ 	}
+ 
+ 	/* 
+ 	 * Lock 
+ 	 */
+ 	outp(vgaIOBase + 8, Save[1]);
+ 	outp(0x3BF, Save[0]);
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 
+ 	return(Mem);
  }
diff -c /dev/null mit/server/ddx/x386/SuperProbe/UMC.c:2.1
*** /dev/null	Fri Mar 11 23:36:27 1994
--- mit/server/ddx/x386/SuperProbe/UMC.c	Fri Mar 11 23:36:27 1994
***************
*** 0 ****
--- 1,108 ----
+ /*
+  * Copyright 1994 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/SuperProbe/UMC.c,v 2.1 1994/03/02 08:04:58 dawes Exp $ */
+ 
+ #include "Probe.h"
+ 
+ static Word Ports[] = {0x3BF, SEQ_IDX, SEQ_REG};
+ #define NUMPORTS (sizeof(Ports)/sizeof(Word))
+ 
+ static int MemProbe_UMC __STDCARGS((int));
+ 
+ Chip_Descriptor UMC_Descriptor = {
+ 	"UMC",
+ 	Probe_UMC,
+ 	Ports,
+ 	NUMPORTS,
+ 	FALSE,
+ 	FALSE,
+ 	TRUE,
+ 	MemProbe_UMC,
+ };
+ 
+ Bool Probe_UMC(Chipset)
+ int *Chipset;
+ {
+ 	Bool result = FALSE;
+ 	Byte old;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	old = inp(0x3BF);
+ 	outp(0x3BF, 0x03);
+ 	if (!testinx(SEQ_IDX, 0x06))
+ 	{
+ 		outp(0x3BF, 0xAC);
+ 		if (testinx(SEQ_IDX, 0x06))
+ 		{
+ 			result = TRUE;
+ 			*Chipset = CHIP_UMC_408;
+ 		}
+ 	}
+ 	outp(0x3BF, old);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(result);
+ }
+ 
+ /* ARGSUSED */
+ static int MemProbe_UMC(Chipset)
+ int Chipset;
+ {
+ 	Byte old;
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Unlock
+ 	 */
+ 	old = inp(0x3BF);
+ 	outp(0x3BF, 0xAC);
+ 
+ 	/*
+ 	 * Check
+ 	 */
+ 	switch(rdinx(SEQ_IDX, 0x07) >> 6)
+ 	{
+ 	case 0x00:
+ 		Mem = 256;
+ 		break;
+ 	case 0x01:
+ 		Mem = 512;
+ 		break;
+ 	case 0x02:
+ 	case 0x03:
+ 		Mem = 1024;
+ 		break;
+ 	}
+ 
+ 	/*
+ 	 * Lock
+ 	 */
+ 	outp(0x3BF, old);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
+ }
diff -c mit/server/ddx/x386/SuperProbe/Utils.c:2.2 mit/server/ddx/x386/SuperProbe/Utils.c:2.4
*** mit/server/ddx/x386/SuperProbe/Utils.c:2.2	Fri Mar 11 23:36:28 1994
--- mit/server/ddx/x386/SuperProbe/Utils.c	Fri Mar 11 23:36:28 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Utils.c,v 2.2 1993/09/27 12:23:29 dawes Exp $ */
  
  #include "Probe.h"
  #include "AsmMacros.h"
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Utils.c,v 2.4 1994/03/03 12:42:31 dawes Exp $ */
  
  #include "Probe.h"
  #include "AsmMacros.h"
***************
*** 91,103 ****
  #endif
  {
  	Byte tmp;
! 	Word Port = (inp(0x3CC) & 0x01) ? 0x3DA : 0x3BA;
  
! 	if (port == 0x3C0)
  	{
! 		EnableIOPorts(1, &Port);
! 		tmp = inb(Port);	/* Reset Attribute Reg flip-flop */
! 		DisableIOPorts(1, &Port);
  	}
  	outb(port, index);
  	return(inb(port+1));
--- 91,105 ----
  #endif
  {
  	Byte tmp;
! 	Word Port[2] = {MISC_OUT_R, 0x000};
  
! 	if (port == ATR_IDX)
  	{
! 		EnableIOPorts(1, Port);
! 		Port[1] = (inp(MISC_OUT_R) & 0x01) ? 0x3DA : 0x3BA;
! 		EnableIOPorts(2, Port);
! 		tmp = inp(Port[1]);	/* Reset Attribute Reg flip-flop */
! 		DisableIOPorts(2, Port);
  	}
  	outb(port, index);
  	return(inb(port+1));
***************
*** 115,122 ****
  Byte val;
  #endif
  {
! 	outb(port, index);
! 	outb(port+1, val);
  }
  
  /*
--- 117,208 ----
  Byte val;
  #endif
  {
! 	Byte tmp;
! 	Word Port[2] = {MISC_OUT_R, 0x000};
! 
! 	if (port == ATR_REG_W)
! 	{
! 		EnableIOPorts(1, Port);
! 		Port[1] = (inp(MISC_OUT_R) & 0x01) ? 0x3DA : 0x3BA;
! 		EnableIOPorts(2, Port);
! 		tmp = inp(Port[1]);
! 		DisableIOPorts(2, Port);
! 		outp(port, index);
! 		outp(port, val);
! 	}
! 	else
! 	{
! 		outb(port, index);
! 		outb(port+1, val);
! 	}
! }
! 
! /*
!  * Set the word register 'port', index 'index' to 'val'
!  */
! #ifdef __STDC__
! void wrinx2(Word port, Byte index, Word val)
! #else
! void wrinx2(port, index, val)
! Word port;
! Byte index;
! Word val;
! #endif
! {
! 	wrinx(port, index, (val) & 0xFF);
! 	wrinx(port, index+1, (val >> 8) & 0xFF);
! }
! 
! /*
!  * Set the longword register 'port', index 'index' to 'val' (3 bytes, actually)
!  */
! #ifdef __STDC__
! void wrinx3(Word port, Byte index, Long val)
! #else
! void wrinx3(port, index, val)
! Word port;
! Byte index;
! Long val;
! #endif
! {
! 	wrinx(port, index, (val) & 0xFF);
! 	wrinx(port, index+1, (val >> 8) & 0xFF);
! 	wrinx(port, index+2, (val >> 16) & 0xFF);
! }
! 
! /*
!  * Set the word register 'port', index 'index' to 'val' (Motorola (big-endian)
!  * byte order)
!  */
! #ifdef __STDC__
! void wrinx2m(Word port, Byte index, Word val)
! #else
! void wrinx2m(port, index, val)
! Word port;
! Byte index;
! Word val;
! #endif
! {
! 	wrinx(port, index, (val >> 8) & 0xFF);
! 	wrinx(port, index+1, (val) & 0xFF);
! }
! 
! /*
!  * Set the longword register 'port', index 'index' to 'val' (3 bytes, actually)
!  * (Motorola (big-endian) byte order)
!  */
! #ifdef __STDC__
! void wrinx3m(Word port, Byte index, Long val)
! #else
! void wrinx3m(port, index, val)
! Word port;
! Byte index;
! Long val;
! #endif
! {
! 	wrinx(port, index, (val >> 16) & 0xFF);
! 	wrinx(port, index+1, (val >> 8) & 0xFF);
! 	wrinx(port, index+2, (val) & 0xFF);
  }
  
  /*
***************
*** 140,145 ****
--- 226,285 ----
  }
  
  /*
+  * In register 'port' sets the bits in 'mask' as in 'nvw'.  Other bits are
+  * left unchanged.
+  */
+ #ifdef __STDC__
+ void modreg(Word port, Byte mask, Byte nvw)
+ #else
+ void modreg(port, mask, nvw)
+ Word port;
+ Byte mask;
+ Byte nvw;
+ #endif
+ {
+ 	Byte tmp;
+ 
+ 	tmp = (inp(port) & (~mask)) | (nvw & mask);
+ 	outp(port, tmp);
+ }
+ 
+ /*
+  * Sets the bits in register 'port', index 'index' that are also set in 'val'
+  */
+ #ifdef __STDC__
+ void setinx(Word port, Byte index, Byte val)
+ #else
+ void setinx(port, index, val)
+ Word port;
+ Byte index;
+ Byte val;
+ #endif
+ {
+ 	Byte tmp;
+ 
+ 	tmp = rdinx(port, index);
+ 	wrinx(port, index, tmp | val);
+ }
+ 
+ /*
+  * Clears the bits in register 'port', index 'index' that are set in 'val'
+  */
+ #ifdef __STDC__
+ void clrinx(Word port, Byte index, Byte val)
+ #else
+ void clrinx(port, index, val)
+ Word port;
+ Byte index;
+ Byte val;
+ #endif
+ {
+ 	Byte tmp;
+ 
+ 	tmp = rdinx(port, index);
+ 	wrinx(port, index, tmp & ~val);
+ }
+ /*
   * Return TRUE iff the bits in 'mask' of register 'port' are read/write.
   */
  #ifdef __STDC__
***************
*** 193,199 ****
  #else
  Bool testinx(port, index)
  Word port;
! Word index;
  #endif
  {
  	return(testinx2(port, index, 0xFF));
--- 333,339 ----
  #else
  Bool testinx(port, index)
  Word port;
! Byte index;
  #endif
  {
  	return(testinx2(port, index, 0xFF));
***************
*** 202,226 ****
  /*
   * Force DAC back to PEL mode
   */
- #ifdef __STDC__
- void dactopel(void)
- #else
  void dactopel()
- #endif
  {
  	(void)inp(0x3C8);
  }
  
  /*
!  * Enter command mode of HiColor DACs (result is stored in extern DACcommand)
   */
! #ifdef __STDC__
! Byte dactocomm(void)
! #else
! Byte dactocomm()
! #endif
  {
- 	dactopel();
  	(void)inp(0x3C6);
  	(void)inp(0x3C6);
  	(void)inp(0x3C6);
--- 342,357 ----
  /*
   * Force DAC back to PEL mode
   */
  void dactopel()
  {
  	(void)inp(0x3C8);
  }
  
  /*
!  * Trigger HiColor DACs to change mode.
   */
! Byte trigdac()
  {
  	(void)inp(0x3C6);
  	(void)inp(0x3C6);
  	(void)inp(0x3C6);
***************
*** 228,243 ****
  }
  
  /*
   * Check chip descriptor against exclusion list
   */
- #ifdef __STDC__
- Bool Excluded(Range *ExList, Chip_Descriptor *Chip, Bool Mask10)
- #else
  Bool Excluded(ExList, Chip, Mask10)
  Range *ExList;
  Chip_Descriptor *Chip;
  Bool Mask10;
- #endif
  {
  	int i, j;
  	Word mask = (Mask10 ? 0x3FF : 0xFFFF);
--- 359,417 ----
  }
  
  /*
+  * Enter command mode of HiColor DACs.
+  */
+ Byte dactocomm()
+ {
+ 	dactopel();
+ 	return(trigdac());
+ }
+ 
+ /*
+  * Get the HiColor DAC command register and return to PEL mode.
+  */
+ Byte getdaccomm()
+ {
+ 	Byte ret;
+ 
+ 	dactocomm();
+ 	ret = inp(0x3C6);
+ 	dactopel();
+ 
+ 	return(ret);
+ }
+ 
+ /*
+  * Wait for vertical retrace interval.
+  */
+ void waitforretrace()
+ {
+ 	Word Port[2] = {MISC_OUT_R, 0x000};
+ 
+ 	EnableIOPorts(1, Port);
+ 
+ 	Port[1] = (inp(MISC_OUT_R) & 0x01) ? 0x3DA : 0x3BA;
+ 	EnableIOPorts(2, Port);
+ 	while ((inp(Port[1]) & 0x08) != 0)
+ 	{
+ 		/* Idle */
+ 	}
+ 	while ((inp(Port[1]) & 0x08) == 0)
+ 	{
+ 		/* Idle */
+ 	}
+ 
+ 	DisableIOPorts(2, Port);
+ 	return;
+ }
+ 
+ /*
   * Check chip descriptor against exclusion list
   */
  Bool Excluded(ExList, Chip, Mask10)
  Range *ExList;
  Chip_Descriptor *Chip;
  Bool Mask10;
  {
  	int i, j;
  	Word mask = (Mask10 ? 0x3FF : 0xFFFF);
***************
*** 278,290 ****
  	return(FALSE);
  }
  
- #ifdef __STDC__
- int StrCaseCmp(char *s1, char *s2)
- #else
  int StrCaseCmp(s1, s2)
  char *s1;
  char *s2;
- #endif
  {
  	char c1, c2;
  
--- 452,460 ----
***************
*** 308,322 ****
  	return(c1 - c2);
  }
  
- #ifdef __STDC__
- unsigned int StrToUL(const char *str)
- #else
  unsigned int StrToUL(str)
! char *str;
! #endif
  {
  	int base = 10;
! 	const char *p = str;
  	unsigned int tot = 0;
  
  	if (*p == '0')
--- 478,488 ----
  	return(c1 - c2);
  }
  
  unsigned int StrToUL(str)
! CONST char *str;
  {
  	int base = 10;
! 	CONST char *p = str;
  	unsigned int tot = 0;
  
  	if (*p == '0')
diff -c mit/server/ddx/x386/SuperProbe/VGA.c:2.2 mit/server/ddx/x386/SuperProbe/VGA.c:2.4
*** mit/server/ddx/x386/SuperProbe/VGA.c:2.2	Fri Mar 11 23:36:29 1994
--- mit/server/ddx/x386/SuperProbe/VGA.c	Fri Mar 11 23:36:29 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/VGA.c,v 2.2 1993/09/21 15:20:51 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/VGA.c,v 2.4 1994/02/28 14:10:02 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 32,37 ****
--- 32,39 ----
  static Word Ports[] = {0x3C0, 0x3C1};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_VGA __STDCARGS((int));
+ 
  Chip_Descriptor VGA_Descriptor = {
  	"VGA",
  	Probe_VGA,
***************
*** 39,53 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_VGA(int *Chipset)
- #else
  Bool Probe_VGA(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  	Byte origVal, newVal;
--- 41,52 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_VGA,
  };
  
  Bool Probe_VGA(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  	Byte origVal, newVal;
***************
*** 64,67 ****
--- 63,73 ----
  		*Chipset = CHIP_VGA;
  	}
  	return(result);
+ }
+ 
+ /* ARGSUSED */
+ static int MemProbe_VGA(Chipset)
+ int Chipset;
+ {
+ 	return(256);
  }
diff -c mit/server/ddx/x386/SuperProbe/Video7.c:2.2 mit/server/ddx/x386/SuperProbe/Video7.c:2.4
*** mit/server/ddx/x386/SuperProbe/Video7.c:2.2	Fri Mar 11 23:36:29 1994
--- mit/server/ddx/x386/SuperProbe/Video7.c	Fri Mar 11 23:36:29 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,31 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Video7.c,v 2.2 1993/09/27 12:23:30 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, 0x3C4, 0x3C5};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Video7_Descriptor = {
--- 21,31 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Video7.c,v 2.4 1994/02/28 14:10:03 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, SEQ_IDX, SEQ_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor Video7_Descriptor = {
***************
*** 35,57 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Video7(int *Chipset)
- #else
  Bool Probe_Video7(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
! 	Byte old, old1, id;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
  	old = rdinx(0x3C4, 0x06);
  	wrinx(0x3C4, 0x06, 0xEA);		/* enable extensions */
  	old1 = rdinx(CRTC_IDX, 0x0C);
--- 35,56 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	NULL,
  };
  
  Bool Probe_Video7(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
! 	Byte old, old1;
! 	Word id;
  
  	/* Add CRTC to enabled ports */
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
+ 
  	old = rdinx(0x3C4, 0x06);
  	wrinx(0x3C4, 0x06, 0xEA);		/* enable extensions */
  	old1 = rdinx(CRTC_IDX, 0x0C);
***************
*** 64,85 ****
  		 * It's Video7
  		 */
  		result = TRUE;
! 		id = rdinx(0x3C4, 0x8E);
! 		if ((id < 0xFF) && (id >= 0x80))
  		{
! 			*Chipset = CHIP_V7_VEGA;
  		}
! 		else if ((id < 0x7F) && (id >= 0x70))
  		{
! 			*Chipset = CHIP_V7_FWRITE;
  		}
! 		else if ((id < 0x5A) && (id >= 0x50))
  		{
! 			*Chipset = CHIP_V7_VRAM2;
  		}
! 		else if ((id < 0x4A) && (id >= 0x40))
  		{
! 			*Chipset = CHIP_V7_1024i;
  		}
  		else
  		{
--- 63,104 ----
  		 * It's Video7
  		 */
  		result = TRUE;
! 		id = (rdinx(SEQ_IDX, 0x8F) << 8) | rdinx(0x3C4, 0x8E);
! 		if ((id >= 0x7000) && (id <= 0x70FF))
  		{
! 			*Chipset = CHIP_V7_FWRITE;
  		}
! 		else if ((id >= 0x7140) && (id <= 0x714F))
  		{
! 			*Chipset = CHIP_V7_1024i;
  		}
! 		else if (id == 0x7151)
  		{
! 			*Chipset = CHIP_V7_VRAM2_B;
  		}
! 		else if (id == 0x7152)
  		{
! 			*Chipset = CHIP_V7_VRAM2_C;
! 		}
! 		else if (id == 0x7760)
! 		{
! 			*Chipset = CHIP_HT216BC;
! 		}
! 		else if (id == 0x7763)
! 		{
! 			*Chipset = CHIP_HT216D;
! 		}
! 		else if (id == 0x7764)
! 		{
! 			*Chipset = CHIP_HT216E;
! 		}
! 		else if (id == 0x7765)
! 		{
! 			*Chipset = CHIP_HT216F;
! 		}
! 		else if ((id >= 0x8000) && (id < 0xFFFF))
! 		{
! 			*Chipset = CHIP_V7_VEGA;
  		}
  		else
  		{
diff -c mit/server/ddx/x386/SuperProbe/WD.c:2.2 mit/server/ddx/x386/SuperProbe/WD.c:2.5
*** mit/server/ddx/x386/SuperProbe/WD.c:2.2	Fri Mar 11 23:36:30 1994
--- mit/server/ddx/x386/SuperProbe/WD.c	Fri Mar 11 23:36:30 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,33 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/WD.c,v 2.2 1993/09/22 15:42:22 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, 0x3CE, 0x3CF, 0x3C4, 0x3C5};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
  Chip_Descriptor WD_Descriptor = {
  	"WD",
  	Probe_WD,
--- 21,35 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/WD.c,v 2.5 1994/03/02 08:05:00 dawes Exp $ */
  
  #include "Probe.h"
  
! static Word Ports[] = {0x000, 0x000, GRC_IDX, GRC_REG, SEQ_IDX, SEQ_REG};
  #define NUMPORTS (sizeof(Ports)/sizeof(Word))
  
+ static int MemProbe_WD __STDCARGS((int));
+ 
  Chip_Descriptor WD_Descriptor = {
  	"WD",
  	Probe_WD,
***************
*** 35,51 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_WD(int *Chipset)
- #else
  Bool Probe_WD(Chipset)
  int *Chipset;
- #endif
  {
! 	Byte old, old1, old2, old3;
  	Bool result = FALSE;
  
  	/* Add CRTC to enabled ports */
--- 37,51 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	MemProbe_WD,
  };
  
  Bool Probe_WD(Chipset)
  int *Chipset;
  {
! 	Byte old, old1, old2;
! 	Word ver;
  	Bool result = FALSE;
  
  	/* Add CRTC to enabled ports */
***************
*** 52,63 ****
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
! 	old = rdinx(0x3CE, 0x0F);
! 	modinx(0x3CE, 0x0F, 0x17, 0x00);	/* Lock registers */
! 	if (!testinx2(0x3CE, 0x09, 0x7F))
  	{
! 		wrinx(0x3CE, 0x0F, 0x05);	/* Unlock them again */
! 		if (testinx2(0x3CE, 0x09, 0x7F))
  		{
  			result = TRUE;
  			old2 = rdinx(CRTC_IDX, 0x29);
--- 52,64 ----
  	Ports[0] = CRTC_IDX;
  	Ports[1] = CRTC_REG;
  	EnableIOPorts(NUMPORTS, Ports);
! 
! 	old = rdinx(GRC_IDX, 0x0F);
! 	setinx(GRC_IDX, 0x0F, 0x17);	/* Lock registers */
! 	if (!testinx2(GRC_IDX, 0x09, 0x7F))
  	{
! 		wrinx(GRC_IDX, 0x0F, 0x05);	/* Unlock them again */
! 		if (testinx2(GRC_IDX, 0x09, 0x7F))
  		{
  			result = TRUE;
  			old2 = rdinx(CRTC_IDX, 0x29);
***************
*** 69,81 ****
  			}
  			else
  			{
! 				old1 = rdinx(0x3C4, 0x06);
! 				wrinx(0x3C4, 0x06, 0x48);
! 				if (!testinx2(0x3C4, 0x07, 0xF0))
  				{
  					*Chipset = CHIP_WD_90C00;
  				}
! 				else if (!testinx(0x3C4, 0x10))
  				{
  					if (testinx2(CRTC_IDX, 0x31, 0x68))
  					{
--- 70,82 ----
  			}
  			else
  			{
! 				old1 = rdinx(SEQ_IDX, 0x06);
! 				wrinx(SEQ_IDX, 0x06, 0x48);
! 				if (!testinx2(SEQ_IDX, 0x07, 0xF0))
  				{
  					*Chipset = CHIP_WD_90C00;
  				}
! 				else if (!testinx(SEQ_IDX, 0x10))
  				{
  					if (testinx2(CRTC_IDX, 0x31, 0x68))
  					{
***************
*** 90,121 ****
  						*Chipset = CHIP_WD_90C20;
  					}
  					wrinx(CRTC_IDX, 0x34, 0xA6);
! 					if (rdinx(CRTC_IDX, 0x32))
  					{
  						wrinx(CRTC_IDX, 0x34, 0x00);
  					}
  				}
! 				else if (testinx(0x3C4, 0x25))
! 				{
! 					*Chipset = CHIP_WD_90C24;
! 				}
! 				else if (testinx2(0x3C4, 0x14, 0x0F))
  				{
! 					old3 = rdinx(CRTC_IDX, 0x34);
! 					wrinx(CRTC_IDX, 0x34, 0xA0);
! 					if (testinx(CRTC_IDX, 0x31))
! 					{
  						*Chipset = CHIP_WD_90C26;
! 					}
! 					else if (rdinx(CRTC_IDX, 0x37) == 0x31)
! 					{
! 						*Chipset = CHIP_WD_90C31;
! 					}
! 					else
! 					{	
  						*Chipset = CHIP_WD_90C30;
  					}
- 					wrinx(CRTC_IDX, 0x34, old3);
  				}
  				else if (!testinx2(0x3C4, 0x10, 0x04))
  				{
--- 91,127 ----
  						*Chipset = CHIP_WD_90C20;
  					}
  					wrinx(CRTC_IDX, 0x34, 0xA6);
! 					if (rdinx(CRTC_IDX, 0x32) & 0x20)
  					{
  						wrinx(CRTC_IDX, 0x34, 0x00);
  					}
  				}
! 				else if (testinx2(SEQ_IDX, 0x14, 0x0F))
  				{
! 					ver = ((rdinx(CRTC_IDX, 0x36) << 8) |
! 					       (rdinx(CRTC_IDX, 0x37)));
! 					switch (ver)
! 					{
! 					case 0x3234:
! 						*Chipset = CHIP_WD_90C24;
! 						break;
! 					case 0x3236:
  						*Chipset = CHIP_WD_90C26;
! 						break;
! 					case 0x3330:
  						*Chipset = CHIP_WD_90C30;
+ 						break;
+ 					case 0x3331:
+ 						*Chipset = CHIP_WD_90C31;
+ 						break;
+ 					case 0x3333:
+ 						*Chipset = CHIP_WD_90C33;
+ 						break;
+ 					default:
+ 						Chip_data = ver & 0xFF;
+ 						*Chipset = CHIP_WD_UNK;
+ 						break;
  					}
  				}
  				else if (!testinx2(0x3C4, 0x10, 0x04))
  				{
***************
*** 131,136 ****
--- 137,189 ----
  		}
  	}
  	wrinx(0x3CE, 0x0F, old);
+ 
  	DisableIOPorts(NUMPORTS, Ports);
  	return(result);
+ }
+ 
+ static int MemProbe_WD(Chipset)
+ int Chipset;
+ {
+ 	Byte old;
+ 	int Mem = 0;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Unlock
+ 	 */
+ 	old = rdinx(GRC_IDX, 0x0F);
+ 	wrinx(GRC_IDX, 0x0F, 0x05);
+ 
+ 	/*
+ 	 * Check
+ 	 */
+ 	switch (rdinx(GRC_IDX, 0x0B) >> 6)
+ 	{
+ 	case 0x00:
+ 	case 0x01:
+ 		Mem = 256;
+ 		break;
+ 	case 0x02:
+ 		Mem = 512;
+ 		break;
+ 	case 0x03:
+ 		Mem = 1024;
+ 		break;
+ 	}
+ 
+ 	if ((Chipset >= CHIP_WD_90C33) &&
+ 	    (rdinx(CRTC_IDX, 0x3E) & 0x80))
+ 	{
+ 		Mem = 2048;
+ 	}
+ 
+ 	/*
+ 	 * Lock
+ 	 */
+ 	wrinx(GRC_IDX, 0x0F, old);
+ 
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(Mem);
  }
diff -c /dev/null mit/server/ddx/x386/SuperProbe/Weitek.c:2.1
*** /dev/null	Fri Mar 11 23:36:30 1994
--- mit/server/ddx/x386/SuperProbe/Weitek.c	Fri Mar 11 23:36:31 1994
***************
*** 0 ****
--- 1,119 ----
+ /*
+  * Copyright 1994 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/SuperProbe/Weitek.c,v 2.1 1994/03/07 13:56:09 dawes Exp $ */
+ 
+ #include "Probe.h"
+ 
+ static Word Ports[] = {0x3CD, SEQ_IDX, SEQ_REG};
+ #define NUMPORTS (sizeof(Ports)/sizeof(Word))
+ 
+ Chip_Descriptor Weitek_Descriptor = {
+ 	"Weitek",
+ 	Probe_Weitek,
+ 	Ports,
+ 	NUMPORTS,
+ 	FALSE,
+ 	FALSE,
+ 	TRUE,
+ 	NULL,
+ };
+ 
+ static Byte WeitekEnable(Flag)
+ Byte Flag;
+ {
+ 	Byte new, old, x;
+ 
+ 	old = rdinx(SEQ_IDX, 0x11);
+ 	for (x=0; x < 10; x++)
+ 	{
+ 		;
+ 	}
+ 	outp(SEQ_REG, old);
+ 	for (x=0; x < 10; x++)
+ 	{
+ 		;
+ 	}
+ 	outp(SEQ_REG, old);
+ 	for (x=0; x < 10; x++)
+ 	{
+ 		;
+ 	}
+ 	new = inp(SEQ_REG);
+ 	for (x=0; x < 10; x++)
+ 	{
+ 		;
+ 	}
+ 	outp(SEQ_REG, (new & 0x9F) | Flag);
+ 
+ 	return(old);
+ }
+ 
+ Bool Probe_Weitek(Chipset)
+ int *Chipset;
+ {
+ 	Bool result = FALSE;
+ 	Byte old, ver;
+ 
+ 	EnableIOPorts(NUMPORTS, Ports);
+ 
+ 	/*
+ 	 * Disable extensions
+ 	 */
+ 	old = WeitekEnable(0x60);
+ 	if (!testinx(SEQ_IDX, 0x12))
+ 	{
+ 		/*
+ 		 * Enable extensions
+ 		 */
+ 		WeitekEnable(0);
+ 		if (testinx(SEQ_IDX, 0x12))
+ 		{
+ 			if (tstrg(0x3CD, 0xFF))
+ 			{
+ 				result = TRUE;
+ 				ver = rdinx(SEQ_IDX, 0x07) >> 5;
+ 				switch (ver)
+ 				{
+ 				case 0x00:	/* guess */
+ 					*Chipset = CHIP_WEIT_5086;
+ 					break;
+ 				case 0x01:
+ 					*Chipset = CHIP_WEIT_5186;
+ 					break;
+ 				case 0x02:
+ 					*Chipset = CHIP_WEIT_5286;
+ 					break;
+ 				default:
+ 					Chip_data = ver;
+ 					*Chipset = CHIP_WEIT_UNK;
+ 					break;
+ 				}
+ 			}
+ 		}
+ 	}
+ 
+ 	wrinx(SEQ_IDX, 0x12, old);
+ 	DisableIOPorts(NUMPORTS, Ports);
+ 	return(result);
+ }
diff -c mit/server/ddx/x386/SuperProbe/Yamaha.c:2.1 mit/server/ddx/x386/SuperProbe/Yamaha.c:2.3
*** mit/server/ddx/x386/SuperProbe/Yamaha.c:2.1	Fri Mar 11 23:36:31 1994
--- mit/server/ddx/x386/SuperProbe/Yamaha.c	Fri Mar 11 23:36:31 1994
***************
*** 1,5 ****
  /*
!  * 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
--- 1,5 ----
  /*
!  * Copyright 1993,1994 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
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Yamaha.c,v 2.1 1993/09/21 15:20:54 dawes Exp $ */
  
  #include "Probe.h"
  
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/SuperProbe/Yamaha.c,v 2.3 1994/02/28 14:10:07 dawes Exp $ */
  
  #include "Probe.h"
  
***************
*** 35,49 ****
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE
  };
  
- #ifdef __STDC__
- Bool Probe_Yamaha(int *Chipset)
- #else
  Bool Probe_Yamaha(Chipset)
  int *Chipset;
- #endif
  {
  	Bool result = FALSE;
  
--- 35,46 ----
  	NUMPORTS,
  	FALSE,
  	FALSE,
! 	TRUE,
! 	NULL,
  };
  
  Bool Probe_Yamaha(Chipset)
  int *Chipset;
  {
  	Bool result = FALSE;
  
diff -c mit/server/ddx/x386/accel/ibm8514/Imakefile:2.7 mit/server/ddx/x386/accel/ibm8514/Imakefile:2.8
*** mit/server/ddx/x386/accel/ibm8514/Imakefile:2.7	Fri Mar 11 23:36:40 1994
--- mit/server/ddx/x386/accel/ibm8514/Imakefile	Fri Mar 11 23:36:40 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/accel/ibm8514/Imakefile,v 2.7 1993/09/21 15:21:18 dawes Exp $
  #include <Server.tmpl>
  
  SRCS = 	ibm8514.c ibm8514cmap.c ibm8514gc.c ibm8514fs.c ibm8514ss.c \
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/accel/ibm8514/Imakefile,v 2.8 1993/12/03 13:13:47 dawes Exp $
  #include <Server.tmpl>
  
  SRCS = 	ibm8514.c ibm8514cmap.c ibm8514gc.c ibm8514fs.c ibm8514ss.c \
***************
*** 7,13 ****
  	ibm8514line.c ibm8514seg.c ibm8514frec.c ibm8514text.c \
  	ibm8514font.c ibm8514fcac.c \
  	ibm8514dsln.c ibm8514dssg.c ibm8514ddln.c ibm8514ddsg.c \
! 	ibm8514imwr.s ibm8514imrd.s ibm8514imfl.s ibm8514imst.s
  
  OBJS = 	ibm8514.o ibm8514cmap.o ibm8514gc.o ibm8514fs.o ibm8514ss.o \
  	ibm8514gs.o ibm8514win.o ibm8514init.o ibm8514im.o ibm8514bsto.o \
--- 7,14 ----
  	ibm8514line.c ibm8514seg.c ibm8514frec.c ibm8514text.c \
  	ibm8514font.c ibm8514fcac.c \
  	ibm8514dsln.c ibm8514dssg.c ibm8514ddln.c ibm8514ddsg.c \
! 	ibm8514imwr.s ibm8514imrd.s ibm8514imfl.s ibm8514imst.s \
! 	ibm8514gtim.c
  
  OBJS = 	ibm8514.o ibm8514cmap.o ibm8514gc.o ibm8514fs.o ibm8514ss.o \
  	ibm8514gs.o ibm8514win.o ibm8514init.o ibm8514im.o ibm8514bsto.o \
***************
*** 15,21 ****
  	ibm8514line.o ibm8514seg.o ibm8514frec.o ibm8514text.o \
  	ibm8514font.o ibm8514fcac.o \
  	ibm8514dsln.o ibm8514dssg.o ibm8514ddln.o ibm8514ddsg.o \
! 	ibm8514imwr.o ibm8514imrd.o ibm8514imfl.o ibm8514imst.o
  
  INCLUDES = -I../../common -I../../os-support -I. \
  	   -I../../../mfb -I../../../mi -I../../../../include \
--- 16,23 ----
  	ibm8514line.o ibm8514seg.o ibm8514frec.o ibm8514text.o \
  	ibm8514font.o ibm8514fcac.o \
  	ibm8514dsln.o ibm8514dssg.o ibm8514ddln.o ibm8514ddsg.o \
! 	ibm8514imwr.o ibm8514imrd.o ibm8514imfl.o ibm8514imst.o \
! 	ibm8514gtim.o
  
  INCLUDES = -I../../common -I../../os-support -I. \
  	   -I../../../mfb -I../../../mi -I../../../../include \
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514.c:2.11 mit/server/ddx/x386/accel/ibm8514/ibm8514.c:2.15
*** mit/server/ddx/x386/accel/ibm8514/ibm8514.c:2.11	Fri Mar 11 23:36:40 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514.c	Fri Mar 11 23:36:40 1994
***************
*** 27,35 ****
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vga.c,v 1.2 1991/06/27 00:02:49 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514.c,v 2.11 1993/10/02 07:14:07 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
  #include "pixmapstr.h"
  #include "scrnintstr.h"
--- 27,36 ----
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vga.c,v 1.2 1991/06/27 00:02:49 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514.c,v 2.15 1994/01/09 03:30:03 dawes Exp $ */
  
  #include "X.h"
+ #include "Xmd.h"
  #include "input.h"
  #include "pixmapstr.h"
  #include "scrnintstr.h"
***************
*** 40,45 ****
--- 41,47 ----
  
  #include "x386.h"
  #include "x386Priv.h"
+ #include "x386Procs.h"
  #include "xf86_OSlib.h"
  #include "ibm8514.h"
  #include "reg8514.h"
***************
*** 47,52 ****
--- 49,57 ----
  
  extern Bool x386Exiting, x386Resetting, x386ProbeFailed, x386Verbose;
  extern void NoopDDA();
+ extern Bool mfbRegisterCopyPlaneProc();
+ extern Bool miDCInitialize();
+ extern void SetTimeSinceLastInputEvent();
  
  ScrnInfoRec ibm8514InfoRec = {
      FALSE,		/* Bool configured */
***************
*** 74,79 ****
--- 79,85 ----
      0,			/* int maxClock */
      0,			/* int videoRam */
      0,			/* int BIOSbase, 1.3 new */
+     0,			/* unsigned long MemBase, unused for this driver */
      240, 180,		/* int width, height */
      0,                  /* unsigned long  speedup */
      NULL,	       	/* DisplayModePtr modes */
***************
*** 113,120 ****
  static int ibm8514ScreenMode;
  
  static ScreenPtr savepScreen = NULL;
  
- 
  static unsigned ibm8514_IOPorts[] = {
  	DAC_MASK, DAC_R_INDEX, DAC_W_INDEX, DAC_DATA, DISP_STAT,
  	H_TOTAL, H_DISP, H_SYNC_STRT, H_SYNC_WID,
--- 119,126 ----
  static int ibm8514ScreenMode;
  
  static ScreenPtr savepScreen = NULL;
+ static PixmapPtr ppix = NULL;
  
  static unsigned ibm8514_IOPorts[] = {
  	DAC_MASK, DAC_R_INDEX, DAC_W_INDEX, DAC_DATA, DISP_STAT,
  	H_TOTAL, H_DISP, H_SYNC_STRT, H_SYNC_WID,
***************
*** 204,209 ****
--- 210,218 ----
      int            argc;         /* The number of the Server's arguments. */
      char           **argv;       /* The arguments themselves. Don't change! */
  {
+   int displayResolution = 75;    /* default to 75dpi */
+   extern int monitorResolution;
+ 
      if (ibm8514InfoRec.virtualX == 1024 && ibm8514InfoRec.virtualY == 768) {
  	ibm8514ScreenMode = MODE_1024;
      } else if (ibm8514InfoRec.virtualX == 640 &&
***************
*** 232,241 ****
  
      ibm8514ImageInit();
  
      if (!ibm8514ScreenInit(pScreen,
  			   (pointer) 0,
  			   ibm8514InfoRec.virtualX, ibm8514InfoRec.virtualY,
! 			   75, 75,
  			   ibm8514InfoRec.virtualX))
  	return(FALSE);
  
--- 241,257 ----
  
      ibm8514ImageInit();
  
+     /*
+      * Take display resolution from the -dpi flag if specified
+      */
+ 
+     if (monitorResolution)
+         displayResolution = monitorResolution;
+ 
      if (!ibm8514ScreenInit(pScreen,
  			   (pointer) 0,
  			   ibm8514InfoRec.virtualX, ibm8514InfoRec.virtualY,
! 			   displayResolution, displayResolution,
  			   ibm8514InfoRec.virtualX))
  	return(FALSE);
  
***************
*** 266,272 ****
       int screen_idx;
  {
    PixmapPtr   pspix;
-   static PixmapPtr ppix = NULL;
    ScreenPtr   pScreen = savepScreen;
  
      if (!x386Resetting && !x386Exiting)
--- 282,287 ----
***************
*** 308,314 ****
                ibm8514ImageRead(0, 0, pScreen->width, pScreen->height,
                                 ppix->devPrivate.ptr,
                                 PixmapBytePad(pScreen->width, pScreen->rootDepth),
!                                0, 0);
                pspix->devPrivate.ptr = ppix->devPrivate.ptr;
             }
          }
--- 323,329 ----
                ibm8514ImageRead(0, 0, pScreen->width, pScreen->height,
                                 ppix->devPrivate.ptr,
                                 PixmapBytePad(pScreen->width, pScreen->rootDepth),
!                                0, 0, 0xff);
                pspix->devPrivate.ptr = ppix->devPrivate.ptr;
             }
          }
***************
*** 345,350 ****
--- 360,373 ----
      x386Exiting = TRUE;
      if (x386VTSema)
  	ibm8514EnterLeaveVT(LEAVE, screen_idx);
+     else if (ppix) {
+         /*
+          * 7-Jan-94 CEG: The server is not running on the current vt.
+          * Free the screen snapshot taken when the server vt was left.
+ 	 */
+         (savepScreen->DestroyPixmap)(ppix);
+         ppix = NULL;
+     }
      return(TRUE);
  }
  
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514.h:2.3 mit/server/ddx/x386/accel/ibm8514/ibm8514.h:2.6
*** mit/server/ddx/x386/accel/ibm8514/ibm8514.h:2.3	Fri Mar 11 23:36:41 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514.h	Fri Mar 11 23:36:41 1994
***************
*** 22,28 ****
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514.h,v 2.3 1993/09/21 15:21:19 dawes Exp $ */
  
  #ifndef IBM8514_H
  #define IBM8514_H
--- 22,28 ----
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514.h,v 2.6 1993/12/25 13:57:09 dawes Exp $ */
  
  #ifndef IBM8514_H
  #define IBM8514_H
***************
*** 41,46 ****
--- 41,47 ----
  
  extern Bool ibm8514SaveScreen();
  extern Bool ibm8514CloseScreen();
+ extern Bool ibm8514ScreenInit();
  
  extern void ibm8514RestoreDACvalues();
  extern int ibm8514ListInstalledColormaps();
***************
*** 56,62 ****
  extern void ibm8514ImageWrite();
  extern void ibm8514ImageFill();
  extern void ibm8514ImageStipple();
- extern void ibm8514ImageOpStipple();
  
  extern void ibm8514CacheInit();
  extern void ibm8514FontCache8Init();
--- 57,62 ----
***************
*** 104,109 ****
--- 104,111 ----
  extern void ibm8514RestoreAreas();
  
  extern Bool ibm8514CreateGC();
+ 
+ extern void ibm8514GetImage();
  
  extern ScrnInfoRec ibm8514InfoRec;
  
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514blt.c:2.3 mit/server/ddx/x386/accel/ibm8514/ibm8514blt.c:2.7
*** mit/server/ddx/x386/accel/ibm8514/ibm8514blt.c:2.3	Fri Mar 11 23:36:42 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514blt.c	Fri Mar 11 23:36:42 1994
***************
*** 27,33 ****
  
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514blt.c,v 2.3 1993/09/12 11:24:51 dawes Exp $ */
  
  /* $XConsortium: cfbbitblt.c,v 5.39 91/05/24 16:33:25 keith Exp $ */
  
--- 27,33 ----
  
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514blt.c,v 2.7 1994/02/25 14:57:03 dawes Exp $ */
  
  /* $XConsortium: cfbbitblt.c,v 5.39 91/05/24 16:33:25 keith Exp $ */
  
***************
*** 47,57 ****
  #include	"reg8514.h"
  #include	"ibm8514.h"
  
! void ibm8514FindOrdering();
  
- static unsigned long bitBltPlane = 0;
- 
- 
  RegionPtr
  ibm8514CopyArea(pSrcDrawable, pDstDrawable,
  		pGC, srcx, srcy, width, height, dstx, dsty)
--- 47,54 ----
  #include	"reg8514.h"
  #include	"ibm8514.h"
  
! extern RegionPtr cfbBitBlt();
  
  RegionPtr
  ibm8514CopyArea(pSrcDrawable, pDstDrawable,
  		pGC, srcx, srcy, width, height, dstx, dsty)
***************
*** 356,362 ****
  	    for (i = numRects; --i >= 0; pbox++)
  		ibm8514ImageRead(pbox->x1 + dx, pbox->y1 + dy,
  				 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				 pdst, pixWidth, pbox->x1, pbox->y1);
  	} else if (pSrcDrawable->type != DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
  	    /* Pixmap --> Window */
  	    int pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
--- 353,359 ----
  	    for (i = numRects; --i >= 0; pbox++)
  		ibm8514ImageRead(pbox->x1 + dx, pbox->y1 + dy,
  				 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				 pdst, pixWidth, pbox->x1, pbox->y1, 0xff);
  	} else if (pSrcDrawable->type != DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
  	    /* Pixmap --> Window */
  	    int pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
***************
*** 521,528 ****
  	(void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
  			 width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
  	pSrcDrawable = (DrawablePtr)pBitmap;
!     }
!     else if (((pSrcDrawable->type == DRAWABLE_WINDOW) && 
                (pDstDrawable->type != DRAWABLE_WINDOW)) ||
               ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
                (pDstDrawable->type == DRAWABLE_WINDOW) &&
--- 518,550 ----
  	(void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
  			 width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
  	pSrcDrawable = (DrawablePtr)pBitmap;
!     } else if ((pSrcDrawable->type == DRAWABLE_WINDOW) &&
!  	       (pDstDrawable->type != DRAWABLE_WINDOW)) {
! 	/*
!  	 * Shortcut - we can do Window->Pixmap by copying the window to
!  	 * a pixmap, then we have a Pixmap->Pixmap operation
!  	 */
!  	GCPtr pGC1;
!  	RegionPtr retval;
!  	PixmapPtr pPixmap;
!  
!  	pPixmap=(*pSrcDrawable->pScreen->CreatePixmap)(pSrcDrawable->pScreen, 
!  						        width, height, 8);
!  	if (!pPixmap)
!  	    return(NULL);
!  	pGC1 = GetScratchGC(8, pSrcDrawable->pScreen);
!  	if (!pGC1) {
!  	    (*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
!  	    return(NULL);
!  	}
!  	ValidateGC((DrawablePtr)pPixmap, pGC1);
!  	ibm8514CopyArea(pSrcDrawable, pPixmap, pGC1, srcx, srcy, width, height,
!  		        0, 0);
!  	retval = cfbCopyPlane((DrawablePtr)pPixmap, pDstDrawable, pGC,
!                               0, 0, width, height, dstx, dsty, bitPlane);
!  	(*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
!  	return(retval);
!     } else if (((pSrcDrawable->type == DRAWABLE_WINDOW) && 
                (pDstDrawable->type != DRAWABLE_WINDOW)) ||
               ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
                (pDstDrawable->type == DRAWABLE_WINDOW) &&
***************
*** 797,808 ****
           psrc = pix->devPrivate.ptr;
  
           for (i = numRects; --i >= 0; pbox++) {
!             ibm8514ImageOpStipple(pbox->x1, pbox->y1,
!                                   pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
!                                   psrc, pixWidth,
!                                   pix->drawable.width, pix->drawable.height,
!                                   -dx, -dy, pGC->fgPixel, pGC->bgPixel,
!                                   ibm8514alu[pGC->alu], (short) pGC->planemask);
           }
        } else {
           /* Pixmap --> Pixmap */
--- 819,831 ----
           psrc = pix->devPrivate.ptr;
  
           for (i = numRects; --i >= 0; pbox++) {
!             ibm8514ImageStipple(pbox->x1, pbox->y1,
!                                 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
!                                 psrc, pixWidth,
!                                 pix->drawable.width, pix->drawable.height,
!                                 -dx, -dy, pGC->fgPixel, pGC->bgPixel,
!                                 ibm8514alu[pGC->alu],
! 				(short) pGC->planemask, 1);
           }
        } else {
           /* Pixmap --> Pixmap */
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514bsto.c:2.3 mit/server/ddx/x386/accel/ibm8514/ibm8514bsto.c:2.4
*** mit/server/ddx/x386/accel/ibm8514/ibm8514bsto.c:2.3	Fri Mar 11 23:36:43 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514bsto.c	Fri Mar 11 23:36:43 1994
***************
*** 25,31 ****
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514bsto.c,v 2.3 1993/08/17 16:14:42 dawes Exp $ */
  
  #include    "cfb.h"
  #include    "X.h"
--- 25,31 ----
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514bsto.c,v 2.4 1993/12/03 13:13:53 dawes Exp $ */
  
  #include    "cfb.h"
  #include    "X.h"
***************
*** 64,70 ****
  	ibm8514ImageRead(pBox->x1 + xorg, pBox->y1 + yorg,
  			 pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
  			 pPixmap->devPrivate.ptr, pixWidth,
! 			 pBox->x1, pBox->y1);
  	pBox++;
      }
  }
--- 64,70 ----
  	ibm8514ImageRead(pBox->x1 + xorg, pBox->y1 + yorg,
  			 pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
  			 pPixmap->devPrivate.ptr, pixWidth,
! 			 pBox->x1, pBox->y1, 0xff);
  	pBox++;
      }
  }
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514dsln.c:2.1 mit/server/ddx/x386/accel/ibm8514/ibm8514dsln.c:2.2
*** mit/server/ddx/x386/accel/ibm8514/ibm8514dsln.c:2.1	Fri Mar 11 23:36:44 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514dsln.c	Fri Mar 11 23:36:44 1994
***************
*** 26,32 ****
  ******************************************************************/
  /* 14-sep-93 TCG: ibm8514dsln.c based on ibm8514line.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514dsln.c,v 2.1 1993/10/18 12:16:33 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 26,32 ----
  ******************************************************************/
  /* 14-sep-93 TCG: ibm8514dsln.c based on ibm8514line.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514dsln.c,v 2.2 1993/12/25 13:57:13 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 105,112 ****
      unsigned int oc1;           /* outcode of point 1 */
      unsigned int oc2;           /* outcode of point 2 */
  
-     unsigned long *addrl;       /* address of destination pixmap */
-     int nlwidth;                /* width in longwords of destination pixmap */
      int xorg, yorg;             /* origin of window */
  
      int adx;                    /* abs values of dx and dy */
--- 105,110 ----
***************
*** 124,136 ****
      unsigned char *pDash;
      Bool dashupdated;
                                  /* a bunch of temporaries */
-     int tmp;
      register int y1, y2;
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int             alu;
  
  /* 4-5-93 TCG : is VT visible */
      if (!x386VTSema)
--- 122,131 ----
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514dssg.c:2.1 mit/server/ddx/x386/accel/ibm8514/ibm8514dssg.c:2.2
*** mit/server/ddx/x386/accel/ibm8514/ibm8514dssg.c:2.1	Fri Mar 11 23:36:45 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514dssg.c	Fri Mar 11 23:36:45 1994
***************
*** 26,32 ****
  ******************************************************************/
  /* 16-sep-93 TCG: ibm8514dssg.c from ibm8514dsln.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514dssg.c,v 2.1 1993/10/18 12:16:35 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 26,32 ----
  ******************************************************************/
  /* 16-sep-93 TCG: ibm8514dssg.c from ibm8514dsln.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514dssg.c,v 2.2 1993/12/25 13:57:15 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 103,110 ****
      unsigned int oc1;           /* outcode of point 1 */
      unsigned int oc2;           /* outcode of point 2 */
  
-     unsigned long *addrl;       /* address of destination pixmap */
-     int nlwidth;                /* width in longwords of destination pixmap */
      int xorg, yorg;             /* origin of window */
  
      int adx;                    /* abs values of dx and dy */
--- 103,108 ----
***************
*** 121,133 ****
      int dash0len, dashidx, dashstartidx, dashnum, dashrem;
      unsigned char *pDash;
                                  /* a bunch of temporaries */
-     int tmp;
      register int y1, y2;
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int             alu;
  
  /* 4-5-93 TCG : is VT visible */
      if (!x386VTSema)
--- 119,128 ----
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514fcac.c:2.5 mit/server/ddx/x386/accel/ibm8514/ibm8514fcac.c:2.7
*** mit/server/ddx/x386/accel/ibm8514/ibm8514fcac.c:2.5	Fri Mar 11 23:36:45 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514fcac.c	Fri Mar 11 23:36:45 1994
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514fcac.c,v 2.5 1993/09/27 12:23:43 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514fcac.c,v 2.7 1993/12/25 13:57:17 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 39,44 ****
--- 39,46 ----
  #define FC_MAX_WIDTH	24
  #define FC_MAX_HEIGHT	32
  
+ extern void QueryGlyphExtents();
+ 
  typedef struct {
      FontPtr		font;
      unsigned int	lru;
***************
*** 148,161 ****
  				*pb++ = *pglyph++;
  			pb = pbits;
  		    }
! 		    ibm8514ImageOpStipple(ibm8514FC_X+(c%32)*FC_MAX_WIDTH,
! 					  ibm8514FC_Y+(c/32)*FC_MAX_HEIGHT,
! 					  gWidth, gHeight,
! 					  pb, nbyGlyphWidth, gWidth, gHeight,
! 					  ibm8514FC_X+(c%32)*FC_MAX_WIDTH,
! 					  ibm8514FC_Y+(c/32)*FC_MAX_HEIGHT,
! 					  0xff, 0, ibm8514alu[GXcopy],
! 					  (1 << ret));
  		}
  	    }
  	}
--- 150,163 ----
  				*pb++ = *pglyph++;
  			pb = pbits;
  		    }
! 		    ibm8514ImageStipple(ibm8514FC_X+(c%32)*FC_MAX_WIDTH,
! 					ibm8514FC_Y+(c/32)*FC_MAX_HEIGHT,
! 					gWidth, gHeight,
! 					pb, nbyGlyphWidth, gWidth, gHeight,
! 					ibm8514FC_X+(c%32)*FC_MAX_WIDTH,
! 					ibm8514FC_Y+(c/32)*FC_MAX_HEIGHT,
! 					0xff, 0, ibm8514alu[GXcopy],
! 					(1 << ret), 1);
  		}
  	    }
  	}
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514frec.c:2.3 mit/server/ddx/x386/accel/ibm8514/ibm8514frec.c:2.4
*** mit/server/ddx/x386/accel/ibm8514/ibm8514frec.c:2.3	Fri Mar 11 23:36:46 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514frec.c	Fri Mar 11 23:36:46 1994
***************
*** 28,34 ****
  Modified by Tiago Gons (tiago@comosjn.hobby.nl)
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514frec.c,v 2.3 1993/08/17 16:14:45 dawes Exp $ */
  
  /* $XConsortium: cfbfillrct.c,v 5.13 90/05/15 18:40:19 keith Exp $ */
  
--- 28,34 ----
  Modified by Tiago Gons (tiago@comosjn.hobby.nl)
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514frec.c,v 2.4 1993/11/24 12:33:08 dawes Exp $ */
  
  /* $XConsortium: cfbfillrct.c,v 5.13 90/05/15 18:40:19 keith Exp $ */
  
***************
*** 291,298 ****
  					pboxClipped->y2 - pboxClipped->y1,
  					pPix->devPrivate.ptr, pixWidth,
  					width, height, xrot, yrot,
! 					pGC->fgPixel,
! 					ibm8514alu[pGC->alu], pGC->planemask);
  		    pboxClipped++;
  		}
  	    }
--- 291,299 ----
  					pboxClipped->y2 - pboxClipped->y1,
  					pPix->devPrivate.ptr, pixWidth,
  					width, height, xrot, yrot,
! 					pGC->fgPixel, 0,
! 					ibm8514alu[pGC->alu],
! 					pGC->planemask, 0);
  		    pboxClipped++;
  		}
  	    }
***************
*** 321,334 ****
  		}
  	    } else {
  		while (n--) {
! 		    ibm8514ImageOpStipple(pboxClipped->x1, pboxClipped->y1,
! 					  pboxClipped->x2 - pboxClipped->x1,
! 					  pboxClipped->y2 - pboxClipped->y1,
! 					  pPix->devPrivate.ptr, pixWidth,
! 					  width, height, xrot, yrot,
! 					  pGC->fgPixel, pGC->bgPixel,
! 					  ibm8514alu[pGC->alu],
! 					  pGC->planemask);
  		    pboxClipped++;
  		}
  	    }
--- 322,335 ----
  		}
  	    } else {
  		while (n--) {
! 		    ibm8514ImageStipple(pboxClipped->x1, pboxClipped->y1,
! 					pboxClipped->x2 - pboxClipped->x1,
! 					pboxClipped->y2 - pboxClipped->y1,
! 					pPix->devPrivate.ptr, pixWidth,
! 					width, height, xrot, yrot,
! 					pGC->fgPixel, pGC->bgPixel,
! 					ibm8514alu[pGC->alu],
! 					pGC->planemask, 1);
  		    pboxClipped++;
  		}
  	    }
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514fs.c:2.2 mit/server/ddx/x386/accel/ibm8514/ibm8514fs.c:2.3
*** mit/server/ddx/x386/accel/ibm8514/ibm8514fs.c:2.2	Fri Mar 11 23:36:47 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514fs.c	Fri Mar 11 23:36:47 1994
***************
*** 62,68 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514fs.c,v 2.2 1993/08/17 16:14:46 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 62,68 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514fs.c,v 2.3 1993/11/24 12:33:10 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 329,336 ****
  	while (n--) {
  	    ibm8514ImageStipple(ppt->x, ppt->y, *pwidth, 1,
  				pPix->devPrivate.ptr, pixWidth, width, height,
! 				xrot, yrot, pGC->fgPixel,
! 				ibm8514alu[pGC->alu], pGC->planemask);
  	    ppt++;
  	    pwidth++;
      	}
--- 329,336 ----
  	while (n--) {
  	    ibm8514ImageStipple(ppt->x, ppt->y, *pwidth, 1,
  				pPix->devPrivate.ptr, pixWidth, width, height,
! 				xrot, yrot, pGC->fgPixel, 0,
! 				ibm8514alu[pGC->alu], pGC->planemask, 0);
  	    ppt++;
  	    pwidth++;
      	}
***************
*** 419,429 ****
      	}
      } else {
  	while (n--) {
! 	    ibm8514ImageOpStipple(ppt->x, ppt->y, *pwidth, 1,
! 				  pPix->devPrivate.ptr, pixWidth,
! 				  width, height,
! 				  xrot, yrot, pGC->fgPixel, pGC->bgPixel,
! 				  ibm8514alu[pGC->alu], pGC->planemask);
  	    ppt++;
  	    pwidth++;
      	}
--- 419,429 ----
      	}
      } else {
  	while (n--) {
! 	    ibm8514ImageStipple(ppt->x, ppt->y, *pwidth, 1,
! 				pPix->devPrivate.ptr, pixWidth,
! 				width, height,
! 				xrot, yrot, pGC->fgPixel, pGC->bgPixel,
! 				ibm8514alu[pGC->alu], pGC->planemask, 1);
  	    ppt++;
  	    pwidth++;
      	}
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514gc.c:2.2 mit/server/ddx/x386/accel/ibm8514/ibm8514gc.c:2.4
*** mit/server/ddx/x386/accel/ibm8514/ibm8514gc.c:2.2	Fri Mar 11 23:36:48 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514gc.c	Fri Mar 11 23:36:48 1994
***************
*** 24,30 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514gc.c,v 2.2 1993/09/21 15:21:24 dawes Exp $ */
  
  /* $XConsortium: cfbgc.c,v 1.2 91/07/18 23:00:53 keith Exp $ */
  
--- 24,30 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514gc.c,v 2.4 1993/12/25 13:57:19 dawes Exp $ */
  
  /* $XConsortium: cfbgc.c,v 1.2 91/07/18 23:00:53 keith Exp $ */
  
***************
*** 50,56 ****
  
  static void cfbValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
  static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
! static cfbDestroyOps();
  
  static GCFuncs cfbFuncs = {
      cfbValidateGC,
--- 50,56 ----
  
  static void cfbValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
  static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
! static void cfbDestroyOps();
  
  static GCFuncs cfbFuncs = {
      cfbValidateGC,
***************
*** 65,71 ****
  static GCOps	ibm8514Ops = {
      ibm8514SolidFSpans,
      ibm8514SetSpans,
!     miPutImage,
      ibm8514CopyArea,
      ibm8514CopyPlane,
      ibm8514PolyPoint,
--- 65,71 ----
  static GCOps	ibm8514Ops = {
      ibm8514SolidFSpans,
      ibm8514SetSpans,
!     cfbPutImage,
      ibm8514CopyArea,
      ibm8514CopyPlane,
      ibm8514PolyPoint,
***************
*** 318,324 ****
      return ret;
  }
  
! static
  cfbDestroyOps (ops)
      GCOps   *ops;
  {
--- 318,324 ----
      return ret;
  }
  
! static void
  cfbDestroyOps (ops)
      GCOps   *ops;
  {
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514gs.c:2.2 mit/server/ddx/x386/accel/ibm8514/ibm8514gs.c:2.4
*** mit/server/ddx/x386/accel/ibm8514/ibm8514gs.c:2.2	Fri Mar 11 23:36:48 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514gs.c	Fri Mar 11 23:36:48 1994
***************
*** 25,31 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514gs.c,v 2.2 1993/08/17 16:14:47 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 25,31 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514gs.c,v 2.4 1993/12/25 13:57:21 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 58,64 ****
  {
      int			j;
      unsigned char	*pdst; /* where to put the bits */
-     unsigned char	*psrc; /* where to get the bits */
      int			pixmapStride;
  
  /* 4-5-93 TCG : is VT visible */
--- 58,63 ----
***************
*** 89,95 ****
      pdst = (unsigned char *)pdstStart;
  
      for (; nspans--; ppt++, pwidth++) {
! 	ibm8514ImageRead(ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride, 0, 0);
  	pdst += j;		/* width is in 32 bit words */
  	j = (-j) & 3;
  	while (j--)		/* Pad out to 32-bit boundary */
--- 88,95 ----
      pdst = (unsigned char *)pdstStart;
  
      for (; nspans--; ppt++, pwidth++) {
! 	ibm8514ImageRead(ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride,
! 			 0, 0, 0xff);
  	pdst += j;		/* width is in 32 bit words */
  	j = (-j) & 3;
  	while (j--)		/* Pad out to 32-bit boundary */
diff -c /dev/null mit/server/ddx/x386/accel/ibm8514/ibm8514gtim.c:2.0
*** /dev/null	Fri Mar 11 23:36:49 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514gtim.c	Fri Mar 11 23:36:49 1994
***************
*** 0 ****
--- 1,82 ----
+ /*
+  * 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.
+  *
+  */
+ /*
+  * Stolen from the S3 server and adapted to the 8514 server.
+  * Hans Nasten. (nasten@everyware.se).
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514gtim.c,v 2.0 1993/12/03 13:13:56 dawes Exp $ */
+ 
+ #include "X.h"
+ #include "windowstr.h"
+ #include "scrnintstr.h"
+ #include "pixmapstr.h"
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "ibm8514.h"
+ 
+ extern void mfbGetImage();
+ 
+ void
+ ibm8514GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+      DrawablePtr pDrawable;
+      int         sx, sy, w, h;
+      unsigned int format;
+      unsigned long planeMask;
+      pointer     pdstLine;
+ {
+    int width;
+ 
+    if ((w == 0) || (h == 0))
+       return;
+ 
+    if (pDrawable->bitsPerPixel == 1)
+    {
+       mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+       return;
+    }
+ 
+    if (pDrawable->type != DRAWABLE_WINDOW)
+    {
+       cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+       return;
+    }
+ 
+    width = PixmapBytePad(w, pDrawable->depth);
+    if (format == ZPixmap)
+    {
+       ibm8514ImageRead(sx+pDrawable->x, sy+pDrawable->y, w, h, 
+ 			pdstLine, width, 0, 0, planeMask);
+    }
+    else
+    {
+       /*
+        * Worry about this later (much!).  Should be straighforward, though.
+        * Read an image into a dummy pixmap, then use cfbCopyPlane8to1 to
+        * copy each plane in planeMask into the destination.  At least
+        * this is the theory.
+        */
+       miGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+    }
+ }
+ 
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514im.c:2.7 mit/server/ddx/x386/accel/ibm8514/ibm8514im.c:2.11
*** mit/server/ddx/x386/accel/ibm8514/ibm8514im.c:2.7	Fri Mar 11 23:36:50 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514im.c	Fri Mar 11 23:36:50 1994
***************
*** 22,35 ****
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514im.c,v 2.7 1993/09/21 15:21:26 dawes Exp $ */
  
  #include "os.h"
  #include "reg8514.h"
  #include "ibm8514im.h"
  
  #define ASM_IMAGE
  
  #define	reorder(a)	( \
  	(a & 0x80) >> 7 | \
  	(a & 0x40) >> 5 | \
--- 22,38 ----
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514im.c,v 2.11 1993/12/25 13:57:23 dawes Exp $ */
  
  #include "os.h"
  #include "reg8514.h"
  #include "ibm8514im.h"
+ #include "ibm8514.h"
  
  #define ASM_IMAGE
  
+ extern void ibm8514RealImageFill();
+ 
  #define	reorder(a)	( \
  	(a & 0x80) >> 7 | \
  	(a & 0x40) >> 5 | \
***************
*** 145,151 ****
  }
  
  void
! ibm8514ImageRead(x, y, w, h, psrc, pwidth, px, py)
      int			x;
      int			y;
      int			w;
--- 148,154 ----
  }
  
  void
! ibm8514ImageRead(x, y, w, h, psrc, pwidth, px, py, planemask)
      int			x;
      int			y;
      int			w;
***************
*** 154,159 ****
--- 157,163 ----
      int			pwidth;
      int			px;
      int			py;
+     short		planemask;
  {
      int i,j;
      unsigned short *sp;
***************
*** 171,183 ****
      outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | BYTSEQ |_16BIT | PCDATA);
      sp = (unsigned short*)(psrc + pwidth * py + px);
      pwidth = pwidth / 2 - w / 2;
      WaitDataReady();
      if( w & 1 ) {
          w /= 2;
          for (j = 0; j < h; j++) {
              for (i = 0; i < w; i++)
! 	        *sp++ = inw(PIX_TRANS);
! 	    *((unsigned char *)(sp)) = (unsigned char)(inw(PIX_TRANS));
  	    sp += pwidth;
  	}
      }
--- 175,189 ----
      outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | BYTSEQ |_16BIT | PCDATA);
      sp = (unsigned short*)(psrc + pwidth * py + px);
      pwidth = pwidth / 2 - w / 2;
+     planemask = (planemask & 0x00ff) | ((planemask << 8) & 0xff00);
      WaitDataReady();
      if( w & 1 ) {
          w /= 2;
          for (j = 0; j < h; j++) {
              for (i = 0; i < w; i++)
! 	        *sp++ = inw(PIX_TRANS) & planemask;
! 	    *((unsigned char *)(sp)) = (unsigned char)(inw(PIX_TRANS))
! 					& (unsigned char)(planemask);
  	    sp += pwidth;
  	}
      }
***************
*** 185,191 ****
          w /= 2;
          for (j = 0; j < h; j++) {
              for (i = 0; i < w; i++)
! 	        *sp++ = inw(PIX_TRANS);
  	    sp += pwidth;
  	}
      }
--- 191,197 ----
          w /= 2;
          for (j = 0; j < h; j++) {
              for (i = 0; i < w; i++)
! 	        *sp++ = inw(PIX_TRANS) & planemask;
  	    sp += pwidth;
  	}
      }
***************
*** 281,287 ****
  }
  
  void
! ibm8514RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
  			fgPixel, bgPixel, alu, planemask, opaque)
      int			x;
      int			y;
--- 287,293 ----
  }
  
  void
! ibm8514ImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
  			fgPixel, bgPixel, alu, planemask, opaque)
      int			x;
      int			y;
***************
*** 325,379 ****
      outw(CUR_Y, (short)y);
      outw(CMD, CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |
  	      YMAJAXIS | DRAW | PLANAR | WRTDATA);
-     WaitQueue(8);
      modulus(x - pox, pw, x);
      modulus(y - poy, ph, y);
!     while( h > 0 ) {
! 	srch = ( y+h > ph ? ph - y : h );
! 	while( srch > 0 ) {
! 	    dstw = w;
! 	    srcx = x;
! 	    ptmp = (unsigned short *)(psrc + pwidth * y);
! 	    while( dstw > 0 ) {
! 		int np, x2;
! 		unsigned short *pnt, pix;
! 		/*
! 		 * Assemble 16 bits and feed them to the draw engine.
! 		 */
! 		np = pw - srcx;			/* No. pixels left in bitmap.*/
! 		pnt =(unsigned short *)((unsigned char *)(ptmp) + (srcx >> 3));
! 		x2 = srcx & 7;			/* Offset within byte. */
! 		if( np >= 16 ) {
! 		    pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
! 		}
! 		else if( pw >= 16 ) {
! 		    pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
  						 & MSKBIT(np)) | (*ptmp << np);
! 		}
! 		else if( pw >= 8 ) {
! 		    pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
  						      | (*pnt << (np+pw));
! 		}
! 		else {
! 		    pix = (*ptmp >> x2) & MSKBIT(np);
! 		    while( np < 16 && np < dstw ) {
! 			pix |= *ptmp << np;
! 			np += pw;
  		    }
  		}
! 		outw( PIX_TRANS, ibm8514stipple_tab[ pix & 0xff ] );
! 		if( dstw > 8 )
! 		    outw( PIX_TRANS, ibm8514stipple_tab[( pix >> 8 ) & 0xff] );
! 		srcx += 16;
! 		if( srcx >= pw )
! 		    srcx -= pw;
! 		dstw -= 16;
  	    }
! 	    y++;
! 	    h--;
! 	    srch--;
  	}
- 	y = 0;
      }
      WaitQueue(5);
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
--- 331,408 ----
      outw(CUR_Y, (short)y);
      outw(CMD, CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |
  	      YMAJAXIS | DRAW | PLANAR | WRTDATA);
      modulus(x - pox, pw, x);
      modulus(y - poy, ph, y);
!     WaitQueue(8);
!     /*
!      * When the source bitmap is properly aligned, max 16 pixels wide,
!      * and nonrepeating use this faster loop instead.
!      * This speeds up all copying to the font cache.
!      */
!     if( (x & 7) == 0 && w <= 16 && x+w <= pw && y+h <= ph ) {
! 	unsigned short pix;
! 	unsigned char *pnt;
! 
! 	pnt = (unsigned char *)(psrc + pwidth * y + (x >> 3));
! 	while( h-- > 0 ) {
! 	    pix = *((unsigned short *)(pnt));
! 	    outw( PIX_TRANS, ibm8514stipple_tab[ pix & 0xff ] );
! 	    if( w > 8 )
! 		outw( PIX_TRANS, ibm8514stipple_tab[ ( pix >> 8 ) & 0xff ] );
! 
! 	    pnt += pwidth;
! 	}
!     }
!     else {
! 	while( h > 0 ) {
! 	    srch = ( y+h > ph ? ph - y : h );
! 	    while( srch > 0 ) {
! 		dstw = w;
! 		srcx = x;
! 		ptmp = (unsigned short *)(psrc + pwidth * y);
! 		while( dstw > 0 ) {
! 		    int np, x2;
! 		    unsigned short *pnt, pix;
! 		    /*
! 		     * Assemble 16 bits and feed them to the draw engine.
! 		     */
! 		    np = pw - srcx;		/* No. pixels left in bitmap.*/
! 		    pnt =(unsigned short *)
! 				       ((unsigned char *)(ptmp) + (srcx >> 3));
! 		    x2 = srcx & 7;		/* Offset within byte. */
! 		    if( np >= 16 ) {
! 			pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
! 		    }
! 		    else if( pw >= 16 ) {
! 			pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
  						 & MSKBIT(np)) | (*ptmp << np);
! 		    }
! 		    else if( pw >= 8 ) {
! 			pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
  						      | (*pnt << (np+pw));
! 		    }
! 		    else {
! 			pix = (*ptmp >> x2) & MSKBIT(np);
! 			while( np < 16 && np < dstw ) {
! 			    pix |= *ptmp << np;
! 			    np += pw;
! 			}
  		    }
+ 		    outw( PIX_TRANS, ibm8514stipple_tab[ pix & 0xff ] );
+ 		    if( dstw > 8 )
+ 			outw( PIX_TRANS,
+ 			      ibm8514stipple_tab[ ( pix >> 8 ) & 0xff ] );
+ 		    srcx += 16;
+ 		    if( srcx >= pw )
+ 			srcx -= pw;
+ 		    dstw -= 16;
  		}
! 		y++;
! 		h--;
! 		srch--;
  	    }
! 	    y = 0;
  	}
      }
      WaitQueue(5);
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
***************
*** 384,424 ****
  }
  
  #endif /* ASM_IMAGE */
- 
- void
- ibm8514ImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, fgPixel, alu, planemask)
-     int			x;
-     int			y;
-     int			w;
-     int			h;
-     unsigned char	*psrc;
-     int			pwidth;
-     int			pw, ph, pox, poy;
-     int			fgPixel;
-     short		alu;
-     short		planemask;
- {
- 
-     ibm8514RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
- 			    fgPixel, 0, alu, planemask, 0);
- }
- 
- void
- ibm8514ImageOpStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, fgPixel, bgPixel, alu, planemask)
-     int			x;
-     int			y;
-     int			w;
-     int			h;
-     unsigned char	*psrc;
-     int			pw, ph, pox, poy;
-     int			pwidth;
-     int			fgPixel;
-     int			bgPixel;
-     short		alu;
-     short		planemask;
- {
- 
-     ibm8514RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
- 			    fgPixel, bgPixel, alu, planemask, 1);
- 
- }
--- 413,415 ----
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514imrd.s:2.1 mit/server/ddx/x386/accel/ibm8514/ibm8514imrd.s:2.3
*** mit/server/ddx/x386/accel/ibm8514/ibm8514imrd.s:2.1	Fri Mar 11 23:36:50 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514imrd.s	Fri Mar 11 23:36:50 1994
***************
*** 4,10 ****
  Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
  
  void
! ibm8514ImageRead(x, y, w, h, psrc, pwidth, px, py)
      int			x;
      int			y;
      int			w;
--- 4,10 ----
  Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
  
  void
! ibm8514ImageRead(x, y, w, h, psrc, pwidth, px, py, planemask)
      int			x;
      int			y;
      int			w;
***************
*** 13,22 ****
      int			pwidth;
      int			px;
      int			py;
  
  ******************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514imrd.s,v 2.1 1993/09/09 06:00:56 dawes Exp $ */
  
  #define _8514_ASM_
  #include "assyntax.h"
--- 13,23 ----
      int			pwidth;
      int			px;
      int			py;
+     short		planemask;
  
  ******************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514imrd.s,v 2.3 1993/12/06 10:35:37 dawes Exp $ */
  
  #define _8514_ASM_
  #include "assyntax.h"
***************
*** 35,40 ****
--- 36,42 ----
  #define pwidth_arg	REGOFF(28,EBP)
  #define px_arg		REGOFF(32,EBP)
  #define py_arg		REGOFF(36,EBP)
+ #define planemask_arg	REGOFF(40,EBP)
  
  
  	SEG_TEXT
***************
*** 138,143 ****
--- 140,202 ----
  	SUB_L	(EBX,ESI)
  	SHL_L	(CONST(1),ESI)
  
+ 	MOV_W   (planemask_arg,BX)
+ 	CMP_W   (CONST(0xff),BX)
+ 	JZ      (.get_all_planes)
+ 
+ 	MOV_L   (ESI,pwidth_arg)
+ 	MOV_L   (h_arg,ESI)
+ 	MOV_B   (BL,BH)
+ 	TEST_W  (CONST(1),w_arg)
+ 	JNZ     (.odd_width_masked)
+ /*
+  * Even number of pixels on each line, but some of the bitplanes
+  * should be masked out.
+  */
+ 	SHR_L   (CONST(1),w_arg)
+ .next_even_line_masked:
+ 	MOV_L   (w_arg,ECX)
+ .next_even_word_masked:
+ 	IN_W
+ 	AND_W   (BX,AX)
+ 	STOS_W
+ 	LOOP    (.next_even_word_masked)
+ 
+ 	ADD_L   (pwidth_arg,EDI)
+ 	DEC_W   (SI)
+ 	JNZ     (.next_even_line_masked)
+ 
+ 	JMP     (.all_done)
+ /*
+  * Odd number of pixels on each line, but some of the bitplanes
+  * should be masked out. Read an additional pixel on each line.
+  */
+ .odd_width_masked:
+ 	SHR_L   (CONST(1),w_arg)
+ .next_odd_line_masked:
+ 	MOV_L   (w_arg,ECX)
+ 	AND_L   (ECX,ECX)
+ 	JZ      (.odd_masked_skip)
+ 
+ .next_odd_word_masked:
+ 	IN_W
+ 	AND_W   (BX,AX)
+ 	STOS_W
+ 	LOOP    (.next_odd_word_masked)
+ 
+ .odd_masked_skip:
+ 	IN_W
+ 	AND_B   (BL,AL)
+ 	MOV_B   (AL,REGIND(EDI))
+ 	ADD_L   (pwidth_arg,EDI)
+ 	DEC_W   (SI)
+ 	JNZ     (.next_odd_line_masked)
+ 
+ 	JMP     (.all_done)
+ /*
+  * All bitplanes is to be stored. Skip planemask anding.
+  */
+ .get_all_planes:
  	MOV_W	(h_arg,BX)
  	TEST_W	(CONST(1),w_arg)
  	JNZ	(.odd_width)
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514imst.s:2.2 mit/server/ddx/x386/accel/ibm8514/ibm8514imst.s:2.4
*** mit/server/ddx/x386/accel/ibm8514/ibm8514imst.s:2.2	Fri Mar 11 23:36:51 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514imst.s	Fri Mar 11 23:36:51 1994
***************
*** 1,114 ****
  /******************************************************************************
  
! This is a assembly language version of the ibm8514RealImageStipple routine.
  
  Written by Hans Nasten ( nasten@everyware.se ) SEP 16, 1993.
  
! $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514imst.s,v 2.2 1993/09/27 12:23:45 dawes Exp $
  
! The equivalent C-code looks like this.
  
- void
- ibm8514RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
- 			fgPixel, bgPixel, alu, planemask, opaque)
-     int			x;
-     int			y;
-     int			w;
-     int			h;
-     unsigned char	*psrc;
-     int			pw, ph, pox, poy;
-     int			pwidth;
-     int			fgPixel;
-     int			bgPixel;
-     short		alu;
-     short		planemask;
-     int			opaque;
- {
-     int			srcx, srch, dstw;
-     unsigned short	*ptmp;
- 
- 
-     if (alu == MIX_DST || w == 0 || h == 0)
-         return;
- 
-     WaitQueue(6);
-     outw(MULTIFUNC_CNTL, SCISSORS_L | x);
-     outw(MULTIFUNC_CNTL, SCISSORS_R | (x+w-1));
-     outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPPC | COLCMPOP_F);
-     outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
-     outw(WRT_MASK, planemask);
-     outw(FRGD_MIX, FSS_FRGDCOL | alu);
-     WaitQueue(7);
-     if( opaque ) {
- 	outw(BKGD_MIX, BSS_BKGDCOL | alu);
- 	outw(BKGD_COLOR, (short)bgPixel);
-     }
-     else
- 	 outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
-     outw(FRGD_COLOR, (short)fgPixel);
-     w += (x & 3);
-     x &= ~3;
-     outw(MAJ_AXIS_PCNT, (short)(((w + 7) & ~7)-1));
-     outw(CUR_X, (short)x);
-     outw(CUR_Y, (short)y);
-     outw(CMD, CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |
- 	      YMAJAXIS | DRAW | PLANAR | WRTDATA);
-     WaitQueue(8);
-     modulus(x - pox, pw, x);
-     modulus(y - poy, ph, y);
-     while( h > 0 ) {
- 	srch = ( y+h > ph ? ph - y : h );
- 	while( srch > 0 ) {
- 	    dstw = w;
- 	    srcx = x;
- 	    ptmp = (unsigned short *)(psrc + pwidth * y);
- 	    while( dstw > 0 ) {
- 		int np, x2;
- 		unsigned short *pnt, pix;
- 
- 		np = pw - srcx;
- 		pnt =(unsigned short *)((unsigned char *)(ptmp) + (srcx >> 3));
- 		x2 = srcx & 7;
- 		if( np >= 16 ) {
- 		    pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
- 		}
- 		else if( pw >= 16 ) {
- 		    pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
- 						 & MSKBIT(np)) | (*ptmp << np);
- 		}
- 		else if( pw >= 8 ) {
- 		    pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
- 						      | (*pnt << (np+pw));
- 		}
- 		else {
- 		    pix = (*ptmp >> x2) & MSKBIT(np);
- 		    while( np < 16 && np < dstw ) {
- 			pix |= *ptmp << np;
- 			np += pw;
- 		    }
- 		}
- 		outw( PIX_TRANS, ibm8514stipple_tab[ pix & 0xff ] );
- 		if( dstw > 8 )
- 		    outw( PIX_TRANS, ibm8514stipple_tab[( pix >> 8 ) & 0xff] );
- 		srcx += 16;
- 		if( srcx >= pw )
- 		    srcx -= pw;
- 		dstw -= 16;
- 	    }
- 	    y++;
- 	    h--;
- 	    srch--;
- 	}
- 	y = 0;
-     }
-     WaitQueue(5);
-     outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
-     outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
-     outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
-     outw(MULTIFUNC_CNTL, SCISSORS_R | 1023);
-     outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
- }
- 
  ******************************************************************************/
  
  #define _8514_ASM_
--- 1,13 ----
  /******************************************************************************
  
! This is a assembly language version of the ibm8514ImageStipple routine.
  
  Written by Hans Nasten ( nasten@everyware.se ) SEP 16, 1993.
  
! $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514imst.s,v 2.4 1993/11/24 12:33:14 dawes Exp $
  
! This is a assembly language version of the C code in ibm8514im.c
  
  ******************************************************************************/
  
  #define _8514_ASM_
***************
*** 168,176 ****
  	D_WORD	0x0000
  
  
! GLOBL	GLNAME(ibm8514RealImageStipple)
  
! GLNAME(ibm8514RealImageStipple):
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	SUB_L	(CONST(12),ESP)
--- 67,75 ----
  	D_WORD	0x0000
  
  
! GLOBL	GLNAME(ibm8514ImageStipple)
  
! GLNAME(ibm8514ImageStipple):
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	SUB_L	(CONST(12),ESP)
***************
*** 312,318 ****
  	ADD_L	(ph_arg,EDX)
  .mod1:
  	MOV_L	(EDX,y_arg)
- 
  /*
   * Wait until the fifo is empty.
   */
--- 211,216 ----
***************
*** 322,327 ****
--- 220,292 ----
  	TEST_W	(CONST(1),AX)
  	JNZ	(.wait_queue_2)
  /*
+  * When the source bitmap is properly aligned, max 16 pixels wide,
+  * and nonrepeating use this faster loop instead.
+  * This speeds up all copying to the font cache.
+  */
+ 	MOV_L	(x_arg,EAX)
+ 	AND_L	(CONST(7),EAX)
+ 	JNZ	(.next_bitmap_vertical)
+ 
+ 	MOV_L	(w_arg,EAX)
+ 	CMP_L	(CONST(16),EAX)
+ 	JG	(.next_bitmap_vertical)	
+ 
+ 	ADD_L	(x_arg,EAX)
+ 	CMP_L	(pw_arg,EAX)
+ 	JG	(.next_bitmap_vertical)	
+ 
+ 	MOV_L	(y_arg,EAX)
+ 	ADD_L	(h_arg,EAX)
+ 	CMP_L	(ph_arg,EAX)
+ 	JG	(.next_bitmap_vertical)	
+ 
+ 	MOV_L	(y_arg,EAX)
+ 	MUL_L	(pwidth_arg)
+ 	MOV_L	(x_arg,EDX)
+ 	SHR_L	(CONST(3),EDX)
+ 	ADD_L	(EDX,EAX)
+ 	MOV_L	(psrc_arg,ESI)
+ 	ADD_L	(EAX,ESI)
+ 	MOV_L	(PIX_TRANS,EDX)
+ 	MOV_L	(h_arg,EDI)
+ 	CMP_L	(CONST(8),w_arg)
+ 	JLE	(.fast_loop_8)
+ /*
+  * This loop is for max 16 pixels wide bitmaps.
+  */
+ .fast_loop_16:
+ 	MOV_W	(REGIND(ESI),CX)
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(CL,BL)
+ 	SHL_L	(CONST(1),EBX)
+ 	MOV_W	(REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ 	OUT_W
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(CH,BL)
+ 	SHL_L	(CONST(1),EBX)
+ 	MOV_W	(REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ 	OUT_W
+ 	ADD_L	(pwidth_arg,ESI)
+ 	DEC_L	(EDI)
+ 	JNZ	(.fast_loop_16)
+ 
+ 	JMP	(.stipple_exit)
+ /*
+  * This loop is for max 8 pixels wide bitmaps.
+  */
+ .fast_loop_8:
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(REGIND(ESI),BL)
+ 	SHL_L	(CONST(1),EBX)
+ 	MOV_W	(REGOFF(GLNAME(ibm8514stipple_tab),EBX),AX)
+ 	OUT_W
+ 	ADD_L	(pwidth_arg,ESI)
+ 	DEC_L	(EDI)
+ 	JNZ	(.fast_loop_8)
+ 
+ 	JMP	(.stipple_exit)
+ /*
   * Process all lines on screen repeating the bitmap if needed.
   * This loop paints from the present y location to the end of
   * the bitmap. ( or to the end of the screen area if the bitmap
***************
*** 568,573 ****
--- 533,539 ----
  /*
   * Wait until room for 5 entries in the fifo.
   */
+ .stipple_exit:
  	MOV_L   (GP_STAT,EDX)
  .wait_queue_3:
  	IN_W
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514init.c:2.4 mit/server/ddx/x386/accel/ibm8514/ibm8514init.c:2.5
*** mit/server/ddx/x386/accel/ibm8514/ibm8514init.c:2.4	Fri Mar 11 23:36:52 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514init.c	Fri Mar 11 23:36:52 1994
***************
*** 18,28 ****
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514init.c,v 2.4 1993/10/16 17:30:46 dawes Exp $ */
  
! #include "misc.h"
  #include "reg8514.h"
  #include "ibm8514.h"
  
  static short numPlanes = -1;
  static short resolution = -1;
--- 18,31 ----
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514init.c,v 2.5 1993/12/25 13:57:24 dawes Exp $ */
  
! #include "X.h"
! #include "input.h"
  #include "reg8514.h"
  #include "ibm8514.h"
+ #include "x386.h"
+ #include "xf86_OSlib.h"
  
  static short numPlanes = -1;
  static short resolution = -1;
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514line.c:2.4 mit/server/ddx/x386/accel/ibm8514/ibm8514line.c:2.5
*** mit/server/ddx/x386/accel/ibm8514/ibm8514line.c:2.4	Fri Mar 11 23:36:52 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514line.c	Fri Mar 11 23:36:53 1994
***************
*** 25,31 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514line.c,v 2.4 1993/09/21 15:21:29 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 25,31 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514line.c,v 2.5 1993/12/25 13:57:26 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 100,107 ****
      unsigned int oc1;		/* outcode of point 1 */
      unsigned int oc2;		/* outcode of point 2 */
  
-     unsigned long *addrl;		/* address of destination pixmap */
-     int nlwidth;		/* width in longwords of destination pixmap */
      int xorg, yorg;		/* origin of window */
  
      int adx;		/* abs values of dx and dy */
--- 100,105 ----
***************
*** 121,128 ****
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int		    alu;
  
  /* 4-5-93 TCG : is VT visible */
      if (!x386VTSema)
--- 119,124 ----
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514pcac.c:2.3 mit/server/ddx/x386/accel/ibm8514/ibm8514pcac.c:2.5
*** mit/server/ddx/x386/accel/ibm8514/ibm8514pcac.c:2.3	Fri Mar 11 23:36:53 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514pcac.c	Fri Mar 11 23:36:53 1994
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514pcac.c,v 2.3 1993/08/14 05:09:04 dawes Exp $ */
  
  /*       Offscreen memory organization:
   *
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514pcac.c,v 2.5 1993/12/25 13:57:28 dawes Exp $ */
  
  /*       Offscreen memory organization:
   *
***************
*** 214,223 ****
      else
  	pci->id = pix->cacheId = NEXT_CACHE_ID;
  
!     ibm8514ImageOpStipple(pci->x, pci->y, pci->pix_w, pci->pix_h,
! 			  pix->devPrivate.ptr, pix->devKind,
! 			  pci->pix_w, pci->pix_h, pci->x, pci->y,
! 			  255, 0, MIX_SRC, 0xffff);
  
      DoCacheExpandPixmap(pci);
  }
--- 214,223 ----
      else
  	pci->id = pix->cacheId = NEXT_CACHE_ID;
  
!     ibm8514ImageStipple(pci->x, pci->y, pci->pix_w, pci->pix_h,
! 			pix->devPrivate.ptr, pix->devKind,
! 			pci->pix_w, pci->pix_h, pci->x, pci->y,
! 			255, 0, MIX_SRC, 0xffff, 1);
  
      DoCacheExpandPixmap(pci);
  }
***************
*** 399,405 ****
      int xwmid, ywmid, orig_xwmid;
      int startx, starty, endx, endy;
      int orig_x = x;
-     int i;
  
      if (w == 0 || h == 0)
  	return;
--- 399,404 ----
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514scri.c:2.2 mit/server/ddx/x386/accel/ibm8514/ibm8514scri.c:2.5
*** mit/server/ddx/x386/accel/ibm8514/ibm8514scri.c:2.2	Fri Mar 11 23:36:54 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514scri.c	Fri Mar 11 23:36:54 1994
***************
*** 36,42 ****
  
  ********************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514scri.c,v 2.2 1993/09/04 16:27:07 dawes Exp $ */
  
  /* $XConsortium: cfbscrinit.c,v 5.18 90/09/24 17:46:11 rws Exp $ */
  
--- 36,42 ----
  
  ********************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514scri.c,v 2.5 1993/12/25 13:57:30 dawes Exp $ */
  
  /* $XConsortium: cfbscrinit.c,v 5.18 90/09/24 17:46:11 rws Exp $ */
  
***************
*** 58,63 ****
--- 58,65 ----
  
  extern RegionPtr mfbPixmapToRegion();
  extern Bool mfbAllocatePrivates();
+ extern Bool mfbRegisterCopyPlaneProc();
+ extern Bool miScreenInit();
  
  extern int defaultColorVisualClass;
  
***************
*** 97,104 ****
  
  #define NUMDEPTHS	((sizeof depths)/(sizeof depths[0]))
  
- int cfbWindowPrivateIndex;
- int cfbGCPrivateIndex;
  static unsigned long cfbGeneration = 0;
  
  miBSFuncRec ibm8514BSFuncRec = {
--- 99,104 ----
***************
*** 154,160 ****
      pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
      pScreen->QueryBestSize = mfbQueryBestSize;
      /* SaveScreen */
!     pScreen->GetImage = miGetImage;
      pScreen->GetSpans = ibm8514GetSpans;
      pScreen->CreateWindow = cfbCreateWindow;
      pScreen->DestroyWindow = cfbDestroyWindow;
--- 154,160 ----
      pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
      pScreen->QueryBestSize = mfbQueryBestSize;
      /* SaveScreen */
!     pScreen->GetImage = ibm8514GetImage;
      pScreen->GetSpans = ibm8514GetSpans;
      pScreen->CreateWindow = cfbCreateWindow;
      pScreen->DestroyWindow = cfbDestroyWindow;
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514seg.c:2.4 mit/server/ddx/x386/accel/ibm8514/ibm8514seg.c:2.5
*** mit/server/ddx/x386/accel/ibm8514/ibm8514seg.c:2.4	Fri Mar 11 23:36:55 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514seg.c	Fri Mar 11 23:36:55 1994
***************
*** 25,31 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514seg.c,v 2.4 1993/09/21 15:21:30 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 25,31 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514seg.c,v 2.5 1993/12/25 13:57:34 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 97,104 ****
      unsigned int oc1;		/* outcode of point 1 */
      unsigned int oc2;		/* outcode of point 2 */
  
-     unsigned long *addrl;		/* address of destination pixmap */
-     int nlwidth;		/* width in longwords of destination pixmap */
      int xorg, yorg;		/* origin of window */
  
      int adx;		/* abs values of dx and dy */
--- 97,102 ----
***************
*** 118,125 ****
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int		    alu;
  
  /* 4-5-93 TCG : is VT visible */
      if (!x386VTSema)
--- 116,121 ----
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514text.c:2.2 mit/server/ddx/x386/accel/ibm8514/ibm8514text.c:2.3
*** mit/server/ddx/x386/accel/ibm8514/ibm8514text.c:2.2	Fri Mar 11 23:36:55 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514text.c	Fri Mar 11 23:36:55 1994
***************
*** 22,28 ****
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514text.c,v 2.2 1993/09/09 06:01:00 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 22,28 ----
   * Modified by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514text.c,v 2.3 1993/12/25 13:57:37 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 33,39 ****
--- 33,43 ----
  #include        "scrnintstr.h"
  #include        "pixmapstr.h"
  #include	"dixfontstr.h"
+ #include	"mi.h"
  #include	"ibm8514.h"
+ 
+ extern int ibm8514CPolyText8();
+ extern int ibm8514CImageText8();
  
  int
  ibm8514PolyText8(pDraw, pGC, x, y, count, chars)
diff -c mit/server/ddx/x386/accel/ibm8514/ibm8514win.c:2.2 mit/server/ddx/x386/accel/ibm8514/ibm8514win.c:2.3
*** mit/server/ddx/x386/accel/ibm8514/ibm8514win.c:2.2	Fri Mar 11 23:36:56 1994
--- mit/server/ddx/x386/accel/ibm8514/ibm8514win.c	Fri Mar 11 23:36:56 1994
***************
*** 25,31 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514win.c,v 2.2 1993/08/17 16:14:54 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 25,31 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/ibm8514/ibm8514win.c,v 2.3 1993/12/25 13:57:38 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 40,45 ****
--- 40,46 ----
  #include "x386.h"
  #include "x386Priv.h"
  #include "reg8514.h"
+ #include "ibm8514.h"
  
  void 
  ibm8514CopyWindow(pWin, ptOldOrg, prgnSrc)
diff -c mit/server/ddx/x386/accel/mach32/Imakefile:2.2 mit/server/ddx/x386/accel/mach32/Imakefile:2.8
*** mit/server/ddx/x386/accel/mach32/Imakefile:2.2	Fri Mar 11 23:37:00 1994
--- mit/server/ddx/x386/accel/mach32/Imakefile	Fri Mar 11 23:37:00 1994
***************
*** 1,30 ****
! XCOMM $XFree86: mit/server/ddx/x386/accel/mach32/Imakefile,v 2.2 1993/10/02 07:14:18 dawes Exp $
  #include <Server.tmpl>
  
  SRCS = 	mach32.c mach32cmap.c mach32gc.c mach32fs.c mach32ss.c \
  	mach32gs.c mach32win.c mach32init.c mach32im.c mach32bstor.c \
  	mach32scrin.c mach32blt.c mach32pcach.c mach32plypt.c \
! 	mach32line.c mach32seg.c mach32frect.c mach32text.c \
  	mach32font.c mach32fcach.c mach32pntwn.c ativga.c \
! 	mach32curs.c
  
  OBJS = 	mach32.o mach32cmap.o mach32gc.o mach32fs.o mach32ss.o \
  	mach32gs.o mach32win.o mach32init.o mach32im.o mach32bstor.o \
  	mach32scrin.o mach32blt.o mach32pcach.o mach32plypt.o \
! 	mach32line.o mach32seg.o mach32frect.o mach32text.o \
  	mach32font.o mach32fcach.o mach32pntwn.o ativga.o \
! 	mach32curs.o
  
  INCLUDES = -I../../common -I. \
  	   -I../../../mfb -I../../../mi -I../../../../include \
!            -I../../../cfb -I$(INCLUDESRC) -I$(FONTSRC)/include \
! 	   -I$(FONTSRC)/lib/font/include -I../../os-support
  
  NormalLibraryObjectRule()
  
  NormalAsmObjectRule()
  
  NormalLibraryTarget(mach32,$(OBJS))
  
  InstallLinkKitLibrary(mach32,$(LINKKITDIR)/drivers)
  
--- 1,37 ----
! XCOMM $XFree86: mit/server/ddx/x386/accel/mach32/Imakefile,v 2.8 1994/03/01 09:51:26 dawes Exp $
  #include <Server.tmpl>
  
  SRCS = 	mach32.c mach32cmap.c mach32gc.c mach32fs.c mach32ss.c \
  	mach32gs.c mach32win.c mach32init.c mach32im.c mach32bstor.c \
  	mach32scrin.c mach32blt.c mach32pcach.c mach32plypt.c \
! 	mach32line.c mach32line1r.c mach32seg.c mach32frect.c mach32text.c \
  	mach32font.c mach32fcach.c mach32pntwn.c ativga.c \
! 	mach32curs.c mach32gtimg.c mach32mem.c mach32dline.c mach32dseg.c \
! 	vgaHW.c
  
  OBJS = 	mach32.o mach32cmap.o mach32gc.o mach32fs.o mach32ss.o \
  	mach32gs.o mach32win.o mach32init.o mach32im.o mach32bstor.o \
  	mach32scrin.o mach32blt.o mach32pcach.o mach32plypt.o \
! 	mach32line.o mach32line1r.o mach32seg.o mach32frect.o mach32text.o \
  	mach32font.o mach32fcach.o mach32pntwn.o ativga.o \
! 	mach32curs.o mach32gtimg.o mach32mem.o mach32dline.o mach32dseg.o \
! 	vgaHW.o
  
  INCLUDES = -I../../common -I. \
  	   -I../../../mfb -I../../../mi -I../../../../include \
!       -I../../vga256/vga -I../../../cfb -I$(INCLUDESRC) -I$(FONTSRC)/include \
! 	   -I$(FONTSRC)/lib/font/include -I../../os-support -I../../common_hw
  
+ DEFINES = -DMACH32_SERVER
+ 
  NormalLibraryObjectRule()
  
  NormalAsmObjectRule()
  
  NormalLibraryTarget(mach32,$(OBJS))
+ 
+ ObjectFromSpecialSource(vgaHW,../../vga256/vga/vgaHW,/**/)
+ ObjectFromSpecialSource(mach32line1r,mach32line,-DONE_RECT)
  
  InstallLinkKitLibrary(mach32,$(LINKKITDIR)/drivers)
  
diff -c mit/server/ddx/x386/accel/mach32/ativga.c:2.5 mit/server/ddx/x386/accel/mach32/ativga.c:2.6
*** mit/server/ddx/x386/accel/mach32/ativga.c:2.5	Fri Mar 11 23:37:00 1994
--- mit/server/ddx/x386/accel/mach32/ativga.c	Fri Mar 11 23:37:01 1994
***************
*** 40,77 ****
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/ativga.c,v 2.5 1993/10/02 07:14:19 dawes Exp $ */
  
  #include "X.h"
  #include "misc.h"
  #include "input.h"
  #include "os.h"
  #include "xf86_OSlib.h"
  #include "regmach32.h"
  
- #if !defined(linux) && !defined(SVR4) && !defined(SYSV)
- #define SAVE_TEXT
- #endif
- #define SAVE_FONT1
- 
  typedef struct {
!    unsigned char MiscOutReg;
!    unsigned char CRTC[25];	/* Crtc Controller */
!    unsigned char Sequencer[5];	/* video Sequencer */
!    unsigned char Graphics[9];	/* Video Graphics */
!    unsigned char Attribute[21]; /* Video Atribute */
!    unsigned char DAC[768];	/* Internal Colorlookuptable */
!    void          *FontInfo1;	/* Fonts */
!    unsigned char *TextInfo;	/* Screen text */
     unsigned char ATIExtRegBank[11]; /* ATI Registers B0,B1,B2,B3,
  				       B5, B6,B8,B9, BE,A6,A7 */
  } SaveBlock;
  
! pointer               vgaBase  = NULL;
  
! static SaveBlock      save      = { 0, };
! static short          ATIExtReg = 0x1ce;
! unsigned short vgaIOBase;
  
  #define ER_B0   0               /* Extended Register indices (ATIExtRegBank) */
  #define ER_B1   1
--- 40,72 ----
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/ativga.c,v 2.6 1994/02/13 04:04:58 dawes Exp $ */
  
  #include "X.h"
  #include "misc.h"
  #include "input.h"
  #include "os.h"
+ #include "vga.h"
  #include "xf86_OSlib.h"
  #include "regmach32.h"
  
  typedef struct {
!    vgaHWRec std;
     unsigned char ATIExtRegBank[11]; /* ATI Registers B0,B1,B2,B3,
  				       B5, B6,B8,B9, BE,A6,A7 */
  } SaveBlock;
  
! pointer        vgaBase  = NULL;
! pointer        vgaNewVideoState = NULL;
! 
! #define save   ((SaveBlock *)vgaNewVideoState)
! 
! static short   ATIExtReg = 0x1ce;
! int            vgaIOBase;
! int            vgaInterlaceType = VGA_DIVIDE_VERT;
  
! /* Define dummy to keep vgaHW.c happy */
! void (*vgaSaveScreenFunc)() = NoopDDA;
  
  #define ER_B0   0               /* Extended Register indices (ATIExtRegBank) */
  #define ER_B1   1
***************
*** 109,115 ****
  {
     unsigned char b2_save;
     unsigned char b8_save;
-    int           i;
  
     if (!vgaBase) {
        vgaBase = xf86MapVidMem(screen_idx, VGA_REGION, (pointer)0xa0000,
--- 104,109 ----
***************
*** 116,331 ****
  			      64 * 1024);
     }
  
-    /* The rest of this routine is mostly from ATISave() in
-       x386/vga256/drivers/ati/driver.c */
- 
     vgaIOBase = (inb(0x3cc) & 0x01) ? 0x3D0 : 0x3B0;
     
!    /* Disable video */
!    inb(vgaIOBase + 0x0A);	/* reset flip-flop */
!    outb( 0x3c0, 0x00 );
  
     /* Unlock ATI specials */
     outb(ATIExtReg, (((b8_save = inATI(0xb8)) & 0xC0) << 8) | 0xb8);
  
-    save.MiscOutReg = inb(0x3CC);
- 
     b2_save = inATI(0xb2);
     outb(ATIExtReg, 0x00b2);	/* segment select 0 */
  
!    save.ATIReg0  = inATI(0xb0);
!    save.ATIReg1  = inATI(0xb1);
!    save.ATIReg2  = b2_save;
!    save.ATIReg3  = inATI(0xb3);
!    save.ATIReg5  = inATI(0xb5);
!    save.ATIReg6  = inATI(0xb6);
!    save.ATIReg8  = b8_save;
!    save.ATIRegE  = inATI(0xbe);
!    save.ATIReg9  = inATI(0xb9);
!    save.ATIRegA6 = inATI(0xa6);
!    save.ATIRegA7 = inATI(0xa7);
! 
!    for (i=0; i<25; i++) {
!       outb(vgaIOBase + 4,i);
!       save.CRTC[i] = inb(vgaIOBase + 5);
!    }
!         
!    for (i=0; i<21; i++) {
!       inb(vgaIOBase + 0x0A); /* reset flip-flop */
!       outb(0x3C0,i);
!       save.Attribute[i] = inb(0x3C1);
!    }
! 
!    for (i=0; i<9;  i++) {
!       outb(0x3CE,i);
!       save.Graphics[i]  = inb(0x3CF);
!    }
  
!    for (i=0; i<5;  i++) {
!       outb(0x3C4,i);
!       save.Sequencer[i] = inb(0x3C5);
!    }
!         
!    /*                       
!     * save the colorlookuptable 
!     */
!    outb(0x3C6,0xFF);
!    outb(0x3C7,0x00);
!    for (i=0; i<768; i++)
! 	 save.DAC[i] = inb(0x3C9); 
! 
!    /* Save fonts */
! 
! #ifdef SAVE_FONT1
!    if (!save.FontInfo1)
! 	 save.FontInfo1 = (void *)xalloc(8192);
!    inb(vgaIOBase + 0x0A);	/* reset flip-flop */
!    outb(0x3C0,0x10); outb(0x3C0, 0x01); /* graphics mode */
!    outw(0x3C4, 0x0402);			/* write to plane 2 */
!    outw(0x3C4, 0x0604);			/* enable plane graphics */
!    outw(0x3CE, 0x0204);			/* read plane 2 */
!    outw(0x3CE, 0x0005);			/* write mode 0, read mode 0 */
!    outw(0x3CE, 0x0506);			/* set graphics */
!    bcopy(vgaBase, save.FontInfo1, 8192);
! #endif /* SAVE_FONT1 */
! 
! #ifdef SAVE_TEXT
!    if (!save.TextInfo)
! 	save.TextInfo = (unsigned char *)xalloc(8192);
!    inb(vgaIOBase + 0x0A);	/* reset flip-flop */
!    outb(0x3C0,0x10); outb(0x3C0, 0x01); /* graphics mode */
!    outw(0x3C4, 0x0102);			/* write to plane 0 */
!    outw(0x3C4, 0x0604);			/* enable plane graphics */
!    outw(0x3CE, 0x0004);			/* read plane 0 */
!    outw(0x3CE, 0x0005);			/* write mode 0, read mode 0 */
!    outw(0x3CE, 0x0506);			/* set graphics */
!    bcopy(vgaBase, save.TextInfo, 4096);
!    outw(0x3C4, 0x0202);			/* write to plane 1 */
!    outw(0x3C4, 0x0604);			/* enable plane graphics */
!    outw(0x3CE, 0x0104);			/* read plane 1 */
!    outw(0x3CE, 0x0005);			/* write mode 0, read mode 0 */
!    outw(0x3CE, 0x0506);			/* set graphics */
!    bcopy(vgaBase, save.TextInfo + 4096, 4096);
! #endif /* SAVE_TEXT */
!           
     /* Enable video */
     inb(vgaIOBase + 0x0A); /* reset flip-flop */
     outb( 0x3c0, 0x20 );
  }
  
  void mach32RestoreVGAInfo()
  {
     /* This routine is mostly from ATIRestore() in
!       x386/vga256/drivers/ati/driver.c */
! 
!    int i;
! 
!    if (vgaIOBase == 0x3B0)
! 	 save.MiscOutReg &= 0xFE;
!    else
! 	 save.MiscOutReg |= 0x01;
! 
!    /* Disable video */
!    (void) inb(vgaIOBase + 0x0A); /* reset flip-flop */
!    outb(0x3C0, 0x00);
  
     /* Unlock ATI specials */
     outw(ATIExtReg, ((inATI(0xb8) & 0xC0) << 8) | 0xb8);
  
!    /* Load Miscellaneous Output External Register */
!    outb(0x3C2, save.MiscOutReg);
! 
!    outw(ATIExtReg, 0x00b2);	/* segment select 0 */
!    
!    if (save.FontInfo1 || save.TextInfo) {
!       inb(vgaIOBase + 0x0A);	/* reset flip-flop */
!       outb(0x3C0,0x10); outb(0x3C0, 0x01); /* graphics mode */
! 
!       if (save.FontInfo1) {
! 	 outw(0x3C4, 0x0402);	/* write to plane 2 */
! 	 outw(0x3C4, 0x0604);	/* enable plane graphics */
! 	 outw(0x3CE, 0x0204);	/* read plane 2 */
! 	 outw(0x3CE, 0x0005);	/* write mode 0, read mode 0 */
! 	 outw(0x3CE, 0x0506);	/* set graphics */
! 	 bcopy(save.FontInfo1, vgaBase, 8192);
!       }
!       if (save.TextInfo) {
! 	 outw(0x3C4, 0x0102);	/* write to plane 0 */
! 	 outw(0x3C4, 0x0604);	/* enable plane graphics */
! 	 outw(0x3CE, 0x0004);	/* read plane 0 */
! 	 outw(0x3CE, 0x0005);	/* write mode 0, read mode 0 */
! 	 outw(0x3CE, 0x0506);	/* set graphics */
! 	 bcopy(save.TextInfo, vgaBase, 4096);
! 	 outw(0x3C4, 0x0202);	/* write to plane 1 */
! 	 outw(0x3C4, 0x0604);	/* enable plane graphics */
! 	 outw(0x3CE, 0x0104);	/* read plane 1 */
! 	 outw(0x3CE, 0x0005);	/* write mode 0, read mode 0 */
! 	 outw(0x3CE, 0x0506);	/* set graphics */
! 	 bcopy(save.TextInfo + 4096, vgaBase, 4096);
!       }
!    }
!         
!    /* This sequence is from the "VGA Wonder Programmer's
!       Reference Manual."  I assume it is correct :-)
!       faith@cs.unc.edu (7Aug92) */
! 
!    /* Place Sequencer into Reset condition using its Reset Register */
!    outw(0x3C4, 0x0100);
! 
!    /* Load ATI Extended Registers */
!    outw(ATIExtReg, (save.ATIReg0  << 8) | 0xb0);
!    outw(ATIExtReg, (save.ATIReg1  << 8) | 0xb1);
!    outw(ATIExtReg, (save.ATIReg2  << 8) | 0xb2);
!    outw(ATIExtReg, (save.ATIReg5  << 8) | 0xb5);
!    outw(ATIExtReg, (save.ATIReg6  << 8) | 0xb6);
!    outw(ATIExtReg, (save.ATIRegE  << 8) | 0xbe);
!    outw(ATIExtReg, (save.ATIReg3  << 8) | 0xb3);
!    outw(ATIExtReg, (save.ATIReg8  << 8) | 0xb8);
!    outw(ATIExtReg, (save.ATIReg9  << 8) | 0xb9);
!    outw(ATIExtReg, (save.ATIRegA6 << 8) | 0xa6);
!    outw(ATIExtReg, (save.ATIRegA7 << 8) | 0xa7);
!    
!    /* Load Miscellaneous Output External Register */
!    outb(0x3C2, save.MiscOutReg);
!    
!    /* Load Sequence Registers 1 through 4 */
!    for (i=1; i<5;  i++)
! 	 outw(0x3C4, (save.Sequencer[i] << 8) | i);
! 
!    /* Restart Sequencer using Reset Register */
!    outw(0x3C4, 0x0300);
!    
!    /* Load all 25 CRT Control Registers */
!    /* But first, unlock CRTC registers 0 to 7 */
!    outw(vgaIOBase + 4, ((save.CRTC[0x11] & 0x7F) << 8) | 0x11);
!    for (i=0; i<25; i++)
! 	 outw(vgaIOBase + 4,(save.CRTC[i] << 8) | i);
! 
!    /* Reset Attribute Controller address/data flip-flop */
!    (void) inb(vgaIOBase + 0x0A);
! 
!    /* Load all 20 Attribute Controller Registers */
!    for (i=0; i<21; i++) {
!       (void) inb(vgaIOBase + 0x0A);
!       outb(0x3C0,i);
!       outb(0x3C0, save.Attribute[i]);
!    }
  
!    /* Load all 9 Graphics Controller Registers */
!    for (i=0; i<9; i++)
! 	 outw(0x3CE, (save.Graphics[i] << 8) | i);
! 
!    /* Load all 768 DAC Registers */
!    outb(0x3C8,0x00);
!    for (i=0; i<768; i++)
! 	 outb(0x3C9, save.DAC[i]);
! 
!    /* Reset Attribute Controller address/data flip-flop */
!    (void) inb(vgaIOBase + 0x0A);
! 
!    /* Turn Attribute Controller on */
!    outb(0x3C0, 0x20);
!         
  }
  
  /*
--- 110,183 ----
  			      64 * 1024);
     }
  
     vgaIOBase = (inb(0x3cc) & 0x01) ? 0x3D0 : 0x3B0;
     
!    /* This part is copied from ATISave() in
!     * x386/vga256/drivers/ati/driver.c
!     */
  
     /* Unlock ATI specials */
     outb(ATIExtReg, (((b8_save = inATI(0xb8)) & 0xC0) << 8) | 0xb8);
  
     b2_save = inATI(0xb2);
     outb(ATIExtReg, 0x00b2);	/* segment select 0 */
  
!    vgaNewVideoState = vgaHWSave(vgaNewVideoState, sizeof(SaveBlock));
  
!    save->ATIReg0  = inATI(0xb0);
!    save->ATIReg1  = inATI(0xb1);
!    save->ATIReg2  = b2_save;
!    save->ATIReg5  = inATI(0xb5);
!    save->ATIReg6  = inATI(0xb6);
!    save->ATIReg3  = inATI(0xb3);
!    save->ATIReg8  = b8_save;
!    save->ATIRegE  = inATI(0xbe);
!    save->ATIReg9  = inATI(0xb9);
!    save->ATIRegA6 = inATI(0xa6);
!    save->ATIRegA7 = inATI(0xa7);
!    
! #if 0
!   /*
!    * TvR: don't know whether this is neccesary for mach32
!    * Should be removed if it isn't needed. 
!    */
     /* Enable video */
     inb(vgaIOBase + 0x0A); /* reset flip-flop */
     outb( 0x3c0, 0x20 );
+ #endif
  }
  
  void mach32RestoreVGAInfo()
  {
     /* This routine is mostly from ATIRestore() in
!     * x386/vga256/drivers/ati/driver.c
!     */
  
     /* Unlock ATI specials */
     outw(ATIExtReg, ((inATI(0xb8) & 0xC0) << 8) | 0xb8);
  
!    /* Load ATI Extended registers */
!    outw(ATIExtReg, (save->ATIReg0 << 8) | 0xb0);
!    outw(ATIExtReg, (save->ATIReg1 << 8) | 0xb1);
!    outw(ATIExtReg, (save->ATIReg2 << 8) | 0xb2);
!    outw(ATIExtReg, (save->ATIReg3 << 8) | 0xb3);
!    outw(ATIExtReg, (save->ATIReg5 << 8) | 0xb5);
!    outw(ATIExtReg, (save->ATIReg6 << 8) | 0xb6);
!    outw(ATIExtReg, (save->ATIRegE << 8) | 0xbE);
!    outw(ATIExtReg, (save->ATIReg9 << 8) | 0xb9);
!    outw(ATIExtReg, (save->ATIRegA6 << 8) | 0xa6);
!    outw(ATIExtReg, (save->ATIRegA7 << 8) | 0xa7);
! 
!    /*
!     * Last but not least ATIReg8 -- according to vgadoc's this lock the 
!     * ATI special registers
!     */
!    outw(ATIExtReg, (save->ATIReg8 << 8) | 0xb8);
  
!    /*
!     * Restore the generic vga registers
!     */
!    vgaHWRestore(save);
  }
  
  /*
diff -c mit/server/ddx/x386/accel/mach32/mach32.c:2.25 mit/server/ddx/x386/accel/mach32/mach32.c:2.47
*** mit/server/ddx/x386/accel/mach32/mach32.c:2.25	Fri Mar 11 23:37:02 1994
--- mit/server/ddx/x386/accel/mach32/mach32.c	Fri Mar 11 23:37:02 1994
***************
*** 29,37 ****
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vga.c,v 1.2 1991/06/27 00:02:49 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32.c,v 2.25 1993/10/18 12:17:03 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
  #include "scrnintstr.h"
  #include "pixmapstr.h"
--- 29,38 ----
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vga.c,v 1.2 1991/06/27 00:02:49 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32.c,v 2.47 1994/03/03 12:43:18 dawes Exp $ */
  
  #include "X.h"
+ #include "Xmd.h"
  #include "input.h"
  #include "scrnintstr.h"
  #include "pixmapstr.h"
***************
*** 42,48 ****
--- 43,51 ----
  
  #include "x386.h"
  #include "x386Priv.h"
+ #include "x386Procs.h"
  #include "xf86_OSlib.h"
+ #include "xf86_HWlib.h"
  #include "mach32.h"
  #include "regmach32.h"
  #include "cfb.h"
***************
*** 51,61 ****
--- 54,68 ----
  #include "xf86_Config.h"
  
  extern int mach32MaxClock;
+ extern int mach32MaxTlc34075Clock;
  extern Bool x386Verbose, x386Resetting, x386Exiting, x386ProbeFailed;
  extern void NoopDDA();
  extern void mach32QueryBestSize();
  extern void mach32WarpCursor();
  extern void mach32RepositionCursor();
+ extern Bool miDCInitialize();
+ extern void SetTimeSinceLastInputEvent();
+ unsigned short mach32MemorySize = 0;
  
  ScrnInfoRec mach32InfoRec = {
      FALSE,		/* Bool configured */
***************
*** 83,88 ****
--- 90,96 ----
      0,			/* int maxClock */
      0,			/* int videoRam */
      0xC0000,            /* int BIOSbase */   
+     0,			/* unsigned long MemBase */
      240, 180,		/* int width, height */
      0,                  /* unsigned long  speedup */
      NULL,	       	/* DisplayModePtr modes */
***************
*** 123,130 ****
  short mach32MaxX, mach32MaxY;
  short mach32VirtX, mach32VirtY;
  
! Bool mach32Use4MbAperture;
  
  static unsigned Mach32_IOPorts[] = {
  	/* VGA Registers */
          0x3B4, 0x3B5, 0x3BA, 0x3C0, 0x3C1, 0x3C2, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 
--- 131,141 ----
  short mach32MaxX, mach32MaxY;
  short mach32VirtX, mach32VirtY;
  
! Bool mach32Use4MbAperture = FALSE;
! Bool mach32DAC8Bit = FALSE;
  
+ Bool mach32clkprobedif4fix = FALSE;
+ 
  static unsigned Mach32_IOPorts[] = {
  	/* VGA Registers */
          0x3B4, 0x3B5, 0x3BA, 0x3C0, 0x3C1, 0x3C2, 0x3C4, 0x3C5, 0x3C6, 0x3C7, 
***************
*** 146,151 ****
--- 157,165 ----
  	EXT_SCISSOR_L, EXT_SCISSOR_R, EXT_SCISSOR_T, EXT_SCISSOR_B,
  	MISC_OPTIONS, CONFIG_STATUS_1, CONFIG_STATUS_2, 
  	MEM_CFG, MEM_BNDRY, ROM_ADDR_1, READ_SRC_X, CHIP_ID, EXT_FIFO_STATUS,
+ 	R_EXT_GE_CONFIG, EXT_GE_CONFIG, DP_CONFIG, DEST_X_START, DEST_X_END,
+ 	DEST_Y_END, ALU_FG_FN, MISC_CNTL, R_MISC_CNTL, HORZ_OVERSCAN,
+ 	VERT_OVERSCAN, EXT_GE_STATUS, LINEDRAW, LINEDRAW_OPT, LINEDRAW_INDEX,
  };
  static int Num_Mach32_IOPorts = (sizeof(Mach32_IOPorts)/
  				 sizeof(Mach32_IOPorts[0]));
***************
*** 152,157 ****
--- 166,172 ----
  
  static mach32CRTCRegRec mach32CRTCRegs;
  static ScreenPtr savepScreen = NULL;
+ static PixmapPtr ppix = NULL;
  
  /*
   * ATI Hardware Probe
***************
*** 177,182 ****
--- 192,212 ----
     int  DAC_Type;
  } ATIInformationBlock;
  
+ int	mach32Ramdac;
+ char	*mach32ramdac_names[] = {
+ 	"ATI-68830",
+ 	"IMS-G173/SC1148[368]",
+ 	"ATI68875/TLC34075/Bt885",
+ 	"Bt47[68]/INMOS17[68]",
+ 	"AT&T20C49[01]/Bt48[12]/IMS-G174/MU9C{1880,4910}/SC1502[56]",
+ 	"ATI-68860",
+ 	"unknown",
+ 	"unknown",
+ };
+ 
+ 
+ int	mach32BusType;
+ 
  static ATIInformationBlock *GetATIInformationBlock()
  {
  #define BIOS_DATA_SIZE 0x70
***************
*** 221,232 ****
  
     tmp = inw( ROM_ADDR_1 );
     outw( ROM_ADDR_1, 0x5555 );
!    WaitIdleEmpty();
     if (inw( ROM_ADDR_1 ) != 0x5555) {
        info.ATI_Accelerator_Present = 0;
     } else {
        outw( ROM_ADDR_1, 0x2a2a );
!       WaitIdleEmpty();
        if (inw( ROM_ADDR_1 ) != 0x2a2a) {
  	 info.ATI_Accelerator_Present = 0;
        }
--- 251,262 ----
  
     tmp = inw( ROM_ADDR_1 );
     outw( ROM_ADDR_1, 0x5555 );
!    ProbeWaitIdleEmpty();
     if (inw( ROM_ADDR_1 ) != 0x5555) {
        info.ATI_Accelerator_Present = 0;
     } else {
        outw( ROM_ADDR_1, 0x2a2a );
!       ProbeWaitIdleEmpty();
        if (inw( ROM_ADDR_1 ) != 0x2a2a) {
  	 info.ATI_Accelerator_Present = 0;
        }
***************
*** 280,305 ****
        tmp = inw( CONFIG_STATUS_1 );
        info.Bus_Type = tmp & BUS_TYPE;
        info.Mem_Type = tmp & MEM_TYPE;
!       info.DAC_Type = tmp & DACTYPE;
  
        tmp = inw( CONFIG_STATUS_2 );
!       if ((info.Bus_Type == ISA_16_BIT
! 	   || info.Bus_Type == ISA_8_BIT)
! 	  && !(tmp & ISA_16_ENA))
  	    info.Bus_8bit_Only = 1;
  
        tmp = inw( MISC_OPTIONS );
!       switch ((tmp & MEM_SIZE_ALIAS) >> 2) {
!       case 0:
  	 info.Mem_Size = 512;
  	 break;
!       case 1:
  	 info.Mem_Size = 1024;
  	 break;
!       case 2:
  	 info.Mem_Size = 2*1024;
  	 break;
!       case 3:
  	 info.Mem_Size = 4*1024;
  	 break;
        }
--- 310,333 ----
        tmp = inw( CONFIG_STATUS_1 );
        info.Bus_Type = tmp & BUS_TYPE;
        info.Mem_Type = tmp & MEM_TYPE;
!       info.DAC_Type = (tmp & DACTYPE) >> 9;
  
        tmp = inw( CONFIG_STATUS_2 );
!       if ((info.Bus_Type == ISA_16_BIT) && !(tmp & ISA_16_ENA))
  	    info.Bus_8bit_Only = 1;
  
        tmp = inw( MISC_OPTIONS );
!       switch (tmp & MEM_SIZE_ALIAS) {
!       case MEM_SIZE_512K:
  	 info.Mem_Size = 512;
  	 break;
!       case MEM_SIZE_1M:
  	 info.Mem_Size = 1024;
  	 break;
!       case MEM_SIZE_2M:
  	 info.Mem_Size = 2*1024;
  	 break;
!       case MEM_SIZE_4M:
  	 info.Mem_Size = 4*1024;
  	 break;
        }
***************
*** 315,321 ****
  Bool
  mach32Probe()
  {
!     int                   i;
      DisplayModePtr        pMode, pEnd;
      ATIInformationBlock   *info;
      int                   extra_ram;
--- 343,349 ----
  Bool
  mach32Probe()
  {
!     int                   i, j;
      DisplayModePtr        pMode, pEnd;
      ATIInformationBlock   *info;
      int                   extra_ram;
***************
*** 322,329 ****
      int                   extra_caches;
      Bool                  sw_cursor_supplied;
      OFlagSet              validOptions;
  
-     mach32InfoRec.maxClock = mach32MaxClock;
  
      xf86ClearIOPortList(mach32InfoRec.scrnIndex);
      xf86AddIOPorts(mach32InfoRec.scrnIndex, Num_Mach32_IOPorts, Mach32_IOPorts);
--- 350,357 ----
      int                   extra_caches;
      Bool                  sw_cursor_supplied;
      OFlagSet              validOptions;
+     int                   tx, ty;
  
  
      xf86ClearIOPortList(mach32InfoRec.scrnIndex);
      xf86AddIOPorts(mach32InfoRec.scrnIndex, Num_Mach32_IOPorts, Mach32_IOPorts);
***************
*** 331,350 ****
      xf86EnableIOPorts(mach32InfoRec.scrnIndex);
  
      info = GetATIInformationBlock();
- 
      if (!info || !info->Mach32_Present) {
  	xf86DisableIOPorts(mach32InfoRec.scrnIndex);
  	return(FALSE);
      }
  
      OFLG_ZERO(&validOptions);
      OFLG_SET(OPTION_SW_CURSOR, &validOptions);
      OFLG_SET(OPTION_NOLINEAR_MODE, &validOptions);
      xf86VerifyOptions(&validOptions, &mach32InfoRec);
      
      mach32InfoRec.chipset = "mach32";
      x386ProbeFailed = FALSE;
  
      if (x386Verbose) {
  	ErrorF("%s ",OFLG_ISSET(XCONFIG_CLOCKS,&mach32InfoRec.xconfigFlag) ?
  			XCONFIG_GIVEN : XCONFIG_PROBED);
--- 359,461 ----
      xf86EnableIOPorts(mach32InfoRec.scrnIndex);
  
      info = GetATIInformationBlock();
      if (!info || !info->Mach32_Present) {
  	xf86DisableIOPorts(mach32InfoRec.scrnIndex);
  	return(FALSE);
      }
  
+     switch(info->DAC_Type) {
+     case DAC_TLC34075: 
+ 	mach32InfoRec.maxClock = mach32MaxTlc34075Clock;
+ 	break;
+     default:
+ 	mach32InfoRec.maxClock = mach32MaxClock;
+ 	break;
+     }
+ 
      OFLG_ZERO(&validOptions);
      OFLG_SET(OPTION_SW_CURSOR, &validOptions);
      OFLG_SET(OPTION_NOLINEAR_MODE, &validOptions);
+     OFLG_SET(OPTION_CSYNC, &validOptions);
+     OFLG_SET(OPTION_INTEL_GX, &validOptions);
+     OFLG_SET(OPTION_DAC_8_BIT, &validOptions);
      xf86VerifyOptions(&validOptions, &mach32InfoRec);
      
      mach32InfoRec.chipset = "mach32";
      x386ProbeFailed = FALSE;
  
+     mach32BusType = info->Bus_Type;
+     if (x386Verbose)
+     {
+ 	ErrorF("%s %s: card type: ", XCONFIG_PROBED, mach32InfoRec.name);
+ 	switch(mach32BusType)
+ 	{
+ 	case EISA:
+ 	    ErrorF("EISA\n");
+ 	    break;
+ 	case LOCAL_386SX:
+ 	    ErrorF("localbus (386SX)\n");
+ 	    break;
+ 	case LOCAL_386DX:
+ 	    ErrorF("localbus (386DX)\n");
+ 	    break;
+ 	case LOCAL_486:
+ 	    ErrorF("localbus (486)\n");
+ 	    break;
+ 	case PCI:
+ 	    ErrorF("PCI\n");
+ 	    break;
+ 	default:
+ 	    ErrorF("ISA\n");
+ 	}
+     }
+ 
+     if (!mach32InfoRec.clocks)
+     {
+         outb(DISP_CNTL, DISPEN_DISAB /*| INTERLACE*/ | MEMCFG_4 | ODDBNKENAB);
+         /* 13-jun-93 TCG : set up dummy video mode */
+         outw(SHADOW_SET, 1);
+         outw(SHADOW_CTL, 0);
+         outw(SHADOW_SET, 2);
+         outw(SHADOW_CTL, 0);
+         outw(SHADOW_SET, 0);
+         outw(ADVFUNC_CNTL, DISABPASSTHRU);
+ 
+         /* vt: 480 488 +31 528 hz: 640 656 +248 920 */
+         outw(V_TOTAL, 0x420);
+         outw(V_DISP, 0x3c0);
+         outw(V_SYNC_STRT, 0x3d0);
+         outw(V_SYNC_WID, 0x1f);
+         outb(H_TOTAL, 0x72);
+         outw(H_DISP, 0x4f);
+         outb(H_SYNC_STRT, 0x51);
+         outb(H_SYNC_WID, 0x1f);
+ 
+         outb(DAC_MASK, 0x00);
+         outb(DISP_CNTL, DISPEN_ENAB | MEMCFG_4 | ODDBNKENAB);
+ 
+         /* 2-oct-93 TCG : detect clocks with dif4 fix */
+         mach32clkprobedif4fix = TRUE;
+         xf86GetClocks(16, mach32ClockSelect, NoopDDA, NoopDDA,
+                       DISP_STAT, 2, 7, 44900, &mach32InfoRec);
+         outw(CLOCK_SEL, 0); /* reset pass-through */
+         mach32clkprobedif4fix = FALSE;
+ 
+         outw(SHADOW_SET, 1);
+         outw(SHADOW_CTL, 0x3f);
+         outw(SHADOW_SET, 2);
+         outw(SHADOW_CTL, 0x3f);
+         outw(SHADOW_SET, 0);
+ 
+         outb(DAC_MASK, 0xff);
+ 
+         for (j = 0; j < 16; j++)
+             mach32InfoRec.clock[j + 16] = mach32InfoRec.clock[j] / 2;
+ 
+         mach32InfoRec.clocks = 32;
+     }
+ 
+ 
      if (x386Verbose) {
  	ErrorF("%s ",OFLG_ISSET(XCONFIG_CLOCKS,&mach32InfoRec.xconfigFlag) ?
  			XCONFIG_GIVEN : XCONFIG_PROBED);
***************
*** 362,376 ****
  	ErrorF("\n");
      }
  
      pMode = pEnd = mach32InfoRec.modes;
      do {
  	x386LookupMode(pMode, &mach32InfoRec);
  	pMode = pMode->next;
      } while (pMode != pEnd);
  
!     mach32VirtX = (mach32InfoRec.virtualX+7) & 0xfff8;
      mach32VirtY = mach32InfoRec.virtualY;
  
      /*
       * Limitation of 8514 drawing commands  (taking into account 256 lines
       * required by the cache)
--- 473,494 ----
  	ErrorF("\n");
      }
  
+     tx = mach32InfoRec.virtualX;
+     ty = mach32InfoRec.virtualY;
      pMode = pEnd = mach32InfoRec.modes;
      do {
  	x386LookupMode(pMode, &mach32InfoRec);
+ 	mach32InfoRec.virtualX = max(mach32InfoRec.virtualX, pMode->HDisplay);
+ 	mach32InfoRec.virtualY = max(mach32InfoRec.virtualY, pMode->VDisplay);
  	pMode = pMode->next;
      } while (pMode != pEnd);
  
!     mach32VirtX = mach32InfoRec.virtualX = (mach32InfoRec.virtualX+7) & 0xfff8;
      mach32VirtY = mach32InfoRec.virtualY;
  
+     if ((tx != mach32InfoRec.virtualX) || (ty != mach32InfoRec.virtualY))
+ 	OFLG_CLR(XCONFIG_VIRTUAL,&mach32InfoRec.xconfigFlag);
+ 
      /*
       * Limitation of 8514 drawing commands  (taking into account 256 lines
       * required by the cache)
***************
*** 402,422 ****
  	return(FALSE);
      }
  
!     if (!mach32InfoRec.videoRam)
! 	  mach32InfoRec.videoRam = info->Mem_Size;
! 
!     /* XXXX we normally allow the Xconfig to completely override probed info */
!     if (mach32InfoRec.videoRam > info->Mem_Size) {
!        ErrorF( "Illegal value for videoRam (max is %d)\n", info->Mem_Size );
!        xf86DisableIOPorts(mach32InfoRec.scrnIndex);
!        return(FALSE);
!     }
! 
      if (x386Verbose) {
!        ErrorF("%s %s: %d kb memory available (using %d kb)\n",
  	      OFLG_ISSET(XCONFIG_VIDEORAM, &mach32InfoRec.xconfigFlag) ?
! 		XCONFIG_GIVEN : XCONFIG_PROBED, mach32InfoRec.name,
! 	       info->Mem_Size, mach32InfoRec.videoRam );
      }
  
      if (((mach32MaxX+1)*(mach32MaxY+1)) > (mach32InfoRec.videoRam*1024)) {
--- 520,548 ----
  	return(FALSE);
      }
  
!     if (!mach32InfoRec.videoRam) {
! #ifdef NEW_MEM_DETECT
! 	mach32InfoRec.videoRam = mach32GetMemSize();
! #else
! 	mach32InfoRec.videoRam = info->Mem_Size;
! #endif
!     }
! 
!     /* Set mach32MemorySize to required MEM_SIZE value in MISC_OPTIONS */
!     if (mach32InfoRec.videoRam <= 512)
! 	mach32MemorySize = MEM_SIZE_512K;
!     else if (mach32InfoRec.videoRam <= 1024)
! 	mach32MemorySize = MEM_SIZE_1M;
!     else if (mach32InfoRec.videoRam <= 2048)
! 	mach32MemorySize = MEM_SIZE_2M;
!     else
! 	mach32MemorySize = MEM_SIZE_4M;
! 	
      if (x386Verbose) {
!        ErrorF("%s %s: videoram: %dk\n",
  	      OFLG_ISSET(XCONFIG_VIDEORAM, &mach32InfoRec.xconfigFlag) ?
! 	      XCONFIG_GIVEN : XCONFIG_PROBED, mach32InfoRec.name,
! 	      mach32InfoRec.videoRam );
      }
  
      if (((mach32MaxX+1)*(mach32MaxY+1)) > (mach32InfoRec.videoRam*1024)) {
***************
*** 468,477 ****
  			   (info->Bus_Type == LOCAL_386SX ||
  			    info->Bus_Type == LOCAL_386DX ||
  			    info->Bus_Type == LOCAL_486 ||
! 			    info->Bus_Type == EISA)
  			   && xf86LinearVidMem();
  
!     if (x386Verbose)
  	if (mach32Use4MbAperture) {
  	    ErrorF("%s %s: Using 4 MB aperture\n", XCONFIG_PROBED,
  		   mach32InfoRec.name);
--- 594,606 ----
  			   (info->Bus_Type == LOCAL_386SX ||
  			    info->Bus_Type == LOCAL_386DX ||
  			    info->Bus_Type == LOCAL_486 ||
! 			    info->Bus_Type == EISA ||
!                             info->Bus_Type == PCI)
  			   && xf86LinearVidMem();
  
!     mach32Ramdac = info->DAC_Type;
! 
!     if (x386Verbose) {
  	if (mach32Use4MbAperture) {
  	    ErrorF("%s %s: Using 4 MB aperture\n", XCONFIG_PROBED,
  		   mach32InfoRec.name);
***************
*** 480,485 ****
--- 609,630 ----
  		   OFLG_ISSET(OPTION_NOLINEAR_MODE, &mach32InfoRec.options) ?
  		   XCONFIG_GIVEN : XCONFIG_PROBED, mach32InfoRec.name);
  	}
+ 	ErrorF("%s %s: Ramdac is %s\n", XCONFIG_PROBED, mach32InfoRec.name,
+ 	       mach32ramdac_names[mach32Ramdac]);
+     }
+ 
+     /* The Type 2 RAMDACS can support 8 bits per RGB value, not just the
+      * VGA-standard 6 bits; however, according to ATI, this is not an
+      * official feature of the mach32.
+      */
+     mach32DAC8Bit = OFLG_ISSET(OPTION_DAC_8_BIT, &mach32InfoRec.options)
+ 		    && (info->DAC_Type == DAC_TLC34075);
+ 
+     if (x386Verbose)
+ 	ErrorF("%s %s: Using %d bits per RGB value\n",
+ 		(info->DAC_Type == DAC_TLC34075) ? XCONFIG_GIVEN :
+ 		XCONFIG_PROBED, mach32InfoRec.name,
+ 		mach32DAC8Bit ?  8 : 6);
  
      return(TRUE);
  }
***************
*** 512,517 ****
--- 657,665 ----
      int            argc;         /* The number of the Server's arguments. */
      char           **argv;       /* The arguments themselves. Don't change! */
  {
+     int displayResolution = 75;  /* default to 75dpi */
+     extern int monitorResolution;
+ 
      mach32InitDisplay(scr_index);
      mach32InitAperture(scr_index);
      mach32CalcCRTCRegs(&mach32CRTCRegs, mach32InfoRec.modes);
***************
*** 536,544 ****
  
      WaitIdleEmpty(); /* Make sure that all commands have finished */
  
      if (!mach32ScreenInit(pScreen, mach32VideoMem,
  			  mach32VirtX, mach32VirtY,
! 			  75, 75,
  			  mach32VirtX))
  
  		return(FALSE);
--- 684,699 ----
  
      WaitIdleEmpty(); /* Make sure that all commands have finished */
  
+     /*
+      * Take display resolution from the -dpi flag if specified
+      */
+ 
+     if (monitorResolution)
+ 	displayResolution = monitorResolution;
+ 
      if (!mach32ScreenInit(pScreen, mach32VideoMem,
  			  mach32VirtX, mach32VirtY,
! 			  displayResolution, displayResolution,
  			  mach32VirtX))
  
  		return(FALSE);
***************
*** 574,580 ****
       int screen_idx;
  {
      PixmapPtr pspix;
-     static PixmapPtr ppix = NULL;
      ScreenPtr pScreen = savepScreen;
  
      pspix = (PixmapPtr)pScreen->devPrivate;
--- 729,734 ----
***************
*** 640,646 ****
  				ppix->devPrivate.ptr,
  				PixmapBytePad(pScreen->width,
  					      pScreen->rootDepth),
! 				0, 0);
  		pspix->devPrivate.ptr = ppix->devPrivate.ptr;
  	    }
  	}
--- 794,800 ----
  				ppix->devPrivate.ptr,
  				PixmapBytePad(pScreen->width,
  					      pScreen->rootDepth),
! 				0, 0, ~0);
  		pspix->devPrivate.ptr = ppix->devPrivate.ptr;
  	    }
  	}
***************
*** 667,672 ****
--- 821,828 ----
  mach32CloseScreen(screen_idx)
       int screen_idx;
  {
+     extern void mach32ClearSavedCursor();
+ 
      /*
       * Hmm... The server may shut down even if it is not running on the
       * current vt. Let's catch this case here.
***************
*** 674,680 ****
      x386Exiting = TRUE;
      if (x386VTSema)
  	mach32EnterLeaveVT(LEAVE, screen_idx);
! 
      return(TRUE);
  }
  
--- 830,844 ----
      x386Exiting = TRUE;
      if (x386VTSema)
  	mach32EnterLeaveVT(LEAVE, screen_idx);
!     else if (ppix) {
!     /* 7-Jan-94 CEG: The server is not running on the current vt.
!      * Free the screen snapshot taken when the server vt was left.
!      */
! 	    (savepScreen->DestroyPixmap)(ppix);
! 	    ppix = NULL;
!     }
!     mach32ClearSavedCursor(screen_idx);
!     savepScreen = NULL;
      return(TRUE);
  }
  
***************
*** 688,700 ****
       ScreenPtr     pScreen;
       Bool          on;
  {
      if (on)
  	SetTimeSinceLastInputEvent();
      if (x386VTSema) {
  	if (on) {
  	    mach32RestoreColor0(pScreen);
  
! 	    outw(DAC_MASK, 0xff);
  	} else {
  	    outb(DAC_W_INDEX, 0);
  	    outb(DAC_DATA, 0);
--- 852,873 ----
       ScreenPtr     pScreen;
       Bool          on;
  {
+      int	   ext_ge_config;
+ 
      if (on)
  	SetTimeSinceLastInputEvent();
+ 
      if (x386VTSema) {
+ 	/*
+ 	 *	Make sure that register 0-3 are addressed
+ 	 */
+ 	ext_ge_config = inw(R_EXT_GE_CONFIG) & ~0x3000;
+ 	outw(EXT_GE_CONFIG, ext_ge_config);
+ 
  	if (on) {
  	    mach32RestoreColor0(pScreen);
  
! 	    outb(DAC_MASK, 0xff);
  	} else {
  	    outb(DAC_W_INDEX, 0);
  	    outb(DAC_DATA, 0);
***************
*** 701,707 ****
  	    outb(DAC_DATA, 0);
  	    outb(DAC_DATA, 0);
  
! 	    outw(DAC_MASK, 0x00);
  	}
      }
  
--- 874,880 ----
  	    outb(DAC_DATA, 0);
  	    outb(DAC_DATA, 0);
  
! 	    outb(DAC_MASK, 0x00);
  	}
      }
  
***************
*** 736,739 ****
--- 909,934 ----
      mach32SetCRTCRegs(&mach32CRTCRegs);
  
      return(TRUE);
+ }
+ 
+ /*
+  * mach32ClockSelect
+  */
+ Bool
+ mach32ClockSelect(no)
+      int no;
+ {
+   switch(no)
+   {
+     case CLK_REG_SAVE:
+       break;
+     case CLK_REG_RESTORE:
+       break;
+     default:
+       if (mach32clkprobedif4fix)
+          outw(CLOCK_SEL, (no << 2) | 0xac1);
+       else
+          outw(CLOCK_SEL, (no << 2) | 0xa01);
+   }
+   return(TRUE);
  }
diff -c mit/server/ddx/x386/accel/mach32/mach32.h:2.4 mit/server/ddx/x386/accel/mach32/mach32.h:2.13
*** mit/server/ddx/x386/accel/mach32/mach32.h:2.4	Fri Mar 11 23:37:04 1994
--- mit/server/ddx/x386/accel/mach32/mach32.h	Fri Mar 11 23:37:04 1994
***************
*** 23,29 ****
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32.h,v 2.4 1993/10/08 15:57:23 dawes Exp $ */
  
  #ifndef MACH32_H
  #define MACH32_H
--- 23,29 ----
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32.h,v 2.13 1994/03/01 09:51:30 dawes Exp $ */
  
  #ifndef MACH32_H
  #define MACH32_H
***************
*** 33,38 ****
--- 33,40 ----
  #define MACH32_CURSBYTES	1024
  #define MACH32_CURSMAX		64
  
+ #define NEW_MEM_DETECT
+ 
  #include "X.h"
  #include "misc.h"
  #include "x386.h"
***************
*** 45,55 ****
--- 47,70 ----
  extern void mach32AdjustFrame();
  extern Bool mach32SwitchMode();
  extern void mach32PrintIdent();
+ extern Bool mach32ClockSelect();
+ 
+ extern void mach32Dline();
+ extern void mach32Dsegment();
  
  extern Bool mach32SaveScreen();
  extern Bool mach32CloseScreen();
  
  extern Bool mach32ScreenInit();
+ extern void mach32InitDisplay();
+ extern void mach32InitAperture();
+ extern void mach32InitEnvironment();
+ extern void mach32CalcCRTCRegs();
+ extern void mach32SetCRTCRegs();
+ extern void mach32SaveLUT();
+ extern void mach32RestoreLUT();
+ extern void mach32CleanUp();
+ extern void mach32SetRamdac();
  
  extern int mach32ListInstalledColormaps();
  extern int mach32GetInstalledColormaps();
***************
*** 84,95 ****
  
  extern int mach32CacheFont8();
  extern void mach32UnCacheFont8();
- extern int mach32IsCached();
  extern int mach32CPolyText8();
  extern void mach32CImageText8();
  
  extern void mach32PolyPoint();
  extern void mach32Line();
  extern void mach32Segment();
  
  extern void mach32SetSpans();
--- 99,110 ----
  
  extern int mach32CacheFont8();
  extern void mach32UnCacheFont8();
  extern int mach32CPolyText8();
  extern void mach32CImageText8();
  
  extern void mach32PolyPoint();
  extern void mach32Line();
+ extern void mach32Line1Rect();
  extern void mach32Segment();
  
  extern void mach32SetSpans();
***************
*** 111,116 ****
--- 126,132 ----
  extern RegionPtr mach32CopyArea();
  extern RegionPtr mach32CopyPlane();
  extern void mach32CopyWindow();
+ extern void mach32GetImage();
  
  extern void mach32PaintWindow();
  extern void mach32FillBoxSolid();
***************
*** 120,125 ****
--- 136,148 ----
  
  extern Bool mach32CreateGC();
  
+ extern Bool mach32CursorInit();
+ extern void mach32RestoreCursor();
+ extern void mach32CursorOff();
+ extern void mach32RenewCursorColor();
+ 
+ extern int mach32GetMemSize();
+ 
  extern pointer mach32VideoMem;
  extern pointer vgaBase;
  extern Bool x386VTSema;
***************
*** 126,131 ****
--- 149,158 ----
  extern short mach32MaxX, mach32MaxY;
  extern short mach32VirtX, mach32VirtY;
  extern Bool mach32Use4MbAperture;
+ extern Bool mach32DAC8Bit;
+ 
+ extern int mach32Ramdac;
+ extern int mach32BusType;
  
  /* == 0 --> no boundary crossing on this line */
  /*  > 0 --> x value of first pixel in video aperture */
diff -c mit/server/ddx/x386/accel/mach32/mach32blt.c:2.3 mit/server/ddx/x386/accel/mach32/mach32blt.c:2.7
*** mit/server/ddx/x386/accel/mach32/mach32blt.c:2.3	Fri Mar 11 23:37:05 1994
--- mit/server/ddx/x386/accel/mach32/mach32blt.c	Fri Mar 11 23:37:05 1994
***************
*** 29,35 ****
  
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32blt.c,v 2.3 1993/09/23 15:44:05 dawes Exp $ */
  
  /* $XConsortium: cfbbitblt.c,v 5.39 91/05/24 16:33:25 keith Exp $ */
  
--- 29,35 ----
  
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32blt.c,v 2.7 1994/02/25 14:58:17 dawes Exp $ */
  
  /* $XConsortium: cfbbitblt.c,v 5.39 91/05/24 16:33:25 keith Exp $ */
  
***************
*** 50,58 ****
  #include	"mach32.h"
  
  void mach32FindOrdering();
  
- static unsigned long bitBltPlane = 0;
- 
  RegionPtr
  mach32CopyArea(pSrcDrawable, pDstDrawable,
  		pGC, srcx, srcy, width, height, dstx, dsty)
--- 50,57 ----
  #include	"mach32.h"
  
  void mach32FindOrdering();
+ extern RegionPtr cfbBitBlt();
  
  RegionPtr
  mach32CopyArea(pSrcDrawable, pDstDrawable,
  		pGC, srcx, srcy, width, height, dstx, dsty)
***************
*** 345,353 ****
  	    if (dy > 0) direction |= INC_Y;
  
  	    WaitQueue(3);
! 	    outw(FRGD_MIX, FSS_BITBLT | MIX_SRC);
  	    outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
! 	    outw(WRT_MASK, 0xffff);
  
  	    if (direction == (INC_X | INC_Y)) {
  		for (i = 0; i < numRects; i++) {
--- 344,352 ----
  	    if (dy > 0) direction |= INC_Y;
  
  	    WaitQueue(3);
! 	    outw(FRGD_MIX, FSS_BITBLT | mach32alu[pGC->alu]);
  	    outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
! 	    outw(WRT_MASK, pGC->planemask);
  
  	    if (direction == (INC_X | INC_Y)) {
  		for (i = 0; i < numRects; i++) {
***************
*** 414,420 ****
  	    for (i = numRects; --i >= 0; pbox++)
  		(mach32ImageReadFunc)(pbox->x1 + dx, pbox->y1 + dy,
  				 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				 pdst, pixWidth, pbox->x1, pbox->y1);
  	} else if (pSrcDrawable->type != DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
  	    /* Pixmap --> Window */
  	    int pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
--- 413,420 ----
  	    for (i = numRects; --i >= 0; pbox++)
  		(mach32ImageReadFunc)(pbox->x1 + dx, pbox->y1 + dy,
  				 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				 pdst, pixWidth, pbox->x1, pbox->y1,
! 				 pGC->planemask);
  	} else if (pSrcDrawable->type != DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
  	    /* Pixmap --> Window */
  	    int pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
***************
*** 581,588 ****
  	(void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
  			  width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
  	 pSrcDrawable = (DrawablePtr)pBitmap;
!     }
!     else if (((pSrcDrawable->type == DRAWABLE_WINDOW) && 
                (pDstDrawable->type != DRAWABLE_WINDOW)) ||
               ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
                (pDstDrawable->type == DRAWABLE_WINDOW) &&
--- 581,613 ----
  	(void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
  			  width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
  	 pSrcDrawable = (DrawablePtr)pBitmap;
!     } else if ((pSrcDrawable->type == DRAWABLE_WINDOW) &&
!  	       (pDstDrawable->type != DRAWABLE_WINDOW)) {
! 	/*
!  	 * Shortcut - we can do Window->Pixmap by copying the window to
!  	 * a pixmap, then we have a Pixmap->Pixmap operation
!  	 */
!  	GCPtr pGC1;
!  	RegionPtr retval;
!  	PixmapPtr pPixmap;
! 
!  	pPixmap=(*pSrcDrawable->pScreen->CreatePixmap)(pSrcDrawable->pScreen, 
!  						       width, height, 8);
!  	if (!pPixmap)
!  	    return(NULL);
!  	pGC1 = GetScratchGC(8, pSrcDrawable->pScreen);
!  	if (!pGC1) {
!  	    (*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
!  	    return(NULL);
!  	}
!  	ValidateGC((DrawablePtr)pPixmap, pGC1);
!  	mach32CopyArea(pSrcDrawable, pPixmap, pGC1, srcx, srcy, width, height,
!  		       0, 0);
!  	retval = cfbCopyPlane((DrawablePtr)pPixmap, pDstDrawable, pGC,
!                               0, 0, width, height, dstx, dsty, bitPlane);
!  	(*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
!  	return(retval);
!     } else if (((pSrcDrawable->type == DRAWABLE_WINDOW) && 
                (pDstDrawable->type != DRAWABLE_WINDOW)) ||
               ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
                (pDstDrawable->type == DRAWABLE_WINDOW) &&
diff -c mit/server/ddx/x386/accel/mach32/mach32bstor.c:2.2 mit/server/ddx/x386/accel/mach32/mach32bstor.c:2.3
*** mit/server/ddx/x386/accel/mach32/mach32bstor.c:2.2	Fri Mar 11 23:37:06 1994
--- mit/server/ddx/x386/accel/mach32/mach32bstor.c	Fri Mar 11 23:37:06 1994
***************
*** 27,33 ****
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32bstor.c,v 2.2 1993/09/23 15:44:06 dawes Exp $ */
  
  #include    "cfb.h"
  #include    "X.h"
--- 27,33 ----
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32bstor.c,v 2.3 1994/02/12 11:05:31 dawes Exp $ */
  
  #include    "cfb.h"
  #include    "X.h"
***************
*** 64,70 ****
  	(mach32ImageReadFunc)(pBox->x1 + xorg, pBox->y1 + yorg,
  			 pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
  			 pPixmap->devPrivate.ptr, pixWidth,
! 			 pBox->x1, pBox->y1);
  	pBox++;
      }
  
--- 64,70 ----
  	(mach32ImageReadFunc)(pBox->x1 + xorg, pBox->y1 + yorg,
  			 pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
  			 pPixmap->devPrivate.ptr, pixWidth,
! 			 pBox->x1, pBox->y1, ~0);
  	pBox++;
      }
  
diff -c mit/server/ddx/x386/accel/mach32/mach32cmap.c:2.3 mit/server/ddx/x386/accel/mach32/mach32cmap.c:2.5
*** mit/server/ddx/x386/accel/mach32/mach32cmap.c:2.3	Fri Mar 11 23:37:07 1994
--- mit/server/ddx/x386/accel/mach32/mach32cmap.c	Fri Mar 11 23:37:07 1994
***************
*** 30,36 ****
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vgaCmap.c,v 1.2 1991/06/27 00:03:01 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32cmap.c,v 2.3 1993/10/12 15:30:08 dawes Exp $ */
  
  #include "X.h"
  #include "Xproto.h"
--- 30,36 ----
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vgaCmap.c,v 1.2 1991/06/27 00:03:01 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32cmap.c,v 2.5 1994/01/09 03:30:15 dawes Exp $ */
  
  #include "X.h"
  #include "Xproto.h"
***************
*** 88,101 ****
      }
  
      for (i = 0; i < ndef; i++) {
! 	mach32savedLUT[pdefs[i].pixel].r = pdefs[i].red >> 10;
! 	mach32savedLUT[pdefs[i].pixel].g = pdefs[i].green >> 10;
! 	mach32savedLUT[pdefs[i].pixel].b = pdefs[i].blue >> 10;
  	if (x386VTSema) {
  	    outb(DAC_W_INDEX, pdefs[i].pixel);
! 	    outb(DAC_DATA, pdefs[i].red >> 10);
! 	    outb(DAC_DATA, pdefs[i].green >> 10);
! 	    outb(DAC_DATA, pdefs[i].blue >> 10);
  	}
      }
  }
--- 88,116 ----
      }
  
      for (i = 0; i < ndef; i++) {
! 	/* Return the n most significant bits from a 16-bit value.
! 	 * For VGA, n = 6.  For 8-bit DACs, n = 8.
! 	 */
! 	if (mach32DAC8Bit) {
! 	    mach32savedLUT[pdefs[i].pixel].r = pdefs[i].red >> 8;
! 	    mach32savedLUT[pdefs[i].pixel].g = pdefs[i].green >> 8;
! 	    mach32savedLUT[pdefs[i].pixel].b = pdefs[i].blue >> 8;
! 	} else {
! 	    mach32savedLUT[pdefs[i].pixel].r = pdefs[i].red >> 10;
! 	    mach32savedLUT[pdefs[i].pixel].g = pdefs[i].green >> 10;
! 	    mach32savedLUT[pdefs[i].pixel].b = pdefs[i].blue >> 10;
! 	}
  	if (x386VTSema) {
  	    outb(DAC_W_INDEX, pdefs[i].pixel);
! 	    if (mach32DAC8Bit) {
! 		outb(DAC_DATA, pdefs[i].red >> 8);
! 		outb(DAC_DATA, pdefs[i].green >> 8);
! 		outb(DAC_DATA, pdefs[i].blue >> 8);
! 	    } else {
! 		outb(DAC_DATA, pdefs[i].red >> 10);
! 		outb(DAC_DATA, pdefs[i].green >> 10);
! 		outb(DAC_DATA, pdefs[i].blue >> 10);
! 	    }
  	}
      }
  }
***************
*** 188,194 ****
    QueryColors(InstalledMaps[pScreen->myNum], 1, &pix, &rgb);
  
    outb(DAC_W_INDEX, 0);
!   outb(DAC_DATA, rgb.red >> 10);
!   outb(DAC_DATA, rgb.green >> 10);
!   outb(DAC_DATA, rgb.blue >> 10);
  }
--- 203,215 ----
    QueryColors(InstalledMaps[pScreen->myNum], 1, &pix, &rgb);
  
    outb(DAC_W_INDEX, 0);
!   if (mach32DAC8Bit) {
!     outb(DAC_DATA, rgb.red >> 8);
!     outb(DAC_DATA, rgb.green >> 8);
!     outb(DAC_DATA, rgb.blue >> 8);
!   } else {
!     outb(DAC_DATA, rgb.red >> 10);
!     outb(DAC_DATA, rgb.green >> 10);
!     outb(DAC_DATA, rgb.blue >> 10);
!   }
  }
diff -c mit/server/ddx/x386/accel/mach32/mach32curs.c:2.4 mit/server/ddx/x386/accel/mach32/mach32curs.c:2.11
*** mit/server/ddx/x386/accel/mach32/mach32curs.c:2.4	Fri Mar 11 23:37:07 1994
--- mit/server/ddx/x386/accel/mach32/mach32curs.c	Fri Mar 11 23:37:07 1994
***************
*** 29,35 ****
   */
  /* Header: /home/src/xfree86/server/ddx/x386/accel/s3/RCS/s3Cursor.c,v 2.4 1993/07/06 10:23:47 jon Exp jon */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32curs.c,v 2.4 1993/10/17 14:40:32 dawes Exp $ */
  
  #include <signal.h>
  
--- 29,35 ----
   */
  /* Header: /home/src/xfree86/server/ddx/x386/accel/s3/RCS/s3Cursor.c,v 2.4 1993/07/06 10:23:47 jon Exp jon */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32curs.c,v 2.11 1994/02/20 01:54:44 dawes Exp $ */
  
  #include <signal.h>
  
***************
*** 44,54 ****
--- 44,56 ----
  #include <servermd.h>
  #include <windowstr.h>
  #include <mipointer.h>
+ #include "mfb.h"
  #include "x386.h"
  #include "inputstr.h"
  #include "x386Priv.h"
  #include "xf86_Option.h"
  #include "xf86_OSlib.h"
+ #include "xf86_HWlib.h"
  #include "mach32.h"
  #include "regmach32.h"
  
***************
*** 68,74 ****
  static void mach32MoveCursor();
  static void mach32RecolorCursor();
  
! 
  extern miPointerScreenFuncRec x386PointerScreenFuncs;
  
  static int xhot, yhot;
--- 70,76 ----
  static void mach32MoveCursor();
  static void mach32RecolorCursor();
  
! extern void mach32SetVGAPage();
  extern miPointerScreenFuncRec x386PointerScreenFuncs;
  
  static int xhot, yhot;
***************
*** 188,201 ****
  {
    register int    i;
    register int	  j;
!   unsigned short  *pServMsk;
!   unsigned short  *pServSrc;
    int             index = pScr->myNum;
    Mach32CursPriv  *cursPriv;
    pointer         *pPriv = &pCurs->bits->devPriv[index];
    int             w;
    int             h;
-   int             lastLine;
    unsigned short  *ram;
    CursorBitsPtr   bits = pCurs->bits;
  
--- 190,202 ----
  {
    register int    i;
    register int	  j;
!   unsigned char   *pServMsk;
!   unsigned char   *pServSrc;
    int             index = pScr->myNum;
    Mach32CursPriv  *cursPriv;
    pointer         *pPriv = &pCurs->bits->devPriv[index];
    int             w;
    int             h;
    unsigned short  *ram;
    CursorBitsPtr   bits = pCurs->bits;
  
***************
*** 208,242 ****
       return (FALSE);
    ram = cursPriv->data;
  
!   pServSrc = (unsigned short *)bits->source;
!   pServMsk = (unsigned short *)bits->mask;
  
-   lastLine = -1;
    h = bits->height;
    if (h > MACH32_CURSMAX)
        h = MACH32_CURSMAX;
  
!   w = PixmapBytePad(bits->width, 1)/2;
!   if(w > MACH32_CURSMAX / 16)
!       w = MACH32_CURSMAX / 16;
  
    for(i = 0; i < h; i++) {
!       for(j = 0; j < w; j++) {
! 	  ram[0] = cursor_mask[*pServMsk & 0xff] |
! 	      cursor_lookup[*pServSrc & 0xff];
! 	  ram[1] = cursor_mask[*pServMsk++ >> 8] |
! 	      cursor_lookup[*pServSrc++ >> 8];
! 	  if(ram[0] != 0xaaaa || ram[1] != 0xaaaa)
! 	      lastLine = i;
! 	  ram += 2;
!       }
!       for(; j < MACH32_CURSMAX / 16; j++) {
! 	  *ram++ = 0xaaaa;
  	  *ram++ = 0xaaaa;
-       }
    }
    memset(ram, 0xaa, (MACH32_CURSMAX-h)*16);
!   cursPriv->yExtra = MACH32_CURSMAX - i - 1;
    return(TRUE);
  }
  
--- 209,235 ----
       return (FALSE);
    ram = cursPriv->data;
  
!   pServSrc = (unsigned char *)bits->source;
!   pServMsk = (unsigned char *)bits->mask;
  
    h = bits->height;
    if (h > MACH32_CURSMAX)
        h = MACH32_CURSMAX;
  
!   w = PixmapBytePad(bits->width, 1) + 1;
!   if(w > MACH32_CURSMAX / 8)
!       w = MACH32_CURSMAX / 8;
  
    for(i = 0; i < h; i++) {
!       *ram++ = 0xaaaa;
!       for(j = 1; j < w; j++)
! 	  *ram++ = cursor_mask[*pServMsk++] | cursor_lookup[*pServSrc++];
!       for(; j < MACH32_CURSMAX / 8; j++)
  	  *ram++ = 0xaaaa;
    }
    memset(ram, 0xaa, (MACH32_CURSMAX-h)*16);
! 
!   cursPriv->yExtra = MACH32_CURSMAX - h - 1;
    return(TRUE);
  }
  
***************
*** 272,278 ****
  
    cursPriv = (Mach32CursPriv *)pCurs->bits->devPriv[index];
    if(!mach32Use4MbAperture)
!       SetVGAPage(mach32CursorOffset >> 16);
    MemToBus(mach32CursorMemory, cursPriv->data, MACH32_CURSBYTES);
    mach32CursYExtra = cursPriv->yExtra;
  
--- 265,271 ----
  
    cursPriv = (Mach32CursPriv *)pCurs->bits->devPriv[index];
    if(!mach32Use4MbAperture)
!       mach32SetVGAPage(mach32CursorOffset >> 16);
    MemToBus(mach32CursorMemory, cursPriv->data, MACH32_CURSBYTES);
    mach32CursYExtra = cursPriv->yExtra;
  
***************
*** 279,294 ****
    mach32MoveCursor(0, x, y);
    mach32RecolorCursor(pScr, pCurs);
  
    outw(CURSOR_OFFSET_LO, mach32CursorOffset >> 2);
    outw(CURSOR_OFFSET_HI, 0x8000 | (mach32CursorOffset >> 18));
  }
  
  void
! mach32SetCursor(pScr, pCurs, x, y, generateEvent)
       ScreenPtr pScr;
       CursorPtr pCurs;
       int       x, y;
-      Bool      generateEvent;
  {
    int  index = pScr->myNum;
  
--- 272,288 ----
    mach32MoveCursor(0, x, y);
    mach32RecolorCursor(pScr, pCurs);
  
+ #if 0
    outw(CURSOR_OFFSET_LO, mach32CursorOffset >> 2);
    outw(CURSOR_OFFSET_HI, 0x8000 | (mach32CursorOffset >> 18));
+ #endif
  }
  
  void
! mach32SetCursor(pScr, pCurs, x, y)
       ScreenPtr pScr;
       CursorPtr pCurs;
       int       x, y;
  {
    int  index = pScr->myNum;
  
***************
*** 295,301 ****
    if(!pCurs)
  	return;
  
!   xhot = pCurs->bits->xhot;
    yhot = pCurs->bits->yhot;
    mach32SaveCursors[index] = pCurs;
    
--- 289,295 ----
    if(!pCurs)
  	return;
  
!   xhot = pCurs->bits->xhot + 8;
    yhot = pCurs->bits->yhot;
    mach32SaveCursors[index] = pCurs;
    
***************
*** 334,349 ****
      int xoff;
      int yoff;
      int enabled;
      
      x -= xhot + mach32InfoRec.frameX0;
      y -= yhot + mach32InfoRec.frameY0;
      
!     if (x < 0) {
! 	xoff = -x;
! 	x = 0;
!     } else {
! 	xoff = 0;
!     }
      
      if (y < 0) {
  	yoff = -y;
--- 328,342 ----
      int xoff;
      int yoff;
      int enabled;
+ 
+     if (!x386VTSema)
+ 	return;
      
      x -= xhot + mach32InfoRec.frameX0;
      y -= yhot + mach32InfoRec.frameY0;
      
!     xoff = (x < 0) ? -x : (x & 1);
!     x += xoff;
      
      if (y < 0) {
  	yoff = -y;
***************
*** 368,374 ****
  	
  	outb(HORZ_CURSOR_OFFSET, xoff);
  	outb(VERT_CURSOR_OFFSET, mach32CursYExtra + yoff);
- 
  	outw(CURSOR_OFFSET_LO, (mach32CursorOffset + yoff * 16) >> 2);
  	if (!mach32CursLastEnabled)
  	    outw(CURSOR_OFFSET_HI, 0x8000 | (mach32CursorOffset >> 18));
--- 361,366 ----
***************
*** 383,388 ****
--- 375,383 ----
  mach32RenewCursorColor(pScr)
       ScreenPtr pScr;
  {
+     if (!x386VTSema)
+ 	return;
+ 
      if (mach32SaveCursors[pScr->myNum])
  	mach32RecolorCursor(pScr, mach32SaveCursors[pScr->myNum], TRUE);
  }
***************
*** 393,399 ****
       CursorPtr pCurs;
       Bool      displayed;
  {
-   unsigned char color_0, color_1;
    ColormapPtr	pmap;
    xColorItem	sourceColor;
    xColorItem	maskColor;
--- 388,393 ----
***************
*** 457,459 ****
--- 451,459 ----
    mach32CursLastEnabled = 0;
  }
  
+ void
+ mach32ClearSavedCursor(scr_index)
+ 	int scr_index;
+ {
+ 	mach32SaveCursors[scr_index] = NULL;
+ }
diff -c /dev/null mit/server/ddx/x386/accel/mach32/mach32dline.c:2.3
*** /dev/null	Fri Mar 11 23:37:08 1994
--- mit/server/ddx/x386/accel/mach32/mach32dline.c	Fri Mar 11 23:37:08 1994
***************
*** 0 ****
--- 1,614 ----
+ /***********************************************************
+ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+ and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+ 
+                         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 names of Digital or MIT not be
+ used in advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+ 
+ DIGITAL AND KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ IN NO EVENT SHALL DIGITAL OR KEVIN E. MARTIN 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.
+ 
+ Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+ Modified for the mach32 by Mike Bernson    (mike@mbsun.mlb.org)
+ 
+ ******************************************************************/
+ /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
+ 
+ /* s3dline.c from s3line.c with help from cfbresd.c and cfbline.c - Jon */
+ /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32dline.c,v 2.3 1994/02/28 14:10:32 dawes Exp $ */
+ 
+ #include "X.h"
+ 
+ #include "gcstruct.h"
+ #include "windowstr.h"
+ #include "pixmapstr.h"
+ #include "regionstr.h"
+ #include "scrnintstr.h"
+ #include "mistruct.h"
+ 
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "misc.h"
+ #include "x386.h"
+ #include "mach32.h"
+ #include "regmach32.h"
+ 
+ /*
+  * single-pixel lines on a color frame buffer
+  * 
+  * NON-SLOPED LINES horizontal lines are always drawn left to right; we have to
+  * move the endpoints right by one after they're swapped. horizontal lines
+  * will be confined to a single band of a region.  the code finds that band
+  * (giving up if the lower bound of the band is above the line we're
+  * drawing); then it finds the first box in that band that contains part of
+  * the line.  we clip the line to subsequent boxes in that band. vertical
+  * lines are always drawn top to bottom (y-increasing.) this requires adding
+  * one to the y-coordinate of each endpoint after swapping.
+  * 
+  * SLOPED LINES when clipping a sloped line, we bring the second point inside
+  * the clipping box, rather than one beyond it, and then add 1 to the length
+  * of the line before drawing it.  this lets us use the same box for finding
+  * the outcodes for both endpoints.  since the equation for clipping the
+  * second endpoint to an edge gives us 1 beyond the edge, we then have to
+  * move the point towards the first point by one step on the major axis.
+  * eventually, there will be a diagram here to explain what's going on.  the
+  * method uses Cohen-Sutherland outcodes to determine outsideness, and a
+  * method similar to Pike's layers for doing the actual clipping.
+  * 
+  */
+ 
+ #define OUTCODES(result, x, y, pbox) \
+     if (x < pbox->x1) \
+ 	result |= OUT_LEFT; \
+     else if (x >= pbox->x2) \
+ 	result |= OUT_RIGHT; \
+     if (y < pbox->y1) \
+ 	result |= OUT_ABOVE; \
+     else if (y >= pbox->y2) \
+ 	result |= OUT_BELOW;
+ 
+ #define NextDash {\
+     dashIndexTmp++; \
+     if (dashIndexTmp == numInDashList) \
+         dashIndexTmp = 0; \
+     dashRemaining = pDash[dashIndexTmp]; \
+     thisDash = dashRemaining; \
+     }
+ 
+ #define FillDashPat {\
+    int i; \
+ \
+    for (i = 0; i < 16; i++) {\
+       dashPat <<= 1;\
+       if (tmp + i < len) {\
+ 	 if (!(dashIndexTmp & 1))\
+ 	    dashPat |= 1;\
+ 	 if (--thisDash == 0)\
+ 	    NextDash\
+       }\
+    }\
+ }
+ 
+ static	int low_translate[16] = 
+ 	{
+ 	  0x0000,  0x0010, 0x0008, 0x0018,
+ 	  0x0004,  0x0014, 0x000c, 0x001c,
+ 	  0x0006,  0x001c, 0x000e, 0x001e,
+ 	  0x0002,  0x001a, 0x000a, 0x001a
+ 	};
+ 
+ static	int high_translate[16] = 
+ 	{
+ 	  0x0000,  0x1000, 0x0800, 0x1800,
+ 	  0x0400,  0x1400, 0x0c00, 0x1c00,
+ 	  0x0600,  0x1c00, 0x0e00, 0x1e00,
+ 	  0x0200,  0x1a00, 0x0a00, 0x1a00
+ 	};
+ 
+ 
+ 
+ #define	HIGH_HIGH_NIBLE(x)	high_translate[((x) >> 12) & 0x0f]
+ #define LOW_HIGH_NIBLE(x)	low_translate[((x) >> 8) & 0x0f]
+ #define HIGH_LOW_NIBLE(x)	high_translate[((x) >> 4) & 0x0f]
+ #define	LOW_LOW_NIBLE(x)	low_translate[(x) & 0x0f]
+ 
+ /*
+  * Dashed lines through the graphics engine.
+  * Known Bugs: Jon 13/9/93
+  * - Dash offset isn't caclulated correctly for clipped lines. [fixed?]
+  * - Dash offset isn't updated correctly. [fixed?]
+  * - Dash patters which are a power of 2 and < 16 can be done faster through
+  *   the color compare register.
+  * - DoubleDashed lines are are probably very incorrect.
+  * - line caps are possible wrong too.
+  * - Caclulating the dashes could probably be done more optimally,
+  *   e.g. We could producing the pattern stipple before hand?
+  */
+ void
+ mach32Dline(pDrawable, pGC, mode, npt, pptInit)
+      DrawablePtr pDrawable;
+      GCPtr pGC;
+      int   mode;		/* Origin or Previous */
+      int   npt;			/* number of points */
+      DDXPointPtr pptInit;
+ {
+    int   nboxInit;
+    register int nbox;
+    BoxPtr pboxInit;
+    register BoxPtr pbox;
+    register DDXPointPtr ppt;	/* pointer to list of translated points */
+ 
+    unsigned int oc1;		/* outcode of point 1 */
+    unsigned int oc2;		/* outcode of point 2 */
+ 
+    int   xorg, yorg;		/* origin of window */
+ 
+    int   adx;			/* abs values of dx and dy */
+    int   ady;
+    int   signdx;		/* sign of dx and dy */
+    int   signdy;
+    int   e, e1, e2;		/* bresenham error and increments */
+    int   len;			/* length of segment */
+    int   axis;			/* major axis */
+    short direction;
+    unsigned char *pDash;
+    int   dashOffset;   
+    int numInDashList;
+    int dashIndex;
+    int dashIndexTmp, dashOffsetTmp, thisDash, dashRemaining;
+    int unclippedlen;
+    short dashPat;
+  /* a bunch of temporaries */
+    int   tmp;
+    register int y1, y2;
+    register int x1, x2;
+    RegionPtr cclip;
+    cfbPrivGCPtr devPriv;
+    short fix;
+ 
+    if (!x386VTSema)
+    {
+       cfbLineSD(pDrawable, pGC, mode, npt, pptInit);
+       return;
+    }
+ 
+    devPriv = (cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr);
+    cclip = devPriv->pCompositeClip;
+    pboxInit = REGION_RECTS(cclip);
+    nboxInit = REGION_NUM_RECTS(cclip);
+ 
+    WaitQueue(6);
+    outw(FRGD_MIX, FSS_FRGDCOL | mach32alu[pGC->alu]);
+    if (pGC->lineStyle == LineDoubleDash) {
+       outw(BKGD_COLOR, (short)pGC->bgPixel);
+       outw(BKGD_MIX, BSS_BKGDCOL | mach32alu[pGC->alu]);      
+    } else
+       outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
+    outw(WRT_MASK, (short)pGC->planemask);
+    outw(FRGD_COLOR, (short)pGC->fgPixel);
+    outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPPC | COLCMPOP_F);
+    
+    xorg = pDrawable->x;
+    yorg = pDrawable->y;
+    ppt = pptInit;
+ 
+    x2 = ppt->x + xorg;
+    y2 = ppt->y + yorg;
+ 
+    pDash = (unsigned char *) pGC->dash;
+    numInDashList = pGC->numInDashList;
+     
+    dashIndex = 0;
+    dashOffset = 0;
+    miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
+                 numInDashList, &dashOffset);
+ 
+    dashRemaining = pDash[dashIndex] - dashOffset;
+    thisDash = dashRemaining ;
+ 		  
+    
+    while (--npt) {
+       nbox = nboxInit;
+       pbox = pboxInit;
+ 
+       x1 = x2;
+       y1 = y2;
+       ++ppt;
+       if (mode == CoordModePrevious) {
+ 	 xorg = x1;
+ 	 yorg = y1;
+       }
+       x2 = ppt->x + xorg;
+       y2 = ppt->y + yorg;
+ 
+ #ifdef fastaxislinesfixed
+       if (x1 == x2) {
+ 
+ 	 if (y1 > y2) {
+ 	    unclippedlen = y1 = y2;
+ 	 } else {
+ 	    direction |= INC_X;
+ 	    unclippedlen = y2 - y1;	    
+ 	 }
+ 	 
+        /* get to first band that might contain part of line */
+ 	 while ((nbox) && (pbox->y2 <= y1)) {
+ 	    pbox++;
+ 	    nbox--;
+ 	 }
+ 
+ 	 if (nbox) {
+ 	  /* stop when lower edge of box is beyond end of line */
+ 	    while ((nbox) && (y2 >= pbox->y1)) {
+ 	       if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
+ 		  int   y1t, y2t;
+ 
+ 
+ 		/* this box has part of the line in it */
+ 		  y1t = max(y1, pbox->y1);
+ 		  y2t = min(y2, pbox->y2);
+ 		  if (y1t != y2t) {
+ 		     /* use tmp dash index and offsets */
+ 		     dashIndexTmp = dashIndex;    
+ 		     dashOffsetTmp = dashOffset; 
+ 
+ 		     if (y1t != y1) { /* advance the dash index */
+ 			miStepDash (y1t - y1, &dashIndexTmp, pDash,
+ 				 numInDashList, &dashOffsetTmp);
+ 		     }
+ 		     dashRemaining = pDash[dashIndexTmp] - dashOffsetTmp;
+ 		     thisDash = dashRemaining ;
+ 		     
+ 		     WaitQueue(4);
+ 		     outw(CUR_X, (short)x1);
+ 		     outw(CUR_Y, (short)y1t);
+ 		     len = y2t - y1t;
+ 		     outw(MAJ_AXIS_PCNT, (short)(len - 1));
+ 		     outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ 			PCDATA | _16BIT | WRTDATA | INC_Y | YMAJAXIS);
+ 
+ 		     for (tmp = 0 ; tmp < len; tmp+=16) {
+ #ifdef	NEVER
+ 
+ 			FillDashPat;			
+ 			outw(PIX_TRANS, dashPat);
+ #else
+ 	    outw(PIX_TRANS, HIGH_HIGH_NIBLE(dashPat) | LOW_HIGH_NIBLE(dashPat));
+ 	    outw(PIX_TRANS, HIGH_LOW_NIBLE(dashPat) | LOW_LOW_NIBLE(dashPat));
+ #endif
+ 
+ 		     }		  
+ 		  }
+ 	       }
+ 	       nbox--;
+ 	       pbox++;
+ 	    }
+ 	 }
+ 	 y2 = ppt->y + yorg;
+       } else if (y1 == y2) {
+ 
+        /*
+         * force line from left to right, keeping endpoint semantics
+         */
+ 	 if (x1 > x2) {
+ 	    register int tmp;
+ 
+ 	    tmp = x2;
+ 	    x2 = x1 + 1;
+ 	    x1 = tmp + 1;
+ 	 }
+ 	 unclippedlen = x2 - x1;
+        /* find the correct band */
+ 	 while ((nbox) && (pbox->y2 <= y1)) {
+ 	    pbox++;
+ 	    nbox--;
+ 	 }
+ 
+        /* try to draw the line, if we haven't gone beyond it */
+ 	 if ((nbox) && (pbox->y1 <= y1)) {
+ 	  /* when we leave this band, we're done */
+ 	    tmp = pbox->y1;
+ 	    while ((nbox) && (pbox->y1 == tmp)) {
+ 	       int   x1t, x2t;
+ 
+ 	       if (pbox->x2 <= x1) {
+ 		/* skip boxes until one might contain start point */
+ 		  nbox--;
+ 		  pbox++;
+ 		  continue;
+ 	       }
+ 	     /* stop if left of box is beyond right of line */
+ 	       if (pbox->x1 >= x2) {
+ 		  nbox = 0;
+ 		  break;
+ 	       }
+ 	       x1t = max(x1, pbox->x1);
+ 	       x2t = min(x2, pbox->x2);	       
+ 	       if (x1t != x2t) {
+ 		  dashIndexTmp = dashIndex;    
+ 		  dashOffsetTmp = dashOffset; 
+ 
+ 		  if (x1t != x1) { /* advance the dash index */
+ 		     miStepDash (x1t - x1, &dashIndexTmp, pDash,
+ 				 numInDashList, &dashOffsetTmp);
+ 		  }
+ 		  dashRemaining = pDash[dashIndexTmp] - dashOffsetTmp;
+ 		  thisDash = dashRemaining ;
+ 		  
+ 		  WaitQueue(4);
+ 		  outw(CUR_X, (short)x1t);
+ 		  outw(CUR_Y, (short)y1);
+ 		  len = x2t - x1t;
+ 		  outw(MAJ_AXIS_PCNT, (short)(len - 1));
+ 		  outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ 			PCDATA | _16BIT | WRTDATA);
+ 		  for (tmp = 0 ; tmp < len; tmp+=16) {
+ #ifdef	NEVER
+ 		     FillDashPat;
+ 		     outw(PIX_TRANS, dashPat);
+ #else
+ 	    outw(PIX_TRANS, HIGH_HIGH_NIBLE(dashPat) | LOW_HIGH_NIBLE(dashPat));
+ 	    outw(PIX_TRANS, HIGH_LOW_NIBLE(dashPat) | LOW_LOW_NIBLE(dashPat));
+ 
+ #endif
+ 		  }		 
+ 	       }
+ 	       nbox--;
+ 	       pbox++;
+ 	    }
+ 	 }
+ 	 x2 = ppt->x + xorg;
+       }
+       else
+ #endif
+       {			/* sloped line */
+ 	 direction = 0x0000;
+ 	 signdx = 1;
+ 	 if ((adx = x2 - x1) < 0) {
+ 	    adx = -adx;
+ 	    signdx = -1;
+ 	    fix = 0;
+ 	 } else {
+ 	    direction |= INC_X;
+ 	    fix = -1;
+ 	 }
+ 	 signdy = 1;
+ 	 if ((ady = y2 - y1) < 0) {
+ 	    ady = -ady;
+ 	    signdy = -1;
+ 	 } else {
+ 	    direction |= INC_Y;
+ 	 }
+ 
+ 	 if (adx > ady) {
+ 	    axis = X_AXIS;
+ 	    e1 = ady << 1;
+ 	    e2 = e1 - (adx << 1);
+ 	    e = e1 - adx;
+ 	    unclippedlen = adx;
+ 	 } else {
+ 	    axis = Y_AXIS;
+ 	    e1 = adx << 1;
+ 	    e2 = e1 - (ady << 1);
+ 	    e = e1 - ady;
+ 	    direction |= YMAJAXIS;
+ 	    unclippedlen = ady;	    
+ 	 }
+ 
+        /*
+         * we have bresenham parameters and two points. all we have to do now
+         * is clip and draw.
+         */
+ 
+ 	 while (nbox--) {
+ 	    oc1 = 0;
+ 	    oc2 = 0;
+ 	    OUTCODES(oc1, x1, y1, pbox);
+ 	    OUTCODES(oc2, x2, y2, pbox);
+ 	    if ((oc1 | oc2) == 0) {
+ 	       if (axis == X_AXIS) 
+ 		  len = adx;
+ 	       else 
+ 		  len = ady;
+ 	     dashIndexTmp = dashIndex;    
+ 	     dashOffsetTmp = dashOffset;
+ 	     /* No need to adjust dash offset */
+ 	     /*
+ 	      * NOTE:  The 8514/A hardware routines for generating lines do
+ 	      * not match the software generated lines of mi, cfb, and mfb.
+ 	      * This is a problem, and if I ever get time, I'll figure out
+ 	      * the 8514/A algorithm and implement it in software for mi,
+ 	      * cfb, and mfb.
+ 	      * 2-sep-93 TCG: apparently only change needed is
+ 	      * addition of 'fix' stuff in cfbline.c
+ 	      */
+ 	       WaitQueue(7);
+ 	       outw(CUR_X, (short)x1);
+ 	       outw(CUR_Y, (short)y1);
+ 	       outw(ERR_TERM, (short)(e + fix));
+ 	       outw(DESTY_AXSTP, (short)e1);
+ 	       outw(DESTX_DIASTP, (short)e2);
+ 	       outw(MAJ_AXIS_PCNT, (short)len);
+ 	       outw(CMD, CMD_LINE | DRAW | LASTPIX | PLANAR | direction |
+ 		       PCDATA | _16BIT | WRTDATA);
+ 	       for (tmp = 0 ; tmp < len; tmp+=16) {
+ #ifdef	NEVER
+ 		  FillDashPat;
+ 		  outw(PIX_TRANS, dashPat);
+ #else
+ 	    outw(PIX_TRANS, HIGH_HIGH_NIBLE(dashPat) | LOW_HIGH_NIBLE(dashPat));
+ 	    outw(PIX_TRANS, HIGH_LOW_NIBLE(dashPat) | LOW_LOW_NIBLE(dashPat));
+ #endif
+ 	       }
+ 	       break;
+ 	    } else if (oc1 & oc2) {
+ 	       pbox++;
+ 	    } else {
+ 
+ 	     /*
+ 	      * let the mfb helper routine do our work; better than
+ 	      * duplicating code...
+ 	      */
+ 	       BoxRec box;
+ 	       DDXPointRec pt1Copy;	/* clipped start point */
+ 	       DDXPointRec pt2Copy;	/* clipped end point */
+ 	       int   err;	/* modified bresenham error term */
+ 	       int   clip1, clip2;	/* clippedness of the endpoints */
+ 
+ 	       int   clipdx, clipdy;	/* difference between clipped and
+ 					 * unclipped start point */
+ 	       DDXPointRec pt1;
+ 	       int dlen;
+ 
+ 	       pt1.x = pt1Copy.x = x1;
+ 	       pt1.y = pt1Copy.y = y1;
+ 	       pt2Copy.x = x2;
+ 	       pt2Copy.y = y2;
+ 	       box.x1 = pbox->x1;
+ 	       box.y1 = pbox->y1;
+ 	       box.x2 = pbox->x2 - 1;
+ 	       box.y2 = pbox->y2 - 1;
+ 	       clip1 = 0;
+ 	       clip2 = 0;
+ 
+ 	       if (mfbClipLine(pbox, box,
+ 			       &pt1, &pt1Copy, &pt2Copy,
+ 			       adx, ady, signdx, signdy, axis,
+ 			       &clip1, &clip2) == 1) {
+ 		  dashIndexTmp = dashIndex;
+ 		  dashOffsetTmp = dashOffset; 
+ 			       
+ 		  if (axis == X_AXIS) {
+ 		     dlen = abs(pt1Copy.x - x1);
+ 		     len = abs(pt2Copy.x - pt1Copy.x);
+ 		  } else {
+ 		     dlen = abs(pt1Copy.y - y1);
+ 		     len = abs(pt2Copy.y - pt1Copy.y);
+ 		  }
+ 
+ 		  len += (clip2 != 0);
+ 		  if (len) {
+ 		   /* unwind bresenham error term to first point */
+ 		     if (clip1) {
+ 			clipdx = abs(pt1Copy.x - x1);
+ 			clipdy = abs(pt1Copy.y - y1);
+ 			if (axis == X_AXIS)
+ 			   err = e + ((clipdy * e2) + ((clipdx - clipdy) * e1));
+ 			else
+ 			   err = e + ((clipdx * e2) + ((clipdy - clipdx) * e1));
+ 		     } else
+ 			err = e;
+ 
+ 		     /*
+ 		      * Here is a problem, the unwound error terms could be
+ 		      * upto 16bit now. The poor MACH32 is only 12 or 13 bit.
+ 		      * The rounding error is probably small I favor scaling
+ 		      * the error terms, although re-evaluation is also an
+ 		      * option I think it might give visable errors
+ 		      * - Jon 12/9/93.
+ 		      */
+ 		      
+ 		     if (abs(err) > 4096  || abs(e1) > 4096 || abs(e2) > 4096) {
+ #if 1
+ 			int div;
+ 
+ 			if (abs(err) > abs(e1))
+ 			    div = (abs(err) > abs(e2)) ?
+ 			    (abs(err) + 4095)/ 4096 : (abs(e2) + 4095)/ 4096;
+ 			else
+ 			    div = (abs(e1) > abs(e2)) ?
+ 			    (abs(e1) + 4095)/ 4096 : (abs(e2) + 4095)/ 4096;
+ 
+ 			err /= div;
+ 			e1 /= div;
+ 			e2 /= div;
+ #else
+ 			int minor;
+ 			if (axis == X_AXIS) {			
+ 			   minor = abs(pt2Copy.y - pt1Copy.y);
+ 			   err = 2 * minor - len;			   
+ 			} else {
+ 			   minor = abs(pt2Copy.x - pt1Copy.x);
+ 			   err = 2 * minor - len - 1;	   
+ 			}
+ 			e1 = minor << 1;
+ 			e2 = e1 - (len << 1);
+ #endif
+ 		     }
+ 		     miStepDash (dlen, &dashIndexTmp, pDash,
+ 				 numInDashList, &dashOffsetTmp);
+ 		     WaitQueue(7);
+ 		     outw(CUR_X, (short)pt1Copy.x);
+ 		     outw(CUR_Y, (short)pt1Copy.y);
+ 		     outw(ERR_TERM, (short)(err + fix));
+ 		     outw(DESTY_AXSTP, (short)e1);
+ 		     outw(DESTX_DIASTP, (short)e2);
+ 		     outw(MAJ_AXIS_PCNT, (short)len);
+ 		     outw(CMD, CMD_LINE | DRAW | LASTPIX | PLANAR |
+ 			     direction | PCDATA | _16BIT | WRTDATA);
+ 
+ 		     for (tmp = 0 ; tmp < len; tmp+=16) {
+ #ifdef	NEVER
+ 
+ 			FillDashPat;
+ 			outw(PIX_TRANS, dashPat);
+ #else
+ 	    outw(PIX_TRANS, HIGH_HIGH_NIBLE(dashPat) | LOW_HIGH_NIBLE(dashPat));
+ 	    outw(PIX_TRANS, HIGH_LOW_NIBLE(dashPat) | LOW_LOW_NIBLE(dashPat));
+ #endif
+ 		     }
+ 		  }
+ 	       }
+ 	       pbox++;
+ 	    }
+ 	 }			/* while (nbox--) */
+       }/* sloped line */
+       miStepDash (unclippedlen, &dashIndex, pDash,
+ 		  numInDashList, &dashOffset);
+    } /* while (nline--) */
+ 
+  /*
+   * paint the last point if the end style isn't CapNotLast. (Assume that a
+   * projecting, butt, or round cap that is one pixel wide is the same as the
+   * single pixel of the endpoint.)
+   */
+ 
+    if ((pGC->capStyle != CapNotLast) &&
+        ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
+ 	(ppt->y + yorg != pptInit->y + pDrawable->y) ||
+ 	(ppt == pptInit + 1))) {
+       nbox = nboxInit;
+       pbox = pboxInit;
+       while (nbox--) {
+ 	 if ((x2 >= pbox->x1) &&
+ 	     (y2 >= pbox->y1) &&
+ 	     (x2 < pbox->x2) &&
+ 	     (y2 < pbox->y2)) {
+ 	    WaitQueue(4);
+ 	    outw(CUR_X, (short)x2);
+ 	    outw(CUR_Y, (short)y2);
+ 	    outw(MAJ_AXIS_PCNT, 0);
+ 	    outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR | WRTDATA);
+ 
+ 	    break;
+ 	 } else
+ 	    pbox++;
+       }
+    }
+    WaitQueue(3);
+    outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+    outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+    outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);  
+ }
diff -c /dev/null mit/server/ddx/x386/accel/mach32/mach32dseg.c:2.1
*** /dev/null	Fri Mar 11 23:37:09 1994
--- mit/server/ddx/x386/accel/mach32/mach32dseg.c	Fri Mar 11 23:37:09 1994
***************
*** 0 ****
--- 1,534 ----
+ /***********************************************************
+ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+ and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+ 
+                         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 names of Digital or MIT not be
+ used in advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.
+ 
+ DIGITAL AND KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+ SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+ IN NO EVENT SHALL DIGITAL OR KEVIN E. MARTIN 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.
+ 
+ Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
+ Modified for the mach32 by Mike Bernson (mike@mbsun.mlb.org)
+ ******************************************************************/
+ /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
+ 
+ /* s3dline.c from s3line.c with help from cfbresd.c and cfbline.c - Jon */
+ /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32dseg.c,v 2.1 1993/12/25 13:58:03 dawes Exp $ */
+ 
+ #include "X.h"
+ 
+ #include "gcstruct.h"
+ #include "windowstr.h"
+ #include "pixmapstr.h"
+ #include "regionstr.h"
+ #include "scrnintstr.h"
+ #include "mistruct.h"
+ 
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "misc.h"
+ #include "x386.h"
+ #include "mach32.h"
+ #include "regmach32.h"
+ 
+ /*
+  * single-pixel lines on a color frame buffer
+  * 
+  * NON-SLOPED LINES horizontal lines are always drawn left to right; we have to
+  * move the endpoints right by one after they're swapped. horizontal lines
+  * will be confined to a single band of a region.  the code finds that band
+  * (giving up if the lower bound of the band is above the line we're
+  * drawing); then it finds the first box in that band that contains part of
+  * the line.  we clip the line to subsequent boxes in that band. vertical
+  * lines are always drawn top to bottom (y-increasing.) this requires adding
+  * one to the y-coordinate of each endpoint after swapping.
+  * 
+  * SLOPED LINES when clipping a sloped line, we bring the second point inside
+  * the clipping box, rather than one beyond it, and then add 1 to the length
+  * of the line before drawing it.  this lets us use the same box for finding
+  * the outcodes for both endpoints.  since the equation for clipping the
+  * second endpoint to an edge gives us 1 beyond the edge, we then have to
+  * move the point towards the first point by one step on the major axis.
+  * eventually, there will be a diagram here to explain what's going on.  the
+  * method uses Cohen-Sutherland outcodes to determine outsideness, and a
+  * method similar to Pike's layers for doing the actual clipping.
+  * 
+  */
+ 
+ #define OUTCODES(result, x, y, pbox) \
+     if (x < pbox->x1) \
+ 	result |= OUT_LEFT; \
+     else if (x >= pbox->x2) \
+ 	result |= OUT_RIGHT; \
+     if (y < pbox->y1) \
+ 	result |= OUT_ABOVE; \
+     else if (y >= pbox->y2) \
+ 	result |= OUT_BELOW;
+ 
+ #define NextDash {\
+     dashIndexTmp++; \
+     if (dashIndexTmp == numInDashList) \
+         dashIndexTmp = 0; \
+     dashRemaining = pDash[dashIndexTmp]; \
+     thisDash = dashRemaining; \
+     }
+ 
+ #define FillDashPat {\
+    int i; \
+ \
+    for (i = 0; i < 16; i++) {\
+       dashPat <<= 1;\
+       if (tmp + i < len) {\
+ 	 if (!(dashIndexTmp & 1))\
+ 	    dashPat |= 1;\
+ 	 if (--thisDash == 0)\
+ 	    NextDash\
+       }\
+    }\
+ }
+ /*
+  * Dashed lines through the graphics engine.
+  * Known Bugs: Jon 13/9/93
+  * - Dash offset isn't caclulated correctly for clipped lines. [fixed?]
+  * - Dash offset isn't updated correctly. [fixed?]
+  * - Dash patters which are a power of 2 and < 16 can be done faster through
+  *   the color compare register.
+  * - DoubleDashed lines are are probably very incorrect.
+  * - line caps are possible wrong too.
+  * - Caclulating the dashes could probably be done more optimally,
+  *   e.g. We could producing the pattern stipple before hand?
+  */
+ void
+ mach32Dsegment (pDrawable, pGC, nseg, pSeg)
+     DrawablePtr pDrawable;
+     GCPtr pGC;
+     int   nseg;
+     register xSegment *pSeg;
+ {
+    int   nboxInit;
+    register int nbox;
+    BoxPtr pboxInit;
+    register BoxPtr pbox;
+ 
+    unsigned int oc1;		/* outcode of point 1 */
+    unsigned int oc2;		/* outcode of point 2 */
+ 
+    int   xorg, yorg;		/* origin of window */
+ 
+    int   adx;			/* abs values of dx and dy */
+    int   ady;
+    int   signdx;		/* sign of dx and dy */
+    int   signdy;
+    int   e, e1, e2;		/* bresenham error and increments */
+    int   len;			/* length of segment */
+    int   axis;			/* major axis */
+    short direction;
+    unsigned char *pDash;
+    int   dashOffset;   
+    int numInDashList;
+    int dashIndex;
+    int dashIndexTmp, dashOffsetTmp, thisDash, dashRemaining;
+    int unclippedlen;
+    short dashPat;
+  /* a bunch of temporaries */
+    int   tmp;
+    register int y1, y2;
+    register int x1, x2;
+    RegionPtr cclip;
+    cfbPrivGCPtr devPriv;
+    short fix;
+ 
+    if (!x386VTSema)
+    {
+       cfbSegmentSD(pDrawable, pGC, nseg, pSeg);
+       return;
+    }
+ 
+    devPriv = (cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr);
+    cclip = devPriv->pCompositeClip;
+    pboxInit = REGION_RECTS(cclip);
+    nboxInit = REGION_NUM_RECTS(cclip);
+ 
+    WaitQueue(6);
+    outw(FRGD_MIX, FSS_FRGDCOL | mach32alu[pGC->alu]);
+    if (pGC->lineStyle == LineDoubleDash) {
+       outw(BKGD_COLOR, (short)pGC->bgPixel);
+       outw(BKGD_MIX, BSS_BKGDCOL | mach32alu[pGC->alu]);      
+    } else
+       outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
+    outw(WRT_MASK, (short)pGC->planemask);
+    outw(FRGD_COLOR, (short)pGC->fgPixel);
+    outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPPC | COLCMPOP_F);
+    
+    xorg = pDrawable->x;
+    yorg = pDrawable->y;
+ 
+    pDash = (unsigned char *) pGC->dash;
+    numInDashList = pGC->numInDashList;
+     
+    dashIndex = 0;
+    dashOffset = 0;
+    miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
+                 numInDashList, &dashOffset);
+ 
+    dashRemaining = pDash[dashIndex] - dashOffset;
+    thisDash = dashRemaining ;
+ 		  
+    
+    while (nseg--) {
+       nbox = nboxInit;
+       pbox = pboxInit;
+ 
+       x1 = pSeg->x1 + xorg;
+       y1 = pSeg->y1 + yorg;
+       x2 = pSeg->x2 + xorg;
+       y2 = pSeg->y2 + yorg;
+ 
+       pSeg++;
+       /* The following code doesn't work as it can change the direction of
+        * the line in order to simplify the cliping. Dashed lines need to
+        * be drawn in the order given in order to caclulate the dash offset
+        * correctly.
+        */
+ #ifdef fastaxislinesfixed
+       if (x1 == x2) {
+ 
+ 	 if (y1 > y2) {
+ 	    unclippedlen = y1 = y2;
+ 	 } else {
+ 	    direction |= INC_X;
+ 	    unclippedlen = y2 - y1;	    
+ 	 }
+ 	 
+        /* get to first band that might contain part of line */
+ 	 while ((nbox) && (pbox->y2 <= y1)) {
+ 	    pbox++;
+ 	    nbox--;
+ 	 }
+ 
+ 	 if (nbox) {
+ 	  /* stop when lower edge of box is beyond end of line */
+ 	    while ((nbox) && (y2 >= pbox->y1)) {
+ 	       if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
+ 		  int   y1t, y2t;
+ 
+ 
+ 		/* this box has part of the line in it */
+ 		  y1t = max(y1, pbox->y1);
+ 		  y2t = min(y2, pbox->y2);
+ 		  if (y1t != y2t) {
+ 		     /* use tmp dash index and offsets */
+ 		     dashIndexTmp = dashIndex;    
+ 		     dashOffsetTmp = dashOffset; 
+ 
+ 		     if (y1t != y1) { /* advance the dash index */
+ 			miStepDash (y1t - y1, &dashIndexTmp, pDash,
+ 				 numInDashList, &dashOffsetTmp);
+ 		     }
+ 		     dashRemaining = pDash[dashIndexTmp] - dashOffsetTmp;
+ 		     thisDash = dashRemaining ;
+ 		     
+ 		     WaitQueue(4);
+ 		     outw(CUR_X, (short)x1);
+ 		     outw(CUR_Y, (short)y1t);
+ 		     len = y2t - y1t;
+ 		     outw(MAJ_AXIS_PCNT, (short)(len - 1));
+ 		     outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ 			   PCDATA | _16BIT |WRTDATA | (6 << 5));
+ 
+ 		     for (tmp = 0 ; tmp < len; tmp+=16) {
+ 			FillDashPat;			
+ 			outw(PIX_TRANS, dashPat);
+ 		     }		  
+ 		  }
+ 	       }
+ 	       nbox--;
+ 	       pbox++;
+ 	    }
+ 	 }
+       } else if (y1 == y2) {
+ 
+        /*
+         * force line from left to right, keeping endpoint semantics
+         */
+ 	 if (x1 > x2) {
+ 	    register int tmp;
+ 
+ 	    tmp = x2;
+ 	    x2 = x1 + 1;
+ 	    x1 = tmp + 1;
+ 	 }
+ 	 unclippedlen = x2 - x1;
+        /* find the correct band */
+ 	 while ((nbox) && (pbox->y2 <= y1)) {
+ 	    pbox++;
+ 	    nbox--;
+ 	 }
+ 
+        /* try to draw the line, if we haven't gone beyond it */
+ 	 if ((nbox) && (pbox->y1 <= y1)) {
+ 	  /* when we leave this band, we're done */
+ 	    tmp = pbox->y1;
+ 	    while ((nbox) && (pbox->y1 == tmp)) {
+ 	       int   x1t, x2t;
+ 
+ 	       if (pbox->x2 <= x1) {
+ 		/* skip boxes until one might contain start point */
+ 		  nbox--;
+ 		  pbox++;
+ 		  continue;
+ 	       }
+ 	     /* stop if left of box is beyond right of line */
+ 	       if (pbox->x1 >= x2) {
+ 		  nbox = 0;
+ 		  break;
+ 	       }
+ 	       x1t = max(x1, pbox->x1);
+ 	       x2t = min(x2, pbox->x2);	       
+ 	       if (x1t != x2t) {
+ 		  dashIndexTmp = dashIndex;    
+ 		  dashOffsetTmp = dashOffset; 
+ 
+ 		  if (x1t != x1) { /* advance the dash index */
+ 		     miStepDash (x1t - x1, &dashIndexTmp, pDash,
+ 				 numInDashList, &dashOffsetTmp);
+ 		  }
+ 		  dashRemaining = pDash[dashIndexTmp] - dashOffsetTmp;
+ 		  thisDash = dashRemaining ;
+ 		  
+ 		  WaitQueue(4);
+ 		  outw(CUR_X, (short)x1t);
+ 		  outw(CUR_Y, (short)y1);
+ 		  len = x2t - x1t;
+ 		  outw(MAJ_AXIS_PCNT, (short)(len - 1));
+ 		  outw(CMD, CMD_LINE | DRAW | LINETYPE | PLANAR |
+ 			PCDATA | _16BIT | WRTDATA);
+ 		  for (tmp = 0 ; tmp < len; tmp+=16) {
+ 		     FillDashPat;
+ 		     outw(PIX_TRANS, dashPat);
+ 		  }		 
+ 	       }
+ 	       nbox--;
+ 	       pbox++;
+ 	    }
+ 	 }
+       }
+       else
+ #endif
+       {			/* sloped line */
+ 	 direction = 0x0000;
+ 	 signdx = 1;
+ 	 if ((adx = x2 - x1) < 0) {
+ 	    adx = -adx;
+ 	    signdx = -1;
+ 	    fix = 0;
+ 	 } else {
+ 	    direction |= INC_X;
+ 	    fix = -1;
+ 	 }
+ 	 signdy = 1;
+ 	 if ((ady = y2 - y1) < 0) {
+ 	    ady = -ady;
+ 	    signdy = -1;
+ 	 } else {
+ 	    direction |= INC_Y;
+ 	 }
+ 
+ 	 if (adx > ady) {
+ 	    axis = X_AXIS;
+ 	    e1 = ady << 1;
+ 	    e2 = e1 - (adx << 1);
+ 	    e = e1 - adx;
+ 	    unclippedlen = adx;
+ 	 } else {
+ 	    axis = Y_AXIS;
+ 	    e1 = adx << 1;
+ 	    e2 = e1 - (ady << 1);
+ 	    e = e1 - ady;
+ 	    direction |= YMAJAXIS;
+ 	    unclippedlen = ady;	    
+ 	 }
+ 
+        /*
+         * we have bresenham parameters and two points. all we have to do now
+         * is clip and draw.
+         */
+ 
+ 	 while (nbox--) {
+ 	    oc1 = 0;
+ 	    oc2 = 0;
+ 	    OUTCODES(oc1, x1, y1, pbox);
+ 	    OUTCODES(oc2, x2, y2, pbox);
+ 	    if ((oc1 | oc2) == 0) {
+ 	       if (axis == X_AXIS) 
+ 		  len = adx;
+ 	       else 
+ 		  len = ady;
+ 
+ 	     if (pGC->capStyle != CapNotLast) {
+ 	        unclippedlen++;	
+ 		len++;
+ 	     }
+ 	     dashIndexTmp = dashIndex;    
+ 	     dashOffsetTmp = dashOffset;
+ 	     /* No need to adjust dash offset */
+ 	     /*
+ 	      * NOTE:  The 8514/A hardware routines for generating lines do
+ 	      * not match the software generated lines of mi, cfb, and mfb.
+ 	      * This is a problem, and if I ever get time, I'll figure out
+ 	      * the 8514/A algorithm and implement it in software for mi,
+ 	      * cfb, and mfb.
+ 	      * 2-sep-93 TCG: apparently only change needed is
+ 	      * addition of 'fix' stuff in cfbline.c
+ 	      */
+ 	       WaitQueue(7);
+ 	       outw(CUR_X, (short)x1);
+ 	       outw(CUR_Y, (short)y1);
+ 	       outw(ERR_TERM, (short)(e + fix));
+ 	       outw(DESTY_AXSTP, (short)e1);
+ 	       outw(DESTX_DIASTP, (short)e2);
+ 	       outw(MAJ_AXIS_PCNT, (short)len);
+ 	       outw(CMD, CMD_LINE | DRAW | LASTPIX | PLANAR | direction |
+ 		       PCDATA | _16BIT | WRTDATA);
+ 	       for (tmp = 0 ; tmp < len; tmp+=16) {
+ 		  FillDashPat;
+ 		  outw(PIX_TRANS, dashPat);
+ 	       }
+ 	       break;
+ 	    } else if (oc1 & oc2) {
+ 	       pbox++;
+ 	    } else {
+ 
+ 	     /*
+ 	      * let the mfb helper routine do our work; better than
+ 	      * duplicating code...
+ 	      */
+ 	       BoxRec box;
+ 	       DDXPointRec pt1Copy;	/* clipped start point */
+ 	       DDXPointRec pt2Copy;	/* clipped end point */
+ 	       int   err;	/* modified bresenham error term */
+ 	       int   clip1, clip2;	/* clippedness of the endpoints */
+ 
+ 	       int   clipdx, clipdy;	/* difference between clipped and
+ 					 * unclipped start point */
+ 	       DDXPointRec pt1;
+ 	       int dlen;
+ 
+ 	       pt1.x = pt1Copy.x = x1;
+ 	       pt1.y = pt1Copy.y = y1;
+ 	       pt2Copy.x = x2;
+ 	       pt2Copy.y = y2;
+ 	       box.x1 = pbox->x1;
+ 	       box.y1 = pbox->y1;
+ 	       box.x2 = pbox->x2 - 1;
+ 	       box.y2 = pbox->y2 - 1;
+ 	       clip1 = 0;
+ 	       clip2 = 0;
+ 
+ 	       if (mfbClipLine(pbox, box,
+ 			       &pt1, &pt1Copy, &pt2Copy,
+ 			       adx, ady, signdx, signdy, axis,
+ 			       &clip1, &clip2) == 1) {
+ 		  dashIndexTmp = dashIndex;
+ 		  dashOffsetTmp = dashOffset; 
+ 			       
+ 		  if (axis == X_AXIS) {
+ 		     dlen = abs(pt1Copy.x - x1);
+ 		     len = abs(pt2Copy.x - pt1Copy.x);
+ 		  } else {
+ 		     dlen = abs(pt1Copy.y - y1);
+ 		     len = abs(pt2Copy.y - pt1Copy.y);
+ 		  }
+ 
+ 		  if (clip2 != 0 || pGC->capStyle != CapNotLast)
+ 		     len++;
+ 		  if (len) {
+ 		   /* unwind bresenham error term to first point */
+ 		     if (clip1) {
+ 			clipdx = abs(pt1Copy.x - x1);
+ 			clipdy = abs(pt1Copy.y - y1);
+ 			if (axis == X_AXIS)
+ 			   err = e + ((clipdy * e2) + ((clipdx - clipdy) * e1));
+ 			else
+ 			   err = e + ((clipdx * e2) + ((clipdy - clipdx) * e1));
+ 		     } else
+ 			err = e;
+ 
+ 		     /*
+ 		      * Here is a problem, the unwound error terms could be
+ 		      * upto 16bit now. The poor MACH32 is only 12 or 13 bit.
+ 		      * The rounding error is probably small I favor scaling
+ 		      * the error terms, although re-evaluation is also an
+ 		      * option I think it might give visable errors
+ 		      * - Jon 12/9/93.
+ 		      */
+ 		      
+ 		     if (abs(err) > 4096  || abs(e1) > 4096 || abs(e2) > 4096) {
+ #if 1
+ 			int div;
+ 
+ 			if (abs(err) > abs(e1))
+ 			    div = (abs(err) > abs(e2)) ?
+ 			    (abs(err) + 4095)/ 4096 : (abs(e2) + 4095)/ 4096;
+ 			else
+ 			    div = (abs(e1) > abs(e2)) ?
+ 			    (abs(e1) + 4095)/ 4096 : (abs(e2) + 4095)/ 4096;
+ 
+ 			err /= div;
+ 			e1 /= div;
+ 			e2 /= div;
+ #else
+ 			int minor;
+ 			if (axis == X_AXIS) {			
+ 			   minor = abs(pt2Copy.y - pt1Copy.y);
+ 			   err = 2 * minor - len;			   
+ 			} else {
+ 			   minor = abs(pt2Copy.x - pt1Copy.x);
+ 			   err = 2 * minor - len - 1;	   
+ 			}
+ 			e1 = minor << 1;
+ 			e2 = e1 - (len << 1);
+ #endif			
+ 		     }
+ 		     miStepDash (dlen, &dashIndexTmp, pDash,
+ 				 numInDashList, &dashOffsetTmp);
+ 		     WaitQueue(7);
+ 		     outw(CUR_X, (short)pt1Copy.x);
+ 		     outw(CUR_Y, (short)pt1Copy.y);
+ 		     outw(ERR_TERM, (short)(err + fix));
+ 		     outw(DESTY_AXSTP, (short)e1);
+ 		     outw(DESTX_DIASTP, (short)e2);
+ 		     outw(MAJ_AXIS_PCNT, (short)len);
+ 		     outw(CMD, CMD_LINE | DRAW | LASTPIX | PLANAR |
+ 			     direction | PCDATA | _16BIT | WRTDATA);
+ 
+ 		     for (tmp = 0 ; tmp < len; tmp+=16) {
+ 			FillDashPat;
+ 			outw(PIX_TRANS, dashPat);
+ 		     }
+ 		  }
+ 	       }
+ 	       pbox++;
+ 	    }
+ 	 }			/* while (nbox--) */
+       }/* sloped line */
+    } /* while (nline--) */
+ 
+    WaitQueue(3);
+    outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
+    outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
+    outw (MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);  
+ }
diff -c mit/server/ddx/x386/accel/mach32/mach32fcach.c:2.4 mit/server/ddx/x386/accel/mach32/mach32fcach.c:2.5
*** mit/server/ddx/x386/accel/mach32/mach32fcach.c:2.4	Fri Mar 11 23:37:10 1994
--- mit/server/ddx/x386/accel/mach32/mach32fcach.c	Fri Mar 11 23:37:10 1994
***************
*** 25,31 ****
   * Dynamic cache allocation added by Rickard E. Faith (faith@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32fcach.c,v 2.4 1993/10/04 05:00:57 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 25,31 ----
   * Dynamic cache allocation added by Rickard E. Faith (faith@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32fcach.c,v 2.5 1993/12/25 13:58:05 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 59,64 ****
--- 59,66 ----
  static int      NumFonts;
  short		mach32ReadMask[8] = { 2, 4, 8, 16, 32, 64, 128, 1 };
  
+ extern void QueryGlyphExtents();
+ 
  void
  mach32FontCache8Init(x,y)
      int x, y;
***************
*** 96,101 ****
--- 98,104 ----
      }
  }
  
+ #if 0
  int
  mach32IsCached(font)
      FontPtr font;
***************
*** 106,111 ****
--- 109,115 ----
  	if (mach32FontCache[i].font == font)
  	    return i;
  }
+ #endif
  
  void
  mach32UnCacheFont8(font)
diff -c mit/server/ddx/x386/accel/mach32/mach32gc.c:2.0 mit/server/ddx/x386/accel/mach32/mach32gc.c:2.4
*** mit/server/ddx/x386/accel/mach32/mach32gc.c:2.0	Fri Mar 11 23:37:11 1994
--- mit/server/ddx/x386/accel/mach32/mach32gc.c	Fri Mar 11 23:37:11 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32gc.c,v 2.0 1993/08/07 08:19:17 dawes Exp $ */
  
  /* $XConsortium: cfbgc.c,v 1.2 91/07/18 23:00:53 keith Exp $ */
  
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32gc.c,v 2.4 1994/03/01 09:51:32 dawes Exp $ */
  
  /* $XConsortium: cfbgc.c,v 1.2 91/07/18 23:00:53 keith Exp $ */
  
***************
*** 54,60 ****
  
  static void cfbValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
  static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
! static cfbDestroyOps();
  
  static GCFuncs cfbFuncs = {
      cfbValidateGC,
--- 54,60 ----
  
  static void cfbValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
  static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
! static void cfbDestroyOps();
  
  static GCFuncs cfbFuncs = {
      cfbValidateGC,
***************
*** 69,75 ****
  static GCOps	mach32Ops = {
      mach32SolidFSpans,
      mach32SetSpans,
!     miPutImage,
      mach32CopyArea,
      mach32CopyPlane,
      mach32PolyPoint,
--- 69,75 ----
  static GCOps	mach32Ops = {
      mach32SolidFSpans,
      mach32SetSpans,
!     cfbPutImage,
      mach32CopyArea,
      mach32CopyPlane,
      mach32PolyPoint,
***************
*** 93,99 ****
  static GCOps	mach32MemApertureOps = {
      mach32SolidFSpans,
      mach32SetSpans,
!     miPutImage,
      mach32CopyArea,
      cfbCopyPlane,
      mach32PolyPoint,
--- 93,99 ----
  static GCOps	mach32MemApertureOps = {
      mach32SolidFSpans,
      mach32SetSpans,
!     cfbPutImage,
      mach32CopyArea,
      cfbCopyPlane,
      mach32PolyPoint,
***************
*** 346,352 ****
      return ret;
  }
  
! static
  cfbDestroyOps (ops)
      GCOps   *ops;
  {
--- 346,352 ----
      return ret;
  }
  
! static void
  cfbDestroyOps (ops)
      GCOps   *ops;
  {
***************
*** 774,780 ****
  	    {
  		if (pGC->fillStyle == FillSolid)
  		{
! 		  pGC->ops->Polylines = mach32Line;
  		  pGC->ops->PolySegment = mach32Segment;
  		}
   		else
--- 774,783 ----
  	    {
  		if (pGC->fillStyle == FillSolid)
  		{
! 		  if (devPriv->oneRect)
! 		    pGC->ops->Polylines = mach32Line1Rect;
! 		  else
! 		    pGC->ops->Polylines = mach32Line;
  		  pGC->ops->PolySegment = mach32Segment;
  		}
   		else
***************
*** 785,797 ****
  	    break;
  	case LineOnOffDash:
  	case LineDoubleDash:
! 	    if (mach32Use4MbAperture &&
! 		(pGC->lineWidth == 0) && (pGC->fillStyle == FillSolid))
! 	    {
! 		pGC->ops->Polylines = cfbLineSD;
! 		pGC->ops->PolySegment = cfbSegmentSD;
! 	    } else
! 		pGC->ops->Polylines = miWideDash;
  	    break;
  	}
        } else {
--- 788,801 ----
  	    break;
  	case LineOnOffDash:
  	case LineDoubleDash:
! 	   if (pGC->lineWidth == 0) {
! 		if (pGC->fillStyle == FillSolid) {
! 		   pGC->ops->Polylines = mach32Dline;
! 		   pGC->ops->PolySegment = mach32Dsegment;
! 	         } else
! 		   pGC->ops->Polylines = miWideDash;
! 	   } else
! 	      pGC->ops->Polylines = miWideDash;
  	    break;
  	}
        } else {
diff -c mit/server/ddx/x386/accel/mach32/mach32gs.c:2.1 mit/server/ddx/x386/accel/mach32/mach32gs.c:2.3
*** mit/server/ddx/x386/accel/mach32/mach32gs.c:2.1	Fri Mar 11 23:37:12 1994
--- mit/server/ddx/x386/accel/mach32/mach32gs.c	Fri Mar 11 23:37:12 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32gs.c,v 2.1 1993/09/23 15:44:10 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32gs.c,v 2.3 1994/02/12 11:05:34 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 60,66 ****
  {
      int			j;
      unsigned char	*pdst; /* where to put the bits */
-     unsigned char	*psrc; /* where to get the bits */
      int			pixmapStride;
  
      if ((pDrawable->type != DRAWABLE_WINDOW) || (!x386VTSema)) {
--- 60,65 ----
***************
*** 84,90 ****
      pdst = (unsigned char *)pdstStart;
  
      for (; nspans--; ppt++, pwidth++) {
! 	(mach32ImageReadFunc)(ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride, 0, 0);
  	pdst += j;		/* width is in 32 bit words */
  	j = (-j) & 3;
  	while (j--)		/* Pad out to 32-bit boundary */
--- 83,90 ----
      pdst = (unsigned char *)pdstStart;
  
      for (; nspans--; ppt++, pwidth++) {
! 	(mach32ImageReadFunc)(ppt->x, ppt->y, j = *pwidth, 1, pdst,
! 				pixmapStride, 0, 0, ~0);
  	pdst += j;		/* width is in 32 bit words */
  	j = (-j) & 3;
  	while (j--)		/* Pad out to 32-bit boundary */
diff -c /dev/null mit/server/ddx/x386/accel/mach32/mach32gtimg.c:2.1
*** /dev/null	Fri Mar 11 23:37:12 1994
--- mit/server/ddx/x386/accel/mach32/mach32gtimg.c	Fri Mar 11 23:37:12 1994
***************
*** 0 ****
--- 1,81 ----
+ /*
+  * 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.
+  *
+  * Code Modify for mach32 server By mike@mbsun.mlb.org
+  *	Changes for mach32 server only changed the s3 -> mach32
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32gtimg.c,v 2.1 1994/02/23 14:17:09 dawes Exp $ */
+ 
+ #include "X.h"
+ #include "windowstr.h"
+ #include "scrnintstr.h"
+ #include "pixmapstr.h"
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "mach32.h"
+ 
+ extern void mfbGetImage();
+ 
+ void
+ mach32GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+      DrawablePtr pDrawable;
+      int         sx, sy, w, h;
+      unsigned int format;
+      unsigned long planeMask;
+      pointer     pdstLine;
+ {
+    int width;
+ 
+    if ((w == 0) || (h == 0))
+       return;
+ 
+    if (pDrawable->bitsPerPixel == 1)
+    {
+       mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+       return;
+    }
+ 
+    if (!x386VTSema || pDrawable->type != DRAWABLE_WINDOW)
+    {
+       cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+       return;
+    }
+ 
+    width = PixmapBytePad(w, pDrawable->depth);
+    if (format == ZPixmap)
+    {
+       (mach32ImageReadFunc)(sx+pDrawable->x, sy+pDrawable->y, w, h, 
+ 			pdstLine, width, 0, 0, planeMask);
+    }
+    else
+    {
+       /*
+        * Worry about this later (much!).  Should be straighforward, though.
+        * Read an image into a dummy pixmap, then use cfbCopyPlane8to1 to
+        * copy each plane in planeMask into the destination.  At least
+        * this is the theory.
+        */
+       miGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+    }
+ }
+ 
diff -c mit/server/ddx/x386/accel/mach32/mach32im.c:2.9 mit/server/ddx/x386/accel/mach32/mach32im.c:2.12
*** mit/server/ddx/x386/accel/mach32/mach32im.c:2.9	Fri Mar 11 23:37:13 1994
--- mit/server/ddx/x386/accel/mach32/mach32im.c	Fri Mar 11 23:37:13 1994
***************
*** 27,34 ****
   *   Added outsw code.
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32im.c,v 2.9 1993/10/04 05:00:59 dawes Exp $ */
  
  #include "mach32.h"
  #include "regmach32.h"
  #include "mach32im.h"
--- 27,38 ----
   *   Added outsw code.
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32im.c,v 2.12 1994/02/12 11:05:35 dawes Exp $ */
  
+ #include "X.h"
+ #include "misc.h"
+ #include "x386.h"
+ #include "xf86_HWlib.h"
  #include "mach32.h"
  #include "regmach32.h"
  #include "mach32im.h"
***************
*** 64,84 ****
  #define __inline__ /**/
  #endif
  
! static void __inline__ outsw(void *buf, short count, unsigned short port)
  {
     __asm__ __volatile__ ("cld;rep;outsw"
  		     ::"d" (port),"S" (buf),"c" (count):"cx","si");
  }
  
! void __inline__ SetVGAPage(int page)
  {
  	outw(ATIEXT, bank_to_page_1[page]);
  	outw(ATIEXT, bank_to_page_2[page]);
  }
  
! void __inline__ XYSetVGAPage(int x, int y)
  {
! 	SetVGAPage((x + y * (mach32MaxX+1)) >> 16);
  }
  
  #else /* __GNUC__ */
--- 68,88 ----
  #define __inline__ /**/
  #endif
  
! static __inline__ void outsw(void *buf, short count, unsigned short port)
  {
     __asm__ __volatile__ ("cld;rep;outsw"
  		     ::"d" (port),"S" (buf),"c" (count):"cx","si");
  }
  
! __inline__ void mach32SetVGAPage(int page)
  {
  	outw(ATIEXT, bank_to_page_1[page]);
  	outw(ATIEXT, bank_to_page_2[page]);
  }
  
! static __inline__ void XYSetVGAPage(int x, int y)
  {
! 	mach32SetVGAPage((x + y * (mach32MaxX+1)) >> 16);
  }
  
  #else /* __GNUC__ */
***************
*** 95,101 ****
  		outw(port, *(p++));
  }
  
! void SetVGAPage(page)
  int page;
  {
  	outw(ATIEXT, bank_to_page_1[page]);
--- 99,105 ----
  		outw(port, *(p++));
  }
  
! void mach32SetVGAPage(page)
  int page;
  {
  	outw(ATIEXT, bank_to_page_1[page]);
***************
*** 106,112 ****
  int x;
  int y;
  {
! 	SetVGAPage((x + y * (mach32MaxX+1)) >> 16);
  }
  
  
--- 110,116 ----
  int x;
  int y;
  {
! 	mach32SetVGAPage((x + y * (mach32MaxX+1)) >> 16);
  }
  
  
***************
*** 208,213 ****
--- 212,218 ----
      int offset;
      int bank;
      int left;
+     int count;
  
      if ((w == 0) || (h == 0))
  	return;
***************
*** 228,262 ****
      bank = offset / mach32BankSize;
      offset &= (mach32BankSize-1);
      curvm = &mach32VideoMem[offset];
!     SetVGAPage(bank);
  
!     while(h--) {
! 	if (offset + w > mach32BankSize) {
! 	    if (offset < mach32BankSize) {
! 		left = mach32BankSize - offset;
  		MemToBus(curvm, psrc, left);
  		bank++;
! 		SetVGAPage(bank);
  		
  		MemToBus(mach32VideoMem, psrc+left, w-left);
  		psrc += pwidth;
! 		offset = (offset + mach32VirtX) & (mach32BankSize-1);
! 		curvm = &mach32VideoMem[offset];
  	    } else {
  		bank++;
! 		SetVGAPage(bank);
! 		offset &= (mach32BankSize-1);
! 		curvm = &mach32VideoMem[offset];
! 		MemToBus(curvm, psrc, w);
! 		offset += mach32VirtX;
! 		curvm += mach32VirtX;
! 		psrc += pwidth;
  	    }
! 	} else {
! 	    MemToBus(curvm, psrc, w);
! 	    offset += mach32VirtX;
! 	    curvm += mach32VirtX;
! 	    psrc += pwidth;
  	}
      }
  }
--- 233,284 ----
      bank = offset / mach32BankSize;
      offset &= (mach32BankSize-1);
      curvm = &mach32VideoMem[offset];
!     mach32SetVGAPage(bank);
  
! 
!     while(h) {
! 	/*
! 	 * calc number of line before need to switch banks
! 	 */
! 	count = (mach32BankSize - offset) / mach32VirtX;
! 	if (count >= h) {
! 		count = h;
! 		h = 0;
! 	} else {
! 		offset += (count * mach32VirtX);
! 		if (offset + w < mach32BankSize) {
! 			count++;
! 			offset += mach32VirtX;
! 		}
! 		h -= count;
! 	}
! 
! 	/*
! 	 * Output line till back switch
! 	 */
! 	while(count--) {
! 		MemToBus(curvm, psrc, w);
! 		curvm += mach32VirtX;
! 		psrc += pwidth;
! 	}
! 
! 	if (h) {
! 	   if (offset < mach32BankSize) {
! 		h--;
! 	        left = mach32BankSize - offset;
  		MemToBus(curvm, psrc, left);
  		bank++;
! 		mach32SetVGAPage(bank);
  		
  		MemToBus(mach32VideoMem, psrc+left, w-left);
  		psrc += pwidth;
! 		offset += mach32VirtX;
  	    } else {
  		bank++;
! 		mach32SetVGAPage(bank);
  	    }
! 	offset &= (mach32BankSize-1);
! 	curvm = &mach32VideoMem[offset];
  	}
      }
  }
***************
*** 315,321 ****
  
  
  static void
! mach32ImageRead(x, y, w, h, psrc, pwidth, px, py)
      int			x;
      int			y;
      int			w;
--- 337,343 ----
  
  
  static void
! mach32ImageRead(x, y, w, h, psrc, pwidth, px, py, planemask)
      int			x;
      int			y;
      int			w;
***************
*** 324,337 ****
      int			pwidth;
      int			px;
      int			py;
  {
!     int i,j;
!     short pix;
      pointer curvm;
  
      if ((w == 0) || (h == 0))
  	return;
  
      WaitIdleEmpty();
  
      psrc += pwidth * py + px;
--- 346,364 ----
      int			pwidth;
      int			px;
      int			py;
+     short		planemask;
  {
!     int j;
      pointer curvm;
  
      if ((w == 0) || (h == 0))
  	return;
  
+     if ((planemask & 0xff) != 0xff) {
+ 	mach32ImageReadNoMem(x, y, w, h, psrc, pwidth, px, py, planemask);
+ 	return;
+     }
+ 
      WaitIdleEmpty();
  
      psrc += pwidth * py + px;
***************
*** 344,350 ****
  }
  
  static void
! mach32ImageReadBank(x, y, w, h, psrc, pwidth, px, py)
      int			x;
      int			y;
      int			w;
--- 371,377 ----
  }
  
  static void
! mach32ImageReadBank(x, y, w, h, psrc, pwidth, px, py, planemask)
      int			x;
      int			y;
      int			w;
***************
*** 353,358 ****
--- 380,386 ----
      int			pwidth;
      int			px;
      int			py;
+     short		planemask;
  {
      pointer curvm;
      int offset;
***************
*** 362,367 ****
--- 390,400 ----
      if ((w == 0) || (h == 0))
  	return;
  
+     if ((planemask & 0xff) != 0xff) {
+ 	mach32ImageReadNoMem(x, y, w, h, psrc, pwidth, px, py, planemask);
+ 	return;
+     }
+ 
      WaitIdleEmpty();
  
      psrc += pwidth * py + px;
***************
*** 369,375 ****
      bank = offset / mach32BankSize;
      offset &= (mach32BankSize-1);
      curvm = &mach32VideoMem[offset];
!     SetVGAPage(bank);
  
      while(h--) {
  	if (offset + w > mach32BankSize) {
--- 402,408 ----
      bank = offset / mach32BankSize;
      offset &= (mach32BankSize-1);
      curvm = &mach32VideoMem[offset];
!     mach32SetVGAPage(bank);
  
      while(h--) {
  	if (offset + w > mach32BankSize) {
***************
*** 377,383 ****
  		left = mach32BankSize - offset;
  		BusToMem(psrc, curvm, left);
  		bank++;
! 		SetVGAPage(bank);
  		
  		BusToMem(psrc+left, mach32VideoMem, w-left);
  		psrc += pwidth;
--- 410,416 ----
  		left = mach32BankSize - offset;
  		BusToMem(psrc, curvm, left);
  		bank++;
! 		mach32SetVGAPage(bank);
  		
  		BusToMem(psrc+left, mach32VideoMem, w-left);
  		psrc += pwidth;
***************
*** 385,391 ****
  		curvm = &mach32VideoMem[offset];
  	    } else {
  		bank++;
! 		SetVGAPage(bank);
  		offset &= (mach32BankSize-1);
  		curvm = &mach32VideoMem[offset];
  		BusToMem(psrc, curvm, w);
--- 418,424 ----
  		curvm = &mach32VideoMem[offset];
  	    } else {
  		bank++;
! 		mach32SetVGAPage(bank);
  		offset &= (mach32BankSize-1);
  		curvm = &mach32VideoMem[offset];
  		BusToMem(psrc, curvm, w);
***************
*** 403,409 ****
  }
  
  static void
! mach32ImageReadNoMem(x, y, w, h, psrc, pwidth, px, py)
      int			x;
      int			y;
      int			w;
--- 436,442 ----
  }
  
  static void
! mach32ImageReadNoMem(x, y, w, h, psrc, pwidth, px, py, planemask)
      int			x;
      int			y;
      int			w;
***************
*** 412,417 ****
--- 445,451 ----
      int			pwidth;
      int			px;
      int			py;
+     short		planemask;
  {
      int	j;
      int	i;
***************
*** 418,428 ****
      short   pix;
      
      WaitIdleEmpty();
      outw(FRGD_MIX, FSS_PCDATA | MIX_SRC);
      outw(CUR_X, (short)x);
      outw(CUR_Y, (short)y);
!     outw(MAJ_AXIS_PCNT, (short)w-1);
!     outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
      
      outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | PCDATA);
      
--- 452,463 ----
      short   pix;
      
      WaitIdleEmpty();
+     outw(MULTIFUNC_CNTL, PIX_CNTL | 0);
      outw(FRGD_MIX, FSS_PCDATA | MIX_SRC);
      outw(CUR_X, (short)x);
      outw(CUR_Y, (short)y);
!     outw(MAJ_AXIS_PCNT, (short)(w - 1));
!     outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | (h - 1));
      
      outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | PCDATA);
      
***************
*** 434,440 ****
      for (j = 0; j < h; j++) {
  	for (i = px; i < w; i++) {
  	    pix = inw(PIX_TRANS);
! 	    psrc[i] = (char)pix;
  	}
  	psrc += pwidth;
      }
--- 469,475 ----
      for (j = 0; j < h; j++) {
  	for (i = px; i < w; i++) {
  	    pix = inw(PIX_TRANS);
! 	    psrc[i] = (unsigned char)(pix & planemask);
  	}
  	psrc += pwidth;
      }
***************
*** 444,450 ****
  }
  
  
- 
  static void
  mach32ImageFill(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, alu, planemask)
      int			x;
--- 479,484 ----
***************
*** 673,683 ****
      short		alu;
      short		planemask;
  {
!     int 		i,j;
      unsigned char	*pline;
!     int			x1, x2, y1, y2, width, pix, ypix, need;
!     short		data;
!     short		lo, hi;
      unsigned char	*newsrc = NULL, *newline;
  
      if ((w == 0) || (h == 0))
--- 707,715 ----
      short		alu;
      short		planemask;
  {
!     int 		i;
      unsigned char	*pline;
!     int			x1, x2, y1, y2, width;
      unsigned char	*newsrc = NULL, *newline;
  
      if ((w == 0) || (h == 0))
***************
*** 694,700 ****
      width = x2 - x1;
  
      if (pw <= 8) {
! 	newsrc = (unsigned char *)malloc(2*ph*sizeof(char));
  	if (!newsrc) {
  	    return;
  	}
--- 726,732 ----
      width = x2 - x1;
  
      if (pw <= 8) {
! 	newsrc = (unsigned char *)ALLOCATE_LOCAL(2*ph*sizeof(char));
  	if (!newsrc) {
  	    return;
  	}
***************
*** 799,805 ****
      outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
  
      if (newsrc)
! 	free(newsrc);
  }
  
  void
--- 831,837 ----
      outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
  
      if (newsrc)
! 	DEALLOCATE_LOCAL(newsrc);
  }
  
  void
***************
*** 819,829 ****
      short		alu;
      short		planemask;
  {
!     int 		i,j;
      unsigned char	*pline;
!     int			x1, x2, y1, y2, width, pix, ypix, need;
!     short		data;
!     short		lo, hi;
      unsigned char	*newsrc = NULL, *newline;
  
      if ((w == 0) || (h == 0))
--- 851,859 ----
      short		alu;
      short		planemask;
  {
!     int 		i;
      unsigned char	*pline;
!     int			x1, x2, y1, y2, width;
      unsigned char	*newsrc = NULL, *newline;
  
      if ((w == 0) || (h == 0))
***************
*** 840,846 ****
      width = x2 - x1;
  
      if (pw <= 8) {
! 	newsrc = (unsigned char *)malloc(2*ph*sizeof(char));
  	if (!newsrc) {
  	    return;
  	}
--- 870,876 ----
      width = x2 - x1;
  
      if (pw <= 8) {
! 	newsrc = (unsigned char *)ALLOCATE_LOCAL(2*ph*sizeof(char));
  	if (!newsrc) {
  	    return;
  	}
***************
*** 945,949 ****
      outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
  
      if (newsrc)
! 	free(newsrc);
  }
--- 975,979 ----
      outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
  
      if (newsrc)
! 	DEALLOCATE_LOCAL(newsrc);
  }
diff -c mit/server/ddx/x386/accel/mach32/mach32init.c:2.7 mit/server/ddx/x386/accel/mach32/mach32init.c:2.19
*** mit/server/ddx/x386/accel/mach32/mach32init.c:2.7	Fri Mar 11 23:37:14 1994
--- mit/server/ddx/x386/accel/mach32/mach32init.c	Fri Mar 11 23:37:14 1994
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32init.c,v 2.7 1993/10/06 14:54:32 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32init.c,v 2.19 1994/02/27 05:20:32 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 35,44 ****
--- 35,50 ----
  #include "xf86_Config.h"
  
  extern Bool x386Verbose;
+ extern int  mach32MaxClock;
+ 
  static LUTENTRY oldlut[256];
  static Bool LUTInited = FALSE;
  
  static short old_DAC_MASK;
+ static short old_DAC_in_clock;
+ static short old_DAC_out_clock;
+ static short old_DAC_mux_clock;
+ static short old_clock_sel;
  
  static Bool mach32Inited = FALSE;
  
***************
*** 47,56 ****
  static char old_ATI2E, old_ATI32, old_ATI36;
  static char old_GRA06, old_SEQ02, old_SEQ04;
  
! static short old_MEM_BNDRY;
  
  int mach32VideoPageBoundary[MACH32_MAX_Y+1];
  
  /*	mach32CalcCRTCRegs(crtcRegs, mode)
  
  	Initializes the Mach32 for the currently selected CRTC parameters.
--- 53,68 ----
  static char old_ATI2E, old_ATI32, old_ATI36;
  static char old_GRA06, old_SEQ02, old_SEQ04;
  
! static unsigned short old_MEM_BNDRY;
! static unsigned short old_MISC_OPTIONS;
! static unsigned short old_EXT_GE_CONFIG;
! static unsigned short old_MISC_CNTL;
! extern unsigned short mach32MemorySize;
  
  int mach32VideoPageBoundary[MACH32_MAX_Y+1];
  
+ extern void mach32SetVGAPage();
+ 
  /*	mach32CalcCRTCRegs(crtcRegs, mode)
  
  	Initializes the Mach32 for the currently selected CRTC parameters.
***************
*** 93,98 ****
--- 105,113 ----
      if (mode->Flags & V_INTERLACE) crtcRegs->disp_cntl |= INTERLACE;
  
      crtcRegs->clock_sel = (mode->Clock << 2) | VFIFO_DEPTH_6 | DISABPASSTHRU;
+     if (mode->Flags & V_CSYNC) crtcRegs->clock_sel |= COMPOSITE_SYNC;
+     if (OFLG_ISSET(OPTION_CSYNC, &mach32InfoRec.options))
+ 	crtcRegs->clock_sel |= COMPOSITE_SYNC;
  }
  
  /*	mach32SetCRTCRegs(crtcRegs)
***************
*** 102,120 ****
  void mach32SetCRTCRegs(crtcRegs)
       mach32CRTCRegPtr crtcRegs;
  {
-     /* Blank the screen temporarily to display color 0 by turning the
-      * display of all planes off
-      */
-     outb(DAC_MASK, 0x00);
  
      /*
       * Reset controller while setting CRTC registers
       * This is recommended by the mach32 programmer's guide
-      *
-      * (Setting the DAC_MASK to 0 above is probably useless now
-      *  that this is here, but it doesn't hurt)
       */
      outb(DISP_CNTL, DISPEN_DISAB);
  
      /* Now initialize the display controller part of the Mach32.
       * The CRTC registers are passed in from the calling routine.
--- 117,130 ----
  void mach32SetCRTCRegs(crtcRegs)
       mach32CRTCRegPtr crtcRegs;
  {
  
      /*
       * Reset controller while setting CRTC registers
       * This is recommended by the mach32 programmer's guide
       */
+     WaitQueue(1);
      outb(DISP_CNTL, DISPEN_DISAB);
+     WaitIdleEmpty();
  
      /* Now initialize the display controller part of the Mach32.
       * The CRTC registers are passed in from the calling routine.
***************
*** 134,151 ****
  
      /* Set the width of the display -- useful for future extensions */
      outw(CRT_PITCH, mach32VirtX >> 3);
      outw(GE_PITCH,  mach32VirtX >> 3);
  
      /* Clock select register */
      outw(CLOCK_SEL, crtcRegs->clock_sel);
  
      /* Display control register -- this one turns on the display */
      outb(DISP_CNTL, crtcRegs->disp_cntl);
- 
-     /* Now reenable the screen, but only the planes that actually exist.
-      * Otherwise, you end up with bus noise on the display.
-      */
-     outb(DAC_MASK, 0xff);
  }
  
  /*	mach32SaveLUT(lut)
--- 144,165 ----
  
      /* Set the width of the display -- useful for future extensions */
      outw(CRT_PITCH, mach32VirtX >> 3);
+ 
      outw(GE_PITCH,  mach32VirtX >> 3);
  
      /* Clock select register */
      outw(CLOCK_SEL, crtcRegs->clock_sel);
  
+     /* Zero overscan register to insure proper color */
+     outw(HORZ_OVERSCAN, 0);
+     outw(VERT_OVERSCAN, 0);
+ 
+     /* Set the DAC for the currect mode */
+     mach32SetRamdac(crtcRegs->clock_sel);
+ 
      /* Display control register -- this one turns on the display */
+     WaitIdleEmpty();
      outb(DISP_CNTL, crtcRegs->disp_cntl);
  }
  
  /*	mach32SaveLUT(lut)
***************
*** 257,279 ****
      int screen_idx;
  {
      int i;
-     int fd;
  
      if (!mach32VideoMem) {
  	if (mach32Use4MbAperture) {
  	    int apaddr;
  
! 	    apaddr = inw(MEM_CFG) >> 8;
! 	    if (!apaddr)
  		apaddr = 0x7c;
  	    if (x386Verbose) {
! 		ErrorF("%s %s: Aperture mapped to 0x%x\n", XCONFIG_PROBED,
! 		       mach32InfoRec.name, apaddr << 20);
  	    }
! 	    outw(MEM_CFG, (apaddr << 8) | 0x02);
  
  	    mach32VideoMem = xf86MapVidMem(screen_idx, LINEAR_REGION, 
! 					   (pointer)(apaddr << 20),
  					   4 * 1024 * 1024);
  
  	    /* Initialize the mach32VideoPageBoundary array */
--- 271,312 ----
      int screen_idx;
  {
      int i;
  
      if (!mach32VideoMem) {
  	if (mach32Use4MbAperture) {
  	    int apaddr;
+ 	    int mem_cfg_shift;
+ 	    unsigned long hw_offset = 0;
+ 
+ 	    /* For PCI, there is no hw_offset */
+ 	    if (mach32BusType != PCI) {
+ 		if (OFLG_ISSET(OPTION_INTEL_GX, &mach32InfoRec.options)) {
+ 		    hw_offset = 0x78000000;
+ 		} else if (mach32InfoRec.MemBase != 0) {
+ 		    hw_offset = mach32InfoRec.MemBase & 0xf8000000;
+ 		}
+ 	    }
+ 
+ 	    if (mach32BusType == PCI)
+ 		mem_cfg_shift = 4;
+ 	    else
+ 		mem_cfg_shift = 8;
  
! 	    apaddr = inw(MEM_CFG) >> mem_cfg_shift;
! 
! 	    if (!apaddr && !hw_offset)
  		apaddr = 0x7c;
  	    if (x386Verbose) {
! 		ErrorF("%s %s: Aperture mapped to 0x%x + 0x%x\n",
! 		       XCONFIG_PROBED, mach32InfoRec.name, apaddr << 20,
! 		       hw_offset);
  	    }
! 	    /* XXXX probably should restore MEM_CFG at exit */
! 	    outw(MEM_CFG, (apaddr << mem_cfg_shift) | 0x02);
  
  	    mach32VideoMem = xf86MapVidMem(screen_idx, LINEAR_REGION, 
! 					   (pointer)((apaddr << 20) +
! 						     hw_offset),
  					   4 * 1024 * 1024);
  
  	    /* Initialize the mach32VideoPageBoundary array */
***************
*** 289,294 ****
--- 322,328 ----
  
  	    /* Initialize the mach32VideoPageBoundary array */
  	    for (i = 0; i <= mach32MaxY; i++) {
+ 
  		mach32VideoPageBoundary[i] = 65536 -
  		    ((i*mach32VirtX) - ((i*mach32VirtX)&0xffff0000));
  		if (mach32VideoPageBoundary[i] >= mach32MaxX)
***************
*** 298,303 ****
--- 332,421 ----
      }
  }
  
+ /*
+  * From the _Programmer's Guide to the mach32 Registers_:
+  * MISC_CNTL[8:9]   BLANK_ADJUST Type 2 DAC only:  Delays BLANK by 1 or 2 PCLK
+  * MISC_CNTL[10:11] PIXEL_DELAY  Adjusts pixel data skew from PCLK (adjusts
+  *                               setup and hold times to suit different DACs)
+  *
+  * So x should have blank adjust in bits 0:1; pixel delay in 2:3.
+  */
+ #define	SET_BLANK_ADJ(x)	{\
+ 	unsigned short tmp; \
+ 	tmp = inw(R_MISC_CNTL) & 0xf0f0; \
+ 	outw(MISC_CNTL, tmp | (((x) & 0x0f) << 8)); \
+ }
+ 
+ void mach32SetRamdac(clock)
+     int clock;
+ {
+     int	old_EXT_GE_CONFIG;
+ 
+     switch(mach32Ramdac) {
+ 
+     case DAC_TLC34075:
+ 	/* get the current value */
+ 	old_EXT_GE_CONFIG = inw(R_EXT_GE_CONFIG) & ~0x3100;
+ 	
+ 	if (mach32InfoRec.clock[(clock >> 2) & 0xf] > 80000) {
+ 	    
+ 	    /* Guarantee low pixel clock */
+ 	    outw(CLOCK_SEL, 0x11);
+ 
+ 	    /* Make sure that upper 2 address bit are ok */
+ 	    outw(EXT_GE_CONFIG, old_EXT_GE_CONFIG | 0x2000);
+ 
+ 	    /* pixel clock is SCLK/2 and VCLK/2 */
+ 	    outb(OUTPUT_CLK_SEL, 0x09);
+ 
+ 	    /* set MUX contol 8/16 to 16 */
+ 	    outb(MUX_CNTL, 0x1d);
+ 
+ 	    /* Set clock source */
+ 	    outb(INPUT_CLK_SEL, 1);
+ 
+ 	    /* set multiplex_pixels */
+ 	    outw(EXT_GE_CONFIG, old_EXT_GE_CONFIG | 0x0100);
+ 
+ 	    /*set the blank adj and pixel delay values */
+ 	    SET_BLANK_ADJ(1);
+ 
+ 	    /* allow all 8 bit to go though dac */
+ 	    outb(DAC_MASK, 0xff);
+ 
+ 	    /* restore the pixel clock */
+ 	    outw(CLOCK_SEL, clock);
+ 	} else {
+ 	    /* Guarantee low pixel clock */
+ 	    outw(CLOCK_SEL, 0x11);
+ 
+ 	    /*set the blank adj and pixel delay values */
+ 	    SET_BLANK_ADJ(0x0c);
+ 
+ 	    /* Make sure that upper 2 address bit are ok */
+ 	    outw(EXT_GE_CONFIG, old_EXT_GE_CONFIG | 0x2000);
+ 
+ 	    /* Set clock source */
+ 	    outb(INPUT_CLK_SEL, 0);
+ 
+ 	    /* pixel clock is SCLK/1 and VCLK */
+ 	    outb(OUTPUT_CLK_SEL, 0x30);
+ 
+ 	    /* set MUX contol 8/16 to 16 */
+ 	    outb(MUX_CNTL, 0x2d);
+ 
+ 	    /* allow all 8 bit to go though dac none mux */
+ 	    outw(EXT_GE_CONFIG, old_EXT_GE_CONFIG);
+ 
+ 	    outb(DAC_MASK, 0xff);
+ 
+ 	    /* restore the pixel clock */
+ 	    outw(CLOCK_SEL, clock);
+ 	}
+ 	break;
+     }
+ }
+ 
  /*	mach32InitDisplay(screen_idx)
  
  	Initializes the display for the Mach32.
***************
*** 330,342 ****
      /* Set the VGA display buffer to 0xa0000 */
      outw(VGAGRA, GRA06 | 0x05 << 8);
  
!     SetVGAPage(0);
  
      old_DAC_MASK = inb(DAC_MASK);
  
      old_MEM_BNDRY = inw(MEM_BNDRY);
      outw(MEM_BNDRY, 0); /* Turn off the memory boundary */
  
      /* Reset the 8514/A, and disable all interrupts. */
      outw(SUBSYS_CNTL, GPCTRL_RESET | CHPTEST_NORMAL);
      outw(SUBSYS_CNTL, GPCTRL_ENAB | CHPTEST_NORMAL);
--- 448,483 ----
      /* Set the VGA display buffer to 0xa0000 */
      outw(VGAGRA, GRA06 | 0x05 << 8);
  
!     mach32SetVGAPage(0);
! 
!     old_MISC_CNTL = inw(R_MISC_CNTL);
!     old_EXT_GE_CONFIG = inw(R_EXT_GE_CONFIG);
  
+     outw(EXT_GE_CONFIG, old_EXT_GE_CONFIG & ~0x3000);
      old_DAC_MASK = inb(DAC_MASK);
  
      old_MEM_BNDRY = inw(MEM_BNDRY);
      outw(MEM_BNDRY, 0); /* Turn off the memory boundary */
+     old_MISC_OPTIONS = inw(MISC_OPTIONS);
+     outw(MISC_OPTIONS, (old_MISC_OPTIONS & ~MEM_SIZE_ALIAS) | mach32MemorySize);
+ 
+     old_clock_sel = inw(CLOCK_SEL);
  
+     switch(mach32Ramdac) {
+ 
+     case DAC_TLC34075:
+ 	outw(EXT_GE_CONFIG, (old_EXT_GE_CONFIG & ~0x3000) | 0x2000);
+ 	outw(CLOCK_SEL, 0x11);
+ 
+ 	old_DAC_in_clock = inb(INPUT_CLK_SEL);
+ 	old_DAC_out_clock = inb(OUTPUT_CLK_SEL);
+ 	old_DAC_mux_clock = inb(MUX_CNTL);
+ 
+ 	outw(EXT_GE_CONFIG, (old_EXT_GE_CONFIG & ~0x3000));
+ 	outw(CLOCK_SEL, old_clock_sel);
+ 	break;
+     }
+ 
      /* Reset the 8514/A, and disable all interrupts. */
      outw(SUBSYS_CNTL, GPCTRL_RESET | CHPTEST_NORMAL);
      outw(SUBSYS_CNTL, GPCTRL_ENAB | CHPTEST_NORMAL);
***************
*** 356,361 ****
--- 497,505 ----
      outw(SHADOW_CTL, 0);
      outw(SHADOW_SET, 0);
  
+     if (mach32DAC8Bit)
+ 	outw(EXT_GE_CONFIG, old_EXT_GE_CONFIG | DAC_8_BIT_EN);
+ 
      WaitIdleEmpty(); /* Make sure that all commands have finished */
  
      mach32Inited = TRUE;
***************
*** 367,377 ****
  */
  void mach32CleanUp()
  {
-     int i;
- 
      if (!mach32Inited)
  	return;
  
      outw(SHADOW_SET, 1);
      outw(SHADOW_CTL, 0x3f);
      outw(SHADOW_SET, 2);
--- 511,534 ----
  */
  void mach32CleanUp()
  {
      if (!mach32Inited)
  	return;
  
+     switch(mach32Ramdac) {
+ 
+     case DAC_TLC34075:
+ 	SET_BLANK_ADJ(0x0c);
+ 	outw(CLOCK_SEL, 0x11);
+ 	outw(EXT_GE_CONFIG, (old_EXT_GE_CONFIG & ~0x3000) | 0x2000);
+ 	outb(INPUT_CLK_SEL, old_DAC_in_clock);
+ 	outb(OUTPUT_CLK_SEL, old_DAC_out_clock);
+ 	outb(MUX_CNTL, old_DAC_mux_clock);
+ 	outw(EXT_GE_CONFIG, old_EXT_GE_CONFIG & ~0x3000);
+ 	outb(DAC_MASK, 0xff);
+ 	outw(CLOCK_SEL, old_clock_sel);
+ 	break;
+     }
+ 
      outw(SHADOW_SET, 1);
      outw(SHADOW_CTL, 0x3f);
      outw(SHADOW_SET, 2);
***************
*** 391,398 ****
--- 548,559 ----
      outw(VGASEQ, SEQ02 | old_SEQ02 << 8);
      outw(VGASEQ, SEQ04 | old_SEQ04 << 8);
  
+     outw(EXT_GE_CONFIG, (old_EXT_GE_CONFIG & ~0x3000));
      outb(DAC_MASK, old_DAC_MASK);
      outw(MEM_BNDRY, old_MEM_BNDRY);
+     outw(MISC_OPTIONS, old_MISC_OPTIONS);
+ 
+     outw(MISC_CNTL, old_MISC_CNTL);
  
      WaitIdleEmpty(); /* Make sure that all commands have finished */
  
***************
*** 402,407 ****
--- 563,569 ----
      outw(CRT_OFFSET_HI, 0);
  
      mach32CursorOff();
+ 
  
      mach32RestoreVGAInfo();
  
diff -c mit/server/ddx/x386/accel/mach32/mach32line.c:2.4 mit/server/ddx/x386/accel/mach32/mach32line.c:2.6
*** mit/server/ddx/x386/accel/mach32/mach32line.c:2.4	Fri Mar 11 23:37:15 1994
--- mit/server/ddx/x386/accel/mach32/mach32line.c	Fri Mar 11 23:37:15 1994
***************
*** 13,33 ****
  used in advertising or publicity pertaining to distribution of the
  software without specific, written prior permission.  
  
! DIGITAL AND KEVIN E. MARTIN AND RICKARD E. FAITH DISCLAIM ALL WARRANTIES
! WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
! MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL OR KEVIN E. MARTIN
! 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.
  
  Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
  Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
  Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32line.c,v 2.4 1993/09/21 15:21:39 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 13,36 ----
  used in advertising or publicity pertaining to distribution of the
  software without specific, written prior permission.  
  
! DIGITAL AND KEVIN E. MARTIN AND RICKARD E. FAITH AND CRAIG E. GROESCHEL
! DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
! WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL OR
! KEVIN E. MARTIN OR RICKARD E. FAITH OR CRAIG E. GROESCHEL 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.
  
  Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
  Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
  Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
+ mach32Line1Rect by Craig E. Groeschel (craig@adikia.sccsi.com),
+   based on an ATI preclipping code example
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32line.c,v 2.6 1994/03/01 09:51:35 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 86,92 ****
--- 89,99 ----
  
  
  void
+ #ifdef ONE_RECT
+ mach32Line1Rect(pDrawable, pGC, mode, npt, pptInit)
+ #else
  mach32Line(pDrawable, pGC, mode, npt, pptInit)
+ #endif
      DrawablePtr pDrawable;
      GCPtr	pGC;
      int		mode;		/* Origin or Previous */
***************
*** 102,109 ****
      unsigned int oc1;		/* outcode of point 1 */
      unsigned int oc2;		/* outcode of point 2 */
  
-     unsigned long *addrl;		/* address of destination pixmap */
-     int nlwidth;		/* width in longwords of destination pixmap */
      int xorg, yorg;		/* origin of window */
  
      int adx;		/* abs values of dx and dy */
--- 109,114 ----
***************
*** 123,134 ****
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int		    alu;
  
      if (!x386VTSema)
      {
  	cfbLineSS(pDrawable, pGC, mode, npt, pptInit);
  	return;
      }
  
--- 128,141 ----
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
  
      if (!x386VTSema)
      {
+ #ifdef ONE_RECT
+ 	cfb8LineSS1Rect(pDrawable, pGC, mode, npt, pptInit);
+ #else
  	cfbLineSS(pDrawable, pGC, mode, npt, pptInit);
+ #endif
  	return;
      }
  
***************
*** 137,143 ****
--- 144,159 ----
      pboxInit = REGION_RECTS(cclip);
      nboxInit = REGION_NUM_RECTS(cclip);
  
+ #ifdef ONE_RECT
+     WaitQueue(11);
+     outw(LINEDRAW_OPT, CLIP_MODE_1 | LASTPIX);
+     outw(EXT_SCISSOR_L, pboxInit->x1);
+     outw(EXT_SCISSOR_T, pboxInit->y1);
+     outw(EXT_SCISSOR_R, pboxInit->x2-1);
+     outw(EXT_SCISSOR_B, pboxInit->y2-1);
+ #else
      WaitQueue(3);
+ #endif
      outw(FRGD_MIX, FSS_FRGDCOL | mach32alu[pGC->alu]);
      outw(WRT_MASK, (short)pGC->planemask);
      outw(FRGD_COLOR, (short)pGC->fgPixel);
***************
*** 147,157 ****
      ppt = pptInit;
      x2 = ppt->x + xorg;
      y2 = ppt->y + yorg;
      while(--npt)
      {
! 	nbox = nboxInit;
! 	pbox = pboxInit;
! 
  	x1 = x2;
  	y1 = y2;
  	++ppt;
--- 163,229 ----
      ppt = pptInit;
      x2 = ppt->x + xorg;
      y2 = ppt->y + yorg;
+ #ifdef ONE_RECT
+     outw(LINEDRAW_INDEX, 0);	/* reset the state machine; set current x,y */
+     outw(LINEDRAW, x2);
+     outw(LINEDRAW, y2);
+ #endif
+ 
      while(--npt)
      {
! #ifdef ONE_RECT
!       /* Send a burst of endpoints before checking for a clip exception */
!       int overrun;
!       int nburst = min(14, npt);
!       npt -= nburst - 1;
! 
!       while (nburst--)
!       {
! #endif
! 	x1 = x2;
! 	y1 = y2;
! 	++ppt;
! 	if (mode == CoordModePrevious)
! 	{
! 	    xorg = x1;
! 	    yorg = y1;
! 	}
! 	x2 = ppt->x + xorg;
! 	y2 = ppt->y + yorg;
! #ifdef ONE_RECT
! 	WaitQueue(2);
! 	outw(LINEDRAW, x2);	/* write destination x,y; draw line */
! 	outw(LINEDRAW, y2);
!       } /* while (nburst--) */
! 
!       WaitIdleEmpty();	/* 8-( */
! /*
!  * Read CLIP_OVERRUN and, if an exception has occurred, put the endpoints
!  * of the offending line into (x1, y1),(x2, y2) and let the software
!  * clip and draw.
!  */
!       if ((overrun = (inw(EXT_GE_STATUS) & 0x0f))) {
! 	ppt -= overrun;
! 
! 	/* Put the start point of the line that caused the clip exception
! 	 * into (x2, y2).  If (mode == CoordModePrevious), we have to start
! 	 * from the beginning (pptInit) to calculate xorg and yorg.
! 	 */
! 	x2 = pDrawable->x;
! 	y2 = pDrawable->y;
! 	if (mode == CoordModePrevious) {
! 	    DDXPointPtr ppt_tmp;
! 	    for (ppt_tmp = pptInit; ppt_tmp != ppt; ppt_tmp++) {
! 		xorg = x2;
! 		yorg = y2;
! 		x2 = ppt_tmp->x + xorg;
! 		y2 = ppt_tmp->y + yorg;
! 	    }
! 	}
! 	x2 += ppt->x;
! 	y2 += ppt->y;
!         
! 	/* Now draw the line that caused the clip exception. */
  	x1 = x2;
  	y1 = y2;
  	++ppt;
***************
*** 162,167 ****
--- 234,243 ----
  	}
  	x2 = ppt->x + xorg;
  	y2 = ppt->y + yorg;
+ #endif
+ 
+ 	nbox = nboxInit;
+ 	pbox = pboxInit;
  
  	if (x1 == x2)
  	{
***************
*** 422,428 ****
  		}
  	    } /* while (nbox--) */
  	} /* sloped line */
!     } /* while (nline--) */
  
      /* paint the last point if the end style isn't CapNotLast.
         (Assume that a projecting, butt, or round cap that is one
--- 498,519 ----
  		}
  	    } /* while (nbox--) */
  	} /* sloped line */
! #ifdef ONE_RECT
! 	npt += overrun - 1;
! 	WaitQueue(3);
! 	outw(LINEDRAW_INDEX, 0);  /* clear CLIP_OVERRUN; write current x,y */
! 	outw(LINEDRAW, x2);
! 	outw(LINEDRAW, y2);
!       } /* if (overrun) */
! #endif
!     } /* while (--npt) */
! 
! #ifdef ONE_RECT
!     WaitQueue(10);
!     outw(LINEDRAW_OPT, CLIP_MODE_0);
! #else
!     WaitQueue(5);
! #endif
  
      /* paint the last point if the end style isn't CapNotLast.
         (Assume that a projecting, butt, or round cap that is one
***************
*** 443,449 ****
  		(x2 <  pbox->x2) &&
  		(y2 <  pbox->y2))
  	    {
- 		WaitQueue(4);
  		outw(CUR_X, (short)x2);
  		outw(CUR_Y, (short)y2);
  		outw(MAJ_AXIS_PCNT, 0);
--- 534,539 ----
***************
*** 456,464 ****
  	}
      }
  
!     WaitQueue(2);
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
-     outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
  
      WaitIdleEmpty(); /* Make sure that all commands have finished */
  }
--- 546,558 ----
  	}
      }
  
! #ifdef ONE_RECT
!     outw(EXT_SCISSOR_L, 0);
!     outw(EXT_SCISSOR_T, 0);
!     outw(EXT_SCISSOR_R, mach32MaxX);
!     outw(EXT_SCISSOR_B, mach32MaxY);
! #endif
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
  
      WaitIdleEmpty(); /* Make sure that all commands have finished */
  }
diff -c /dev/null mit/server/ddx/x386/accel/mach32/mach32mem.c:2.3
*** /dev/null	Fri Mar 11 23:37:16 1994
--- mit/server/ddx/x386/accel/mach32/mach32mem.c	Fri Mar 11 23:37:16 1994
***************
*** 0 ****
--- 1,391 ----
+ /*
+  * Copyright 1993 ATI
+  *
+  * Used by XFree86 with permission
+  *
+  * Modified heavily by Mark_Weaver@brown.edu for XFree86
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32mem.c,v 2.3 1994/02/10 21:24:51 dawes Exp $ */
+ 
+ 
+ #include "compiler.h"
+ #include "mach32.h"
+ 
+ #ifdef NEW_MEM_DETECT
+ 
+ static void SetupRestoreEngine_m();
+ static unsigned short ReadPixel_m();
+ static void WritePixel_m();
+ 
+ /*
+  * Private definitions
+  */
+ #define SETUP_ENGINE    0
+ #define RESTORE_ENGINE  1
+ 
+ #define MAX_TEST_PIXELS 4
+ 
+ typedef unsigned short MyPixel;
+ 
+ static struct {
+     int memSize;		/* Mem in kb if this test succeeds */
+     struct {
+ 	short x, y;		/* One entry for each pixel */
+     } pt[MAX_TEST_PIXELS + 1];	/* Terminated by x < 0 */
+ } testCases[] = {
+     /*
+      * Given the engine settings used, only a 4M card will have
+      * enough memory to back up the 1025th line of the display.
+      * Since the pixel coordinates are zero-based, line 1024 will
+      * be the first one which is only backed on 4M cards.
+      *
+      * <Mark_Weaver@brown.edu>:
+      * In case memory is being wrapped, (0,0) and (0,1024)
+      * to make sure they can each hold a unique value.
+      */
+     {4096, {{0,0}, {0,1024}, {-1,-1}}},
+ 
+     /*
+      * We know this card has 2M or less. On a 1M card, the first 2M
+      * of the card's memory will have even doublewords backed by
+      * physical memory and odd doublewords unbacked.
+      *
+      * Pixels 0 and 1 of a row will be in the zeroth doubleword, while
+      * pixels 2 and 3 will be in the first. Check both pixels 2 and 3
+      * in case this is a pseudo-1M card (one chip pulled to turn a 2M
+      * card into a 1M card).
+      *
+      * <Mark_Weaver@brown.edu>:
+      * I don't have a 1M card, so I'm taking a stab in the dark.
+      * Maybe memory wraps every 512 lines, or maybe odd doublewords
+      * are aliases of their even doubleword counterparts.  I try
+      * everything here.
+      */
+     {2048, {{0,0}, {0,512}, {2,0}, {3,0}, {-1,-1}}},
+ 
+     /*
+      * This is a either a 1M card or a 512k card. Test pixel 1, since
+      * it is an odd word in an even doubleword.
+      *
+      * NOTE: We have not received 512k cards for testing - this is an
+      *       extrapolation of the 1M/2M determination code.
+      *
+      * <Mark_Weaver@brown.edu>:
+      * This is the same idea as the test above.
+      */
+     {1024, {{0,0}, {0,256}, {1,0}, {-1,-1}}},
+ 
+     /*
+      * We assume it is a 512k card by default, since that is the
+      * minimum configuration.
+      */
+     {512, {{-1,-1}}}
+ };
+ 
+ #define NUM_TEST_CASES (sizeof(testCases) / sizeof(testCases[0]))
+ 
+ /*
+  * Bit patterns which are extremely unlikely to show up when reading
+  * from nonexistant memory (which normally shows up as either all
+  * bits set or all bits clear).
+  */
+ 
+ static MyPixel testColor[MAX_TEST_PIXELS]={0x5aa5, 0x55aa, 0xa55a, 0xca53};
+ 
+ 
+ /***************************************************************************
+  *
+  * int mach32GetMemSize(void);
+  *
+  * DESCRIPTION:
+  *  Determine the amount of video memory installed on the graphics card.
+  *  This is done because the 68800-6 contains a bug which causes MISC_OPTIONS
+  *  to report 1M rather than the true amount of memory.
+  *
+  * RETURN VALUE:
+  *  Amount of memory in kb
+  *
+  * GLOBALS CHANGED:
+  *  none
+  *
+  * BASED ON CODE BY:
+  *  Robert Wolff
+  *
+  * CHANGE HISTORY:
+  *  Modified for use with XFree86 (David Dawes)
+  *  Rewritten for XFree86 (Mark_Weaver@brown.edu)
+  *
+  * TEST HISTORY:
+  *
+  ***************************************************************************/
+ 
+ /*
+  * I believe that redundancy is the root of all evil in the world.
+  * These are few macros to make things below little less redundant.
+  * <Mark_Weaver@brown.edu>
+  */
+ #define TestPixel testCases[caseNum].pt[pixelNum]
+ #define ForEachTestPixel \
+     for (pixelNum = 0; TestPixel.x >= 0; ++pixelNum)
+ 
+ int mach32GetMemSize()
+ {
+     MyPixel savedPixel[MAX_TEST_PIXELS];
+     int caseNum, pixelNum;
+     int success;
+ 
+     /*
+      * Switch into accelerator mode, and initialize the engine to
+      * a pitch of 1024 pixels in 16BPP.
+      */
+     SetupRestoreEngine_m(SETUP_ENGINE);
+ 
+     for (caseNum = 0; caseNum < NUM_TEST_CASES; ++caseNum) {
+ 	/*
+ 	 * If you're confused, see the #defines above this routine
+ 	 */
+ 
+ 	/* Save all the pixel values */
+ 	ForEachTestPixel
+ 	    savedPixel[pixelNum] = ReadPixel_m(TestPixel.x, TestPixel.y);
+ 
+ 	/* Write the test patterns */
+ 	ForEachTestPixel
+ 	    WritePixel_m(TestPixel.x, TestPixel.y, testColor[pixelNum]);
+ 	
+ 	/* See if any of the pixels forgot what we wrote */
+ 	success = 1;
+ 	ForEachTestPixel {
+ 	    if (ReadPixel_m(TestPixel.x, TestPixel.y) != testColor[pixelNum])
+ 		success = 0;
+ 	}
+ 
+ 	/* Regardless of the outcome, restore all the values */
+ 	ForEachTestPixel
+ 	    WritePixel_m(TestPixel.x, TestPixel.y, savedPixel[pixelNum]);
+ 
+ 	if (success) {
+ 	    /*
+ 	     * If the test was successful, we're done.
+ 	     * Restore the engine, and return the appropriate value
+ 	     */
+ 	    SetupRestoreEngine_m(RESTORE_ENGINE);
+ 	    return testCases[caseNum].memSize;
+ 	}
+     }
+ 
+     /*
+      * We shouldn't ever get here.  But just in case we do.
+      */
+     SetupRestoreEngine_m(RESTORE_ENGINE);
+     return 512;
+ 
+ }
+ 
+ #undef TestPixel
+ #undef ForEachTestPixel
+ 
+ /***************************************************************************
+  *
+  * void SetupRestoreEngine_m(DesiredStatus);
+  *
+  * int DesiredStatus;   Whether the user wants to set up or restore
+  *
+  * DESCRIPTION:
+  *  Set engine to 1024 pitch 16BPP with 512k of VGA memory,
+  *  or restore the engine and boundary status, as selected by the user.
+  *
+  * GLOBALS CHANGED:
+  *  none
+  *
+  * CALLED BY:
+  *  GetTrueMemSize_m()
+  *
+  * AUTHOR:
+  *  Robert Wolff
+  *
+  * CHANGE HISTORY:
+  *
+  * TEST HISTORY:
+  *
+  ***************************************************************************/
+ static void SetupRestoreEngine_m(DesiredStatus)
+ int DesiredStatus;
+ {
+     static unsigned short MiscOptions;  /* Contents of MISC_OPTIONS register */
+     static unsigned short ExtGeConfig;  /* Contents of EXT_GE_CONFIG register */
+     static unsigned short MemBndry;     /* Contents of MEM_BNDRY register */
+     unsigned short tmp;
+ 
+ 
+     if (DesiredStatus == SETUP_ENGINE) {
+ 	
+ 	tmp = inw(CLOCK_SEL);
+ 	outw(CLOCK_SEL, tmp | 0x0001);
+         /* Passth8514_m(SHOW_ACCEL); */
+ 
+         /*
+          * Set up a 512k VGA boundary so "blue screen" writes that happen
+          * when we are in accelerator mode won't show up in the wrong place.
+          */
+         MemBndry = inw(MEM_BNDRY);     /* Set up shared memory */
+         outw(MEM_BNDRY, 0);
+ 
+         /*
+          * Save the contents of the MISC_OPTIONS register, then
+          * tell it that we have 4M of video memory. Otherwise,
+          * video memory will wrap when it hits the boundary
+          * in the MEM_SIZE_ALIAS field.
+          */
+         MiscOptions = inw(MISC_OPTIONS);
+         outw(MISC_OPTIONS, MiscOptions | MEM_SIZE_4M);
+ 
+         /*
+          * Set 16BPP with pitch of 1024. Only set up the drawing
+          * engine, and not the CRT, since the results of this test
+          * are not intended to be seen.
+          */
+         ExtGeConfig = inw(R_EXT_GE_CONFIG);
+         outw(EXT_GE_CONFIG, PIX_WIDTH_16BPP | ORDER_16BPP_565 | 0x000A);
+         outw(GE_PITCH, (1024 >> 3));
+         outw(GE_OFFSET_HI, 0);
+         outw(GE_OFFSET_LO, 0);
+     } else {   /* DesiredStatus == RESTORE_ENGINE */
+         /*
+          * Restore the memory boundary, MISC_OPTIONS register,
+          * and EXT_GE_CONFIG. It is not necessary to reset the
+          * drawing engine pitch and offset, because they don't
+          * affect what is displayed and they will be set to
+          * whatever values are needed when the desired video
+          * mode is set.
+          */
+         outw(EXT_GE_CONFIG, ExtGeConfig);
+         outw(MISC_OPTIONS, MiscOptions);
+         outw(MEM_BNDRY, MemBndry);
+ 
+         /*
+          * Give the VGA control of the screen.
+          */
+ 	tmp = inw(CLOCK_SEL);
+ 	outw(CLOCK_SEL, tmp & ~0x0001);
+         /* Passth8514_m(SHOW_VGA); */
+     }
+     return;
+ 
+ }   /* SetupRestoreEngine_m() */
+ 
+ 
+ 
+ /***************************************************************************
+  *
+  * MyPixel ReadPixel_m(XPos, YPos);
+  *
+  * short XPos;      X coordinate of pixel to read
+  * short YPos;      Y coordinate of pixel to read
+  *
+  * DESCRIPTION:
+  *  Read a single pixel from the screen.
+  *
+  * RETURN VALUE:
+  *  Colour of pixel at the desired location.
+  *
+  * GLOBALS CHANGED:
+  *  none
+  *
+  * CALLED BY:
+  *  GetTrueMemSize_m()
+  *
+  * AUTHOR:
+  *  Robert Wolff
+  *
+  * CHANGE HISTORY:
+  *
+  * TEST HISTORY:
+  *
+  ***************************************************************************/
+ 
+ static MyPixel ReadPixel_m(XPos, YPos)
+ short XPos, YPos;
+ {
+     MyPixel RetVal;
+ 
+     /*
+      * Don't read if the engine is busy.
+      */
+     WaitIdleEmpty();
+ 
+     /*
+      * Set up the engine to read colour data from the screen.
+      */
+     WaitQueue(7);
+     outw(RD_MASK, 0x0FFFF);
+     outw(DP_CONFIG, FG_COLOR_SRC_BLIT | DATA_WIDTH | DRAW | DATA_ORDER);
+     outw(CUR_X, XPos);
+     outw(CUR_Y, YPos);
+     outw(DEST_X_START, XPos);
+     outw(DEST_X_END, XPos+1);
+     outw(DEST_Y_END, YPos+1);
+ 
+     /*
+      * Wait for the engine to process the orders we just gave it and
+      * start asking for data.
+      */
+     WaitQueue(16);
+     while (!(inw(GE_STAT) & DATA_READY));
+ 
+     RetVal = inw(PIX_TRANS);
+     WaitIdleEmpty();
+     return RetVal;
+ 
+ }   /* ReadPixel_m() */
+ 
+ 
+ 
+ /***************************************************************************
+  *
+  * void WritePixel_m(XPos, YPos, Colour);
+  *
+  * short XPos;      X coordinate of pixel to read
+  * short YPos;      Y coordinate of pixel to read
+  * MyPixel Colour;  Colour to paint the pixel
+  *
+  * DESCRIPTION:
+  *  Write a single pixel to the screen.
+  *
+  * GLOBALS CHANGED:
+  *  none
+  *
+  * CALLED BY:
+  *  GetTrueMemSize_m()
+  *
+  * AUTHOR:
+  *  Robert Wolff
+  *
+  * CHANGE HISTORY:
+  *
+  * TEST HISTORY:
+  *
+  ***************************************************************************/
+ 
+ static void WritePixel_m(XPos, YPos, Colour)
+ short XPos, YPos;
+ MyPixel Colour;
+ {
+     /*
+      * Set up the engine to paint to the screen.
+      */
+     WaitQueue(8);
+     outw(DP_CONFIG, FG_COLOR_SRC_FG | DRAW | READ_WRITE);
+     outw(ALU_FG_FN, MIX_FN_PAINT);
+     outw(FRGD_COLOR, Colour);
+     outw(CUR_X, XPos);
+     outw(CUR_Y, YPos);
+     outw(DEST_X_START, XPos);
+     outw(DEST_X_END, XPos+1);
+     outw(DEST_Y_END, YPos+1);
+ 
+     return;
+ 
+ }   /* WritePixel_m() */
+ #endif /* NEW_MEM_DETECT */
diff -c mit/server/ddx/x386/accel/mach32/mach32pcach.c:2.4 mit/server/ddx/x386/accel/mach32/mach32pcach.c:2.5
*** mit/server/ddx/x386/accel/mach32/mach32pcach.c:2.4	Fri Mar 11 23:37:17 1994
--- mit/server/ddx/x386/accel/mach32/mach32pcach.c	Fri Mar 11 23:37:17 1994
***************
*** 25,31 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32pcach.c,v 2.4 1993/10/04 05:01:03 dawes Exp $ */
  
  /*       Offscreen memory organization for one 256-line cache set:
   *
--- 25,31 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32pcach.c,v 2.5 1993/12/25 13:58:18 dawes Exp $ */
  
  /*       Offscreen memory organization for one 256-line cache set:
   *
***************
*** 655,661 ****
      int xwmid, ywmid, orig_xwmid;
      int startx, starty, endx, endy;
      int orig_x = x;
-     int i;
  
      if (w == 0 || h == 0)
  	return;
--- 655,660 ----
diff -c mit/server/ddx/x386/accel/mach32/mach32pntwn.c:2.2 mit/server/ddx/x386/accel/mach32/mach32pntwn.c:2.3
*** mit/server/ddx/x386/accel/mach32/mach32pntwn.c:2.2	Fri Mar 11 23:37:18 1994
--- mit/server/ddx/x386/accel/mach32/mach32pntwn.c	Fri Mar 11 23:37:18 1994
***************
*** 25,31 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32pntwn.c,v 2.2 1993/08/17 16:15:17 dawes Exp $ */
  
  #include "X.h"
  
--- 25,31 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32pntwn.c,v 2.3 1993/12/25 13:58:20 dawes Exp $ */
  
  #include "X.h"
  
***************
*** 38,45 ****
  #include "cfbmskbits.h"
  #include "mach32.h"
  #include "regmach32.h"
- 
- static void cfbPaintArea32(), cfbPaintAreaSolid();
  
  extern void miPaintWindow();
  
--- 38,43 ----
diff -c mit/server/ddx/x386/accel/mach32/mach32scrin.c:2.1 mit/server/ddx/x386/accel/mach32/mach32scrin.c:2.5
*** mit/server/ddx/x386/accel/mach32/mach32scrin.c:2.1	Fri Mar 11 23:37:18 1994
--- mit/server/ddx/x386/accel/mach32/mach32scrin.c	Fri Mar 11 23:37:18 1994
***************
*** 40,46 ****
  
  ********************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32scrin.c,v 2.1 1993/09/04 16:28:30 dawes Exp $ */
  
  /* $XConsortium: cfbscrinit.c,v 5.18 90/09/24 17:46:11 rws Exp $ */
  
--- 40,46 ----
  
  ********************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32scrin.c,v 2.5 1993/12/25 13:58:22 dawes Exp $ */
  
  /* $XConsortium: cfbscrinit.c,v 5.18 90/09/24 17:46:11 rws Exp $ */
  
***************
*** 63,68 ****
--- 63,70 ----
  
  extern RegionPtr mfbPixmapToRegion();
  extern Bool mfbAllocatePrivates();
+ extern Bool mfbRegisterCopyPlaneProc();
+ extern Bool miScreenInit();
  
  extern int defaultColorVisualClass;
  
***************
*** 102,109 ****
  
  #define NUMDEPTHS	((sizeof depths)/(sizeof depths[0]))
  
- int cfbWindowPrivateIndex;
- int cfbGCPrivateIndex;
  static unsigned long cfbGeneration = 0;
  
  miBSFuncRec mach32BSFuncRec = {
--- 104,109 ----
***************
*** 131,136 ****
--- 131,139 ----
  	for (i = 0; i < NUMVISUALS; i++) {
  	    visuals[i].vid = FakeClientID(0);
  	    VIDs[i] = visuals[i].vid;
+ 	    if (mach32DAC8Bit) {
+ 		visuals[i].bitsPerRGBValue = 8;
+ 	    }
  	}
  	cfbGeneration = serverGeneration;
      }
***************
*** 159,165 ****
      pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
      pScreen->QueryBestSize = mfbQueryBestSize;
      /* SaveScreen */
!     pScreen->GetImage = miGetImage;
      pScreen->GetSpans = mach32GetSpans;
      pScreen->CreateWindow = cfbCreateWindow;
      pScreen->DestroyWindow = cfbDestroyWindow;
--- 162,168 ----
      pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
      pScreen->QueryBestSize = mfbQueryBestSize;
      /* SaveScreen */
!     pScreen->GetImage = mach32GetImage;
      pScreen->GetSpans = mach32GetSpans;
      pScreen->CreateWindow = cfbCreateWindow;
      pScreen->DestroyWindow = cfbDestroyWindow;
diff -c mit/server/ddx/x386/accel/mach32/mach32seg.c:2.4 mit/server/ddx/x386/accel/mach32/mach32seg.c:2.5
*** mit/server/ddx/x386/accel/mach32/mach32seg.c:2.4	Fri Mar 11 23:37:19 1994
--- mit/server/ddx/x386/accel/mach32/mach32seg.c	Fri Mar 11 23:37:19 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32seg.c,v 2.4 1993/09/21 15:21:40 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/mach32seg.c,v 2.5 1993/12/25 13:58:24 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 99,106 ****
      unsigned int oc1;		/* outcode of point 1 */
      unsigned int oc2;		/* outcode of point 2 */
  
-     unsigned long *addrl;		/* address of destination pixmap */
-     int nlwidth;		/* width in longwords of destination pixmap */
      int xorg, yorg;		/* origin of window */
  
      int adx;		/* abs values of dx and dy */
--- 99,104 ----
***************
*** 120,127 ****
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int		    alu;
  
      if (!x386VTSema)
      {
--- 118,123 ----
diff -c mit/server/ddx/x386/accel/mach32/regmach32.h:2.6 mit/server/ddx/x386/accel/mach32/regmach32.h:2.16
*** mit/server/ddx/x386/accel/mach32/regmach32.h:2.6	Fri Mar 11 23:37:19 1994
--- mit/server/ddx/x386/accel/mach32/regmach32.h	Fri Mar 11 23:37:20 1994
***************
*** 21,27 ****
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/regmach32.h,v 2.6 1993/10/06 14:54:34 dawes Exp $ */
  
  #ifndef REGMACH32_H
  #define REGMACH32_H
--- 21,27 ----
   * Modified for the Mach32 by Kevin E. Martin (martin@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach32/regmach32.h,v 2.16 1994/03/03 12:43:20 dawes Exp $ */
  
  #ifndef REGMACH32_H
  #define REGMACH32_H
***************
*** 67,72 ****
--- 67,73 ----
  #define	ERR_TERM		0x92e8
  #define	MAJ_AXIS_PCNT		0x96e8
  #define	GP_STAT			0x9ae8
+ #define	GE_STAT			GP_STAT
  #define	CMD			0x9ae8
  #define	SHORT_STROKE		0x9ee8
  #define	BKGD_COLOR		0xa2e8
***************
*** 111,116 ****
--- 112,118 ----
  #define	MEMCFG_4		0x0002
  #define	MEMCFG_6		0x0004
  #define	MEMCFG_8		0x0006
+ #define	ODDBNKENAB		0x0001
  
  /* Subsystem Status Register */
  #define	_8PLANE			0x0080
***************
*** 156,161 ****
--- 158,164 ----
  /* Graphics Processor Status Register */
  #define	GPBUSY			0x0200
  #define	DATDRDY			0x0100
+ #define	DATA_READY		DATDRDY
  
  /* Command Register */
  #define	CMD_NOP			0x0000
***************
*** 234,239 ****
--- 237,243 ----
  #define	MIX_HALF__DST_MINUS_SRC_SAT	0x001c
  #define	MIX_HALF__SRC_MINUS_DST_SAT	0x001e
  #define	MIX_AVERAGE_SAT			0x001f
+ #define	MIX_FN_PAINT			MIX_SRC
  
  /* Memory Control Register */
  #define	BUFSWP			0x0010
***************
*** 284,289 ****
--- 288,308 ----
  #define READ_SRC_X		0xdaee
  #define CHIP_ID			0xfaee
  #define EXT_FIFO_STATUS		0x9aee
+ #define EXT_GE_CONFIG		0x7aee
+ #define R_EXT_GE_CONFIG		0x8eee
+ #define EXT_GE_STATUS		0x62ee
+ #define MISC_CNTL		0x7eee
+ #define R_MISC_CNTL		0x92ee
+ #define DP_CONFIG		0xceee
+ #define DEST_X_START		0xa6ee
+ #define DEST_X_END		0xaaee
+ #define DEST_Y_END		0xaeee
+ #define ALU_FG_FN		0xbaee
+ #define HORZ_OVERSCAN		0x62ee
+ #define VERT_OVERSCAN		0x66ee
+ #define LINEDRAW		0xfeee
+ #define LINEDRAW_INDEX		0x9aee
+ #define LINEDRAW_OPT		0xa2ee
  
  /* Mach8 config status 1 */
  #define CLK_MODE		0x0001
***************
*** 337,344 ****
  #define LOCAL_386SX		0x0008
  #define LOCAL_386DX		0x000a
  #define LOCAL_486		0x000c
! #define ISA_8_BIT		0x000e
  
  /* Mach32 CRT Polarity */
  #define H_POLARITY_POS		0x0000
  #define H_POLARITY_NEG		0x0020
--- 356,372 ----
  #define LOCAL_386SX		0x0008
  #define LOCAL_386DX		0x000a
  #define LOCAL_486		0x000c
! #define PCI			0x000e
  
+ /* Mach32 RAMDAC types */
+ #define DAC_ATI68830		0
+ #define DAC_SC11483		1
+ #define DAC_TLC34075		2
+ #define DAC_BT476		3
+ #define DAC_BT481		4
+ #define DAC_ATI68860		5
+ #define DAC_ATI68875		DAC_TLC34075
+ 
  /* Mach32 CRT Polarity */
  #define H_POLARITY_POS		0x0000
  #define H_POLARITY_NEG		0x0020
***************
*** 345,350 ****
--- 373,381 ----
  #define V_POLARITY_POS		0x0000
  #define V_POLARITY_NEG		0x0020
  
+ /* Mach32 Composite Sync */
+ #define COMPOSITE_SYNC		0x1000
+ 
  /* Mach32 Number of Video FIFO entries */
  #define VFIFO_DEPTH_1		0x0100
  #define VFIFO_DEPTH_2		0x0200
***************
*** 373,378 ****
--- 404,445 ----
  #define TEST_MODE		0x0100
  #define BLK_WR_ENA		0x0400
  #define _64_DRAW_ENA		0x0800
+ #define MEM_SIZE_512K		0x0000
+ #define MEM_SIZE_1M		0x0004
+ #define MEM_SIZE_2M		0x0008
+ #define MEM_SIZE_4M		0x000c
+ 
+ /* Mach32 Extended Graphics Engine Configuration Register */
+ #define PIXEL_WIDTH_4		0x0000
+ #define PIXEL_WIDTH_8		0x0010
+ #define PIXEL_WIDTH_16		0x0020
+ #define PIXEL_WIDTH_24		0x0030
+ #define RGB16_555		0x0000
+ #define RGB16_565		0x0040
+ #define RGB16_655		0x0080
+ #define RGB16_664		0x00c0
+ #define MULTIPLEX_PIXELS	0x0100
+ #define RGB24			0x0000
+ #define RGBx24			0x0200
+ #define BGR24			0x0400
+ #define xBGR24			0x0600
+ #define DAC_8_BIT_EN		0x4000
+ #define PIX_WIDTH_16BPP		PIXEL_WIDTH_16
+ #define ORDER_16BPP_565		RGB16_565
+ 
+ /* Mach32 DP_CONFIG register */
+ #define FG_COLOR_SRC_BLIT	0x6000
+ #define FG_COLOR_SRC_FG		0x2000
+ #define DATA_WIDTH		0x0200
+ #define DATA_ORDER		0x1000
+ #define READ_WRITE		0x0001
+ 
+ /* Mach8/Mach32 Linedraw Options register */
+ #define BOUNDS_RESET		0x0100
+ #define CLIP_MODE_0		0x0000		/* clip exception disabled */
+ #define CLIP_MODE_1		0x0200		/* line segments */
+ #define CLIP_MODE_2		0x0400		/* polygon boundary lines */
+ #define CLIP_MODE_3		0x0600		/* patterned lines */
  
  /* ATI VGA Extended Regsiters */
  #define ATIEXT		0x1ce
***************
*** 392,397 ****
--- 459,468 ----
  #define MACH32_MAX_X	2047
  #define MACH32_MAX_Y	2047
  
+ /* RAMDAC type 2 registers */
+ #define	OUTPUT_CLK_SEL  0x2ea
+ #define	MUX_CNTL	0x2eb
+ #define	INPUT_CLK_SEL	0x2ed
  
  typedef struct {
      unsigned char r, g, b;
***************
*** 409,414 ****
--- 480,495 ----
  
  /* Wait until GP is idle and queue is empty */
  #define	WaitIdleEmpty() { while (inw(GP_STAT) & (GPBUSY | 1)); }
+ 
+ /*
+  * This version is for use in mach8Probe() to prevent a server hang if
+  * there is no 8514/A-style chip present
+  */
+ #define	ProbeWaitIdleEmpty() { int i; \
+ 			       for (i = 0; i < 100000; i++) \
+ 			          if (!(inw(GP_STAT) & (GPBUSY | 1))) \
+ 				     break; \
+ 			     }
  
  #define SKIP_2(_v) ((((_v)<<1)&0xfff8)|((_v)&0x3)|(((_v)&0x80)>>5))
  
diff -c mit/server/ddx/x386/accel/mach8/Imakefile:2.5 mit/server/ddx/x386/accel/mach8/Imakefile:2.8
*** mit/server/ddx/x386/accel/mach8/Imakefile:2.5	Fri Mar 11 23:37:24 1994
--- mit/server/ddx/x386/accel/mach8/Imakefile	Fri Mar 11 23:37:24 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/accel/mach8/Imakefile,v 2.5 1993/09/21 15:21:55 dawes Exp $
  #include <Server.tmpl>
  
  SRCS = 	mach8.c mach8cmap.c mach8gc.c mach8fs.c mach8ss.c \
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/accel/mach8/Imakefile,v 2.8 1994/02/19 09:28:55 dawes Exp $
  #include <Server.tmpl>
  
  SRCS = 	mach8.c mach8cmap.c mach8gc.c mach8fs.c mach8ss.c \
***************
*** 7,13 ****
  	mach8line.c mach8seg.c mach8frect.c mach8text.c \
  	mach8font.c mach8fcach.c \
  	mach8dsln.c mach8dssg.c mach8ddln.c mach8ddsg.c \
! 	mach8imwrt.s mach8imrd.s mach8imfl.s mach8imst.s
  
  OBJS = 	mach8.o mach8cmap.o mach8gc.o mach8fs.o mach8ss.o \
  	mach8gs.o mach8win.o mach8init.o mach8im.o mach8bstor.o \
--- 7,15 ----
  	mach8line.c mach8seg.c mach8frect.c mach8text.c \
  	mach8font.c mach8fcach.c \
  	mach8dsln.c mach8dssg.c mach8ddln.c mach8ddsg.c \
! 	mach8imwrt.s mach8imrd.s mach8imfl.s mach8imst.s \
! 	mach8imwrd.s mach8imrdd.s mach8imfld.s mach8imstd.s \
! 	mach8gtimg.c
  
  OBJS = 	mach8.o mach8cmap.o mach8gc.o mach8fs.o mach8ss.o \
  	mach8gs.o mach8win.o mach8init.o mach8im.o mach8bstor.o \
***************
*** 15,21 ****
  	mach8line.o mach8seg.o mach8frect.o mach8text.o \
  	mach8font.o mach8fcach.o \
  	mach8dsln.o mach8dssg.o mach8ddln.o mach8ddsg.o \
! 	mach8imwrt.o mach8imrd.o mach8imfl.o mach8imst.o
  
  INCLUDES = -I../../common -I../../common_hw -I../../os-support -I. \
  	   -I../../../mfb -I../../../mi -I../../../../include \
--- 17,25 ----
  	mach8line.o mach8seg.o mach8frect.o mach8text.o \
  	mach8font.o mach8fcach.o \
  	mach8dsln.o mach8dssg.o mach8ddln.o mach8ddsg.o \
! 	mach8imwrt.o mach8imrd.o mach8imfl.o mach8imst.o \
! 	mach8imwrd.o mach8imrdd.o mach8imfld.o mach8imstd.o \
! 	mach8gtimg.o
  
  INCLUDES = -I../../common -I../../common_hw -I../../os-support -I. \
  	   -I../../../mfb -I../../../mi -I../../../../include \
***************
*** 32,36 ****
--- 36,44 ----
  
  ObjectFromSpecialSource(mach8ddln,mach8dsln,-DMach8DoubleDash)
  ObjectFromSpecialSource(mach8ddsg,mach8dssg,-DMach8DoubleDash)
+ ObjectFromSpecialAsmSource(mach8imfld,mach8imfl,-DDRAM_VERSION)
+ ObjectFromSpecialAsmSource(mach8imrdd,mach8imrd,-DDRAM_VERSION)
+ ObjectFromSpecialAsmSource(mach8imstd,mach8imst,-DDRAM_VERSION)
+ ObjectFromSpecialAsmSource(mach8imwrd,mach8imwrt,-DDRAM_VERSION)
  
  DependTarget()
diff -c mit/server/ddx/x386/accel/mach8/mach8.c:2.23 mit/server/ddx/x386/accel/mach8/mach8.c:2.34
*** mit/server/ddx/x386/accel/mach8/mach8.c:2.23	Fri Mar 11 23:37:25 1994
--- mit/server/ddx/x386/accel/mach8/mach8.c	Fri Mar 11 23:37:25 1994
***************
*** 30,38 ****
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vga.c,v 1.2 1991/06/27 00:02:49 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8.c,v 2.23 1993/10/12 15:41:25 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
  #include "pixmapstr.h"
  #include "scrnintstr.h"
--- 30,39 ----
   * Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vga.c,v 1.2 1991/06/27 00:02:49 root Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8.c,v 2.34 1994/03/03 12:43:39 dawes Exp $ */
  
  #include "X.h"
+ #include "Xmd.h"
  #include "input.h"
  #include "pixmapstr.h"
  #include "scrnintstr.h"
***************
*** 43,48 ****
--- 44,50 ----
  
  #include "x386.h"
  #include "x386Priv.h"
+ #include "x386Procs.h"
  #include "xf86_OSlib.h"
  #include "xf86_HWlib.h"
  #include "mach8.h"
***************
*** 55,62 ****
  extern int mach8MaxClock;
  extern Bool x386Exiting, x386Resetting, x386ProbeFailed, x386Verbose;
  extern void NoopDDA();
  
- 
  ScrnInfoRec mach8InfoRec = {
      FALSE,		/* Bool configured */
      -1,			/* int tmpIndex */
--- 57,66 ----
  extern int mach8MaxClock;
  extern Bool x386Exiting, x386Resetting, x386ProbeFailed, x386Verbose;
  extern void NoopDDA();
+ extern Bool mfbRegisterCopyPlaneProc();
+ extern Bool miDCInitialize();
+ extern void SetTimeSinceLastInputEvent();
  
  ScrnInfoRec mach8InfoRec = {
      FALSE,		/* Bool configured */
      -1,			/* int tmpIndex */
***************
*** 83,88 ****
--- 87,93 ----
      0,			/* int maxClock */
      0,			/* int videoRam */
      0,                  /* int BIOSbase, 1.3 new */
+     0,			/* unsigned long MemBase, unused for this driver */
      240, 180,		/* int width, height */
      0,                  /* unsigned long  speedup */
      NULL,	       	/* DisplayModePtr modes */
***************
*** 117,122 ****
--- 122,133 ----
  
  extern miPointerScreenFuncRec x386PointerScreenFuncs;
  
+ void (*mach8ImageWriteFunc)();
+ void (*mach8ImageReadFunc)();
+ void (*mach8RealImageFillFunc)();
+ void (*mach8ImageStippleFunc)();
+ 
+ static Bool mach8DramUsed = FALSE;
  static int AlreadyInited = FALSE;
  
  Bool mach8clkprobedif4fix = FALSE;
***************
*** 124,129 ****
--- 135,141 ----
  static struct mach8vmodedef  mach8ScreenMode;
  
  static ScreenPtr savepScreen = NULL;
+ static PixmapPtr ppix = NULL;
  
  static unsigned mach8_IOPorts[] = {
  	/* 8514 Registers */
***************
*** 183,189 ****
  	 * entirely arbitrary.
  	 */
  	outw(ERR_TERM, 0x5a5a);
! 	WaitIdleEmpty();
  	if (inw(ERR_TERM) != 0x5a5a) {
  	    ErrorF("%s: No 8514/A registers detected!\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
--- 195,201 ----
  	 * entirely arbitrary.
  	 */
  	outw(ERR_TERM, 0x5a5a);
! 	ProbeWaitIdleEmpty();
  	if (inw(ERR_TERM) != 0x5a5a) {
  	    ErrorF("%s: No 8514/A registers detected!\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
***************
*** 191,197 ****
  	}
  	/* 6 mar 93 TCG : let's make certain */
  	outw(ERR_TERM, 0x2525);
! 	WaitIdleEmpty();
  	if (inw(ERR_TERM) != 0x2525) {
  	    ErrorF("%s: No 8514/A registers detected!\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
--- 203,209 ----
  	}
  	/* 6 mar 93 TCG : let's make certain */
  	outw(ERR_TERM, 0x2525);
! 	ProbeWaitIdleEmpty();
  	if (inw(ERR_TERM) != 0x2525) {
  	    ErrorF("%s: No 8514/A registers detected!\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
***************
*** 200,206 ****
  
  	temp = inw(ROM_ADDR_1);
  	outw(ROM_ADDR_1, 0x5555);
! 	WaitIdleEmpty();
  	if (inw(ROM_ADDR_1) != 0x5555) {
  	    ErrorF("%s: No ATI accelerator detected\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
--- 212,218 ----
  
  	temp = inw(ROM_ADDR_1);
  	outw(ROM_ADDR_1, 0x5555);
! 	ProbeWaitIdleEmpty();
  	if (inw(ROM_ADDR_1) != 0x5555) {
  	    ErrorF("%s: No ATI accelerator detected\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
***************
*** 207,213 ****
  	    return(FALSE);
  	}
  	outw(ROM_ADDR_1, 0x2a2a);
! 	WaitIdleEmpty();
  	if (inw(ROM_ADDR_1) != 0x2a2a) {
  	    ErrorF("%s: No ATI accelerator detected\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
--- 219,225 ----
  	    return(FALSE);
  	}
  	outw(ROM_ADDR_1, 0x2a2a);
! 	ProbeWaitIdleEmpty();
  	if (inw(ROM_ADDR_1) != 0x2a2a) {
  	    ErrorF("%s: No ATI accelerator detected\n", mach8InfoRec.name);
  	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
***************
*** 216,237 ****
  	outw(ROM_ADDR_1, temp);
  
  	outw(DESTX_DIASTP, 0xaaaa);
! 	WaitIdleEmpty();
  	if ((inw(READ_SRC_X) != 0xaaaa) && x386Verbose) {
! 	    ErrorF("%s %s: Mach-8 detected\n", XCONFIG_PROBED,
! 		   mach8InfoRec.name);
! 	}
! 	outw(DESTX_DIASTP, 0x5555);
! 	WaitIdleEmpty();
! 	if (inw(READ_SRC_X) == 0x0555) {
! 	    ErrorF("%s %s: Mach-32 detected\n", XCONFIG_PROBED,
! 		   mach8InfoRec.name);
! 	    xf86DisableIOPorts(mach8InfoRec.scrnIndex);
! 	    return(FALSE);
  	}
      }
  
      OFLG_ZERO(&validOptions);
      xf86VerifyOptions(&validOptions, &mach8InfoRec);
  
      if (!mach8InfoRec.clocks)
--- 228,249 ----
  	outw(ROM_ADDR_1, temp);
  
  	outw(DESTX_DIASTP, 0xaaaa);
! 	ProbeWaitIdleEmpty();
  	if ((inw(READ_SRC_X) != 0xaaaa) && x386Verbose) {
! 	    outw(DESTX_DIASTP, 0x5555);
! 	    ProbeWaitIdleEmpty();
! 	    if (inw(READ_SRC_X) == 0x0555) {
! 		ErrorF("%s %s: Mach-32 detected, used as a Mach-8\n",
! 			XCONFIG_PROBED, mach8InfoRec.name);
! 	    }
! 	    else
! 		ErrorF("%s %s: Mach-8 detected\n", XCONFIG_PROBED,
! 			mach8InfoRec.name);
  	}
      }
  
      OFLG_ZERO(&validOptions);
+     OFLG_SET(OPTION_CSYNC, &validOptions);
      xf86VerifyOptions(&validOptions, &mach8InfoRec);
  
      if (!mach8InfoRec.clocks)
***************
*** 297,303 ****
  
      mach8InfoRec.chipset = "mach8";
      x386ProbeFailed = FALSE;
! 
      if (x386Verbose)
      {
          ErrorF("%s %s: (mem: %dk %cRAM numclocks: %d)",
--- 309,315 ----
  
      mach8InfoRec.chipset = "mach8";
      x386ProbeFailed = FALSE;
!     mach8DramUsed = (temp & 0x10) != 0;
      if (x386Verbose)
      {
          ErrorF("%s %s: (mem: %dk %cRAM numclocks: %d)",
***************
*** 305,311 ****
                 XCONFIG_GIVEN : XCONFIG_PROBED,
                 mach8InfoRec.name,
                 mach8InfoRec.videoRam,
!                temp & 0x10 ? 'D' : 'V',
                 mach8InfoRec.clocks);
  
          for (j=0; j < mach8InfoRec.clocks; j++)
--- 317,323 ----
                 XCONFIG_GIVEN : XCONFIG_PROBED,
                 mach8InfoRec.name,
                 mach8InfoRec.videoRam,
!                mach8DramUsed ? 'D' : 'V',
                 mach8InfoRec.clocks);
  
          for (j=0; j < mach8InfoRec.clocks; j++)
***************
*** 333,339 ****
      maxX = maxY = -1;
      pMode = pEnd = mach8InfoRec.modes;
      do {
!         x386LookupMode(pMode, &mach8InfoRec, mach8InfoRec.name);
    
          if (pMode->HDisplay * pMode->VDisplay > memavail)
          {
--- 345,351 ----
      maxX = maxY = -1;
      pMode = pEnd = mach8InfoRec.modes;
      do {
!         x386LookupMode(pMode, &mach8InfoRec);
    
          if (pMode->HDisplay * pMode->VDisplay > memavail)
          {
***************
*** 363,370 ****
      if (mach8InfoRec.virtualX % rounding)
      {
          mach8InfoRec.virtualX -= mach8InfoRec.virtualX % rounding;
! 	ErrorF("%s: Virtual width rounded down to a multiple of %d (%d)\n",
! 	       mach8InfoRec.name, rounding, mach8InfoRec.virtualX);
          if (mach8InfoRec.virtualX < maxX)
          {
              ErrorF(
--- 375,383 ----
      if (mach8InfoRec.virtualX % rounding)
      {
          mach8InfoRec.virtualX -= mach8InfoRec.virtualX % rounding;
! 	ErrorF("%s %s: Virtual width rounded down to a multiple of %d (%d)\n",
! 	       XCONFIG_PROBED, mach8InfoRec.name, rounding,
! 	       mach8InfoRec.virtualX);
          if (mach8InfoRec.virtualX < maxX)
          {
              ErrorF(
***************
*** 381,387 ****
          ErrorF("%s: Virtual width must be no greater than 1024\n");
          return(FALSE);
      }
- 
      if ( mach8InfoRec.virtualX * mach8InfoRec.virtualY > memavail)
      {
          if (mach8InfoRec.virtualX != maxX || mach8InfoRec.virtualY != maxY)
--- 394,399 ----
***************
*** 425,430 ****
--- 437,445 ----
      int            argc;         /* The number of the Server's arguments. */
      char           **argv;       /* The arguments themselves. Don't change! */
  {
+     int displayResolution = 75;  /* default to 75dpi */
+     extern int monitorResolution;
+ 
      /*
       *  Convert from XFree mode definitions to Mach8 register values.
       */
***************
*** 431,448 ****
      mach8calcvmode(&mach8ScreenMode,mach8InfoRec.modes);
  
      mach8Init(&mach8ScreenMode);
!     InitEnvironment();
      AlreadyInited = TRUE;
  
      mach8CacheInit();
      mach8FontCache8Init();
! 
      mach8ImageInit();
  
      if (!mach8ScreenInit(pScreen,
  			   (pointer) 0,
  			   mach8InfoRec.virtualX, mach8InfoRec.virtualY,
! 			   75, 75,
  			   mach8InfoRec.virtualX))
  	return(FALSE);
  
--- 446,481 ----
      mach8calcvmode(&mach8ScreenMode,mach8InfoRec.modes);
  
      mach8Init(&mach8ScreenMode);
!     mach8InitEnvironment();
      AlreadyInited = TRUE;
  
      mach8CacheInit();
      mach8FontCache8Init();
!     if( mach8DramUsed ) {
! 	mach8ImageWriteFunc = mach8ImageWriteDram;
! 	mach8ImageReadFunc = mach8ImageReadDram;
! 	mach8RealImageFillFunc = mach8RealImageFillDram;
! 	mach8ImageStippleFunc = mach8ImageStippleDram;
!     }
!     else {
! 	mach8ImageWriteFunc = mach8ImageWrite;
! 	mach8ImageReadFunc = mach8ImageRead;
! 	mach8RealImageFillFunc = mach8RealImageFill;
! 	mach8ImageStippleFunc = mach8ImageStipple;
!     }
      mach8ImageInit();
  
+     /*
+      * Take display resolution from the -dpi flag if specified
+      */
+ 
+     if (monitorResolution)
+ 	displayResolution = monitorResolution;
+ 
      if (!mach8ScreenInit(pScreen,
  			   (pointer) 0,
  			   mach8InfoRec.virtualX, mach8InfoRec.virtualY,
! 			   displayResolution, displayResolution,
  			   mach8InfoRec.virtualX))
  	return(FALSE);
  
***************
*** 473,479 ****
       int screen_idx;
  {
    PixmapPtr   pspix;
-   static PixmapPtr ppix = NULL;
    ScreenPtr   pScreen = savepScreen;
  
      if (!x386Resetting && !x386Exiting)
--- 506,511 ----
***************
*** 484,490 ****
      if (enter) {
  	xf86EnableIOPorts(mach8InfoRec.scrnIndex);
  	mach8Init(&mach8ScreenMode);
! 	InitEnvironment();
          mach8RestoreDACvalues();
          mach8CacheInit();
          mach8FontCache8Init();
--- 516,522 ----
      if (enter) {
  	xf86EnableIOPorts(mach8InfoRec.scrnIndex);
  	mach8Init(&mach8ScreenMode);
! 	mach8InitEnvironment();
          mach8RestoreDACvalues();
          mach8CacheInit();
          mach8FontCache8Init();
***************
*** 495,504 ****
             if ((pointer)pspix->devPrivate.ptr != NULL && ppix)
             {
                pspix->devPrivate.ptr = NULL;
!               mach8ImageWrite(0, 0, pScreen->width, pScreen->height,
!                               ppix->devPrivate.ptr,
!                               PixmapBytePad(pScreen->width, pScreen->rootDepth),
!                               0, 0, mach8alu[GXcopy], 0xFF);
  
             }
          if (ppix) {
--- 527,537 ----
             if ((pointer)pspix->devPrivate.ptr != NULL && ppix)
             {
                pspix->devPrivate.ptr = NULL;
!               (mach8ImageWriteFunc)(0, 0, pScreen->width, pScreen->height,
! 				    ppix->devPrivate.ptr,
! 				    PixmapBytePad(pScreen->width,
! 						  pScreen->rootDepth),
! 				    0, 0, mach8alu[GXcopy], 0xFF);
  
             }
          if (ppix) {
***************
*** 512,521 ****
                                            pScreen->height, pScreen->rootDepth);
             if (ppix)
             {
!               mach8ImageRead(0, 0, pScreen->width, pScreen->height,
!                              ppix->devPrivate.ptr,
!                              PixmapBytePad(pScreen->width, pScreen->rootDepth),
!                              0, 0);
                pspix->devPrivate.ptr = ppix->devPrivate.ptr;
             }
          }
--- 545,555 ----
                                            pScreen->height, pScreen->rootDepth);
             if (ppix)
             {
!               (mach8ImageReadFunc)(0, 0, pScreen->width, pScreen->height,
! 				   ppix->devPrivate.ptr,
! 				   PixmapBytePad(pScreen->width,
! 						 pScreen->rootDepth),
! 				   0, 0, 0xff);
                pspix->devPrivate.ptr = ppix->devPrivate.ptr;
             }
          }
***************
*** 558,563 ****
--- 592,605 ----
      x386Exiting = TRUE;
      if (x386VTSema) 
  	mach8EnterLeaveVT(LEAVE, screen_idx);
+     else if (ppix) {
+         /*
+          * 7-Jan-94 CEG: The server is not running on the current vt.
+          * Free the screen snapshot taken when the server vt was left.
+ 	 */
+         (savepScreen->DestroyPixmap)(ppix);
+         ppix = NULL;
+     }
      return(TRUE);
  }
  
***************
*** 606,612 ****
     *  We adjust the CRT offset to pan the display.
     */
  
!     offset = (2 + x + mach8InfoRec.virtualX*y) >> 2;
    
      outw(CRT_OFFSET_HI, (offset >> 16) & 0xF);
      outw(CRT_OFFSET_LO, offset & 0xFFFF);
--- 648,657 ----
     *  We adjust the CRT offset to pan the display.
     */
  
!     if( mach8InfoRec.videoRam > 512 )
! 	offset = (2 + x + 1024*y) >> 2;
!     else
! 	offset = (2 + x + mach8InfoRec.virtualX*y) >> 2;
    
      outw(CRT_OFFSET_HI, (offset >> 16) & 0xF);
      outw(CRT_OFFSET_LO, offset & 0xFFFF);
diff -c mit/server/ddx/x386/accel/mach8/mach8.h:2.5 mit/server/ddx/x386/accel/mach8/mach8.h:2.10
*** mit/server/ddx/x386/accel/mach8/mach8.h:2.5	Fri Mar 11 23:37:26 1994
--- mit/server/ddx/x386/accel/mach8/mach8.h	Fri Mar 11 23:37:26 1994
***************
*** 25,31 ****
   * and Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8.h,v 2.5 1993/09/23 15:44:24 dawes Exp $ */
  
  #ifndef MACH8_H
  #define MACH8_H
--- 25,31 ----
   * and Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8.h,v 2.10 1994/02/01 13:51:26 dawes Exp $ */
  
  #ifndef MACH8_H
  #define MACH8_H
***************
*** 48,54 ****
  extern void mach8calcvmode();
  
  extern void mach8Init();
! extern void InitEnvironment(void);
  extern void mach8CleanUp(void);
  
  extern Bool mach8SaveScreen();
--- 48,55 ----
  extern void mach8calcvmode();
  
  extern void mach8Init();
! extern Bool mach8ScreenInit();
! extern void mach8InitEnvironment();
  extern void mach8CleanUp(void);
  
  extern Bool mach8SaveScreen();
***************
*** 64,74 ****
  extern Bool mach8RealizeFont();
  extern Bool mach8UnrealizeFont();
  
  extern void mach8ImageRead();
  extern void mach8ImageWrite();
! extern void mach8ImageFill();
  extern void mach8ImageStipple();
! extern void mach8ImageOpStipple();
  
  extern void mach8CacheInit();
  extern void mach8FontCache8Init();
--- 65,80 ----
  extern Bool mach8RealizeFont();
  extern Bool mach8UnrealizeFont();
  
+ extern void mach8ImageFill();
+ 
  extern void mach8ImageRead();
  extern void mach8ImageWrite();
! extern void mach8RealImageFill();
  extern void mach8ImageStipple();
! extern void mach8ImageReadDram();
! extern void mach8ImageWriteDram();
! extern void mach8RealImageFillDram();
! extern void mach8ImageStippleDram();
  
  extern void mach8CacheInit();
  extern void mach8FontCache8Init();
***************
*** 82,88 ****
  extern void mach8CImageOpStipple();
  extern void mach8CacheFreeSlot();
  
! extern int mach8CacheFont8();
  extern void mach8UnCacheFont8();
  
  extern void mach8PolyPoint();
--- 88,94 ----
  extern void mach8CImageOpStipple();
  extern void mach8CacheFreeSlot();
  
! extern void *mach8CacheFont8();
  extern void mach8UnCacheFont8();
  
  extern void mach8PolyPoint();
***************
*** 111,116 ****
--- 117,123 ----
  extern RegionPtr mach8CopyArea();
  extern RegionPtr mach8CopyPlane();
  extern void mach8CopyWindow();
+ extern void mach8FindOrdering();
  
  extern void mach8SaveAreas();
  extern void mach8RestoreAreas();
***************
*** 117,126 ****
--- 124,140 ----
  
  extern Bool mach8CreateGC();
  
+ extern void mach8GetImage();
+ 
  extern ScrnInfoRec mach8InfoRec;
  
  extern short mach8alu[];
  
  extern int mach8ValidTokens[];
+ 
+ extern void (*mach8ImageWriteFunc)();
+ extern void (*mach8ImageReadFunc)();
+ extern void (*mach8RealImageFillFunc)();
+ extern void (*mach8ImageStippleFunc)();
  
  #endif /* MACH8_H */
diff -c mit/server/ddx/x386/accel/mach8/mach8blt.c:2.3 mit/server/ddx/x386/accel/mach8/mach8blt.c:2.8
*** mit/server/ddx/x386/accel/mach8/mach8blt.c:2.3	Fri Mar 11 23:37:26 1994
--- mit/server/ddx/x386/accel/mach8/mach8blt.c	Fri Mar 11 23:37:27 1994
***************
*** 28,34 ****
  Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8blt.c,v 2.3 1993/09/12 11:26:07 dawes Exp $ */
  
  /* $XConsortium: cfbbitblt.c,v 5.39 91/05/24 16:33:25 keith Exp $ */
  
--- 28,34 ----
  Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8blt.c,v 2.8 1994/02/25 14:58:26 dawes Exp $ */
  
  /* $XConsortium: cfbbitblt.c,v 5.39 91/05/24 16:33:25 keith Exp $ */
  
***************
*** 48,57 ****
  #include	"regmach8.h"
  #include	"mach8.h"
  
! void mach8FindOrdering();
  
- static unsigned long bitBltPlane = 0;
- 
  RegionPtr
  mach8CopyArea(pSrcDrawable, pDstDrawable,
  		pGC, srcx, srcy, width, height, dstx, dsty)
--- 48,55 ----
  #include	"regmach8.h"
  #include	"mach8.h"
  
! extern RegionPtr cfbBitBlt();
  
  RegionPtr
  mach8CopyArea(pSrcDrawable, pDstDrawable,
  		pGC, srcx, srcy, width, height, dstx, dsty)
***************
*** 354,362 ****
  	    unsigned char *pdst = ((PixmapPtr)pDstDrawable)->devPrivate.ptr;
  
  	    for (i = numRects; --i >= 0; pbox++)
! 		mach8ImageRead(pbox->x1 + dx, pbox->y1 + dy,
! 				 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				 pdst, pixWidth, pbox->x1, pbox->y1);
  	} else if (pSrcDrawable->type != DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
  	    /* Pixmap --> Window */
  	    int pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
--- 352,360 ----
  	    unsigned char *pdst = ((PixmapPtr)pDstDrawable)->devPrivate.ptr;
  
  	    for (i = numRects; --i >= 0; pbox++)
! 		(mach8ImageReadFunc)(pbox->x1 + dx, pbox->y1 + dy,
! 				     pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				     pdst, pixWidth, pbox->x1, pbox->y1, 0xff);
  	} else if (pSrcDrawable->type != DRAWABLE_WINDOW && pDstDrawable->type == DRAWABLE_WINDOW) {
  	    /* Pixmap --> Window */
  	    int pixWidth = PixmapBytePad(pSrcDrawable->width, pSrcDrawable->depth);
***************
*** 363,372 ****
  	    unsigned char *psrc = ((PixmapPtr)pSrcDrawable)->devPrivate.ptr;
  
  	    for (i = numRects; --i >= 0; pbox++)
! 		mach8ImageWrite(pbox->x1, pbox->y1,
! 				  pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				  psrc, pixWidth, pbox->x1 + dx, pbox->y1 + dy,
! 				  mach8alu[pGC->alu], pGC->planemask);
  	} else {
  	    /* Pixmap --> Pixmap */
  	    ErrorF("mach8CopyArea:  Tried to do a Pixmap to Pixmap copy\n");
--- 361,371 ----
  	    unsigned char *psrc = ((PixmapPtr)pSrcDrawable)->devPrivate.ptr;
  
  	    for (i = numRects; --i >= 0; pbox++)
! 		(mach8ImageWriteFunc)(pbox->x1, pbox->y1,
! 				      pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				      psrc, pixWidth,
! 				      pbox->x1 + dx, pbox->y1 + dy,
! 				      mach8alu[pGC->alu], pGC->planemask);
  	} else {
  	    /* Pixmap --> Pixmap */
  	    ErrorF("mach8CopyArea:  Tried to do a Pixmap to Pixmap copy\n");
***************
*** 521,528 ****
  	(void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
  			 width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
  	pSrcDrawable = (DrawablePtr)pBitmap;
!     }
!     else if (((pSrcDrawable->type == DRAWABLE_WINDOW) && 
                (pDstDrawable->type != DRAWABLE_WINDOW)) ||
               ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
                (pDstDrawable->type == DRAWABLE_WINDOW) &&
--- 520,552 ----
  	(void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
  			 width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
  	pSrcDrawable = (DrawablePtr)pBitmap;
!     } else if ((pSrcDrawable->type == DRAWABLE_WINDOW) &&
!  	       (pDstDrawable->type != DRAWABLE_WINDOW)) {
! 	/*
!  	 * Shortcut - we can do Window->Pixmap by copying the window to
!  	 * a pixmap, then we have a Pixmap->Pixmap operation
!  	 */
!  	GCPtr pGC1;
!  	RegionPtr retval;
!  	PixmapPtr pPixmap;
! 
! 	pPixmap=(*pSrcDrawable->pScreen->CreatePixmap)(pSrcDrawable->pScreen, 
!  						       width, height, 8);
!  	if (!pPixmap)
!  	    return(NULL);
!  	pGC1 = GetScratchGC(8, pSrcDrawable->pScreen);
!  	if (!pGC1) {
!  	    (*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
!  	    return(NULL);
!  	}
!  	ValidateGC((DrawablePtr)pPixmap, pGC1);
!  	mach8CopyArea(pSrcDrawable, pPixmap, pGC1, srcx, srcy, width, height,
!  		      0, 0);
!  	retval = cfbCopyPlane((DrawablePtr)pPixmap, pDstDrawable, pGC,
!                               0, 0, width, height, dstx, dsty, bitPlane);
!  	(*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
!  	return(retval);
!     } else if (((pSrcDrawable->type == DRAWABLE_WINDOW) && 
                (pDstDrawable->type != DRAWABLE_WINDOW)) ||
               ((pSrcDrawable->type != DRAWABLE_WINDOW) &&
                (pDstDrawable->type == DRAWABLE_WINDOW) &&
***************
*** 797,808 ****
           psrc = pix->devPrivate.ptr;
  
           for (i = numRects; --i >= 0; pbox++) {
!             mach8ImageOpStipple(pbox->x1, pbox->y1,
!                                 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
!                                 psrc, pixWidth,
!                                 pix->drawable.width, pix->drawable.height,
!                                 -dx, -dy, pGC->fgPixel, pGC->bgPixel,
!                                 mach8alu[pGC->alu], (short) pGC->planemask);
           }
        } else {
           /* Pixmap --> Pixmap */
--- 821,833 ----
           psrc = pix->devPrivate.ptr;
  
           for (i = numRects; --i >= 0; pbox++) {
!             (mach8ImageStippleFunc)(pbox->x1, pbox->y1,
! 				    pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
! 				    psrc, pixWidth,
! 				    pix->drawable.width, pix->drawable.height,
! 				    -dx, -dy, pGC->fgPixel, pGC->bgPixel,
! 				    mach8alu[pGC->alu],
! 				    (short) pGC->planemask, 1);
           }
        } else {
           /* Pixmap --> Pixmap */
diff -c mit/server/ddx/x386/accel/mach8/mach8bstor.c:2.2 mit/server/ddx/x386/accel/mach8/mach8bstor.c:2.4
*** mit/server/ddx/x386/accel/mach8/mach8bstor.c:2.2	Fri Mar 11 23:37:27 1994
--- mit/server/ddx/x386/accel/mach8/mach8bstor.c	Fri Mar 11 23:37:27 1994
***************
*** 27,33 ****
   * Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8bstor.c,v 2.2 1993/08/17 16:15:28 dawes Exp $ */
  
  #include    "cfb.h"
  #include    "X.h"
--- 27,33 ----
   * Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8bstor.c,v 2.4 1994/02/01 13:51:29 dawes Exp $ */
  
  #include    "cfb.h"
  #include    "X.h"
***************
*** 62,71 ****
      pixWidth = PixmapBytePad(pPixmap->drawable.width, pPixmap->drawable.depth);
  
      while (i--) {
! 	mach8ImageRead(pBox->x1 + xorg, pBox->y1 + yorg,
! 			 pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
! 			 pPixmap->devPrivate.ptr, pixWidth,
! 			 pBox->x1, pBox->y1);
  	pBox++;
      }
  }
--- 62,71 ----
      pixWidth = PixmapBytePad(pPixmap->drawable.width, pPixmap->drawable.depth);
  
      while (i--) {
! 	(mach8ImageReadFunc)(pBox->x1 + xorg, pBox->y1 + yorg,
! 			     pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
! 			     pPixmap->devPrivate.ptr, pixWidth,
! 			     pBox->x1, pBox->y1, 0xff);
  	pBox++;
      }
  }
***************
*** 94,104 ****
      pixWidth = PixmapBytePad(pPixmap->drawable.width, pPixmap->drawable.depth);
  
      while (i--) {
! 	mach8ImageWrite(pBox->x1, pBox->y1,
! 			  pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
! 			  pPixmap->devPrivate.ptr, pixWidth,
! 			  pBox->x1 - xorg, pBox->y1 - yorg,
! 			  mach8alu[GXcopy], 0xffffffff);
  	pBox++;
      }
  }
--- 94,104 ----
      pixWidth = PixmapBytePad(pPixmap->drawable.width, pPixmap->drawable.depth);
  
      while (i--) {
! 	(mach8ImageWriteFunc)(pBox->x1, pBox->y1,
! 			      pBox->x2 - pBox->x1, pBox->y2 - pBox->y1,
! 			      pPixmap->devPrivate.ptr, pixWidth,
! 			      pBox->x1 - xorg, pBox->y1 - yorg,
! 			      mach8alu[GXcopy], 0xffffffff);
  	pBox++;
      }
  }
diff -c mit/server/ddx/x386/accel/mach8/mach8dsln.c:2.1 mit/server/ddx/x386/accel/mach8/mach8dsln.c:2.2
*** mit/server/ddx/x386/accel/mach8/mach8dsln.c:2.1	Fri Mar 11 23:37:28 1994
--- mit/server/ddx/x386/accel/mach8/mach8dsln.c	Fri Mar 11 23:37:28 1994
***************
*** 26,32 ****
  ******************************************************************/
  /* 17-sep-93 TCG: mach8dsln.c from ibm8514dsln.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8dsln.c,v 2.1 1993/10/18 12:17:18 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 26,32 ----
  ******************************************************************/
  /* 17-sep-93 TCG: mach8dsln.c from ibm8514dsln.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8dsln.c,v 2.2 1993/12/25 13:58:47 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 105,112 ****
      unsigned int oc1;           /* outcode of point 1 */
      unsigned int oc2;           /* outcode of point 2 */
  
-     unsigned long *addrl;       /* address of destination pixmap */
-     int nlwidth;                /* width in longwords of destination pixmap */
      int xorg, yorg;             /* origin of window */
  
      int adx;                    /* abs values of dx and dy */
--- 105,110 ----
***************
*** 124,136 ****
      unsigned char *pDash;
      Bool dashupdated;
                                  /* a bunch of temporaries */
-     int tmp;
      register int y1, y2;
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int             alu;
  
  /* 4-5-93 TCG : is VT visible */
      if (!x386VTSema)
--- 122,131 ----
diff -c mit/server/ddx/x386/accel/mach8/mach8dssg.c:2.1 mit/server/ddx/x386/accel/mach8/mach8dssg.c:2.2
*** mit/server/ddx/x386/accel/mach8/mach8dssg.c:2.1	Fri Mar 11 23:37:29 1994
--- mit/server/ddx/x386/accel/mach8/mach8dssg.c	Fri Mar 11 23:37:29 1994
***************
*** 26,32 ****
  ******************************************************************/
  /* 18-sep-93 TCG: mach8dssg.c from ibm8514dssg.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8dssg.c,v 2.1 1993/10/18 12:17:19 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 26,32 ----
  ******************************************************************/
  /* 18-sep-93 TCG: mach8dssg.c from ibm8514dssg.c */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8dssg.c,v 2.2 1993/12/25 13:58:49 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 103,110 ****
      unsigned int oc1;           /* outcode of point 1 */
      unsigned int oc2;           /* outcode of point 2 */
  
-     unsigned long *addrl;       /* address of destination pixmap */
-     int nlwidth;                /* width in longwords of destination pixmap */
      int xorg, yorg;             /* origin of window */
  
      int adx;                    /* abs values of dx and dy */
--- 103,108 ----
***************
*** 121,133 ****
      int dash0len, dashidx, dashstartidx, dashnum, dashrem;
      unsigned char *pDash;
                                  /* a bunch of temporaries */
-     int tmp;
      register int y1, y2;
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int             alu;
  
  /* 4-5-93 TCG : is VT visible */
      if (!x386VTSema)
--- 119,128 ----
diff -c mit/server/ddx/x386/accel/mach8/mach8fcach.c:2.7 mit/server/ddx/x386/accel/mach8/mach8fcach.c:2.17
*** mit/server/ddx/x386/accel/mach8/mach8fcach.c:2.7	Fri Mar 11 23:37:30 1994
--- mit/server/ddx/x386/accel/mach8/mach8fcach.c	Fri Mar 11 23:37:30 1994
***************
*** 20,28 ****
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8fcach.c,v 2.7 1993/10/04 05:13:42 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 20,34 ----
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
+  *
+  * Modified to use a dynamic font cache.
+  * Accelerated text display when no font cache is available added.
+  * Now using a linked list to store the CacheFont8Rec structs instead
+  * of a pointer array.
+  * Hans Nasten. (nasten@everyware.se)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8fcach.c,v 2.17 1994/02/12 11:05:43 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 40,60 ****
  #include "xf86_Config.h"
  extern Bool x386Verbose;
  
! #define NUM_FONTS      	8
! #define FC_MAX_WIDTH	24
! #define FC_MAX_HEIGHT	32
  
! typedef struct {
      FontPtr		font;
!     unsigned int	lru;
      CharInfoPtr		pci[256];
  } CacheFont8Rec;
  
! CacheFont8Rec	mach8FontCache[NUM_FONTS];
! int		mach8FC_X, mach8FC_Y;
! int             mach8FC_H, mach8FC_W;
  short		mach8ReadMask[8] = { 2, 4, 8, 16, 32, 64, 128, 1 };
  
  /*
   * mach8FontCache8Init --
   *      initialize Mach8 font cache.  We need to set the mach8FC*
--- 46,196 ----
  #include "xf86_Config.h"
  extern Bool x386Verbose;
  
! extern void QueryGlyphExtents();
  
! #define CACHECELL_WIDTH  48
! #define CACHECELL_HEIGHT 51
! #define FC_MAX_WIDTH	 CACHECELL_WIDTH/2
! #define FC_MAX_HEIGHT	 CACHECELL_HEIGHT
! 
! struct cachecell {
!     struct cachecell	*next;
!     unsigned short	x;
!     unsigned short	y;
!     unsigned short	plane;
! };
! 
! struct font_pos {
!     unsigned short	x;
!     unsigned short	y;
!     unsigned short	planemask;
! };
! 
! typedef struct CFRec{
!     struct CFRec	*next;
      FontPtr		font;
!     struct cachecell	*cells;
!     struct font_pos	pos[256];
      CharInfoPtr		pci[256];
  } CacheFont8Rec;
  
! CacheFont8Rec	*mach8FontCache;
  short		mach8ReadMask[8] = { 2, 4, 8, 16, 32, 64, 128, 1 };
  
+ int			mach8FCacheInit = 0;
+ struct cachecell	*mach8CacheFreeList;
+ int			mach8FreeCacheCells;
+ int			mach8TotalCacheCells;
+ int			mach8NumberOfCachedFonts;
+ 
+ /*
+  * mach8FreeCellChain
+  *      Add a linked list of cell structs to the front of the free list.
+  */
+ 
+ void
+ mach8FreeCellChain( chain )
+ struct cachecell *chain;
+ 
+ {
+ struct cachecell *lastlink;
+ int n_cells;
+ 
+     if( chain != NULL ) {
+ 	n_cells = 1;
+ 	for( lastlink = chain;
+ 	     lastlink->next != NULL;
+ 	     lastlink = lastlink->next )
+ 	    n_cells++;
+ 
+ 	lastlink->next = mach8CacheFreeList;
+ 	mach8CacheFreeList = chain;
+ 	mach8FreeCacheCells += n_cells;
+     }
+ }
+ 
+ 
+ /*
+  * mach8AllocCellChain
+  *      Allocate a linked list of cell structs from the front of the free list.
+  */
+ 
+ struct cachecell *
+ mach8AllocCellChain( n_cells )
+ int n_cells;
+ 
+ {
+ struct cachecell *cellpnt, *retpnt;
+ int nc;
+ 
+     if( mach8FreeCacheCells < n_cells )
+ 	return( NULL );
+ 
+     nc = n_cells;
+     retpnt = cellpnt = mach8CacheFreeList;
+     while( --nc > 0 ) {
+ 	if( cellpnt == NULL )
+ 	    ErrorF( "Severe cache panic. Reached NULL with n_cells > 0\n" );
+ 
+ 	cellpnt = cellpnt->next;
+     }
+ 
+     mach8CacheFreeList = cellpnt->next;
+     cellpnt->next = NULL;
+     mach8FreeCacheCells -= n_cells;
+     return( retpnt );
+ 
+ }
+ 
+ 
+ /*
+  * mach8AddCacheArea
+  *      Add the specified screen memory to the cache free list.
+  */
+ 
+ void
+ mach8AddCacheArea( x, y, width, height )
+ int x, y, width, height;
+ {
+ struct cachecell *chain, *lastcell, *newcell;
+ int h, w, x2, y2;
+ unsigned short bitplane;
+ 
+     chain = lastcell = NULL;
+     for( bitplane = 0; bitplane < 8; bitplane++ ) {
+ 	y2 = y;
+ 	h = height;
+ 	while( h >= CACHECELL_HEIGHT ) {
+ 	    x2 = x;
+ 	    w = width;
+ 	    while( w >= CACHECELL_WIDTH ) {
+ 		if( ( newcell = (struct cachecell *)
+ 			    (Xalloc( sizeof( struct cachecell ))) ) == NULL ) {
+ 		   ErrorF("Out of memory when Xallocing cache cell structs\n");
+ 		   return;
+ 		}
+ 		newcell->plane = bitplane;
+ 		newcell->x = x2;
+ 		newcell->y = y2;
+ 		newcell->next = NULL;
+ 		if( lastcell == NULL )
+ 		    chain = lastcell = newcell;
+ 		else {
+ 		    lastcell->next = newcell;
+ 		    lastcell = newcell;
+ 		}
+ 		x2 += CACHECELL_WIDTH;
+ 		w -= CACHECELL_WIDTH;
+ 	    }
+ 	    y2 += CACHECELL_HEIGHT;
+ 	    h -= CACHECELL_HEIGHT;
+ 	}
+     }
+     if( chain != NULL )
+ 	mach8FreeCellChain( chain );
+ 
+ }
+ 
  /*
   * mach8FontCache8Init --
   *      initialize Mach8 font cache.  We need to set the mach8FC*
***************
*** 65,97 ****
  void
  mach8FontCache8Init()
  {
!     int i;
!     int totalx,totaly,freey,freex;
  
    
!     totalx=mach8InfoRec.virtualX;
!     totaly=(mach8InfoRec.videoRam*1024) / totalx; 
! 
!     if (totaly>2048) totaly=2048;
! 
!     freex=mach8InfoRec.virtualX;
!     freey=totaly-mach8InfoRec.virtualY;
!   
! 
!     mach8FC_X = mach8InfoRec.virtualX>>2;
!     mach8FC_Y = mach8InfoRec.virtualY;
  
-     mach8FC_H = freey>>3;   if(mach8FC_H > 32) mach8FC_H=32;
-     mach8FC_W = (freex-mach8FC_X)>>5;
  
-     if (x386Verbose)
-       ErrorF("%s %s: fontcache room for %d fonts of %dx%d\n", XCONFIG_PROBED,
- 	     mach8InfoRec.name, NUM_FONTS, mach8FC_W, mach8FC_H);
- 
-     for (i = 0; i < NUM_FONTS; i++) {
- 	mach8FontCache[i].font = (FontPtr)0;
- 	mach8FontCache[i].lru = 0xffffffff;
-     }
  }
  
  void
--- 201,253 ----
  void
  mach8FontCache8Init()
  {
!     int totaly;
!     int first = 1;
!     CacheFont8Rec *fpnt, *fpnt2;
  
    
!     /*
!      * If this is a call due to a VT switch, uncache all fonts.
!      * I belive this is needed at least when someone starts 2 servers
!      * on different VT:s.
!      */
!     if( mach8FCacheInit ) {
! 	for (fpnt = mach8FontCache; fpnt != NULL; fpnt = fpnt2) {
! 	    fpnt2 = fpnt->next;
! 	    Xfree( fpnt );
! 	    first = 0;
! 	}
!     }
!     mach8FCacheInit = 1;
!     mach8FontCache = NULL;
!     mach8CacheFreeList = NULL;
!     mach8FreeCacheCells = 0;
!     mach8NumberOfCachedFonts = 0;
!     totaly=(mach8InfoRec.videoRam*1024) / mach8InfoRec.virtualX; 
!     if( totaly > 1024 )
! 	totaly = 1024;
!     if( mach8InfoRec.videoRam > 512 ) {
! 	mach8AddCacheArea( 256, mach8InfoRec.virtualY, 768,
! 			   1024-mach8InfoRec.virtualY > 256 ? 256 :
! 						1024-mach8InfoRec.virtualY);
! 	if( mach8InfoRec.virtualX < 1024 )
! 	    mach8AddCacheArea( mach8InfoRec.virtualX, 0,
! 			       1024-mach8InfoRec.virtualX,
! 			       mach8InfoRec.virtualY );
!     }
!     else {
! 	mach8AddCacheArea( 256, mach8InfoRec.virtualY,
! 			   mach8InfoRec.virtualX-256,
! 			   totaly-mach8InfoRec.virtualY > 256 ? 256 :
! 						totaly-mach8InfoRec.virtualY);
!     }
!     mach8TotalCacheCells = mach8FreeCacheCells;
!     if( x386Verbose && first )
! 	ErrorF( "%s %s: Total number of font cache cells (%dx%d) %d\n",
! 		XCONFIG_PROBED, mach8InfoRec.name,
! 		CACHECELL_WIDTH, CACHECELL_HEIGHT, mach8FreeCacheCells );
  
  
  }
  
  void
***************
*** 99,119 ****
      FontPtr font;
  {
      int i;
  
!     for (i = 0; i < NUM_FONTS; i++)
! 	if (mach8FontCache[i].font == font) {
! 	    mach8FontCache[i].font = (FontPtr)0;
! 	    mach8FontCache[i].lru = 0xffffffff;
! 	    return;
  	}
  }
  
! int
  mach8CacheFont8(font)
      FontPtr font;
  {
      int i, j, c;
-     int ret = -1;
      unsigned long n;
      unsigned char chr;
      int width, height;
--- 255,292 ----
      FontPtr font;
  {
      int i;
+     CacheFont8Rec *fpnt, *fpnt2;
  
!     if( mach8FontCache != NULL ) {
! 	fpnt = mach8FontCache;
! 	if( fpnt->font == font ) {
! 	    mach8FontCache = fpnt->next;
! 	    mach8FreeCellChain( fpnt->cells );
! 	    Xfree( fpnt );
! 	    mach8NumberOfCachedFonts--;
! 	}
! 	else {
! 	    while( fpnt->next != NULL ) {
! 		fpnt2 = fpnt->next;
! 		if (fpnt2->font == font) {
! 		    fpnt->next = fpnt2->next;
! 		    mach8FreeCellChain( fpnt2->cells );
! 		    Xfree( fpnt2 );
! 		    mach8NumberOfCachedFonts--;
! 		    break;
! 		}
! 		fpnt = fpnt2;
! 	    }
  	}
+     }
+ 
  }
  
! void *
  mach8CacheFont8(font)
      FontPtr font;
  {
      int i, j, c;
      unsigned long n;
      unsigned char chr;
      int width, height;
***************
*** 124,162 ****
      int gWidth, gHeight;
      int nbyGlyphWidth;
      int nbyPadGlyph;
  
-     for (i = 0; i < NUM_FONTS; i++)
- 	if (mach8FontCache[i].font == font)
- 	    ret = i;
  
      width = FONTMAXBOUNDS(font,rightSideBearing) -
  	    FONTMINBOUNDS(font,leftSideBearing);
      height = FONTMAXBOUNDS(font,ascent) + FONTMAXBOUNDS(font,descent);
! 
!     if ((ret == -1) && (width <= mach8FC_W) && (height <= mach8FC_H) &&
  	(FONTFIRSTROW(font) == 0) && (FONTLASTROW(font) == 0) &&
  	(FONTLASTCOL(font) < 256)) {
- 	ret = 0;
- 	for (i = 1; i < NUM_FONTS; i++)
- 	    if (mach8FontCache[i].lru > mach8FontCache[ret].lru)
- 		ret = i;
- 
  	nbyLine = PixmapBytePad(width, 1);
  	pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
! 	if (!pbits) {
! 	    return -1;
! 	}
! 
! 	mach8FontCache[ret].font = font;
! 	mach8FontCache[ret].lru = 0;
  
  	for (c = 0; c < 256; c++) {
  	    chr = (unsigned char)c;
  	    GetGlyphs(font, 1, &chr, Linear8Bit, &n, &pci);
  	    if (n == 0) {
! 		mach8FontCache[ret].pci[c] = NULL;
  	    } else {
! 		mach8FontCache[ret].pci[c] = pci;
  		pglyph = FONTGLYPHBITS(pglyphBase, pci);
  		gWidth = GLYPHWIDTHPIXELS(pci);
  		gHeight = GLYPHHEIGHTPIXELS(pci);
--- 297,378 ----
      int gWidth, gHeight;
      int nbyGlyphWidth;
      int nbyPadGlyph;
+     struct cachecell *cell;
+     int glyphs_cell, n_cells;
+     int cell_x, cell_y, cell_width, cell_height;
+     CacheFont8Rec *fpnt;
  
  
+     for (fpnt = mach8FontCache; fpnt != NULL; fpnt = fpnt->next) {
+ 	if( fpnt->font == font )
+ 	    return( (void *)(fpnt) );
+     }
      width = FONTMAXBOUNDS(font,rightSideBearing) -
  	    FONTMINBOUNDS(font,leftSideBearing);
      height = FONTMAXBOUNDS(font,ascent) + FONTMAXBOUNDS(font,descent);
!     fpnt = NULL;
!     if ((width <= FC_MAX_WIDTH) && (height <= FC_MAX_HEIGHT) &&
  	(FONTFIRSTROW(font) == 0) && (FONTLASTROW(font) == 0) &&
  	(FONTLASTCOL(font) < 256)) {
  	nbyLine = PixmapBytePad(width, 1);
  	pbits = (unsigned char *)ALLOCATE_LOCAL(height*nbyLine);
! 	if (!pbits)
! 	    return( NULL );
  
+ 	glyphs_cell = (CACHECELL_WIDTH/width)*(CACHECELL_HEIGHT/height);
+ 	n_cells = 256 / glyphs_cell;
+ 	if( ( 256 % glyphs_cell ) != 0 )
+ 	    n_cells++;
+ 
+ 	/*
+ 	 * Free old fonts until enough cache cells are available.
+ 	 */
+ 	while( ( cell = mach8AllocCellChain(n_cells) ) == NULL ) {
+ 	    if( mach8FontCache == NULL ) {
+ 		DEALLOCATE_LOCAL(pbits);
+ 		return( NULL );	/* No fonts cached and no cache cells free. */
+ 	    }
+ 	    /*
+ 	     * Find oldest cached font. ( last in linked list ).
+ 	     */
+ 	    for( fpnt = mach8FontCache; fpnt->next != NULL; fpnt = fpnt->next )
+ 		;
+ 
+ 	    /*
+ 	     * Uncache oldest cached font.
+ 	     */
+ 	    mach8UnCacheFont8( fpnt->font );
+ 	}
+ 	/*
+ 	 * Allocate a font cache record and link it first in the chain.
+ 	 */
+ 	if( ( fpnt = (CacheFont8Rec *)
+ 				 (Xalloc( sizeof(CacheFont8Rec)))) == NULL ) {
+ 	    DEALLOCATE_LOCAL(pbits);
+ 	    return( NULL );
+ 	}
+ 	fpnt->next = mach8FontCache;
+ 	mach8FontCache = fpnt;
+ 	mach8NumberOfCachedFonts++;
+ 
+ 	/*
+ 	 * Now we cache the font.
+ 	 */
+ 	fpnt->cells = cell;
+ 	fpnt->font = font;
+ 	cell_x = cell_y = 0;
+ 	cell_width = CACHECELL_WIDTH;
+ 	cell_height = CACHECELL_HEIGHT;
  	for (c = 0; c < 256; c++) {
+ 	    fpnt->pos[c].x = cell->x + cell_x;
+ 	    fpnt->pos[c].y = cell->y + cell_y;
+ 	    fpnt->pos[c].planemask = mach8ReadMask[cell->plane];
  	    chr = (unsigned char)c;
  	    GetGlyphs(font, 1, &chr, Linear8Bit, &n, &pci);
  	    if (n == 0) {
! 		fpnt->pci[c] = NULL;
  	    } else {
! 		fpnt->pci[c] = pci;
  		pglyph = FONTGLYPHBITS(pglyphBase, pci);
  		gWidth = GLYPHWIDTHPIXELS(pci);
  		gHeight = GLYPHHEIGHTPIXELS(pci);
***************
*** 178,201 ****
  				*pb++ = *pglyph++;
  			pb = pbits;
  		    }
! 		    mach8ImageOpStipple(mach8FC_X+(c%32)*mach8FC_W,
! 					  mach8FC_Y+(c/32)*mach8FC_H,
! 					  gWidth, gHeight,
! 					  pb, nbyGlyphWidth, gWidth, gHeight,
! 					  mach8FC_X+(c%32)*mach8FC_W,
! 					  mach8FC_Y+(c/32)*mach8FC_H,
! 					  0xff, 0, mach8alu[GXcopy],
! 					  (1 << ret));
  		}
  	    }
  	}
      }
! 
!     return ret;
  }
  
  int
! mach8CPolyText8(pDraw, pGC, x, y, count, chars, plane)
      DrawablePtr pDraw;
      GCPtr pGC;
      int x;
--- 394,440 ----
  				*pb++ = *pglyph++;
  			pb = pbits;
  		    }
! 		    (mach8ImageStippleFunc)(cell->x + cell_x,
! 					    cell->y + cell_y,
! 					    gWidth, gHeight,
! 					    pb, nbyGlyphWidth, gWidth, gHeight,
! 					    cell->x + cell_x,
! 					    cell->y + cell_y,
! 					    0xff, 0, mach8alu[GXcopy],
! 					    (1 << cell->plane), 1);
  		}
  	    }
+ 	    /*
+ 	     * Advance the cache cell pointers from left to right,
+ 	     * top to bottom, cell by cell.
+ 	     */
+ 	    cell_x += width;
+ 	    cell_width -= width;
+ 	    if( cell_width < width ) {
+ 		/*
+ 		 * At right edge. Try to put another row below this one.
+ 		 */
+ 		cell_width = CACHECELL_WIDTH;
+ 		cell_x = 0;
+ 		cell_y += height;
+ 		cell_height -= height;
+ 		if( cell_height < height ) {
+ 		    /*
+ 		     * Use next cache cell.
+ 		     */
+ 		    cell_height = CACHECELL_HEIGHT;
+ 		    cell_y = 0;
+ 		    cell = cell->next;
+ 		}
+ 	    }
  	}
+ 	DEALLOCATE_LOCAL(pbits);
      }
!     return( (void *)(fpnt) );
  }
  
  int
! mach8CPolyText8(pDraw, pGC, x, y, count, chars, vpnt)
      DrawablePtr pDraw;
      GCPtr pGC;
      int x;
***************
*** 202,208 ****
      int y;
      int count;
      unsigned char *chars;
!     int plane;
  {
      int		i;
      BoxPtr	pBox;
--- 441,447 ----
      int y;
      int count;
      unsigned char *chars;
!     void *vpnt;
  {
      int		i;
      BoxPtr	pBox;
***************
*** 213,222 ****
      int		minLeftBearing;
      FontPtr	pfont = pGC->font;
      int		xorig;
!     CharInfoPtr	pci;
!     CacheFont8Rec *mach8FCP = &(mach8FontCache[plane]);
      int         ret_x;
  
      /*
       * If miPolyText8() is to be believed, the returned new X value is
       * completely independent of what happens during rendering.
--- 452,466 ----
      int		minLeftBearing;
      FontPtr	pfont = pGC->font;
      int		xorig;
!     CacheFont8Rec *mach8FCP = (CacheFont8Rec *)(vpnt);
!     CacheFont8Rec *fpnt;
      int         ret_x;
+     CharInfoPtr	pci;
+     int		ci;
+     struct font_pos *pos;
+     unsigned short pmsk, width, height, gwidth, gheight;
  
+ 
      /*
       * If miPolyText8() is to be believed, the returned new X value is
       * completely independent of what happens during rendering.
***************
*** 226,235 ****
  	ret_x += mach8FCP->pci[(int)chars[i]] ?
  		 mach8FCP->pci[(int)chars[i]]->metrics.characterWidth : 0;
  
!     for (i = 0; i < NUM_FONTS; i++)
! 	if (i != plane && mach8FontCache[i].lru != 0xffffffff)
! 	    mach8FontCache[i].lru++;
! 
      x += pDraw->x;
      y += pDraw->y;
  
--- 470,485 ----
  	ret_x += mach8FCP->pci[(int)chars[i]] ?
  		 mach8FCP->pci[(int)chars[i]]->metrics.characterWidth : 0;
  
!     /*
!      * Make sure this font is first in the linked list.
!      */
!     if( mach8FCP != mach8FontCache ) {
! 	for( fpnt = mach8FontCache; fpnt->next != mach8FCP; fpnt = fpnt->next )
! 	    ;
! 	fpnt->next = mach8FCP->next;
! 	mach8FCP->next = mach8FontCache;
! 	mach8FontCache = mach8FCP;
!     }
      x += pDraw->x;
      y += pDraw->y;
  
***************
*** 257,270 ****
      if (!numRects)
  	return ret_x;
  
!     WaitQueue(6);
      outw(FRGD_COLOR, (short)pGC->fgPixel);
      outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPBLT | COLCMPOP_F);
-     outw(RD_MASK, mach8ReadMask[plane]);
      outw(FRGD_MIX, FSS_FRGDCOL | mach8alu[pGC->alu]);
      outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
      outw(WRT_MASK, (short)pGC->planemask);
- 
      for (xorig = x; --numRects >= 0; ++pBox, x = xorig) {
  	WaitQueue(4);
  	outw(MULTIFUNC_CNTL, SCISSORS_L | (short)pBox->x1);
--- 507,518 ----
      if (!numRects)
  	return ret_x;
  
!     WaitQueue(5);
      outw(FRGD_COLOR, (short)pGC->fgPixel);
      outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPBLT | COLCMPOP_F);
      outw(FRGD_MIX, FSS_FRGDCOL | mach8alu[pGC->alu]);
      outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
      outw(WRT_MASK, (short)pGC->planemask);
      for (xorig = x; --numRects >= 0; ++pBox, x = xorig) {
  	WaitQueue(4);
  	outw(MULTIFUNC_CNTL, SCISSORS_L | (short)pBox->x1);
***************
*** 271,292 ****
  	outw(MULTIFUNC_CNTL, SCISSORS_T | (short)pBox->y1);
  	outw(MULTIFUNC_CNTL, SCISSORS_R | (short)(pBox->x2-1));
  	outw(MULTIFUNC_CNTL, SCISSORS_B | (short)(pBox->y2-1));
! 
  	for (i = 0; i < count; i++) {
! 	    pci = mach8FCP->pci[(int)chars[i]];
! 
  	    if (pci != NULL) {
! 		if (GLYPHHEIGHTPIXELS(pci) && GLYPHWIDTHPIXELS(pci))
! 		{
! 		    WaitQueue(7);
! 		    outw(CUR_X, (short)(mach8FC_X+(((int)chars[i])%32)*mach8FC_W));
! 		    outw(CUR_Y, (short)(mach8FC_Y+(((int)chars[i])/32)*mach8FC_H));
  		    outw(DESTX_DIASTP, (short)(x + pci->metrics.leftSideBearing));
  		    outw(DESTY_AXSTP, (short)(y - pci->metrics.ascent));
! 		    outw(MAJ_AXIS_PCNT, (short)(GLYPHWIDTHPIXELS(pci)-1));
! 		    outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT |
! 			 (short)(GLYPHHEIGHTPIXELS(pci)-1));
! 		    outw(CMD, CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
  		}
  		x += pci->metrics.characterWidth;
  	    }
--- 519,553 ----
  	outw(MULTIFUNC_CNTL, SCISSORS_T | (short)pBox->y1);
  	outw(MULTIFUNC_CNTL, SCISSORS_R | (short)(pBox->x2-1));
  	outw(MULTIFUNC_CNTL, SCISSORS_B | (short)(pBox->y2-1));
! 	pmsk = width = height = 0;
  	for (i = 0; i < count; i++) {
! 	    ci = (int)(chars[i]);
! 	    pci = mach8FCP->pci[ci];
! 	    pos = &mach8FCP->pos[ci];
  	    if (pci != NULL) {
! 		if( ( gheight = (short)(GLYPHHEIGHTPIXELS(pci)) )
! 		&& ( gwidth = (short)(GLYPHWIDTHPIXELS(pci)) ) ) {
! 		    gheight--;
! 		    gwidth--;
! 		    WaitQueue(8);
! 		    if( !pmsk || pmsk != pos->planemask ) {
! 			pmsk = pos->planemask;
! 			outw(RD_MASK, pmsk);
! 		    }
! 		    outw(CUR_X, pos->x);
! 		    outw(CUR_Y, pos->y);
  		    outw(DESTX_DIASTP, (short)(x + pci->metrics.leftSideBearing));
  		    outw(DESTY_AXSTP, (short)(y - pci->metrics.ascent));
! 		    if( !width || width != gwidth ) {
! 			width = gwidth;
! 			outw(MAJ_AXIS_PCNT, width);
! 		    }
! 		    if( !height || height != gheight ){
! 			height = gheight;
! 			outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | height);
! 		    }
! 		    outw(CMD,
! 			 CMD_BITBLT | INC_X | INC_Y | DRAW | PLANAR | WRTDATA);
  		}
  		x += pci->metrics.characterWidth;
  	    }
***************
*** 308,314 ****
  
  
  void
! mach8CImageText8(pDraw, pGC, x, y, count, chars, plane)
      DrawablePtr pDraw;
      GCPtr pGC;
      int x;
--- 569,701 ----
  
  
  void
! mach8AccPolyText8(pDraw, pGC, x, y, count, chars)
!     DrawablePtr pDraw;
!     GCPtr	pGC;
!     int		x, y;
!     int		count;
!     char	*chars;
! {
!     int i, j;
!     FontPtr font = pGC->font;
!     unsigned long n;
!     int nbyLine;
!     unsigned char *pb, *pbits;
!     CharInfoPtr pci;
!     unsigned char *pglyph;
!     int gWidth, gHeight;
!     int nbyGlyphWidth;
!     int nbyPadGlyph;
!     int		maxAscent, maxDescent;
!     int		minLeftBearing;
!     BoxPtr	pBox;
!     int		numRects;
!     RegionPtr	pRegion;
!     int		yBand;
!     int		xorig;
!     int		clipx, clipy, clipw, cliph, xoff, yoff;
! 
! 
!     gWidth = FONTMAXBOUNDS(font,rightSideBearing) -
! 	    FONTMINBOUNDS(font,leftSideBearing);
!     gHeight = FONTMAXBOUNDS(font,ascent) + FONTMAXBOUNDS(font,descent);
!     nbyLine = PixmapBytePad(gWidth, 1);
!     pbits = (unsigned char *)ALLOCATE_LOCAL(gHeight*nbyLine);
!     if (!pbits)
! 	return;
! 
!     x += pDraw->x;
!     y += pDraw->y;
! 
!     maxAscent = FONTMAXBOUNDS(font,ascent);
!     maxDescent = FONTMAXBOUNDS(font,descent);
!     minLeftBearing = FONTMINBOUNDS(font,leftSideBearing);
! 
!     pRegion = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
! 
!     pBox = REGION_RECTS(pRegion);
!     numRects = REGION_NUM_RECTS (pRegion);
!     while (numRects && pBox->y2 <= y - maxAscent)
!     {
! 	++pBox;
! 	--numRects;
!     }
!     if (!numRects || pBox->y1 >= y + maxDescent) {
! 	DEALLOCATE_LOCAL(pbits);
! 	return;
!     }
!     yBand = pBox->y1;
!     while (numRects && pBox->y1 == yBand && pBox->x2 <= x + minLeftBearing)
!     {
! 	++pBox;
! 	--numRects;
!     }
!     if (!numRects) {
! 	DEALLOCATE_LOCAL(pbits);
! 	return;
!     }
!     for (xorig = x; --numRects >= 0; ++pBox, x = xorig) {
! 	for (i = 0; i < count; i++) {
! 	    GetGlyphs(font, 1, &chars[i], Linear8Bit, &n, &pci);
! 	    if (n != 0) {
! 		pglyph = FONTGLYPHBITS(pglyphBase, pci);
! 		gWidth = GLYPHWIDTHPIXELS(pci);
! 		gHeight = GLYPHHEIGHTPIXELS(pci);
! 		clipx = x + pci->metrics.leftSideBearing;
! 		clipy = y - pci->metrics.ascent;
! 		if( gWidth && gHeight
! 		&& clipx + gWidth > pBox->x1 && clipx < pBox->x2
! 		&& clipy + gHeight > pBox->y1 && clipy < pBox->y2 ) {
! 		    xoff = ( clipx < pBox->x1 ? pBox->x1 - clipx : 0 );
! 		    if( clipx + gWidth > pBox->x2 )
! 			clipw = gWidth - xoff - ((clipx + gWidth) - pBox->x2);
! 		    else
! 			clipw = gWidth - xoff;
! 
! 		    yoff = ( clipy < pBox->y1 ? pBox->y1 - clipy : 0 );
! 		    if( clipy + gHeight > pBox->y2 )
! 			cliph = gHeight-yoff - ((clipy + gHeight) - pBox->y2);
! 		    else
! 			cliph = gHeight - yoff;
! 
! 		    nbyGlyphWidth = GLYPHWIDTHBYTESPADDED(pci);
! 		    nbyPadGlyph = PixmapBytePad(gWidth, 1);
! 		    
! 		    if (nbyGlyphWidth == nbyPadGlyph
! #if GLYPHPADBYTES != 4
! 			&& (((int) pglyph) & 3) == 0
! #endif
! 			) {
! 			pb = pglyph;
! 		    } else {
! 			for (i = 0, pb = pbits;
! 			     i < gHeight;
! 			     i++, pb = pbits+(i*nbyPadGlyph))
! 			    for (j = 0; j < nbyGlyphWidth; j++)
! 				*pb++ = *pglyph++;
! 			pb = pbits;
! 		    }
! 		    (mach8ImageStippleFunc)( clipx + xoff,
! 					     clipy + yoff,
! 					     clipw, cliph,
! 					     pb, nbyGlyphWidth,
! 					     gWidth, gHeight,
! 					     clipx, clipy,
! 					     pGC->fgPixel, pGC->bgPixel,
! 					     mach8alu[pGC->alu],
! 					     pGC->planemask, 1);
! 		}
! 		x += pci->metrics.characterWidth;
! 	    }
! 	}
!     }
!     DEALLOCATE_LOCAL(pbits);
! 
! }
! 
! 
! void
! mach8CImageText8(pDraw, pGC, x, y, count, chars, vpnt)
      DrawablePtr pDraw;
      GCPtr pGC;
      int x;
***************
*** 315,321 ****
      int y;
      int count;
      unsigned char *chars;
!     int plane;
  {
      ExtentInfoRec info;		/* used by QueryGlyphExtents() */
      XID gcvals[3];
--- 702,708 ----
      int y;
      int count;
      unsigned char *chars;
!     void *vpnt;
  {
      ExtentInfoRec info;		/* used by QueryGlyphExtents() */
      XID gcvals[3];
***************
*** 364,370 ****
      gcvals[0] = oldFG;
      DoChangeGC(pGC, GCForeground, gcvals, 0);
      ValidateGC(pDraw, pGC);
!     (void)mach8CPolyText8(pDraw, pGC, x, y, count, chars, plane);
  
      /* put all the toys away when done playing */
      gcvals[0] = oldAlu;
--- 751,760 ----
      gcvals[0] = oldFG;
      DoChangeGC(pGC, GCForeground, gcvals, 0);
      ValidateGC(pDraw, pGC);
!     if( vpnt == NULL )
! 	mach8AccPolyText8(pDraw, pGC, x, y, count, chars );
!     else
! 	(void)mach8CPolyText8(pDraw, pGC, x, y, count, chars, vpnt);
  
      /* put all the toys away when done playing */
      gcvals[0] = oldAlu;
diff -c mit/server/ddx/x386/accel/mach8/mach8frect.c:2.3 mit/server/ddx/x386/accel/mach8/mach8frect.c:2.5
*** mit/server/ddx/x386/accel/mach8/mach8frect.c:2.3	Fri Mar 11 23:37:32 1994
--- mit/server/ddx/x386/accel/mach8/mach8frect.c	Fri Mar 11 23:37:32 1994
***************
*** 31,37 ****
  
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8frect.c,v 2.3 1993/08/28 07:51:11 dawes Exp $ */
  
  /* $XConsortium: cfbfillrct.c,v 5.13 90/05/15 18:40:19 keith Exp $ */
  
--- 31,37 ----
  
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8frect.c,v 2.5 1994/02/01 13:51:32 dawes Exp $ */
  
  /* $XConsortium: cfbfillrct.c,v 5.13 90/05/15 18:40:19 keith Exp $ */
  
***************
*** 299,322 ****
  					    mach8alu[pGC->alu],
  					    pGC->planemask);
  		    else
! 			mach8ImageStipple(pboxClipped->x1, pboxClipped->y1,
! 					   w, h,
! 					   pPix->devPrivate.ptr, pixWidth,
! 					   width, height, xrot, yrot,
! 					   pGC->fgPixel,
! 					   mach8alu[pGC->alu],
! 					   pGC->planemask);
  		    pboxClipped++;
  		}
  	    } else {
  		while (n--) {
! 		    mach8ImageStipple(pboxClipped->x1, pboxClipped->y1,
! 					pboxClipped->x2 - pboxClipped->x1,
! 					pboxClipped->y2 - pboxClipped->y1,
! 					pPix->devPrivate.ptr, pixWidth,
! 					width, height, xrot, yrot,
! 					pGC->fgPixel,
! 					mach8alu[pGC->alu], pGC->planemask);
  		    pboxClipped++;
  		}
  	    }
--- 299,324 ----
  					    mach8alu[pGC->alu],
  					    pGC->planemask);
  		    else
! 			(mach8ImageStippleFunc)(pboxClipped->x1,
! 						pboxClipped->y1,
! 						w, h,
! 						pPix->devPrivate.ptr, pixWidth,
! 						width, height, xrot, yrot,
! 						pGC->fgPixel, 0,
! 						mach8alu[pGC->alu],
! 						pGC->planemask, 0);
  		    pboxClipped++;
  		}
  	    } else {
  		while (n--) {
! 		    (mach8ImageStippleFunc)(pboxClipped->x1, pboxClipped->y1,
! 					    pboxClipped->x2 - pboxClipped->x1,
! 					    pboxClipped->y2 - pboxClipped->y1,
! 					    pPix->devPrivate.ptr, pixWidth,
! 					    width, height, xrot, yrot,
! 					    pGC->fgPixel, 0,
! 					    mach8alu[pGC->alu],
! 					    pGC->planemask, 0);
  		    pboxClipped++;
  		}
  	    }
***************
*** 345,370 ****
  					      mach8alu[pGC->alu],
  					      pGC->planemask);
  		    else
! 			mach8ImageOpStipple(pboxClipped->x1, pboxClipped->y1,
! 					     w, h,
! 					     pPix->devPrivate.ptr, pixWidth,
! 					     width, height,
! 					   xrot, yrot,
! 					   pGC->fgPixel, pGC->bgPixel,
! 					   mach8alu[pGC->alu],
! 					   pGC->planemask);
  		    pboxClipped++;
  		}
  	    } else {
  		while (n--) {
! 		    mach8ImageOpStipple(pboxClipped->x1, pboxClipped->y1,
! 					  pboxClipped->x2 - pboxClipped->x1,
! 					  pboxClipped->y2 - pboxClipped->y1,
! 					  pPix->devPrivate.ptr, pixWidth,
! 					  width, height, xrot, yrot,
! 					  pGC->fgPixel, pGC->bgPixel,
! 					  mach8alu[pGC->alu],
! 					  pGC->planemask);
  		    pboxClipped++;
  		}
  	    }
--- 347,373 ----
  					      mach8alu[pGC->alu],
  					      pGC->planemask);
  		    else
! 			(mach8ImageStippleFunc)(pboxClipped->x1,
! 						pboxClipped->y1,
! 						w, h,
! 						pPix->devPrivate.ptr, pixWidth,
! 						width, height,
! 						xrot, yrot,
! 						pGC->fgPixel, pGC->bgPixel,
! 						mach8alu[pGC->alu],
! 						pGC->planemask, 1);
  		    pboxClipped++;
  		}
  	    } else {
  		while (n--) {
! 		    (mach8ImageStippleFunc)(pboxClipped->x1, pboxClipped->y1,
! 					    pboxClipped->x2 - pboxClipped->x1,
! 					    pboxClipped->y2 - pboxClipped->y1,
! 					    pPix->devPrivate.ptr, pixWidth,
! 					    width, height, xrot, yrot,
! 					    pGC->fgPixel, pGC->bgPixel,
! 					    mach8alu[pGC->alu],
! 					    pGC->planemask, 1);
  		    pboxClipped++;
  		}
  	    }
diff -c mit/server/ddx/x386/accel/mach8/mach8fs.c:2.3 mit/server/ddx/x386/accel/mach8/mach8fs.c:2.6
*** mit/server/ddx/x386/accel/mach8/mach8fs.c:2.3	Fri Mar 11 23:37:33 1994
--- mit/server/ddx/x386/accel/mach8/mach8fs.c	Fri Mar 11 23:37:33 1994
***************
*** 64,70 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8fs.c,v 2.3 1993/08/28 07:51:13 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 64,70 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8fs.c,v 2.6 1994/02/01 13:51:33 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 229,235 ****
  
      if (mach8CacheTile(pPix)) {
  	while (n--) {
! 	    if (*pwidth < 50)
  		mach8ImageFill(ppt->x, ppt->y, *pwidth, 1,
  			       pPix->devPrivate.ptr, pixWidth,
  			       width, height, xrot, yrot,
--- 229,235 ----
  
      if (mach8CacheTile(pPix)) {
  	while (n--) {
! 	    if (*pwidth < 9)
  		mach8ImageFill(ppt->x, ppt->y, *pwidth, 1,
  			       pPix->devPrivate.ptr, pixWidth,
  			       width, height, xrot, yrot,
***************
*** 326,337 ****
  
      if (mach8CacheStipple(pPix)) {
  	while (n--) {
! 	    if (*pwidth < 50)
! 		mach8ImageStipple(ppt->x, ppt->y, *pwidth, 1,
! 				  pPix->devPrivate.ptr, pixWidth,
! 				  width, height,
! 				  xrot, yrot, pGC->fgPixel,
! 				  mach8alu[pGC->alu], pGC->planemask);
  	    else
  		mach8CImageStipple(pPix->slot,
  				   ppt->x, ppt->y, *pwidth, 1, xrot, yrot,
--- 326,337 ----
  
      if (mach8CacheStipple(pPix)) {
  	while (n--) {
! 	    if (*pwidth < 9)
! 		(mach8ImageStippleFunc)(ppt->x, ppt->y, *pwidth, 1,
! 					pPix->devPrivate.ptr, pixWidth,
! 					width, height,
! 					xrot, yrot, pGC->fgPixel, 0,
! 					mach8alu[pGC->alu], pGC->planemask, 0);
  	    else
  		mach8CImageStipple(pPix->slot,
  				   ppt->x, ppt->y, *pwidth, 1, xrot, yrot,
***************
*** 342,351 ****
      	}
      } else {
  	while (n--) {
! 	    mach8ImageStipple(ppt->x, ppt->y, *pwidth, 1,
! 				pPix->devPrivate.ptr, pixWidth, width, height,
! 				xrot, yrot, pGC->fgPixel,
! 				mach8alu[pGC->alu], pGC->planemask);
  	    ppt++;
  	    pwidth++;
      	}
--- 342,352 ----
      	}
      } else {
  	while (n--) {
! 	    (mach8ImageStippleFunc)(ppt->x, ppt->y, *pwidth, 1,
! 				    pPix->devPrivate.ptr, pixWidth,
! 				    width, height,
! 				    xrot, yrot, pGC->fgPixel, 0,
! 				    mach8alu[pGC->alu], pGC->planemask, 0);
  	    ppt++;
  	    pwidth++;
      	}
***************
*** 425,436 ****
  
      if (mach8CacheOpStipple(pPix)) {
  	while (n--) {
! 	    if (*pwidth < 50)
! 		mach8ImageOpStipple(ppt->x, ppt->y, *pwidth, 1,
! 				    pPix->devPrivate.ptr, pixWidth,
! 				    width, height,
! 				    xrot, yrot, pGC->fgPixel, pGC->bgPixel,
! 				    mach8alu[pGC->alu], pGC->planemask);
  	    else
  		mach8CImageOpStipple(pPix->slot,
  				     ppt->x, ppt->y, *pwidth, 1, xrot, yrot,
--- 426,437 ----
  
      if (mach8CacheOpStipple(pPix)) {
  	while (n--) {
! 	    if (*pwidth < 9)
! 		(mach8ImageStippleFunc)(ppt->x, ppt->y, *pwidth, 1,
! 					pPix->devPrivate.ptr, pixWidth,
! 					width, height,
! 					xrot, yrot, pGC->fgPixel, pGC->bgPixel,
! 					mach8alu[pGC->alu], pGC->planemask, 1);
  	    else
  		mach8CImageOpStipple(pPix->slot,
  				     ppt->x, ppt->y, *pwidth, 1, xrot, yrot,
***************
*** 441,451 ****
      	}
      } else {
  	while (n--) {
! 	    mach8ImageOpStipple(ppt->x, ppt->y, *pwidth, 1,
! 				  pPix->devPrivate.ptr, pixWidth,
! 				  width, height,
! 				  xrot, yrot, pGC->fgPixel, pGC->bgPixel,
! 				  mach8alu[pGC->alu], pGC->planemask);
  	    ppt++;
  	    pwidth++;
      	}
--- 442,452 ----
      	}
      } else {
  	while (n--) {
! 	    (mach8ImageStippleFunc)(ppt->x, ppt->y, *pwidth, 1,
! 				    pPix->devPrivate.ptr, pixWidth,
! 				    width, height,
! 				    xrot, yrot, pGC->fgPixel, pGC->bgPixel,
! 				    mach8alu[pGC->alu], pGC->planemask, 1);
  	    ppt++;
  	    pwidth++;
      	}
diff -c mit/server/ddx/x386/accel/mach8/mach8gc.c:2.2 mit/server/ddx/x386/accel/mach8/mach8gc.c:2.4
*** mit/server/ddx/x386/accel/mach8/mach8gc.c:2.2	Fri Mar 11 23:37:34 1994
--- mit/server/ddx/x386/accel/mach8/mach8gc.c	Fri Mar 11 23:37:34 1994
***************
*** 25,31 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8gc.c,v 2.2 1993/09/21 15:22:07 dawes Exp $ */
  
  /* $XConsortium: cfbgc.c,v 1.2 91/07/18 23:00:53 keith Exp $ */
  
--- 25,31 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8gc.c,v 2.4 1993/12/25 13:58:54 dawes Exp $ */
  
  /* $XConsortium: cfbgc.c,v 1.2 91/07/18 23:00:53 keith Exp $ */
  
***************
*** 51,57 ****
  
  static void cfbValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
  static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
! static cfbDestroyOps();
  
  static GCFuncs cfbFuncs = {
      cfbValidateGC,
--- 51,57 ----
  
  static void cfbValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
  static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
! static void cfbDestroyOps();
  
  static GCFuncs cfbFuncs = {
      cfbValidateGC,
***************
*** 66,72 ****
  static GCOps	mach8Ops = {
      mach8SolidFSpans,
      mach8SetSpans,
!     miPutImage,
      mach8CopyArea,
      mach8CopyPlane,
      mach8PolyPoint,
--- 66,72 ----
  static GCOps	mach8Ops = {
      mach8SolidFSpans,
      mach8SetSpans,
!     cfbPutImage,
      mach8CopyArea,
      mach8CopyPlane,
      mach8PolyPoint,
***************
*** 319,325 ****
      return ret;
  }
  
! static
  cfbDestroyOps (ops)
      GCOps   *ops;
  {
--- 319,325 ----
      return ret;
  }
  
! static void
  cfbDestroyOps (ops)
      GCOps   *ops;
  {
diff -c mit/server/ddx/x386/accel/mach8/mach8gs.c:2.2 mit/server/ddx/x386/accel/mach8/mach8gs.c:2.5
*** mit/server/ddx/x386/accel/mach8/mach8gs.c:2.2	Fri Mar 11 23:37:34 1994
--- mit/server/ddx/x386/accel/mach8/mach8gs.c	Fri Mar 11 23:37:35 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8gs.c,v 2.2 1993/08/17 16:15:34 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8gs.c,v 2.5 1994/02/01 13:51:35 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 60,66 ****
  {
      int			j;
      unsigned char	*pdst; /* where to put the bits */
-     unsigned char	*psrc; /* where to get the bits */
      int			pixmapStride;
  
  /* 11-jun-93 TCG : is VT visible */
--- 60,65 ----
***************
*** 91,97 ****
      pdst = (unsigned char *)pdstStart;
  
      for (; nspans--; ppt++, pwidth++) {
! 	mach8ImageRead(ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride, 0, 0);
  	pdst += j;		/* width is in 32 bit words */
  	j = (-j) & 3;
  	while (j--)		/* Pad out to 32-bit boundary */
--- 90,97 ----
      pdst = (unsigned char *)pdstStart;
  
      for (; nspans--; ppt++, pwidth++) {
! 	(mach8ImageReadFunc)(ppt->x, ppt->y, j = *pwidth, 1,
! 			     pdst, pixmapStride, 0, 0, 0xff);
  	pdst += j;		/* width is in 32 bit words */
  	j = (-j) & 3;
  	while (j--)		/* Pad out to 32-bit boundary */
diff -c /dev/null mit/server/ddx/x386/accel/mach8/mach8gtimg.c:2.1
*** /dev/null	Fri Mar 11 23:37:35 1994
--- mit/server/ddx/x386/accel/mach8/mach8gtimg.c	Fri Mar 11 23:37:35 1994
***************
*** 0 ****
--- 1,82 ----
+ /*
+  * 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.
+  *
+  */
+ /*
+  * Stolen from the S3 server and adapted to the Mach8 server.
+  * Hans Nasten. (nasten@everyware.se).
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8gtimg.c,v 2.1 1994/02/01 13:51:36 dawes Exp $ */
+ 
+ #include "X.h"
+ #include "windowstr.h"
+ #include "scrnintstr.h"
+ #include "pixmapstr.h"
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "mach8.h"
+ 
+ extern void mfbGetImage();
+ 
+ void
+ mach8GetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine)
+      DrawablePtr pDrawable;
+      int         sx, sy, w, h;
+      unsigned int format;
+      unsigned long planeMask;
+      pointer     pdstLine;
+ {
+    int width;
+ 
+    if ((w == 0) || (h == 0))
+       return;
+ 
+    if (pDrawable->bitsPerPixel == 1)
+    {
+       mfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+       return;
+    }
+ 
+    if (pDrawable->type != DRAWABLE_WINDOW)
+    {
+       cfbGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+       return;
+    }
+ 
+    width = PixmapBytePad(w, pDrawable->depth);
+    if (format == ZPixmap)
+    {
+       (mach8ImageReadFunc)(sx+pDrawable->x, sy+pDrawable->y, w, h, 
+ 			   pdstLine, width, 0, 0, planeMask);
+    }
+    else
+    {
+       /*
+        * Worry about this later (much!).  Should be straighforward, though.
+        * Read an image into a dummy pixmap, then use cfbCopyPlane8to1 to
+        * copy each plane in planeMask into the destination.  At least
+        * this is the theory.
+        */
+       miGetImage(pDrawable, sx, sy, w, h, format, planeMask, pdstLine);
+    }
+ }
+ 
diff -c mit/server/ddx/x386/accel/mach8/mach8im.c:2.12 mit/server/ddx/x386/accel/mach8/mach8im.c:2.17
*** mit/server/ddx/x386/accel/mach8/mach8im.c:2.12	Fri Mar 11 23:37:36 1994
--- mit/server/ddx/x386/accel/mach8/mach8im.c	Fri Mar 11 23:37:36 1994
***************
*** 25,35 ****
   * A few speedups by Hans Nasten (nasten@everyware.se)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8im.c,v 2.12 1993/09/21 15:22:10 dawes Exp $ */
  
  #include "os.h"
  #include "regmach8.h"
  #include "mach8im.h"
  
  #define ASM_IMAGE
  
--- 25,36 ----
   * A few speedups by Hans Nasten (nasten@everyware.se)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8im.c,v 2.17 1994/02/01 13:51:37 dawes Exp $ */
  
  #include "os.h"
  #include "regmach8.h"
  #include "mach8im.h"
+ #include "mach8.h"
  
  #define ASM_IMAGE
  
***************
*** 84,93 ****
  	return;
  
      if( pox == 0 && poy == 0 && pw >= x+w && ph >= y+h )
! 	mach8ImageWrite(x, y, w, h, psrc, pwidth, x, y, alu, planemask);
      else
! 	mach8RealImageFill(x, y, w, h, psrc, pwidth,
! 			   pw, ph, pox, poy, alu, planemask);
  }
  
  #else /* ASM_IMAGE */
--- 85,94 ----
  	return;
  
      if( pox == 0 && poy == 0 && pw >= x+w && ph >= y+h )
! 	(mach8ImageWriteFunc)(x, y, w, h, psrc, pwidth, x, y, alu, planemask);
      else
! 	(mach8RealImageFillFunc)(x, y, w, h, psrc, pwidth,
! 				 pw, ph, pox, poy, alu, planemask);
  }
  
  #else /* ASM_IMAGE */
***************
*** 143,149 ****
  }
  
  void
! mach8ImageRead(x, y, w, h, psrc, pwidth, px, py)
      int			x;
      int			y;
      int			w;
--- 144,150 ----
  }
  
  void
! mach8ImageRead(x, y, w, h, psrc, pwidth, px, py, planemask)
      int			x;
      int			y;
      int			w;
***************
*** 152,157 ****
--- 153,159 ----
      int			pwidth;
      int			px;
      int			py;
+     short		planemask;
  {
      int i, j;
      unsigned short *sp;
***************
*** 169,181 ****
      outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | BYTSEQ |_16BIT | PCDATA);
      sp = (unsigned short*)(psrc + pwidth * py + px);
      pwidth = pwidth / 2 - w / 2;
      WaitDataReady();
      if( w & 1 ) {
  	w /= 2;
  	for (j = 0; j < h; j++) {
  	    for (i = 0; i < w; i++)
! 		*sp++ = inw(PIX_TRANS);
! 	    *((unsigned char *)(sp)) = (unsigned char)(inw(PIX_TRANS));
  	    sp += pwidth;
          }
      }
--- 171,185 ----
      outw(CMD, CMD_RECT | INC_Y | INC_X | DRAW | BYTSEQ |_16BIT | PCDATA);
      sp = (unsigned short*)(psrc + pwidth * py + px);
      pwidth = pwidth / 2 - w / 2;
+     planemask = (planemask & 0x00ff) | ((planemask << 8) & 0xff00);
      WaitDataReady();
      if( w & 1 ) {
  	w /= 2;
  	for (j = 0; j < h; j++) {
  	    for (i = 0; i < w; i++)
! 		*sp++ = inw(PIX_TRANS) & planemask;
! 	    *((unsigned char *)(sp)) = (unsigned char)(inw(PIX_TRANS))
! 					& (unsigned char)(planemask);
  	    sp += pwidth;
          }
      }
***************
*** 183,189 ****
  	w /= 2;
  	for (j = 0; j < h; j++) {
  	    for (i = 0; i < w; i++)
! 		*sp++ = inw(PIX_TRANS);
  	    sp += pwidth;
  	}
      }
--- 187,193 ----
  	w /= 2;
  	for (j = 0; j < h; j++) {
  	    for (i = 0; i < w; i++)
! 		*sp++ = inw(PIX_TRANS) & planemask;
  	    sp += pwidth;
  	}
      }
***************
*** 276,283 ****
  }
  
  void
! mach8RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
! 		      fgPixel, bgPixel, alu, planemask, opaque)
      int			x;
      int			y;
      int			w;
--- 280,287 ----
  }
  
  void
! mach8ImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
! 		  fgPixel, bgPixel, alu, planemask, opaque)
      int			x;
      int			y;
      int			w;
***************
*** 319,373 ****
      outw(CUR_Y, (short)y);
      outw(CMD, CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |
  	      YMAJAXIS | DRAW | PLANAR | WRTDATA);
-     WaitQueue(16);
      modulus(x - pox, pw, x);
      modulus(y - poy, ph, y);
!     while( h > 0 ) {
! 	srch = ( y+h > ph ? ph - y : h );
! 	while( srch > 0 ) {
! 	    dstw = w;
! 	    srcx = x;
! 	    ptmp = (unsigned short *)(psrc + pwidth * y);
! 	    while( dstw > 0 ) {
! 		int np, x2;
! 		unsigned short *pnt, pix;
! 		/*
! 		 * Assemble 16 bits and feed them to the draw engine.
! 		 */
! 		np = pw - srcx;			/* No. pixels left in bitmap.*/
! 		pnt =(unsigned short *)((unsigned char *)(ptmp) + (srcx >> 3));
! 		x2 = srcx & 7;			/* Offset within byte. */
! 		if( np >= 16 ) {
! 		    pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
! 		}
! 		else if( pw >= 16 ) {
! 		    pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
  						 & MSKBIT(np)) | (*ptmp << np);
! 		}
! 		else if( pw >= 8 ) {
! 		    pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
  						      | (*pnt << (np+pw));
- 		}
- 		else {
- 		    pix = (*ptmp >> x2) & MSKBIT(np);
- 		    while( np < 16 && np < dstw ) {
- 			pix |= *ptmp << np;
- 			np += pw;
  		    }
  		}
! 		outw( PIX_TRANS, mach8stipple_tab[ pix & 0xff ] );
! 		if( dstw > 8 )
! 		    outw( PIX_TRANS, mach8stipple_tab[ ( pix >> 8 ) & 0xff ] );
! 		srcx += 16;
! 		if( srcx >= pw )
! 		    srcx -= pw;
! 		dstw -= 16;
  	    }
! 	    y++;
! 	    h--;
! 	    srch--;
  	}
- 	y = 0;
      }
      WaitQueue(5);
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
--- 323,400 ----
      outw(CUR_Y, (short)y);
      outw(CMD, CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |
  	      YMAJAXIS | DRAW | PLANAR | WRTDATA);
      modulus(x - pox, pw, x);
      modulus(y - poy, ph, y);
!     WaitQueue(16);
!     /*
!      * When the source bitmap is properly aligned, max 16 pixels wide,
!      * and nonrepeating use this faster loop instead.
!      * This speeds up all copying to the font cache.
!      */
!     if( (x & 7) == 0 && w <= 16 && x+w <= pw && y+h <= ph ) {
! 	unsigned short pix;
! 	unsigned char *pnt;
! 
! 	pnt = (unsigned char *)(psrc + pwidth * y + (x >> 3));
! 	while( h-- > 0 ) {
! 	    pix = *((unsigned short *)(pnt));
! 	    outw( PIX_TRANS, mach8stipple_tab[ pix & 0xff ] );
! 	    if( w > 8 )
! 		outw( PIX_TRANS, mach8stipple_tab[ ( pix >> 8 ) & 0xff ] );
! 
! 	    pnt += pwidth;
! 	}
!     }
!     else {
! 	while( h > 0 ) {
! 	    srch = ( y+h > ph ? ph - y : h );
! 	    while( srch > 0 ) {
! 		dstw = w;
! 		srcx = x;
! 		ptmp = (unsigned short *)(psrc + pwidth * y);
! 		while( dstw > 0 ) {
! 		    int np, x2;
! 		    unsigned short *pnt, pix;
! 		    /*
! 		     * Assemble 16 bits and feed them to the draw engine.
! 		     */
! 		    np = pw - srcx;		/* No. pixels left in bitmap.*/
! 		    pnt =(unsigned short *)
! 				       ((unsigned char *)(ptmp) + (srcx >> 3));
! 		    x2 = srcx & 7;		/* Offset within byte. */
! 		    if( np >= 16 ) {
! 			pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
! 		    }
! 		    else if( pw >= 16 ) {
! 			pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
  						 & MSKBIT(np)) | (*ptmp << np);
! 		    }
! 		    else if( pw >= 8 ) {
! 			pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
  						      | (*pnt << (np+pw));
  		    }
+ 		    else {
+ 			pix = (*ptmp >> x2) & MSKBIT(np);
+ 			while( np < 16 && np < dstw ) {
+ 			    pix |= *ptmp << np;
+ 			    np += pw;
+ 			}
+ 		    }
+ 		    outw( PIX_TRANS, mach8stipple_tab[ pix & 0xff ] );
+ 		    if( dstw > 8 )
+ 			outw( PIX_TRANS,
+ 			      mach8stipple_tab[ ( pix >> 8 ) & 0xff ] );
+ 		    srcx += 16;
+ 		    if( srcx >= pw )
+ 			srcx -= pw;
+ 		    dstw -= 16;
  		}
! 		y++;
! 		h--;
! 		srch--;
  	    }
! 	    y = 0;
  	}
      }
      WaitQueue(5);
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
***************
*** 378,418 ****
  }
  
  #endif /* ASM_IMAGE */
- 
- void
- mach8ImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, fgPixel, alu, planemask)
-     int			x;
-     int			y;
-     int			w;
-     int			h;
-     unsigned char	*psrc;
-     int			pwidth;
-     int			pw, ph, pox, poy;
-     int			fgPixel;
-     short		alu;
-     short		planemask;
- {
- 
-     mach8RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
- 			  fgPixel, 0, alu, planemask, 0);
- }
- 
- void
- mach8ImageOpStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy, fgPixel, bgPixel, alu, planemask)
-     int			x;
-     int			y;
-     int			w;
-     int			h;
-     unsigned char	*psrc;
-     int			pw, ph, pox, poy;
-     int			pwidth;
-     int			fgPixel;
-     int			bgPixel;
-     short		alu;
-     short		planemask;
- {
- 
-     mach8RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
- 			  fgPixel, bgPixel, alu, planemask, 1);
- 
- }
--- 405,407 ----
diff -c mit/server/ddx/x386/accel/mach8/mach8imfl.s:2.4 mit/server/ddx/x386/accel/mach8/mach8imfl.s:2.5
*** mit/server/ddx/x386/accel/mach8/mach8imfl.s:2.4	Fri Mar 11 23:37:37 1994
--- mit/server/ddx/x386/accel/mach8/mach8imfl.s	Fri Mar 11 23:37:37 1994
***************
*** 8,14 ****
  8514 compatible.
  Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
  
! $XFree86: mit/server/ddx/x386/accel/mach8/mach8imfl.s,v 2.4 1993/09/18 04:31:26 dawes Exp $
  
  The equivalent C-code looks like this.
  
--- 8,14 ----
  8514 compatible.
  Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
  
! $XFree86: mit/server/ddx/x386/accel/mach8/mach8imfl.s,v 2.5 1994/02/19 09:28:57 dawes Exp $
  
  The equivalent C-code looks like this.
  
***************
*** 125,140 ****
  #define srcx_loc	REGOFF(-12,EBP)
  #define srcxsave_loc	REGOFF(-16,EBP)
  
  
  	SEG_TEXT
  	ALIGNTEXT4
! 
! GLOBL	GLNAME(mach8RealImageFill)
  
! GLNAME(mach8RealImageFill):
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
! 	SUB_L	(CONST(16),ESP)
  	PUSH_L	(EDI)
  	PUSH_L	(ESI)
  	PUSH_L	(EBX)
--- 125,149 ----
  #define srcx_loc	REGOFF(-12,EBP)
  #define srcxsave_loc	REGOFF(-16,EBP)
  
+ #ifdef DRAM_VERSION
+ #define tempcount_loc	REGOFF(-20,EBP)
+ #define STACK_USG	CONST(20)
+ #define IMAGEFILL	GLNAME(mach8RealImageFillDram)
+ #else
+ #define tempcount_loc	EAX
+ #define STACK_USG	CONST(16)
+ #define IMAGEFILL	GLNAME(mach8RealImageFill)
+ #endif
  
+ 
  	SEG_TEXT
  	ALIGNTEXT4
! GLOBL	IMAGEFILL
  
! IMAGEFILL:
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
! 	SUB_L	(STACK_USG,ESP)
  	PUSH_L	(EDI)
  	PUSH_L	(ESI)
  	PUSH_L	(EBX)
***************
*** 321,326 ****
--- 330,342 ----
   * Yes there was, combine it with the first pixel and write them
   * to the 8514/Mach engine.
   */
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_a:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_a)
+ #endif
  	MOV_B	(CH,AL)
  	MOV_B	(REGIND(ESI),AH)
  	MOV_L	(PIX_TRANS,EDX)
***************
*** 337,347 ****
   * Move the rest of the line using a "rep outsw" instruction.
   */
  .move_pixels:
! 	MOV_L	(ECX,EAX)
  	SHR_L	(CONST(1),ECX)
  	REP
  	OUTS_W
! 	MOV_L	(EAX,ECX)
  	SUB_L	(EDI,EBX)
  /*
   * Is there a pixel left unwritten ?
--- 353,382 ----
   * Move the rest of the line using a "rep outsw" instruction.
   */
  .move_pixels:
! 	MOV_L	(ECX,tempcount_loc)
  	SHR_L	(CONST(1),ECX)
+ 
+ #ifndef DRAM_VERSION
  	REP
  	OUTS_W
! #else
! 	AND_L	(ECX,ECX)
! 	JZ	(.move_pixels_3)
! 
! .move_pixels_2:
! 	MOV_L	(EXT_FIFO_STATUS,EDX)
! .wait_queue_b:
! 	IN_W
! 	TEST_W	(CONST(0x8000),AX)
! 	JNZ	(.wait_queue_b)
! 
! 	MOV_L 	(PIX_TRANS,EDX)
! 	LODS_W
! 	OUT_W
! 	LOOP	(.move_pixels_2)
! #endif
! .move_pixels_3:
! 	MOV_L	(tempcount_loc,ECX)
  	SUB_L	(EDI,EBX)
  /*
   * Is there a pixel left unwritten ?
***************
*** 363,368 ****
--- 398,411 ----
   * Write it and let the scissors cut the unwanted extra pixel.
   */
  .write_pixel:
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_c:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_c)
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_B	(REGIND(ESI),AL)
  	OUT_W
  /*
***************
*** 418,423 ****
  	POP_L	(EBX)
  	POP_L	(ESI)
  	POP_L	(EDI)
! 	ADD_L	(CONST(16),ESP)
  	POP_L	(EBP)
  	RET
--- 461,466 ----
  	POP_L	(EBX)
  	POP_L	(ESI)
  	POP_L	(EDI)
! 	ADD_L	(STACK_USG,ESP)
  	POP_L	(EBP)
  	RET
diff -c mit/server/ddx/x386/accel/mach8/mach8imrd.s:2.1 mit/server/ddx/x386/accel/mach8/mach8imrd.s:2.4
*** mit/server/ddx/x386/accel/mach8/mach8imrd.s:2.1	Fri Mar 11 23:37:37 1994
--- mit/server/ddx/x386/accel/mach8/mach8imrd.s	Fri Mar 11 23:37:38 1994
***************
*** 6,12 ****
  Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
  
  void
! mach8ImageRead(x, y, w, h, psrc, pwidth, px, py)
      int			x;
      int			y;
      int			w;
--- 6,12 ----
  Written by Hans Nasten ( nasten@everyware.se ) AUG 29, 1993.
  
  void
! mach8ImageRead(x, y, w, h, psrc, pwidth, px, py, planemask)
      int			x;
      int			y;
      int			w;
***************
*** 15,24 ****
      int			pwidth;
      int			px;
      int			py;
  
  ******************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8imrd.s,v 2.1 1993/09/02 14:25:52 dawes Exp $ */
  
  #define _MACH8_ASM_
  #include "assyntax.h"
--- 15,25 ----
      int			pwidth;
      int			px;
      int			py;
+     short		planemask;
  
  ******************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8imrd.s,v 2.4 1994/02/19 09:28:59 dawes Exp $ */
  
  #define _MACH8_ASM_
  #include "assyntax.h"
***************
*** 37,50 ****
  #define pwidth_arg	REGOFF(28,EBP)
  #define px_arg		REGOFF(32,EBP)
  #define py_arg		REGOFF(36,EBP)
  
  
  	SEG_TEXT
  	ALIGNTEXT4
  
! GLOBL	GLNAME(mach8ImageRead)
  
! GLNAME(mach8ImageRead):
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	PUSH_L	(EDI)
--- 38,57 ----
  #define pwidth_arg	REGOFF(28,EBP)
  #define px_arg		REGOFF(32,EBP)
  #define py_arg		REGOFF(36,EBP)
+ #define planemask_arg	REGOFF(40,EBP)
  
+ #ifdef DRAM_VERSION
+ #define IMAGEREAD	GLNAME(mach8ImageReadDram)
+ #else
+ #define IMAGEREAD	GLNAME(mach8ImageRead)
+ #endif
  
  	SEG_TEXT
  	ALIGNTEXT4
  
! GLOBL	IMAGEREAD
  
! IMAGEREAD:
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	PUSH_L	(EDI)
***************
*** 131,137 ****
--- 138,146 ----
   * Read the pixels line by line from the fifo.
   */
  	CLD
+ #ifndef DRAM_VERSION
  	MOV_L	(PIX_TRANS,EDX)
+ #endif
  
  	MOV_L	(pwidth_arg,ESI)
  	SHR_L	(CONST(1),ESI)
***************
*** 140,145 ****
--- 149,238 ----
  	SUB_L	(EBX,ESI)
  	SHL_L	(CONST(1),ESI)
  
+ 	MOV_W	(planemask_arg,BX)
+ 	CMP_W	(CONST(0xff),BX)
+ 	JZ	(.get_all_planes)
+ 
+ 	MOV_L	(ESI,pwidth_arg)
+ 	MOV_L	(h_arg,ESI)
+ 	MOV_B	(BL,BH)
+ 	TEST_W	(CONST(1),w_arg)
+ 	JNZ	(.odd_width_masked)
+ /*
+  * Even number of pixels on each line, but some of the bitplanes
+  * should be masked out.
+  */
+ 	SHR_L	(CONST(1),w_arg)
+ .next_even_line_masked:
+ 	MOV_L	(w_arg,ECX)
+ .next_even_word_masked:	
+ #ifdef DRAM_VERSION
+ 	MOV_L	(GP_STAT,EDX)
+ .wait_ready_2:
+ 	IN_W
+ 	TEST_W	(DATARDY,AX)
+ 	JZ	(.wait_ready_2)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
+ 	IN_W
+ 	AND_W	(BX,AX)
+ 	STOS_W
+ 	LOOP	(.next_even_word_masked)
+ 
+ 	ADD_L	(pwidth_arg,EDI)
+ 	DEC_W	(SI)
+ 	JNZ	(.next_even_line_masked)
+ 
+ 	JMP	(.all_done)
+ /*
+  * Odd number of pixels on each line, but some of the bitplanes
+  * should be masked out. Read an additional pixel on each line.
+  */
+ .odd_width_masked:
+ 	SHR_L	(CONST(1),w_arg)
+ .next_odd_line_masked:
+ 	MOV_L	(w_arg,ECX)
+ 	AND_L	(ECX,ECX)
+ 	JZ	(.odd_masked_skip)
+ 
+ .next_odd_word_masked:	
+ #ifdef DRAM_VERSION
+ 	MOV_L	(GP_STAT,EDX)
+ .wait_ready_3:
+ 	IN_W
+ 	TEST_W	(DATARDY,AX)
+ 	JZ	(.wait_ready_3)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
+ 	IN_W
+ 	AND_W	(BX,AX)
+ 	STOS_W
+ 	LOOP	(.next_odd_word_masked)
+ 
+ .odd_masked_skip:
+ #ifdef DRAM_VERSION
+ 	MOV_L	(GP_STAT,EDX)
+ .wait_ready_4:
+ 	IN_W
+ 	TEST_W	(DATARDY,AX)
+ 	JZ	(.wait_ready_4)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
+ 	IN_W
+ 	AND_B	(BL,AL)
+ 	MOV_B	(AL,REGIND(EDI))
+ 	ADD_L	(pwidth_arg,EDI)
+ 	DEC_W	(SI)
+ 	JNZ	(.next_odd_line_masked)
+ 
+ 	JMP	(.all_done)
+ /*
+  * All bitplanes is to be stored. Skip planemask anding.
+  */
+ .get_all_planes:
  	MOV_W	(h_arg,BX)
  	TEST_W	(CONST(1),w_arg)
  	JNZ	(.odd_width)
***************
*** 151,158 ****
--- 244,265 ----
  	SHR_L	(CONST(1),EBP)
  .next_even_line:
  	MOV_L	(EBP,ECX)
+ #ifndef DRAM_VERSION
  	REP
  	INS_W
+ #else
+ .next_even_line_2:
+ 	MOV_L	(GP_STAT,EDX)
+ .wait_ready_5:
+ 	IN_W
+ 	TEST_W	(DATARDY,AX)
+ 	JZ	(.wait_ready_5)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ 	IN_W
+ 	STOS_W
+ 	LOOP	(.next_even_line_2)
+ #endif
  	ADD_L	(ESI,EDI)
  	DEC_W	(BX)
  	JNZ	(.next_even_line)
***************
*** 167,174 ****
--- 274,307 ----
  	SHR_L	(CONST(1),EBP)
  .next_odd_line:
  	MOV_L	(EBP,ECX)
+ #ifndef DRAM_VERSION
  	REP
  	INS_W
+ #else
+ 	AND_L	(ECX,ECX)
+ 	JZ	(.odd_line_skip)
+ 
+ .next_odd_line_2:
+ 	MOV_L	(GP_STAT,EDX)
+ .wait_ready_6:
+ 	IN_W
+ 	TEST_W	(DATARDY,AX)
+ 	JZ	(.wait_ready_6)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ 	IN_W
+ 	STOS_W
+ 	LOOP	(.next_odd_line_2)
+ 
+ .odd_line_skip:
+ 	MOV_L	(GP_STAT,EDX)
+ .wait_ready_7:
+ 	IN_W
+ 	TEST_W	(DATARDY,AX)
+ 	JZ	(.wait_ready_7)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	IN_W
  	MOV_B	(AL,REGIND(EDI))
  	ADD_L	(ESI,EDI)
diff -c mit/server/ddx/x386/accel/mach8/mach8imst.s:2.2 mit/server/ddx/x386/accel/mach8/mach8imst.s:2.5
*** mit/server/ddx/x386/accel/mach8/mach8imst.s:2.2	Fri Mar 11 23:37:38 1994
--- mit/server/ddx/x386/accel/mach8/mach8imst.s	Fri Mar 11 23:37:39 1994
***************
*** 1,115 ****
  /******************************************************************************
  
! This is a assembly language version of the mach8RealImageStipple routine.
  
  Except for the extended fifo status register, everything should be
  8514 compatible.
  Written by Hans Nasten ( nasten@everyware.se ) SEP 16, 1993.
  
! $XFree86: mit/server/ddx/x386/accel/mach8/mach8imst.s,v 2.2 1993/09/27 12:24:00 dawes Exp $
  
! The equivalent C-code looks like this.
  
- void
- mach8RealImageStipple(x, y, w, h, psrc, pwidth, pw, ph, pox, poy,
- 		      fgPixel, bgPixel, alu, planemask, opaque)
-     int			x;
-     int			y;
-     int			w;
-     int			h;
-     unsigned char	*psrc;
-     int			pw, ph, pox, poy;
-     int			pwidth;
-     int			fgPixel;
-     int			bgPixel;
-     short		alu;
-     short		planemask;
-     int			opaque;
- {
-     int			srcx, srch, dstw;
-     unsigned short	*ptmp;
- 
- 
-     if (alu == MIX_DST || w == 0 || h == 0)
- 	return;
- 
-     WaitQueue(13);
-     outw(MULTIFUNC_CNTL, SCISSORS_L | x);
-     outw(MULTIFUNC_CNTL, SCISSORS_R | (x+w-1));
-     outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_EXPPC | COLCMPOP_F);
-     outw(MULTIFUNC_CNTL, MIN_AXIS_PCNT | h-1);
-     outw(WRT_MASK, planemask);
-     outw(FRGD_MIX, FSS_FRGDCOL | alu);
-     if( opaque ) {
- 	outw(BKGD_MIX, BSS_BKGDCOL | alu);
- 	outw(BKGD_COLOR, (short)bgPixel);
-     }
-     else
- 	 outw(BKGD_MIX, BSS_BKGDCOL | MIX_DST);
-     outw(FRGD_COLOR, (short)fgPixel);
-     w += (x & 3);
-     x &= ~3;
-     outw(MAJ_AXIS_PCNT, (short)(((w + 7) & ~7)-1));
-     outw(CUR_X, (short)x);
-     outw(CUR_Y, (short)y);
-     outw(CMD, CMD_RECT | PCDATA | _16BIT | INC_Y | INC_X |
- 	      YMAJAXIS | DRAW | PLANAR | WRTDATA);
-     WaitQueue(16);
-     modulus(x - pox, pw, x);
-     modulus(y - poy, ph, y);
-     while( h > 0 ) {
- 	srch = ( y+h > ph ? ph - y : h );
- 	while( srch > 0 ) {
- 	    dstw = w;
- 	    srcx = x;
- 	    ptmp = (unsigned short *)(psrc + pwidth * y);
- 	    while( dstw > 0 ) {
- 		int np, x2;
- 		unsigned short *pnt, pix;
- 
- 		np = pw - srcx;
- 		pnt =(unsigned short *)((unsigned char *)(ptmp) + (srcx >> 3));
- 		x2 = srcx & 7;
- 		if( np >= 16 ) {
- 		    pix = (unsigned short)(*((unsigned int *)(pnt)) >> x2);
- 		}
- 		else if( pw >= 16 ) {
- 		    pix = (unsigned short)((*((unsigned int *)(pnt)) >> x2)
- 						 & MSKBIT(np)) | (*ptmp << np);
- 		}
- 		else if( pw >= 8 ) {
- 		    pix = ((*pnt >> x2) & MSKBIT(np)) | (*ptmp << np)
- 						      | (*pnt << (np+pw));
- 		}
- 		else {
- 		    pix = (*ptmp >> x2) & MSKBIT(np);
- 		    while( np < 16 && np < dstw ) {
- 			pix |= *ptmp << np;
- 			np += pw;
- 		    }
- 		}
- 		outw( PIX_TRANS, mach8stipple_tab[ pix & 0xff ] );
- 		if( dstw > 8 )
- 		    outw( PIX_TRANS, mach8stipple_tab[ ( pix >> 8 ) & 0xff ] );
- 		srcx += 16;
- 		if( srcx >= pw )
- 		    srcx -= pw;
- 		dstw -= 16;
- 	    }
- 	    y++;
- 	    h--;
- 	    srch--;
- 	}
- 	y = 0;
-     }
-     WaitQueue(5);
-     outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
-     outw(BKGD_MIX, BSS_BKGDCOL | MIX_SRC);
-     outw(MULTIFUNC_CNTL, SCISSORS_L | 0);
-     outw(MULTIFUNC_CNTL, SCISSORS_R | MACH8_MAX_X);
-     outw(MULTIFUNC_CNTL, PIX_CNTL | MIXSEL_FRGDMIX | COLCMPOP_F);
- }
- 
  ******************************************************************************/
  
  #define _MACH8_ASM_
--- 1,15 ----
  /******************************************************************************
  
! This is a assembly language version of the mach8ImageStipple routine.
  
  Except for the extended fifo status register, everything should be
  8514 compatible.
  Written by Hans Nasten ( nasten@everyware.se ) SEP 16, 1993.
  
! $XFree86: mit/server/ddx/x386/accel/mach8/mach8imst.s,v 2.5 1994/02/19 09:29:00 dawes Exp $
  
! This is a assembly language version of the C code in mach8im.c
  
  ******************************************************************************/
  
  #define _MACH8_ASM_
***************
*** 144,149 ****
--- 44,54 ----
  #define srch_loc	REGOFF(-8,EBP)
  #define dstw_loc	REGOFF(-12,EBP)
  
+ #ifdef DRAM_VERSION
+ #define IMAGESTIPPLE	GLNAME(mach8ImageStippleDram)
+ #else
+ #define IMAGESTIPPLE	GLNAME(mach8ImageStipple)
+ #endif
  
  	SEG_TEXT
  	ALIGNTEXT4
***************
*** 169,177 ****
  	D_WORD	0x0000
  
  
! GLOBL	GLNAME(mach8RealImageStipple)
  
! GLNAME(mach8RealImageStipple):
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	SUB_L	(CONST(12),ESP)
--- 74,82 ----
  	D_WORD	0x0000
  
  
! GLOBL	IMAGESTIPPLE
  
! IMAGESTIPPLE:
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	SUB_L	(CONST(12),ESP)
***************
*** 305,311 ****
  	ADD_L	(ph_arg,EDX)
  .mod1:
  	MOV_L	(EDX,y_arg)
- 
  /*
   * Wait until the fifo is empty.
   */
--- 210,215 ----
***************
*** 315,320 ****
--- 219,321 ----
  	TEST_W	(CONST(1),AX)
  	JNZ	(.wait_queue_1)
  /*
+  * When the source bitmap is properly aligned, max 16 pixels wide,
+  * and nonrepeating use this faster loop instead.
+  * This speeds up all copying to the font cache.
+  */
+ 	MOV_L	(x_arg,EAX)
+ 	AND_L	(CONST(7),EAX)
+ 	JNZ	(.next_bitmap_vertical)
+ 
+ 	MOV_L	(w_arg,EAX)
+ 	CMP_L	(CONST(16),EAX)
+ 	JG	(.next_bitmap_vertical)	
+ 
+ 	ADD_L	(x_arg,EAX)
+ 	CMP_L	(pw_arg,EAX)
+ 	JG	(.next_bitmap_vertical)	
+ 
+ 	MOV_L	(y_arg,EAX)
+ 	ADD_L	(h_arg,EAX)
+ 	CMP_L	(ph_arg,EAX)
+ 	JG	(.next_bitmap_vertical)	
+ 
+ 	MOV_L	(y_arg,EAX)
+ 	MUL_L	(pwidth_arg)
+ 	MOV_L	(x_arg,EDX)
+ 	SHR_L	(CONST(3),EDX)
+ 	ADD_L	(EDX,EAX)
+ 	MOV_L	(psrc_arg,ESI)
+ 	ADD_L	(EAX,ESI)
+ #ifndef DRAM_VERSION
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
+ 	MOV_L	(h_arg,EDI)
+ 	CMP_L	(CONST(8),w_arg)
+ 	JLE	(.fast_loop_8)
+ /*
+  * This loop is for max 16 pixels wide bitmaps.
+  */
+ .fast_loop_16:
+ 	MOV_W	(REGIND(ESI),CX)
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(CL,BL)
+ 	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_a:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_a)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
+ 	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
+ 	OUT_W
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(CH,BL)
+ 	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_b:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_b)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
+ 	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
+ 	OUT_W
+ 	ADD_L	(pwidth_arg,ESI)
+ 	DEC_L	(EDI)
+ 	JNZ	(.fast_loop_16)
+ 
+ 	JMP	(.stipple_exit)
+ /*
+  * This loop is for max 8 pixels wide bitmaps.
+  */
+ .fast_loop_8:
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(REGIND(ESI),BL)
+ 	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_c:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_c)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
+ 	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
+ 	OUT_W
+ 	ADD_L	(pwidth_arg,ESI)
+ 	DEC_L	(EDI)
+ 	JNZ	(.fast_loop_8)
+ 
+ 	JMP	(.stipple_exit)
+ 
+ /*
   * Process all lines on screen repeating the bitmap if needed.
   * This loop paints from the present y location to the end of
   * the bitmap. ( or to the end of the screen area if the bitmap
***************
*** 385,390 ****
--- 386,400 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(AL,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_d:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_d)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	CMP_L	(CONST(8),dstw_loc)
***************
*** 393,398 ****
--- 403,417 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(CH,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_e:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_e)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	SUB_L	(CONST(16),dstw_loc)
***************
*** 429,434 ****
--- 448,462 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(AL,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_f:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_f)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	CMP_L	(CONST(8),dstw_loc)
***************
*** 437,442 ****
--- 465,479 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(CH,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_g:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_g)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	SUB_L	(CONST(16),dstw_loc)
***************
*** 477,482 ****
--- 514,528 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(AL,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_h:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_h)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	CMP_L	(CONST(8),dstw_loc)
***************
*** 485,490 ****
--- 531,545 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(CH,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_i:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_i)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	SUB_L	(CONST(16),dstw_loc)
***************
*** 534,539 ****
--- 589,603 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(AL,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_j:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_j)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	CMP_L	(CONST(8),dstw_loc)
***************
*** 542,547 ****
--- 606,620 ----
  	XOR_L	(EBX,EBX)
  	MOV_B	(CH,BL)
  	SHL_L	(CONST(1),EBX)
+ #ifdef DRAM_VERSION
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_k:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_k)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ #endif
  	MOV_W	(REGOFF(GLNAME(mach8stipple_tab),EBX),AX)
  	OUT_W
  	SUB_L	(CONST(16),dstw_loc)
***************
*** 561,566 ****
--- 634,640 ----
  /*
   * Wait until room for 5 entries in the fifo.
   */
+ .stipple_exit:
  	MOV_L	(EXT_FIFO_STATUS,EDX)
  .wait_queue_2:
  	IN_W
diff -c mit/server/ddx/x386/accel/mach8/mach8imwrt.s:2.2 mit/server/ddx/x386/accel/mach8/mach8imwrt.s:2.3
*** mit/server/ddx/x386/accel/mach8/mach8imwrt.s:2.2	Fri Mar 11 23:37:39 1994
--- mit/server/ddx/x386/accel/mach8/mach8imwrt.s	Fri Mar 11 23:37:40 1994
***************
*** 20,26 ****
  
  ******************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8imwrt.s,v 2.2 1993/09/18 04:31:28 dawes Exp $ */
  
  #define _MACH8_ASM_
  #include "assyntax.h"
--- 20,26 ----
  
  ******************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8imwrt.s,v 2.3 1994/02/19 09:29:02 dawes Exp $ */
  
  #define _MACH8_ASM_
  #include "assyntax.h"
***************
*** 42,53 ****
  #define alu_arg		REGOFF(40,EBP)
  #define planemask_arg	REGOFF(44,EBP)
  
  	SEG_TEXT
  	ALIGNTEXT4
  
! GLOBL	GLNAME(mach8ImageWrite)
  
! GLNAME(mach8ImageWrite):
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	PUSH_L	(EDI)
--- 42,59 ----
  #define alu_arg		REGOFF(40,EBP)
  #define planemask_arg	REGOFF(44,EBP)
  
+ #ifdef DRAM_VERSION
+ #define IMAGEWRITE	GLNAME(mach8ImageWriteDram)
+ #else
+ #define IMAGEWRITE	GLNAME(mach8ImageWrite)
+ #endif
+ 
  	SEG_TEXT
  	ALIGNTEXT4
  
! GLOBL	IMAGEWRITE
  
! IMAGEWRITE:
  	PUSH_L	(EBP)
  	MOV_L	(ESP,EBP)
  	PUSH_L	(EDI)
***************
*** 148,153 ****
--- 154,160 ----
  /*
   * Copy the pixels line by line to the fifo.
   */
+ #ifndef DRAM_VERSION
  	CLD
  	MOV_L	(PIX_TRANS,EDX)
  	MOV_W	(h_arg,BX)
***************
*** 163,168 ****
--- 170,200 ----
  	ADD_L	(EAX,EDI)
  	DEC_W	(BX)
  	JNZ	(.next_line)
+ #else
+ 	CLD
+ 	MOV_L	(w_arg,EBX)
+ 	INC_L	(EBX)
+ 	SHR_L	(CONST(1),EBX)
+ .next_line:
+ 	MOV_L	(EDI,ESI)
+ 	MOV_L	(EBX,ECX)
+ 
+ .next_line_2:
+ 	MOV_L	(EXT_FIFO_STATUS,EDX)
+ .wait_queue_a:
+ 	IN_W
+ 	TEST_W	(CONST(0x8000),AX)
+ 	JNZ	(.wait_queue_a)
+ 
+ 	MOV_L	(PIX_TRANS,EDX)
+ 	LODS_W
+ 	OUT_W
+ 	LOOP	(.next_line_2)
+ 
+ 	ADD_L	(pwidth_arg,EDI)
+ 	DEC_W	(h_arg)
+ 	JNZ	(.next_line)
+ #endif
  /*
   * Wait until room for 3 entries in the fifo.
   */
diff -c mit/server/ddx/x386/accel/mach8/mach8init.c:2.7 mit/server/ddx/x386/accel/mach8/mach8init.c:2.10
*** mit/server/ddx/x386/accel/mach8/mach8init.c:2.7	Fri Mar 11 23:37:40 1994
--- mit/server/ddx/x386/accel/mach8/mach8init.c	Fri Mar 11 23:37:40 1994
***************
*** 21,31 ****
   * and Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8init.c,v 2.7 1993/10/15 15:39:13 dawes Exp $ */
  
! #include "misc.h"
  #include "mach8.h"
  #include "regmach8.h"
  
  #define XCONFIG_FLAGS_ONLY
  #include "xf86_Config.h"
--- 21,34 ----
   * and Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8init.c,v 2.10 1994/02/01 14:25:03 dawes Exp $ */
  
! #include "X.h"
! #include "input.h"
  #include "mach8.h"
  #include "regmach8.h"
+ #include "x386.h"
+ #include "xf86_OSlib.h"
  
  #define XCONFIG_FLAGS_ONLY
  #include "xf86_Config.h"
***************
*** 94,99 ****
--- 97,105 ----
      if(pMode->Flags & V_INTERLACE)
          vmdef->dc |= INTERLACE;
  
+     if(pMode->Flags & V_CSYNC)
+         vmdef->clk |= COMPOSITE_SYNC;
+ 
  /*
      ErrorF("Mach8calcvmode: (%x,%x,%x,%x),(%x,%x,%x,%x),(%x,%x)\n",
             vmdef->hd,vmdef->hss,vmdef->hsw,vmdef->ht,      
***************
*** 124,132 ****
       * virtualX.
       */
  
!     outw(CRT_PITCH, mach8InfoRec.virtualX >> 3);
!     outw(GE_PITCH, mach8InfoRec.virtualX >> 3);
! 
      outw(H_TOTAL,vmdef->ht);
      outw(H_DISP,vmdef->hd);
      outw(H_SYNC_STRT,vmdef->hss);
--- 130,143 ----
       * virtualX.
       */
  
!     if( mach8InfoRec.videoRam > 512 ) {
! 	outw( CRT_PITCH, 1024 >> 3 );
! 	outw( GE_PITCH, 1024 >> 3 );
!     }
!     else {
! 	outw(CRT_PITCH, mach8InfoRec.virtualX >> 3);
! 	outw(GE_PITCH, mach8InfoRec.virtualX >> 3);
!     }
      outw(H_TOTAL,vmdef->ht);
      outw(H_DISP,vmdef->hd);
      outw(H_SYNC_STRT,vmdef->hss);
***************
*** 151,157 ****
  	outw(CRT_OFFSET_LO,0);
      }
  
!     (void) mach8ClockSelect(vmdef->clk);
      outw(DISP_CNTL,vmdef->dc);
  }
  
--- 162,173 ----
  	outw(CRT_OFFSET_LO,0);
      }
  
!     if (OFLG_ISSET(OPTION_CSYNC, &mach8InfoRec.options))
! 	outw(CLOCK_SEL, ((vmdef->clk & 0x00ff) << 2) | 0xa01 | COMPOSITE_SYNC);
!     else
! 	outw(CLOCK_SEL,
! 	 ((vmdef->clk & 0x00ff) << 2) | 0xa01 | (vmdef->clk & COMPOSITE_SYNC));
! 
      outw(DISP_CNTL,vmdef->dc);
  }
  
***************
*** 270,280 ****
      }
  }
  
! /*	InitEnvironment()
  
  	Initializes the Mach-8's drawing environment and clears the display.
  */
! void InitEnvironment(void)
  {
      /* Current mixes, src, foreground active */
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
--- 286,296 ----
      }
  }
  
! /*	mach8InitEnvironment()
  
  	Initializes the Mach-8's drawing environment and clears the display.
  */
! void mach8InitEnvironment()
  {
      /* Current mixes, src, foreground active */
      outw(FRGD_MIX, FSS_FRGDCOL | MIX_SRC);
diff -c mit/server/ddx/x386/accel/mach8/mach8line.c:2.4 mit/server/ddx/x386/accel/mach8/mach8line.c:2.5
*** mit/server/ddx/x386/accel/mach8/mach8line.c:2.4	Fri Mar 11 23:37:41 1994
--- mit/server/ddx/x386/accel/mach8/mach8line.c	Fri Mar 11 23:37:41 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8line.c,v 2.4 1993/09/21 15:22:13 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8line.c,v 2.5 1993/12/25 13:59:01 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 112,119 ****
      unsigned int oc1;		/* outcode of point 1 */
      unsigned int oc2;		/* outcode of point 2 */
  
-     unsigned long *addrl;		/* address of destination pixmap */
-     int nlwidth;		/* width in longwords of destination pixmap */
      int xorg, yorg;		/* origin of window */
  
      int adx;		/* abs values of dx and dy */
--- 112,117 ----
***************
*** 133,140 ****
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int		    alu;
  
  /* 11-jun-93 TCG : is VT visible */
      if (!x386VTSema)
--- 131,136 ----
diff -c mit/server/ddx/x386/accel/mach8/mach8pcach.c:2.4 mit/server/ddx/x386/accel/mach8/mach8pcach.c:2.10
*** mit/server/ddx/x386/accel/mach8/mach8pcach.c:2.4	Fri Mar 11 23:37:42 1994
--- mit/server/ddx/x386/accel/mach8/mach8pcach.c	Fri Mar 11 23:37:42 1994
***************
*** 20,41 ****
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * Modified for the Mach-8 by Rickard E. Faith
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8pcach.c,v 2.4 1993/10/04 05:13:45 dawes Exp $ */
  
! /*       Offscreen memory organization:
   *
!  *       128      128                         768
!  *     +-------+-------+-----------------------------------------------+
!  *     |       |       |                                               |
!  * 128 |   0   |   1   |                                               |
!  *     |       |       |                                               |
!  *     +---+---+---+---+                     FONTS                     | 256
!  *  64 | 2 | 3 | 4 | 5 |                                               |
!  *     +---+---+---+---+                                               |
!  *  64 | 6 | 7 | 8 | 9 |                                               |
!  *     +---+---+---+---+-----------------------------------------------+
   *
   *     \_______________/
   *       Pixmap Cache
--- 20,44 ----
   * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
   *
   * Modified for the Mach-8 by Rickard E. Faith
+  * Small fix to enable use without font or pixmap cache.
+  * Hans Nasten. (nasten@everyware.se)
+  *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8pcach.c,v 2.10 1994/02/01 14:25:05 dawes Exp $ */
  
! /*       Offscreen memory organization at 1024x768:
   *
!  *       128     64 64                        768
!  *     +-------+---+---+-----------------------------------------------+
!  *     |       | 2 | 3 |                                               |
!  * 128 |   0   +---+---+                                               |
!  *     |       | 4 | 5 |                                               |
!  *     +-------+---+---+                     FONTS                     | 256
!  *     |       | 6 | 7 |                                               |
!  * 128 |   1   +---+---+                                               |
!  *     |       | 8 | 9 |                                               |
!  *     +-------+---+---+-----------------------------------------------+
   *
   *     \_______________/
   *       Pixmap Cache
***************
*** 108,125 ****
      int count128 = 0,count64 = 0;
      int next=0;
    
!     totalx=mach8InfoRec.virtualX;
!     totaly=(mach8InfoRec.videoRam*1024) / totalx; 
  
      if (totaly>1024) totaly=1024;
  
!     freex=mach8InfoRec.virtualX;
!     freey=totaly-mach8InfoRec.virtualY;
    
!     if (x386Verbose)
!         ErrorF("%s %s: Total memory %dx%d (%dx%d in cache)\n", XCONFIG_PROBED,
! 	       mach8InfoRec.name, totalx, totaly, freex, freey);
!     
      for (i = 0; i < MAX_SLOTS; i++) {
  	cInfo[i].id = -2;
  	cInfo[i].lru = 0;
--- 111,139 ----
      int count128 = 0,count64 = 0;
      int next=0;
    
!     if( mach8InfoRec.videoRam > 512 )
! 	totalx = 1024;
!     else
! 	totalx = mach8InfoRec.virtualX;
  
+     totaly = (mach8InfoRec.videoRam*1024) / totalx; 
+ 
      if (totaly>1024) totaly=1024;
  
!     freex = totalx;
!     freey = totaly-mach8InfoRec.virtualY;
    
!     if (x386Verbose) {
! 	if( mach8InfoRec.videoRam > 512 && mach8InfoRec.virtualX < 1024 )
! 	    ErrorF("%s %s: Total memory %dx%d (%dx%d + %dx%d in cache)\n",
! 		   XCONFIG_PROBED, mach8InfoRec.name,
! 		   totalx, totaly, freex, freey,
! 		   1024 - mach8InfoRec.virtualX, mach8InfoRec.virtualY);
! 	else
! 	    ErrorF("%s %s: Total memory %dx%d (%dx%d in cache)\n",
! 		   XCONFIG_PROBED, mach8InfoRec.name,
! 		   totalx, totaly, freex, freey);
!     }
      for (i = 0; i < MAX_SLOTS; i++) {
  	cInfo[i].id = -2;
  	cInfo[i].lru = 0;
***************
*** 209,214 ****
--- 223,231 ----
  	cInfo[pix->slot].id == pix->cacheId)
  	return 1;
  
+     if( !CacheSlots )
+ 	return( 0 );
+ 
      if (pix->drawable.width <= 64 && pix->drawable.height <= 64) {
  	next = CacheSlots-1;
  	for (i = CacheFirst64; i < CacheSlots; i++)
***************
*** 276,284 ****
      else
  	pci->id = pix->cacheId = NEXT_CACHE_ID;
  
!     mach8ImageWrite(pci->x, pci->y, pci->pix_w, pci->pix_h,
! 		      pix->devPrivate.ptr, pix->devKind, 0, 0,
! 		      MIX_SRC, 0xffff);
  
      DoCacheExpandPixmap(pci);
  }
--- 293,301 ----
      else
  	pci->id = pix->cacheId = NEXT_CACHE_ID;
  
!     (mach8ImageWriteFunc)(pci->x, pci->y, pci->pix_w, pci->pix_h,
! 			  pix->devPrivate.ptr, pix->devKind, 0, 0,
! 			  MIX_SRC, 0xffff);
  
      DoCacheExpandPixmap(pci);
  }
***************
*** 302,311 ****
      else
  	pci->id = pix->cacheId = NEXT_CACHE_ID;
  
!     mach8ImageOpStipple(pci->x, pci->y, pci->pix_w, pci->pix_h,
! 			  pix->devPrivate.ptr, pix->devKind,
! 			  pci->pix_w, pci->pix_h, pci->x, pci->y,
! 			  255, 0, MIX_SRC, 0xffff);
  
      DoCacheExpandPixmap(pci);
  }
--- 319,328 ----
      else
  	pci->id = pix->cacheId = NEXT_CACHE_ID;
  
!     (mach8ImageStippleFunc)(pci->x, pci->y, pci->pix_w, pci->pix_h,
! 			    pix->devPrivate.ptr, pix->devKind,
! 			    pci->pix_w, pci->pix_h, pci->x, pci->y,
! 			    255, 0, MIX_SRC, 0xffff, 1);
  
      DoCacheExpandPixmap(pci);
  }
***************
*** 487,493 ****
      int xwmid, ywmid, orig_xwmid;
      int startx, starty, endx, endy;
      int orig_x = x;
-     int i;
  
      if (w == 0 || h == 0)
  	return;
--- 504,509 ----
diff -c mit/server/ddx/x386/accel/mach8/mach8scrin.c:2.1 mit/server/ddx/x386/accel/mach8/mach8scrin.c:2.4
*** mit/server/ddx/x386/accel/mach8/mach8scrin.c:2.1	Fri Mar 11 23:37:43 1994
--- mit/server/ddx/x386/accel/mach8/mach8scrin.c	Fri Mar 11 23:37:43 1994
***************
*** 38,44 ****
  
  ********************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8scrin.c,v 2.1 1993/09/04 16:28:37 dawes Exp $ */
  
  /* $XConsortium: cfbscrinit.c,v 5.18 90/09/24 17:46:11 rws Exp $ */
  
--- 38,44 ----
  
  ********************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8scrin.c,v 2.4 1993/12/25 13:59:05 dawes Exp $ */
  
  /* $XConsortium: cfbscrinit.c,v 5.18 90/09/24 17:46:11 rws Exp $ */
  
***************
*** 60,65 ****
--- 60,67 ----
  
  extern RegionPtr mfbPixmapToRegion();
  extern Bool mfbAllocatePrivates();
+ extern Bool mfbRegisterCopyPlaneProc();
+ extern Bool miScreenInit();
  
  extern int defaultColorVisualClass;
  
***************
*** 99,106 ****
  
  #define NUMDEPTHS	((sizeof depths)/(sizeof depths[0]))
  
- int cfbWindowPrivateIndex;
- int cfbGCPrivateIndex;
  static unsigned long cfbGeneration = 0;
  
  miBSFuncRec mach8BSFuncRec = {
--- 101,106 ----
***************
*** 156,162 ****
      pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
      pScreen->QueryBestSize = mfbQueryBestSize;
      /* SaveScreen */
!     pScreen->GetImage = miGetImage;
      pScreen->GetSpans = mach8GetSpans;
      pScreen->CreateWindow = cfbCreateWindow;
      pScreen->DestroyWindow = cfbDestroyWindow;
--- 156,162 ----
      pScreen->blackPixel = pScreen->whitePixel = (Pixel) 0;
      pScreen->QueryBestSize = mfbQueryBestSize;
      /* SaveScreen */
!     pScreen->GetImage = mach8GetImage;
      pScreen->GetSpans = mach8GetSpans;
      pScreen->CreateWindow = cfbCreateWindow;
      pScreen->DestroyWindow = cfbDestroyWindow;
diff -c mit/server/ddx/x386/accel/mach8/mach8seg.c:2.5 mit/server/ddx/x386/accel/mach8/mach8seg.c:2.6
*** mit/server/ddx/x386/accel/mach8/mach8seg.c:2.5	Fri Mar 11 23:37:44 1994
--- mit/server/ddx/x386/accel/mach8/mach8seg.c	Fri Mar 11 23:37:44 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8seg.c,v 2.5 1993/10/08 15:57:41 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8seg.c,v 2.6 1993/12/25 13:59:07 dawes Exp $ */
  
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
***************
*** 109,116 ****
      unsigned int oc1;       /* outcode of point 1 */
      unsigned int oc2;       /* outcode of point 2 */
  
-     unsigned long *addrl;   /* address of destination pixmap */
-     int nlwidth;            /* width in longwords of destination pixmap */
      int xorg, yorg;         /* origin of window */
  
      int adx;                /* abs values of dx and dy */
--- 109,114 ----
***************
*** 131,138 ****
      register int x1, x2;
      RegionPtr cclip;
      cfbPrivGCPtr    devPriv;
-     unsigned long   xor, and;
-     int             alu;
  
  /* 11-jun-93 TCG : is VT visible */
      if (!x386VTSema)
--- 129,134 ----
diff -c mit/server/ddx/x386/accel/mach8/mach8ss.c:2.2 mit/server/ddx/x386/accel/mach8/mach8ss.c:2.3
*** mit/server/ddx/x386/accel/mach8/mach8ss.c:2.2	Fri Mar 11 23:37:44 1994
--- mit/server/ddx/x386/accel/mach8/mach8ss.c	Fri Mar 11 23:37:45 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8ss.c,v 2.2 1993/08/17 16:15:42 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8ss.c,v 2.3 1994/02/01 13:51:45 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 149,157 ****
  		cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
  		    pdstBase, widthDst, pGC->planemask);
  ***************/
! 		mach8ImageWrite(xStart, ppt->y, xEnd-xStart, 1,
! 				  psrc + (xStart-ppt->x), xEnd-xStart, 0, 0,
! 				  mach8alu[alu], pGC->planemask);
  		if(ppt->x + *pwidth <= pbox->x2)
  		{
  		    /* End of the line, as it were */
--- 149,157 ----
  		cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
  		    pdstBase, widthDst, pGC->planemask);
  ***************/
! 		(mach8ImageWriteFunc)(xStart, ppt->y, xEnd-xStart, 1,
! 				      psrc + (xStart-ppt->x), xEnd-xStart,
! 				      0, 0, mach8alu[alu], pGC->planemask);
  		if(ppt->x + *pwidth <= pbox->x2)
  		{
  		    /* End of the line, as it were */
***************
*** 198,206 ****
  			cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
  			    pdstBase, widthDst, pGC->planemask);
  **************/
! 			mach8ImageWrite(xStart, ppt->y, xEnd-xStart, 1,
! 					  psrc + (xStart-ppt->x), xEnd-xStart, 0, 0,
! 					  mach8alu[alu], pGC->planemask);
  		    }
  
  		}
--- 198,207 ----
  			cfbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
  			    pdstBase, widthDst, pGC->planemask);
  **************/
! 			(mach8ImageWriteFunc)(xStart, ppt->y, xEnd-xStart, 1,
! 					      psrc + (xStart-ppt->x),
! 					      xEnd-xStart, 0, 0,
! 					      mach8alu[alu], pGC->planemask);
  		    }
  
  		}
diff -c mit/server/ddx/x386/accel/mach8/mach8text.c:2.2 mit/server/ddx/x386/accel/mach8/mach8text.c:2.5
*** mit/server/ddx/x386/accel/mach8/mach8text.c:2.2	Fri Mar 11 23:37:45 1994
--- mit/server/ddx/x386/accel/mach8/mach8text.c	Fri Mar 11 23:37:45 1994
***************
*** 22,30 ****
   *
   * Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
   * Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8text.c,v 2.2 1993/09/09 06:01:21 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 22,33 ----
   *
   * Modified for the Mach-8 by Rickard E. Faith (faith@cs.unc.edu)
   * Further modifications by Tiago Gons (tiago@comosjn.hobby.nl)
+  * Adapted to use accelerated text output without font cache.
+  * Hans Nasten (nasten@everyware.se)
+  *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8text.c,v 2.5 1994/01/09 03:30:30 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 35,42 ****
--- 38,49 ----
  #include        "scrnintstr.h"
  #include        "pixmapstr.h"
  #include	"dixfontstr.h"
+ #include	"mi.h"
  #include	"mach8.h"
  
+ extern int mach8CPolyText8();
+ extern int mach8CImageText8();
+ 
  int
  mach8PolyText8(pDraw, pGC, x, y, count, chars)
      DrawablePtr pDraw;
***************
*** 45,51 ****
      int 	count;
      char	*chars;
  {
!     int plane;
  
  /* 11-jun-93 TCG : is VT visible */
      if (!x386VTSema)
--- 52,58 ----
      int 	count;
      char	*chars;
  {
!     void *vpnt;
  
  /* 11-jun-93 TCG : is VT visible */
      if (!x386VTSema)
***************
*** 53,63 ****
          return miPolyText8(pDraw, pGC, x, y, count, chars);
      }
  
!     if (((plane = mach8CacheFont8(pGC->font)) == -1) ||
  	(pGC->fillStyle != FillSolid))
  	return miPolyText8(pDraw, pGC, x, y, count, chars);
      else
! 	return mach8CPolyText8(pDraw, pGC, x, y, count, chars, plane);
  }
  
  
--- 60,70 ----
          return miPolyText8(pDraw, pGC, x, y, count, chars);
      }
  
!     if (((vpnt = mach8CacheFont8(pGC->font)) == NULL) ||
  	(pGC->fillStyle != FillSolid))
  	return miPolyText8(pDraw, pGC, x, y, count, chars);
      else
! 	return mach8CPolyText8(pDraw, pGC, x, y, count, chars, vpnt);
  }
  
  
***************
*** 81,88 ****
      int		count;
      char	*chars;
  {
-     int plane;
- 
  /* 11-jun-93 TCG : is VT visible */
      if (!x386VTSema)
      {
--- 88,93 ----
***************
*** 91,100 ****
      }
  
      /* Don't need to check fill style here - it isn't used in image text */
!     if ((plane = mach8CacheFont8(pGC->font)) == -1)
! 	miImageText8(pDraw, pGC, x, y, count, chars);
!     else
! 	mach8CImageText8(pDraw, pGC, x, y, count, chars, plane);
  }
  
  
--- 96,105 ----
      }
  
      /* Don't need to check fill style here - it isn't used in image text */
! 
!     mach8CImageText8( pDraw, pGC, x, y, count, chars,
! 		       mach8CacheFont8(pGC->font) );
! 
  }
  
  
diff -c mit/server/ddx/x386/accel/mach8/mach8win.c:2.2 mit/server/ddx/x386/accel/mach8/mach8win.c:2.3
*** mit/server/ddx/x386/accel/mach8/mach8win.c:2.2	Fri Mar 11 23:37:45 1994
--- mit/server/ddx/x386/accel/mach8/mach8win.c	Fri Mar 11 23:37:46 1994
***************
*** 27,33 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8win.c,v 2.2 1993/08/17 16:15:44 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 27,33 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/mach8win.c,v 2.3 1993/12/25 13:59:10 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 42,47 ****
--- 42,48 ----
  #include "x386.h"
  #include "x386Priv.h"
  #include "regmach8.h"
+ #include "mach8.h"
  
  void 
  mach8CopyWindow(pWin, ptOldOrg, prgnSrc)
diff -c mit/server/ddx/x386/accel/mach8/regmach8.h:2.8 mit/server/ddx/x386/accel/mach8/regmach8.h:2.10
*** mit/server/ddx/x386/accel/mach8/regmach8.h:2.8	Fri Mar 11 23:37:46 1994
--- mit/server/ddx/x386/accel/mach8/regmach8.h	Fri Mar 11 23:37:46 1994
***************
*** 22,28 ****
   * and Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/regmach8.h,v 2.8 1993/10/02 16:51:20 dawes Exp $ */
  
  #ifndef _MACH8_ASM_
  #include "compiler.h"
--- 22,28 ----
   * and Tiago Gons (tiago@comosjn.hobby.nl)
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/mach8/regmach8.h,v 2.10 1994/03/03 12:43:41 dawes Exp $ */
  
  #ifndef _MACH8_ASM_
  #include "compiler.h"
***************
*** 96,101 ****
--- 96,104 ----
  #define	PIX_CNTL	0xa000
  #define	PIX_TRANS	0xe2e8
  
+ /* Composite sync bit in clock select register. */
+ #define COMPOSITE_SYNC	0x1000
+ 
  /* Display Status Bit Fields */
  #define	HORTOG		0x0004
  #define	VBLANK		0x0002
***************
*** 281,286 ****
--- 284,299 ----
  
  /* Wait until GP is idle and queue is empty */
  #define	WaitIdleEmpty() { while (inw(GP_STAT) & (GPBUSY | 1)); }
+ 
+ /*
+  * This version is for use in mach8Probe() to prevent a server hang if
+  * there is no 8514/A-style chip present
+  */
+ #define	ProbeWaitIdleEmpty() { int i; \
+ 			       for (i = 0; i < 100000; i++) \
+ 			          if (!(inw(GP_STAT) & (GPBUSY | 1))) \
+ 				     break; \
+ 			     }
  
  /* Wait until GP has data available */
  #define       WaitDataReady() { while (!(inw(GP_STAT) & DATARDY)); }
diff -c mit/server/ddx/x386/accel/s3/Imakefile:2.10 mit/server/ddx/x386/accel/s3/Imakefile:2.11
*** mit/server/ddx/x386/accel/s3/Imakefile:2.10	Fri Mar 11 23:37:52 1994
--- mit/server/ddx/x386/accel/s3/Imakefile	Fri Mar 11 23:37:53 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/accel/s3/Imakefile,v 2.10 1993/09/23 15:44:34 dawes Exp $
  XCOMM Id: Imakefile,v 1.1 1993/06/18 13:32:08 jon Exp jon
  
  #include <Server.tmpl>
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/accel/s3/Imakefile,v 2.11 1994/01/09 03:30:47 dawes Exp $
  XCOMM Id: Imakefile,v 1.1 1993/06/18 13:32:08 jon Exp jon
  
  #include <Server.tmpl>
***************
*** 12,18 ****
  	s3scrin.c s3blt.c s3pcach.c s3plypt.c \
  	s3line.c s3seg.c s3frect.c s3text.c \
  	s3font.c s3fcach.c s3Cursor.c s3BtCursor.c vgaHW.c s3dline.c \
! 	s3dseg.c s3bcach.c s3gtimg.c
  
  OBJS = 	s3.o s3misc.o s3cmap.o s3gc.o s3fs.o s3ss.o \
  	s3gs.o s3win.o s3init.o s3im.o s3bstor.o \
--- 12,18 ----
  	s3scrin.c s3blt.c s3pcach.c s3plypt.c \
  	s3line.c s3seg.c s3frect.c s3text.c \
  	s3font.c s3fcach.c s3Cursor.c s3BtCursor.c vgaHW.c s3dline.c \
! 	s3dseg.c s3bcach.c s3gtimg.c s3TiCursor.c
  
  OBJS = 	s3.o s3misc.o s3cmap.o s3gc.o s3fs.o s3ss.o \
  	s3gs.o s3win.o s3init.o s3im.o s3bstor.o \
***************
*** 19,25 ****
  	s3scrin.o s3blt.o s3pcach.o s3plypt.o \
  	s3line.o s3seg.o s3frect.o s3text.o \
  	s3font.o s3fcach.o s3Cursor.o s3BtCursor.o vgaHW.o s3dline.o \
! 	s3dseg.o s3bcach.o s3gtimg.o
  
  INCLUDES = -I../.. -I. -I../../../mfb -I../../../mi -I../../../../include \
  	   -I../../../cfb -I$(INCLUDESRC) -I$(FONTSRC)/include \
--- 19,25 ----
  	s3scrin.o s3blt.o s3pcach.o s3plypt.o \
  	s3line.o s3seg.o s3frect.o s3text.o \
  	s3font.o s3fcach.o s3Cursor.o s3BtCursor.o vgaHW.o s3dline.o \
! 	s3dseg.o s3bcach.o s3gtimg.o s3TiCursor.o
  
  INCLUDES = -I../.. -I. -I../../../mfb -I../../../mi -I../../../../include \
  	   -I../../../cfb -I$(INCLUDESRC) -I$(FONTSRC)/include \
diff -c mit/server/ddx/x386/accel/s3/regs3.h:2.9 mit/server/ddx/x386/accel/s3/regs3.h:2.13
*** mit/server/ddx/x386/accel/s3/regs3.h:2.9	Fri Mar 11 23:37:53 1994
--- mit/server/ddx/x386/accel/s3/regs3.h	Fri Mar 11 23:37:53 1994
***************
*** 19,25 ****
   * 
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/regs3.h,v 2.9 1993/09/22 15:43:18 dawes Exp $ */
  
  #ifndef _S3_H
  #define _S3_H
--- 19,25 ----
   * 
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/regs3.h,v 2.13 1994/03/08 10:28:52 dawes Exp $ */
  
  #ifndef _S3_H
  #define _S3_H
***************
*** 70,83 ****
  
  #define S3_911_ONLY(chip)     (chip==0x81)
  #define S3_924_ONLY(chip)     (chip==0x82)
- #if 0
- /* XXXX These are NOT valid. These will only detect certains steps */
- #define S3_801_ONLY(chip)       (chip==0xa0)
- #define S3_928_ONLY(chip)       (chip==0x90)
- #endif
  #define S3_911_SERIES(chip)     ((chip&0xf0)==0x80)
  #define S3_801_SERIES(chip)     ((chip&0xf0)==0xa0)
  #define S3_928_SERIES(chip)     (((chip&0xf0)==0x90)||((chip&0xf0)==0xb0))
  #define S3_801_928_SERIES(chip) (S3_801_SERIES(chip)||S3_928_SERIES(chip))
  #define S3_8XX_9XX_SERIES(chip) (S3_911_SERIES(chip)||S3_801_928_SERIES(chip))
  #define S3_ANY_SERIES(chip)     (S3_8XX_9XX_SERIES(chip))
--- 70,81 ----
  
  #define S3_911_ONLY(chip)     (chip==0x81)
  #define S3_924_ONLY(chip)     (chip==0x82)
  #define S3_911_SERIES(chip)     ((chip&0xf0)==0x80)
  #define S3_801_SERIES(chip)     ((chip&0xf0)==0xa0)
+ #define S3_801_I_SERIES(chip)	(S3_801_SERIES(chip) && ((chip) & 0x08))
+ #define S3_801_REV_C(chip)      (S3_801_SERIES(chip) && ((chip) & 0x07) >= 2)
  #define S3_928_SERIES(chip)     (((chip&0xf0)==0x90)||((chip&0xf0)==0xb0))
+ #define S3_928_REV_E(chip)      (S3_928_SERIES(chip) && ((chip) & 0x0F) >= 4)
  #define S3_801_928_SERIES(chip) (S3_801_SERIES(chip)||S3_928_SERIES(chip))
  #define S3_8XX_9XX_SERIES(chip) (S3_911_SERIES(chip)||S3_801_928_SERIES(chip))
  #define S3_ANY_SERIES(chip)     (S3_8XX_9XX_SERIES(chip))
diff -c mit/server/ddx/x386/accel/s3/s3.c:2.51 mit/server/ddx/x386/accel/s3/s3.c:2.79
*** mit/server/ddx/x386/accel/s3/s3.c:2.51	Fri Mar 11 23:37:54 1994
--- mit/server/ddx/x386/accel/s3/s3.c	Fri Mar 11 23:37:54 1994
***************
*** 31,37 ****
   * Id: s3.c,v 2.6 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3.c,v 2.51 1993/10/16 17:31:09 dawes Exp $ */
  
  #include "cfb.h"
  #include "pixmapstr.h"
--- 31,37 ----
   * Id: s3.c,v 2.6 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3.c,v 2.79 1994/03/08 10:28:57 dawes Exp $ */
  
  #include "cfb.h"
  #include "pixmapstr.h"
***************
*** 46,53 ****
  #include "vga.h"
  #include "s3linear.h"
  #include "s3Bt485.h"
  
! extern int s3MaxClock, s3MaxBt485Clock;
  char s3Mbanks;
  extern void NoopDDA();
  void s3PrintIdent();
--- 46,56 ----
  #include "vga.h"
  #include "s3linear.h"
  #include "s3Bt485.h"
+ #include "s3Ti3020.h"
  
! extern int s3MaxClock;
! extern int s3MaxBt485Clock, s3MaxBt485MuxClock;
! extern int s3MaxTi3020Clock, s3MaxTi3020ClockFast;
  char s3Mbanks;
  extern void NoopDDA();
  void s3PrintIdent();
***************
*** 84,89 ****
--- 87,93 ----
     0,				/* int maxClock */
     0,				/* int videoRam */
     0xC0000,                     /* int BIOSbase */  
+    0,				/* unsigned long MemBase */
     240, 180,			/* int width, height */
     0,				/* unsigned long  speedup */
     NULL,			/* DisplayModePtr modes */   
***************
*** 133,138 ****
--- 137,143 ----
  Bool  s3Localbus = FALSE;
  Bool  s3LinearAperture = FALSE;
  Bool  s3Mmio928 = FALSE;
+ Bool  s3DAC8Bit = FALSE;
  unsigned char s3LinApOpt;
  int s3BankSize;
  int s3DisplayWidth;
***************
*** 141,154 ****
  
  extern Bool x386Exiting, x386Resetting, x386ProbeFailed, x386Verbose;
  
- static Bool AlreadyInited = FALSE;
- static Bool s3ModeSwitched = FALSE;
- 
  int s3ScissB;
  unsigned char s3SwapBits[256];
  unsigned char s3Port40;
  unsigned char s3Port51;
  unsigned char s3Port54;
  void (*s3ImageReadFunc)();
  void (*s3ImageWriteFunc)();
  void (*s3ImageFillFunc)();
--- 146,159 ----
  
  extern Bool x386Exiting, x386Resetting, x386ProbeFailed, x386Verbose;
  
  int s3ScissB;
  unsigned char s3SwapBits[256];
  unsigned char s3Port40;
  unsigned char s3Port51;
  unsigned char s3Port54;
+ unsigned char s3Port59 = 0x00;
+ unsigned char s3Port5A = 0x0A;
+ unsigned char s3Port31 = 0x8d;
  void (*s3ImageReadFunc)();
  void (*s3ImageWriteFunc)();
  void (*s3ImageFillFunc)();
***************
*** 157,162 ****
--- 162,171 ----
  CacheFont8Ptr s3HeadFont, s3FontCache;
  int s3hotX, s3hotY;
  Bool s3BlockCursor, s3ReloadCursor;
+ int s3CursorStartX, s3CursorStartY, s3CursorLines;
+ int s3RamdacType = UNKNOWN_DAC;
+ Bool s3UsingPixMux = FALSE;
+ Bool s3Bt485PixMux = FALSE;
  
  
  /*
***************
*** 203,213 ****
  s3Probe()
  {
     DisplayModePtr pMode, pEnd;
!    unsigned char config, tmp;
     int i, j, numClocks;
     int tx, ty;
     OFlagSet validOptions;
  
     xf86ClearIOPortList(s3InfoRec.scrnIndex);
     xf86AddIOPorts(s3InfoRec.scrnIndex, Num_VGA_IOPorts, VGA_IOPorts);
     xf86AddIOPorts(s3InfoRec.scrnIndex, Num_S3_IOPorts, S3_IOPorts);
--- 212,253 ----
  s3Probe()
  {
     DisplayModePtr pMode, pEnd;
!    unsigned char config, tmp, tmp1;
     int i, j, numClocks;
     int tx, ty;
+    int maxDisplayWidth, maxDisplayHeight;
     OFlagSet validOptions;
  
+    /*
+     * These characterise a RAMDACs pixel multiplexing capabilities and
+     * requirements:
+     *
+     *   pixMuxPossible         - pixmux is supported for the current RAMDAC
+     *   allowPixMuxInterlace   - pixmux supports interlaced modes
+     *   allowPixMuxSwitching   - possible to use pixmux for some modes
+     *                            and non-pixmux for others
+     *   pixMuxMinWidth         - smallest physical width supported in
+     *                            pixmux mode
+     *   nonMuxMaxClock         - highest dot clock supported without pixmux
+     *   nonMuxMaxMemory        - max video memory accessible without pixmux
+     *   pixMuxLimitedWidths    - pixmux only works for logical display
+     *                            widths 1024 and 2048
+     *   pixMuxInterlaceOK      - FALSE if pixmux isn't possible because
+     *                            there is an interlaced mode present
+     *   pixMuxWidthOK          - FALSE if pixmux isn't possible because
+     *                            there is mode has too small a width
+     */
+    Bool pixMuxPossible = FALSE;
+    Bool allowPixMuxInterlace = FALSE;
+    Bool allowPixMuxSwitching = FALSE;
+    Bool pixMuxNeeded = FALSE;
+    int pixMuxMinWidth = 1024;
+    int nonMuxMaxClock = 0;
+    int nonMuxMaxMemory = 4096;
+    Bool pixMuxLimitedWidths = TRUE;
+    Bool pixMuxInterlaceOK = TRUE;
+    Bool pixMuxWidthOK = TRUE;
+ 
     xf86ClearIOPortList(s3InfoRec.scrnIndex);
     xf86AddIOPorts(s3InfoRec.scrnIndex, Num_VGA_IOPorts, VGA_IOPorts);
     xf86AddIOPorts(s3InfoRec.scrnIndex, Num_S3_IOPorts, S3_IOPorts);
***************
*** 279,310 ****
     OFLG_SET(OPTION_NOLINEAR_MODE, &validOptions);
     OFLG_SET(OPTION_NO_MEM_ACCESS, &validOptions);
     OFLG_SET(OPTION_MEM_ACCESS, &validOptions);
     OFLG_SET(OPTION_BT485, &validOptions);
-    OFLG_SET(OPTION_NO_BT485, &validOptions);
     OFLG_SET(OPTION_BT485_CURS, &validOptions);
     OFLG_SET(OPTION_SHOWCACHE, &validOptions);
     xf86VerifyOptions(&validOptions, &s3InfoRec);
!    if (OFLG_ISSET(OPTION_MEM_ACCESS, &s3InfoRec.options) &&
!        OFLG_ISSET(OPTION_NO_MEM_ACCESS, &s3InfoRec.options)) {
!       ErrorF("%s: Warning: Options \"memaccess\" and \"nomemaccess\" are ",
  	     s3InfoRec.name);
!       ErrorF("incompatible.\n\t\"nomemaccess\" will be assumed.\n");
     }
  
!    s3Localbus = ((config & 0x03) == 1);
  
     if (x386Verbose) {
!       if ((config & 0x03) == 0) {
           ErrorF("%s %s: card type: EISA\n",
!               XCONFIG_PROBED, s3InfoRec.name);
!       }
!       if (s3Localbus) {
           ErrorF("%s %s: card type: 386/486 localbus\n",
!               XCONFIG_PROBED, s3InfoRec.name);
!       }
!       if ((config & 0x03) == 3) {
           ErrorF("%s %s: card type: ISA\n",
! 	      XCONFIG_PROBED, s3InfoRec.name);
        }
     }
  
--- 319,370 ----
     OFLG_SET(OPTION_NOLINEAR_MODE, &validOptions);
     OFLG_SET(OPTION_NO_MEM_ACCESS, &validOptions);
     OFLG_SET(OPTION_MEM_ACCESS, &validOptions);
+    OFLG_SET(OPTION_NORMAL_DAC, &validOptions);
     OFLG_SET(OPTION_BT485, &validOptions);
     OFLG_SET(OPTION_BT485_CURS, &validOptions);
     OFLG_SET(OPTION_SHOWCACHE, &validOptions);
+    OFLG_SET(OPTION_FB_DEBUG, &validOptions);
+    OFLG_SET(OPTION_TI3020, &validOptions);
+    OFLG_SET(OPTION_TI3020_CURS, &validOptions);
+    OFLG_SET(OPTION_NO_TI3020_CURS, &validOptions);
+    OFLG_SET(OPTION_TI3020_FAST, &validOptions);
+    OFLG_SET(OPTION_DAC_8_BIT, &validOptions);
+    OFLG_SET(OPTION_20C505, &validOptions);
+    OFLG_SET(OPTION_FAST_DRAM, &validOptions);
+    OFLG_SET(OPTION_MED_DRAM, &validOptions);
+    OFLG_SET(OPTION_SLOW_DRAM, &validOptions);
+    OFLG_SET(OPTION_ATT490_1, &validOptions);
+    OFLG_SET(OPTION_SC15025, &validOptions);
+    OFLG_SET(OPTION_SPEA_MERCURY, &validOptions);
+ #ifdef NUMNINETEST
+    OFLG_SET(OPTION_NUMBER_NINE, &validOptions);
+ #endif
     xf86VerifyOptions(&validOptions, &s3InfoRec);
!    if (OFLG_ISSET(OPTION_MEM_ACCESS, &s3InfoRec.options)) {
!       ErrorF("%s: Warning: the \"memaccess\" option is now redundant\n",
  	     s3InfoRec.name);
!       ErrorF("\tIt will be removed in the next release\n");
     }
  
!    s3Localbus = ((config & 0x03) <= 1);		/* LocalBus or EISA */
  
     if (x386Verbose) {
!       switch (config & 0x03) {
!       case 0:
           ErrorF("%s %s: card type: EISA\n",
!         	XCONFIG_PROBED, s3InfoRec.name);
! 	 break;
!       case 1:
           ErrorF("%s %s: card type: 386/486 localbus\n",
!         	XCONFIG_PROBED, s3InfoRec.name);
! 	 break;
!       case 3:
           ErrorF("%s %s: card type: ISA\n",
! 		XCONFIG_PROBED, s3InfoRec.name);
! 	 break;
!       default:
! 	 ErrorF("%s %s: card type: unknown (%d)\n",
! 		XCONFIG_PROBED, s3InfoRec.name, config & 0x03);
        }
     }
  
***************
*** 312,324 ****
        if (S3_801_928_SERIES(s3ChipId)) {
  	 if (S3_801_SERIES(s3ChipId)) {
  	    if (!((config & 0x03) == 3))
! 		ErrorF("%s %s: chipset:   805\n",
!                    XCONFIG_PROBED, s3InfoRec.name);
  	    else
! 		ErrorF("%s %s: chipset:   801\n",
!                    XCONFIG_PROBED, s3InfoRec.name);
  	 } else if (S3_928_SERIES(s3ChipId)) {
! 	    ErrorF("%s %s: chipset:   928 \n",
                     XCONFIG_PROBED, s3InfoRec.name);
  	 }
        } else if (S3_911_SERIES(s3ChipId)) {
--- 372,395 ----
        if (S3_801_928_SERIES(s3ChipId)) {
  	 if (S3_801_SERIES(s3ChipId)) {
  	    if (!((config & 0x03) == 3))
! 	       ErrorF("%s %s: chipset:   805",
!                       XCONFIG_PROBED, s3InfoRec.name);
  	    else
! 	       ErrorF("%s %s: chipset:   801",
!                        XCONFIG_PROBED, s3InfoRec.name);
! 	    if (S3_801_I_SERIES(s3ChipId))
! 	       ErrorF("i");
! 	    ErrorF(", ");
! 	    if (S3_801_REV_C(s3ChipId))
! 	       ErrorF("rev C or above\n");
! 	    else
! 	       ErrorF("rev A or B\n");
  	 } else if (S3_928_SERIES(s3ChipId)) {
! 	    if (S3_928_REV_E(s3ChipId))
! 		ErrorF("%s %s: chipset:   928, rev E or above\n",
!                    XCONFIG_PROBED, s3InfoRec.name);
! 	    else
! 	        ErrorF("%s %s: chipset:   928, rev D or below\n",
                     XCONFIG_PROBED, s3InfoRec.name);
  	 }
        } else if (S3_911_SERIES(s3ChipId)) {
***************
*** 366,377 ****
  	 }
        }
        if (x386Verbose) {
!          ErrorF("%s %s: videoram:  %dk",
                XCONFIG_PROBED, s3InfoRec.name, s3InfoRec.videoRam);
        }
     } else {
        if (x386Verbose) {
! 	 ErrorF("%s %s: videoram:  %dk", 
                XCONFIG_GIVEN, s3InfoRec.name, s3InfoRec.videoRam);
        }
     }
--- 437,448 ----
  	 }
        }
        if (x386Verbose) {
!          ErrorF("%s %s: videoram:  %dk\n",
                XCONFIG_PROBED, s3InfoRec.name, s3InfoRec.videoRam);
        }
     } else {
        if (x386Verbose) {
! 	 ErrorF("%s %s: videoram:  %dk\n", 
                XCONFIG_GIVEN, s3InfoRec.name, s3InfoRec.videoRam);
        }
     }
***************
*** 380,416 ****
     else
        s3Mbanks = 0;
  
!    if (OFLG_ISSET(OPTION_LEGEND, &s3InfoRec.options)) {
!       s3ClockSelectFunc = LegendClockSelect;
!       numClocks = 32;
     } else {
!       s3ClockSelectFunc = s3ClockSelect;
!       numClocks = 16;
     }
  
!    if (OFLG_ISSET(CLOCK_OPTION_ICD2061A, &s3InfoRec.clockOptions)) {
        s3ClockSelectFunc = icd2061ClockSelect;
        if (x386Verbose)
!          ErrorF("\n%s %s: Using ICD2061A programmable clock\n",
              XCONFIG_GIVEN, s3InfoRec.name);
        numClocks = 3;
     } else if (OFLG_ISSET(CLOCK_OPTION_ICD2061ASL, &s3InfoRec.clockOptions)) {
        s3ClockSelectFunc = icd2061ClockSelect;
        if (x386Verbose)
!          ErrorF("\n%s %s: Using slow ICD2061A programmable clock\n",
              XCONFIG_GIVEN, s3InfoRec.name);
        numClocks = 3;
!    } else if (!s3InfoRec.clocks) 
!       vgaGetClocks(numClocks, s3ClockSelectFunc);
  
     if (x386Verbose) {
        if (! OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &s3InfoRec.clockOptions)) {
  	 for (j = 0; j < s3InfoRec.clocks; j++) {
! 	    if ((j % 8) == 0)
!                ErrorF("\n%s %s: clocks:",
                  OFLG_ISSET(XCONFIG_CLOCKS,&s3InfoRec.xconfigFlag) ?
                      XCONFIG_GIVEN : XCONFIG_PROBED , 
                  s3InfoRec.name);
  	    ErrorF(" %6.2f", (double)s3InfoRec.clock[j] / 1000.0);
           }
           ErrorF("\n");
--- 451,707 ----
     else
        s3Mbanks = 0;
  
!    /*
!     * Handle RAMDAC Option flags first.
!     */
!    if (OFLG_ISSET(OPTION_NORMAL_DAC, &s3InfoRec.options)) {
!       s3RamdacType = NORMAL_DAC;
!    }
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
!       if (s3RamdacType != UNKNOWN_DAC) {
! 	 ErrorF("%s %s: Only one RAMDAC Option may be specified.  %s\n",
! 		s3InfoRec.name, XCONFIG_PROBED, "Ignoring \"bt485\"");
!       } else {
! 	 if (!S3_928_SERIES(s3ChipId)) {
!             ErrorF("%s %s: Bt485 is only supported on 928\n",
! 	           XCONFIG_PROBED, s3InfoRec.name);
! 	    OFLG_CLR(OPTION_BT485, &s3InfoRec.options);
! 	 } else {
!             ErrorF("%s %s: Programming for BrookTree Bt485 RAMDAC\n",
! 	           XCONFIG_GIVEN, s3InfoRec.name);
!             s3RamdacType = BT485_DAC;
! 	 }
!       }
!    }
!    if (OFLG_ISSET(OPTION_20C505, &s3InfoRec.options)) {
!       if (s3RamdacType != UNKNOWN_DAC) {
! 	 ErrorF("%s %s: Only one RAMDAC Option may be specified.  %s\n",
! 		s3InfoRec.name, XCONFIG_PROBED, "Ignoring \"20c505\"");
!       } else {
! 	 if (!S3_928_SERIES(s3ChipId)) {
!             ErrorF("%s %s: 20C505 is only supported on 928\n",
! 	           XCONFIG_PROBED, s3InfoRec.name);
! 	    OFLG_CLR(OPTION_20C505, &s3InfoRec.options);
! 	 } else {
!             ErrorF("%s %s: Programming for AT&T 20C505 RAMDAC\n",
! 	           XCONFIG_GIVEN, s3InfoRec.name);
!             s3RamdacType = ATT20C505_DAC;
! 	 }
!       }
!    }
!    if (OFLG_ISSET(OPTION_TI3020_FAST, &s3InfoRec.options)) {
!       OFLG_SET(OPTION_TI3020, &s3InfoRec.options);
!    }
!    if (OFLG_ISSET(OPTION_TI3020, &s3InfoRec.options)) {
!       if (s3RamdacType != UNKNOWN_DAC) {
! 	 ErrorF("%s %s: Only one RAMDAC Option may be specified.  %s\n",
! 		s3InfoRec.name, XCONFIG_PROBED, "Ignoring \"ti3020\"");
!       } else {
! 	 if (!S3_928_SERIES(s3ChipId)) {
!             ErrorF("%s %s: Ti3020 is only supported on 928\n",
! 	           XCONFIG_PROBED, s3InfoRec.name);
! 	    OFLG_CLR(OPTION_TI3020, &s3InfoRec.options);
! 	 } else {
!             ErrorF("%s %s: Programming for Ti ViewPoint 3020 RAMDAC\n",
! 	           XCONFIG_GIVEN, s3InfoRec.name);
! 	    s3RamdacType = TI3020_DAC;
! 	 }
!       }
!    }
! 
!    /* Make sure CR55 is unlocked for Bt485 probe */
!    outb(vgaCRIndex, 0x39);
!    outb(vgaCRReg, 0xA5);
! 
!    /* For chipsets other than 928, there is only one RAMDAC type possible */
!    if (!S3_928_SERIES(s3ChipId)) {
!       s3RamdacType = NORMAL_DAC;
!    } else if (s3RamdacType == UNKNOWN_DAC) {
!       /* Otherwise, probe for the RAMDAC type */
!       /*
!        * Bt485/AT&T20C505 first
!        *
!        * Probe for the bloody thing.  Set 0x3C6 to a bogus value, then
!        * try to get the Bt485 status register.  If it's there, then we will
!        * get something else back from this port.
!        */
!       unsigned char tmp2;
!       tmp = inb(0x3C6);
!       outb(0x3C6, 0x0F);
!       if (((tmp2 = s3InBtStatReg()) & 0x80) == 0x80) {
! 	 /*
! 	  * Found either a BrookTree Bt485 or AT&T 20C505.
! 	  */
! 	 if ((tmp2 & 0xF0) == 0xD0) {
! 	    s3RamdacType = ATT20C505_DAC;
! 	    ErrorF("%s %s: Detected an AT&T 20C505 RAMDAC\n",
! 	           XCONFIG_PROBED, s3InfoRec.name);
! 	 } else {
! 	    s3RamdacType = BT485_DAC;
! 	    ErrorF("%s %s: Detected a BrookTree Bt485 RAMDAC\n",
! 	           XCONFIG_PROBED, s3InfoRec.name);
! 	 }
!       }
!       outb(0x3C6, tmp);
! 
!       /* If it wasn't a Bt485 or AT&T 20C505, probe for the Ti3020 */
!       if (s3RamdacType == UNKNOWN_DAC) {
! 	 outb(vgaCRIndex, 0x55);
! 	 tmp = inb(vgaCRReg);
! 	 /* toggle to upper 4 direct registers */
! 	 outb(vgaCRReg, (tmp & 0xFC) | 0x01);
! 	 tmp1 = inb(TI_INDEX_REG);
! 	 outb(TI_INDEX_REG, TI_ID);
! 	 if (inb(TI_DATA_REG) == TI_VIEWPOINT_ID) {
! 	    /*
! 	     * Found TI ViewPoint DAC
! 	     */
! 	    ErrorF("%s %s: Detected a TI ViewPoint 3020 RAMDAC\n",
! 	           XCONFIG_PROBED, s3InfoRec.name);
! 	    s3RamdacType = TI3020_DAC;
! 	 }
! 	 outb(TI_INDEX_REG, tmp1);
! 	 outb(vgaCRReg, tmp);
!       }
! 
!       /* If it wasn't a Ti3020 either, it must be a "normal" ramdac */
!       if (s3RamdacType == UNKNOWN_DAC) {
! 	 s3RamdacType = NORMAL_DAC;
!       }
!    }
! 
!    /* Now handle the various ramdac cursor options */
! 
!    if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options)) {
!       if (DAC_IS_BT485_SERIES) {
! 	 ErrorF("%s %s: Using hardware cursor from Bt485/20C505 RAMDAC\n",
! 		XCONFIG_GIVEN, s3InfoRec.name);
!       } else {
! 	 ErrorF("%s %s: Bt485 cursor requires a Bt485 or 20C505 RAMDAC\n",
! 		XCONFIG_PROBED, s3InfoRec.name);
!       }
!    }
! 
!    if (DAC_IS_TI3020) {
!       if (OFLG_ISSET(OPTION_NO_TI3020_CURS, &s3InfoRec.options)) {
!          ErrorF("%s %s: Use of Ti3020 cursor disabled in Xconfig\n",
! 	        XCONFIG_GIVEN, s3InfoRec.name);
! 	 OFLG_CLR(OPTION_TI3020_CURS, &s3InfoRec.options);
!       } else {
! 	 /* use the ramdac cursor by default */
! 	 ErrorF("%s %s: Using hardware cursor from Ti3020 RAMDAC\n",
! 	        OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options) ?
! 		XCONFIG_GIVEN : XCONFIG_PROBED, s3InfoRec.name);
! 	 OFLG_SET(OPTION_TI3020_CURS, &s3InfoRec.options);
!       }
     } else {
!       if (OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options)) {
! 	 ErrorF("%s %s: Ti30205 cursor requires a Ti3020 RAMDAC\n",
! 		XCONFIG_PROBED, s3InfoRec.name);
!       }
     }
  
!    /* So far pixmux is only supported on the SPEA Mercury */
!    if (DAC_IS_BT485_SERIES &&
!        (
! #ifdef NUMNINETEST
!         OFLG_ISSET(OPTION_NUMBER_NINE, &s3InfoRec.options) ||
! #endif
!         OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options)))
!       s3Bt485PixMux = TRUE;
! 
!    /* pixmux on Bt485 requires use of Bt's cursor */
!    if (s3Bt485PixMux && !OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options)) {
!       OFLG_SET(OPTION_BT485_CURS, &s3InfoRec.options);
!       ErrorF("%s %s: Using hardware cursor from Bt485/20C505 RAMDAC\n",
! 	     XCONFIG_PROBED, s3InfoRec.name);
!    }
! 
!    /* Set clock limit */
!    switch(s3RamdacType) {
!    case BT485_DAC:
!    case ATT20C505_DAC:
!       if (s3Bt485PixMux)
! 	 s3InfoRec.maxClock = s3MaxBt485MuxClock;
!       else
! 	 s3InfoRec.maxClock = s3MaxBt485Clock;
!       break;
!    case TI3020_DAC:
!       if (OFLG_ISSET(OPTION_TI3020_FAST, &s3InfoRec.options))
!          s3InfoRec.maxClock = s3MaxTi3020ClockFast;
!       else 
!          s3InfoRec.maxClock = s3MaxTi3020Clock;
!       break;
!    default:
!       s3InfoRec.maxClock = s3MaxClock;
!    }
! 
!    /* Set the pix-mux description based on the ramdac type */
!    if (DAC_IS_TI3020) {
!       pixMuxPossible = TRUE;
!       allowPixMuxInterlace = FALSE;
!       allowPixMuxSwitching = FALSE;
!       nonMuxMaxClock = 70000;
!    } else if (s3Bt485PixMux) {
!       /* XXXX Are the defaults for the other parameters correct? */
!       pixMuxPossible = TRUE;
!       allowPixMuxInterlace = FALSE;	/* It doesn't work right (yet) */
!       allowPixMuxSwitching = FALSE;	/* XXXX Is this right? */
!       if (OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options)) {
! 	 nonMuxMaxClock = 67500;	/* Doubling only works in mux mode */
! 	 nonMuxMaxMemory = 1024;	/* Can't access more without mux */
! 	 pixMuxLimitedWidths = FALSE;
! 	 /* pixMuxMinWidth = 800;	   Not sure if this is OK */
!       } else {
! 	 nonMuxMaxClock = 85000;
!       }
!    }
! 
!    /*
!     * clock options are now done after the ramdacs because the next
!     * generation ramdacs will have a built in clock (i.e. TI 3025)
!     */
! 
!    if (OFLG_ISSET(OPTION_LEGEND, &s3InfoRec.options)) {
!       s3ClockSelectFunc = LegendClockSelect;
!       numClocks = 32;
!    } else if (OFLG_ISSET(CLOCK_OPTION_ICD2061A, &s3InfoRec.clockOptions)) {
        s3ClockSelectFunc = icd2061ClockSelect;
        if (x386Verbose)
!          ErrorF("%s %s: Using ICD2061A programmable clock\n",
              XCONFIG_GIVEN, s3InfoRec.name);
        numClocks = 3;
     } else if (OFLG_ISSET(CLOCK_OPTION_ICD2061ASL, &s3InfoRec.clockOptions)) {
        s3ClockSelectFunc = icd2061ClockSelect;
        if (x386Verbose)
!          ErrorF("%s %s: Using ICD2061A programmable clock\n",
              XCONFIG_GIVEN, s3InfoRec.name);
+ 	 ErrorF("\tNote: \"icd2061a_slow\" is deprecated; use \"icd2061a\"\n");
        numClocks = 3;
!    } else if (OFLG_ISSET(CLOCK_OPTION_SC11412, &s3InfoRec.clockOptions)) {
!       s3ClockSelectFunc = icd2061ClockSelect;
!       if (x386Verbose)
! 	 ErrorF("%s %s: Using Sierra SC11412 programmable clock\n",
! 		XCONFIG_GIVEN, s3InfoRec.name);
! 	 numClocks = 3;
!    } else {
!       s3ClockSelectFunc = s3ClockSelect;
!       numClocks = 16;
!       if (!s3InfoRec.clocks) 
!          vgaGetClocks(numClocks, s3ClockSelectFunc);
!    }
  
     if (x386Verbose) {
        if (! OFLG_ISSET(CLOCK_OPTION_PROGRAMABLE, &s3InfoRec.clockOptions)) {
  	 for (j = 0; j < s3InfoRec.clocks; j++) {
! 	    if ((j % 8) == 0) {
! 	       if (j != 0)
! 		  ErrorF("\n");
!                ErrorF("%s %s: clocks:",
                  OFLG_ISSET(XCONFIG_CLOCKS,&s3InfoRec.xconfigFlag) ?
                      XCONFIG_GIVEN : XCONFIG_PROBED , 
                  s3InfoRec.name);
+ 	    }
  	    ErrorF(" %6.2f", (double)s3InfoRec.clock[j] / 1000.0);
           }
           ErrorF("\n");
***************
*** 417,479 ****
        } 
     }
  
!    /*
!     * Handle Bt485.
!     */
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
!       if (!S3_801_928_SERIES(s3ChipId)) {
!          ErrorF("%s %s: Bt485 cannot be supported on 911/924\n",
! 	        XCONFIG_PROBED, s3InfoRec.name);
! 	 OFLG_CLR(OPTION_BT485, &s3InfoRec.options);
!       } else {
!          ErrorF("%s %s: Programming for BrookTree Bt485 RAMDAC\n",
! 	        XCONFIG_GIVEN, s3InfoRec.name);
!       }
!    } else if ((!OFLG_ISSET(OPTION_NO_BT485, &s3InfoRec.options)) &&
! 	      (S3_801_928_SERIES(s3ChipId))) {
!       /*
!        * Probe for the bloody thing.  Set 0x3C6 to a bogus value, then
!        * try to get the Bt485 status register.  If it's there, then we will
!        * get something else back from this port.
!        */
!       tmp = inb(0x3C6);
!       outb(0x3C6, 0xFF);
!       if ((s3InBtStatReg() & 0xC0) == 0x80) {
! 	 /*
! 	  * Found it.
! 	  */
! 	 ErrorF("%s %s: Detected a BrookTree Bt485 RAMDAC\n",
! 	        XCONFIG_PROBED, s3InfoRec.name);
! 	 OFLG_SET(OPTION_BT485, &s3InfoRec.options);
!       }
!       outb(0x3C6, tmp);
!    }
!    if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options)) {
!       if (OFLG_ISSET(OPTION_NO_BT485, &s3InfoRec.options)) {
!          ErrorF("%s %s: Use of Bt485 disabled in Xconfig; won't use cursor\n",
! 	        XCONFIG_GIVEN, s3InfoRec.name);
! 	 OFLG_CLR(OPTION_BT485_CURS, &s3InfoRec.options);
!       } else {
! 	 if (!S3_928_SERIES(s3ChipId)) {
!             ErrorF("%s %s: Bt485 is only supported on 928 boards\n",
! 	           XCONFIG_PROBED, s3InfoRec.name);
! 	    OFLG_CLR(OPTION_BT485_CURS, &s3InfoRec.options);
! 	 } else {
!             ErrorF("%s %s: Using hardware cursor from Bt485 RAMDAC\n",
! 	           XCONFIG_GIVEN, s3InfoRec.name);
! 	    if (!OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
!                ErrorF("%s %s: Assuming Bt485 is present\n",
! 	              XCONFIG_PROBED, s3InfoRec.name);
! 	       OFLG_SET(OPTION_BT485, &s3InfoRec.options);
! 	    }
! 	 }
!       }
!    }
! 
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options))
!       s3InfoRec.maxClock = s3MaxBt485Clock;
!    else
!       s3InfoRec.maxClock = s3MaxClock;
  
     tx = s3InfoRec.virtualX;
     ty = s3InfoRec.virtualY;
--- 708,715 ----
        } 
     }
  
!    if (pixMuxPossible && s3InfoRec.videoRam > nonMuxMaxMemory)
!       pixMuxNeeded = TRUE;
  
     tx = s3InfoRec.virtualX;
     ty = s3InfoRec.virtualY;
***************
*** 491,523 ****
        }
        s3InfoRec.virtualX = max(s3InfoRec.virtualX, pMode->HDisplay);
        s3InfoRec.virtualY = max(s3InfoRec.virtualY, pMode->VDisplay);
        pMode = pMode->next;
     } while (pMode != pEnd);
     if ((tx != s3InfoRec.virtualX) || (ty != s3InfoRec.virtualY))
        OFLG_CLR(XCONFIG_VIRTUAL,&s3InfoRec.xconfigFlag);
  
!  /*
!   * It would seem the S3 can only do two accelarated screen widths
!   */
!    if (s3InfoRec.virtualX <= 1024) {
!       s3DisplayWidth = 1024;
!    } else if (s3InfoRec.virtualX <= 1280) {
!       if (S3_911_SERIES(s3ChipId)) {
! 	 ErrorF("%s: Unsupported width for the S3 911 series chipsets\n",
! 		s3InfoRec.name);
! 	 ErrorF("%s: Maximum supported width is 1024\n", s3InfoRec.name);
  	 xf86DisableIOPorts(s3InfoRec.scrnIndex);
! 	 return (FALSE);
        }
!       s3DisplayWidth = 1280;
     } else {
        ErrorF("%s: Illegal screen size: (%dx%d)\n", s3InfoRec.name,
  	     s3InfoRec.virtualX, s3InfoRec.virtualY);
!       ErrorF("  Virtual width must be no greater than 1280\n");
        xf86DisableIOPorts(s3InfoRec.scrnIndex);
        return (FALSE);
     }
!    if ((s3DisplayWidth * (1 + s3InfoRec.virtualY)) > s3InfoRec.videoRam * 1024) {
        ErrorF("%s %s: Display size %dx%d is too large: ", 
               OFLG_ISSET(XCONFIG_VIRTUAL,&s3InfoRec.xconfigFlag) ?
                   XCONFIG_GIVEN : XCONFIG_PROBED,
--- 727,944 ----
        }
        s3InfoRec.virtualX = max(s3InfoRec.virtualX, pMode->HDisplay);
        s3InfoRec.virtualY = max(s3InfoRec.virtualY, pMode->VDisplay);
+ 
+       /*
+        * Check what impact each mode has on pixel multiplexing, and mark those
+        * modes for which pixmux must be used.
+        */
+       if (pixMuxPossible) {
+ 	 if ((s3InfoRec.clock[pMode->Clock] / 1000) >
+ 	     (nonMuxMaxClock / 1000)) {
+ 	    pMode->Flags |= V_PIXMUX;
+ 	    pixMuxNeeded = TRUE;
+ 	 }
+ 	 if (s3InfoRec.videoRam > nonMuxMaxMemory)
+ 	    pMode->Flags |= V_PIXMUX;
+ 
+ 	 /*
+ 	  * Check if pixmux can't be used.  There are two cases:
+ 	  *
+ 	  *   1. No switching between mux and non-mux modes.  In this case
+ 	  *      the presence of any mode which can't be used in pixmux
+ 	  *      mode is flagged.
+ 	  *   2. Switching allowed.  In this cases the presence of modes
+ 	  *      which require mux for one feature, but can't use it because
+ 	  *      of another is flagged.
+ 	  */
+          if (!allowPixMuxSwitching || (pMode->Flags & V_PIXMUX)) {
+ 	    if (pMode->HDisplay < pixMuxMinWidth)
+ 	       pixMuxWidthOK = FALSE;
+ 	    if ((pMode->Flags & V_INTERLACE) && !allowPixMuxInterlace)
+ 	       pixMuxInterlaceOK = FALSE;
+ 	 }
+       }
        pMode = pMode->next;
     } while (pMode != pEnd);
+ 
     if ((tx != s3InfoRec.virtualX) || (ty != s3InfoRec.virtualY))
        OFLG_CLR(XCONFIG_VIRTUAL,&s3InfoRec.xconfigFlag);
  
!    /*
!     * Are we using pixel multiplexing, or does the mode combination mean
!     * we can't continue
!     */
!    if (pixMuxPossible && pixMuxNeeded) {
!       if (!pixMuxWidthOK) {
! 	 if (s3InfoRec.videoRam > nonMuxMaxMemory) {
! 	    ErrorF("To access more than %dkB video memory the RAMDAC must\n",
! 		   nonMuxMaxMemory);
! 	    ErrorF("operate in pixel multiplex mode, but pixel multiplexing\n");
! 	    ErrorF("cannot be used for modes of width less than %d.\n",
! 		   pixMuxMinWidth);
! 	    ErrorF("Adjust the Modes and/or VideoRam and Virtual lines in\n");
! 	    ErrorF("your Xconfig to meet these requirements\n");
! 	 } else {
! 	    ErrorF("Modes with a dot-clock above %dMHz require the RAMDAC to\n",
! 		   nonMuxMaxClock / 1000);
! 	    ErrorF("operate in pixel multiplex mode, but pixel multiplexing\n");
! 	    ErrorF("cannot be used for modes with width less than %d.\n",
! 		   pixMuxMinWidth);
! 	    ErrorF("Adjust the Modes line in your Xconfig to meet these ");
! 	    ErrorF("requirements.\n");
! 	 }
!       }
!       if (!pixMuxInterlaceOK) {
! 	 if (s3InfoRec.videoRam > nonMuxMaxMemory) {
! 	    ErrorF("To access more than %dkB video memory the RAMDAC must\n",
! 		   nonMuxMaxMemory);
! 	    ErrorF("operate in pixel multiplex mode, but pixel multiplexing\n");
! 	    ErrorF("cannot be used for interlaced modes.\n",
! 		   pixMuxMinWidth);
! 	    ErrorF("Adjust the Modes and/or VideoRam and Virtual lines in\n");
! 	    ErrorF("your Xconfig to meet these requirements\n");
! 	 } else {
! 	    ErrorF("Modes with a dot-clock above %dMHz require the RAMDAC to\n",
! 		   nonMuxMaxClock / 1000);
! 	    ErrorF("operate in pixel multiplex mode, but pixel multiplexing\n");
! 	    ErrorF("cannot be used for interlaced modes.\n");
! 	    ErrorF("Adjust the Modes line in your Xconfig to meet these ");
! 	    ErrorF("requirements.\n");
! 	 }
!       }
!       if (!pixMuxWidthOK || !pixMuxInterlaceOK) {
  	 xf86DisableIOPorts(s3InfoRec.scrnIndex);
! 	 return(FALSE);
!       } else {
! 	 if (x386Verbose)
! 	    ErrorF("%s %s: Operating RAMDAC in pixel multiplex mode\n",
! 		   XCONFIG_PROBED, s3InfoRec.name);
! 	 s3UsingPixMux = TRUE;
!       }
!    }
! 
!    if (s3UsingPixMux && !allowPixMuxSwitching) {
!       /* Mark all modes as V_PIXMUX */
!       pEnd = pMode = s3InfoRec.modes;
!       do {
! 	 pMode->Flags |= V_PIXMUX;
!          pMode = pMode->next;
!       } while (pMode != pEnd);
!    }
! 
!    if (DAC_IS_TI3020 &&
!        OFLG_ISSET(OPTION_DAC_8_BIT, &s3InfoRec.options))
!       s3DAC8Bit = TRUE;
! 
!    if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
!       if (x386Verbose)
!          ErrorF("%s %s: Using AT&T 20C490/1 RAMDAC\n",
!             XCONFIG_GIVEN, s3InfoRec.name);
!       if (OFLG_ISSET(OPTION_DAC_8_BIT, &s3InfoRec.options)) {
!          s3DAC8Bit = TRUE;
!          if (x386Verbose)
!             ErrorF("%s %s: Putting RAMDAC into 8-bit mode\n",
!                XCONFIG_GIVEN, s3InfoRec.name);
!       }
!    }
!      
!    if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
!       if (x386Verbose)
!          ErrorF("%s %s: Using Sierra SC 15025/6 RAMDAC\n",
!             XCONFIG_GIVEN, s3InfoRec.name);
!       if (OFLG_ISSET(OPTION_DAC_8_BIT, &s3InfoRec.options)) {
!          s3DAC8Bit = TRUE;
!          if (x386Verbose)
!             ErrorF("%s %s: Putting RAMDAC into 8-bit mode\n",
!                XCONFIG_GIVEN, s3InfoRec.name);
        }
!    }
! 
!    if (S3_911_SERIES(s3ChipId)) {
!       maxDisplayWidth = 1024;
!       maxDisplayHeight = 1024 - 1; /* Cursor takes exactly 1 line for 911 */
     } else {
+       maxDisplayWidth = 2048;
+       maxDisplayHeight = 4096 - 3; /* Cursor can take up to 3 lines */
+    }
+    if (s3InfoRec.virtualX > maxDisplayWidth) {
+       ErrorF("%s: Illegal screen size: (%dx%d)\n", s3InfoRec.name,
+ 	     s3InfoRec.virtualX, s3InfoRec.virtualY);
+       ErrorF("\tVirtual width must be no greater than %d\n", maxDisplayWidth);
+       xf86DisableIOPorts(s3InfoRec.scrnIndex);
+       return (FALSE);
+    }
+    if (s3InfoRec.virtualY > maxDisplayHeight) {
        ErrorF("%s: Illegal screen size: (%dx%d)\n", s3InfoRec.name,
  	     s3InfoRec.virtualX, s3InfoRec.virtualY);
!       ErrorF("\tVirtual height must be no greater than %d\n", maxDisplayHeight);
        xf86DisableIOPorts(s3InfoRec.scrnIndex);
        return (FALSE);
     }
!  
!    /* Select the appropriate logical line width */
!    if (s3UsingPixMux && pixMuxLimitedWidths) {
!       if (s3InfoRec.virtualX <= 1024) {
! 	 s3DisplayWidth = 1024;
!       } else if (s3InfoRec.virtualX <= 2048) {
! 	 s3DisplayWidth = 2048;
!       } else { /* should never get here */
! 	 ErrorF("Internal error in DisplayWidth check, virtual width = %d\n",
! 	        s3InfoRec.virtualX);
! 	 xf86DisableIOPorts(s3InfoRec.scrnIndex);
! 	 return (FALSE);
!       }
!    } else if (S3_911_SERIES(s3ChipId)) {
!       s3DisplayWidth = 1024;
!    } else {
!       if (s3InfoRec.virtualX <= 640) {
! 	 s3DisplayWidth = 640;
!       } else if (s3InfoRec.virtualX <= 800) {
! 	 s3DisplayWidth = 800;
!       } else if (s3InfoRec.virtualX <= 1024) {
! 	 s3DisplayWidth = 1024;
!       } else if ((s3InfoRec.virtualX <= 1152) &&
! 		 (S3_801_REV_C(s3ChipId) || S3_928_REV_E(s3ChipId))) {
! 	 s3DisplayWidth = 1152;
!       } else if (s3InfoRec.virtualX <= 1280) {
! 	 s3DisplayWidth = 1280;
!       } else if ((s3InfoRec.virtualX <= 1600) && S3_928_REV_E(s3ChipId)) {
! 	 s3DisplayWidth = 1600;
!       } else if (s3InfoRec.virtualX <= 2048) {
! 	 s3DisplayWidth = 2048;
!       } else { /* should never get here */
! 	 ErrorF("Internal error in DisplayWidth check, virtual width = %d\n",
! 	        s3InfoRec.virtualX);
! 	 xf86DisableIOPorts(s3InfoRec.scrnIndex);
! 	 return (FALSE);
!       }
!    }
!       
!    /*
!     * Work out where to locate S3's HW cursor storage.  It must be on a
!     * 1k boundary.
!     */
! 
!    {
!       int st_addr = (s3InfoRec.virtualY * s3DisplayWidth + 1023) / 1024 * 1024;
!       s3CursorStartX = st_addr % s3DisplayWidth;
!       s3CursorStartY = st_addr / s3DisplayWidth;
!       s3CursorLines = ((s3CursorStartX + 1023) / s3DisplayWidth) + 1;
!    }
! 
!    /*
!     * Reduce the videoRam value if necessary to prevent Y coords exceeding
!     * the 12-bit (4096) limit when small display widths are used on cards
!     * with a lot of memory
!     */
!    if (s3InfoRec.videoRam * 1024 / s3DisplayWidth > 4096) {
!       s3InfoRec.videoRam = s3DisplayWidth * 4096 / 1024;
!       ErrorF("%s %s: videoram usage reduced to %dk to avoid co-ord overflow\n",
! 	     XCONFIG_PROBED, s3InfoRec.name, s3InfoRec.videoRam);
!    }
!   
!    if ((s3DisplayWidth * (s3CursorStartY + s3CursorLines)) >
!        s3InfoRec.videoRam * 1024) { /* XXXX improve this message */
        ErrorF("%s %s: Display size %dx%d is too large: ", 
               OFLG_ISSET(XCONFIG_VIRTUAL,&s3InfoRec.xconfigFlag) ?
                   XCONFIG_GIVEN : XCONFIG_PROBED,
***************
*** 634,639 ****
--- 1055,1064 ----
     long  freq;
     Bool result = TRUE;
  
+ #define MAX_SC11412_FREQ  (DAC_IS_BT485_SERIES ? \
+ 			   ((s3RamdacType == ATT20C505_DAC) ? 90000 : 67500) : \
+ 			   100000)
+ 
     UNLOCK_SYS_REGS;
     switch(no)
     {
***************
*** 652,691 ****
  	 }
  	 /* Start with freq in kHz */
  	 freq = s3InfoRec.clock[no];
! 	 if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
! 	    if (freq > s3MaxBt485Clock) {
! 	       ErrorF("%s %s: Specified dot clock (%7.3f) too high for Bt485.",
! 		      XCONFIG_PROBED, s3InfoRec.name, freq / 1000.0);
! 	       ErrorF("\tUsing %7.3Mhz\n", s3MaxBt485Clock / 1000.0);
! 	       freq = s3MaxBt485Clock;
!             }
! 	    if (freq > 67500) {
  	       /* Use Bt485 clock doubler - Bit 3 of Command Reg 3 */
  	       freq /= 2;
  	       s3OutBtRegCom3(0xF7, 0x08);
  	    } else {
  	       /* No doubler */
  	       s3OutBtRegCom3(0xF7, 0x00);
  	    }
! 	 } else {
! 	    if (freq > s3MaxClock) {
! 	       ErrorF("%s %s: Specified dot clock (%7.3f) too high for RAMDAC.",
  		      XCONFIG_PROBED, s3InfoRec.name, freq / 1000.0);
! 	       ErrorF("\tUsing %7.3MHz\n", s3MaxClock / 1000.0);
! 	       freq = s3MaxClock;
  	    }
!          }
  	 /* Convert freq to Hz */
  	 freq *= 1000;
! 	 if (OFLG_ISSET(CLOCK_OPTION_ICD2061A, &s3InfoRec.clockOptions)) {
!             clockNo = ICD2061ACalcClock(freq, 2);
!             ICD2061ASetClock(clockNo);
!             ICD2061ASetClock(clockNo);
!             ICD2061ASetClock(clockNo);
! 	 } else {
  	    AltICD2061SetClock(freq, 2);
  	    AltICD2061SetClock(freq, 2);
  	    AltICD2061SetClock(freq, 2);
  	 }
           outb(vgaCRIndex, 0x42);/* select the clock */
           outb(vgaCRReg, 0x02);
--- 1077,1150 ----
  	 }
  	 /* Start with freq in kHz */
  	 freq = s3InfoRec.clock[no];
! 	 /* Check if clock frequency is within range */
! 	 if (
! 	     !OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options) &&
! 	     OFLG_ISSET(CLOCK_OPTION_SC11412, &s3InfoRec.clockOptions) &&
! 	     freq > MAX_SC11412_FREQ) {
! 	    /* SC11412 limit as there is no clockdoubling yet */
! 	    ErrorF("%s %s: Specified dot clock (%7.3f) too high for SC11412",
! 		   XCONFIG_PROBED, s3InfoRec.name, freq / 1000.0);
! 	    ErrorF("\tUsing %7.3fMHz\n", MAX_SC11412_FREQ / 1000.0);
! 	    freq = MAX_SC11412_FREQ;
! 	 }
! 	 if (freq > s3InfoRec.maxClock) {
! 	    ErrorF("%s %s: Specified dot clock (%7.3f) too high for RAMDAC.",
! 		   XCONFIG_PROBED, s3InfoRec.name, freq / 1000.0);
! 	    ErrorF("\tUsing %7.3fMHz\n", s3InfoRec.maxClock / 1000.0);
! 	    freq = s3InfoRec.maxClock;
! 	 }
! 	 if (DAC_IS_BT485_SERIES &&
! 	     (
! 	      OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options) ||
! 	      !OFLG_ISSET(CLOCK_OPTION_SC11412, &s3InfoRec.clockOptions))) {
! 	    if (freq > ((s3RamdacType == ATT20C505_DAC) ? 90000 : 67500)) {
  	       /* Use Bt485 clock doubler - Bit 3 of Command Reg 3 */
  	       freq /= 2;
+ 	       if (s3Bt485PixMux) {
+ 		  s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01); /* sleep mode */
+ 		  s3OutBtReg(BT_COMMAND_REG_2, 0xEF, 0x10); /* pclock 1   */
+ 	       }
  	       s3OutBtRegCom3(0xF7, 0x08);
+ 	       if (s3Bt485PixMux) {
+ 	          s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x00); /* wake up    */
+ 	       }
  	    } else {
  	       /* No doubler */
+ 	       if (s3Bt485PixMux) {
+ 	          s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01); /* sleep mode */
+ 	          s3OutBtReg(BT_COMMAND_REG_2, 0xEF, 0x10); /* pclock 1   */
+ 	       }
  	       s3OutBtRegCom3(0xF7, 0x00);
+ 	       if (s3Bt485PixMux) {
+ 	          s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x00); /* wake up    */
+ 	       }
  	    }
! 	 } else if (DAC_IS_TI3020) {
! 	    if (freq > 100000) {
! 	       /* Use Ti3020 clock doubler */
! 	       ErrorF("%s %s: Specified dot clock (%7.3f) requires clock doubling.\n",
  		      XCONFIG_PROBED, s3InfoRec.name, freq / 1000.0);
! 	       freq /= 2;
! 	       s3OutTiIndReg(TI_INPUT_CLOCK_SELECT, 0x00, TI_ICLK_CLK1_DOUBLE);
! 	    } else {
! 	       /* No doubler */
! 	       s3OutTiIndReg(TI_INPUT_CLOCK_SELECT, 0x00, TI_ICLK_CLK1);
  	    }
! 	 }
  	 /* Convert freq to Hz */
  	 freq *= 1000;
! 	 /* Use the "Alt" version always since it is more reliable */
! 	 if (OFLG_ISSET(CLOCK_OPTION_ICD2061A, &s3InfoRec.clockOptions) ||
! 	     OFLG_ISSET(CLOCK_OPTION_ICD2061ASL, &s3InfoRec.clockOptions)) {
  	    AltICD2061SetClock(freq, 2);
  	    AltICD2061SetClock(freq, 2);
  	    AltICD2061SetClock(freq, 2);
+ 	 } else if (OFLG_ISSET(CLOCK_OPTION_SC11412, &s3InfoRec.clockOptions)) {
+ 	    result = SC11412SetClock((long)freq/1000);
+ 	 } else { /* Should never get here */
+ 	    result = FALSE;
+ 	    break;
  	 }
           outb(vgaCRIndex, 0x42);/* select the clock */
           outb(vgaCRReg, 0x02);
diff -c mit/server/ddx/x386/accel/s3/s3.h:2.22 mit/server/ddx/x386/accel/s3/s3.h:2.31
*** mit/server/ddx/x386/accel/s3/s3.h:2.22	Fri Mar 11 23:37:56 1994
--- mit/server/ddx/x386/accel/s3/s3.h	Fri Mar 11 23:37:56 1994
***************
*** 27,33 ****
   * Id: s3.h,v 2.2 1993/06/22 20:54:09 jon Exp jon
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3.h,v 2.22 1993/09/29 11:10:56 dawes Exp $ */
  
  #ifndef S3_H
  #define S3_H
--- 27,33 ----
   * Id: s3.h,v 2.2 1993/06/22 20:54:09 jon Exp jon
  */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3.h,v 2.31 1994/03/08 04:48:11 dawes Exp $ */
  
  #ifndef S3_H
  #define S3_H
***************
*** 34,39 ****
--- 34,45 ----
  
  #define S3_PATCHLEVEL "0"
  
+ /*
+  * This is included, but it hasn't been tested properly yet.  It enables
+  * the undocumented "number_nine" Option (which will turn on the pixmux code).
+  */
+ #define NUMNINETEST
+ 
  #ifndef LINKKIT
  #include "s3name.h"
  
***************
*** 89,94 ****
--- 95,101 ----
  
  extern void s3WarpCursor();
  extern void s3RestoreCursor();
+ extern void s3RenewCursorColor();
  extern void s3QueryBestSize();
  extern void (*s3ImageReadFunc)();
  extern void (*s3ImageWriteFunc)();
***************
*** 127,133 ****
  	DisplayModePtr mode
  #endif
  );
! extern void InitEnvironment(
  #if NeedFunctionPrototypes
  	void
  #endif
--- 134,140 ----
  	DisplayModePtr mode
  #endif
  );
! extern void s3InitEnvironment(
  #if NeedFunctionPrototypes
  	void
  #endif
***************
*** 204,209 ****
--- 211,217 ----
  extern pointer s3VideoMem;
  extern pointer vgaBase;
  extern ScreenPtr s3savepScreen;
+ extern int s3CursorStartX, s3CursorStartY, s3CursorLines;
  
  /* also needed in s3 somebody fix these headers please */
  extern Bool mfbRegisterCopyPlaneProc();
***************
*** 223,228 ****
--- 231,252 ----
  extern int vgaCRReg;
  
  extern int s3ValidTokens[];
+ 
+ extern int s3RamdacType;
+ extern Bool s3DAC8Bit;
+ extern Bool s3UsingPixMux;
+ extern Bool s3Bt485PixMux;
+ 
+ #define UNKNOWN_DAC       -1
+ #define NORMAL_DAC         0
+ #define BT485_DAC          1
+ #define ATT20C505_DAC      2
+ #define TI3020_DAC         3
+ 
+ #define DAC_IS_BT485_SERIES    (s3RamdacType == BT485_DAC || \
+ 			        s3RamdacType == ATT20C505_DAC)
+ #define DAC_IS_TI3020	       (s3RamdacType == TI3020_DAC)
+ 
  _XFUNCPROTOEND
  
  #endif /* !LINKKIT */
diff -c mit/server/ddx/x386/accel/s3/s3BtCursor.c:2.4 mit/server/ddx/x386/accel/s3/s3BtCursor.c:2.7
*** mit/server/ddx/x386/accel/s3/s3BtCursor.c:2.4	Fri Mar 11 23:37:57 1994
--- mit/server/ddx/x386/accel/s3/s3BtCursor.c	Fri Mar 11 23:37:57 1994
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3BtCursor.c,v 2.4 1993/10/03 14:55:02 dawes Exp $ */
  
  #define NEED_EVENTS
  #include <X.h>
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3BtCursor.c,v 2.7 1994/01/09 03:30:51 dawes Exp $ */
  
  #define NEED_EVENTS
  #include <X.h>
***************
*** 132,137 ****
--- 132,138 ----
     s3OutBtReg(BT_COMMAND_REG_0, 0x7F, 0x80);
     s3OutBtReg(BT_WRITE_ADDR, 0x00, 0x01);
     ret = s3InBtReg(BT_STATUS_REG);
+    return(ret);
  }
  
  /*
***************
*** 250,255 ****
--- 251,261 ----
  	    *plane1++ = 0x00;
  	 }
        }
+       /*
+        * if we still have more bytes on this line (j < wsrc),
+        * we have to ignore the rest of the line.
+        */
+        while (j++ < wsrc) pServMsk++,pServSrc++;
     }
     return TRUE;
  }
***************
*** 364,370 ****
       int x, y;
  {
     int   index = pScr->myNum;
!    register int   i, j, t;
     unsigned char *ram, *p;
  
     if (!x386VTSema)
--- 370,376 ----
       int x, y;
  {
     int   index = pScr->myNum;
!    register int   i, j;
     unsigned char *ram, *p;
  
     if (!x386VTSema)
diff -c mit/server/ddx/x386/accel/s3/s3Cursor.c:2.29 mit/server/ddx/x386/accel/s3/s3Cursor.c:2.34
*** mit/server/ddx/x386/accel/s3/s3Cursor.c:2.29	Fri Mar 11 23:37:57 1994
--- mit/server/ddx/x386/accel/s3/s3Cursor.c	Fri Mar 11 23:37:57 1994
***************
*** 28,34 ****
   * Id: s3Cursor.c,v 2.5 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3Cursor.c,v 2.29 1993/10/17 14:43:29 dawes Exp $ */
  
  /*
   * Device independent (?) part of HW cursor support
--- 28,34 ----
   * Id: s3Cursor.c,v 2.5 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3Cursor.c,v 2.34 1994/02/25 14:58:42 dawes Exp $ */
  
  /*
   * Device independent (?) part of HW cursor support
***************
*** 48,53 ****
--- 48,54 ----
  #include <windowstr.h>
  #include "x386.h"
  #include "inputstr.h"
+ #include "mfb.h"
  #include "x386Priv.h"
  #include "xf86_Option.h"
  #include "xf86_OSlib.h"
***************
*** 65,71 ****
  extern void s3BtCursorOff();
  extern void s3BtLoadCursor();
  extern void s3BtMoveCursor();
! extern void s3BtRecolorCursor();
  
  extern short s3ChipId;
  
--- 66,76 ----
  extern void s3BtCursorOff();
  extern void s3BtLoadCursor();
  extern void s3BtMoveCursor();
! extern Bool s3TiRealizeCursor();
! extern void s3TiCursorOn();
! extern void s3TiCursorOff();
! extern void s3TiLoadCursor();
! extern void s3TiMoveCursor();
  
  extern short s3ChipId;
  
***************
*** 85,90 ****
--- 90,103 ----
     s3BtMoveCursor,
  };
  
+ static miPointerSpriteFuncRec s3TiPointerSpriteFuncs =
+ {
+    s3TiRealizeCursor,
+    s3UnrealizeCursor,
+    s3SetCursor,
+    s3TiMoveCursor,
+ };
+ 
  extern miPointerScreenFuncRec x386PointerScreenFuncs;
  extern x386InfoRec x386Info;
  extern unsigned char s3SwapBits[256];
***************
*** 94,99 ****
--- 107,119 ----
  
  extern int s3hotX, s3hotY;
  
+ #define VerticalRetraceWait() \
+ { \
+    while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ; \
+    while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x08) ; \
+    while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ; \
+ }
+ 
  Bool
  s3CursorInit(pm, pScr)
       char *pm;
***************
*** 109,114 ****
--- 129,138 ----
           if (!(miPointerInitialize(pScr, &s3BtPointerSpriteFuncs,
  				   &x386PointerScreenFuncs, FALSE)))
              return FALSE;
+       } else if (OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options)) {
+          if (!(miPointerInitialize(pScr, &s3TiPointerSpriteFuncs,
+ 				   &x386PointerScreenFuncs, FALSE)))
+             return FALSE;
        } else {
           if (!(miPointerInitialize(pScr, &s3PointerSpriteFuncs,
  				   &x386PointerScreenFuncs, FALSE)))
***************
*** 125,130 ****
--- 149,156 ----
  {
     if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options))
        s3BtCursorOn();
+    else if (OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options))
+       s3TiCursorOn();
     /* Nothing to do for integrated cursor */
  }
  
***************
*** 133,138 ****
--- 159,166 ----
  {
     if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options))
        s3BtCursorOff();
+    else if (OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options))
+       s3TiCursorOff();
     /* Nothing to do for integrated cursor */
  }
  
***************
*** 218,224 ****
       int x, y;
  {
     int   index = pScr->myNum;
!    int   i, yline;
     unsigned short *ram;
     unsigned char tmp;
     int cpos;
--- 246,253 ----
       int x, y;
  {
     int   index = pScr->myNum;
!    int   i, j;
!    int   n, bytes_remaining, xpos, ypos, ram_loc;
     unsigned short *ram;
     unsigned char tmp;
     int cpos;
***************
*** 230,236 ****
        return;
  
     /* Load storage location.  */
!    cpos = (s3DisplayWidth * s3InfoRec.virtualY) / 1024;
     outb(vgaCRIndex, 0x4d);
     outb(vgaCRReg, (0xff & cpos));
     outb(vgaCRIndex, 0x4c);
--- 259,265 ----
        return;
  
     /* Load storage location.  */
!    cpos = (s3DisplayWidth * s3CursorStartY + s3CursorStartX) / 1024;
     outb(vgaCRIndex, 0x4d);
     outb(vgaCRReg, (0xff & cpos));
     outb(vgaCRIndex, 0x4c);
***************
*** 249,283 ****
     /* s3 stuff */
     WaitIdle();
  
!    WaitQueue(4);
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_L | 0);
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_T | 0);
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_R | (s3DisplayWidth-1));
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_B | s3ScissB);
  
     WaitIdle();
  
!    S3_OUTW(WRT_MASK, 0x0ff);
!    S3_OUTW(FRGD_MIX, 0x40 | 0x7);
!    S3_OUTW(MULTIFUNC_CNTL, PIX_CNTL + 0x7);
!    S3_OUTW(MULTIFUNC_CNTL, 0);
!    S3_OUTW(MAJ_AXIS_PCNT, 1023);
!    S3_OUTW(CUR_X, 0);
!    S3_OUTW(CUR_Y, s3InfoRec.virtualY);
! 
!    S3_OUTW(CMD, CMD_RECT | _16BIT | BYTSEQ | INC_X | INC_Y
! 	 | PCDATA | DRAW | WRTDATA);
! 
!    WaitQueue(8);
!    for (i = 0; i < 512; i++) {
!       S3_OUTW(PIX_TRANS, ram[i]);
     }
     UNBLOCK_CURSOR;
  
     /* Wait for vertical retrace */
!    while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ;
!    while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x08) ;
!    while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ;
  
     /* position cursor */
     s3MoveCursor(0, x, y);
--- 278,334 ----
     /* s3 stuff */
     WaitIdle();
  
!    WaitQueue(7);
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_L | 0);
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_T | 0);
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_R | (s3DisplayWidth-1));
     S3_OUTW(MULTIFUNC_CNTL, SCISSORS_B | s3ScissB);
+    S3_OUTW(WRT_MASK, 0x0ff);
+    S3_OUTW(FRGD_MIX, FSS_PCDATA | MIX_SRC);
+    S3_OUTW(MULTIFUNC_CNTL, PIX_CNTL | 0);
  
     WaitIdle();
  
!    /*
!     * This form is general enough for any valid DisplayWidth.  The only
!     * assumption is that it is even.
!     */
!    xpos = s3CursorStartX;
!    ypos = s3CursorStartY;
!    bytes_remaining = 1024;
!    ram_loc = 0;
!    while (bytes_remaining > 0) {
!       if (s3DisplayWidth - xpos < bytes_remaining)
!          n = s3DisplayWidth - xpos;
!       else
!          n = bytes_remaining;
! 
!       WaitQueue(5);
! 
!       S3_OUTW(MULTIFUNC_CNTL, MIN_AXIS_PCNT | 0);
!       S3_OUTW(MAJ_AXIS_PCNT, n - 1);
!       S3_OUTW(CUR_X, xpos);
!       S3_OUTW(CUR_Y, ypos);
! 
!       S3_OUTW(CMD, CMD_RECT | _16BIT | BYTSEQ | INC_X | INC_Y
!  		     | PCDATA | DRAW | WRTDATA);
! 
!       WaitQueue(8);
! 
!       for (i = ram_loc; i < n/2 + ram_loc; i++) {
!          S3_OUTW(PIX_TRANS, ram[i]);
!       }
! 
!       ram_loc = i;
!       ypos++;
!       xpos = 0;
!       bytes_remaining -= n;
     }
+ 
     UNBLOCK_CURSOR;
  
     /* Wait for vertical retrace */
!    VerticalRetraceWait();
  
     /* position cursor */
     s3MoveCursor(0, x, y);
***************
*** 309,320 ****
     s3hotY = pCurs->bits->yhot;
     s3SaveCursors[index] = pCurs;
  
!    if (!s3BlockCursor)
        if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options))
           s3BtLoadCursor(pScr, pCurs, x, y);
        else
           s3LoadCursor(pScr, pCurs, x, y);
!    else
        s3ReloadCursor = TRUE;
  }
  
--- 360,373 ----
     s3hotY = pCurs->bits->yhot;
     s3SaveCursors[index] = pCurs;
  
!    if (!s3BlockCursor) {
        if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options))
           s3BtLoadCursor(pScr, pCurs, x, y);
+       else if (OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options))
+          s3TiLoadCursor(pScr, pCurs, x, y);
        else
           s3LoadCursor(pScr, pCurs, x, y);
!    } else
        s3ReloadCursor = TRUE;
  }
  
***************
*** 329,334 ****
--- 382,389 ----
     miPointerPosition(&x, &y);
     if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options))
        s3BtLoadCursor(pScr, s3SaveCursors[index], x, y);
+    else if (OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options))
+       s3TiLoadCursor(pScr, s3SaveCursors[index], x, y);
     else
        s3LoadCursor(pScr, s3SaveCursors[index], x, y);
  }
***************
*** 342,352 ****
     miPointerPosition(&x, &y);
     if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options))
        s3BtMoveCursor(pScr, x, y);
     else {
        /* Wait for vertical retrace */
!       while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ;
!       while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x08) ;
!       while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ;
        s3MoveCursor(pScr, x, y);
     }
  }
--- 397,407 ----
     miPointerPosition(&x, &y);
     if (OFLG_ISSET(OPTION_BT485_CURS, &s3InfoRec.options))
        s3BtMoveCursor(pScr, x, y);
+    else if (OFLG_ISSET(OPTION_TI3020_CURS, &s3InfoRec.options))
+       s3TiMoveCursor(pScr, x, y);
     else {
        /* Wait for vertical retrace */
!       VerticalRetraceWait();
        s3MoveCursor(pScr, x, y);
     }
  }
***************
*** 413,421 ****
--- 468,480 ----
     LOCK_SYS_REGS;
  }
  
+ void
  s3RenewCursorColor(pScr)
     ScreenPtr pScr;
  {
+    if (!x386VTSema)
+       return;
+ 
     if (s3SaveCursors[pScr->myNum])
        s3RecolorCursor(pScr, s3SaveCursors[pScr->myNum], TRUE);
  }
***************
*** 454,462 ****
  {
     if (x386VTSema) {
        /* Wait for vertical retrace */
!       while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ;
!       while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x08) ;
!       while ((inb(vgaIOBase + 0x0A) & 0x08) == 0x00) ;
     }
     miPointerWarpCursor(pScr, x, y);
     x386Info.currentScreen = pScr;
--- 513,519 ----
  {
     if (x386VTSema) {
        /* Wait for vertical retrace */
!       VerticalRetraceWait();
     }
     miPointerWarpCursor(pScr, x, y);
     x386Info.currentScreen = pScr;
diff -c /dev/null mit/server/ddx/x386/accel/s3/s3Ti3020.h:2.1
*** /dev/null	Fri Mar 11 23:37:58 1994
--- mit/server/ddx/x386/accel/s3/s3Ti3020.h	Fri Mar 11 23:37:58 1994
***************
*** 0 ****
--- 1,134 ----
+ /*
+  * Copyright 1994 by Robin Cutshaw <robin@paros.com>
+  *
+  * 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 Robin Cutshaw not be used in
+  * advertising or publicity pertaining to distribution of the software without
+  * specific, written prior permission.  Robin Cutshaw makes no representations
+  * about the suitability of this software for any purpose.  It is provided
+  * "as is" without express or implied warranty.
+  *
+  * ROBIN CUTSHAW DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+  * EVENT SHALL ROBIN CUTSHAW 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: mit/server/ddx/x386/accel/s3/s3Ti3020.h,v 2.1 1994/01/15 02:50:40 dawes Exp $ */
+ 
+ #include "compiler.h"
+ #include <X11/Xfuncproto.h>
+ 
+ /*
+ #define MAX_TI3020_CLOCK       135000
+ #define MAX_TI3020_CLOCK_FAST  200000
+ */
+ 
+ /* Direct standard VGA registers, special index and data registers */
+ 
+ #define TI_WRITE_ADDR		0x3C8   /* CR55 low bit == 0 */
+ #define TI_RAMDAC_DATA		0x3C9   /* CR55 low bit == 0 */
+ #define TI_PIXEL_MASK		0x3C6   /* CR55 low bit == 0 */
+ #define TI_READ_ADDR		0x3C7   /* CR55 low bit == 0 */
+ #define TI_INDEX_REG		0x3C6   /* CR55 low bit == 1 */
+ #define TI_DATA_REG		0x3C7   /* CR55 low bit == 1 */
+ 
+ /* Indirect indexed registers */
+ 
+ #define TI_CURS_X_LOW		0x00
+ #define TI_CURS_X_HIGH		0x01    /* only lower 4 bits are used */
+ #define TI_CURS_Y_LOW		0x02
+ #define TI_CURS_Y_HIGH		0x03    /* only lower 4 bits are used */
+ #define TI_SPRITE_ORIGIN_X	0x04
+ #define TI_SPRITE_ORIGIN_Y	0x05
+ #define TI_CURS_CONTROL		0x06
+ #define   TI_CURS_SPRITE_ENABLE 0x40
+ #define   TI_CURS_X_WINDOW_MODE 0x10
+ #define   TI_CURS_CTRL_MASK     (TI_CURS_SPRITE_ENABLE | TI_CURS_X_WINDOW_MODE)
+ #define TI_CURS_RAM_ADDR_LOW	0x08
+ #define TI_CURS_RAM_ADDR_HIGH	0x09
+ #define TI_CURS_RAM_DATA	0x0A
+ #define TI_WINDOW_START_X_LOW	0x10
+ #define TI_WINDOW_START_X_HIGH	0x11
+ #define TI_WINDOW_STOP_X_LOW	0x12
+ #define TI_WINDOW_STOP_X_HIGH	0x13
+ #define TI_WINDOW_START_Y_LOW	0x14
+ #define TI_WINDOW_START_Y_HIGH	0x15
+ #define TI_WINDOW_STOP_Y_LOW	0x16
+ #define TI_WINDOW_STOP_Y_HIGH	0x17
+ #define TI_MUX_CONTROL_1	0x18
+ #define   TI_MUX1_PSEUDO_COLOR	0x80
+ #define TI_MUX_CONTROL_2	0x19
+ #define   TI_MUX2_BUS_VGA	0x98
+ #define   TI_MUX2_BUS_PIX64	0x1C
+ #define TI_INPUT_CLOCK_SELECT	0x1A
+ #define   TI_ICLK_CLK0		0x00
+ #define   TI_ICLK_CLK0_DOUBLE	0x10
+ #define   TI_ICLK_CLK1		0x01
+ #define   TI_ICLK_CLK1_DOUBLE	0x11
+ #define TI_OUTPUT_CLOCK_SELECT	0x1B
+ #define   TI_OCLK_VGA		0x3E
+ #define   TI_OCLK_S_V4_R8	0x53
+ #define TI_PALETTE_PAGE		0x1C
+ #define TI_GENERAL_CONTROL	0x1D
+ #define TI_OVERSCAN_COLOR_RED	0x20
+ #define TI_OVERSCAN_COLOR_GREEN	0x21
+ #define TI_OVERSCAN_COLOR_BLUE	0x22
+ #define TI_CURSOR_COLOR_0_RED	0x23
+ #define TI_CURSOR_COLOR_0_GREEN	0x24
+ #define TI_CURSOR_COLOR_0_BLUE	0x25
+ #define TI_CURSOR_COLOR_1_RED	0x26
+ #define TI_CURSOR_COLOR_1_GREEN	0x27
+ #define TI_CURSOR_COLOR_1_BLUE	0x28
+ #define TI_AUXILLARY_CONTROL	0x29
+ #define   TI_AUX_SELF_CLOCK	0x08
+ #define   TI_AUX_W_CMPL		0x01
+ #define TI_GENERAL_IO_CONTROL	0x2A
+ #define   TI_GIC_ALL_BITS	0x1F
+ #define TI_GENERAL_IO_DATA	0x2B
+ #define   TI_GID_S3_DAC_6BIT	0x1C
+ #define   TI_GID_S3_DAC_8BIT	0x1E
+ #define   TI_GID_TI_DAC_6BIT	0x1D
+ #define   TI_GID_TI_DAC_8BIT	0x1F
+ #define TI_COLOR_KEY_OLVGA_LOW	0x30
+ #define TI_COLOR_KEY_OLVGA_HIGH	0x31
+ #define TI_COLOR_KEY_RED_LOW	0x32
+ #define TI_COLOR_KEY_RED_HIGH	0x33
+ #define TI_COLOR_KEY_GREEN_LOW	0x34
+ #define TI_COLOR_KEY_GREEN_HIGH	0x35
+ #define TI_COLOR_KEY_BLUE_LOW	0x36
+ #define TI_COLOR_KEY_BLUE_HIGH	0x37
+ #define TI_COLOR_KEY_CONTROL	0x38
+ #define TI_SENSE_TEST		0x3A
+ #define TI_TEST_DATA		0x3B
+ #define TI_CRC_LOW		0x3C
+ #define TI_CRC_HIGH		0x3D
+ #define TI_CRC_CONTROL		0x3E
+ #define TI_ID			0x3F
+ #define   TI_VIEWPOINT_ID	0x20
+ 
+ 
+ _XFUNCPROTOBEGIN
+ 
+ extern void s3OutTiIndReg(
+ #if NeedFunctionPrototypes
+ 	unsigned char,
+ 	unsigned char,
+ 	unsigned char
+ #endif
+ );
+ 
+ extern unsigned char s3InTiIndReg(
+ #if NeedFunctionPrototypes
+ 	unsigned char
+ #endif
+ );
+ 
+ _XFUNCPROTOEND
diff -c /dev/null mit/server/ddx/x386/accel/s3/s3TiCursor.c:2.1
*** /dev/null	Fri Mar 11 23:37:59 1994
--- mit/server/ddx/x386/accel/s3/s3TiCursor.c	Fri Mar 11 23:37:59 1994
***************
*** 0 ****
--- 1,391 ----
+ /*
+  * Copyright 1994 by Robin Cutshaw <robin@paros.com>
+  *
+  * 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 Robin Cutshaw not be used in
+  * advertising or publicity pertaining to distribution of the software without
+  * specific, written prior permission.  Robin Cutshaw makes no representations
+  * about the suitability of this software for any purpose.  It is provided
+  * "as is" without express or implied warranty.
+  *
+  * ROBIN CUTSHAW DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+  * EVENT SHALL ROBIN CUTSHAW 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: mit/server/ddx/x386/accel/s3/s3TiCursor.c,v 2.1 1994/02/12 11:06:15 dawes Exp $ */
+ 
+ #define NEED_EVENTS
+ #include <X.h>
+ #include "Xproto.h"
+ #include <misc.h>
+ #include <input.h>
+ #include <cursorstr.h>
+ #include <regionstr.h>
+ #include <scrnintstr.h>
+ #include <servermd.h>
+ #include <windowstr.h>
+ #include "x386.h"
+ #include "inputstr.h"
+ #include "x386Priv.h"
+ #include "xf86_OSlib.h"
+ #include "s3.h"
+ #include "regs3.h"
+ #include "s3Ti3020.h"
+ 
+ #define MAX_CURS_HEIGHT 64   /* 64 scan lines */
+ #define MAX_CURS_WIDTH  64   /* 64 pixels     */
+ 
+ 
+ #ifndef __GNUC__
+ # define __inline__ /**/
+ #endif
+ 
+ /*
+  * TI ViewPoint 3020 support - Robin Cutshaw
+  *
+  * The Ti3020 has 8 direct command registers and indirect registers
+  * 0x00-0x3F and 0xFF.  The low-order two bits of the direct register
+  * address follow normal VGA DAC addressing conventions (which 
+  * for some reason aren't in numeric order, so we remap them through 
+  * an array).  The S3 provides access to the high-order bit via
+  * the low-order bit of CR55.  The indirect registers are accessed
+  * through the direct index and data registers.  See s3Ti3020.h for
+  * details.
+  */
+ 
+ /*
+  * s3OutTiIndReg() and s3InTiIndReg() are used to access the indirect
+  * 3020 registers only.
+  */
+ 
+ #ifdef __STDC__
+ void s3OutTiIndReg(unsigned char reg, unsigned char mask, unsigned char data)
+ #else
+ void s3OutTiIndReg(reg, mask, data)
+ unsigned char reg;
+ unsigned char mask;
+ unsigned char data;
+ #endif
+ {
+    unsigned char tmp, tmp1, tmp2 = 0x00;
+ 
+    /* High 2 bits of reg in CR55 bits 0-1 (1 is cleared for the TI ramdac) */
+    outb(vgaCRIndex, 0x55);
+    tmp = inb(vgaCRReg) & 0xFC;
+    outb(vgaCRReg, tmp | 0x01);  /* toggle to upper 4 direct registers */
+    tmp1 = inb(TI_INDEX_REG);
+    outb(TI_INDEX_REG, reg);
+ 
+    /* Have to map the low two bits to the correct DAC register */
+    if (mask != 0x00)
+       tmp2 = inb(TI_DATA_REG) & mask;
+    outb(TI_DATA_REG, tmp2 | data);
+    
+    /* Now clear 2 high-order bits so that other things work */
+    outb(TI_INDEX_REG, tmp1);  /* just in case anyone relies on this */
+    outb(vgaCRReg, tmp);
+ }
+ 
+ #ifdef __STDC__
+ unsigned char s3InTiIndReg(unsigned char reg)
+ #else
+ unsigned char s3InTiIndReg(reg)
+ unsigned char reg;
+ #endif
+ {
+    unsigned char tmp, tmp1, ret;
+ 
+    /* High 2 bits of reg in CR55 bits 0-1 (1 is cleared for the TI ramdac) */
+    outb(vgaCRIndex, 0x55);
+    tmp = inb(vgaCRReg) & 0xFC;
+    outb(vgaCRReg, tmp | 0x01);  /* toggle to upper 4 direct registers */
+    tmp1 = inb(TI_INDEX_REG);
+    outb(TI_INDEX_REG, reg);
+ 
+    /* Have to map the low two bits to the correct DAC register */
+    ret = inb(TI_DATA_REG);
+ 
+    /* Now clear 2 high-order bits so that other things work */
+    outb(TI_INDEX_REG, tmp1);  /* just in case anyone relies on this */
+    outb(vgaCRReg, tmp);
+ 
+    return(ret);
+ }
+ 
+ /*
+  * Convert the cursor from server-format to hardware-format.  The Ti3020
+  * has two planes, plane 0 selects cursor color 0 or 1 and plane 1
+  * selects transparent or display cursor.  The bits of these planes
+  * are packed together so that one byte has 4 pixels. The organization
+  * looks like:
+  *             Byte 0x000 - 0x00F    top scan line, left to right
+  *                  0x010 - 0x01F
+  *                    .       .
+  *                  0x3F0 - 0x3FF    bottom scan line
+  *
+  *             Byte/bit map - D7D6,D5D4,D3D2,D1D0  four pixels, two planes each
+  *             Pixel/bit map - P1P0  (plane 1) == 1 maps to cursor color
+  *                                   (plane 1) == 0 maps to transparent
+  *                                   (plane 0) maps to cursor colors 0 and 1
+  */
+ 
+ Bool
+ s3TiRealizeCursor(pScr, pCurs)
+      ScreenPtr pScr;
+      CursorPtr pCurs;
+ {
+    register int i, j;
+    unsigned char *pServMsk;
+    unsigned char *pServSrc;
+    pointer *pPriv;
+    int   wsrc, h;
+    unsigned char *ram;
+ 
+    if (pCurs->bits->refcnt > 1)
+       return TRUE;
+ 
+    ram = (unsigned char *)xalloc(1024);  /* 64x64x2 bits */
+    pPriv = &pCurs->bits->devPriv[pScr->myNum];
+    *pPriv = (pointer) ram;
+ 
+    if (!ram)
+       return FALSE;
+ 
+    pServSrc = (unsigned char *)pCurs->bits->source;
+    pServMsk = (unsigned char *)pCurs->bits->mask;
+ 
+    h = pCurs->bits->height;
+    if (h > MAX_CURS_HEIGHT)
+       h = MAX_CURS_HEIGHT;
+ 
+    wsrc = PixmapBytePad(pCurs->bits->width, 1);	/* bytes per line */
+ 
+    for (i = 0; i < MAX_CURS_HEIGHT; i++,ram+=16) {
+       for (j = 0; j < MAX_CURS_WIDTH / 8; j++) {
+ 	 register unsigned char mask, source;
+ 
+ 	 if (i < h && j < wsrc) {
+ 	    /*
+ 	     * normally we would use s3SwapBits to quickly reverse bits
+ 	     * but since have to do bit twiddles anyway, there is no need.
+ 	     * mask byte ABCDEFGH and source byte 12345678 map to two byte
+ 	     * cursor data H8G7F6E5 D4C3B2A1
+ 	     */
+ 	    mask = *pServMsk++;
+ 	    source = *pServSrc++ & mask;
+ 
+ 	    /* map 1 byte source and mask into two byte cursor data */
+ 	    ram[j*2] =     ((mask&0x01) << 7) | ((source&0x01) << 6) |
+ 		           ((mask&0x02) << 4) | ((source&0x02) << 3) |
+ 		           ((mask&0x04) << 1) | (source&0x04)        |
+ 		           ((mask&0x08) >> 2) | ((source&0x08) >> 3) ;
+ 	    ram[(j*2)+1] = ((mask&0x10) << 3) | ((source&0x10) << 2) |
+ 		           (mask&0x20)        | ((source&0x20) >> 1) |
+ 		           ((mask&0x40) >> 3) | ((source&0x40) >> 4) |
+ 		           ((mask&0x80) >> 6) | ((source&0x80) >> 7) ;
+ 	 } else {
+ 	    ram[j*2]     = 0x00;
+ 	    ram[(j*2)+1] = 0x00;
+ 	 }
+       }
+       /*
+        * if we still have more bytes on this line (j < wsrc),
+        * we have to ignore the rest of the line.
+        */
+        while (j++ < wsrc) pServMsk++,pServSrc++;
+    }
+    return TRUE;
+ }
+ 
+ void 
+ s3TiCursorOn()
+ {
+    unsigned char tmp;
+ 
+    UNLOCK_SYS_REGS;
+ 
+    /* turn on external cursor */
+    outb(vgaCRIndex, 0x55);
+    tmp = inb(vgaCRReg) & 0xDF;
+    outb(vgaCRReg, tmp | 0x20);
+ 
+    /* Enable Ti3020 */
+    outb(vgaCRIndex, 0x45);
+    tmp = inb(vgaCRReg) & 0xDF;
+    outb(vgaCRReg, tmp | 0x20);
+    
+    /* Enable cursor - sprite enable, X11 mode */
+    s3OutTiIndReg(TI_CURS_CONTROL,
+ 		 (unsigned char )~TI_CURS_CTRL_MASK,
+ 	         TI_CURS_SPRITE_ENABLE | TI_CURS_X_WINDOW_MODE);
+ 
+    LOCK_SYS_REGS;
+    return;
+ }
+ 
+ void
+ s3TiCursorOff()
+ {
+    UNLOCK_SYS_REGS;
+ 
+    /*
+     * Don't need to undo the S3 registers here; they will be undone when
+     * the mode is restored from save registers.  If it is done here, it
+     * causes the cursor to flash each time it is loaded, so don't do that.
+     */
+ 
+    /* Disable cursor */
+    s3OutTiIndReg(TI_CURS_CONTROL,
+ 		 (unsigned char )~TI_CURS_CTRL_MASK, 0x00);
+ 
+    LOCK_SYS_REGS;
+    return;
+ }
+ 
+ void
+ s3TiMoveCursor(pScr, x, y)
+      ScreenPtr pScr;
+      int   x, y;
+ {
+ 
+    if (s3BlockCursor)
+       return;
+    
+    x -= s3InfoRec.frameX0;
+    if (x < 0)
+       return;
+ 
+    y -= s3InfoRec.frameY0;
+    if (y < 0)
+       return;
+ 
+    UNLOCK_SYS_REGS;
+ 
+    /* Output position - "only" 12 bits of location documented */
+    s3OutTiIndReg(TI_CURS_X_LOW, 0x00, x & 0xFF);
+    s3OutTiIndReg(TI_CURS_X_HIGH, 0x00, (x >> 8) & 0x0F);
+    s3OutTiIndReg(TI_CURS_Y_LOW, 0x00, y & 0xFF);
+    s3OutTiIndReg(TI_CURS_Y_HIGH, 0x00, (y >> 8) & 0x0F);
+ 
+    LOCK_SYS_REGS;
+    return;
+ }
+ 
+ void
+ s3TiRecolorCursor(pScr, pCurs)
+      ScreenPtr pScr;
+      CursorPtr pCurs;
+ {
+    UNLOCK_SYS_REGS;
+ 
+    /* The TI 3020 cursor is always 8 bits so shift 8, not 10 */
+ 
+    /* Background color */
+    s3OutTiIndReg(TI_CURSOR_COLOR_0_RED,   0, (pCurs->backRed >> 8) & 0xFF);
+    s3OutTiIndReg(TI_CURSOR_COLOR_0_GREEN, 0, (pCurs->backGreen >> 8) &0xFF);
+    s3OutTiIndReg(TI_CURSOR_COLOR_0_BLUE,  0, (pCurs->backBlue >> 8) & 0xFF);
+ 
+    /* Foreground color */
+    s3OutTiIndReg(TI_CURSOR_COLOR_1_RED,   0, (pCurs->foreRed >> 8) & 0xFF);
+    s3OutTiIndReg(TI_CURSOR_COLOR_1_GREEN, 0, (pCurs->foreGreen >> 8) & 0xFF);
+    s3OutTiIndReg(TI_CURSOR_COLOR_1_BLUE,  0, (pCurs->foreBlue >> 8) & 0xFF);
+ 
+    LOCK_SYS_REGS;
+    return;
+ }
+ 
+ void 
+ s3TiLoadCursor(pScr, pCurs, x, y)
+      ScreenPtr pScr;
+      CursorPtr pCurs;
+      int x, y;
+ {
+    extern int s3hotX, s3hotY;
+    int   index = pScr->myNum;
+    register int   i, j;
+    unsigned char *ram, *p, tmp, tmp1, tmpcurs;
+    extern int s3InitCursorFlag;
+ 
+    if (!x386VTSema)
+       return;
+ 
+    if (!pCurs)
+       return;
+ 
+    /* turn the cursor off */
+    if ((tmpcurs = s3InTiIndReg(TI_CURS_CONTROL)) & TI_CURS_SPRITE_ENABLE)
+       s3TiCursorOff();
+ 
+    /* load colormap */
+    s3TiRecolorCursor(pScr, pCurs);
+ 
+    ram = (unsigned char *)pCurs->bits->devPriv[index];
+ 
+    UNLOCK_SYS_REGS;
+    BLOCK_CURSOR;
+ 
+    /* The hardware cursor is not supported in interlaced mode */
+ 
+    /* High 2 bits of reg in CR55 bits 0-1 (1 is cleared for the TI ramdac) */
+    outb(vgaCRIndex, 0x55);
+    tmp = inb(vgaCRReg) & 0xFC;
+    outb(vgaCRReg, tmp | 0x01); /* toggle to the high four direct registers */
+    tmp1 = inb(TI_INDEX_REG);
+ 
+    outb(TI_INDEX_REG, TI_CURS_RAM_ADDR_LOW); /* must be first */
+    outb(TI_DATA_REG, 0x00);
+    outb(TI_INDEX_REG, TI_CURS_RAM_ADDR_HIGH);
+    outb(TI_DATA_REG, 0x00);
+    outb(TI_INDEX_REG, TI_CURS_RAM_DATA);
+ 
+    /* 
+     * Output the cursor data.  The realize function has put the planes into
+     * their correct order, so we can just blast this out.
+     */
+    p = ram;
+    for (i = 0; i < 1024; i++,p++)
+       outb(TI_DATA_REG, *p);
+ 
+    if (s3hotX >= MAX_CURS_WIDTH)
+       s3hotX = MAX_CURS_WIDTH - 1;
+    else if (s3hotX < 0)
+       s3hotX = 0;
+    if (s3hotY >= MAX_CURS_HEIGHT)
+       s3hotY = MAX_CURS_HEIGHT - 1;
+    else if (s3hotY < 0)
+       s3hotY = 0;
+ 
+    outb(TI_INDEX_REG, TI_SPRITE_ORIGIN_X); /* offset into cursor data */
+    outb(TI_DATA_REG, s3hotX);
+    outb(TI_INDEX_REG, TI_SPRITE_ORIGIN_Y);
+    outb(TI_DATA_REG, s3hotY);
+    outb(TI_INDEX_REG, tmp1);
+ 
+    outb(vgaCRIndex, 0x55);
+    outb(vgaCRReg, tmp);
+ 
+    UNBLOCK_CURSOR;
+    LOCK_SYS_REGS;
+ 
+    /* position cursor */
+    s3TiMoveCursor(0, x, y);
+ 
+    /* turn the cursor on */
+    if ((tmpcurs & TI_CURS_SPRITE_ENABLE) || s3InitCursorFlag)
+       s3TiCursorOn();
+ 
+    if (s3InitCursorFlag)
+       s3InitCursorFlag = FALSE;
+ 
+    return;
+ }
diff -c mit/server/ddx/x386/accel/s3/s3bcach.c:2.18 mit/server/ddx/x386/accel/s3/s3bcach.c:2.20
*** mit/server/ddx/x386/accel/s3/s3bcach.c:2.18	Fri Mar 11 23:38:00 1994
--- mit/server/ddx/x386/accel/s3/s3bcach.c	Fri Mar 11 23:38:00 1994
***************
*** 25,31 ****
   * Id: s3bcach.c,v 2.3 1993/07/24 13:16:56 jon Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3bcach.c,v 2.18 1993/09/27 12:24:15 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 25,31 ----
   * Id: s3bcach.c,v 2.3 1993/07/24 13:16:56 jon Exp
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3bcach.c,v 2.20 1994/01/01 16:24:02 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 50,56 ****
--- 50,58 ----
  extern int s3FC_MAX_HEIGHT;
  extern Bool x386Verbose;
  
+ #ifdef DEBUG_FCACHE
  static void showcache();
+ #endif
  
  /*
   * TERMS:
***************
*** 88,98 ****
        return;
     }
     reEntry = TRUE;
!    s3FC_MAX_HEIGHT = s3ScissB - y;
!    y++;   /* one line for cursor on top */
     
  
!    if (s3FC_MAX_HEIGHT < 32) /* no pixmap cache */
        s3CacheLen = s3DisplayWidth;
     else
        s3CacheLen = 768;
--- 90,103 ----
        return;
     }
     reEntry = TRUE;
! 
!    /* y now includes the cursor space */
!    s3FC_MAX_HEIGHT = s3ScissB + 1 - y;
     
  
!    /* Currently no pixmap cache when s3DisplayWidth < 1024 */
! 
!    if (s3FC_MAX_HEIGHT < 32 || s3DisplayWidth < 1024) /* no pixmap cache */
        s3CacheLen = s3DisplayWidth;
     else
        s3CacheLen = 768;
***************
*** 369,374 ****
--- 374,380 ----
  
  }
  
+ #ifdef DEBUG_FCACHE
  /*
   * debuging print out, this give a nice picture of the current structure
   * of linked lists - believe it or not.
***************
*** 386,388 ****
--- 392,395 ----
        ErrorF(":\n");
     }
  }
+ #endif
diff -c mit/server/ddx/x386/accel/s3/s3blt.c:2.12 mit/server/ddx/x386/accel/s3/s3blt.c:2.15
*** mit/server/ddx/x386/accel/s3/s3blt.c:2.12	Fri Mar 11 23:38:01 1994
--- mit/server/ddx/x386/accel/s3/s3blt.c	Fri Mar 11 23:38:01 1994
***************
*** 32,38 ****
   * Id: s3blt.c,v 2.2 1993/06/22 20:54:09 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3blt.c,v 2.12 1993/09/25 05:02:01 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 32,38 ----
   * Id: s3blt.c,v 2.2 1993/06/22 20:54:09 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3blt.c,v 2.15 1994/02/25 14:58:44 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 55,60 ****
--- 55,61 ----
  
  extern int s3MAX_SLOTS;
  void  s3FindOrdering();
+ extern RegionPtr cfbBitBlt();
  
  RegionPtr
  s3CopyArea(pSrcDrawable, pDstDrawable,
***************
*** 539,544 ****
--- 540,572 ----
  	 (void) cfbBitBlt(pSrcDrawable, (DrawablePtr)pBitmap, pGC1, srcx, srcy,
  			  width, height, 0, 0, cfbCopyPlane8to1, bitPlane);
  	 pSrcDrawable = (DrawablePtr)pBitmap;
+       }
+       else if ((pSrcDrawable->type == DRAWABLE_WINDOW) &&
+ 	       (pDstDrawable->type != DRAWABLE_WINDOW)) {
+ 	 /*
+ 	  * Shortcut - we can do Window->Pixmap by copying the window to
+ 	  * a pixmap, then we have a Pixmap->Pixmap operation
+ 	  */
+ 	 GCPtr pGC1;
+ 	 RegionPtr retval;
+ 	 PixmapPtr pPixmap;
+ 
+ 	 pPixmap=(*pSrcDrawable->pScreen->CreatePixmap)(pSrcDrawable->pScreen, 
+ 						        width, height, 8);
+ 	 if (!pPixmap)
+ 	    return(NULL);
+ 	 pGC1 = GetScratchGC(8, pSrcDrawable->pScreen);
+ 	 if (!pGC1) {
+ 	    (*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
+ 	    return(NULL);
+ 	 }
+ 	 ValidateGC((DrawablePtr)pPixmap, pGC1);
+ 	 s3CopyArea(pSrcDrawable, pPixmap, pGC1, srcx, srcy, width, height,
+ 		    0, 0);
+ 	 retval = cfbCopyPlane((DrawablePtr)pPixmap, pDstDrawable, pGC,
+                              0, 0, width, height, dstx, dsty, bitPlane);
+ 	 (*pSrcDrawable->pScreen->DestroyPixmap)(pPixmap);
+ 	 return(retval);
        }
        else if (((pSrcDrawable->type == DRAWABLE_WINDOW) && 
                  (pDstDrawable->type != DRAWABLE_WINDOW)) ||
diff -c mit/server/ddx/x386/accel/s3/s3cmap.c:2.5 mit/server/ddx/x386/accel/s3/s3cmap.c:2.6
*** mit/server/ddx/x386/accel/s3/s3cmap.c:2.5	Fri Mar 11 23:38:02 1994
--- mit/server/ddx/x386/accel/s3/s3cmap.c	Fri Mar 11 23:38:02 1994
***************
*** 31,37 ****
   * Id: s3cmap.c,v 2.2 1993/06/22 20:54:09 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3cmap.c,v 2.5 1993/09/21 15:22:38 dawes Exp $ */
  
  #include "X.h"
  #include "Xproto.h"
--- 31,37 ----
   * Id: s3cmap.c,v 2.2 1993/06/22 20:54:09 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3cmap.c,v 2.6 1994/01/09 03:30:56 dawes Exp $ */
  
  #include "X.h"
  #include "Xproto.h"
***************
*** 102,107 ****
--- 102,108 ----
  {
     int   i;
     xColorItem directDefs[256];
+    extern Bool s3DAC8Bit;
  
     if (pmap != InstalledMaps[pmap->pScreen->myNum])
        return;
***************
*** 112,125 ****
     }
     BLOCK_CURSOR;
     for (i = 0; i < ndef; i++) {
!       currents3dac[pdefs[i].pixel].r = pdefs[i].red >> 10;
!       currents3dac[pdefs[i].pixel].g = pdefs[i].green >> 10;
!       currents3dac[pdefs[i].pixel].b = pdefs[i].blue >> 10;
        if (x386VTSema) {
  	 outb(DAC_W_INDEX, pdefs[i].pixel);
! 	 outb(DAC_DATA, pdefs[i].red >> 10);
! 	 outb(DAC_DATA, pdefs[i].green >> 10);
! 	 outb(DAC_DATA, pdefs[i].blue >> 10);
        }
     }
     UNBLOCK_CURSOR;
--- 113,134 ----
     }
     BLOCK_CURSOR;
     for (i = 0; i < ndef; i++) {
!       unsigned char r, g, b;
! 
!       if (s3DAC8Bit) {
!          r = currents3dac[pdefs[i].pixel].r = pdefs[i].red >> 8;
!          g = currents3dac[pdefs[i].pixel].g = pdefs[i].green >> 8;
!          b = currents3dac[pdefs[i].pixel].b = pdefs[i].blue >> 8;
!       } else {
!          r = currents3dac[pdefs[i].pixel].r = pdefs[i].red >> 10;
!          g = currents3dac[pdefs[i].pixel].g = pdefs[i].green >> 10;
!          b = currents3dac[pdefs[i].pixel].b = pdefs[i].blue >> 10;
!       }
        if (x386VTSema) {
  	 outb(DAC_W_INDEX, pdefs[i].pixel);
! 	 outb(DAC_DATA, r);
! 	 outb(DAC_DATA, g);
! 	 outb(DAC_DATA, b);
        }
     }
     UNBLOCK_CURSOR;
***************
*** 202,208 ****
  {
     Pixel pix = 0;
     xrgb  rgb;
! 
     if (InstalledMaps[pScreen->myNum] == NOMAPYET)
        return;
  
--- 211,218 ----
  {
     Pixel pix = 0;
     xrgb  rgb;
!    extern Bool s3DAC8Bit;
!    
     if (InstalledMaps[pScreen->myNum] == NOMAPYET)
        return;
  
***************
*** 210,217 ****
  
     BLOCK_CURSOR;
     outb(DAC_W_INDEX, 0);
!    outb(DAC_DATA, rgb.red >> 10);
!    outb(DAC_DATA, rgb.green >> 10);
!    outb(DAC_DATA, rgb.blue >> 10);
     UNBLOCK_CURSOR;
  }
--- 220,233 ----
  
     BLOCK_CURSOR;
     outb(DAC_W_INDEX, 0);
!    if (s3DAC8Bit) {
!       outb(DAC_DATA, rgb.red >> 8);
!       outb(DAC_DATA, rgb.green >> 8);
!       outb(DAC_DATA, rgb.blue >> 8);
!    } else {
!       outb(DAC_DATA, rgb.red >> 10);
!       outb(DAC_DATA, rgb.green >> 10);
!       outb(DAC_DATA, rgb.blue >> 10);
!    }
     UNBLOCK_CURSOR;
  }
diff -c mit/server/ddx/x386/accel/s3/s3dline.c:2.10 mit/server/ddx/x386/accel/s3/s3dline.c:2.11
*** mit/server/ddx/x386/accel/s3/s3dline.c:2.10	Fri Mar 11 23:38:02 1994
--- mit/server/ddx/x386/accel/s3/s3dline.c	Fri Mar 11 23:38:02 1994
***************
*** 26,32 ****
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
  /* s3dline.c from s3line.c with help from cfbresd.c and cfbline.c - Jon */
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3dline.c,v 2.10 1993/09/21 15:22:39 dawes Exp $ */
  
  #include "X.h"
  
--- 26,32 ----
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
  /* s3dline.c from s3line.c with help from cfbresd.c and cfbline.c - Jon */
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3dline.c,v 2.11 1993/12/25 13:59:50 dawes Exp $ */
  
  #include "X.h"
  
***************
*** 376,382 ****
          */
  
  	 while (nbox--) {
- 	    int dlen;
  	    oc1 = 0;
  	    oc2 = 0;
  	    OUTCODES(oc1, x1, y1, pbox);
--- 376,381 ----
diff -c mit/server/ddx/x386/accel/s3/s3dseg.c:2.2 mit/server/ddx/x386/accel/s3/s3dseg.c:2.3
*** mit/server/ddx/x386/accel/s3/s3dseg.c:2.2	Fri Mar 11 23:38:03 1994
--- mit/server/ddx/x386/accel/s3/s3dseg.c	Fri Mar 11 23:38:03 1994
***************
*** 26,32 ****
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
  /* s3dline.c from s3line.c with help from cfbresd.c and cfbline.c - Jon */
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3dseg.c,v 2.2 1993/09/21 15:22:41 dawes Exp $ */
  
  #include "X.h"
  
--- 26,32 ----
  /* $XConsortium: cfbline.c,v 1.19 91/08/13 18:48:42 keith Exp $ */
  
  /* s3dline.c from s3line.c with help from cfbresd.c and cfbline.c - Jon */
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3dseg.c,v 2.3 1993/12/25 13:59:53 dawes Exp $ */
  
  #include "X.h"
  
***************
*** 369,375 ****
          */
  
  	 while (nbox--) {
- 	    int dlen;
  	    oc1 = 0;
  	    oc2 = 0;
  	    OUTCODES(oc1, x1, y1, pbox);
--- 369,374 ----
diff -c mit/server/ddx/x386/accel/s3/s3im.c:2.26 mit/server/ddx/x386/accel/s3/s3im.c:2.28
*** mit/server/ddx/x386/accel/s3/s3im.c:2.26	Fri Mar 11 23:38:04 1994
--- mit/server/ddx/x386/accel/s3/s3im.c	Fri Mar 11 23:38:04 1994
***************
*** 27,33 ****
   * Id: s3im.c,v 2.7 1993/08/10 15:20:03 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3im.c,v 2.26 1993/10/07 13:55:39 dawes Exp $ */
  
  #include "misc.h"
  #include "x386.h"
--- 27,33 ----
   * Id: s3im.c,v 2.7 1993/08/10 15:20:03 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3im.c,v 2.28 1993/12/25 13:59:56 dawes Exp $ */
  
  #include "misc.h"
  #include "x386.h"
***************
*** 60,66 ****
  extern unsigned char s3Port54;
  extern Bool x386Verbose;
  extern Bool s3LinearAperture;
- extern unsigned char s3LinApOpt;
  extern void  (*s3ImageReadFunc) (), (*s3ImageWriteFunc) ();
  extern void  (*s3ImageFillFunc) ();
  
--- 60,65 ----
***************
*** 457,463 ****
       short alu;
       short planemask;
  {
!    int   j, i, offset;
     char  bank;
     char *videobuffer;
  
--- 456,462 ----
       short alu;
       short planemask;
  {
!    int   j, offset;
     char  bank;
     char *videobuffer;
  
***************
*** 527,533 ****
       int   py;
       short planemask;
  {
!    int   j, i;
     int   offset;
     int   bank;
     char *videobuffer;
--- 526,532 ----
       int   py;
       short planemask;
  {
!    int   j;
     int   offset;
     int   bank;
     char *videobuffer;
***************
*** 588,594 ****
       short alu;
       short planemask;
  {
!    int   j, i;
     unsigned char *pline;
     int   ypix, xpix, offset0;
     int   cxpix;
--- 587,593 ----
       short alu;
       short planemask;
  {
!    int   j;
     unsigned char *pline;
     int   ypix, xpix, offset0;
     int   cxpix;
diff -c mit/server/ddx/x386/accel/s3/s3init.c:2.34 mit/server/ddx/x386/accel/s3/s3init.c:2.58
*** mit/server/ddx/x386/accel/s3/s3init.c:2.34	Fri Mar 11 23:38:05 1994
--- mit/server/ddx/x386/accel/s3/s3init.c	Fri Mar 11 23:38:06 1994
***************
*** 23,29 ****
   * Id: s3init.c,v 2.5 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3init.c,v 2.34 1993/09/30 17:48:59 dawes Exp $ */
  
  #define USE_VGAHWINIT
  
--- 23,29 ----
   * Id: s3init.c,v 2.5 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3init.c,v 2.58 1994/03/10 07:05:14 dawes Exp $ */
  
  #define USE_VGAHWINIT
  
***************
*** 41,51 ****
--- 41,55 ----
  #include "s3.h"
  #include "regs3.h"
  #include "s3Bt485.h"
+ #include "s3Ti3020.h"
  
  #ifdef NEW_INIT_SAVE_RESTORE
  typedef struct {
     vgaHWRec std;                /* good old IBM VGA */
+    unsigned char SC15025[2];    /* Sierra SC 15025/6 command registers */
+    unsigned char ATT490_1;	/* AT&T 20C490/1 command register */
     unsigned char Bt485[4];	/* Bt485 Command Registers 0-3 */
+    unsigned char Ti3020[0x40];	/* Ti3020 Indirect Registers 0x0-0x3F */
     unsigned char s3reg[13];     /* Video Atribute (CR30-3C) */
     unsigned char s3sysreg[36];  /* Video Atribute (CR40-63) */
     unsigned short AdvFuncCntl;  /* 0x4AE8 */
***************
*** 54,60 ****
--- 58,67 ----
  #else
  typedef struct {
     vgaHWRec std;                /* good old IBM VGA */
+    unsigned char SC15025[2];    /* Sierra SC 15025/6 command registers */
+    unsigned char ATT490_1;	/* AT&T 20C490/1 command register */
     unsigned char Bt485[4];	/* Bt485 Command Registers 0-3 */
+    unsigned char Ti3020[0x40];	/* Ti3020 Indirect Registers 0x0-0x3F */
     unsigned char s3reg[10];     /* Video Atribute (CR30-34, CR38-3C) */
     unsigned char s3sysreg[36];  /* Video Atribute (CR40-63)*/
  }
***************
*** 64,69 ****
--- 71,77 ----
  int   vgaIOBase = 0x3d0; /* These defaults are overriden in s3Probe() */
  int   vgaCRIndex = 0x3d4;
  int   vgaCRReg = 0x3d5;
+ int   s3InitCursorFlag = TRUE;
  extern x386InfoRec x386Info;
  
  static vgaS3Ptr oldS3 = NULL;
***************
*** 102,116 ****
   * Registers to save/restore in the 0x50 - 0x5f control range
   */
  
! static short reg50_mask = 0x4023;
  
! extern char s3Port54;
! extern char s3Port51;
! extern char s3Port40;
  void
  s3CleanUp(void)
  {
     int   i;
  
     UNLOCK_SYS_REGS;
     
--- 110,129 ----
   * Registers to save/restore in the 0x50 - 0x5f control range
   */
  
! static short reg50_mask = 0x6733; /* was 0x4023 */
  
! extern unsigned char s3Port54;
! extern unsigned char s3Port51;
! extern unsigned char s3Port40;
! extern unsigned char s3Port59;
! extern unsigned char s3Port5A;
! extern unsigned char s3Port31;
! 
  void
  s3CleanUp(void)
  {
     int   i;
+    unsigned char c, tmp;
  
     UNLOCK_SYS_REGS;
     
***************
*** 127,149 ****
        outb(vgaCRIndex, 0x53);
        outb(vgaCRReg, 0x00);
     }
-    vgaHWRestore(oldS3);
  
   /* (s3ClockSelectFunc)(restore->std.NoClock); */
  
     /*
      * Restore Bt485 registers
      */
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
        s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01);
        s3OutBtRegCom3(0x00, oldS3->Bt485[3]);
! #if NOTYET
!       s3OutBtReg(BT_COMMAND_REG_2, 0x00, oldS3->Bt485[2]);
!       s3OutBtReg(BT_COMMAND_REG_1, 0x00, oldS3->Bt485[1]);
! #endif
        s3OutBtReg(BT_COMMAND_REG_0, 0x00, oldS3->Bt485[0]);
     }
  
   /* restore s3 special bits */
     if (S3_801_928_SERIES(s3ChipId)) {
      /* restore 801 specific registers */
--- 140,223 ----
        outb(vgaCRIndex, 0x53);
        outb(vgaCRReg, 0x00);
     }
  
   /* (s3ClockSelectFunc)(restore->std.NoClock); */
  
     /*
+     * Restore AT&T 20C490/1 command register.
+     */
+    if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
+       xf86setdaccomm(oldS3->ATT490_1);
+    }
+    
+    /*
+     * Restore Sierra SC 15025/6 registers.
+     */
+    if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
+       c=xf86getdaccomm();
+       xf86setdaccomm( c | 0x10 );  /* set internal register access */
+       (void)xf86dactocomm();
+       outb(0x3c7, 0x8);
+       outb(0x3c8, oldS3->SC15025[1]);
+       xf86setdaccomm( c );
+       xf86setdaccomm(oldS3->SC15025[0]);
+    }
+ 
+    /*
      * Restore Bt485 registers
      */
!    if (DAC_IS_BT485_SERIES) {
! 
!       /* Turn off parallel mode explicitly here */
!       if (s3Bt485PixMux) {
! #ifdef NO_USER_OUT
! 	 /* This might not be SPEA specific */
!          if (OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options))
! #endif
! 	 {
! 	    outb(vgaCRIndex, 0x5C);
! 	    outb(vgaCRReg, 0x20);
! 	    outb(0x3C7, 0x00);
! 	    /* set s3 reg53 to non-parallel addressing by and'ing 0xDF     */
!             outb(vgaCRIndex, 0x53);
!             tmp = inb(vgaCRReg);
!             outb(vgaCRReg, tmp & 0xDF);
! 	    outb(vgaCRIndex, 0x5C);
! 	    outb(vgaCRReg, 0x00);
!          }
!       }
! 	 
        s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01);
        s3OutBtRegCom3(0x00, oldS3->Bt485[3]);
!       if (s3Bt485PixMux) {
! 	 s3OutBtReg(BT_COMMAND_REG_2, 0x00, oldS3->Bt485[2]);
! 	 s3OutBtReg(BT_COMMAND_REG_1, 0x00, oldS3->Bt485[1]);
!       }
        s3OutBtReg(BT_COMMAND_REG_0, 0x00, oldS3->Bt485[0]);
     }
  
+    /*
+     * Restore Ti3020 registers
+     */
+    if (DAC_IS_TI3020) {
+       s3OutTiIndReg(TI_CURS_CONTROL, 0x00, oldS3->Ti3020[TI_CURS_CONTROL]);
+       s3OutTiIndReg(TI_MUX_CONTROL_1, 0x00, oldS3->Ti3020[TI_MUX_CONTROL_1]);
+       s3OutTiIndReg(TI_MUX_CONTROL_2, 0x00, oldS3->Ti3020[TI_MUX_CONTROL_2]);
+       s3OutTiIndReg(TI_INPUT_CLOCK_SELECT, 0x00,
+ 		    oldS3->Ti3020[TI_INPUT_CLOCK_SELECT]);
+       s3OutTiIndReg(TI_OUTPUT_CLOCK_SELECT, 0x00,
+ 		    oldS3->Ti3020[TI_OUTPUT_CLOCK_SELECT]);
+       s3OutTiIndReg(TI_GENERAL_CONTROL, 0x00,
+ 		    oldS3->Ti3020[TI_GENERAL_CONTROL]);
+       s3OutTiIndReg(TI_AUXILLARY_CONTROL, 0x00,
+ 		    oldS3->Ti3020[TI_AUXILLARY_CONTROL]);
+       s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, 0x1f);
+       s3OutTiIndReg(TI_GENERAL_IO_DATA, 0x00,
+ 		    oldS3->Ti3020[TI_GENERAL_IO_DATA]);
+    }
+ 
+    vgaHWRestore(oldS3);
+ 
   /* restore s3 special bits */
     if (S3_801_928_SERIES(s3ChipId)) {
      /* restore 801 specific registers */
***************
*** 195,203 ****
  s3Init(mode)
       DisplayModePtr mode;
  {
- 
     short i;
!    int   interlacedived = 1;
  
     UNLOCK_SYS_REGS;
  
--- 269,279 ----
  s3Init(mode)
       DisplayModePtr mode;
  {
     short i;
!    int   interlacedived = mode->Flags & V_INTERLACE ? 2 : 1;
!    int   pixel_multiplexing;
!    unsigned char tmp, tmp1, tmp2;
!    extern Bool s3DAC8Bit;
  
     UNLOCK_SYS_REGS;
  
***************
*** 226,247 ****
        oldS3 = vgaHWSave(oldS3, sizeof(vgaS3Rec));
  
        /*
         * Save Bt485 Registers
         */
!       if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
  	 oldS3->Bt485[0] = s3InBtReg(BT_COMMAND_REG_0);
! #ifdef NOTYET
! 	 oldS3->Bt485[1] = s3InBtReg(BT_COMMAND_REG_1);
! 	 oldS3->Bt485[2] = s3InBtReg(BT_COMMAND_REG_2);
! #endif
  	 oldS3->Bt485[3] = s3InBtRegCom3();
        }
  
        for (i = 0; i < 5; i++) {
  	 outb(vgaCRIndex, 0x30 + i);
  	 oldS3->s3reg[i] = inb(vgaCRReg);
  	 outb(vgaCRIndex, 0x38 + i);
  	 oldS3->s3reg[5 + i] = inb(vgaCRReg);
        }
  
        outb(vgaCRIndex, 0x11);	/* allow writting? */
--- 302,367 ----
        oldS3 = vgaHWSave(oldS3, sizeof(vgaS3Rec));
  
        /*
+        * Save AT&T 20C490/1 command register.
+        */
+       if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
+          oldS3->ATT490_1 = xf86getdaccomm();
+       }
+ 
+       /*
+        * Save Sierra SC15025/6 command registers.
+        */
+       LOCK_SYS_REGS;
+       if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
+          oldS3->SC15025[0] = xf86getdaccomm();
+ 	 xf86setdaccomm((oldS3->SC15025[0] | 0x10));
+          (void)xf86dactocomm();
+ 	 outb(0x3c7,0x8);
+ 	 oldS3->SC15025[1] = inb(0x3c8);
+ 	 xf86setdaccomm(oldS3->SC15025[0]);
+       }
+       UNLOCK_SYS_REGS;
+       /*
         * Save Bt485 Registers
         */
!       if (DAC_IS_BT485_SERIES) {
  	 oldS3->Bt485[0] = s3InBtReg(BT_COMMAND_REG_0);
! 	 if (s3Bt485PixMux) {
! 	    oldS3->Bt485[1] = s3InBtReg(BT_COMMAND_REG_1);
! 	    oldS3->Bt485[2] = s3InBtReg(BT_COMMAND_REG_2);
! 	 }
  	 oldS3->Bt485[3] = s3InBtRegCom3();
        }
  
+       /*
+        * Save Ti3020 registers
+        */
+       if (DAC_IS_TI3020) {
+           oldS3->Ti3020[TI_CURS_CONTROL] = s3InTiIndReg(TI_CURS_CONTROL);
+           oldS3->Ti3020[TI_MUX_CONTROL_1] = s3InTiIndReg(TI_MUX_CONTROL_1);
+           oldS3->Ti3020[TI_MUX_CONTROL_2] = s3InTiIndReg(TI_MUX_CONTROL_2);
+           oldS3->Ti3020[TI_INPUT_CLOCK_SELECT] =
+                  s3InTiIndReg(TI_INPUT_CLOCK_SELECT);
+           oldS3->Ti3020[TI_OUTPUT_CLOCK_SELECT] =
+                  s3InTiIndReg(TI_OUTPUT_CLOCK_SELECT);
+           oldS3->Ti3020[TI_GENERAL_CONTROL] = s3InTiIndReg(TI_GENERAL_CONTROL);
+           oldS3->Ti3020[TI_AUXILLARY_CONTROL] =
+ 		 s3InTiIndReg(TI_AUXILLARY_CONTROL);
+           s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, 0x1f);
+           oldS3->Ti3020[TI_GENERAL_IO_DATA] = s3InTiIndReg(TI_GENERAL_IO_DATA);
+       }
+ 
        for (i = 0; i < 5; i++) {
  	 outb(vgaCRIndex, 0x30 + i);
  	 oldS3->s3reg[i] = inb(vgaCRReg);
+ #ifdef REG_DEBUG
+ 	 ErrorF("CR%X = 0x%02x\n", 0x30 + i, oldS3->s3reg[i]);
+ #endif
  	 outb(vgaCRIndex, 0x38 + i);
  	 oldS3->s3reg[5 + i] = inb(vgaCRReg);
+ #ifdef REG_DEBUG
+ 	 ErrorF("CR%X = 0x%02x\n", 0x38 + i, oldS3->s3reg[i + 5]);
+ #endif
        }
  
        outb(vgaCRIndex, 0x11);	/* allow writting? */
***************
*** 249,258 ****
--- 369,385 ----
        for (i = 0; i < 16; i++) {
  	 outb(vgaCRIndex, 0x40 + i);
  	 oldS3->s3sysreg[i] = inb(vgaCRReg);
+ #ifdef REG_DEBUG
+ 	 ErrorF("CR%X = 0x%02x\n", 0x40 + i, oldS3->s3sysreg[i]);
+ #endif
        }
  
        if (S3_801_928_SERIES(s3ChipId)) 
           for (i = 0; i < 16; i++) {
+ #ifdef REG_DEBUG
+ 	     outb(vgaCRIndex, 0x50 + i);
+ 	     ErrorF("CR%X = 0x%02x\n", 0x50 + i, inb(vgaCRReg));
+ #endif
  	     if (!((1 << i) & reg50_mask))
  	       continue;
  	     outb(vgaCRIndex, 0x50 + i);
***************
*** 262,267 ****
--- 389,397 ----
        for (i = 32; i < 35; i++) {
  	 outb(vgaCRIndex, 0x40 + i);
  	 oldS3->s3sysreg[i] = inb(vgaCRReg);
+ #ifdef REG_DEBUG
+ 	 ErrorF("CR%X = 0x%02x\n", 0x40 + i, oldS3->s3sysreg[i]);
+ #endif
        }
  
        s3Initialised = 1;
***************
*** 270,278 ****
--- 400,430 ----
  
     }
  
+    if (s3UsingPixMux && (mode->Flags & V_PIXMUX))
+       pixel_multiplexing = TRUE;
+    else
+       pixel_multiplexing = FALSE;
+ 
+ 
+    if (pixel_multiplexing) {
+       /* now divide the horizontal timing parameters by 4 for VCLK/4 */
+       mode->HTotal >>= 2;
+       mode->HDisplay >>= 2;
+       mode->HSyncStart >>= 2;
+       mode->HSyncEnd >>= 2;
+    }
+ 
     if (!vgaHWInit(mode, sizeof(vgaS3Rec)))
        return(FALSE);
  
+    if (pixel_multiplexing) {
+       /* put back the horizontal timing parameters */
+       mode->HTotal <<= 2;
+       mode->HDisplay <<= 2;
+       mode->HSyncStart <<= 2;
+       mode->HSyncEnd <<= 2;
+    }
+ 
     new->MiscOutReg |= 0x0C;		/* enable CR42 clock selection */
     new->Sequencer[0] = 0x03;		/* XXXX shouldn't need this */
     new->CRTC[19] = s3DisplayWidth >> 3;
***************
*** 287,299 ****
     else
        new->MiscOutReg |= 0x01;
  
     /* Don't change the clock bits when using an external clock program */
  
     if (new->NoClock < 0) {
-       unsigned char tmp;
- 
        tmp = inb(0x3CC);
        new->MiscOutReg = (new->MiscOutReg & 0xF3) | (tmp & 0x0C);
     }
  
     outb(0x3C2, new->MiscOutReg);
--- 439,721 ----
     else
        new->MiscOutReg |= 0x01;
  
+    if (OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options)) {
+       /*
+        * Make sure that parallel option is already set correctly before
+        * changing the clock doubler state.
+        * XXXX maybe the !pixel_multiplexing bit is not required?
+        */
+       if (pixel_multiplexing) {
+ 	 outb(vgaCRIndex, 0x5C);
+ 	 outb(vgaCRReg, 0x20);
+ 	 outb(0x3C7, 0x21);
+ 	 /* set s3 reg53 to parallel addressing by or'ing 0x20		*/
+ 	 outb(vgaCRIndex, 0x53);
+ 	 tmp = inb(vgaCRReg);
+ 	 outb(vgaCRReg, tmp | 0x20);  
+ 	 outb(vgaCRIndex, 0x5C);
+ 	 outb(vgaCRReg, 0x00);
+       } else {
+ 	 outb(vgaCRIndex, 0x5C);
+ 	 outb(vgaCRReg, 0x20);
+ 	 outb(0x3C7, 0x00); 
+ 	 /* set s3 reg53 to non-parallel addressing by and'ing 0xDF	*/
+ 	 outb(vgaCRIndex, 0x53);
+ 	 tmp = inb(vgaCRReg);
+ 	 outb(vgaCRReg, tmp & 0xDF);
+ 	 outb(vgaCRIndex, 0x5C);
+ 	 outb(vgaCRReg, 0x00);
+       }
+    }
+ 
     /* Don't change the clock bits when using an external clock program */
  
     if (new->NoClock < 0) {
        tmp = inb(0x3CC);
        new->MiscOutReg = (new->MiscOutReg & 0xF3) | (tmp & 0x0C);
+    } else {
+       /* XXXX Should we really do something about the return value? */
+       (void) (s3ClockSelectFunc) (mode->Clock);
+    }
+ 
+    /*
+     * Set AT&T 20C490/1 command register to 8-bit mode if desired.
+     */
+    if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
+       if (s3DAC8Bit) {
+          xf86setdaccommbit(0x02);
+       } else {
+ 	 xf86clrdaccommbit(0x02);
+       }
+    }
+ 
+    /*
+     * Set Sierra SC 15025/6 command registers to 8-bit mode if desired.
+     */
+    LOCK_SYS_REGS;
+    if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
+       if (s3DAC8Bit) {
+          tmp2=xf86getdaccomm();
+          xf86setdaccomm(tmp2 | 0x10);
+          (void)xf86dactocomm();
+ 	 outb(0x3c7,0x8);
+ 	 outb(0x3c8,0x01);
+ 	 xf86setdaccomm(tmp2);
+       } else {
+          tmp2=xf86getdaccomm();
+          xf86setdaccomm(tmp2 | 0x10);
+          (void)xf86dactocomm();
+          outb(0x3c7,0x8);
+          outb(0x3c8,0x00);
+          xf86setdaccomm(tmp2);
+       }
+    UNLOCK_SYS_REGS;
+    }
+ 
+ 
+    if (s3Bt485PixMux) {
+       outb(0x3C4, 1);
+       tmp2 = inb(0x3C5);
+       outb(0x3C5, tmp2 | 0x20); /* blank the screen */
+ 
+       if (pixel_multiplexing) {
+          /* fun timing mods for pixel-multiplexing!                     */
+ 
+ #ifdef NO_USER_OUT
+ 	 /* This might not be SPEA specific */
+ 	 if (OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options))	
+ #endif
+ 	 {
+ 	    outb(vgaCRIndex, 0x5C);
+ 	    outb(vgaCRReg, 0x20);
+ 	    outb(0x3C7, 0x21);
+ 	 }
+          /* set s3 reg53 to parallel addressing by or'ing 0x20          */
+          outb(vgaCRIndex, 0x53);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp | 0x20);
+ #ifdef NO_USER_OUT
+ 	 /* This might not be SPEA specific */
+ 	 if (OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options))
+ #endif
+ 	 {
+ 	    outb(vgaCRIndex, 0x5C);
+ 	    outb(vgaCRReg, 0x00);
+ 	 }
+ 
+          /* set s3 reg55 to external serial by or'ing 0x08              */
+          outb(vgaCRIndex, 0x55);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp | 0x08);
+ 
+          /* the input clock is already set to clk1 or clk1double (s3.c) */
+ 
+          /* set command reg 0 to normal clocking, CR3, sleep, 8bit      */
+ 	 s3OutBtReg(BT_COMMAND_REG_0, 0x00, 0x83);
+ 
+          /* clear command reg 1                                         */
+ 	 s3OutBtReg(BT_COMMAND_REG_1, 0x00, 0x00);
+ 
+ 	 s3OutBtReg(BT_WRITE_ADDR, 0x00, 0x01);
+ 
+ 	 /* clock double bit already set                                */
+ 
+          /*
+           * set output clocking to 4:1 multiplexing
+           */
+          s3OutBtReg(BT_COMMAND_REG_1, 0x00, 0x40);
+ 
+ 	 /* SCLK enable,pclk1,pixport,xcursor                           */
+ 	 if (mode->Flags & V_INTERLACE)
+ 	    s3OutBtReg(BT_COMMAND_REG_2, 0x00, 0x33 | 0x08);
+ 	 else
+ 	    s3OutBtReg(BT_COMMAND_REG_2, 0x00, 0x33);
+ 
+          /* change to 8-bit DAC if option is set                        */
+          if (s3DAC8Bit)
+             s3OutBtReg(BT_COMMAND_REG_0, 0x00, 0x02);
+          else
+             s3OutBtReg(BT_COMMAND_REG_0, 0x00, 0x00);
+       } else {
+ 
+ #ifdef NO_USER_OUT
+ 	 /* This might not be SPEA specific */
+ 	 if (OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options))
+ #endif
+ 	 {
+ 	    outb(vgaCRIndex, 0x5C);
+ 	    outb(vgaCRReg, 0x20);
+ 	    outb(0x3C7, 0x00);
+ 	 }
+ 
+          /* set s3 reg53 to non-parallel addressing by and'ing 0xDF     */
+          outb(vgaCRIndex, 0x53);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp & 0xDF);
+ 
+ #ifdef NO_USER_OUT
+ 	 /* This might not be SPEA specific */
+ 	 if (OFLG_ISSET(OPTION_SPEA_MERCURY, &s3InfoRec.options))
+ #endif
+ 	 {
+ 	    outb(vgaCRIndex, 0x5C);
+ 	    outb(vgaCRReg, 0x00);
+ 	 }
+ 
+          /* set s3 reg55 to non-external serial by and'ing 0xF7         */
+          outb(vgaCRIndex, 0x55);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp & 0xF7);
+ 
+          /* the input clock is already set to clk1 or clk1double (s3.c) */
+ 
+          /* set command reg 0 to normal clocking                        */
+ 	 s3OutBtReg(BT_COMMAND_REG_0, 0x00, 0x00);
+ 
+ 	 /* pclk1                                                       */
+ 	 s3OutBtReg(BT_COMMAND_REG_2, 0x00, 0x10);
+ 
+          /* change to 8-bit DAC if option is set                        */
+          if (s3DAC8Bit)
+             s3OutBtReg(BT_COMMAND_REG_0, 0x00, 0x02);
+          else
+             s3OutBtReg(BT_COMMAND_REG_0, 0x00, 0x00);
+       }  /* end of pixel_multiplexing */
+ 
+       outb(0x3C4, 1);
+       outb(0x3C5, tmp2); /* unblank the screen */
+    } else
+    if (DAC_IS_TI3020) {
+       outb(0x3C4, 1);
+       tmp2 = inb(0x3C5);
+       outb(0x3C5, tmp2 | 0x20); /* blank the screen */
+ 
+       /* change polarity on S3 to pass through control to the 3020      */
+       tmp = new->MiscOutReg; /* BUG tmp = inb(0x3CC); */
+       new->MiscOutReg |= 0xC0;
+       tmp1 = 0x00;
+       if (!(tmp & 0x80)) tmp1 |= 0x02; /* invert bits for the 3020      */
+       if (!(tmp & 0x40)) tmp1 |= 0x01;
+       s3OutTiIndReg(TI_GENERAL_CONTROL, 0x00, tmp1);
+ 
+       if (pixel_multiplexing) {
+          /* fun timing mods for pixel-multiplexing!                     */
+ 
+          /* set s3 reg53 to parallel addressing by or'ing 0x20          */
+          outb(vgaCRIndex, 0x53);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp | 0x20);
+ 
+          /* set s3 reg55 to external serial by or'ing 0x08              */
+          outb(vgaCRIndex, 0x55);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp | 0x08);
+ 
+          /* the input clock is already set to clk1 or clk1double (s3.c) */
+ 
+          /* set aux control to self clocked, window function complement */
+          s3OutTiIndReg(TI_AUXILLARY_CONTROL, 0,
+ 		       TI_AUX_SELF_CLOCK | TI_AUX_W_CMPL);
+ 
+          /*
+           * set output clocking to VCLK/4, RCLK/8 like the fixed Bt485.
+           * RCLK/8 is used because of the 8:1 pixel-multiplexing below.
+           * the RCLK output is tied to the LCLK input which is the same
+           * as SCLK but with no blanking.  SCLK is the actual pixel
+           * shift clock for the pixel bus.
+           */
+          s3OutTiIndReg(TI_OUTPUT_CLOCK_SELECT, 0x00, TI_OCLK_S_V4_R8);
+ 
+          /* set mux control 1 and 2 to provide pseudocolor sub-mode 4   */
+          /* this provides a 64-bit pixel bus with 8:1 multiplexing      */
+          s3OutTiIndReg(TI_MUX_CONTROL_1, 0x00, TI_MUX1_PSEUDO_COLOR);
+          s3OutTiIndReg(TI_MUX_CONTROL_2, 0x00, TI_MUX2_BUS_PIX64);
+ 
+          /* change to 8-bit DAC and re-route the data path and clocking */
+          s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, TI_GIC_ALL_BITS);
+          if (s3DAC8Bit)
+             s3OutTiIndReg(TI_GENERAL_IO_DATA, 0x00, TI_GID_TI_DAC_8BIT);
+          else
+             s3OutTiIndReg(TI_GENERAL_IO_DATA, 0x00, TI_GID_TI_DAC_6BIT);
+       } else {
+          /* set s3 reg53 to non-parallel addressing by and'ing 0xDF     */
+          outb(vgaCRIndex, 0x53);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp & 0xDF);
+ 
+          /* set s3 reg55 to non-external serial by and'ing 0xF7         */
+          outb(vgaCRIndex, 0x55);
+          tmp = inb(vgaCRReg);
+          outb(vgaCRReg, tmp & 0xF7);
+ 
+          /* the input clock is already set to clk1 or clk1double (s3.c) */
+ 
+          /* set aux control to self clocked only                        */
+          s3OutTiIndReg(TI_AUXILLARY_CONTROL, 0, TI_AUX_SELF_CLOCK);
+ 
+          /*
+           * set output clocking to default of VGA.
+           */
+          s3OutTiIndReg(TI_OUTPUT_CLOCK_SELECT, 0x00, TI_OCLK_VGA);
+ 
+          /* set mux control 1 and 2 to provide pseudocolor VGA          */
+          s3OutTiIndReg(TI_MUX_CONTROL_1, 0x00, TI_MUX1_PSEUDO_COLOR);
+          s3OutTiIndReg(TI_MUX_CONTROL_2, 0x00, TI_MUX2_BUS_VGA);
+ 
+          /* change to 8-bit DAC and re-route the data path and clocking */
+          s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, TI_GIC_ALL_BITS);
+          if (s3DAC8Bit)
+             s3OutTiIndReg(TI_GENERAL_IO_DATA, 0x00, TI_GID_S3_DAC_8BIT);
+          else
+             s3OutTiIndReg(TI_GENERAL_IO_DATA, 0x00, TI_GID_S3_DAC_6BIT);
+       }  /* end of pixel_multiplexing */
+ 
+       /* for some reason the bios doesn't set this properly          */
+       s3OutTiIndReg(TI_SENSE_TEST, 0x00, 0x00);
+ 
+       outb(0x3C4, 1);
+       outb(0x3C5, tmp2);        /* unblank the screen */
+       s3InitCursorFlag = TRUE;  /* turn on the cursor during the next load */
     }
  
     outb(0x3C2, new->MiscOutReg);
***************
*** 317,324 ****
        outb(0x3C0, new->Attribute[i]);
     }
  
     outb(vgaCRIndex, 0x31);
!    outb(vgaCRReg, 0x8d);
     outb(vgaCRIndex, 0x32);
     outb(vgaCRReg, 0x00);
     outb(vgaCRIndex, 0x33);
--- 739,751 ----
        outb(0x3C0, new->Attribute[i]);
     }
  
+    if (s3DisplayWidth == 2048)
+       s3Port31 = 0x8f;
+    else
+       s3Port31 = 0x8d;
+ 
     outb(vgaCRIndex, 0x31);
!    outb(vgaCRReg, s3Port31);
     outb(vgaCRIndex, 0x32);
     outb(vgaCRReg, 0x00);
     outb(vgaCRIndex, 0x33);
***************
*** 366,372 ****
  
        outb(vgaCRIndex, 0x50);
        i = inb(vgaCRReg);
!       i &= 0x3f;
        switch (s3DisplayWidth) { 
  	case 640:
  	   outb(vgaCRReg, i | 0x40);
--- 793,799 ----
  
        outb(vgaCRIndex, 0x50);
        i = inb(vgaCRReg);
!       i &= ~0xc1;
        switch (s3DisplayWidth) { 
  	case 640:
  	   outb(vgaCRReg, i | 0x40);
***************
*** 374,411 ****
  	case 800:
  	   outb(vgaCRReg, i | 0x80);
  	   break;
  	case 1280:
  	   outb(vgaCRReg, i | 0xc0);
  	   break;
! 	default:
  	   outb(vgaCRReg, i);
        }
  
        outb(vgaCRIndex, 0x51);
!       s3Port51 = inb(vgaCRReg) & 0xC0;
        outb(vgaCRReg, s3Port51);
  
        if (s3Mmio928) {
! 	 outb(vgaCRIndex, 0x53);
! 	 outb(vgaCRReg, 0x10);
!       } else { /* just to make sure */
! 	 outb(vgaCRIndex, 0x53);
! 	 outb(vgaCRReg, 0x00);
        }
  
        outb(vgaCRIndex, 0x54);
!       if (s3InfoRec.videoRam == 512)
  	 s3Port54 = 0x00;
        else
! 	 s3Port54 = 0xa0;      
        outb(vgaCRReg, s3Port54);
        
        outb(vgaCRIndex, 0x55);
!       outb(vgaCRReg, 0x40);		/* remove mysterious dot at 60Hz */
  
        outb(vgaCRIndex, 0x58);
        outb(vgaCRReg, 0x00);
  
        i = (((mode->VTotal  / interlacedived - 2) & 0x400) >> 10) |
  	  (((mode->VDisplay / interlacedived - 1) & 0x400) >> 9) |
  	  (((mode->VSyncStart / interlacedived) & 0x400) >> 8)  |
--- 801,863 ----
  	case 800:
  	   outb(vgaCRReg, i | 0x80);
  	   break;
+ 	case 1152:
+ 	   outb(vgaCRReg, i | 0x01);
+ 	   break;
  	case 1280:
  	   outb(vgaCRReg, i | 0xc0);
  	   break;
! 	case 1600:
! 	   outb(vgaCRReg, i | 0x81);
! 	   break;
! 	default: /* 1024 and 2048 */
  	   outb(vgaCRReg, i);
        }
  
        outb(vgaCRIndex, 0x51);
!       s3Port51 = (inb(vgaCRReg) & 0xC0) | ((s3DisplayWidth >> 7) & 0x30);
        outb(vgaCRReg, s3Port51);
  
+       outb(vgaCRIndex, 0x53);
+       tmp = inb(vgaCRReg);
        if (s3Mmio928) {
! 	 tmp |= 0x10;
!       } else {
! 	 /* make sure mmio is off */
! 	 tmp &= ~0x10;
!       }
!       /*
!        * Now the DRAM interleaving bit for the 801/805 chips
!        * Note, we don't touch this bit for 928 chips because they use it
!        * for pixel multiplexing control.
!        */
!       if (S3_801_SERIES(s3ChipId)) {
! 	 if (S3_801_I_SERIES(s3ChipId))
! 	    tmp |= 0x20;
! 	 else
! 	    tmp &= ~0x20;
        }
+       outb(vgaCRReg, tmp);
  
        outb(vgaCRIndex, 0x54);
!       if (s3InfoRec.videoRam == 512 || mode->HDisplay > 1200) /* XXXX */
  	 s3Port54 = 0x00;
        else
! 	 s3Port54 = 0xa0;
        outb(vgaCRReg, s3Port54);
        
        outb(vgaCRIndex, 0x55);
!       tmp = inb(vgaCRReg) & 0x08;       /* save the external serial bit  */
!       outb(vgaCRReg, tmp | 0x40);	/* remove mysterious dot at 60Hz */
  
        outb(vgaCRIndex, 0x58);
        outb(vgaCRReg, 0x00);
  
+       outb(vgaCRIndex, 0x59);
+       outb(vgaCRReg, s3Port59);
+       outb(vgaCRIndex, 0x5A);
+       outb(vgaCRReg, s3Port5A);
+ 
        i = (((mode->VTotal  / interlacedived - 2) & 0x400) >> 10) |
  	  (((mode->VDisplay / interlacedived - 1) & 0x400) >> 9) |
  	  (((mode->VSyncStart / interlacedived) & 0x400) >> 8)  |
***************
*** 414,443 ****
        outb(vgaCRIndex, 0x5e);
        outb(vgaCRReg, i);
  
!       if (s3DisplayWidth == 1280) {
! 	outb(vgaCRIndex, 0x60);
! 	outb(vgaCRReg, 0x7f);
! 	outb(vgaCRIndex, 0x61);
! 	outb(vgaCRReg, 0x81);
! 	outb(vgaCRIndex, 0x62);
! 	outb(vgaCRReg, 0xa1);
!       } else {
! 	outb(vgaCRIndex, 0x60);
! 	if (s3InfoRec.videoRam == 512)
! 	   outb(vgaCRReg, 0xff);
! 	else
! 	   outb(vgaCRReg, 0x3f);
! 	outb(vgaCRIndex, 0x61);
! 	outb(vgaCRReg, 0x81);
! 	outb(vgaCRIndex, 0x62);
! 	outb(vgaCRReg, 0);
        }
-    }
  
!    /* Don't use internal clock-select code when using an external clock prog */
!    if (new->NoClock >= 0) {
!       /* XXXX Should we really do something about the return value? */
!       (void) (s3ClockSelectFunc) (mode->Clock); 
     }
  
     if ((mode->Flags & V_INTERLACE) != 0) {
--- 866,954 ----
        outb(vgaCRIndex, 0x5e);
        outb(vgaCRReg, i);
  
!       if (pixel_multiplexing) {
!          /* now divide the horizontal timing parameters by 4 for VCLK/4 */
!          mode->HTotal >>= 2;
!          mode->HDisplay >>= 2;
!          mode->HSyncStart >>= 2;
!          mode->HSyncEnd >>= 2;
        }
  
!       i = ((mode->HTotal & 0x800) >> 11) |
! 	  ((mode->HDisplay & 0x800) >> 10) |
! 	  ((mode->HSyncStart & 0x800) >> 9) |
! 	  ((mode->HSyncStart & 0x800) >> 7);
! 
!       if (pixel_multiplexing) {
!          /* put back the horizontal timing parameters */
!          mode->HTotal <<= 2;
!          mode->HDisplay <<= 2;
!          mode->HSyncStart <<= 2;
!          mode->HSyncEnd <<= 2;
!       }
! 
!       outb(vgaCRIndex, 0x5d);
!       tmp = inb(vgaCRReg);
!       outb(vgaCRReg, (tmp & ~0x17) | i);
! 
!       /*
!        * Set up CR60 according the the DRAM speed specified in the Xconfig
!        * and the selected dot clock.  This is all empirical and/or guesswork
!        * at this point.
!        */
! 
!       /* Not sure about the 512k case, so deal with it separately */
!       if (s3InfoRec.videoRam == 512) {
! 	 tmp = 0xff;
!       } else {
! 	 /*
! 	  * Default to 0xff except for clocks > 100Mhz unless one of the
! 	  * "dram_..." options is specified (0xff seems to be fine for
! 	  * most (all?) cards).  The "dram_..." options are probably not
! 	  * necessary at all, and may be removed in a future release.
! 	  */
! 	 if (OFLG_ISSET(OPTION_SLOW_DRAM, &s3InfoRec.options)) {
! 	    if (s3InfoRec.clock[mode->Clock] > 69000) { /* guess */
! 	       tmp = 0xff;
! 	    } else if (s3InfoRec.clock[mode->Clock] > 49000) { /* guess */
! 	       tmp = 0x7f;
! 	    } else {
! 	       tmp = 0x3f;
! 	    }
! 	 } else if (OFLG_ISSET(OPTION_MED_DRAM, &s3InfoRec.options)) {
! 	    if (s3InfoRec.clock[mode->Clock] > 69000) { /* guess */
! 	       tmp = 0x7f;
! 	    } else {
! 	       tmp = 0x3f;
! 	    }
! 	 } else if (OFLG_ISSET(OPTION_FAST_DRAM, &s3InfoRec.options)) {
! 	    /* This is from experimentation with an Actix GE32+ 2MB @ 110MHz */
! 	    if (s3InfoRec.clock[mode->Clock] > 100000) {
! 	       tmp = 0xff;
! 	    } else if (s3InfoRec.clock[mode->Clock] > 79000) { /* guess */
! 	       tmp = 0x7f;
! 	    } else {
! 	       tmp = 0x3f;
! 	    }
! 	 } else {
! 	    /* Default to 0xff for all modes/clocks -- it seems to be OK */
! 	    tmp = 0xff;
! 	 }
!       }
!       outb(vgaCRIndex, 0x60);
!       outb(vgaCRReg, tmp);
! 
!       outb(vgaCRIndex, 0x61);
!       outb(vgaCRReg, 0x81);
! 
!       /* Not really sure about CR62, but this is what we've always had */
!       if (s3DisplayWidth >= 1152) {
! 	 tmp = 0xa1;
!       } else {
! 	 tmp = 0x00;
!       }
!       outb(vgaCRIndex, 0x62);
!       outb(vgaCRReg, tmp);
     }
  
     if ((mode->Flags & V_INTERLACE) != 0) {
***************
*** 446,451 ****
--- 957,987 ----
        outb(vgaCRReg, 0x20 | i);
     }
  
+ #ifdef REG_DEBUG
+    for (i=0; i<10; i++) {
+ 	 outb(vgaCRIndex, i);
+ 	 tmp = inb(vgaCRReg);
+ 	 ErrorF("CR%X = 0x%02x\n", i, tmp);
+    }
+    for (i=0x10; i<0x19; i++) {
+ 	 outb(vgaCRIndex, i);
+ 	 tmp = inb(vgaCRReg);
+ 	 ErrorF("CR%X = 0x%02x\n", i, tmp);
+    }
+    outb(vgaCRIndex, 0x3b);
+    tmp = inb(vgaCRReg);
+    ErrorF("CR%X = 0x%02x\n", 0x3b, tmp);
+    outb(vgaCRIndex, 0x5d);
+    tmp = inb(vgaCRReg);
+    ErrorF("CR%X = 0x%02x\n", 0x5d, tmp);
+    outb(vgaCRIndex, 0x5e);
+    tmp = inb(vgaCRReg);
+    ErrorF("CR%X = 0x%02x\n", 0x5e, tmp);
+    for (i=0; i<0x40; i++) {
+ 	 tmp = s3InTiIndReg(i);
+ 	 ErrorF("TI%X = 0x%02x\n", i, tmp);
+    }
+ #endif
     vgaProtect(FALSE);
  
     if (s3DisplayWidth == 1024) /* this is unclear Jon */
***************
*** 479,485 ****
  
  /*
   * Loads the Look-Up Table with all black. Assumes 8-bit board is in use.  If
!  * 4 bit board, the only the first 16 entries in LUT will be used.
   */
  static void
  InitLUT()
--- 1015,1021 ----
  
  /*
   * Loads the Look-Up Table with all black. Assumes 8-bit board is in use.  If
!  * 4 bit board, then only the first 16 entries in LUT will be used.
   */
  static void
  InitLUT()
***************
*** 662,670 ****
--- 1198,1212 ----
  	case 800:
  	   new->s3sysreg[0x10] = 0x80;
  	   break;
+ 	case 1152:
+ 	   new->s3sysreg[0x10] = 0x01;
+ 	   break;
  	case 1280:
  	   new->s3sysreg[0x10] = 0xC0;
  	   break;
+ 	case 1600:
+ 	   new->s3sysreg[0x10] = 0x81;
+ 	   break;
  	default:
  	   new->s3sysreg[0x10] = 0x00;
        }
***************
*** 675,681 ****
  	 s3Port54 = 0xA0;
        new->sysreg[0x14] = s3Port54;
         new->s3sysreg[0x21] = 0x81;
!       if (s3DisplayWidth == 1280) {
  	 new->s3sysreg[0x20] = 0x7F;
  	 new->s3sysreg[0x22] = 0xA1;
  	 new->s3sysreg[0x15] = 0x40;
--- 1217,1223 ----
  	 s3Port54 = 0xA0;
        new->sysreg[0x14] = s3Port54;
         new->s3sysreg[0x21] = 0x81;
!       if (s3DisplayWidth >= 1152) {
  	 new->s3sysreg[0x20] = 0x7F;
  	 new->s3sysreg[0x22] = 0xA1;
  	 new->s3sysreg[0x15] = 0x40;
***************
*** 699,709 ****
--- 1241,1254 ----
  #endif
  
  #ifndef NEW_INIT_SAVE_RESTORE
+ /* s3Save and s3Restore are not currently used */
+ #if 0
  void
  s3Restore(restore)
       vgaS3Ptr restore;
  {
     int   i;
+    unsigned char c;
  
     UNLOCK_SYS_REGS;
  
***************
*** 749,767 ****
        outb(vgaCRReg, restore->s3sysreg[i]);
     }
  
  #if 0
     /*
      * Restore Bt485 Registers
      */
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
        s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01);
        s3OutBtRegCom3(0x00, restore->Bt485[3]);
! #ifdef NOTYET
!       s3OutBtReg(BT_COMMAND_REG_2, 0x00, restore->Bt485[2]);
!       s3OutBtReg(BT_COMMAND_REG_1, 0x00, restore->Bt485[1]);
! #endif
        s3OutBtReg(BT_COMMAND_REG_0, 0x00, restore->Bt485[0]);
     }
  #endif
  
  
--- 1294,1353 ----
        outb(vgaCRReg, restore->s3sysreg[i]);
     }
  
+    /*
+     * Restore AT&T 20C490/1 command register.
+     */
+    if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
+       xf86setdaccomm(oldS3->ATT490_1);
+    }
+    /*
+     * Restore Sierra SC 15025/6 registers.
+     */
+     LOCK_SYS_REGS;
+     if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
+       c=xf86getdaccomm();
+       xf86setdaccomm( c | 0x10 );  /* set internal register access */
+       (void)xf86dactocomm();
+       outb(0x3c7, 0x8);
+       outb(0x3c8, oldS3->SC15025[1]);
+       xf86setdaccomm( c );
+       xf86setdaccomm(oldS3->SC15025[0]);
+    }
+    UNLOCK_SYS_REGS;
+ 
  #if 0
     /*
      * Restore Bt485 Registers
      */
!    if (DAC_IS_BT485_SERIES) {
        s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01);
        s3OutBtRegCom3(0x00, restore->Bt485[3]);
!       if (s3Bt485PixMux) {
!          s3OutBtReg(BT_COMMAND_REG_2, 0x00, restore->Bt485[2]);
!          s3OutBtReg(BT_COMMAND_REG_1, 0x00, restore->Bt485[1]);
!       }
        s3OutBtReg(BT_COMMAND_REG_0, 0x00, restore->Bt485[0]);
     }
+ 
+    /*
+     * Restore Ti3020 registers
+     */
+    if (DAC_IS_TI3020) {
+       s3OutTiIndReg(TI_CURS_CONTROL, 0x00, restore->Ti3020[TI_CURS_CONTROL]);
+       s3OutTiIndReg(TI_MUX_CONTROL_1, 0x00, restore->Ti3020[TI_MUX_CONTROL_1]);
+       s3OutTiIndReg(TI_MUX_CONTROL_2, 0x00, restore->Ti3020[TI_MUX_CONTROL_2]);
+       s3OutTiIndReg(TI_INPUT_CLOCK_SELECT, 0x00,
+ 		    restore->Ti3020[TI_INPUT_CLOCK_SELECT]);
+       s3OutTiIndReg(TI_OUTPUT_CLOCK_SELECT, 0x00,
+ 		    restore->Ti3020[TI_OUTPUT_CLOCK_SELECT]);
+       s3OutTiIndReg(TI_GENERAL_CONTROL, 0x00,
+ 		    restore->Ti3020[TI_GENERAL_CONTROL]);
+       s3OutTiIndReg(TI_AUXILLARY_CONTROL, 0x00,
+ 		    restore->Ti3020[TI_AUXILLARY_CONTROL]);
+       s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, 0x1f);
+       s3OutTiIndReg(TI_GENERAL_IO_DATA, 0x00,
+ 		    restore->Ti3020[TI_GENERAL_IO_DATA]);
+    }
  #endif
  
  
***************
*** 787,803 ****
     save = vgaHWSave(save, sizeof(vgaS3Rec));
  
     /*
      * Save Bt485 Registers
      */
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
        save->Bt485[0] = s3InBtReg(BT_COMMAND_REG_0);
! #ifdef NOTYET
!       save->Bt485[1] = s3InBtReg(BT_COMMAND_REG_1);
!       save->Bt485[2] = s3InBtReg(BT_COMMAND_REG_2);
! #endif
        save->Bt485[3] = s3InBtRegCom3();
     }
  
     for (i = 0; i < 5; i++) {
        outb(vgaCRIndex, 0x30 + i);
        save->s3reg[i] = inb(vgaCRReg);
--- 1373,1426 ----
     save = vgaHWSave(save, sizeof(vgaS3Rec));
  
     /*
+     * Save AT&T 20C490/1 command register.
+     */
+    if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
+       oldS3->ATT490_1 = xf86getdaccomm();
+    }
+    /*
+     * Save Sierra SC15025 command register.
+     */
+    LOCK_SYS_REGS;
+    if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
+       oldS3->SC15025[0] = xf86getdaccomm();
+       xf86setdaccomm((oldS3->SC15025[0] | 0x10));
+       (void)xf86dactocomm();
+       outb(0x3c7,0x8);
+       oldS3->SC15025[1] = inb(0x3c8);
+       xf86setdaccomm(oldS3->SC15025[0]);
+    }
+    UNLOCK_SYS_REGS;
+ 
+    /*
      * Save Bt485 Registers
      */
!    if (DAC_IS_BT485_SERIES) {
        save->Bt485[0] = s3InBtReg(BT_COMMAND_REG_0);
!       if (s3Bt485PixMux) {
!          save->Bt485[1] = s3InBtReg(BT_COMMAND_REG_1);
!          save->Bt485[2] = s3InBtReg(BT_COMMAND_REG_2);
!       }
        save->Bt485[3] = s3InBtRegCom3();
     }
  
+    /*
+     * Save Ti3020 registers
+     */
+    if (DAC_IS_TI3020) {
+       save->Ti3020[TI_CURS_CONTROL] = s3InTiIndReg(TI_CURS_CONTROL);
+       save->Ti3020[TI_MUX_CONTROL_1] = s3InTiIndReg(TI_MUX_CONTROL_1);
+       save->Ti3020[TI_MUX_CONTROL_2] = s3InTiIndReg(TI_MUX_CONTROL_2);
+       save->Ti3020[TI_INPUT_CLOCK_SELECT] =
+             s3InTiIndReg(TI_INPUT_CLOCK_SELECT);
+       save->Ti3020[TI_OUTPUT_CLOCK_SELECT] =
+             s3InTiIndReg(TI_OUTPUT_CLOCK_SELECT);
+       save->Ti3020[TI_GENERAL_CONTROL] = s3InTiIndReg(TI_GENERAL_CONTROL);
+       save->Ti3020[TI_AUXILLARY_CONTROL] = s3InTiIndReg(TI_AUXILLARY_CONTROL);
+       s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, 0x1f);
+       save->Ti3020[TI_GENERAL_IO_DATA] = s3InTiIndReg(TI_GENERAL_IO_DATA);
+    }
+ 
     for (i = 0; i < 5; i++) {
        outb(vgaCRIndex, 0x30 + i);
        save->s3reg[i] = inb(vgaCRReg);
***************
*** 830,835 ****
--- 1453,1459 ----
     LOCK_SYS_REGS;
     return save;
  }
+ #endif
  
  #else
  
***************
*** 853,869 ****
     save = (vgaS3Ptr) vgaHWSave(save, sizeof(vgaS3Rec));
  
     /*
      * Save Bt485 Registers
      */
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
        save->Bt485[0] = s3InBtReg(BT_COMMAND_REG_0);
! #ifdef NOTYET
!       save->Bt485[1] = s3InBtReg(BT_COMMAND_REG_1);
!       save->Bt485[2] = s3InBtReg(BT_COMMAND_REG_2);
! #endif
        save->Bt485[3] = s3InBtRegCom3();
     }
  
     for (i = 0; i < 5; i++) {
        outb(vgaCRIndex, 0x31 + i);
        save->s3reg[i] = inb(vgaCRReg);
--- 1477,1531 ----
     save = (vgaS3Ptr) vgaHWSave(save, sizeof(vgaS3Rec));
  
     /*
+     * Save AT&T 20C490/1 command register.
+     */
+    if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
+       oldS3->ATT490_1 = xf86getdaccomm();
+    }
+ 
+    /*
+     * Save Sierra SC15025 command register.
+     */
+    LOCK_SYS_REGS;
+    if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
+       oldS3->SC15025[0] = xf86getdaccomm();
+       xf86setdaccomm((oldS3->SC15025[0] | 0x10));
+       (void)xf86dactocomm();
+       outb(0x3c7,0x8);
+       oldS3->SC15025[1] = inb(0x3c8);
+       xf86setdaccomm(oldS3->SC15025[0]);
+    }
+    UNLOCK_SYS_REGS;
+ 
+    /*
      * Save Bt485 Registers
      */
!    if (DAC_IS_BT485_SERIES) {
        save->Bt485[0] = s3InBtReg(BT_COMMAND_REG_0);
!       if (s3Bt485PixMux) {
!          save->Bt485[1] = s3InBtReg(BT_COMMAND_REG_1);
!          save->Bt485[2] = s3InBtReg(BT_COMMAND_REG_2);
!       }
        save->Bt485[3] = s3InBtRegCom3();
     }
  
+    /*
+     * Save Ti3020 registers
+     */
+    if (DAC_IS_TI3020) {
+       save->Ti3020[TI_CURS_CONTROL] = s3InTiIndReg(TI_CURS_CONTROL);
+       save->Ti3020[TI_MUX_CONTROL_1] = s3InTiIndReg(TI_MUX_CONTROL_1);
+       save->Ti3020[TI_MUX_CONTROL_2] = s3InTiIndReg(TI_MUX_CONTROL_2);
+       save->Ti3020[TI_INPUT_CLOCK_SELECT] =
+              s3InTiIndReg(TI_INPUT_CLOCK_SELECT);
+       save->Ti3020[TI_OUTPUT_CLOCK_SELECT] =
+              s3InTiIndReg(TI_OUTPUT_CLOCK_SELECT);
+       save->Ti3020[TI_GENERAL_CONTROL] = s3InTiIndReg(TI_GENERAL_CONTROL);
+       save->Ti3020[TI_AUXILLARY_CONTROL] = s3InTiIndReg(TI_AUXILLARY_CONTROL);
+       s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, 0x1f);
+       save->Ti3020[TI_GENERAL_IO_DATA] = s3InTiIndReg(TI_GENERAL_IO_DATA);
+    }
+ 
     for (i = 0; i < 5; i++) {
        outb(vgaCRIndex, 0x31 + i);
        save->s3reg[i] = inb(vgaCRReg);
***************
*** 960,975 ****
     }
  
     /*
      * Restore Bt485 Registers
      */
!    if (OFLG_ISSET(OPTION_BT485, &s3InfoRec.options)) {
        s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01);
        s3OutBtRegCom3(0x00, restore->Bt485[3]);
! #ifdef NOTYET
!       s3OutBtReg(BT_COMMAND_REG_2, 0x00, restore->Bt485[2]);
!       s3OutBtReg(BT_COMMAND_REG_1, 0x00, restore->Bt485[1]);
! #endif
        s3OutBtReg(BT_COMMAND_REG_0, 0x00, restore->Bt485[0]);
     }
  
     if (restore->std.NoClock >= 0)
--- 1622,1679 ----
     }
  
     /*
+     * Restore AT&T 20C490/1 command register.
+     */
+    if (OFLG_ISSET(OPTION_ATT490_1, &s3InfoRec.options)) {
+       xf86setdaccomm(oldS3->ATT490_1);
+    }
+ 
+    /*
+     * Restore Sierra SC15025 command register.
+     */
+     LOCK_SYS_REGS;
+     if (OFLG_ISSET(OPTION_SC15025, &s3InfoRec.options)) {
+       i=xf86getdaccomm();
+       xf86setdaccomm( i | 0x10 );  /* set internal register access */
+       (void)xf86dactocomm();
+       outb(0x3c7, 0x8);
+       outb(0x3c8, oldS3->SC15025[1]);
+       xf86setdaccomm( i );
+       xf86setdaccomm(oldS3->SC15025[0]);
+    }
+    UNLOCK_SYS_REGS;	
+ 
+    /*
      * Restore Bt485 Registers
      */
!    if (DAC_IS_BT485_SERIES) {
        s3OutBtReg(BT_COMMAND_REG_0, 0xFE, 0x01);
        s3OutBtRegCom3(0x00, restore->Bt485[3]);
!       if (s3Bt485PixMux) {
!          s3OutBtReg(BT_COMMAND_REG_2, 0x00, restore->Bt485[2]);
!          s3OutBtReg(BT_COMMAND_REG_1, 0x00, restore->Bt485[1]);
!       }
        s3OutBtReg(BT_COMMAND_REG_0, 0x00, restore->Bt485[0]);
+    }
+ 
+    /*
+     * Restore Ti3020 registers
+     */
+    if (DAC_IS_TI3020) {
+       s3OutTiIndReg(TI_CURS_CONTROL, 0x00, restore->Ti3020[TI_CURS_CONTROL]);
+       s3OutTiIndReg(TI_MUX_CONTROL_1, 0x00, restore->Ti3020[TI_MUX_CONTROL_1]);
+       s3OutTiIndReg(TI_MUX_CONTROL_2, 0x00, restore->Ti3020[TI_MUX_CONTROL_2]);
+       s3OutTiIndReg(TI_INPUT_CLOCK_SELECT, 0x00,
+ 		    restore->Ti3020[TI_INPUT_CLOCK_SELECT]);
+       s3OutTiIndReg(TI_OUTPUT_CLOCK_SELECT, 0x00,
+ 		    restore->Ti3020[TI_OUTPUT_CLOCK_SELECT]);
+       s3OutTiIndReg(TI_GENERAL_CONTROL, 0x00,
+ 		    restore->Ti3020[TI_GENERAL_CONTROL]);
+       s3OutTiIndReg(TI_AUXILLARY_CONTROL, 0x00,
+ 		    restore->Ti3020[TI_AUXILLARY_CONTROL]);
+       s3OutTiIndReg(TI_GENERAL_IO_CONTROL, 0x00, 0x1f);
+       s3OutTiIndReg(TI_GENERAL_IO_DATA, 0x00,
+ 		    restore->Ti3020[TI_GENERAL_IO_DATA]);
     }
  
     if (restore->std.NoClock >= 0)
diff -c mit/server/ddx/x386/accel/s3/s3linear.h:2.6 mit/server/ddx/x386/accel/s3/s3linear.h:2.7
*** mit/server/ddx/x386/accel/s3/s3linear.h:2.6	Fri Mar 11 23:38:08 1994
--- mit/server/ddx/x386/accel/s3/s3linear.h	Fri Mar 11 23:38:08 1994
***************
*** 10,16 ****
   * Not currently used apart from s3im.c
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3linear.h,v 2.6 1993/09/21 15:22:48 dawes Exp $ */
  
  extern Bool s3LinearAperture;
  extern unsigned char s3LinApOpt;
--- 10,16 ----
   * Not currently used apart from s3im.c
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3linear.h,v 2.7 1994/01/09 03:31:00 dawes Exp $ */
  
  extern Bool s3LinearAperture;
  extern unsigned char s3LinApOpt;
***************
*** 22,32 ****
  /* Some poor compilers don't have inlines */
  #ifdef S3_MMIO 
  # define DISABLE_MMIO   \
        outb(vgaCRIndex, 0x53); \
!       outb(vgaCRReg, 0x00);
  # define ENABLE_MMIO   \
        outb(vgaCRIndex, 0x53); \
!       outb(vgaCRReg, 0x10);
  #else
  # define DISABLE_MMIO /**/
  # define ENABLE_MMIO /**/
--- 22,36 ----
  /* Some poor compilers don't have inlines */
  #ifdef S3_MMIO 
  # define DISABLE_MMIO   \
+       { unsigned char tmp; \
        outb(vgaCRIndex, 0x53); \
!       tmp = inb(vgaCRReg); \
!       outb(vgaCRReg, tmp & 0xEF); }
  # define ENABLE_MMIO   \
+       { unsigned char tmp; \
        outb(vgaCRIndex, 0x53); \
!       tmp = inb(vgaCRReg); \
!       outb(vgaCRReg, tmp | 0x10); }
  #else
  # define DISABLE_MMIO /**/
  # define ENABLE_MMIO /**/
diff -c mit/server/ddx/x386/accel/s3/s3misc.c:2.19 mit/server/ddx/x386/accel/s3/s3misc.c:2.34
*** mit/server/ddx/x386/accel/s3/s3misc.c:2.19	Fri Mar 11 23:38:09 1994
--- mit/server/ddx/x386/accel/s3/s3misc.c	Fri Mar 11 23:38:09 1994
***************
*** 31,37 ****
   * Id: s3.c,v 2.6 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3misc.c,v 2.19 1993/10/21 15:54:15 dawes Exp $ */
  
  #include "cfb.h"
  #include "pixmapstr.h"
--- 31,37 ----
   * Id: s3.c,v 2.6 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3misc.c,v 2.34 1994/03/08 08:31:42 dawes Exp $ */
  
  #include "cfb.h"
  #include "pixmapstr.h"
***************
*** 47,52 ****
--- 47,56 ----
  #include "s3linear.h"
  
  extern void s3RepositionCursor();
+ extern void s3ImageWriteNoMem();
+ extern void s3ShowCursor();
+ extern void s3HideCursor();
+ extern void SetTimeSinceLastInputEvent();
  
  extern char s3Mbanks;
  extern void NoopDDA();
***************
*** 56,61 ****
--- 60,66 ----
  extern miPointerScreenFuncRec x386PointerScreenFuncs;
  static Bool s3TryAddress();
  extern ScreenPtr s3savepScreen;
+ static PixmapPtr ppix = NULL;
  extern Bool  s3Localbus;
  extern Bool  s3LinearAperture;
  extern unsigned char s3LinApOpt;
***************
*** 63,68 ****
--- 68,76 ----
  extern int s3DisplayWidth;
  extern pointer vgaBase;
  extern pointer s3VideoMem;
+ extern unsigned char s3Port59;
+ extern unsigned char s3Port5A;
+ extern unsigned char s3Port31;
  
  extern Bool x386Exiting, x386Resetting, x386ProbeFailed, x386Verbose;
  
***************
*** 69,74 ****
--- 77,83 ----
  static Bool AlreadyInited = FALSE;
  static Bool s3ModeSwitched = FALSE;
  
+ 
  /*
   * s3Initialize -- Attempt to find and initialize a VGA framebuffer Most of
   * the elements of the ScreenRec are filled in.  The video is enabled for the
***************
*** 82,87 ****
--- 91,98 ----
       int   argc;		/* The number of the Server's arguments. */
       char **argv;		/* The arguments themselves. Don't change! */
  {
+    int displayResolution = 75;	/* default to 75dpi */
+    extern int monitorResolution;
  
     s3Unlock();	  /* for restarts */
     
***************
*** 93,101 ****
    * function
    */
  
-    /* XXXX need to check how much should be done only for generation #1 */
-    /* XXXX this should be mostly OK now */
- 
     if (serverGeneration == 1) {
        s3BankSize = 0x10000;
        s3LinApOpt = 0x14;
--- 104,109 ----
***************
*** 119,127 ****
--- 127,138 ----
  	    long i;
  	    long *poker;
  	    unsigned long pVal;
+ 	    unsigned char reg53tmp = 0;
+ 	    Bool CachedFrameBuffer = FALSE;
  
  	    pVal = 0x12345678;
  
+ 	    s3InitEnvironment();
  	    s3ImageWriteNoMem(0, 0, 4, 1, (unsigned char *) &pVal, 4, 0, 0,
  			      (short) s3alu[GXcopy], (short) 0xffff);	 
  
***************
*** 130,136 ****
  
  	       if (s3Mmio928) { /* Due to S3 bugs we must disable mmio */
  		  outb(vgaCRIndex, 0x53);
! 		  outb(vgaCRReg, 0x00);
  	       }
  	       /* begin 801 sequence for going in to linear mode */
  	       outb (vgaCRIndex, 0x40);
--- 141,148 ----
  
  	       if (s3Mmio928) { /* Due to S3 bugs we must disable mmio */
  		  outb(vgaCRIndex, 0x53);
! 		  reg53tmp = inb(vgaCRReg);
! 		  outb(vgaCRReg, reg53tmp & ~0x10); /* save parallel bit */
  	       }
  	       /* begin 801 sequence for going in to linear mode */
  	       outb (vgaCRIndex, 0x40);
***************
*** 138,204 ****
  	       j = (s3Port40 & 0xf6) | 0x0a;
  	       outb (vgaCRReg, (unsigned char) j);
  	       outb(vgaCRIndex, 0x59);
! 	       outb(vgaCRReg, 0x02);
  	       outb(vgaCRIndex, 0x5a);
  	       outb(vgaCRReg, 0x00);
  	       outb (vgaCRIndex, 0x58);
! #if 0
! 	       /* find what size aperture we can manage */
! 	       if (OFLG_ISSET(OPTION_NOLINEAR_MODE, &s3InfoRec.options)) {
! 	          s3LinApOpt=0x14;	       
! 	       } else  {
! #endif
! 	          if (s3InfoRec.videoRam <= 1024) {
! 		     s3LinApOpt=0x15;
! 	          } else if (s3InfoRec.videoRam <= 2048) {
! 		     s3LinApOpt=0x16;
! 	          } else {
! 		     s3LinApOpt=0x17;
! 	          }
!        	          s3BankSize = s3InfoRec.videoRam * 1024;
! #if 0
  	       }
! #endif
  	       /* go on to linear mode */
  	       outb (vgaCRReg, s3LinApOpt);
  	       /* end  801 sequence to go into linear mode */
  	    }
  	 
! 	    for (i = 0xfc; i >= 0; i-=4) {
  	       unsigned long addr;
! 	    
! 	       addr = (i << 24) + (0x2<<24);
  	       s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION,
! 				          (pointer)addr, s3BankSize);
! 	       poker = (long *) s3VideoMem; 
  
! 	       if (s3TryAddress(poker, pVal)) {
! 	          /* We found some ram, but is it ours? */
  	       
! 		 /* move it up by 16MB */
!  	         addr += (0x1<<24);
! 		 outb(vgaCRIndex, 0x59);
! 		 outb(vgaCRReg, 0x03);
! 		 if (!s3TryAddress(poker, pVal)) {
! 		     xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem,
! 				     s3BankSize);
! 		     s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION,
! 						(pointer)addr, s3BankSize);
  		     
! 		    if (s3TryAddress((long *)s3VideoMem, pVal)) {
! 			ErrorF("%s %s: Local bus LAW31-26 is %X\n", 
! 			    XCONFIG_PROBED, s3InfoRec.name, i);
! #if 0
! 		        if (!OFLG_ISSET(OPTION_NOLINEAR_MODE,
! 					&s3InfoRec.options))
! #endif
! 			   s3LinearAperture = TRUE;
! 		    break;
! 		    }
! 		 }
  	       }
- 	       xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem,
- 			       s3BankSize);
  	    }
  
              /* The UnMap can unmap all mapped regions, so make sure vgaBase is
--- 150,244 ----
  	       j = (s3Port40 & 0xf6) | 0x0a;
  	       outb (vgaCRReg, (unsigned char) j);
  	       outb(vgaCRIndex, 0x59);
! 	       outb(vgaCRReg, 0x03);
  	       outb(vgaCRIndex, 0x5a);
  	       outb(vgaCRReg, 0x00);
  	       outb (vgaCRIndex, 0x58);
! 	       if (s3InfoRec.videoRam <= 1024) {
! 		  s3LinApOpt=0x15;
! 	       } else if (s3InfoRec.videoRam <= 2048) {
! 		  s3LinApOpt=0x16;
! 	       } else {
! 		  s3LinApOpt=0x17;
  	       }
!        	       s3BankSize = s3InfoRec.videoRam * 1024;
  	       /* go on to linear mode */
  	       outb (vgaCRReg, s3LinApOpt);
  	       /* end  801 sequence to go into linear mode */
  	    }
  	 
! 	    /*
! 	     * XXXX This is for debugging only.  It attempts to find
! 	     * which values of LAW are decoded (see s3TryAddress() below).
! 	     */
! 	    if (OFLG_ISSET(OPTION_FB_DEBUG, &s3InfoRec.options)) {
! 	       for (i = 0xfc; i >= 0; i-=4) {
! 		  unsigned long addr = (i << 24) + (0x3<<24);
! 
! 	          s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION,
! 				          (pointer)addr, 4096);
! 	          poker = (long *) s3VideoMem; 
! 	          s3TryAddress(poker, pVal, addr, 0);
! 	          xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem, 4096);
! 	       }
! 	    }
! 		  
! 	    /*
! 	     * If a MemBase value was given in the Xconfig, skip the LAW
! 	     * probe and use the high 6 bits for the hw part of LAW.
! 	     */
! 	    if (s3InfoRec.MemBase != 0) {
  	       unsigned long addr;
! 
! 	       /* Software part of LAW is 60MB = 0x3c00000 */
! 	       addr = (s3InfoRec.MemBase & 0xfc000000) + 0x3c00000;
  	       s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION,
! 					  (pointer)addr, s3BankSize);
! 	       outb(vgaCRIndex, 0x5a);
! 	       outb(vgaCRReg, 0xC0);
! 	       s3LinearAperture = TRUE;
! 	       ErrorF("%s %s: Local bus LAW31-26 is %X\n", 
! 		      XCONFIG_GIVEN, s3InfoRec.name, (addr >> 24) & 0xfc);
! 	    } else {
! 	       for (i = 0xfc; i >= 0; i-=4) {
! 	          unsigned long addr;
! 	    
! 	          /* Start at LAW(hw) + 48MB */
! 	          addr = (i << 24) + (0x3<<24);
! 	          s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION,
! 				             (pointer)addr, s3BankSize);
! 	          poker = (long *) s3VideoMem; 
  
! 	          if (s3TryAddress(poker, pVal, addr, 1)) {
! 	             /* We found some ram, but is it ours? */
  	       
! 		     /* move it up by 12MB to LAW(hw) + 60MB */
! 		     outb(vgaCRIndex, 0x5a);
! 		     outb(vgaCRReg, 0xC0);
! 		     if (!s3TryAddress(poker, pVal, addr, 2)) {
!  	                addr += (0x0C<<20);
! 		        xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem,
! 				        s3BankSize);
! 		        s3VideoMem = xf86MapVidMem(scr_index, LINEAR_REGION,
! 						   (pointer)addr, s3BankSize);
  		     
! 		        if (s3TryAddress((long *)s3VideoMem, pVal, addr, 3)) {
! 		           ErrorF("%s %s: Local bus LAW31-26 is %X\n", 
! 			          XCONFIG_PROBED, s3InfoRec.name, i);
! 		           s3LinearAperture = TRUE;
! 		           break;
! 		        }
! 		     } else {
! 			ErrorF("%s %s: linear framebuffer found, but",
! 			       XCONFIG_PROBED, s3InfoRec.name);
! 			ErrorF(" it appears to be in a cachable\n");
! 			ErrorF("\t address range.\n");
! 			CachedFrameBuffer = TRUE;
! 		     }
! 	          }
! 	          xf86UnMapVidMem(scr_index, LINEAR_REGION, s3VideoMem,
! 			          s3BankSize);
  	       }
  	    }
  
              /* The UnMap can unmap all mapped regions, so make sure vgaBase is
***************
*** 206,221 ****
  	    xf86MapDisplay(scr_index, VGA_REGION);
  
  	    if (!s3LinearAperture) {
! 	       ErrorF("%s %s: Couldn't find local bus framebuffer -",
! 		      XCONFIG_PROBED, s3InfoRec.name);
  	       ErrorF(" linear access disabled\n");
! 	       if (OFLG_ISSET(OPTION_MEM_ACCESS, &s3InfoRec.options)) {
! 		  s3BankSize = 0x10000;
! 	       } else {
! 	          OFLG_SET(OPTION_NO_MEM_ACCESS, &s3InfoRec.options);
! 	          OFLG_SET(XCONFIG_NOMEMACCESS, &s3InfoRec.xconfigFlag);
! 	          s3BankSize = 0;	    
! 	       }
  	       s3VideoMem = NULL;
  	    }
  	    if (S3_801_928_SERIES (s3ChipId)) {
--- 246,256 ----
  	    xf86MapDisplay(scr_index, VGA_REGION);
  
  	    if (!s3LinearAperture) {
! 	       ErrorF("%s %s: %s local bus framebuffer -",
! 		      XCONFIG_PROBED, s3InfoRec.name,
! 	              (CachedFrameBuffer? "Can't use": "Couldn't find"));
  	       ErrorF(" linear access disabled\n");
! 	       s3BankSize = 0x10000;
  	       s3VideoMem = NULL;
  	    }
  	    if (S3_801_928_SERIES (s3ChipId)) {
***************
*** 228,250 ****
  	    }
  	    if (s3Mmio928) { /* Now re-enable mmio if required */
  	       outb(vgaCRIndex, 0x53);
! 	       outb(vgaCRReg, 0x10);
  	    }
  
           }
-       } else { /* No support for linear video memory */
- 	 if (s3Localbus && !S3_924_ONLY(s3ChipId)) {
- 	    if (!OFLG_ISSET(OPTION_NO_MEM_ACCESS, &s3InfoRec.options) &&
- 		!OFLG_ISSET(OPTION_MEM_ACCESS, &s3InfoRec.options)) {
- 	       OFLG_SET(OPTION_NO_MEM_ACCESS, &s3InfoRec.options);
- 	       OFLG_SET(XCONFIG_NOMEMACCESS, &s3InfoRec.xconfigFlag);
- 	    }
- 	 }
        }
  
        /* No linear mapping */
!       if (!s3VideoMem)
  	 s3VideoMem = vgaBase;
  	
     } else
        s3Init(s3InfoRec.modes);
--- 263,292 ----
  	    }
  	    if (s3Mmio928) { /* Now re-enable mmio if required */
  	       outb(vgaCRIndex, 0x53);
! 	       outb(vgaCRReg, reg53tmp | 0x10);
  	    }
  
           }
        }
  
        /* No linear mapping */
!       if (!s3VideoMem) {
  	 s3VideoMem = vgaBase;
+ 	 /* If using VGA aperture, set it up */
+ 	 if (s3BankSize == 0x10000) {
+ 	    outb(vgaCRIndex, 0x59);
+ 	    outb(vgaCRReg, 0x00);
+ 	    outb(vgaCRIndex, 0x5a);
+ 	    outb(vgaCRReg, 0x0a);
+ 	    s3LinApOpt = 0x14;
+ 	 }
+       }
+ 	   
+       /* Save CR59, CR5A for future calls to s3Init() */
+       outb(vgaCRIndex, 0x59);
+       s3Port59 = inb(vgaCRReg);
+       outb(vgaCRIndex, 0x5A);
+       s3Port5A = inb(vgaCRReg);
  	
     } else
        s3Init(s3InfoRec.modes);
***************
*** 254,267 ****
  
     s3ImageInit();
  
!    s3CacheInit(s3InfoRec.virtualX, s3InfoRec.virtualY);
!    s3BitCache8Init(s3InfoRec.virtualX, s3InfoRec.virtualY);
  
  
     if (!s3ScreenInit(pScreen,
  		     (pointer) s3VideoMem,
  		     s3InfoRec.virtualX, s3InfoRec.virtualY,
! 		     75, 75,
  		     s3DisplayWidth))
        return (FALSE);
  
--- 296,315 ----
  
     s3ImageInit();
  
!    s3CacheInit(s3InfoRec.virtualX, s3CursorStartY + s3CursorLines);
!    s3BitCache8Init(s3InfoRec.virtualX, s3CursorStartY + s3CursorLines);
! 
!    /*
!     * Take display resolution from the -dpi flag if specified
!     */
  
+    if (monitorResolution)
+       displayResolution = monitorResolution;
  
     if (!s3ScreenInit(pScreen,
  		     (pointer) s3VideoMem,
  		     s3InfoRec.virtualX, s3InfoRec.virtualY,
! 		     displayResolution, displayResolution,
  		     s3DisplayWidth))
        return (FALSE);
  
***************
*** 296,302 ****
       int screen_idx;
  {
     PixmapPtr pspix;
-    static PixmapPtr ppix = NULL;
     ScreenPtr pScreen = s3savepScreen;
  
     pspix = (PixmapPtr)pScreen->devPrivate;
--- 344,349 ----
***************
*** 315,322 ****
           AlreadyInited = TRUE;
  	 s3RestoreDACvalues();
  	 s3ImageInit();
!    	 s3CacheInit(s3InfoRec.virtualX, s3InfoRec.virtualY);
!    	 s3BitCache8Init(s3InfoRec.virtualX, s3InfoRec.virtualY);
  	 s3RestoreColor0(pScreen);
  	 (void)s3CursorInit(0, pScreen); 
  	 s3RestoreCursor(pScreen);
--- 362,369 ----
           AlreadyInited = TRUE;
  	 s3RestoreDACvalues();
  	 s3ImageInit();
!    	 s3CacheInit(s3InfoRec.virtualX, s3CursorStartY + s3CursorLines);
!    	 s3BitCache8Init(s3InfoRec.virtualX, s3CursorStartY + s3CursorLines);
  	 s3RestoreColor0(pScreen);
  	 (void)s3CursorInit(0, pScreen); 
  	 s3RestoreCursor(pScreen);
***************
*** 379,384 ****
--- 426,439 ----
     x386Exiting = TRUE;
     if (x386VTSema)
        s3EnterLeaveVT(LEAVE, screen_idx);
+    else if (ppix) {
+       /*
+        * 7-Jan-94 CEG: The server is not running on the current vt.
+        * Free the screen snapshot taken when the server vt was left.
+        */
+       (s3savepScreen->DestroyPixmap)(ppix);
+       ppix = NULL;
+    }
     return (TRUE);
  }
  
***************
*** 446,451 ****
--- 501,507 ----
  s3AdjustFrame(int x, int y)
  {
     int   Base;
+    unsigned char tmp;
  
     if (OFLG_ISSET(OPTION_SHOWCACHE, &s3InfoRec.options)) {
        if ( debugcache & 1)
***************
*** 455,461 ****
     Base = (y * s3DisplayWidth + x) >> 2;
  
     outb(vgaCRIndex, 0x31);
!    outb(vgaCRReg, ((Base & 0x030000) >> 12) | 0x8d);
  
     outw(vgaCRIndex, (Base & 0x00FF00) | 0x0C);
     outw(vgaCRIndex, ((Base & 0x00FF) << 8) | 0x0D);
--- 511,523 ----
     Base = (y * s3DisplayWidth + x) >> 2;
  
     outb(vgaCRIndex, 0x31);
!    outb(vgaCRReg, ((Base & 0x030000) >> 12) | s3Port31);
!    s3Port51 &= ~0x03;
!    s3Port51 |= ((Base & 0x040000) >> 18);
!    outb(vgaCRIndex, 0x51);
!    /* Don't override current bank selection */
!    tmp = (inb(vgaCRReg) & ~0x03) | ((Base & 0x040000) >> 18);
!    outb(vgaCRReg, tmp);
  
     outw(vgaCRIndex, (Base & 0x00FF00) | 0x0C);
     outw(vgaCRIndex, ((Base & 0x00FF) << 8) | 0x0D);
***************
*** 473,485 ****
   * Force optimising compilers to read *addr
   */
  static Bool
! s3TryAddress(long *addr, long value)
  {
     long tmp;
  
     tmp = *addr;
  
! /*   ErrorF("got %X\n", tmp);*/
     if (tmp == value)
        return TRUE;
     else
--- 535,558 ----
   * Force optimising compilers to read *addr
   */
  static Bool
! s3TryAddress(addr, value, physaddr, stage)
!      long *addr;
!      long value;
!      long physaddr;
!      int stage;
  {
     long tmp;
  
     tmp = *addr;
  
!    if (OFLG_ISSET(OPTION_FB_DEBUG, &s3InfoRec.options)) {
!       if (stage == 0 && tmp != 0xFFFFFFFF) {
! 	 ErrorF("Memory found at 0x%08X (read 0x%08X)\n", physaddr, tmp);
!       } else {
! 	 ErrorF("Stage %d: address = 0x%08X, read 0x%08X\n", stage, physaddr,
! 		tmp);
!       }
!    }
     if (tmp == value)
        return TRUE;
     else
diff -c mit/server/ddx/x386/accel/s3/s3name.h:2.7 mit/server/ddx/x386/accel/s3/s3name.h:2.8
*** mit/server/ddx/x386/accel/s3/s3name.h:2.7	Fri Mar 11 23:38:11 1994
--- mit/server/ddx/x386/accel/s3/s3name.h	Fri Mar 11 23:38:11 1994
***************
*** 22,33 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3name.h,v 2.7 1993/10/17 14:43:33 dawes Exp $ */
  
  #ifndef S3_NAME_H
  #define S3_NAME_H
  
! #if __STDC__ && !defined(UNIXCPP)
  #define CATNAME(prefix,subname) prefix##subname
  #else
  #define CATNAME(prefix,subname) prefix/**/subname
--- 22,33 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3name.h,v 2.8 1993/12/10 14:35:30 dawes Exp $ */
  
  #ifndef S3_NAME_H
  #define S3_NAME_H
  
! #if (__STDC__ && !defined(UNIXCPP)) || (defined (SOLX86) && defined (__STDC__) && !defined (__GNUC__))
  #define CATNAME(prefix,subname) prefix##subname
  #else
  #define CATNAME(prefix,subname) prefix/**/subname
diff -c mit/server/ddx/x386/accel/s3/s3pcach.c:2.15 mit/server/ddx/x386/accel/s3/s3pcach.c:2.17
*** mit/server/ddx/x386/accel/s3/s3pcach.c:2.15	Fri Mar 11 23:38:11 1994
--- mit/server/ddx/x386/accel/s3/s3pcach.c	Fri Mar 11 23:38:12 1994
***************
*** 41,47 ****
   *                                                  Pixmap Cache
   *
   * sizes cache may be more or less depending on off screen ram size.
!  * If the space is less than 32 pixel high, all is used for the fonts.
   *
   * If there is space to the right of the display, it is tiled (depending on
   * width w as: (| or - is 32 pixels)
--- 41,48 ----
   *                                                  Pixmap Cache
   *
   * sizes cache may be more or less depending on off screen ram size.
!  * If the space is less than 32 pixel high or if DisplayWidth < 1024,
!  * all is used for the fonts.
   *
   * If there is space to the right of the display, it is tiled (depending on
   * width w as: (| or - is 32 pixels)
***************
*** 74,80 ****
   * Id: s3pcach.c,v 2.4 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3pcach.c,v 2.15 1993/09/09 07:29:11 dawes Exp $ */
  
  #include "misc.h"
  #include "x386.h"
--- 75,81 ----
   * Id: s3pcach.c,v 2.4 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3pcach.c,v 2.17 1994/01/01 16:24:08 dawes Exp $ */
  
  #include "misc.h"
  #include "x386.h"
***************
*** 134,141 ****
     reEntry = TRUE;
  
  
!    lines = s3ScissB - h;
!    h++;				/* one line for the cursor */
  
     slots = lines / 64;
     if (slots > 16)
--- 135,142 ----
     reEntry = TRUE;
  
  
!    /* h now includes the cursor space */
!    lines = s3ScissB + 1 - h;
  
     slots = lines / 64;
     if (slots > 16)
***************
*** 171,184 ****
        s3MAX_SLOTS += 8;
  
     if (s3DisplayWidth == 1280) {   
!      s3MAX_SLOTS *= 2;
!      FIRST_32_SLOT *= 2;
!      FIRST_64_SLOT *= 2;
!      FIRST_128_SLOT *= 2;
!      num = 4;
     } else
!      num = 2;
  
     /* Now look to the left of the display */
     leftWidth = s3DisplayWidth - s3InfoRec.virtualX;
     slots = s3InfoRec.virtualY / 32;
--- 172,205 ----
        s3MAX_SLOTS += 8;
  
     if (s3DisplayWidth == 1280) {   
!       s3MAX_SLOTS *= 2;
!       FIRST_32_SLOT *= 2;
!       FIRST_64_SLOT *= 2;
!       FIRST_128_SLOT *= 2;
!       num = 4;
!    } else if (s3DisplayWidth == 1600) {
!       s3MAX_SLOTS *= 3;
!       FIRST_32_SLOT *= 3;
!       FIRST_64_SLOT *= 3;
!       FIRST_128_SLOT *= 3;
!       num = 6;
!    } else if (s3DisplayWidth == 2048) {
!       s3MAX_SLOTS *= 5;
!       FIRST_32_SLOT *= 5;
!       FIRST_64_SLOT *= 5;
!       FIRST_128_SLOT *= 5;
!       num = 10;
     } else
!       num = 2;
  
+    /* For s3DisplayWidth < 1024, no pixmap cache in below-screen area */
+    if (s3DisplayWidth < 1024) {
+       s3MAX_SLOTS = 0;
+       FIRST_32_SLOT = 0;
+       FIRST_64_SLOT = 0;
+       FIRST_128_SLOT = 0;
+    }
+      
     /* Now look to the left of the display */
     leftWidth = s3DisplayWidth - s3InfoRec.virtualX;
     slots = s3InfoRec.virtualY / 32;
***************
*** 659,665 ****
       short alu;
       short planemask;
  {
-    int   i;
  
     DoCacheImageFill(slot, x, y, w, h, pox, poy, alu, MIX_SRC, FSS_BITBLT, BSS_BITBLT, planemask);
  
--- 680,685 ----
diff -c mit/server/ddx/x386/accel/s3/s3scrin.c:2.4 mit/server/ddx/x386/accel/s3/s3scrin.c:2.5
*** mit/server/ddx/x386/accel/s3/s3scrin.c:2.4	Fri Mar 11 23:38:12 1994
--- mit/server/ddx/x386/accel/s3/s3scrin.c	Fri Mar 11 23:38:13 1994
***************
*** 43,49 ****
   * Id: s3scrin.c,v 2.2 1993/06/22 20:54:09 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3scrin.c,v 2.4 1993/09/25 05:02:04 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 43,49 ----
   * Id: s3scrin.c,v 2.2 1993/06/22 20:54:09 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3scrin.c,v 2.5 1994/02/25 14:58:49 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 130,135 ****
--- 130,138 ----
        for (i = 0; i < NUMVISUALS; i++) {
  	 visuals[i].vid = FakeClientID(0);
  	 VIDs[i] = visuals[i].vid;
+ 	 if (s3DAC8Bit) {
+ 	    visuals[i].bitsPerRGBValue = 8;
+ 	 }
        }
        cfbGeneration = serverGeneration;
     }
diff -c mit/server/ddx/x386/accel/s3/s3text.c:2.6 mit/server/ddx/x386/accel/s3/s3text.c:2.7
*** mit/server/ddx/x386/accel/s3/s3text.c:2.6	Fri Mar 11 23:38:13 1994
--- mit/server/ddx/x386/accel/s3/s3text.c	Fri Mar 11 23:38:13 1994
***************
*** 27,33 ****
   * Id: s3text.c,v 2.3 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3text.c,v 2.6 1993/09/25 05:02:05 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
--- 27,33 ----
   * Id: s3text.c,v 2.3 1993/08/09 06:17:57 jon Exp jon
   */
  
! /* $XFree86: mit/server/ddx/x386/accel/s3/s3text.c,v 2.7 1993/12/25 14:00:04 dawes Exp $ */
  
  #include	"X.h"
  #include	"Xmd.h"
***************
*** 39,48 ****
--- 39,51 ----
  #include	"windowstr.h"
  #include	"fontstruct.h"
  #include	"dixfontstr.h"
+ #include	"mi.h"
  #include	"s3.h"
  #include	"regs3.h"
  #include	"s3bcach.h"
  
+ int s3NoCPolyText();
+ int s3NoCImageText();
  extern CacheFont8Ptr s3CacheFont8();
  extern unsigned char s3SwapBits[256];
  
***************
*** 149,158 ****
      unsigned char *pglyphBase;	/* start of array of glyphs */
  {
      int width, height;
-     PixmapPtr pPixmap;
      int nbyLine;			/* bytes per line of padded pixmap */
      FontPtr pfont;
-     GCPtr pGCtmp;
      register int i;
      register int j;
      unsigned char *pbits;		/* buffer for PutImage */
--- 152,159 ----
***************
*** 436,442 ****
     }
     if (!numRects || pBox->y1 >= y + maxDescent) {
        DEALLOCATE_LOCAL(charinfo);
!       return;
     }
     yBand = pBox->y1;
     while (numRects && pBox->y1 == yBand && pBox->x2 <= x + minLeftBearing) {
--- 437,443 ----
     }
     if (!numRects || pBox->y1 >= y + maxDescent) {
        DEALLOCATE_LOCAL(charinfo);
!       return 0;
     }
     yBand = pBox->y1;
     while (numRects && pBox->y1 == yBand && pBox->x2 <= x + minLeftBearing) {
***************
*** 445,451 ****
     }
     if (!numRects) {
        DEALLOCATE_LOCAL(charinfo);   
!       return;
     }
  
     BLOCK_CURSOR;
--- 446,452 ----
     }
     if (!numRects) {
        DEALLOCATE_LOCAL(charinfo);   
!       return 0;
     }
  
     BLOCK_CURSOR;
diff -c mit/server/ddx/x386/bdm2/BUGS:2.1 mit/server/ddx/x386/bdm2/BUGS:2.2
*** mit/server/ddx/x386/bdm2/BUGS:2.1	Fri Mar 11 23:38:23 1994
--- mit/server/ddx/x386/bdm2/BUGS	Fri Mar 11 23:38:23 1994
***************
*** 2,21 ****
  Pascal Haible 8/93
  haible@izfm.uni-stuttgart.de
  
- All bdm2 drivers:
- allowed options:
- STATICGRAY:	(anyway)
- CHIPSET:	supported
- SCREENNO:	supported by upper levels ??
- DISPLAYSIZE:	not yet supported, this is given by hardware for the
- 			cards supported 'till now
- VIRTUAL:	supported if the driver supports it
- VIEWPORT:	not supported yet
- not yet allowed:
- VIDEORAM
- 
  hgc1280 only:
  - autodetection is not very reliable, the probe may fail if the card
    was in a fancy mode before. In this case ' chipset "hgc1280" ' is required.
  sigmalview only:
  - currently untested
--- 2,10 ----
  Pascal Haible 8/93
  haible@izfm.uni-stuttgart.de
  
  hgc1280 only:
  - autodetection is not very reliable, the probe may fail if the card
    was in a fancy mode before. In this case ' chipset "hgc1280" ' is required.
+ 
  sigmalview only:
  - currently untested
diff -c mit/server/ddx/x386/bdm2/HISTORY:2.2 mit/server/ddx/x386/bdm2/HISTORY:2.3
*** mit/server/ddx/x386/bdm2/HISTORY:2.2	Fri Mar 11 23:38:23 1994
--- mit/server/ddx/x386/bdm2/HISTORY	Fri Mar 11 23:38:23 1994
***************
*** 2,7 ****
--- 2,20 ----
  Pascal Haible 8/93
  haible@izfm.uni-stuttgart.de
  
+ sa,su 13/14Nov93
+ - changed and tested hgc1280 to work as
+   - primary on primary address
+   - secondary on primary address and
+   - secondary on secondary address.
+ - fixed port constants in visa.
+ fr 12Nov93
+ - finished integrating visa.
+ Nov93
+ - got info about the 'visa' card from Christian Mock.
+ - Frank Dolle found my stupid bug in the Sigma L-View code.
+ - got bug report about hgc1280 compiled for primary address: does not
+   restore text mode correctly.
  we 29Sep93
  - Ran XTEST on the bdm2 server with hgc1280.
  th 09Sep93
diff -c mit/server/ddx/x386/bdm2/README:2.2 mit/server/ddx/x386/bdm2/README:2.3
*** mit/server/ddx/x386/bdm2/README:2.2	Fri Mar 11 23:38:24 1994
--- mit/server/ddx/x386/bdm2/README	Fri Mar 11 23:38:24 1994
***************
*** 22,29 ****
  Mode: 'graphics mode only'
          Ports 0x390 - 0x397
          Mem 0xC8000 - 0xCFFFF (32kBytes)
! THE LOWLEVEL DRIVER HGC1280 IS FOR THE CARD JUMPERED TO GRAPHICS MODE
! (SECONDARY ADDRESS) ONLY!!
  These 32kBytes are 2 separate read/write banks.
  Though lines are 1280/8 = 160 Bytes long, they are aligned to 256 Byte.
  In other words: there is a 96 Byte gap at the end of each line.
--- 22,31 ----
  Mode: 'graphics mode only'
          Ports 0x390 - 0x397
          Mem 0xC8000 - 0xCFFFF (32kBytes)
! 
! The restriction of the hgc1280 lowlevel driver to secondary address
! has been liftet.
! 
  These 32kBytes are 2 separate read/write banks.
  Though lines are 1280/8 = 160 Bytes long, they are aligned to 256 Byte.
  In other words: there is a 96 Byte gap at the end of each line.
***************
*** 60,73 ****
  size		1024x768	800x600x50MHz	1024x768	1280x1024
  virt.		1024x1024	800x600		1472x1024	1472x1024
  -------------	---------	---------	---------	---------
! lineStones	  73392		 27745		  24366		  7922
! fillStones	   7297		  5591		  17330		  4424
! blitStones	   2969		  6496		  14019		  4698
! arcStones	1059390		719489		1835344		869540
! textStones	  63250		  2062		  47437		 24062
! complexStones	  10718		  9542		  26013		  9281
! -------------	-------		------		-------		------
! xStones		   9798		  4531		  24006		  7822
  
  4) Can I write another lowlevel driver for bdm2?
  ------------------------------------------------
--- 62,88 ----
  size		1024x768	800x600x50MHz	1024x768	1280x1024
  virt.		1024x1024	800x600		1472x1024	1472x1024
  -------------	---------	---------	---------	---------
! lineStones	  73392		  27745		  24366		  7922
! fillStones	   7297		   5591		  17330		  4424
! blitStones	   2969		   6496		  14019		  4698
! arcStones	1059390		 719489		1835344		869540
! textStones	  63250		   2062		  47437		 24062
! complexStones	  10718		   9542		  26013		  9281
! -------------	-------		-------		-------		------
! xStones		   9798		   4531		  24006		  7822
! 
! card		HGC-1280 mono	Sigma L-View mono
! size		1280x1024	1664x1200
! virt.		1472x1024	1664x1200
! -------------	---------	---------
! lineStones	   7922		  10086
! fillStones	   4424		   5457
! blitStones	   4698		   6017
! arcStones	 869540		1083676
! textStones	  24062		  32187
! complexStones	   9281		  10339
! -------------	-------		-------
! xStones		   7822		   9825
  
  4) Can I write another lowlevel driver for bdm2?
  ------------------------------------------------
diff -c /dev/null mit/server/ddx/x386/bdm2/USING:2.0
*** /dev/null	Fri Mar 11 23:38:24 1994
--- mit/server/ddx/x386/bdm2/USING	Fri Mar 11 23:38:24 1994
***************
*** 0 ****
--- 1,24 ----
+ bdm2/USING
+ Pascal Haible 11/93
+ haible@izfm.uni-stuttgart.de
+ 
+ All bdm2 drivers:
+ allowed options:
+ STATICGRAY:	(anyway)
+ CHIPSET:	supported
+ SCREENNO:	supported by upper levels ??
+ DISPLAYSIZE:	not yet supported, this is given by hardware for the
+ 			cards supported 'till now
+ VIRTUAL:	supported if the driver supports it
+ VIEWPORT:	not supported yet
+ VIDEORAM:	allowed, but doesn't do anything
+ 
+ hgc1280 only:
+ option "secondary"	If chipset "hgc1280" is given, primary address is
+ 			assumed. This overrides this.
+ sigmalview only:
+ membase "xxxx"		Frame buffer base address (to be set by the driver).
+ 			Allowed values: 0xA0000, 0xB0000, ... , 0xE0000.
+ 			0xA0000, 0xB0000 and 0xC0000 conflict with VGA
+ 			and are reasonable only on primary displays.
+ 			Default is 0xE0000.
diff -c mit/server/ddx/x386/bdm2/bdm/bdm.c:2.4 mit/server/ddx/x386/bdm2/bdm/bdm.c:2.7
*** mit/server/ddx/x386/bdm2/bdm/bdm.c:2.4	Fri Mar 11 23:38:26 1994
--- mit/server/ddx/x386/bdm2/bdm/bdm.c	Fri Mar 11 23:38:26 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdm.c,v 2.4 1993/10/02 09:50:22 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdm.c,v 2.7 1994/02/10 21:25:11 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 35,41 ****
  #include "bdm.h"
  
  /* From bdmBank.h */
! #ifdef __386BSD__
  #define BDMBASE 0xFF000000
  #else
  #define BDMBASE 0xF0000000
--- 35,41 ----
  #include "bdm.h"
  
  /* From bdmBank.h */
! #ifdef __BSD__
  #define BDMBASE 0xFF000000
  #else
  #define BDMBASE 0xF0000000
***************
*** 89,94 ****
--- 89,95 ----
    0,			/* int maxClock */
    0,			/* int videoRam */
    0,			/* int BIOSbase */
+   0,			/* int MemBase, memory base address of framebuffer */
    350, 285,		/* int width, height : Screen picture size in mm */
  			/* This should be given from the lowlevel driver! */
    0,			/* unsigned long speedup */
***************
*** 108,114 ****
  
  pointer bdmOrigVideoState = NULL;
  pointer bdmNewVideoState = NULL;
- pointer bdmInitVideoState = NULL;
  
  extern void *bdmwriteseg; /* ?? */
  
--- 109,114 ----
***************
*** 141,148 ****
--- 141,151 ----
  void (* bdmSetWriteFunc)()     = NoopDDA;
  void (* bdmSetReadWriteFunc)() = NoopDDA;
  
+ OFlagSet bdmOptionFlags;
+ 
  /* Pointer to the Screen while VT is switched out */
  static ScreenPtr savepScreen = NULL;
+ static PixmapPtr ppix = NULL;
  
  /* Banking functions etc. are saved and set to NoopDDA
   * while VT is switched out */
***************
*** 218,224 ****
  				XCONFIG_GIVEN : XCONFIG_PROBED ,
  			bdm2InfoRec.name,
  			bdm2InfoRec.chipset);
- 		/* videoram is not yet allowed */
  		ErrorF("%s %s: videoram: %dk\n",
  			OFLG_ISSET(XCONFIG_VIDEORAM,&bdm2InfoRec.xconfigFlag) ?
  				XCONFIG_GIVEN : XCONFIG_PROBED ,
--- 221,226 ----
***************
*** 247,258 ****
  	bdmSegmentMask      = bdmDrivers[i]->ChipSegmentMask;
  	bdmUse2Banks        = bdmDrivers[i]->ChipUse2Banks;
  	bdmScanLineWidth    = bdmDrivers[i]->ChipScanLineWidth;
  
!         for (j=0; xf86_OptionTab[j].token >= 0; j++)
!           if (OFLG_ISSET(j,&bdm2InfoRec.options)) {
!             ErrorF("%s: Option flags are not supported\n", bdm2InfoRec.name);
!             break;
!           }
  
  	/* Set up later (?) by x386InitViewport in common/x386Cursor.c */
  	/* (X0,Y0) = ViewPort */
--- 249,257 ----
  	bdmSegmentMask      = bdmDrivers[i]->ChipSegmentMask;
  	bdmUse2Banks        = bdmDrivers[i]->ChipUse2Banks;
  	bdmScanLineWidth    = bdmDrivers[i]->ChipScanLineWidth;
+ 	bdmOptionFlags      = bdmDrivers[i]->ChipOptionFlags;
  
! 	xf86VerifyOptions(&bdmOptionFlags, &bdm2InfoRec);
  
  	/* Set up later (?) by x386InitViewport in common/x386Cursor.c */
  	/* (X0,Y0) = ViewPort */
***************
*** 323,341 ****
    int mapSize;
  
    if (serverGeneration == 1) {
! #if defined(__386BSD__) && !defined(__bsdi__)
  	/* Hack for mmap() problem on 386bsd */
  	if (bdmMapSize < 0x18000)
  		mapSize = 0x18000;
  	else
! #endif /* __386BSD__ && !__bsdi__ */
  	mapSize = bdmMapSize;
  	bdmBase = xf86MapVidMem(index, VGA_REGION /* ?? */,
  				(pointer)bdmMapBase, mapSize);
- #if 0
- 	ErrorF("%s: Using banked dumb framebuffer mono mode\n",
- 	       bdm2InfoRec.name);
- #endif
  	bdmVirtBase = (pointer)BDMBASE;
  	bdmReadBottom  = (void *)((unsigned int)bdmReadBottom
  			 + (unsigned int)bdmBase);
--- 322,336 ----
    int mapSize;
  
    if (serverGeneration == 1) {
! #if defined(__BSD__) && !defined(__bsdi__)
  	/* Hack for mmap() problem on 386bsd */
  	if (bdmMapSize < 0x18000)
  		mapSize = 0x18000;
  	else
! #endif /* __BSD__ && !__bsdi__ */
  	mapSize = bdmMapSize;
  	bdmBase = xf86MapVidMem(index, VGA_REGION /* ?? */,
  				(pointer)bdmMapBase, mapSize);
  	bdmVirtBase = (pointer)BDMBASE;
  	bdmReadBottom  = (void *)((unsigned int)bdmReadBottom
  			 + (unsigned int)bdmBase);
***************
*** 349,360 ****
    }
  
  /* Warning: bdmInit returns the video state (copy of it) that is to be set */
!   if (!(bdmInitVideoState=(pointer)(bdmInitFunc)(bdm2InfoRec.modes)))
  	FatalError("%s: hardware initialisation failed\n", bdm2InfoRec.name);
-   bdmNewVideoState = bdmInitVideoState;
    if (!bdmOrigVideoState)
  	bdmOrigVideoState=(pointer)(bdmSaveFunc)(bdmOrigVideoState);
!   (bdmRestoreFunc)(bdmInitVideoState);
  #ifndef DIRTY_STARTUP
    bdmSaveScreenFunc(NULL, FALSE); /* blank the screen */
  #endif
--- 344,354 ----
    }
  
  /* Warning: bdmInit returns the video state (copy of it) that is to be set */
!   if (!(bdmNewVideoState=(pointer)(bdmInitFunc)(bdm2InfoRec.modes)))
  	FatalError("%s: hardware initialisation failed\n", bdm2InfoRec.name);
    if (!bdmOrigVideoState)
  	bdmOrigVideoState=(pointer)(bdmSaveFunc)(bdmOrigVideoState);
!   (bdmRestoreFunc)(bdmNewVideoState);
  #ifndef DIRTY_STARTUP
    bdmSaveScreenFunc(NULL, FALSE); /* blank the screen */
  #endif
***************
*** 426,438 ****
    RegionRec pixReg;	/* */
    DDXPointRec pixPt;	/* Point: upper left corner */
    PixmapPtr   pspix;	/* Pointer to the pixmap of the saved screen */
-   static PixmapPtr ppix = NULL;
    ScreenPtr   pScreen = savepScreen;	/* This is the 'old' Screen:
  				/* real screen on leave, dummy on enter */
  
    /* Set up pointer to the saved pixmap (pspix) only if not resetting
  						and not exiting */
!   if (!x386Resetting && !x386Exiting) {
  	pixBox.x1 = 0; pixBox.x2 = pScreen->width;
  	pixBox.y1 = 0; pixBox.y2 = pScreen->height;
  	pixPt.x = 0; pixPt.y = 0;
--- 420,436 ----
    RegionRec pixReg;	/* */
    DDXPointRec pixPt;	/* Point: upper left corner */
    PixmapPtr   pspix;	/* Pointer to the pixmap of the saved screen */
    ScreenPtr   pScreen = savepScreen;	/* This is the 'old' Screen:
  				/* real screen on leave, dummy on enter */
  
    /* Set up pointer to the saved pixmap (pspix) only if not resetting
  						and not exiting */
!   /* bdm2 should treat this differently:
!    * As this screen might be a secondary screen, it is better to clear
!    * it on exit.
!    * This makes VT switching on a primary mono card look better (& slower)
!    */
!   if (!x386Resetting /* && !x386Exiting */ ) {
  	pixBox.x1 = 0; pixBox.x2 = pScreen->width;
  	pixBox.y1 = 0; pixBox.y2 = pScreen->height;
  	pixPt.x = 0; pixPt.y = 0;
***************
*** 487,500 ****
         *
         * This pixmap has to be ScanLineWidth pixels wide !!
         */
-       if (!x386Exiting)
        {
          ppix = (pScreen->CreatePixmap)(pScreen, /* pScreen->width */
  		bdmScanLineWidth, pScreen->height, pScreen->rootDepth);
          if (ppix)
          {
! 	  bdm_mfbDoBitblt(&pspix->drawable, &ppix->drawable, GXcopy, &pixReg,
!                       &pixPt, 0xFF);
  	  bdm_mfbSolidBlackArea(&pspix->drawable, 1, &pixBox, GXcopy, NULL);
  	  pspix->devPrivate.ptr = ppix->devPrivate.ptr;
          }
--- 485,498 ----
         *
         * This pixmap has to be ScanLineWidth pixels wide !!
         */
        {
          ppix = (pScreen->CreatePixmap)(pScreen, /* pScreen->width */
  		bdmScanLineWidth, pScreen->height, pScreen->rootDepth);
          if (ppix)
          {
! 	  if (!x386Exiting)
! 	      bdm_mfbDoBitblt(&pspix->drawable, &ppix->drawable, GXcopy, &pixReg,
! 		&pixPt, 0xFF);
  	  bdm_mfbSolidBlackArea(&pspix->drawable, 1, &pixBox, GXcopy, NULL);
  	  pspix->devPrivate.ptr = ppix->devPrivate.ptr;
          }
***************
*** 507,514 ****
         */
        if (bdmOrigVideoState)
  	(bdmRestoreFunc)(bdmOrigVideoState);
-       /* Special for bdm2: setting OrigVideoState does not blank the screen */
-       (bdmSaveScreenFunc)(NULL,FALSE);
  
        (bdmEnterLeaveFunc)(LEAVE);
        xf86UnMapDisplay(screen_idx, VGA_REGION);
--- 505,510 ----
***************
*** 545,551 ****
     * current vt. Let's catch this case here.
     */
    x386Exiting = TRUE;
!   if (x386VTSema) bdmEnterLeaveVT(LEAVE, screen_idx);
    return(TRUE);
  }
  
--- 541,556 ----
     * current vt. Let's catch this case here.
     */
    x386Exiting = TRUE;
!   if (x386VTSema)
!     bdmEnterLeaveVT(LEAVE, screen_idx);
!   else if (ppix) {
!     /*
!      * 7-Jan-94 CEG: The server is not running on the current vt.
!      * Free the screen snapshot taken when the server vt was left.
!      */
!     (savepScreen->DestroyPixmap)(ppix);
!     ppix = NULL;
!   }
    return(TRUE);
  }
  
diff -c mit/server/ddx/x386/bdm2/bdm/bdm.h:2.0 mit/server/ddx/x386/bdm2/bdm/bdm.h:2.1
*** mit/server/ddx/x386/bdm2/bdm/bdm.h:2.0	Fri Mar 11 23:38:27 1994
--- mit/server/ddx/x386/bdm2/bdm/bdm.h	Fri Mar 11 23:38:27 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdm.h,v 2.0 1993/08/30 15:21:57 dawes Exp $ */
  
  /* Included from bdm.c, bdmBank.c */
  
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdm.h,v 2.1 1993/12/01 12:37:09 dawes Exp $ */
  
  /* Included from bdm.c, bdmBank.c */
  
***************
*** 68,74 ****
    void *ChipWriteTop;
    /* Memory to map	*/
    int ChipMapBase;
!   int ChipMapSize;	/* replaces MEMTOMAP */
    int ChipSegmentSize;
    int ChipSegmentShift;
    int ChipSegmentMask;
--- 68,74 ----
    void *ChipWriteTop;
    /* Memory to map	*/
    int ChipMapBase;
!   int ChipMapSize;		/* replaces MEMTOMAP */
    int ChipSegmentSize;
    int ChipSegmentShift;
    int ChipSegmentMask;
***************
*** 77,83 ****
    int ChipHDisplay;
    int ChipVDisplay;
    /* In case Scan Line in mfb is longer than HDisplay */
!   int ChipScanLineWidth;/* in pixels */
  } bdmVideoChipRec, *bdmVideoChipPtr;
  
  /*
--- 77,85 ----
    int ChipHDisplay;
    int ChipVDisplay;
    /* In case Scan Line in mfb is longer than HDisplay */
!   int ChipScanLineWidth;	/* in pixels */
!   /* option flags support by this driver */
!   OFlagSet ChipOptionFlags;
  } bdmVideoChipRec, *bdmVideoChipPtr;
  
  /*
diff -c mit/server/ddx/x386/bdm2/bdm/bdmBank.h:2.0 mit/server/ddx/x386/bdm2/bdm/bdmBank.h:2.1
*** mit/server/ddx/x386/bdm2/bdm/bdmBank.h:2.0	Fri Mar 11 23:38:27 1994
--- mit/server/ddx/x386/bdm2/bdm/bdmBank.h	Fri Mar 11 23:38:28 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdmBank.h,v 2.0 1993/08/30 15:21:58 dawes Exp $ */
  
  #ifndef BDM_BANK_H
  #define BDM_BANK_H
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdmBank.h,v 2.1 1994/02/10 21:25:12 dawes Exp $ */
  
  #ifndef BDM_BANK_H
  #define BDM_BANK_H
***************
*** 46,52 ****
  extern void (*bdmPopRead)(	/* void *p */);
  
  
! #ifdef __386BSD__
  #define BDMBASE 0xFF000000
  #else
  #define BDMBASE 0xF0000000
--- 46,52 ----
  extern void (*bdmPopRead)(	/* void *p */);
  
  
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
  #define BDMBASE 0xFF000000
  #else
  #define BDMBASE 0xF0000000
diff -c mit/server/ddx/x386/bdm2/bdm/bdmBank.s:2.2 mit/server/ddx/x386/bdm2/bdm/bdmBank.s:2.3
*** mit/server/ddx/x386/bdm2/bdm/bdmBank.s:2.2	Fri Mar 11 23:38:28 1994
--- mit/server/ddx/x386/bdm2/bdm/bdmBank.s	Fri Mar 11 23:38:28 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdmBank.s,v 2.2 1993/10/02 16:53:22 dawes Exp $ */
  
  /********** WARNING: **********/
  /* If you use bdmBank.s instead of bdmBank.c the lowlevel banking
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/bdm/bdmBank.s,v 2.3 1994/02/10 21:25:14 dawes Exp $ */
  
  /********** WARNING: **********/
  /* If you use bdmBank.s instead of bdmBank.c the lowlevel banking
***************
*** 76,86 ****
          FILE("bdmBank.s")
          AS_BEGIN
  
! #ifdef __386BSD__
  #define BDMBASE CONST(0xFF000000)
! #else /* __386BSD__ */
  #define BDMBASE CONST(0xF0000000)
! #endif /* __386BSD__ */
  
  #ifndef __ASSYNTAX_H__
  #define bdmSetReadWrite _bdmSetReadWrite
--- 76,86 ----
          FILE("bdmBank.s")
          AS_BEGIN
  
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
  #define BDMBASE CONST(0xFF000000)
! #else
  #define BDMBASE CONST(0xF0000000)
! #endif
  
  #ifndef __ASSYNTAX_H__
  #define bdmSetReadWrite _bdmSetReadWrite
diff -c mit/server/ddx/x386/bdm2/drivers/hgc1280/HGC1280.info:2.1 mit/server/ddx/x386/bdm2/drivers/hgc1280/HGC1280.info:2.2
*** mit/server/ddx/x386/bdm2/drivers/hgc1280/HGC1280.info:2.1	Fri Mar 11 23:38:32 1994
--- mit/server/ddx/x386/bdm2/drivers/hgc1280/HGC1280.info	Fri Mar 11 23:38:32 1994
***************
*** 25,30 ****
--- 25,31 ----
  address.
  
  Mem window 0xC8000 - 0xCFFFF (32kBytes) is 2 separate read/write banks.
+ (On primary address: first Herc bank 0xB0000-0xB7FFF = 2 banks)
  
  Visible lines are 1280 pixels (160 Byte) long. On the right side, further
  32 bytes are read/write. By changing one of the regs, the visible area
***************
*** 39,45 ****
  
  Register level programming:
  The HGC-1280 (in 'graphics only' mode) is programmed like a Hercules:
! Base: 0x390
  base+0	index port
  base+1	data port
  base+8	control port
--- 40,46 ----
  
  Register level programming:
  The HGC-1280 (in 'graphics only' mode) is programmed like a Hercules:
! Base: 0x3B0 (primary) , 0x390 (secondary)
  base+0	index port
  base+1	data port
  base+8	control port
diff -c mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280HW.h:2.3 mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280HW.h:2.4
*** mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280HW.h:2.3	Fri Mar 11 23:38:33 1994
--- mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280HW.h	Fri Mar 11 23:38:33 1994
***************
*** 7,19 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280HW.h,v 2.3 1993/10/02 09:50:42 dawes Exp $ */
  
- /* ********** WARNING: **********
-  * Couldn't include defined constants in hgc1280bank.s, so the
-  * ports are hardcoded in there!!!
-  */
- 
  #include "compiler.h"	/*	void outb(port,val);
  				void outw(port,val);
  				unsigned int inb(port);
--- 7,14 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280HW.h,v 2.4 1993/12/01 12:37:17 dawes Exp $ */
  
  #include "compiler.h"	/*	void outb(port,val);
  				void outw(port,val);
  				unsigned int inb(port);
***************
*** 29,35 ****
  
  #define HGC_NUM_REGS		(0x40)
  
! #define HGC_MEM_BASE		(0xC8000L)
  
  #define HGC_BANK_SIZE		(0x4000L)
  
--- 24,31 ----
  
  #define HGC_NUM_REGS		(0x40)
  
! #define HGC_PRIM_MEM_BASE		(0xB0000L)
! #define HGC_SEC_MEM_BASE		(0xC8000L)
  
  #define HGC_BANK_SIZE		(0x4000L)
  
***************
*** 36,47 ****
  #define HGC_MEM_BASE_BANK1	(0L)
  #define HGC_MEM_BASE_BANK2	(HGC_BANK_SIZE)
  
  #define HGC_BANK1_BOTTOM	(HGC_MEM_BASE_BANK1)
  #define HGC_BANK1_TOP		(HGC_BANK1_BOTTOM+HGC_BANK_SIZE)
! #define HGC_BANK2_BOTTOM        (HGC_MEM_BASE_BANK2)
  #define HGC_BANK2_TOP		(HGC_BANK2_BOTTOM+HGC_BANK_SIZE)
  
! #define HGC_MAP_BASE		(HGC_MEM_BASE)
  
  #define HGC_MAP_SIZE		(2*HGC_BANK_SIZE)
  
--- 32,45 ----
  #define HGC_MEM_BASE_BANK1	(0L)
  #define HGC_MEM_BASE_BANK2	(HGC_BANK_SIZE)
  
+ /* rel. to HGC_XXX_MAP_BASE */
  #define HGC_BANK1_BOTTOM	(HGC_MEM_BASE_BANK1)
  #define HGC_BANK1_TOP		(HGC_BANK1_BOTTOM+HGC_BANK_SIZE)
! #define HGC_BANK2_BOTTOM	(HGC_MEM_BASE_BANK2)
  #define HGC_BANK2_TOP		(HGC_BANK2_BOTTOM+HGC_BANK_SIZE)
  
! #define HGC_PRIM_MAP_BASE	(HGC_PRIM_MEM_BASE)
! #define HGC_SEC_MAP_BASE	(HGC_SEC_MEM_BASE)
  
  #define HGC_MAP_SIZE		(2*HGC_BANK_SIZE)
  
***************
*** 61,86 ****
   * the mode registers. Setting the banking regs seems to work without
   * this delay.
   */
! #define IO_RECOVER		{ volatile unsigned char io_recover_dummy; \
! 				  io_recover_dummy=inb(HGC_PORT_INDEX);    \
! 				  io_recover_dummy=inb(HGC_PORT_INDEX); }
! 
! #define HGC_SET_REG(reg,val)	{ outb(HGC_PORT_INDEX,reg);	\
! 				  IO_RECOVER;			\
! 				  outb(HGC_PORT_DATA,val); }	\
! 				  IO_RECOVER;
! 
! #define HGC_GET_REG(reg,pval)	{ outb(HGC_PORT_INDEX,reg);	\
! 				  IO_RECOVER;			\
! 				  *(pval)=inb(HGC_PORT_DATA); }	\
! 				  IO_RECOVER;
  
  #if 0
  #define HGC_SHIFT_DISPLAY(offs)	{ HGC_SET_REG(45, 16 - ((offs)>>4) ) }
  #endif
  
  #define HGC_SET_BANK1(b)	HGC_SET_REG(HGC_REG_BANK1,b)
  #define HGC_SET_BANK2(b)	HGC_SET_REG(HGC_REG_BANK2,b)
  
  #define HGC_PROBE_REG_RW	(56)
  #define HGC_PROBE_VAL_WRITE	(0xFF)
--- 59,100 ----
   * the mode registers. Setting the banking regs seems to work without
   * this delay.
   */
! #define IO_RECOVER_PRIM		{ volatile unsigned char io_recover_dummy; \
! 				  io_recover_dummy=inb(HGC_PRIM_PORT_INDEX);    \
! 				  io_recover_dummy=inb(HGC_PRIM_PORT_INDEX); }
! 
! #define IO_RECOVER_SEC		{ volatile unsigned char io_recover_dummy; \
! 				  io_recover_dummy=inb(HGC_SEC_PORT_INDEX);    \
! 				  io_recover_dummy=inb(HGC_SEC_PORT_INDEX); }
! 
! #define HGC_PRIM_SET_REG(reg,val) { outb(HGC_PRIM_PORT_INDEX,reg);	\
! 				    IO_RECOVER_PRIM;			\
! 				    outb(HGC_PRIM_PORT_DATA,val); }	\
! 				    IO_RECOVER_PRIM;
! 
! #define HGC_PRIM_GET_REG(reg,pval) { outb(HGC_PRIM_PORT_INDEX,reg);	\
! 				     IO_RECOVER_PRIM;			\
! 				     *(pval)=inb(HGC_PRIM_PORT_DATA); }	\
! 				     IO_RECOVER_PRIM;
! 
! #define HGC_SEC_SET_REG(reg,val)  { outb(HGC_SEC_PORT_INDEX,reg);	\
! 				    IO_RECOVER_SEC;			\
! 				    outb(HGC_SEC_PORT_DATA,val); }	\
! 				    IO_RECOVER_SEC;
! 
! #define HGC_SEC_GET_REG(reg,pval) { outb(HGC_SEC_PORT_INDEX,reg);	\
! 				     IO_RECOVER_SEC;			\
! 				     *(pval)=inb(HGC_SEC_PORT_DATA); }	\
! 				     IO_RECOVER_SEC;
  
  #if 0
  #define HGC_SHIFT_DISPLAY(offs)	{ HGC_SET_REG(45, 16 - ((offs)>>4) ) }
  #endif
  
+ #if 0
  #define HGC_SET_BANK1(b)	HGC_SET_REG(HGC_REG_BANK1,b)
  #define HGC_SET_BANK2(b)	HGC_SET_REG(HGC_REG_BANK2,b)
+ #endif
  
  #define HGC_PROBE_REG_RW	(56)
  #define HGC_PROBE_VAL_WRITE	(0xFF)
***************
*** 90,95 ****
--- 104,110 ----
  #define HGC_PROBE_VAL_FIX1	(16)
  #define HGC_PROBE_VAL_FIX2	(85)
  
+ #define HGC_Graphmode		(1407)
  unsigned char hgcRegsGraf1280x1024[HGC_NUM_REGS] = {
  /***     0    1    2    3    4    5    6    7    8    9 ***/
  /*0*/    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
***************
*** 98,101 ****
--- 113,127 ----
  /*3*/    0,   0, 214, 212,   0, 212,   1, 212,  10, 213,
  /*4*/  107, 153, 138,  90,  33,  16, 191,   2,   9, 192,
  /*5*/  224,  68,  65,   1,  65,  79,   0,  85,   3,   0,
+ /*6*/    0,  85,   3,   0 };
+ 
+ #define HGC_Textmode		(1408)
+ unsigned char hgcRegsText[HGC_NUM_REGS] = {
+ /***     0    1    2    3    4    5    6    7    8    9 ***/
+ /*0*/    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+ /*1*/   12,  14,   0,   0,   7, 128,   0,   0,   0,   0,
+ /*2*/    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
+ /*3*/    0,   0, 135, 132, 135, 132,   5, 132, 200, 134,
+ /*4*/  107, 153,  10,  90,  36,  74, 195,  98,  13,  34,
+ /*5*/   28,  64,  30,   2,  27, 143,   0,  85,   3,   0,
  /*6*/    0,  85,   3,   0 };
diff -c mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280Port.h:2.1 mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280Port.h:2.2
*** mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280Port.h:2.1	Fri Mar 11 23:38:33 1994
--- mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280Port.h	Fri Mar 11 23:38:34 1994
***************
*** 7,16 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280Port.h,v 2.1 1993/10/02 09:50:44 dawes Exp $ */
  
  #if 0
! #define HGC_PORT_BASE           0x390
  #define HGC_PORT_INDEX          HGC_PORT_BASE
  #define HGC_PORT_DATA           HGC_PORT_BASE+0x01
  #define HGC_PORT_CONTROL        HGC_PORT_BASE+0x08
--- 7,19 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280Port.h,v 2.2 1993/12/01 12:37:18 dawes Exp $ */
  
+ /* Primary I/O Base		0x3B0
+  * Secondary I/O Base		0x390
+  */
  #if 0
! #define HGC_PORT_BASE           0x3B0
  #define HGC_PORT_INDEX          HGC_PORT_BASE
  #define HGC_PORT_DATA           HGC_PORT_BASE+0x01
  #define HGC_PORT_CONTROL        HGC_PORT_BASE+0x08
***************
*** 19,46 ****
  #endif
  
  #if defined(C_STYLE_HEX_CONSTANTS)
  
! #define HGC_PORT_BASE           0x390
! #define HGC_PORT_INDEX          0x390
! #define HGC_PORT_DATA           0x391
! #define HGC_PORT_CONTROL        0x398
! #define HGC_PORT_CRT_STATUS     0x39A
! #define HGC_PORT_CONFIG         0x39F
! 
! #define HGC_REG_BANK1           0x22
! #define HGC_REG_BANK2           0x24
! #define HGC_REG_SHIFT_DISPLAY   0x2D
! #define HGC_REG_LEFT_BORDER     0x2A
! #define HGC_REG_RIGHT_BORDER    0x2B
! 
! #else
! 
! #define HGC_PORT_BASE           CONST(0x390)
! #define HGC_PORT_INDEX          CONST(0x390)
! #define HGC_PORT_DATA           CONST(0x391)
! #define HGC_PORT_CONTROL        CONST(0x398)
! #define HGC_PORT_CRT_STATUS     CONST(0x39A)
! #define HGC_PORT_CONFIG         CONST(0x39F)
  
  #define HGC_REG_BANK1           CONST(0x22)
  #define HGC_REG_BANK2           CONST(0x24)
--- 22,45 ----
  #endif
  
  #if defined(C_STYLE_HEX_CONSTANTS)
+ #undef CONST
+ #define CONST(a)	(a)
+ #endif
+ 
  
! #define HGC_PRIM_PORT_BASE           CONST(0x3B0)
! #define HGC_PRIM_PORT_INDEX          CONST(0x3B0)
! #define HGC_PRIM_PORT_DATA           CONST(0x3B1)
! #define HGC_PRIM_PORT_CONTROL        CONST(0x3B8)
! #define HGC_PRIM_PORT_CRT_STATUS     CONST(0x3BA)
! #define HGC_PRIM_PORT_CONFIG         CONST(0x3BF)
! 
! #define HGC_SEC_PORT_BASE           CONST(0x390)
! #define HGC_SEC_PORT_INDEX          CONST(0x390)
! #define HGC_SEC_PORT_DATA           CONST(0x391)
! #define HGC_SEC_PORT_CONTROL        CONST(0x398)
! #define HGC_SEC_PORT_CRT_STATUS     CONST(0x39A)
! #define HGC_SEC_PORT_CONFIG         CONST(0x39F)
  
  #define HGC_REG_BANK1           CONST(0x22)
  #define HGC_REG_BANK2           CONST(0x24)
***************
*** 48,51 ****
  #define HGC_REG_LEFT_BORDER     CONST(0x2A)
  #define HGC_REG_RIGHT_BORDER    CONST(0x2B)
  
- #endif
--- 47,49 ----
diff -c mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280bank.s:2.1 mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280bank.s:2.2
*** mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280bank.s:2.1	Fri Mar 11 23:38:34 1994
--- mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280bank.s	Fri Mar 11 23:38:34 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280bank.s,v 2.1 1993/10/02 09:50:45 dawes Exp $ */
  
  /*
   * These are here the very lowlevel VGA bankswitching routines.
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280bank.s,v 2.2 1993/12/01 12:37:19 dawes Exp $ */
  
  /*
   * These are here the very lowlevel VGA bankswitching routines.
***************
*** 39,70 ****
  
          SEG_TEXT
  
          ALIGNTEXT4
!         GLOBL   GLNAME(HGC1280SetRead)
! GLNAME(HGC1280SetRead):
  	/* set index reg */
  	PUSH_L	(EAX)
! 	MOV_L	(HGC_PORT_INDEX,EDX)
  	MOV_B	(HGC_REG_BANK1,AL)
  	OUT_B
  	/* output data */
! 	MOV_L	(HGC_PORT_DATA,EDX)
  	POP_L	(EAX)
  	OUT_B
          RET
  
          ALIGNTEXT4
!         GLOBL   GLNAME(HGC1280SetWrite)
!         GLOBL   GLNAME(HGC1280SetReadWrite)
! GLNAME(HGC1280SetWrite):
! GLNAME(HGC1280SetReadWrite):
  	/* set index reg */
  	PUSH_L	(EAX)
! 	MOV_L	(HGC_PORT_INDEX,EDX)
  	MOV_B	(HGC_REG_BANK2,AL)
  	OUT_B
  	/* output data */
! 	MOV_L	(HGC_PORT_DATA,EDX)
  	POP_L	(EAX)
  	OUT_B
          RET
--- 39,104 ----
  
          SEG_TEXT
  
+ /* Functions for the card jumpered primary */
+ 
+         ALIGNTEXT4
+         GLOBL   GLNAME(HGC1280pSetRead)
+ GLNAME(HGC1280pSetRead):
+ 	/* set index reg */
+ 	PUSH_L	(EAX)
+ 	MOV_L	(HGC_PRIM_PORT_INDEX,EDX)
+ 	MOV_B	(HGC_REG_BANK1,AL)
+ 	OUT_B
+ 	/* output data */
+ 	MOV_L	(HGC_PRIM_PORT_DATA,EDX)
+ 	POP_L	(EAX)
+ 	OUT_B
+         RET
+ 
+         ALIGNTEXT4
+         GLOBL   GLNAME(HGC1280pSetWrite)
+         GLOBL   GLNAME(HGC1280pSetReadWrite)
+ GLNAME(HGC1280pSetWrite):
+ GLNAME(HGC1280pSetReadWrite):
+ 	/* set index reg */
+ 	PUSH_L	(EAX)
+ 	MOV_L	(HGC_PRIM_PORT_INDEX,EDX)
+ 	MOV_B	(HGC_REG_BANK2,AL)
+ 	OUT_B
+ 	/* output data */
+ 	MOV_L	(HGC_PRIM_PORT_DATA,EDX)
+ 	POP_L	(EAX)
+ 	OUT_B
+         RET
+ 
+ /* Functions for the card jumpered secondary */
+ 
          ALIGNTEXT4
!         GLOBL   GLNAME(HGC1280sSetRead)
! GLNAME(HGC1280sSetRead):
  	/* set index reg */
  	PUSH_L	(EAX)
! 	MOV_L	(HGC_SEC_PORT_INDEX,EDX)
  	MOV_B	(HGC_REG_BANK1,AL)
  	OUT_B
  	/* output data */
! 	MOV_L	(HGC_SEC_PORT_DATA,EDX)
  	POP_L	(EAX)
  	OUT_B
          RET
  
          ALIGNTEXT4
!         GLOBL   GLNAME(HGC1280sSetWrite)
!         GLOBL   GLNAME(HGC1280sSetReadWrite)
! GLNAME(HGC1280sSetWrite):
! GLNAME(HGC1280sSetReadWrite):
  	/* set index reg */
  	PUSH_L	(EAX)
! 	MOV_L	(HGC_SEC_PORT_INDEX,EDX)
  	MOV_B	(HGC_REG_BANK2,AL)
  	OUT_B
  	/* output data */
! 	MOV_L	(HGC_SEC_PORT_DATA,EDX)
  	POP_L	(EAX)
  	OUT_B
          RET
diff -c mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280driv.c:2.2 mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280driv.c:2.3
*** mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280driv.c:2.2	Fri Mar 11 23:38:35 1994
--- mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280driv.c	Fri Mar 11 23:38:35 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280driv.c,v 2.2 1993/10/02 09:50:46 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/hgc1280/hgc1280driv.c,v 2.3 1993/12/01 12:37:21 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 29,43 ****
  #include "bdm.h"
  #include "hgc1280HW.h"
  
! typedef struct {
!   unsigned char reg[HGC_NUM_REGS];
!   } hgc1280Rec, *hgc1280Ptr;
  
  /*
   * Define the HGC I/O Ports
   */
! unsigned HGC1280_IOPorts[] = { HGC_PORT_INDEX, HGC_PORT_DATA,
! 		HGC_PORT_CONTROL, HGC_PORT_CRT_STATUS, HGC_PORT_CONFIG };
  int Num_HGC1280_IOPorts = (sizeof(HGC1280_IOPorts)/sizeof(HGC1280_IOPorts[0]));
  
  char *	HGC1280Ident();
--- 29,48 ----
  #include "bdm.h"
  #include "hgc1280HW.h"
  
! int HGC_Current_mode = HGC_Textmode;
! 
! Bool HGC_Primary = TRUE;
  
+ /* #define HGC1280_DEBUG */
+ 
  /*
   * Define the HGC I/O Ports
+  * We take the ports for both primary and secondary 
   */
! unsigned HGC1280_IOPorts[] = { HGC_PRIM_PORT_INDEX, HGC_PRIM_PORT_DATA,
! 	HGC_PRIM_PORT_CONTROL, HGC_PRIM_PORT_CRT_STATUS, HGC_PRIM_PORT_CONFIG,
!                                HGC_SEC_PORT_INDEX, HGC_SEC_PORT_DATA,
! 	HGC_SEC_PORT_CONTROL, HGC_SEC_PORT_CRT_STATUS, HGC_SEC_PORT_CONFIG };
  int Num_HGC1280_IOPorts = (sizeof(HGC1280_IOPorts)/sizeof(HGC1280_IOPorts[0]));
  
  char *	HGC1280Ident();
***************
*** 52,60 ****
  
  /* Assembler functions in hgc1280bank.s
   * - to be called by assembler functions only! */
! extern void HGC1280SetRead();
! extern void HGC1280SetWrite();
! extern void HGC1280SetReadWrite();
  
  #if 0
  /* From bdm.h -- see there, this here might not be up to date */
--- 57,68 ----
  
  /* Assembler functions in hgc1280bank.s
   * - to be called by assembler functions only! */
! extern void HGC1280pSetRead();
! extern void HGC1280pSetWrite();
! extern void HGC1280pSetReadWrite();
! extern void HGC1280sSetRead();
! extern void HGC1280sSetWrite();
! extern void HGC1280sSetReadWrite();
  
  #if 0
  /* From bdm.h -- see there, this here might not be up to date */
***************
*** 100,105 ****
--- 108,114 ----
    int ChipVDisplay;
    /* In case Scan Line in mfb is longer than HDisplay */
    int ChipScanLineWidth;
+   OFlagSet ChipOptionFlags;
  } bdmVideoChipRec, *bdmVideoChipPtr;
  #endif /* 0 */
  
***************
*** 114,127 ****
    HGC1280Adjust,
    HGC1280SaveScreen,
    NoopDDA,			/* HGC1280GetMode */
!   HGC1280SetRead,
!   HGC1280SetWrite,
!   HGC1280SetReadWrite,
    (void *)HGC_BANK1_BOTTOM,	/* ReadBottom */
    (void *)HGC_BANK1_TOP,	/* ReadTop */
    (void *)HGC_BANK2_BOTTOM,	/* WriteBottom */
    (void *)HGC_BANK2_TOP,	/* WriteTop */
!   HGC_MAP_BASE,			/* MapBase */
    HGC_MAP_SIZE,			/* MapSize */
    HGC_SEGMENT_SIZE,		/* SegmentSize */
    HGC_SEGMENT_SHIFT,		/* SegmentShift */
--- 123,136 ----
    HGC1280Adjust,
    HGC1280SaveScreen,
    NoopDDA,			/* HGC1280GetMode */
!   HGC1280pSetRead,
!   HGC1280pSetWrite,
!   HGC1280pSetReadWrite,
    (void *)HGC_BANK1_BOTTOM,	/* ReadBottom */
    (void *)HGC_BANK1_TOP,	/* ReadTop */
    (void *)HGC_BANK2_BOTTOM,	/* WriteBottom */
    (void *)HGC_BANK2_TOP,	/* WriteTop */
!   HGC_PRIM_MAP_BASE,		/* MapBase */
    HGC_MAP_SIZE,			/* MapSize */
    HGC_SEGMENT_SIZE,		/* SegmentSize */
    HGC_SEGMENT_SHIFT,		/* SegmentShift */
***************
*** 130,135 ****
--- 139,145 ----
    HGC_HDISPLAY,			/* HDisplay */
    HGC_VDISPLAY,			/* VDisplay */
    HGC_SCAN_LINE_WIDTH,		/* ScanLineWidth */
+   {0,},
  };
  
  /*
***************
*** 166,171 ****
--- 176,193 ----
  		/* desired chipset != this one */
  		return (FALSE);
  	else {
+ 		/* chipset "hgc1280" */
+ 		if (OFLG_ISSET(OPTION_SECONDARY, &bdm2InfoRec.options)) {
+ 		    /* option "secondary" */
+ 		    HGC_Primary=FALSE;
+ 		    ErrorF("%s %s: %s: Using secondary address\n",
+ 		    XCONFIG_GIVEN, bdm2InfoRec.name, bdm2InfoRec.chipset);
+ 		} else {
+ 		    /* assume primary */
+ 		    HGC_Primary=TRUE;
+ 		    ErrorF("%s %s: %s: Assuming primary address\n",
+ 		    XCONFIG_PROBED, bdm2InfoRec.name, bdm2InfoRec.chipset);
+ 		}
  		HGC1280EnterLeave(ENTER);
  		/* go on with videoram etc. below */
  	}
***************
*** 190,198 ****
  	/* Check for Hercules-like HSYNC on BASE+0xA, Bit 1 */ 
  #define HSYNC_MASK  0x01
  #define MIN_COUNT 2000
! 	dsp_old = inb(HGC_PORT_CRT_STATUS) & HSYNC_MASK;
  	for (i = 0; i < 5000; i++) {
! 		dsp = inb(HGC_PORT_CRT_STATUS) & HSYNC_MASK;
  		if (dsp != dsp_old) cnt++;
  		dsp_old = dsp;
  	}
--- 212,224 ----
  	/* Check for Hercules-like HSYNC on BASE+0xA, Bit 1 */ 
  #define HSYNC_MASK  0x01
  #define MIN_COUNT 2000
! 	/* First check the primary address */
! #ifdef HGC1280_DEBUG
! ErrorF("Checking primary address: ");
! #endif
! 	dsp_old = inb(HGC_PRIM_PORT_CRT_STATUS) & HSYNC_MASK;
  	for (i = 0; i < 5000; i++) {
! 		dsp = inb(HGC_PRIM_PORT_CRT_STATUS) & HSYNC_MASK;
  		if (dsp != dsp_old) cnt++;
  		dsp_old = dsp;
  	}
***************
*** 199,228 ****
  	/* This cnt is about 3500 to 4500 with a 'virgin' hardware,
  	 * and might be exactly 5000 if the card had been switched
  	 * to 'my' graphics mode before */
  	if (cnt>MIN_COUNT) {
  		bdm2InfoRec.chipset = HGC1280Ident(0);
  		ErrorF("%s %s: %s: cnt=%d, ", XCONFIG_PROBED,
  			bdm2InfoRec.name, bdm2InfoRec.chipset, cnt);
  		/* Test a r/w register */
! 		HGC_SET_REG(HGC_PROBE_REG_RW,HGC_PROBE_VAL_WRITE);
! 		HGC_GET_REG(HGC_PROBE_REG_RW,&val);
  		ErrorF("r/w-val=%d, ",val);
  		found = (val==HGC_PROBE_VAL_READ);
  		/* this register can't be set, depends on other registers */
! 		HGC_GET_REG(HGC_PROBE_REG_FIX,&val);
  		ErrorF("fix-val1=%d, ",val);
  		found = found && (val==HGC_PROBE_VAL_FIX1);
! 		HGC_SET_REG(HGC_PROBE_REG_RW,HGC_PROBE_VAL_RESET);
! 		HGC_GET_REG(HGC_PROBE_REG_FIX,&val);
! 		ErrorF("fix-val2=%d ",val);
  		found = found && (val==HGC_PROBE_VAL_FIX2);
! 		if (found)
! 			ErrorF("==> found\n");
  		else {
  			ErrorF("==> not found\n");
  			bdm2InfoRec.chipset = "\0";
  		}
! 	}
  	if ( !(cnt>MIN_COUNT) || !found ) {
  	/* there is no HGC-1280 card */
  		HGC1280EnterLeave(LEAVE);
--- 225,323 ----
  	/* This cnt is about 3500 to 4500 with a 'virgin' hardware,
  	 * and might be exactly 5000 if the card had been switched
  	 * to 'my' graphics mode before */
+ #ifdef HGC1280_DEBUG
+ ErrorF("count=%d\n",cnt);
+ #endif
  	if (cnt>MIN_COUNT) {
  		bdm2InfoRec.chipset = HGC1280Ident(0);
+ #ifdef HGC1280_DEBUG
  		ErrorF("%s %s: %s: cnt=%d, ", XCONFIG_PROBED,
  			bdm2InfoRec.name, bdm2InfoRec.chipset, cnt);
+ #endif
  		/* Test a r/w register */
! 		HGC_PRIM_SET_REG(HGC_PROBE_REG_RW,HGC_PROBE_VAL_WRITE);
! 		HGC_PRIM_GET_REG(HGC_PROBE_REG_RW,&val);
! #ifdef HGC1280_DEBUG
  		ErrorF("r/w-val=%d, ",val);
+ #endif
  		found = (val==HGC_PROBE_VAL_READ);
  		/* this register can't be set, depends on other registers */
! 		HGC_PRIM_GET_REG(HGC_PROBE_REG_FIX,&val);
! #ifdef HGC1280_DEBUG
  		ErrorF("fix-val1=%d, ",val);
+ #endif
  		found = found && (val==HGC_PROBE_VAL_FIX1);
! 		HGC_PRIM_SET_REG(HGC_PROBE_REG_RW,HGC_PROBE_VAL_RESET);
! 		HGC_PRIM_GET_REG(HGC_PROBE_REG_FIX,&val);
! #ifdef HGC1280_DEBUG
! 		ErrorF("fix-val2=%d\n",val);
! #endif
  		found = found && (val==HGC_PROBE_VAL_FIX2);
! 		if (found) {
! 			HGC_Primary=TRUE;
! 			ErrorF("%s %s: %s found on primary address\n",
! 				XCONFIG_PROBED, bdm2InfoRec.name,
! 				bdm2InfoRec.chipset);
! 		}
  		else {
+ #ifdef HGC1280_DEBUG
+ 		    ErrorF("==> not found\n");
+ #endif
+ 		    bdm2InfoRec.chipset = "\0";
+ 		}
+ 	};
+ 	if ( !(cnt>MIN_COUNT) || !found ) {
+ #ifdef HGC1280_DEBUG
+ ErrorF("Checking secondary address: ");
+ #endif
+ 	    /* Check the secondary address */
+ 	    dsp_old = inb(HGC_SEC_PORT_CRT_STATUS) & HSYNC_MASK;
+ 	    for (i = 0; i < 5000; i++) {
+ 		dsp = inb(HGC_SEC_PORT_CRT_STATUS) & HSYNC_MASK;
+ 		if (dsp != dsp_old) cnt++;
+ 		dsp_old = dsp;
+ 	    }
+ #ifdef HGC1280_DEBUG
+ ErrorF("count=%d\n",cnt);
+ #endif
+ 	    if (cnt>MIN_COUNT) {
+ 		bdm2InfoRec.chipset = HGC1280Ident(0);
+ #ifdef HGC1280_DEBUG
+ 		ErrorF("%s %s: %s: cnt=%d, ", XCONFIG_PROBED,
+ 		       bdm2InfoRec.name, bdm2InfoRec.chipset, cnt);
+ #endif
+ 		/* Test a r/w register */
+ 		HGC_SEC_SET_REG(HGC_PROBE_REG_RW,HGC_PROBE_VAL_WRITE);
+ 		HGC_SEC_GET_REG(HGC_PROBE_REG_RW,&val);
+ #ifdef HGC1280_DEBUG
+ 		ErrorF("r/w-val=%d, ",val);
+ #endif
+ 		found = (val==HGC_PROBE_VAL_READ);
+ 		/* this register can't be set, depends on other registers */
+ 		HGC_SEC_GET_REG(HGC_PROBE_REG_FIX,&val);
+ #ifdef HGC1280_DEBUG
+ 		ErrorF("fix-val1=%d, ",val);
+ #endif
+ 		found = found && (val==HGC_PROBE_VAL_FIX1);
+ 		HGC_SEC_SET_REG(HGC_PROBE_REG_RW,HGC_PROBE_VAL_RESET);
+ 		HGC_SEC_GET_REG(HGC_PROBE_REG_FIX,&val);
+ #ifdef HGC1280_DEBUG
+ 		ErrorF("fix-val2=%d\n",val);
+ #endif
+ 		found = found && (val==HGC_PROBE_VAL_FIX2);
+ 		if (found) {
+ 			HGC_Primary=FALSE;
+ 			ErrorF("%s %s: %s found on secondary address\n",
+ 				XCONFIG_PROBED, bdm2InfoRec.name,
+ 				bdm2InfoRec.chipset);
+ 		} else {
+ #ifdef HGC1280_DEBUG
  			ErrorF("==> not found\n");
+ #endif
  			bdm2InfoRec.chipset = "\0";
  		}
! 	    }
! 	} /* if ( !(cnt>MIN_COUNT) || !found ) */
  	if ( !(cnt>MIN_COUNT) || !found ) {
  	/* there is no HGC-1280 card */
  		HGC1280EnterLeave(LEAVE);
***************
*** 229,238 ****
--- 324,343 ----
  		return(FALSE);
  	}
    } /* else (bdm2InfoRec.chipset) -- bdm2InfoRec.chipset is already set */
+ 
+   /* The following is done for both probed and preset chipset */
+ 
    if (!bdm2InfoRec.videoRam) {
  	/* videoram not given in Xconfig */
  	bdm2InfoRec.videoRam=192;
    }
+   if (!HGC_Primary) {
+ 	/* Fill in consts and functions for secondary I/O / Mem Base */
+ 	HGC1280.ChipMapBase=HGC_SEC_MAP_BASE;
+ 	HGC1280.ChipSetRead=HGC1280sSetRead;
+ 	HGC1280.ChipSetWrite=HGC1280sSetWrite;
+ 	HGC1280.ChipSetReadWrite=HGC1280sSetReadWrite;
+   }
    /* We do 'virtual' handling here as it is highly chipset specific */
    /* Screen size (pixels) is fixed, virtual size can be larger up to
     * ChipMaxVirtualX and ChipMaxVirtualY */
***************
*** 281,286 ****
--- 386,395 ----
  			bdm2InfoRec.virtualX);
  	}
     }
+ 
+    /* Initialize option flags allowed for this driver */
+    OFLG_SET(OPTION_SECONDARY, &HGC1280.ChipOptionFlags);
+ 
     /* Must return real display size */
     /* hardcoded in HGC1280 */
     return(TRUE);
***************
*** 310,324 ****
  HGC1280Init(mode)
       DisplayModePtr mode;
  {
! /* this is a r/w copy of the initial graph mode */
! static hgc1280Ptr hgcInitVideoMode = NULL;
! 
! if (!hgcInitVideoMode)
! 	hgcInitVideoMode = (hgc1280Ptr)Xalloc(sizeof(hgc1280Rec));
! /* memcpy(dest,source,size) */
! memcpy((void *)hgcInitVideoMode, (void *)hgcRegsGraf1280x1024,
!        sizeof(hgc1280Rec));
! return((void *)hgcInitVideoMode);
  }
  
  /*
--- 419,425 ----
  HGC1280Init(mode)
       DisplayModePtr mode;
  {
! return((void *)HGC_Graphmode);
  }
  
  /*
***************
*** 328,345 ****
  
  void *
  HGC1280Save(save)
!      hgc1280Ptr save;
  {
! unsigned char i, val;
! 
! if (save==NULL)
! 	save=(hgc1280Ptr)Xalloc(sizeof(hgc1280Rec));
! for (i = 0; i < HGC_NUM_REGS; i++) {
! 	HGC_GET_REG(i,&val);
! 	save->reg[i] = val;
  }
- return((void *)save);
- }
  
  /*
   * HGC1280Restore --
--- 429,438 ----
  
  void *
  HGC1280Save(save)
!      int save;
  {
! return((void *)HGC_Current_mode);
  }
  
  /*
   * HGC1280Restore --
***************
*** 348,362 ****
  
  void
  HGC1280Restore(restore)
!      hgc1280Ptr restore;
  {
    unsigned char i;
!   if (restore!=NULL) /* better be shure */ {
! 	for (i = 0; i < HGC_NUM_REGS; i++) {
! 		HGC_SET_REG(i,restore->reg[i]);
! 	}
    }
-   else ErrorF("Warning: HGC1280Restore called with arg==NULL\n");
  }
  
  /*
--- 441,475 ----
  
  void
  HGC1280Restore(restore)
!      int restore;
  {
    unsigned char i;
!   if (HGC_Primary) {
! 	if (restore==HGC_Textmode) {
! 		for (i = 0; i < HGC_NUM_REGS; i++) {
! 			HGC_PRIM_SET_REG(i,hgcRegsText[i]);
! 		}
! 		HGC_Current_mode = HGC_Textmode;
! 	} else if (restore==HGC_Graphmode) {
! 		for (i = 0; i < HGC_NUM_REGS; i++) {
! 			HGC_PRIM_SET_REG(i,hgcRegsGraf1280x1024[i]);
! 		}
! 		HGC_Current_mode = HGC_Graphmode;
! 	} else ErrorF("Warning: HGC1280Restore called with invalid arg.\n");
!   } else {
!   /* secondary */ 
! 	if (restore==HGC_Textmode) {
! 		for (i = 0; i < HGC_NUM_REGS; i++) {
! 			HGC_SEC_SET_REG(i,hgcRegsText[i]);
! 		}
! 		HGC_Current_mode = HGC_Textmode;
! 	} else if (restore==HGC_Graphmode) {
! 		for (i = 0; i < HGC_NUM_REGS; i++) {
! 			HGC_SEC_SET_REG(i,hgcRegsGraf1280x1024[i]);
! 		}
! 		HGC_Current_mode = HGC_Graphmode;
! 	} else ErrorF("Warning: HGC1280Restore called with invalid arg.\n");
    }
  }
  
  /*
***************
*** 376,386 ****
  	 * "begin [end] of display within scanline" to middle of the screen
  	 */
  	if (on) { /* Grrr! SaveScreen(on=TRUE) means turn ScreenSaver off */
! 		HGC_SET_REG(HGC_REG_LEFT_BORDER,138);
! 		HGC_SET_REG(HGC_REG_RIGHT_BORDER,90);
  	} else {
! 		HGC_SET_REG(HGC_REG_LEFT_BORDER,170);
! 		HGC_SET_REG(HGC_REG_RIGHT_BORDER,50);
  	}
  } /* if we are not on the active VT, don't do anything - the screen
     * will be visible as soon as we switch back anyway (?) */
--- 489,509 ----
  	 * "begin [end] of display within scanline" to middle of the screen
  	 */
  	if (on) { /* Grrr! SaveScreen(on=TRUE) means turn ScreenSaver off */
! 		if (HGC_Primary) {
! 			HGC_PRIM_SET_REG(HGC_REG_LEFT_BORDER,138);
! 			HGC_PRIM_SET_REG(HGC_REG_RIGHT_BORDER,90);
! 		} else {
! 			HGC_SEC_SET_REG(HGC_REG_LEFT_BORDER,138);
! 			HGC_SEC_SET_REG(HGC_REG_RIGHT_BORDER,90);
! 		}
  	} else {
! 		if (HGC_Primary) {
! 			HGC_PRIM_SET_REG(HGC_REG_LEFT_BORDER,170);
! 			HGC_PRIM_SET_REG(HGC_REG_RIGHT_BORDER,50);
! 		} else {
! 			HGC_SEC_SET_REG(HGC_REG_LEFT_BORDER,170);
! 			HGC_SEC_SET_REG(HGC_REG_RIGHT_BORDER,50);
! 		}
  	}
  } /* if we are not on the active VT, don't do anything - the screen
     * will be visible as soon as we switch back anyway (?) */
***************
*** 412,416 ****
  	/* left side */
  	val=16-(x>>4);
  oldx=x;
! HGC_SET_REG(HGC_REG_SHIFT_DISPLAY,val);
  }
--- 535,543 ----
  	/* left side */
  	val=16-(x>>4);
  oldx=x;
! if (HGC_Primary) {
! 	HGC_PRIM_SET_REG(HGC_REG_SHIFT_DISPLAY,val);
! } else {
! 	HGC_SEC_SET_REG(HGC_REG_SHIFT_DISPLAY,val);
! }
  }
diff -c mit/server/ddx/x386/bdm2/drivers/sigma/sigmaHW.h:2.1 mit/server/ddx/x386/bdm2/drivers/sigma/sigmaHW.h:2.2
*** mit/server/ddx/x386/bdm2/drivers/sigma/sigmaHW.h:2.1	Fri Mar 11 23:38:37 1994
--- mit/server/ddx/x386/bdm2/drivers/sigma/sigmaHW.h	Fri Mar 11 23:38:37 1994
***************
*** 10,29 ****
  
  /* Many thanks to Rich Murphey (rich@rice.edu) who sent me the docs */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmaHW.h,v 2.1 1993/09/10 08:11:45 dawes Exp $ */
  
  #define C_STYLE_HEX_CONSTANTS
  #include "sigmaPorts.h"
  
  /* Memory Base Address */
! /* Valid choices for bdm2 are 0xC0000L, 0xD0000L and 0xE0000L */
! /* This is the only place to change it! */
! #define SIGMA_MEM_BASE            (0xD0000L)
! 
! #define SIGMA_MEM_BASE_BIT16	((SIGMA_MEM_BASE & 0x10000L) ? 1 : 0)
! #define SIGMA_MEM_BASE_BIT17	((SIGMA_MEM_BASE & 0x20000L) ? 1 : 0)
! #define SIGMA_MEM_BASE_BIT18	((SIGMA_MEM_BASE & 0x40000L) ? 1 : 0)
  
  /* Sigma LaserView [PLUS] has its video mem 'high address aligned',
   * the first line is line 848. Unfortunately, this is not on a bank boundary.
   * Following trick to cope with this:
--- 10,36 ----
  
  /* Many thanks to Rich Murphey (rich@rice.edu) who sent me the docs */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmaHW.h,v 2.2 1993/12/01 12:37:26 dawes Exp $ */
  
  #define C_STYLE_HEX_CONSTANTS
  #include "sigmaPorts.h"
  
  /* Memory Base Address */
! /* According to the docs, this can be anywhere (on a 64k boundary)
!  * in the second half MB, but show me the PC running *N*X where
!  * 0x8000, 0x9000 or 0xF0000 is available!
!  * On Systems without VGA, 0xA0000, 0xB0000 and 0xC0000 is available */
! /* So: valid choices for bdm2 are 0x{ABCDE}0000L */
! /* 0xE0000 is the default, other values are selected in Xconfig
!  * with ' membase "xxxx" ' */
! #define SIGMA_DEF_MEM_BASE	(0xE0000L)
  
+ #if 0
+ #define SIGMA_DEF_MEM_BASE_BIT16    ((SIGMA_DEF_MEM_BASE & 0x10000L) ? 1 : 0)
+ #define SIGMA_DEF_MEM_BASE_BIT17    ((SIGMA_DEF_MEM_BASE & 0x20000L) ? 1 : 0)
+ #define SIGMA_DEF_MEM_BASE_BIT18    ((SIGMA_DEF_MEM_BASE & 0x40000L) ? 1 : 0)
+ #endif
+ 
  /* Sigma LaserView [PLUS] has its video mem 'high address aligned',
   * the first line is line 848. Unfortunately, this is not on a bank boundary.
   * Following trick to cope with this:
***************
*** 35,41 ****
  
  #define SIGMA_BANK_SIZE		(0x4000L)	/* 16k */
  
! #define SIGMA_MAP_BASE		(SIGMA_MEM_BASE)
  
  #define SIGMA_MAP_SIZE		(4*SIGMA_BANK_SIZE)
  
--- 42,48 ----
  
  #define SIGMA_BANK_SIZE		(0x4000L)	/* 16k */
  
! #define SIGMA_DEF_MAP_BASE	(SIGMA_DEF_MEM_BASE)
  
  #define SIGMA_MAP_SIZE		(4*SIGMA_BANK_SIZE)
  
***************
*** 47,55 ****
   */
  #define SIGMA_Y_GAP		(0x1000L)	/* 4k */
  
  #define SIGMA_MEM_BASE_BANK1	(SIGMA_Y_GAP + SIGMA_X_GAP)
  #define SIGMA_MEM_BASE_BANK2	(2*SIGMA_BANK_SIZE+SIGMA_Y_GAP+SIGMA_X_GAP)
- 
  #define SIGMA_BANK1_BOTTOM	(SIGMA_MEM_BASE_BANK1)
  #define SIGMA_BANK1_TOP		(SIGMA_BANK1_BOTTOM+SIGMA_BANK_SIZE)
  #define SIGMA_BANK2_BOTTOM	(SIGMA_MEM_BASE_BANK2)
--- 54,62 ----
   */
  #define SIGMA_Y_GAP		(0x1000L)	/* 4k */
  
+ /* rel. to SIGMA_MAP_BASE */
  #define SIGMA_MEM_BASE_BANK1	(SIGMA_Y_GAP + SIGMA_X_GAP)
  #define SIGMA_MEM_BASE_BANK2	(2*SIGMA_BANK_SIZE+SIGMA_Y_GAP+SIGMA_X_GAP)
  #define SIGMA_BANK1_BOTTOM	(SIGMA_MEM_BASE_BANK1)
  #define SIGMA_BANK1_TOP		(SIGMA_BANK1_BOTTOM+SIGMA_BANK_SIZE)
  #define SIGMA_BANK2_BOTTOM	(SIGMA_MEM_BASE_BANK2)
***************
*** 64,78 ****
  
  #define SIGMA_SCAN_LINE_WIDTH	(2048)
  
! #if 0
! 
! #define Y_Coord_to_Segment(Y)   ((((Y) + 848) >> 6) | 0x80)
! 
! #define Y_to_line_offset(Y) (((Y) + 848) % 64)
! #define XY_to_window_offset(X,Y) \
!   ((Y_to_line_offset(Y) << 8) \
!    + (((X) + 384) >> 3))
! #define XYWindow_to_addr(X,Y,Window) \
!   (XY_to_window_offset(X,Y) + ((Window) << 14))
! 
! #endif
--- 71,75 ----
  
  #define SIGMA_SCAN_LINE_WIDTH	(2048)
  
! #define sigma_Textmode		(1409)
! #define sigma_Graphmode		(1410)
diff -c mit/server/ddx/x386/bdm2/drivers/sigma/sigmaPorts.h:2.1 mit/server/ddx/x386/bdm2/drivers/sigma/sigmaPorts.h:2.2
*** mit/server/ddx/x386/bdm2/drivers/sigma/sigmaPorts.h:2.1	Fri Mar 11 23:38:37 1994
--- mit/server/ddx/x386/bdm2/drivers/sigma/sigmaPorts.h	Fri Mar 11 23:38:37 1994
***************
*** 10,16 ****
  
  /* Many thanks to Rich Murphey (rich@rice.edu) who sent me the docs */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmaPorts.h,v 2.1 1993/09/10 08:11:46 dawes Exp $ */
  
  /*
   * Name   r/w I/O  Bit Reset Description
--- 10,16 ----
  
  /* Many thanks to Rich Murphey (rich@rice.edu) who sent me the docs */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmaPorts.h,v 2.2 1993/12/01 12:37:27 dawes Exp $ */
  
  /*
   * Name   r/w I/O  Bit Reset Description
***************
*** 39,76 ****
   *                           Black Background
   */
  
! #if defined(ACK_ASSEMBLER) || defined(C_STYLE_HEX_CONSTANTS)
! #define SLV_EN1    0x0249
! #define SLV_W16    0x4249
! #define SLV_W17    0x8249
! #define SLV_W18    0xC249
! #define SLV_BLANK  0x0649
! #define SLV_ZOOM   0x4649
! #define SLV_GR0    0x8649
! #define SLV_GR1    0xC649
! #define SLV_BANK0  0x0248
! #define SLV_BANK1  0x4248
! #define SLV_BANK2  0x8248
! #define SLV_BANK3  0xC248
! #define SLV_HIRES  0x0A48
! #define SLV_MONOEN 0x0A48
! #define SLV_BOLD   0x8A48
! #define SLV_WOB    0x8A48
! #else
! #define SLV_EN1    $0x0249
! #define SLV_W16    $0x4249
! #define SLV_W17    $0x8249
! #define SLV_W18    $0xC249
! #define SLV_BLANK  $0x0649
! #define SLV_ZOOM   $0x4649
! #define SLV_GR0    $0x8649
! #define SLV_GR1    $0xC649
! #define SLV_BANK0  $0x0248
! #define SLV_BANK1  $0x4248
! #define SLV_BANK2  $0x8248
! #define SLV_BANK3  $0xC248
! #define SLV_HIRES  $0x0A48
! #define SLV_MONOEN $0x0A48
! #define SLV_BOLD   $0x8A48
! #define SLV_WOB    $0x8A48
  #endif
--- 39,62 ----
   *                           Black Background
   */
  
! #if defined(C_STYLE_HEX_CONSTANTS)
! #undef CONST
! #define CONST(a)	(a)
  #endif
+ 
+ #define SLV_EN1    CONST(0x0249)
+ #define SLV_W16    CONST(0x4249)
+ #define SLV_W17    CONST(0x8249)
+ #define SLV_W18    CONST(0xC249)
+ #define SLV_BLANK  CONST(0x0649)
+ #define SLV_ZOOM   CONST(0x4649)
+ #define SLV_GR0    CONST(0x8649)
+ #define SLV_GR1    CONST(0xC649)
+ #define SLV_BANK0  CONST(0x0248)
+ #define SLV_BANK1  CONST(0x4248)
+ #define SLV_BANK2  CONST(0x8248)
+ #define SLV_BANK3  CONST(0xC248)
+ #define SLV_HIRES  CONST(0x0A48)
+ #define SLV_MONOEN CONST(0x0A48)
+ #define SLV_BOLD   CONST(0x8A48)
+ #define SLV_WOB    CONST(0x8A48)
diff -c mit/server/ddx/x386/bdm2/drivers/sigma/sigmabank.s:2.1 mit/server/ddx/x386/bdm2/drivers/sigma/sigmabank.s:2.2
*** mit/server/ddx/x386/bdm2/drivers/sigma/sigmabank.s:2.1	Fri Mar 11 23:38:38 1994
--- mit/server/ddx/x386/bdm2/drivers/sigma/sigmabank.s	Fri Mar 11 23:38:38 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmabank.s,v 2.1 1993/09/10 08:11:47 dawes Exp $ */
  
  /*
   * These are here the very lowlevel bankswitching routines.
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmabank.s,v 2.2 1993/12/01 12:37:28 dawes Exp $ */
  
  /*
   * These are here the very lowlevel bankswitching routines.
***************
*** 57,63 ****
  	/* Add 13 */
  	ADD_L	(CONST(13),EAX)
  	/* Set bit 7 */
! 	AND_L	(CONST(0x80),EAX)
  	/* Out byte */
  	MOV_L	(SLV_BANK0,EDX)
  	OUT_B
--- 57,63 ----
  	/* Add 13 */
  	ADD_L	(CONST(13),EAX)
  	/* Set bit 7 */
! 	OR_L	(CONST(0x80),EAX)
  	/* Out byte */
  	MOV_L	(SLV_BANK0,EDX)
  	OUT_B
***************
*** 75,81 ****
  	/* Add 13 */
  	ADD_L	(CONST(13),EAX)
  	/* Set bit 7 */
! 	AND_L	(CONST(0x80),EAX)
  	/* Out byte */
  	MOV_L	(SLV_BANK2,EDX)
  	OUT_B
--- 75,81 ----
  	/* Add 13 */
  	ADD_L	(CONST(13),EAX)
  	/* Set bit 7 */
! 	OR_L	(CONST(0x80),EAX)
  	/* Out byte */
  	MOV_L	(SLV_BANK2,EDX)
  	OUT_B
diff -c mit/server/ddx/x386/bdm2/drivers/sigma/sigmadriv.c:2.2 mit/server/ddx/x386/bdm2/drivers/sigma/sigmadriv.c:2.3
*** mit/server/ddx/x386/bdm2/drivers/sigma/sigmadriv.c:2.2	Fri Mar 11 23:38:38 1994
--- mit/server/ddx/x386/bdm2/drivers/sigma/sigmadriv.c	Fri Mar 11 23:38:38 1994
***************
*** 14,20 ****
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmadriv.c,v 2.2 1993/10/02 09:50:52 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 14,20 ----
   * see bdm2/COPYRIGHT for copyright and disclaimers.
   */
  
! /* $XFree86: mit/server/ddx/x386/bdm2/drivers/sigma/sigmadriv.c,v 2.3 1993/12/01 12:37:29 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 25,54 ****
  #include "x386.h"
  #include "x386Priv.h"
  #include "xf86_OSlib.h"
  #include "bdm.h"
  #include "sigmaHW.h"
  
! typedef struct {
!   unsigned char en1, w16, w17, w18, blank, zoom, gr0, gr1,
! 		bank0, bank1, bank2, bank3, hires;
!   } sigmaRec, *sigmaPtr;
! 
! sigmaRec sigmaRegsGraf1664x1152 = {
! 	/* en1 */	0x80,
! 	/* w16 */	((SIGMA_MEM_BASE_BIT16) ? 0 : 0x80),
! 	/* w17 */	((SIGMA_MEM_BASE_BIT17) ? 0 : 0x80),
! 	/* w18 */	((SIGMA_MEM_BASE_BIT18) ? 0 : 0x80),
! 	/* blank */	0x80,
! 	/* zoom */	0x80,
! 	/* gr0 */	0x80,
! 	/* gr1 */	0x80,
! 	/* Don't think the bank regs are really needed, but it certainly doesn't hurt */
! 	/* bank0 */	0,
! 	/* bank1 */	0,
! 	/* bank2 */	0,
! 	/* bank3 */	0,
! 	/* hires */	0x80
! };
  
  /*
   * Define the SIGMA I/O Ports
--- 25,36 ----
  #include "x386.h"
  #include "x386Priv.h"
  #include "xf86_OSlib.h"
+ #include "xf86_Config.h"
  #include "bdm.h"
  #include "sigmaHW.h"
  
! int sigma_Current_mode = sigma_Textmode;
! int sigmaMemBase = SIGMA_DEF_MEM_BASE;
  
  /*
   * Define the SIGMA I/O Ports
***************
*** 59,64 ****
--- 41,49 ----
  			SLV_HIRES /* = MONOEN */, SLV_BOLD /* = WOB */ };
  int Num_SIGMA_IOPorts = (sizeof(SIGMA_IOPorts)/sizeof(SIGMA_IOPorts[0]));
  
+ volatile int delay_dummy=0;
+ #define SIGMA_DELAY	{ delay_dummy++; }
+ 
  char *	SIGMAIdent();
  Bool	SIGMAProbe();
  void	SIGMAEnterLeave();
***************
*** 119,124 ****
--- 104,110 ----
    int ChipVDisplay;
    /* In case Scan Line in mfb is longer than HDisplay */
    int ChipScanLineWidth;
+   OFlagSet ChipOptionFlags;
  } bdmVideoChipRec, *bdmVideoChipPtr;
  #endif /* 0 */
  
***************
*** 140,146 ****
    (void *)SIGMA_BANK1_TOP,	/* ReadTop */
    (void *)SIGMA_BANK2_BOTTOM,	/* WriteBottom */
    (void *)SIGMA_BANK2_TOP,	/* WriteTop */
!   SIGMA_MAP_BASE,		/* MapBase */
    SIGMA_MAP_SIZE,		/* MapSize */
    SIGMA_SEGMENT_SIZE,		/* SegmentSize */
    SIGMA_SEGMENT_SHIFT,		/* SegmentShift */
--- 126,132 ----
    (void *)SIGMA_BANK1_TOP,	/* ReadTop */
    (void *)SIGMA_BANK2_BOTTOM,	/* WriteBottom */
    (void *)SIGMA_BANK2_TOP,	/* WriteTop */
!   SIGMA_DEF_MAP_BASE,		/* MapBase */
    SIGMA_MAP_SIZE,		/* MapSize */
    SIGMA_SEGMENT_SIZE,		/* SegmentSize */
    SIGMA_SEGMENT_SHIFT,		/* SegmentShift */
***************
*** 149,154 ****
--- 135,141 ----
    SIGMA_HDISPLAY,		/* HDisplay */
    SIGMA_VDISPLAY,		/* VDisplay */
    SIGMA_SCAN_LINE_WIDTH,	/* ScanLineWidth */
+   {0,},
  };
  
  /*
***************
*** 207,226 ****
  	/* Test if ZOOM bit (bit 7 on extended port 0x4649) is r/w */
  	/* save it first */
  	zoom_save = inb(SLV_ZOOM);
  	outb(SLV_ZOOM,0);
! 	found=(inb(SLV_ZOOM)==0);
  	outb(SLV_ZOOM,0x80);
  	found=found && ((inb(SLV_ZOOM)&0x80)==0x80);
  	/* write back */
  	if (found)
! 		outb(SLV_ZOOM, zoom_save);
  
  	/* There seems to be no easy way to tell if it is an PLUS or not
  	 * (apart perhaps from writing to both planes) */
  	if (found) {
  		bdm2InfoRec.chipset = SIGMAIdent(0);
! 		ErrorF("%s: %s detected\n", bdm2InfoRec.name,
! 				bdm2InfoRec.chipset);
  	} else {
  	/* there is no Sigma L-View card */
  		SIGMAEnterLeave(LEAVE);
--- 194,221 ----
  	/* Test if ZOOM bit (bit 7 on extended port 0x4649) is r/w */
  	/* save it first */
  	zoom_save = inb(SLV_ZOOM);
+ 	SIGMA_DELAY;
  	outb(SLV_ZOOM,0);
! 	SIGMA_DELAY;
! 	found=((inb(SLV_ZOOM)&0x80)==0);
! 	SIGMA_DELAY;
  	outb(SLV_ZOOM,0x80);
+ 	SIGMA_DELAY;
  	found=found && ((inb(SLV_ZOOM)&0x80)==0x80);
+ 	SIGMA_DELAY;
  	/* write back */
  	if (found)
! 		outb(SLV_ZOOM, (zoom_save & 0x80));
! 					/* write only 0x00 or 0x80 */
  
  	/* There seems to be no easy way to tell if it is an PLUS or not
  	 * (apart perhaps from writing to both planes) */
  	if (found) {
  		bdm2InfoRec.chipset = SIGMAIdent(0);
! 		ErrorF("%s %s: %s detected\n",
! 			XCONFIG_PROBED,
! 			bdm2InfoRec.name,
! 			bdm2InfoRec.chipset);
  	} else {
  	/* there is no Sigma L-View card */
  		SIGMAEnterLeave(LEAVE);
***************
*** 227,236 ****
--- 222,271 ----
  		return(FALSE);
  	}
    } /* else (bdm2InfoRec.chipset) -- bdm2InfoRec.chipset is already set */
+ 
+ /* The following is done for both probed and preset chipset */
+ 
    if (!bdm2InfoRec.videoRam) {
  	/* videoram not given in Xconfig */
  	bdm2InfoRec.videoRam=256;
    }
+   if (bdm2InfoRec.MemBase!=0) {
+ 	if ( (bdm2InfoRec.MemBase!=0xA0000L) &&
+ 		(bdm2InfoRec.MemBase!=0xB0000L) &&
+ 		(bdm2InfoRec.MemBase!=0xC0000L) &&
+ 		(bdm2InfoRec.MemBase!=0xD0000L) &&
+ 		(bdm2InfoRec.MemBase!=0xE0000L) ) {
+ 	    /* Invalid MemBase */
+ 	    ErrorF("%s %s: %s: Invalid MemBase 0x%x (must be 0x{ABCDE}0000),\n\t\tusing default\n",
+ 		XCONFIG_GIVEN,
+ 		bdm2InfoRec.name,
+ 		bdm2InfoRec.chipset,
+ 		sigmaMemBase);
+ 	    sigmaMemBase=SIGMA_DEF_MEM_BASE;
+ 	    ErrorF("%s %s: %s using mem base 0x%x\n",
+ 		XCONFIG_PROBED,
+ 		bdm2InfoRec.name,
+ 		bdm2InfoRec.chipset,
+ 		sigmaMemBase);
+ 	} else {
+ 	    /* Valid MemBase */
+ 	    sigmaMemBase=bdm2InfoRec.MemBase;
+ 	    SIGMA.ChipMapBase=sigmaMemBase;
+ 	    ErrorF("%s %s: %s using mem base 0x%x\n",
+ 		XCONFIG_GIVEN,
+ 		bdm2InfoRec.name,
+ 		bdm2InfoRec.chipset,
+ 		sigmaMemBase);
+ 	}
+   } else {
+ 	/* Default MemBase */
+ 	sigmaMemBase=SIGMA_DEF_MEM_BASE;
+ 	ErrorF("%s %s: %s using mem base 0x%x\n",
+ 		XCONFIG_PROBED,
+ 		bdm2InfoRec.name,
+ 		bdm2InfoRec.chipset,
+ 		sigmaMemBase);
+   }
    /* We do 'virtual' handling here as it is highly chipset specific */
    /* Screen size (pixels) is fixed, virtual size can be larger up to
     * ChipMaxVirtualX and ChipMaxVirtualY */
***************
*** 242,249 ****
     */
     if (!(bdm2InfoRec.virtualX < 0)) {
  	/* virtual set in Xconfig */
! 	ErrorF("%s: %s: Virtual not allowed for Sigma LaserView\n",
! 		       bdm2InfoRec.name, bdm2InfoRec.chipset);
     }
     /* Set virtual to real size */
     bdm2InfoRec.virtualX = SIGMA_HDISPLAY;
--- 277,284 ----
     */
     if (!(bdm2InfoRec.virtualX < 0)) {
  	/* virtual set in Xconfig */
! 	ErrorF("%s %s: %s: Virtual not allowed for this chipset\n",
! 		XCONFIG_PROBED, bdm2InfoRec.name, bdm2InfoRec.chipset);
     }
     /* Set virtual to real size */
     bdm2InfoRec.virtualX = SIGMA_HDISPLAY;
***************
*** 277,291 ****
  SIGMAInit(mode)
       DisplayModePtr mode;
  {
! /* this is a r/w copy of the initial graph mode */
! static sigmaPtr sigmaInitVideoMode = NULL;
! 
! if (!sigmaInitVideoMode)
! 	sigmaInitVideoMode = (sigmaPtr)Xalloc(sizeof(sigmaRec));
! /* memcpy(dest,source,size) */
! memcpy((void *)sigmaInitVideoMode, (void *)&sigmaRegsGraf1664x1152,
!        sizeof(sigmaRec));
! return((void *)sigmaInitVideoMode);
  }
  
  /*
--- 312,318 ----
  SIGMAInit(mode)
       DisplayModePtr mode;
  {
! return((void *)sigma_Graphmode);
  }
  
  /*
***************
*** 295,321 ****
  
  void *
  SIGMASave(save)
!      sigmaPtr save;
  {
! unsigned char i, val;
! 
! if (save==NULL)
! 	save=(sigmaPtr)Xalloc(sizeof(sigmaRec));
! save->en1=inb(SLV_EN1);
! save->w16=inb(SLV_W16);
! save->w17=inb(SLV_W17);
! save->w18=inb(SLV_W18);
! save->blank=inb(SLV_BLANK);
! save->zoom=inb(SLV_ZOOM);
! save->gr0=inb(SLV_GR0);
! save->gr1=inb(SLV_GR1);
! save->bank0=inb(SLV_BANK0);
! save->bank1=inb(SLV_BANK1);
! save->bank2=inb(SLV_BANK2);
! save->bank3=inb(SLV_BANK3);
! save->hires=inb(SLV_HIRES);
! 
! return((void *)save);
  }
  
  /*
--- 322,330 ----
  
  void *
  SIGMASave(save)
!      pointer save;
  {
! return((void *)sigma_Current_mode);
  }
  
  /*
***************
*** 325,359 ****
  
  void
  SIGMARestore(restore)
!      sigmaPtr restore;
  {
!   unsigned char i;
!   if (restore!=NULL) /* better be shure */ {
  	/* Blank the screen to black */
  	outb(SLV_GR0,0);
  	outb(SLV_GR1,0);
  	outb(SLV_BLANK,0);
  	/* Disable adapter memory */
  	outb(SLV_EN1,0);
  
! 	/* Restore original values */
! 	outb(SLV_W16,restore->w16);
! 	outb(SLV_W17,restore->w17);
! 	outb(SLV_W18,restore->w18);
! 	outb(SLV_ZOOM,restore->zoom);
! 	outb(SLV_BANK0,restore->bank0);
! 	outb(SLV_BANK1,restore->bank1);
! 	outb(SLV_BANK2,restore->bank2);
! 	outb(SLV_BANK3,restore->bank3);
! 	outb(SLV_HIRES,restore->hires);
! 	/* Restore screensaver values */
! 	outb(SLV_GR0,restore->gr0);
! 	outb(SLV_GR1,restore->gr1);
! 	outb(SLV_BLANK,restore->blank);
! 	/* Restore enable state (may be disabled) */
! 	outb(SLV_EN1,restore->en1);
!   }
!   else ErrorF("Warning: SIGMARestore called with arg==NULL\n");
  }
  
  /*
--- 334,404 ----
  
  void
  SIGMARestore(restore)
!      pointer restore;
  {
!     if ((int)restore==sigma_Textmode) {
  	/* Blank the screen to black */
  	outb(SLV_GR0,0);
+ 	SIGMA_DELAY;
  	outb(SLV_GR1,0);
+ 	SIGMA_DELAY;
  	outb(SLV_BLANK,0);
+ 	SIGMA_DELAY;
  	/* Disable adapter memory */
  	outb(SLV_EN1,0);
+ 	SIGMA_DELAY;
  
! 	/* deselect hires */
! 	outb(SLV_HIRES,0x0);
! 	SIGMA_DELAY;
! 	/* Unblank the screen */
! 	outb(SLV_GR0,0x80);
! 	SIGMA_DELAY;
! 	outb(SLV_GR1,0x80);
! 	SIGMA_DELAY;
! 	outb(SLV_BLANK,0x80);
! 	SIGMA_DELAY;
! 
! 	sigma_Current_mode=sigma_Textmode;
! 
!     } else if ((int)restore==sigma_Graphmode) {
! 	/* Blank the screen to black */
! 	outb(SLV_GR0,0);
! 	SIGMA_DELAY;
! 	outb(SLV_GR1,0);
! 	SIGMA_DELAY;
! 	outb(SLV_BLANK,0);
! 	SIGMA_DELAY;
! 	/* Disable adapter memory */
! 	outb(SLV_EN1,0);
! 	SIGMA_DELAY;
! 
! 	/* Set page frame */
! 	outb(SLV_W16,((sigmaMemBase & 0x10000L) ? 0 : 0x80));
! 	SIGMA_DELAY;
! 	outb(SLV_W17,((sigmaMemBase & 0x20000L) ? 0 : 0x80));
! 	SIGMA_DELAY;
! 	outb(SLV_W18,((sigmaMemBase & 0x40000L) ? 0 : 0x80));
! 	SIGMA_DELAY;
! 	outb(SLV_ZOOM,0x80);
! 	SIGMA_DELAY;
! 
! 	/* */
! 	outb(SLV_HIRES,0x80);
! 	SIGMA_DELAY;
! 	/* Unblank the screen */
! 	outb(SLV_GR0,0x80);
! 	SIGMA_DELAY;
! 	outb(SLV_GR1,0x80);
! 	SIGMA_DELAY;
! 	outb(SLV_BLANK,0x80);
! 	SIGMA_DELAY;
! 	/* Set enable state */
! 	outb(SLV_EN1,0x80);
! 
! 	sigma_Current_mode=sigma_Graphmode;
! 
!     } else ErrorF("Warning: SIGMARestore called with invalid arg.\n");
  }
  
  /*
***************
*** 372,383 ****
--- 417,432 ----
  	if (on) { /* Grrr! SaveScreen(on=TRUE) means turn ScreenSaver off */
  		/* Unblank to 4 gray levels */
  		outb(SLV_BLANK,0x80);
+ 		SIGMA_DELAY;
  		outb(SLV_GR0,0x80);
+ 		SIGMA_DELAY;
  		outb(SLV_GR1,0x80);
  	} else {
  		/* Blank to black */
  		outb(SLV_BLANK,0);
+ 		SIGMA_DELAY;
  		outb(SLV_GR0,0);
+ 		SIGMA_DELAY;
  		outb(SLV_GR1,0);
  	}
  } /* if we are not on the active VT, don't do anything - the screen
diff -c /dev/null mit/server/ddx/x386/bdm2/drivers/visa/Imakefile:2.0
*** /dev/null	Fri Mar 11 23:38:41 1994
--- mit/server/ddx/x386/bdm2/drivers/visa/Imakefile	Fri Mar 11 23:38:42 1994
***************
*** 0 ****
--- 1,28 ----
+ XCOMM $XFree86: mit/server/ddx/x386/bdm2/drivers/visa/Imakefile,v 2.0 1993/12/01 12:37:36 dawes Exp $
+ XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:59:40 gildea Exp $
+ #include <Server.tmpl>
+ 
+ SRCS = visadriv.c visabank.s
+ 
+ OBJS = visadriv.o visabank.o
+ 
+ #if X386LinkKit
+ INCLUDES = -I. -I../../../include -I../..
+ #else
+ INCLUDES = -I. -I../../../common -I../../../os-support -I../../bdm \
+            -I$(SERVERSRC)/include -I$(INCLUDESRC)
+ #endif
+ 
+ NormalLibraryObjectRule()
+ NormalAsmObjectRule()
+ 
+ NormalRelocatableTarget(visa, $(OBJS))
+ 
+ InstallLinkKitNonExecFile(Imakefile,$(LINKKITDIR)/drivers/bdm2/visa)
+ InstallLinkKitNonExecFile(visaHW.h,$(LINKKITDIR)/drivers/bdm2/visa)
+ InstallLinkKitNonExecFile(visaPorts.h,$(LINKKITDIR)/drivers/bdm2/visa)
+ InstallLinkKitNonExecFile(visabank.s,$(LINKKITDIR)/drivers/bdm2/visa)
+ InstallLinkKitNonExecFile(visadriv.c,$(LINKKITDIR)/drivers/bdm2/visa)
+ 
+ DependTarget()
+ 
diff -c /dev/null mit/server/ddx/x386/bdm2/drivers/visa/visaHW.h:2.0
*** /dev/null	Fri Mar 11 23:38:42 1994
--- mit/server/ddx/x386/bdm2/drivers/visa/visaHW.h	Fri Mar 11 23:38:42 1994
***************
*** 0 ****
--- 1,44 ----
+ /*
+  * BDM2: Banked dumb monochrome driver
+  * Pascal Haible 10/93, haible@izfm.uni-stuttgart.de
+  *
+  * bdm2/driver/visa/visaHW.c
+  * Register definitions for visa6845
+  *
+  * see bdm2/COPYRIGHT for copyright and disclaimers.
+  */
+ 
+ /* Thanks to Christian (cm@htu.tuwien.ac.at) who did the first port */
+ 
+ /* $XFree86: mit/server/ddx/x386/bdm2/drivers/visa/visaHW.h,v 2.0 1993/12/01 12:37:38 dawes Exp $ */
+ 
+ #define C_STYLE_HEX_CONSTANTS
+ #include "visaPorts.h"
+ 
+ /* Memory Base Address */
+ #define VISA_MEM_BASE            (0xB0000L)
+ 
+ #define VISA_BANK_SIZE		(0x10000L)	/* 64k */
+ 
+ #define VISA_MAP_BASE		(VISA_MEM_BASE)
+ 
+ #define VISA_MAP_SIZE		(VISA_BANK_SIZE)
+ 
+ #define VISA_MEM_BASE_BANK1	(0)
+ #define VISA_MEM_BASE_BANK2	(0)		/* unused */
+ 
+ /* rel. to VISA_MAP_BASE */
+ #define VISA_BANK1_BOTTOM	(VISA_MEM_BASE_BANK1)
+ #define VISA_BANK1_TOP		(VISA_BANK1_BOTTOM+VISA_BANK_SIZE)
+ /* unused */
+ #define VISA_BANK2_BOTTOM	(VISA_MEM_BASE_BANK2)
+ #define VISA_BANK2_TOP		(VISA_BANK2_BOTTOM+VISA_BANK_SIZE)
+ 
+ #define VISA_SEGMENT_SIZE	(VISA_BANK_SIZE)
+ #define VISA_SEGMENT_SHIFT	(16)		/* 64k */
+ #define VISA_SEGMENT_MASK	(0xFFFFL)
+ 
+ #define VISA_HDISPLAY		(1280)
+ #define VISA_VDISPLAY		(1024)
+ 
+ #define VISA_SCAN_LINE_WIDTH	(2048)
diff -c /dev/null mit/server/ddx/x386/bdm2/drivers/visa/visaPorts.h:2.0
*** /dev/null	Fri Mar 11 23:38:42 1994
--- mit/server/ddx/x386/bdm2/drivers/visa/visaPorts.h	Fri Mar 11 23:38:42 1994
***************
*** 0 ****
--- 1,25 ----
+ /*
+  * BDM2: Banked dumb monochrome driver
+  * Pascal Haible 10/93, haible@izfm.uni-stuttgart.de
+  *
+  * bdm2/driver/sigma/sigmaPorts.h
+  * I/O Port definitions for Sigma L-View and Sigma LaserView PLUS
+  *
+  * see bdm2/COPYRIGHT for copyright and disclaimers.
+  */
+ 
+ /* Thanks to Christian (cm@htu.tuwien.ac.at) who did the first driver */
+ 
+ /* $XFree86: mit/server/ddx/x386/bdm2/drivers/visa/visaPorts.h,v 2.0 1993/12/01 12:37:39 dawes Exp $ */
+ 
+ #if defined(C_STYLE_HEX_CONSTANTS)
+ #undef CONST
+ #define CONST(a)	(a)
+ #endif
+ 
+ #define VISA_INDEX	CONST(0x3B4)
+ #define VISA_DATA	CONST(0x3B5)
+ #define VISA_MODE	CONST(0x3B8)
+ #define VISA_STATUS	CONST(0x3BA)
+ #define VISA_CONFIG	CONST(0x3BF)
+ #define VISA_BANK	CONST(0x3BF)
diff -c /dev/null mit/server/ddx/x386/bdm2/drivers/visa/visabank.s:2.0
*** /dev/null	Fri Mar 11 23:38:43 1994
--- mit/server/ddx/x386/bdm2/drivers/visa/visabank.s	Fri Mar 11 23:38:43 1994
***************
*** 0 ****
--- 1,83 ----
+ /*
+  * BDM2: Banked dumb monochrome driver
+  * Pascal Haible 10/93, haible@izfm.uni-stuttgart.de
+  *
+  * bdm2/driver/visa/visabank.s
+  *
+  * derived from:
+  * hga2/*
+  * Author:  Davor Matic, dmatic@athena.mit.edu
+  * and
+  * vga256/*
+  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+  *
+  * see bdm2/COPYRIGHT for copyright and disclaimers.
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/bdm2/drivers/visa/visabank.s,v 2.0 1993/12/01 12:37:40 dawes Exp $ */
+ 
+ /*
+  * These are here the very lowlevel bankswitching routines.
+  * The segment to switch to is passed via %eax. Only %eax and %edx my be used
+  * without saving the original contents.
+  *
+  * WHY ASSEMBLY LANGUAGE ???
+  *
+  * These routines must be callable by other assembly routines. But I don't
+  * want to have the overhead of pushing and poping the normal stack-frame.
+  */
+ 
+ /* The visa6845 allows the following braindead banking:
+  *             bank banked to  bank banked to
+  *  Bit 6 5 4  B0000-B7FFF     B8000-BFFFF
+  *      0 0 0   0               1
+  *      0 0 1   1               2
+  *      0 1 0   2               3
+  *      0 1 1   3               4
+  *      1 0 0   4               5
+  *      1 0 1   5               6
+  *      1 1 0   6               7
+  *      1 1 1   7               0
+  *
+  * We have to use it as a single 64k bank.
+  * This gives bank(BankNo) as
+  * out(0x3BF,(BankNo<<5)|3)
+  */
+ 
+ #include "assyntax.h"
+ 
+ #include "visaPorts.h"
+ 
+         FILE("visabank.s")
+ 
+         AS_BEGIN
+ 
+         SEG_DATA
+ 
+         SEG_TEXT
+ 
+         ALIGNTEXT4
+         GLOBL   GLNAME(VISASetRead)
+ GLNAME(VISASetRead):
+ 	/* Shift left by 5 */
+ 	SHL_L	(CONST(5),EAX)
+ 	/* Set bit 1 and 0 */
+ 	OR_L	(CONST(3),EAX)
+ 	/* Out byte */
+ 	MOV_L	(VISA_BANK,EDX)
+ 	OUT_B
+         RET
+ 
+         ALIGNTEXT4
+         GLOBL   GLNAME(VISASetWrite)
+         GLOBL   GLNAME(VISASetReadWrite)
+ GLNAME(VISASetWrite):
+ GLNAME(VISASetReadWrite):
+ 	/* Shift left by 5 */
+ 	SHL_L	(CONST(5),EAX)
+ 	/* Set bit 1 and 0 */
+ 	OR_L	(CONST(3),EAX)
+ 	/* Out byte */
+ 	MOV_L	(VISA_BANK,EDX)
+ 	OUT_B
+         RET
diff -c /dev/null mit/server/ddx/x386/bdm2/drivers/visa/visadriv.c:2.0
*** /dev/null	Fri Mar 11 23:38:43 1994
--- mit/server/ddx/x386/bdm2/drivers/visa/visadriv.c	Fri Mar 11 23:38:43 1994
***************
*** 0 ****
--- 1,371 ----
+ /*
+  * BDM2: Banked dumb monochrome driver
+  * Pascal Haible 10/93, haible@izfm.uni-stuttgart.de
+  *
+  * bdm2/driver/visa/visadriv.c
+  *
+  * Parts derived from:
+  * hga2/*
+  * Author:  Davor Matic, dmatic@athena.mit.edu
+  * and
+  * vga256/*
+  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+  *
+  * see bdm2/COPYRIGHT for copyright and disclaimers.
+  */
+ 
+ /* Thanks to Christian (cm@htu.tuwien.ac.at) who did the first driver */
+ 
+ /* $XFree86: mit/server/ddx/x386/bdm2/drivers/visa/visadriv.c,v 2.0 1993/12/01 12:37:41 dawes Exp $ */
+ 
+ #include "X.h"
+ #include "input.h"
+ #include "screenint.h"
+ 
+ #include "compiler.h"
+ 
+ #include "x386.h"
+ #include "x386Priv.h"
+ #include "xf86_OSlib.h"
+ #include "xf86_Config.h"
+ #include "bdm.h"
+ #include "visaHW.h"
+ 
+ typedef struct {
+   unsigned char conf;	/* write only conf register at port 0x3BF */
+   unsigned char mode;	/* write only mode register at port 0x3B8 */
+   unsigned char tbl[16];/* graph. params */
+   } visaRec, *visaPtr;
+ 
+ visaRec visaRegsGraf1280x1024 = {
+ 0x03,	/* conf */
+ 0x0A,	/* mode */
+ { 0x35, 0x50, 0x2E, 0x07, 0x5B, 0x02, 0x57, 0x57,
+   0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
+ };
+ 
+ /*
+  * Since the table of 6845 registers is write only, we need to keep
+  * a local copy of the state here.  The initial state is assumed to
+  * be 160x55 text mode.
+  */
+ visaRec visaRegsActual = {
+ 0x00,
+ 0x00,
+ { 0x61, 0xA0, 0x52, 0x0F, 0x19, 0x06, 0x19, 0x19,
+   0x02, 0x0D, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x00 }
+ };
+ 
+ /*
+  * Define the VISA I/O Ports
+  */
+ unsigned VISA_IOPorts[] = {
+ VISA_INDEX, VISA_DATA, VISA_MODE, VISA_STATUS, VISA_CONFIG /* = VISA_BANK */ };
+ int Num_VISA_IOPorts = (sizeof(VISA_IOPorts)/sizeof(VISA_IOPorts[0]));
+ 
+ volatile int visa_delay_dummy=0;
+ #define VISA_DELAY	{ visa_delay_dummy++; }
+ 
+ char *	VISAIdent();
+ Bool	VISAProbe();
+ void	VISAEnterLeave();
+ void *	VISAInit();
+ void *	VISASave();
+ void	VISARestore();
+ void	VISAAdjust();
+ Bool	VISASaveScreen();
+ void	VISAGetMode();
+ 
+ /* Assembler functions in visabank.s
+  * - to be called by assembler functions only! */
+ extern void VISASetRead();
+ extern void VISASetWrite();
+ extern void VISASetReadWrite();
+ 
+ #if 0
+ /* From bdm.h -- see there, this here might not be up to date */
+ /*
+  * structure for accessing the video chip`s functions
+  *
+  * We are doing a total encapsulation of the driver's functions.
+  * Banking (bdmSetReadWrite(p) etc.) is done in bdmBank.c
+  *   using the chip's function pointed to by
+  *   bmpSetReadWriteFunc(bank) etc.
+  */
+ typedef struct {
+   char * (* ChipIdent)();
+   Bool (* ChipProbe)();
+   void (* ChipEnterLeave)();
+   void * (* ChipInit)();
+   void * (* ChipSave)();
+   void (* ChipRestore)();
+   void (* ChipAdjust)();
+   Bool (* ChipSaveScreen)();
+   void (* ChipGetMode)();
+   /* These are the chip's banking functions:		*/
+   /* they do the real switching to the desired bank	*/
+   /* they 'become' bdmSetReadFunc() etc.		*/
+   void (* ChipSetRead)();
+   void (* ChipSetWrite)();
+   void (* ChipSetReadWrite)();
+   /* Bottom and top of the banking window (rel. to ChipMapBase)	*/
+   /* Note: Top = highest accessable byte + 1			*/
+   void *ChipReadBottom;
+   void *ChipReadTop;
+   void *ChipWriteBottom;
+   void *ChipWriteTop;
+   /* Memory to map      */
+   int ChipMapBase;
+   int ChipMapSize;      /* replaces MEMTOMAP */
+   int ChipSegmentSize;
+   int ChipSegmentShift;
+   int ChipSegmentMask;
+   Bool ChipUse2Banks;
+   /* Display size is given by the driver */
+   int ChipHDisplay;
+   int ChipVDisplay;
+   /* In case Scan Line in mfb is longer than HDisplay */
+   int ChipScanLineWidth;
+   OFlagSet ChipOptionFlags;
+ } bdmVideoChipRec, *bdmVideoChipPtr;
+ #endif /* 0 */
+ 
+ bdmVideoChipRec VISA = {
+   /* Functions */
+   VISAIdent,
+   VISAProbe,
+   VISAEnterLeave,
+   VISAInit,
+   VISASave,
+   VISARestore,
+   VISAAdjust,
+   VISASaveScreen,
+   NoopDDA,			/* VISAGetMode */
+   VISASetRead,
+   VISASetWrite,
+   VISASetReadWrite,
+   (void *)VISA_BANK1_BOTTOM,	/* ReadBottom */
+   (void *)VISA_BANK1_TOP,	/* ReadTop */
+   (void *)VISA_BANK2_BOTTOM,	/* WriteBottom */
+   (void *)VISA_BANK2_TOP,	/* WriteTop */
+   VISA_MAP_BASE,		/* MapBase */
+   VISA_MAP_SIZE,		/* MapSize */
+   VISA_SEGMENT_SIZE,		/* SegmentSize */
+   VISA_SEGMENT_SHIFT,		/* SegmentShift */
+   VISA_SEGMENT_MASK,		/* SegmentMask */
+   FALSE,			/* Use2Banks */
+   VISA_HDISPLAY,		/* HDisplay */
+   VISA_VDISPLAY,		/* VDisplay */
+   VISA_SCAN_LINE_WIDTH,	/* ScanLineWidth */
+   {0,},
+ };
+ 
+ /*
+  * VISAIdent
+  */
+ 
+ char *
+ VISAIdent(n)
+ 	int n;
+ {
+ static char *chipsets[] = {"visa6845"};
+ if (n >= sizeof(chipsets) / sizeof(char *))
+ 	return(NULL);
+ else return(chipsets[n]);
+ }
+ 
+ /*
+  * VISAProbe --
+  *      check whether an VISA based board is installed
+  */
+ 
+ Bool
+ VISAProbe()
+ {
+   /*
+    * Set up I/O ports to be used by this card
+    */
+   xf86ClearIOPortList(bdm2InfoRec.scrnIndex);
+   xf86AddIOPorts(bdm2InfoRec.scrnIndex, Num_VISA_IOPorts, VISA_IOPorts);
+ 
+   if (bdm2InfoRec.chipset) {
+ 	/* Chipset preset */
+ 	if (strcmp(bdm2InfoRec.chipset, VISAIdent(0)))
+ 		/* desired chipset != this one */
+ 		return (FALSE);
+ 	else {
+ 		VISAEnterLeave(ENTER);
+ 		/* go on with videoram etc. below */
+ 	}
+   }
+   else {
+ 	/* do the real probing */
+ /***** This currently detects any herc board *****/
+ #define DSP_VSYNC_MASK  0x80
+ #define DSP_ID_MASK  0x70
+       unsigned char dsp, dsp_old;
+       int i, cnt;
+ 
+       VISAEnterLeave(ENTER);
+       /*
+        * Checks if there is a VISA 6845 based bard in the system.
+        * The following loop tries to see if the Hercules display
+        * status port register is counting vertical syncs (50Hz).
+        */
+       cnt = 0;
+       dsp_old = inb(0x3BA) & DSP_VSYNC_MASK;
+       for (i = 0; i < 0x10000; i++) {
+         dsp = inb(0x3BA) & DSP_VSYNC_MASK;
+         if (dsp != dsp_old) cnt++;
+         dsp_old = dsp;
+       }
+ 
+       /* If there are active sync changes, we found a Hercules board. */
+       if (cnt) {
+ 		bdm2InfoRec.chipset = VISAIdent(0);
+ 		ErrorF("%s %s: %s detected\n",
+ 			XCONFIG_PROBED,
+ 			bdm2InfoRec.name,
+ 			bdm2InfoRec.chipset);
+ 	} else {
+ 	/* there is no VISA 6845 card */
+ 		VISAEnterLeave(LEAVE);
+ 		return(FALSE);
+ 	}
+   } /* else (bdm2InfoRec.chipset) -- bdm2InfoRec.chipset is already set */
+   if (!bdm2InfoRec.videoRam) {
+ 	/* videoram not given in Xconfig */
+ 	bdm2InfoRec.videoRam=256;
+   }
+   /* We do 'virtual' handling here as it is highly chipset specific */
+   /* Screen size (pixels) is fixed, virtual size can be larger up to
+    * ChipMaxVirtualX and ChipMaxVirtualY */
+   /* Real display size is given by VISA_HDISPLAY and VISA_VDISPLAY,
+    * desired virtual size is bdm2InfoRec.virtualX and bdm2InfoRec.virtualY.
+    * Think they can be -1 at this point.
+    * Maximum virtual size as done by the driver is
+    * VISA_MAX_VIRTUAL_X and ..._Y
+    */
+    if (!(bdm2InfoRec.virtualX < 0)) {
+ 	/* virtual set in Xconfig */
+ 	ErrorF("%s %s: %s: Virtual not allowed for this chipset\n",
+ 		XCONFIG_PROBED, bdm2InfoRec.name, bdm2InfoRec.chipset);
+    }
+    /* Set virtual to real size */
+    bdm2InfoRec.virtualX = VISA_HDISPLAY;
+    bdm2InfoRec.virtualY = VISA_VDISPLAY;
+    /* Must return real display size */
+    /* hardcoded in VISA */
+    return(TRUE);
+ }
+ 
+ /*
+  * VISAEnterLeave --
+  *      enable/disable io permissions
+  */
+ 
+ void 
+ VISAEnterLeave(enter)
+      Bool enter;
+ {
+   if (enter)
+ 	xf86EnableIOPorts(bdm2InfoRec.scrnIndex);
+   else
+ 	xf86DisableIOPorts(bdm2InfoRec.scrnIndex);
+ }
+ 
+ /*
+  * VISAInit --
+  *      Handle the initialization of the VISAs registers
+  */
+ 
+ void *
+ VISAInit(mode)
+      DisplayModePtr mode;
+ {
+ /* this is a r/w copy of the initial graph mode */
+ static visaPtr visaInitVideoMode = NULL;
+ 
+ if (!visaInitVideoMode)
+ 	visaInitVideoMode = (visaPtr)Xalloc(sizeof(visaRec));
+ /* memcpy(dest,source,size) */
+ memcpy((void *)visaInitVideoMode, (void *)&visaRegsGraf1280x1024,
+        sizeof(visaRec));
+ return((void *)visaInitVideoMode);
+ }
+ 
+ /*
+  * VISASave --
+  *      save the current video mode
+  */
+ 
+ void *
+ VISASave(save)
+      visaPtr save;
+ {
+ unsigned char i;
+ 
+ if (save==NULL)
+ 	save=(visaPtr)Xalloc(sizeof(visaRec));
+ save->conf=inb(VISA_CONFIG);
+ save->mode=inb(VISA_MODE);
+ /* The table of 6845 registers is write only, we return the local copy */
+ for (i=0; i<16; i++)
+ 	save->tbl[i] = visaRegsActual.tbl[i];
+ return((void *)save);
+ }
+ 
+ /*
+  * VISARestore --
+  *      restore a video mode
+  */
+ 
+ void
+ VISARestore(restore)
+      visaPtr restore;
+ {
+ unsigned char i;
+ if (restore!=NULL) /* better be shure */ {
+ 	outb(VISA_CONFIG, (visaRegsActual.conf = restore->conf));
+ 	outb(VISA_MODE, (visaRegsActual.mode = restore->mode));
+ 	for (i=0; i<16; i++) {
+ 		outb(VISA_INDEX, i);
+ 		outb(VISA_DATA, (visaRegsActual.tbl[i] = restore->tbl[i]));
+ 	}
+ }
+ else ErrorF("Warning: VISARestore called with arg==NULL\n");
+ }
+ 
+ /*
+  * VISASaveScreen();
+  *	Disable the video on the frame buffer (screensaver)
+  */
+ 
+ Bool
+ VISASaveScreen(pScreen,on)
+ 	ScreenPtr pScreen;
+ 	Bool      on;
+ {
+ if (on == SCREEN_SAVER_FORCER)
+ 	SetTimeSinceLastInputEvent();
+ if (x386VTSema) {
+ 	if (on) { /* Grrr! SaveScreen(on=TRUE) means turn ScreenSaver off */
+ 		outb(VISA_MODE, (visaRegsActual.mode |= 0x08)); /* unblank */
+ 	} else {
+ 		outb(VISA_MODE, (visaRegsActual.mode &= 0xF7)); /* blank */
+ 	}
+ } /* if we are not on the active VT, don't do anything - the screen
+    * will be visible as soon as we switch back anyway (?) */
+ return(TRUE);
+ }
+ 
+ /* VISAAdjust --
+  *      adjust the current video frame to display the mousecursor
+  *      (x,y) is the upper left corner to be displayed.
+  *      The VISA 6845 can't pan.
+  */
+ void
+ VISAAdjust(x,y)
+ 	int x, y;
+ {
+ }
diff -c mit/server/ddx/x386/common/Imakefile:2.16 mit/server/ddx/x386/common/Imakefile:2.17
*** mit/server/ddx/x386/common/Imakefile:2.16	Fri Mar 11 23:38:51 1994
--- mit/server/ddx/x386/common/Imakefile	Fri Mar 11 23:38:51 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/common/Imakefile,v 2.16 1993/09/23 15:45:15 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:57:37 gildea Exp $
  #include <Server.tmpl>
  
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/common/Imakefile,v 2.17 1994/02/23 14:17:43 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:57:37 gildea Exp $
  #include <Server.tmpl>
  
***************
*** 5,15 ****
  #if i386Mach
          KBD = x386KbdMach
  #else
! #if i386Bsd
          KBD = xf86_KbdBSD
! #else
          KBD = x386Kbd
! #endif
  #endif
  
  SERVERSRCS = \
--- 5,19 ----
  #if i386Mach
          KBD = x386KbdMach
  #else
! # if i386Bsd
          KBD = xf86_KbdBSD
! # else
! #  ifdef LinuxArchitecture
!         KBD = xf86_KbdLnx
! #  else
          KBD = x386Kbd
! #  endif
! # endif
  #endif
  
  SERVERSRCS = \
diff -c mit/server/ddx/x386/common/XF86_Mach32.c:2.1 mit/server/ddx/x386/common/XF86_Mach32.c:2.3
*** mit/server/ddx/x386/common/XF86_Mach32.c:2.1	Fri Mar 11 23:38:51 1994
--- mit/server/ddx/x386/common/XF86_Mach32.c	Fri Mar 11 23:38:51 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_Mach32.c,v 2.1 1993/10/07 13:55:56 dawes Exp $
   */
  
  #include "X.h"
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_Mach32.c,v 2.3 1994/02/26 05:02:04 dawes Exp $
   */
  
  #include "X.h"
***************
*** 15,23 ****
   * is added for using the ramdacs in 2:1 mode.  Increasing this limit
   * could result in damage to your hardware.
   */
! #define MAX_MACH32_CLOCK	80000
  
  int mach32MaxClock = MAX_MACH32_CLOCK;
  
  ScrnInfoPtr x386Screens[] = 
  {
--- 15,25 ----
   * is added for using the ramdacs in 2:1 mode.  Increasing this limit
   * could result in damage to your hardware.
   */
! #define MAX_MACH32_CLOCK		80000
! #define MAX_MACH32_TLC34075_CLOCK	135000
  
  int mach32MaxClock = MAX_MACH32_CLOCK;
+ int mach32MaxTlc34075Clock = MAX_MACH32_TLC34075_CLOCK;
  
  ScrnInfoPtr x386Screens[] = 
  {
***************
*** 50,55 ****
--- 52,58 ----
    VIRTUAL,
    CLOCKPROG,
    BIOSBASE,
+   MEMBASE,
    -1
  };
  
diff -c mit/server/ddx/x386/common/XF86_Mono.c:2.2 mit/server/ddx/x386/common/XF86_Mono.c:2.3
*** mit/server/ddx/x386/common/XF86_Mono.c:2.2	Fri Mar 11 23:38:52 1994
--- mit/server/ddx/x386/common/XF86_Mono.c	Fri Mar 11 23:38:52 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_Mono.c,v 2.2 1993/08/30 15:23:13 dawes Exp $
   */
  
  #include "X.h"
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_Mono.c,v 2.3 1993/12/01 12:38:18 dawes Exp $
   */
  
  #include "X.h"
***************
*** 82,87 ****
--- 82,89 ----
  {
    STATICGRAY,
    CHIPSET,
+   OPTION,
+   MEMBASE,
    SCREENNO,
    DISPLAYSIZE,
    VIRTUAL,
diff -c mit/server/ddx/x386/common/XF86_S3.c:2.2 mit/server/ddx/x386/common/XF86_S3.c:2.6
*** mit/server/ddx/x386/common/XF86_S3.c:2.2	Fri Mar 11 23:38:52 1994
--- mit/server/ddx/x386/common/XF86_S3.c	Fri Mar 11 23:38:52 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_S3.c,v 2.2 1993/10/14 16:05:56 dawes Exp $
   */
  
  #include "X.h"
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_S3.c,v 2.6 1994/03/06 06:44:39 dawes Exp $
   */
  
  #include "X.h"
***************
*** 14,20 ****
   * the ramdacs used on many S3 cards Increasing this limit
   * could result in damage to your hardware.
   */
! /* Clock limit for non-Bt485 cards */
  #define MAX_S3_CLOCK    110000
  
  /*
--- 14,20 ----
   * the ramdacs used on many S3 cards Increasing this limit
   * could result in damage to your hardware.
   */
! /* Clock limit for non-Bt485, non-Ti3020 cards */
  #define MAX_S3_CLOCK    110000
  
  /*
***************
*** 25,34 ****
   */
  
  /* Clock limit for cards with a Bt485 */
! #define MAX_BT485_CLOCK  85000
  
  int s3MaxClock = MAX_S3_CLOCK;
  int s3MaxBt485Clock = MAX_BT485_CLOCK;
  
  ScrnInfoPtr x386Screens[] = 
  {
--- 25,43 ----
   */
  
  /* Clock limit for cards with a Bt485 */
! #define MAX_BT485_CLOCK		 85000
! /* Clock limit for Bt485 cards where we support pixel multiplexing */
! #define MAX_BT485_MUX_CLOCK	135000
! 
! /* Clock limits for cards with a Ti3020 */
! #define MAX_TI3020_CLOCK	135000
! #define MAX_TI3020_CLOCK_FAST	200000
  
  int s3MaxClock = MAX_S3_CLOCK;
  int s3MaxBt485Clock = MAX_BT485_CLOCK;
+ int s3MaxBt485MuxClock = MAX_BT485_MUX_CLOCK;
+ int s3MaxTi3020Clock = MAX_TI3020_CLOCK;
+ int s3MaxTi3020ClockFast = MAX_TI3020_CLOCK_FAST;
  
  ScrnInfoPtr x386Screens[] = 
  {
***************
*** 61,66 ****
--- 70,76 ----
    VIRTUAL,
    CLOCKPROG,
    BIOSBASE,
+   MEMBASE,
    -1
  };
  
diff -c mit/server/ddx/x386/common/XF86_VGA16.c:2.1 mit/server/ddx/x386/common/XF86_VGA16.c:2.2
*** mit/server/ddx/x386/common/XF86_VGA16.c:2.1	Fri Mar 11 23:38:53 1994
--- mit/server/ddx/x386/common/XF86_VGA16.c	Fri Mar 11 23:38:53 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_VGA16.c,v 2.1 1993/08/20 16:26:34 dawes Exp $
   */
  
  #include "X.h"
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/XF86_VGA16.c,v 2.2 1994/02/01 13:52:34 dawes Exp $
   */
  
  #include "X.h"
***************
*** 32,37 ****
--- 32,39 ----
  int vga16ValidTokens[] =
  {
    PSEUDOCOLOR,
+   STATICGRAY,
+   GRAYSCALE,
    CHIPSET,
    CLOCKS,
    DISPLAYSIZE,
diff -c mit/server/ddx/x386/common/x386.h:2.7 mit/server/ddx/x386/common/x386.h:2.10
*** mit/server/ddx/x386/common/x386.h:2.7	Fri Mar 11 23:38:53 1994
--- mit/server/ddx/x386/common/x386.h	Fri Mar 11 23:38:53 1994
***************
*** 1,4 ****
! /* $XFree86: mit/server/ddx/x386/common/x386.h,v 2.7 1993/09/30 17:49:30 dawes Exp $ */
  /*
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
--- 1,4 ----
! /* $XFree86: mit/server/ddx/x386/common/x386.h,v 2.10 1994/03/06 08:28:10 dawes Exp $ */
  /*
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
***************
*** 52,57 ****
--- 52,59 ----
  #define V_NVSYNC    0x0008
  #define V_INTERLACE 0x0010
  #define V_DBLSCAN   0x0020
+ #define V_CSYNC     0x0040
+ #define V_PIXMUX    0x0100
  
  #define MAXCLOCKS   32
  
***************
*** 91,96 ****
--- 93,99 ----
    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;
diff -c mit/server/ddx/x386/common/x386Config.c:2.25 mit/server/ddx/x386/common/x386Config.c:2.34
*** mit/server/ddx/x386/common/x386Config.c:2.25	Fri Mar 11 23:38:54 1994
--- mit/server/ddx/x386/common/x386Config.c	Fri Mar 11 23:38:55 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Config.c,v 2.25 1993/10/10 11:46:48 dawes Exp $
   * $XConsortium: x386Config.c,v 1.2 91/08/20 15:08:26 gildea Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Config.c,v 2.34 1994/02/10 21:25:26 dawes Exp $
   * $XConsortium: x386Config.c,v 1.2 91/08/20 15:08:26 gildea Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
***************
*** 430,435 ****
--- 430,436 ----
    x386Info.kbdDelay      = 500;
    x386Info.kbdRate       = 30;
    x386Info.vtinit        = NULL;
+   x386Info.vtSysreq      = VT_SYSREQ_DEFAULT;
    x386Info.specialKeyMap = (int *)xalloc((RIGHTCTL - LEFTALT + 1) *
                                              sizeof(int));
    x386Info.specialKeyMap[LEFTALT - LEFTALT] = K_META;
***************
*** 492,497 ****
--- 493,508 ----
  	}
        }
        break;
+     case VTSYSREQ:
+ #ifdef USE_VT_SYSREQ
+       x386Info.vtSysreq = TRUE;
+       if (x386Verbose && !VT_SYSREQ_DEFAULT)
+         ErrorF("%s VTSysReq enabled\n", XCONFIG_GIVEN);
+ #else
+       configError("VTSysReq not supported on this OS");
+ #endif
+       break;
+ 
      default:
        pushToken = token;
        return;
***************
*** 512,520 ****
    x386Info.sampleRate      = 0;
    x386Info.emulate3Buttons = FALSE;
    x386Info.chordMiddle     = FALSE;
! #ifdef CLEARDTR_SUPPORT
!   x386Info.clearDTR = FALSE;
! #endif
  
    for (;;) {
  
--- 523,529 ----
    x386Info.sampleRate      = 0;
    x386Info.emulate3Buttons = FALSE;
    x386Info.chordMiddle     = FALSE;
!   x386Info.mouseFlags = 0;
  
    for (;;) {
  
***************
*** 562,568 ****
      case CLEARDTR:
  #ifdef CLEARDTR_SUPPORT
        if (x386Info.mseType + MICROSOFT == MOUSESYS)
!         x386Info.clearDTR = TRUE;
        else
          configError("ClearDTR only supported for MouseSystems mouse");
  #else
--- 571,577 ----
      case CLEARDTR:
  #ifdef CLEARDTR_SUPPORT
        if (x386Info.mseType + MICROSOFT == MOUSESYS)
!         x386Info.mouseFlags |= MF_CLEAR_DTR;
        else
          configError("ClearDTR only supported for MouseSystems mouse");
  #else
***************
*** 569,574 ****
--- 578,593 ----
        configError("ClearDTR not supported on this OS");
  #endif
        break;
+     case CLEARRTS:
+ #ifdef CLEARDTR_SUPPORT
+       if (x386Info.mseType + MICROSOFT == MOUSESYS)
+         x386Info.mouseFlags |= MF_CLEAR_RTS;
+       else
+         configError("ClearRTS only supported for MouseSystems mouse");
+ #else
+       configError("ClearRTS not supported on this OS");
+ #endif
+       break;
      default:
        pushToken = token;
        return;
***************
*** 852,869 ****
            FatalError("ClockProg \"%s\" is not a regular file\n", val.str);
        }
        screen->clockprog = val.str;
!       if (x386Verbose)
!         ErrorF("%s: ClockProg: \"%s\"", screen->name,
                 screen->clockprog);
        if (getToken(NULL) == NUMBER)
        {
          textClockValue = (int)(val.realnum * 1000.0 + 0.5);
!         ErrorF(", Text Clock: %7.3f\n", textClockValue / 1000.0);
        }
        else
        {
          pushToken = token;
!         ErrorF("\n");
        }
        break;
  
--- 871,890 ----
            FatalError("ClockProg \"%s\" is not a regular file\n", val.str);
        }
        screen->clockprog = val.str;
!       if (!dummy && x386Verbose)
!         ErrorF("%s %s: ClockProg: \"%s\"", XCONFIG_GIVEN, screen->name,
                 screen->clockprog);
        if (getToken(NULL) == NUMBER)
        {
          textClockValue = (int)(val.realnum * 1000.0 + 0.5);
! 	if (!dummy && x386Verbose)
!           ErrorF(", Text Clock: %7.3f\n", textClockValue / 1000.0);
        }
        else
        {
          pushToken = token;
! 	if (!dummy && x386Verbose)
!           ErrorF("\n");
        }
        break;
  
***************
*** 870,879 ****
      case BIOSBASE:
        if (getToken(NULL) != NUMBER) configError("BIOS base address expected");
        screen->BIOSbase = val.num;
!       if (x386Verbose)
!         ErrorF("BIOS Base Address: %x\n", val.num);
        break;
  
      case BLACK:
      case WHITE:
        {
--- 891,909 ----
      case BIOSBASE:
        if (getToken(NULL) != NUMBER) configError("BIOS base address expected");
        screen->BIOSbase = val.num;
!       if (!dummy && x386Verbose)
!         ErrorF("%s %s: BIOS Base Address: %x\n", XCONFIG_GIVEN, screen->name,
! 	       val.num);
        break;
  
+     case MEMBASE:
+       if (getToken(NULL) != NUMBER) configError("Memory base address expected");
+       screen->MemBase = val.num;
+       if (!dummy && x386Verbose)
+         ErrorF("%s %s: Memory Base Address: %x\n", XCONFIG_GIVEN, screen->name,
+ 	       val.num);
+       break;
+ 
      case BLACK:
      case WHITE:
        {
***************
*** 1335,1341 ****
                break;
            }
            if (found_clock && x386Verbose)
!             ErrorF("%s: text clock = %7.3f, clock used = %7.3f\n",
                driver->name, textClockValue / 1000.0,
                driver->clock[driver->textclock] / 1000.0);
            if (!found_clock)
--- 1365,1372 ----
                break;
            }
            if (found_clock && x386Verbose)
!             ErrorF("$s %s: text clock = %7.3f, clock used = %7.3f\n",
!               XCONFIG_GIVEN,
                driver->name, textClockValue / 1000.0,
                driver->clock[driver->textclock] / 1000.0);
            if (!found_clock)
***************
*** 1417,1422 ****
--- 1448,1454 ----
  	    case NHSYNC:    pNew->Flags |= V_NHSYNC;     break;
  	    case PVSYNC:    pNew->Flags |= V_PVSYNC;     break;
  	    case NVSYNC:    pNew->Flags |= V_NVSYNC;     break;
+ 	    case CSYNC:     pNew->Flags |= V_CSYNC;      break;
  	    default:
  	      configError("Videomode special flag expected");
  	      break;
***************
*** 1500,1508 ****
      ErrorF("following graphics drivers: ");
      for (i = 0; i < x386MaxScreens; i++)
      {
!       ErrorF("%s%s", needcomma ? ", " : "",
!              tokenToString(SymTab, xf86ScreenNames[i]));
!       needcomma = TRUE;
      }
      ErrorF("\n");
      FatalError("No configured graphics devices");
--- 1532,1543 ----
      ErrorF("following graphics drivers: ");
      for (i = 0; i < x386MaxScreens; i++)
      {
!       if (!x386Screens[i])
!       {
!         ErrorF("%s%s", needcomma ? ", " : "",
!                tokenToString(SymTab, xf86ScreenNames[i]));
!         needcomma = TRUE;
!       }
      }
      ErrorF("\n");
      FatalError("No configured graphics devices");
***************
*** 1538,1544 ****
    /*
     * free up mode info...
     */
!   for (pLast = pModes, pNew = pModes->next; pLast;)
      {
        Xfree(pLast->name);
        Xfree(pLast);
--- 1573,1580 ----
    /*
     * free up mode info...
     */
!   if (pModes)
!     for (pLast = pModes, pNew = pModes->next; pLast;)
      {
        Xfree(pLast->name);
        Xfree(pLast);
***************
*** 1582,1588 ****
  	       driver->clocks = 2;
  	    }
  
! 	    if (p->Clock > driver->maxClock)
  	       clock_too_high = TRUE;
  	    else
  	    {
--- 1618,1624 ----
  	       driver->clocks = 2;
  	    }
  
! 	    if ((p->Clock / 1000) > (driver->maxClock / 1000))
  	       clock_too_high = TRUE;
  	    else
  	    {
***************
*** 1619,1625 ****
  	 for (i=0; i < driver->clocks; i++)      /* scan clocks */
  	  if (abs(p->Clock - driver->clock[i]) <= tol_table[j])
  	  {
! 	    if (driver->clock[i] > driver->maxClock)
  	    {
  	      clock_too_high = TRUE;
  	      break;
--- 1655,1661 ----
  	 for (i=0; i < driver->clocks; i++)      /* scan clocks */
  	  if (abs(p->Clock - driver->clock[i]) <= tol_table[j])
  	  {
! 	    if ((driver->clock[i] / 1000) > (driver->maxClock / 1000))
  	    {
  	      clock_too_high = TRUE;
  	      break;
diff -c mit/server/ddx/x386/common/x386Cursor.c:1.8 mit/server/ddx/x386/common/x386Cursor.c:2.0
*** mit/server/ddx/x386/common/x386Cursor.c:1.8	Fri Mar 11 23:38:56 1994
--- mit/server/ddx/x386/common/x386Cursor.c	Fri Mar 11 23:38:56 1994
***************
*** 58,66 ****
  x386InitViewport(pScr)
       ScrnInfoPtr pScr;
  {
-   DisplayModePtr pMode, pEnd;
-   int            virtualX, virtualY;
- 
    /*
     * Compute the initial Viewport if necessary
     */
--- 58,63 ----
***************
*** 145,151 ****
       ScreenPtr   pScreen;
       int        zoom;
  {
-   int           x, y;
    ScrnInfoPtr   pScr = X386SCRNINFO(pScreen);
  
    if (pScr->modes != pScr->modes->next)
--- 142,147 ----
diff -c mit/server/ddx/x386/common/x386Events.c:2.13 mit/server/ddx/x386/common/x386Events.c:2.18
*** mit/server/ddx/x386/common/x386Events.c:2.13	Fri Mar 11 23:38:57 1994
--- mit/server/ddx/x386/common/x386Events.c	Fri Mar 11 23:38:57 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Events.c,v 2.13 1993/10/15 15:39:41 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Events.c,v 2.18 1994/02/10 21:25:29 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
***************
*** 79,89 ****
  
  Bool x386VTSema = TRUE;
  
  #ifndef _MINIX
  extern long EnabledDevices[];
  #endif
  
! #if defined(__386BSD__) && !defined(__bsdi__)
  extern unsigned char x386CodrvMap[];
  #endif
  
--- 79,109 ----
  
  Bool x386VTSema = 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 */
+ 
  #ifndef _MINIX
  extern long EnabledDevices[];
  #endif
  
! #if defined(CODRV_SUPPORT)
  extern unsigned char x386CodrvMap[];
  #endif
  
***************
*** 295,305 ****
    KeySym      *keysym;
    int         keycode;
    static int  lockkeys = 0;
  
! #if defined(__386BSD__) && !defined(__bsdi__)
    if (x386Info.consType == CODRV011 || x386Info.consType == CODRV01X)
      scanCode = x386CodrvMap[scanCode];
  #endif
    /*
     * First do some special scancode remapping ...
     */
--- 315,336 ----
    KeySym      *keysym;
    int         keycode;
    static int  lockkeys = 0;
+ #if defined(SYSCONS_SUPPORT)
+   static Bool first_time = TRUE;
+ #endif
  
! #if defined(CODRV_SUPPORT)
    if (x386Info.consType == CODRV011 || x386Info.consType == CODRV01X)
      scanCode = x386CodrvMap[scanCode];
  #endif
+ 
+ #if defined(SYSCONS_SUPPORT)
+   if (first_time)
+   {
+     first_time = FALSE;
+     VTSwitchEnabled = (x386Info.consType == SYSCONS);
+   }
+ #endif
    /*
     * First do some special scancode remapping ...
     */
***************
*** 309,320 ****
        
      case KEY_Prefix0:
      case KEY_Prefix1:
! #if defined(__386BSD__) && !defined(__bsdi__)
        if (x386Info.consType == PCCONS || x386Info.consType == SYSCONS) {
  #endif
          x386Info.scanPrefix = scanCode;  /* special prefixes */
          return;
! #if defined(__386BSD__) && !defined(__bsdi__)
        }
        break;
  #endif
--- 340,351 ----
        
      case KEY_Prefix0:
      case KEY_Prefix1:
! #if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT)
        if (x386Info.consType == PCCONS || x386Info.consType == SYSCONS) {
  #endif
          x386Info.scanPrefix = scanCode;  /* special prefixes */
          return;
! #if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT)
        }
        break;
  #endif
***************
*** 348,354 ****
    }
  
    else if (
! #if defined(__386BSD__) && !defined(__bsdi__)
             (x386Info.consType == PCCONS || x386Info.consType == SYSCONS) &&
  #endif
             (x386Info.scanPrefix == KEY_Prefix0)) {
--- 379,385 ----
    }
  
    else if (
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
             (x386Info.consType == PCCONS || x386Info.consType == SYSCONS) &&
  #endif
             (x386Info.scanPrefix == KEY_Prefix0)) {
***************
*** 418,424 ****
  	if (down) x386ZoomViewport(x386Info.currentScreen,  1);
  	return;
  
! #ifdef linux
  	/*
  	 * Under Linux, the raw keycodes are consumed before the kernel
  	 * does any processing on them, so we must emulate the vt switching
--- 449,455 ----
  	if (down) x386ZoomViewport(x386Info.currentScreen,  1);
  	return;
  
! #if defined(linux) || defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
  	/*
  	 * Under Linux, the raw keycodes are consumed before the kernel
  	 * does any processing on them, so we must emulate the vt switching
***************
*** 434,452 ****
        case KEY_F8:
        case KEY_F9:
        case KEY_F10:
!         if (down)
!           ioctl(x386Info.consoleFd, VT_ACTIVATE, scanCode - KEY_F1 + 1);
!         return;
!         break;
        case KEY_F11:
        case KEY_F12:
!         if (down)
!           ioctl(x386Info.consoleFd, VT_ACTIVATE, scanCode - KEY_F11 + 11);
!         return;
!         break;
  #endif
  
- #if defined(__386BSD__) && !defined(__bsdi__)
        case KEY_F1:
        case KEY_F2:
        case KEY_F3:
--- 465,550 ----
        case KEY_F8:
        case KEY_F9:
        case KEY_F10:
!         if (VTSwitchEnabled && !x386Info.vtSysreq)
!         {
! 	  if (down)
!             ioctl(x386Info.consoleFd, VT_ACTIVATE, scanCode - KEY_F1 + 1);
!           return;
!         }
! 	break;
        case KEY_F11:
        case KEY_F12:
!         if (VTSwitchEnabled && !x386Info.vtSysreq)
!         {
! 	  if (down)
!             ioctl(x386Info.consoleFd, VT_ACTIVATE, scanCode - KEY_F11 + 11);
!           return;
!         }
! 	break;
! #endif
! 
!       /* 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. X386) will see it
!        * OBS: syscons does not !
!        */
!       } 
!     }
! 
!     /*
!      * Start of acutal Solaris VT switching code.  
!      * This should pretty much emulate standard SVR4 switching keys.
!      * 
!      * DWH 12/2/93
!      */
! 
! #ifdef USE_VT_SYSREQ
!     if (VTSwitchEnabled && x386Info.vtSysreq)
!     {
!       switch (scanCode)
!       {
!       /*
!        * syscons on *BSD doesn't have a VT #0  -- don't think Linux does
!        * either
!        */
! #ifdef SOLX86
!       case KEY_H: 
! 	if (VTSysreqToggle && down)
!         {
!           ioctl(x386Info.consoleFd, VT_ACTIVATE, 0);
!           VTSysreqToggle = 0;
!           return; 
!         }
! 	break;
! 
!       /*
!        * Yah, I know the N, and P keys seem backwards, however that's
!        * how they work under Solaris
!        * XXXX N means go to next active VT not necessarily vtno+1 (or vtno-1)
!        */
! 
!       case KEY_N:
! 	if (VTSysreqToggle && down)
! 	{
!           if (ioctl(x386Info.consoleFd, VT_ACTIVATE, x386Info.vtno - 1 ) < 0)
!             ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
!           VTSysreqToggle = FALSE;
!           return;
!         }
! 	break;
! 
!       case KEY_P:
! 	if (VTSysreqToggle && down)
! 	{
!           if (ioctl(x386Info.consoleFd, VT_ACTIVATE, x386Info.vtno + 1 ) < 0)
!             if (ioctl(x386Info.consoleFd, VT_ACTIVATE, 0) < 0)
!               ErrorF("Failed to switch consoles (%s)\n", strerror(errno));
!           VTSysreqToggle = FALSE;
!           return;
!         }
! 	break;
  #endif
  
        case KEY_F1:
        case KEY_F2:
        case KEY_F3:
***************
*** 457,486 ****
        case KEY_F8:
        case KEY_F9:
        case KEY_F10:
!         if (x386Info.consType == SYSCONS)
!         {
! 	  if (down)
!             ioctl(x386Info.consoleFd, VT_ACTIVATE, scanCode - KEY_F1 + 1);
            return;
          }
        case KEY_F11:
        case KEY_F12:
!         if (x386Info.consType == SYSCONS)
!         {
! 	  if (down)
!             ioctl(x386Info.consoleFd, VT_ACTIVATE, scanCode - KEY_F11 + 11);
            return;
          }
! #endif
  
!       /* 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. X386) will see it
!        * OBS: syscons does not !
!        */
!       } 
      }
  
  #ifdef SCO
      /*
       *	With the console in raw mode, SCO will not switch consoles,
--- 555,605 ----
        case KEY_F8:
        case KEY_F9:
        case KEY_F10:
! 	if (VTSysreqToggle && down)
! 	{
!           if (ioctl(x386Info.consoleFd, VT_ACTIVATE, scanCode-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(x386Info.consoleFd, VT_ACTIVATE, scanCode-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 */
+ 
  #ifdef SCO
      /*
       *	With the console in raw mode, SCO will not switch consoles,
***************
*** 604,610 ****
     * normal, non-keypad keys
     */
    if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
! #if !defined(__386BSD__) && !defined(MACH386) && !defined(_MINIX) && !defined(__OSF__)
      /*
       * magic ALT_L key on AT84 keyboards for multilingual support
       */
--- 723,729 ----
     * normal, non-keypad keys
     */
    if (scanCode < KEY_KP_7 || scanCode > KEY_KP_Decimal) {
! #if !defined(__BSD__) && !defined(MACH386) && !defined(_MINIX) && !defined(__OSF__)
      /*
       * magic ALT_L key on AT84 keyboards for multilingual support
       */
***************
*** 615,621 ****
  	UsePrefix = TRUE;
  	Direction = TRUE;
        }
! #endif /* !MACH386 && !__386BSD__ && !_MINIX && !__OSF__ */
    }
  
  
--- 734,740 ----
  	UsePrefix = TRUE;
  	Direction = TRUE;
        }
! #endif /* !MACH386 && !__BSD__ && !_MINIX && !__OSF__ */
    }
  
  
***************
*** 656,662 ****
  x386PostMseEvent(buttons, dx, dy)
       int buttons, dx, dy;
  {
-   int         eventNum = 0;
    int         id, change;
    int         truebuttons;
    xEvent      mevent;
--- 775,780 ----
***************
*** 881,894 ****
  x386VTSwitch()
  {
    int j;
-   int result;
  
    if (x386VTSema) {
-     
- #if 0
-     SaveScreens(SCREEN_SAVER_FORCER,ScreenSaverActive);
- #endif
- 
      for (j = 0; j < screenInfo.numScreens; j++)
        (X386SCRNINFO(screenInfo.screens[j])->EnterLeaveVT)(LEAVE, j);
        
--- 999,1006 ----
diff -c mit/server/ddx/x386/common/x386Kbd.c:2.1 mit/server/ddx/x386/common/x386Kbd.c:2.2
*** mit/server/ddx/x386/common/x386Kbd.c:2.1	Fri Mar 11 23:38:59 1994
--- mit/server/ddx/x386/common/x386Kbd.c	Fri Mar 11 23:38:59 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Kbd.c,v 2.1 1993/08/01 05:56:09 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Kbd.c,v 2.2 1994/02/23 14:17:45 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
***************
*** 237,249 ****
       CARD8      *pModMap;
  {
    KeySym        *k;
! #if !defined(linux) && !defined(AMOEBA) && !defined(_MINIX) && !defined(__OSF__)
    keymap_t      keymap;
! #endif /* !linux && !AMOEBA && !_MINIX && !__OSF__ */
    char          type;
    int           i, j;
    
! #if !defined(linux) && !defined(AMOEBA) && !defined(_MINIX) && !defined(__OSF__)
    /*
     * use the keymap, which can be gotten from our oringinal vt??.
     * ( ttymap(1) !!!! )
--- 237,249 ----
       CARD8      *pModMap;
  {
    KeySym        *k;
! #if !defined(AMOEBA) && !defined(_MINIX) && !defined(__OSF__)
    keymap_t      keymap;
! #endif /* !AMOEBA && !_MINIX && !__OSF__ */
    char          type;
    int           i, j;
    
! #if !defined(AMOEBA) && !defined(_MINIX) && !defined(__OSF__)
    /*
     * use the keymap, which can be gotten from our oringinal vt??.
     * ( ttymap(1) !!!! )
***************
*** 266,272 ****
  	if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
        }
    }
! #endif /* !linux && !AMOEBA && !_MINIX && !__OSF__ */
  
    /*
     * Apply the special key mapping specified in Xconfig 
--- 266,272 ----
  	if (k[0] == k[2] && k[1] == k[3]) k[2] = k[3] = NoSymbol;
        }
    }
! #endif /* !AMOEBA && !_MINIX && !__OSF__ */
  
    /*
     * Apply the special key mapping specified in Xconfig 
diff -c mit/server/ddx/x386/common/x386Priv.h:2.7 mit/server/ddx/x386/common/x386Priv.h:2.9
*** mit/server/ddx/x386/common/x386Priv.h:2.7	Fri Mar 11 23:38:59 1994
--- mit/server/ddx/x386/common/x386Priv.h	Fri Mar 11 23:38:59 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Priv.h,v 2.7 1993/09/23 15:45:21 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/x386Priv.h,v 2.9 1994/02/10 21:25:31 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
***************
*** 26,31 ****
--- 26,32 ----
  #ifndef _X386PRIV_H
  #define _X386PRIV_H
  
+ #include "xf86_OSlib.h"
  
  typedef struct {
  
***************
*** 62,67 ****
--- 63,69 ----
    Bool          modeSwitchLock;
    Bool          serverNumLock;
    Bool          composeLock;
+   Bool          vtSysreq;
  
    /* pointer part */
    DevicePtr     pPointer;
***************
*** 82,90 ****
    int           emulateState;         /* automata state for 2 button mode */
    Bool          emulate3Buttons;
    Bool          chordMiddle;
! #if defined(SYSV386) || defined(linux) || defined(__386BSD__)
!   Bool          clearDTR;             /* Clear DTR after opening mouse dev */
! #endif
  
    /* xque part */
    int           xqueFd;
--- 84,90 ----
    int           emulateState;         /* automata state for 2 button mode */
    Bool          emulate3Buttons;
    Bool          chordMiddle;
!   int           mouseFlags;        /* Flags to Clear after opening mouse dev */
  
    /* xque part */
    int           xqueFd;
***************
*** 101,110 ****
    /* graphics part */
    Bool          sharedMonitor;
    ScreenPtr     currentScreen;
! #if defined(__386BSD__) || defined(_MINIX)
    int           screenFd;	/* fd for memory mapped access to vga card */
  #endif
! #ifdef __386BSD__
    int		consType;	/* Which console driver? */
  #endif
  #ifdef _MINIX
--- 101,110 ----
    /* graphics part */
    Bool          sharedMonitor;
    ScreenPtr     currentScreen;
! #if defined(__BSD__) || defined(_MINIX)
    int           screenFd;	/* fd for memory mapped access to vga card */
  #endif
! #ifdef __BSD__
    int		consType;	/* Which console driver? */
  #endif
  #ifdef _MINIX
***************
*** 128,139 ****
  #define XCOMP	((unsigned long) 0x00008000)
  
  /* 386BSD console driver types (consType) */
! #ifdef __386BSD__
  #define PCCONS		   0
  #define CODRV011	   1
  #define CODRV01X	   2
  #define SYSCONS		   8
  #endif
  
  extern int x386ScreenIndex;
  
--- 128,143 ----
  #define XCOMP	((unsigned long) 0x00008000)
  
  /* 386BSD console driver types (consType) */
! #ifdef __BSD__
  #define PCCONS		   0
  #define CODRV011	   1
  #define CODRV01X	   2
  #define SYSCONS		   8
  #endif
+ 
+ /* Values of x386Info.mouseFlags */
+ #define MF_CLEAR_DTR       1
+ #define MF_CLEAR_RTS       2
  
  extern int x386ScreenIndex;
  
diff -c mit/server/ddx/x386/common/xf86_Config.h:2.7 mit/server/ddx/x386/common/xf86_Config.h:2.11
*** mit/server/ddx/x386/common/xf86_Config.h:2.7	Fri Mar 11 23:39:00 1994
--- mit/server/ddx/x386/common/xf86_Config.h	Fri Mar 11 23:39:00 1994
***************
*** 23,29 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common/xf86_Config.h,v 2.7 1993/10/07 13:56:00 dawes Exp $ */
  
  #ifndef XCONFIG_FLAGS_ONLY
  
--- 23,29 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common/xf86_Config.h,v 2.11 1994/02/10 21:25:33 dawes Exp $ */
  
  #ifndef XCONFIG_FLAGS_ONLY
  
***************
*** 135,140 ****
--- 135,141 ----
  #define RIGHTALT   6
  #define SCROLLLOCK 7
  #define RIGHTCTL   8
+ #define VTSYSREQ   9
  
  #ifdef INIT_CONFIG
  static SymTabRec KeyboardTab[] = {
***************
*** 148,153 ****
--- 149,155 ----
    { RIGHTALT,   "altgr" },
    { SCROLLLOCK, "scrolllock" },
    { RIGHTCTL,   "rightctl" },
+   { VTSYSREQ,   "vtsysreq" },
    { -1,         "" },
  };
  #endif /* INIT_CONFIG */
***************
*** 184,190 ****
  #define BAUDRATE   1
  #define SAMPLERATE 2
  #define CLEARDTR   3
! #define CHORDMIDDLE 4
  
  #ifdef INIT_CONFIG
  static SymTabRec MouseTab[] = {
--- 186,193 ----
  #define BAUDRATE   1
  #define SAMPLERATE 2
  #define CLEARDTR   3
! #define CLEARRTS   4
! #define CHORDMIDDLE 5
  
  #ifdef INIT_CONFIG
  static SymTabRec MouseTab[] = {
***************
*** 192,197 ****
--- 195,201 ----
    { EMULATE3,   "emulate3buttons" },
    { SAMPLERATE, "samplerate" },
    { CLEARDTR,   "cleardtr" },
+   { CLEARRTS,   "clearrts" },
    { CHORDMIDDLE,"chordmiddle" },
    { -1,         "" },
  };
***************
*** 220,225 ****
--- 224,230 ----
  #define BIOSBASE    22
  #define BLACK       23
  #define WHITE       24
+ #define MEMBASE     25
  
  #ifdef INIT_CONFIG
  static SymTabRec GraphicsTab[] = {
***************
*** 245,250 ****
--- 250,256 ----
    { BIOSBASE,   "biosbase" },
    { BLACK,	"black" },
    { WHITE,	"white" },
+   { MEMBASE,	"membase" },
    { -1,         "" },
  };
  #endif /* INIT_CONFIG */
***************
*** 255,260 ****
--- 261,267 ----
  #define NHSYNC    2
  #define PVSYNC    3
  #define NVSYNC    4
+ #define CSYNC     5
  
  #ifdef INIT_CONFIG
  static SymTabRec TimingTab[] = {
***************
*** 263,268 ****
--- 270,276 ----
    { NHSYNC,     "-hsync"},
    { PVSYNC,     "+vsync"},
    { NVSYNC,     "-vsync"},
+   { CSYNC,      "composite"},
    { -1,         "" },
  };
  #endif /* INIT_CONFIG */
diff -c /dev/null mit/server/ddx/x386/common/xf86_KbdLnx.c:2.3
*** /dev/null	Fri Mar 11 23:39:00 1994
--- mit/server/ddx/x386/common/xf86_KbdLnx.c	Fri Mar 11 23:39:01 1994
***************
*** 0 ****
--- 1,583 ----
+ /*
+  * 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.
+  */
+ /*
+  * $XFree86: mit/server/ddx/x386/common/xf86_KbdLnx.c,v 2.3 1994/03/11 03:04:58 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.
+  *
+  * $Header: /proj/X11/mit/server/ddx/x386/RCS/x386Kbd.c,v 1.1 1991/06/02 22:36:16 root Exp $
+  */
+ 
+ #include "X.h"
+ #include "Xmd.h"
+ #include "input.h"
+ #include "scrnintstr.h"
+ 
+ #include "compiler.h"
+ 
+ #include "x386Procs.h"
+ #include "xf86_OSlib.h"
+ #include "atKeynames.h"
+ #include "xf86_Config.h"
+ 
+ #include "x386Keymap.h"
+ 
+ 
+ /*
+  * LegalModifier --
+  *      determine whether a key is a legal modifier key, i.e send a
+  *      press/release sequence.
+  */
+ 
+ /*ARGSUSED*/
+ Bool
+ LegalModifier(key)
+      int  key;
+ {
+   return (TRUE);
+ }
+ 
+ /*
+  * x386KbdGetMapping --
+  *	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
+ x386KbdGetMapping (pKeySyms, pModMap)
+      KeySymsPtr pKeySyms;
+      CARD8      *pModMap;
+ {
+   KeySym        *k;
+   char          type;
+   int           i, j;
+ 
+   readKernelMapping(pKeySyms, pModMap);
+ 
+   /*
+    * Apply the special key mapping specified in Xconfig 
+    */
+   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 (x386Info.specialKeyMap[j]) {
+         case K_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 K_COMPOSE:
+           k[0] = XK_Multi_key;
+           break;
+         case K_MODESHIFT:
+           k[0] = XK_Mode_switch;
+           k[1] = NoSymbol;
+           break;
+         case K_MODELOCK:
+           k[0] = XK_Mode_switch;
+           k[1] = XK_Mode_Lock;
+           break;
+         case K_SCROLLLOCK:
+           k[0] = XK_Scroll_Lock;
+           break;
+         case K_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 (!x386Info.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;
+ 
+     }
+   
+   x386Info.kbdType =
+     ioctl(x386Info.consoleFd, KDGKBTYPE, &type) != -1 ? type : KB_101;
+ 
+   pKeySyms->map        = map;
+   pKeySyms->mapWidth   = GLYPHS_PER_KEY;
+   pKeySyms->minKeyCode = MIN_KEYCODE;
+   pKeySyms->maxKeyCode = MAX_KEYCODE;
+ }
+ 
+ #undef K_COMPOSE
+ #include <linux/keyboard.h>
+ 
+ /*
+  * As of Linux 0.99.15h, these are not defined in keyboard.h, but
+  * Andries Brouwer (aeb@cwi.nl), who's done the work in getting key
+  * mapping in the kernel, promised me they'd be in soon.
+  */
+ #ifndef KG_SHIFTL
+ 
+ #define KG_SHIFTL        4
+ #define KG_SHIFTR        5
+ #define KG_CTRLL         6
+ #define KG_CTRLR         7
+ 
+ #define K_SHIFTL         K(KT_SHIFT,KG_SHIFTL)
+ #define K_SHIFTR         K(KT_SHIFT,KG_SHIFTR)
+ #define K_CTRLL          K(KT_SHIFT,KG_CTRLL)
+ #define K_CTRLR          K(KT_SHIFT,KG_CTRLR)
+ 
+ #endif /* KG_SHIFTL */
+ 
+ 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
+ };
+ 
+ /*
+  * 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 */
+ 	0x55,	/* unused */		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 */
+ };
+ #define NUM_AT2LNX (sizeof(at2lnx) / sizeof(at2lnx[0]))
+ 
+ static void
+ readKernelMapping(KeySymsPtr pKeySyms, CARD8 *pModMap)
+ {
+   KeySym        *k;
+   char          type;
+   int           i, j;
+   static unsigned char tbl[GLYPHS_PER_KEY] =
+   {
+ 	0,	/* unshifted */
+ 	1,	/* shifted */
+ 	0,	/* modeswitch unshifted */
+ 	0	/* modeswitch shifted */
+   };
+ 
+   for (k = map, i = GLYPHS_PER_KEY * NUM_KEYCODES; i--; )
+ 	  *k++ = NoSymbol;
+ 
+   /*
+    * 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 Xconfig fields.
+    */
+   if (x386Info.specialKeyMap[K_INDEX_RIGHTCTL] == K_MODESHIFT ||
+       x386Info.specialKeyMap[K_INDEX_RIGHTCTL] == K_MODELOCK)
+     tbl[2] = 4;	/* control */
+   else if (x386Info.specialKeyMap[K_INDEX_RIGHTALT] == K_MODESHIFT ||
+            x386Info.specialKeyMap[K_INDEX_RIGHTALT] == K_MODELOCK)
+     tbl[2] = 2;	/* AltGr */
+   else
+     tbl[2] = 8;	/* alt */
+   tbl[3] = tbl[2] | 1;
+ 
+   for (i = 0, k = map+GLYPHS_PER_KEY; i < NUM_AT2LNX; ++i)
+   {
+     struct kbentry kbe;
+     int j;
+ 
+     kbe.kb_index = at2lnx[i];
+     for (j = 0; j < GLYPHS_PER_KEY; ++j, ++k)
+     {
+       unsigned short kval;
+ 
+       kbe.kb_table = tbl[j];
+       if (ioctl(x386Info.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;
+ 	default:
+ 	  if (kval <= 9)
+ 	    *k = XK_KP_0 + kval;
+ 	  break;
+ 	}
+ 	break;
+ 
+       /*
+        * KT_DEAD keys are for accelerated diacritical creation.
+        * We should generate "XK_Compose XK_xxx" but can only map to one
+        * keysym.
+        */
+       case KT_DEAD:
+ 	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;
+   }
+ }
diff -c mit/server/ddx/x386/common/xf86_Mouse.c:2.5 mit/server/ddx/x386/common/xf86_Mouse.c:2.7
*** mit/server/ddx/x386/common/xf86_Mouse.c:2.5	Fri Mar 11 23:39:02 1994
--- mit/server/ddx/x386/common/xf86_Mouse.c	Fri Mar 11 23:39:02 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/common/xf86_Mouse.c,v 2.5 1993/08/28 07:52:44 dawes Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/common/xf86_Mouse.c,v 2.7 1994/02/10 21:25:34 dawes Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   * Copyright 1993 by David Dawes <dawes@physics.su.oz.au>
***************
*** 226,235 ****
          }
  
  #ifdef CLEARDTR_SUPPORT
!       if (x386Info.mseType == P_MSC && x386Info.clearDTR)
          {
!           int val = 0;
!           ioctl(x386Info.mseFd, TIOCMSET, &val);
          }
  #endif
  #endif /* !MOUSE_PROTOCOL_IN_KERNEL || MACH386 */
--- 226,240 ----
          }
  
  #ifdef CLEARDTR_SUPPORT
!       if (x386Info.mseType == P_MSC && (x386Info.mouseFlags & MF_CLEAR_DTR))
          {
!           int val = TIOCM_DTR;
!           ioctl(x386Info.mseFd, TIOCMBIC, &val);
!         }
!       if (x386Info.mseType == P_MSC && (x386Info.mouseFlags & MF_CLEAR_RTS))
!         {
!           int val = TIOCM_RTS;
!           ioctl(x386Info.mseFd, TIOCMBIC, &val);
          }
  #endif
  #endif /* !MOUSE_PROTOCOL_IN_KERNEL || MACH386 */
diff -c mit/server/ddx/x386/common/xf86_Option.h:2.15 mit/server/ddx/x386/common/xf86_Option.h:2.27
*** mit/server/ddx/x386/common/xf86_Option.h:2.15	Fri Mar 11 23:39:02 1994
--- mit/server/ddx/x386/common/xf86_Option.h	Fri Mar 11 23:39:02 1994
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common/xf86_Option.h,v 2.15 1993/10/16 17:31:31 dawes Exp $ */
  
  #ifndef _XF86_OPTION_H
  #define _XF86_OPTION_H
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common/xf86_Option.h,v 2.27 1994/03/07 16:32:39 dawes Exp $ */
  
  #ifndef _XF86_OPTION_H
  #define _XF86_OPTION_H
***************
*** 43,76 ****
  /*
   * Option flags.  Define these in numeric order.
   */
  #define OPTION_LEGEND		0  /* Legend board with 32 clocks           */
  #define OPTION_SWAP_HIBIT	1  /* WD90Cxx-swap high-order clock sel bit */
! #define OPTION_INTERN_DISP	2  /* Laptops - enable internal display (WD)*/
! #define OPTION_EXTERN_DISP	3  /* Laptops - enable external display (WD)*/
! #define OPTION_NOLINEAR_MODE	4  /* chipset has broken linear access mode */
! #define OPTION_8CLKS		5  /* Probe for 8 clocks instead of 4 (PVGA1) */
! #define OPTION_16CLKS		6  /* probe for 16 clocks instead of 8 */
! #define OPTION_PROBE_CLKS	7  /* Force clock probe for cards where a
  				      set of preset clocks is used */
! #define OPTION_HIBIT_HIGH	8  /* Initial state of high order clock bit */
! #define OPTION_HIBIT_LOW	9
! #define OPTION_FAST_DRAM	10 /* reduce DRAM access time (for ET4000) */
! #define OPTION_SLOW_DRAM	11 /* Allow for slow DRAM (for Cirrus) */
! #define OPTION_MEM_ACCESS	12 /* prevent direct access to video ram
  				      from being automatically disabled */
! #define OPTION_NO_MEM_ACCESS	13 /* Unable to access video ram directly */
! #define OPTION_NOACCEL		14 /* Disable accel support in SVGA server */
! #define OPTION_HW_CURSOR	15 /* Turn on HW cursor */
! #define OPTION_SW_CURSOR	16 /* Turn off HW cursor (Mach32) */
! #define OPTION_BT485		17 /* Has BrookTree Bt485 RAMDAC */
! #define OPTION_NO_BT485		18 /* Override Bt485 RAMDAC probe */
! #define OPTION_BT485_CURS	19 /* Override Bt485 RAMDAC probe */
! #define OPTION_SHOWCACHE	20 /* Allow cache to be seen (S3) */
  
  #define CLOCK_OPTION_PROGRAMABLE 0 /* has a programable clock */
  #define CLOCK_OPTION_ICD2061A	 1 /* use ICD 2061A programable clocks      */
  #define CLOCK_OPTION_ICD2061ASL	 2 /* use slow ICD 2061A programable clocks */
! 
  
  /*
   * Table to map option strings to tokens.
--- 43,108 ----
  /*
   * 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 for 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
! 
! /* Laptop display options */
! #define OPTION_INTERN_DISP	8  /* Laptops - enable internal display (WD)*/
! #define OPTION_EXTERN_DISP	9  /* Laptops - enable external display (WD)*/
! 
! /* Memory options */
! #define OPTION_FAST_DRAM	12 /* fast DRAM (for ET4000, S3) */
! #define OPTION_MED_DRAM		13 /* medium speed DRAM (for S3) */
! #define OPTION_SLOW_DRAM	14 /* slow DRAM (for Cirrus, S3) */
! #define OPTION_MEM_ACCESS	15 /* prevent direct access to video ram
  				      from being automatically disabled */
! #define OPTION_NO_MEM_ACCESS	16 /* Unable to access video ram directly */
! #define OPTION_NOLINEAR_MODE	17 /* chipset has broken linear access mode */
! #define OPTION_INTEL_GX		18 /* Linear fb on an Intel GX/Pro (Mach32) */
! #define OPTION_NO_2MB_BANKSEL	19 /* For cirrus cards with 512kx8 memory */
! 
! /* Accel/cursor features */
! #define OPTION_NOACCEL		20 /* Disable accel support in SVGA server */
! #define OPTION_HW_CURSOR	21 /* Turn on HW cursor */
! #define OPTION_SW_CURSOR	22 /* Turn off HW cursor (Mach32) */
! 
! /* RAMDAC options */
! #define OPTION_NORMAL_DAC	24 /* Override probes for Bt, Ti ramdacs (S3) */
! #define OPTION_BT485		25 /* Has BrookTree Bt485 RAMDAC */
! #define OPTION_BT485_CURS	26 /* Override Bt485 RAMDAC probe */
! #define OPTION_20C505		27 /* Has AT&T 20C505 RAMDAC */
! #define OPTION_TI3020		28 /* Has TI ViewPoint 3020 (default 135MHz) */
! #define OPTION_TI3020_CURS	29 /* Use 3020 RAMDAC cursor (default) */
! #define OPTION_NO_TI3020_CURS	30 /* Override 3020 RAMDAC cursor use */
! #define OPTION_TI3020_FAST	31 /* Has TI ViewPoint 3020-200 RAMDAC */
! #define OPTION_DAC_8_BIT	32 /* 8-bit DAC operation */
! #define OPTION_ATT490_1		33 /* AT&T 20C490 or 20C491 */
! #define OPTION_SC15025          34 /* Sierra SC15025/6 RAMDAC */
! 
! /* Misc options */
! #define OPTION_CSYNC		40 /* Composite sync */
! #define OPTION_SECONDARY	41 /* Use secondary address (HGC1280) */
! /* These should probably be included under "memory options" */
! #define OPTION_FIFO_CONSERV	42 /* (cirrus) */
! #define OPTION_FIFO_AGGRESSIVE	43 /* (cirrus) */
! #define OPTION_SPEA_MERCURY	45 /* Enable pixmux for SPEA Mercury (S3) */
! #define OPTION_NUMBER_NINE	46 /* Enable pixmux for #9 with Bt485 (S3) */
! 
! /* Debugging options */
! #define OPTION_SHOWCACHE	48 /* Allow cache to be seen (S3) */
! #define OPTION_FB_DEBUG		49 /* Linear fb debug for S3 */
  
  #define CLOCK_OPTION_PROGRAMABLE 0 /* has a programable clock */
  #define CLOCK_OPTION_ICD2061A	 1 /* use ICD 2061A programable clocks      */
  #define CLOCK_OPTION_ICD2061ASL	 2 /* use slow ICD 2061A programable clocks */
! #define CLOCK_OPTION_SC11412     3 /* use SC11412 programmable clocks */
  
  /*
   * Table to map option strings to tokens.
***************
*** 84,108 ****
  OptFlagRec xf86_OptionTab[] = {
    { "legend",		OPTION_LEGEND },
    { "swap_hibit",	OPTION_SWAP_HIBIT },
-   { "intern_disp",	OPTION_INTERN_DISP },
-   { "extern_disp",	OPTION_EXTERN_DISP },
-   { "nolinear",		OPTION_NOLINEAR_MODE },
    { "8clocks",		OPTION_8CLKS },
    { "16clocks",		OPTION_16CLKS },
    { "probe_clocks",	OPTION_PROBE_CLKS },
    { "hibit_high",	OPTION_HIBIT_HIGH },
    { "hibit_low",	OPTION_HIBIT_LOW },
    { "fast_dram",	OPTION_FAST_DRAM },
    { "slow_dram",	OPTION_SLOW_DRAM },
    { "memaccess",	OPTION_MEM_ACCESS },
    { "nomemaccess",	OPTION_NO_MEM_ACCESS },
    { "noaccel",		OPTION_NOACCEL },
    { "hw_cursor",	OPTION_HW_CURSOR },
    { "sw_cursor",	OPTION_SW_CURSOR },
    { "bt485",		OPTION_BT485 },
-   { "no_bt485",		OPTION_NO_BT485 },
    { "bt485_curs",	OPTION_BT485_CURS },
    { "showcache",	OPTION_SHOWCACHE },
    { "",			-1 },
  };
  
--- 116,165 ----
  OptFlagRec xf86_OptionTab[] = {
    { "legend",		OPTION_LEGEND },
    { "swap_hibit",	OPTION_SWAP_HIBIT },
    { "8clocks",		OPTION_8CLKS },
    { "16clocks",		OPTION_16CLKS },
    { "probe_clocks",	OPTION_PROBE_CLKS },
    { "hibit_high",	OPTION_HIBIT_HIGH },
    { "hibit_low",	OPTION_HIBIT_LOW },
+ 
+   { "intern_disp",	OPTION_INTERN_DISP },
+   { "extern_disp",	OPTION_EXTERN_DISP },
+ 
    { "fast_dram",	OPTION_FAST_DRAM },
+   { "med_dram",		OPTION_MED_DRAM },
    { "slow_dram",	OPTION_SLOW_DRAM },
    { "memaccess",	OPTION_MEM_ACCESS },
    { "nomemaccess",	OPTION_NO_MEM_ACCESS },
+   { "nolinear",		OPTION_NOLINEAR_MODE },
+   { "intel_gx",		OPTION_INTEL_GX },
+   { "no_2mb_banksel",	OPTION_NO_2MB_BANKSEL },
+ 
    { "noaccel",		OPTION_NOACCEL },
    { "hw_cursor",	OPTION_HW_CURSOR },
    { "sw_cursor",	OPTION_SW_CURSOR },
+ 
+   { "normal_dac",	OPTION_NORMAL_DAC },
    { "bt485",		OPTION_BT485 },
    { "bt485_curs",	OPTION_BT485_CURS },
+   { "20c505",		OPTION_20C505 },
+   { "ti3020",		OPTION_TI3020 },
+   { "ti3020_curs",	OPTION_TI3020_CURS },
+   { "no_ti3020_curs",	OPTION_NO_TI3020_CURS },
+   { "ti3020_fast",	OPTION_TI3020_FAST },
+   { "dac_8_bit",	OPTION_DAC_8_BIT },
+   { "att_20c490_1",	OPTION_ATT490_1 },
+   { "sc15025",          OPTION_SC15025 },
+ 
+   { "composite",	OPTION_CSYNC },
+   { "secondary",	OPTION_SECONDARY },
+   { "fifo_conservative",OPTION_FIFO_CONSERV },
+   { "fifo_aggressive",	OPTION_FIFO_AGGRESSIVE },
+   { "spea_mercury",	OPTION_SPEA_MERCURY },
+   { "number_nine",	OPTION_NUMBER_NINE },
+ 
    { "showcache",	OPTION_SHOWCACHE },
+   { "fb_debug",		OPTION_FB_DEBUG },
+ 
    { "",			-1 },
  };
  
***************
*** 109,114 ****
--- 166,172 ----
  OptFlagRec xf86_ClockOptionTab [] = {
    { "icd2061a",		CLOCK_OPTION_ICD2061A }, /* generic ICD2061A */
    { "icd2061a_slow",	CLOCK_OPTION_ICD2061ASL }, /* slow ICD2061A */
+   { "sc11412", 		CLOCK_OPTION_SC11412 }, /* Sierra SC11412 */
    { "",			-1 },
  };
  
diff -c /dev/null mit/server/ddx/x386/common_hw/ATTDac.c:2.0
*** /dev/null	Fri Mar 11 23:39:06 1994
--- mit/server/ddx/x386/common_hw/ATTDac.c	Fri Mar 11 23:39:06 1994
***************
*** 0 ****
--- 1,85 ----
+ /*
+  * Copyright 1994 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/common_hw/ATTDac.c,v 2.0 1994/03/03 12:45:54 dawes Exp $ */
+ 
+ #include "compiler.h"
+ 
+ void xf86dactopel()
+ {
+ 	(void)inb(0x3C8);
+ 	return;
+ }
+ 
+ unsigned char 
+ xf86dactocomm()
+ {
+ 	(void)inb(0x3C6);
+ 	(void)inb(0x3C6);
+ 	(void)inb(0x3C6);
+ 	return(inb(0x3C6));
+ }
+ 
+ unsigned char
+ xf86getdaccomm()
+ {
+ 	unsigned char ret;
+ 
+ 	(void)xf86dactocomm();
+ 	ret = inb(0x3C6);
+ 	xf86dactopel();
+ 
+ 	return(ret);
+ }
+ 
+ void
+ xf86setdaccomm(comm)
+ unsigned char comm;
+ {
+ 	(void)xf86dactocomm();
+ 	outb(0x3C6, comm);
+ 	xf86dactopel();
+ 	return;
+ }
+ 
+ void
+ xf86setdaccommbit(bits)
+ unsigned char bits;
+ {
+ 	unsigned char tmp;
+ 
+ 	tmp = xf86getdaccomm() | bits;
+ 	xf86setdaccomm(tmp);
+ 	return;
+ }
+ 
+ void
+ xf86clrdaccommbit(bits)
+ unsigned char bits;
+ {
+ 	unsigned char tmp;
+ 
+ 	tmp = xf86getdaccomm() & ~bits;
+ 	xf86setdaccomm(tmp);
+ 	return;
+ }
diff -c mit/server/ddx/x386/common_hw/ICD2061Aalt.c:2.3 mit/server/ddx/x386/common_hw/ICD2061Aalt.c:2.4
*** mit/server/ddx/x386/common_hw/ICD2061Aalt.c:2.3	Fri Mar 11 23:39:07 1994
--- mit/server/ddx/x386/common_hw/ICD2061Aalt.c	Fri Mar 11 23:39:07 1994
***************
*** 1,4 ****
! /* $XFree86: mit/server/ddx/x386/common_hw/ICD2061Aalt.c,v 2.3 1993/10/12 15:51:45 dawes Exp $ */
  
  #include "compiler.h"
  
--- 1,4 ----
! /* $XFree86: mit/server/ddx/x386/common_hw/ICD2061Aalt.c,v 2.4 1993/12/25 14:00:57 dawes Exp $ */
  
  #include "compiler.h"
  
***************
*** 21,37 ****
  #ifdef __STDC__
  static double genratio(unsigned int *p, unsigned int *q, double tgt);
  static double f(unsigned int p, unsigned int q, double basefreq);
  static void prtbinary(unsigned int size, unsigned int val);
  static void wait_vb();
  static void wrt_clk_bit(unsigned int value);
! static init_clock(unsigned long setup, unsigned short crtcport);
  #else
  static double genratio();
  static double f();
  static void prtbinary();
  static void wait_vb();
  static void wrt_clk_bit();
! static init_clock();
  #endif
  
  void AltICD2061SetClock(frequency, select)
--- 21,41 ----
  #ifdef __STDC__
  static double genratio(unsigned int *p, unsigned int *q, double tgt);
  static double f(unsigned int p, unsigned int q, double basefreq);
+ #if 0
  static void prtbinary(unsigned int size, unsigned int val);
+ #endif
  static void wait_vb();
  static void wrt_clk_bit(unsigned int value);
! static void init_clock(unsigned long setup, unsigned short crtcport);
  #else
  static double genratio();
  static double f();
+ #if 0
  static void prtbinary();
+ #endif
  static void wait_vb();
  static void wrt_clk_bit();
! static void init_clock();
  #endif
  
  void AltICD2061SetClock(frequency, select)
***************
*** 47,53 ****
     double delta, deltax;
     unsigned int p, q;
     unsigned int bestp, bestq;
-    unsigned short clockval;
  
     crtcaddr=(inb(0x3CC) & 0x01) ? 0x3D4 : 0x3B4;
  
--- 51,56 ----
***************
*** 188,196 ****
  
  
  #ifdef __STDC__
! static init_clock(unsigned long setup, unsigned short crtcport)
  #else
! static init_clock(setup, crtcport)
     unsigned long setup;
     unsigned short crtcport;
  #endif
--- 191,199 ----
  
  
  #ifdef __STDC__
! static void init_clock(unsigned long setup, unsigned short crtcport)
  #else
! static void init_clock(setup, crtcport)
     unsigned long setup;
     unsigned short crtcport;
  #endif
diff -c mit/server/ddx/x386/common_hw/ICD2061Acal.c:2.1 mit/server/ddx/x386/common_hw/ICD2061Acal.c:2.2
*** mit/server/ddx/x386/common_hw/ICD2061Acal.c:2.1	Fri Mar 11 23:39:08 1994
--- mit/server/ddx/x386/common_hw/ICD2061Acal.c	Fri Mar 11 23:39:08 1994
***************
*** 22,28 ****
   */
  /* Header: /home/src/xfree86/mit/server/ddx/x386/common_hw/RCS/ICD2061Acalc.c,v 1.1 1993/03/22 00:25:21 jon Exp jon
   */
! /* $XFree86: mit/server/ddx/x386/common_hw/ICD2061Acal.c,v 2.1 1993/10/02 16:31:29 dawes Exp $ */
  
  #include "compiler.h"
  #include "ICD2061A.h"
--- 22,28 ----
   */
  /* Header: /home/src/xfree86/mit/server/ddx/x386/common_hw/RCS/ICD2061Acalc.c,v 1.1 1993/03/22 00:25:21 jon Exp jon
   */
! /* $XFree86: mit/server/ddx/x386/common_hw/ICD2061Acal.c,v 2.2 1993/12/25 14:00:58 dawes Exp $ */
  
  #include "compiler.h"
  #include "ICD2061A.h"
***************
*** 65,71 ****
  register long   frequency;               /* in Hz */
  int select;
  {
-   register long         clock_value;        /* 7bits M, 7bits N, 2bits P */
    register long         index;
    long                  temp;
    long                  min_m, min_n, min_diff;
--- 65,70 ----
diff -c mit/server/ddx/x386/common_hw/ICD2061Aset.c:2.2 mit/server/ddx/x386/common_hw/ICD2061Aset.c:2.3
*** mit/server/ddx/x386/common_hw/ICD2061Aset.c:2.2	Fri Mar 11 23:39:08 1994
--- mit/server/ddx/x386/common_hw/ICD2061Aset.c	Fri Mar 11 23:39:08 1994
***************
*** 22,28 ****
   */
  /* Header: /home/src/xfree86/mit/server/ddx/x386/common_hw/RCS/ICD2061Aset.c,v 1.1 1993/03/22 00:25:21 jon Exp jon
   */
! /* $XFree86: mit/server/ddx/x386/common_hw/ICD2061Aset.c,v 2.2 1993/10/02 16:31:30 dawes Exp $ */
  
  #include "compiler.h"
  #include "ICD2061A.h"
--- 22,28 ----
   */
  /* Header: /home/src/xfree86/mit/server/ddx/x386/common_hw/RCS/ICD2061Aset.c,v 1.1 1993/03/22 00:25:21 jon Exp jon
   */
! /* $XFree86: mit/server/ddx/x386/common_hw/ICD2061Aset.c,v 2.3 1993/12/25 14:01:00 dawes Exp $ */
  
  #include "compiler.h"
  #include "ICD2061A.h"
***************
*** 129,135 ****
  register long clock_value;              /* 7bits M, 7bits N, 2bits P */
  {
    long                  temp;
-   register long         index;
  
    /* Unpack the clock value */
    clock_m = ((clock_value >>  1) & 0x7F) + 2;
--- 129,134 ----
diff -c mit/server/ddx/x386/common_hw/Imakefile:2.5 mit/server/ddx/x386/common_hw/Imakefile:2.7
*** mit/server/ddx/x386/common_hw/Imakefile:2.5	Fri Mar 11 23:39:09 1994
--- mit/server/ddx/x386/common_hw/Imakefile	Fri Mar 11 23:39:09 1994
***************
*** 1,10 ****
! XCOMM $XFree86: mit/server/ddx/x386/common_hw/Imakefile,v 2.5 1993/09/28 07:58:40 dawes Exp $
  XCOMM Header: /home/src/xfree86/mit/server/ddx/x386/common_hw/RCS/Imakefile,v 1.1 1993/03/22 00:25:21 jon Exp jon
  #include <Server.tmpl>
  
! SRCS = ICD2061Acal.c ICD2061Aset.c ICD2061Aalt.c xf86_ClkPr.c BUSmemcpy.s
  
! OBJS = ICD2061Acal.o ICD2061Aset.o ICD2061Aalt.o xf86_ClkPr.o BUSmemcpy.o
  
  INCLUDES = -I. -I../common -I../os-support -I../../vga -I$(SERVERSRC)/include \
             -I$(INCLUDESRC)
--- 1,12 ----
! XCOMM $XFree86: mit/server/ddx/x386/common_hw/Imakefile,v 2.7 1994/03/03 12:45:56 dawes Exp $
  XCOMM Header: /home/src/xfree86/mit/server/ddx/x386/common_hw/RCS/Imakefile,v 1.1 1993/03/22 00:25:21 jon Exp jon
  #include <Server.tmpl>
  
! SRCS = ICD2061Acal.c ICD2061Aset.c ICD2061Aalt.c xf86_ClkPr.c BUSmemcpy.s \
!        SC11412.c ATTDac.c
  
! OBJS = ICD2061Acal.o ICD2061Aset.o ICD2061Aalt.o xf86_ClkPr.o BUSmemcpy.o \
!        SC11412.o ATTDac.o
  
  INCLUDES = -I. -I../common -I../os-support -I../../vga -I$(SERVERSRC)/include \
             -I$(INCLUDESRC)
diff -c /dev/null mit/server/ddx/x386/common_hw/SC11412.c:2.1
*** /dev/null	Fri Mar 11 23:39:09 1994
--- mit/server/ddx/x386/common_hw/SC11412.c	Fri Mar 11 23:39:09 1994
***************
*** 0 ****
--- 1,131 ----
+ /* $XFree86: mit/server/ddx/x386/common_hw/SC11412.c,v 2.1 1994/02/26 05:02:13 dawes Exp $ */
+ 
+ /* Norbert Distler ndistler@physik.tu-muenchen.de  */
+ 
+ #include "SC11412.h" 
+ #include "compiler.h"
+ #define NO_OSLIB_PROTOTYPES
+ #include "xf86_OSlib.h"
+ 
+ extern int vgaIOBase;
+ #ifdef __STDC__
+ static void wrtSC11412bit(int);
+ static Bool SetSC11412(unsigned  int, unsigned int, unsigned int, unsigned int);
+ #else
+ static void wrtSC11412bit();
+ static Bool SetSC11412();
+ #endif
+ 
+ Bool
+ SC11412SetClock(frequency)
+ register long frequency;
+ {  
+ unsigned i;
+ unsigned  _mul, _div, _D;
+ unsigned _err=32767;
+ 
+ SetSC11412(105,32,0,0);    /* set Mclock to 46,... MHz */
+ 
+   /* calculate postscalar divider */
+   _D = 0;
+   if (frequency < MIN_SC11412_FREQ)
+     _D = 1;
+   if (frequency < MIN_SC11412_FREQ / 2)
+     _D = 2;
+   if (frequency < MIN_SC11412_FREQ / 4)
+     _D = 3;
+   frequency <<= _D;
+ 
+ if (frequency<MIN_SC11412_FREQ)
+   return FALSE; 	/* Frequency too low! */ 
+ if (frequency>MAX_SC11412_FREQ)
+   return FALSE;    /* Frequency too high! */
+ 
+ /* taken from F. Klemms clockprg. */
+ 
+ for (i=0; i<125; i++)
+       { unsigned long t1=QUARZFREQ*1000*(i+3)/((unsigned long)frequency);
+         unsigned long t2=(t1+1000/2)/1000;
+         unsigned long t3=t1-t2*1000;
+         t2 -= 2;
+         t3=(long)t3 > 0 ? t3 : -t3;
+         t3=t3*127/(i+3);
+         if (t2 > 125)
+           continue;
+         if (t3 < _err)
+           _err=(unsigned)t3, _mul=i, _div=(unsigned)t2;
+       }
+         _mul+=3; 
+         _div+=2;
+ 
+  return SetSC11412(_mul,_div,_D,1);
+ 
+ }	/* end of SC11412SetClock */
+ 
+ 
+ static Bool 
+ #ifdef __STDC__
+ SetSC11412(unsigned int N, unsigned int M, unsigned int D, unsigned int Clock)
+ #else
+ SetSC11412(N, M, D, Clock)
+ unsigned int N, M, D, Clock;
+ #endif
+ {
+ 	/* N, M, D -> Freq = N/(M*2^D)*QUARZFREQ   C: 1 -> Pclock, 0 -> Mclock selected */
+ 	int vgaCRIndex = vgaIOBase + 4;
+ 	int vgaCRReg = vgaIOBase + 5;
+         unsigned int i; 
+ 	if (Clock>1)
+ 	  return FALSE; /* ERROR in M/Pclock selection on SC11412 */
+ 
+     	outb(0x3C2,0xef); 
+ 	/* reset pointer with rising edge for access to serial interface */
+ 
+ 	outb(vgaCRIndex,0x42);
+ 	outb(vgaCRReg,0x00);
+ 	outb(vgaCRReg,0x08);
+ 	/* enable programming of SC11412 */
+ 
+         wrtSC11412bit(Clock);          /* select, enable M/Pclock       */
+         wrtSC11412bit(0);              /* enable output driver          */
+         wrtSC11412bit(0);              /* enable VCO                    */
+         wrtSC11412bit(0);              /* external freq. prog. mode     */
+         wrtSC11412bit(D&1);
+         wrtSC11412bit((D>>1)&1);       /* auxiliary divider    */
+         
+         for(i=1; i<8; i++)
+         {   
+                 wrtSC11412bit(N&1);     
+                 N>>=1;
+         }
+         for(i=1; i<8; i++)
+         {       
+                 wrtSC11412bit(M&1);
+                 M>>=1;
+         }
+ 	outb(vgaCRReg,0x02); /* End programming of SC11412 */
+         return TRUE;         /* successful M/Pclock programmed */
+ }		
+ 
+ static void wrtSC11412bit(bool)
+ int bool;
+ { 
+    int vgaCRIndex = vgaIOBase + 4;
+    int vgaCRReg = vgaIOBase + 5;
+    if (bool==1)
+    {
+     outb(vgaCRReg,0x09);
+     usleep(10);
+     outb(vgaCRReg,0x0b);
+     usleep(10);
+    }
+    else
+    {
+     outb(vgaCRReg,0x08);
+     usleep(10);
+     outb(vgaCRReg,0x0a);
+     usleep(10);
+    }
+ }         
+ 
+ /* End of SC11412.C */
diff -c /dev/null mit/server/ddx/x386/common_hw/SC11412.h:2.0
*** /dev/null	Fri Mar 11 23:39:09 1994
--- mit/server/ddx/x386/common_hw/SC11412.h	Fri Mar 11 23:39:09 1994
***************
*** 0 ****
--- 1,16 ----
+ /* $XFree86: mit/server/ddx/x386/common_hw/SC11412.h,v 2.0 1994/02/25 15:02:15 dawes Exp $ */
+ 
+ /* Norbert Distler ndistler@physik.tu-muenchen.de */
+ 
+ typedef int Bool;
+ #define TRUE 1
+ #define FALSE 0
+ #define QUARZFREQ	        14318
+ #define MIN_SC11412_FREQ        45000
+ #define MAX_SC11412_FREQ       100000
+ 
+ Bool SC11412SetClock( 
+ #if NeedFunctionPrototypes
+    long
+ #endif
+ );     
diff -c mit/server/ddx/x386/common_hw/xf86_ClkPr.c:2.6 mit/server/ddx/x386/common_hw/xf86_ClkPr.c:2.8
*** mit/server/ddx/x386/common_hw/xf86_ClkPr.c:2.6	Fri Mar 11 23:39:10 1994
--- mit/server/ddx/x386/common_hw/xf86_ClkPr.c	Fri Mar 11 23:39:10 1994
***************
*** 29,35 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common_hw/xf86_ClkPr.c,v 2.6 1993/09/23 15:45:40 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 29,35 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common_hw/xf86_ClkPr.c,v 2.8 1994/02/10 21:25:43 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 43,49 ****
  #include "xf86_OSlib.h"
  #include "xf86_HWlib.h"
  
! #if defined(__386BSD__) || defined(MACH386)
  #include <sys/resource.h>
  #endif
  
--- 43,49 ----
  #include "xf86_OSlib.h"
  #include "xf86_HWlib.h"
  
! #if defined(__BSD__) || defined(MACH386)
  #include <sys/resource.h>
  #endif
  
***************
*** 61,75 ****
  int vertsyncreg, maskval, knownclkindex, knownclkvalue;
  ScrnInfoRec *InfoRec;
  {
-     int norm;
      register int status = vertsyncreg;
!     unsigned long i, j, cnt, rcnt, sync;
      int saved_nice;
  
      /* First save registers that get written on */
      (*ClockFunc)(CLK_REG_SAVE);
  
! #if defined(__386BSD__) || defined(MACH386)
      saved_nice = getpriority(PRIO_PROCESS, 0);
      setpriority(PRIO_PROCESS, 0, -20);
  #endif
--- 61,74 ----
  int vertsyncreg, maskval, knownclkindex, knownclkvalue;
  ScrnInfoRec *InfoRec;
  {
      register int status = vertsyncreg;
!     unsigned long i, cnt, rcnt, sync;
      int saved_nice;
  
      /* First save registers that get written on */
      (*ClockFunc)(CLK_REG_SAVE);
  
! #if defined(__BSD__) || defined(MACH386)
      saved_nice = getpriority(PRIO_PROCESS, 0);
      setpriority(PRIO_PROCESS, 0, -20);
  #endif
***************
*** 124,130 ****
          (*SaveScreen)(NULL, TRUE);
      }
  
! #if defined(__386BSD__) || defined(MACH386)
      setpriority(PRIO_PROCESS, 0, saved_nice);
  #endif
  #if defined(SYSV386) || defined(linux)
--- 123,129 ----
          (*SaveScreen)(NULL, TRUE);
      }
  
! #if defined(__BSD__) || defined(MACH386)
      setpriority(PRIO_PROCESS, 0, saved_nice);
  #endif
  #if defined(SYSV386) || defined(linux)
diff -c mit/server/ddx/x386/common_hw/xf86_HWlib.h:2.4 mit/server/ddx/x386/common_hw/xf86_HWlib.h:2.5
*** mit/server/ddx/x386/common_hw/xf86_HWlib.h:2.4	Fri Mar 11 23:39:10 1994
--- mit/server/ddx/x386/common_hw/xf86_HWlib.h	Fri Mar 11 23:39:10 1994
***************
*** 28,34 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common_hw/xf86_HWlib.h,v 2.4 1993/09/28 07:58:41 dawes Exp $ */
  
  #ifndef _XF86_HWLIB_H
  #define _XF86_HWLIB_H
--- 28,34 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/common_hw/xf86_HWlib.h,v 2.5 1994/02/25 14:59:44 dawes Exp $ */
  
  #ifndef _XF86_HWLIB_H
  #define _XF86_HWLIB_H
***************
*** 72,77 ****
--- 72,84 ----
  extern void ICD2061ASetClock(
  #if NeedFunctionPrototypes
  	long
+ #endif
+ );
+ 
+ /*  SC11412.c */
+ extern Bool SC11412SetClock(
+ #if NeedFunctionPrototypes
+      long 
  #endif
  );
  
diff -c mit/server/ddx/x386/etc/AccelCards:2.1 mit/server/ddx/x386/etc/AccelCards:2.6
*** mit/server/ddx/x386/etc/AccelCards:2.1	Fri Mar 11 23:39:20 1994
--- mit/server/ddx/x386/etc/AccelCards	Fri Mar 11 23:39:20 1994
***************
*** 2,9 ****
  #
  # Accelerated card supported by XFree86
  # 
! # Version 1.0 - Oct 16, 1993
! #  List for XFree86 2.0 - David Wexelblat <dwex@goblin.org>, <dwex@aib.com>
  #---------------------------------------------------------------------------#
  # This file contains the list of accelerated cards that have been tested
  # as compatible with XFree86.  Other cards with supported chipsets may
--- 2,9 ----
  #
  # Accelerated card supported by XFree86
  # 
! # Version 1.3 - Mar 6, 1994
! #  List for XFree86 2.1 - David Wexelblat <dwex@goblin.org>, <dwex@aib.com>
  #---------------------------------------------------------------------------#
  # This file contains the list of accelerated cards that have been tested
  # as compatible with XFree86.  Other cards with supported chipsets may
***************
*** 36,41 ****
--- 36,75 ----
  #---------------------------------------------------------------------------#
  # S3 911/924                                                                #
  #---------------------------------------------------------------------------#
+ Card Vendor		: DEC
+ Card Model		: DEC PC450D2LP
+ Card Bus (ISA/EISA/VLB)	: Embedded
+ Chipset			: 86C924
+ Video Memory		: 1024K
+ Memory Type (DRAM/VRAM)	: VRAM
+ Memory Speed		: 
+ Clock Chip		: 
+ Programmable? (Y/N)	: 
+ Number of clocks	: 16
+ Clocks			: 25 28 40 0 50 77 46 45 130 12 80 32 110 65 75 95
+ Clocks (cont)		: 
+ Option Flags            : 
+ RAMDAC			: 
+ Submitter		: Eric Hvozda <ack@clark.net>
+ Last Edit Date		: Feb 20, 1994
+ #---------------------------------------------------------------------------#
+ Card Vendor		: Hewlett-Packard 
+ Card Model		: D2325A
+ Card Bus (ISA/EISA/VLB)	: ISA
+ Chipset			: 86C911
+ Video Memory		: 1024K
+ Memory Type (DRAM/VRAM)	: DRAM
+ Memory Speed		: 80 nS
+ Clock Chip		: ICS1394M
+ Programmable? (Y/N)	: No 
+ Number of clocks	: 16
+ Clocks			: 25.20 28.32 30.00  0.00 32.50 36.00 38.00 40.00
+ Clocks (cont)		: 44.90 48.00 50.10 60.10 64.20 65.10 75.20 80.20
+ Option Flags            : nomemaccess on my setup to prevent lockups 
+ RAMDAC			: MUSIC TR9C1710-80
+ Submitter		: Greg Holdren <gregh@hprnd.rose.hp.com,geh@netcom.com>
+ Last Edit Date		: Jan 21, 1994
+ #---------------------------------------------------------------------------#
  Card Vendor		: Orchid
  Card Model		: Fahrenheit 1280 (Circa 1991)
  Card Bus (ISA/EISA/VLB)	: ISA
***************
*** 53,58 ****
--- 87,109 ----
  Submitter		: Douglas Lenz (lenz@comm.mot.com)
  Last Edit Date		: Sept 29, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : Orchid
+ Card Model              : Fahrenheit 1280
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : 911
+ Video Memory            : 1 Meg
+ Memory Type (DRAM/VRAM) : VRAM
+ Memory Speed            : 100ns
+ Clock Chip              : ???
+ Programmable? (Y/N)     : No ???
+ Number of clocks        : 16
+ Clocks                  : 25.2 28.3 40 72 50 77 36 45
+ Clocks (cont)           : 131 120 80 32 110 65 75 95
+ Option Flags            :
+ RAMDAC                  : Sierra HC
+ Submitter               : Kent A. Vander Velden
+ Last Edit Date          : Oct 24, 1993
+ #---------------------------------------------------------------------------#
  Card Vendor		: Paelit
  Card Model		: S3 VGA (I kid you not)
  Card Bus (ISA/EISA/VLB)	: ISA
***************
*** 104,109 ****
--- 155,177 ----
  Submitter		: C.E. Hawkins ceh@eng.cam.ac.uk
  Last Edit Date		: Oct 4, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor		: SIXGRAPH
+ Card Model		: WIZARD 924
+ Card Bus (ISA/EISA/VLB)	: ISA
+ Chipset			: 924
+ Video Memory		: 1024k
+ Memory Type (DRAM/VRAM)	: VRAM
+ Memory Speed		: 80ns
+ Clock Chip		: ?
+ Programmable? (Y/N)	: No
+ Number of clocks	: 16
+ Clocks			: 25.20 28.32 39.70 0.00 50.00 77.00 35.70 44.70
+ Clocks (cont)		: 130.30 119.60 79.50 31.20 109.70 65.30 75.00 71.40
+ Option Flags		:
+ RAMDAC			: AT&T 20C491
+ Submitter		: Jean-F. Cormier (jfcor@phy.ulaval.ca)
+ Last Edit Date		: Jan 23, 1994
+ #---------------------------------------------------------------------------#
  # S3 801/805                                                                #
  #---------------------------------------------------------------------------#
  Card Vendor		: Actix
***************
*** 123,128 ****
--- 191,213 ----
  Submitter		: Jon Tombs <jon@gtex02.us.es>
  Last Edit Date		: Sept 27, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : Actix
+ Card Model              : GE32
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : S3-801
+ Video Memory            : 1M
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : (80ns ?)
+ Clock Chip              : ATT
+ Programmable? (Y/N)     : N
+ Number of clocks        : 16
+ Clocks                  : 25 28 40 72 50 77 36 45 90 120 80 32 110 65 75 95
+ Clocks (cont)           :
+ Option Flags            :
+ RAMDAC                  :
+ Submitter               : brezak@ch.hp.com
+ Last Edit Date          : 10/25/93
+ #---------------------------------------------------------------------------#
  Card Vendor		: Actix
  Card Model		: GraphicsEngine32 Plus
  Card Bus (ISA/EISA/VLB)	: ISA
***************
*** 174,179 ****
--- 259,298 ----
  Submitter		: R.E. Wolff
  Last Edit Date		: Mon Sep 27 09:15:36 MET 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : Actix
+ Card Model              : Graphics Engine 32VL+
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : S3 86C805
+ Video Memory            : 2048K
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 45ns
+ Clock Chip              : Avasem AV9194-11
+ Programmable? (Y/N)     : No
+ Number of clocks        : 16
+ Clocks                  :  25  28 40    0  50 77 36 45
+ Clocks (cont)           : 130 120 80 31.5 110 65 75 95
+ Option Flags            :
+ RAMDAC                  : AT&T 20C490-11
+ Submitter               : Marc Wandschneider (marcwan@microsoft.com)
+ Last Edit Date          : Oct 25, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : Actix
+ Card Model              : GraphicsEngine32VL+/2mb
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : S3 86C805
+ Video Memory            : 2048k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 45ns
+ Clock Chip              : Avasem AV9194-11
+ Programmable? (Y/N)     : No
+ Number of clocks        : 16
+ Clocks                  : 25.20  28.30 39.70  0.00  50.00  76.70  35.70  44.60
+ Clocks (cont)           : 130.30 121.40 79.40 31.20 109.80 65.10  74.90  94.60
+ Option Flags            :
+ RAMDAC                  : Winbond W82C490P-110
+ Submitter               : Dick Garner <cedar!dick@beaver.cs.washington.edu>
+ Last Edit Date          : Oct. 29, 1993
+ #---------------------------------------------------------------------------#
  Card Vendor		: Dell Computer on board video card
  Card Model		:
  Card Bus (ISA/EISA/VLB)	: Integrated Local Bus
***************
*** 225,230 ****
--- 344,435 ----
  Submitter		: Joe V. Moss <joe@morton.rain.com>
  Last Edit Date		: Oct 14, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : Dell
+ Card Model              : Built-into Dell 4066/XE
+ Card Bus (ISA/EISA/VLB) : local bus
+ Chipset                 : S3 86C805
+ Video Memory            : 1024k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 512k @ ? / 512k @ 70ns
+ Clock Chip              : ?
+ Programmable? (Y/N)     : no?
+ Number of clocks        :  16
+ Clocks                  : 25.20  28.32  39.90   0.00  50.10  77.60  36.00  36.10
+ Clocks (cont)           : 62.90 100.30  79.90  31.50 109.90 109.90  75.00  94.50
+ Option Flags            : Option "nomemaccess"
+ RAMDAC                  : AT&T 20C492
+ Submitter               : harry@brain.Jpl.Nasa.Gov (Harry Langenbacher)
+ Last Edit Date          : Oct 29, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor		: "Made In Taiwan" VGA Windows Accellerator
+ Card Model		: P/N: 910-0032 CODE 2155
+ Card Bus (ISA/EISA/VLB)	: VESA Local Bus
+ Chipset			: S3 86C805
+ Video Memory		: 1024k
+ Memory Type (DRAM/VRAM)	: DRAM
+ Memory Speed		: 45 ns
+ Clock Chip		: ICS 2494 AN  9312-305  (ICS2494-305)
+ Programmable? (Y/N)	: No.
+ Number of clocks	: 16
+ Clocks			: 25.175  28.322  40.0  0.0  50.0  77.0  36.0  44.889
+ Clocks (cont)		: 130.0   120.0   80.0  31.5 110.0 65.0  75.0  94.5 
+ Option Flags		: 
+ RAMDAC			: AT&T 20C491-11
+ Submitter		: Frode Roervik <froder@ifi.uio.no>
+ Last Edit Date		: Jan 26, 1994
+ #---------------------------------------------------------------------------#
+ Card Vendor             : Micronics
+ Card Model              : MPower 3
+ Card Bus (ISA/EISA/VLB) : on-motherboard (VLB)
+ Chipset                 : S3 86C805
+ Video Memory            : 1024k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 60ns
+ Clock Chip              : AvaSem
+ Programmable? (Y/N)     : No
+ Number of clocks        : 16
+ Clocks                  : 25 28 40 0 50 77 36 45
+ Clocks (cont)           : 130 120 80 31.5 110 65 75 95
+ Option Flags            :
+ RAMDAC                  : AT&T 20C491-80
+ Comments                : RAMDAC limits max clock to 80MHz
+ Submitter               : David Dawes <dawes@physics.su.oz.au>
+ Last Edit Date          : Dec 14, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : miro Computer Products AG Germany
+ Card Model              : CRYSTAL 8S
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : S3 P86C805
+ Video Memory            : 1024k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 45 ns
+ Clock Chip              : ICS2494AN
+ Programmable? (Y/N)     : N
+ Number of clocks        : 16
+ Clocks                  : 25.2 28.32 39.9 0 50.1 77 36 44.8 129.7 120.2 
+ Clocks (cont)		: 120.2 31.5 109.9 65 75 94.5 31.5 109.9 65 75 94.5
+ Option Flags            : 
+ RAMDAC                  : AT&T 20C491
+ Submitter               : rohde@physik.uni-kiel.d400.de
+ Last Edit Date          : Nov 5, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : miro Computer Products AG 
+ Card Model              : miroCRYSTAL 8S
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : S3 P86C805
+ Video Memory            : 1024k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 45 ns
+ Clock Chip              : ICS2494AN
+ Programmable? (Y/N)     : N
+ Number of clocks        : 16
+ Clocks                  : 25.2 28.32 40.0 0 50.0 77.0 36.0 44.9 
+ Clocks (cont)		: 130.0 120.0 80.0 31.5 110.0 65.0 75.0 94.5
+ Option Flags            : 
+ RAMDAC                  : AT&T 20C491-11
+ Submitter               : Christoph Rimek <chrimek@toppoint.de>
+ Last Edit Date          : Mar 6, 1994
+ #---------------------------------------------------------------------------#
  Card Vendor		: Orchid
  Card Model		: Fahrenheit VLB  ( = VA/VLB - audio )
  Card Bus (ISA/EISA/VLB)	: VLB
***************
*** 303,309 ****
  Clock Chip		: ICD2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: progamable
! Clocks			: "icd2061a_slow"
  Option Flags		:
  RAMDAC			:
  Submitter		:
--- 508,514 ----
  Clock Chip		: ICD2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: progamable
! Clocks			: "icd2061a"
  Option Flags		:
  RAMDAC			:
  Submitter		:
***************
*** 345,351 ****
  Last Edit Date		: 1-OCT-1993
  #---------------------------------------------------------------------------#
  Card Vendor		: Diamond Computer Systems, Inc.
! Card Model		: Stealth Pro
  Card Bus (ISA/EISA/VLB)	: VLB
  Chipset			: S3 86C928
  Video Memory		: 1024k
--- 550,556 ----
  Last Edit Date		: 1-OCT-1993
  #---------------------------------------------------------------------------#
  Card Vendor		: Diamond Computer Systems, Inc.
! Card Model		: Stealth Pro (not officially supported)
  Card Bus (ISA/EISA/VLB)	: VLB
  Chipset			: S3 86C928
  Video Memory		: 1024k
***************
*** 373,379 ****
  Clock Chip		: ICD 2061ASC-1
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a_slow"
  Option Flags		: 
  RAMDAC			: Sierra SC 15025CV Highcolor 24 - 110
  Submitter		: hohndel@informatik.uni-wuerzburg.de
--- 578,584 ----
  Clock Chip		: ICD 2061ASC-1
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a"
  Option Flags		: 
  RAMDAC			: Sierra SC 15025CV Highcolor 24 - 110
  Submitter		: hohndel@informatik.uni-wuerzburg.de
***************
*** 389,395 ****
  Clock Chip		: ICD 2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a_slow"
  Option Flags		: 
  RAMDAC			: SC 15025
  Submitter		: Harald Koenig <koenig@tat.physik.uni-tuebingen.de>
--- 594,600 ----
  Clock Chip		: ICD 2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a"
  Option Flags		: 
  RAMDAC			: SC 15025
  Submitter		: Harald Koenig <koenig@tat.physik.uni-tuebingen.de>
***************
*** 405,411 ****
  Clock Chip		: ICD 2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a_slow"
  Option Flags		: 
  RAMDAC			: SC 15025
  Submitter		: Harald Koenig <koenig@tat.physik.uni-tuebingen.de>
--- 610,616 ----
  Clock Chip		: ICD 2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a"
  Option Flags		: 
  RAMDAC			: SC 15025
  Submitter		: Harald Koenig <koenig@tat.physik.uni-tuebingen.de>
***************
*** 421,427 ****
  Clock Chip		: ICD2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "ic2061a_slow"
  Option Flags		: nomemaccess
  RAMDAC			: SIERRA 15/16 bit (SC15025)
  Submitter		: Helmut Geyer  geyer@kalliope.iwr.uni-heidelberg.de
--- 626,632 ----
  Clock Chip		: ICD2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "ic2061a"
  Option Flags		: nomemaccess
  RAMDAC			: SIERRA 15/16 bit (SC15025)
  Submitter		: Helmut Geyer  geyer@kalliope.iwr.uni-heidelberg.de
***************
*** 437,443 ****
  Clock Chip              : ICD2061A
  Programmable? (Y/N)     : Y
  Number of clocks        : programmable
! Clocks                  : "icd2061a_slow"
  Option Flags            :
  RAMDAC                  : Sierra 15/16-bit HiColor
  Submitter               : Peter E. <Peter.Eubert@iwb.mw.tu-muenchen.d400.de>
--- 642,648 ----
  Clock Chip              : ICD2061A
  Programmable? (Y/N)     : Y
  Number of clocks        : programmable
! Clocks                  : "icd2061a"
  Option Flags            :
  RAMDAC                  : Sierra 15/16-bit HiColor
  Submitter               : Peter E. <Peter.Eubert@iwb.mw.tu-muenchen.d400.de>
***************
*** 453,459 ****
  Clock Chip		: ICD2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a_slow"
  Option Flags		:
  RAMDAC			: Sierra SC 15025CV 
  Submitter		: Helmut Geyer 	geyer@kalliope.iwr.uni-heidelberg.de
--- 658,664 ----
  Clock Chip		: ICD2061A
  Programmable? (Y/N)	: Y
  Number of clocks	: programmable
! Clocks			: "icd2061a"
  Option Flags		:
  RAMDAC			: Sierra SC 15025CV 
  Submitter		: Helmut Geyer 	geyer@kalliope.iwr.uni-heidelberg.de
***************
*** 469,475 ****
  Clock Chip              : ICD2061A
  Programmable? (Y/N)     : Y
  Number of clocks        : programmable
! Clocks                  : "icd2061a_slow"
  Option Flags            :
  RAMDAC                  :
  Submitter               : Walter Tuppa <tuppa@iue.tuwien.ac.at>
--- 674,680 ----
  Clock Chip              : ICD2061A
  Programmable? (Y/N)     : Y
  Number of clocks        : programmable
! Clocks                  : "icd2061a"
  Option Flags            :
  RAMDAC                  :
  Submitter               : Walter Tuppa <tuppa@iue.tuwien.ac.at>
***************
*** 507,512 ****
--- 712,749 ----
  Submitter               : David Wexelblat <dwex@goblin.org>
  Last Edit Date          : October 16, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : Number 9
+ Card Model              : GXe12
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : S3 928
+ Video Memory            : 3Mb
+ Memory Type (DRAM/VRAM) : VRAM
+ Memory Speed            : ?
+ Clock Chip              : ?
+ Programmable? (Y/N)     : Yes
+ Number of clocks        : Programmable
+ Clocks                  : "icd2061a"
+ Option Flags            : "bt485"
+ RAMDAC                  : Brooktree Bt485
+ Submitter               : Orest Zborowski <orestz@microsoft.com>
+ Last Edit Date          : Sep 25, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : Number Nine
+ Card Model              : #9GXE Level 12
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : S3 928 Rev E
+ Video Memory            : 3072k
+ Memory Type (DRAM/VRAM) : 2MB VRAM, 1MB DRAM
+ Memory Speed            : 70ns
+ Clock Chip              : ICD2061A
+ Programmable? (Y/N)     : Y
+ N}mber of clocks        : programmable
+ Clocks                  : "icd2061a"
+ Option Flags            : "bt485"
+ RAMDAC                  : BrookTree Bt485
+ Submitter               : Daniel Ling <danzig@eclipse.its.rpi.edu>
+ Last Edit Date          :
+ #---------------------------------------------------------------------------#
  Card Vendor             : Number Nine
  Card Model              : #9GXE Level 12
  Card Bus (ISA/EISA/VLB) : VLB
***************
*** 523,528 ****
--- 760,813 ----
  Submitter               : Ed Hall <edhall@rand.org>
  Last Edit Date          : October 15, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : Number Nine
+ Card Model              : GXE level 12
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : S3 928
+ Video Memory            : 3 MB
+ Memory Type (DRAM/VRAM) : 2 MB VRAM / 1 MB DRAM 
+ Memory Speed            : ?
+ Clock Chip              : icd2061a
+ Programmable? (Y/N)     : Y
+ Number of clocks        : programmable
+ Clocks                  : "icd2061a"
+ Option Flags            : "bt485"
+ RAMDAC                  : Bt485
+ Submitter               : Ted Goldblatt
+ Last Edit Date          : 25 October 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : #9
+ Card Model              : GXE Level 12
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : S3 86C928
+ Video Memory            : 3072k
+ Memory Type (DRAM/VRAM) : VRAM
+ Memory Speed            :
+ Clock Chip              : ICD2061A
+ Programmable? (Y/N)     : Yes
+ Number of clocks        : programmable
+ Clocks                  : "icd2061a"
+ Option Flags            : "bt485"
+ RAMDAC                  : BrookTree 485
+ Submitter               : Randy Terbush <randyt@cse.unl.edu>
+ Last Edit Date          : Oct 25, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : Number Nine
+ Card Model              : #9GXE Level 12
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : S3 928 Rev E
+ Video Memory            : 3072k
+ Memory Type (DRAM/VRAM) : 2MB VRAM, 1MB DRAM
+ Memory Speed            : 60ns
+ Clock Chip              : ICD2061A
+ Programmable? (Y/N)     : Y
+ N}mber of clocks        : programmable
+ Clocks                  : "icd2061a"
+ Option Flags            : "bt485"
+ RAMDAC                  : BrookTree Bt485 
+ Submitter               : Daniel Ling <danzig@eclipse.its.rpi.edu>
+ Last Edit Date          : 
+ #---------------------------------------------------------------------------#
  # 8514/A                                                                    #
  #---------------------------------------------------------------------------#
  Card Vendor             : Western Digital
***************
*** 653,676 ****
  Submitter		: Joergen Haegg <jh@efd.lth.se>
  Last Edit Date		: Oct 13, 1993
  #---------------------------------------------------------------------------#
  # ATI Mach32                                                                #
  #---------------------------------------------------------------------------#
! Card Vendor		:  ATI
! Card Model		:  Ultra Pro
! Card Bus (ISA/EISA/VLB)	:  ISA
! Chipset			:  Mach32
! Video Memory		:  2048k
! Memory Type (DRAM/VRAM)	:  VRAM
! Memory Speed		:  
! Clock Chip		:  18811-1
! Programmable? (Y/N)	:  No
! Number of clocks	:  16
! Clocks			:  100.0 126.0 92.4 36.0 50.35 56.64 0 44.90
! Clocks (cont)		:  135.0 32.0 110.0 80.0 39.91 49.90 75.0 65.0
! Option Flags		:  None
! RAMDAC			:  ATI34075
! Submitter		:  Mike Bernson
! Last Edit Date		:  Sept 26, 1993
  #---------------------------------------------------------------------------#
  Card Vendor		: ATI
  Card Model		: VLB mach32
--- 938,995 ----
  Submitter		: Joergen Haegg <jh@efd.lth.se>
  Last Edit Date		: Oct 13, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : ATI
+ Card Model              : Graphics Ultra 
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : Mach8
+ Video Memory            : 1MB VRAM ACCEL / 512KB DRAM VGA
+ Memory Type (DRAM/VRAM) : See above
+ Memory Speed            : 60ns
+ Clock Chip              : 
+ Programmable? (Y/N)     : N
+ Number of clocks        : 13
+ Clocks                  : 30.3 32.0 36.0 40.0 43.0 44.9 48.8
+ Clocks (cont)           : 50.3 56.7 65.1 75.0 80.0 92.0
+ Option Flags            :
+ RAMDAC                  :
+ Submitter               : Dimitrios Evmorfopoulos
+ Last Edit Date          : Oct 26th 1993
+ #---------------------------------------------------------------------------#
  # ATI Mach32                                                                #
  #---------------------------------------------------------------------------#
! Card Vendor		: ATI
! Card Model		: AX0
! Card Bus (ISA/EISA/VLB)	: PCI
! Chipset			: Mach32
! Video Memory		: 2048k
! Memory Type (DRAM/VRAM)	: DRAM
! Memory Speed		: 45ns
! Clock Chip		: 18811-1
! Programmable? (Y/N)	: No
! Number of clocks	: 32
! Clocks			: 100 126 92 36 51 57 0 44 135 32 110 80 39 45 75 65
! Clocks (cont)		: 50 63 46 18 25 28 0 22 67 16 55 40 19 23 37 33
! Option Flags		: 
! RAMDAC			: ATI 68875
! Submitter		: Alan Hourihane (alanh@metro.co.uk)
! Last Edit Date		: Jan 6, 1994
! #---------------------------------------------------------------------------#
! Card Vendor		: ATI
! Card Model		: Ultra Pro
! Card Bus (ISA/EISA/VLB)	: ISA
! Chipset			: Mach32
! Video Memory		: 2048k
! Memory Type (DRAM/VRAM)	: VRAM
! Memory Speed		: 
! Clock Chip		: 18811-1
! Programmable? (Y/N)	: No
! Number of clocks	: 16
! Clocks			: 100.0 126.0 92.4 36.0 50.35 56.64 0 44.90
! Clocks (cont)		: 135.0 32.0 110.0 80.0 39.91 49.90 75.0 65.0
! Option Flags		: None
! RAMDAC			: ATI34075
! Submitter		: Mike Bernson
! Last Edit Date		: Sept 26, 1993
  #---------------------------------------------------------------------------#
  Card Vendor		: ATI
  Card Model		: VLB mach32
***************
*** 809,814 ****
--- 1128,1237 ----
  Submitter		: Dietmar Wolz <dietmar@cs.tu-berlin.de>
  Last Edit Date		: Oct 09, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : ATI
+ Card Model              : Graphic Ultra Pro
+ Card Bus (ISA/EISA/VLB) : EISA
+ Chipset                 : ATI 28800-A
+ Video Memory            : 2M
+ Memory Type (DRAM/VRAM) : VRAM
+ Memory Speed            : 70ns (I think!  if not 60ns)
+ Clock Chip              : 18811-1
+ Programmable? (Y/N)     : N
+ Number of clocks        : 16
+ Clocks                  : 100 126  92  36  50  56   0  45
+ Clocks (cont)           : 132  32 110  80  40  45  75  65
+ Option Flags            : none(?)
+ RAMDAC                  : ATI68875/TLC34075 (reported by inw 12EE[11:9])
+ Submitter               : aal@rot.qc.ca (Alain Hebert)
+ Last Edit Date          : Oct 26, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : ATI
+ Card Model              : ATI Ultra Mach32
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : Mach32  2200688003  + ATI 68875 BFN
+ Video Memory            : 2 MB
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 80ns
+ Clock Chip              : ICS 2494 AM ?
+ Programmable? (Y/N)     : Y
+ Number of clocks        : 32
+ Clocks                  : 100 126 92 36 51 57 0 44 135 32 110 80 39 45 75 65
+ Clocks (cont)           :  50  63 46 18 25 28 0 22  67 16  55 40 19 23 37 33
+ Option Flags            : --
+ RAMDAC                  : 18820 ATI 
+ Submitter               : Christoph Kukulies (kuku@acds.physik.rwth-aachen.de)
+ Last Edit Date          : Oct 30, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : ATI
+ Card Model              : Graphics Ultra CLX
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : ATI 68800-06
+ Video Memory            : 2048K
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 60ns
+ Clock Chip              : ATI 18811-2
+ Programmable? (Y/N)     : No
+ Number of clocks        : 32
+ Clocks                  : 100 126 92 36 51 57 0 44 135 32 110 80 39 45 75 65
+ Clocks (cont)           :  50  63 46 18 25 28 0 22  67 16  55 40 19 23 37 33
+ Option Flags            :
+ RAMDAC                  : ATI68875
+ Submitter               : Marc Wandschneider (marcwan@microsoft.com)
+ Last Edit Date          : Oct 25, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : NCR
+ Card Model              : Clarity II
+ Card Bus (ISA/EISA/VLB) : Direct Access Video Buss (DAVB) Sort of a VLB
+ Chipset                 : ATI Mach-32
+ Video Memory            : 2048K
+ Memory Type (DRAM/VRAM) : ?? (Toshiba TC524258BJ-80)
+ Memory Speed            : 80ns
+ Clock Chip              : ??
+ Programmable? (Y/N)     : ?
+ Number of clocks        : ?
+ Clocks                  : ?
+ Clocks (cont)           : ?
+ Option Flags            : none
+ RAMDAC                  : TIC34075
+ Submitter               : Stuart Anderson (Stuart.Anderson@ColumbiaSC.NCR.COM)
+ Last Edit Date          : Thu Dec  2 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : PRISMA
+ Card Model              : GraphicSTAR-FX V
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : ATI 28800-A/Mach32
+ Video Memory            : 2048k
+ Memory Type (DRAM/VRAM) : VRAM
+ Memory Speed            : 45ns
+ Clock Chip              : 
+ Programmable? (Y/N)     : N
+ Number of clocks        : 32
+ Clocks                  : 100 126 92 36 51 57 0 44 135 32 110 80 39 45 75 65
+ Clocks (cont)           : 50 63 46 18 25 28 0 22 67 16 55 40 19 23 37 33
+ Option Flags            :
+ RAMDAC                  : ATI 68875 RAMDAC
+ Submitter               : Peter Blok <pb@pbgate.iaf.nl>
+ Last Edit Date          : Dec 09, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor            :  ATI
+ Card Model             :  
+ Card Bus (ISA/EISA/VLB):  VLB
+ Chipset                :  Mach32
+ Video Memory           :  2048k
+ Memory Type (DRAM/VRAM):  DRAM
+ Memory Speed           :  
+ Clock Chip             :  
+ Programmable? (Y/N)    :  No
+ Number of clocks       :  32
+ Clocks                 :  100.30 126.60 92.40 36.10 50.50 56.80 0.00 44.90
+ Clocks (cont)          :  135.10 32.00 109.70 80.00 40.00 44.90 75.00 65.00
+ Clocks (cont)          :  50.15 63.30 46.20 18.05 25.25 28.40 0.00 22.45
+ Clocks (cont)          :  67.55 16.00 54.85 40.00 20.00 22.45 37.50 32.50
+ Option Flags           :  None
+ RAMDAC                 :  BT481
+ Submitter              :  Jin Tao
+ Last Edit Date         :  Dec. 15, 1993
+ #---------------------------------------------------------------------------#
  # SVGA (Cirrus)                                                             #
  #---------------------------------------------------------------------------#
  Card Vendor		: Boca
***************
*** 896,901 ****
--- 1319,1341 ----
  Submitter		: Dave Kochan (slflq@cc.usu.edu)
  Last Edit Date		: Oct. 5, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : No Name
+ Card Model              : Unmarked
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : CLGD5426
+ Video Memory            : 1MB+1MB
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 80ns
+ Clock Chip              : builtin
+ Programmable? (Y/N)     : Y
+ Number of clocks        : 16
+ Clocks                  : 25.23 28.32 41.16 36.08 31.5 39.99 45.08 49.87
+ Clocks (cont)           : 64.98 72.16 75.17 80.05 85.23 90.20 94.95 100.23
+ Option Flags            : slow_ram
+ RAMDAC                  : builtin (?)
+ Submitter               : Piercarlo Grandi <pcg@aber.ac.uk>
+ Last Edit Date          : 93/10/26
+ #---------------------------------------------------------------------------#
  Card Vendor		: TMC Research Corporation
  Card Model		: HG426AV VESA Local(VL) Bus Graphics Card
  Card Bus (ISA/EISA/VLB) : VLB
***************
*** 913,918 ****
--- 1353,1408 ----
  Submitter		: Dilvan de A. Moreira <ddam@ukc.ac.uk>
  Last Edit Date		: Oct 7, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : Unspecified 
+ Card Model              : AVGA3VL
+ Card Bus (ISA/EISA/VLB) : VLB
+ Chipset                 : Cirrus Logic GD5426-A
+ Video Memory            : 2048k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 80ns surface-mounted, and 8 x 70/80ns 256kx4 
+ Clock Chip              : Cirrus, built-in 
+ Programmable? (Y/N)     : Y 
+ Number of clocks        : 12
+ Clocks			: 25.20 28.30 41.20 36.10 31.50 40.00 44.90 49.87
+ Clocks (cont)		: 65.00 72.20 75.00 80.00 
+ Option Flags            :
+ RAMDAC                  : Cirrus built-in
+ Submitter               : H. Hanemaayer <hhanemaa@cs.ruu.nl>
+ Last Edit Date          : Oct 26, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor     	: Genoa
+ Card Model      	: 8500vl 18/24
+ Card Bus (ISA/EISA/VLB)	: VLB
+ Chipset         	: Cirrus CL-5428
+ Video Memory    	: 2048k
+ Memory Type (DRAM/VRA)	: DRAM (2nd meg)/ VRAM (1st meg)
+ Memory Speed    	: 60ns (1st), 80ns (2nd)
+ Clock Chip      	: ?
+ Programmable (Y/N)   	: ?
+ Number of clocks	: 16
+ Clocks          	: ?
+ Option Flags    	: ?
+ RAMDAC          	: ?
+ Submitter       	: John L. Clarke,III <jlc3@netcom.com>
+ Last Edit Date  	: Oct 28, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor     	: ?
+ Card Model      	: PT-528
+ Card Bus (ISA/EISA/VLB)	: ?
+ Chipset         	: Cirrus CL-5428
+ Video Memory    	: 1024k
+ Memory Type (DRAM/VRA)	: DRAM (2nd meg)
+ Memory Speed    	: ?
+ Clock Chip      	: ?
+ Programmable (Y/N)   	: ?
+ Number of clocks	: 13
+ Clocks          	: 25.23 28.32 41.16 36.08 31.50 39.99 48.08 49.87
+ Clocks (cont)		: 64.98 72.16  0.00 75.00 80.01
+ Option Flags    	: ?
+ RAMDAC          	: ?
+ Submitter       	: Aled Davies <ssudavia@reading.ac.uk>
+ Last Edit Date  	: Dec 15, 1993
+ #---------------------------------------------------------------------------#
  # SVGA (Western Digital)                                                    #
  #---------------------------------------------------------------------------#
  Card Vendor		: DFI Inc
***************
*** 949,954 ****
--- 1439,1477 ----
  Submitter               : Mike Tierney <mjtiern@pepsi.eng.umd.edu>
  Last Edit Date          : Oct 7, 1993
  #---------------------------------------------------------------------------#
+ Card Vendor             : HP
+ Card Model              : 5/60LM
+ Card Bus (ISA/EISA/VLB) : Integrated
+ Chipset                 : WD/Paradise 90C31
+ Video Memory            : 1024k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 
+ Clock Chip              : 
+ Programmable? (Y/N)     : N
+ Number of clocks        : 9
+ Clocks                  : 25.20  28.32  65.60 36.30 0.00 28.30 0.00 0.00
+ Clocks (cont)           : 49.70  (most bogus because of server probing problem)
+ Option Flags            :
+ RAMDAC                  : ?
+ Submitter               : [skelton%jdp.UUCP@dragon.com]
+ Last Edit Date          : Nov 29, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : OCTEK
+ Card Model              : PVGA1D+
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : WD/Paradise 90C31-LR
+ Video Memory            : 1024k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 70nS
+ Clock Chip              : Avasem AV90C64N
+ Programmable? (Y/N)     : N
+ Number of clocks        : 9
+ Clocks                  : 25.20 28.32 65.10 35.60 0.00 49.90 32.10 45.00 44.50
+ Option Flags            :
+ RAMDAC                  : Sierra 15/16/bit Hicolor
+ Submitter               : Antti Heinila <aheinila@vipunen.hut.fi>
+ Last Edit Date          : Nov 12, 1993
+ #---------------------------------------------------------------------------#
  Card Vendor		: Western Digital (on Viglen Motherboard)
  Card Model		: 
  Card Bus (ISA/EISA/VLB)	: Integrated
***************
*** 964,969 ****
--- 1487,1508 ----
  RAMDAC			:
  Submitter		: row@uk.co.bnr
  Last Edit Date		: Oct 14, 1993
+ #---------------------------------------------------------------------------#
+ Card Vendor             : Western Digital
+ Card Model              : Accelerator for Windows
+ Card Bus (ISA/EISA/VLB) : ISA
+ Chipset                 : WD90c31
+ Video Memory            : 1024k
+ Memory Type (DRAM/VRAM) : DRAM
+ Memory Speed            : 
+ Clock Chip              : 
+ Programmable? (Y/N)     : 
+ Number of clocks        : 9
+ Clocks                  : 25 28 65 36 40 50 32 45 ??
+ Option Flags            :
+ RAMDAC                  : Sierra HiColor (32k colors)
+ Submitter               : wmagro@uiuc.edu (William Magro)
+ Last Edit Date          : Nov 2, 1993
  
  #---------------------------------------------------------------------------#
  # Known clock synthesizer dot-clocks                                        #
***************
*** 1015,1018 ****
  
  
  
! $XFree86: mit/server/ddx/x386/etc/AccelCards,v 2.1 1993/10/23 04:53:24 dawes Exp $
--- 1554,1557 ----
  
  
  
! $XFree86: mit/server/ddx/x386/etc/AccelCards,v 2.6 1994/03/07 14:00:19 dawes Exp $
diff -c mit/server/ddx/x386/etc/Imakefile:2.10 mit/server/ddx/x386/etc/Imakefile:2.17
*** mit/server/ddx/x386/etc/Imakefile:2.10	Fri Mar 11 23:39:22 1994
--- mit/server/ddx/x386/etc/Imakefile	Fri Mar 11 23:39:22 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/etc/Imakefile,v 2.10 1993/10/24 13:44:47 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.3 91/08/26 15:00:14 gildea Exp $
  
  #if SystemV
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/etc/Imakefile,v 2.17 1994/03/06 14:55:12 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.3 91/08/26 15:00:14 gildea Exp $
  
  #if SystemV
***************
*** 15,40 ****
  #if SystemV4
  X386INSTPROG = install.svr4
       XDMCONF = XdmConf.svr4
     MISCFILES = 2key.c xcode.xfree86
  #endif
  
  #if i386Bsd
   PATCHFILES  = stdlib.diff
! X386INSTPROG = install.bsd
!    MISCFILES = README.XS3
! #endif
! 
! #if defined(LinuxArchitecture)
!    MISCFILES = README.XS3
  #endif
  
! #if SystemV || SystemV4
     TERMFILES = sun.termcap sun.terminfo xterm.termcap xterm.terminfo
  #endif
  
         FILES = VideoModes.doc modeDB.txt $(CONFIGFILES) $(TERMFILES) \
                 $(PATCHFILES) $(XDMCONF) ati.test.c README.ati README.trident \
!                README.tseng README.WstDig xmodmap.std \
                 AccelCards \
                 et4000clock.c README.clkprog $(MISCFILES)
      OLDFILES = CONFIG XConfig.Notes
--- 15,50 ----
  #if SystemV4
  X386INSTPROG = install.svr4
       XDMCONF = XdmConf.svr4
+ #if defined(i386SVR4Solarisx86)
+    MISCFILES = apSolx86.shar xcode.xfree86
+ #else
     MISCFILES = 2key.c xcode.xfree86
  #endif
+ #endif
  
  #if i386Bsd
   PATCHFILES  = stdlib.diff
! # ifdef i386FreeBsd
! X386INSTPROG = inst.freebsd
! # endif
! # ifdef i386NetBsd
! X386INSTPROG = inst.netbsd
! # endif
  #endif
  
! #if !BuildServersOnly
! #if (SystemV || SystemV4) 
! #if defined (i386SVR4Solarisx86)
!    TERMFILES = xterm.termcap xterm.terminfo
! #else
     TERMFILES = sun.termcap sun.terminfo xterm.termcap xterm.terminfo
  #endif
+ #endif
+ #endif
  
         FILES = VideoModes.doc modeDB.txt $(CONFIGFILES) $(TERMFILES) \
                 $(PATCHFILES) $(XDMCONF) ati.test.c README.ati README.trident \
!                README.tseng README.WstDig README.cirrus xmodmap.std \
                 AccelCards \
                 et4000clock.c README.clkprog $(MISCFILES)
      OLDFILES = CONFIG XConfig.Notes
***************
*** 66,80 ****
--- 76,94 ----
  InstallNamedProg(svr3_patch_rem,svr3_patch_rem,$(LIBDIR)/etc)
  #endif
  #if SystemV4
+ #if !defined (i386SVR4Solarisx86)
  InstallNamedProg(svr4_patch,svr4_patch,$(LIBDIR)/etc)
  InstallNamedProg(svr4_patch_rem,svr4_patch_rem,$(LIBDIR)/etc)
  #endif
+ #endif
  
+ #if !BuildServersOnly
  LinkFile(xterm.termcap,$(CLIENTSRC)/xterm/termcap)
  LinkFile(xterm.terminfo,$(CLIENTSRC)/xterm/terminfo)
  
  clean::
  	$(RM) xterm.termcap xterm.terminfo
+ #endif
  
  NormalLibraryObjectRule()
  DependTarget()
diff -c mit/server/ddx/x386/etc/README.WstDig:2.0 mit/server/ddx/x386/etc/README.WstDig:2.1
*** mit/server/ddx/x386/etc/README.WstDig:2.0	Fri Mar 11 23:39:23 1994
--- mit/server/ddx/x386/etc/README.WstDig	Fri Mar 11 23:39:23 1994
***************
*** 10,34 ****
  ----------------------
    XFree86 supports the following Western Digital SVGA chipsets: PVGA1,
  WD90C00, WD90C10, WD90C11, WD90C30, WD90C31.  Note that the WD90C2x series
! of LCD-controller chipsets (common on laptops) is still not supported.  
! The WD90C31 is now supported as an accelerated chipset in the SVGA server; 
! the accelerated features are automatically activated when a WD90C31 is 
  detected, or specified in the Xconfig file.
  
  2 - Special considerations
  --------------------------
    All of the Western Digital chipsets after the PVGA1 support the ability
! to use the memory-refresh clock as an alternate dot-clock for video timing.
! Hence for all of these chipsets, the server will detect NINE clocks, instead
! of the 8 found by the older driver.  What this means is that if you have a
! 'Clocks' line in your Xconfig file, you should comment it out, and rerun
! the server with the '-probeonly' option to find all 9 clock values.  The
! first 8 should be the same as what you had before; the 9th will be new.
    For the WD90C00 chipset, the chipset will only support 640x480 in 256-color
  mode.  Even though 512k of memory should allow better than 800x600, the
  chipset itself cannot do this.  This is stated in the databook (which lists
  1024x768x16 and 640x480x256 for specifications).  We have also witnessed
  this behavior.
    There is an "Option" flag available for the Xconfig file that is specific
  to the Western Digital chipsets.  This option is "swap_hibit".  We have
  determined via experimentation that the WD90C1x and WD90C3x chipsets need
--- 10,40 ----
  ----------------------
    XFree86 supports the following Western Digital SVGA chipsets: PVGA1,
  WD90C00, WD90C10, WD90C11, WD90C30, WD90C31.  Note that the WD90C2x series
! of LCD-controller chipsets (common on laptops) is still not supported.
! The WD90C24 is an exception to this.  It appears to be compatible with the
! WD90C30, and the server will treat it as one of these.  There may be some
! problems on some OSs when returning to text mode when using the WD90C24.
! The WD90C31 is now supported as an accelerated chipset in the SVGA server;
! the accelerated features are automatically activated when a WD90C31 is
  detected, or specified in the Xconfig file.
  
  2 - Special considerations
  --------------------------
    All of the Western Digital chipsets after the PVGA1 support the ability
! to use the memory-refresh clock as an alternate dot-clock for video
! timing.  Hence for all of these chipsets, the server will detect one more
! clocks than "normal".  What this means is that if you have an old 'Clocks'
! line in your Xconfig file, you should comment it out, and rerun the server
! with the '-probeonly' option to find all of the clock values.  All but the
! last should be the same as what you had before; the last will be new.
    For the WD90C00 chipset, the chipset will only support 640x480 in 256-color
  mode.  Even though 512k of memory should allow better than 800x600, the
  chipset itself cannot do this.  This is stated in the databook (which lists
  1024x768x16 and 640x480x256 for specifications).  We have also witnessed
  this behavior.
+   The server will now detect 17 clocks for the WD90C30 and WD90C31 chipsets.
+ If you have one of these chipsets, you should let the server re-probe the
+ clocks and update your Xconfig.
    There is an "Option" flag available for the Xconfig file that is specific
  to the Western Digital chipsets.  This option is "swap_hibit".  We have
  determined via experimentation that the WD90C1x and WD90C3x chipsets need
***************
*** 35,42 ****
  the high-order clock-select bit inverted, and the PVGA1 and WD90C00 need it
  non-inverted.  This is hardcoded into the driver.  Since our sample-set was
  rather small, we have provided the "swap_hibit" option to invert this 
! behavior.  If the clocks detected by the server show a very low 9th clock
  (under 28Mhz), then this option is likely needed.
  
  
! $XFree86: mit/server/ddx/x386/etc/README.WstDig,v 2.0 1993/10/18 12:17:59 dawes Exp $
--- 41,48 ----
  the high-order clock-select bit inverted, and the PVGA1 and WD90C00 need it
  non-inverted.  This is hardcoded into the driver.  Since our sample-set was
  rather small, we have provided the "swap_hibit" option to invert this 
! behavior.  If the clocks detected by the server show a very low last clock
  (under 28Mhz), then this option is likely needed.
  
  
! $XFree86: mit/server/ddx/x386/etc/README.WstDig,v 2.1 1994/03/05 08:23:27 dawes Exp $
diff -c mit/server/ddx/x386/etc/README.XS3:2.2 mit/server/ddx/x386/etc/README.XS3:removed
*** mit/server/ddx/x386/etc/README.XS3:2.2	Fri Mar 11 23:39:23 1994
--- mit/server/ddx/x386/etc/README.XS3	Fri Mar 11 23:39:23 1994
***************
*** 1,53 ****
- 
-                 Information for former XS3 users
-                 --------------------------------
- 
- Contents
- --------
-         1) Functionality
-         2) Xconfig changes
- 
- 1 - Functionality
- -----------------
- 
- XF86_S3 is derived from XS3 but it contains many new features and has
- many bugs removed. There are several improvements that should be noted:
- 
-   -  Real support for the S3 86C928 (no Hack needed); the server defaults
-      to use the Memory-Mapped-IO (mmio) routines for 928 boards which give
-      a significant performance boost on some operations. This can be
-      overruled with the 'chipset "s3_generic"' keyword.
-   -  Support for programmable clocks (for the icd2061a programmable clock
-      generator): Note that there exist two versions to set the clocks:
-      "icd2061a" and "icd2061a_slow". There is no visible speed difference
-      between both of them, but some boards don't work reliably with the 
-      standard "icd2061a" method (notably ELSA Winner boards). For those 
-      use "icd2061a_slow".
-   -  Better support for external clock programs than with XS3. See the
-      Xconfig(4/5) manpage and README.clockprog for details.
-   -  More than 1MB Videoram supported.  The videoram setting is usually not
-      needed in Xconfig. Some 512k boards seem to be exceptions.
-   -  Rudimentary support for Brooktree Bt485 RAMDACs (full support will be
-      available shortly). This basically means that on boards with the Bt485 
-      the maximum dot clock frequency is restricted to 85MHz. These boards 
-      are for example the #9GXe, the Metheus Premier and the ELSA Winner 2000.
-   -  VT switching supported.
-   -  The x-resolution is not restricted to 1024, and can be up to 1280.
- 
- 2 - Xconfig changes
- -------------------
- 
- Due to the integration of the S3 server into XFree86-2.0 several
- changes to the parsing of the Xconfig file have been made:
- 
-   -  the configuration for the server has the keyword accel instead of vga256
-   -  It is no longer necessary to set the virtual resolution. It defaults to
-      the largest physical display mode specified.
-   -  the "vendor" keyword has been replaced by "option"
-   -  'option "nolinear"' is NOT the same as 'vendor "nolinear"' in XS3. To 
-      get the same result, you have to use the option "nomemaccess". This is,
-      however, much less likely to be needed than with XS3.   
- 
- 
- 
- $XFree86: mit/server/ddx/x386/etc/README.XS3,v 2.2 1993/10/24 13:44:49 dawes Exp $
--- 0 ----
diff -c /dev/null mit/server/ddx/x386/etc/README.cirrus:2.4
*** /dev/null	Fri Mar 11 23:39:23 1994
--- mit/server/ddx/x386/etc/README.cirrus	Fri Mar 11 23:39:24 1994
***************
*** 0 ****
--- 1,236 ----
+ 
+ 		Information for Cirrus Chipset Users
+ 		------------------------------------
+ 
+ A number of problems has been reported with the Cirrus driver in XFree86
+ 2.0, and it is hoped that these are alleviated in XFree86 2.1. Some
+ important issues are described here. Please take the time to read this.
+ 
+ Contents
+ 
+ 	1. Supported chipsets
+ 	2. Overview of Xconfig options
+ 	3. Mode issues
+ 	4. Trouble shooting
+ 
+ 
+ 1 - Supported chipsets
+ 
+ The following chipsets by Cirrus Logic are supported by this driver:
+ 
+ CL-GD5420	ISA SVGA chipset, 1Mbyte; maximum dot clock is 50 MHz.
+ 		Acceleration with extended write modes (used for scrolling
+ 		and solid filling in this driver). This chipset can *not*
+ 		support 1024x768 non-interlaced. The 50 MHz clock may or
+ 		may not work.
+ 
+ CL-GD5422	Enhanced version of the 5420 (32-bit internal memory
+ 		interface). Maximum dot clock is 80 MHz.
+ 
+ CL-GD6205/6215/6225/6235
+ 		Laptop chipsets more or less compatible with the 5420. The
+ 		only dot clock supported is 25 MHz.
+ 
+ CL-GD5424	Basically VLB version of the 5422, but resembles the
+ 		5426 in some respects.
+ 
+ CL-GD5426	Supports both ISA bus and VLB, and up to 2Mbyte of memory.
+ 		Has BitBLT engine for improved acceleration (BitBlt, image
+ 		transfer, text). Dot clock limit is 85 MHz.
+ 
+ CL-GD5428	Enhanced version of the 5426.
+ 
+ CL-GD543x	Next generation 'Alpine' family chip with 64-bit internal
+ 		memory interface. There is some limited support for this
+ 		chipset, but it is untested. It is hoped that it will be
+ 		usable with this driver (being largely compatible with
+ 		the 5426).
+ 
+ The CL-GD5429 will probably be compatible with the CL-GD5428.
+ 
+ 
+ 2 - Xconfig options
+ 
+ The following options are of particular interest to the Cirrus driver. Each
+ of them must be specified in the 'vga256' section of the Xconfig file.
+ 
+ Option "noaccel"
+ 
+ 	This option will disable the use of any accelerated functions. This
+ 	is likely to help with some problems related to DRAM timing,
+ 	high dot clocks, and bugs in accelerated functions, at the cost
+ 	of performance (which will still be reasonable on VLB).
+ 
+ Option "fast_dram"	(5424, 5426, 5428)
+ Option "slow_dram"	(5424, 5426, 5428)
+ 
+ 	The "fast_dram" option will cause the driver to set the internal
+ 	memory clock (MCLK) register of the video card to a higher value.
+ 	Normally, this register is not touched but it appears that the
+ 	standard CL-GD542x BIOS initializes it to a value that is somewhat
+ 	on the low side, which has a profound negative influence on
+ 	performance, and on the	stability of high dot clock modes. The actual
+ 	speed of DRAM is not a critical factor in the determining whether
+ 	this option is appropriate; one card with 80ns DRAM, which came with
+ 	a DOS driver utility to set the MCLK to this value (0x22), seems to
+ 	run stable with a value of 0x26.
+ 
+ 	There are also (mainly brand name) cards whose customized BIOS does
+ 	initialize to a proper (high-performance) value. In this case, the
+ 	use of this option is probably not appropriate.
+ 
+ 	The "slow_dram"	option will set the MCLK to the value used by the
+ 	standard CL-GD542x BIOS (0x1c). Symptoms of a MCLK that is too high
+ 	can be vertical bands of flickering pixels on the screen, and
+ 	loosing pixels in the textmode font after running X (note that
+ 	very similar effects can be caused by an MCLK setting that is
+ 	too low).
+ 
+ 	Upon start-up, the driver will report the value of the MCLK
+ 	register, and also any changes that are made.
+ 
+ 	Typical MCLK values:
+ 
+ 	0x1c	This is usually the BIOS default. Corresponds to 50 MHz.
+ 		It is forced by the "slow_dram" option.
+ 	0x22	Value that most cards seem to be able to handle, used by
+ 		the "fast_dram" option.
+ 	0x26	Highest value that seems to be stable on one card tested.
+ 		This is also the maximum value of the MCLK register
+ 		according to the CL-GD542x databook, however, in other
+ 		places the databook says that the parts are not specified
+ 		for a MCLK higher than 50 MHz.
+ 
+ 	If you are not having any problems (performance or stability at
+ 	high dot clocks), it is best not to use the "fast_dram" option.
+ 
+ chipset "clgd5424"
+ 
+ 	This option, when used with a 5426/28, will have the effect of
+ 	disabling the use of the BitBLT engine (which the 5424 does not
+ 	have), while retaining some acceleration. This will be useful for
+ 	problems related to the BitBLT engine.
+ 
+ videoram 1024
+ 
+ 	This option will override the detected amount of video memory, and
+ 	pretend there is 1024K on the card. This is useful on cards with
+ 	2Mbyte of memory whose DRAM configuration is not compatible with
+ 	the way the driver enables the upper megabyte of memory.
+ 
+ Option "fifo_conservative"
+ 
+ 	This option will set the CRT FIFO threshold to a conservative value
+ 	for high dot clocks (>= 65 MHz), reducing performance but hopefully
+ 	alleviating problems with 'streaks' on the screen (especially when
+ 	a BitBLT operation is in progress).
+ 
+ Option "fifo_aggressive"
+ 
+ 	This option will set the CRT FIFO threshold to an aggressive value;
+ 	it will be the same as that used for lower dot clocks. It improves
+ 	performance at high dot clocks. It is probably appropriate on the
+ 	543x chips.
+ 
+ Option "no_2mb_banksel"
+ 
+ 	This option will cause the driver not to set the 'DRAM bank select'
+ 	bit to enable the upper megabyte of memory on a 2Mbyte card. This
+ 	should be helpful with cards equipped with 512Kx8 DRAMs, as opposed
+ 	to 256Kx4/16 DRAMs, when using a virtual screen configuration that
+ 	uses more than 1Mbyte of memory.
+ 
+ 
+ 3 - Mode issues
+ 
+ The accelerated driver uses 256 bytes of scratch space in video memory.
+ Consequently, a 1024x1024 virtual resolution cannot be used with a 1Mbyte
+ card. Recommended virtual resolutions are 800x600 on a 512K card,
+ 1152x900 on a card equipped with 1Mbyte of video memory, and 1600x1200
+ on a 2 Mbyte card (apart from problems described above).
+ 
+ The use of a higher dot clock frequencies has a profound negative effect on
+ the performance of graphics operations, especially BitBlt. With default MCLK
+ setting (0x1c), performance with a 65 MHz dot clock can be half of that with
+ a dot clock of 25 MHz, and it becomes much worse with higher dot clocks. The
+ "fast_dram" option helps a bit. For this reason, it is recommended that that
+ lowest dot clock that is acceptable is used; for example, on a 14" or 15"
+ screen 800x600 with high refresh (50 MHz dot clock) is not so bad, with a
+ large virtual screen.
+ 
+ It does not make much sense to use the highest clock (85 MHz) for 1024x768
+ at 76 Hz; the card will almost come to a standstill. A 75 MHz dot clock
+ results in 70 Hz which should be acceptable. If you have a monitor that
+ supports 1024x768 at 76 Hz with a 85 MHz dot clock, a standard 5426/5428
+ based card is a very poor match anyway.
+ 
+ Any 543x-based cards (untested at the time of writing) should do much better
+ at high dot clocks; the DRAM bandwidth is basically double that of the 542x
+ series.
+ 
+ 
+ 4 - Trouble shooting
+ 
+ First of all, make sure that the default mode selected from your Xconfig is
+ supported by your monitor. Make sure you have commented out all modes/dot
+ clock combinations that your monitor does not support. It is best to start
+ with standard 640x480x256 with a 25 MHz clock to make sure the driver works
+ on your configuration. The default mode used will always be the first mode
+ listed in the modes line, with the highest dot clock listed for that
+ resolution in the timing section.
+ 
+ There is a video signal, but the screen doesn't sync.
+ 
+ 	You are using a mode that your monitor cannot handle. If it is
+ 	a non-standard mode, maybe you need to tweak the timings a bit. If
+ 	it is a standard mode and frequency that your monitor should be able
+ 	to handle, try to find different timings for a similar mode and
+ 	frequency combination.
+ 
+ Sparklies/streaks at high dot clocks.
+ 
+ 	You can try the "fast_dram" option, or use a lower dot clock. If
+ 	it happens when moving something on the screen, try the
+ 	"fifo_conservative" option. If that is not sufficient, the "noaccel"
+ 	option or chipset "clgd5424" will probably help.
+ 
+ 'Wavy' screen, horizontal jitter.
+ 
+ 	You are probably using a dot clock that is too high. Try a lower
+ 	dot clock. You can also try to tweak the mode timings; try
+ 	increasing the second horizontal value somewhat. Here's a 65 MHz
+ 	dot clock 1024x768 mode (about 60 Hz) that might help:
+ 
+  "1024x768"     65      1024 1116 1228 1328     768  783  789  818
+ 
+ Crash or hang with after start-up (probably with a black screen).
+ 
+ 	Try the "noaccel" option. If that works, try chipset "clgd5424" for
+ 	somewhat better performance.
+ 
+ Crash, hang, or trash on the screen after a graphics operation, or 'Blitter
+ timeout' messages from the server.
+ 
+ 	This may be related to a bug in one of the accelerated functions, or
+ 	a problem with the BitBLT engine. Try the "noaccel" option, or
+ 	chipset	"clgd5424".
+ 
+ Screen is 'wrapped' vertically.
+ 
+ 	This indicates a DRAM configuration problem. If your card has two
+ 	megabytes of memory, try the "no_2mb_banksel" option, or use
+ 	videoram "1024" if you only use 1 Mbyte for the virtual screen.
+ 
+ Chipset is not detected.
+ 
+ 	Try forcing the chipset with the nearest lower number. For example,
+ 	if you have a 5429 chip (not available at the time of writing), use
+ 	chipset	"clgd5428".
+ 
+ 
+ If are having driver-related problems that are not addressed by this document,
+ or if you have found bugs in accelerated functions, you can try contacting
+ the XFree86 team, or post in the Usenet newsgroup "comp.windows.x.i386unix".
+ 
+ 
+ $XFree86: mit/server/ddx/x386/etc/README.cirrus,v 2.4 1994/03/08 04:50:18 dawes Exp $
diff -c mit/server/ddx/x386/etc/README.clkprog:2.0 mit/server/ddx/x386/etc/README.clkprog:2.1
*** mit/server/ddx/x386/etc/README.clkprog:2.0	Fri Mar 11 23:39:24 1994
--- mit/server/ddx/x386/etc/README.clkprog	Fri Mar 11 23:39:24 1994
***************
*** 17,23 ****
  This facility is enabled by adding a ClockProg line to the Xconfig file.
  The format of this line is:
  
! ClockProg  "comandpath"
  
  where commandpath is the full pathname of the clock setting program.
  No flags are allowed in commandpath.
--- 17,23 ----
  This facility is enabled by adding a ClockProg line to the Xconfig file.
  The format of this line is:
  
! ClockProg  "commandpath"
  
  where commandpath is the full pathname of the clock setting program.
  No flags are allowed in commandpath.
***************
*** 43,49 ****
  ----------------------------------------------
  When such an external program is being used, the server does not change
  any register fields related to clock selection, and the external program
! must be careful to only modifiy clock selection fields.  The program is
  run with stdin and stdout set to x386Info.consoleFd -- which is the
  fd to use for display-related ioctl() operations if required.  Stderr is
  the same as the server's stderr -- so error or warning messages should
--- 43,49 ----
  ----------------------------------------------
  When such an external program is being used, the server does not change
  any register fields related to clock selection, and the external program
! must be careful to only modify clock selection fields.  The program is
  run with stdin and stdout set to x386Info.consoleFd -- which is the
  fd to use for display-related ioctl() operations if required.  Stderr is
  the same as the server's stderr -- so error or warning messages should
***************
*** 71,74 ****
  The idea of using an external clock program was suggested by
  Frank Klemm <pfk@rz.uni-jena.de>
  
! $XFree86: mit/server/ddx/x386/etc/README.clkprog,v 2.0 1993/10/18 12:18:01 dawes Exp $
--- 71,74 ----
  The idea of using an external clock program was suggested by
  Frank Klemm <pfk@rz.uni-jena.de>
  
! $XFree86: mit/server/ddx/x386/etc/README.clkprog,v 2.1 1994/03/08 08:11:10 dawes Exp $
diff -c mit/server/ddx/x386/etc/README.trident:1.8 mit/server/ddx/x386/etc/README.trident:2.2
*** mit/server/ddx/x386/etc/README.trident:1.8	Fri Mar 11 23:39:25 1994
--- mit/server/ddx/x386/etc/README.trident	Fri Mar 11 23:39:25 1994
***************
*** 1,11 ****
- 		Information for Trident Chipset Users
- 		-------------------------------------
  
  Contents
  --------
! 	1) Supported chipsets
! 	2) Special considerations for 512k boards
! 	3) Additional notes
  
  1 - Supported chipsets
  ----------------------
--- 1,12 ----
  
+                 Information for Trident Chipset Users
+                 -------------------------------------
+ 
  Contents
  --------
!         1) Supported chipsets
!         2) Special considerations for 512k boards
!         3) Additional notes
  
  1 - Supported chipsets
  ----------------------
***************
*** 12,24 ****
    The Trident driver has undergone major work between XFree86 1.2 and
  XFree86 1.3.  Because of this work, all of the Trident SVGA chipsets, except
  the very first one, are supported by both the color and monochrome servers.
! Specifically, the following chipsets are supported:
  
! 	8800CS
! 	8900B
! 	8900C
! 	8900CL
! 	9000
  
  The original Trident chipset, 8800BR, cannot be supported as an SVGA chipset 
  by either the color or monochrome servers.  The chip is supported, however, 
--- 13,42 ----
    The Trident driver has undergone major work between XFree86 1.2 and
  XFree86 1.3.  Because of this work, all of the Trident SVGA chipsets, except
  the very first one, are supported by both the color and monochrome servers.
! Additionally support has been added for the latter four chipset with the
! release of XFree86 2.1:
! 
!         8800CS
!         8900B
!         8900C
!         8900CL/D
!         9000
!         9000i
!         9100B
!         9200CX
!         9320
!         9400CX
!         9420
! 
! It must be noted that the 9000i chipset is treated as a 9000 by the server.
! Additionally the 9100B, 9200CX, 9320, 9400CX, and 9420 chipsets are treated 
! as a Trident 8900CL. Therefore it is equivalent to putting 
! 'Chipset "tvga8900cl"' or 'Chipset "tvga9000"' in the Xconfig file.  Also, 
! note that the 9000i, 9100B, and 9320 have not been tested with the server, 
! but should work in this way according to the chipset documentation.
  
! NOTE: No acceleration features of the newer chipsets have been taken advantage
! of.
  
  The original Trident chipset, 8800BR, cannot be supported as an SVGA chipset 
  by either the color or monochrome servers.  The chip is supported, however, 
***************
*** 34,53 ****
  To create timings for the color modes, take the timings for the corresponding 
  monochrome mode, and double the clock.  For example:
  
! 	monochrome timings (taken from Xconfig.sample):
! 	 "640x480"     25      640  664  760  800    480  491  493  525
! 	 "800x600"     36      800  824  896 1024    600  601  603  625
! 
! 	color timings:
! 	 "640x480c"    50      640  664  760  800    480  491  493  525
! 	 "800x600c"    72      800  824  896 1024    600  601  603  625
  
  Be aware that older Trident chipsets support a maximum clock of 65Mhz.  Hence 
  the best actual clock available to the color server is 32.5Mhz.  This means, 
  in broad terms, that the color server will require an interlaced mode to be 
! defined for resolutions above 640x480.  Newer chipsets (8900CL and 9000) 
! support up to 16 clocks, and can support much higher clocks, which will allow 
! 800x600 modes, non-interlaced.
  
  3 - Additional Notes
  --------------------
--- 52,71 ----
  To create timings for the color modes, take the timings for the corresponding 
  monochrome mode, and double the clock.  For example:
  
!         monochrome timings (taken from Xconfig.sample):
!          "640x480"     25      640  664  760  800    480  491  493  525
!          "800x600"     36      800  824  896 1024    600  601  603  625
! 
!         color timings:
!          "640x480c"    50      640  664  760  800    480  491  493  525
!          "800x600c"    72      800  824  896 1024    600  601  603  625
  
  Be aware that older Trident chipsets support a maximum clock of 65Mhz.  Hence 
  the best actual clock available to the color server is 32.5Mhz.  This means, 
  in broad terms, that the color server will require an interlaced mode to be 
! defined for resolutions above 640x480.  Newer chipsets (8900CL, 9000, 9000i,
! 9100B, 9200CX and 9420) support up to 16 clocks, and can support much higher
! clocks, which will allow 800x600 modes, non-interlaced.
  
  3 - Additional Notes
  --------------------
***************
*** 58,64 ****
  the server has problems detecting the dot-clocks, try adding the following 
  line to your Xconfig file:
  
! 	Clocks	25 28 45 36 57 65 50 40
  
  This line gives the clock values provided by older Trident clock synthesizer
  chipsets.  This also appears to be the standard first 8 clocks for the newer
--- 76,82 ----
  the server has problems detecting the dot-clocks, try adding the following 
  line to your Xconfig file:
  
!         Clocks  25 28 45 36 57 65 50 40
  
  This line gives the clock values provided by older Trident clock synthesizer
  chipsets.  This also appears to be the standard first 8 clocks for the newer
***************
*** 73,79 ****
  an 8900B or 8900C, put the following line in your Xconfig file after the
  "vga256" and/or "vga2" line:
  
! 	Option "16clocks"
  
  This will cause the same clock selection code as is used for the 8900CL to
  be used for the board.
--- 91,97 ----
  an 8900B or 8900C, put the following line in your Xconfig file after the
  "vga256" and/or "vga2" line:
  
!         Option "16clocks"
  
  This will cause the same clock selection code as is used for the 8900CL to
  be used for the board.
***************
*** 89,92 ****
  clock speed.  So be prepared for this phenomenon to occur, and have the board
  documentation handy.
  
! $XFree86: mit/server/ddx/x386/etc/README.trident,v 1.8 1993/05/04 10:18:10 dawes Exp $
--- 107,111 ----
  clock speed.  So be prepared for this phenomenon to occur, and have the board
  documentation handy.
  
! 
! $XFree86: mit/server/ddx/x386/etc/README.trident,v 2.2 1994/03/08 08:11:12 dawes Exp $
diff -c /dev/null mit/server/ddx/x386/etc/apSolx86.shar:2.0
*** /dev/null	Fri Mar 11 23:39:25 1994
--- mit/server/ddx/x386/etc/apSolx86.shar	Fri Mar 11 23:39:26 1994
***************
*** 0 ****
--- 1,1339 ----
+ #!/bin/sh
+ # This is a shell archive (produced by shar 3.49)
+ # To extract the files from this archive, save it to a file, remove
+ # everything above the "!/bin/sh" line above, and type "sh file_name".
+ #
+ # made 02/25/1994 17:20 UTC by davidh@dorite
+ # Source directory /usr13/davidh
+ #
+ # $XFree86: mit/server/ddx/x386/etc/apSolx86.shar,v 2.0 1994/02/26 03:14:54 dawes Exp $
+ #
+ # existing files will NOT be overwritten unless -c is specified
+ #
+ # This shar contains:
+ # length  mode       name
+ # ------ ---------- ------------------------------------------
+ #   1343 -rw-r--r-- aperture/Makefile
+ #   4042 -rw-r--r-- aperture/aperture.h
+ #     95 -rw-r--r-- aperture/devlink.tab
+ #   2770 -rw-r--r-- aperture/README
+ #  20528 -rw-r--r-- aperture/aperture.c
+ #    816 -rw-r--r-- aperture/aperture.conf
+ #   3530 -rw-r--r-- aperture/aptest.c
+ #   2174 -rw-r--r-- aperture/DISCLAIMER
+ #
+ # ============= aperture/Makefile ==============
+ if test ! -d 'aperture'; then
+     echo 'x - creating directory aperture'
+     mkdir 'aperture'
+ fi
+ if test -f 'aperture/Makefile' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/Makefile (File already exists)'
+ else
+ echo 'x - extracting aperture/Makefile (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/Makefile' &&
+ #
+ #   File: makefile for aperture Framebuffer Driver
+ # Author: Doug Anson (danson@lgc.com)
+ #   Date: 2/15/94
+ # Modified: David Holland (davidh@use.com)
+ #   Date: 2/23/94
+ #   - Changed name, and debugging structure
+ #
+ # $Id
+ #
+ # Debug flags may be set to the following values:
+ #
+ # APERTURE_DEBUG = 1 -- basic log reporting (mininal)
+ # APERTURE_DEBUG = 2 -- more log reporting (mmap results)
+ # APERTURE_DEBUG = 3 -- verbose log reporting (kernel entry points)
+ #
+ X
+ #
+ # GNU gcc compiler (2.4.5 or 2.5.8)
+ CC=gcc
+ CFLGS=-fno-builtin
+ X
+ #
+ # Proworks compiler (untested!)
+ #CC= /opt/SUNWspro/bin/cc 
+ #CFLGS=-Xa
+ X
+ #
+ # location of lint program (untested!)
+ LINT= /usr/opt/SUNWspro/bin/lint
+ X
+ #
+ # Debug error reporting 
+ #DEBUG_FLG=
+ #DEBUG_FLG=-DAPERTURE_DEBUG=1
+ #DEBUG_FLG=-DAPERTURE_DEBUG=2
+ DEBUG_FLG=-DAPERTURE_DEBUG=3
+ X
+ #
+ # Files and object declarations
+ KERNEL_FLGS=-D_KERNEL -DSUNDDI -I.
+ CFLAGS= $(CFLGS) $(KERNEL_FLGS) $(DEBUG_FLG)
+ CFILES= aperture.c
+ HEADERS= aperture.h
+ OBJS= aperture.o
+ DRIVER= aperture
+ APTEST= aptest
+ APTESTOBJ= aptest.o
+ X
+ # 
+ # Make rules
+ all:	aperture aptest
+ X
+ aperture: $(OBJS)
+ X	ld -r -o aperture aperture.o
+ X
+ install: aperture aptest
+ X	cp aperture aperture.conf /kernel/drv
+ X
+ aptest: $(APTESTOBJ)
+ X	$(CC) -o $(APTEST) $(APTESTOBJ)
+ X
+ clean:
+ X	rm -f *% *.BAK $(OBJS) $(APTESTOBJ) $(APTEST) $(DRIVER) core
+ X
+ lint:
+ X	$(LINT) -D_KERNEL -x -u $(CFILES)
+ SHAR_EOF
+ chmod 0644 aperture/Makefile ||
+ echo 'restore of aperture/Makefile failed'
+ Wc_c="`wc -c < 'aperture/Makefile'`"
+ test 1343 -eq "$Wc_c" ||
+ 	echo 'aperture/Makefile: original size 1343, current size' "$Wc_c"
+ fi
+ # ============= aperture/aperture.h ==============
+ if test -f 'aperture/aperture.h' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/aperture.h (File already exists)'
+ else
+ echo 'x - extracting aperture/aperture.h (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/aperture.h' &&
+ /*
+ X * Copyright 1994  	Doug Anson, danson@lgc.com & David Holland, davidh@use.com
+ X *
+ X * File:   aperture.h
+ X * Author: Doug Anson
+ X * Date:   1/31/94
+ X *
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:		 Modified for new name		2/23/9
+ X *
+ X * Purpose: This header is the master header for the Solaris 2.1 x86
+ X *          framebuffer mmap driver. Portions of this driver are taken
+ X *          from mmapio.h 1.4 copyright 93/06/03 Sun  Microsystems, Inc.
+ X *
+ X * Disclamer:
+ X *
+ X * This code is based largely upon the sample device drivers provided
+ X * by Sun Microsystems Inc.
+ X * 
+ X * Original copyright notice:
+ X * @(#)mmapio.h 1.4 copyright 93/06/03 Sun Microsystems, Inc.
+ X *
+ X * Our copyright notice:
+ X * Permission to use, copy, modify, distribute, and sell this software and its
+ X * documentation for any purpose is hereby granted without fee, provided that
+ X * the above copyright notice appear in all copies and that both that
+ X * copyright notice and this permission notice appear in supporting
+ X * documentation, and that the name of Doug Anson, and David Holland be used in
+ X * advertising or publicity pertaining to distribution of the software 
+ X * Doug Anson, and David Holland make no * representations about the 
+ X * suitability of this software for any purpose.
+ X * It is provided "as is" without express or implied warranty.
+ X *
+ X * Original disclamer from Sun Microsystems, Inc.:
+ X * This is a package of sample device drivers for Solaris 2.x (SunOS
+ X * 5.x).  You may use, modify and distribute these drivers and/or binaries
+ X * derived from them. However please note that:
+ X * 
+ X * These examples are provided with no warranties of any kind, including
+ X * without limitation accuracy and usefulness, and Sun expressly disclaims
+ X * all implied warranties of merchantability, fitness for a particular
+ X * purpose and non-infringement. In no event shall Sun be liable for any
+ X * damages, including without limitation, direct, special, indirect, or
+ X * consequential damages arising out of, or relating to, use of these
+ X * examples by customer or any third party. Sun is under no obligation to
+ X * provide support to customer for this software.
+ X * 
+ X * Our disclaimer:
+ X * DOUG ANSON, AND DAVID HOLLAND DISCLAIMS ALL WARRIENTS WITH REGARD TO THIS 
+ X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS, 
+ X * IN NO EVENT SHALL DOUG ANSON, OR DAVID HOLLAND BE LIABLE FOR ANY SPECIAL, 
+ X * INDIRECT, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM 
+ X * USAGE OF THIS SOFTWARE.
+ X */
+ X
+ /*
+ X * linear framebuffer aperture driver header file
+ X * 
+ X * $Id
+ X */
+ X
+ #ifndef APERTURE_H
+ #define APERTURE_H
+ X
+ /*
+ X * Framebuffer identification definitions 
+ X */
+ #define APERTURE_NAME 		"aperture"
+ #define DEV_BANNER_STRING	"SVGA Framebuffer Driver v0.99"
+ #define DEV_IDENT_STRING	APERTURE_NAME	
+ X
+ /*
+ X * driver.conf(4) "reg" property definition for aperture driver: 
+ X * FORMAT:	reg=AP_REGNUM,AP_ADDR,AP_SIZE
+ X */
+ #define AP_REGNUM	0		/* register number is 1st number in "reg" prop */
+ #define AP_ADDR		1		/* fb base address is 2nd number in "reg" prop */
+ #define AP_SIZE		2		/* fb length value is 3rd number in "reg" prop */
+ #define AP_MAX		3		/* number of values in "reg" property		   */
+ X
+ /*
+ X * How big a chunk of register we map with each ddi_map_regs(9F)
+ X */
+ #define AP_MEM_CHUNK			sizeof(int)
+ X
+ /*
+ X * Error value for mmap(2) failure status 
+ X */
+ #define AP_MEM_FAILURE	-1
+ X
+ /*
+ X * Main memory map structure for the Framebuffer mmap driver
+ X */
+ struct mmap 
+ {
+ X	u_int			 regnum;		/* registers number			   	   */
+ X	volatile caddr_t regbase;		/* base address of device to mmap  */
+ X	off_t		     regsize;		/* length of region to mmap(2)	   */
+ X	off_t			 reglength;		/* map length for ddi_map_regs(9F) */
+ X	volatile caddr_t kaddr;			/* kernel address of mapped device */
+ X	off_t			 off;			/* offset from mmap(2) call		   */
+ X	volatile off_t   mapaddr;		/* base address of mmap(2) region  */
+ X	kmutex_t		 map_lock;		/* device map mutex lock		   */
+ X	dev_info_t	     *dip;			/* device information pointer	   */
+ };
+ typedef struct mmap Mmap;
+ X
+ #endif /* APERTURE_H */
+ SHAR_EOF
+ chmod 0644 aperture/aperture.h ||
+ echo 'restore of aperture/aperture.h failed'
+ Wc_c="`wc -c < 'aperture/aperture.h'`"
+ test 4042 -eq "$Wc_c" ||
+ 	echo 'aperture/aperture.h: original size 4042, current size' "$Wc_c"
+ fi
+ # ============= aperture/devlink.tab ==============
+ if test -f 'aperture/devlink.tab' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/devlink.tab (File already exists)'
+ else
+ echo 'x - extracting aperture/devlink.tab (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/devlink.tab' &&
+ # The following entry is for the SVGA framebuffer driver
+ type=ddi_pseudo;name=aperture	fbs/\M0
+ SHAR_EOF
+ chmod 0644 aperture/devlink.tab ||
+ echo 'restore of aperture/devlink.tab failed'
+ Wc_c="`wc -c < 'aperture/devlink.tab'`"
+ test 95 -eq "$Wc_c" ||
+ 	echo 'aperture/devlink.tab: original size 95, current size' "$Wc_c"
+ fi
+ # ============= aperture/README ==============
+ if test -f 'aperture/README' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/README (File already exists)'
+ else
+ echo 'x - extracting aperture/README (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/README' &&
+ Framebuffer apperture driver.
+ X
+ (Note, see the DISCLAIMER file before using this driver!
+ X  - Sorry, we've gotta cover ourselves)
+ X
+ This driver was written to help work around one particular limitation in the
+ x86 /dev/mem driver.
+ X
+ 1) No Solaris x86 device we've found allows access to memory regions that 
+ X   exist above the amount of RAM in the machine.  So one could not 
+ X   access the linear frame buffer of a Mach32 VLB board that decodes
+ X   is memory aperture at the 124Megabyte mark.
+ X
+ This driver attempts to work around some of those problems. All it simply
+ does is allow a user to mmap() any physical address less than 128Megs
+ back into user address space. 
+ X
+ It is the corroborative work of Doug Anson (danson@lgc.com), and 
+ David Holland (davidh@use.com).
+ X
+ Many thanks to the XFree86[tm] Alpha, and Beta teams, for without 
+ all their hard work, there wouldn't be any need for this driver.
+ X
+ Installation instructions:
+ X
+ 1) Check the Makefile, for appropriate CC, and CFLAGS defintions.
+ X   Compiling with APERTURE_DEBUG defined (via -DAPERTURE_DEBUG=?) means 
+ X   the driver will generate reams of debugging output.  You'll probably 
+ X   want to leave this off, or set to zero..
+ X
+ 2) type 'make'.  The driver and test program should compile with out any
+ X   problems.  There also should not be any warning messages.
+ X
+ 3) Become 'root'.
+ X
+ 4) type 'make install' and run 'add_drv /kernel/drv/aperture'.
+ X   The screen should look something like this:
+ X
+ X	# make install
+ X	cp aperture aperture.conf /kernel/drv
+ X	# add_drv /kernel/drv/mmap
+ X
+ X   This installs the driver in the system. 
+ X
+ 5) While as root modify the file /etc/devlink.tab, adding these lines:
+ X
+ # The following entry is for the SVGA framebuffer driver
+ type=ddi_pseudo;name=aperture	fbs/\M0
+ X
+ X   Add that line exactly as shown. You may also simply add the 
+ X   contents of the devlink.tab file supplied to /etc/devlink.tab.
+ X   It contains the lines as well.
+ X
+ 6) Reboot the system.
+ X
+ 7) Login as root and run the aptest program. It tests that the 
+ X   mmap driver is working properly, by mmaping the main bios
+ X   into user address space.  If you happen to have AMI bios the
+ X   output will look something like so:
+ X
+ # ./aptest
+ NOTICE: BIOS mapped [0xf0000 ,size=4096) to addr=0x8000b000...
+ 0123AAAAMMMMIIII05/05/91(C)1990 American Megatrends Inc., All Rights Reserved
+ DONE displaying memory contents (80 bytes)
+ UNMAPPING [0xf0000 ,size=4096) to addr=0x8000b000... and closing...DONE.
+ Exiting successful...
+ #
+ X
+ X
+ 8) Nope, there are not any man pages, I don't know nroff.  As for programming
+ X   suggestions, take a look at aptest.c a working example is obviously
+ X   in there.
+ X
+ Bug reports, questions, suggestions, etc can be sent to 
+ X
+ Doug Anson
+ danson@lgc.com
+ X
+ X or
+ X
+ David Holland
+ davidh@use.com
+ X
+ Flames can be sent to 
+ /dev/null
+ SHAR_EOF
+ chmod 0644 aperture/README ||
+ echo 'restore of aperture/README failed'
+ Wc_c="`wc -c < 'aperture/README'`"
+ test 2770 -eq "$Wc_c" ||
+ 	echo 'aperture/README: original size 2770, current size' "$Wc_c"
+ fi
+ # ============= aperture/aperture.c ==============
+ if test -f 'aperture/aperture.c' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/aperture.c (File already exists)'
+ else
+ echo 'x - extracting aperture/aperture.c (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/aperture.c' &&
+ /*
+ X * Copyright 1994  	Doug Anson, danson@lgc.com & David Holland, davidh@use.com
+ X *
+ X * File:   aperture.c
+ X * Author: Doug Anson (danson@lgc.com)
+ X * Date:   1/31/94
+ X * 
+ X * Modified: David Holland (davidh@use.com)
+ X * Date:     2/23/94
+ X * Changes: Changed general name of driver
+ X * 			Debugging flags
+ X * 			Removed a few extraneous erorr messages.
+ X * 		
+ X *
+ X * Purpose: This file is the master device file for the Solaris 2.1 x86
+ X *          framebuffer aperture driver. Portions of this driver are taken
+ X *          from mmap.c 1.4 copyright 93/06/03 Sun  Microsystems, Inc.
+ X *          (Sample memory mapped driver for Solaris 2.0/Sun OS 5.0)
+ X *
+ X *      	This driver allows accelerated SVGA graphics cards that are
+ X *			attached vi 32-bit paths (VESA/EISA/MC) and that have 
+ X *			linear framebuffer capabilities to have their framebuffer
+ X *			memory mapped into the user process space.
+ X *
+ X * Disclamer:
+ X *
+ X * This code is based largely upon the sample device drivers provided
+ X * by Sun Microsystems Inc.
+ X * 
+ X * Original copyright notice:
+ X * @(#)mmap.c     1.3 copyright 93/06/03 Sun Microsystems, Inc.
+ X *
+ X * Our copyright notice:
+ X * Permission to use, copy, modify, distribute, and sell this software and its
+ X * documentation for any purpose is hereby granted without fee, provided that
+ X * the above copyright notice appear in all copies and that both that
+ X * copyright notice and this permission notice appear in supporting
+ X * documentation, and that the name of Doug Anson, and David Holland be used in
+ X * advertising or publicity pertaining to distribution of the software 
+ X * Doug Anson, and David Holland make no * representations about the 
+ X * suitability of this software for any purpose.
+ X * It is provided "as is" without express or implied warranty.
+ X *
+ X * Original disclamer from Sun Microsystems, Inc.:
+ X * This is a package of sample device drivers for Solaris 2.x (SunOS
+ X * 5.x).  You may use, modify and distribute these drivers and/or binaries
+ X * derived from them. However please note that:
+ X * 
+ X * These examples are provided with no warranties of any kind, including
+ X * without limitation accuracy and usefulness, and Sun expressly disclaims
+ X * all implied warranties of merchantability, fitness for a particular
+ X * purpose and non-infringement. In no event shall Sun be liable for any
+ X * damages, including without limitation, direct, special, indirect, or
+ X * consequential damages arising out of, or relating to, use of these
+ X * examples by customer or any third party. Sun is under no obligation to
+ X * provide support to customer for this software.
+ X * 
+ X * Our disclaimer:
+ X * DOUG ANSON, AND DAVID HOLLAND DISCLAIMS ALL WARRIENTS WITH REGARD TO THIS 
+ X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS, 
+ X * IN NO EVENT SHALL DOUG ANSON, OR DAVID HOLLAND BE LIABLE FOR ANY SPECIAL, 
+ X * INDIRECT, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM 
+ X * USAGE OF THIS SOFTWARE.
+ X */
+ X
+ /*
+ X * linear framebuffer aperture driver
+ X * 
+ X * $Id
+ X */
+ X
+ #include <sys/types.h>
+ #include <sys/param.h>
+ #include <sys/errno.h>
+ #include <sys/file.h>
+ #include <sys/conf.h>
+ #include <sys/uio.h>
+ #include <sys/map.h>
+ #include <sys/debug.h>
+ #include <sys/modctl.h>
+ #include <sys/kmem.h>
+ #include <sys/cmn_err.h>
+ #include <sys/open.h>
+ #include <sys/stat.h>
+ #include <sys/ddi.h>
+ #include <sys/sunddi.h>
+ X
+ #include "aperture.h"
+ X
+ /* opaque handle top of state structs */
+ static	void *state_head = NULL;
+ X
+ /* 
+ X * Solaris DDI/DKI driver entry points
+ X */
+ #if defined(__STDC__)
+ static	int	aperture_getinfo(dev_info_t *, ddi_info_cmd_t, void *,void **);
+ static	int	aperture_identify(dev_info_t *dip);
+ static  int aperture_probe(dev_info_t *dip);
+ static	int	aperture_attach(dev_info_t *, ddi_attach_cmd_t);
+ static	int	aperture_open(dev_t *, int, int, cred_t *);
+ static	int	aperture_close(dev_t, int, int, cred_t *);
+ static	int	aperture_detach(dev_info_t *, ddi_detach_cmd_t);
+ static	int	aperture_mmap(dev_t, off_t, int);
+ #else
+ static  int	aperture_getinfo();
+ static  int	aperture_identify();
+ static  int	aperture_probe();
+ static  int	aperture_attach();
+ static  int	aperture_open();
+ static  int	aperture_close();
+ static  int	aperture_detach();
+ static  int	aperture_mmap();
+ #endif /* __STDC__ */
+ X
+ /*
+ X * Solaris DDI/DKI module linkeage structure declarations
+ X */
+ static struct cb_ops	aperture_cb_ops = 
+ {
+ X	aperture_open,			/* XXopen routine						*/
+ X	aperture_close,			/* XXclose routine						*/
+ X	nodev,					/* XXstrategy routine					*/
+ X	nodev,					/* XXprint routine	    				*/
+ X	nodev,					/* XXdump routine	    				*/
+ X	nodev,					/* XXread routine	    				*/
+ X	nodev,					/* XXwrite routine 						*/
+ X	nodev,					/* XXioctl routine 						*/
+ X	nodev,					/* XXdevmap routine						*/
+ X	aperture_mmap,			/* XXmmap routine						*/
+ X	ddi_segmap,				/* XXsegmap routine						*/
+ X	nochpoll,				/* XXchpoll routine						*/
+ X	ddi_prop_op,			/* XXprop_op routine					*/	
+ X	(struct streamtab *)0,	/* not a STREAMS driver				 	*/
+ X	D_NEW | D_MP,			/* safe for multi-thread/multi-processor*/
+ };
+ X
+ static struct dev_ops aperture_ops = 
+ {
+ X	DEVO_REV,				/* DEVO_REV indicated by manual		*/
+ X	0,						/* device reference count	    	*/
+ X	aperture_getinfo,		/* devo_getinfo routine				*/
+ X	aperture_identify,		/* devo_identiry routine			*/
+ X	aperture_probe,			/* device probe for non-self-id 	*/
+ X	aperture_attach,		/* devo_attach routine				*/
+ X	aperture_detach,		/* devo_detach routine				*/
+ X	nodev,					/* device reset routine				*/
+ X	&aperture_cb_ops,		/* cb_ops structure pointer			*/
+ X	(struct bus_ops *)0,	/* bus operations					*/
+ };
+ X
+ extern	struct	mod_ops mod_driverops;
+ static	struct modldrv modldrv = 
+ {
+ X	&mod_driverops,					/* mod_ops structure pointer 	*/
+ X	DEV_BANNER_STRING,				/* device banner string			*/
+ X	&aperture_ops,					/* dev_ops structure pointer 	*/
+ };
+ X
+ static	struct modlinkage modlinkage = 
+ {
+ X	MODREV_1,			/* as indicated indicated by manual 	 		*/
+ X	(void *)&modldrv,	/* module driver structure pointer				*/
+ X	NULL,				/* termination of list of linkage structures 	*/
+ };
+ X
+ /*
+ X * Function: _init()
+ X * Purpose:  Solaris DDI/DKI _init(9E) entry point
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Log:		DMA -- Origional Version
+ X * 		DWH - Removed extra cmn_err() calls 	2/23/94
+ X * 		DWH - Changed debugging 		2/23/94
+ X */
+ #if defined(__STDC__)
+ int _init(void)
+ #else
+ int _init()
+ #endif /* __STDC__ */
+ {
+ X	register int	error;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X        /* enterance announcement */
+ X        cmn_err(CE_CONT,"%s: entering _init(aperture)\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X
+ X	if ((error = ddi_soft_state_init(&state_head, sizeof (Mmap), 1)) != 0)
+ X	{
+ X		/* failed to get state structure */
+ X		return (error);
+ X	}
+ X
+ X	if ((error = mod_install(&modlinkage)) != 0)
+ X		ddi_soft_state_fini(&state_head);
+ X
+ X	return (error);
+ }
+ X
+ /*
+ X * Function: _info()
+ X * Purpose:  Solaris DDI/DKI _info(9E) entry point
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - Changed debugging 	2/23/94
+ X */
+ #if defined(__STDC__)
+ int _info(struct modinfo *modinfop)
+ #else
+ int _info(modinfop)
+ struct modinfo *modinfop;
+ #endif /* __STDC__ */
+ {
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X	/* entrance announcement */
+ X	cmn_err(CE_CONT,"%s: entering _info(aperture)\n", DEV_IDENT_STRING);
+ X
+ #endif /* APERTURE_DEBUG >= 3 */
+ X
+ X	return (mod_info(&modlinkage, modinfop));
+ }
+ X
+ /*
+ X * Function: _fini()
+ X * Purpose:  Solaris DDI/DKI _fini(9E) entry point
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - Changed debugging
+ X */
+ #if defined(__STDC__)
+ int _fini(void)
+ #else
+ int _fini()
+ #endif /* __STDC__ */
+ {
+ X	int status;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ /* entrance announcement */
+ cmn_err(CE_CONT,"%s: entering _fini(aperture)\n", DEV_IDENT_STRING);
+ X
+ #endif /* APERTURE_DEBUG >= 3*/
+ X
+ X	if ((status = mod_remove(&modlinkage)) != 0)
+ X		return (status);
+ X
+ X	ddi_soft_state_fini(&state_head);
+ X
+ X	return (status);
+ }
+ X
+ /*
+ X * Function: aperture_getinfo()
+ X * Purpose:  This function provides the getinfo(9E) functionality 
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - Changed function name/variables/debugging	2/23/94
+ X */
+ #if defined(__STDC__)
+ static int aperture_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, 
+ X						  void *arg, void **result)
+ #else
+ static int aperture_getinfo(dip,infocmd,arg,result)
+ dev_info_t     *dip;
+ ddi_info_cmd_t infocmd;
+ void           *arg;
+ void           **result;
+ #endif /* __STDC__ */
+ {
+ X	register int 	error;
+ X	register Mmap	*aperture_p = NULL;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X        /* enterance announcement */
+ X        cmn_err(CE_CONT,"%s: entering aperture_getinfo()\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X
+ X	switch (infocmd) 
+ X	{
+ X	    case DDI_INFO_DEVT2DEVINFO:
+ X			aperture_p = (Mmap *)ddi_get_soft_state(state_head, getminor((dev_t)arg));
+ X			if (aperture_p == NULL) 
+ X			{
+ X				/* could not get state structure */
+ X				*result = NULL;
+ X				error = DDI_FAILURE;
+ X			} 
+ X			else 
+ X			{
+ X				/* got state structure */
+ X				*result = aperture_p->dip;
+ X				error = DDI_SUCCESS;
+ X			}
+ X			break;
+ X		case DDI_INFO_DEVT2INSTANCE:
+ X			*result = (void *)getminor((dev_t)arg);
+ X			error = DDI_SUCCESS;
+ X			break;
+ X		default:
+ X			*result = NULL;
+ X			error = DDI_FAILURE;
+ X			break;
+ X	}
+ X	return (error);
+ }
+ X
+ /*
+ X * Function: aperture_identify()
+ X * Purpose:  This function implements the identify(9E) functionality
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - Changed function name/debugging/variables	2/23/94
+ X */
+ #if defined(__STDC__)
+ static int aperture_identify(dev_info_t *dip)
+ #else
+ static int aperture_identify(dip)
+ dev_info_t *dip;
+ #endif /* __STDC__ */
+ {
+ #if APERTURE_DEBUG >= 3
+ X
+ X        /* entrance announcement */
+ X        cmn_err(CE_CONT,"%s: entering aperture_identify()\n", DEV_IDENT_STRING);
+ X
+ #endif 
+ X
+ X	/* check the driver name and respond */
+ X	if (strcmp(ddi_get_name(dip), APERTURE_NAME) == 0)
+ X		return (DDI_IDENTIFIED); 		/* device driver is identified */
+ X	else
+ X		return (DDI_NOT_IDENTIFIED);	/* device driver not identified */
+ }
+ X
+ /*
+ X * Function: aperture_probe()
+ X * Purpose:  This function implements the probe(9E) functionality.
+ X *		     Currently this function returns a "dont care" result
+ X *			 as nothing is probed.
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modfied:	 David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - changed function name/variables/debugging	2/23/94
+ X */
+ #if defined(__STDC__)
+ static int aperture_probe(dev_info_t *dip)
+ #else
+ static int aperture_probe(dip)
+ dev_info_t *dip;
+ #endif /* __STDC__ */
+ {
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X        /* enterance announcement */
+ X        cmn_err(CE_CONT,"%s: entering aperture_probe()\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X
+ X	/* return success as we really aren't probing for anything */
+ X	return (DDI_PROBE_SUCCESS);
+ }
+ X
+ /*
+ X * Function: aperture_attach()
+ X * Purpose:  This function implements the attach(9E) functionality
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - changed function name/variables/debugging	2/23/94
+ X */
+ #if defined(__STDC__)
+ static int aperture_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
+ #else
+ static int aperture_attach(dip,cmd)
+ dev_info_t       *dip;
+ ddi_attach_cmd_t cmd;
+ #endif /* __STDC__ */
+ {
+ X	register Mmap  *aperture_p = NULL;
+ X	int			   buf[AP_MAX];
+ X	int			   length;
+ X	int			   instance;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X        /* entrance announcement */
+ X        cmn_err(CE_CONT,"%s: entering aperture_attach()\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X
+ X	/* only continue if doing a DDI_ATTACH */
+ X	if (cmd == DDI_ATTACH)
+ X	{
+ X		/* get and initialize our state structure */
+ X		instance = ddi_get_instance(dip);
+ X		if (ddi_soft_state_zalloc(state_head, instance) != DDI_SUCCESS)
+ X		{
+ X			/* could not allocate state structure */
+ X			return (DDI_FAILURE);
+ X		}
+ X
+ X		/* get the state structure */
+ X		aperture_p = (Mmap *)ddi_get_soft_state(state_head, instance);
+ X
+ X		if (aperture_p == NULL)
+ X		{
+ X			/* failed to get the soft state */
+ X			return (DDI_FAILURE);
+ X		}
+ X
+ X		/* initialize the mutex driver (ATOMIC) */
+ X		mutex_init(&aperture_p->map_lock, "apperture mmap lock", MUTEX_DRIVER, 0);
+ X
+ X		/* ENTER the critical region */
+ X		mutex_enter(&aperture_p->map_lock);
+ X		
+ X		/* get the "reg" property from the .conf file */
+ X		length = sizeof(buf);
+ X		if (ddi_getlongprop_buf(DDI_DEV_T_ANY, dip, DDI_PROP_DONTPASS, "reg", (caddr_t)buf, &length) != DDI_PROP_SUCCESS)
+ X		{
+ X			/* could not get the framebuffer properties */
+ X			return (DDI_FAILURE);
+ X		}
+ X
+ X		/* remember our register configuration */
+ X        aperture_p->regnum  = (u_int)buf[AP_REGNUM];
+ X        aperture_p->regbase = (caddr_t)buf[AP_ADDR];
+ X        aperture_p->regsize = (off_t)buf[AP_SIZE];
+ X
+ X		/* initialize the mmap state info */
+ X		aperture_p->reglength = (off_t)AP_MEM_CHUNK;
+ X		aperture_p->kaddr	 = (caddr_t)0;
+ X        aperture_p->off     = (off_t)0;
+ X        aperture_p->mapaddr = AP_MEM_FAILURE;
+ X
+ X		/* initialize internal accounting */
+ X        aperture_p->dip     = dip;
+ X
+ X		/* EXIT the critical region */
+ X		mutex_exit(&aperture_p->map_lock);
+ X
+ X		/* create the device node */
+ X		/* DDI_PSEUDO, CLONE_DEV */
+ X		if (ddi_create_minor_node(dip, ddi_get_name(dip), S_IFCHR, instance, NULL, (int)NULL) == DDI_FAILURE) 
+ X		{
+ X			/* failed to make the device leaf or in error state */
+ X			mutex_destroy(&aperture_p->map_lock);
+ X			ddi_soft_state_free(state_head, instance);
+ X			return (DDI_FAILURE);
+ X		}
+ X
+ X		/* device driver attached successfully */
+ X		ddi_report_dev(aperture_p->dip);
+ X		return (DDI_SUCCESS);
+ X	}
+ X	else
+ X	{
+ X		/* command not DDI_ATTACH -- return failure */
+ X		return (DDI_FAILURE);
+ X	}
+ }
+ X
+ /*
+ X * Function: aperture_detach()
+ X * Purpose:  This function implements the detach(9E) functionality
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - changed function name/variables/debugging	2/23/94
+ X */
+ #if defined(__STDC__)
+ static int aperture_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
+ #else
+ static int aperture_detach(dip,cmd)
+ dev_info_t       *dip;
+ ddi_detach_cmd_t cmd;
+ #endif /* __STDC__ */
+ {
+ X	register Mmap  	*aperture_p = NULL;	
+ X	int		       	instance;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X	/* entrance announcement */
+ X	cmn_err(CE_CONT,"%s: entering aperture_detach()\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X
+ X	/* check the parameter list */
+ X	if (cmd != DDI_DETACH)
+ X	{
+ X		return (DDI_FAILURE);
+ X	}
+ X
+ X	/* get the instance info and state structure */
+ X	instance = ddi_get_instance(dip);
+ X	aperture_p = (Mmap *)ddi_get_soft_state(state_head, instance);
+ X	if (aperture_p == NULL)
+ X	{
+ X		/* failed to get the soft state */
+ X		return (DDI_FAILURE);
+ X	}
+ X
+ X	/* clean up the driver */
+ X	mutex_destroy(&aperture_p->map_lock);
+ X	ddi_remove_minor_node(dip, NULL);
+ X	ddi_soft_state_free(state_head, instance);
+ X
+ X    /* device driver detached successfully */
+ X	return (DDI_SUCCESS);
+ }
+ X
+ /*
+ X * Function: aperture_open()
+ X * Purpose:  This function is called in response to the open(2) system call
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - Changed function name/variables/debugging
+ X */
+ #if defined(__STDC__)
+ static	int aperture_open(dev_t *dev, int openflags, int otyp, cred_t *credp)
+ #else
+ static	int aperture_open(dev, openflags, otyp, credp)
+ dev_t  *dev;
+ int    openflags;
+ int    otyp;
+ cred_t *credp;
+ #endif /* __STDC__ */
+ {
+ X	register Mmap	*aperture_p = NULL;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X	/* entrance announcement */
+ X	cmn_err(CE_CONT,"%s: entering aperture_open()\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X
+ X	/* get the state structure */
+ X	aperture_p = (Mmap *)ddi_get_soft_state(state_head, getminor(*dev));
+ X	if (aperture_p == NULL)
+ X	{
+ X		/* failed to get the soft state */
+ X		return (ENXIO);
+ X	}
+ X
+ X	/* check the parameter list for correctness */
+ X	if (otyp != OTYP_CHR)
+ X	{
+ X		/* invalid parameter list */
+ X		return (EINVAL);
+ X	}
+ X
+ X	return (0);
+ }
+ X
+ /*
+ X * Function: aperture_close()
+ X * Purpose:  This function is called after the last process that has 
+ X * 		     the device open calls close(2)
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - changed function name/variables/debugging	2/23/94
+ X */
+ #if defined(__STDC__)
+ static	int aperture_close(dev_t dev, int closeflags, int otyp, cred_t *credp)
+ #else
+ static	int aperture_close(dev, closeflags, otyp, credp)
+ dev_t  dev;
+ int    closeflags;
+ int    otyp;
+ cred_t *credp;
+ #endif /* __STDC__ */
+ {
+ X	register Mmap	*aperture_p = NULL;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X        /* enterance announcement */
+ X        cmn_err(CE_CONT,"%s: entering aperture_close()\n", DEV_IDENT_STRING);
+ X
+ #endif 
+ X
+ X	/* get the state structure */
+ X    aperture_p = (Mmap *)ddi_get_soft_state(state_head, getminor(dev));
+ X    if (aperture_p == NULL)
+ X	{
+ X		/* failed to get the soft state */
+ X        return (ENXIO);
+ X	}
+ X
+ X	/* check the paramter list for correctness */
+ X    if (otyp != OTYP_CHR)
+ X	{
+ X		/* invalid parameter */
+ X        return (EINVAL);
+ X	}
+ X
+ X	/* do nothing but return successful */
+ X    return (0);
+ }
+ X
+ /*
+ X * Function: aperture_mmap()
+ X * Purpose:  This function gets called when the user process tries to mmap 
+ X *			 the framebuffer device using mmap(2).
+ X * Author:   Doug Anson
+ X * Calls:     
+ X * Modified: David Holland (davidh@use.com)
+ X * Log:      DMA -- Origional Version
+ X * 			 DWH - changed function name/variables/debugging	2/23/94
+ X */
+ #if defined(__STDC__)
+ static int aperture_mmap(dev_t dev, off_t off, int prot)
+ #else
+ static int aperture_mmap(dev, off, prot)
+ dev_t dev;
+ off_t off;
+ int   prot;
+ #endif /* __STDC__ */
+ {
+ X	register Mmap	*aperture_p = NULL;
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X        /* enterance announcement */
+ X        cmn_err(CE_CONT,"%s: entering aperture_mmap()\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X
+ X	/* get the state structure */
+ X	aperture_p = (Mmap *)ddi_get_soft_state(state_head, getminor(dev));
+ X	if (aperture_p == NULL)
+ X	{
+ X		/* failed to get the soft state */
+ X		return (AP_MEM_FAILURE);
+ X	}
+ X
+ X	/* check that we dont mmap out of bounds */
+ X	if (off > aperture_p->regsize)
+ X	{
+ X		/* offset is out of range for register length */
+ X		return (AP_MEM_FAILURE);
+ X	}
+ X
+ X	/* check that READ/WRITE only priv only */
+ X	if (!((prot & PROT_READ) || (prot & PROT_WRITE)))
+ X	{
+ X		/* invalid prot parameter in mmap(2) call */
+ X        return (AP_MEM_FAILURE);
+ X	} 
+ X
+ X	/* ENTER the critical region */
+ X	mutex_enter(&aperture_p->map_lock);
+ X
+ X	/* map the registers  CRITICAL REGION ASSIGNMENT */
+ X
+ X	aperture_p->off = off;
+ X    if (ddi_map_regs(aperture_p->dip, aperture_p->regnum, (caddr_t *)&(aperture_p->kaddr), 
+ X		aperture_p->off, aperture_p->reglength) == DDI_FAILURE)
+ X	{
+ X
+ #if APERTURE_DEBUG >= 2
+ X
+ X		/* report error */
+ X		cmn_err(CE_CONT, "%s: ERROR: mmap failed (map regs). kaddr=0x%x off=0x%x\n", 
+ X			DEV_IDENT_STRING,aperture_p->kaddr,aperture_p->off);
+ X
+ #endif
+ X
+ X		aperture_p->mapaddr = (off_t)AP_MEM_FAILURE;
+ X	}
+ X	else
+ X	{
+ X		/* fill in our state structure  CRITICAL REGION ASSIGNMENT */
+ X	   	aperture_p->mapaddr  = (off_t)hat_getkpfnum((caddr_t)aperture_p->kaddr); 
+ X		if ((u_int)aperture_p->mapaddr == (u_int)AP_MEM_FAILURE)
+ X		{
+ X
+ #if APERTURE_DEBUG >= 2
+ X
+ X			/* report error */
+ X			cmn_err(CE_CONT, "%s: ERROR: mmap failed (kpf). kaddr=0x%x off=0x%x\n", 
+ X				DEV_IDENT_STRING,aperture_p->kaddr,aperture_p->off);
+ #endif 
+ X
+ X		}
+ X
+ X	    /* now unmap the region  CRITICAL REGION ASSIGNMENT */
+ X
+ X       	 ddi_unmap_regs(aperture_p->dip, aperture_p->regnum, (caddr_t *)&(aperture_p->kaddr), 
+ X			aperture_p->off, aperture_p->reglength);
+ X
+ #if APERTURE_DEBUG >= 2
+ X  		/* report register mmaping status */
+ X		if (aperture_p->mapaddr != AP_MEM_FAILURE)
+ X		{
+ X			/* mmap successful */
+ X   			cmn_err(CE_CONT,"%s: mmap [off=0x%x,length=0x%x) successful\n", 
+ X				DEV_IDENT_STRING,aperture_p->off,aperture_p->regsize);
+ X
+ X    		cmn_err(CE_CONT,"%s: configuration:\n",DEV_IDENT_STRING);
+ X    		cmn_err(CE_CONT,"    REG(%d): regbase=0x%x regsize=0x%x\n", 
+ X				aperture_p->regnum, aperture_p->regbase, aperture_p->regsize);
+ X
+ X    		cmn_err(CE_CONT,"    kaddr=0x%x mmap off=0x%x mmap addr=0x%x\n", 
+ X				aperture_p->kaddr, aperture_p->off, aperture_p->mapaddr);
+ X		}
+ X		else
+ X		{
+ X			/* error in mmap routine */
+ X			cmn_err(CE_CONT,"%s: mmap not established due to errors", DEV_IDENT_STRING);
+ X		}
+ #endif
+ X
+ X	}
+ X
+ X    /* EXIT the critical region */
+ X    mutex_exit(&aperture_p->map_lock);
+ X
+ X	/* return the page frame number (PFN) */
+ X
+ #if APERTURE_DEBUG >= 3
+ X
+ X	/* report exit - determining where the long delay is... */
+ X	cmn_err(CE_CONT, "%s: _mmap routine exiting\n", DEV_IDENT_STRING);
+ X
+ #endif
+ X	
+ X	return ((int)(aperture_p->mapaddr));
+ }
+ SHAR_EOF
+ chmod 0644 aperture/aperture.c ||
+ echo 'restore of aperture/aperture.c failed'
+ Wc_c="`wc -c < 'aperture/aperture.c'`"
+ test 20528 -eq "$Wc_c" ||
+ 	echo 'aperture/aperture.c: original size 20528, current size' "$Wc_c"
+ fi
+ # ============= aperture/aperture.conf ==============
+ if test -f 'aperture/aperture.conf' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/aperture.conf (File already exists)'
+ else
+ echo 'x - extracting aperture/aperture.conf (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/aperture.conf' &&
+ #
+ # Copyright 1994	Doug Anson, danson@lgc.com & David Holland, davidh@use.com
+ #
+ # File:   fbmem.conf
+ # Author: Doug Anson (danson@lgc.com)
+ # 
+ # Modified: David Holland (davidh@use.com)
+ # Log:		Change comments		2/23/94
+ #
+ # Purpose: 	This conf file is used by the aperture Framebuffer mmap 
+ # 			driver. The only portion of this configuration file 
+ # 			should be changed is possibly the last entry in the
+ #			'reg' propery.  This entry controls the maximum address
+ #			the driver is allowed to access.  It is set to
+ #			128Megs (0x8000000).  If your framebuffer apperture
+ # 			happens to lay at a address greater than this
+ #			change it appropriately. Do NOT! change the first
+ #			two numbers of of the 'reg' property. They should be
+ #			0, and 0x0, respectivly.
+ #
+ name="aperture" class="sysbus" reg=0,0x0,0x8000000;
+ SHAR_EOF
+ chmod 0644 aperture/aperture.conf ||
+ echo 'restore of aperture/aperture.conf failed'
+ Wc_c="`wc -c < 'aperture/aperture.conf'`"
+ test 816 -eq "$Wc_c" ||
+ 	echo 'aperture/aperture.conf: original size 816, current size' "$Wc_c"
+ fi
+ # ============= aperture/aptest.c ==============
+ if test -f 'aperture/aptest.c' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/aptest.c (File already exists)'
+ else
+ echo 'x - extracting aperture/aptest.c (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/aptest.c' &&
+ /* 
+ X * Copyright 1994  	Doug Anson, danson@lgc.com & David Holland, davidh@use.com
+ X *
+ X * Author: Doug Anson (danson@lgc.com)
+ X * Date  : 2/21/94
+ X * Modifed: David Holland (davidh@use.com)
+ X * Log:
+ X * 		DWH - Changed names/added comments	2/23/94
+ X * 		DWH - Removed annoying delays.		2/23/94
+ X * 
+ X * This program test the fb aperture driver by 'cheating'
+ X * it uses the aperture driver to access/read the main
+ X * system BIOS header
+ X * 
+ X * Copyright notice:
+ X * Permission to use, copy, modify, distribute, and sell this software and its
+ X * documentation for any purpose is hereby granted without fee, provided that
+ X * the above copyright notice appear in all copies and that both that
+ X * copyright notice and this permission notice appear in supporting
+ X * documentation, and that the name of Doug Anson, and David Holland be used in
+ X * advertising or publicity pertaining to distribution of the software 
+ X * Doug Anson, and David Holland make no * representations about the 
+ X * suitability of this software for any purpose.
+ X * It is provided "as is" without express or implied warranty.
+ X *
+ X * Disclaimer:
+ X * DOUG ANSON, AND DAVID HOLLAND DISCLAIMS ALL WARRIENTS WITH REGARD TO THIS 
+ X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS, 
+ X * IN NO EVENT SHALL DOUG ANSON, OR DAVID HOLLAND BE LIABLE FOR ANY SPECIAL, 
+ X * INDIRECT, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM 
+ X * USAGE OF THIS SOFTWARE.
+ X */
+ X
+ /*
+ X * linear framebuffer aperture driver test program
+ X */
+ X
+ /* 
+ X * $Id
+ X */
+ X
+ X
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <sys/mman.h>
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ #include <errno.h>
+ X
+ #if !defined(sun)
+ extern void exit(int);
+ extern caddr_t mmap();
+ extern int close();
+ extern int munmap();
+ #endif
+ X
+ /* framebuffer access defines */
+ #define AP_DEV		"/dev/fbs/aperture"	/* framebuffer apperture device		*/
+ #define PADDR		0xf0000				/* offset from fbmem base     		*/
+ #define BUF_LENGTH  0x1000				/* length in bytes -- ignored 		*/
+ X
+ /* debug testing defines */
+ #define START_INDEX	0		/* display starting index(>=0)*/
+ #define STOP_INDEX	80		/* display stopping index	  */
+ #define INCR		1		/* display increment		  */
+ X
+ /* main program */
+ int main(int argc,char **argv)
+ {
+ X	caddr_t	addr = (caddr_t)0;
+ X	int		fb_dev;
+ X	long	start = START_INDEX;
+ X	long	stop = STOP_INDEX;
+ X	int		i;
+ X
+ X	/* open the framebuffer device */
+ X	fb_dev = open (AP_DEV,O_RDWR);
+ X	if (fb_dev < 0)
+ X	{
+ X		/* failed to open framebuffer driver */
+ X		printf("ERROR: failed to open %s\n",AP_DEV);
+ X		perror("ERROR: open()");
+ X		exit(1);
+ X	} 
+ X
+ X	/* memory map the framebuffer */
+ X	addr = (caddr_t)mmap((caddr_t)0,BUF_LENGTH,PROT_READ|PROT_WRITE,MAP_SHARED,
+ X			             fb_dev,(off_t)PADDR);
+ X	if (addr == (caddr_t)-1)
+ X	{
+ X		/* failed to memory map framebuffer driver */
+ X		printf("ERROR: failed to mmap [0x%x ,size=%d bytes)\n",
+ X			   PADDR,BUF_LENGTH);
+ X		perror("ERROR: mmap()");
+ X		close(fb_dev);
+ X		exit(1);
+ X	}
+ X	else
+ X	{
+ X		/* frame buffer mapped */
+ X		close(fb_dev);
+ X		printf("NOTICE: BIOS mapped [0x%x ,size=%d) to addr=0x%x...\n",
+ X			   PADDR,BUF_LENGTH,(int)addr);
+ X
+ X		/* display the buffer */
+ X    	for(i=start;i<stop;i=i+INCR)
+ X			printf("%c",addr[i]);
+ X        	/* printf("addr[%d]=%c\n",i,addr[i]);
+ X			 */
+ X		printf("\nDONE displaying memory contents (%d bytes)\n",stop);
+ X
+ X		/* unmap and close */
+ X		printf("UNMAPPING [0x%x ,size=%d) to addr=0x%x... and closing...",
+ X               PADDR,BUF_LENGTH,(int)addr);
+ X		munmap(addr,BUF_LENGTH);
+ X		printf("DONE.\n");
+ X		printf("Exiting successful...\n");
+ X		exit(0);
+ X	}
+ X	return 1;
+ }
+ SHAR_EOF
+ chmod 0644 aperture/aptest.c ||
+ echo 'restore of aperture/aptest.c failed'
+ Wc_c="`wc -c < 'aperture/aptest.c'`"
+ test 3530 -eq "$Wc_c" ||
+ 	echo 'aperture/aptest.c: original size 3530, current size' "$Wc_c"
+ fi
+ # ============= aperture/DISCLAIMER ==============
+ if test -f 'aperture/DISCLAIMER' -a X"$1" != X"-c"; then
+ 	echo 'x - skipping aperture/DISCLAIMER (File already exists)'
+ else
+ echo 'x - extracting aperture/DISCLAIMER (Text)'
+ sed 's/^X//' << 'SHAR_EOF' > 'aperture/DISCLAIMER' &&
+ /*
+ X * Copyright 1994 Doug Anson (danson@lgc.com) & David Holland (davidh@use.com)
+ X *
+ X * This code is based largely upon the sample device drivers provided
+ X * by Sun Microsystems Inc.
+ X * 
+ X * Original copyright notice:
+ X * @(#)mmap.c     1.3 copyright 93/06/03 Sun Microsystems, Inc.
+ X *
+ X * Our copyright notice:
+ X * Permission to use, copy, modify, distribute, and sell this software and its
+ X * documentation for any purpose is hereby granted without fee, provided that
+ X * the above copyright notice appear in all copies and that both that
+ X * copyright notice and this permission notice appear in supporting
+ X * documentation, and that the name of Doug Anson, and David Holland be used in
+ X * advertising or publicity pertaining to distribution of the software 
+ X * Doug Anson, and David Holland make no * representations about the 
+ X * suitability of this software for any purpose.
+ X * It is provided "as is" without express or implied warranty.
+ X *
+ X * Original disclamer from Sun Microsystems, Inc.:
+ X * This is a package of sample device drivers for Solaris 2.x (SunOS
+ X * 5.x).  You may use, modify and distribute these drivers and/or binaries
+ X * derived from them. However please note that:
+ X * 
+ X * These examples are provided with no warranties of any kind, including
+ X * without limitation accuracy and usefulness, and Sun expressly disclaims
+ X * all implied warranties of merchantability, fitness for a particular
+ X * purpose and non-infringement. In no event shall Sun be liable for any
+ X * damages, including without limitation, direct, special, indirect, or
+ X * consequential damages arising out of, or relating to, use of these
+ X * examples by customer or any third party. Sun is under no obligation to
+ X * provide support to customer for this software.
+ X * 
+ X * Our disclaimer:
+ X * DOUG ANSON, AND DAVID HOLLAND DISCLAIMS ALL WARRIENTS WITH REGARD TO THIS 
+ X * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, AND FITNESS, 
+ X * IN NO EVENT SHALL DOUG ANSON, OR DAVID HOLLAND BE LIABLE FOR ANY SPECIAL, 
+ X * INDIRECT, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM 
+ X * USAGE OF THIS SOFTWARE.
+ X */
+ X
+ /*
+ X * linear framebuffer aperture driver
+ X * 
+ X * $Id
+ X */
+ SHAR_EOF
+ chmod 0644 aperture/DISCLAIMER ||
+ echo 'restore of aperture/DISCLAIMER failed'
+ Wc_c="`wc -c < 'aperture/DISCLAIMER'`"
+ test 2174 -eq "$Wc_c" ||
+ 	echo 'aperture/DISCLAIMER: original size 2174, current size' "$Wc_c"
+ fi
+ exit 0
diff -c mit/server/ddx/x386/etc/console.h:2.1 mit/server/ddx/x386/etc/console.h:2.3
*** mit/server/ddx/x386/etc/console.h:2.1	Fri Mar 11 23:39:28 1994
--- mit/server/ddx/x386/etc/console.h	Fri Mar 11 23:39:28 1994
***************
*** 1,5 ****
  /*
!  *  Copyright (C) 1992, 1993 Søren Schmidt
   *
   *  This program is free software; you may redistribute it and/or 
   *  modify it, provided that it retain the above copyright notice 
--- 1,5 ----
  /*
!  *  Copyright (C) 1992, 1993, 1994 Søren Schmidt
   *
   *  This program is free software; you may redistribute it and/or 
   *  modify it, provided that it retain the above copyright notice 
***************
*** 9,20 ****
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
   *
!  *	Søren Schmidt 		Email:	sos@kmd-ac.dk
!  *	Tritonvej 36		UUCP:	...uunet!dkuug!kmd-ac!sos
   *	DK9210 Aalborg SO	Phone:  +45 9814 8076
   */
  
! /* $XFree86: mit/server/ddx/x386/etc/console.h,v 2.1 1993/10/04 05:14:47 dawes Exp $ */
  
  #ifndef	_CONSOLE_H_
  #define	_CONSOLE_H_
--- 9,23 ----
   *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
   *
!  *	Søren Schmidt 		Email:	sos@login.dkuug.dk
!  *	Tritonvej 36		UUCP:	...uunet!dkuug!login!sos
   *	DK9210 Aalborg SO	Phone:  +45 9814 8076
+  *
+  *	from:@(#)console.h	1.1 940105
+  *	$Id: console.h,v 1.3 1993/10/16 14:39:07 rgrimes Exp $
   */
  
! /* $XFree86: mit/server/ddx/x386/etc/console.h,v 2.3 1994/03/10 10:26:34 dawes Exp $ */
  
  #ifndef	_CONSOLE_H_
  #define	_CONSOLE_H_
***************
*** 32,38 ****
  #define KDSKBSTATE	_IO('K', 20)
  #define KDENABIO	_IO('K', 60)
  #define KDDISABIO	_IO('K', 61)
! #define KIOCSOUND	_IO('k', 63)
  #define KDGKBTYPE	_IOR('K', 64, int)
  #define KDGETLED	_IOR('K', 65, int)
  #define KDSETLED	_IO('K', 66) 
--- 35,41 ----
  #define KDSKBSTATE	_IO('K', 20)
  #define KDENABIO	_IO('K', 60)
  #define KDDISABIO	_IO('K', 61)
! #define KIOCSOUND	_IO('K', 63)
  #define KDGKBTYPE	_IOR('K', 64, int)
  #define KDGETLED	_IOR('K', 65, int)
  #define KDSETLED	_IO('K', 66) 
***************
*** 46,51 ****
--- 49,56 ----
  #define PIO_KEYMAP 	_IOW('k', 7, keymap_t)
  
  #define CONS_BLANKTIME	_IOW('c', 4, long)
+ #define CONS_SSAVER	_IOW('c', 5, ssaver_t)
+ #define CONS_GSAVER	_IOWR('c', 6, ssaver_t)
  #define PIO_FONT8x8	_IOW('c', 64, fnt8_t)
  #define GIO_FONT8x8	_IOR('c', 65, fnt8_t)
  #define PIO_FONT8x14	_IOW('c', 66, fnt14_t)
***************
*** 85,91 ****
  	short	frsig;			/* not implemented yet	SOS	*/
  };
  
- typedef struct vt_mode vtmode_t;
  
  #define KD_MONO		1		/* monochrome adapter        	*/
  #define KD_HERCULES	2		/* hercules adapter          	*/
--- 90,95 ----
***************
*** 101,117 ****
  #define K_RAW		0		/* keyboard returns scancodes	*/
  #define K_XLATE		1		/* keyboard returns ascii 	*/
  
! #define KB_84		1
! #define KB_101		2
! #define KB_OTHER	3
! 
! #define CLKED		1
! #define NLKED		2
! #define SLKED		4
! #define ALKED		8
! #define LED_CAP		1
! #define LED_NUM		2
! #define LED_SCR		4
  
  /* possible flag values */
  #define	FLAG_LOCK_O	0
--- 105,121 ----
  #define K_RAW		0		/* keyboard returns scancodes	*/
  #define K_XLATE		1		/* keyboard returns ascii 	*/
  
! #define KB_84		1		/* 'old' 84 key AT-keyboard	*/
! #define KB_101		2		/* MF-101 or MF-102 keyboard	*/
! #define KB_OTHER	3		/* keyboard not known 		*/
! 
! #define CLKED		1		/* Caps locked			*/
! #define NLKED		2		/* Num locked			*/
! #define SLKED		4		/* Scroll locked		*/
! #define ALKED		8		/* AltGr locked			*/
! #define LED_CAP		1		/* Caps lock LED 		*/ 
! #define LED_NUM		2		/* Num lock LED 		*/
! #define LED_SCR		4		/* Scroll lock LED 		*/
  
  /* possible flag values */
  #define	FLAG_LOCK_O	0
***************
*** 118,126 ****
  #define	FLAG_LOCK_C	1
  #define FLAG_LOCK_N	2
  
! #define NUM_KEYS	256
! #define NUM_STATES	8
! #define ALTGR_OFFSET	128
  
  struct keymap {
  	u_short	n_keys;
--- 122,130 ----
  #define	FLAG_LOCK_C	1
  #define FLAG_LOCK_N	2
  
! #define NUM_KEYS	256		/* number of keys in table	*/
! #define NUM_STATES	8		/* states per key		*/
! #define ALTGR_OFFSET	128		/* offset for altlock keys	*/
  
  struct keymap {
  	u_short	n_keys;
***************
*** 161,195 ****
  	u_char	mk_keylock;
  };
  
  typedef struct keymap keymap_t;
  typedef struct fkeytab fkeytab_t;
  typedef struct fkeyarg fkeyarg_t;
  typedef struct vid_info vid_info_t;
  typedef struct {char scrmap[256];} scrmap_t;
  typedef struct {char fnt8x8[8*256];} fnt8_t;
  typedef struct {char fnt8x14[14*256];} fnt14_t;
  typedef struct {char fnt8x16[16*256];} fnt16_t;
  
  #define F(x)		((x)+F_FN-1)
  #define	S(x)		((x)+F_SCR-1)
! #define NOP		0x00
! #define LSH		0x02
! #define RSH		0x03
! #define CLK		0x04
! #define NLK		0x05
! #define SLK		0x06
! #define LALT		0x07
! #define LCTR		0x09
! #define RCTR		0x7b
! #define RALT		0x7c
! #define ALK		0x7d
! #define ASH		0x7e
! 
! #define F_SCR		11		/* switch to first screen 	*/
! #define L_SCR		26		/* switch to last screen 	*/
! #define F_FN		27		/* first function key 		*/
! #define L_FN		122		/* last function key 		*/
  #define FKEY		0x200		/* funtion key marker 		*/
  
  #define	KB_DATA		0x60		/* kbd data port 		*/
  #define	KB_STAT		0x64		/* kbd status port 		*/
--- 165,216 ----
  	u_char	mk_keylock;
  };
  
+ #define MAXSSAVER	16
+ 
+ struct ssaver	{
+ 	char	name[MAXSSAVER];
+ 	int	num;
+ 	long	time;
+ };
+ 
  typedef struct keymap keymap_t;
  typedef struct fkeytab fkeytab_t;
  typedef struct fkeyarg fkeyarg_t;
  typedef struct vid_info vid_info_t;
+ typedef struct vt_mode vtmode_t;
  typedef struct {char scrmap[256];} scrmap_t;
  typedef struct {char fnt8x8[8*256];} fnt8_t;
  typedef struct {char fnt8x14[14*256];} fnt14_t;
  typedef struct {char fnt8x16[16*256];} fnt16_t;
+ typedef struct ssaver ssaver_t;
+ 
+ /* defines for "special" keys (spcl bit set in keymap) */
+ #define NOP		0x00		/* nothing (dead key)		*/
+ #define LSH		0x02		/* left shift key		*/
+ #define RSH		0x03		/* right shift key		*/
+ #define CLK		0x04		/* caps lock key		*/
+ #define NLK		0x05		/* num lock key			*/
+ #define SLK		0x06		/* scroll lock key		*/
+ #define LALT		0x07		/* left alt key			*/
+ #define LCTR		0x09		/* left control key		*/
+ #define NEXT		0x0a		/* switch to next screen 	*/
+ #define F_SCR		0x0b		/* switch to first screen 	*/
+ #define L_SCR		0x1a		/* switch to last screen 	*/
+ #define F_FN		0x1b		/* first function key 		*/
+ #define L_FN		0x7a		/* last function key 		*/
+ #define RCTR		0x7b		/* right control key		*/
+ #define RALT		0x7c		/* right alt (altgr) key	*/
+ #define ALK		0x7d		/* alt lock key			*/
+ #define ASH		0x7e		/* alt shift key		*/
+ #define META		0x7f		/* meta key			*/
+ #define RBT		0x80		/* boot machine			*/
+ #define DBG		0x81		/* call debugger		*/
  
  #define F(x)		((x)+F_FN-1)
  #define	S(x)		((x)+F_SCR-1)
! #define NOKEY		0x100		/* no key pressed marker 	*/
  #define FKEY		0x200		/* funtion key marker 		*/
+ #define MKEY		0x400		/* meta key marker (prepend ESC)*/
  
  #define	KB_DATA		0x60		/* kbd data port 		*/
  #define	KB_STAT		0x64		/* kbd status port 		*/
diff -c mit/server/ddx/x386/etc/et4000clock.c:1.3 mit/server/ddx/x386/etc/et4000clock.c:2.0
*** mit/server/ddx/x386/etc/et4000clock.c:1.3	Fri Mar 11 23:39:29 1994
--- mit/server/ddx/x386/etc/et4000clock.c	Fri Mar 11 23:39:29 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/etc/et4000clock.c,v 1.3 1993/03/27 09:31:25 dawes Exp $
   *
   * This is a sample clock setting program.  It will not work with all
   * ET4000 cards.  To work correctly the clocks line in Xconfig must
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/etc/et4000clock.c,v 2.0 1994/02/10 21:25:57 dawes Exp $
   *
   * This is a sample clock setting program.  It will not work with all
   * ET4000 cards.  To work correctly the clocks line in Xconfig must
***************
*** 17,23 ****
  
  /* The following inlines are from compiler.h in the XFree86 source dist */
  
! #if defined(__386BSD__) || defined(MACH) || defined(MACH386) || defined(linux)
  #define GCCUSESGAS
  #endif
  
--- 17,23 ----
  
  /* The following inlines are from compiler.h in the XFree86 source dist */
  
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__) || defined(MACH) || defined(MACH386) || defined(linux)
  #define GCCUSESGAS
  #endif
  
diff -c /dev/null mit/server/ddx/x386/etc/inst.freebsd:2.2
*** /dev/null	Fri Mar 11 23:39:29 1994
--- mit/server/ddx/x386/etc/inst.freebsd	Fri Mar 11 23:39:29 1994
***************
*** 0 ****
--- 1,49 ----
+ #!/bin/sh
+ 
+ # Installation script for XFree86 2.1 on FreeBSD 1.1.
+ 
+ # $XFree86: mit/server/ddx/x386/etc/inst.freebsd,v 2.2 1994/03/06 06:44:56 dawes Exp $
+ 
+ # if /usr/X386 doesn't exist, check if we are being run from the directory
+ # containing X386, or from X386/lib/X11/etc
+ 
+ if [ ! -d /usr/X386 ]; then
+ 	if [ -d X386 ]; then
+ 		instdir=`pwd`
+ 	elif [ -d ../../../../X386 ]; then
+ 		instdir=`(cd ../../../..; pwd)`
+ 	else
+ 		echo Please change to the directory where you unpacked
+ 		echo XFree86 and then run `basename $0`.
+ 		exit 1
+ 	fi
+ 
+ 	echo creating the sym link for /usr/X386
+ 	(set -x; cd /usr; ln -s $instdir/X386 .)
+ fi
+ 		
+ # put /usr/X386/bin in /etc/csh.login
+ d=/etc/csh.login
+ if [ -f $d ]; then
+     if grep -s '/usr/X386/bin' $d; then
+ 	:
+     else
+ 	echo adding /usr/X386/bin to the search path in $d
+ 	echo '# add X386 executables to the search path' >>$d
+ 	(set -x; echo 'set path = ($path /usr/X386/bin)' >>$d )
+     fi
+ fi
+ 
+ # put /usr/X386/bin in /etc/profile
+ d=/etc/profile
+ if [ -f $d ]; then
+     if grep -s '/usr/X386/bin' $d; then
+ 	:
+     else
+ 	echo adding /usr/X386/bin to the search path in $d
+ 	echo '# add X386 executables to the search path' >>$d
+ 	(set -x; echo 'PATH=$PATH:/usr/X386/bin' >>$d )
+     fi
+ fi
+ 
+ echo "That's it, done."
diff -c /dev/null mit/server/ddx/x386/etc/inst.netbsd:2.3
*** /dev/null	Fri Mar 11 23:39:29 1994
--- mit/server/ddx/x386/etc/inst.netbsd	Fri Mar 11 23:39:30 1994
***************
*** 0 ****
--- 1,101 ----
+ #!/bin/sh
+ 
+ # Installation script for XFree86 on NetBSD.
+ #
+ # $XFree86: mit/server/ddx/x386/etc/inst.netbsd,v 2.3 1994/03/06 14:55:14 dawes Exp $
+ 
+ # if XWINHOME isn't set and if /usr/X386 doesn't exist, check if we
+ # are being run from the directory containing X386, or from
+ # X386/lib/X11/etc
+ 
+ if [ -z "${XWINHOME}" ]; then
+     if [ -d /usr/X386 ]; then
+ 	XWINHOME=/usr/X386
+     else
+ 	if [ -d X386 ]; then
+ 	    XWINHOME=`pwd`/X386
+ 	elif [ -d ../../../../X386 ]; then
+ 	    XWINHOME=`(cd ../../../..; pwd)`/X386
+ 	else
+ 	    echo Please set the XWINHOME environment variable 
+ 	    echo to the directory where you unpacked
+ 	    echo 'XFree86 (eg /usr/local/X386) and then run `basename $0`.'
+ 	    exit 1
+ 	fi
+     fi
+     echo setting XWINHOME to "${XWINHOME}"
+ fi
+ 		
+ # put ${XWINHOME}/bin in /etc/csh.login
+ d=/etc/csh.login
+ if grep -s '\${XWINHOME}' $d; then
+ 	:
+ else
+ 	echo adding the definition of XWINHOME to $d
+ 	echo '# directory of XFree86 2.1' >> $d
+ 	(set -x; echo 'setenv XWINHOME '"${XWINHOME}" >>$d )
+ fi
+ if grep -s '\${XWINHOME}/bin' $d; then
+ 	:
+ else
+ 	echo adding ${XWINHOME}/bin to the search path in $d
+ 	echo '# add X386 executables to the search path' >>$d
+ 	(set -x; echo 'set path = ($path ${XWINHOME}/bin)' >>$d )
+ fi
+ 
+ # put ${XWINHOME}/bin in /etc/profile
+ d=/etc/profile
+ if grep -s '\${XWINHOME}' $d; then
+ 	:
+ else
+ 	echo adding the definition of XWINHOME to $d
+ 	echo '# directory of XFree86 2.1' >> $d
+ 	(set -x; echo 'XWINHOME='"${XWINHOME}"'; export XWINHOME' >>$d )
+ fi
+ if grep -s '\${XWINHOME}/bin' $d; then
+ 	:
+ else
+ 	echo adding ${XWINHOME}/bin to the search path in $d
+ 	echo '# add X386 executables to the search path' >>$d
+ 	(set -x; echo 'PATH=$PATH:${XWINHOME}/bin' >>$d )
+ fi
+ 
+ # check for console drivers
+ if [ -f /386bsd ]; then
+     kern=/386bsd
+ elif [ -f /netbsd ]; then
+     kern=/netbsd
+ fi
+ 
+ echo looking for your console driver in $kern ...
+ 
+ if grep -s pcprobe $kern >/dev/null 2>&1 ; then
+     if grep -s load_font $kern >/dev/null 2>&1 ; then
+         # if it's syscons, do nothing.
+         echo "Good, you are using syscons in $kern."
+     else
+         # if it's pccons and /dev/vga isn't a character device, create it
+         if [ ! -c /dev/vga ]; then
+             echo 'creating /dev/vga.'
+             (set -x; rm /dev/vga; mknod /dev/vga c 12 0)
+         fi
+         if grep -s '^vga.*\bon\b' /etc/ttys >/dev/null 2>&1 ; then
+             echo Good, you have a getty running on /dev/vga.
+         else
+             echo You don\'t have a getty running on /dev/vga.
+             cons=`grep -s '^console.*\bon\b' /etc/ttys 2>/dev/null`
+             if [ X"$cons" != X ]; then
+                 echo I suggest you edit /etc/ttys and change the line:
+                 echo "$cons"
+                 echo to:
+                 echo "$cons" | sed -e 's/^console/vga/'
+             else
+                 echo I suggest you edit /etc/ttys and insert:
+                 echo 'vga     "/usr/libexec/getty Pc" pc3     on secure'
+             fi
+             echo You must then reboot for this change to take effect
+         fi
+     fi
+ fi
+ 
+ echo "That's it, done."
diff -c mit/server/ddx/x386/etc/install.bsd:2.1 mit/server/ddx/x386/etc/install.bsd:removed
*** mit/server/ddx/x386/etc/install.bsd:2.1	Fri Mar 11 23:39:30 1994
--- mit/server/ddx/x386/etc/install.bsd	Fri Mar 11 23:39:30 1994
***************
*** 1,84 ****
- #!/bin/sh
- 
- # Installation script for XFree86 on FreeBSD.
- # This script should also be suitable for NetBSD and 386BSD.
- #
- # $XFree86: mit/server/ddx/x386/etc/install.bsd,v 2.1 1993/10/24 13:44:50 dawes Exp $
- 
- # if /usr/X386 doesn't exist, check if we are being run from the directory
- # containing X386, or from X386/lib/X11/etc
- 
- if [ ! -d /usr/X386 ]; then
- 	if [ -d X386 ]; then
- 		instdir=`pwd`
- 	elif [ -d ../../../../X386 ]; then
- 		instdir=`(cd ../../../..; pwd)`
- 	else
- 		echo Please change to the directory where you unpacked
- 		echo XFree86 and then run `basename $0`.
- 		exit 1
- 	fi
- 
- 	echo creating the sym link for /usr/X386
- 	(set -x; cd /usr; ln -s $instdir/X386 .)
- fi
- 		
- # put /usr/X386/bin in /etc/csh.login
- d=/etc/csh.login
- if grep -s '/usr/X386/bin' $d; then
- 	:
- else
- 	echo adding /usr/X386/bin to the search path in $d
- 	echo '# add X386 executables to the search path' >>$d
- 	(set -x; echo 'set path = ($path /usr/X386/bin)' >>$d )
- fi
- 
- # put /usr/X386/bin in /etc/profile
- d=/etc/profile
- if grep -s '/usr/X386/bin' $d; then
- 	:
- else
- 	echo adding /usr/X386/bin to the search path in $d
- 	echo '# add X386 executables to the search path' >>$d
- 	(set -x; echo 'PATH=$PATH:/usr/X386/bin' >>$d )
- fi
- 
- # check for console drivers
- if [ -f /386bsd ]; then
-     kern=/386bsd
- elif [ -f /netbsd ]; then
-     kern=/netbsd
- fi
- 
- echo looking for your console driver in $kern ...
- 
- if grep -s pcprobe $kern >/dev/null 2>&1 ; then
-     if grep -s load_font $kern >/dev/null 2>&1 ; then
-         # if it's syscons, do nothing.
-         echo "Good, you are using syscons in $kern."
-     else
-         # if it's pccons and /dev/vga isn't a character device, create it
-         if [ ! -c /dev/vga ]; then
-             echo 'creating /dev/vga.'
-             (set -x; rm /dev/vga; mknod /dev/vga c 12 0)
-         fi
-         if grep -s '^vga.*\bon\b' /etc/ttys >/dev/null 2>&1 ; then
-             echo Good, you have a getty running on /dev/vga.
-         else
-             echo You don\'t have a getty running on /dev/vga.
-             cons=`grep -s '^console.*\bon\b' /etc/ttys 2>/dev/null`
-             if [ X"$cons" != X ]; then
-                 echo I suggest you edit /etc/ttys and change the line:
-                 echo "$cons"
-                 echo to:
-                 echo "$cons" | sed -e 's/^console/vga/'
-             else
-                 echo I suggest you edit /etc/ttys and insert:
-                 echo 'vga     "/usr/libexec/getty Pc" pc3     on secure'
-             fi
-             echo You must then reboot for this change to take effect
-         fi
-     fi
- fi
- 
- echo "That's it, done."
--- 0 ----
diff -c mit/server/ddx/x386/etc/mmapSVR3.shar:2.0 mit/server/ddx/x386/etc/mmapSVR3.shar:2.1
*** mit/server/ddx/x386/etc/mmapSVR3.shar:2.0	Fri Mar 11 23:39:32 1994
--- mit/server/ddx/x386/etc/mmapSVR3.shar	Fri Mar 11 23:39:32 1994
***************
*** 3,12 ****
  # To extract the files from this archive, save it to a file, remove
  # everything above the "!/bin/sh" line above, and type "sh file_name".
  #
! # made 10/02/1993 08:59 UTC by root@gamma
  # Source directory /home1/tmp/x11r5
  #
! # $XFree86: mit/server/ddx/x386/etc/mmapSVR3.shar,v 2.0 1993/10/02 09:51:10 dawes Exp $
  #
  # existing files will NOT be overwritten unless -c is specified
  #
--- 3,12 ----
  # To extract the files from this archive, save it to a file, remove
  # everything above the "!/bin/sh" line above, and type "sh file_name".
  #
! # made 02/26/1994 03:10 UTC by root@gamma
  # Source directory /home1/tmp/x11r5
  #
! # $XFree86: mit/server/ddx/x386/etc/mmapSVR3.shar,v 2.1 1994/02/26 03:14:56 dawes Exp $
  #
  # existing files will NOT be overwritten unless -c is specified
  #
***************
*** 13,52 ****
  # This shar contains:
  # length  mode       name
  # ------ ---------- ------------------------------------------
! #    884 -rw-r--r-- mmap-2.2.2/CHANGELOG
! #   1633 -rw-r--r-- mmap-2.2.2/COPYRIGHT
! #     73 -rw-r--r-- mmap-2.2.2/DrivDesc
! #   7870 -rw-r--r-- mmap-2.2.2/Makefile
! #     28 -rw-r--r-- mmap-2.2.2/Master
! #     75 -rw-r--r-- mmap-2.2.2/Mtune
! #     25 -rw-r--r-- mmap-2.2.2/Name
! #     14 -rw-r--r-- mmap-2.2.2/Node
! #   3463 -rw-r--r-- mmap-2.2.2/README
! #    622 -rw-r--r-- mmap-2.2.2/Space.c
! #     23 -rw-r--r-- mmap-2.2.2/System
! #     65 -rw-r--r-- mmap-2.2.2/description
! #  12533 -rw-r--r-- mmap-2.2.2/mmap.7
! #  12708 -rw-r--r-- mmap-2.2.2/mmap.c
! #   1422 -rw-r--r-- mmap-2.2.2/mmap.h
! #   7904 -rw-r--r-- mmap-2.2.2/mmap.man
! #   1495 -rw-r--r-- mmap-2.2.2/mmaprm.1
! #   3346 -rw-r--r-- mmap-2.2.2/mmaprm.c
! #    845 -rw-r--r-- mmap-2.2.2/mmaprm.man
! #   1453 -rw-r--r-- mmap-2.2.2/mmapstat.1
! #   2531 -rw-r--r-- mmap-2.2.2/mmapstat.c
! #    809 -rw-r--r-- mmap-2.2.2/mmapstat.man
! #   2539 -rw-r--r-- mmap-2.2.2/tstmap.c
  #
! # ============= mmap-2.2.2/CHANGELOG ==============
! if test ! -d 'mmap-2.2.2'; then
!     echo 'x - creating directory mmap-2.2.2'
!     mkdir 'mmap-2.2.2'
! fi
! if test -f 'mmap-2.2.2/CHANGELOG' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/CHANGELOG (File already exists)'
! else
! echo 'x - extracting mmap-2.2.2/CHANGELOG (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/CHANGELOG' &&
  X
  MMAP 2.2.2 (24 September 1993)
  UNMAP/UNMAPRM didn't decrement the number of attached shared
--- 13,57 ----
  # This shar contains:
  # length  mode       name
  # ------ ---------- ------------------------------------------
! #   1061 -rw-r--r-- mmap-2.2.3/CHANGELOG
! #   1633 -rw-r--r-- mmap-2.2.3/COPYRIGHT
! #     73 -rw-r--r-- mmap-2.2.3/DrivDesc
! #   7870 -rw-r--r-- mmap-2.2.3/Makefile
! #     28 -rw-r--r-- mmap-2.2.3/Master
! #     75 -rw-r--r-- mmap-2.2.3/Mtune
! #     25 -rw-r--r-- mmap-2.2.3/Name
! #     14 -rw-r--r-- mmap-2.2.3/Node
! #   3816 -rw-r--r-- mmap-2.2.3/README
! #    622 -rw-r--r-- mmap-2.2.3/Space.c
! #     23 -rw-r--r-- mmap-2.2.3/System
! #     65 -rw-r--r-- mmap-2.2.3/description
! #  12533 -rw-r--r-- mmap-2.2.3/mmap.7
! #  15554 -rw-r--r-- mmap-2.2.3/mmap.c
! #   1422 -rw-r--r-- mmap-2.2.3/mmap.h
! #   7901 -rw-r--r-- mmap-2.2.3/mmap.man
! #   1495 -rw-r--r-- mmap-2.2.3/mmaprm.1
! #   3346 -rw-r--r-- mmap-2.2.3/mmaprm.c
! #    843 -rw-r--r-- mmap-2.2.3/mmaprm.man
! #   1453 -rw-r--r-- mmap-2.2.3/mmapstat.1
! #   2531 -rw-r--r-- mmap-2.2.3/mmapstat.c
! #    808 -rw-r--r-- mmap-2.2.3/mmapstat.man
! #   2539 -rw-r--r-- mmap-2.2.3/tstmap.c
  #
! # ============= mmap-2.2.3/CHANGELOG ==============
! if test ! -d 'mmap-2.2.3'; then
!     echo 'x - creating directory mmap-2.2.3'
!     mkdir 'mmap-2.2.3'
! fi
! if test -f 'mmap-2.2.3/CHANGELOG' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/CHANGELOG (File already exists)'
! else
! echo 'x - extracting mmap-2.2.3/CHANGELOG (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/CHANGELOG' &&
! X
! MMAP 2.2.3 (22 November 1993)
! Workaround a problem when the page daemon (vhand) steals a mmap
! region which isn't used any longer by any processes the page tables
! (see mmap.c).
  X
  MMAP 2.2.2 (24 September 1993)
  UNMAP/UNMAPRM didn't decrement the number of attached shared
***************
*** 75,92 ****
  calling process to allocate the needed virtuell address space.
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/CHANGELOG ||
! echo 'restore of mmap-2.2.2/CHANGELOG failed'
! Wc_c="`wc -c < 'mmap-2.2.2/CHANGELOG'`"
! test 884 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/CHANGELOG: original size 884, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.2/COPYRIGHT ==============
! if test -f 'mmap-2.2.2/COPYRIGHT' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/COPYRIGHT (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/COPYRIGHT (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/COPYRIGHT' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
--- 80,97 ----
  calling process to allocate the needed virtuell address space.
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/CHANGELOG ||
! echo 'restore of mmap-2.2.3/CHANGELOG failed'
! Wc_c="`wc -c < 'mmap-2.2.3/CHANGELOG'`"
! test 1061 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/CHANGELOG: original size 1061, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.3/COPYRIGHT ==============
! if test -f 'mmap-2.2.3/COPYRIGHT' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/COPYRIGHT (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/COPYRIGHT (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/COPYRIGHT' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
***************
*** 124,158 ****
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/COPYRIGHT ||
! echo 'restore of mmap-2.2.2/COPYRIGHT failed'
! Wc_c="`wc -c < 'mmap-2.2.2/COPYRIGHT'`"
  test 1633 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/COPYRIGHT: original size 1633, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/DrivDesc ==============
! if test -f 'mmap-2.2.2/DrivDesc' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/DrivDesc (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/DrivDesc (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/DrivDesc' &&
  DRIVER=mmap
  CLASS=io
  HARDWARE=FALSE
  DESCRIPTION=Memory Mapped I/O Driver
  SHAR_EOF
! chmod 0644 mmap-2.2.2/DrivDesc ||
! echo 'restore of mmap-2.2.2/DrivDesc failed'
! Wc_c="`wc -c < 'mmap-2.2.2/DrivDesc'`"
  test 73 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/DrivDesc: original size 73, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/Makefile ==============
! if test -f 'mmap-2.2.2/Makefile' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/Makefile (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/Makefile (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/Makefile' &&
  #/*
  # * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  # *
--- 129,163 ----
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/COPYRIGHT ||
! echo 'restore of mmap-2.2.3/COPYRIGHT failed'
! Wc_c="`wc -c < 'mmap-2.2.3/COPYRIGHT'`"
  test 1633 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/COPYRIGHT: original size 1633, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/DrivDesc ==============
! if test -f 'mmap-2.2.3/DrivDesc' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/DrivDesc (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/DrivDesc (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/DrivDesc' &&
  DRIVER=mmap
  CLASS=io
  HARDWARE=FALSE
  DESCRIPTION=Memory Mapped I/O Driver
  SHAR_EOF
! chmod 0644 mmap-2.2.3/DrivDesc ||
! echo 'restore of mmap-2.2.3/DrivDesc failed'
! Wc_c="`wc -c < 'mmap-2.2.3/DrivDesc'`"
  test 73 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/DrivDesc: original size 73, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/Makefile ==============
! if test -f 'mmap-2.2.3/Makefile' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/Makefile (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/Makefile (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/Makefile' &&
  #/*
  # * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  # *
***************
*** 375,460 ****
  clobber: clean
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/Makefile ||
! echo 'restore of mmap-2.2.2/Makefile failed'
! Wc_c="`wc -c < 'mmap-2.2.2/Makefile'`"
  test 7870 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/Makefile: original size 7870, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/Master ==============
! if test -f 'mmap-2.2.2/Master' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/Master (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/Master (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/Master' &&
  mmap	Ii	ic		mmap	0	0	1	1	-1
  SHAR_EOF
! chmod 0644 mmap-2.2.2/Master ||
! echo 'restore of mmap-2.2.2/Master failed'
! Wc_c="`wc -c < 'mmap-2.2.2/Master'`"
  test 28 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/Master: original size 28, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/Mtune ==============
! if test -f 'mmap-2.2.2/Mtune' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/Mtune (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/Mtune (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/Mtune' &&
  * Memory Mapped I/O Parameters ------
  NMMAPREG        64      8       1024
  SHAR_EOF
! chmod 0644 mmap-2.2.2/Mtune ||
! echo 'restore of mmap-2.2.2/Mtune failed'
! Wc_c="`wc -c < 'mmap-2.2.2/Mtune'`"
  test 75 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/Mtune: original size 75, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/Name ==============
! if test -f 'mmap-2.2.2/Name' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/Name (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/Name (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/Name' &&
  Memory Mapped I/O Driver
  SHAR_EOF
! chmod 0644 mmap-2.2.2/Name ||
! echo 'restore of mmap-2.2.2/Name failed'
! Wc_c="`wc -c < 'mmap-2.2.2/Name'`"
  test 25 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/Name: original size 25, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/Node ==============
! if test -f 'mmap-2.2.2/Node' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/Node (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/Node (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/Node' &&
  mmap	mmap c	0
  SHAR_EOF
! chmod 0644 mmap-2.2.2/Node ||
! echo 'restore of mmap-2.2.2/Node failed'
! Wc_c="`wc -c < 'mmap-2.2.2/Node'`"
  test 14 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/Node: original size 14, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/README ==============
! if test -f 'mmap-2.2.2/README' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/README (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/README (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/README' &&
  X
! MMAP - Memory Mapped I/O Driver v2.2.2
  Installation
  ------------------------------------------------------------------------
  MMAP is a pseudo device driver which provides memory mapped I/O for user
! processes, i.e. direct mapping of a physical memory ranges into the user's
  virtual address space for fast access. It is especially useful for accessing
  the linear frame buffers of certain graphics hardware from the user level.
  X
! Note, the driver is currently tested only under ISC 2.0.2, ISC 3.0,
! ISC 4.0 and SCO 3.2v4, although it should work on any SVR3.2 based system.
  A description of the driver itself and how to use it you'll find in the
  accompanied manual page.
  X
--- 380,470 ----
  clobber: clean
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/Makefile ||
! echo 'restore of mmap-2.2.3/Makefile failed'
! Wc_c="`wc -c < 'mmap-2.2.3/Makefile'`"
  test 7870 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/Makefile: original size 7870, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/Master ==============
! if test -f 'mmap-2.2.3/Master' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/Master (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/Master (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/Master' &&
  mmap	Ii	ic		mmap	0	0	1	1	-1
  SHAR_EOF
! chmod 0644 mmap-2.2.3/Master ||
! echo 'restore of mmap-2.2.3/Master failed'
! Wc_c="`wc -c < 'mmap-2.2.3/Master'`"
  test 28 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/Master: original size 28, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/Mtune ==============
! if test -f 'mmap-2.2.3/Mtune' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/Mtune (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/Mtune (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/Mtune' &&
  * Memory Mapped I/O Parameters ------
  NMMAPREG        64      8       1024
  SHAR_EOF
! chmod 0644 mmap-2.2.3/Mtune ||
! echo 'restore of mmap-2.2.3/Mtune failed'
! Wc_c="`wc -c < 'mmap-2.2.3/Mtune'`"
  test 75 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/Mtune: original size 75, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/Name ==============
! if test -f 'mmap-2.2.3/Name' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/Name (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/Name (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/Name' &&
  Memory Mapped I/O Driver
  SHAR_EOF
! chmod 0644 mmap-2.2.3/Name ||
! echo 'restore of mmap-2.2.3/Name failed'
! Wc_c="`wc -c < 'mmap-2.2.3/Name'`"
  test 25 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/Name: original size 25, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/Node ==============
! if test -f 'mmap-2.2.3/Node' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/Node (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/Node (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/Node' &&
  mmap	mmap c	0
  SHAR_EOF
! chmod 0644 mmap-2.2.3/Node ||
! echo 'restore of mmap-2.2.3/Node failed'
! Wc_c="`wc -c < 'mmap-2.2.3/Node'`"
  test 14 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/Node: original size 14, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/README ==============
! if test -f 'mmap-2.2.3/README' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/README (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/README (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/README' &&
  X
! MMAP - Memory Mapped I/O Driver v2.2.3
  Installation
  ------------------------------------------------------------------------
  MMAP is a pseudo device driver which provides memory mapped I/O for user
! processes, i.e. direct mapping of physical memory ranges into the user's
  virtual address space for fast access. It is especially useful for accessing
  the linear frame buffers of certain graphics hardware from the user level.
  X
! Note, the driver is currently tested only under ISC 2.0.2, ISC 2.2.1, 
! ISC 3.0 and ISC 4.0 although it should work on any SVR3.2 based system.
! It should also work on SCO, but page locking is not tested yet with SCO
! and for this reason disabled for SCO. (look into mmap.c). But if mapping of
! ranges less or equal 4MB is enough for your needs it could be easier to use
! the "dmmap" driver by David McCullough <davidm@stallion.oz.au> which uses
! the vas*() functions already provided by the SCO kernel.
  A description of the driver itself and how to use it you'll find in the
  accompanied manual page.
  X
***************
*** 462,468 ****
  X
  1. Unpack the archive with:
  X
! X	# gzcat mmap-2.2.2.t.z | tar xovf -
  X
  2. Edit the Makefile for your system. Change BINDIR, CATMANDIR, COMPRESS
  X   if you like.
--- 472,478 ----
  X
  1. Unpack the archive with:
  X
! X	# gzcat mmap-2.2.3.t.z | tar xovf -
  X
  2. Edit the Makefile for your system. Change BINDIR, CATMANDIR, COMPRESS
  X   if you like.
***************
*** 553,570 ****
  wolf@prz.tu-berlin.de or thomas@aeon.in-berlin.de
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/README ||
! echo 'restore of mmap-2.2.2/README failed'
! Wc_c="`wc -c < 'mmap-2.2.2/README'`"
! test 3463 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/README: original size 3463, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.2/Space.c ==============
! if test -f 'mmap-2.2.2/Space.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/Space.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/Space.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/Space.c' &&
  X
  /* Configuration file for the MMAP driver
  X *
--- 563,580 ----
  wolf@prz.tu-berlin.de or thomas@aeon.in-berlin.de
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/README ||
! echo 'restore of mmap-2.2.3/README failed'
! Wc_c="`wc -c < 'mmap-2.2.3/README'`"
! test 3816 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/README: original size 3816, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.3/Space.c ==============
! if test -f 'mmap-2.2.3/Space.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/Space.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/Space.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/Space.c' &&
  X
  /* Configuration file for the MMAP driver
  X *
***************
*** 574,580 ****
  X */
  X
  #if !defined (M_I286)
! #ident	"@(#)space.c - MMAP v2.2.2, Copyright (c) Thomas Wolfram 1993"
  #endif
  X
  #include "sys/types.h"
--- 584,590 ----
  X */
  X
  #if !defined (M_I286)
! #ident	"@(#)space.c - MMAP v2.2.3, Copyright (c) Thomas Wolfram 1993"
  #endif
  X
  #include "sys/types.h"
***************
*** 595,640 ****
  X */
  uint nmmapreg = NMMAPREG;
  SHAR_EOF
! chmod 0644 mmap-2.2.2/Space.c ||
! echo 'restore of mmap-2.2.2/Space.c failed'
! Wc_c="`wc -c < 'mmap-2.2.2/Space.c'`"
  test 622 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/Space.c: original size 622, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/System ==============
! if test -f 'mmap-2.2.2/System' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/System (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/System (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/System' &&
  mmap	Y	1	0	0	0	0	0	0	0
  SHAR_EOF
! chmod 0644 mmap-2.2.2/System ||
! echo 'restore of mmap-2.2.2/System failed'
! Wc_c="`wc -c < 'mmap-2.2.2/System'`"
  test 23 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/System: original size 23, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/description ==============
! if test -f 'mmap-2.2.2/description' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/description (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/description (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/description' &&
  mmap    -    -     io     -             Memory Mapped I/O Driver
  SHAR_EOF
! chmod 0644 mmap-2.2.2/description ||
! echo 'restore of mmap-2.2.2/description failed'
! Wc_c="`wc -c < 'mmap-2.2.2/description'`"
  test 65 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/description: original size 65, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/mmap.7 ==============
! if test -f 'mmap-2.2.2/mmap.7' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmap.7 (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmap.7 (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmap.7' &&
  X
  X
  X
--- 605,650 ----
  X */
  uint nmmapreg = NMMAPREG;
  SHAR_EOF
! chmod 0644 mmap-2.2.3/Space.c ||
! echo 'restore of mmap-2.2.3/Space.c failed'
! Wc_c="`wc -c < 'mmap-2.2.3/Space.c'`"
  test 622 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/Space.c: original size 622, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/System ==============
! if test -f 'mmap-2.2.3/System' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/System (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/System (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/System' &&
  mmap	Y	1	0	0	0	0	0	0	0
  SHAR_EOF
! chmod 0644 mmap-2.2.3/System ||
! echo 'restore of mmap-2.2.3/System failed'
! Wc_c="`wc -c < 'mmap-2.2.3/System'`"
  test 23 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/System: original size 23, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/description ==============
! if test -f 'mmap-2.2.3/description' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/description (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/description (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/description' &&
  mmap    -    -     io     -             Memory Mapped I/O Driver
  SHAR_EOF
! chmod 0644 mmap-2.2.3/description ||
! echo 'restore of mmap-2.2.3/description failed'
! Wc_c="`wc -c < 'mmap-2.2.3/description'`"
  test 65 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/description: original size 65, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/mmap.7 ==============
! if test -f 'mmap-2.2.3/mmap.7' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmap.7 (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmap.7 (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmap.7' &&
  X
  X
  X
***************
*** 697,703 ****
  X               the mapping region.)  But with the _U_N_M_A_P_R_M ioctl removing
  X
  X
! X          Rev. 2.2.2, 24 September 1993                              Page 1
  X
  X
  X
--- 707,713 ----
  X               the mapping region.)  But with the _U_N_M_A_P_R_M ioctl removing
  X
  X
! X          Rev. 2.2.3, 22 November 1993                               Page 1
  X
  X
  X
***************
*** 763,769 ****
  X                                  boundary.
  X
  X
! X          Rev. 2.2.2, 24 September 1993                              Page 2
  X
  X
  X
--- 773,779 ----
  X                                  boundary.
  X
  X
! X          Rev. 2.2.3, 22 November 1993                               Page 2
  X
  X
  X
***************
*** 829,835 ****
  X                 of the following type (defined in <sys/mmap.h>):
  X
  X
! X          Rev. 2.2.2, 24 September 1993                              Page 3
  X
  X
  X
--- 839,845 ----
  X                 of the following type (defined in <sys/mmap.h>):
  X
  X
! X          Rev. 2.2.3, 22 November 1993                               Page 3
  X
  X
  X
***************
*** 895,901 ****
  X          BUGS
  X
  X
! X          Rev. 2.2.2, 24 September 1993                              Page 4
  X
  X
  X
--- 905,911 ----
  X          BUGS
  X
  X
! X          Rev. 2.2.3, 22 November 1993                               Page 4
  X
  X
  X
***************
*** 961,983 ****
  X
  X
  X
! X          Rev. 2.2.2, 24 September 1993                              Page 5
  X
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmap.7 ||
! echo 'restore of mmap-2.2.2/mmap.7 failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmap.7'`"
  test 12533 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmap.7: original size 12533, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/mmap.c ==============
! if test -f 'mmap-2.2.2/mmap.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmap.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmap.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmap.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
--- 971,993 ----
  X
  X
  X
! X          Rev. 2.2.3, 22 November 1993                               Page 5
  X
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmap.7 ||
! echo 'restore of mmap-2.2.3/mmap.7 failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmap.7'`"
  test 12533 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmap.7: original size 12533, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/mmap.c ==============
! if test -f 'mmap-2.2.3/mmap.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmap.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmap.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmap.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
***************
*** 1003,1011 ****
  X */
  X
  #if !defined (M_I286)
! #ident	"@(#)mmap.c - MMAP v2.2.2, Copyright (c) Thomas Wolfram 1993"
  #endif
  X
  #include <sys/types.h>
  #include <sys/file.h>
  #include <sys/param.h>
--- 1013,1026 ----
  X */
  X
  #if !defined (M_I286)
! #ident	"@(#)mmap.c - MMAP v2.2.3, Copyright (c) Thomas Wolfram 1993"
  #endif
  X
+ #define MMAP_MAJ 2
+ #define MMAP_MIN 2
+ #define MMAP_PL  3
+ #define MMAPVERSION MMAP_MAJ*256 + MMAP_MIN*16 + MMAP_PL
+ X
  #include <sys/types.h>
  #include <sys/file.h>
  #include <sys/param.h>
***************
*** 1078,1084 ****
  X
  int mmapinit()
  {
! X    printf("Memory Mapped I/O Driver v2.2.2 installed.\n");
  X    printf("Copyright (c) 1993 Thomas Wolfram\n\n");
  X
  }
--- 1093,1100 ----
  X
  int mmapinit()
  {
! X    printf("Memory Mapped I/O Driver v%d.%d.%d installed.\n",
! X	   MMAP_MAJ, MMAP_MIN, MMAP_PL);
  X    printf("Copyright (c) 1993 Thomas Wolfram\n\n");
  X
  }
***************
*** 1154,1166 ****
  X	    Reg_p = NULL;
  X	    for(i = 0; i < map_cnt; i++) {
  X		if((paddr_t)memDesc.physaddr == mmapreg[i].physaddr &&
! X		       btoc(memDesc.length)  == mmapreg[i].Reg_p->r_pgsz)
  X			Reg_p = mmapreg[i].Reg_p;
  X	    }
  X
  X
  X	    /* If necessary allocate a new region, type is shared memory.
- X	     * Otherwise lock existing region.
  X	     */
  X	    if(Reg_p == NULL) {
  X
--- 1170,1260 ----
  X	    Reg_p = NULL;
  X	    for(i = 0; i < map_cnt; i++) {
  X		if((paddr_t)memDesc.physaddr == mmapreg[i].physaddr &&
! X		       btoc(memDesc.length)  == mmapreg[i].Reg_p->r_pgsz) {
  X			Reg_p = mmapreg[i].Reg_p;
+ X			break;
+ X		}
+ X	    }
+ X
+ X
+ X	    if(Reg_p != NULL) {
+ X
+ X		/* If we have still such a region lock it.
+ X		 */
+ X		reglock(Reg_p);
+ X
+ X		/* XXXX This is a ugly hack.
+ X		 * If our region isn't any longer referenced by a process
+ X		 * it's possible that vhand steals the page tables of our
+ X		 * region. Attaching such a region with swapped-out page
+ X		 * tables doesn't work, because the page directory entries
+ X		 * of the process get a present-bit set to 1 and valid re-
+ X		 * ferences to page tables but which contain entries of in-
+ X		 * valid non-present pages. And the related dbd tables still
+ X		 * contain the type DBD_IOMAP.
+ X		 * I.e. the effect is there won't occur a page fault to
+ X		 * read the swapped-out page tables in, as I expected. The
+ X		 * page fault will instead occur in the second level (i.e. in
+ X		 * the page tables) when attempting to read the non-present
+ X		 * pages from disk or elsewhere. The kernel will look in the
+ X		 * dbd table and find the type DBD_IOMAP, but which is invalid
+ X		 * for a non-present page. Hence it would panic then with:
+ X		 * "vfault - bad dbd_type".
+ X		 *
+ X		 * Also I have no idea how I could the swapped-out page tables
+ X		 * read in "by hand". The "pseudo page directory" of the re-
+ X		 * gion (addressed by Reg_p->r_list) contains obviously only
+ X		 * the base addresses and not the page state flags. Also
+ X		 * I don't know how to find the dbd's of the page table's
+ X		 * pages.
+ X		 * 
+ X		 * Probably I did something wrong here. If you've an idea
+ X		 * please let me know. Thanks.
+ X		 *
+ X		 * Anyway, until then I simply throw away the region if
+ X		 * the page tables of it are swapped out and then I reallocate
+ X		 * the same region.
+ X		 */
+ X		if(Reg_p->r_flags & RG_SWAP) {
+ X
+ X		    /* Freereg takes only effect if no users pointing
+ X		     * at it.
+ X		     */
+ X		    if(Reg_p->r_refcnt == 0) {
+ X			Reg_p->r_flags &= ~RG_NOFREE;
+ X			freereg(Reg_p);
+ X
+ X			/* Free the old slot and force allocating a
+ X			 * new region.
+ X			 */
+ X			for(i = i; i < map_cnt; i++)
+ X				mmapreg[i] = mmapreg[i+1];
+ X			map_cnt--;
+ X
+ X			Reg_p = NULL;
+ X
+ #ifdef DEBUG
+ X			printf("MMAP: Info - reallocate region [a=0x%x, l=%dk]\n", memDesc.physaddr, memDesc.length/1024);
+ #endif
+ X		    }
+ X		    else {
+ X			/* I hope this point here will never be reached!
+ X			 * Or - better - page tables are read in correctly
+ X			 * by the system. So we don't panic in the hope
+ X			 * it works.
+ X			 */
+ X			printf("MMAP: Warning - region [a=%x, l=%dk] still used but page tables are swapped out!\n", memDesc.physaddr, memDesc.length/1024);
+ X			printf("MMAP: Cannot reallocate this region!\n");
+ X			printf("MMAP: Please email Thomas Wolfram <thomas@aeon.in-berlin.de> or\n      <wolf@prz.tu-berlin.de>. Thanks.\n");
+ X
+ X			/* panic("MMAP: PANIC\n");
+ X			 */
+ X		    }
+ X		}
  X	    }
  X
  X
  X	    /* If necessary allocate a new region, type is shared memory.
  X	     */
  X	    if(Reg_p == NULL) {
  X
***************
*** 1171,1181 ****
  X		    break;
  X		}
  X
  X	    	if((Reg_p = allocreg(NULL, RT_SHMEM, 0)) == NULL)
  X		    break;
  X	    }
- X	    else
- X		reglock(Reg_p);
  X
  X
  X	    /* If the region is already initialized, check whether it is
--- 1265,1275 ----
  X		    break;
  X		}
  X
+ X		/* Allocate new region which will be locked.
+ X		 */
  X	    	if((Reg_p = allocreg(NULL, RT_SHMEM, 0)) == NULL)
  X		    break;
  X	    }
  X
  X
  X	    /* If the region is already initialized, check whether it is
***************
*** 1391,1397 ****
  X	/* Return version number
  X	 */
  X	case GETVERSION:
! X	    u.u_rval1 = 0x0222;
  X	    break;
  X
  X
--- 1485,1491 ----
  X	/* Return version number
  X	 */
  X	case GETVERSION:
! X	    u.u_rval1 = MMAPVERSION;
  X	    break;
  X
  X
***************
*** 1449,1455 ****
  X	    continue;
  X	}
  X
! X	/* If desired start and end addresses are below the this region
  X	 * use this address for mapping, otherwise try next address at
  X	 * MMAPLBA boundary after end of this region.
  X	 */
--- 1543,1549 ----
  X	    continue;
  X	}
  X
! X	/* If desired start and end addresses are below this region
  X	 * use this address for mapping, otherwise try next address at
  X	 * MMAPLBA boundary after end of this region.
  X	 */
***************
*** 1475,1492 ****
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmap.c ||
! echo 'restore of mmap-2.2.2/mmap.c failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmap.c'`"
! test 12708 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmap.c: original size 12708, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.2/mmap.h ==============
! if test -f 'mmap-2.2.2/mmap.h' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmap.h (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmap.h (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmap.h' &&
  X
  /* This file contains various defines for the MMAP driver.
  X *
--- 1569,1586 ----
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmap.c ||
! echo 'restore of mmap-2.2.3/mmap.c failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmap.c'`"
! test 15554 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmap.c: original size 15554, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.3/mmap.h ==============
! if test -f 'mmap-2.2.3/mmap.h' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmap.h (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmap.h (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmap.h' &&
  X
  /* This file contains various defines for the MMAP driver.
  X *
***************
*** 1496,1502 ****
  X */
  X
  #if !defined (M_I286)
! #ident	"@(#)mmap.h - MMAP v2.2.2, Copyright (c) Thomas Wolfram 1993"
  #endif
  X
  #define MMAPLBA  ctob(stoc(1))  /* segment low boundary address multiple */
--- 1590,1596 ----
  X */
  X
  #if !defined (M_I286)
! #ident	"@(#)mmap.h - MMAP v2.2.3, Copyright (c) Thomas Wolfram 1993"
  #endif
  X
  #define MMAPLBA  ctob(stoc(1))  /* segment low boundary address multiple */
***************
*** 1539,1558 ****
  } mmapinfo_t;
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmap.h ||
! echo 'restore of mmap-2.2.2/mmap.h failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmap.h'`"
  test 1422 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmap.h: original size 1422, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/mmap.man ==============
! if test -f 'mmap-2.2.2/mmap.man' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmap.man (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmap.man (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmap.man' &&
  .\" Copyright (c) 1993 by Thomas Wolfram
! .TH mmap 7L "2.2.2, 24 September 1993" "Version 2.2.2"
  .de BP
  .sp
  .ti -.2i
--- 1633,1652 ----
  } mmapinfo_t;
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmap.h ||
! echo 'restore of mmap-2.2.3/mmap.h failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmap.h'`"
  test 1422 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmap.h: original size 1422, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/mmap.man ==============
! if test -f 'mmap-2.2.3/mmap.man' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmap.man (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmap.man (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmap.man' &&
  .\" Copyright (c) 1993 by Thomas Wolfram
! .TH mmap 7L "2.2.3, 22 November 1993" "Version 2.2.3"
  .de BP
  .sp
  .ti -.2i
***************
*** 1594,1600 ****
  space for fast access. It is especially useful for accessing the linear frame
  buffers of certain graphic hardware from the user level.
  .P
! To executing the \fIMMAP ioctl\fR commands \fIfildes\fR must be an open file
  descriptor [see \fIopen(2)\fR] that refers to the special character device
  \fI/dev/mmap\fR. The effective user ID of the calling process must be
  superuser.
--- 1688,1694 ----
  space for fast access. It is especially useful for accessing the linear frame
  buffers of certain graphic hardware from the user level.
  .P
! To execute the \fIMMAP ioctl\fR commands \fIfildes\fR must be an open file
  descriptor [see \fIopen(2)\fR] that refers to the special character device
  \fI/dev/mmap\fR. The effective user ID of the calling process must be
  superuser.
***************
*** 1779,1796 ****
  .SH AUTHOR
  Thomas Wolfram
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmap.man ||
! echo 'restore of mmap-2.2.2/mmap.man failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmap.man'`"
! test 7904 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmap.man: original size 7904, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.2/mmaprm.1 ==============
! if test -f 'mmap-2.2.2/mmaprm.1' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmaprm.1 (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmaprm.1 (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmaprm.1' &&
  X
  X
  X
--- 1873,1890 ----
  .SH AUTHOR
  Thomas Wolfram
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmap.man ||
! echo 'restore of mmap-2.2.3/mmap.man failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmap.man'`"
! test 7901 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmap.man: original size 7901, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.3/mmaprm.1 ==============
! if test -f 'mmap-2.2.3/mmaprm.1' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmaprm.1 (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmaprm.1 (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmaprm.1' &&
  X
  X
  X
***************
*** 1853,1875 ****
  X
  X
  X
! X          Rev. 2.2.2, 24. September 1993                             Page 1
  X
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmaprm.1 ||
! echo 'restore of mmap-2.2.2/mmaprm.1 failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmaprm.1'`"
  test 1495 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmaprm.1: original size 1495, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/mmaprm.c ==============
! if test -f 'mmap-2.2.2/mmaprm.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmaprm.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmaprm.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmaprm.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
--- 1947,1969 ----
  X
  X
  X
! X          Rev. 2.2.3, 22 November 1993                               Page 1
  X
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmaprm.1 ||
! echo 'restore of mmap-2.2.3/mmaprm.1 failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmaprm.1'`"
  test 1495 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmaprm.1: original size 1495, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/mmaprm.c ==============
! if test -f 'mmap-2.2.3/mmaprm.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmaprm.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmaprm.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmaprm.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
***************
*** 1997,2016 ****
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmaprm.c ||
! echo 'restore of mmap-2.2.2/mmaprm.c failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmaprm.c'`"
  test 3346 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmaprm.c: original size 3346, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/mmaprm.man ==============
! if test -f 'mmap-2.2.2/mmaprm.man' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmaprm.man (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmaprm.man (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmaprm.man' &&
  .\" Copyright (c) 1993 by Thomas Wolfram
! .TH mmaprm 1L "2.2.2, 24. September 1993" "Version 2.2.2"
  .de BP
  .sp
  .ti -.2i
--- 2091,2110 ----
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmaprm.c ||
! echo 'restore of mmap-2.2.3/mmaprm.c failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmaprm.c'`"
  test 3346 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmaprm.c: original size 3346, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/mmaprm.man ==============
! if test -f 'mmap-2.2.3/mmaprm.man' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmaprm.man (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmaprm.man (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmaprm.man' &&
  .\" Copyright (c) 1993 by Thomas Wolfram
! .TH mmaprm 1L "2.2.3, 22 November 1993" "Version 2.2.3"
  .de BP
  .sp
  .ti -.2i
***************
*** 2041,2058 ****
  .SH AUTHOR
  Thomas Wolfram
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmaprm.man ||
! echo 'restore of mmap-2.2.2/mmaprm.man failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmaprm.man'`"
! test 845 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmaprm.man: original size 845, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.2/mmapstat.1 ==============
! if test -f 'mmap-2.2.2/mmapstat.1' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmapstat.1 (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmapstat.1 (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmapstat.1' &&
  X
  X
  X
--- 2135,2152 ----
  .SH AUTHOR
  Thomas Wolfram
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmaprm.man ||
! echo 'restore of mmap-2.2.3/mmaprm.man failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmaprm.man'`"
! test 843 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmaprm.man: original size 843, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.3/mmapstat.1 ==============
! if test -f 'mmap-2.2.3/mmapstat.1' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmapstat.1 (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmapstat.1 (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmapstat.1' &&
  X
  X
  X
***************
*** 2115,2137 ****
  X
  X
  X
! X          Rev. 2.2.2, 24 September 1993                              Page 1
  X
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmapstat.1 ||
! echo 'restore of mmap-2.2.2/mmapstat.1 failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmapstat.1'`"
  test 1453 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmapstat.1: original size 1453, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/mmapstat.c ==============
! if test -f 'mmap-2.2.2/mmapstat.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmapstat.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmapstat.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmapstat.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
--- 2209,2231 ----
  X
  X
  X
! X          Rev. 2.2.3, 22 November 1993                               Page 1
  X
  X
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmapstat.1 ||
! echo 'restore of mmap-2.2.3/mmapstat.1 failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmapstat.1'`"
  test 1453 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmapstat.1: original size 1453, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/mmapstat.c ==============
! if test -f 'mmap-2.2.3/mmapstat.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmapstat.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmapstat.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmapstat.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
***************
*** 2228,2247 ****
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmapstat.c ||
! echo 'restore of mmap-2.2.2/mmapstat.c failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmapstat.c'`"
  test 2531 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmapstat.c: original size 2531, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.2/mmapstat.man ==============
! if test -f 'mmap-2.2.2/mmapstat.man' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/mmapstat.man (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/mmapstat.man (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/mmapstat.man' &&
  .\" Copyright (c) 1993 by Thomas Wolfram
! .TH mmapstat 1L "2.2.2, 24 September 1993" "Version 2.2.2"
  .de BP
  .sp
  .ti -.2i
--- 2322,2341 ----
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmapstat.c ||
! echo 'restore of mmap-2.2.3/mmapstat.c failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmapstat.c'`"
  test 2531 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmapstat.c: original size 2531, current size' "$Wc_c"
  fi
! # ============= mmap-2.2.3/mmapstat.man ==============
! if test -f 'mmap-2.2.3/mmapstat.man' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/mmapstat.man (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/mmapstat.man (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/mmapstat.man' &&
  .\" Copyright (c) 1993 by Thomas Wolfram
! .TH mmapstat 1L "2.2.3, 22 November 1993" "Version 2.2.3"
  .de BP
  .sp
  .ti -.2i
***************
*** 2273,2290 ****
  .SH AUTHOR
  Thomas Wolfram
  SHAR_EOF
! chmod 0644 mmap-2.2.2/mmapstat.man ||
! echo 'restore of mmap-2.2.2/mmapstat.man failed'
! Wc_c="`wc -c < 'mmap-2.2.2/mmapstat.man'`"
! test 809 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/mmapstat.man: original size 809, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.2/tstmap.c ==============
! if test -f 'mmap-2.2.2/tstmap.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.2/tstmap.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.2/tstmap.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.2/tstmap.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
--- 2367,2384 ----
  .SH AUTHOR
  Thomas Wolfram
  SHAR_EOF
! chmod 0644 mmap-2.2.3/mmapstat.man ||
! echo 'restore of mmap-2.2.3/mmapstat.man failed'
! Wc_c="`wc -c < 'mmap-2.2.3/mmapstat.man'`"
! test 808 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/mmapstat.man: original size 808, current size' "$Wc_c"
! fi
! # ============= mmap-2.2.3/tstmap.c ==============
! if test -f 'mmap-2.2.3/tstmap.c' -a X"$1" != X"-c"; then
! 	echo 'x - skipping mmap-2.2.3/tstmap.c (File already exists)'
  else
! echo 'x - extracting mmap-2.2.3/tstmap.c (Text)'
! sed 's/^X//' << 'SHAR_EOF' > 'mmap-2.2.3/tstmap.c' &&
  /*
  X * Copyright (c) 1993 by Thomas Wolfram, Berlin, Germany.
  X *
***************
*** 2375,2384 ****
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.2/tstmap.c ||
! echo 'restore of mmap-2.2.2/tstmap.c failed'
! Wc_c="`wc -c < 'mmap-2.2.2/tstmap.c'`"
  test 2539 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.2/tstmap.c: original size 2539, current size' "$Wc_c"
  fi
  exit 0
--- 2469,2478 ----
  }
  X
  SHAR_EOF
! chmod 0644 mmap-2.2.3/tstmap.c ||
! echo 'restore of mmap-2.2.3/tstmap.c failed'
! Wc_c="`wc -c < 'mmap-2.2.3/tstmap.c'`"
  test 2539 -eq "$Wc_c" ||
! 	echo 'mmap-2.2.3/tstmap.c: original size 2539, current size' "$Wc_c"
  fi
  exit 0
diff -c mit/server/ddx/x386/etc/modeDB.txt:2.8 mit/server/ddx/x386/etc/modeDB.txt:2.14
*** mit/server/ddx/x386/etc/modeDB.txt:2.8	Fri Mar 11 23:39:36 1994
--- mit/server/ddx/x386/etc/modeDB.txt	Fri Mar 11 23:39:37 1994
***************
*** 1,16 ****
! #  $XFree86: mit/server/ddx/x386/etc/modeDB.txt,v 2.8 1993/10/23 04:53:28 dawes Exp $
  #
  # X386 Mode database
  # Compiled by David Wexelblat [dwex@goblin.org, dwex@aib.com]
  # Huge Contributions to v2.0 from Thomas Roell [roell@sgcs.com]
  #
! # Version 3.5
! # 10/7/93
  #
  # The lastest version of this file and related documentation is available 
  # for anonymous FTP from ftp.x.org in contrib/XF86mode.tar.gz, or from the 
  # compiler at the address above.
  #
  # NOTE:
  #   The information in this file was provided to the compiler by the
  #   individuals listed with each entry.  No effort has been made to
--- 1,21 ----
! #  $XFree86: mit/server/ddx/x386/etc/modeDB.txt,v 2.14 1994/03/07 14:00:29 dawes Exp $
  #
  # X386 Mode database
  # Compiled by David Wexelblat [dwex@goblin.org, dwex@aib.com]
  # Huge Contributions to v2.0 from Thomas Roell [roell@sgcs.com]
  #
! # Version 3.7
! # Mar 06, 1994
  #
  # The lastest version of this file and related documentation is available 
  # for anonymous FTP from ftp.x.org in contrib/XF86mode.tar.gz, or from the 
  # compiler at the address above.
  #
+ # ACCELERATED CARD NOTE:
+ #   Refer to the AccelCards file for real details on accelerated cards
+ #   supported by XFree86.  Accelerated cards include ATI Mach8/Mach32,
+ #   8514/A, S3, Cirrus 5426/5428, and WD90C31.
+ #
  # NOTE:
  #   The information in this file was provided to the compiler by the
  #   individuals listed with each entry.  No effort has been made to
***************
*** 48,57 ****
  #   distinguished by some identifying characteristic (e.g. board date code).
  #   This was not always possible, however.
  #
! #   If your card is not listed below, you can use the clock.exe program
! #   provided with the X386 1.1b distribution, or the startup information
! #   from X386 1.2 to get the clock information.  Note that the clock listing
! #   must be in the exact order reported by these sources - don't sort them.
  #
  #   Once you have identified your card, you can locate entries for your
  #   monitor.  At the beginning of the monitor section is a listing of the
--- 53,62 ----
  #   distinguished by some identifying characteristic (e.g. board date code).
  #   This was not always possible, however.
  #
! #   If your card is not listed below, you can use the the startup information
! #   from X386 1.2, X386 1.2E, or XFree86 to get the clock information.  Note 
! #   that the clock listing must be in the exact order reported by these 
! #   sources - don't sort them.
  #
  #   Once you have identified your card, you can locate entries for your
  #   monitor.  At the beginning of the monitor section is a listing of the
***************
*** 139,144 ****
--- 144,160 ----
                            135  32 110  80  45  40  75  65
  
  ###############################################################################
+ # Card:                 ATI mach32 (VLB)
+ # Contributor:          Craig E. Groeschel [craig@adikia.sccsi.com]
+ # Last Edit Date:       11/18/93
+ #
+ # chip  ram  virtual  clocks                                 default-mode flags
+  mach32 2048 1152 900 100 126 92.4 36 50.35  56.64 0    44.9 "1024x768"
+ 		      135  32 110  80 39.91  44.9  75   65
+ 		      50   63 46.2 18 25.175 28.32 0    22.45
+ 		      67.5 16 55   40 19.955 22.45 37.5 32.5
+ 
+ ###############################################################################
  # Card: 		ATI VGA-Wondercard
  # Contributor: 		Per Lindqvist [pgd@compuram.bbt.se]
  # Last Edit Date:	9/12/91
***************
*** 167,172 ****
--- 183,198 ----
   ET4000    512   840 624   25  28  36  40  50  45  65   0  "840x624"
  
  ###############################################################################
+ # Card:                 Boca Reasearch SVGAX2
+ # Contributor:          Steve Kump [skump@panix.com]
+ # Last Edit Date:       11/04/93
+ #
+ # chip    ram   virtual   clocks                           default-mode  flags
+  clgd5422 1024  1152 900   25.23  28.32  41.16  36.08      "1024x768i"
+ 			   31.50  39.99  45.08  49.87 
+ 			   64.98  72.16  75.00  80.01
+ 
+ ###############################################################################
  # Card: 		Cardinal 700, 1M
  # Contributor: 		[hedrick@cs.rutgers.edu]
  # Last Edit Date: 	8/29/92
***************
*** 269,275 ****
  
  ###############################################################################
  # Card: 		Diamond Stealth(S3 924)
! # Contributor: 		Keishi Manabe <manabe@zephyrus.tutics.tut.ac.jp>
  # Last Edit Date: 	2/16/93
  #
  # chip    ram   virtual   clocks                           default-mode  flags
--- 295,301 ----
  
  ###############################################################################
  # Card: 		Diamond Stealth(S3 924)
! # Contributor: 		Keishi Manabe [manabe@zephyrus.tutics.tut.ac.jp]
  # Last Edit Date: 	2/16/93
  #
  # chip    ram   virtual   clocks                           default-mode  flags
***************
*** 524,529 ****
--- 550,575 ----
   ET4000   1024  1024 768   24  28  32  36  40  45  56  65  "1024x768"
  
  ###############################################################################
+ # Card: 		Tseng Labs ET4000
+ # Contributor: 		David McCullough [davidm@stallio.oz.au]
+ # Last Edit Date: 	11/19/93
+ #
+ # chip    ram   virtual   clocks                           default-mode  flags
+  ET4000   1024  1024 768   25.2  28.3  32.5  36.0          "1024x768"
+ 			   40.0  44.9  31.5  37.5
+ 			   50.3  56.6  65.0  72.0
+ 			   80.0  89.8  63.0  75.0
+ 
+ ###############################################################################
+ # Card: 		Tseng Labs ET4000/W32 VLB
+ # Contributor: 		Georges Tomazi [tomazi@kralizec.zeta.org.au]
+ # Last Edit Date: 	12/19/93
+ #
+ # chip    ram   virtual   clocks                           default-mode  flags
+  ET4000   1024  1024 768   25  28  32  36  40  34  32  38  "1024x768"
+ 			   50  56  65  72  80  90  63  75
+ 
+ ###############################################################################
  # Card: 		Tseng Highcolor 72Mhz
  # Contributor: 		Tom Hoople [hooplet@ucsu.Colorado.EDU]
  # Last Edit Date: 	3/18/92
***************
*** 786,791 ****
--- 832,856 ----
  ###############################################################################
  
  ###############################################################################
+ # Monitor:              Acer Computer GmbH, Mod. No. 7033
+ #                       (14" 8514/A compatible)
+ # Contributor:          Michael Riepe [riepe@ifwsn4.ifw.uni-hannover.de]
+ # Last Edit Date:       11/20/1993
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "640x480"     25.175  640  672  768  800    480  490  492  525
+  "800x600"     36      800  832  976 1016    600  604  606  634
+  "1024x768i"   44.9   1024 1048 1208 1264    768  776  784  817  Interlace
+ 
+ ###############################################################################
+ # Monitor:              AcerView 25 uvga (also ViewSonic 5e)
+ # Contributor: 		Thomas Dunbar [tdunbar@vtaix.cc.vt.edu]
+ # Last Edit Date: 	5/1/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    78     1024 1056 1336 1368    768  768  776  790
+ 
+ ###############################################################################
  # Monitor:              AcerView 25 uvga (also ViewSonic 5e)
  # Contributor: 		Richard Brown [rab@tauon.ph.unimelb.edu.au]
  # Last Edit Date: 	5/25/93
***************
*** 798,808 ****
  
  ###############################################################################
  # Monitor:              AcerView 25 uvga (also ViewSonic 5e)
! # Contributor: 		Thomas Dunbar [tdunbar@vtaix.cc.vt.edu]
! # Last Edit Date: 	5/1/93
  #
  # name        clock   horizontal timing     vertical timing      flags
!  "1024x768"    78     1024 1056 1336 1368    768  768  776  790
  
  ###############################################################################
  # Monitor:              AOC CM-337
--- 863,887 ----
  
  ###############################################################################
  # Monitor:              AcerView 25 uvga (also ViewSonic 5e)
! # Contributor:          Craig E. Groeschel [craig@adikia.sccsi.com]
! # Last Edit Date:       11/18/93
  #
  # name        clock   horizontal timing     vertical timing      flags
!  "640x400"     28.32   640  664  712  808    400  400  402  417 -hsync -vsync
!  "672x448"     28.32   672  712  760  864    448  451  454  466 -hsync -vsync
!  "680x510"     32      680  736  792  904    510  513  516  530 +hsync +vsync
!  "800x600"     40      800  848 1000 1056    600  603  606  621 +hsync +vsync
!  "920x690"     65      920  984 1024 1272    690  696  699  720 -hsync -vsync
!  "1024x768"    75     1024 1120 1256 1440    768  768  770  800 -hsync -vsync
!                80     1024 1144 1296 1464    768  774  777  801 -hsync -vsync
! 
! ###############################################################################
! # Monitor:              Addonics C172/LR Ultra 1280
! # Contributor:          Joergen Haegg  [jh@efd.lth.se]
! # Last Edit Date:       11/20/93
! #
! # name         clock  horizontal timing     vertical timing      flags
!  "1024x768"    75     1024 1048 1184 1328    768  771  777  806
  
  ###############################################################################
  # Monitor:              AOC CM-337
***************
*** 850,855 ****
--- 929,943 ----
   "1280x1024"  110     1280 1472 1568 1728   1024 1026 1029 1061
  
  ###############################################################################
+ # Monitor:              CTX CMS-1561
+ # Contributor:          Steve Forsythe (forsse@meaddata.com)
+ # Last Edit Date:       11/22/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "800x600"     36      800  824  896 1024    600  601  603  625
+  "1024x768"    75     1024 1072 1216 1352    768  769  775  806 
+ 
+ ###############################################################################
  # Monitor: 		CTX 1760DF
  # Contributor: 		Thomas Dunbar [tdunbar@vtaix.cc.vt.edu]
  # Last Edit Date: 	5/1/93
***************
*** 878,883 ****
--- 966,979 ----
   "1024x768i"   45     1024 1064 1224 1264    768  777  785  817  Interlace
  
  ###############################################################################
+ # Monitor: 		CTX SVGA CVP-5468
+ # Contributor: 		Kent Hamilton [kenth@hns.st-louis.mo.US]
+ # Last Edit Date: 	11/18/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768i"   40     1024 1064 1224 1264    768  773  781  813  Interlace
+ 
+ ###############################################################################
  # Monitor: 		CTX SVGA model CVP-5468NI
  # Contributor: 		Brendan Boerner [bboerner@novell.com]
  # Last Edit Date: 	10/29/92
***************
*** 897,902 ****
--- 993,1027 ----
   "1024x768"    65     1024 1088 1200 1328    768  783  789  818
  
  ###############################################################################
+ # Monitor:              Data General 6628
+ # Contributor:          J"org Wunsch [joerg_wunsch@tcd-dresden.de]
+ # Last Edit Date:       11/19/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "640x480t"    25      640  680  768  800    480  491  493  525
+  "640x480+"    28      640  672  760  816    480  491  493  525
+ 
+ ###############################################################################
+ # Monitor:              DEC PC7XV-DE
+ # Contributor:          Eric Hvozda [ack@clark.net]
+ # Last Edit Date:       2/20/94
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "640x350"     25      640  656  784  800    350  385  386  449
+  "640x400"     25      640  648  776  800    400  412  416  449
+  "640x480"     31      640  664  704  832    480  489  492  520
+  "800x600"     50      800  856  976 1040    600  637  643  666  +hsync +vsync
+  "1024x768"    75     1024 1048 1184 1320    768  771  790  811  -hsync -vsync
+ 
+ ###############################################################################
+ # Monitor:              DEC VR290-DA
+ # Contributor:          Paul Nixon [pnixon@ccd.harris.com]
+ # Last Edit Date:       12/13/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  1024x768      75     1024 1048 1184 1328    768  771  777  806  -hsync -vsync
+ 
+ ###############################################################################
  # Monitor:              DEC VRC16
  # Contributor:          Jack Coyote [uphrrmk@gemini.oscs.montana.edu]
  # Last Edit Date:       6/15/93
***************
*** 979,985 ****
  
  ###############################################################################
  # Monitor:              EIZO/Nanao 9070s
! # Contributor:          Paul De Bra [debra@wsinis07.info.win.tue.nl]
  # Last Edit Date:       8/28/93
  #
  # name        clock   horizontal timing     vertical timing      flags
--- 1104,1110 ----
  
  ###############################################################################
  # Monitor:              EIZO/Nanao 9070s
! # Contributor:          Paul De Bra [debra@win.tue.nl]
  # Last Edit Date:       8/28/93
  #
  # name        clock   horizontal timing     vertical timing      flags
***************
*** 1046,1051 ****
--- 1171,1195 ----
   "1280x1024"  110     1280 1312 1408 1696   1024 1043 1053 1081
  
  ###############################################################################
+ # Monitor:              EIZO/Nanao 550i
+ # Contributor:          Bill Broadley  [broadley@neurocog.lrdc.pitt.edu]
+ # Last Edit Date:       11/22/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    80     1024 1040 1080 1374    768  769  771  790
+ 
+ ###############################################################################
+ # Monitor:              EIZO/Nanao F550i
+ # Contributor:          Mark Weaver [Mark_Weaver@brown.edu]
+ # Last Edit Date:       11/24/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "800x600"     45      800  856  976 1040    600  637  643  666
+  "1024x768"    75     1024 1048 1184 1328    768  771  777  806
+  "1152x900i"   80     1152 1168 1384 1440    900  901  907  945  Interlace
+  "1280x1024i"  80     1280 1296 1512 1568   1024 1025 1037 1165  Interlace
+ 
+ ###############################################################################
  # Monitor:              EIZO/Nanao F550i-M
  # Contributor:          Michael Hirsch [mike@rolivaw.pr.net.ch]
  # Last Edit Date:       3/22/93
***************
*** 1075,1088 ****
                135     1280 1424 1504 1704    1024 1028 1033 1056
  
  ###############################################################################
- # Monitor:              EIZO/Nanao T660i
- # Contributor:          Ng Pheng Siong [ngps@stargate.np.ac.sg]
- # Last Edit Date:       3/20/93
- #
- # name        clock   horizontal timing     vertical timing      flags
-  "1024x768"    80     1024 1088 1216 1344    768  777  782  810
- 
- ###############################################################################
  # Monitor:              EIZO/Nanao T560i
  # Contributor:          Ronald D. Hindmarsh [ronald@cs.tu-berlin.de]
  # Last Edit Date:       5/1/93
--- 1219,1224 ----
***************
*** 1093,1098 ****
--- 1229,1258 ----
                120     1024 1056 1080 1328    768  776  786  800
  
  ###############################################################################
+ # Monitor:              EIZO/Nanao T560i
+ # Contributor:          Raymond Nijssen [raymond@woensel.es.ele.tue.nl]
+ # Last Edit Date:       11/23/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1152x910"    89.8   1152 1256 1272 1424    910  907  912  929
+ 
+ ###############################################################################
+ # Monitor:              EIZO/Nanao T560iT92
+ # Contributor:          Norbert Distler [norbert@physik.tu-muenchen.de]
+ # Last Edit Date:       11/24/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "800x600"     56      800  856  976 1040    600  637  643  666
+ 
+ ###############################################################################
+ # Monitor:              EIZO/Nanao T660i
+ # Contributor:          Ng Pheng Siong [ngps@stargate.np.ac.sg]
+ # Last Edit Date:       3/20/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    80     1024 1088 1216 1344    768  777  782  810
+ 
+ ###############################################################################
  # Monitor:              ESCOMM 15"
  # Contributor: 		Hartmut Kuehn Allgemeine Box IET 
  #			[KUEHNNTE@Rcms1.urz.tu-dresden.de]
***************
*** 1111,1116 ****
--- 1271,1285 ----
   "1096x822"    80     1096 1112 1368 1384    822  830  840  876
  
  ###############################################################################
+ # Monitor:              ESCOM (Liberty?) 20" ES8923MNR
+ # Contributor:          Guido Kueppers ^[Kueppers@uni-bonn.de|
+ # Last Edit Date:       11/17/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1152x900"    80     1152 1184 1264 1408    900  905  908  936
+  "1184x884"    80     1184 1216 1296 1460    884  884  888  913
+ 
+ ###############################################################################
  # Monitor: 		Everex Eversync/VGA
  # Contributor: 		Dan Ellison [dan@dribble.c-mols.siu.edu]
  # Last Edit Date: 	2/20/92
***************
*** 1165,1170 ****
--- 1334,1348 ----
   "1024x768"    65     1024 1096 1264 1344    768  771  777  806
  
  ###############################################################################
+ # Monitor:              Gateway 2000 Crystal Scan 1024NI
+ # Contributor:          Kent Hamilton [kenth@hns.st-louis.mo.US]
+ # Last Edit Date:       11/18/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    65     1024 1088 1256 1328    768  771  777  806
+  "1120x840i"   50     1120 1152 1325 1440    840  859  893  915
+ 
+ ###############################################################################
  # Monitor:              Gateway 2000 (MAG) Crystal Scan 1572 FS 
  # Contributor:          Bill C. Riemers [bcr@physics.purdue.edu]
  # Last Edit Date:       5/4/93
***************
*** 1202,1207 ****
--- 1380,1409 ----
   "1280x960"   110     1280 1464 1616 1728    960  969  985 1061
  
  ###############################################################################
+ # Monitor:              Hitachi 20S
+ # Contributor:          Rich Murphey [rich@rice.edu]
+ # Contributor:          Rod Grimes [rgrimes@freefall.cdrom.com]
+ # Contributor:          David Greenman [davidg%implode@percy.rain.com]
+ # Last Edit Date:       11/20/93
+ #
+ # name         clock  horizontal timing     vertical timing      flags
+  "1024x768"     74     1024 1040 1200 1300   768  772  777  809
+  "1152x900"     85     1152 1184 1376 1464   900  905  923  955
+  "1280x960"    108     1280 1288 1400 1620   960  961  979 1012
+  "1280x1024"   110     1280 1288 1500 1688  1024 1026 1031 1077
+ 
+ ###############################################################################
+ # Monitor:              Hitachi HM-4119
+ # Contributor:          Todd Pfaff [todd@flex.eng.mcmaster.ca]
+ # Last Edit Date:       11/19/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    80     1024 1104 1232 1328    768  769  777  817  -hsync -vsync 
+ 								 composite
+  "1152x900"    92     1152 1232 1376 1456    900  901  909  945  -hsync -vsync 
+ 								 composite
+ 
+ ###############################################################################
  # Monitor:              IBM 8514-001
  # Contributor:          Mark Petrovic [petrovic@watson.ibm.com]
  # Last Edit Date:       5/11/93
***************
*** 1230,1236 ****
  ###############################################################################
  #  Monitor:             IDEKIiyama MF-5217
  # Contributor:          Jun Arihara[j_ariha@hoffman.cc.sophia.ac.jp]
! #                       Takahiro Noguchi<Takahiro.Noguchi@Japan.Sun.COM>
  # Last Edit Date:       2/20/93
  #
  # name        clock   horizontal timing     vertical timing      flags
--- 1432,1438 ----
  ###############################################################################
  #  Monitor:             IDEKIiyama MF-5217
  # Contributor:          Jun Arihara[j_ariha@hoffman.cc.sophia.ac.jp]
! #                       Takahiro Noguchi[Takahiro.Noguchi@Japan.Sun.COM]
  # Last Edit Date:       2/20/93
  #
  # name        clock   horizontal timing     vertical timing      flags
***************
*** 1323,1328 ****
--- 1525,1544 ----
   "1108x796"    65     1108 1136 1288 1344    796  796  799  814
  
  ###############################################################################
+ # Monitor:              MAG15F
+ # Contributor:          John Brezak [brezak@apollo.hp.com]
+ # Last Edit Date:       12/6/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "640x480"     25      640  664  760  800    480  491  493  525
+                31      640  664  704  832    480  489  492  520
+  "800x600"     36      800  824  896 1024    600  601  603  625
+                40      800  840  968 1056    600  601  605  628
+                50      800  856  976 1040    600  637  643  666
+  "1024x768i"   44     1024 1040 1216 1264    768  777  785  817  Interlace
+  "1024x768"    75     1024 1056 1204 1324    768  774  803  806
+ 
+ ###############################################################################
  # Monitor:              MAG 1564NI
  #
  # See entry under "EDGE/MAG 1564NI" above.
***************
*** 1342,1353 ****
  ###############################################################################
  # Monitor:              MAG MX-17H
  # Contributor:          Richard Gooch [rgooch@atnf.csiro.au]
! # Last Edit Date:       8/22/93
  #
  # name        clock   horizontal timing     vertical timing      flags
   "1152x900"    95     1152 1152 1168 1472    900  900  931  939
  
  ###############################################################################
  # Monitor:              Mag Technology Co. PMV1448
  # Contributor:          Mark Petrovic [petrovic@watson.ibm.com]
  # Last Edit Date:       5/12/93
--- 1558,1589 ----
  ###############################################################################
  # Monitor:              MAG MX-17H
  # Contributor:          Richard Gooch [rgooch@atnf.csiro.au]
! # Last Edit Date:       11/19/93
  #
  # name        clock   horizontal timing     vertical timing      flags
   "1152x900"    95     1152 1152 1168 1472    900  900  931  939
+  "1152x900"    95     1152 1152 1192 1472    900  900  911  925
+  "1152x900f"  110     1152 1152 1168 1616    900  900  911  925
+ 
+ ###############################################################################
+ # Monitor:              MAG MX-17H
+ # Contributor:          Dave Truckenmiller [trucken@cs.umn.edu]
+ # Last Edit Date:       11/19/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "640x480"     25      640  672   768  800   480  490  492  525
+  "800x600"     47      800  800   944 1016   600  600  603  617
  
  ###############################################################################
+ # Monitor:              MAG MX-17H
+ # Contributor:          Jordan K. Hubbard [jkh@whisker.lotus.ie]
+ # Last Edit Date:       11/23/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    74     1024 1040 1200 1300    768   772  777  809
+  "1200x900"   105     1200 1208 1364 1572    900   905  923  955
+ 
+ ###############################################################################
  # Monitor:              Mag Technology Co. PMV1448
  # Contributor:          Mark Petrovic [petrovic@watson.ibm.com]
  # Last Edit Date:       5/12/93
***************
*** 1455,1463 ****
--- 1691,1701 ----
  # Monitor:		Nanao 9080i
  # Monitor:		Nanao 9400i
  # Monitor:		Nanao 9500
+ # Monitor:		Nanao F550i
  # Monitor:		Nanao F550i-M
  # Monitor:		Nanao T550i-M
  # Monitor:		Nanao T560i
+ # Monitor:		Nanao T560iT92
  # Monitor:		Nanao T660i
  #
  # See entries under "EIZO" above.
***************
*** 1609,1617 ****
  # Last Edit Date:	6/15/93
  #
  # name         clock  horizontal timing     vertical timing      flags
!  "1024x768"     65     1024 1065 1065 1260   768  787  792  810
  
  ###############################################################################
  # Monitor:              NEC Multisync JC-14O1P3ED
  # Contributor:          Dirk Hohndel [hohndel@informatik.uni-wuerzburg.de]
  # Last Edit Date:       05/11/93
--- 1847,1883 ----
  # Last Edit Date:	6/15/93
  #
  # name         clock  horizontal timing     vertical timing      flags
!  "1024x768"     65    1024 1065 1065 1260    768  787  792  810
! 
! ###############################################################################
! # Monitor:              NEC 5FG.
! # Contributor:          Hans Nasten [nasten@everyware.se]
! # Last Edit Date:       11/18/93
! # 
! # name         clock  horizontal timing     vertical timing      flags
!  "640x480"     32      640  684  724  832    480  489  492  520
!  "800x600"     50      800  856  976 1040    600  637  643  666
!  "1024x768"    75     1024 1032 1264 1272    768  786  791  810
! 
! ###############################################################################
! # Monitor:              NEC 5FG (also works with MAG MX-17H)
! # Contributor:          Richard Gooch [rgooch@atnf.csiro.au]
! # Last Edit Date:       11/19/93
! #
! # name         clock  horizontal timing     vertical timing      flags
!  "1152x900"     95    1152 1152 1192 1472    900  900  931  939
  
  ###############################################################################
+ # Monitor:              NEC 5FGe
+ # Contributor:          [skelton%jdp.uucp@dragon.com]
+ # Last Edit Date:       11/29/93
+ #
+ # name         clock  horizontal timing     vertical timing      flags
+  "640x480"      28.322 640  680  720  864    480  488  491  521
+  "800x600"      36     800  824  896 1024    600  601  603  625
+  "1024x768"     65    1024 1032 1176 1344    768  771  777  806 -hsync -vsync
+ 
+ ###############################################################################
  # Monitor:              NEC Multisync JC-14O1P3ED
  # Contributor:          Dirk Hohndel [hohndel@informatik.uni-wuerzburg.de]
  # Last Edit Date:       05/11/93
***************
*** 1644,1649 ****
--- 1910,1924 ----
   "800x600"      40     800  816  944 1056    600  601  605  628
  
  ###############################################################################
+ # Monitor:              ViewSonic 17
+ # Contributor:          Steven Wallace [swallace@ece.uci.edu]
+ # Last Edit Date:       11/22/93
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    65     1024 1056 1296 1328    768  768  778  807
+  "1024x800"    94.6   1152 1184 1544 1576    800  801  808  845
+ 
+ ###############################################################################
  # Monitor: 		Packard Bell (model unknown)
  # Contributor: 		E.J.McKernan [ejm@datalog.com]
  # Last Edit Date: 	12/16/91
***************
*** 1755,1760 ****
--- 2030,2046 ----
   "1024x768"     64    1024 1030 1196 1264    768  778  779  804
  
  ###############################################################################
+ # Monitor: 		Royal Information Electronics DM1564
+ # Contributor: 		Georges Tomazi [tomazi@kralizec.zeta.org.au]
+ # Last Edit Date: 	12/19/93
+ #
+ # name         clock  horizontal timing     vertical timing      flags
+  "640x480"     31.5    640  680  720  864    480  488  491  521
+  "800x600"     50      800  880 1000 1040    600  637  643  666  +hsync +vsync
+  "1024x768i"   44.9   1024 1056 1216 1264    768  776  784  817  Interlace
+  "1024x768"    72     1024 1048 1184 1280    768  778  784  806  -hsync -vsync
+ 
+ ###############################################################################
  # Monitor:              Sampo AlphaScan Plus
  # Contributor:          Glenn Lai [glenn@cs.utexas.edu]
  # Last Edit Date:       5/11/92
***************
*** 1816,1821 ****
--- 2102,2130 ----
   "1024x768"     62    1024 1040 1184 1328    768  783  789  829
  
  ###############################################################################
+ # Monitor:              Seiko CM 1450
+ # Contributor:          Steve Kump [skump@panix.com]
+ # Last Edit Date:       11/04/93
+ #
+ # name         clock  horizontal timing     vertical timing      flags
+  "640x480"      31.5   640  680  720  832    480  489  491  519
+  "800x600"      50     800  816  936 1024    600  611  617  655
+  "1024x768i"    50    1024 1040 1200 1264    768  773  781  817  Interlace
+  "1024x900i"    65    1024 1074 1248 1392    900  901  905  955  Interlace
+  "1152x900i"    65    1152 1192 1402 1512    900  901  913  947  Interlace
+ 
+ ###############################################################################
+ # Monitor:              Seiko Instruments CM1760LR
+ # Contributor:          Ed Hall [edhall@rand.org]
+ # Last Edit Date:       11/24/93
+ #
+ # name         clock  horizontal timing     vertical timing      flags
+  "640x480"      28     640  660  712  784    480  480  483  496
+  "800x600"      44     800  856  928  992    600  600  607  621
+  "1024x768"     72    1024 1072 1184 1306    768  771  777  796
+  "1152x900"     85    1152 1184 1296 1456    900  908  929  939
+ 
+ ###############################################################################
  # Monitor:              Siemens C79145
  # Contributor:          Thomas Roell [roell@sgcs.com]
  # Last Edit Date:       03/29/91
***************
*** 1833,1838 ****
--- 2142,2155 ----
   "1024x768"    62     1024 1032 1096 1272    768  768  772  792
  
  ###############################################################################
+ # Monitor:              Sony CPD-1304
+ # Contributor: 		Alexander-James Annala [merlin@neuro.usc.edu]
+ # Last Edit Date: 	Jan 1, 1994
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"    75.40   1024 1032 1096 1272   768 768 772 792
+ 
+ ###############################################################################
  # Monitor:              Sony CPD-1404E (14") in AUTO LOCK mode
  # Contributor: 		J. Schnitter [josch@pc.chemie.th-darmstadt.de]
  # Last Edit Date: 	5/6/92
***************
*** 1895,1900 ****
--- 2212,2229 ----
   "1280x1024"   110    1280 1344 1472 1728   1024 1035 1038 1061
  
  ###############################################################################
+ # Monitor:              SuperView DX15F
+ # Contributor:          Frode Roervik [froder@ifi.uio.no]
+ # Last Edit Date:       1/25/94
+ #
+ # name        clock   horizontal timing     vertical timing      flags
+ 
+  "1024x768v1"  75     1024 1096 1232 1312    768  768  776  808
+  "1024x768v2"  75     1024 1048 1184 1328    768  771  777  806  -hsync +vsync
+  "1024x768v3"  75     1024 1048 1184 1288    768  773  777  806
+  "1024x768v4"  80     1024 1072 1288 1328    768  768  771  807
+ 
+ ###############################################################################
  # Monitor:              TARGA 1710 D
  # Contributor:          Helmut Geyer [geyer@kalliope.iwr.uni-heidelberg.de]
  # Last Edit Date:       19/10/93
***************
*** 1915,1920 ****
--- 2244,2259 ----
   "800x655"      36     800  816  976 1008    655  658  660  687
  
  ###############################################################################
+ # Monitor: 		Tatung CM14UAS
+ # Contributor: 		David McCullough [davidm@stallio.oz.au]
+ # Last Edit Date: 	11/19/93
+ #
+ # name         clock  horizontal timing     vertical timing      flags
+  "640x480"     25      640  664  760  800    480  491  493  525
+  "800x600"     40      800  840  968 1056    600  601  605  628
+  "1024x768"    65     1024 1152 1184 1360    768  766  772  806
+ 
+ ###############################################################################
  # Monitor:              TAXAN 990
  # Contributor:          Thomas Roell [roell@sgcs.com]
  # Last Edit Date:       03/29/91
***************
*** 1923,1928 ****
--- 2262,2276 ----
   "1280x1024"   110    1280 1472 1568 1728   1024 1026 1029 1061
  
  ###############################################################################
+ # Monitor:              Taxan MultiVision 875 plus LR
+ # Contributor:          Harald Koenig [koenig@tat.physik.uni-tuebingen.de]
+ # Last Edit Date:       11/25/93
+ #
+ # Horizontal frequency: 71990 Hz, vertical frequency: 90.7 Hz
+ # name        clock   horizontal timing     vertical timing      flags
+  "1024x768"   110     1024 1024 1104 1528    768  768  772  794
+ 
+ ###############################################################################
  # Monitor: 		TAXAN Ultravision 1095
  # Contributor: 		Matti Aarnio [mea@utu.fi, mea@nic.funet.fi]
  # Last Edit Date: 	1/6/92
***************
*** 1931,1941 ****
   "1152x910"     72    1152 1240 1312 1544    910  925  940  955  -hsync -vsync
  
  ###############################################################################
! # Monitor:		Viewsonic 5e
  #
  # See entry for "AcerView 25 uvga" above.
  
  ###############################################################################
  # Monitor: 		ViewSonic 6e
  # Contributor: 		Dennis T. Flahert [dennisf@denix.elk.miles.com]
  # Last Edit Date: 	5/10/93
--- 2279,2308 ----
   "1152x910"     72    1152 1240 1312 1544    910  925  940  955  -hsync -vsync
  
  ###############################################################################
! # Monitor: 		ViewSonic 4
! # Contributor: 		Scott Mitchell [smitchel@credit.erin.utoronto.ca]
! # Last Edit Date: 	12/3/93
! #
! # name         clock  horizontal timing     vertical timing      flags
!  "640x480"      25     640  656  752  800    480  490  492  525
!  "800x600"      36     800  824  896 1024    600  601  603  625
! 
! ###############################################################################
! # Monitor:		ViewSonic 5e
  #
  # See entry for "AcerView 25 uvga" above.
  
  ###############################################################################
+ # Monitor: 		ViewSonic 6
+ # Contributor: 		[afgun@engin.umich.edu]
+ # Last Edit Date: 	12/10/93
+ #
+ # name         clock  horizontal timing     vertical timing      flags
+  "640x480"      25     640  656  752  800    480  490  492  525
+  "800x600"      36     800  824  896 1024    600  601  603  625
+  "1024x768"     65    1024 1063 1271 1344    768  771  774  805
+ 
+ ###############################################################################
  # Monitor: 		ViewSonic 6e
  # Contributor: 		Dennis T. Flahert [dennisf@denix.elk.miles.com]
  # Last Edit Date: 	5/10/93
***************
*** 1962,1970 ****
  ###############################################################################
  # Monitor: 		ViewSonic 7
  # Contributor: 		Henry A Worth [haw30@ras.amdahl.com]
! # Last Edit Date: 	9/7/93
  #
  # name         clock  horizontal timing     vertical timing      flags
!  "1024x768"     65    1024 1072 1176 1272    768  778  779  804
! 		75    1024 1048 1148 1328    768  771  777  806
! 		85    1024 1032 1104 1328    768  786  790  831
--- 2329,2360 ----
  ###############################################################################
  # Monitor: 		ViewSonic 7
  # Contributor: 		Henry A Worth [haw30@ras.amdahl.com]
! # Last Edit Date: 	3/4/94
! #
! # name         clock  horizontal timing     vertical timing      flags
!  "640x480"      30     640  664  728  784    480  480  484  507  
!  "800x600"      50     800  808  920 1032    600  600  610  635
!  "1024x768"     65    1024 1032 1208 1288    768  768  773  798
!                 75    1024 1048 1184 1328    768  771  777  802 
!                 80    1024 1032 1216 1344    768  768  773  805
! 
! ###############################################################################
! # Monitor: 		ViewSonic 15
! # Contributor: 		Frank Mayhar
! # Last Edit Date: 	12/13/93
  #
  # name         clock  horizontal timing     vertical timing      flags
!  "1024x768"     95    1024 1144 1264 1384    768  770  774  809
!  "1152x900"    110    1152 1284 1416 1536    900  902  905  941
!  "1280x1024"   110    1280 1416 1552 1696   1024 1026 1029 1061
! 
! ###############################################################################
! # Monitor:              "Vobis"? Highscreen LE1024
! # Contributor:          Gertjan Akkerman ( akkerman@dutiba.twi.tudelft.nl )
! # Last Edit Date:       11/19/1993
! #
!   name        clock   horizontal timing     vertical timing      flags
!  "640x480"     25      640  664  760  800    480  491  493  525
!  "800x600"     36      800  824  896 1024    600  601  603  625
!  "1024x768i"   44     1024 1040 1216 1264    768  777  785  817  Interlace
! 
diff -c mit/server/ddx/x386/hga2/drivers/hga6845/driver.c:2.1 mit/server/ddx/x386/hga2/drivers/hga6845/driver.c:2.3
*** mit/server/ddx/x386/hga2/drivers/hga6845/driver.c:2.1	Fri Mar 11 23:39:43 1994
--- mit/server/ddx/x386/hga2/drivers/hga6845/driver.c	Fri Mar 11 23:39:43 1994
***************
*** 20,26 ****
   */
  static unsigned char 
    static_tbl[] = {0x61, 0x50, 0x52, 0x0F, 0x19, 0x06, 0x19, 0x19,
! 		  0x02, 0x0D, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x00};
  
  typedef struct {
    hgaHWRec std;               
--- 20,26 ----
   */
  static unsigned char 
    static_tbl[] = {0x61, 0x50, 0x52, 0x0F, 0x19, 0x06, 0x19, 0x19,
! 		  0x02, 0x0D, 0x0B, 0x0C, 0x00, 0x00, 0x00, 0x29};
  
  typedef struct {
    hgaHWRec std;               
***************
*** 164,169 ****
--- 164,170 ----
      outb(0x3B4, i);
      outb(0x3B5, static_tbl[i] = restore->tbl[i]);
    }
+   outb(0x3B8,static_tbl[15]);
  }
  
  /*
***************
*** 197,203 ****
    unsigned char i;
    unsigned char       /* 720x348 graphics mode parameters */
      init_tbl[] = {0x35, 0x2D, 0x2E, 0x07, 0x5B, 0x02, 0x57, 0x57,
! 		  0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    
    if (!hgaHWInit(mode, sizeof(hga6845Rec)))
      return(FALSE);
--- 198,204 ----
    unsigned char i;
    unsigned char       /* 720x348 graphics mode parameters */
      init_tbl[] = {0x35, 0x2D, 0x2E, 0x07, 0x5B, 0x02, 0x57, 0x57,
! 		  0x02, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2A};
    
    if (!hgaHWInit(mode, sizeof(hga6845Rec)))
      return(FALSE);
diff -c mit/server/ddx/x386/hga2/hga/hga.c:2.16 mit/server/ddx/x386/hga2/hga/hga.c:2.18
*** mit/server/ddx/x386/hga2/hga/hga.c:2.16	Fri Mar 11 23:39:46 1994
--- mit/server/ddx/x386/hga2/hga/hga.c	Fri Mar 11 23:39:46 1994
***************
*** 2,8 ****
   *
   * Author:  Davor Matic, dmatic@athena.mit.edu
   *
!  * $XFree86: mit/server/ddx/x386/hga2/hga/hga.c,v 2.16 1993/10/17 14:48:37 dawes Exp $
   */
  
  
--- 2,8 ----
   *
   * Author:  Davor Matic, dmatic@athena.mit.edu
   *
!  * $XFree86: mit/server/ddx/x386/hga2/hga/hga.c,v 2.18 1994/01/09 03:32:31 dawes Exp $
   */
  
  
***************
*** 55,60 ****
--- 55,61 ----
    0,			/* int maxClock */
    0,			/* int videoRam */
    0,			/* int BIOSbase */
+   0,			/* unsigned long MemBase, unused for this driver */
    240, 180,		/* int width, height */
    0,                    /* unsigned long speedup */
    NULL,			/* DisplayModePtr modes */
***************
*** 80,85 ****
--- 81,87 ----
  void (* hgaRestoreFunc)();
  
  static ScreenPtr savepScreen = NULL;
+ static PixmapPtr ppix = NULL;
  static Bool (* saveInitFunc)();
  static void * (* saveSaveFunc)();
  static void (* saveRestoreFunc)();
***************
*** 296,302 ****
    RegionRec pixReg;
    DDXPointRec pixPt;
    PixmapPtr   pspix;
-   static PixmapPtr ppix = NULL;
    ScreenPtr   pScreen = savepScreen;
  
    if (!x386Resetting && !x386Exiting)
--- 298,303 ----
***************
*** 396,401 ****
     * current vt. Let's catch this case here.
     */
    x386Exiting = TRUE;
!   if (x386VTSema) hgaEnterLeaveVT(LEAVE, screen_idx);
    return(TRUE);
  }
--- 397,411 ----
     * current vt. Let's catch this case here.
     */
    x386Exiting = TRUE;
!   if (x386VTSema)
!     hgaEnterLeaveVT(LEAVE, screen_idx);
!   else if (ppix) {
!     /*
!      * 7-Jan-94 CEG: The server is not running on the current vt.
!      * Free the screen snapshot taken when the server vt was left.
!      */
!     (savepScreen->DestroyPixmap)(ppix);
!     ppix = NULL;
!   }
    return(TRUE);
  }
diff -c mit/server/ddx/x386/os-support/Imakefile:2.2 mit/server/ddx/x386/os-support/Imakefile:2.3
*** mit/server/ddx/x386/os-support/Imakefile:2.2	Fri Mar 11 23:39:50 1994
--- mit/server/ddx/x386/os-support/Imakefile	Fri Mar 11 23:39:50 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/os-support/Imakefile,v 2.2 1993/09/02 14:30:06 dawes Exp $
  #include <Server.tmpl>
  
  #define IHaveSubdirs
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/os-support/Imakefile,v 2.3 1993/12/10 14:36:09 dawes Exp $
  #include <Server.tmpl>
  
  #define IHaveSubdirs
***************
*** 12,18 ****
--- 12,22 ----
  #endif
  
  #if defined(i386SVR4Architecture) 
+ # if defined(i386SVR4Solarisx86)
+ OS_SUBDIR = solx86
+ # else
  OS_SUBDIR = sysv
+ # endif
  #endif
  
  #if defined(LinuxArchitecture)
diff -c mit/server/ddx/x386/os-support/README.OS-lib:2.13 mit/server/ddx/x386/os-support/README.OS-lib:2.14
*** mit/server/ddx/x386/os-support/README.OS-lib:2.13	Fri Mar 11 23:39:51 1994
--- mit/server/ddx/x386/os-support/README.OS-lib	Fri Mar 11 23:39:51 1994
***************
*** 42,47 ****
--- 42,48 ----
  		mach/	OS support for the Mach and OSF/1 operating systems.
  		minix/	OS support for the Minix operating system.
  		sco/	OS support for the SCO SVR3.x operating system.
+ 		solx86/	OS support for the Solaris x86 operating system.
  		sysv/	OS support for all SVR4.0 and SVR4.2, and for
  			ISC and AT&T SVR3.2 operating systems.
  
***************
*** 425,428 ****
  	 */
  }
  
! $XFree86: mit/server/ddx/x386/os-support/README.OS-lib,v 2.13 1993/09/22 15:44:26 dawes Exp $
--- 426,429 ----
  	 */
  }
  
! $XFree86: mit/server/ddx/x386/os-support/README.OS-lib,v 2.14 1993/12/23 13:25:05 dawes Exp $
diff -c mit/server/ddx/x386/os-support/assyntax.h:2.0 mit/server/ddx/x386/os-support/assyntax.h:2.3
*** mit/server/ddx/x386/os-support/assyntax.h:2.0	Fri Mar 11 23:39:52 1994
--- mit/server/ddx/x386/os-support/assyntax.h	Fri Mar 11 23:39:52 1994
***************
*** 23,29 ****
   * PERFORMANCE OF THIS SOFTWARE.
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/assyntax.h,v 2.0 1993/07/12 16:03:59 dawes Exp $ */
  
  /*
   * assyntax.h
--- 23,29 ----
   * PERFORMANCE OF THIS SOFTWARE.
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/assyntax.h,v 2.3 1994/03/06 06:45:13 dawes Exp $ */
  
  /*
   * assyntax.h
***************
*** 67,73 ****
  #define GNU_ASSEMBLER
  #endif
  
! #if defined(__STDC__) && !defined(UNIXCPP)
  #define	CONCAT(x, y)	x ## y
  #else
  #define	CONCAT(x, y)	x/**/y
--- 67,73 ----
  #define GNU_ASSEMBLER
  #endif
  
! #if (defined(__STDC__) && !defined(UNIXCPP)) || (defined (SOLX86) && defined (__STDC__) && !defined (__GNUC__)) 
  #define	CONCAT(x, y)	x ## y
  #else
  #define	CONCAT(x, y)	x/**/y
***************
*** 269,275 ****
   */
  #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: */
--- 269,275 ----
   */
  #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: */
***************
*** 365,373 ****
--- 365,379 ----
  #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)
+ #if defined (SOLX86)
+ #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)
diff -c mit/server/ddx/x386/os-support/xf86_OSlib.h:2.29 mit/server/ddx/x386/os-support/xf86_OSlib.h:2.36
*** mit/server/ddx/x386/os-support/xf86_OSlib.h:2.29	Fri Mar 11 23:39:53 1994
--- mit/server/ddx/x386/os-support/xf86_OSlib.h	Fri Mar 11 23:39:54 1994
***************
*** 29,35 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/xf86_OSlib.h,v 2.29 1993/10/02 16:07:58 dawes Exp $ */
  
  #ifndef _XF86_OSLIB_H
  #define _XF86_OSLIB_H
--- 29,35 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/xf86_OSlib.h,v 2.36 1994/02/26 05:03:03 dawes Exp $ */
  
  #ifndef _XF86_OSLIB_H
  #define _XF86_OSLIB_H
***************
*** 40,45 ****
--- 40,46 ----
  #if defined(MACH386) || defined(__OSF__)
  # undef NULL
  #endif /* MACH386 || __OSF__ */
+ 
  #include <stdio.h>
  #include <ctype.h>
  
***************
*** 48,56 ****
  /**************************************************************************/
  #ifdef SYSV386
  # include <sys/ioctl.h>
- # undef NULL
- 
- # include <sys/param.h>
  # include <signal.h>
  # include <termio.h>
  # include <sys/stat.h>
--- 49,54 ----
***************
*** 61,67 ****
  
  # if defined(_NEED_SYSI86)
  #  include <sys/immu.h>
! #  include <sys/region.h>
  #  include <sys/proc.h>
  #  include <sys/tss.h>
  #  include <sys/sysi86.h>
--- 59,67 ----
  
  # if defined(_NEED_SYSI86)
  #  include <sys/immu.h>
! #  if !defined (SOLX86)
! #    include <sys/region.h>
! #  endif
  #  include <sys/proc.h>
  #  include <sys/tss.h>
  #  include <sys/sysi86.h>
***************
*** 69,74 ****
--- 69,77 ----
  #   include <sys/seg.h>
  #  endif /* SVR4 */
  #  include <sys/v86.h>
+ #  if defined(SOLX86)
+ #    include <sys/psw.h>
+ #  endif
  # endif /* _NEED_SYSI86 */
  
  #if defined(HAS_SVR3_MMAPDRV)
***************
*** 106,126 ****
  
  # ifdef SVR4
  #  include <sys/mman.h>
! #  define DEV_MEM "/dev/pmem"
  #  define CLEARDTR_SUPPORT
  # endif /* SVR4 */
  
  # if defined(ATT) && !defined(i386)
  #  define i386 /* note defined in ANSI C mode */
  # endif /* ATT && !i386 */
  
! # if defined(ATT) || defined(SVR4)
  #  define XQUEUE
  #  include <sys/xque.h>
  # endif /* ATT || SVR4 */
  
  /* Hack on SVR3 and SVR4 to avoid linking in Xenix or BSD support */
  # define usleep(usec) syscall(3112, (usec) / 1000)
  
  # ifdef SYSV
  #  if !defined(ISC) || defined(ISC202)
--- 109,141 ----
  
  # ifdef SVR4
  #  include <sys/mman.h>
! #  ifndef SOLX86
! #    define DEV_MEM "/dev/pmem"
! #  endif
  #  define CLEARDTR_SUPPORT
  # endif /* SVR4 */
  
+ # if defined(SOLX86)
+ #  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(SOLX86)
  #  define XQUEUE
  #  include <sys/xque.h>
  # endif /* ATT || SVR4 */
  
  /* Hack on SVR3 and SVR4 to avoid linking in Xenix or BSD support */
+ #if defined (SOLX86)
+ extern int xf86_solx86usleep(unsigned long);
+ # define usleep(usec) xf86_solx86usleep(usec) 
+ #else
  # define usleep(usec) syscall(3112, (usec) / 1000)
+ #endif /* SOLX86 */
  
  # ifdef SYSV
  #  if !defined(ISC) || defined(ISC202)
***************
*** 135,141 ****
  /**************************************************************************/
  #if defined(linux)
  # include <sys/ioctl.h>
- # include <sys/param.h>
  # include <signal.h>
  # include <termio.h>
  
--- 150,155 ----
***************
*** 153,158 ****
--- 167,173 ----
  # define LDNMAP LDSMAP
  
  # define CLEARDTR_SUPPORT
+ # define USE_VT_SYSREQ
  
  #endif /* linux */
  
***************
*** 159,169 ****
  /**************************************************************************/
  /* 386BSD and BSD/386                                                     */
  /**************************************************************************/
! #if defined(__386BSD__)
! # include <sys/ioctl.h>
! # undef NULL
  
! # include <sys/param.h>
  # include <signal.h>
  
  # include <termios.h>
--- 174,192 ----
  /**************************************************************************/
  /* 386BSD and BSD/386                                                     */
  /**************************************************************************/
! #ifdef __BSD__
! # undef __BSD__
! #endif
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined (__bsdi__)
! # define __BSD__
! #endif
  
! #if defined(__386BSD__) && (defined(__FreeBSD__) || defined(__NetBSD__))
! # undef __386BSD__
! #endif
! 
! #ifdef __BSD__
! # include <sys/ioctl.h>
  # include <signal.h>
  
  # include <termios.h>
***************
*** 172,178 ****
  # include <errno.h>
  extern int errno;
  
! # if !defined(LINKKKIT)
    /* Don't need this stuff for the Link Kit */
  #  if defined(__bsdi__)
  #   include <i386/isa/pcconsioctl.h>
--- 195,218 ----
  # include <errno.h>
  extern int errno;
  
! /*
!  * XXXX Note, for 386BSD, FreeBSD and NetBSD, things may not yet work right if
!  * all of these are not defined
!  */
! # ifndef __bsdi__
! #  define PCCONS_SUPPORT
! #  define CODRV_SUPPORT
! #  define SYSCONS_SUPPORT
! #  define PCVT_SUPPORT
! # endif
! 
! /* PCVT support requires SYSCONS support */
! # if defined(PCVT_SUPPORT) && !defined(SYSCONS_SUPPORT)
! #  define SYSCONS_SUPPORT
! # endif
! 
! 
! # if !defined(LINKKIT)
    /* Don't need this stuff for the Link Kit */
  #  if defined(__bsdi__)
  #   include <i386/isa/pcconsioctl.h>
***************
*** 180,194 ****
  #   define CONSOLE_X_MODE_OFF PCCONIOCCOOK
  #   define CONSOLE_X_BELL PCCONIOCBEEP
  #  else /* __bsdi__ */
! #   define COMPAT_CO011
! #   define COMPAT_SYSCONS
! #   if defined(FreeBSD) || defined(__NetBSD__)
! #    include <machine/ioctl_pc.h>
! #    include <machine/console.h>
! #   else
! #    include <sys/console.h>
! #    include <sys/ioctl_pc.h>
! #   endif /* FreeBSD || __NetBSD__ */
  #  endif /* __bsdi__ */
  # endif /* !LINKKIT */
  
--- 220,258 ----
  #   define CONSOLE_X_MODE_OFF PCCONIOCCOOK
  #   define CONSOLE_X_BELL PCCONIOCBEEP
  #  else /* __bsdi__ */
! #   ifdef CODRV_SUPPORT
! #    define COMPAT_CO011
! #    if defined(__FreeBSD__) || defined(__NetBSD__)
! #     include <machine/ioctl_pc.h>
! #    else
! #     include <sys/ioctl_pc.h>
! #    endif /* __FreeBSD__ || __NetBSD__ */
! #   endif /* CODRV_SUPPORT */
! #   ifdef SYSCONS_SUPPORT
! #    define COMPAT_SYSCONS
! #    if defined(__FreeBSD__) || defined(__NetBSD__)
! #     include <machine/console.h>
! #    else
! #     include <sys/console.h>
! #    endif /* __FreeBSD__ || __NetBSD__ */
! #   endif /* SYSCONS_SUPPORT */
! #   if defined(PCVT_SUPPORT) && !defined(VGAPCVTID)
! #    define VGAPCVTID _IOWR('V',113, struct pcvtid)
!      struct pcvtid {
! 	char name[16];
! 	int rmajor, rminor;
!      };
! #   endif /* PCVT_SUPPORT */
!     /* 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 */
  
***************
*** 202,207 ****
--- 266,275 ----
  
  # define CLEARDTR_SUPPORT
  
+ # if !defined(__bsdi__)
+ #  define USE_VT_SYSREQ
+ # endif
+ 
  #endif /* __386BSD__ */
  
  /**************************************************************************/
***************
*** 332,342 ****
--- 400,415 ----
  # endif /* !strerror */
  #endif /* NEED_STRERROR */
  
+ #ifndef VT_SYSREQ_DEFAULT
+ #define VT_SYSREQ_DEFAULT FALSE
+ #endif
+ 
  /* The Region arg to xf86[Un]Map* */
  #define NUM_REGIONS 2
  #define VGA_REGION 0
  #define LINEAR_REGION 1
  
+ #ifndef NO_OSLIB_PROTOTYPES
  /***************************************************************************/
  /* Prototypes                                                              */
  /***************************************************************************/
***************
*** 595,599 ****
--- 668,673 ----
  );
  
  _XFUNCPROTOEND
+ #endif /* NO_OSLIB_PROTOTYPES */
  
  #endif /* _XF86_OSLIB_H */
diff -c mit/server/ddx/x386/os-support/bsd/bsd_VTsw.c:2.0 mit/server/ddx/x386/os-support/bsd/bsd_VTsw.c:2.2
*** mit/server/ddx/x386/os-support/bsd/bsd_VTsw.c:2.0	Fri Mar 11 23:39:57 1994
--- mit/server/ddx/x386/os-support/bsd/bsd_VTsw.c	Fri Mar 11 23:39:57 1994
***************
*** 23,29 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_VTsw.c,v 2.0 1993/09/23 15:46:08 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 23,29 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_VTsw.c,v 2.2 1994/02/19 09:30:56 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 45,68 ****
  void xf86VTRequest(sig)
  int sig;
  {
  	if (x386Info.consType == SYSCONS) {
- 		signal(sig, (void(*)())xf86VTRequest);
  		x386Info.vtRequestsPending = TRUE;
  	}	
  	return;
  }
  
  Bool xf86VTSwitchPending()
  {
  	if (x386Info.consType == SYSCONS) {
  		return(x386Info.vtRequestsPending ? TRUE : FALSE);
  	}
! 	else
! 		return FALSE;
  }
  
  Bool xf86VTSwitchAway()
  {
  	if (x386Info.consType == SYSCONS) {
  		x386Info.vtRequestsPending = FALSE;
  		if (ioctl(x386Info.consoleFd, VT_RELDISP, 1) < 0)
--- 45,71 ----
  void xf86VTRequest(sig)
  int sig;
  {
+ #ifdef SYSCONS_SUPPORT
  	if (x386Info.consType == SYSCONS) {
  		x386Info.vtRequestsPending = TRUE;
  	}	
+ #endif
  	return;
  }
  
  Bool xf86VTSwitchPending()
  {
+ #ifdef SYSCONS_SUPPORT
  	if (x386Info.consType == SYSCONS) {
  		return(x386Info.vtRequestsPending ? TRUE : FALSE);
  	}
! #endif
! 	return FALSE;
  }
  
  Bool xf86VTSwitchAway()
  {
+ #ifdef SYSCONS_SUPPORT
  	if (x386Info.consType == SYSCONS) {
  		x386Info.vtRequestsPending = FALSE;
  		if (ioctl(x386Info.consoleFd, VT_RELDISP, 1) < 0)
***************
*** 70,81 ****
  		else
  			return(TRUE);
  	}
! 	else
! 		return FALSE;
  }
  
  Bool xf86VTSwitchTo()
  {
  	if (x386Info.consType == SYSCONS) {
  		x386Info.vtRequestsPending = FALSE;
  		if (ioctl(x386Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
--- 73,85 ----
  		else
  			return(TRUE);
  	}
! #endif
! 	return FALSE;
  }
  
  Bool xf86VTSwitchTo()
  {
+ #ifdef SYSCONS_SUPPORT
  	if (x386Info.consType == SYSCONS) {
  		x386Info.vtRequestsPending = FALSE;
  		if (ioctl(x386Info.consoleFd, VT_RELDISP, VT_ACKACQ) < 0)
***************
*** 82,88 ****
  			return(FALSE);
  		else
  			return(TRUE);
! }
! 	else
! 		return(TRUE);
  }
--- 86,92 ----
  			return(FALSE);
  		else
  			return(TRUE);
! 	}
! #endif
! 	return(TRUE);
  }
diff -c mit/server/ddx/x386/os-support/bsd/bsd_init.c:2.11 mit/server/ddx/x386/os-support/bsd/bsd_init.c:2.17
*** mit/server/ddx/x386/os-support/bsd/bsd_init.c:2.11	Fri Mar 11 23:39:57 1994
--- mit/server/ddx/x386/os-support/bsd/bsd_init.c	Fri Mar 11 23:39:57 1994
***************
*** 23,29 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_init.c,v 2.11 1993/10/10 11:47:49 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 23,29 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_init.c,v 2.17 1994/03/02 10:10:22 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 47,75 ****
  static int VTnum = -1;
  static int initialVT = -1;
  
  /* Stock 0.1 386bsd pccons console driver interface */
! #define PCCONS_CONSOLE_DEV "/dev/vga"
  #define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
  
  /* Holger Veit's codrv console driver */
  #define CODRV_CONSOLE_DEV "/dev/kbd"
  #define CODRV_CONSOLE_MODE O_RDONLY|O_NDELAY
  
! /* Syscons driver.  At least the FreeBSD version uses /dev/vga */
! #define SYSCONS_CONSOLE_DEV1 "/dev/vga"
! #define SYSCONS_CONSOLE_DEV2 "/dev/ttyv0"
  #define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
  
  #define CHECK_DRIVER_MSG \
    "Check your kernel's console driver configuration and /dev entries"
  
  void xf86OpenConsole()
  {
!     int i, fd, onoff;
      vtmode_t vtmode;
      char vtname[12];
      struct stat status;
      long syscons_version;
  
      if (serverGeneration == 1)
      {
--- 47,100 ----
  static int VTnum = -1;
  static int initialVT = -1;
  
+ #ifdef PCCONS_SUPPORT
  /* Stock 0.1 386bsd pccons console driver interface */
! #define PCCONS_CONSOLE_DEV1 "/dev/ttyv0"
! #define PCCONS_CONSOLE_DEV2 "/dev/vga"
  #define PCCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+ #endif
  
+ #ifdef CODRV_SUPPORT
  /* Holger Veit's codrv console driver */
  #define CODRV_CONSOLE_DEV "/dev/kbd"
  #define CODRV_CONSOLE_MODE O_RDONLY|O_NDELAY
+ #endif
  
! #ifdef SYSCONS_SUPPORT
! /* The FreeBSD 1.1 version syscons driver uses /dev/ttyv0 */
! #define SYSCONS_CONSOLE_DEV1 "/dev/ttyv0"
! #define SYSCONS_CONSOLE_DEV2 "/dev/vga"
  #define SYSCONS_CONSOLE_MODE O_RDWR|O_NDELAY
+ #endif
  
  #define CHECK_DRIVER_MSG \
    "Check your kernel's console driver configuration and /dev entries"
  
+ static char *supported_drivers[] = {
+ #ifdef PCCONS_SUPPORT
+ 	"pccons (with X support)",
+ #endif
+ #ifdef CODRV_SUPPORT
+ 	"codrv",
+ #endif
+ #ifdef SYSCONS_SUPPORT
+ 	"syscons",
+ #endif
+ #ifdef PCVT_SUPPORT
+ 	"pcvt",
+ #endif
+ };
+ 
  void xf86OpenConsole()
  {
!     int i, fd = -1, onoff;
      vtmode_t vtmode;
      char vtname[12];
      struct stat status;
      long syscons_version;
+ #ifdef PCVT_SUPPORT
+     struct pcvtid pcvt_version;
+ #endif
  
      if (serverGeneration == 1)
      {
***************
*** 94,108 ****
  	    }
  	}
  
  	/* First check for syscons */
  	if (((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
  	    || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
  	    && (ioctl(fd, VT_GETMODE, &vtmode) >= 0))
  	{
  	    /* Get syscons version */
- 	    if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
  	    {
! 		syscons_version = 0;
  	    }
  
  	    x386Info.vtno = VTnum;
--- 119,144 ----
  	    }
  	}
  
+ #ifdef SYSCONS_SUPPORT
  	/* First check for syscons */
  	if (((fd = open(SYSCONS_CONSOLE_DEV1, SYSCONS_CONSOLE_MODE, 0)) >= 0
  	    || (fd = open(SYSCONS_CONSOLE_DEV2, SYSCONS_CONSOLE_MODE, 0)) >= 0)
  	    && (ioctl(fd, VT_GETMODE, &vtmode) >= 0))
  	{
+ #ifdef PCVT_SUPPORT
+ 	    /* Check if PCVT */
+ 	    if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
+ 	    {
+ 		syscons_version = -1;
+ 	    }
+ 	    else
+ #endif
  	    /* Get syscons version */
  	    {
! 		if (ioctl(fd, CONS_GETVERS, &syscons_version) < 0)
! 		{
! 		    syscons_version = 0;
! 		}
  	    }
  
  	    x386Info.vtno = VTnum;
***************
*** 113,135 ****
  #endif
  	    if (x386Info.vtno == -1)
  	    {
  		/* check for the fixed VT_OPENQRY */
  		if (syscons_version >= 0x100)
  		{
  		    if (ioctl(fd, VT_OPENQRY, &x386Info.vtno) < 0)
  		    {
  			/* No free VTs */
  			x386Info.vtno = -1;
  		    }
  		}
  
  		if (x386Info.vtno == -1)
  		{
  		    /*
! 		     * Either old syscons, or all VTs are in use, so
! 		     * if stdin is a VT, use that one.
  		     */
! 		    if ((fstat(0, &status) >= 0) && S_ISCHR(status.st_mode)
  		        && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
  		    {
  			/* stdin is a VT */
--- 149,186 ----
  #endif
  	    if (x386Info.vtno == -1)
  	    {
+ 		/*
+ 		 * For old syscons versions (<0x100), VT_OPENQRY returns
+ 		 * the current VT rather than the next free VT.  In this
+ 		 * case, the server gets started on the current VT instead
+ 		 * of the next free VT.
+ 		 */
+ 
+ #if 0
  		/* check for the fixed VT_OPENQRY */
  		if (syscons_version >= 0x100)
  		{
+ #endif
  		    if (ioctl(fd, VT_OPENQRY, &x386Info.vtno) < 0)
  		    {
  			/* No free VTs */
  			x386Info.vtno = -1;
  		    }
+ #if 0
  		}
+ #endif
  
  		if (x386Info.vtno == -1)
  		{
  		    /*
! 		     * All VTs are in use.  If initialVT was found, use it.
! 		     * Otherwise, if stdin is a VT, use that one.
  		     */
! 		    if (initialVT != -1)
! 		    {
! 			x386Info.vtno = initialVT;
! 		    }
! 		    else if ((fstat(0, &status) >= 0) && S_ISCHR(status.st_mode)
  		        && (ioctl(0, VT_GETMODE, &vtmode) >= 0))
  		    {
  			/* stdin is a VT */
***************
*** 142,147 ****
--- 193,199 ----
  			    FatalError("%s: Cannot find a free VT\n",
  				       "xf86OpenConsole");
  			}
+ 			/* Should no longer reach here */
  			FatalError("%s: %s %s\n\t%s %s\n",
  				   "xf86OpenConsole",
  				   "syscons versions prior to 1.0 require",
***************
*** 169,183 ****
  	    x386Info.consType = SYSCONS;
  	    if (x386Verbose)
  	    {
! 	        ErrorF("Using syscons driver with X support");
! 		if (syscons_version >= 0x100)
  		{
! 	            ErrorF(" (version %d.%d)\n", syscons_version >> 8,
! 			   syscons_version & 0xFF);
  		}
  		else
  		{
! 	            ErrorF(" (version 0.x)\n");
  		}
  
  		ErrorF("(using VT number %d)\n\n", x386Info.vtno);
--- 221,245 ----
  	    x386Info.consType = SYSCONS;
  	    if (x386Verbose)
  	    {
! #ifdef PCVT_SUPPORT
! 		if (syscons_version == -1)
  		{
! 		    ErrorF("Using pcvt driver (version %d.%d)\n",
! 			   pcvt_version.rmajor, pcvt_version.rminor);
  		}
  		else
+ #endif
  		{
! 		    ErrorF("Using syscons driver with X support");
! 		    if (syscons_version >= 0x100)
! 		    {
! 	                ErrorF(" (version %d.%d)\n", syscons_version >> 8,
! 			       syscons_version & 0xFF);
! 		    }
! 		    else
! 		    {
! 	                ErrorF(" (version 0.x)\n");
! 		    }
  		}
  
  		ErrorF("(using VT number %d)\n\n", x386Info.vtno);
***************
*** 184,214 ****
  	    }
  	}
          else
  	{
  	    /* Try codrv next */
! 	    if ((fd = open(CODRV_CONSOLE_DEV, CODRV_CONSOLE_MODE, 0)) < 0) 
  	    {
! 	        if (errno == EBUSY)
  	        {
! 		    FatalError("xf86OpenConsole: %s is already in use (codrv)\n",
! 			       CODRV_CONSOLE_DEV);
  	        }
! 	        /* Now try pccons */
! 	        if ((fd = open(PCCONS_CONSOLE_DEV, PCCONS_CONSOLE_MODE, 0)) < 0) 
  	        {
! 		    FatalError("xf86OpenConsole: Cannot open %s (%s)\n%s\n%s\n",
!                    	       PCCONS_CONSOLE_DEV, strerror(errno),
! 			       "You don't have a console driver with X support",
! 			       CHECK_DRIVER_MSG);
  	        }
! 	        else
  	        {
  		    if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
  		    {
  		        FatalError(
! 			    "%s: CONSOLE_X_MODE_OFF on %s failed (%s)\n%s\n%s\n",
  			    "xf86OpenConsole",
! 			    PCCONS_CONSOLE_DEV, strerror(errno),
  			    "Was expecting pccons driver with X support",
  			    CHECK_DRIVER_MSG);
  		    }
--- 246,293 ----
  	    }
  	}
          else
+ #endif /* SYSCONS_SUPPORT */
  	{
+ 	    fd = -1;
+ #ifdef CODRV_SUPPORT
  	    /* Try codrv next */
! 	    if ((fd = open(CODRV_CONSOLE_DEV, CODRV_CONSOLE_MODE, 0)) >= 0) 
  	    {
! 	        int onoff = X_MODE_OFF;
!      
! 	        if (ioctl(fd, CONSOLE_X_MODE, &onoff) < 0)
  	        {
! 		    FatalError("%s: CONSOLE_X_MODE on %s failed (%s)\n%s\n%s\n",
! 			       "xf86OpenConsole",
! 			       CODRV_CONSOLE_DEV, strerror(errno),
! 			       "Was expecting codrv driver",
! 			       CHECK_DRIVER_MSG);
  	        }
! 	        x386Info.consType = CODRV011;
! 	    }
! 	    else
! #endif /* CODRV_SUPPORT */
! 	    {
! #ifdef CODRV_SUPPORT
! 	        if (errno == EBUSY)
  	        {
! 		   FatalError("xf86OpenConsole: %s is already in use (codrv)\n",
! 			      CODRV_CONSOLE_DEV);
  	        }
! #endif /* CODRV_SUPPORT */
! #ifdef PCCONS_SUPPORT
! 	        /* Now try pccons */
! 	        if ((fd = open(PCCONS_CONSOLE_DEV1, PCCONS_CONSOLE_MODE, 0))
! 		    >= 0 ||
! 		    (fd = open(PCCONS_CONSOLE_DEV2, PCCONS_CONSOLE_MODE, 0))
! 		    >= 0)
  	        {
  		    if (ioctl(fd, CONSOLE_X_MODE_OFF, 0) < 0)
  		    {
  		        FatalError(
! 			   "%s: CONSOLE_X_MODE_OFF failed (%s)\n%s\n%s\n",
  			    "xf86OpenConsole",
! 			    strerror(errno),
  			    "Was expecting pccons driver with X support",
  			    CHECK_DRIVER_MSG);
  		    }
***************
*** 215,243 ****
  		    x386Info.consType = PCCONS;
  		    if (x386Verbose)
  		    {
! 		        ErrorF("Using pccons driver with X support\n");
  		    }
  	        }
! 	    }
! 	    else 
! 	    {
! 	        int onoff = X_MODE_OFF;
!      
! 	        if (ioctl(fd, CONSOLE_X_MODE, &onoff) < 0)
! 	        {
! 		    FatalError("%s: CONSOLE_X_MODE on %s failed (%s)\n%s\n%s\n",
! 			       "xf86OpenConsole",
! 			       CODRV_CONSOLE_DEV, strerror(errno),
! 			       "Was expecting codrv driver",
! 			       CHECK_DRIVER_MSG);
! 	        }
! 	        x386Info.consType = CODRV011;
  	    }
!      	} 
       	fclose(stdin);
  	x386Info.consoleFd = fd;
  	x386Info.screenFd = fd;
  
  	if (x386Info.consType == CODRV011)
  	{
  	    /* 
--- 294,335 ----
  		    x386Info.consType = PCCONS;
  		    if (x386Verbose)
  		    {
! #ifdef PCVT_SUPPORT
! 			/* Check if PCVT */
! 			if (ioctl(fd, VGAPCVTID, &pcvt_version) >= 0)
! 			{
! 			    ErrorF("Using pcvt driver (version %d.%d)\n",
! 			           pcvt_version.rmajor, pcvt_version.rminor);
! 			}
! 			else
! #endif
! 		            ErrorF("Using pccons driver with X support\n");
  		    }
  	        }
! #endif /* PCCONS_SUPPORT */
  	    }
!      	}
! 	/* Check that a supported console driver was found */
!         if (fd < 0)
! 	{
! 		char cons_drivers[80] = {0, };
! 		for (i = 0; i < sizeof(supported_drivers) / sizeof(char *); i++)
! 		{
! 			if (i)
! 			{
! 				strcat(cons_drivers, ", ");
! 			}
! 			strcat(cons_drivers, supported_drivers[i]);
! 		}
! 		FatalError(
! 		 "%s: No console driver found\n\tSupported drivers: %s\n\t%s\n",
! 		 "xf86OpenConsole", cons_drivers, CHECK_DRIVER_MSG);
! 	}
       	fclose(stdin);
  	x386Info.consoleFd = fd;
  	x386Info.screenFd = fd;
  
+ #ifdef CODRV_SUPPORT
  	if (x386Info.consType == CODRV011)
  	{
  	    /* 
***************
*** 273,283 ****
--- 365,377 ----
  	    }
  #undef NECESSARY
  	}
+ #endif /* CODRV_SUPPORT */
  
  	x386Config(FALSE); /* Read Xconfig */
  
  	switch (x386Info.consType)
  	{
+ #ifdef CODRV_SUPPORT
  	case CODRV011:
  	case CODRV01X:
  	    onoff = X_MODE_ON;
***************
*** 290,296 ****
  	    if (x386Info.consType == CODRV01X)
  		ioctl(x386Info.consoleFd, VGATAKECTRL, 0);
  	    break;
! 
  	case PCCONS:
  	    if (ioctl (x386Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
  	    {
--- 384,391 ----
  	    if (x386Info.consType == CODRV01X)
  		ioctl(x386Info.consoleFd, VGATAKECTRL, 0);
  	    break;
! #endif
! #ifdef PCCONS_SUPPORT
  	case PCCONS:
  	    if (ioctl (x386Info.consoleFd, CONSOLE_X_MODE_ON, 0) < 0)
  	    {
***************
*** 308,314 ****
  		       strerror(errno));
  	    }
  	    break;
! 
  	case SYSCONS:
  	    /*
  	     * now get the VT
--- 403,410 ----
  		       strerror(errno));
  	    }
  	    break;
! #endif
! #ifdef SYSCONS_SUPPORT
  	case SYSCONS:
  	    /*
  	     * now get the VT
***************
*** 342,352 ****
--- 438,450 ----
  	        FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
  	    }
     	    break; 
+ #endif /* SYSCONS_SUPPORT */
          }
      }
      else 
      {
  	/* serverGeneration != 1 */
+ #ifdef SYSCONS_SUPPORT
      	if (x386Info.consType == SYSCONS)
      	{
  	    if (ioctl(x386Info.consoleFd, VT_ACTIVATE, x386Info.vtno) != 0)
***************
*** 354,359 ****
--- 452,458 ----
  	        ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
  	    }
          }
+ #endif /* SYSCONS_SUPPORT */
      }
      return;
  }
***************
*** 365,370 ****
--- 464,470 ----
  
      switch (x386Info.consType)
      {
+ #ifdef CODRV_SUPPORT
      case CODRV011:
      case CODRV01X:
  	onoff = X_MODE_OFF;
***************
*** 374,394 ****
  	}
  	ioctl (x386Info.consoleFd, CONSOLE_X_MODE, &onoff);
          break;
! 
      case PCCONS:
  	ioctl (x386Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
  	break;
! 
      case SYSCONS:
! #if 0
!         ioctl(x386Info.consoleFd, VT_ACTIVATE, x386Info.vtno);
!         ioctl(x386Info.consoleFd, VT_WAITACTIVE, 0);
! #endif
!         ioctl(x386Info.consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode ... */
          if (ioctl(x386Info.consoleFd, VT_GETMODE, &VT) != -1)
          {
  	    VT.mode = VT_AUTO;
! 	    ioctl(x386Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
          }
          if (ioctl(x386Info.consoleFd, KDDISABIO, 0) < 0)
          {
--- 474,492 ----
  	}
  	ioctl (x386Info.consoleFd, CONSOLE_X_MODE, &onoff);
          break;
! #endif /* CODRV_SUPPORT */
! #ifdef PCCONS_SUPPORT
      case PCCONS:
  	ioctl (x386Info.consoleFd, CONSOLE_X_MODE_OFF, 0);
  	break;
! #endif /* PCCONS_SUPPORT */
! #ifdef SYSCONS_SUPPORT
      case SYSCONS:
!         ioctl(x386Info.consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode */
          if (ioctl(x386Info.consoleFd, VT_GETMODE, &VT) != -1)
          {
  	    VT.mode = VT_AUTO;
! 	    ioctl(x386Info.consoleFd, VT_SETMODE, &VT); /* dflt vt handling */
          }
          if (ioctl(x386Info.consoleFd, KDDISABIO, 0) < 0)
          {
***************
*** 398,403 ****
--- 496,502 ----
  	if (initialVT != -1)
  		ioctl(x386Info.consoleFd, VT_ACTIVATE, initialVT);
          break;
+ #endif /* SYSCONS_SUPPORT */
      }
  
      if (x386Info.screenFd != x386Info.consoleFd)
***************
*** 429,434 ****
--- 528,534 ----
  		KeepTty = TRUE;
  		return(1);
  	}
+ #ifdef SYSCONS_SUPPORT
  	if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
  	{
  		if (sscanf(argv[i], "vt%2d", &VTnum) == 0 ||
***************
*** 440,451 ****
--- 540,554 ----
  		}
  		return(1);
  	}
+ #endif /* SYSCONS_SUPPORT */
  	return(0);
  }
  
  void xf86UseMsg()
  {
+ #ifdef SYSCONS_SUPPORT
  	ErrorF("vtXX                   use the specified VT number (1-12)\n");
+ #endif /* SYSCONS_SUPPORT */
  	ErrorF("-keeptty               ");
  	ErrorF("don't detach controlling tty (for debugging only)\n");
  	return;
diff -c mit/server/ddx/x386/os-support/bsd/bsd_io.c:2.7 mit/server/ddx/x386/os-support/bsd/bsd_io.c:2.8
*** mit/server/ddx/x386/os-support/bsd/bsd_io.c:2.7	Fri Mar 11 23:39:58 1994
--- mit/server/ddx/x386/os-support/bsd/bsd_io.c	Fri Mar 11 23:39:58 1994
***************
*** 23,29 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_io.c,v 2.7 1993/09/23 15:46:10 dawes Exp $ */
  
  #define NEED_EVENTS
  #include "X.h"
--- 23,29 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_io.c,v 2.8 1994/02/10 21:26:27 dawes Exp $ */
  
  #define NEED_EVENTS
  #include "X.h"
***************
*** 48,59 ****
  
  	    	switch (x386Info.consType) {
  
  	    	case PCCONS:
  		    	data[0] = pitch;
  		    	data[1] = (duration * loudness) / 50;
  		    	ioctl(x386Info.consoleFd, CONSOLE_X_BELL, data);
  			break;
! 
  	    	case CODRV011:
  	    	case CODRV01X:
  		    	s.pitch = pitch;
--- 48,61 ----
  
  	    	switch (x386Info.consType) {
  
+ #ifdef PCCONS_SUPPORT
  	    	case PCCONS:
  		    	data[0] = pitch;
  		    	data[1] = (duration * loudness) / 50;
  		    	ioctl(x386Info.consoleFd, CONSOLE_X_BELL, data);
  			break;
! #endif
! #ifdef CODRV_SUPPORT
  	    	case CODRV011:
  	    	case CODRV01X:
  		    	s.pitch = pitch;
***************
*** 60,71 ****
  		    	s.duration = (duration * loudness) / 50;
  		    	ioctl(x386Info.consoleFd, KBDSETBELL, &s);
  			break;
! 
  	    	case SYSCONS:
  			ioctl(x386Info.consoleFd, KDMKTONE,
  			      ((1193190 / pitch) & 0xffff) |
  			      (((unsigned long)duration*loudness/50)<<16));
  			break;
  	    	}
  	}
  }
--- 62,75 ----
  		    	s.duration = (duration * loudness) / 50;
  		    	ioctl(x386Info.consoleFd, KBDSETBELL, &s);
  			break;
! #endif
! #ifdef SYSCONS_SUPPORT
  	    	case SYSCONS:
  			ioctl(x386Info.consoleFd, KDMKTONE,
  			      ((1193190 / pitch) & 0xffff) |
  			      (((unsigned long)duration*loudness/50)<<16));
  			break;
+ #endif
  	    	}
  	}
  }
***************
*** 77,92 ****
  
  	case PCCONS:
  		break;
! 
  	case CODRV011:
  	case CODRV01X:
  	        leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
  		ioctl(x386Info.consoleFd, KBDSLEDS, &leds);
  		break;
! 
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDSETLED, leds);
  		break;
  	}
  }
  
--- 81,98 ----
  
  	case PCCONS:
  		break;
! #ifdef CODRV_SUPPORT
  	case CODRV011:
  	case CODRV01X:
  	        leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
  		ioctl(x386Info.consoleFd, KBDSLEDS, &leds);
  		break;
! #endif
! #ifdef SYSCONS_SUPPORT
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDSETLED, leds);
  		break;
+ #endif
  	}
  }
  
***************
*** 98,113 ****
  
  	case PCCONS:
  		break;
! 
  	case CODRV011:
  	case CODRV01X:
  		ioctl(x386Info.consoleFd, KBDGLEDS, &leds);
  	        leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
  		break;
! 
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDGETLED, &leds);
  		break;
  	}
  	return(leds);
  }
--- 104,121 ----
  
  	case PCCONS:
  		break;
! #ifdef CODRV_SUPPORT
  	case CODRV011:
  	case CODRV01X:
  		ioctl(x386Info.consoleFd, KBDGLEDS, &leds);
  	        leds = (leds&0x01)<<2 | leds&0x02 | (leds&0x04)>>2;
  		break;
! #endif
! #ifdef SYSCONS_SUPPORT
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDGETLED, &leds);
  		break;
+ #endif
  	}
  	return(leds);
  }
***************
*** 123,137 ****
  
  	case PCCONS:
  		break;
! 
  	case CODRV011:
  	case CODRV01X:
  		ioctl(x386Info.consoleFd, KBDSTPMAT, &rad);
  		break;
! 
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDSETRAD, rad);
  		break;
  	}
  }
  
--- 131,147 ----
  
  	case PCCONS:
  		break;
! #ifdef CODRV_SUPPORT
  	case CODRV011:
  	case CODRV01X:
  		ioctl(x386Info.consoleFd, KBDSTPMAT, &rad);
  		break;
! #endif
! #ifdef SYSCONS_SUPPORT
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDSETRAD, rad);
  		break;
+ #endif
  	}
  }
  
***************
*** 144,154 ****
  	case CODRV011:
  	case CODRV01X:
  		break;
! 
  	case PCCONS:
  	case SYSCONS:
  		tcgetattr(x386Info.consoleFd, &kbdtty);
  		break;
  	}
  }
  
--- 154,165 ----
  	case CODRV011:
  	case CODRV01X:
  		break;
! #if defined(PCCONS_SUPPORT) || defined(SYSCONS_SUPPORT)
  	case PCCONS:
  	case SYSCONS:
  		tcgetattr(x386Info.consoleFd, &kbdtty);
  		break;
+ #endif
  	}
  }
  
***************
*** 162,170 ****
--- 173,184 ----
  	case CODRV01X:
  		break;
  
+ #ifdef SYSCONS_SUPPORT
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDSKBMODE, K_RAW);
  		/* FALL THROUGH */
+ #endif
+ #if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT)
  	case PCCONS:
  		nTty = kbdtty;
  		nTty.c_iflag = IGNPAR | IGNBRK;
***************
*** 177,182 ****
--- 191,197 ----
  		cfsetospeed(&nTty, 9600);
  		tcsetattr(x386Info.consoleFd, TCSANOW, &nTty);
  		break;
+ #endif
  	}
  	return(x386Info.consoleFd);
  }
***************
*** 189,200 ****
--- 204,219 ----
  	case CODRV01X:
  		break;
  
+ #ifdef SYSCONS_SUPPORT
  	case SYSCONS:
  		ioctl(x386Info.consoleFd, KDSKBMODE, K_XLATE);
  		/* FALL THROUGH */
+ #endif
+ #if defined(SYSCONS_SUPPORT) || defined(PCCONS_SUPPORT)
  	case PCCONS:
  		tcsetattr(x386Info.consoleFd, TCSANOW, &kbdtty);
  		break;
+ #endif
  	}
  	return(x386Info.consoleFd);
  }
diff -c mit/server/ddx/x386/os-support/bsd/bsd_video.c:2.13 mit/server/ddx/x386/os-support/bsd/bsd_video.c:2.15
*** mit/server/ddx/x386/os-support/bsd/bsd_video.c:2.13	Fri Mar 11 23:39:59 1994
--- mit/server/ddx/x386/os-support/bsd/bsd_video.c	Fri Mar 11 23:39:59 1994
***************
*** 23,29 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_video.c,v 2.13 1993/10/17 14:49:00 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 23,29 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/bsd/bsd_video.c,v 2.15 1993/12/17 11:01:36 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 51,56 ****
--- 51,102 ----
  #define MAP_SIZE 0x20000
  #endif
  
+ static Bool devMemChecked = FALSE;
+ static Bool useDevMem = FALSE;
+ 
+ /*
+  * Check if /dev/mem can be mmap'd.  If it can't print a warning when
+  * "warn" is TRUE.
+  */
+ static void checkDevMem(warn)
+ Bool warn;
+ {
+ 	int fd;
+ 	pointer base;
+ 
+ 	devMemChecked = TRUE;
+ 	if ((fd = open("/dev/mem", O_RDWR)) < 0)
+ 	{
+ 	    if (warn)
+ 	    {
+ 	        ErrorF("checkDevMem: warning: failed to open /dev/mem (%s)\n",
+ 		       strerror(errno));
+ 	        ErrorF("\tlinear fb access unavailable\n");
+ 	    }
+ 	    useDevMem = FALSE;
+ 	    return;
+ 	}
+ 	/* Try to map a page at the VGA address */
+ 	base = (pointer)mmap((caddr_t)0, 4096, PROT_READ|PROT_WRITE,
+ 			     MAP_FILE, fd, (off_t)0xA0000);
+ 	close(fd);
+ 	if (base == (pointer)-1)
+ 	{
+ 	    if (warn)
+ 	    {
+ 	        ErrorF("checkDevMem: warning: failed to mmap /dev/mem (%s)\n",
+ 		       strerror(errno));
+ 	        ErrorF("\tlinear fb access unavailable\n");
+ 	    }
+ 	    useDevMem = FALSE;
+ 	    return;
+ 	}
+ 	munmap((caddr_t)base, 4096);
+ 	useDevMem = TRUE;
+ 	return;
+ }
+ 
+ 
  pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
  int ScreenNum;
  int Region;
***************
*** 59,64 ****
--- 105,134 ----
  {
  	pointer base;
  
+ 	if (!devMemChecked)
+ 		checkDevMem(FALSE);
+ 
+ 	if (useDevMem)
+ 	{
+ 	    int memFd;
+ 
+ 	    if ((memFd = open("/dev/mem", O_RDWR)) < 0)
+ 	    {
+ 		FatalError("xf86MapVidMem: failed to open /dev/mem (%s)\n",
+ 			   strerror(errno));
+ 	    }
+ 	    base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
+ 				 MAP_FILE, memFd, (off_t)Base);
+ 	    close(memFd);
+ 	    if (base == (pointer)-1)
+ 	    {
+ 		FatalError("%s: could not mmap /dev/mem [s=%x,a=%x] (%s)\n",
+ 			   "xf86MapVidMem", Size, Base, strerror(errno));
+ 	    }
+ 	    return(base);
+ 	}
+ 		
+ 	/* else, mmap /dev/vga */
  #ifdef _386BSD_MMAP_BUG
  	if ((unsigned long)Base < MAP_BASE ||
  	    (unsigned long)Base >= MAP_BASE + MAP_SIZE)
***************
*** 111,116 ****
--- 181,192 ----
  pointer Base;
  unsigned long Size;
  {
+ 	if (useDevMem)
+ 	{
+ 		munmap((caddr_t)Base, Size);
+ 		return;
+ 	}
+ 
  #ifdef _386BSD_MMAP_BUG
  	if (MapCount == 0 || MappedPointer == NULL)
  		return;
***************
*** 127,133 ****
  
  Bool xf86LinearVidMem()
  {
! 	return(FALSE);
  }
  
  /***************************************************************************/
--- 203,216 ----
  
  Bool xf86LinearVidMem()
  {
! 	/*
! 	 * Call checkDevMem even if already called by xf86MapVidMem() so that
! 	 * a warning about no linear fb is printed.
! 	 */
! 	if (!useDevMem)
! 		checkDevMem(TRUE);
! 
! 	return(useDevMem);
  }
  
  /***************************************************************************/
diff -c mit/server/ddx/x386/os-support/shared/std_mseEv.c:2.0 mit/server/ddx/x386/os-support/shared/std_mseEv.c:2.1
*** mit/server/ddx/x386/os-support/shared/std_mseEv.c:2.0	Fri Mar 11 23:40:05 1994
--- mit/server/ddx/x386/os-support/shared/std_mseEv.c	Fri Mar 11 23:40:05 1994
***************
*** 23,29 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/shared/std_mseEv.c,v 2.0 1993/07/23 08:58:08 dawes Exp $ */
  
  #define NEED_EVENTS
  #include "X.h"
--- 23,29 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/shared/std_mseEv.c,v 2.1 1993/12/25 14:01:18 dawes Exp $ */
  
  #define NEED_EVENTS
  #include "X.h"
***************
*** 37,43 ****
  void xf86MouseEvents()
  {
  	unsigned char rBuf[64];
! 	int nBytes, i;
  
  	if ((nBytes = read(x386Info.mseFd, (char *)rBuf, sizeof(rBuf))) > 0)
  	{
--- 37,43 ----
  void xf86MouseEvents()
  {
  	unsigned char rBuf[64];
! 	int nBytes;
  
  	if ((nBytes = read(x386Info.mseFd, (char *)rBuf, sizeof(rBuf))) > 0)
  	{
diff -c /dev/null mit/server/ddx/x386/os-support/solx86/Imakefile:2.2
*** /dev/null	Fri Mar 11 23:40:06 1994
--- mit/server/ddx/x386/os-support/solx86/Imakefile	Fri Mar 11 23:40:06 1994
***************
*** 0 ****
--- 1,39 ----
+ XCOMM $XFree86: mit/server/ddx/x386/os-support/solx86/Imakefile,v 2.2 1994/01/09 03:33:15 dawes Exp $
+ #include <Server.tmpl>
+ 
+ BIOS_MOD = solx86_mmap
+ 
+ #if !HasGcc
+ PROWORKS_INOUT_SRC = solx86_iout.s
+ PROWORKS_INOUT_OBJ = solx86_iout.o
+ #endif
+ 
+ 
+ SRCS = solx86_init.c solx86_vid.c IO_utils.c sysv_io.c $(BIOS_MOD).c \
+ 	VTsw_usl.c sysv_kbd.c std_kbdEv.c sysv_tty.c std_mouse.c \
+ 	std_mseEv.c $(PROWORKS_INOUT_SRC)
+ 
+ OBJS = solx86_init.o solx86_vid.o IO_utils.o sysv_io.o $(BIOS_MOD).o \
+ 	VTsw_usl.o sysv_kbd.o std_kbdEv.o sysv_tty.o std_mouse.o \
+ 	std_mseEv.o $(PROWORKS_INOUT_OBJ)
+ 
+ DDXSRC = $(SERVERSRC)/ddx
+ X386SRC = $(DDXSRC)/x386/common
+ XF86OSSRC = $(DDXSRC)/x386/os-support
+ INCLUDES = -I$(X386SRC) -I$(XF86OSSRC) -I. -I$(SERVERSRC)/include \
+            -I$(INCLUDESRC)
+ 
+ SubdirLibraryRule($(OBJS))
+ NormalLibraryObjectRule()
+ NormalAsmObjectRule()
+ 
+ ObjectFromSpecialSource(IO_utils,../shared/IO_utils,/**/)
+ ObjectFromSpecialSource(VTsw_usl,../shared/VTsw_usl,/**/)
+ ObjectFromSpecialSource(sysv_kbd,../shared/sysv_kbd,/**/)
+ ObjectFromSpecialSource(sysv_tty,../shared/sysv_tty,/**/)
+ ObjectFromSpecialSource(std_mouse,../shared/std_mouse,/**/)
+ ObjectFromSpecialSource(std_mseEv,../shared/std_mseEv,/**/)
+ ObjectFromSpecialSource(std_kbdEv,../shared/std_kbdEv,/**/)
+ ObjectFromSpecialSource(sysv_io,../sysv/sysv_io,/**/)
+ 
+ DependTarget()
diff -c /dev/null mit/server/ddx/x386/os-support/solx86/solx86_init.c:2.4
*** /dev/null	Fri Mar 11 23:40:06 1994
--- mit/server/ddx/x386/os-support/solx86/solx86_init.c	Fri Mar 11 23:40:06 1994
***************
*** 0 ****
--- 1,398 ----
+ /*
+  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+  * 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 Thomas Roell and David Wexelblat 
+  * not be used in advertising or publicity pertaining to distribution of 
+  * the software without specific, written prior permission.  Thomas Roell and
+  * David Wexelblat 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 WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO 
+  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+  * FITNESS, IN NO EVENT SHALL THOMAS ROELL 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/os-support/solx86/solx86_init.c,v 2.4 1994/02/28 14:11:23 dawes Exp $ */
+ 
+ #include <signal.h>
+ #include <sys/time.h>
+ #include <unistd.h>
+ 
+ #include "X.h"
+ #include "Xmd.h"
+ #include "input.h"
+ #include "scrnintstr.h"
+ 
+ #include "compiler.h"
+ 
+ #include "x386.h"
+ #include "x386Procs.h"
+ #include "xf86_OSlib.h"
+ 
+ static Bool KeepTty = FALSE;
+ #ifdef SVR4
+ static Bool Protect0 = FALSE;
+ #endif
+ static int VTnum = -1;
+ static int x386StartVT = -1;
+ 
+ #define MAX_SECONDS	60	
+ #define USEC_IN_SEC     (unsigned long)1000000
+ 
+ int xf86_solx86usleep(
+ #if NeedFunctionPrototypes
+ unsigned long
+ #endif
+ );
+ static void xf86_solx86sleep(
+ #if NeedFunctionPrototypes
+ int
+ #endif
+ );
+ 
+ extern void xf86VTRequest(
+ #if NeedFunctionPrototypes
+ 	int
+ #endif
+ );
+ 
+ void xf86OpenConsole()
+ {
+     int fd;
+     struct vt_mode VT;
+     struct vt_stat vtinfo;
+     char vtname1[10];
+     int i, FreeVTslot;
+ 
+     if (serverGeneration == 1) 
+     {
+     	/* check if we're run with euid==0 */
+     	if (geteuid() != 0)
+ 	{
+       	    FatalError("xf86OpenConsole: Server must be suid root\n");
+ 	}
+ 
+ 	/* Protect page 0 to help find NULL dereferencing */
+ 	/* mprotect() doesn't seem to work */
+ 	if (Protect0)
+ 	{
+ 	    int fd = -1;
+ 
+ 	    if ((fd = open("/dev/zero", O_RDONLY, 0)) < 0)
+ 	    {
+ 		ErrorF("xf86OpenConsole: cannot open /dev/zero (%s)\n",
+ 		       strerror(errno));
+ 	    }
+ 	    else
+ 	    {
+ 		if ((int)mmap(0, 0x1000, PROT_NONE,
+ 			      MAP_FIXED | MAP_SHARED, fd, 0) == -1)
+ 		{
+ 		    ErrorF("xf86OpenConsole: failed to protect page 0 (%s)\n",
+ 		       strerror(errno));
+ 		}
+ 		close(fd);
+ 	    }
+ 	}
+     	/*
+      	 * setup the virtual terminal manager
+      	 */
+     	if (VTnum != -1) 
+ 	{
+       	    x386Info.vtno = VTnum;
+     	}
+     	else 
+ 	{
+       	    if ((fd = open("/dev/vt00",O_RDWR,0)) < 0) 
+ 	    {
+         	FatalError(
+ 		    "xf86OpenConsole: Cannot open /dev/vt00 (%s)\n",
+ 		    strerror(errno));
+ 	    }
+             if (ioctl(fd, VT_GETSTATE, &vtinfo) < 0)
+             {
+                 FatalError("xf86OpenConsole: Cannot determine current VT\n");
+             }
+             x386StartVT=vtinfo.v_active;
+ 
+ /* There is a SEVERE problem with x86's VT's the VT_OPENQRY ioctl()
+  * will panic the entire system if all 8 (7 VT's+Console) terminals
+  * are used.
+  * The only other way I've found to determine if there is a free
+  * is to try activating all the the available VT's and see if they
+  * all succeed - if they do, there there is not a free VT, and
+  * the Xserver cannot continue with out panic'ing the system.
+  * (Its ugly, however, it seems to work)
+  * Note there is a possible race condition here, btw.
+  *
+  * David Holland 2/23/94
+  */
+ 
+ 	    FreeVTslot = 0;
+ 	    for(i=7; (i>=0) && (!FreeVTslot); i--)
+ 		if (ioctl(fd, VT_ACTIVATE, i) != 0)
+ 		    FreeVTslot = 1;
+ 
+ 	    if(!FreeVTslot)
+ 	    {
+ 		FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ 	    }
+ 
+       	    if ((ioctl(fd, VT_OPENQRY, &x386Info.vtno) < 0) || 
+ 		(x386Info.vtno == -1))
+ 	    {
+         	FatalError("xf86OpenConsole: Cannot find a free VT\n");
+ 	    }
+            close(fd);
+         }
+ 	ErrorF("(using VT number %d)\n\n", x386Info.vtno);
+ 
+  	sprintf(vtname1,"/dev/vt%02d",x386Info.vtno); /* Solaris 2.1  x86 */ 
+ 
+ 	x386Config(FALSE); /* Read Xconfig */
+ 
+ 	if (!KeepTty)
+     	{
+     	    setpgrp();
+ 	}
+ 
+ 	if (((x386Info.consoleFd = open(vtname1, O_RDWR | O_NDELAY, 0)) < 0))
+ 	{
+             FatalError("xf86OpenConsole: Cannot open %s (%s)\n",
+ 		       vtname1, strerror(errno));
+ 	}
+ 
+ 	/* change ownership of the vt */
+ 	chown(vtname1, getuid(), getgid());
+ 
+ 	/*
+ 	 * now get the VT
+ 	 */
+ 	if (ioctl(x386Info.consoleFd, VT_ACTIVATE, x386Info.vtno) != 0)
+ 	{
+     	    ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ 	}
+ 	if (ioctl(x386Info.consoleFd, VT_WAITACTIVE, x386Info.vtno) != 0)
+ 	{
+ 	    ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
+ 	}
+ 	if (ioctl(x386Info.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(x386Info.consoleFd, VT_SETMODE, &VT) < 0) 
+ 	{
+ 	    FatalError("xf86OpenConsole: VT_SETMODE VT_PROCESS failed\n");
+ 	}
+ 	if (ioctl(x386Info.consoleFd, KDSETMODE, KD_GRAPHICS) < 0)
+ 	{
+ 	    FatalError("xf86OpenConsole: KDSETMODE KD_GRAPHICS failed\n");
+ 	}
+     }
+     else 
+     {   
+ 	/* serverGeneration != 1 */
+ 	/*
+ 	 * now get the VT
+ 	 */
+ 	if (ioctl(x386Info.consoleFd, VT_ACTIVATE, x386Info.vtno) != 0)
+ 	{
+ 	    ErrorF("xf86OpenConsole: VT_ACTIVATE failed\n");
+ 	}
+ 	if (ioctl(x386Info.consoleFd, VT_WAITACTIVE, x386Info.vtno) != 0)
+ 	{
+       	    ErrorF("xf86OpenConsole: VT_WAITACTIVE failed\n");
+ 	}
+ 	/*
+ 	 * If the server doesn't have the VT when the reset occurs,
+ 	 * this is to make sure we don't continue until the activate
+ 	 * signal is received.
+ 	 */
+ 	if (!x386VTSema)
+ 	    sleep(5);
+     }
+     return;
+ }
+ 
+ void xf86CloseConsole()
+ {
+     struct vt_mode   VT;
+     char	     *console = "/dev/vt00";
+     int		     console_fd;
+ 
+     /*
+      * Solaris 2.1 x86 doesnt seem to "switch" back to the console
+      * when the VT is relinquished and its mode is reset to auto. 
+      * Also, Solaris 2.1 also seems to associate vt00 with the
+      * console so I've opened the "console" back up and made it
+      * the active vt again in text mode and then closed it.
+      * There must be a better hack for this but I'm not aware of
+      * one at this time.
+      *
+      * Doug Anson 11/6/93
+      * danson@lgc.com
+      *
+      * Fixed - 12/5/93 - David Holland - davidh@dorite.use.com
+      * Did the whole thing similarly to the way linux does it
+      */
+ 
+     /* reset the display back to text mode */
+ 
+     ioctl(x386Info.consoleFd, KDSETMODE, KD_TEXT);  /* Back to text mode ... */
+     if (ioctl(x386Info.consoleFd, VT_GETMODE, &VT) != -1)
+     {
+ 	VT.mode = VT_AUTO;
+ 	ioctl(x386Info.consoleFd, VT_SETMODE, &VT); /* set dflt vt handling */
+     }
+ 
+     /* Activate the VT that X was started on */ 
+ 
+     ioctl(x386Info.consoleFd, VT_ACTIVATE, x386StartVT);
+     close(x386Info.consoleFd);                 /* make the vt-manager happy */
+     return;
+ }
+ 
+ int xf86ProcessArgument(argc, argv, i)
+ int argc;
+ char *argv[];
+ int i;
+ {
+ 	/*
+ 	 * Keep server from detaching from controlling tty.  This is useful 
+ 	 * when debugging (so the server can receive keyboard signals.
+ 	 */
+ 	if (!strcmp(argv[i], "-keeptty"))
+ 	{
+ 		KeepTty = TRUE;
+ 		return(1);
+ 	}
+ 	/*
+ 	 * Undocumented flag to protect page 0 from read/write to help
+ 	 * catch NULL pointer dereferences.  This is purely a debugging
+ 	 * flag.
+ 	 */
+ 	if (!strcmp(argv[i], "-protect0"))
+ 	{
+ 		Protect0 = TRUE;
+ 		return(1);
+ 	}
+ 	if ((argv[i][0] == 'v') && (argv[i][1] == 't'))
+ 	{
+ 		if (sscanf(argv[i], "vt%2d", &VTnum) == 0)
+ 		{
+ 			UseMsg();
+ 			VTnum = -1;
+ 			return(0);
+ 		}
+ 		return(1);
+ 	}
+ 	return(0);
+ }
+ 
+ void xf86UseMsg()
+ {
+ 	ErrorF("vtXX                   use the specified VT number\n");
+ 	ErrorF("-keeptty               ");
+ 	ErrorF("don't detach controlling tty (for debugging only)\n");
+ 	return;
+ }
+ 
+ /*
+  * xf86_solx86usleep() - Solaris 2.1 x86 does not have a suitable
+  * 			 replacement (SYSV) for usleep. Although
+  *			 usleep exists in the BSD compatiblity libs
+  *			 I dont want to use those libs if possible.
+  *
+  *			 Doug Anson
+  *			 danson@lgc.com
+  */
+ int xf86_solx86usleep(unsigned long usec)
+ {
+     int		      retval = 0;
+     struct itimerval  naptime;
+     struct itimerval  savetime;
+     unsigned long     useconds = 0;
+     unsigned long     seconds = 0;
+     int		      i;
+     unsigned long     tmp;
+ 	
+ /*
+  * WHY DOESN'T THIS SIMPLY DO A select() WITH NO FILE DESCRIPTORS?
+  */
+ 
+     /* this time will allow a max of MAX_SECONDS seconds sleeping */
+     for(i=MAX_SECONDS;i>=0;--i)
+     {
+ 	tmp = (unsigned long)((unsigned long)(i)*USEC_IN_SEC);
+ 	if (tmp <= usec)
+ 	{
+ 	    seconds = i;
+ 	    if (i == MAX_SECONDS)
+ 		useconds = 0;
+ 	    else
+ 	        useconds = (unsigned long)(usec - tmp);
+ 	    i = -1;
+ 	}
+     }
+ 
+     /* get the current time */
+     if ((retval=getitimer(ITIMER_REAL,&savetime)) == 0)
+     {
+     	/* set the itimer to reflect requested time to sleep */
+ 	naptime.it_value.tv_sec = savetime.it_value.tv_sec + seconds;
+     	naptime.it_value.tv_usec = savetime.it_value.tv_usec + useconds;
+     
+     	/* specify a one-shot clock */
+     	naptime.it_interval.tv_usec = 0;
+     	naptime.it_interval.tv_sec = 0;
+ 
+ 	/* redisposition SIGALRM */
+ 	signal(SIGALRM,xf86_solx86sleep);
+ 
+     	/* use SIGLARM */
+     	if ((retval=setitimer(ITIMER_REAL,&naptime,NULL)) == 0)
+ 		/* now just pause */
+ 		retval = pause();
+ 
+ 	/* restore the timer */
+ 	retval = setitimer(ITIMER_REAL,&savetime,NULL);
+ 
+ 	/* restore the SIGALRM disposition */
+ 	signal(SIGALRM,SIG_DFL);
+     }
+ 
+     /* return the return value */
+     return retval;
+ }
+ 
+ /*
+  * xf86_solx86sleep() - This function is a NOP disposition for 
+  *			the SIGALRM that is used to implement 
+  *			usleep() in Solaris 2.1 x86. 
+  *
+  *			Doug Anson
+  *			danson@lgc.com
+  */
+ static void xf86_solx86sleep(int signo)
+ {
+     /* do nothing */
+     return;
+ }
diff -c /dev/null mit/server/ddx/x386/os-support/solx86/solx86_iout.s:2.2
*** /dev/null	Fri Mar 11 23:40:07 1994
--- mit/server/ddx/x386/os-support/solx86/solx86_iout.s	Fri Mar 11 23:40:07 1994
***************
*** 0 ****
--- 1,100 ----
+ /
+ / File: solx86_iout.s
+ /
+ / Purpose: Provide inb(), inw(), inl(), outb(), outw(), outl() functions
+ /          for Solaris x86 using the ProWorks compiler by SunPro
+ /
+ / Author:  Installed into XFree86 SuperProbe by Doug Anson (danson@lgc.com)
+ /          Portions donated to XFree86 by Steve Dever (Steve.Dever@Eng.Sun.Com)
+ /
+ / Synopsis: (c callable external declarations)
+ /          extern unsigned char inb(int port);
+ /          extern unsigned short inw(int port);
+ /          extern unsigned long inl(int port);
+ /          extern void outb(int port, unsigned char value);
+ /          extern void outw(int port, unsigned short value);
+ /          extern void outl(int port, unsigned long value);
+ /
+ 
+ / $XFree86: mit/server/ddx/x386/os-support/solx86/solx86_iout.s,v 2.2 1994/02/01 13:52:48 dawes Exp $
+ 
+ .file "solx86_iout.s"
+ .text
+ 
+ .globl  inb
+ .globl  inw
+ .globl  inl
+ .globl  outb
+ .globl  outw
+ .globl  outl
+ 
+ /
+ / unsigned char inb(int port);
+ /
+ .align	4
+ inb:
+         movl 4(%esp),%edx
+         subl %eax,%eax
+         inb  (%dx)
+ 		ret
+ .type	inb,@function
+ .size	inb,.-inb
+ 
+ /
+ / unsigned short inw(int port);
+ /
+ .align	4
+ inw:
+         movl 4(%esp),%edx
+         subl %eax,%eax
+         inw  (%dx)
+ 		ret
+ .type	inw,@function
+ .size	inw,.-inw
+ 
+ /
+ / unsigned long inl(int port);
+ /
+ .align	4
+ inl:
+         movl 4(%esp),%edx
+         inl  (%dx)
+ 		ret
+ .type	inl,@function
+ .size	inl,.-inl
+ 
+ /
+ /     void outb(int port, unsigned char value);
+ /
+ .align	4
+ outb:
+         movl 4(%esp),%edx
+         movl 8(%esp),%eax
+         outb (%dx)
+ 		ret
+ .type	outb,@function
+ .size	outb,.-outb
+ 
+ /
+ /     void outw(int port, unsigned short value);
+ /
+ .align	4
+ outw:
+         movl 4(%esp),%edx
+         movl 8(%esp),%eax
+         outw (%dx)
+ 	    ret
+ .type	outw,@function
+ .size	outw,.-outw
+ 
+ /
+ /     void outl(int port, unsigned long value);
+ /
+ .align	4
+ outl:
+         movl 4(%esp),%edx
+         movl 8(%esp),%eax
+         outl (%dx)
+ 	    ret
+ .type	outl,@function
+ .size	outl,.-outl
diff -c /dev/null mit/server/ddx/x386/os-support/solx86/solx86_mmap.c:2.0
*** /dev/null	Fri Mar 11 23:40:07 1994
--- mit/server/ddx/x386/os-support/solx86/solx86_mmap.c	Fri Mar 11 23:40:07 1994
***************
*** 0 ****
--- 1,71 ----
+ /*
+  * 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/os-support/solx86/solx86_mmap.c,v 2.0 1993/12/10 14:36:25 dawes Exp $ */
+ 
+ #include "X.h"
+ #include "input.h"
+ #include "scrnintstr.h"
+ 
+ #include "x386.h"
+ #include "x386Priv.h"
+ #include "xf86_OSlib.h"
+ 
+ /*
+  * Read BIOS via mmap()ing /dev/pmem.
+  */
+ int xf86ReadBIOS(Base, Offset, Buf, Len)
+ unsigned long Base;
+ unsigned long Offset;
+ unsigned char *Buf;
+ int Len;
+ {
+ 	int fd;
+ 	unsigned char *ptr;
+ 	char	solx86_vtname[10];
+ 
+ 	/*
+      	 * Solaris 2.1 x86 SVR4 (10/27/93)
+      	 *      The server must treat the virtual terminal device file
+      	 *      as the standard SVR4 /dev/pmem. By default, then used VT
+      	 *      is considered the "default" file to open.
+      	 */
+         sprintf(solx86_vtname,"/dev/vt%02d",x386Info.vtno);
+ 	if ((fd = open(solx86_vtname, O_RDONLY)) < 0)
+     	{
+         	ErrorF("xf86ReadBios: Failed to open %s (%s)\n", solx86_vtname,
+                		strerror(errno));
+         	return(-1);
+ 	}	
+ 	ptr = mmap((caddr_t)0, 0x8000, PROT_READ, MAP_SHARED, fd, (off_t)Base);
+ 	if ((int)ptr == -1)
+ 	{
+ 		ErrorF("xf86ReadBios: %s mmap failed\n", solx86_vtname);
+ 		close(fd);
+ 		return(-1);
+ 	}
+ 	(void)memcpy(Buf, (void *)(ptr + Offset), Len);
+ 	(void)munmap((caddr_t)ptr, 0x8000);
+ 	(void)close(fd);
+ 	return(Len);
+ }
diff -c /dev/null mit/server/ddx/x386/os-support/solx86/solx86_vid.c:2.2
*** /dev/null	Fri Mar 11 23:40:07 1994
--- mit/server/ddx/x386/os-support/solx86/solx86_vid.c	Fri Mar 11 23:40:07 1994
***************
*** 0 ****
--- 1,301 ----
+ /*
+  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany
+  * 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 Thomas Roell and David Wexelblat 
+  * not be used in advertising or publicity pertaining to distribution of 
+  * the software without specific, written prior permission.  Thomas Roell and
+  * David Wexelblat 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 WEXELBLAT DISCLAIMS ALL WARRANTIES WITH REGARD TO 
+  * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND 
+  * FITNESS, IN NO EVENT SHALL THOMAS ROELL 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.
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/os-support/solx86/solx86_vid.c,v 2.2 1994/02/25 15:02:31 dawes Exp $ */
+ 
+ #include "X.h"
+ #include "input.h"
+ #include "scrnintstr.h"
+ 
+ #define _NEED_SYSI86
+ #include "x386.h"
+ #include "x386Priv.h"
+ #include "xf86_OSlib.h"
+ 
+ /***************************************************************************/
+ /* Video Memory Mapping section                                            */
+ /***************************************************************************/
+ 
+ struct kd_memloc MapDSC[MAXSCREENS][NUM_REGIONS];
+ pointer AllocAddress[MAXSCREENS][NUM_REGIONS];
+ 
+ Bool xf86LinearVidMem()
+ {
+ 
+ #ifdef HAS_SOLX86_APERTUREDRV
+ 	int	mmapFd;
+ 
+ 	if((mmapFd = open("/dev/fbs/aperture", O_RDWR)) < 0)
+ 	{
+ 	    ErrorF("xf86LinearVidMem: failed to open /dev/fbs/aperture (%s)\n", 
+ 		   strerror(errno));
+ 	    ErrorF("xf86LinearVidMem: 'aperture' device driver required\n");
+ 	    ErrorF("xf86LinearVidMem: linear memory access disabled\n");
+ 	    return FALSE;
+ 	}
+ 	close(mmapFd);
+ 	return TRUE;
+ #else
+ 	return FALSE;
+ #endif
+ 
+ }
+ 
+ pointer xf86MapVidMem(ScreenNum, Region, Base, Size)
+ int ScreenNum;
+ int Region;
+ pointer Base;
+ unsigned long Size;
+ {
+ 	pointer base;
+ 	int fd;
+ 	char solx86_vtname[20];
+ 
+ 	/* 
+ 	 * Solaris 2.1 x86 SVR4 (10/27/93)
+ 	 *		The server must treat the virtual terminal device file 
+ 	 *		as the standard SVR4 /dev/pmem. 
+ 	 * 
+ 	 * Uning the /dev/vtXX device as /dev/pmem only works for the
+ 	 * A0000-FFFFF region - If we wish you mmap the linear aperture
+  	 * it requires a device driver.
+  	 * 
+ 	 * So what we'll do is use /dev/vtXX for the A0000-FFFFF stuff, and
+ 	 * try to use the /dev/fbs/aperture driver if the server
+ 	 * tries to mmap anything > FFFFF, and HAS_SOLX86_APERTUREDRV is
+ 	 * defined. (its very very unlikely that the server will try to mmap
+ 	 * anything below FFFFF that can't be handled by /dev/vtXX.
+ 	 * If the server tries to mmap anything above FFFFF, and
+ 	 * HAS_SOLX86_APERTUREDRV the server will die.
+ 	 * 
+ 	 * DWH - 2/23/94
+ 	 */
+ 
+ 	if(Base < (pointer)0xFFFFF)
+ 		sprintf(solx86_vtname,"/dev/vt%02d",x386Info.vtno);
+ 	else
+ 
+ #ifdef HAS_SOLX86_APERTUREDRV
+ 		sprintf(solx86_vtname, "/dev/fbs/aperture");
+ #else
+ 		FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ 			   "xf86MapVidMem", Size, Base,
+ 			   "/dev/fbs/aperture driver unavailable");
+ #endif
+ 
+ 	if ((fd = open(solx86_vtname, O_RDWR,0)) < 0)
+ 	{
+ 		FatalError("xf86MapVidMem: failed to open %s (%s)\n",
+ 			   solx86_vtname, strerror(errno));
+ 	}
+ 	base = (pointer)mmap((caddr_t)0, Size, PROT_READ|PROT_WRITE,
+ 			     MAP_SHARED, fd, (off_t)Base);
+ 	close(fd);
+ 	if ((long)base == -1)
+ 	{
+ 		FatalError("%s: Could not mmap framebuffer [s=%x,a=%x] (%s)\n",
+ 			   "xf86MapVidMem", Size, Base, strerror(errno));
+ 	}
+ 	return((pointer)base);
+ }
+ 
+ /* ARGSUSED */
+ void xf86UnMapVidMem(ScreenNum, Region, Base, Size)
+ int ScreenNum;
+ int Region;
+ pointer Base;
+ unsigned long Size;
+ {
+ 	munmap(Base, Size);
+ }
+ 
+ /* ARGSUSED */
+ void xf86MapDisplay(ScreenNum, Region)
+ int ScreenNum;
+ int Region;
+ {
+ 	return;
+ }
+ 
+ /* ARGSUSED */
+ void xf86UnMapDisplay(ScreenNum, Region)
+ int ScreenNum;
+ int Region;
+ {
+ 	return;
+ }
+ 
+ /***************************************************************************/
+ /* I/O Permissions section                                                 */
+ /***************************************************************************/
+ 
+ static unsigned *EnabledPorts[MAXSCREENS];
+ static int NumEnabledPorts[MAXSCREENS];
+ static Bool ScreenEnabled[MAXSCREENS];
+ static Bool ExtendedPorts[MAXSCREENS]; /* Not used, but leave it for now to
+ 					  to keep xf86InitPortLists() happy */
+ static Bool ExtendedEnabled = FALSE;
+ static Bool InitDone = FALSE;
+ 
+ void xf86ClearIOPortList(ScreenNum)
+ int ScreenNum;
+ {
+ 	int i;
+ 
+ 	if (!InitDone)
+ 	{
+ 		xf86InitPortLists(EnabledPorts, NumEnabledPorts, ScreenEnabled,
+ 				  ExtendedPorts, MAXSCREENS);
+ 		InitDone = TRUE;
+ 		return;
+ 	}
+ 	if (EnabledPorts[ScreenNum] != (unsigned *)NULL)
+ 		xfree(EnabledPorts[ScreenNum]);
+ 	EnabledPorts[ScreenNum] = (unsigned *)NULL;
+ 	NumEnabledPorts[ScreenNum] = 0;
+ }
+ 
+ void xf86AddIOPorts(ScreenNum, NumPorts, Ports)
+ int ScreenNum;
+ int NumPorts;
+ unsigned *Ports;
+ {
+ 	int i;
+ 
+ 	if (!InitDone)
+ 	{
+ 	    FatalError("xf86AddIOPorts: I/O control lists not initialised\n");
+ 	}
+ 	EnabledPorts[ScreenNum] = (unsigned *)xrealloc(EnabledPorts[ScreenNum], 
+ 			(NumEnabledPorts[ScreenNum]+NumPorts)*sizeof(unsigned));
+ 	for (i = 0; i < NumPorts; i++)
+ 	{
+ 		EnabledPorts[ScreenNum][NumEnabledPorts[ScreenNum] + i] =
+ 								Ports[i];
+ 	}
+ 	NumEnabledPorts[ScreenNum] += NumPorts;
+ }
+ 
+ void xf86EnableIOPorts(ScreenNum)
+ int ScreenNum;
+ {
+ 
+ 	if (ScreenEnabled[ScreenNum])
+ 		return;
+ 
+ 	ScreenEnabled[ScreenNum] = TRUE;
+ 
+ 	if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
+ 	{
+ 		FatalError("%s: Failed to set IOPL for I/O\n",
+ 			   "xf86EnableIOPorts");
+ 	}
+ 
+ 	ExtendedEnabled = TRUE;
+ 	return;
+ }
+ 
+ void xf86DisableIOPorts(ScreenNum)
+ int ScreenNum;
+ {
+ 	int i;
+ 
+ 	if (!ScreenEnabled[ScreenNum])
+ 		return;
+ 
+ 	ScreenEnabled[ScreenNum] = FALSE;
+ 
+ 	if(!ExtendedEnabled)
+ 		return;
+ 
+ 	for (i = 0; i < MAXSCREENS; i++)
+ 	{
+ 		if (ScreenEnabled[i])
+ 			return;
+ 	}
+ 
+ 	sysi86(SI86V86, V86SC_IOPL, 0);
+ 
+ 	ExtendedEnabled = FALSE;
+ 
+ 	return;
+ }
+ 
+ void xf86DisableIOPrivs()
+ {
+ 	if (ExtendedEnabled)
+ 		sysi86(SI86V86, V86SC_IOPL, 0);
+ 	return;
+ }
+ 
+ /***************************************************************************/
+ /* Interrupt Handling section                                              */
+ /***************************************************************************/
+ 
+ Bool xf86DisableInterrupts()
+ {
+ 	if (!ExtendedEnabled)
+ 	{
+ 		if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
+ 		{
+ 			return(FALSE);
+ 		}
+ 	}
+ 
+ #ifdef __GNUC__
+ 	__asm__ __volatile__("cli");
+ #else 
+ 	asm("cli");
+ #endif /* __GNUC__ */
+ 
+ 	if (!ExtendedEnabled)
+ 	{
+ 		sysi86(SI86V86, V86SC_IOPL, 0);
+ 	}
+ 	return(TRUE);
+ }
+ 
+ void xf86EnableInterrupts()
+ {
+ 	if (!ExtendedEnabled)
+ 	{
+ 		if (sysi86(SI86V86, V86SC_IOPL, PS_IOPL) < 0)
+ 		{
+ 			return;
+ 		}
+ 	}
+ 
+ #ifdef __GNUC__
+ 	__asm__ __volatile__("sti");
+ #else 
+ 	asm("sti");
+ #endif /* __GNUC__ */
+ 
+ 	if (!ExtendedEnabled)
+ 	{
+ 		sysi86(SI86V86, V86SC_IOPL, 0);
+ 	}
+ 	return;
+ }
diff -c mit/server/ddx/x386/os-support/sysv/sysv_video.c:2.15 mit/server/ddx/x386/os-support/sysv/sysv_video.c:2.16
*** mit/server/ddx/x386/os-support/sysv/sysv_video.c:2.15	Fri Mar 11 23:40:09 1994
--- mit/server/ddx/x386/os-support/sysv/sysv_video.c	Fri Mar 11 23:40:09 1994
***************
*** 23,29 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/sysv/sysv_video.c,v 2.15 1993/10/16 17:32:18 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
--- 23,29 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/os-support/sysv/sysv_video.c,v 2.16 1993/12/25 14:01:24 dawes Exp $ */
  
  #include "X.h"
  #include "input.h"
***************
*** 227,234 ****
  void xf86ClearIOPortList(ScreenNum)
  int ScreenNum;
  {
- 	int i;
- 
  	if (!InitDone)
  	{
  		xf86InitPortLists(EnabledPorts, NumEnabledPorts, ScreenEnabled,
--- 227,232 ----
diff -c /dev/null mit/server/ddx/x386/vga16/doc/128kb.shar:2.0
*** /dev/null	Fri Mar 11 23:40:11 1994
--- mit/server/ddx/x386/vga16/doc/128kb.shar	Fri Mar 11 23:40:11 1994
***************
*** 0 ****
--- 1,117 ----
+ # The patches in this file are provided for informational purposes only, to 
+ # indicate what should be changed in order to allow a 128kb bank to be used
+ # in the Trident cards.
+ 
+ # They require, and should be applied AFTER, the cleanup patches.
+ # (Which were late. Sorry.)
+ 
+ # Those modifications can be used in conjunction with the unbank modifications,
+ # to have a [relatively] fast Trident server that allows up to 1152x900.
+ 
+ # Those patches may be out of date.
+ 
+ # The content of the patches is:
+ # 128kb1.dif:
+ #    Update the Trident driver to allow and have an 128kb option.
+ # 128kb2.dif:
+ #    Make this option "map_all" a valid option of the vga16 server.
+ 
+ # $XFree86: mit/server/ddx/x386/vga16/doc/128kb.shar,v 2.0 1994/03/03 12:46:25 dawes Exp $
+ 
+ #!/bin/sh
+ # shar:	Shell Archiver  (v1.22)
+ #
+ #	Run the following text with /bin/sh to create:
+ #	  128kb1.dif
+ #	  128kb2.dif
+ #
+ sed 's/^X//' << 'SHAR_EOF' > 128kb1.dif &&
+ X*** mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c.org	Tue Mar  1 18:58:55 1994
+ X--- mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c	Tue Mar  1 18:59:54 1994
+ X***************
+ X*** 41,46 ****
+ X--- 41,47 ----
+ X   *	    David Wexelblat, massive rewrite to support 8800CS, 8900B,
+ X   *			     8900C, 8900CL, 9000.  Support 512k and 1M.
+ X   *			     Version 3.0.
+ X+  *	    Gertjan Akkerman, made this EXPERIMENTAL version.
+ X   */
+ X  
+ X  #include "X.h"
+ X***************
+ X*** 427,437 ****
+ X--- 428,456 ----
+ X  	vga256InfoRec.chipset = TVGA8900Ident(TVGAchipset);
+ X  	vga256InfoRec.bankedMono = TRUE;
+ X  
+ X+ #ifdef XF86VGA16
+ X+ 	if (OFLG_ISSET(OPTION_MAP_ALL,&vga256InfoRec.options)) {
+ X+   		TVGA8900.ChipMapSize = 0x20000;
+ X+   		TVGA8900.ChipSegmentSize = 0x20000;
+ X+   		TVGA8900.ChipSegmentShift = 17;
+ X+   		TVGA8900.ChipSegmentMask = 0x1ffff;
+ X+   		TVGA8900.ChipReadBottom = 0x00000;
+ X+ 		TVGA8900.ChipReadTop = 0x20000;
+ X+   		TVGA8900.ChipWriteBottom = 0x00000;
+ X+ 		TVGA8900.ChipWriteTop = 0x20000;
+ X+ 		vga256InfoRec.bankedMono = FALSE;
+ X+ 	}
+ X+ 
+ X+ 	/* Allow the map all option */
+ X+ 	OFLG_SET(OPTION_MAP_ALL, &TVGA8900.ChipOptionFlags);
+ X+ #endif
+ X+ 
+ X  	/* Initialize option flags allowed for this driver */
+ X  	if ((TVGAchipset == TVGA8900B) || (TVGAchipset == TVGA8900C))
+ X  	{
+ X  		OFLG_SET(OPTION_16CLKS, &TVGA8900.ChipOptionFlags);
+ X  	}
+ X+ 
+ X      	return(TRUE);
+ X  }
+ X  
+ X***************
+ X*** 667,672 ****
+ X--- 686,696 ----
+ X  			new->OldMode1 = (new->std.NoClock & 0x08) << 1;
+ X  		}
+ X  	}
+ X+ #ifdef XF86VGA16
+ X+ 	if (OFLG_ISSET(OPTION_MAP_ALL,&vga256InfoRec.options)) {
+ X+ 		new->std.Graphics[6] = 0x01; /* Map 128Kb of memory */
+ X+ 	}
+ X+ #endif
+ X          return(TRUE);
+ X  }
+ X  
+ SHAR_EOF
+ chmod 0644 128kb1.dif || echo "restore of 128kb1.dif fails"
+ sed 's/^X//' << 'SHAR_EOF' > 128kb2.dif &&
+ X*** mit/server/ddx/x386/common/xf86_Option.or	Tue Mar  1 18:35:38 1994
+ X--- mit/server/ddx/x386/common/xf86_Option.h	Tue Mar  1 19:03:59 1994
+ X***************
+ X*** 91,96 ****
+ X--- 91,99 ----
+ X  #define OPTION_SHOWCACHE	48 /* Allow cache to be seen (S3) */
+ X  #define OPTION_FB_DEBUG		49 /* Linear fb debug for S3 */
+ X  
+ X+ /* Experimental option: (unsupported) */
+ X+ #define OPTION_MAP_ALL		57 /* Map 128Kb instead of 64Kb of vid. mem */
+ X+   
+ X  #define CLOCK_OPTION_PROGRAMABLE 0 /* has a programable clock */
+ X  #define CLOCK_OPTION_ICD2061A	 1 /* use ICD 2061A programable clocks      */
+ X  #define CLOCK_OPTION_ICD2061ASL	 2 /* use slow ICD 2061A programable clocks */
+ X***************
+ X*** 144,149 ****
+ X--- 147,154 ----
+ X  
+ X    { "showcache",	OPTION_SHOWCACHE },
+ X    { "fb_debug",		OPTION_FB_DEBUG },
+ X+ 
+ X+   { "map_all",		OPTION_MAP_ALL },
+ X  
+ X    { "",			-1 },
+ X  };
+ SHAR_EOF
+ chmod 0644 128kb2.dif || echo "restore of 128kb2.dif fails"
+ exit 0
diff -c /dev/null mit/server/ddx/x386/vga16/doc/cleanup.shar:2.1
*** /dev/null	Fri Mar 11 23:40:11 1994
--- mit/server/ddx/x386/vga16/doc/cleanup.shar	Fri Mar 11 23:40:12 1994
***************
*** 0 ****
--- 1,760 ----
+ # The patches in this file are provided for informational purposes only.
+ # They do a little bit of cleaning up in preparation for future patches:
+ # Basically, they remove all references to vgaVirtBase from the code, although
+ # retaining some references to vgaBase.
+ # I will incorporate these patches in the following release, but was too
+ # late for this one. [Side-tracked to code that should work but doesn't.]
+ # The modifications in this file should be applied before either the 128kb
+ # modifications or the unbank modifications.
+ 
+ # The content of the modifications is:
+ # cleanup1.dif:
+ #    Update vga.c in vga16/vga to call the initialization routine with all
+ #    proper parameters. (mainly cosmetic).
+ # cleanup2.dif:
+ #    Update the Imakefile in vga16/vga so that it no longer fetches vgaBank.s
+ #    but uses the one we provided.
+ # cleanup3.dif:
+ #    create a vgaBank.s that works with vgaBase instead of VGABASE.
+ # cleanup4.dif:
+ #    Update the header from Init16Output in ppcIO.c, and remove all references
+ #    to vgaVirtBase from the code.
+ # cleanup5.dif:
+ #    Late cleanup patch. Hardly tested, but required.
+ #    Set vgaVirtBase to vgaBase, lest VT switching crashes.
+ 
+ # $XFree86: mit/server/ddx/x386/vga16/doc/cleanup.shar,v 2.1 1994/03/07 14:01:24 dawes Exp $
+ 
+ #!/bin/sh
+ # shar:	Shell Archiver  (v1.22)
+ #
+ #	Run the following text with /bin/sh to create:
+ #	  cleanup1.dif
+ #	  cleanup2.dif
+ #	  cleanup3.dif
+ #	  cleanup4.dif
+ #	  cleanup5.dif
+ #
+ sed 's/^X//' << 'SHAR_EOF' > cleanup1.dif &&
+ X*** mit/server/ddx/x386/vga256/vga/vga.c.org	Mon Feb 28 20:23:35 1994
+ X--- mit/server/ddx/x386/vga256/vga/vga.c	Mon Feb 28 20:23:51 1994
+ X***************
+ X*** 618,624 ****
+ X  #endif
+ X      return(FALSE);
+ X  #else /* XF86VGA16 */
+ X!   Init16Output( pScreen, vga256InfoRec.virtualX, vga256InfoRec.virtualY );
+ X  #endif /* XF86VGA16 */
+ X  
+ X    pScreen->CloseScreen = vgaCloseScreen;
+ X--- 618,629 ----
+ X  #endif
+ X      return(FALSE);
+ X  #else /* XF86VGA16 */
+ X!   Init16Output(pScreen,
+ X! 		     (pointer) vgaVirtBase,
+ X! 		     vga256InfoRec.virtualX,
+ X! 		     vga256InfoRec.virtualY,
+ X! 		     displayResolution, displayResolution,
+ X! 		     vga256InfoRec.virtualX);
+ X  #endif /* XF86VGA16 */
+ X  
+ X    pScreen->CloseScreen = vgaCloseScreen;
+ SHAR_EOF
+ chmod 0644 cleanup1.dif || echo "restore of cleanup1.dif fails"
+ sed 's/^X//' << 'SHAR_EOF' > cleanup2.dif &&
+ X*** mit/server/ddx/x386/vga16/vga/Imakefile.org	Mon Feb 28 20:23:35 1994
+ X--- mit/server/ddx/x386/vga16/vga/Imakefile	Mon Feb 28 20:24:20 1994
+ X***************
+ X*** 2,8 ****
+ X  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
+ X  #include <Server.tmpl>
+ X  
+ X! SRCS = 	vgaHW.c vga.c vgaCmap.c
+ X  
+ X  OBJS = 	vgaHW.o vga.o vgaCmap.o vgaBank.o
+ X  
+ X--- 2,8 ----
+ X  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
+ X  #include <Server.tmpl>
+ X  
+ X! SRCS = 	vgaHW.c vga.c vgaCmap.c vgaBank.s
+ X  
+ X  OBJS = 	vgaHW.o vga.o vgaCmap.o vgaBank.o
+ X  
+ X***************
+ X*** 26,31 ****
+ X  ObjectFromSpecialSource(vga,../../vga256/vga/vga,/**/)
+ X  ObjectFromSpecialSource(vgaHW,../../vga256/vga/vgaHW,/**/)
+ X  ObjectFromSpecialSource(vgaCmap,../../vga256/vga/vgaCmap,/**/)
+ X- ObjectFromSpecialAsmSource(vgaBank,../../vga256/vga/vgaBank,/**/)
+ X  
+ X  DependTarget()
+ X--- 26,30 ----
+ SHAR_EOF
+ chmod 0644 cleanup2.dif || echo "restore of cleanup2.dif fails"
+ sed 's/^X//' << 'SHAR_EOF' > cleanup3.dif &&
+ X*** /dev/null	Sat Aug 29 21:48:28 1992
+ X--- mit/server/ddx/x386/vga16/vga/vgaBank.s	Mon Feb 28 20:32:42 1994
+ X***************
+ X*** 0 ****
+ X--- 1,538 ----
+ X+ /* GJA -- deleted rcs id since rcs doesn't like ids embedded in shar files */
+ X+ /*
+ X+  * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
+ X+  *
+ X+  * Permission to use, copy, modify, distribute, and sell this software and its
+ X+  * documentation for any purpose is hereby granted without fee, provided that
+ X+  * the above copyright notice appear in all copies and that both that
+ X+  * copyright notice and this permission notice appear in supporting
+ X+  * documentation, and that the name of Thomas Roell not be used in
+ X+  * advertising or publicity pertaining to distribution of the software without
+ X+  * specific, written prior permission.  Thomas Roell makes no representations
+ X+  * about the suitability of this software for any purpose.  It is provided
+ X+  * "as is" without express or implied warranty.
+ X+  *
+ X+  * THOMAS ROELL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ X+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ X+  * EVENT SHALL THOMAS ROELL BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ X+  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ X+  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ X+  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ X+  * PERFORMANCE OF THIS SOFTWARE.
+ X+  *
+ X+  * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
+ X+  *
+ X+  * $Header: /proj/X11/mit/server/ddx/x386/vga/RCS/vgaBank.s,v 1.1 1991/06/02 22:36:38 root Exp $
+ X+  */
+ X+ 
+ X+ /* GJA -- This file is just vgaBank.s from vga256/vga, with VGABASE replaced
+ X+  * by CONTENT(GLNAME(vgaBase))
+ X+  * VGABASE is used in the other servers for allowing the same routines to be
+ X+  * used for pixmap and window drawing. This is not possible for planar VGA,
+ X+  * and getting rid of VGABASE brings the banked server much closer to the
+ X+  * unbanked server.
+ X+  */
+ X+ 
+ X+ #include "assyntax.h"
+ X+ 
+ X+ 	FILE("vgaBank.s")
+ X+ 	AS_BEGIN
+ X+ 
+ X+ /*
+ X+  * Because a modern VGA has more than 128kBytes (which are mappable into the
+ X+  * 386' memory some logic is required. The VGA's memory (logical VGA
+ X+  * address space) is devided into smaller parts (called logical segments). 
+ X+  * These segments are mapped to logical areas.
+ X+  *
+ X+  * There are there different logical mapping areas:
+ X+  *
+ X+  * Read:       an area which can be read from
+ X+  * Write:      an area which can be written to
+ X+  * ReadWrite:  here is both read an write possible
+ X+  *
+ X+  * It is permissable to use simultaneously a Read and a Write, but you can use
+ X+  * ReadWrite only as a single. 
+ X+  * For example the bitblitting code uses a Read area as source and a Write
+ X+  * area as destination. Most other routines use only a ReadWrite.
+ X+  *
+ X+  * A logical mapping area is described by some parameters (here I will for
+ X+  * example describe a Read area:
+ X+  *
+ X+  * ReadBottom     lowest accessable byte relative to the beginning of the
+ X+  *                VGA boards mapped memory.
+ X+  * 
+ X+  * ReadTop        highes accessable byte plus one.
+ X+  *
+ X+  * SegmentSize    size of such an mapped area (common for all three)
+ X+  *
+ X+  * SegmentShift   log2(SegmentSize) (used to compute the logical segment)
+ X+  *
+ X+  * SegmentMask    SegmentSize - 1 (used to mask the offset inter an area)
+ X+  *
+ X+  * 
+ X+  * All that the following routines are doing is computing for a given offset
+ X+  * into the logical VGA adress space the offset into such an logical area
+ X+  * and the logical segment number. By the way they call also the VGA board's
+ X+  * driver to set up the VGA's physical memory mapping according to the logical
+ X+  * that was requested by the calliie.
+ X+  *
+ X+  * For shake of simplicity Write and ReadWrite share the same Bottom & Top.
+ X+  * NOTE: Read & Write may have differnt starting addresses, or even common.
+ X+  *
+ X+  * There are multible routines present for the same effect. This was made
+ X+  * for effectivly interface lowlevel assembly language best.
+ X+  */
+ X+ 
+ X+ /*
+ X+  * BUGALERT: this should be gotten from vga.h. But since there some C lang.
+ X+  *           things, too ...
+ X+  */
+ X+ 
+ X+ #include "vgaAsm.h"
+ X+ 
+ X+ 
+ X+ 	SEG_DATA
+ X+ 	GLOBL GLNAME(writeseg)
+ X+ GLNAME(writeseg):
+ X+ 	D_LONG 0
+ X+ GLNAME(readseg):
+ X+ 	D_LONG 0
+ X+ GLNAME(saveseg):
+ X+ 	D_LONG 0
+ X+ 
+ X+ 	SEG_TEXT
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaSetReadWrite ---
+ X+  *     select a memory bank of the VGA board for read & write access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  * pointer
+ X+  * vgaSetReadWrite(p)
+ X+  *     register pointer p;
+ X+  * {
+ X+  *   writeseg = ((unsigned long)p - VGABASE) >> vgaSegmentShift;
+ X+  *   (vgaSetReadWriteFunc)(writeseg);
+ X+  *   return (vgaWriteBottom + ((unsigned int)p & vgaSegmentMask));
+ X+  * }
+ X+  *
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL GLNAME(vgaSetReadWrite)
+ X+ GLNAME(vgaSetReadWrite):
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	PUSH_L	(ECX)
+ X+ 	PUSH_L	(EDX)
+ X+ 	SUB_L	(CONTENT(GLNAME(vgaBase)),EAX) /* GJA */
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSegmentShift)),ECX)
+ X+ 	SHR_L	(CL,EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(writeseg)))
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetReadWriteFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	POP_L	(ECX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	AND_L	(CONTENT(GLNAME(vgaSegmentMask)),EAX)
+ X+ 	ADD_L	(CONTENT(GLNAME(vgaWriteBottom)),EAX)
+ X+  	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaReadWriteNext ---
+ X+  *     switch to next memory bank of the VGA board for read & write access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  *
+ X+  * pointer
+ X+  * vgaReadWriteNext(p)
+ X+  *      register pointer p;
+ X+  * {
+ X+  *   (vgaSetReadWriteFunc)(++writeseg);
+ X+  *   return (p - vgaSegmentSize);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaReadWriteNext)
+ X+ GLNAME(vgaReadWriteNext):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(writeseg)),EAX)
+ X+ 	INC_L	(EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(writeseg)))
+ X+ 	MOV_L 	(CONTENT(GLNAME(vgaSetReadWriteFunc)),EDX)
+ X+ 	CALL 	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	SUB_L	(CONTENT(GLNAME(vgaSegmentSize)),EAX)
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaReadWritePrev ---
+ X+  *     switch to previous memory bank of the VGA board for read & write access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  * pointer
+ X+  * vgaReadWritePrev(p)
+ X+  *      register pointer p;
+ X+  * {
+ X+  *   (vgaSetReadWriteFunc)(--writeseg); 
+ X+  *   return (p + vgaSegmentSize);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaReadWritePrev)
+ X+ GLNAME(vgaReadWritePrev):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(writeseg)),EAX)
+ X+ 	DEC_L	(EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(writeseg)))
+ X+ 	MOV_L 	(CONTENT(GLNAME(vgaSetReadWriteFunc)),EDX)
+ X+ 	CALL 	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	ADD_L	(CONTENT(GLNAME(vgaSegmentSize)),EAX)
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaSetRead ---
+ X+  *     select a memory bank of the VGA board for read access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  * pointer
+ X+  * vgaSetRead(p)
+ X+  *     register pointer p;
+ X+  * {
+ X+  *   readseg = ((unsigned long)p - VGABASE) >> vgaSegmentShift;
+ X+  *   (vgaSetReadFunc)(readseg);
+ X+  *   return (vgaReadBottom + ((unsigned int)p & vgaSegmentMask));
+ X+  * }
+ X+  *
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaSetRead)
+ X+ GLNAME(vgaSetRead):
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	PUSH_L  (ECX)
+ X+ 	PUSH_L	(EDX)
+ X+ 	SUB_L	(CONTENT(GLNAME(vgaBase)),EAX) /* GJA */
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSegmentShift)),ECX)
+ X+ 	SHR_L	(CL,EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(readseg)))
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetReadFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	POP_L	(ECX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	AND_L	(CONTENT(GLNAME(vgaSegmentMask)),EAX)
+ X+ 	ADD_L	(CONTENT(GLNAME(vgaReadBottom)),EAX)
+ X+  	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaReadNext ---
+ X+  *     switch to next memory bank of the VGA board for read access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  *
+ X+  * pointer
+ X+  * vgaReadNext(p)
+ X+  *      register pointer p;
+ X+  * {
+ X+  *   (vgaSetReadFunc)(++readseg);
+ X+  *   return (p - vgaSegmentSize);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaReadNext)
+ X+ GLNAME(vgaReadNext):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(readseg)),EAX)
+ X+ 	INC_L	(EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(readseg)))
+ X+ 	MOV_L 	(CONTENT(GLNAME(vgaSetReadFunc)),EDX)
+ X+ 	CALL 	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	SUB_L	(CONTENT(GLNAME(vgaSegmentSize)),EAX)
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaReadPrev ---
+ X+  *     switch to previous memory bank of the VGA board for read access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  * pointer
+ X+  * vgaReadPrev(p)
+ X+  *      register pointer p;
+ X+  * {
+ X+  *   (vgaSetReadFunc)(--readseg); 
+ X+  *   return (p + vgaSegmentSize);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaReadPrev)
+ X+ GLNAME(vgaReadPrev):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(readseg)),EAX)
+ X+ 	DEC_L	(EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(readseg)))
+ X+ 	MOV_L 	(CONTENT(GLNAME(vgaSetReadFunc)),EDX)
+ X+ 	CALL 	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	ADD_L	(CONTENT(GLNAME(vgaSegmentSize)),EAX)
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaSetWrite ---
+ X+  *     select a memory bank of the VGA board for write access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  * pointer
+ X+  * vgaSetWrite(p)
+ X+  *     register pointer p;
+ X+  * {
+ X+  *   writeseg = ((unsigned long)p - VGABASE) >> vgaSegmentShift;
+ X+  *   (vgaSetWriteFunc)(writeseg);
+ X+  *   return (vgaWriteBottom + ((unsigned int)p & vgaSegmentMask));
+ X+  * }
+ X+  *
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaSetWrite)
+ X+ GLNAME(vgaSetWrite):
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	PUSH_L  (ECX)
+ X+ 	PUSH_L	(EDX)
+ X+ 	SUB_L	(CONTENT(GLNAME(vgaBase)),EAX) /* GJA */
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSegmentShift)),ECX)
+ X+ 	SHR_L	(CL,EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(writeseg)))
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetWriteFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	POP_L	(ECX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	AND_L	(CONTENT(GLNAME(vgaSegmentMask)),EAX)
+ X+ 	ADD_L	(CONTENT(GLNAME(vgaWriteBottom)),EAX)
+ X+  	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaWriteNext ---
+ X+  *     switch to next memory bank of the VGA board for write access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  *
+ X+  * pointer
+ X+  * vgaWriteNext(p)
+ X+  *      register pointer p;
+ X+  * {
+ X+  *   (vgaSetWriteFunc)(++writeseg);
+ X+  *   return (p - vgaSegmentSize);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaWriteNext)
+ X+ GLNAME(vgaWriteNext):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(writeseg)),EAX)
+ X+ 	INC_L	(EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(writeseg)))
+ X+ 	MOV_L 	(CONTENT(GLNAME(vgaSetWriteFunc)),EDX)
+ X+ 	CALL 	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	SUB_L	(CONTENT(GLNAME(vgaSegmentSize)),EAX)
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaWritePrev ---
+ X+  *     switch to previous memory bank of the VGA board for write access
+ X+  * Results:
+ X+  *      The adjusted pointer into the memory.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  * pointer
+ X+  * vgaWritePrev(p)
+ X+  *      register pointer p;
+ X+  * {
+ X+  *   (vgaSetWriteFunc)(--writeseg); 
+ X+  *   return (p + vgaSegmentSize);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaWritePrev)
+ X+ GLNAME(vgaWritePrev):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(writeseg)),EAX)
+ X+ 	DEC_L	(EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(writeseg)))
+ X+ 	MOV_L 	(CONTENT(GLNAME(vgaSetWriteFunc)),EDX)
+ X+ 	CALL 	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	MOV_L	(REGOFF(4,ESP),EAX)
+ X+ 	ADD_L	(CONTENT(GLNAME(vgaSegmentSize)),EAX)
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaSaveBank --
+ X+  *     save Banking-state
+ X+  * Results:
+ X+  *      None.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  * void
+ X+  * vgaSaveBank()
+ X+  * {
+ X+  *   saveseg = writeseg;
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaSaveBank)
+ X+ GLNAME(vgaSaveBank):
+ X+ 	MOV_L	(CONTENT(GLNAME(writeseg)),EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(saveseg)))
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaRestoreBank --
+ X+  *     restore the banking after vgaSaveBank was called
+ X+  *
+ X+  * Results:
+ X+  *      None.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  * void
+ X+  * vgaRestoreBank()
+ X+  * {
+ X+  *   (vgaSetWriteFunc)(saveseg);
+ X+  *   (vgaSetReadFunc)(saveseg);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaRestoreBank)
+ X+ GLNAME(vgaRestoreBank):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(saveseg)),EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(writeseg)))
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetWriteFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	MOV_L	(CONTENT(GLNAME(saveseg)),EAX)
+ X+ 	MOV_L	(EAX,CONTENT(GLNAME(readseg)))
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetReadFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	RET
+ X+ 
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaPushRead ---
+ X+  *     make the write-bank also readable. no acces to the former read bank !
+ X+  * Results:
+ X+  *      None.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  * void
+ X+  * vgaPushRead(p)
+ X+  * {
+ X+  *   (vgaSetReadWriteFunc)(writeseg);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaPushRead)
+ X+ GLNAME(vgaPushRead):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(writeseg)),EAX)
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetReadWriteFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	RET
+ X+ 
+ X+ /*
+ X+  *-----------------------------------------------------------------------
+ X+  * vgaPopRead ---
+ X+  *     restore the banking after vgaPushRead was called
+ X+  *
+ X+  * Results:
+ X+  *      None.
+ X+  *
+ X+  * Side Effects:
+ X+  *      None.
+ X+  *-----------------------------------------------------------------------
+ X+  *
+ X+  * void
+ X+  * vgaPopRead(p)
+ X+  * {
+ X+  *   (vgaSetWriteFunc)(writeseg);
+ X+  *   (vgaSetReadFunc)(readseg);
+ X+  * }
+ X+  */
+ X+ 	ALIGNTEXT4
+ X+ 	GLOBL	GLNAME(vgaPopRead)
+ X+ GLNAME(vgaPopRead):
+ X+ 	PUSH_L	(EDX)
+ X+ 	MOV_L	(CONTENT(GLNAME(writeseg)),EAX)
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetWriteFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	MOV_L	(CONTENT(GLNAME(readseg)),EAX)
+ X+ 	MOV_L	(CONTENT(GLNAME(vgaSetReadFunc)),EDX)
+ X+ 	CALL	(CODEPTR(EDX))
+ X+ 	POP_L	(EDX)
+ X+ 	RET
+ SHAR_EOF
+ chmod 0644 cleanup3.dif || echo "restore of cleanup3.dif fails"
+ sed 's/^X//' << 'SHAR_EOF' > cleanup4.dif &&
+ Xdiff -cr mit/server/ddx/x386/vga16/ibm.org/ppcIO.c mit/server/ddx/x386/vga16/ibm/ppcIO.c
+ X*** mit/server/ddx/x386/vga16/ibm.org/ppcIO.c	Mon Feb 28 20:23:34 1994
+ X--- mit/server/ddx/x386/vga16/ibm/ppcIO.c	Mon Feb 28 20:24:14 1994
+ X***************
+ X*** 110,125 ****
+ X  PixmapPtr samplePixmapPerDepth[1] = { 0 };
+ X  
+ X  void
+ X! Init16Output( pScreen, virtx, virty )
+ X      ScreenPtr pScreen;
+ X      int virtx, virty;
+ X  {
+ X    extern int defaultColorVisualClass;
+ X- #ifdef UNBANKED_VGA16
+ X    extern pointer vgaBase; /* GJAHACK */
+ X- #else
+ X-   extern pointer vgaVirtBase; /* GJAHACK */
+ X- #endif
+ X  
+ X    /*
+ X     * patch the original structures
+ X--- 110,124 ----
+ X  PixmapPtr samplePixmapPerDepth[1] = { 0 };
+ X  
+ X  void
+ X! Init16Output( pScreen, pbits, virtx, virty, dpix, dpiy, width )
+ X      ScreenPtr pScreen;
+ X+     pointer pbits; /* We assume that this is equal to vgaBase */
+ X      int virtx, virty;
+ X+     int dpix, dpiy;
+ X+     int width;
+ X  {
+ X    extern int defaultColorVisualClass;
+ X    extern pointer vgaBase; /* GJAHACK */
+ X  
+ X    /*
+ X     * patch the original structures
+ X***************
+ X*** 175,185 ****
+ X    if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
+ X  	return ;
+ X  
+ X! #ifdef UNBANKED_VGA16
+ X!   miScreenInit(pScreen, vgaBase, virtx, virty, 75, 75, virtx,
+ X! #else
+ X!   miScreenInit(pScreen, vgaVirtBase, virtx, virty, 75, 75, virtx,
+ X! #endif
+ X  	1, NUM_DEPTHS, vgaDepths, 0 /* See above */,
+ X  	NUM_VISUALS, vgaVisuals, NULL);
+ X    pScreen-> rootDepth = VGA_MAXPLANES;
+ X--- 174,180 ----
+ X    if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
+ X  	return ;
+ X  
+ X!   miScreenInit(pScreen, vgaBase, virtx, virty, dpix, dpiy, width,
+ X  	1, NUM_DEPTHS, vgaDepths, 0 /* See above */,
+ X  	NUM_VISUALS, vgaVisuals, NULL);
+ X    pScreen-> rootDepth = VGA_MAXPLANES;
+ Xdiff -cr mit/server/ddx/x386/vga16/ibm.org/vgaProcs.h mit/server/ddx/x386/vga16/ibm/vgaProcs.h
+ X*** mit/server/ddx/x386/vga16/ibm.org/vgaProcs.h	Mon Feb 28 20:23:34 1994
+ X--- mit/server/ddx/x386/vga16/ibm/vgaProcs.h	Mon Feb 28 20:24:15 1994
+ X***************
+ X*** 81,87 ****
+ X  /* vgaIO.c */
+ X  Bool vga16ScreenInit P_((register ScreenPtr pScreen));
+ X  Bool vgaScreenClose P_((register int index, register ScreenPtr pScreen));
+ X! void Init16Output P_((ScreenPtr pScreen, int virtx, int virty));
+ X  /* vgaImages.c */
+ X  void vgaDrawColorImage P_((int x, int y, register int w, register int h, register const unsigned char *data, register int RowIncrement, const int alu, const unsigned long int planes));
+ X  void vgaReadColorImage P_((int x, int y, int lx, int ly, register unsigned char *data, int RowIncrement));
+ X--- 81,87 ----
+ X  /* vgaIO.c */
+ X  Bool vga16ScreenInit P_((register ScreenPtr pScreen));
+ X  Bool vgaScreenClose P_((register int index, register ScreenPtr pScreen));
+ X! void Init16Output P_((ScreenPtr pScreen, pointer pbits, int virtx, int virty, int dpix, int dpiy, int width));
+ X  /* vgaImages.c */
+ X  void vgaDrawColorImage P_((int x, int y, register int w, register int h, register const unsigned char *data, register int RowIncrement, const int alu, const unsigned long int planes));
+ X  void vgaReadColorImage P_((int x, int y, int lx, int ly, register unsigned char *data, int RowIncrement));
+ Xdiff -cr mit/server/ddx/x386/vga16/ibm.org/vgaVideo.h mit/server/ddx/x386/vga16/ibm/vgaVideo.h
+ X*** mit/server/ddx/x386/vga16/ibm.org/vgaVideo.h	Mon Feb 28 20:23:35 1994
+ X--- mit/server/ddx/x386/vga16/ibm/vgaVideo.h	Mon Feb 28 20:24:15 1994
+ X***************
+ X*** 83,94 ****
+ X  
+ X  	/* GJA -- Connect IBM code with XFree86 */
+ X  extern pointer vgaBase;
+ X- #ifdef UNBANKED_VGA16
+ X  #define SCREEN_ADDR ((int)vgaBase)
+ X- #else
+ X- extern pointer vgaVirtBase;
+ X- #define SCREEN_ADDR ((int)vgaVirtBase)
+ X- #endif
+ X  
+ X  #define VIDEO_MEMORY_BASE ( (volatile unsigned char *) ( SCREEN_ADDR ) )
+ X  #define VIDBASE VIDEO_MEMORY_BASE
+ X--- 83,89 ----
+ SHAR_EOF
+ chmod 0644 cleanup4.dif || echo "restore of cleanup4.dif fails"
+ sed 's/^X//' << 'SHAR_EOF' > cleanup5.dif &&
+ X*** mit/server/ddx/x386/vga256/vga/vga.org	Sun Mar  6 22:05:02 1994
+ X--- mit/server/ddx/x386/vga256/vga/vga.c	Sun Mar  6 22:06:58 1994
+ X***************
+ X*** 550,556 ****
+ X--- 550,560 ----
+ X        vgaVirtBase = vgaBase;
+ X      }
+ X  #else
+ X+ #ifdef XF86VGA16
+ X+     vgaVirtBase = vgaBase;
+ X+ #else
+ X      vgaVirtBase = (pointer)VGABASE;
+ X+ #endif
+ X  #endif
+ X  
+ X      vgaReadBottom  = (void *)((unsigned int)vgaReadBottom
+ SHAR_EOF
+ chmod 0644 cleanup5.dif || echo "restore of cleanup5.dif fails"
+ exit 0
diff -c /dev/null mit/server/ddx/x386/vga16/doc/unbank.shar:2.0
*** /dev/null	Fri Mar 11 23:40:12 1994
--- mit/server/ddx/x386/vga16/doc/unbank.shar	Fri Mar 11 23:40:13 1994
***************
*** 0 ****
--- 1,74 ----
+ # The patches in this file are provided for informational purposes only, to 
+ # indicate what should be changed in order to build an unbanked server.
+ 
+ # They require, and should be applied AFTER the cleanup patches.
+ # (Which were late. Sorry.)
+ 
+ # Those patches may be out of date.
+ 
+ # Contents of the patches:
+ # unbank1.dif:
+ #    Patch the Imakefile in vga16/ibm to use the -DUNBANKED_VGA16 option.
+ # unbank2.dif:
+ #    Patch vga16/vga/vga.c to allow no greater virtuals than fit into one
+ #    bank.
+ 
+ # $XFree86: mit/server/ddx/x386/vga16/doc/unbank.shar,v 2.0 1994/03/03 12:46:28 dawes Exp $
+ 
+ #!/bin/sh
+ # shar:	Shell Archiver  (v1.22)
+ #
+ #	Run the following text with /bin/sh to create:
+ #	  unbank1.dif
+ #	  unbank2.dif
+ #
+ sed 's/^X//' << 'SHAR_EOF' > unbank1.dif &&
+ Xdiff -cr mit/server/ddx/x386/vga16/ibm.org/Imakefile mit/server/ddx/x386/vga16/ibm/Imakefile
+ X*** mit/server/ddx/x386/vga16/ibm.org/Imakefile	Mon Feb 28 20:34:10 1994
+ X--- mit/server/ddx/x386/vga16/ibm/Imakefile	Mon Feb 28 20:34:47 1994
+ X***************
+ X*** 31,39 ****
+ X  	ppcIO.o mfbfillarc.o mfbzerarc.o
+ X  
+ X  XCOMM This one is for unbanked vga16:
+ X! XCOMM DEFINES = -DUSE_PORTABLE_FAST_LINES -DXF86VGA16 -DUNBANKED_VGA16
+ X  XCOMM This one is for banked vga16
+ X! DEFINES = -DUSE_PORTABLE_FAST_LINES -DXF86VGA16
+ X  
+ X  INCLUDES = -I. -I../../../mi \
+ X  		-I../../vga2/mfb.banked -I../../vga256/vga -I../../../mfb \
+ X--- 31,39 ----
+ X  	ppcIO.o mfbfillarc.o mfbzerarc.o
+ X  
+ X  XCOMM This one is for unbanked vga16:
+ X! DEFINES = -DUSE_PORTABLE_FAST_LINES -DXF86VGA16 -DUNBANKED_VGA16
+ X  XCOMM This one is for banked vga16
+ X! XCOMM DEFINES = -DUSE_PORTABLE_FAST_LINES -DXF86VGA16
+ X  
+ X  INCLUDES = -I. -I../../../mi \
+ X  		-I../../vga2/mfb.banked -I../../vga256/vga -I../../../mfb \
+ SHAR_EOF
+ chmod 0644 unbank1.dif || echo "restore of unbank1.dif fails"
+ sed 's/^X//' << 'SHAR_EOF' > unbank2.dif &&
+ X*** mit/server/ddx/x386/vga256/vga/vga.c.org	Mon Feb 28 20:34:11 1994
+ X--- mit/server/ddx/x386/vga256/vga/vga.c	Mon Feb 28 20:34:53 1994
+ X***************
+ X*** 288,294 ****
+ X  	rounding = 32;
+ X  #else /* MONOVGA */
+ X  #ifdef XF86VGA16
+ X! 	needmem = vga256InfoRec.videoRam / 4 * 1024 * 8;
+ X  	rounding = 32;
+ X  #else
+ X  	needmem = vga256InfoRec.videoRam * 1024;
+ X--- 288,294 ----
+ X  	rounding = 32;
+ X  #else /* MONOVGA */
+ X  #ifdef XF86VGA16
+ X! 	needmem = Drivers[i]->ChipMapSize * 8;
+ X  	rounding = 32;
+ X  #else
+ X  	needmem = vga256InfoRec.videoRam * 1024;
+ SHAR_EOF
+ chmod 0644 unbank2.dif || echo "restore of unbank2.dif fails"
+ exit 0
diff -c /dev/null mit/server/ddx/x386/vga16/drivers/tvga8900/Imakefile:2.1
*** /dev/null	Fri Mar 11 23:40:15 1994
--- mit/server/ddx/x386/vga16/drivers/tvga8900/Imakefile	Fri Mar 11 23:40:15 1994
***************
*** 0 ****
--- 1,29 ----
+ XCOMM $XFree86: mit/server/ddx/x386/vga16/drivers/tvga8900/Imakefile,v 2.1 1994/02/23 14:18:21 dawes Exp $
+ XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:59:40 gildea Exp $
+ #include <Server.tmpl>
+ 
+ SRCS = driverT.c bankT.s
+ 
+ OBJS = driverT.o bankT.o
+ 
+ #if X386LinkKit
+ VGA256DIR = ../../vga256
+ INCLUDES = -I. -I../../../include -I../..
+ #else
+ INCLUDES = -I. -I../../../common -I../../../common_hw -I../../../os-support \
+            -I../../../vga256/vga -I$(SERVERSRC)/include -I$(INCLUDESRC)
+ VGA256DIR = ../../../vga256/drivers
+ #endif
+ 
+ DEFINES = -DXF86VGA16
+ 
+ NormalLibraryObjectRule()
+ 
+ NormalRelocatableTarget(tvga8900, $(OBJS))
+ 
+ ObjectFromSpecialSource(driverT,$(VGA256DIR)/tvga8900/driver,/**/)
+ ObjectFromSpecialAsmSource(bankT,$(VGA256DIR)/tvga8900/bank,/**/)
+ 
+ InstallLinkKitNonExecFile(Imakefile,$(LINKKITDIR)/drivers/vga16/tvga8900)
+ 
+ DependTarget()
diff -c mit/server/ddx/x386/vga16/ibm/Imakefile:2.0 mit/server/ddx/x386/vga16/ibm/Imakefile:2.2
*** mit/server/ddx/x386/vga16/ibm/Imakefile:2.0	Fri Mar 11 23:40:24 1994
--- mit/server/ddx/x386/vga16/ibm/Imakefile	Fri Mar 11 23:40:24 1994
***************
*** 1,36 ****
! XCOMM $XFree86: mit/server/ddx/x386/vga16/ibm/Imakefile,v 2.0 1993/08/19 16:08:22 dawes Exp $
  XCOMM Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/Imakefile,v 9.4 89/07/05 18:20:33 jeff Exp
  XCOMM Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/Imakefile,v
  
  #include <Server.tmpl>
  
! SRCS =	ppcArea.c ppcArc.c ppcBitmap.c ppcBStore.c \
  	ppcClip.c ppcCpArea.c ppcCReduce.c \
  	ppcCurs.c ppcDepth.c ppcFillRct.c ppcWindowFS.c \
  	ppcPixmapFS.c ppcGC.c ppcGetSp.c \
! 	ppcIO.c ppcImg.c ppcLine.c ppcPixmap.c ppcPntWin.c \
  	ppcPolyPnt.c ppcPolyRec.c ppcPushPxl.c ppcQuery.c ppcRot.c \
! 	ppcRslvC.c ppcSetSp.c ppcSinTab.c ppcWindow.c emulOpStip.c \
! 	emulStip.c emulRepAre.c emulTile.c \
! 	vgaData.c vgaIO.c vgaGC.c vgaOSD.c \
! 	vgaBitBlt.c vgaImages.c \
! 	vgaLine.c vgaStipple.c vgaSolid.c offscreen.c
  
! OBJS =	ppcArea.o ppcArc.o ppcBitmap.o ppcBStore.o \
  	ppcClip.o ppcCpArea.o ppcCReduce.o \
  	ppcCurs.o ppcDepth.o ppcFillRct.o ppcWindowFS.o \
  	ppcPixmapFS.o ppcGC.o ppcGetSp.o \
! 	ppcIO.o ppcImg.o ppcLine.o ppcPixmap.o ppcPntWin.o \
  	ppcPolyPnt.o ppcPolyRec.o ppcPushPxl.o ppcQuery.o ppcRot.o \
! 	ppcRslvC.o ppcSetSp.o ppcSinTab.o ppcWindow.o emulOpStip.o \
! 	emulStip.o emulRepAre.o emulTile.o \
! 	vgaData.o vgaIO.o vgaGC.o vgaOSD.o vgaBitBlt.o vgaImages.o \
! 	vgaLine.o vgaStipple.o vgaSolid.o offscreen.o
  
  DEFINES = -DUSE_PORTABLE_FAST_LINES -DXF86VGA16
  
! INCLUDES = -I. -I../../../mi -I../../../mfb -I../../../../include \
! 		-I$(INCLUDESRC) -I../../common -I../../../../include/old
  
  NormalLibraryObjectRule()
  SubdirLibraryRule($(OBJS))
--- 1,45 ----
! XCOMM $XFree86: mit/server/ddx/x386/vga16/ibm/Imakefile,v 2.2 1994/02/25 15:02:45 dawes Exp $
  XCOMM Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/Imakefile,v 9.4 89/07/05 18:20:33 jeff Exp
  XCOMM Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/Imakefile,v
  
  #include <Server.tmpl>
  
! SRCS =	ppcArea.c ppcBitmap.c ppcBStore.c \
  	ppcClip.c ppcCpArea.c ppcCReduce.c \
  	ppcCurs.c ppcDepth.c ppcFillRct.c ppcWindowFS.c \
  	ppcPixmapFS.c ppcGC.c ppcGetSp.c \
! 	ppcImg.c ppcLine.c ppcPixmap.c ppcPntWin.c \
  	ppcPolyPnt.c ppcPolyRec.c ppcPushPxl.c ppcQuery.c ppcRot.c \
! 	ppcRslvC.c ppcSetSp.c ppcWindow.c emulOpStip.c \
! 	emulRepAre.c emulTile.c \
! 	vgaGC.c vgaBitBlt.c vgaImages.c \
! 	vgaLine.c vgaStipple.c vgaSolid.c offscreen.c \
! 	mfbimggblt.c wm3.c \
! 	ppcIO.c mfbfillarc.c mfbzerarc.c
  
! OBJS =	ppcArea.o ppcBitmap.o ppcBStore.o \
  	ppcClip.o ppcCpArea.o ppcCReduce.o \
  	ppcCurs.o ppcDepth.o ppcFillRct.o ppcWindowFS.o \
  	ppcPixmapFS.o ppcGC.o ppcGetSp.o \
! 	ppcImg.o ppcLine.o ppcPixmap.o ppcPntWin.o \
  	ppcPolyPnt.o ppcPolyRec.o ppcPushPxl.o ppcQuery.o ppcRot.o \
! 	ppcRslvC.o ppcSetSp.o ppcWindow.o emulOpStip.o \
! 	emulRepAre.o emulTile.o \
! 	vgaGC.o vgaBitBlt.o vgaImages.o \
! 	vgaLine.o vgaStipple.o vgaSolid.o offscreen.o \
! 	mfbimggblt.o wm3.o \
! 	ppcIO.o mfbfillarc.o mfbzerarc.o
  
+ XCOMM This one is for unbanked vga16:
+ XCOMM DEFINES = -DUSE_PORTABLE_FAST_LINES -DXF86VGA16 -DUNBANKED_VGA16
+ XCOMM This one is for banked vga16
  DEFINES = -DUSE_PORTABLE_FAST_LINES -DXF86VGA16
  
! INCLUDES = -I. -I../../../mi \
! 		-I../../vga2/mfb.banked -I../../vga256/vga -I../../../mfb \
! 		-I../../../../include \
! 		-I$(FONTSRC)/include -I$(INCLUDESRC) \
! 		-I../../common -I../../../../include/old
  
  NormalLibraryObjectRule()
  SubdirLibraryRule($(OBJS))
diff -c mit/server/ddx/x386/vga16/ibm/OScompiler.h:2.2 mit/server/ddx/x386/vga16/ibm/OScompiler.h:2.3
*** mit/server/ddx/x386/vga16/ibm/OScompiler.h:2.2	Fri Mar 11 23:40:24 1994
--- mit/server/ddx/x386/vga16/ibm/OScompiler.h	Fri Mar 11 23:40:24 1994
***************
*** 20,26 ****
   * SOFTWARE.
   *
  */
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/OScompiler.h,v 2.2 1993/10/02 16:08:18 dawes Exp $ */
  /* "@(#)compiler.h	3.1 88/09/22 09:31:34" */
  #ifndef __COMPILER_DEPENDANCIES__
  #define __COMPILER_DEPENDANCIES__
--- 20,26 ----
   * SOFTWARE.
   *
  */
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/OScompiler.h,v 2.3 1994/02/01 13:54:00 dawes Exp $ */
  /* "@(#)compiler.h	3.1 88/09/22 09:31:34" */
  #ifndef __COMPILER_DEPENDANCIES__
  #define __COMPILER_DEPENDANCIES__
***************
*** 38,45 ****
--- 38,116 ----
  #define MIN(a,b) (((a)<(b))?(a):(b))
  #define ABS(x) (((x)>0)?(x):-(x))
  
+ #include "misc.h"
  #include "compiler.h"
+ #include "../vga/vgaBank.h"
  
+ #ifdef UNBANKED_VGA16
+ 
+ #define VSETR(x)
+ #define VSETW(x)
+ #define VSETRW(x)
+ #define VCHECKRO(x)
+ #define VCHECKRU(x)
+ #define VCHECKWO(x)
+ #define VCHECKWU(x)
+ #define VCHECKRWO(x)
+ #define VCHECKRWU(x)
+ #define VCHECKRWONEXT(x)
+ #define VPUSHR()
+ #define VPOPR()
+ 
+ #define ADDR(x,y) {(x) += (y);}
+ #define ADDW(x,y) {(x) += (y);}
+ #define ADDRW(x,y) {(x) += (y);}
+ #define VINCR(x) {(x)++;}
+ #define VINCW(x) {(x)++;}
+ #define VINCRW(x) {(x)++;}
+ #define VDECR(x) {(x)--;}
+ #define VDECW(x) {(x)--;}
+ #define VDECRW(x) {(x)--;}
+ 
+ #else /* UNBANKED_VGA16 */
+ 
+ /* GJA -- This are equivalents of the SETR... macros, but omitting
+  * the vgaReadFlag/vgaWriteFlag. We know for sure that they are always
+  * applied to windows. If they by accident aren't, the results are useless
+  * anyway: A planar VGA does not look like a packed pixmap.
+  */
+ /* GJA -- Actually, they are added because I have not yet tidied up
+  * my include file structure (mfb/mfb.banked). Be careful or it will break.
+  */
+ #define VSETR(x)  { x = vgaSetRead(x); }
+ #define VSETW(x)  { x = vgaSetWrite(x); }
+ #define VSETRW(x) { x = vgaSetReadWrite(x); }
+ #define VCHECKRO(x) { if(((void *)x >= vgaReadTop)) \
+ 			 x = vgaReadNext(x); }
+ #define VCHECKRU(x) { if(((void *)x < vgaReadBottom)) \
+ 			 x = vgaReadPrev(x); }
+ #define VCHECKWO(x) { if(((void *)x >= vgaWriteTop)) \
+ 			 x = vgaWriteNext(x); }
+ #define VCHECKWU(x) { if(((void *)x < vgaWriteBottom)) \
+ 			 x = vgaWritePrev(x); }
+ #define VCHECKRWO(x) { if(((void *)x >= vgaWriteTop)) \
+ 			  x = vgaReadWriteNext(x); }
+ #define VCHECKRWU(x) { if(((void *)x < vgaWriteBottom)) \
+ 			  x = vgaReadWritePrev(x); }
+ #define VCHECKRWONEXT(x) { x++; VCHECKRWO(x); x--; }
+ #define VPUSHR()         { vgaPushRead(); }
+ #define VPOPR()          { vgaPopRead(); }
+ 
+ #define ADDR(x,y) {(x) += (y); if ((y) > 0) {VCHECKRO(x) }else{ VCHECKRU(x); }}
+ #define ADDW(x,y) {(x) += (y); if ((y) > 0) {VCHECKWO(x) }else{ VCHECKWU(x); }}
+ #define ADDRW(x,y) {(x) += (y); if ((y) > 0) {VCHECKRWO(x) }else{ VCHECKRWU(x); }}
+ #define VINCR(x) {(x)++; VCHECKRO(x); }
+ #define VINCW(x) {(x)++; VCHECKWO(x); }
+ #define VINCRW(x) {(x)++; VCHECKRWO(x); }
+ #define VDECR(x) {(x)--; VCHECKRU(x); }
+ #define VDECW(x) {(x)--; VCHECKWU(x); }
+ #define VDECRW(x) {(x)--; VCHECKRWU(x); }
+ #endif /* ! UNBANKED_VGA16 */
+ 
+ #define VMAPR(x) x
+ #define VMAPW(x) x
+ #define VMAPRW(x) x
+   
  #ifdef lint
  /* So that lint doesn't complain about constructs it doesn't understand */
  #ifdef volatile
diff -c mit/server/ddx/x386/vga16/ibm/emulOpStip.c:2.0 mit/server/ddx/x386/vga16/ibm/emulOpStip.c:2.1
*** mit/server/ddx/x386/vga16/ibm/emulOpStip.c:2.0	Fri Mar 11 23:40:25 1994
--- mit/server/ddx/x386/vga16/ibm/emulOpStip.c	Fri Mar 11 23:40:25 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulOpStip.c,v 2.0 1993/08/19 16:08:24 dawes Exp $ */
  
  /* ppc OpaqueStipple
   *
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulOpStip.c,v 2.1 1994/02/01 13:54:01 dawes Exp $ */
  
  /* ppc OpaqueStipple
   *
***************
*** 34,39 ****
--- 34,40 ----
  #include "pixmapstr.h"
  #include "scrnintstr.h"
  
+ #include "windowstr.h"	/* GJA */
  #include "ppc.h"
  #include "OScompiler.h"
  #include "ibmTrace.h"
***************
*** 58,64 ****
  	case GXclear:		/* 0x0 Zero 0 */
  	case GXset:		/* 0xf 1 */
   	    /* Foreground And Background Are Both The Same !! */
! 	    (* devPriv->solidFill )( bg, alu, planes, x, y, w, h ) ;
  	case GXnoop:		/* 0x5 dst */
  	    break ;
  	case GXcopy:		/* 0x3 src */
--- 59,65 ----
  	case GXclear:		/* 0x0 Zero 0 */
  	case GXset:		/* 0xf 1 */
   	    /* Foreground And Background Are Both The Same !! */
! 	    vgaFillSolid( bg, alu, planes, x, y, w, h ) ;
  	case GXnoop:		/* 0x5 dst */
  	    break ;
  	case GXcopy:		/* 0x3 src */
***************
*** 72,86 ****
  		vtarget = MIN( h, pStipple->drawable.height ) ;
  
  		/* First The Background */
! 		(* devPriv->solidFill)( bg, alu, planes, x, y,
  					htarget, vtarget ) ;
  		/* Then The Foreground */
! 		(* devPriv->stipFill)( pStipple, fg, alu, planes,
  				       x, y, htarget, vtarget,
  				       xSrc, ySrc ) ;
  
  		/* Here We Double The Size Of The BLIT Each Iteration */
! 		(* devPriv->replicateArea)( x, y, planes, w, h,
  					    htarget, vtarget,
  					    pStipple->drawable.pScreen ) ;
  	    }
--- 73,87 ----
  		vtarget = MIN( h, pStipple->drawable.height ) ;
  
  		/* First The Background */
! 		vgaFillSolid( bg, alu, planes, x, y,
  					htarget, vtarget ) ;
  		/* Then The Foreground */
! 		vgaFillStipple( pStipple, fg, alu, planes,
  				       x, y, htarget, vtarget,
  				       xSrc, ySrc ) ;
  
  		/* Here We Double The Size Of The BLIT Each Iteration */
! 		ppcReplicateArea( x, y, planes, w, h,
  					    htarget, vtarget,
  					    pStipple->drawable.pScreen ) ;
  	    }
***************
*** 88,94 ****
  	default:
  	/* Hard Cases -- i.e. Final Result DOES Depend On Initial Dest. */
  	    { /* Do The Background */
- 		register void (*fnp)() = devPriv->stipFill ;
  		register int i, j;
  		register PixmapPtr pInvPixmap = ppcCopyPixmap( pStipple ) ;
  		register unsigned char *data = pInvPixmap->devPrivate.ptr ;
--- 89,94 ----
***************
*** 98,107 ****
  			for ( j = pInvPixmap->devKind ; j-- ; data++ )
  				*data = ~ ( *data ) ;
  
! 	        (*fnp)( pInvPixmap, bg, alu, planes, x, y, w, h, xSrc, ySrc );
  	        mfbDestroyPixmap( pInvPixmap ) ;
  	        /* DO FOREGROUND */
! 	        (*fnp)( pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc );
  	    }
  	break ;
      }
--- 98,107 ----
  			for ( j = pInvPixmap->devKind ; j-- ; data++ )
  				*data = ~ ( *data ) ;
  
! 	        vgaFillStipple( pInvPixmap, bg, alu, planes, x, y, w, h, xSrc, ySrc );
  	        mfbDestroyPixmap( pInvPixmap ) ;
  	        /* DO FOREGROUND */
! 	        vgaFillStipple( pStipple, fg, alu, planes, x, y, w, h, xSrc, ySrc );
  	    }
  	break ;
      }
diff -c mit/server/ddx/x386/vga16/ibm/emulRepAre.c:2.0 mit/server/ddx/x386/vga16/ibm/emulRepAre.c:2.1
*** mit/server/ddx/x386/vga16/ibm/emulRepAre.c:2.0	Fri Mar 11 23:40:25 1994
--- mit/server/ddx/x386/vga16/ibm/emulRepAre.c	Fri Mar 11 23:40:25 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulRepAre.c,v 2.0 1993/08/19 16:08:25 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRepArea.c,v 9.1 88/10/24 04:01:09 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRepArea.c,v */
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulRepAre.c,v 2.1 1994/02/01 13:54:02 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRepArea.c,v 9.1 88/10/24 04:01:09 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRepArea.c,v */
  
***************
*** 35,40 ****
--- 35,41 ----
  #include "screenint.h"
  #include "pixmapstr.h"
  #include "pixmap.h"
+ #include "windowstr.h"	/* GJA */
  #include "ppc.h"
  
  void ppcReplicateArea( x, y, planeMask, goalWidth, goalHeight,
***************
*** 44,62 ****
  int currentHoriz, currentVert ;
  ScreenPtr pScrn ;
  {
- register void (*bitBlitFunction)() =
- 		( (ppcScrnPriv *) pScrn->devPrivate )->blit ;
- 
  	for ( ;
  	      currentHoriz <= ( goalWidth >> 1 ) ;
  	      currentHoriz <<= 1 ) {
! 		(*bitBlitFunction)( GXcopy, planeMask, planeMask,
  			x, y,
  			x + currentHoriz, y,
  			currentHoriz, currentVert ) ;
  	}
  	if ( goalWidth - currentHoriz )
! 		(*bitBlitFunction)( GXcopy, planeMask, planeMask,
  			x, y,
  			x + currentHoriz, y,
  			goalWidth - currentHoriz, currentVert ) ;
--- 45,60 ----
  int currentHoriz, currentVert ;
  ScreenPtr pScrn ;
  {
  	for ( ;
  	      currentHoriz <= ( goalWidth >> 1 ) ;
  	      currentHoriz <<= 1 ) {
! 		vgaBitBlt( GXcopy, planeMask, planeMask,
  			x, y,
  			x + currentHoriz, y,
  			currentHoriz, currentVert ) ;
  	}
  	if ( goalWidth - currentHoriz )
! 		vgaBitBlt( GXcopy, planeMask, planeMask,
  			x, y,
  			x + currentHoriz, y,
  			goalWidth - currentHoriz, currentVert ) ;
***************
*** 63,75 ****
  	for ( ;
  	      currentVert <= ( goalHeight >> 1 ) ;
  	      currentVert <<= 1 ) {
! 		(*bitBlitFunction)( GXcopy, planeMask, planeMask,
  			x, y,
  			x, y + currentVert,
  			goalWidth, currentVert ) ;
  	}
  	if ( goalHeight - currentVert )
! 		(*bitBlitFunction)( GXcopy, planeMask, planeMask,
  			x, y,
  			x, y + currentVert,
  			goalWidth, goalHeight - currentVert ) ;
--- 61,73 ----
  	for ( ;
  	      currentVert <= ( goalHeight >> 1 ) ;
  	      currentVert <<= 1 ) {
! 		vgaBitBlt( GXcopy, planeMask, planeMask,
  			x, y,
  			x, y + currentVert,
  			goalWidth, currentVert ) ;
  	}
  	if ( goalHeight - currentVert )
! 		vgaBitBlt( GXcopy, planeMask, planeMask,
  			x, y,
  			x, y + currentVert,
  			goalWidth, goalHeight - currentVert ) ;
diff -c mit/server/ddx/x386/vga16/ibm/emulStip.c:2.0 mit/server/ddx/x386/vga16/ibm/emulStip.c:2.1
*** mit/server/ddx/x386/vga16/ibm/emulStip.c:2.0	Fri Mar 11 23:40:26 1994
--- mit/server/ddx/x386/vga16/ibm/emulStip.c	Fri Mar 11 23:40:26 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulStip.c,v 2.0 1993/08/19 16:08:26 dawes Exp $ */
  
  /* ppc Stipple
   *
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulStip.c,v 2.1 1994/02/01 13:54:03 dawes Exp $ */
  
  /* ppc Stipple
   *
***************
*** 47,53 ****
  int x, y, w, h ;
  int xSrc, ySrc ;
  {
- register void	(*fnp)() ;
  register char 	*data ;
  register int 	htarget, vtarget, tlx, tly ;
  PixmapPtr 	pUseStipple, pTmpStipple ;
--- 47,52 ----
***************
*** 86,92 ****
      savehcount = w / tlx ;
      savevcount = h / tly ;
  
-     fnp = ((ppcScrnPriv *)(pStipple->drawable.pScreen->devPrivate) )->monoFill ;
  /* FIRST DO COMPLETELY VISIBLE PORTIONS */
      data = (char *) pUseStipple->devPrivate.ptr ;
      for ( vcount = savevcount, vtarget = y ;
--- 85,90 ----
***************
*** 95,101 ****
  	for ( htarget = x, hcount = savehcount ;
  	      hcount-- ;
  	      htarget += tlx )
! 		(*fnp)( data, htarget, vtarget, tlx, tly, fg, merge, planes ) ;
  
  /* NOW DO RIGHT HAND SIDE */
      if ( Rtlx = w % tlx ) {
--- 93,99 ----
  	for ( htarget = x, hcount = savehcount ;
  	      hcount-- ;
  	      htarget += tlx )
! 		vgaDrawMonoImage( data, htarget, vtarget, tlx, tly, fg, merge, planes ) ;
  
  /* NOW DO RIGHT HAND SIDE */
      if ( Rtlx = w % tlx ) {
***************
*** 106,112 ****
  		for ( vcount = savevcount, vtarget = y ;
  	      		vcount-- ;
  	      		vtarget += tly )
! 				(*fnp)( data, htarget, vtarget, 
  					Rtlx, tly, fg, merge, planes ) ;
  	   else
  		for ( vcount = savevcount, vtarget = y ;
--- 104,110 ----
  		for ( vcount = savevcount, vtarget = y ;
  	      		vcount-- ;
  	      		vtarget += tly )
! 				vgaDrawMonoImage( data, htarget, vtarget, 
  					Rtlx, tly, fg, merge, planes ) ;
  	   else
  		for ( vcount = savevcount, vtarget = y ;
***************
*** 116,122 ****
  			int tvtarget = vtarget ;
  			unsigned char *tdata = data ;
  			while ( th-- ) {
! 				(*fnp)( tdata, htarget, tvtarget++, 
  					Rtlx, 1, fg, merge, planes ) ;
  				tdata += pStipple->devKind ;
  			}
--- 114,120 ----
  			int tvtarget = vtarget ;
  			unsigned char *tdata = data ;
  			while ( th-- ) {
! 				vgaDrawMonoImage( tdata, htarget, tvtarget++, 
  					Rtlx, 1, fg, merge, planes ) ;
  				tdata += pStipple->devKind ;
  			}
***************
*** 129,135 ****
  	for ( hcount = savehcount, htarget = x ;
        		hcount-- ;
        		htarget += tlx )
! 		(*fnp)( data, htarget, vtarget, tlx, Btly, fg, merge, planes ) ;
  
  /* NOW DO BOTTOM RIGHT CORNER */
      if ( Btly && Rtlx )
--- 127,133 ----
  	for ( hcount = savehcount, htarget = x ;
        		hcount-- ;
        		htarget += tlx )
! 		vgaDrawMonoImage( data, htarget, vtarget, tlx, Btly, fg, merge, planes ) ;
  
  /* NOW DO BOTTOM RIGHT CORNER */
      if ( Btly && Rtlx )
***************
*** 136,145 ****
  	/* htarget is already set to ( x + ( savehcount * tlx ) ) from above */
  	/* vtarget is already set to ( x + ( savevcount * tly ) ) from above */
  	if (xfits)
! 		(*fnp)( data, htarget, vtarget, Rtlx, Btly, fg, merge, planes) ;
  	else
  		while ( Btly-- ) {
! 			(*fnp)( data, htarget, vtarget++, 
  				Rtlx, 1, fg, merge, planes ) ;
  			data += pStipple->devKind ;
  		}
--- 134,143 ----
  	/* htarget is already set to ( x + ( savehcount * tlx ) ) from above */
  	/* vtarget is already set to ( x + ( savevcount * tly ) ) from above */
  	if (xfits)
! 		vgaDrawMonoImage( data, htarget, vtarget, Rtlx, Btly, fg, merge, planes) ;
  	else
  		while ( Btly-- ) {
! 			vgaDrawMonoImage( data, htarget, vtarget++, 
  				Rtlx, 1, fg, merge, planes ) ;
  			data += pStipple->devKind ;
  		}
diff -c mit/server/ddx/x386/vga16/ibm/emulTile.c:2.0 mit/server/ddx/x386/vga16/ibm/emulTile.c:2.1
*** mit/server/ddx/x386/vga16/ibm/emulTile.c:2.0	Fri Mar 11 23:40:26 1994
--- mit/server/ddx/x386/vga16/ibm/emulTile.c	Fri Mar 11 23:40:26 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulTile.c,v 2.0 1993/08/19 16:08:27 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/emulTile.c,v 30.0 89/01/23 19:28:31 paul Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/emulTile.c,v */
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/emulTile.c,v 2.1 1994/02/01 13:54:05 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/emulTile.c,v 30.0 89/01/23 19:28:31 paul Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/emulTile.c,v */
  
***************
*** 41,48 ****
  
  #include "OScompiler.h"
  
! #include "ppcGCstr.h"
! #include "ppcScrn.h"
  
  #include "ibmTrace.h"
  
--- 41,50 ----
  
  #include "OScompiler.h"
  
! /* #include "ppcGCstr.h" */
! #include "windowstr.h"	/* GJA */
! /* #include "ppcScrn.h" */
! #include "ppc.h"	/* GJA */
  
  #include "ibmTrace.h"
  
***************
*** 49,59 ****
  extern void ErrorF() ;
  
  static void
! DrawFirstTile( pTile, x, y, fnp, w, h, alu, planes, xOffset, yOffset )
  register PixmapPtr pTile ;
  register int x ;
  register int y ;
- register void (* fnp)() ;
  int w ;
  int h ;
  int alu ;
--- 51,60 ----
  extern void ErrorF() ;
  
  static void
! DrawFirstTile( pTile, x, y, w, h, alu, planes, xOffset, yOffset )
  register PixmapPtr pTile ;
  register int x ;
  register int y ;
  int w ;
  int h ;
  int alu ;
***************
*** 69,75 ****
  			htarget = MIN( pTile->drawable.width - xOffset, w ),
  			vtarget = MIN( pTile->drawable.height - yOffset, h ),
  			yOffset *= pTile->devKind ;
! 			(* fnp)( x, y,
  				 htarget,
  				 vtarget,
  				 pTile->devPrivate.ptr + yOffset + xOffset,
--- 70,76 ----
  			htarget = MIN( pTile->drawable.width - xOffset, w ),
  			vtarget = MIN( pTile->drawable.height - yOffset, h ),
  			yOffset *= pTile->devKind ;
! 			vgaDrawColorImage( x, y,
  				 htarget,
  				 vtarget,
  				 pTile->devPrivate.ptr + yOffset + xOffset,
***************
*** 79,97 ****
  				w = MIN( w, pTile->drawable.width ) ;
  				if ( h > vtarget ) {
  					h = MIN( h, pTile->drawable.height ) ;
! 					(* fnp)( x, y + vtarget,
  						 htarget,
  						 h - vtarget,
  						 pTile->devPrivate.ptr + xOffset,
  						 pTile->devKind,
  						 alu, planes ) ;
! 					(* fnp)( x + htarget, y,
  						 w - htarget,
  						 vtarget,
  						 pTile->devPrivate.ptr + yOffset,
  						 pTile->devKind,
  						 alu, planes ) ;
! 					(* fnp)( x + htarget,
  						 y + vtarget,
  						 w - htarget,
  						 h - vtarget,
--- 80,98 ----
  				w = MIN( w, pTile->drawable.width ) ;
  				if ( h > vtarget ) {
  					h = MIN( h, pTile->drawable.height ) ;
! 					vgaDrawColorImage( x, y + vtarget,
  						 htarget,
  						 h - vtarget,
  						 pTile->devPrivate.ptr + xOffset,
  						 pTile->devKind,
  						 alu, planes ) ;
! 					vgaDrawColorImage( x + htarget, y,
  						 w - htarget,
  						 vtarget,
  						 pTile->devPrivate.ptr + yOffset,
  						 pTile->devKind,
  						 alu, planes ) ;
! 					vgaDrawColorImage( x + htarget,
  						 y + vtarget,
  						 w - htarget,
  						 h - vtarget,
***************
*** 100,106 ****
  						 alu, planes ) ;
  				}
  				else { /* h <= vtarget */
! 					(* fnp)( x + htarget, y,
  						 w - htarget,
  						 vtarget,
  						 pTile->devPrivate.ptr + yOffset,
--- 101,107 ----
  						 alu, planes ) ;
  				}
  				else { /* h <= vtarget */
! 					vgaDrawColorImage( x + htarget, y,
  						 w - htarget,
  						 vtarget,
  						 pTile->devPrivate.ptr + yOffset,
***************
*** 109,115 ****
  				}
  			}
  			else if ( h > vtarget ) {
! 				(* fnp)( x, y + vtarget,
  					 htarget,
  					 MIN( h, pTile->drawable.height ) - vtarget,
  					 pTile->devPrivate.ptr + xOffset,
--- 110,116 ----
  				}
  			}
  			else if ( h > vtarget ) {
! 				vgaDrawColorImage( x, y + vtarget,
  					 htarget,
  					 MIN( h, pTile->drawable.height ) - vtarget,
  					 pTile->devPrivate.ptr + xOffset,
***************
*** 119,125 ****
  			}
  		}
  		else { /* No Y Offset */
! 			(* fnp)( x, y,
  				 htarget = MIN( pTile->drawable.width - xOffset, w ),
  				 vtarget = MIN( pTile->drawable.height, h ),
  				 pTile->devPrivate.ptr + xOffset,
--- 120,126 ----
  			}
  		}
  		else { /* No Y Offset */
! 			vgaDrawColorImage( x, y,
  				 htarget = MIN( pTile->drawable.width - xOffset, w ),
  				 vtarget = MIN( pTile->drawable.height, h ),
  				 pTile->devPrivate.ptr + xOffset,
***************
*** 126,132 ****
  				 pTile->devKind,
  				 alu, planes ) ;
  			if ( w > htarget ) {
! 				(* fnp)( x + htarget, y,
  					 MIN( pTile->drawable.width, w ) - htarget,
  					 vtarget,
  					 pTile->devPrivate.ptr,
--- 127,133 ----
  				 pTile->devKind,
  				 alu, planes ) ;
  			if ( w > htarget ) {
! 				vgaDrawColorImage( x + htarget, y,
  					 MIN( pTile->drawable.width, w ) - htarget,
  					 vtarget,
  					 pTile->devPrivate.ptr,
***************
*** 136,142 ****
  		}
  	}
  	else if ( yOffset ) {
! 		(* fnp)( x, y,
  			 htarget = MIN( pTile->drawable.width, w ),
  			 vtarget = MIN( pTile->drawable.height - yOffset, h ),
  			 pTile->devPrivate.ptr + ( yOffset * pTile->devKind ),
--- 137,143 ----
  		}
  	}
  	else if ( yOffset ) {
! 		vgaDrawColorImage( x, y,
  			 htarget = MIN( pTile->drawable.width, w ),
  			 vtarget = MIN( pTile->drawable.height - yOffset, h ),
  			 pTile->devPrivate.ptr + ( yOffset * pTile->devKind ),
***************
*** 143,149 ****
  			 pTile->devKind,
  			 alu, planes ) ;
  		if ( h > vtarget ) {
! 			(* fnp)( x, y + vtarget,
  				 htarget,
  				 MIN( pTile->drawable.height, h ) - vtarget,
  				 pTile->devPrivate.ptr,
--- 144,150 ----
  			 pTile->devKind,
  			 alu, planes ) ;
  		if ( h > vtarget ) {
! 			vgaDrawColorImage( x, y + vtarget,
  				 htarget,
  				 MIN( pTile->drawable.height, h ) - vtarget,
  				 pTile->devPrivate.ptr,
***************
*** 152,158 ****
  		}
  	}
  	else { /* NO Offset */
! 		(* fnp)( x, y,
  			 htarget = MIN( pTile->drawable.width, w ),
  			 vtarget = MIN( pTile->drawable.height, h ),
  			 pTile->devPrivate.ptr,
--- 153,159 ----
  		}
  	}
  	else { /* NO Offset */
! 		vgaDrawColorImage( x, y,
  			 htarget = MIN( pTile->drawable.width, w ),
  			 vtarget = MIN( pTile->drawable.height, h ),
  			 pTile->devPrivate.ptr,
***************
*** 189,195 ****
  int xSrc ;
  int ySrc ;
  {
- register void (*fnp)() ;
  ScreenPtr pScreen ;
  int xOffset ;
  int yOffset ;
--- 190,195 ----
***************
*** 203,209 ****
  	case GXclear:		/* 0x0 Zero 0 */
  	case GXinvert:		/* 0xa NOT dst */
  	case GXset:		/* 0xf 1 */
! 		(* ( ( (ppcScrnPriv *) (pScreen->devPrivate) )->solidFill ) )
  			( 0xFF, alu, planes, x0, y0, w, h ) ;
  	case GXnoop:		/* 0x5 dst */
  		return ;
--- 203,209 ----
  	case GXclear:		/* 0x0 Zero 0 */
  	case GXinvert:		/* 0xa NOT dst */
  	case GXset:		/* 0xf 1 */
! 		vgaFillSolid
  			( 0xFF, alu, planes, x0, y0, w, h ) ;
  	case GXnoop:		/* 0x5 dst */
  		return ;
***************
*** 225,240 ****
  	yOffset = height - (( - yOffset ) % height ) ;
      if ( yOffset == height ) yOffset = 0; /* For else case */
  
-      fnp = ( (ppcScrnPriv *) (pScreen->devPrivate) )->imageFill ;
- 
       switch ( alu ) {
  	case GXcopyInverted:	/* 0xc NOT src */
  	case GXcopy:		/* 0x3 src */
  		/* Special Case Code */
! 		DrawFirstTile( pTile, x0, y0, fnp, w, h,
  			       alu, planes, xOffset, yOffset ) ;
  		/* Here We Double The Size Of The BLIT Each Iteration */
! 		(* ( (ppcScrnPriv *) ( pScreen->devPrivate ) )->replicateArea)(
  			    x0, y0, planes, w, h,
  			    MIN( w, pTile->drawable.width ), MIN( h, pTile->drawable.height ), pScreen ) ;
  		break ;
--- 225,238 ----
  	yOffset = height - (( - yOffset ) % height ) ;
      if ( yOffset == height ) yOffset = 0; /* For else case */
  
       switch ( alu ) {
  	case GXcopyInverted:	/* 0xc NOT src */
  	case GXcopy:		/* 0x3 src */
  		/* Special Case Code */
! 		DrawFirstTile( pTile, x0, y0, w, h,
  			       alu, planes, xOffset, yOffset ) ;
  		/* Here We Double The Size Of The BLIT Each Iteration */
! 		ppcReplicateArea(
  			    x0, y0, planes, w, h,
  			    MIN( w, pTile->drawable.width ), MIN( h, pTile->drawable.height ), pScreen ) ;
  		break ;
***************
*** 282,288 ****
  		/* Draw top margin, including corners */
  		if ( topmgn ) {
  			if ( leftmgn ) {
! 				(* fnp)( x0, y0, leftmgn, topmgn,
  					 data + yOffset + xOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
--- 280,286 ----
  		/* Draw top margin, including corners */
  		if ( topmgn ) {
  			if ( leftmgn ) {
! 				vgaDrawColorImage( x0, y0, leftmgn, topmgn,
  					 data + yOffset + xOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
***************
*** 290,301 ****
  				xcount ;
  				xcount--, htarget += width )
  			{
! 				(* fnp)( htarget, y0, width, topmgn,
  					 data + yOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
  			if ( rightmgn ) {
! 				(* fnp)( x2, y0, rightmgn, topmgn,
  					 data + yOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
--- 288,299 ----
  				xcount ;
  				xcount--, htarget += width )
  			{
! 				vgaDrawColorImage( htarget, y0, width, topmgn,
  					 data + yOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
  			if ( rightmgn ) {
! 				vgaDrawColorImage( x2, y0, rightmgn, topmgn,
  					 data + yOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
***************
*** 304,310 ****
  		/* Draw bottom margin, including corners */
  		if ( botmgn ) {
  			if ( leftmgn ) {
! 				(* fnp)( x0, y2, leftmgn, botmgn,
  					 data + xOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
--- 302,308 ----
  		/* Draw bottom margin, including corners */
  		if ( botmgn ) {
  			if ( leftmgn ) {
! 				vgaDrawColorImage( x0, y2, leftmgn, botmgn,
  					 data + xOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
***************
*** 312,323 ****
  				xcount ;
  				xcount--, htarget += width )
  			{
! 				(* fnp)( htarget, y2, width, botmgn,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  			}
  			if ( rightmgn ) {
! 				(* fnp)( x2, y2, rightmgn, botmgn,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  			}
--- 310,321 ----
  				xcount ;
  				xcount--, htarget += width )
  			{
! 				vgaDrawColorImage( htarget, y2, width, botmgn,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  			}
  			if ( rightmgn ) {
! 				vgaDrawColorImage( x2, y2, rightmgn, botmgn,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  			}
***************
*** 329,335 ****
  				ycount ;
  				ycount--, vtarget += height )
  			{
! 				(* fnp)( x0, vtarget, leftmgn, height,
  					 data + xOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
--- 327,333 ----
  				ycount ;
  				ycount--, vtarget += height )
  			{
! 				vgaDrawColorImage( x0, vtarget, leftmgn, height,
  					 data + xOffset,
  					 pTile->devKind, alu, planes ) ;
  			}
***************
*** 341,347 ****
  				ycount ;
  				ycount--, vtarget += height )
  			{
! 				(* fnp)( x2, vtarget, rightmgn, height,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  			}
--- 339,345 ----
  				ycount ;
  				ycount--, vtarget += height )
  			{
! 				vgaDrawColorImage( x2, vtarget, rightmgn, height,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  			}
***************
*** 356,362 ****
  				xcount ;
  				xcount--, htarget += width )
  			{
! 				(* fnp)( htarget, vtarget, width, height,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  				
--- 354,360 ----
  				xcount ;
  				xcount--, htarget += width )
  			{
! 				vgaDrawColorImage( htarget, vtarget, width, height,
  					 data,
  					 pTile->devKind, alu, planes ) ;
  				
diff -c /dev/null mit/server/ddx/x386/vga16/ibm/mfbfillarc.c:2.0
*** /dev/null	Fri Mar 11 23:40:27 1994
--- mit/server/ddx/x386/vga16/ibm/mfbfillarc.c	Fri Mar 11 23:40:27 1994
***************
*** 0 ****
--- 1,297 ----
+ /************************************************************
+ Copyright 1989 by The Massachusetts Institute of Technology
+ 
+ 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 MIT not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific prior written permission.
+ M.I.T. makes no representation about the suitability of
+ this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+ 
+ ********************************************************/
+ /* GJA -- Took mfb code and modified it. */
+ 
+ /* $XFree86: mit/server/ddx/x386/vga16/ibm/mfbfillarc.c,v 2.0 1994/02/25 15:02:47 dawes Exp $ */
+ /* $XConsortium: mfbfillarc.c,v 5.7 90/10/06 13:58:08 rws Exp $ */
+ 
+ #define BANKING_MODS
+ #include "X.h"
+ #include "Xprotostr.h"
+ #include "miscstruct.h"
+ #include "gcstruct.h"
+ #include "pixmapstr.h"
+ #include "scrnintstr.h"
+ #include "mfb.h"
+ #include "maskbits.h"
+ #include "mifillarc.h"
+ #include "OScompiler.h"	/* GJA */
+ #include "wm3.h"	/* GJA */
+ 
+ extern void miPolyFillArc();
+ 
+ static void
+ v16FillEllipseSolid(pDraw, arc, rop)
+     DrawablePtr pDraw;
+     xArc *arc;
+     register int rop;
+ {
+     int x, y, e;
+     int yk, xk, ym, xm, dx, dy, xorg, yorg;
+     register int slw;
+     miFillArcRec info;
+     int *addrlt, *addrlb;
+     register int *addrl;
+     register int n;
+     int nlwidth;
+     register int xpos;
+     int startmask, endmask, nlmiddle;
+ 
+     if (pDraw->type == DRAWABLE_WINDOW)
+     {
+ 	addrlt = (int *)
+ 	       (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr);
+ 	nlwidth = (int)
+ 	       (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
+     }
+     else
+     {
+ 	addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr);
+ 	nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
+     }
+ 
+ /*    BANK_FLAG(addrlt) */
+ 
+     miFillArcSetup(arc, &info);
+     MIFILLARCSETUP();
+     xorg += pDraw->x;
+     yorg += pDraw->y;
+     addrlb = addrlt;
+     addrlt += nlwidth * (yorg - y);
+     addrlb += nlwidth * (yorg + y + dy);
+     while (y)
+     {
+ 	addrlt += nlwidth;
+ 	addrlb -= nlwidth;
+ 	MIFILLARCSTEP(slw);
+ 	if (!slw)
+ 	    continue;
+ 	xpos = xorg - x;
+ 	addrl = addrlt + (xpos >> 5);
+ 	VSETRW(addrl);
+ 	if (((xpos & 0x1f) + slw) < 32)
+ 	{
+ 	    maskpartialbits(xpos, slw, startmask);
+ 	    UPDRW(VMAPRW(addrl),startmask);
+ 	    if (miFillArcLower(slw))
+ 	    {
+ 		addrl = addrlb + (xpos >> 5);
+ 		VSETRW(addrl);
+ 		UPDRW(VMAPRW(addrl),startmask);
+ 	    }
+ 	    continue;
+ 	}
+ 	maskbits(xpos, slw, startmask, endmask, nlmiddle);
+ 	if (startmask)
+ 	{
+ 	    UPDRW(VMAPRW(addrl),startmask); addrl++; VCHECKRWO(addrl);
+ 	}
+ 	n = nlmiddle;
+ 	while (n--) {
+ 	    UPDRW(VMAPRW(addrl),~0); addrl++; VCHECKRWO(addrl);
+ 	}
+ 	if (endmask)
+ 	{
+ 	    UPDRW(VMAPRW(addrl),endmask);
+ 	}
+ 	if (!miFillArcLower(slw))
+ 	    continue;
+ 	addrl = addrlb + (xpos >> 5);
+ 	VSETRW(addrl);
+ 	if (startmask)
+ 	{
+ 	    UPDRW(VMAPRW(addrl),startmask); addrl++; VCHECKRWO(addrl);
+ 	}
+ 	n = nlmiddle;
+ 	while (n--) {
+ 	    UPDRW(VMAPRW(addrl),~0); addrl++; VCHECKRWO(addrl);
+ 	}
+ 	if (endmask)
+ 	{
+ 	    UPDRW(VMAPRW(addrl),endmask);
+ 	}
+     }
+ }
+ 
+ #define FILLSPAN(xl,xr,addr) \
+     if (xr >= xl) \
+     { \
+ 	width = xr - xl + 1; \
+ 	addrl = addr + (xl >> 5); \
+ 	VSETRW(addrl); \
+ 	if (((xl & 0x1f) + width) < 32) \
+ 	{ \
+ 	    maskpartialbits(xl, width, startmask); \
+ 	    UPDRW(VMAPRW(addrl),startmask); \
+ 	} \
+ 	else \
+ 	{ \
+ 	    maskbits(xl, width, startmask, endmask, nlmiddle); \
+ 	    if (startmask) \
+ 	    { \
+ 		UPDRW(VMAPRW(addrl),startmask); addrl++; VCHECKRWO(addrl);\
+ 	    } \
+ 	    n = nlmiddle; \
+ 		while (n--) { \
+ 		    UPDRW(VMAPRW(addrl),~0); addrl++; VCHECKRWO(addrl);\
+ 		} \
+ 	    if (endmask) \
+ 	    { \
+ 		UPDRW(VMAPRW(addrl),endmask); \
+ 	    } \
+ 	} \
+     }
+ 
+ #define FILLSLICESPANS(flip,addr) \
+     if (!flip) \
+     { \
+ 	FILLSPAN(xl, xr, addr); \
+     } \
+     else \
+     { \
+ 	xc = xorg - x; \
+ 	FILLSPAN(xc, xr, addr); \
+ 	xc += slw - 1; \
+ 	FILLSPAN(xl, xc, addr); \
+     }
+ 
+ static void
+ v16FillArcSliceSolidCopy(pDraw, pGC, arc, rop)
+     DrawablePtr pDraw;
+     GCPtr pGC;
+     xArc *arc;
+     register int rop;
+ {
+     register int *addrl;
+     register int n;
+     int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
+     register int x, y, e;
+     miFillArcRec info;
+     miArcSliceRec slice;
+     int xl, xr, xc;
+     int *addrlt, *addrlb;
+     int nlwidth;
+     int width;
+     int startmask, endmask, nlmiddle;
+ 
+     if (pDraw->type == DRAWABLE_WINDOW)
+     {
+ 	addrlt = (int *)
+ 	       (((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr);
+ 	nlwidth = (int)
+ 	       (((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
+     }
+     else
+     {
+ 	addrlt = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr);
+ 	nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
+     }
+ 
+ /*    BANK_FLAG(addrlt) */
+ 
+     miFillArcSetup(arc, &info);
+     miFillArcSliceSetup(arc, &slice, pGC);
+     MIFILLARCSETUP();
+     xorg += pDraw->x;
+     yorg += pDraw->y;
+     addrlb = addrlt;
+     addrlt += nlwidth * (yorg - y);
+     addrlb += nlwidth * (yorg + y + dy);
+     slice.edge1.x += pDraw->x;
+     slice.edge2.x += pDraw->x;
+     while (y > 0)
+     {
+ 	addrlt += nlwidth;
+ 	addrlb -= nlwidth;
+ 	MIFILLARCSTEP(slw);
+ 	MIARCSLICESTEP(slice.edge1);
+ 	MIARCSLICESTEP(slice.edge2);
+ 	if (miFillSliceUpper(slice))
+ 	{
+ 	    MIARCSLICEUPPER(xl, xr, slice, slw);
+ 	    FILLSLICESPANS(slice.flip_top, addrlt);
+ 	}
+ 	if (miFillSliceLower(slice))
+ 	{
+ 	    MIARCSLICELOWER(xl, xr, slice, slw);
+ 	    FILLSLICESPANS(slice.flip_bot, addrlb);
+ 	}
+     }
+ }
+ 
+ void
+ v16PolyFillArcSolid(pDraw, pGC, narcs, parcs)
+     register DrawablePtr pDraw;
+     GCPtr	pGC;
+     int		narcs;
+     xArc	*parcs;
+ {
+     mfbPrivGC *priv;
+     register xArc *arc;
+     register int i;
+     BoxRec box;
+     RegionPtr cclip;
+     int rop;
+ 
+     priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
+     rop = priv->rop;
+ #if 0
+     if ((rop == RROP_NOP) || !(pGC->planemask & 1))
+ #else
+     if ( !(pGC->planemask & 0x0F))
+ #endif
+ 	return;
+     cclip = priv->pCompositeClip;
+     for (arc = parcs, i = narcs; --i >= 0; arc++)
+     {
+ 	if (miFillArcEmpty(arc))
+ 	    continue;
+ 	if (miCanFillArc(arc))
+ 	{
+ 	    box.x1 = arc->x + pDraw->x;
+ 	    box.y1 = arc->y + pDraw->y;
+ 	    box.x2 = box.x1 + (int)arc->width + 1;
+ 	    box.y2 = box.y1 + (int)arc->height + 1;
+ 	    if ((*pDraw->pScreen->RectIn)(cclip, &box) == rgnIN)
+ 	    {
+ 		if ((arc->angle2 >= FULLCIRCLE) ||
+ 		    (arc->angle2 <= -FULLCIRCLE))
+ 		    DO_WM3(pGC,v16FillEllipseSolid(pDraw, arc, rop))
+ 		else
+ 		    DO_WM3(pGC,v16FillArcSliceSolidCopy(pDraw, pGC, arc, rop)) 
+ 		continue;
+ 	    }
+ 	}
+ 	miPolyFillArc(pDraw, pGC, 1, arc);
+     }
+ }
+ 
+ void
+ v16PolyFillArc(pDraw, pGC, narcs, parcs)
+     register DrawablePtr pDraw;
+     GCPtr	pGC;
+     int		narcs;
+     xArc	*parcs;
+ {
+     extern int x386VTSema;
+ 
+     if ( !x386VTSema || (pGC->fillStyle != FillSolid) ) {
+ 	miPolyFillArc(pDraw, pGC, narcs, parcs);
+     } else {
+         v16PolyFillArcSolid(pDraw, pGC, narcs, parcs);
+     }
+ }
diff -c /dev/null mit/server/ddx/x386/vga16/ibm/mfbimggblt.c:2.1
*** /dev/null	Fri Mar 11 23:40:27 1994
--- mit/server/ddx/x386/vga16/ibm/mfbimggblt.c	Fri Mar 11 23:40:27 1994
***************
*** 0 ****
--- 1,506 ----
+ /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
+ /***********************************************************
+ Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+ and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+ 
+                         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 names of Digital or MIT not be
+ used in advertising or publicity pertaining to distribution of the
+ software without specific, written prior permission.  
+ 
+ DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ DIGITAL 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: mit/server/ddx/x386/vga16/ibm/mfbimggblt.c,v 2.1 1994/03/03 12:47:48 dawes Exp $ */
+ /* $XConsortium: mfbimggblt.c,v 5.6 91/05/26 09:21:19 rws Exp $ */
+ #define BANKING_MODS
+ #include	"X.h"
+ #include	"Xmd.h"
+ #include	"Xproto.h"
+ #include	"mfb.h"
+ #include	"fontstruct.h"
+ #include	"dixfontstr.h"
+ #include	"gcstruct.h"
+ #include	"windowstr.h"
+ #include	"scrnintstr.h"
+ #include	"pixmapstr.h"
+ #include	"regionstr.h"
+ #include	"maskbits.h"
+ 
+ #include "ppcGCstr.h"	/* GJA */
+ #include "vgaReg.h"	/* GJA */
+ #include "compiler.h"	/* rvb */
+ #include "vgaVideo.h"	/* GJA */
+ #include "wm3.h"	/* GJA */
+ #include "OScompiler.h"	/* GJA */
+ 
+ void ppcAreaFill(); /* GJA -- HACK */
+ 
+ extern void QueryGlyphExtents();
+ 
+ /*
+     we should eventually special-case fixed-width fonts for ImageText.
+ 
+     this works for fonts with glyphs <= 32 bits wide.
+ 
+     the clipping calculations are done for worst-case fonts.
+ we make no assumptions about the heights, widths, or bearings
+ of the glyphs.  if we knew that the glyphs are all the same height,
+ we could clip the tops and bottoms per clipping box, rather
+ than per character per clipping box.  if we knew that the glyphs'
+ left and right bearings were wlle-behaved, we could clip a single
+ character at the start, output until the last unclipped
+ character, and then clip the last one.  this is all straightforward
+ to determine based on max-bounds and min-bounds from the font.
+     there is some inefficiency introduced in the per-character
+ clipping to make what's going on clearer.
+ 
+     (it is possible, for example, for a font to be defined in which the
+ next-to-last character in a font would be clipped out, but the last
+ one wouldn't.  the code below deals with this.)
+ 
+     Image text looks at the bits in the glyph and the fg and bg in the
+ GC.  it paints a rectangle, as defined in the protocol dcoument,
+ and the paints the characters.
+ 
+    to avoid source proliferation, this file is compiled
+ three times:
+ 	MFBIMAGEGLYPHBLT	OPEQ
+ 	mfbImageGlyphBltWhite	|=
+ 	mfbImageGlyphBltBlack	&=~
+ 
+     the register allocations for startmask and endmask may not
+ be the right thing.  are there two other deserving candidates?
+ xoff, pdst, pglyph, and tmpSrc seem like the right things, though.
+ */
+ 
+ /* Forward declarations -- GJA */
+ void doImageGlyphBlt();
+ 
+ void
+ v16ImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
+     DrawablePtr pDrawable;
+     GC 		*pGC;
+     int 	x, y;
+     unsigned int nglyph;
+     CharInfoPtr *ppci;		/* array of character info */
+     unsigned char *pglyphBase;	/* start of array of glyphs */
+ {
+     ExtentInfoRec info;	/* used by QueryGlyphExtents() */
+     xRectangle backrect;/* backing rectangle to paint.
+ 			   in the general case, NOT necessarily
+ 			   the same as the string's bounding box
+ 			*/
+     extern int x386VTSema;
+ 
+     /* GJA -- I agree, this ALL should be moved to GC validation. */
+     if ( (pDrawable->type != DRAWABLE_WINDOW) || (pGC->alu != GXcopy) ||
+          !x386VTSema ||
+          ((pGC->font) &&
+ 	    (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+ 	     FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ 	     FONTMINBOUNDS(pGC->font,characterWidth) < 0)) ) {
+        miImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+     } else {
+        void (* oldFillArea)();
+        int oldfillStyle, oldfg, oldalu;
+ 
+        if (!(pGC->planemask & 0x0F))
+    	   return;
+ 
+        QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
+ 
+        backrect.x = x;
+        backrect.y = y - FONTASCENT(pGC->font);
+        backrect.width = info.overallWidth;
+        backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
+ 
+ 
+        oldFillArea = ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            FillArea;
+        oldfillStyle = ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            colorRrop.fillStyle; /* GJA */
+        oldfg = ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            colorRrop.fgPixel; /* GJA */
+        oldalu = ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            colorRrop.alu; /* GJA */
+ 
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            FillArea = ppcAreaFill;
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            colorRrop.fillStyle = FillSolid; /* GJA */
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+    			   colorRrop.fgPixel = pGC->bgPixel; /* GJA */
+        pGC->fgPixel = pGC->bgPixel;
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            colorRrop.alu = GXcopy; /* GJA */
+        pGC->alu = GXcopy;
+ 
+        /* Required fields:
+         * colorRrop.alu, colorRrop.planemask, colorRrop.fgPixel, FillArea
+         */
+        ppcPolyFillRect(pDrawable, pGC, 1, &backrect);
+ 
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            FillArea = oldFillArea;
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                         colorRrop.fgPixel = oldfg; /* GJA */
+        pGC->fgPixel = oldfg;
+ 
+        /* the faint-hearted can open their eyes now */
+ 
+        DO_WM3(pGC,doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci,
+ 			pglyphBase,&info))
+ 
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                            colorRrop.fillStyle = oldfillStyle; /* GJA */
+        ((ppcPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->
+                         colorRrop.alu = oldalu; /* GJA */
+        pGC->alu = oldalu;
+     }
+ }
+ 
+ void
+ doImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase,infop)
+     DrawablePtr pDrawable;
+     GC 		*pGC;
+     int 	x, y;
+     unsigned int nglyph;
+     CharInfoPtr *ppci;		/* array of character info */
+     unsigned char *pglyphBase;	/* start of array of glyphs */
+     ExtentInfoRec* infop;	/* used by QueryGlyphExtents() */
+ {
+     BoxRec bbox;	/* string's bounding box */
+ 
+     CharInfoPtr pci;
+     int xorg, yorg;	/* origin of drawable in bitmap */
+     int widthDst;	/* width of dst in longwords */
+ 
+ 			/* these keep track of the character origin */
+     unsigned int *pdstBase;
+ 			/* points to longword with character origin */
+     int xchar;		/* xorigin of char (mod 32) */
+ 
+ 			/* these are used for placing the glyph */
+     register int xoff;	/* x offset of left edge of glyph (mod 32) */
+     register unsigned int *pdst;
+ 			/* pointer to current longword in dst */
+ 
+     int w;		/* width of glyph in bits */
+     int h;		/* height of glyph */
+     int widthGlyph;	/* width of glyph, in bytes */
+     register unsigned char *pglyph;
+ 			/* pointer to current row of glyph */
+ 
+ 			/* used for putting down glyph */    
+     register unsigned int tmpSrc;
+ 			/* for getting bits from glyph */
+     register int startmask;
+     register int endmask;
+ 
+     register int nFirst;/* bits of glyph in current longword */
+     void (* oldFillArea)();
+ 			/* we might temporarily usurp this
+ 			   field in devPriv */
+     int oldfillStyle; /* GJA */
+     int oldfg; /* GJA */
+     volatile int dummy; /* GJA -- HACK */
+ 
+ 
+ 
+     xorg = pDrawable->x;
+     yorg = pDrawable->y;
+     if (pDrawable->type == DRAWABLE_WINDOW)
+     {
+ 	pdstBase = (unsigned int *)
+ 		(((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate.ptr);
+ 	widthDst = (int)
+ 		 (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind) >> 2;
+     }
+     else
+     {
+ 	pdstBase = (unsigned int *)(((PixmapPtr)pDrawable)->devPrivate.ptr);
+ 	widthDst = (int)(((PixmapPtr)pDrawable)->devKind) >> 2;
+     }
+ 
+ /*    BANK_FLAG(pdstBase) */
+ 
+     x += xorg;
+     y += yorg;
+ 
+     bbox.x1 = x + infop->overallLeft;
+     bbox.x2 = x + infop->overallRight;
+     bbox.y1 = y - infop->overallAscent;
+     bbox.y2 = y + infop->overallDescent;
+ 
+     /* UNCLEAN CODE
+        we know the mfbPolyFillRect uses only three fields in
+        devPrivate[mfbGCPrivateIndex].ptr, two of which (the rotated
+        tile/stipple and the ropFillArea) are 
+        irrelevant for solid filling, so we just poke the FillArea
+        field.  the GC is now in an inconsistent state, but we'll fix
+        it as soon as PolyFillRect returns.  fortunately, the server
+        is single threaded.
+ 
+     NOTE:
+        if you are not using the standard mfbFillRectangle code, you
+        need to poke any fields in the GC the rectangle stuff need
+        (probably alu, fgPixel, and fillStyle) and in devPrivate[mfbGCPrivateIndex].ptr
+        (probably rop or ropFillArea.)  You could just call ValidateGC,
+        but that is usually not a cheap thing to do.
+     */
+ 
+     switch ((*pGC->pScreen->RectIn)(
+ 		  ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip, &bbox))
+     {
+       case rgnOUT:
+ 	break;
+       case rgnIN:
+         pdstBase = pdstBase + (widthDst * y) + (x >> 5);
+         xchar = x & 0x1f;
+ 
+         while(nglyph--)
+         {
+ 	    pci = *ppci;
+ 	    pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ 	    w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
+ 	    h = pci->metrics.ascent + pci->metrics.descent;
+ 	    widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+ 
+ 	    /* start at top scanline of glyph */
+ 	    pdst = pdstBase - (pci->metrics.ascent * widthDst);
+ 
+ 	    /* find correct word in scanline and x offset within it
+ 	       for left edge of glyph
+ 	    */
+ 	    xoff = xchar + pci->metrics.leftSideBearing;
+ 	    if (xoff > 31)
+ 	    {
+ 	        pdst++;
+ 	        xoff &= 0x1f;
+ 	    }
+ 	    else if (xoff < 0)
+ 	    {
+ 	        xoff += 32;
+ 	        pdst--;
+ 	    }
+             VSETRW(pdst);
+ 
+ 	    if ((xoff + w) <= 32)
+ 	    {
+ 	        /* glyph all in one longword */
+ 	        maskpartialbits(xoff, w, startmask);
+ 	        while (h--)
+ 	        {
+ 		    getleftbits(pglyph, w, tmpSrc);
+ 		    UPDRW(MAPRW(pdst),(SCRRIGHT(tmpSrc, xoff) & startmask));
+ 		    pglyph += widthGlyph;
+ 		    pdst += widthDst; VCHECKRWO(pdst);
+ 	        }
+ 	    }
+ 	    else
+ 	    {
+ 	        /* glyph crosses longword boundary */
+ 	        mask32bits(xoff, w, startmask, endmask);
+ 	        nFirst = 32 - xoff;
+ 	        while (h--)
+ 	        {
+ 		    getleftbits(pglyph, w, tmpSrc);
+ 		    UPDRW(MAPRW(pdst),(SCRRIGHT(tmpSrc, xoff) & startmask));
+                     VCHECKRWONEXT(pdst);
+ 		    UPDRW(MAPRW(&(pdst[1])),(SCRLEFT(tmpSrc, nFirst) & endmask));
+ 		    pglyph += widthGlyph;
+ 		    pdst += widthDst; VCHECKRWO(pdst);
+ 	        }
+ 	    } /* glyph crosses longwords boundary */
+ 
+ 	    /* update character origin */
+ 	    x += pci->metrics.characterWidth;
+ 	    xchar += pci->metrics.characterWidth;
+ 	    if (xchar > 31)
+ 	    {
+ 	        xchar -= 32;
+ 	        pdstBase++;
+ 	    }
+ 	    else if (xchar < 0)
+ 	    {
+ 	        xchar += 32;
+ 	        pdstBase--;
+ 	    }
+ 	    ppci++;
+         } /* while nglyph-- */
+ 	break;
+       case rgnPART:
+       {
+ 	TEXTPOS *ppos;
+ 	int nbox;
+ 	BoxPtr pbox;
+ 	RegionPtr cclip;
+ 	int xpos;		/* x position of char origin */
+ 	int i;
+ 	BoxRec clip;
+ 	int leftEdge, rightEdge;
+ 	int topEdge, bottomEdge;
+ 	int glyphRow;		/* first row of glyph not wholly
+ 				   clipped out */
+ 	int glyphCol;		/* leftmost visible column of glyph */
+ 	int getWidth;		/* bits to get from glyph */
+ 
+ 	if(!(ppos = (TEXTPOS *)ALLOCATE_LOCAL(nglyph * sizeof(TEXTPOS))))
+ 	    return;
+ 
+         pdstBase = pdstBase + (widthDst * y) + (x >> 5);
+         xpos = x;
+ 	xchar = xpos & 0x1f;
+ 
+ 	for (i=0; i<nglyph; i++)
+ 	{
+ 	    pci = ppci[i];
+ 
+ 	    ppos[i].xpos = xpos;
+ 	    ppos[i].xchar = xchar;
+ 	    ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
+ 	    ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
+ 	    ppos[i].topEdge = y - pci->metrics.ascent;
+ 	    ppos[i].bottomEdge = y + pci->metrics.descent;
+ 	    ppos[i].pdstBase = pdstBase;
+ 	    ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
+ 
+ 	    xpos += pci->metrics.characterWidth;
+ 	    xchar += pci->metrics.characterWidth;
+ 	    if (xchar > 31)
+ 	    {
+ 		xchar &= 0x1f;
+ 		pdstBase++;
+ 	    }
+ 	    else if (xchar < 0)
+ 	    {
+ 		xchar += 32;
+ 		pdstBase--;
+ 	    }
+ 	}
+ 
+ 	cclip = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip;
+ 	pbox = REGION_RECTS(cclip);
+ 	nbox = REGION_NUM_RECTS(cclip);
+ 
+ 	/* HACK ALERT
+ 	   since we continue out of the loop below so often, it
+ 	   is easier to increment pbox at the  top than at the end.
+ 	   don't try this at home.
+ 	*/
+ 	pbox--;
+ 	while(nbox--)
+ 	{
+ 	    pbox++;
+ 	    clip.x1 = max(bbox.x1, pbox->x1);
+ 	    clip.y1 = max(bbox.y1, pbox->y1);
+ 	    clip.x2 = min(bbox.x2, pbox->x2);
+ 	    clip.y2 = min(bbox.y2, pbox->y2);
+ 	    if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
+ 		continue;
+ 
+ 	    for(i=0; i<nglyph; i++)
+ 	    {
+ 		pci = ppci[i];
+ 		xchar = ppos[i].xchar;
+ 
+ 		/* clip the left and right edges */
+ 		if (ppos[i].leftEdge < clip.x1)
+ 		    leftEdge = clip.x1;
+ 		else
+ 		    leftEdge = ppos[i].leftEdge;
+ 
+ 		if (ppos[i].rightEdge > clip.x2)
+ 		    rightEdge = clip.x2;
+ 		else
+ 		    rightEdge = ppos[i].rightEdge;
+ 
+ 		w = rightEdge - leftEdge;
+ 		if (w <= 0)
+ 		    continue;
+ 
+ 		/* clip the top and bottom edges */
+ 		if (ppos[i].topEdge < clip.y1)
+ 		    topEdge = clip.y1;
+ 		else
+ 		    topEdge = ppos[i].topEdge;
+ 
+ 		if (ppos[i].bottomEdge > clip.y2)
+ 		    bottomEdge = clip.y2;
+ 		else
+ 		    bottomEdge = ppos[i].bottomEdge;
+ 
+ 		h = bottomEdge - topEdge;
+ 		if (h <= 0)
+ 		    continue;
+ 
+ 		glyphRow = (topEdge - y) + pci->metrics.ascent;
+ 		widthGlyph = ppos[i].widthGlyph;
+ 		pglyph = FONTGLYPHBITS(pglyphBase, pci);
+ 		pglyph += (glyphRow * widthGlyph);
+ 
+ 		pdst = ppos[i].pdstBase - ((y-topEdge) * widthDst);
+ 
+ 		glyphCol = (leftEdge - ppos[i].xpos) -
+ 			   (pci->metrics.leftSideBearing);
+ 		getWidth = w + glyphCol;
+ 		xoff = xchar + (leftEdge - ppos[i].xpos);
+ 		if (xoff > 31)
+ 		{
+ 		    xoff &= 0x1f;
+ 		    pdst++;
+ 		}
+ 		else if (xoff < 0)
+ 		{
+ 		    xoff += 32;
+ 		    pdst--;
+ 		}
+                 VSETRW(pdst);
+ 
+ 		if ((xoff + w) <= 32)
+ 		{
+ 		    maskpartialbits(xoff, w, startmask);
+ 		    while (h--)
+ 		    {
+ 			getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ 			UPDRW(MAPRW(pdst),(SCRRIGHT(tmpSrc, xoff) & startmask));
+ 			pglyph += widthGlyph;
+ 			pdst += widthDst; VCHECKRWO(pdst);
+ 		    }
+ 		}
+ 		else
+ 		{
+ 		    mask32bits(xoff, w, startmask, endmask);
+ 		    nFirst = 32 - xoff;
+ 		    while (h--)
+ 		    {
+ 			getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
+ 			UPDRW(MAPRW(pdst),(SCRRIGHT(tmpSrc, xoff) & startmask));
+                         VCHECKRWONEXT(pdst);
+ 			UPDRW(MAPRW(&(pdst[1])),(SCRLEFT(tmpSrc, nFirst) & endmask));
+ 			pglyph += widthGlyph;
+ 			pdst += widthDst; VCHECKRWO(pdst);
+ 		    }
+ 		}
+ 	    } /* for each glyph */
+ 	} /* while nbox-- */
+ 	DEALLOCATE_LOCAL(ppos);
+ 	break;
+       }
+       default:
+ 	break;
+     }
+ }
+ 
diff -c /dev/null mit/server/ddx/x386/vga16/ibm/mfbzerarc.c:2.0
*** /dev/null	Fri Mar 11 23:40:28 1994
--- mit/server/ddx/x386/vga16/ibm/mfbzerarc.c	Fri Mar 11 23:40:28 1994
***************
*** 0 ****
--- 1,260 ----
+ /************************************************************
+ Copyright 1989 by The Massachusetts Institute of Technology
+ 
+ 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 MIT not be used in
+ advertising or publicity pertaining to distribution of the
+ software without specific prior written permission.
+ M.I.T. makes no representation about the suitability of
+ this software for any purpose. It is provided "as is"
+ without any express or implied warranty.
+ 
+ ********************************************************/
+ /* GJA -- Took mfb code and modified it. */
+ 
+ /* $XFree86: mit/server/ddx/x386/vga16/ibm/mfbzerarc.c,v 2.0 1994/02/25 15:02:48 dawes Exp $ */
+ /* $XConsortium: mfbzerarc.c,v 5.10 89/09/20 18:55:33 rws Exp $ */
+ 
+ /* Derived from:
+  * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
+  * by M. L. V. Pitteway
+  * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
+  */
+ 
+ #define BANKING_MODS
+ #include "X.h"
+ #include "Xprotostr.h"
+ #include "miscstruct.h"
+ #include "gcstruct.h"
+ #include "pixmapstr.h"
+ #include "scrnintstr.h"
+ #include "mfb.h"
+ #include "maskbits.h"
+ #include "mizerarc.h"
+ #include "OScompiler.h"	/* GJA */
+ #include "wm3.h"	/* GJA */
+ 
+ extern void miPolyArc(), miZeroPolyArc();
+ /*
+  * Note, LEFTMOST must be the bit leftmost in the actual screen
+  * representation.  This depends on both BITMAP_BIT_ORDER and
+  * IMAGE_BYTE_ORDER
+  * DHD 10/92
+  */
+ 
+ #if (BITMAP_BIT_ORDER == MSBFirst)
+ #if (IMAGE_BYTE_ORDER == MSBFirst)
+ #define LEFTMOST	((unsigned int) 0x80000000)
+ #else
+ #define LEFTMOST	((unsigned int) 0x80)
+ #endif
+ #else
+ #if (IMAGE_BYTE_ORDER == LSBFirst)
+ #define LEFTMOST	((unsigned int) 1)
+ #else
+ #define LEFTMOST	((unsigned int) 0x1000000)
+ #endif
+ #endif
+ 
+ #define PixelateWhite(addr,off) \
+ { \
+     register int *tmpaddr = &((addr)[(off)>>5]); \
+     VSETRW(tmpaddr); \
+     UPDRW(VMAPRW(tmpaddr),SCRRIGHT (LEFTMOST, ((off) & 0x1f))); \
+ }
+ #define PixelateBlack(addr,off) \
+ { \
+     register int *tmpaddr = &((addr)[(off)>>5]); \
+     VSETRW(tmpaddr); \
+     UPDRW(VMAPRW(tmpaddr),~(SCRRIGHT (LEFTMOST, ((off) & 0x1f)))); \
+ }
+ 
+ #define Pixelate(base,off) \
+ { \
+     paddr = base + ((off)>>5); \
+     pmask = SCRRIGHT(LEFTMOST, (off) & 0x1f); \
+     VSETRW(paddr); \
+     UPDRW(VMAPW(paddr),(pixel & pmask)); \
+ }
+ 
+ #define DoPix(bit,base,off) if (mask & bit) Pixelate(base,off);
+ 
+ static void
+ v16ZeroArcSS(pDraw, pGC, arc)
+     DrawablePtr pDraw;
+     GCPtr pGC;
+     xArc *arc;
+ {
+     miZeroArcRec info;
+     Bool do360;
+     register int x, y, a, b, d, mask;
+     register int k1, k3, dx, dy;
+     int *addrl;
+     int *yorgl, *yorgol;
+     unsigned long pixel;
+     int nlwidth, yoffset, dyoffset;
+     int pmask;
+     register int *paddr;
+ 
+     if (((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->rop ==
+ 	RROP_BLACK)
+ 	pixel = 0;
+     else
+ 	pixel = ~0L;
+ 
+     if (pDraw->type == DRAWABLE_WINDOW)
+     {
+ 	addrl = (int *)
+ 		(((PixmapPtr)(pDraw->pScreen->devPrivate))->devPrivate.ptr);
+ 	nlwidth = (int)
+ 		(((PixmapPtr)(pDraw->pScreen->devPrivate))->devKind) >> 2;
+     }
+     else
+     {
+ 	addrl = (int *)(((PixmapPtr)pDraw)->devPrivate.ptr);
+ 	nlwidth = (int)(((PixmapPtr)pDraw)->devKind) >> 2;
+     }
+ 
+ /*    BANK_FLAG(addrl) */
+ 
+     do360 = miZeroArcSetup(arc, &info, TRUE);
+     yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth);
+     yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth);
+     info.xorg += pDraw->x;
+     info.xorgo += pDraw->x;
+     MIARCSETUP();
+     yoffset = y ? nlwidth : 0;
+     dyoffset = 0;
+     mask = info.initialMask;
+     if (!(arc->width & 1))
+     {
+ 	DoPix(2, yorgl, info.xorgo);
+ 	DoPix(8, yorgol, info.xorgo);
+     }
+     if (!info.end.x || !info.end.y)
+     {
+ 	mask = info.end.mask;
+ 	info.end = info.altend;
+     }
+     if (do360 && (arc->width == arc->height) && !(arc->width & 1))
+     {
+ 	int xoffset = nlwidth;
+ 	int *yorghl = yorgl + (info.h * nlwidth);
+ 	int xorghp = info.xorg + info.h;
+ 	int xorghn = info.xorg - info.h;
+ 
+         while (1)
+         {
+ 	    PixelateWhite(yorgl + yoffset, info.xorg + x);
+ 	    PixelateWhite(yorgl + yoffset, info.xorg - x);
+ 	    PixelateWhite(yorgol- yoffset, info.xorg - x);
+ 	    PixelateWhite(yorgol - yoffset, info.xorg + x);
+ 	    if (a < 0)
+ 	        break;
+ 	    PixelateWhite(yorghl - xoffset, xorghp - y);
+ 	    PixelateWhite(yorghl - xoffset, xorghn + y);
+ 	    PixelateWhite(yorghl + xoffset, xorghn + y);
+ 	    PixelateWhite(yorghl + xoffset, xorghp - y);
+ 	    xoffset += nlwidth;
+ 	    MIARCCIRCLESTEP(yoffset += nlwidth;);
+         }
+ 	x = info.w;
+ 	yoffset = info.h * nlwidth;
+     }
+     else if (do360)
+     {
+ 	while (y < info.h || x < info.w)
+ 	{
+ 	    MIARCOCTANTSHIFT(dyoffset = nlwidth;);
+ 	    Pixelate(yorgl + yoffset, info.xorg + x);
+ 	    Pixelate(yorgl + yoffset, info.xorgo - x);
+ 	    Pixelate(yorgol - yoffset, info.xorgo - x);
+ 	    Pixelate(yorgol - yoffset, info.xorg + x);
+ 	    MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
+ 	}
+     }
+     else
+     {
+ 	while (y < info.h || x < info.w)
+ 	{
+ 	    MIARCOCTANTSHIFT(dyoffset = nlwidth;);
+ 	    if ((x == info.start.x) || (y == info.start.y))
+ 	    {
+ 		mask = info.start.mask;
+ 		info.start = info.altstart;
+ 	    }
+ 	    DoPix(1, yorgl + yoffset, info.xorg + x);
+ 	    DoPix(2, yorgl + yoffset, info.xorgo - x);
+ 	    DoPix(4, yorgol - yoffset, info.xorgo - x);
+ 	    DoPix(8, yorgol - yoffset, info.xorg + x);
+ 	    if ((x == info.end.x) || (y == info.end.y))
+ 	    {
+ 		mask = info.end.mask;
+ 		info.end = info.altend;
+ 	    }
+ 	    MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
+ 	}
+     }
+     if ((x == info.start.x) || (y == info.start.y))
+ 	mask = info.start.mask;
+     DoPix(1, yorgl + yoffset, info.xorg + x);
+     DoPix(4, yorgol - yoffset, info.xorgo - x);
+     if (arc->height & 1)
+     {
+ 	DoPix(2, yorgl + yoffset, info.xorgo - x);
+ 	DoPix(8, yorgol - yoffset, info.xorg + x);
+     }
+ }
+ 
+ void
+ v16ZeroPolyArcSS(pDraw, pGC, narcs, parcs)
+     DrawablePtr	pDraw;
+     GCPtr	pGC;
+     int		narcs;
+     xArc	*parcs;
+ {
+     register xArc *arc;
+     register int i;
+     BoxRec box;
+     RegionPtr cclip;
+ 
+     if (!pGC->planemask & 0x0F)
+ 	return;
+     cclip = ((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip;
+     for (arc = parcs, i = narcs; --i >= 0; arc++)
+     {
+ 	if (miCanZeroArc(arc))
+ 	{
+ 	    box.x1 = arc->x + pDraw->x;
+ 	    box.y1 = arc->y + pDraw->y;
+ 	    box.x2 = box.x1 + (int)arc->width + 1;
+ 	    box.y2 = box.y1 + (int)arc->height + 1;
+ 	    if ((*pDraw->pScreen->RectIn)(cclip, &box) == rgnIN)
+ 		v16ZeroArcSS(pDraw, pGC, arc);
+ 	    else
+ 		miZeroPolyArc(pDraw, pGC, 1, arc);
+ 	}
+ 	else
+ 	    miPolyArc(pDraw, pGC, 1, arc);
+     }
+ }
+ 
+ void
+ v16ZeroPolyArc(pDraw, pGC, narcs, parcs)
+     DrawablePtr	pDraw;
+     GCPtr	pGC;
+     int		narcs;
+     xArc	*parcs;
+ {
+     extern int x386VTSema;
+ 
+     if ( !x386VTSema ) {
+ 	miZeroPolyArc(pDraw, pGC, narcs, parcs);
+     } else {
+         DO_WM3(pGC,v16ZeroPolyArcSS(pDraw, pGC, narcs, parcs));
+     }
+ }
diff -c mit/server/ddx/x386/vga16/ibm/ppc.h:2.0 mit/server/ddx/x386/vga16/ibm/ppc.h:2.1
*** mit/server/ddx/x386/vga16/ibm/ppc.h:2.0	Fri Mar 11 23:40:28 1994
--- mit/server/ddx/x386/vga16/ibm/ppc.h	Fri Mar 11 23:40:28 1994
***************
*** 20,26 ****
   * SOFTWARE.
   *
  */
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppc.h,v 2.0 1993/08/19 16:08:30 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppc.h,v 9.2 89/04/29 21:25:30 jeff Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppc.h,v */
  /* "@(#)ppc.h	3.1 88/09/22 09:35:08" */
--- 20,26 ----
   * SOFTWARE.
   *
  */
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppc.h,v 2.1 1994/02/01 13:54:07 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppc.h,v 9.2 89/04/29 21:25:30 jeff Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppc.h,v */
  /* "@(#)ppc.h	3.1 88/09/22 09:35:08" */
***************
*** 30,32 ****
--- 30,34 ----
  #include "ppcGCstr.h"
  
  #include "ppcScrn.h"
+ #include "ppcProcs.h"
+ #include "vgaProcs.h"
diff -c mit/server/ddx/x386/vga16/ibm/ppcArc.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcArc.c:removed
*** mit/server/ddx/x386/vga16/ibm/ppcArc.c:2.0	Fri Mar 11 23:40:29 1994
--- mit/server/ddx/x386/vga16/ibm/ppcArc.c	Fri Mar 11 23:40:29 1994
***************
*** 1,1619 ****
- /*
-  * Copyright IBM Corporation 1987,1988,1989
-  *
-  * 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 IBM not be
-  * used in advertising or publicity pertaining to distribution of the
-  * software without specific, written prior permission.
-  *
-  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-  * IBM 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: mit/server/ddx/x386/vga16/ibm/ppcArc.c,v 2.0 1993/08/19 16:08:31 dawes Exp $ */
- 
- /* PPCZEROARCS-
- Tom Paquin 2/19/89
- 
- 	The idea is to draw solid, zero-width circles and ellipses
- using Bresenham or similar techniques, while preserving X semantics.
- Zero widths can be drawn easily without regard to intersection points of
- polyarcs.
- 	I use Art Kauffman's modified algorithm for quadrants 2 and 1 
- (respectively) while reflecting in X and Y, but not the 45s like bresenham.  
- I generate spans or runs for Quadrant 2 and points for Quadrant 1.  
- 	For bounding boxes of even width (EG (0,0) to (3,3)) the reflection
- hasn't an integer center.  I choose floor(center) for left and upper
- reflections and ceiling(center) for right and lower reflections. (Lower is
- increasing Y.)  This can create 4 pseudo-center points.  I refer to this 
- technique as the Jeff Shift (Jeff Weinstien).  Jeffshifted circles will not 
- draw the top dead center and bottom dead center runs in a circle, so we 
- predraw them for Jeffshifted circles.
- 	For potentially clipped circles, I generate Spans since the spans
- routines clip.  For cases where the circle's box resides wholly within the
- composite clip, I merely draw.  For cases I cannot easily handle, I crap
- out to mi, which is HORRENDOUSLY slow, especially if you've no FP hardware.
- */
- 
-  
- /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcArc.c,v 9.9 89/04/29 23:59:59 jeff Exp */
- /* Source: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcArc.c,v */
-  
- 
- #include "X.h"
- #include "Xprotostr.h"
- #include "gcstruct.h"
- #include "regionstr.h"
- #include "scrnintstr.h"
- #include "windowstr.h"
- #include "miscstruct.h"
- #include "misc.h"
- 
- #include "OScompiler.h"
- 
- #include "ppc.h"
- 
- /* FULLCIRCLE is 360 * 64 (sixty-fourths of a degree) */
- #define FULLCIRCLE ( 360 << 6 )
- 
- /* GJA -- made function defs static */
- static void ppcFillIntegerFullArc();
- static void ppcIntegerFullArc() ;
- static void DrawFullArcOnSpans();
- static void DrawFullArcOnHW();
- static void FillFullArcOnSpans();
- static void FillFullArcOnHW();
- static void ppcIntegerArc();
- static void GetPts();
- static void DrawArcOnSpans();
- extern int mfbGCPrivateIndex;
- 
- typedef struct MyPointStruct {
- 	short x;
- 	short y;
- 	} MyPointRec, *MyPointPtr;
- 
- typedef struct MyBoxStruct {
-     signed long int x1, y1, x2, y2;
- } MyBoxRec, *MyBoxPtr;
- 
- void
- ppcPolyZeroArc(pWindow, pGC, narcs, parcs)
- WindowPtr	pWindow;
- GCPtr		pGC;
- int		narcs;
- xArc		*parcs;
- { /* This routine should only be called when LineStyle==Solid and LineWidth=0 */
- register xArc	*thisarc;
- int		box_w, box_h, angle;
- 
- ppcScrnPrivPtr  pScrPriv = (ppcScrnPrivPtr) 
- 			pWindow->drawable.pScreen->devPrivate;
- 
- if ( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu  == GXnoop ) return ;
- 
- while (narcs--)
- 	{
- 	thisarc = parcs++;
- /*
- 	printf("w = %d, h = %d, a1 = %d, a2 = %d\n", thisarc->width,
- 			thisarc->height, thisarc->angle1, thisarc->angle2);
- */
- 
- 	box_w = thisarc->width;
- 	box_h = thisarc->height;
- 	angle = thisarc->angle2;
-     
- 
- 	if ( (angle >= FULLCIRCLE) || (angle <= -FULLCIRCLE) )
- 		{
- 		if ( ( box_w == box_h) || 
- 				( ( box_w < 4096 ) && ( box_h < 4096 ) ) )
- 			ppcIntegerFullArc(pWindow, pGC, thisarc);
- 		else    /* algorithm doesn't work because we'll
- 			   flood a 32-bit int */
- 			miPolyArc(pWindow, pGC, 1, thisarc);
- 		}
- 	else
- 		{ 
- 		ppcIntegerArc(pWindow, pGC, thisarc);
- 		}
- 	}
- return ;
- }
- 
- void
- ppcPolyFillArc(pWindow, pGC, narcs, parcs)
- WindowPtr	pWindow;
- GCPtr		pGC;
- int		narcs;
- xArc		*parcs;
- { /* This routine should only be called when FillStyle==FillSolid */
- register xArc	*thisarc;
- int		box_w, box_h, angle;
- 
- ppcScrnPrivPtr  pScrPriv = (ppcScrnPrivPtr) 
- 			pWindow->drawable.pScreen->devPrivate;
- 
- 
- if ( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.alu  == GXnoop ) return ;
- 
- while (narcs--)
- 	{
- 	thisarc = parcs++;
- 
- 	box_w = thisarc->width;
- 	box_h = thisarc->height;
- 	angle = thisarc->angle2;
-     
- 
- 	if ( (angle >= FULLCIRCLE) || (angle <= -FULLCIRCLE) )
- 		{
- 		if ( ( box_w == box_h) || 
- 				( ( box_w < 4096 ) && ( box_h < 4096 ) ) )
- 			ppcFillIntegerFullArc(pWindow, pGC, thisarc);
- 		else
- 			miPolyFillArc(pWindow, pGC, 1, thisarc);
- 		}
- 	else 
- 		{ 
- 		miPolyFillArc(pWindow, pGC, 1, thisarc);
- 		}
- 	}
- return ;
- }
- 
- static void
- ppcFillIntegerFullArc(pWindow, pGC, pArc)
- WindowPtr 	pWindow;
- GCPtr		pGC;
- xArc		*pArc;
- {
- BoxRec		bbox;
- RegionPtr       pCC;
- ScreenPtr	pScreen;
- xRectangle	rect;
- 
- 
- if (pArc->width == 0) return;
- if (pArc->height == 0) return;
- 
- /* set up the box and convert to screen coordinates */
- bbox.x2 = (rect.x = bbox.x1 = pWindow->drawable.x + pArc->x) 
- 			+ (rect.width = pArc->width ) ;
- bbox.y2 = (rect.y = bbox.y1 = pWindow->drawable.y + pArc->y) 
- 			+ (rect.height = pArc->height );
- 
- if ( pGC->fillStyle != FillSolid )
- 	{
- 	FillFullArcOnSpans(pWindow, pGC, &rect);
- 	return;
- 	}
- 
- pCC = ((ppcPrivGC *)pGC->devPrivates[mfbGCPrivateIndex].ptr)->pCompositeClip;
- pScreen = pWindow->drawable.pScreen;
- 
- switch ( (*pScreen->RectIn)(pCC, &bbox))
- 	{
- 	case rgnOUT:
- 		/* nothing to draw, abandon ship */
- 		return;
- 	case rgnIN:
- 		/* blast away, mateys! */
- 		FillFullArcOnHW( 
- 			((ppcScrnPriv *)pScreen->devPrivate)->solidFill,
- 			&rect, 
- 			((ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr)->colorRrop.fgPixel,
- 			((ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr)->colorRrop.alu,
- 			((ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr)->colorRrop.planemask );
- 		break;
- 	case rgnPART:
- 		/* avast! time to use finesse. */
- 		FillFullArcOnSpans(pWindow, pGC, &rect);
- 		break;
- 	}
- return ;
- }
- 
- #define PAINT(X,Y,WIDTH)			\
- 	{					\
- 	xR = cxR + (X);				\
- 	xL = cxL - (X) - (WIDTH) + 1;		\
- 	yU = cyU - (Y) ;			\
- 	yL = cyL + (Y) ;			\
- 	/* Quadrant 1 */ (*paint)(color, alu, pm, xR, yU, WIDTH, 1) ; \
- 	/* Quadrant 2 */ (*paint)(color, alu, pm, xL, yU, WIDTH, 1) ; \
- 	/* Quadrant 3 */ (*paint)(color, alu, pm, xL, yL, WIDTH, 1) ; \
- 	/* Quadrant 4 */ (*paint)(color, alu, pm, xR, yL, WIDTH, 1) ; \
- 	}
- 
- #define SPAN(X,Y,W)	\
- 	{		\
- 	ppt->x = X; ppt->y = Y; *pwidth = W;	\
- 	ppt++; pwidth++; nspans++;		\
- 	}
- 
- static void
- ppcIntegerFullArc(pWindow, pGC, pArc)
- WindowPtr 	pWindow;
- GCPtr		pGC;
- xArc		*pArc;
- {
- BoxRec		bbox;
- RegionPtr       pCC;
- ScreenPtr	pScreen;
- xRectangle	rect;
- 
- if (pArc->width == 0) return;
- if (pArc->height == 0) return;
- 
- /* set up the box and convert to screen coordinates */
- bbox.x2 = (rect.x = bbox.x1 = pWindow->drawable.x + pArc->x) 
- 			+ (rect.width = pArc->width ) ;
- bbox.y2 = (rect.y = bbox.y1 = pWindow->drawable.y + pArc->y) 
- 			+ (rect.height = pArc->height );
- 
- if ( pGC->fillStyle != FillSolid )
- 	{
- 	DrawFullArcOnSpans(pWindow, pGC, &rect);
- 	return;
- 	}
- 
- pCC = ((ppcPrivGC *)pGC->devPrivates[mfbGCPrivateIndex].ptr)->pCompositeClip;
- pScreen = pWindow->drawable.pScreen;
- 
- switch ( (*pScreen->RectIn)(pCC, &bbox))
- 	{
- 	case rgnOUT:
- 		/* nothing to draw, abandon ship */
- 		return;
- 	case rgnIN:
- 		/* blast away, mateys! */
- 		DrawFullArcOnHW( 
- 			((ppcScrnPriv *)pScreen->devPrivate)->solidFill,
- 			&rect, 
- 			((ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr)->colorRrop.fgPixel,
- 			((ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr)->colorRrop.alu,
- 			((ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr)->colorRrop.planemask );
- 		break;
- 	case rgnPART:
- 		/* avast! time to use finesse. */
- 		/**** WHICH ONE IS FASTER???    ****/
- 		DrawFullArcOnSpans(pWindow, pGC, &rect);
- 		break;
- 	}
- return ;
- }
- 
- static void
- ppcIntegerArc(pWindow, pGC, pArc)
- 	WindowPtr 	pWindow;
- 	GCPtr		pGC;
- 	xArc		*pArc;
- 	{
- 
- 	if (pArc->width == 0) return;
- 	if (pArc->height == 0) return;
- 
- 	if ( (pArc->width != pArc->height) && 
- 			( ( pArc->width > 2048 ) || ( pArc->height > 2048 ) ) )
- 		{
- 		miPolyArc(pWindow, pGC, 1, pArc);
- 		}
- 	else
- 		{
- 		DrawArcOnSpans(pWindow, pGC, pArc);
- 		}
- 	return ;
- 	}
- 
- #define HALFCIRCLE ( FULLCIRCLE >> 1 )
- #define QUARTERCIRCLE ( FULLCIRCLE >> 2 )
- 
- extern unsigned short ppcSinTab[];
- 
- static int 
- isin(theta)
- 	int theta;
- 	{
- 	int ret, tmptheta;
- 	int savtheta;
- 
- 	savtheta = theta;
- 	/* Compilers can't seem to handle modulo of a negative number */
- 	theta %= FULLCIRCLE;
- 	if ( theta < 0 )
- 		theta += FULLCIRCLE;
- 
- /*
- 	printf("theta = %d\n", theta);
- */
- 
- 	if ( ( tmptheta = theta % HALFCIRCLE ) > QUARTERCIRCLE )
- 		ret = ppcSinTab[(HALFCIRCLE - tmptheta) >> 1];
- 	else
- 		ret = ppcSinTab[(tmptheta) >> 1];
- 
- /*
- 	printf("tmptheta = %d, ret = %d\n", tmptheta, ret);
- */
- 		
- 	if ( theta > HALFCIRCLE )
- 		{
- /*
- 		printf("sin(%d) is %d\n", savtheta, -ret);
- */
- 		return ( -ret );
- 		}
- 	else
- 		{
- /*
- 		printf("sin(%d) is %d\n", savtheta, ret);
- */
- 		return ( ret );
- 		}
- 
- 	}
- 
- #define icos(x) isin((x)+QUARTERCIRCLE)
- 
- static void
- GetPts(pArc, a, b)
- 	xArc *pArc;
- 	MyPointRec *a, *b;
- 	{
- 	long int	rx, ry, a1, a2;
- 
- 	if (pArc->angle2 < 0)
- 		{
- 		a1 = pArc->angle1 + pArc->angle2;
- 		a2 = pArc->angle1;
- 		}
- 	else 
- 		{
- 		a1 = pArc->angle1;
- 		a2 = pArc->angle1 + pArc->angle2;
- 		}
- 
- 	rx = pArc->width >> 1;
- 	ry = pArc->height >> 1;
- 
- /*
- 	printf("rx = %d, ry = %d, a1 = %d, a2 = %d\n", rx, ry, a1, a2);
- */
- 	a->x = ( ( rx * icos(a1) ) + ( 1 << 14 ) ) >> 15;
- 	a->y = - ( ( ( ry * isin(a1) ) + ( 1 << 14 ) ) >> 15 );
- 	b->x = ( ( rx * icos(a2) ) + ( 1 << 14 ) ) >> 15;
- 	b->y = - ( ( ( ry * isin(a2) ) + ( 1 << 14 ) ) >> 15 );
- /*
- 	printf("a = (%d, %d), b = (%d, %d)\n", a->x, a->y, b->x, b->y);
- */
- 
- 	return ;
- 	}
- 
- static int lastradius = -1;
- static MyPointPtr circlePts = 0;
- static int *circleWidths = 0;
- static int ncirclespans;
- 
- static MyPointRec	*ellipsePts = 0;
- static int		*ellipseWidths = 0;
- static int		nellipsespans = 0;
- static int		lasta = -1, lastb = -1;
- 
- static MyPointRec	*quadPts = 0;
- static int		*quadWidths = 0;
- static int		nquadspans = 0;
- 
- static void
- ComputeCQuad( r )
- 	int r;
- {
- register int 	dv;
- short		moves, x, y;
- int		startx, lasty, width;
- MyPointPtr	ppt;
- int		nspans;
- int		*pwidth;
- 
- if ( r == lastradius )
- 	return;
- 
- Xfree(circlePts);
- Xfree(circleWidths);
- 
- moves = -( y = r );
- x = 0;
- dv = 1-r;
- width = 0;
- startx = x+1;
- lasty = y;
- 
- 
- /* allocate space for the spans */
- ppt = (MyPointPtr) Xalloc( ( ( 2 + 2 * r ) * sizeof(MyPointRec)));
- if (ppt == 0)
- 	{
- 	ErrorF("ppcZeroCircle: ComputeCQuad: cannot malloc ppt");
- 	return ;
- 	}
- 
- pwidth = (int *) Xalloc( ( 2 + 2 * r ) * sizeof(int) );
- if (pwidth == 0)
- 	{
- 	Xfree(ppt);
- 	ErrorF("ppcZeroCircle: ComputeCQuad: cannot malloc pwidth");
- 	return ;
- 	}
- 
- circlePts = ppt;
- circleWidths = pwidth;
- lastradius = r;
- 
- nspans = 0;
- 
- /* Draw 2 octants and reflect them.  Do not draw first Pel.  Draw Last Pel.  */
- 
- /* OCTANT 2 */
- while(moves<0)
- 	{
- 	if (dv >= 0)
- 		{ /* go diagonal */
- 		x++; y--;
- 		moves += 2;
- 		dv += ( ((x-y) << 1) + 1 );
- 		SPAN(startx, lasty, width);
- 		startx = x;	
- 		lasty = y;	
- 		width = 1;
- 		}
- 	   else { /* go axial */
- 		x++;
- 		moves++;
- 		dv += ( (x<<1) + 1 );
- 		width++;	
- 		}
- 	}
- 
- if (width) SPAN(startx, lasty, width);
- 
- /* OCTANT 1 */
- dv -= (x + y);
- moves -= r ;
- 
- while (moves < 0)
- 	{
- 	if (dv<0)
- 		{ /* go diagonal */
- 		x++; y--;
- 		moves += 2;
- 		dv += ( ((x-y) << 1) + 1 );
- 		SPAN(x, y, 1);
- 		lasty = y;	
- 		}
- 	   else { /* go axial */
- 		y--;
- 		moves++;
- 		dv += ( 1 - (y<<1));
- 		SPAN(x, y, 1);
- 		}
- 	}
- 
- ncirclespans = nspans - 1;
- return ;
- }
- 
- static void
- ComputeEQuad(a, b)
- 	int a, b;
- 	{
- 	long int 	TwoBsq, TwoAsq, dv1, dv2, TwoBsqX, TwoAsqY;
- 	int		x, y, startx;
- 	int		r, *pwidth, *pwidthInit, nspans;
- 	MyPointRec	*ppt, *pptInit;
- 
- 	if ( a == lasta && b == lastb )
- 		return;
- 
- 	x = 0; y = b;
- 	startx = 1;
- 	r = ( a>b ? a : b );
- 
- 	pptInit = ppt = 
- 		(MyPointPtr) Xalloc( ( ( 14 + 8 * r ) * sizeof(MyPointRec)));
- 	if (ppt == 0)
- 		{
- 		ErrorF("ComputeEQuad: cannot malloc ppt");
- 		return ;
- 		}
- 
- 	pwidthInit = pwidth = 
- 			(int *) Xalloc( ( ( 14 + 8 * r ) * sizeof(int)) );
- 	if (pwidth == 0)
- 		{
- 		Xfree(ppt);
- 		ErrorF("ComputeEQuad: cannot malloc pwidth");
- 		return ;
- 		}
- 
- 	Xfree(ellipsePts);
- 	Xfree(ellipseWidths);
- 
- 	nspans = 0;
- 
- 	TwoBsq = (b * b) << 1 ;
- 	TwoAsq = (a * a) << 1 ;
- 	TwoBsqX = 0; /* x is still zero */
- 	TwoAsqY = TwoAsq * y;
- 
- 	dv2 = - (b * TwoAsq);	 /* use dv2 as a temp to hold -2b(aa) */
- 	dv1 = (TwoBsq >> 1) + (dv2 >> 1) + (TwoAsq >> 3);
- 	dv2 += (TwoBsq >> 3) + (TwoAsq >> 1) ;
- 
- 	/*START LOOP */
- 	while (dv2 < 0)
- 		{
- 		/* REGION 1 */
- 		x++;
- 		TwoBsqX += TwoBsq;
- 		if (dv1 < 0)
- 			{ /* MOVE AXIAL */
- 			dv1 += TwoBsqX + (TwoBsq >> 1);
- 			dv2 += TwoBsqX;
- 			}
- 		else 
- 			{ /* MOVE DIAGONAL */
- 			ppt->x = startx;
- 			ppt->y = y;
- 			*pwidth = x - startx;
- 			ppt++; pwidth++; nspans++;
- 			startx = x;
- 			y--;
- 			TwoAsqY -= TwoAsq;
- 			dv1 += TwoBsqX - TwoAsqY + (TwoBsq >> 1);
- 			dv2 += (TwoAsq >> 1) - TwoAsqY + TwoBsqX ;
- 			}
- 		}
- 
- 		ppt->x = startx;
- 		ppt->y = y;
- 		*pwidth = x - startx + 1;
- 		ppt++; pwidth++; nspans++;
- 
- 	while (y>1)
- 		{
- 		/* REGION 2 */
- 		y--;
- 		TwoAsqY -= TwoAsq;
- 		if (dv2 < 0)
- 			{  /* diagonal move */
- 			x++;
- 			TwoBsqX += TwoBsq;
- 			dv2 += (TwoAsq>>1) - TwoAsqY + TwoBsqX;
- 			}
- 		else 
- 			{  /* axial move */
- 			dv2 += (TwoAsq >> 1) - TwoAsqY;
- 			}
- 		ppt->x = x;
- 		ppt->y = y;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 		}
- 
- 	nellipsespans = nspans;
- 	ellipsePts = pptInit;
- 	ellipseWidths = pwidthInit;
- 	return ;
- 	}
- 
- static void
- ComputeQuad( a, b )
- 	int a, b;
- 	{
- 	if ( a == b )
- 		{
- 		ComputeCQuad( a );
- 		quadPts = circlePts;
- 		quadWidths = circleWidths;
- 		nquadspans = ncirclespans;
- 		}
- 	else
- 		{
- 		ComputeEQuad( a, b );
- 		quadPts = ellipsePts;
- 		quadWidths = ellipseWidths;
- 		nquadspans = nellipsespans;
- 		}
- 	}
- 
- static void
- DrawFullArcOnHW(paint, pRect, color, alu, pm)
- 	register void 	(*paint)();
- 	xRectangle	*pRect;
- 	int		color;
- 	int 		alu;
- 	int		pm;
- 	{
- 	register int 	dv;
- 	short		x, y;
- 	int		diam;
- 	int		cxL, cxR, cyL, cyU;
- 	int		startx, lasty, width, xR, xL, yU, yL;
- 	int		nspans, *pwidth;
- 	MyPointPtr	ppt;
- 	int		a, b;
- 
- 	a = ( pRect->width - 1 ) >> 1;
- 	b = ( pRect->height - 1 ) >> 1;
- 
- 	if ( pRect->width & 1)
- 		{
- 		cxL = cxR = pRect->x + a;
- 		(*paint)(color, alu, pm, cxL, pRect->y, 1, 1) ;
- 		(*paint)(color, alu, pm, cxL, pRect->y + pRect->height - 1, 1, 1) ;
- 		}
- 	else
- 		{
- 		cxL = pRect->x + a;
- 		cxR = pRect->x + a + 1;
- 		(*paint)(color, alu, pm, cxL, pRect->y, 2, 1) ;
- 		(*paint)(color, alu, pm, cxL, pRect->y + pRect->height - 1, 2, 1) ;
- 		}
- 
- 	if ( pRect->height & 1)
- 		{
- 		cyL = cyU = pRect->y + b;
- 		(*paint)(color, alu, pm, pRect->x, cyU, 1, 1) ;
- 		(*paint)(color, alu, pm, pRect->x + pRect->width - 1, cyU, 1, 1) ;
- 		}
- 	else
- 		{
- 		cyU = pRect->y + b;
- 		cyL = pRect->y + b + 1;
- 		(*paint)(color, alu, pm, pRect->x, cyU, 1, 2) ;
- 		(*paint)(color, alu, pm, pRect->x + pRect->width - 1, cyU, 1, 2) ;
- 		}
- 
- 	ComputeQuad(a,b);
- 
- 	for( nspans = nquadspans, ppt = quadPts, pwidth = quadWidths;
- 			nspans > 0; nspans--, ppt++, pwidth++ )
- 		{
- 		PAINT(ppt->x, ppt->y, *pwidth);
- 		}
- 
- 	return ;
- 	}
- 
- static void
- FillFullArcOnHW(paint, pRect, color, alu, pm)
- 	register void 	(*paint)();
- 	xRectangle	*pRect;
- 	int		color;
- 	int 		alu;
- 	int		pm;
- 	{
- 	register int 	dv;
- 	short		x, y;
- 	int		diam;
- 	int		cxL, cxR, cyL, cyU;
- 	int		startx, lasty, width, xR, xL, yU, yL;
- 	int		nspans, *pwidth;
- 	MyPointPtr	ppt;
- 	int		a, b, w;
- 
- 	a = ( pRect->width - 1 ) >> 1;
- 	b = ( pRect->height - 1 ) >> 1;
- 
- 	if ( pRect->width & 1 )
- 		{
- 		cxL = cxR = pRect->x + a;
- 		}
- 	else
- 		{
- 		cxL = pRect->x + a;
- 		cxR = pRect->x + a + 1;
- 		}
- 		
- 	if ( pRect->height & 1)
- 		{
- 		cyL = cyU = pRect->y + b;
- 		(*paint)(color, alu, pm, pRect->x, cyU, pRect->width, 1) ;
- 		}
- 	else
- 		{
- 		cyU = pRect->y + b;
- 		cyL = pRect->y + b + 1;
- 		(*paint)(color, alu, pm, pRect->x, cyU, pRect->width, 2) ;
- 		}
- 
- 	ComputeQuad(a,b);
- 
- 	for( nspans = nquadspans, ppt = quadPts, pwidth = quadWidths;
- 			nspans > 0; nspans--, ppt++, pwidth++ )
- 		{
- 		xL = cxL - ppt->x - *pwidth + 1;
- 		yU = cyU - ppt->y;
- 		yL = cyL + ppt->y;
- 		if ( cxL == cxR )
- 			w = ( ( ppt->x + *pwidth - 1 ) << 1 ) + 1;
- 		else
- 			w = ( ( ppt->x + *pwidth - 1 ) << 1 ) + 2;
- 
- 		(*paint)(color, alu, pm, xL, yU, w, 1);
- 		(*paint)(color, alu, pm, xL, yL, w, 1);
- 		}
- 
- 	return ;
- 	}
- 
- static void
- DrawFullArcOnSpans(pWindow, pGC, pRect)
- 	WindowPtr	pWindow;
- 	GCPtr		pGC;
- 	xRectangle	*pRect;
- 	{
- 	register int 	dv;
- 	short		r, moves, x, y;
- 	int		diam;
- 	int		cxL, cxR, cyL, cyU;
- 	int		startx, lasty, width, xR, xL, yU, yL;
- 	MyPointPtr	pptInit, ppt, pptsrc, p1, p2, p3, p4;
- 	int		nspans, *pwidthInit, *pwidth, *pwidthsrc;
- 	int		i;
- 	int		a, b;
- 
- 	a = ( pRect->width - 1 ) >> 1;
- 	b = ( pRect->height - 1 ) >> 1;
- 	nspans = 0;
- 
- 	ComputeQuad(a,b);
- 
- 	/* allocate space for the spans */
- 	pptInit = ppt = (MyPointPtr) Xalloc( ( ( 8 + nquadspans * 4 ) * sizeof(MyPointRec)));
- 	if (ppt == 0)
- 		{
- 		ErrorF("ppcZeroCircle: DrawCircleOnSpans: cannot malloc ppt");
- 		return ;
- 		}
- 
- 	pwidthInit = pwidth = (int *) Xalloc( ( ( 8 + nquadspans * 4 ) * sizeof(int)) );
- 	if (pwidth == 0)
- 		{
- 		Xfree(ppt);
- 		ErrorF("ppcZeroCircle: DrawCircleOnSpans: cannot malloc pwidth");
- 		return ;
- 		}
- 
- 	/* take care of joining point of reflection; worry about Jeffshift */
- 
- 	if ( pRect->width & 1)
- 		{
- 		cxL = cxR = pRect->x + a;
- 
- 		ppt->x = cxL; ppt->y = pRect->y;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 
- 		ppt->x = cxL; ppt->y = pRect->y + pRect->height - 1;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 		}
- 	else
- 		{
- 		cxL = pRect->x + a;
- 		cxR = pRect->x + a + 1;
- 		ppt->x = cxL; ppt->y = pRect->y;
- 		*pwidth = 2;
- 		ppt++; pwidth++; nspans++;
- 
- 		ppt->x = cxL; ppt->y = pRect->y + pRect->height - 1;
- 		*pwidth = 2;
- 		ppt++; pwidth++; nspans++;
- 		}
- 
- 	if ( pRect->height & 1)
- 		{
- 		cyL = cyU = pRect->y + b;
- 
- 		ppt->x = pRect->x; ppt->y = cyU;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 
- 		ppt->x = pRect->x + pRect->width - 1; ppt->y = cyU;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 		}
- 	else
- 		{
- 		cyU = pRect->y + b;
- 		cyL = pRect->y + b + 1;
- 
- 		ppt->x = pRect->x; ppt->y = cyU;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 		ppt->x = pRect->x; ppt->y = cyL;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 
- 		ppt->x = pRect->x + pRect->width - 1; ppt->y = cyU;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 		ppt->x = pRect->x + pRect->width - 1; ppt->y = cyL;
- 		*pwidth = 1;
- 		ppt++; pwidth++; nspans++;
- 		}
- 
- 	MOVE( quadWidths, pwidth, nquadspans * sizeof(int) );
- 	pwidth += nquadspans;
- 	MOVE( quadWidths, pwidth, nquadspans * sizeof(int) );
- 	pwidth += nquadspans;
- 	MOVE( quadWidths, pwidth, nquadspans * sizeof(int) );
- 	pwidth += nquadspans;
- 	MOVE( quadWidths, pwidth, nquadspans * sizeof(int) );
- 
- 	for( i = nquadspans, p1 = ppt, p2 = p1 + nquadspans, 
- 			p3 = p2 + nquadspans, p4 = p3 + nquadspans, 
- 			pptsrc = quadPts, pwidthsrc = quadWidths; 
- 		i > 0; 
- 		i--, p1++, p2++, p3++, p4++, pptsrc++, pwidthsrc++ )
- 		{
- 
- 		xR = cxR + pptsrc->x;
- 		xL = cxL - pptsrc->x - *pwidthsrc + 1;
- 		yU = cyU - pptsrc->y ;
- 		yL = cyL + pptsrc->y ;
- 		/* Quadrant 1 */ p1->x = xR; p1->y = yU;
- 		/* Quadrant 2 */ p2->x = xL; p2->y = yU;
- 		/* Quadrant 3 */ p3->x = xL; p3->y = yL;
- 		/* Quadrant 4 */ p4->x = xR; p4->y = yL;
- 	
- 		}
- 
- 	(* pGC->ops->FillSpans)( pWindow, pGC, nspans + (nquadspans << 2), 
- 					pptInit, pwidthInit, FALSE );
- 
- 	Xfree(pptInit);
- 	Xfree(pwidthInit);
- 
- 	return ;
- 	}
- 
- static void
- FillFullArcOnSpans(pWindow, pGC, pRect)
- 	WindowPtr	pWindow;
- 	GCPtr		pGC;
- 	xRectangle	*pRect;
- 	{
- 	register int 	dv;
- 	short		r, moves, x, y;
- 	int		diam;
- 	int		cxL, cxR, cyL, cyU;
- 	int		startx, lasty, width, xR, xL, yU, yL;
- 	MyPointPtr	pptInit, ppt, pptsrc, p1, p2, p3, p4;
- 	int		nspans, *pwidthInit, *pwidth, *pwidthsrc;
- 	int		i;
- 	int		a, b, w;
- 
- 	a = ( pRect->width - 1 ) >> 1;
- 	b = ( pRect->height - 1 ) >> 1;
- 	nspans = 0;
- 
- 	ComputeQuad(a,b);
- 
- 	/* allocate space for the spans */
- 	pptInit = ppt = (MyPointPtr) Xalloc( ( ( 8 + nquadspans * 2 ) * sizeof(MyPointRec)));
- 	if (ppt == 0)
- 		{
- 		ErrorF("ppcZeroCircle: DrawCircleOnSpans: cannot malloc ppt");
- 		return ;
- 		}
- 
- 	pwidthInit = pwidth = (int *) Xalloc( ( ( 8 + nquadspans * 2 ) * sizeof(int)) );
- 	if (pwidth == 0)
- 		{
- 		Xfree(ppt);
- 		ErrorF("ppcZeroCircle: DrawCircleOnSpans: cannot malloc pwidth");
- 		return ;
- 		}
- 
- 	/* take care of joining point of reflection; worry about Jeffshift */
- 
- 	if ( pRect->width & 1)
- 		{
- 		cxL = cxR = pRect->x + a;
- 		}
- 	else
- 		{
- 		cxL = pRect->x + a;
- 		cxR = pRect->x + a + 1;
- 		}
- 
- 	if ( pRect->height & 1)
- 		{
- 		cyL = cyU = pRect->y + b;
- 
- 		ppt->x = pRect->x; ppt->y = cyU;
- 		*pwidth = pRect->width;
- 		ppt++; pwidth++; nspans++;
- 		}
- 	else
- 		{
- 		cyU = pRect->y + b;
- 		cyL = pRect->y + b + 1;
- 
- 		ppt->x = pRect->x; ppt->y = cyU;
- 		*pwidth = pRect->width;
- 		ppt++; pwidth++; nspans++;
- 		ppt->x = pRect->x; ppt->y = cyL;
- 		*pwidth = pRect->width;
- 		ppt++; pwidth++; nspans++;
- 
- 		}
- 
- 	for( i = nquadspans, pptsrc = quadPts, pwidthsrc = quadWidths; 
- 		i > 0; 
- 		i--, pptsrc++, pwidthsrc++ )
- 		{
- 
- 		xL = cxL - pptsrc->x - *pwidthsrc + 1;
- 		yU = cyU - pptsrc->y ;
- 		yL = cyL + pptsrc->y ;
- 
- 		if ( cxL == cxR )
- 			w = ( ( pptsrc->x + *pwidthsrc - 1 ) << 1 ) + 1;
- 		else
- 			w = ( ( pptsrc->x + *pwidthsrc - 1 ) << 1 ) + 2;
- 
- 		ppt->x = xL; ppt->y = yU;
- 		*pwidth = w;
- 		ppt++; pwidth++;
- 
- 		ppt->x = xL; ppt->y = yL;
- 		*pwidth = w;
- 		ppt++; pwidth++;
- 		}
- 
- 	(* pGC->ops->FillSpans)( pWindow, pGC, nspans + (nquadspans << 1), 
- 					pptInit, pwidthInit, FALSE );
- 
- 	Xfree(pptInit);
- 	Xfree(pwidthInit);
- 
- 	return ;
- 	}
- 
- static void
- DrawArcOnSpans(pWindow, pGC, pArc)
- WindowPtr	pWindow;
- GCPtr		pGC;
- xArc		*pArc;
- {
- int		cxL, cxR, cyL, cyU;
- int		xR, xL, yU, yL;
- MyPointPtr	pptInit, ppt, pptsrc, p1, p2, p3, p4;
- int		nspans, *pwidthInit, *pwidth, *pwidthsrc;
- int		i;
- int		aQuad, bQuad;
- MyPointRec	pta, ptb;
- int		shortArc = 0, longArc = 0;
- int		q, tmpspans, *tmppwidth;
- int		topPt = 0, botPt = 0;
- int		leftPt = 0, rightPt = 0;
- int		x1, x2, y1, y2;
- int		a, b;
- 
- x2 = (x1 = pWindow->drawable.x + pArc->x) + pArc->width -1;
- y2 = (y1 = pWindow->drawable.y + pArc->y) + pArc->height -1;
- 
- a = ( pArc->width - 1 ) >> 1;
- b = ( pArc->height - 1 ) >> 1;
- 
- if ( pArc->width & 1)
- 	{
- 	cxL = cxR = pArc->x + a;
- 	}
- else
- 	{
- 	cxL = pArc->x + a;
- 	cxR = pArc->x + a + 1;
- 	}
- 
- if ( pArc->height & 1)
- 	{
- 	cyL = cyU = pArc->y + b;
- 	}
- else
- 	{
- 	cyU = pArc->y + b;
- 	cyL = pArc->y + b + 1;
- 	}
- 
- ComputeQuad( a, b );
- 
- /* allocate space for the spans */
- pptInit = ppt = (MyPointPtr) Xalloc( ( ( 6 + nquadspans * 4 ) * sizeof(MyPointRec)));
- if (ppt == 0)
- 	{
- 	ErrorF("ppcZeroCircle: DrawCArcOnSpans: cannot malloc ppt");
- 	return ;
- 	}
- 
- pwidthInit = pwidth = (int *) Xalloc( ( ( 6 + nquadspans * 4 ) * sizeof(int)) );
- if (pwidth == 0)
- 	{
- 	Xfree(ppt);
- 	ErrorF("ppcZeroCircle: DrawCArcOnSpans: cannot malloc pwidth");
- 	return ;
- 	}
- 
- nspans = 0;
- 
- GetPts(pArc, &pta, &ptb);
- 
- if ( pta.x > a )
- 	pta.x = a;
- if ( pta.y > b )
- 	pta.y = b;
- 
- if ( ptb.x > a )
- 	ptb.x = a;
- if ( ptb.y > b )
- 	ptb.y = b;
- 
- #define QUAD(X,Y) (((X)>=0) ? ((Y)>0 ? 4 : 1) : ((Y)>0 ? 3:2))
- 
- aQuad = QUAD(pta.x, pta.y);
- bQuad = QUAD(ptb.x, ptb.y);
- 
- /*
- printf("a = (%d,%d), b = (%d,%d)\n", pta.x, pta.y, ptb.x, ptb.y );
- printf("aQuad = %d, bQuad = %d\n", aQuad, bQuad);
- */
- 
- if ( bQuad == aQuad )
- 	{
- 	if ( pta.y > 0 )
- 		{
- 		if( pta.x > ptb.x )
- 			{
- 			longArc = 1;
- 			}
- 		else
- 			shortArc = 1;
- 		}
- 	else
- 		{
- 		if( pta.x < ptb.x )
- 			{
- 			longArc = 1;
- 			}
- 		else
- 			shortArc = 1;
- 		}
- 	}
- 
- if( shortArc ) /* arc is within one quadrant */
- 	{
- /*
- printf("shortArc\n");
- */
- 	switch( aQuad )
- 		{
- 		case 1:
- 			pptsrc = quadPts + b - MAX(-pta.y, -ptb.y);
- 			pwidthsrc = quadWidths + b - MAX(-pta.y, -ptb.y);
- 			nspans = ABS( pta.y - ptb.y ) + 1;
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++ )
- 				{
- 				ppt->x = cxR + pptsrc->x;
- 				ppt->y = cyU - pptsrc->y;
- 				}
- 			break;
- 		case 2:
- 			pptsrc = quadPts + b - MAX(-pta.y, -ptb.y);
- 			pwidth = pwidthsrc = quadWidths + b - MAX(-pta.y, -ptb.y);
- 			nspans = ABS( pta.y - ptb.y ) + 1;
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++, pwidth++ )
- 				{
- 				ppt->x = cxL - pptsrc->x - *pwidth + 1;
- 				ppt->y = cyU - pptsrc->y;
- 				}
- 			break;
- 		case 3:
- 			pptsrc = quadPts + b - MAX(pta.y, ptb.y);
- 			pwidth = pwidthsrc = quadWidths + b - MAX(pta.y, ptb.y);
- 			nspans = ABS( pta.y - ptb.y ) + 1;
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++, pwidth++ )
- 				{
- 				ppt->x = cxL - pptsrc->x - *pwidth + 1;
- 				ppt->y = cyL + pptsrc->y;
- 				}
- 			break;
- 		case 4:
- 			pptsrc = quadPts + b - MAX(pta.y, ptb.y);
- 			pwidthsrc = quadWidths + b - MAX(pta.y, ptb.y);
- 			nspans = ABS( pta.y - ptb.y ) + 1;
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++, pwidth++ )
- 				{
- 				ppt->x = cxR + pptsrc->x;
- 				ppt->y = cyL + pptsrc->y;
- 				}
- 			break;
- 		}
- 	(* pGC->ops->FillSpans)( pWindow, pGC, nspans, pptInit, pwidthsrc, FALSE );
- 	
- 	}
- else if ( longArc )
- 	{
- /*
- printf("longArc\n");
- */
- 
- 	/* take care of joining point of reflection; worry about Jeffshift */
- 	ppt->x = x1; ppt->y = cyU; *pwidth = 1;
- 	ppt++; pwidth++;
- 	ppt->x = x2; ppt->y = cyU; *pwidth = 1;
- 	ppt++; pwidth++;
- 
- 	if (cxL == cxR)
- 		{
- 		ppt->x = cxL; ppt->y = y1; *pwidth = 1;
- 		ppt++; pwidth++;
- 		ppt->x = cxL; ppt->y = y2; *pwidth = 1;
- 		ppt++; pwidth++;
- 		nspans = 4;
- 		}
- 	else 
- 		{  /* Jeffshift */
- 		ppt->x = cxL; ppt->y = y1; *pwidth = 2;
- 		ppt++; pwidth++;
- 		ppt->x = cxL; ppt->y = y2; *pwidth = 2;
- 		ppt++; pwidth++;
- 		ppt->x = x1; ppt->y = cyL; *pwidth = 1;
- 		ppt++; pwidth++;
- 		ppt->x = x2; ppt->y = cyL; *pwidth = 1;
- 		ppt++; pwidth++;
- 		nspans = 6;
- 		}
- 
- 	MOVE( quadWidths, pwidth, nquadspans * sizeof(int) );
- 	pwidth += nquadspans;
- 	MOVE( quadWidths, pwidth, nquadspans * sizeof(int) );
- 	pwidth += nquadspans;
- 	MOVE( quadWidths, pwidth, nquadspans * sizeof(int) );
- 	pwidth += nquadspans;
- 
- 	nspans = nquadspans * 3 + nspans;
- 
- 	switch ( aQuad )
- 		{
- 		case 1:
- 			for( i = nquadspans, p2 = ppt,
- 					p3 = p2 + nquadspans,
- 					p4 = p3 + nquadspans,
- 					p1 = p4 + nquadspans,
- 					pptsrc = quadPts,
- 					pwidthsrc = quadWidths;
- 				i > 0;
- 				i--, p2++, p3++, p4++, pptsrc++,
- 					pwidthsrc++ )
- 				{
- 
- 				xR = cxR + pptsrc->x;
- 				xL = cxL - pptsrc->x - *pwidthsrc + 1;
- 				yU = cyU - pptsrc->y ;
- 				yL = cyL + pptsrc->y ;
- 				/* Quadrant 2 */ p2->x = xL; p2->y = yU;
- 				/* Quadrant 3 */ p3->x = xL; p3->y = yL;
- 				/* Quadrant 4 */ p4->x = xR; p4->y = yL;
- 				if ( ( (-(pptsrc->y)) < MIN(pta.y, ptb.y) ) 
- 					|| ( (-(pptsrc->y)) > MAX(pta.y, ptb.y) ) )
- 					{
- 					/* Quadrant 1 */ 
- 					p1->x = xR; p1->y = yU;
- 					p1++;
- 					*pwidth = *pwidthsrc;
- 					pwidth++;
- 					nspans++;
- 					}
- 				}
- 			break;
- 
- 		case 2:
- 			for( i = nquadspans, p1 = ppt,
- 					p3 = p1 + nquadspans,
- 					p4 = p3 + nquadspans,
- 					p2 = p4 + nquadspans,
- 					pptsrc = quadPts,
- 					pwidthsrc = quadWidths;
- 				i > 0;
- 				i--, p1++, p3++, p4++, pptsrc++,
- 					pwidthsrc++ )
- 				{
- 
- 				xR = cxR + pptsrc->x;
- 				xL = cxL - pptsrc->x - *pwidthsrc + 1;
- 				yU = cyU - pptsrc->y ;
- 				yL = cyL + pptsrc->y ;
- 				/* Quadrant 1 */ p1->x = xR; p1->y = yU;
- 				/* Quadrant 3 */ p3->x = xL; p3->y = yL;
- 				/* Quadrant 4 */ p4->x = xR; p4->y = yL;
- 				if ( ( (-(pptsrc->y)) < MIN(pta.y, ptb.y) ) 
- 					|| ( (-(pptsrc->y)) > MAX(pta.y, ptb.y) ) )
- 					{
- 					/* Quadrant 2 */ 
- 					p2->x = xL; p2->y = yU;
- 					p2++;
- 					*pwidth = *pwidthsrc;
- 					pwidth++;
- 					nspans++;
- 					}
- 				}
- 			break;
- 
- 		case 3:
- 			for( i = nquadspans, p1 = ppt,
- 					p2 = p1 + nquadspans,
- 					p4 = p2 + nquadspans,
- 					p3 = p4 + nquadspans,
- 					pptsrc = quadPts,
- 					pwidthsrc = quadWidths;
- 				i > 0;
- 				i--, p1++, p2++, p4++, pptsrc++,
- 					pwidthsrc++ )
- 				{
- 
- 				xR = cxR + pptsrc->x;
- 				xL = cxL - pptsrc->x - *pwidthsrc + 1;
- 				yU = cyU - pptsrc->y ;
- 				yL = cyL + pptsrc->y ;
- 				/* Quadrant 1 */ p1->x = xR; p1->y = yU;
- 				/* Quadrant 2 */ p2->x = xL; p2->y = yU;
- 				/* Quadrant 4 */ p4->x = xR; p4->y = yL;
- 				if ( ( pptsrc->y < MIN(pta.y, ptb.y) ) 
- 					|| ( pptsrc->y > MAX(pta.y, ptb.y) ) )
- 					{
- 					/* Quadrant 3 */ 
- 					p3->x = xL; p3->y = yL;
- 					p3++;
- 					*pwidth = *pwidthsrc;
- 					pwidth++;
- 					nspans++;
- 					}
- 				}
- 			break;
- 			
- 		case 4:
- 			for( i = nquadspans, p1 = ppt,
- 					p2 = p1 + nquadspans,
- 					p3 = p2 + nquadspans,
- 					p4 = p3 + nquadspans,
- 					pptsrc = quadPts,
- 					pwidthsrc = quadWidths;
- 				i > 0;
- 				i--, p1++, p2++, p3++, pptsrc++,
- 					pwidthsrc++ )
- 				{
- 
- 				xR = cxR + pptsrc->x;
- 				xL = cxL - pptsrc->x - *pwidthsrc + 1;
- 				yU = cyU - pptsrc->y ;
- 				yL = cyL + pptsrc->y ;
- 				/* Quadrant 1 */ p1->x = xR; p1->y = yU;
- 				/* Quadrant 2 */ p2->x = xL; p2->y = yU;
- 				/* Quadrant 3 */ p3->x = xL; p3->y = yL;
- 				if ( ( pptsrc->y < MIN(pta.y, ptb.y) ) 
- 					|| ( pptsrc->y > MAX(pta.y, ptb.y) ) )
- 					{
- 					/* Quadrant 4 */ 
- 					p4->x = xR; p4->y = yL;
- 					p4++;
- 					*pwidth = *pwidthsrc;
- 					pwidth++;
- 					nspans++;
- 					}
- 				}
- 			break;
- 
- 		}
- 	(* pGC->ops->FillSpans)( pWindow, pGC, nspans, pptInit, pwidthInit, FALSE );
- 	}
- else /* start and end of arc are not in same quadrant */
- 	{
- /*
- printf("mediumArc\n");
- */
- 	/* first we draw the starting part of the arc */
- 	switch ( aQuad )
- 		{
- 		case 1:
- 			pptsrc = quadPts;
- 			pwidthsrc = quadWidths;
- 			nspans = MIN(pta.y + b + 1, b);
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++ )
- 				{
- 				ppt->x = cxR + pptsrc->x;
- 				ppt->y = cyU - pptsrc->y;
- 				}
- 			topPt = 1;
- 			break;
- 		case 2:
- 			pptsrc = quadPts + b + pta.y;
- 			tmppwidth = pwidthsrc = quadWidths + b + pta.y;
- 			nspans = -pta.y;
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++, tmppwidth++ )
- 				{
- 				ppt->x = cxL - pptsrc->x - *tmppwidth + 1;
- 				ppt->y = cyU - pptsrc->y;
- 				}
- 			leftPt = 1;
- 			break;
- 		case 3:
- 			pptsrc = quadPts;
- 			tmppwidth = pwidthsrc = quadWidths;
- 			nspans = MIN(b - pta.y + 1, b);
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++, tmppwidth++ )
- 				{
- 				ppt->x = cxL - pptsrc->x - *tmppwidth + 1;
- 				ppt->y = cyL + pptsrc->y;
- 				}
- 			botPt = 1;
- 			break;
- 		case 4:
- 			pptsrc = quadPts + b - pta.y;
- 			pwidthsrc = quadWidths + b - pta.y;
- 			nspans = pta.y;
- 			for ( i = 0; i < nspans; i++, pptsrc++, ppt++ )
- 				{
- 				ppt->x = cxR + pptsrc->x;
- 				ppt->y = cyL + pptsrc->y;
- 				}
- 			rightPt = 1;
- 			break;
- 		}
- /*
- 	printf("medium: first move\n");
- */
- 
- 	MOVE( pwidthsrc, pwidth, nspans * sizeof(int) );
- 	pwidth += nspans;
- 
- #ifdef notdef
- 	if ( ( *( pwidth - 1 ) ) > 5 )
- 		{
- 	printf("ppt->x = %d, ppt->y = %d, *pwidth = %d\n", 
- 		(ppt-1)->x, (ppt-1)->y, *(pwidth-1) );
- 	printf("medium: first move\n");
- 	printf("aQuad = %d\n", aQuad);
- 	printf("pwidthsrc = 0x%x, pwidth = 0x%x, nspans = %d\n",
- 		pwidthsrc, pwidth, nspans );
- 	printf("a = %d, b = %d, pta = (%d,%d)\n", a, b, pta.x, pta.y);
- 		}
- #endif
- 
- 	/* next we draw the end of the arc */
- 	switch ( bQuad)
- 		{
- 		case 1:
- 			pptsrc = quadPts + b + ptb.y;
- 			pwidthsrc = quadWidths + b + ptb.y;
- 			tmpspans = -ptb.y;
- 			for ( i = 0; i < tmpspans; i++, pptsrc++, ppt++ )
- 				{
- 				ppt->x = cxR + pptsrc->x;
- 				ppt->y = cyU - pptsrc->y;
- 				}
- 			rightPt = 1;
- 			break;
- 		case 2:
- 			pptsrc = quadPts;
- 			tmppwidth = pwidthsrc = quadWidths;
- 			tmpspans = MIN(b + ptb.y + 1, b);
- 			for ( i = 0; i < tmpspans; i++, pptsrc++, ppt++, tmppwidth++ )
- 				{
- 				ppt->x = cxL - pptsrc->x - *tmppwidth + 1;
- 				ppt->y = cyU - pptsrc->y;
- 				}
- 			topPt = 1;
- 			break;
- 		case 3:
- 			pptsrc = quadPts + b - ptb.y;
- 			tmppwidth = pwidthsrc = quadWidths + b - ptb.y;
- 			tmpspans = ptb.y;
- 			for ( i = 0; i < tmpspans; i++, pptsrc++, ppt++, tmppwidth++ )
- 				{
- 				ppt->x = cxL - pptsrc->x - *tmppwidth + 1;
- 				ppt->y = cyL + pptsrc->y;
- 				}
- 			leftPt = 1;
- 			break;
- 		case 4:
- 			pptsrc = quadPts;
- 			pwidthsrc = quadWidths;
- 			tmpspans = MIN(b - ptb.y + 1, b);
- 			for ( i = 0; i < tmpspans; i++, pptsrc++, ppt++ )
- 				{
- 				ppt->x = cxR + pptsrc->x;
- 				ppt->y = cyL + pptsrc->y;
- 				}
- 			botPt = 1;
- 			break;
- 		}
- 
- 
- 
- 	MOVE( pwidthsrc, pwidth, tmpspans * sizeof(int) );
- 	pwidth += tmpspans;
- 	nspans += tmpspans;
- 
- #ifdef notdef
- 	if ( ( *( pwidth - 1 ) ) > 5 )
- 		{
- 	printf("ppt->x = %d, ppt->y = %d, *pwidth = %d\n", 
- 		(ppt-1)->x, (ppt-1)->y, *(pwidth-1) );
- 	printf("medium: second move\n");
- 	printf("bQuad = %d\n", bQuad);
- 	printf("pwidthsrc = 0x%x, pwidth = 0x%x, tmpspans = %d\n",
- 		pwidthsrc, pwidth, tmpspans );
- 	printf("a = %d, b = %d, ptb = (%d,%d)\n", a, b, ptb.x, ptb.y);
- 		}
- #endif
- 
- 	
- 	/*
- 	 * Fill the whole quads.
- 	 */
- 	q = aQuad + 1;
- 	if ( q == 5 ) q = 1;
- 	while ( q != bQuad )
- 		{
- 		switch ( q )
- 			{
- 			case 1:
- 				pptsrc = quadPts;
- 				pwidthsrc = quadWidths;
- 				for ( i = 0; i < nquadspans; i++, pptsrc++, ppt++ )
- 					{
- 					ppt->x = cxR + pptsrc->x;
- 					ppt->y = cyU - pptsrc->y;
- 					}
- 				topPt = 1;
- 				rightPt = 1;
- 				break;
- 			case 2:
- 				pptsrc = quadPts;
- 				tmppwidth = pwidthsrc = quadWidths;
- 				for ( i = 0; i < nquadspans; i++, pptsrc++, ppt++, tmppwidth++ )
- 					{
- 					ppt->x = cxL - pptsrc->x - *tmppwidth + 1;
- 					ppt->y = cyU - pptsrc->y;
- 					}
- 				topPt = 1;
- 				leftPt = 1;
- 				break;
- 			case 3:
- 				pptsrc = quadPts;
- 				tmppwidth = pwidthsrc = quadWidths;
- 				for ( i = 0; i < nquadspans; i++, pptsrc++, ppt++, tmppwidth++ )
- 					{
- 					ppt->x = cxL - pptsrc->x - *tmppwidth + 1;
- 					ppt->y = cyL + pptsrc->y;
- 					}
- 				botPt = 1;
- 				leftPt = 1;
- 				break;
- 			case 4:
- 				pptsrc = quadPts;
- 				pwidthsrc = quadWidths;
- 				for ( i = 0; i < nquadspans; i++, pptsrc++, ppt++ )
- 					{
- 					ppt->x = cxR + pptsrc->x;
- 					ppt->y = cyL + pptsrc->y;
- 					}
- 				botPt = 1;
- 				rightPt = 1;
- 				break;
- 			}
- /*
- 		printf("medium: third move\n");
- */
- 		MOVE( pwidthsrc, pwidth, nquadspans * sizeof(int) );
- 		pwidth += nquadspans;
- 		nspans += nquadspans;
- 
- 		q++;
- 		if ( q == 5 ) q = 1;
- 		}
- 
- 	/* take care of joining point of reflection; worry about Jeffshift */
- 
- 
- 	if (cxL == cxR)
- 		{
- 		if ( topPt )
- 			{
- 			ppt->x = cxL; ppt->y = y1; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 		if ( botPt )
- 			{
- 			ppt->x = cxL; ppt->y = y2; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 		}
- 	else 
- 		{  /* Jeffshift */
- 		if ( topPt )
- 			{
- 			ppt->x = cxL; ppt->y = y1; *pwidth = 2;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 		if ( botPt )
- 			{
- 			ppt->x = cxL; ppt->y = y2; *pwidth = 2;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 		}
- 	if ( cyU == cyL )
- 		{  /* no jeffshift */
- 		if ( leftPt )
- 			{
- 			ppt->x = x1; ppt->y = cyL; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 		if ( rightPt )
- 			{
- 			ppt->x = x2; ppt->y = cyL; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 		}
- 	else
- 		{  /* jeffshift */
- 		if ( leftPt )
- 			{
- 			ppt->x = x1; ppt->y = cyL; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			ppt->x = x1; ppt->y = cyU; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 		if ( rightPt )
- 			{
- 			ppt->x = x2; ppt->y = cyL; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			ppt->x = x2; ppt->y = cyU; *pwidth = 1;
- 			ppt++; pwidth++;
- 			nspans++;
- 			}
- 
- 		}
- 	(* pGC->ops->FillSpans)( pWindow, pGC, nspans, pptInit, pwidthInit, FALSE );
- 	}
- 
- Xfree(pptInit);
- Xfree(pwidthInit);
- 
- return ;
- }
--- 0 ----
diff -c mit/server/ddx/x386/vga16/ibm/ppcArea.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcArea.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcArea.c:2.0	Fri Mar 11 23:40:30 1994
--- mit/server/ddx/x386/vga16/ibm/ppcArea.c	Fri Mar 11 23:40:30 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcArea.c,v 2.0 1993/08/19 16:08:33 dawes Exp $ */
  /* Header: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/ppc/RCS/ppcArea.c,v 9.4 88/11/21 14:58:39 paul Exp */
  /* Source: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/ppc/RCS/ppcArea.c,v  */
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcArea.c,v 2.1 1994/02/01 13:54:10 dawes Exp $ */
  /* Header: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/ppc/RCS/ppcArea.c,v 9.4 88/11/21 14:58:39 paul Exp */
  /* Source: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/ppc/RCS/ppcArea.c,v  */
  
***************
*** 50,56 ****
      register BoxPtr pBox ;
      GCPtr	pGC ;
  {
- register void (*FillFunc)() ;
  register int x, y, w, h ;
  int alu ;
  unsigned long int fg, bg, pm ;
--- 50,55 ----
***************
*** 73,111 ****
  nboxes++ ;
  switch (  ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fillStyle ) {
  	case FillTiled:
- 		FillFunc =
-  ( (ppcScrnPriv *) ( ( (DrawablePtr) pWin )->pScreen->devPrivate ) )->tileFill ;
  		for ( pPixmap = pGC->tile.pixmap ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				(*FillFunc)( pPixmap, alu, pm,
  					     x, y, w, h, xSrc, ySrc ) ;
  		break ;
  	case FillOpaqueStippled:
- 		FillFunc =
- ( (ppcScrnPriv *) ( ( (DrawablePtr) pWin )->pScreen->devPrivate ) )->opstipFill;
  		for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				(*FillFunc)( pPixmap, fg, bg, alu, pm,
  					     x, y, w, h, xSrc, ySrc ) ;
  		break ;
  	case FillStippled:
- 		FillFunc =
- ( (ppcScrnPriv *) ( ( (DrawablePtr) pWin )->pScreen->devPrivate ) )->stipFill ;
  		for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				(*FillFunc)( pPixmap, fg, alu, pm,
  					     x, y, w, h, xSrc, ySrc ) ;
  		break ;
  	case FillSolid:
- 		FillFunc =
- ( (ppcScrnPriv *) ( ( (DrawablePtr) pWin )->pScreen->devPrivate ) )->solidFill ;
  		for ( ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				(*FillFunc)( fg, alu, pm, x, y, w, h ) ;
  		break ;
  }
  
--- 72,102 ----
  nboxes++ ;
  switch (  ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fillStyle ) {
  	case FillTiled:
  		for ( pPixmap = pGC->tile.pixmap ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				ppcTileRect( pPixmap, alu, pm,
  					     x, y, w, h, xSrc, ySrc ) ;
  		break ;
  	case FillOpaqueStippled:
  		for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				ppcOpaqueStipple( pPixmap, fg, bg, alu, pm,
  					     x, y, w, h, xSrc, ySrc ) ;
  		break ;
  	case FillStippled:
  		for ( pPixmap = pGC->stipple ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				vgaFillStipple( pPixmap, fg, alu, pm,
  					     x, y, w, h, xSrc, ySrc ) ;
  		break ;
  	case FillSolid:
  		for ( ; --nboxes ; pBox++ )
  			if ( ( w = pBox->x2 - ( x = pBox->x1 ) )
  			  && ( h = pBox->y2 - ( y = pBox->y1 ) ) )
! 				vgaFillSolid( fg, alu, pm, x, y, w, h ) ;
  		break ;
  }
  
diff -c mit/server/ddx/x386/vga16/ibm/ppcBStore.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcBStore.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcBStore.c:2.0	Fri Mar 11 23:40:31 1994
--- mit/server/ddx/x386/vga16/ibm/ppcBStore.c	Fri Mar 11 23:40:31 1994
***************
*** 58,64 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcBStore.c,v 2.0 1993/08/19 16:08:35 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcBStore.c,v 30.0 89/01/23 19:29:01 paul Exp */
  
  #include "X.h"
--- 58,64 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcBStore.c,v 2.1 1994/02/01 13:54:12 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcBStore.c,v 30.0 89/01/23 19:29:01 paul Exp */
  
  #include "X.h"
***************
*** 97,114 ****
  {
      register BoxPtr pBox ;
      register int nBox ;
-     register void (*pFn)() ;
  
      TRACE( ( "ppcSaveAreas(0x%x,0x%x,%d,%d)\n",
  	   pPixmap, prgnSave, xorg, yorg ) ) ;
! /* WHOOP WHOOP WHOOP XXX -- depth 8 *only* */
  
      if ( !( nBox = REGION_NUM_RECTS(prgnSave) ) )
  	return ;
  
-     pFn = ( (ppcScrnPriv *) pPixmap->drawable.pScreen->devPrivate )->imageRead ;
      for ( pBox = REGION_RECTS(prgnSave) ; nBox-- ; pBox++ )
! 	(* pFn)( pBox->x1 + xorg,
  		 pBox->y1 + yorg,
  		 pBox->x2 - pBox->x1,
  		 pBox->y2 - pBox->y1,
--- 97,112 ----
  {
      register BoxPtr pBox ;
      register int nBox ;
  
      TRACE( ( "ppcSaveAreas(0x%x,0x%x,%d,%d)\n",
  	   pPixmap, prgnSave, xorg, yorg ) ) ;
! /* WHOOP WHOOP WHOOP XXX -- depth 8 *only* */ /* GJA -- ? */
  
      if ( !( nBox = REGION_NUM_RECTS(prgnSave) ) )
  	return ;
  
      for ( pBox = REGION_RECTS(prgnSave) ; nBox-- ; pBox++ )
! 	vgaReadColorImage( pBox->x1 + xorg,
  		 pBox->y1 + yorg,
  		 pBox->x2 - pBox->x1,
  		 pBox->y2 - pBox->y1,
***************
*** 141,147 ****
  {
      register BoxPtr pBox ;
      register int nBox ;
-     register void (*pFn)() ;
  
      TRACE( ( "ppcRestoreAreas(0x%x,0x%x,%d,%d)\n",
  	   pPixmap, prgnRestore, xorg, yorg ) ) ;
--- 139,144 ----
***************
*** 149,157 ****
  
      if ( !( nBox = REGION_NUM_RECTS(prgnRestore) ) )
  	return ;
-     pFn = ( (ppcScrnPriv *) pPixmap->drawable.pScreen->devPrivate )->imageFill ;
      for ( pBox = REGION_RECTS(prgnRestore) ; nBox-- ; pBox++ )
! 	(* pFn)( pBox->x1,
  		 pBox->y1,
  		 pBox->x2 - pBox->x1,
  		 pBox->y2 - pBox->y1,
--- 146,153 ----
  
      if ( !( nBox = REGION_NUM_RECTS(prgnRestore) ) )
  	return ;
      for ( pBox = REGION_RECTS(prgnRestore) ; nBox-- ; pBox++ )
! 	vgaDrawColorImage( pBox->x1,
  		 pBox->y1,
  		 pBox->x2 - pBox->x1,
  		 pBox->y2 - pBox->y1,
diff -c mit/server/ddx/x386/vga16/ibm/ppcCReduce.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcCReduce.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcCReduce.c:2.0	Fri Mar 11 23:40:31 1994
--- mit/server/ddx/x386/vga16/ibm/ppcCReduce.c	Fri Mar 11 23:40:31 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcCReduce.c,v 2.0 1993/08/19 16:08:38 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCReduce.c,v 9.1 88/10/24 03:59:37 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCReduce.c,v */
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcCReduce.c,v 2.1 1994/02/01 13:54:13 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCReduce.c,v 9.1 88/10/24 03:59:37 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCReduce.c,v */
  
***************
*** 30,35 ****
--- 30,36 ----
  #include "gcstruct.h"
  #include "pixmapstr.h"
  #include "colormapst.h"
+ #include "windowstr.h"	/* GJA */
  #include "ppc.h"
  
  /* ppcGetReducedColorRrop( pGC, drawableDepth, returnLoc )
diff -c mit/server/ddx/x386/vga16/ibm/ppcCpArea.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcCpArea.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcCpArea.c:2.0	Fri Mar 11 23:40:31 1994
--- mit/server/ddx/x386/vga16/ibm/ppcCpArea.c	Fri Mar 11 23:40:31 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcCpArea.c,v 2.0 1993/08/19 16:08:40 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcCpArea.c,v 9.4 89/05/07 15:30:29 paul Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcCpArea.c,v */
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcCpArea.c,v 2.1 1994/02/01 13:54:15 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcCpArea.c,v 9.4 89/05/07 15:30:29 paul Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcCpArea.c,v */
  
***************
*** 148,155 ****
  		register BoxPtr pbox = REGION_RECTS(prgnDst);
  		register unsigned char *data = pSrcDrawable->devPrivate.ptr ;
  		register int stride = pSrcDrawable->devKind ;
- 		register void (*fnp)() =
- 			( (ppcScrnPriv *) ( pScreen->devPrivate ) )->imageFill ;
  		register int dx ;
  		register int dy ;
  
--- 148,153 ----
***************
*** 157,163 ****
  		dy = srcy - dsty ;
  
  		for ( ; nbox-- ; pbox++ )
! 			(* fnp)( pbox->x1, pbox->y1,
  				 pbox->x2 - pbox->x1,
  				 pbox->y2 - pbox->y1,
  				 data + pbox->x1 + dx
--- 155,161 ----
  		dy = srcy - dsty ;
  
  		for ( ; nbox-- ; pbox++ )
! 			vgaDrawColorImage( pbox->x1, pbox->y1,
  				 pbox->x2 - pbox->x1,
  				 pbox->y2 - pbox->y1,
  				 data + pbox->x1 + dx
***************
*** 354,363 ****
  			}
  		}
  		{ /* Here is the "REAL" copy. All clipped and GO. */
- 		register void (*fnp)() ;
- 		fnp = ( (ppcScrnPriv *) ( pScreen->devPrivate ) )->blit ;
  		for ( ; nbox-- ; pbox++ )
! 			(* fnp)( alu, pm, pm,
  				 pbox->x1 + dx, pbox->y1 + dy,
  				 pbox->x1, pbox->y1,
  				 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ;
--- 352,359 ----
  			}
  		}
  		{ /* Here is the "REAL" copy. All clipped and GO. */
  		for ( ; nbox-- ; pbox++ )
! 			vgaBitBlt( alu, pm, pm,
  				 pbox->x1 + dx, pbox->y1 + dy,
  				 pbox->x1, pbox->y1,
  				 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ;
diff -c mit/server/ddx/x386/vga16/ibm/ppcCurs.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcCurs.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcCurs.c:2.0	Fri Mar 11 23:40:32 1994
--- mit/server/ddx/x386/vga16/ibm/ppcCurs.c	Fri Mar 11 23:40:32 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcCurs.c,v 2.0 1993/08/19 16:08:42 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCurs.c,v 9.1 88/10/24 03:59:54 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCurs.c,v */
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcCurs.c,v 2.1 1994/02/01 13:54:16 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCurs.c,v 9.1 88/10/24 03:59:54 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcCurs.c,v */
  
***************
*** 43,48 ****
--- 43,49 ----
  #include "pixmapstr.h"
  
  #include "OScompiler.h"
+ #include "windowstr.h"	/* GJA */
  #include "ppc.h"
  #include "ppcBitMacs.h"
  #include "ibmTrace.h"
diff -c mit/server/ddx/x386/vga16/ibm/ppcFillRct.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcFillRct.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcFillRct.c:2.0	Fri Mar 11 23:40:32 1994
--- mit/server/ddx/x386/vga16/ibm/ppcFillRct.c	Fri Mar 11 23:40:32 1994
***************
*** 1,39 ****
! /*
!  * Copyright IBM Corporation 1987,1988,1989
!  *
!  * 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 IBM not be
!  * used in advertising or publicity pertaining to distribution of the
!  * software without specific, written prior permission.
!  *
!  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
!  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
!  * IBM 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.
!  *
! */
! 
  /***********************************************************
  Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  
! 			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 names of Digital or MIT not be
  used in advertising or publicity pertaining to distribution of the
! software without specific, written prior permission.
  
  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
--- 1,17 ----
! /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
  /***********************************************************
  Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  
!                         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 names of Digital or MIT not be
  used in advertising or publicity pertaining to distribution of the
! software without specific, written prior permission.  
  
  DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
***************
*** 44,55 ****
  SOFTWARE.
  
  ******************************************************************/
! 
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcFillRct.c,v 2.0 1993/08/19 16:08:44 dawes Exp $ */
! /* Header: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcFillRct.c,v 30.0 89/01/23 19:29:05 paul Exp */
! /* Source: /andrew/X11/r3src/release/server/ddx/ibm/ppc/RCS/ppcFillRct.c,v */
! 
  #include "X.h"
  #include "pixmapstr.h"
  #include "gcstruct.h"
  #include "windowstr.h"
--- 22,31 ----
  SOFTWARE.
  
  ******************************************************************/
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcFillRct.c,v 2.1 1994/02/01 13:54:17 dawes Exp $ */
! /* $XConsortium: mfbfillrct.c,v 5.8 91/05/25 19:00:50 rws Exp $ */
  #include "X.h"
+ #include "Xprotostr.h"
  #include "pixmapstr.h"
  #include "gcstruct.h"
  #include "windowstr.h"
***************
*** 57,166 ****
  #include "regionstr.h"
  #include "scrnintstr.h"
  
! #include "OScompiler.h"
! #include "ibmTrace.h"
  
! #include "ppc.h"
! extern int mfbGCPrivateIndex;
  
! /*
! 	filled rectangles.
! 	translate the rectangles, clip them, and call the
! 	helper function in the GC.
  */
  
  void
! ppcPolyFillRect( pDrawable, pGC, nrectFill, prectInit )
!     DrawablePtr pDrawable ;
!     GCPtr	pGC ;
!     int		nrectFill ; 	/* number of rectangles to fill */
!     xRectangle	*prectInit ;  	/* Pointer to first rectangle to fill */
  {
!     register int n ;		/* spare counter */
!     register xRectangle *prect ;	/* temporary */
!     RegionPtr prgnClip ;
!     register BoxPtr pbox ;	/* used to clip with */
!     register BoxPtr pboxClipped ;
!     BoxPtr pboxTempBase ;
!     BoxPtr pboxTempEnd ;
!     BoxPtr pboxClippedBase ;
!     void (* fillArea)() ;
! 
!     TRACE(("ppcPolyFillRect(0x%x,0x%x,%d,0x%x)\n",pDrawable,pGC,
! 						  nrectFill,prectInit)) ;
! 
!     if ( pDrawable->type != DRAWABLE_WINDOW ) {
! 	ErrorF("ppcPolyFillRect: Not a window\n") ;
! 	return ;
      }
  
-     if ( ( pGC->alu == GXnoop ) || !pGC->planemask )
- 	return ;
  
!     prgnClip = ( (ppcPrivGC *) (pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip ;
  
!     pboxTempBase = (BoxPtr)
!       ALLOCATE_LOCAL( ( REGION_NUM_RECTS(prgnClip) + nrectFill ) * sizeof( BoxRec ) ) ;
!     if ( !pboxTempBase )
! 	return ;
  
      {
! 	register const int xorg = pDrawable->x ;
! 	register const int yorg = pDrawable->y ;
  
! 	for ( prect = prectInit, n = nrectFill ; n-- ; prect++ ) {
! 	    prect->x += xorg ;
! 	    prect->y += yorg ;
! 	}
      }
  
!     fillArea = ( (ppcPrivGC *) ( pGC->devPrivates[mfbGCPrivateIndex].ptr ) )->FillArea ;
!     pboxClippedBase = ( pboxTempEnd = pboxTempBase ) + nrectFill ;
! /* NOTE:
!  *	Some VERY stupid programs may call the server with
!  *	very large width or height values.
!  *	These programs think they are using negative numbers!
!  *	Therefore, we must do "saturation" arithmetic for the rect's .
!  */
! #define MAXIMUM_X11_POS	(32767)
! #define MINIMUM_X11_POS	(-32768)
!     for ( prect = prectInit ; nrectFill-- ; prect++ ) {
! 	pboxTempEnd->x1 = prect->x ;
! 	pboxTempEnd->x2 = MIN( prect->x + prect->width, MAXIMUM_X11_POS ) ;
! 	pboxTempEnd->y1 = prect->y ;
! 	pboxTempEnd->y2 = MIN( prect->y + prect->height, MAXIMUM_X11_POS ) ;
! 
! 	switch ( (* pGC->pScreen->RectIn)( prgnClip, pboxTempEnd ) ) {
! 	  case rgnIN:
! 	    pboxTempEnd++ ; /* Save for later ! */
! 	  case rgnOUT:
! 	    break ;
! 	  case rgnPART:
  	    /* clip the rectangle to each box in the clip region
  	       this is logically equivalent to calling Intersect()
  	    */
! 	    for ( pboxClipped = pboxClippedBase,
! 		  pbox = REGION_RECTS(prgnClip),
! 		  n = REGION_NUM_RECTS(prgnClip) ;
! 		  n-- ; pbox++ ) {
! 		pboxClipped->x1 = MAX( pboxTempEnd->x1, pbox->x1 ) ;
! 		pboxClipped->x2 = MIN( pboxTempEnd->x2, pbox->x2 ) ;
! 		if ( pboxClipped->x1 < pboxClipped->x2 ) {
! 		    pboxClipped->y1 = MAX( pboxTempEnd->y1, pbox->y1 ) ;
! 		    pboxClipped->y2 = MIN( pboxTempEnd->y2, pbox->y2 ) ;
! 		    /* see if clipping left anything */
! 		    if ( pboxClipped->y1 < pboxClipped->y2 )
! 			pboxClipped++ ;
  		}
  	    }
! 	    if ( n = pboxClipped - pboxClippedBase )
! 		(* fillArea)( pDrawable, n, pboxClippedBase, pGC ) ;
! 	    break ;
! 	}
      }
!     if ( n = pboxTempEnd - pboxTempBase )
! 	(* fillArea)( pDrawable, n, pboxTempBase, pGC ) ;
! 
!     DEALLOCATE_LOCAL( pboxTempBase ) ;
!     return ;
  }
--- 33,202 ----
  #include "regionstr.h"
  #include "scrnintstr.h"
  
! #include "mfb.h"
! #include "maskbits.h"
  
! #define MODEQ(a, b) ((a) %= (b))
! void mfbPaintOddSize();
  
! /* 
!     filled rectangles.
!     translate the rectangles, clip them, and call the
! helper function in the GC.
  */
  
+ #define NUM_STACK_RECTS	1024
+ 
  void
! ppcPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
!     DrawablePtr pDrawable;
!     GCPtr	pGC;
!     int		nrectFill; 	/* number of rectangles to fill */
!     xRectangle	*prectInit;  	/* Pointer to first rectangle to fill */
  {
!     xRectangle	    *prect;
!     RegionPtr	    prgnClip;
!     register BoxPtr pbox;
!     register BoxPtr pboxClipped;
!     BoxPtr	    pboxClippedBase;
!     BoxPtr	    pextent;
!     BoxRec	    stackRects[NUM_STACK_RECTS];
!     int		    numRects;
!     int		    n;
!     int		    xorg, yorg;
!     mfbPrivGC	*priv;
! /*    int alu; */
!     void (* pfn) ();
! /*    PixmapPtr ppix; */
! 
!     if (!(pGC->planemask & 0x0F)) /* GJA */
! 	return;
! 
!     priv = (mfbPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr;
! /*    alu = priv->ropFillArea; */
!     pfn = priv->FillArea;
! /*    ppix = priv->pRotatedPixmap; */
!     prgnClip = priv->pCompositeClip;
! 
!     prect = prectInit;
!     xorg = pDrawable->x;
!     yorg = pDrawable->y;
!     if (xorg || yorg)
!     {
!         prect = prectInit;
! 	n = nrectFill;
! 	Duff (n, prect->x += xorg; prect->y += yorg; prect++);
      }
  
  
!     prect = prectInit;
  
!     numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
!     if (numRects > NUM_STACK_RECTS)
!     {
! 	pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
! 	if (!pboxClippedBase)
! 	    return;
!     }
!     else
! 	pboxClippedBase = stackRects;
  
+     pboxClipped = pboxClippedBase;
+ 	
+     if (REGION_NUM_RECTS(prgnClip) == 1)
      {
! 	int x1, y1, x2, y2, bx2, by2;
  
! 	pextent = REGION_RECTS(prgnClip);
! 	x1 = pextent->x1;
! 	y1 = pextent->y1;
! 	x2 = pextent->x2;
! 	y2 = pextent->y2;
!     	while (nrectFill--)
!     	{
! 	    if ((pboxClipped->x1 = prect->x) < x1)
! 		pboxClipped->x1 = x1;
!     
! 	    if ((pboxClipped->y1 = prect->y) < y1)
! 		pboxClipped->y1 = y1;
!     
! 	    bx2 = (int) prect->x + (int) prect->width;
! 	    if (bx2 > x2)
! 		bx2 = x2;
! 	    pboxClipped->x2 = bx2;
!     
! 	    by2 = (int) prect->y + (int) prect->height;
! 	    if (by2 > y2)
! 		by2 = y2;
! 	    pboxClipped->y2 = by2;
! 
! 	    prect++;
! 	    if ((pboxClipped->x1 < pboxClipped->x2) &&
! 		(pboxClipped->y1 < pboxClipped->y2))
! 	    {
! 		pboxClipped++;
! 	    }
!     	}
      }
+     else
+     {
+ 	int x1, y1, x2, y2, bx2, by2;
  
! 	pextent = (*pGC->pScreen->RegionExtents)(prgnClip);
! 	x1 = pextent->x1;
! 	y1 = pextent->y1;
! 	x2 = pextent->x2;
! 	y2 = pextent->y2;
!     	while (nrectFill--)
!     	{
! 	    BoxRec box;
!     
! 	    if ((box.x1 = prect->x) < x1)
! 		box.x1 = x1;
!     
! 	    if ((box.y1 = prect->y) < y1)
! 		box.y1 = y1;
!     
! 	    bx2 = (int) prect->x + (int) prect->width;
! 	    if (bx2 > x2)
! 		bx2 = x2;
! 	    box.x2 = bx2;
!     
! 	    by2 = (int) prect->y + (int) prect->height;
! 	    if (by2 > y2)
! 		by2 = y2;
! 	    box.y2 = by2;
!     
! 	    prect++;
!     
! 	    if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
! 	    	continue;
!     
! 	    n = REGION_NUM_RECTS (prgnClip);
! 	    pbox = REGION_RECTS(prgnClip);
!     
  	    /* clip the rectangle to each box in the clip region
  	       this is logically equivalent to calling Intersect()
  	    */
! 	    while(n--)
! 	    {
! 		pboxClipped->x1 = max(box.x1, pbox->x1);
! 		pboxClipped->y1 = max(box.y1, pbox->y1);
! 		pboxClipped->x2 = min(box.x2, pbox->x2);
! 		pboxClipped->y2 = min(box.y2, pbox->y2);
! 		pbox++;
! 
! 		/* see if clipping left anything */
! 		if(pboxClipped->x1 < pboxClipped->x2 && 
! 		   pboxClipped->y1 < pboxClipped->y2)
! 		{
! 		    pboxClipped++;
  		}
  	    }
!     	}
      }
!     if (pboxClipped != pboxClippedBase)
! 	(*pfn) (pDrawable,pboxClipped-pboxClippedBase, pboxClippedBase, pGC);
!     if (pboxClippedBase != stackRects)
!     	DEALLOCATE_LOCAL(pboxClippedBase);
  }
diff -c mit/server/ddx/x386/vga16/ibm/ppcGC.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcGC.c:2.2
*** mit/server/ddx/x386/vga16/ibm/ppcGC.c:2.0	Fri Mar 11 23:40:33 1994
--- mit/server/ddx/x386/vga16/ibm/ppcGC.c	Fri Mar 11 23:40:33 1994
***************
*** 66,72 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcGC.c,v 2.0 1993/08/19 16:08:45 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGC.c,v 9.7 89/06/16 16:37:21 jeff Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGC.c,v */
  
--- 66,72 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcGC.c,v 2.2 1994/02/25 15:02:49 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGC.c,v 9.7 89/06/16 16:37:21 jeff Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGC.c,v */
  
***************
*** 93,98 ****
--- 93,100 ----
  
  #include "ibmTrace.h"
  
+ #include "vgaVideo.h"
+ 
  extern int ibmAllowBackingStore ;
  extern int mfbGCPrivateInterest;
  #define ppcGCInterestValidateMask \
***************
*** 100,105 ****
--- 102,171 ----
  | GCFunction | GCPlaneMask | GCFillStyle | GC_CALL_VALIDATE_BIT         \
  | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode )
  
+ 
+ /* GJA -- we modified the following function to get rid of
+  * the records in file vgaData.c
+  */
+ static /* GJA */ GCFuncs vgaGCFuncs = {
+ 	ppcValidateGC,
+ 	NoopDDA,
+ 	NoopDDA,
+ 	ppcDestroyGC,
+ 	ppcChangeClip,
+ 	ppcDestroyClip,
+ 	ppcCopyClip
+ };
+ 
+ 
+ static ppcPrivGC vgaPrototypeGCPriv = {
+ 	GXcopy,	/* unsigned char	rop */
+ 	0,	/* unsigned char	ropOpStip */
+ 	0,	/* unsigned char	ropFillArea */
+ 	TRUE,		/* short	fExpose */
+ 	FALSE,		/* short	freeCompClip */
+ 	NullPixmap,	/* PixmapPtr	pRotatedPixmap */
+ 	0,	/* RegionPtr	pCompositeClip */
+ 	ppcAreaFill,	/* void 	(* FillArea)() */
+ 		{
+ 		    VGA_ALLPLANES,	/* unsigned long	planemask */
+ 		    1,			/* unsigned long	fgPixel */
+ 		    0,			/* unsigned long	bgPixel */
+ 		    GXcopy,		/* int			alu */
+ 		    FillSolid,		/* int			fillStyle */
+ 		}, /* ppcReducedRrop	colorRrop  */
+ 	-1,	/* short lastDrawableType */
+ 	-1,	/* short lastDrawableDepth */
+ 	(void (*)())NoopDDA, /* GJA -- void (* cacheIGBlt)() */
+ 	(void (*)())NoopDDA, /* GJA -- void (* cachePGBlt) () */
+ 	0	/* pointer devPriv */
+ } ;
+ 
+ void v16ImageGlyphBlt(), v16PolyFillArc(), v16ZeroPolyArc();
+ 
+ static GCOps vgaGCOps = {
+ 	ppcSolidWindowFS,	/*  void (* FillSpans)() */
+ 	ppcSetSpans,		/*  void (* SetSpans)()	 */
+ 	miPutImage,		/*  void (* PutImage)()	 */
+ 	ppcCopyArea,		/*  RegionPtr (* CopyArea)()	 */
+ 	miCopyPlane,		/*  void (* CopyPlane)() */
+ 	ppcPolyPoint,		/*  void (* PolyPoint)() */
+ 	ppcScrnZeroLine,	/*  void (* Polylines)() */
+ 	ppcScrnZeroSegs,	/*  void (* PolySegment)() */
+ 	miPolyRectangle,	/*  void (* PolyRectangle)() */
+ 	v16ZeroPolyArc,		/*  void (* PolyArc)()	 */
+ 	miFillPolygon,		/*  void (* FillPolygon)() */
+ 	miPolyFillRect,		/*  void (* PolyFillRect)() */
+ 	v16PolyFillArc,		/*  void (* PolyFillArc)() */
+ 	miPolyText8,		/*  int (* PolyText8)()	 */
+ 	miPolyText16,		/*  int (* PolyText16)() */
+ 	miImageText8,		/*  void (* ImageText8)() */
+ 	miImageText16,		/*  void (* ImageText16)() */
+ 	(void (*)()) v16ImageGlyphBlt,	/*  GJA -- void (* ImageGlyphBlt)() */
+ 	(void (*)()) miPolyGlyphBlt,	/*  GJA -- void (* PolyGlyphBlt)() */
+ 	miPushPixels,		/*  void (* PushPixels)() */
+ 	miMiter			/*  void (* LineHelper)() */
+ };
+ 
  Bool
  ppcCreateGC( pGC )
  register GCPtr pGC ;
***************
*** 108,113 ****
--- 174,180 ----
  		pGC->pScreen->devPrivate ;
  	ppcPrivGC *pPriv ;
  	GCOps *pOps ;
+ 	static DDXPointRec zeroOrg = { 0, 0 }; /* GJA */
  
  	if ( pGC->depth == 1 )
  		{
***************
*** 122,156 ****
  		return FALSE;
  	}
  	
! 	{ /* Save & Restore any passed-in variables !! */
! 		int		orig_depth	= pGC->depth ;
! 		PixmapPtr	orig_tile	= pGC->tile.pixmap ;
! 		PixmapPtr	orig_stipple	= pGC->stipple ;
! 		struct _Font	*orig_font	= pGC->font ;
! 		int		orig_numInDashList	= pGC->numInDashList ;
! 		unsigned char	*orig_dash	= pGC->dash ;
! 		unsigned long	orig_serialNumber	= pGC->serialNumber ;
! 		DevUnion	*orig_devPrivates	= pGC->devPrivates ;
! 
! 		/* Copy The Prototype GC */
! 		*pGC = *( devScrnPriv->devPrototypeGC ) ;
! 
! 		/* Now restore the pointers ! */
! 		pGC->depth	= orig_depth ;
! 		pGC->tile.pixmap	= orig_tile ;
! 		pGC->stipple	= orig_stipple ;
! 		pGC->font	= orig_font ;
! 		pGC->numInDashList = orig_numInDashList ;
! 		pGC->dash	= orig_dash ;
! 		pGC->serialNumber  = orig_serialNumber ;
! 		pGC->devPrivates = orig_devPrivates;
! 	}
! 
! 	/* Copy The Prototype devPriv */
! 	pGC->devPrivates[mfbGCPrivateIndex].ptr = (pointer) pPriv ;
! 	*pPriv = *( devScrnPriv->devPrototypeGCPriv ) ;
  
! 	*pOps = *( pGC->ops );
  	pOps->devPrivate.val = 1;
  	pGC->ops = pOps;
  
--- 189,213 ----
  		return FALSE;
  	}
  	
!         /* Now we initialize the GC fields */
! 	pGC->miTranslate = 1;
! 	pGC->tileIsPixel = 1;
! 	pGC->unused = 0;
! 	pGC->planemask = VGA_ALLPLANES;
! 	pGC->fgPixel = VGA_BLACK_PIXEL;
! 	pGC->bgPixel = VGA_WHITE_PIXEL;
! 	pGC->funcs = &vgaGCFuncs;
! 	/* ops, -- see below */
! 	
! 	/* GJA: I don't like this code:
!          * they allocated a mfbPrivGC, ignore the allocated data and place
!          * a pointer to a ppcPrivGC in its slot.
!          */
! 	*pPriv = vgaPrototypeGCPriv;
! 	(pGC->devPrivates[mfbGCPrivateIndex].ptr) = (pointer) pPriv;
  
! 	/* Set the vgaGCOps */
! 	*pOps = vgaGCOps;
  	pOps->devPrivate.val = 1;
  	pGC->ops = pOps;
  
***************
*** 176,184 ****
  
      if ( pPriv->freeCompClip && pPriv->pCompositeClip )
  	(* pGC->pScreen->RegionDestroy)( pPriv->pCompositeClip ) ;
-     if ( pPriv->devPriv )
- 	 (* ( (ppcScrnPrivPtr) (pGC->pScreen->devPrivate) )->DestroyGCPriv)(
- 					pPriv->devPriv ) ;
      if(pGC->ops->devPrivate.val) Xfree( pGC->ops );
      Xfree( pGC->devPrivates[mfbGCPrivateIndex].ptr ) ;
      return ;
--- 233,238 ----
***************
*** 277,283 ****
  
      if ( pDrawable->type != devPriv->lastDrawableType ) {
  	devPriv->lastDrawableType = pDrawable->type ;
! 	bsChanges |= (* devScrnPriv->changeGCtype)( pGC, devPriv ) ;
  	changes = ~0 ;
      }
  
--- 331,337 ----
  
      if ( pDrawable->type != devPriv->lastDrawableType ) {
  	devPriv->lastDrawableType = pDrawable->type ;
! 	bsChanges |= vgaChangeGCtype( pGC, devPriv ) ;
  	changes = ~0 ;
      }
  
***************
*** 425,431 ****
  					&devPriv->colorRrop ) ;
  
  	(* ( ( pDrawable->type == DRAWABLE_WINDOW )
! 	     ? devScrnPriv->changeWindowGC
  	     : ppcChangePixmapGC ) )( pGC, changes ) ;
  
      return ;
--- 479,485 ----
  					&devPriv->colorRrop ) ;
  
  	(* ( ( pDrawable->type == DRAWABLE_WINDOW )
! 	     ? vgaChangeWindowGC
  	     : ppcChangePixmapGC ) )( pGC, changes ) ;
  
      return ;
diff -c mit/server/ddx/x386/vga16/ibm/ppcGetSp.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcGetSp.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcGetSp.c:2.0	Fri Mar 11 23:40:33 1994
--- mit/server/ddx/x386/vga16/ibm/ppcGetSp.c	Fri Mar 11 23:40:33 1994
***************
*** 45,51 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcGetSp.c,v 2.0 1993/08/19 16:08:48 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGetSp.c,v 9.2 89/05/07 15:27:55 paul Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGetSp.c,v */
  
--- 45,51 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcGetSp.c,v 2.1 1994/02/01 13:54:20 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGetSp.c,v 9.2 89/05/07 15:27:55 paul Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcGetSp.c,v */
  
***************
*** 59,66 ****
  
  #include "OScompiler.h"
  
! #include "ppcGCstr.h"
! #include "ppcScrn.h"
  
  #include "ibmTrace.h"
  
--- 59,67 ----
  
  #include "OScompiler.h"
  
! /* #include "ppcGCstr.h" */
! /* #include "ppcScrn.h" */
! #include "ppc.h"	/* GJA */
  
  #include "ibmTrace.h"
  
***************
*** 97,106 ****
      pdst = (unsigned char *) /* GJA */ pdstStart ;
  
      if ( pDrawable->type == DRAWABLE_WINDOW ) {
-      	register void (* fnp)()
- 	   = ((ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->imageRead ;
  	for ( ; nspans-- ; ppt++, pwidth++ ) {
! 		(* fnp)( ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride ) ;
  		pdst += j ; /* width is in 32 bit words */
  		j = ( -j ) & 3 ;
  		while ( j-- ) /* Pad out to 32-bit boundary */
--- 98,105 ----
      pdst = (unsigned char *) /* GJA */ pdstStart ;
  
      if ( pDrawable->type == DRAWABLE_WINDOW ) {
  	for ( ; nspans-- ; ppt++, pwidth++ ) {
! 		vgaReadColorImage( ppt->x, ppt->y, j = *pwidth, 1, pdst, pixmapStride ) ;
  		pdst += j ; /* width is in 32 bit words */
  		j = ( -j ) & 3 ;
  		while ( j-- ) /* Pad out to 32-bit boundary */
diff -c mit/server/ddx/x386/vga16/ibm/ppcIO.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcIO.c:2.3
*** mit/server/ddx/x386/vga16/ibm/ppcIO.c:2.0	Fri Mar 11 23:40:34 1994
--- mit/server/ddx/x386/vga16/ibm/ppcIO.c	Fri Mar 11 23:40:34 1994
***************
*** 1,3 ****
--- 1,4 ----
+ 
  /*
   * Copyright IBM Corporation 1987,1988,1989
   *
***************
*** 20,98 ****
   * SOFTWARE.
   *
  */
- /***********************************************************
- 		Copyright IBM Corporation 1987,1988
- 
-                       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 IBM not be
! used in advertising or publicity pertaining to distribution of the
! software without specific, written prior permission.  
! 
! IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
! ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
! IBM 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.
! 
! ******************************************************************/
! /***********************************************************
! Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
! and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
! 
! 			    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 names of Digital or MIT not be
! used in advertising or publicity pertaining to distribution of the
! software without specific, written prior permission.  
! 
! DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
! ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
! DIGITAL 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: mit/server/ddx/x386/vga16/ibm/ppcIO.c,v 2.0 1993/08/19 16:08:50 dawes Exp $ */
! /* Header: ppcIO.c,v 1.2 89/11/29 18:01:46 keith Exp */
! /* Source: /xsrc/mit/server/ddx/ibm/ppc/RCS/ppcIO.c,v */
  
  #include "X.h"
- #include "Xproto.h"
  #include "resource.h"
- #include "servermd.h"
  #include "scrnintstr.h"
! #include "window.h"
! #include "dixfont.h" /* GJA */
! #include "miscstruct.h"
! #include "colormap.h"
! #include "colormapst.h"
! #include "cursorstr.h"
! #include "pixmapstr.h"
! #include "mistruct.h"
! #include "mibstore.h"
  
! #include "OScompiler.h"
! /* #include "OScursor.h" */
  
  #include "ppc.h"
- #include "ppcProcs.h"
  
! #include "ibmTrace.h"
  
  miBSFuncRec ppcBSFuncRec = {
      ppcSaveAreas,
      ppcRestoreAreas,
--- 21,90 ----
   * SOFTWARE.
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcIO.c,v 2.3 1994/03/08 04:51:08 dawes Exp $ */
  
  #include "X.h"
  #include "resource.h"
  #include "scrnintstr.h"
! #include "servermd.h"	/* GJA */
! #include "mi.h" /* GJA */
  
! #include "compiler.h"	/* rvb */
! #include "vgaVideo.h"
  
+ #include "ibmTrace.h"
+ #include "windowstr.h"
  #include "ppc.h"
  
! #include "mistruct.h"
! #include "mfb.h"
! 
! extern void miRecolorCursor() ;
! extern void NoopDDA() ;
! /* extern void ibmAbort(); */
! 
! static PixmapPtr BogusPixmap = (PixmapPtr) 1 ;
! extern ScreenRec vgaScreenRec ; /* Forward Declaration Here */
! 
! PixmapFormatRec	vgaFormats[] = { { 4, 8, 32 } } ;
! 
! VisualRec vgaVisuals[] = {
! 	{
! 	0,			/* unsigned long	vid */
! 	PseudoColor,		/* short       class */
! 	6,			/* short       bitsPerRGBValue */
! 	1 << VGA_MAXPLANES,	/* short	ColormapEntries */
! 	VGA_MAXPLANES,		/* short	nplanes */
! 	0,			/* unsigned long	redMask */
! 	0,			/* unsigned long	greenMask */
! 	0,			/* unsigned long	blueMask */
! 	0,			/* int		offsetRed */
! 	0,			/* int		offsetGreen */
! 	0			/* int		offsetBlue */
! 	}
! } ;
! 
! #define NUM_VISUALS  (sizeof vgaVisuals/sizeof (VisualRec))
! 
! unsigned long int vgaDepthVIDs[NUM_VISUALS];
  
+ DepthRec vgaDepths[] = {
+ /*	depth		numVid	vids */
+     {	1,		0,	NULL	},
+     {	VGA_MAXPLANES,	NUM_VISUALS,	vgaDepthVIDs }
+ } ;
+ 
+ #define NUM_DEPTHS  (sizeof vgaDepths/sizeof (DepthRec))
+ 
+ NeverCalled()
+ {
+ 	ErrorF("NeverCalled was nevertheless called\n");
+ 	abort();
+ }
+ 
+ Bool ppcInitializeColormap();	/* GJAHACK */
+ 
  miBSFuncRec ppcBSFuncRec = {
      ppcSaveAreas,
      ppcRestoreAreas,
***************
*** 101,200 ****
      (PixmapPtr (*)()) 0,
  };
  
- void
- ppc16CommonScreenInit( pScreen, pScrnProto )
- register ScreenPtr const pScreen ;
- /* register const int index ; -- GJA deleted index */
- ScreenPtr const pScrnProto ;
- {
- 	register int i ;
- 	ppcScrnPriv *pScrnPriv ;
- 	int savemyNum = pScreen->myNum;
- 	int saveWindowPrivateLen = pScreen->WindowPrivateLen;
- 	unsigned *saveWindowPrivateSizes = pScreen->WindowPrivateSizes;
- 	unsigned savetotalWindowSize = pScreen->totalWindowSize;
- 	int saveGCPrivateLen = pScreen->GCPrivateLen;
- 	unsigned *saveGCPrivateSizes = pScreen->GCPrivateSizes;
- 	unsigned savetotalGCSize = pScreen->totalGCSize;
- 	DevUnion *savedevPrivates = pScreen->devPrivates;
- 
- 	TRACE( ( "ppcCommonScreenInit(pScreen=0x%x,index=%d,pScrnProto=0x%x)\n",
- 		pScreen, index, pScrnProto ) ) ;
- 
- 	*pScreen = *pScrnProto ; /* Copy The Prototype Structure */
- 
- 	pScreen->devPrivates = savedevPrivates;
- 	pScreen->myNum = savemyNum;
- 	pScreen->WindowPrivateLen = saveWindowPrivateLen;
- 	pScreen->WindowPrivateSizes = saveWindowPrivateSizes;
- 	pScreen->totalWindowSize = savetotalWindowSize;
- 	pScreen->GCPrivateLen = saveGCPrivateLen;
- 	pScreen->GCPrivateSizes = saveGCPrivateSizes;
- 	pScreen->totalGCSize = savetotalGCSize;
- 
- 	if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
- 		return ;
- 
- 	pScrnPriv = (ppcScrnPriv *) ( pScreen->devPrivate ) ;
- /*	pScreen->myNum = index; /* GJA - deleted this and more */
- 	pScrnPriv->devPrototypeGC->pScreen =
- 	pScrnPriv->pixmap.drawable.pScreen =
- 	pScreen ;
  
! 	miInitializeBackingStore (pScreen, &ppcBSFuncRec);
! 	TRACE(("ppcCommonScreenInit returns\n"));
! 	return ;
! }
  
  /*ARGSUSED*/
! void
! ppcCommonScreenClose( pScreen, index, pScrnProto )
! register ScreenPtr const pScreen ;
  register const int index ;
! ScreenPtr const pScrnProto ;
  {
- /*
- 	FreeColormap( pScreen->defColormap ) ;
- */
  	pScreen->defColormap = 0 ;
- 	( (ppcScrnPriv *) pScreen->devPrivate )->InstalledColormap =
- 		(ColormapPtr) 0 ;
- 	return ;
  }
  
- /* GJA - snarfed from above. */
- Bool
- vga16CreateDefColormap(pScreen)
-     ScreenPtr pScreen;
- {
- 	VisualPtr pVis ;
- 	unsigned short int r, g, b ;
- 
- 	/* Set up the visuals */
- 	pVis = pScreen->visuals ;
- 
- 	{ /* Set The Standard Colormap Stuff */
- 		ColormapPtr pColormap ;
  
! 		/* "dix" Colormap Stuff */
! 		CreateColormap( pScreen->defColormap =
! 				(Colormap) FakeClientID( 0 ),
! 				pScreen, pVis, &pColormap, AllocNone, 0 ) ;
! 		pColormap->pScreen = pScreen ;
  
! 		/* "ppc" Colormap Stuff */
! 
! #define SERVER_ID 0
  
! 		r = g = b = 0 ; /* zeros oughta be pretty black, I think */
!     		AllocColor( pColormap, &r, &g, &b,
! 			&(pColormap->pScreen->blackPixel), SERVER_ID ) ;
  
! 		r = g = b = 0xFFFF ; /* should be pretty white, I think */
!     		AllocColor( pColormap, &r, &g, &b,
! 			&(pColormap->pScreen->whitePixel), SERVER_ID ) ;
  
! 		(*(pScreen->InstallColormap))( pColormap ) ;
  
! 	}
  }
--- 93,192 ----
      (PixmapPtr (*)()) 0,
  };
  
  
! /* Global Variables */
! int BYTES_PER_LINE, MAX_ROW, MAX_COLUMN;
  
  /*ARGSUSED*/
! Bool
! vgaScreenClose( index, pScreen )
  register const int index ;
! register ScreenPtr const pScreen ;
  {
  	pScreen->defColormap = 0 ;
  }
  
  
! GCPtr sampleGCperDepth[MAXFORMATS+1] = { 0 };
! PixmapPtr samplePixmapPerDepth[1] = { 0 };
  
! void
! Init16Output( pScreen, virtx, virty )
!     ScreenPtr pScreen;
!     int virtx, virty;
! {
!   extern int defaultColorVisualClass;
! #ifdef UNBANKED_VGA16
!   extern pointer vgaBase; /* GJAHACK */
! #else
!   extern pointer vgaVirtBase; /* GJAHACK */
! #endif
! 
!   /*
!    * patch the original structures
!    */
!   BYTES_PER_LINE = virtx / 8;
!   MAX_ROW       = virty - 1;
!   MAX_COLUMN    = virtx - 1;
! 
!   if ( defaultColorVisualClass < 0 ) {
!     vgaVisuals[0].class = PseudoColor;
!   } else {
!     vgaVisuals[0].class = defaultColorVisualClass;
!   }
! 
!   pScreen-> id = 0;
!   pScreen->defColormap = FakeClientID(0);
!   pScreen-> whitePixel = VGA_WHITE_PIXEL;
!   pScreen-> blackPixel = VGA_BLACK_PIXEL;
!   pScreen-> rgf = 0;
!   *(pScreen-> GCperDepth) = *(sampleGCperDepth);
!   *(pScreen-> PixmapPerDepth) = *(samplePixmapPerDepth);
!   pScreen-> numVisuals = sizeof vgaVisuals/sizeof (VisualRec);
!   pScreen-> visuals = &vgaVisuals[0];
!   pScreen-> CloseScreen = vgaScreenClose;
!   pScreen-> QueryBestSize = ppcQueryBestSize;
!   pScreen-> GetImage = ppcGetImage;
!   pScreen-> GetSpans = ppcGetSpans;
!   pScreen-> CreateWindow = ppcCreateWindowForXYhardware;
!   pScreen-> DestroyWindow = ppcDestroyWindow;
!   pScreen-> PositionWindow = ppcPositionWindow;
!   pScreen-> ChangeWindowAttributes = mfbChangeWindowAttributes;
!   pScreen-> RealizeWindow = mfbMapWindow;
!   pScreen-> UnrealizeWindow = mfbUnmapWindow;
!   pScreen-> PaintWindowBackground = ppcPaintWindow;
!   pScreen-> PaintWindowBorder = ppcPaintWindow;
!   pScreen-> CopyWindow = ppcCopyWindow;
!   pScreen-> CreatePixmap = ppcCreatePixmap;
!   pScreen-> DestroyPixmap = mfbDestroyPixmap;
!   pScreen-> SaveDoomedAreas = NoopDDA;
!   pScreen-> RestoreAreas = (RegionPtr(*)())ppcRestoreAreas;
!   pScreen-> ExposeCopy = NoopDDA;
!   pScreen-> TranslateBackingStore = (RegionPtr(*)())NoopDDA;
!   pScreen-> ClearBackingStore = (RegionPtr(*)())NoopDDA;
!   pScreen-> DrawGuarantee = NoopDDA;
!   pScreen-> RealizeFont = mfbRealizeFont;
!   pScreen-> UnrealizeFont = mfbUnrealizeFont;
!   pScreen-> CreateGC = ppcCreateGC;
!   pScreen-> CreateColormap = (Bool (*)())ppcInitializeColormap;
!   pScreen-> DestroyColormap = (void (*)())NoopDDA;
!   pScreen-> ResolveColor = ppcResolveColor;
!   pScreen-> BitmapToRegion = mfbPixmapToRegion;
  
!   if (!mfbAllocatePrivates(pScreen, (int*)NULL, (int*)NULL))
! 	return ;
  
! #ifdef UNBANKED_VGA16
!   miScreenInit(pScreen, vgaBase, virtx, virty, 75, 75, virtx,
! #else
!   miScreenInit(pScreen, vgaVirtBase, virtx, virty, 75, 75, virtx,
! #endif
! 	1, NUM_DEPTHS, vgaDepths, 0 /* See above */,
! 	NUM_VISUALS, vgaVisuals, NULL);
!   pScreen-> rootDepth = VGA_MAXPLANES;
  
!   miInitializeBackingStore (pScreen, &ppcBSFuncRec);
!   TRACE(("ppcCommonScreenInit returns\n"));
  
!   mfbRegisterCopyPlaneProc(pScreen,miCopyPlane); /* GJA -- R4->R5 */
  }
diff -c mit/server/ddx/x386/vga16/ibm/ppcLine.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcLine.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcLine.c:2.0	Fri Mar 11 23:40:35 1994
--- mit/server/ddx/x386/vga16/ibm/ppcLine.c	Fri Mar 11 23:40:35 1994
***************
*** 45,51 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcLine.c,v 2.0 1993/08/19 16:08:53 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcLine.c,v 30.2 89/05/07 15:26:53 paul Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcLine.c,v */
  
--- 45,51 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcLine.c,v 2.1 1994/02/01 13:54:24 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcLine.c,v 30.2 89/05/07 15:26:53 paul Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcLine.c,v */
  
***************
*** 150,156 ****
      int x1, x2, y1, y2 ;		/* a bunch of temporaries */
      ppcPrivGC *gcPriv ;
      ppcScrnPriv *scrnPriv ;
-     void (* scrnFunc)() ;
  
      if ( pDrawable->type != DRAWABLE_WINDOW ) {
  	ErrorF("ppcScrnZeroLine: not a window\n") ;
--- 150,155 ----
***************
*** 228,234 ****
  	    }
  
  	    if ( nbox ) {
- 		scrnFunc = scrnPriv->lineVert ;
  		/* stop when lower edge of box is beyond end of line */
  		while ( ( nbox ) && ( pt2.y >= pbox->y1 ) ) {
  		    if ( ( pt1.x >= pbox->x1 ) && ( pt1.x < pbox->x2 ) ) {
--- 227,232 ----
***************
*** 235,241 ****
  			/* this box has part of the line in it */
  			if ( ( y1 = MAX( pt1.y, pbox->y1 ) )
  			  != ( y2 = MIN( pt2.y, pbox->y2 ) ) ) {
! 			    (* scrnFunc)( fg, alu, pm, pt1.x, y1, y2 - y1 ) ;
  			}
  		    }
  		    nbox-- ;
--- 233,239 ----
  			/* this box has part of the line in it */
  			if ( ( y1 = MAX( pt1.y, pbox->y1 ) )
  			  != ( y2 = MIN( pt2.y, pbox->y2 ) ) ) {
! 			    vgaVertLine( fg, alu, pm, pt1.x, y1, y2 - y1 ) ;
  			}
  		    }
  		    nbox-- ;
***************
*** 264,270 ****
  	    if ( nbox && ( pbox->y1 <= pt1.y ) ) {
  		/* when we leave this band, we're done */
  		tmp = pbox->y1 ;
- 		scrnFunc = scrnPriv->lineHorz ;
  		while ( nbox && ( pbox->y1 == tmp ) ) {
  		    if ( pbox->x2 <= pt1.x ) {
  			/* skip boxes until one might contain start point */
--- 262,267 ----
***************
*** 281,287 ****
  		    }
  		    if ( ( x1 = MAX( pt1.x, pbox->x1 ) )
  		      != ( x2 = MIN( pt2.x, pbox->x2 ) ) ) {
! 			    (* scrnFunc)( fg, alu, pm, x1, pt1.y, x2 - x1 ) ;
  		    }
  		    nbox-- ;
  		    pbox++ ;
--- 278,284 ----
  		    }
  		    if ( ( x1 = MAX( pt1.x, pbox->x1 ) )
  		      != ( x2 = MIN( pt2.x, pbox->x2 ) ) ) {
! 			    vgaHorzLine( fg, alu, pm, x1, pt1.y, x2 - x1 ) ;
  		    }
  		    nbox-- ;
  		    pbox++ ;
***************
*** 346,352 ****
  		if (clipDone == -1)
  		    pbox++ ;
  		else {
- 			scrnFunc = scrnPriv->lineBres ;
  
  		    if ( adx > ady )
  			len = ABS(pt2.x - pt1.x) ;
--- 343,348 ----
***************
*** 369,375 ****
  			}
  			else
  			    err = e ;
! 			(* scrnFunc)( fg, alu, pm,
  				      signdx, signdy,
  				      ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  				      pt1.x, pt1.y, err, e1, e2, len ) ;
--- 365,371 ----
  			}
  			else
  			    err = e ;
! 			vgaBresLine( fg, alu, pm,
  				      signdx, signdy,
  				      ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  				      pt1.x, pt1.y, err, e1, e2, len ) ;
***************
*** 395,401 ****
        && ( (* pDrawable->pScreen->PointInRegion)(
  		gcPriv->pCompositeClip,
  		ppt->x, ppt->y, &box ) ) )
! 	(* scrnPriv->solidFill)( fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ;
  
      return ;
  }
--- 391,397 ----
        && ( (* pDrawable->pScreen->PointInRegion)(
  		gcPriv->pCompositeClip,
  		ppt->x, ppt->y, &box ) ) )
! 	vgaFillSolid( fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ;
  
      return ;
  }
***************
*** 446,452 ****
      DDXPointRec pt1Orig ;	/* unclipped start point */
      int clip1, clip2 ;		/* clippedness of the endpoints */
  
-     void (* scrnFunc)() ;
      register int tmp1 ;
      register int tmp2 ;
  
--- 442,447 ----
***************
*** 590,597 ****
  	    for ( ; nbox && ( pbox->y2 <= tmp1 ) ; pbox++, nbox-- ) ;
  
  	    if ( nbox ) {
- 		scrnFunc =
- 		 ( (ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->lineVert ;
  		/* stop when lower edge of box is beyond end of line */
  		for ( ; nbox && ( pbox->y1 < tmp2 ) ; nbox--, pbox++ ) {
  		    if ( ( pt1.x >= pbox->x1 ) && ( pt1.x < pbox->x2 ) ) {
--- 585,590 ----
***************
*** 599,605 ****
  			/* this box has part of the line in it */
  			if ( ( y1 = MAX( tmp1, pbox->y1 ) )
  			  != ( y2 = MIN( tmp2, pbox->y2 ) ) ) {
! 			    (* scrnFunc)( color, alu, pm, pt1.x, y1, y2 - y1 ) ;
  			}
  		    }
  		}
--- 592,598 ----
  			/* this box has part of the line in it */
  			if ( ( y1 = MAX( tmp1, pbox->y1 ) )
  			  != ( y2 = MIN( tmp2, pbox->y2 ) ) ) {
! 			    vgaVertLine( color, alu, pm, pt1.x, y1, y2 - y1 ) ;
  			}
  		    }
  		}
***************
*** 627,634 ****
  	    if ( nbox && ( pbox->y1 <= pt1.y ) ) {
  		/* when we leave this band, we're done */
  		int tmp3 = pbox->y1 ;
- 		scrnFunc =
- 		 ( (ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->lineHorz ;
  		for ( ; nbox && ( pbox->y1 == tmp3 ) ; nbox--, pbox++ )
  		    if ( pbox->x2 <= tmp1 )
  			/* skip boxes until one might contain start point */
--- 620,625 ----
***************
*** 640,646 ****
  			register int x1, x2 ;
  			if ( ( x1 = MAX( tmp1, pbox->x1 ) )
  			  != ( x2 = MIN( tmp2, pbox->x2 ) ) )
! 			    (* scrnFunc)( color, alu, pm, x1, pt1.y, x2 - x1 ) ;
  		    }
  	    }
  	}
--- 631,637 ----
  			register int x1, x2 ;
  			if ( ( x1 = MAX( tmp1, pbox->x1 ) )
  			  != ( x2 = MIN( tmp2, pbox->x2 ) ) )
! 			    vgaHorzLine( color, alu, pm, x1, pt1.y, x2 - x1 ) ;
  		    }
  	    }
  	}
***************
*** 648,656 ****
  	    /* we have bresenham parameters and two points.
  	       all we have to do now is clip and draw.
  	    */
- 	    scrnFunc =
- 		( (ppcScrnPriv *)(pDrawable->pScreen->devPrivate))->lineBres ;
- 
  	    for ( ; nbox-- ; pbox++ ) {
  		BoxRec box ;
  
--- 639,644 ----
***************
*** 703,709 ****
  			    /* use error term calculated with the dash */
  			    err = pdash->e ;
  			}
! 			(* scrnFunc)( color, alu, pm, signdx, signdy,
  				      ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  				      pt1.x, pt1.y, err, e1, e2, len ) ;
  		    }
--- 691,697 ----
  			    /* use error term calculated with the dash */
  			    err = pdash->e ;
  			}
! 			vgaBresLine( color, alu, pm, signdx, signdy,
  				      ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  				      pt1.x, pt1.y, err, e1, e2, len ) ;
  		    }
***************
*** 759,765 ****
  unsigned long int pm ;			/* plane mask */
  ppcPrivGC	 *gcPriv ;
  ppcScrnPriv	 *scrnPriv ;
- void		 (* scrnFunc)() ;	/* function that will do the draw */
  
  if ( pDrawable->type != DRAWABLE_WINDOW ) {
  	ErrorF( "ppcScrnZeroSegs: not a window\n" ) ;
--- 747,752 ----
***************
*** 826,832 ****
  			nbox-- ;
  		}
  		if ( nbox ) {
- 			scrnFunc = scrnPriv->lineVert ;
  			/* stop when lower edge of box is beyond end of line */
  			while ( ( nbox ) && ( pt2.y >= pbox->y1 ) ) {
  				if ( ( pt1.x >= pbox->x1 )
--- 813,818 ----
***************
*** 834,840 ****
  					/* box has part of the line in it */
  					if ( ( y1 = MAX( pt1.y, pbox->y1 ) )
  					  != ( y2 = MIN( pt2.y, pbox->y2 ) ) )
! 						(* scrnFunc)( fg, alu, pm,
  							      pt1.x, y1,
  							      y2 - y1 ) ;
  				nbox-- ;
--- 820,826 ----
  					/* box has part of the line in it */
  					if ( ( y1 = MAX( pt1.y, pbox->y1 ) )
  					  != ( y2 = MIN( pt2.y, pbox->y2 ) ) )
! 						vgaVertLine( fg, alu, pm,
  							      pt1.x, y1,
  							      y2 - y1 ) ;
  				nbox-- ;
***************
*** 862,868 ****
  		if ( nbox && ( pbox->y1 <= pt1.y ) ) {
  			/* when we leave this band, we're done */
  			tmp = pbox->y1 ;
- 			scrnFunc = scrnPriv->lineHorz ;
  			while ( nbox && ( pbox->y1 == tmp ) ) {
  				/* skip boxes until one may hold start point */
  				if ( pbox->x2 <= pt1.x ) {
--- 848,853 ----
***************
*** 877,883 ****
  				}
  				if ( ( x1 = MAX( pt1.x, pbox->x1 ) )
  				  != ( x2 = MIN( pt2.x, pbox->x2 ) ) ) {
! 					(* scrnFunc)( fg, alu, pm, x1,
  						      pt1.y, x2 - x1 ) ;
  				}
  				nbox-- ;
--- 862,868 ----
  				}
  				if ( ( x1 = MAX( pt1.x, pbox->x1 ) )
  				  != ( x2 = MIN( pt2.x, pbox->x2 ) ) ) {
! 					vgaHorzLine( fg, alu, pm, x1,
  						      pt1.y, x2 - x1 ) ;
  				}
  				nbox-- ;
***************
*** 906,912 ****
  		 */
  		pt1Orig = pt1 ;
  		pt2Orig = pt2 ;
- 		scrnFunc = scrnPriv->lineBres ;
  		while ( nbox-- ) {
  			pt1 = pt1Orig ;
  			pt2 = pt2Orig ;
--- 891,896 ----
***************
*** 961,967 ****
  					}
  					else
  					    err = e ;
! 					(* scrnFunc)( fg, alu, pm,
  						      signdx, signdy,
  					  ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  						      pt1.x, pt1.y,
--- 945,951 ----
  					}
  					else
  					    err = e ;
! 					vgaBresLine( fg, alu, pm,
  						      signdx, signdy,
  					  ( ( adx > ady ) ? X_AXIS : Y_AXIS ),
  						      pt1.x, pt1.y,
diff -c mit/server/ddx/x386/vga16/ibm/ppcPntWin.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcPntWin.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcPntWin.c:2.0	Fri Mar 11 23:40:35 1994
--- mit/server/ddx/x386/vga16/ibm/ppcPntWin.c	Fri Mar 11 23:40:35 1994
***************
*** 45,52 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcPntWin.c,v 2.0 1993/08/19 16:08:58 dawes Exp $ */
  
  #include "X.h"
  
  #include "windowstr.h"
--- 45,53 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcPntWin.c,v 2.1 1994/02/01 13:54:25 dawes Exp $ */
  
+ #define BANKING_MODS
  #include "X.h"
  
  #include "windowstr.h"
***************
*** 58,63 ****
--- 59,65 ----
  #include "ppc.h"
  
  #include "ibmTrace.h"
+ #include "OScompiler.h"	/* GJA */
  
  /* NOTE: These functions only work for visuals up to 31-bits deep */
  void ppcPaintWindowSolid();
***************
*** 75,81 ****
  
      TRACE(("ppcPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n",
  							pWin,pRegion,what));
!     
      switch (what) {
      case PW_BACKGROUND:
  	switch (pWin->backgroundState) {
--- 77,83 ----
  
      TRACE(("ppcPaintWindow( pWin= 0x%x, pRegion= 0x%x, what= %d )\n",
  							pWin,pRegion,what));
! 
      switch (what) {
      case PW_BACKGROUND:
  	switch (pWin->backgroundState) {
***************
*** 125,131 ****
      register int nbox;
      register BoxPtr pbox;
      register unsigned long int pixel;
-     register void (*fnp)();
      register unsigned long int pm ;
  
      TRACE(("ppcPaintWindowSolid(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
--- 127,132 ----
***************
*** 140,152 ****
  	pixel = pWin->border.pixel; 
  
      pm = ( 1 << pWin->drawable.depth ) - 1 ;
-     fnp = ((ppcScrnPriv *)(pWin->drawable.pScreen->devPrivate))->solidFill;
      for ( ; nbox-- ; pbox++ ) {
  	/*
  	 * call fill routine, the parms are:
  	 * 	fill(color, alu, planes, x, y, width, height);
  	 */
! 	(* fnp)( pixel, GXcopy, pm, pbox->x1, pbox->y1, 
  		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ; 
      }
      return ;
--- 141,152 ----
  	pixel = pWin->border.pixel; 
  
      pm = ( 1 << pWin->drawable.depth ) - 1 ;
      for ( ; nbox-- ; pbox++ ) {
  	/*
  	 * call fill routine, the parms are:
  	 * 	fill(color, alu, planes, x, y, width, height);
  	 */
! 	vgaFillSolid( pixel, GXcopy, pm, pbox->x1, pbox->y1, 
  		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ; 
      }
      return ;
***************
*** 161,167 ****
      register int nbox;
      register BoxPtr pbox;
      register PixmapPtr pTile;
-     register void (*fnp)();
      register unsigned long int pm ;
  
      TRACE(("ppcPaintWindowTile(pWin= 0x%x, pRegion= 0x%x, what= %d)\n", pWin, pRegion, what));
--- 161,166 ----
***************
*** 176,188 ****
  	pTile = pWin->border.pixmap;
  
      pm = ( 1 << pWin->drawable.depth ) - 1 ;
-     fnp = ((ppcScrnPriv *)(pWin->drawable.pScreen->devPrivate))->tileFill;
      for ( ; nbox-- ; pbox++ ) {
  	/*
  	 * call tile routine, the parms are:
  	 * 	tile(tile, alu, planes, x, y, width, height,xSrc,ySrc);
  	 */
! 	(* fnp)(pTile, GXcopy, pm, 
  		pbox->x1, pbox->y1, 
  		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
  		pWin->drawable.x, pWin->drawable.y );
--- 175,186 ----
  	pTile = pWin->border.pixmap;
  
      pm = ( 1 << pWin->drawable.depth ) - 1 ;
      for ( ; nbox-- ; pbox++ ) {
  	/*
  	 * call tile routine, the parms are:
  	 * 	tile(tile, alu, planes, x, y, width, height,xSrc,ySrc);
  	 */
! 	ppcTileRect(pTile, GXcopy, pm, 
  		pbox->x1, pbox->y1, 
  		pbox->x2 - pbox->x1, pbox->y2 - pbox->y1,
  		pWin->drawable.x, pWin->drawable.y );
diff -c mit/server/ddx/x386/vga16/ibm/ppcPolyPnt.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcPolyPnt.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcPolyPnt.c:2.0	Fri Mar 11 23:40:36 1994
--- mit/server/ddx/x386/vga16/ibm/ppcPolyPnt.c	Fri Mar 11 23:40:36 1994
***************
*** 45,51 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcPolyPnt.c,v 2.0 1993/08/19 16:08:59 dawes Exp $ */
  
  #include "X.h"
  #include "Xprotostr.h"
--- 45,51 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcPolyPnt.c,v 2.1 1994/02/01 13:54:27 dawes Exp $ */
  
  #include "X.h"
  #include "Xprotostr.h"
***************
*** 112,119 ****
  
  {
  	register int (* PointInRegion)() = pDrawable->pScreen->PointInRegion ;
- 	register void (* fillFunc)() =
- 	    ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->solidFill ;
  	register RegionPtr pRegion = devPriv->pCompositeClip ;
  	register unsigned long int fg = devPriv->colorRrop.fgPixel ;
  	register unsigned long int pm = devPriv->colorRrop.planemask ;
--- 112,117 ----
***************
*** 124,130 ****
  
  	for ( ppt = pptInit ; npt-- ; ppt++ )
  		if ( (* PointInRegion)( pRegion, ppt->x, ppt->y, &box ) )
! 			(* fillFunc)( fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ;
  }
  
  return ;
--- 122,128 ----
  
  	for ( ppt = pptInit ; npt-- ; ppt++ )
  		if ( (* PointInRegion)( pRegion, ppt->x, ppt->y, &box ) )
! 			vgaFillSolid( fg, alu, pm, ppt->x, ppt->y, 1, 1 ) ;
  }
  
  return ;
diff -c mit/server/ddx/x386/vga16/ibm/ppcPushPxl.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcPushPxl.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcPushPxl.c:2.0	Fri Mar 11 23:40:36 1994
--- mit/server/ddx/x386/vga16/ibm/ppcPushPxl.c	Fri Mar 11 23:40:36 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcPushPxl.c,v 2.0 1993/08/19 16:09:02 dawes Exp $ */
  
  /* ppc PushPixels */
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcPushPxl.c,v 2.1 1994/02/01 13:54:28 dawes Exp $ */
  
  /* ppc PushPixels */
  
***************
*** 264,270 ****
  	PixmapPtr		ptmpBitmap = (PixmapPtr) 0 ;
  				/* Temp bitmap Make Sure It's Zero'ed Here */
  	int			BitmapIsCopy = FALSE ;
- 	void			(*FillFunc)() = scrPriv->stipFill ;
  	unsigned long int	fg = gcPriv->colorRrop.fgPixel ;
  	unsigned long int	bg = gcPriv->colorRrop.bgPixel ;
  	unsigned long int	pm = gcPriv->colorRrop.planemask ;
--- 264,269 ----
***************
*** 285,291 ****
  			for ( nbox = REGION_NUM_RECTS(prgnDst), pbox = REGION_RECTS(prgnDst);
  			      nbox-- ;
  			      pbox++ ) {
! 				(* FillFunc)( ptmpBitmap, bg, alu, pm,
  					      pbox->x1,
  					      pbox->y1,
  					      pbox->x2 - pbox->x1,
--- 284,290 ----
  			for ( nbox = REGION_NUM_RECTS(prgnDst), pbox = REGION_RECTS(prgnDst);
  			      nbox-- ;
  			      pbox++ ) {
! 				vgaFillStipple( ptmpBitmap, bg, alu, pm,
  					      pbox->x1,
  					      pbox->y1,
  					      pbox->x2 - pbox->x1,
***************
*** 313,319 ****
  			for ( nbox = REGION_NUM_RECTS(prgnDst), pbox = REGION_RECTS(prgnDst);
  			      nbox-- ;
  			      pbox++ ) {
! 				(* FillFunc)( ptmpBitmap, fg, alu, pm,
  					      pbox->x1,
  					      pbox->y1,
  					      pbox->x2 - pbox->x1,
--- 312,318 ----
  			for ( nbox = REGION_NUM_RECTS(prgnDst), pbox = REGION_RECTS(prgnDst);
  			      nbox-- ;
  			      pbox++ ) {
! 				vgaFillStipple( ptmpBitmap, fg, alu, pm,
  					      pbox->x1,
  					      pbox->y1,
  					      pbox->x2 - pbox->x1,
diff -c mit/server/ddx/x386/vga16/ibm/ppcRslvC.c:2.1 mit/server/ddx/x386/vga16/ibm/ppcRslvC.c:2.2
*** mit/server/ddx/x386/vga16/ibm/ppcRslvC.c:2.1	Fri Mar 11 23:40:36 1994
--- mit/server/ddx/x386/vga16/ibm/ppcRslvC.c	Fri Mar 11 23:40:37 1994
***************
*** 49,55 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcRslvC.c,v 2.1 1993/10/15 15:40:03 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRslvC.c,v 9.1 88/10/24 04:01:18 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRslvC.c,v */
  
--- 49,55 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcRslvC.c,v 2.2 1994/02/01 13:54:29 dawes Exp $ */
  /* Header: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRslvC.c,v 9.1 88/10/24 04:01:18 paul Exp */
  /* Source: /andrew/X11/R3src/tape/server/ddx/ibm/ppc/RCS/ppcRslvC.c,v */
  
***************
*** 60,67 ****
--- 60,69 ----
  #include "X.h"
  #include "screenint.h"
  #include "scrnintstr.h"
+ #include "colormapst.h"	/* GJA */
  #include "OScompiler.h"
  
+ 
  void
  ppcResolveColor( pRed, pGreen, pBlue, pVisual )
  register unsigned short * const pRed ;
***************
*** 86,93 ****
--- 88,161 ----
  	*pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100;
  	*pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim;
      }
+     else if (pVisual->class == StaticGray)
+     {
+ 	unsigned limg = pVisual->ColormapEntries - 1;
+ 	/* rescale to gray then [0..limg] then [0..65535] then rgb bits */
+ 	*pRed = (30L * *pRed + 59L * *pGreen + 11L * *pBlue) / 100;
+ 	*pRed = ((((*pRed * (limg + 1))) >> 16) * 65535) / limg;
+ 	*pBlue = *pGreen = *pRed = ((*pRed >> shift) * 65535) / lim;
+     }
      else {
  	Error( "can't resolve color for this visual" ) ;
      }
  }
  	
+ 
+ /* GJA --
+  * Took the code below from cfb. It's for staticgray visuals.
+  */
+ Bool
+ ppcInitializeColormap(pmap)
+     register ColormapPtr	pmap;
+ {
+     register unsigned i;
+     register VisualPtr pVisual;
+     unsigned lim, maxent, shift;
+ 
+     pVisual = pmap->pVisual;
+     lim = (1 << pVisual->bitsPerRGBValue) - 1;
+     shift = 16 - pVisual->bitsPerRGBValue;
+     maxent = pVisual->ColormapEntries - 1;
+ 
+     if (pVisual->class == StaticGray)
+     {
+ 	for(i = 0; i <= maxent; i++)
+ 	{
+ 	    /* rescale to [0..65535] then rgb bits */
+ 	    pmap->red[i].co.local.red = ((((i * 65535) / maxent) >> shift)
+ 					 * 65535) / lim;
+ 	    pmap->red[i].co.local.green = pmap->red[i].co.local.red;
+ 	    pmap->red[i].co.local.blue = pmap->red[i].co.local.red;
+ 	}
+     }
+     return TRUE;
+ }
+ 
+ 
+ Bool
+ vga16CreateDefColormap(pScreen)
+     ScreenPtr pScreen;
+ {
+     unsigned short	zero = 0, ones = 0xFFFF;
+     VisualPtr	pVisual;
+     ColormapPtr	cmap;
+     
+     for (pVisual = pScreen->visuals;
+ 	 pVisual->vid != pScreen->rootVisual;
+ 	 pVisual++)
+ 	;
+ 
+     if (CreateColormap(pScreen->defColormap, pScreen, pVisual, &cmap,
+ 		       (pVisual->class & DynamicClass) ? AllocNone : AllocAll,
+ 		       0)
+ 	!= Success)
+ 	return FALSE;
+     if ((AllocColor(cmap, &ones, &ones, &ones, &(pScreen->whitePixel), 0) !=
+        	   Success) ||
+     	(AllocColor(cmap, &zero, &zero, &zero, &(pScreen->blackPixel), 0) !=
+        	   Success))
+     	return FALSE;
+     (*pScreen->InstallColormap)(cmap);
+     return TRUE;
+ }
diff -c mit/server/ddx/x386/vga16/ibm/ppcScrn.h:2.0 mit/server/ddx/x386/vga16/ibm/ppcScrn.h:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcScrn.h:2.0	Fri Mar 11 23:40:37 1994
--- mit/server/ddx/x386/vga16/ibm/ppcScrn.h	Fri Mar 11 23:40:37 1994
***************
*** 43,49 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcScrn.h,v 2.0 1993/08/19 16:09:07 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcScrn.h,v 1.3 89/06/21 16:36:51 jeff Exp Locker: jeff */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcScrn.h,v */
  
--- 43,49 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcScrn.h,v 2.1 1994/02/01 13:54:31 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcScrn.h,v 1.3 89/06/21 16:36:51 jeff Exp Locker: jeff */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcScrn.h,v */
  
***************
*** 51,87 ****
  	PixmapRec	pixmap ; /* this is here for mfb, it expects
  				  * devPrivate to point to a pixmap.
  				  */
- 	/* These next 7 field are for support of
- 	 * common Screen Init & Validate GC
- 	 */
- 	void		(* devHardwareInitBB)() ; /* Call Before struct copy */
- 	void		(* devHardwareInitAB)() ; /* Call After struct copy */
- 	GCPtr		devPrototypeGC ;
- 	ppcPrivGC 	*devPrototypeGCPriv ;
- 	Mask		(* changeGCtype)() ;
- 	Mask		(* changeWindowGC)() ;
- 	/* Here Down Is the "old" ppc */
- 	ColormapPtr	InstalledColormap ;
- 	void		(* blit)() ;
- 	void		(* solidFill)() ;
- 	void		(* tileFill)() ;
- 	void		(* stipFill)() ;
- 	void		(* opstipFill)() ;
- 	void		(* imageFill)() ;
- 	void		(* imageRead)() ;
- 	void		(* lineBres)() ;
- 	void		(* lineHorz)() ;
- 	void		(* lineVert)() ;
- 	void		(* setColor)() ;
- 	void		(* RecolorCursor)() ;
- 	void		(* monoFill)() ;		/* 32 bit padded */
- 	void		(* glyphFill)() ;	/* GLYPHPADBYTES*8 bit padded */
- 	unsigned long *((* planeRead)()) ;	/* for XYformat getImage() */
- 	void		(* replicateArea)() ; /*Accelerator for Tile & Stipple*/
- 	void		(* DestroyGCPriv)() ; /* destroy devPriv in ppcPrivGC */
- 	/* High Level Software Cursor Support !! */
- 	int		* CursorSemaphore ;
- 	int			(* CheckCursor)() ;
- 	void		(* ReplaceCursor)() ;
- /*	ppcCacheInfoPtr	cacheInfo; */
  } ppcScrnPriv, *ppcScrnPrivPtr ;
--- 51,54 ----
diff -c mit/server/ddx/x386/vga16/ibm/ppcSetSp.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcSetSp.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcSetSp.c:2.0	Fri Mar 11 23:40:37 1994
--- mit/server/ddx/x386/vga16/ibm/ppcSetSp.c	Fri Mar 11 23:40:37 1994
***************
*** 45,51 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcSetSp.c,v 2.0 1993/08/19 16:09:08 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
--- 45,51 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcSetSp.c,v 2.1 1994/02/01 13:54:32 dawes Exp $ */
  
  #include "X.h"
  #include "Xmd.h"
***************
*** 247,254 ****
  					    + ( ppt->y * widthDst ),
  				            pm, alu ) ;
  		    else
!     			    ( *( ( (ppcScrnPriv *)
! 		      ( pDrawable->pScreen->devPrivate ) )->imageFill ) )
  			    ( xStart, ppt->y, xEnd - xStart, 1,
  			      psrc + ( xStart - ppt->x ), xEnd - xStart,
  			      alu, pm ) ;
--- 247,253 ----
  					    + ( ppt->y * widthDst ),
  				            pm, alu ) ;
  		    else
! 			vgaDrawColorImage
  			    ( xStart, ppt->y, xEnd - xStart, 1,
  			      psrc + ( xStart - ppt->x ), xEnd - xStart,
  			      alu, pm ) ;
***************
*** 285,292 ****
  						 + xStart ),
  						pm, alu ) ;
      			else	/* pDrawable->type == DRAWABLE_WINDOW */
!     				( *( ( (ppcScrnPriv *)
! 			( pDrawable->pScreen->devPrivate ) )->imageFill ) )
  				( xStart, ppt->y, xEnd - xStart, 1,
  				  psrc + ( xStart - ppt->x ), xEnd - xStart,
  					/* GJA ^ */
--- 284,290 ----
  						 + xStart ),
  						pm, alu ) ;
      			else	/* pDrawable->type == DRAWABLE_WINDOW */
! 			    vgaDrawColorImage
  				( xStart, ppt->y, xEnd - xStart, 1,
  				  psrc + ( xStart - ppt->x ), xEnd - xStart,
  					/* GJA ^ */
diff -c mit/server/ddx/x386/vga16/ibm/ppcSinTab.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcSinTab.c:removed
*** mit/server/ddx/x386/vga16/ibm/ppcSinTab.c:2.0	Fri Mar 11 23:40:38 1994
--- mit/server/ddx/x386/vga16/ibm/ppcSinTab.c	Fri Mar 11 23:40:38 1994
***************
*** 1,2909 ****
- /*
-  * Copyright IBM Corporation 1987,1988,1989
-  *
-  * 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 IBM not be
-  * used in advertising or publicity pertaining to distribution of the
-  * software without specific, written prior permission.
-  *
-  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-  * IBM 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: mit/server/ddx/x386/vga16/ibm/ppcSinTab.c,v 2.0 1993/08/19 16:09:10 dawes Exp $ */
- 
- unsigned short ppcSinTab[] =
- 	{
- 	0,
- 	18,
- 	36,
- 	54,
- 	71,
- 	89,
- 	107,
- 	125,
- 	143,
- 	161,
- 	179,
- 	197,
- 	214,
- 	232,
- 	250,
- 	268,
- 	286,
- 	304,
- 	322,
- 	340,
- 	357,
- 	375,
- 	393,
- 	411,
- 	429,
- 	447,
- 	465,
- 	483,
- 	500,
- 	518,
- 	536,
- 	554,
- 	572,
- 	590,
- 	608,
- 	625,
- 	643,
- 	661,
- 	679,
- 	697,
- 	715,
- 	733,
- 	751,
- 	768,
- 	786,
- 	804,
- 	822,
- 	840,
- 	858,
- 	876,
- 	893,
- 	911,
- 	929,
- 	947,
- 	965,
- 	983,
- 	1001,
- 	1019,
- 	1036,
- 	1054,
- 	1072,
- 	1090,
- 	1108,
- 	1126,
- 	1144,
- 	1161,
- 	1179,
- 	1197,
- 	1215,
- 	1233,
- 	1251,
- 	1269,
- 	1286,
- 	1304,
- 	1322,
- 	1340,
- 	1358,
- 	1376,
- 	1394,
- 	1411,
- 	1429,
- 	1447,
- 	1465,
- 	1483,
- 	1501,
- 	1519,
- 	1536,
- 	1554,
- 	1572,
- 	1590,
- 	1608,
- 	1626,
- 	1644,
- 	1661,
- 	1679,
- 	1697,
- 	1715,
- 	1733,
- 	1751,
- 	1768,
- 	1786,
- 	1804,
- 	1822,
- 	1840,
- 	1858,
- 	1876,
- 	1893,
- 	1911,
- 	1929,
- 	1947,
- 	1965,
- 	1983,
- 	2000,
- 	2018,
- 	2036,
- 	2054,
- 	2072,
- 	2090,
- 	2107,
- 	2125,
- 	2143,
- 	2161,
- 	2179,
- 	2197,
- 	2214,
- 	2232,
- 	2250,
- 	2268,
- 	2286,
- 	2304,
- 	2321,
- 	2339,
- 	2357,
- 	2375,
- 	2393,
- 	2411,
- 	2428,
- 	2446,
- 	2464,
- 	2482,
- 	2500,
- 	2517,
- 	2535,
- 	2553,
- 	2571,
- 	2589,
- 	2607,
- 	2624,
- 	2642,
- 	2660,
- 	2678,
- 	2696,
- 	2713,
- 	2731,
- 	2749,
- 	2767,
- 	2785,
- 	2803,
- 	2820,
- 	2838,
- 	2856,
- 	2874,
- 	2892,
- 	2909,
- 	2927,
- 	2945,
- 	2963,
- 	2981,
- 	2998,
- 	3016,
- 	3034,
- 	3052,
- 	3070,
- 	3087,
- 	3105,
- 	3123,
- 	3141,
- 	3158,
- 	3176,
- 	3194,
- 	3212,
- 	3230,
- 	3247,
- 	3265,
- 	3283,
- 	3301,
- 	3319,
- 	3336,
- 	3354,
- 	3372,
- 	3390,
- 	3407,
- 	3425,
- 	3443,
- 	3461,
- 	3479,
- 	3496,
- 	3514,
- 	3532,
- 	3550,
- 	3567,
- 	3585,
- 	3603,
- 	3621,
- 	3638,
- 	3656,
- 	3674,
- 	3692,
- 	3709,
- 	3727,
- 	3745,
- 	3763,
- 	3780,
- 	3798,
- 	3816,
- 	3834,
- 	3851,
- 	3869,
- 	3887,
- 	3905,
- 	3922,
- 	3940,
- 	3958,
- 	3976,
- 	3993,
- 	4011,
- 	4029,
- 	4047,
- 	4064,
- 	4082,
- 	4100,
- 	4118,
- 	4135,
- 	4153,
- 	4171,
- 	4188,
- 	4206,
- 	4224,
- 	4242,
- 	4259,
- 	4277,
- 	4295,
- 	4313,
- 	4330,
- 	4348,
- 	4366,
- 	4383,
- 	4401,
- 	4419,
- 	4437,
- 	4454,
- 	4472,
- 	4490,
- 	4507,
- 	4525,
- 	4543,
- 	4560,
- 	4578,
- 	4596,
- 	4614,
- 	4631,
- 	4649,
- 	4667,
- 	4684,
- 	4702,
- 	4720,
- 	4737,
- 	4755,
- 	4773,
- 	4790,
- 	4808,
- 	4826,
- 	4843,
- 	4861,
- 	4879,
- 	4896,
- 	4914,
- 	4932,
- 	4949,
- 	4967,
- 	4985,
- 	5002,
- 	5020,
- 	5038,
- 	5055,
- 	5073,
- 	5091,
- 	5108,
- 	5126,
- 	5144,
- 	5161,
- 	5179,
- 	5197,
- 	5214,
- 	5232,
- 	5250,
- 	5267,
- 	5285,
- 	5302,
- 	5320,
- 	5338,
- 	5355,
- 	5373,
- 	5391,
- 	5408,
- 	5426,
- 	5444,
- 	5461,
- 	5479,
- 	5496,
- 	5514,
- 	5532,
- 	5549,
- 	5567,
- 	5584,
- 	5602,
- 	5620,
- 	5637,
- 	5655,
- 	5673,
- 	5690,
- 	5708,
- 	5725,
- 	5743,
- 	5760,
- 	5778,
- 	5796,
- 	5813,
- 	5831,
- 	5848,
- 	5866,
- 	5884,
- 	5901,
- 	5919,
- 	5936,
- 	5954,
- 	5971,
- 	5989,
- 	6007,
- 	6024,
- 	6042,
- 	6059,
- 	6077,
- 	6094,
- 	6112,
- 	6130,
- 	6147,
- 	6165,
- 	6182,
- 	6200,
- 	6217,
- 	6235,
- 	6252,
- 	6270,
- 	6288,
- 	6305,
- 	6323,
- 	6340,
- 	6358,
- 	6375,
- 	6393,
- 	6410,
- 	6428,
- 	6445,
- 	6463,
- 	6480,
- 	6498,
- 	6515,
- 	6533,
- 	6550,
- 	6568,
- 	6585,
- 	6603,
- 	6620,
- 	6638,
- 	6655,
- 	6673,
- 	6690,
- 	6708,
- 	6725,
- 	6743,
- 	6760,
- 	6778,
- 	6795,
- 	6813,
- 	6830,
- 	6848,
- 	6865,
- 	6883,
- 	6900,
- 	6918,
- 	6935,
- 	6953,
- 	6970,
- 	6988,
- 	7005,
- 	7022,
- 	7040,
- 	7057,
- 	7075,
- 	7092,
- 	7110,
- 	7127,
- 	7145,
- 	7162,
- 	7180,
- 	7197,
- 	7214,
- 	7232,
- 	7249,
- 	7267,
- 	7284,
- 	7302,
- 	7319,
- 	7336,
- 	7354,
- 	7371,
- 	7389,
- 	7406,
- 	7423,
- 	7441,
- 	7458,
- 	7476,
- 	7493,
- 	7510,
- 	7528,
- 	7545,
- 	7563,
- 	7580,
- 	7597,
- 	7615,
- 	7632,
- 	7650,
- 	7667,
- 	7684,
- 	7702,
- 	7719,
- 	7736,
- 	7754,
- 	7771,
- 	7788,
- 	7806,
- 	7823,
- 	7841,
- 	7858,
- 	7875,
- 	7893,
- 	7910,
- 	7927,
- 	7945,
- 	7962,
- 	7979,
- 	7997,
- 	8014,
- 	8031,
- 	8049,
- 	8066,
- 	8083,
- 	8101,
- 	8118,
- 	8135,
- 	8153,
- 	8170,
- 	8187,
- 	8204,
- 	8222,
- 	8239,
- 	8256,
- 	8274,
- 	8291,
- 	8308,
- 	8326,
- 	8343,
- 	8360,
- 	8377,
- 	8395,
- 	8412,
- 	8429,
- 	8446,
- 	8464,
- 	8481,
- 	8498,
- 	8516,
- 	8533,
- 	8550,
- 	8567,
- 	8585,
- 	8602,
- 	8619,
- 	8636,
- 	8653,
- 	8671,
- 	8688,
- 	8705,
- 	8722,
- 	8740,
- 	8757,
- 	8774,
- 	8791,
- 	8809,
- 	8826,
- 	8843,
- 	8860,
- 	8877,
- 	8895,
- 	8912,
- 	8929,
- 	8946,
- 	8963,
- 	8981,
- 	8998,
- 	9015,
- 	9032,
- 	9049,
- 	9066,
- 	9084,
- 	9101,
- 	9118,
- 	9135,
- 	9152,
- 	9169,
- 	9187,
- 	9204,
- 	9221,
- 	9238,
- 	9255,
- 	9272,
- 	9289,
- 	9307,
- 	9324,
- 	9341,
- 	9358,
- 	9375,
- 	9392,
- 	9409,
- 	9427,
- 	9444,
- 	9461,
- 	9478,
- 	9495,
- 	9512,
- 	9529,
- 	9546,
- 	9563,
- 	9580,
- 	9598,
- 	9615,
- 	9632,
- 	9649,
- 	9666,
- 	9683,
- 	9700,
- 	9717,
- 	9734,
- 	9751,
- 	9768,
- 	9785,
- 	9802,
- 	9819,
- 	9836,
- 	9854,
- 	9871,
- 	9888,
- 	9905,
- 	9922,
- 	9939,
- 	9956,
- 	9973,
- 	9990,
- 	10007,
- 	10024,
- 	10041,
- 	10058,
- 	10075,
- 	10092,
- 	10109,
- 	10126,
- 	10143,
- 	10160,
- 	10177,
- 	10194,
- 	10211,
- 	10228,
- 	10245,
- 	10262,
- 	10279,
- 	10296,
- 	10313,
- 	10330,
- 	10347,
- 	10364,
- 	10380,
- 	10397,
- 	10414,
- 	10431,
- 	10448,
- 	10465,
- 	10482,
- 	10499,
- 	10516,
- 	10533,
- 	10550,
- 	10567,
- 	10584,
- 	10601,
- 	10618,
- 	10634,
- 	10651,
- 	10668,
- 	10685,
- 	10702,
- 	10719,
- 	10736,
- 	10753,
- 	10770,
- 	10786,
- 	10803,
- 	10820,
- 	10837,
- 	10854,
- 	10871,
- 	10888,
- 	10904,
- 	10921,
- 	10938,
- 	10955,
- 	10972,
- 	10989,
- 	11006,
- 	11022,
- 	11039,
- 	11056,
- 	11073,
- 	11090,
- 	11106,
- 	11123,
- 	11140,
- 	11157,
- 	11174,
- 	11191,
- 	11207,
- 	11224,
- 	11241,
- 	11258,
- 	11274,
- 	11291,
- 	11308,
- 	11325,
- 	11342,
- 	11358,
- 	11375,
- 	11392,
- 	11409,
- 	11425,
- 	11442,
- 	11459,
- 	11476,
- 	11492,
- 	11509,
- 	11526,
- 	11543,
- 	11559,
- 	11576,
- 	11593,
- 	11609,
- 	11626,
- 	11643,
- 	11660,
- 	11676,
- 	11693,
- 	11710,
- 	11726,
- 	11743,
- 	11760,
- 	11776,
- 	11793,
- 	11810,
- 	11826,
- 	11843,
- 	11860,
- 	11876,
- 	11893,
- 	11910,
- 	11926,
- 	11943,
- 	11960,
- 	11976,
- 	11993,
- 	12010,
- 	12026,
- 	12043,
- 	12059,
- 	12076,
- 	12093,
- 	12109,
- 	12126,
- 	12142,
- 	12159,
- 	12176,
- 	12192,
- 	12209,
- 	12225,
- 	12242,
- 	12259,
- 	12275,
- 	12292,
- 	12308,
- 	12325,
- 	12341,
- 	12358,
- 	12374,
- 	12391,
- 	12408,
- 	12424,
- 	12441,
- 	12457,
- 	12474,
- 	12490,
- 	12507,
- 	12523,
- 	12540,
- 	12556,
- 	12573,
- 	12589,
- 	12606,
- 	12622,
- 	12639,
- 	12655,
- 	12672,
- 	12688,
- 	12705,
- 	12721,
- 	12738,
- 	12754,
- 	12771,
- 	12787,
- 	12803,
- 	12820,
- 	12836,
- 	12853,
- 	12869,
- 	12886,
- 	12902,
- 	12919,
- 	12935,
- 	12951,
- 	12968,
- 	12984,
- 	13001,
- 	13017,
- 	13033,
- 	13050,
- 	13066,
- 	13083,
- 	13099,
- 	13115,
- 	13132,
- 	13148,
- 	13164,
- 	13181,
- 	13197,
- 	13214,
- 	13230,
- 	13246,
- 	13263,
- 	13279,
- 	13295,
- 	13312,
- 	13328,
- 	13344,
- 	13361,
- 	13377,
- 	13393,
- 	13410,
- 	13426,
- 	13442,
- 	13458,
- 	13475,
- 	13491,
- 	13507,
- 	13524,
- 	13540,
- 	13556,
- 	13572,
- 	13589,
- 	13605,
- 	13621,
- 	13637,
- 	13654,
- 	13670,
- 	13686,
- 	13702,
- 	13719,
- 	13735,
- 	13751,
- 	13767,
- 	13784,
- 	13800,
- 	13816,
- 	13832,
- 	13848,
- 	13865,
- 	13881,
- 	13897,
- 	13913,
- 	13929,
- 	13945,
- 	13962,
- 	13978,
- 	13994,
- 	14010,
- 	14026,
- 	14042,
- 	14059,
- 	14075,
- 	14091,
- 	14107,
- 	14123,
- 	14139,
- 	14155,
- 	14171,
- 	14188,
- 	14204,
- 	14220,
- 	14236,
- 	14252,
- 	14268,
- 	14284,
- 	14300,
- 	14316,
- 	14332,
- 	14348,
- 	14365,
- 	14381,
- 	14397,
- 	14413,
- 	14429,
- 	14445,
- 	14461,
- 	14477,
- 	14493,
- 	14509,
- 	14525,
- 	14541,
- 	14557,
- 	14573,
- 	14589,
- 	14605,
- 	14621,
- 	14637,
- 	14653,
- 	14669,
- 	14685,
- 	14701,
- 	14717,
- 	14733,
- 	14749,
- 	14765,
- 	14781,
- 	14797,
- 	14813,
- 	14829,
- 	14845,
- 	14860,
- 	14876,
- 	14892,
- 	14908,
- 	14924,
- 	14940,
- 	14956,
- 	14972,
- 	14988,
- 	15004,
- 	15019,
- 	15035,
- 	15051,
- 	15067,
- 	15083,
- 	15099,
- 	15115,
- 	15131,
- 	15146,
- 	15162,
- 	15178,
- 	15194,
- 	15210,
- 	15226,
- 	15241,
- 	15257,
- 	15273,
- 	15289,
- 	15305,
- 	15320,
- 	15336,
- 	15352,
- 	15368,
- 	15384,
- 	15399,
- 	15415,
- 	15431,
- 	15447,
- 	15462,
- 	15478,
- 	15494,
- 	15510,
- 	15525,
- 	15541,
- 	15557,
- 	15573,
- 	15588,
- 	15604,
- 	15620,
- 	15636,
- 	15651,
- 	15667,
- 	15683,
- 	15698,
- 	15714,
- 	15730,
- 	15745,
- 	15761,
- 	15777,
- 	15792,
- 	15808,
- 	15824,
- 	15839,
- 	15855,
- 	15871,
- 	15886,
- 	15902,
- 	15917,
- 	15933,
- 	15949,
- 	15964,
- 	15980,
- 	15996,
- 	16011,
- 	16027,
- 	16042,
- 	16058,
- 	16073,
- 	16089,
- 	16105,
- 	16120,
- 	16136,
- 	16151,
- 	16167,
- 	16182,
- 	16198,
- 	16213,
- 	16229,
- 	16245,
- 	16260,
- 	16276,
- 	16291,
- 	16307,
- 	16322,
- 	16338,
- 	16353,
- 	16369,
- 	16384,
- 	16399,
- 	16415,
- 	16430,
- 	16446,
- 	16461,
- 	16477,
- 	16492,
- 	16508,
- 	16523,
- 	16539,
- 	16554,
- 	16569,
- 	16585,
- 	16600,
- 	16616,
- 	16631,
- 	16646,
- 	16662,
- 	16677,
- 	16693,
- 	16708,
- 	16723,
- 	16739,
- 	16754,
- 	16769,
- 	16785,
- 	16800,
- 	16815,
- 	16831,
- 	16846,
- 	16861,
- 	16877,
- 	16892,
- 	16907,
- 	16923,
- 	16938,
- 	16953,
- 	16969,
- 	16984,
- 	16999,
- 	17014,
- 	17030,
- 	17045,
- 	17060,
- 	17075,
- 	17091,
- 	17106,
- 	17121,
- 	17136,
- 	17152,
- 	17167,
- 	17182,
- 	17197,
- 	17213,
- 	17228,
- 	17243,
- 	17258,
- 	17273,
- 	17289,
- 	17304,
- 	17319,
- 	17334,
- 	17349,
- 	17364,
- 	17380,
- 	17395,
- 	17410,
- 	17425,
- 	17440,
- 	17455,
- 	17470,
- 	17485,
- 	17501,
- 	17516,
- 	17531,
- 	17546,
- 	17561,
- 	17576,
- 	17591,
- 	17606,
- 	17621,
- 	17636,
- 	17651,
- 	17666,
- 	17682,
- 	17697,
- 	17712,
- 	17727,
- 	17742,
- 	17757,
- 	17772,
- 	17787,
- 	17802,
- 	17817,
- 	17832,
- 	17847,
- 	17862,
- 	17877,
- 	17892,
- 	17907,
- 	17922,
- 	17937,
- 	17952,
- 	17966,
- 	17981,
- 	17996,
- 	18011,
- 	18026,
- 	18041,
- 	18056,
- 	18071,
- 	18086,
- 	18101,
- 	18116,
- 	18131,
- 	18145,
- 	18160,
- 	18175,
- 	18190,
- 	18205,
- 	18220,
- 	18235,
- 	18249,
- 	18264,
- 	18279,
- 	18294,
- 	18309,
- 	18324,
- 	18338,
- 	18353,
- 	18368,
- 	18383,
- 	18398,
- 	18412,
- 	18427,
- 	18442,
- 	18457,
- 	18472,
- 	18486,
- 	18501,
- 	18516,
- 	18531,
- 	18545,
- 	18560,
- 	18575,
- 	18589,
- 	18604,
- 	18619,
- 	18634,
- 	18648,
- 	18663,
- 	18678,
- 	18692,
- 	18707,
- 	18722,
- 	18736,
- 	18751,
- 	18766,
- 	18780,
- 	18795,
- 	18810,
- 	18824,
- 	18839,
- 	18853,
- 	18868,
- 	18883,
- 	18897,
- 	18912,
- 	18926,
- 	18941,
- 	18956,
- 	18970,
- 	18985,
- 	18999,
- 	19014,
- 	19028,
- 	19043,
- 	19058,
- 	19072,
- 	19087,
- 	19101,
- 	19116,
- 	19130,
- 	19145,
- 	19159,
- 	19174,
- 	19188,
- 	19203,
- 	19217,
- 	19232,
- 	19246,
- 	19261,
- 	19275,
- 	19289,
- 	19304,
- 	19318,
- 	19333,
- 	19347,
- 	19362,
- 	19376,
- 	19390,
- 	19405,
- 	19419,
- 	19434,
- 	19448,
- 	19462,
- 	19477,
- 	19491,
- 	19506,
- 	19520,
- 	19534,
- 	19549,
- 	19563,
- 	19577,
- 	19592,
- 	19606,
- 	19620,
- 	19635,
- 	19649,
- 	19663,
- 	19677,
- 	19692,
- 	19706,
- 	19720,
- 	19735,
- 	19749,
- 	19763,
- 	19777,
- 	19792,
- 	19806,
- 	19820,
- 	19834,
- 	19848,
- 	19863,
- 	19877,
- 	19891,
- 	19905,
- 	19920,
- 	19934,
- 	19948,
- 	19962,
- 	19976,
- 	19990,
- 	20005,
- 	20019,
- 	20033,
- 	20047,
- 	20061,
- 	20075,
- 	20089,
- 	20104,
- 	20118,
- 	20132,
- 	20146,
- 	20160,
- 	20174,
- 	20188,
- 	20202,
- 	20216,
- 	20230,
- 	20244,
- 	20258,
- 	20272,
- 	20286,
- 	20301,
- 	20315,
- 	20329,
- 	20343,
- 	20357,
- 	20371,
- 	20385,
- 	20399,
- 	20413,
- 	20427,
- 	20440,
- 	20454,
- 	20468,
- 	20482,
- 	20496,
- 	20510,
- 	20524,
- 	20538,
- 	20552,
- 	20566,
- 	20580,
- 	20594,
- 	20608,
- 	20622,
- 	20635,
- 	20649,
- 	20663,
- 	20677,
- 	20691,
- 	20705,
- 	20719,
- 	20732,
- 	20746,
- 	20760,
- 	20774,
- 	20788,
- 	20802,
- 	20815,
- 	20829,
- 	20843,
- 	20857,
- 	20871,
- 	20884,
- 	20898,
- 	20912,
- 	20926,
- 	20939,
- 	20953,
- 	20967,
- 	20981,
- 	20994,
- 	21008,
- 	21022,
- 	21035,
- 	21049,
- 	21063,
- 	21077,
- 	21090,
- 	21104,
- 	21118,
- 	21131,
- 	21145,
- 	21159,
- 	21172,
- 	21186,
- 	21199,
- 	21213,
- 	21227,
- 	21240,
- 	21254,
- 	21268,
- 	21281,
- 	21295,
- 	21308,
- 	21322,
- 	21335,
- 	21349,
- 	21363,
- 	21376,
- 	21390,
- 	21403,
- 	21417,
- 	21430,
- 	21444,
- 	21457,
- 	21471,
- 	21484,
- 	21498,
- 	21511,
- 	21525,
- 	21538,
- 	21552,
- 	21565,
- 	21579,
- 	21592,
- 	21605,
- 	21619,
- 	21632,
- 	21646,
- 	21659,
- 	21673,
- 	21686,
- 	21699,
- 	21713,
- 	21726,
- 	21739,
- 	21753,
- 	21766,
- 	21780,
- 	21793,
- 	21806,
- 	21820,
- 	21833,
- 	21846,
- 	21860,
- 	21873,
- 	21886,
- 	21899,
- 	21913,
- 	21926,
- 	21939,
- 	21953,
- 	21966,
- 	21979,
- 	21992,
- 	22006,
- 	22019,
- 	22032,
- 	22045,
- 	22059,
- 	22072,
- 	22085,
- 	22098,
- 	22111,
- 	22125,
- 	22138,
- 	22151,
- 	22164,
- 	22177,
- 	22190,
- 	22204,
- 	22217,
- 	22230,
- 	22243,
- 	22256,
- 	22269,
- 	22282,
- 	22295,
- 	22308,
- 	22322,
- 	22335,
- 	22348,
- 	22361,
- 	22374,
- 	22387,
- 	22400,
- 	22413,
- 	22426,
- 	22439,
- 	22452,
- 	22465,
- 	22478,
- 	22491,
- 	22504,
- 	22517,
- 	22530,
- 	22543,
- 	22556,
- 	22569,
- 	22582,
- 	22595,
- 	22608,
- 	22621,
- 	22634,
- 	22647,
- 	22659,
- 	22672,
- 	22685,
- 	22698,
- 	22711,
- 	22724,
- 	22737,
- 	22750,
- 	22763,
- 	22775,
- 	22788,
- 	22801,
- 	22814,
- 	22827,
- 	22840,
- 	22852,
- 	22865,
- 	22878,
- 	22891,
- 	22904,
- 	22916,
- 	22929,
- 	22942,
- 	22955,
- 	22967,
- 	22980,
- 	22993,
- 	23006,
- 	23018,
- 	23031,
- 	23044,
- 	23056,
- 	23069,
- 	23082,
- 	23095,
- 	23107,
- 	23120,
- 	23133,
- 	23145,
- 	23158,
- 	23170,
- 	23183,
- 	23196,
- 	23208,
- 	23221,
- 	23234,
- 	23246,
- 	23259,
- 	23271,
- 	23284,
- 	23297,
- 	23309,
- 	23322,
- 	23334,
- 	23347,
- 	23359,
- 	23372,
- 	23384,
- 	23397,
- 	23409,
- 	23422,
- 	23434,
- 	23447,
- 	23459,
- 	23472,
- 	23484,
- 	23497,
- 	23509,
- 	23522,
- 	23534,
- 	23546,
- 	23559,
- 	23571,
- 	23584,
- 	23596,
- 	23609,
- 	23621,
- 	23633,
- 	23646,
- 	23658,
- 	23670,
- 	23683,
- 	23695,
- 	23707,
- 	23720,
- 	23732,
- 	23744,
- 	23757,
- 	23769,
- 	23781,
- 	23794,
- 	23806,
- 	23818,
- 	23830,
- 	23843,
- 	23855,
- 	23867,
- 	23880,
- 	23892,
- 	23904,
- 	23916,
- 	23928,
- 	23941,
- 	23953,
- 	23965,
- 	23977,
- 	23989,
- 	24002,
- 	24014,
- 	24026,
- 	24038,
- 	24050,
- 	24062,
- 	24074,
- 	24087,
- 	24099,
- 	24111,
- 	24123,
- 	24135,
- 	24147,
- 	24159,
- 	24171,
- 	24183,
- 	24195,
- 	24207,
- 	24219,
- 	24231,
- 	24243,
- 	24255,
- 	24267,
- 	24279,
- 	24291,
- 	24303,
- 	24315,
- 	24327,
- 	24339,
- 	24351,
- 	24363,
- 	24375,
- 	24387,
- 	24399,
- 	24411,
- 	24423,
- 	24435,
- 	24447,
- 	24459,
- 	24471,
- 	24482,
- 	24494,
- 	24506,
- 	24518,
- 	24530,
- 	24542,
- 	24554,
- 	24565,
- 	24577,
- 	24589,
- 	24601,
- 	24613,
- 	24624,
- 	24636,
- 	24648,
- 	24660,
- 	24672,
- 	24683,
- 	24695,
- 	24707,
- 	24719,
- 	24730,
- 	24742,
- 	24754,
- 	24765,
- 	24777,
- 	24789,
- 	24801,
- 	24812,
- 	24824,
- 	24836,
- 	24847,
- 	24859,
- 	24870,
- 	24882,
- 	24894,
- 	24905,
- 	24917,
- 	24929,
- 	24940,
- 	24952,
- 	24963,
- 	24975,
- 	24986,
- 	24998,
- 	25010,
- 	25021,
- 	25033,
- 	25044,
- 	25056,
- 	25067,
- 	25079,
- 	25090,
- 	25102,
- 	25113,
- 	25125,
- 	25136,
- 	25148,
- 	25159,
- 	25171,
- 	25182,
- 	25193,
- 	25205,
- 	25216,
- 	25228,
- 	25239,
- 	25250,
- 	25262,
- 	25273,
- 	25285,
- 	25296,
- 	25307,
- 	25319,
- 	25330,
- 	25341,
- 	25353,
- 	25364,
- 	25375,
- 	25387,
- 	25398,
- 	25409,
- 	25420,
- 	25432,
- 	25443,
- 	25454,
- 	25466,
- 	25477,
- 	25488,
- 	25499,
- 	25510,
- 	25522,
- 	25533,
- 	25544,
- 	25555,
- 	25566,
- 	25578,
- 	25589,
- 	25600,
- 	25611,
- 	25622,
- 	25633,
- 	25645,
- 	25656,
- 	25667,
- 	25678,
- 	25689,
- 	25700,
- 	25711,
- 	25722,
- 	25733,
- 	25744,
- 	25755,
- 	25766,
- 	25777,
- 	25788,
- 	25800,
- 	25811,
- 	25822,
- 	25833,
- 	25844,
- 	25855,
- 	25865,
- 	25876,
- 	25887,
- 	25898,
- 	25909,
- 	25920,
- 	25931,
- 	25942,
- 	25953,
- 	25964,
- 	25975,
- 	25986,
- 	25997,
- 	26007,
- 	26018,
- 	26029,
- 	26040,
- 	26051,
- 	26062,
- 	26073,
- 	26083,
- 	26094,
- 	26105,
- 	26116,
- 	26127,
- 	26137,
- 	26148,
- 	26159,
- 	26170,
- 	26180,
- 	26191,
- 	26202,
- 	26213,
- 	26223,
- 	26234,
- 	26245,
- 	26255,
- 	26266,
- 	26277,
- 	26288,
- 	26298,
- 	26309,
- 	26320,
- 	26330,
- 	26341,
- 	26351,
- 	26362,
- 	26373,
- 	26383,
- 	26394,
- 	26404,
- 	26415,
- 	26426,
- 	26436,
- 	26447,
- 	26457,
- 	26468,
- 	26478,
- 	26489,
- 	26499,
- 	26510,
- 	26520,
- 	26531,
- 	26541,
- 	26552,
- 	26562,
- 	26573,
- 	26583,
- 	26594,
- 	26604,
- 	26615,
- 	26625,
- 	26635,
- 	26646,
- 	26656,
- 	26667,
- 	26677,
- 	26687,
- 	26698,
- 	26708,
- 	26718,
- 	26729,
- 	26739,
- 	26749,
- 	26760,
- 	26770,
- 	26780,
- 	26791,
- 	26801,
- 	26811,
- 	26821,
- 	26832,
- 	26842,
- 	26852,
- 	26862,
- 	26873,
- 	26883,
- 	26893,
- 	26903,
- 	26914,
- 	26924,
- 	26934,
- 	26944,
- 	26954,
- 	26964,
- 	26975,
- 	26985,
- 	26995,
- 	27005,
- 	27015,
- 	27025,
- 	27035,
- 	27045,
- 	27055,
- 	27066,
- 	27076,
- 	27086,
- 	27096,
- 	27106,
- 	27116,
- 	27126,
- 	27136,
- 	27146,
- 	27156,
- 	27166,
- 	27176,
- 	27186,
- 	27196,
- 	27206,
- 	27216,
- 	27226,
- 	27236,
- 	27246,
- 	27256,
- 	27265,
- 	27275,
- 	27285,
- 	27295,
- 	27305,
- 	27315,
- 	27325,
- 	27335,
- 	27344,
- 	27354,
- 	27364,
- 	27374,
- 	27384,
- 	27394,
- 	27403,
- 	27413,
- 	27423,
- 	27433,
- 	27443,
- 	27452,
- 	27462,
- 	27472,
- 	27482,
- 	27491,
- 	27501,
- 	27511,
- 	27520,
- 	27530,
- 	27540,
- 	27549,
- 	27559,
- 	27569,
- 	27578,
- 	27588,
- 	27598,
- 	27607,
- 	27617,
- 	27627,
- 	27636,
- 	27646,
- 	27655,
- 	27665,
- 	27675,
- 	27684,
- 	27694,
- 	27703,
- 	27713,
- 	27722,
- 	27732,
- 	27741,
- 	27751,
- 	27760,
- 	27770,
- 	27779,
- 	27789,
- 	27798,
- 	27808,
- 	27817,
- 	27827,
- 	27836,
- 	27846,
- 	27855,
- 	27864,
- 	27874,
- 	27883,
- 	27893,
- 	27902,
- 	27911,
- 	27921,
- 	27930,
- 	27939,
- 	27949,
- 	27958,
- 	27967,
- 	27977,
- 	27986,
- 	27995,
- 	28004,
- 	28014,
- 	28023,
- 	28032,
- 	28042,
- 	28051,
- 	28060,
- 	28069,
- 	28078,
- 	28088,
- 	28097,
- 	28106,
- 	28115,
- 	28124,
- 	28134,
- 	28143,
- 	28152,
- 	28161,
- 	28170,
- 	28179,
- 	28188,
- 	28198,
- 	28207,
- 	28216,
- 	28225,
- 	28234,
- 	28243,
- 	28252,
- 	28261,
- 	28270,
- 	28279,
- 	28288,
- 	28297,
- 	28306,
- 	28315,
- 	28324,
- 	28333,
- 	28342,
- 	28351,
- 	28360,
- 	28369,
- 	28378,
- 	28387,
- 	28396,
- 	28405,
- 	28414,
- 	28422,
- 	28431,
- 	28440,
- 	28449,
- 	28458,
- 	28467,
- 	28476,
- 	28485,
- 	28493,
- 	28502,
- 	28511,
- 	28520,
- 	28529,
- 	28537,
- 	28546,
- 	28555,
- 	28564,
- 	28572,
- 	28581,
- 	28590,
- 	28599,
- 	28607,
- 	28616,
- 	28625,
- 	28634,
- 	28642,
- 	28651,
- 	28660,
- 	28668,
- 	28677,
- 	28685,
- 	28694,
- 	28703,
- 	28711,
- 	28720,
- 	28729,
- 	28737,
- 	28746,
- 	28754,
- 	28763,
- 	28771,
- 	28780,
- 	28789,
- 	28797,
- 	28806,
- 	28814,
- 	28823,
- 	28831,
- 	28840,
- 	28848,
- 	28857,
- 	28865,
- 	28873,
- 	28882,
- 	28890,
- 	28899,
- 	28907,
- 	28916,
- 	28924,
- 	28932,
- 	28941,
- 	28949,
- 	28958,
- 	28966,
- 	28974,
- 	28983,
- 	28991,
- 	28999,
- 	29008,
- 	29016,
- 	29024,
- 	29032,
- 	29041,
- 	29049,
- 	29057,
- 	29066,
- 	29074,
- 	29082,
- 	29090,
- 	29099,
- 	29107,
- 	29115,
- 	29123,
- 	29131,
- 	29139,
- 	29148,
- 	29156,
- 	29164,
- 	29172,
- 	29180,
- 	29188,
- 	29197,
- 	29205,
- 	29213,
- 	29221,
- 	29229,
- 	29237,
- 	29245,
- 	29253,
- 	29261,
- 	29269,
- 	29277,
- 	29285,
- 	29293,
- 	29301,
- 	29309,
- 	29317,
- 	29325,
- 	29333,
- 	29341,
- 	29349,
- 	29357,
- 	29365,
- 	29373,
- 	29381,
- 	29389,
- 	29397,
- 	29405,
- 	29412,
- 	29420,
- 	29428,
- 	29436,
- 	29444,
- 	29452,
- 	29460,
- 	29467,
- 	29475,
- 	29483,
- 	29491,
- 	29499,
- 	29506,
- 	29514,
- 	29522,
- 	29530,
- 	29537,
- 	29545,
- 	29553,
- 	29561,
- 	29568,
- 	29576,
- 	29584,
- 	29591,
- 	29599,
- 	29607,
- 	29614,
- 	29622,
- 	29630,
- 	29637,
- 	29645,
- 	29652,
- 	29660,
- 	29668,
- 	29675,
- 	29683,
- 	29690,
- 	29698,
- 	29705,
- 	29713,
- 	29721,
- 	29728,
- 	29736,
- 	29743,
- 	29751,
- 	29758,
- 	29766,
- 	29773,
- 	29780,
- 	29788,
- 	29795,
- 	29803,
- 	29810,
- 	29818,
- 	29825,
- 	29832,
- 	29840,
- 	29847,
- 	29855,
- 	29862,
- 	29869,
- 	29877,
- 	29884,
- 	29891,
- 	29899,
- 	29906,
- 	29913,
- 	29921,
- 	29928,
- 	29935,
- 	29942,
- 	29950,
- 	29957,
- 	29964,
- 	29971,
- 	29979,
- 	29986,
- 	29993,
- 	30000,
- 	30007,
- 	30014,
- 	30022,
- 	30029,
- 	30036,
- 	30043,
- 	30050,
- 	30057,
- 	30064,
- 	30072,
- 	30079,
- 	30086,
- 	30093,
- 	30100,
- 	30107,
- 	30114,
- 	30121,
- 	30128,
- 	30135,
- 	30142,
- 	30149,
- 	30156,
- 	30163,
- 	30170,
- 	30177,
- 	30184,
- 	30191,
- 	30198,
- 	30205,
- 	30212,
- 	30219,
- 	30226,
- 	30232,
- 	30239,
- 	30246,
- 	30253,
- 	30260,
- 	30267,
- 	30274,
- 	30281,
- 	30287,
- 	30294,
- 	30301,
- 	30308,
- 	30315,
- 	30321,
- 	30328,
- 	30335,
- 	30342,
- 	30348,
- 	30355,
- 	30362,
- 	30369,
- 	30375,
- 	30382,
- 	30389,
- 	30395,
- 	30402,
- 	30409,
- 	30415,
- 	30422,
- 	30429,
- 	30435,
- 	30442,
- 	30448,
- 	30455,
- 	30462,
- 	30468,
- 	30475,
- 	30481,
- 	30488,
- 	30494,
- 	30501,
- 	30508,
- 	30514,
- 	30521,
- 	30527,
- 	30534,
- 	30540,
- 	30547,
- 	30553,
- 	30559,
- 	30566,
- 	30572,
- 	30579,
- 	30585,
- 	30592,
- 	30598,
- 	30604,
- 	30611,
- 	30617,
- 	30623,
- 	30630,
- 	30636,
- 	30643,
- 	30649,
- 	30655,
- 	30661,
- 	30668,
- 	30674,
- 	30680,
- 	30687,
- 	30693,
- 	30699,
- 	30705,
- 	30712,
- 	30718,
- 	30724,
- 	30730,
- 	30736,
- 	30743,
- 	30749,
- 	30755,
- 	30761,
- 	30767,
- 	30773,
- 	30780,
- 	30786,
- 	30792,
- 	30798,
- 	30804,
- 	30810,
- 	30816,
- 	30822,
- 	30828,
- 	30834,
- 	30840,
- 	30846,
- 	30853,
- 	30859,
- 	30865,
- 	30871,
- 	30877,
- 	30883,
- 	30888,
- 	30894,
- 	30900,
- 	30906,
- 	30912,
- 	30918,
- 	30924,
- 	30930,
- 	30936,
- 	30942,
- 	30948,
- 	30954,
- 	30959,
- 	30965,
- 	30971,
- 	30977,
- 	30983,
- 	30989,
- 	30994,
- 	31000,
- 	31006,
- 	31012,
- 	31017,
- 	31023,
- 	31029,
- 	31035,
- 	31040,
- 	31046,
- 	31052,
- 	31058,
- 	31063,
- 	31069,
- 	31075,
- 	31080,
- 	31086,
- 	31092,
- 	31097,
- 	31103,
- 	31109,
- 	31114,
- 	31120,
- 	31125,
- 	31131,
- 	31136,
- 	31142,
- 	31148,
- 	31153,
- 	31159,
- 	31164,
- 	31170,
- 	31175,
- 	31181,
- 	31186,
- 	31192,
- 	31197,
- 	31203,
- 	31208,
- 	31214,
- 	31219,
- 	31224,
- 	31230,
- 	31235,
- 	31241,
- 	31246,
- 	31251,
- 	31257,
- 	31262,
- 	31267,
- 	31273,
- 	31278,
- 	31283,
- 	31289,
- 	31294,
- 	31299,
- 	31305,
- 	31310,
- 	31315,
- 	31320,
- 	31326,
- 	31331,
- 	31336,
- 	31341,
- 	31347,
- 	31352,
- 	31357,
- 	31362,
- 	31367,
- 	31373,
- 	31378,
- 	31383,
- 	31388,
- 	31393,
- 	31398,
- 	31403,
- 	31408,
- 	31414,
- 	31419,
- 	31424,
- 	31429,
- 	31434,
- 	31439,
- 	31444,
- 	31449,
- 	31454,
- 	31459,
- 	31464,
- 	31469,
- 	31474,
- 	31479,
- 	31484,
- 	31489,
- 	31494,
- 	31499,
- 	31504,
- 	31508,
- 	31513,
- 	31518,
- 	31523,
- 	31528,
- 	31533,
- 	31538,
- 	31543,
- 	31547,
- 	31552,
- 	31557,
- 	31562,
- 	31567,
- 	31571,
- 	31576,
- 	31581,
- 	31586,
- 	31591,
- 	31595,
- 	31600,
- 	31605,
- 	31609,
- 	31614,
- 	31619,
- 	31624,
- 	31628,
- 	31633,
- 	31638,
- 	31642,
- 	31647,
- 	31651,
- 	31656,
- 	31661,
- 	31665,
- 	31670,
- 	31674,
- 	31679,
- 	31684,
- 	31688,
- 	31693,
- 	31697,
- 	31702,
- 	31706,
- 	31711,
- 	31715,
- 	31720,
- 	31724,
- 	31729,
- 	31733,
- 	31738,
- 	31742,
- 	31747,
- 	31751,
- 	31755,
- 	31760,
- 	31764,
- 	31769,
- 	31773,
- 	31777,
- 	31782,
- 	31786,
- 	31790,
- 	31795,
- 	31799,
- 	31803,
- 	31808,
- 	31812,
- 	31816,
- 	31820,
- 	31825,
- 	31829,
- 	31833,
- 	31837,
- 	31842,
- 	31846,
- 	31850,
- 	31854,
- 	31858,
- 	31863,
- 	31867,
- 	31871,
- 	31875,
- 	31879,
- 	31883,
- 	31887,
- 	31892,
- 	31896,
- 	31900,
- 	31904,
- 	31908,
- 	31912,
- 	31916,
- 	31920,
- 	31924,
- 	31928,
- 	31932,
- 	31936,
- 	31940,
- 	31944,
- 	31948,
- 	31952,
- 	31956,
- 	31960,
- 	31964,
- 	31968,
- 	31972,
- 	31976,
- 	31980,
- 	31984,
- 	31987,
- 	31991,
- 	31995,
- 	31999,
- 	32003,
- 	32007,
- 	32010,
- 	32014,
- 	32018,
- 	32022,
- 	32026,
- 	32029,
- 	32033,
- 	32037,
- 	32041,
- 	32044,
- 	32048,
- 	32052,
- 	32056,
- 	32059,
- 	32063,
- 	32067,
- 	32070,
- 	32074,
- 	32078,
- 	32081,
- 	32085,
- 	32089,
- 	32092,
- 	32096,
- 	32099,
- 	32103,
- 	32107,
- 	32110,
- 	32114,
- 	32117,
- 	32121,
- 	32124,
- 	32128,
- 	32131,
- 	32135,
- 	32138,
- 	32142,
- 	32145,
- 	32149,
- 	32152,
- 	32156,
- 	32159,
- 	32163,
- 	32166,
- 	32169,
- 	32173,
- 	32176,
- 	32180,
- 	32183,
- 	32186,
- 	32190,
- 	32193,
- 	32196,
- 	32200,
- 	32203,
- 	32206,
- 	32209,
- 	32213,
- 	32216,
- 	32219,
- 	32223,
- 	32226,
- 	32229,
- 	32232,
- 	32235,
- 	32239,
- 	32242,
- 	32245,
- 	32248,
- 	32251,
- 	32255,
- 	32258,
- 	32261,
- 	32264,
- 	32267,
- 	32270,
- 	32273,
- 	32276,
- 	32279,
- 	32283,
- 	32286,
- 	32289,
- 	32292,
- 	32295,
- 	32298,
- 	32301,
- 	32304,
- 	32307,
- 	32310,
- 	32313,
- 	32316,
- 	32319,
- 	32322,
- 	32324,
- 	32327,
- 	32330,
- 	32333,
- 	32336,
- 	32339,
- 	32342,
- 	32345,
- 	32348,
- 	32350,
- 	32353,
- 	32356,
- 	32359,
- 	32362,
- 	32365,
- 	32367,
- 	32370,
- 	32373,
- 	32376,
- 	32378,
- 	32381,
- 	32384,
- 	32387,
- 	32389,
- 	32392,
- 	32395,
- 	32397,
- 	32400,
- 	32403,
- 	32405,
- 	32408,
- 	32411,
- 	32413,
- 	32416,
- 	32419,
- 	32421,
- 	32424,
- 	32426,
- 	32429,
- 	32431,
- 	32434,
- 	32437,
- 	32439,
- 	32442,
- 	32444,
- 	32447,
- 	32449,
- 	32452,
- 	32454,
- 	32457,
- 	32459,
- 	32461,
- 	32464,
- 	32466,
- 	32469,
- 	32471,
- 	32473,
- 	32476,
- 	32478,
- 	32481,
- 	32483,
- 	32485,
- 	32488,
- 	32490,
- 	32492,
- 	32495,
- 	32497,
- 	32499,
- 	32501,
- 	32504,
- 	32506,
- 	32508,
- 	32511,
- 	32513,
- 	32515,
- 	32517,
- 	32519,
- 	32522,
- 	32524,
- 	32526,
- 	32528,
- 	32530,
- 	32532,
- 	32535,
- 	32537,
- 	32539,
- 	32541,
- 	32543,
- 	32545,
- 	32547,
- 	32549,
- 	32551,
- 	32553,
- 	32555,
- 	32557,
- 	32559,
- 	32561,
- 	32563,
- 	32565,
- 	32567,
- 	32569,
- 	32571,
- 	32573,
- 	32575,
- 	32577,
- 	32579,
- 	32581,
- 	32583,
- 	32585,
- 	32587,
- 	32588,
- 	32590,
- 	32592,
- 	32594,
- 	32596,
- 	32598,
- 	32600,
- 	32601,
- 	32603,
- 	32605,
- 	32607,
- 	32608,
- 	32610,
- 	32612,
- 	32614,
- 	32615,
- 	32617,
- 	32619,
- 	32621,
- 	32622,
- 	32624,
- 	32626,
- 	32627,
- 	32629,
- 	32631,
- 	32632,
- 	32634,
- 	32635,
- 	32637,
- 	32639,
- 	32640,
- 	32642,
- 	32643,
- 	32645,
- 	32646,
- 	32648,
- 	32649,
- 	32651,
- 	32652,
- 	32654,
- 	32655,
- 	32657,
- 	32658,
- 	32660,
- 	32661,
- 	32663,
- 	32664,
- 	32666,
- 	32667,
- 	32668,
- 	32670,
- 	32671,
- 	32673,
- 	32674,
- 	32675,
- 	32677,
- 	32678,
- 	32679,
- 	32681,
- 	32682,
- 	32683,
- 	32684,
- 	32686,
- 	32687,
- 	32688,
- 	32689,
- 	32691,
- 	32692,
- 	32693,
- 	32694,
- 	32695,
- 	32697,
- 	32698,
- 	32699,
- 	32700,
- 	32701,
- 	32702,
- 	32704,
- 	32705,
- 	32706,
- 	32707,
- 	32708,
- 	32709,
- 	32710,
- 	32711,
- 	32712,
- 	32713,
- 	32714,
- 	32715,
- 	32716,
- 	32717,
- 	32718,
- 	32719,
- 	32720,
- 	32721,
- 	32722,
- 	32723,
- 	32724,
- 	32725,
- 	32726,
- 	32727,
- 	32728,
- 	32729,
- 	32729,
- 	32730,
- 	32731,
- 	32732,
- 	32733,
- 	32734,
- 	32734,
- 	32735,
- 	32736,
- 	32737,
- 	32738,
- 	32738,
- 	32739,
- 	32740,
- 	32741,
- 	32741,
- 	32742,
- 	32743,
- 	32743,
- 	32744,
- 	32745,
- 	32745,
- 	32746,
- 	32747,
- 	32747,
- 	32748,
- 	32749,
- 	32749,
- 	32750,
- 	32750,
- 	32751,
- 	32752,
- 	32752,
- 	32753,
- 	32753,
- 	32754,
- 	32754,
- 	32755,
- 	32755,
- 	32756,
- 	32756,
- 	32757,
- 	32757,
- 	32758,
- 	32758,
- 	32759,
- 	32759,
- 	32759,
- 	32760,
- 	32760,
- 	32761,
- 	32761,
- 	32761,
- 	32762,
- 	32762,
- 	32762,
- 	32763,
- 	32763,
- 	32763,
- 	32764,
- 	32764,
- 	32764,
- 	32764,
- 	32765,
- 	32765,
- 	32765,
- 	32765,
- 	32766,
- 	32766,
- 	32766,
- 	32766,
- 	32766,
- 	32767,
- 	32767,
- 	32767,
- 	32767,
- 	32767,
- 	32767,
- 	32767,
- 	32768,
- 	32768,
- 	32768,
- 	32768,
- 	32768,
- 	32768,
- 	32768,
- 	32768,
- 	32768,
- 	32768,
- 	32768
- 	};
--- 0 ----
diff -c mit/server/ddx/x386/vga16/ibm/ppcWindow.c:2.1 mit/server/ddx/x386/vga16/ibm/ppcWindow.c:2.2
*** mit/server/ddx/x386/vga16/ibm/ppcWindow.c:2.1	Fri Mar 11 23:40:39 1994
--- mit/server/ddx/x386/vga16/ibm/ppcWindow.c	Fri Mar 11 23:40:39 1994
***************
*** 44,50 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcWindow.c,v 2.1 1993/08/28 07:54:18 dawes Exp $ */
  
  #include "X.h"
  #include "scrnintstr.h"
--- 44,50 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcWindow.c,v 2.2 1994/02/01 13:54:34 dawes Exp $ */
  
  #include "X.h"
  #include "scrnintstr.h"
***************
*** 75,81 ****
      register int nbox ;
      register int pm ;
  
-     register void (*fnp)() ;
      BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew ;
  				/* temporaries for shuffling rectangles */
  
--- 75,80 ----
***************
*** 160,168 ****
       */
  
      pm = ( 1 << pWin->drawable.depth ) - 1 ;
-     fnp = ((ppcScrnPriv *)(pWin->drawable.pScreen->devPrivate))->blit ;
      for ( ; nbox-- ; pbox++ )
! 	(* fnp)( GXcopy, pm, pm, 
  		 pbox->x1 + dx, pbox->y1 + dy, 
  		 pbox->x1, pbox->y1, 
  		 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1) ;
--- 159,166 ----
       */
  
      pm = ( 1 << pWin->drawable.depth ) - 1 ;
      for ( ; nbox-- ; pbox++ )
! 	vgaBitBlt( GXcopy, pm, pm, 
  		 pbox->x1 + dx, pbox->y1 + dy, 
  		 pbox->x1, pbox->y1, 
  		 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1) ;
***************
*** 189,195 ****
      register int pm ;
      int box_direction = 1 ; /* go forward */
  
-     register void (*fnp)() ;
      BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew ;
  				/* temporaries for shuffling rectangles */
  
--- 187,192 ----
***************
*** 267,277 ****
       */
  
      pm = (~( ~0 << pWin->drawable.depth ) ) & pWin->optional->backingBitPlanes ;
-     fnp = ((ppcScrnPriv *)(pWin->drawable.pScreen->devPrivate))->blit ;
      if ( box_direction < 0 )
  	pbox += nbox - 1 ;
      for ( ; nbox-- ; pbox += box_direction )
! 	(* fnp)( GXcopy, pm, pm, 
  		 pbox->x1 + dx, pbox->y1 + dy, 
  		 pbox->x1, pbox->y1, 
  		 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1) ;
--- 264,273 ----
       */
  
      pm = (~( ~0 << pWin->drawable.depth ) ) & pWin->optional->backingBitPlanes ;
      if ( box_direction < 0 )
  	pbox += nbox - 1 ;
      for ( ; nbox-- ; pbox += box_direction )
! 	vgaBitBlt( GXcopy, pm, pm, 
  		 pbox->x1 + dx, pbox->y1 + dy, 
  		 pbox->x1, pbox->y1, 
  		 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1) ;
***************
*** 284,293 ****
  	if ( nbox = REGION_NUM_RECTS(prgnDst)) {
  	    unsigned long int fg = pWin->optional->backingPixel ;
  
- 	    fnp =
- 	      ((ppcScrnPriv *)(pWin->drawable.pScreen->devPrivate))->solidFill ;
  	    for ( pbox = REGION_RECTS(prgnDst) ; nbox-- ; pbox++ )
! 		(* fnp)( fg, GXcopy, pm,
  			 pbox->x1, pbox->y1,
  			 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ;
  	    }
--- 280,287 ----
  	if ( nbox = REGION_NUM_RECTS(prgnDst)) {
  	    unsigned long int fg = pWin->optional->backingPixel ;
  
  	    for ( pbox = REGION_RECTS(prgnDst) ; nbox-- ; pbox++ )
! 		vgaFillSolid( fg, GXcopy, pm,
  			 pbox->x1, pbox->y1,
  			 pbox->x2 - pbox->x1, pbox->y2 - pbox->y1 ) ;
  	    }
diff -c mit/server/ddx/x386/vga16/ibm/ppcWindowFS.c:2.0 mit/server/ddx/x386/vga16/ibm/ppcWindowFS.c:2.1
*** mit/server/ddx/x386/vga16/ibm/ppcWindowFS.c:2.0	Fri Mar 11 23:40:40 1994
--- mit/server/ddx/x386/vga16/ibm/ppcWindowFS.c	Fri Mar 11 23:40:40 1994
***************
*** 45,51 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcWindowFS.c,v 2.0 1993/08/19 16:09:13 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v 1.1 89/05/07 15:23:36 jeff Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v */
  
--- 45,51 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/ppcWindowFS.c,v 2.1 1994/02/01 13:54:36 dawes Exp $ */
  /* Header: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v 1.1 89/05/07 15:23:36 jeff Exp */
  /* Source: /andrew/X11/r3src/r3plus/server/ddx/ibm/ppc/RCS/ppcWindowFS.c,v */
  
***************
*** 89,95 ****
      int		*pwidthInit ;		/* pointer to list of n widths */
      int 	fSorted ;
  {
-     register void (*fnp)() ;
      register unsigned long int pm ;
      register unsigned long int fg ;
      register int alu ;
--- 89,94 ----
***************
*** 126,138 ****
      n = miClipSpans( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip,
  		     pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ;
  
-     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->solidFill ;
      pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
      fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  
      for ( ; n-- ; ppt++, pwidth++ )
  	if ( *pwidth )
! 	    (* fnp)( fg, alu, pm, ppt->x, ppt->y, *pwidth, 1 ) ;
  
      DEALLOCATE_LOCAL( pptFree ) ;
      DEALLOCATE_LOCAL( pwidthFree ) ;
--- 125,136 ----
      n = miClipSpans( ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->pCompositeClip,
  		     pptInit, pwidthInit, nInit, ppt, pwidth, fSorted ) ;
  
      pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
      fg = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.fgPixel ;
  
      for ( ; n-- ; ppt++, pwidth++ )
  	if ( *pwidth )
! 	    vgaFillSolid( fg, alu, pm, ppt->x, ppt->y, *pwidth, 1 ) ;
  
      DEALLOCATE_LOCAL( pptFree ) ;
      DEALLOCATE_LOCAL( pwidthFree ) ;
***************
*** 148,154 ****
  int *pwidthInit ;		/* pointer to list of n widths */
  int fSorted ;
  {
-     register void (*fnp)() ;
      register unsigned long int pm ;
      register unsigned long int fg ;
      register int alu ;
--- 146,151 ----
***************
*** 188,197 ****
      xSrc = pGC->patOrg.x + pDrawable->x ;
      ySrc = pGC->patOrg.y + pDrawable->y ;
      pTile = pGC->stipple ;
-     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->stipFill ;
  
      for ( ; n-- ; ppt++, pwidth++ )
! 	(* fnp)( pTile, fg, alu, pm, ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
  
      DEALLOCATE_LOCAL( pptFree ) ;
      DEALLOCATE_LOCAL( pwidthFree ) ;
--- 185,193 ----
      xSrc = pGC->patOrg.x + pDrawable->x ;
      ySrc = pGC->patOrg.y + pDrawable->y ;
      pTile = pGC->stipple ;
  
      for ( ; n-- ; ppt++, pwidth++ )
! 	vgaFillStipple( pTile, fg, alu, pm, ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
  
      DEALLOCATE_LOCAL( pptFree ) ;
      DEALLOCATE_LOCAL( pwidthFree ) ;
***************
*** 210,216 ****
  {
      register DDXPointPtr ppt ;	/* pointer to list of start points */
      register int *pwidth ;	/* pointer to list of n widths */
-     register void (*fnp)() ;
      int n ;			/* number of spans to fill */
      int xSrc ;
      int ySrc ;
--- 206,211 ----
***************
*** 242,251 ****
      xSrc = pGC->patOrg.x + pDrawable->x ;
      ySrc = pGC->patOrg.y + pDrawable->y ;
  
-     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->opstipFill ;
- 
      for ( ; n-- ; ppt++, pwidth++ )
! 	(*fnp)( pGC->stipple, fg, bg, alu, pm,
  		ppt->x, ppt->y, *pwidth, 1,
  		xSrc, ySrc ) ;
  
--- 237,244 ----
      xSrc = pGC->patOrg.x + pDrawable->x ;
      ySrc = pGC->patOrg.y + pDrawable->y ;
  
      for ( ; n-- ; ppt++, pwidth++ )
! 	ppcOpaqueStipple( pGC->stipple, fg, bg, alu, pm,
  		ppt->x, ppt->y, *pwidth, 1,
  		xSrc, ySrc ) ;
  
***************
*** 263,269 ****
  int *pwidthInit ;		/* pointer to list of n widths */
  int fSorted ;
  {
-     register void (* fnp)() ;
  				/* next three parameters are post-clip */
      register DDXPointPtr ppt ;	/* pointer to list of start points */
      register int *pwidth ;	/* pointer to list of n widths */
--- 256,261 ----
***************
*** 287,296 ****
      xSrc = pGC->patOrg.x + pDrawable->x ;
      ySrc = pGC->patOrg.y + pDrawable->y ;
      pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
-     fnp = ( (ppcScrnPriv *) ( pDrawable->pScreen->devPrivate ) )->tileFill ;
  
      for ( ; n-- ; ppt++, pwidth++ )
! 	    (* fnp)( pGC->tile.pixmap, alu, pm,
  		     ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
  
      DEALLOCATE_LOCAL( pptFree ) ;
--- 279,287 ----
      xSrc = pGC->patOrg.x + pDrawable->x ;
      ySrc = pGC->patOrg.y + pDrawable->y ;
      pm = ( (ppcPrivGC *) pGC->devPrivates[mfbGCPrivateIndex].ptr )->colorRrop.planemask ;
  
      for ( ; n-- ; ppt++, pwidth++ )
! 	    ppcTileRect( pGC->tile.pixmap, alu, pm,
  		     ppt->x, ppt->y, *pwidth, 1, xSrc, ySrc ) ;
  
      DEALLOCATE_LOCAL( pptFree ) ;
diff -c mit/server/ddx/x386/vga16/ibm/vgaAddr.c:2.0 mit/server/ddx/x386/vga16/ibm/vgaAddr.c:2.1
*** mit/server/ddx/x386/vga16/ibm/vgaAddr.c:2.0	Fri Mar 11 23:40:40 1994
--- mit/server/ddx/x386/vga16/ibm/vgaAddr.c	Fri Mar 11 23:40:40 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaAddr.c,v 2.0 1993/08/19 16:09:15 dawes Exp $ */
  
  #ifndef LEFT_SHIFT
  #ifndef RIGHT_SHIFT
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaAddr.c,v 2.1 1994/02/01 13:54:37 dawes Exp $ */
  
  #ifndef LEFT_SHIFT
  #ifndef RIGHT_SHIFT
***************
*** 69,74 ****
--- 69,75 ----
  unsigned int height ;
  int y_increment ;
  {
+ register int tmp_bits ; /* GJA -- introduced */
  #if !defined(NO_SHIFT)
  register unsigned char tmp ;
  #endif
***************
*** 76,109 ****
  #ifdef LEFT_SHIFT
  register int savebits ;
  #define shift ( 8 - backshift )
! register volatile unsigned char *stop_address = source - bytewidth ;
  register const int row_jump = y_increment + bytewidth ;
  #define SHIFT_OP <<
  #define BACKSHIFT_OP >>
  #define INCREMENT_OP --
  #define SAVE_OFFSET ( 1 )
  
  #else
  #ifdef RIGHT_SHIFT
  register int savebits ;
  #define backshift ( 8 - shift )
! register volatile unsigned char *stop_address = source + bytewidth ;
  register int row_jump = y_increment - bytewidth ;
  #define SHIFT_OP >>
  #define BACKSHIFT_OP <<
  #define INCREMENT_OP ++
  #define SAVE_OFFSET ( -1 )
  
  #else
  #ifdef NO_SHIFT
  #ifdef MOVE_RIGHT
! register volatile unsigned char *stop_address = source + bytewidth ;
  register int row_jump = y_increment - bytewidth ;
  #define INCREMENT_OP ++
  #else
! register volatile unsigned char *stop_address = source - bytewidth ;
  register int row_jump = y_increment + bytewidth ;
  #define INCREMENT_OP --
  
  #endif
  #endif
--- 77,118 ----
  #ifdef LEFT_SHIFT
  register int savebits ;
  #define shift ( 8 - backshift )
! int stop_count = bytewidth ;
  register const int row_jump = y_increment + bytewidth ;
  #define SHIFT_OP <<
  #define BACKSHIFT_OP >>
  #define INCREMENT_OP --
  #define SAVE_OFFSET ( 1 )
+ #define UPDR(x) VDECR(x)
+ #define UPDW(x) VDECW(x)
  
  #else
  #ifdef RIGHT_SHIFT
  register int savebits ;
  #define backshift ( 8 - shift )
! int stop_count = bytewidth ;
  register int row_jump = y_increment - bytewidth ;
  #define SHIFT_OP >>
  #define BACKSHIFT_OP <<
  #define INCREMENT_OP ++
  #define SAVE_OFFSET ( -1 )
+ #define UPDR(x) VINCR(x)
+ #define UPDW(x) VINCW(x)
  
  #else
  #ifdef NO_SHIFT
  #ifdef MOVE_RIGHT
! int stop_count = bytewidth ;
  register int row_jump = y_increment - bytewidth ;
  #define INCREMENT_OP ++
+ #define UPDR(x) VINCR(x)
+ #define UPDW(x) VINCW(x)
  #else
! int stop_count = bytewidth ;
  register int row_jump = y_increment + bytewidth ;
  #define INCREMENT_OP --
+ #define UPDR(x) VDECR(x)
+ #define UPDW(x) VDECW(x)
  
  #endif
  #endif
***************
*** 110,135 ****
  #endif
  #endif
  
  /* TOP OF FIRST LOOP */
  BranchPoint:
  
  #if !defined(NO_SHIFT)
  #define SINGLE_LOAD \
! 	tmp = *( (VgaMemoryPtr) ( source INCREMENT_OP ) ) ;
  
  #define SINGLE_STORE \
!     ( ( *( (VgaMemoryPtr) ( destination INCREMENT_OP ) ) = \
! 	   ( tmp SHIFT_OP shift ) | savebits ) )
  #define SINGLE_SAVE ( savebits = tmp BACKSHIFT_OP backshift )
  
! savebits =
!     *( (VgaMemoryPtr) ( source + SAVE_OFFSET ) )
! 	BACKSHIFT_OP backshift ;
  
  #else /* MOD 8 == 0 GOOD CASE */
  #define SINGLE_LOAD \
!     ( *( (VgaMemoryPtr) ( destination INCREMENT_OP ) ) = \
! 	*( (VgaMemoryPtr) ( source INCREMENT_OP ) ) )
  
  #define SINGLE_SAVE
  #define SINGLE_STORE
--- 119,158 ----
  #endif
  #endif
  
+ /* GJA -- setup banking */
+ VSETW(destination); VSETR(source);
+ 
  /* TOP OF FIRST LOOP */
  BranchPoint:
  
  #if !defined(NO_SHIFT)
  #define SINGLE_LOAD \
! 	tmp = *(VgaMemoryPtr) source ; UPDR(source) ;
  
  #define SINGLE_STORE \
!     VPUSHR(); \
!     ( ( *( (VgaMemoryPtr) destination ) ) = \
! 	   ( tmp SHIFT_OP shift ) | savebits ) ; \
! 	UPDW(destination) ; \
!     VPOPR();
  #define SINGLE_SAVE ( savebits = tmp BACKSHIFT_OP backshift )
  
! #if (SAVE_OFFSET == 1)
! VINCR(source);
!    savebits = *( (VgaMemoryPtr) source ) BACKSHIFT_OP backshift ;
! VDECR(source);
! #else
! VDECR(source);
!    savebits = *( (VgaMemoryPtr) source ) BACKSHIFT_OP backshift ;
! VINCR(source);
! #endif
  
  #else /* MOD 8 == 0 GOOD CASE */
  #define SINGLE_LOAD \
!     tmp_bits = *( (VgaMemoryPtr) source ) ; UPDR(source); \
!     VPUSHR(); \
!     *(VgaMemoryPtr) destination = tmp_bits ; UPDW(destination); \
!     VPOPR();
  
  #define SINGLE_SAVE
  #define SINGLE_STORE
***************
*** 140,163 ****
  
  switch ( bytewidth & 0xF ) {
  	LoopTop :
! 	case 0x0 : SINGLE_STEP ;
! 	case 0xF : SINGLE_STEP ;
! 	case 0xE : SINGLE_STEP ;
! 	case 0xD : SINGLE_STEP ;
! 	case 0xC : SINGLE_STEP ;
! 	case 0xB : SINGLE_STEP ;
! 	case 0xA : SINGLE_STEP ;
! 	case 0x9 : SINGLE_STEP ;
! 	case 0x8 : SINGLE_STEP ;
! 	case 0x7 : SINGLE_STEP ;
! 	case 0x6 : SINGLE_STEP ;
! 	case 0x5 : SINGLE_STEP ;
! 	case 0x4 : SINGLE_STEP ;
! 	case 0x3 : SINGLE_STEP ;
! 	case 0x2 : SINGLE_STEP ;
! 	case 0x1 : SINGLE_LOAD ; SINGLE_STORE ;
  /* FIRST LOOP */
! 		if ( source != stop_address ) {
  			SINGLE_SAVE ;
  			goto LoopTop ;
  		}
--- 163,186 ----
  
  switch ( bytewidth & 0xF ) {
  	LoopTop :
! 	case 0x0 : SINGLE_STEP ; stop_count--;
! 	case 0xF : SINGLE_STEP ; stop_count--;
! 	case 0xE : SINGLE_STEP ; stop_count--;
! 	case 0xD : SINGLE_STEP ; stop_count--;
! 	case 0xC : SINGLE_STEP ; stop_count--;
! 	case 0xB : SINGLE_STEP ; stop_count--;
! 	case 0xA : SINGLE_STEP ; stop_count--;
! 	case 0x9 : SINGLE_STEP ; stop_count--;
! 	case 0x8 : SINGLE_STEP ; stop_count--;
! 	case 0x7 : SINGLE_STEP ; stop_count--;
! 	case 0x6 : SINGLE_STEP ; stop_count--;
! 	case 0x5 : SINGLE_STEP ; stop_count--;
! 	case 0x4 : SINGLE_STEP ; stop_count--;
! 	case 0x3 : SINGLE_STEP ; stop_count--;
! 	case 0x2 : SINGLE_STEP ; stop_count--;
! 	case 0x1 : SINGLE_LOAD ; SINGLE_STORE ; stop_count--;
  /* FIRST LOOP */
! 		if ( stop_count ) {
  			SINGLE_SAVE ;
  			goto LoopTop ;
  		}
***************
*** 165,171 ****
  		if ( --height ) {
  			source += row_jump ;
  			destination += row_jump ;
! 			stop_address += y_increment ;
  			goto BranchPoint ;
  		}
  		else
--- 188,201 ----
  		if ( --height ) {
  			source += row_jump ;
  			destination += row_jump ;
! 			if ( row_jump > 0 ) {
! 				VCHECKRO(source);
! 				VPUSHR(); VCHECKWO(destination); VPOPR();
! 			} else {
! 				VCHECKRU(source);
! 				VPUSHR(); VCHECKWU(destination); VPOPR();
! 			}
! 			stop_count = bytewidth ;
  			goto BranchPoint ;
  		}
  		else
***************
*** 180,185 ****
--- 210,217 ----
  #undef SINGLE_STORE
  #undef SINGLE_SAVE
  #undef SINGLE_STEP
+ #undef UPDR
+ #undef UPDW
  
  #ifndef NO_SHIFT
  #undef SHIFT_OP
diff -c mit/server/ddx/x386/vga16/ibm/vgaBitBlt.c:2.1 mit/server/ddx/x386/vga16/ibm/vgaBitBlt.c:2.3
*** mit/server/ddx/x386/vga16/ibm/vgaBitBlt.c:2.1	Fri Mar 11 23:40:41 1994
--- mit/server/ddx/x386/vga16/ibm/vgaBitBlt.c	Fri Mar 11 23:40:41 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaBitBlt.c,v 2.1 1993/08/20 16:27:36 dawes Exp $ */
  
  /*
   * REGISTER USAGE
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaBitBlt.c,v 2.3 1994/03/08 04:51:09 dawes Exp $ */
  
  /*
   * REGISTER USAGE
***************
*** 97,112 ****
  /* This Code MIGHT try to read the byte before the start of the screen */
  
  	{
! 		if ( source != VGABASE )
! 		tmp1 =
! 	  SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset )
! 	| SCRLEFT8( *( (VgaMemoryPtr) ( source - 1 ) ), ( 8 - byte_offset ) ) ;
! 		else
! 		tmp1 =
! 	  SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset ) ;
  	}
  	else
  		tmp1 = *( (VgaMemoryPtr) source ) ;
  	tmp2 = *( (VgaMemoryPtr) destination ) ;
  	switch ( alu ) {
  	case GXnor:
--- 97,113 ----
  /* This Code MIGHT try to read the byte before the start of the screen */
  
  	{
! 		if ( source != VIDBASE ) {
! 			tmp1 = SCRRIGHT8( *( (VgaMemoryPtr) source ), byte_offset ) ;
! 			VDECR(source);
! 			tmp1 |= SCRLEFT8( *( (VgaMemoryPtr) source ), ( 8 - byte_offset ) ) ;
! 			VINCR(source);
! 		} else
! 		tmp1 = SCRRIGHT8( *( (VgaMemoryPtr) source ), byte_offset ) ;
  	}
  	else
  		tmp1 = *( (VgaMemoryPtr) source ) ;
+ 	VPUSHR();
  	tmp2 = *( (VgaMemoryPtr) destination ) ;
  	switch ( alu ) {
  	case GXnor:
***************
*** 146,151 ****
--- 147,153 ----
  		break ;
  	}
  	*( (VgaMemoryPtr) destination ) = tmp1 ;
+ 	VPOPR();
  return ;
  }
  
***************
*** 161,187 ****
  register int y_direction ;
  {
    register unsigned long int tmp1, tmp2 ;
    if ( byte_offset ) {
  
!     for ( ; height-- ; destination += y_direction, source += y_direction ) {
        if (source != vgaBase) {
!         tmp1 =
! 	 SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset )
! 	  | SCRLEFT8( *( (VgaMemoryPtr) (source - 1)), ( 8 - byte_offset )) ;
        } else {
          tmp1 =
           SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset ) ;
        }
        tmp2 = *( (VgaMemoryPtr) destination ) ;
          *( (VgaMemoryPtr) destination ) = tmp1 ;
      }
  
    } else {
  
!    for ( ; height-- ; destination += y_direction, source += y_direction ) {
        tmp1 = *( (VgaMemoryPtr) source ) ;
        tmp2 = *( (VgaMemoryPtr) destination ) ;
        *( (VgaMemoryPtr) destination ) = tmp1 ; }
    }
  return ;
  }
--- 163,199 ----
  register int y_direction ;
  {
    register unsigned long int tmp1, tmp2 ;
+   VSETW(destination); VSETR(source); /* GJA */
    if ( byte_offset ) {
  
!     for ( ; height-- ; ) {
        if (source != vgaBase) {
!         tmp1 = SCRRIGHT8( *( (VgaMemoryPtr) source ), byte_offset ) ;
! 	VDECR(source);
! 	tmp1 |= SCRLEFT8( *( (VgaMemoryPtr) source), ( 8 - byte_offset )) ;
! 	VINCR(source);
        } else {
          tmp1 =
           SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset ) ;
        }
+       ADDR(source,y_direction);
+       VPUSHR();
        tmp2 = *( (VgaMemoryPtr) destination ) ;
          *( (VgaMemoryPtr) destination ) = tmp1 ;
+       ADDW(destination,y_direction); 
+       VPOPR();
      }
  
    } else {
  
!    for ( ; height-- ; ) {
        tmp1 = *( (VgaMemoryPtr) source ) ;
+       ADDR(source,y_direction);
+       VPUSHR();
        tmp2 = *( (VgaMemoryPtr) destination ) ;
        *( (VgaMemoryPtr) destination ) = tmp1 ; }
+       ADDW(destination,y_direction); 
+       VPOPR();
    }
  return ;
  }
***************
*** 199,220 ****
  {
  register unsigned long int tmp1, tmp2 ;
  
! 	for ( ; height-- ; destination += y_direction, source += y_direction ) {
  		if ( byte_offset )
  	/* This Code MIGHT try to read the byte before the start of the screen */
  		{
! 			if ( source != vgaBase )
  			tmp1 =
! 		  SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset )
! 		| SCRLEFT8( *( (VgaMemoryPtr) ( source - 1 ) ), ( 8 - byte_offset ) ) ;
! 			else
  			tmp1 =
  		  SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset ) ;
  		}
  		else
  			tmp1 = *( (VgaMemoryPtr) source ) ;
  		tmp2 = *( (VgaMemoryPtr) destination ) ;
  		*( (VgaMemoryPtr) destination ) = tmp1 ;
  	}
  return ;
  }
--- 211,241 ----
  {
  register unsigned long int tmp1, tmp2 ;
  
! 	VSETW(destination); VSETR(source); /* GJA */
! 
! 	for ( ; height-- ; ) {
  		if ( byte_offset )
  	/* This Code MIGHT try to read the byte before the start of the screen */
  		{
! 			if ( source != vgaBase ) {
  			tmp1 =
! 		  SCRRIGHT8( *( (VgaMemoryPtr) source ), byte_offset ) ;
! 			VDECR(source);
! 			tmp1 |=
! 		  SCRLEFT8( *( (VgaMemoryPtr) source ), ( 8 - byte_offset ) ) ;
! 			VINCR(source);
! 			} else
  			tmp1 =
  		  SCRRIGHT8( *( (VgaMemoryPtr) ( source ) ), byte_offset ) ;
  		}
  		else
  			tmp1 = *( (VgaMemoryPtr) source ) ;
+ 		ADDR(source,y_direction);
+ 		VPUSHR();
  		tmp2 = *( (VgaMemoryPtr) destination ) ;
  		*( (VgaMemoryPtr) destination ) = tmp1 ;
+ 		ADDW(destination,y_direction); 
+ 		VPOPR();
  	}
  return ;
  }
***************
*** 228,238 ****
  register int y_direction ;
  {
  register unsigned char tmp1, tmp2 ;
! 
! 	for ( ; height-- ; dest += y_direction, src += y_direction ) {
  		tmp1 = *( (VgaMemoryPtr) src ) ;
  		tmp2 = *( (VgaMemoryPtr) dest ) ;
  		*( (VgaMemoryPtr) dest ) = tmp1 ;
  	}
  return ;
  }
--- 249,264 ----
  register int y_direction ;
  {
  register unsigned char tmp1, tmp2 ;
!  
! 	VSETW(dest); VSETR(src); /* GJA */
! 	for ( ; height-- ; ) {
  		tmp1 = *( (VgaMemoryPtr) src ) ;
+ 		ADDR(src,y_direction);
+ 		VPUSHR();
  		tmp2 = *( (VgaMemoryPtr) dest ) ;
  		*( (VgaMemoryPtr) dest ) = tmp1 ;
+ 		ADDW(dest,y_direction); 
+ 		VPOPR();
  	}
  return ;
  }
***************
*** 239,244 ****
--- 265,283 ----
  
  extern int vgaFillSolid() ;
  
+ /* GJA -- BANKING STRATEGY:
+  * The strategy for setting up banking is quite simple:
+  * Call SETR/SETW whenever we begin a vertical line or block.
+  * This can be at the start of the left edge, at the start of the right
+  * edge, or at the start of the center.
+  * This requires that we walk 'nicely' through the center; e.g. assuming,
+  * for the sake of example, that we can move bytes left to right and top
+  * down: when we arrive at the right hand side of a span we jump to the next
+  * span in the rectangle by adding the remaining bytes, not by BYTES_PER_LINE
+  * to the left hand side of the previous span.
+  * The latter will go wrong if there has been a bankswitch in the middle of
+  * the span: The addition will cause yet another bank switch.
+  */
  void
  vgaBitBlt( alu, readplanes, writeplanes, x0, y0, x1, y1, w, h )
  const int alu, readplanes, writeplanes ;
***************
*** 290,304 ****
  right_ragged = 7 - BIT_OFFSET( x1 + w - 1 ) ;
  center_width = ROW_OFFSET( x1 + w ) - ROW_OFFSET( ( x1 + 0x7 ) & ~0x7 ) ;
  
! src = (unsigned char *) VGABASE + ( BYTES_PER_ROW * y0 ) ;
! dst = (unsigned char *) VGABASE + ( BYTES_PER_ROW * y1 ) ;
  if ( y1 > y0 ) {
! 	y_interval = - BYTES_PER_ROW ;
! 	src += BYTES_PER_ROW * ( h - 1 ) ;
! 	dst += BYTES_PER_ROW * ( h - 1 ) ;
  }
  else {
! 	y_interval = BYTES_PER_ROW ;
  }
  
  if ( x1 < x0 ) {
--- 329,343 ----
  right_ragged = 7 - BIT_OFFSET( x1 + w - 1 ) ;
  center_width = ROW_OFFSET( x1 + w ) - ROW_OFFSET( ( x1 + 0x7 ) & ~0x7 ) ;
  
! src = (unsigned char *) VIDBASE + ( BYTES_PER_LINE * y0 ) ;
! dst = (unsigned char *) VIDBASE + ( BYTES_PER_LINE * y1 ) ;
  if ( y1 > y0 ) {
! 	y_interval = - BYTES_PER_LINE ;
! 	src += BYTES_PER_LINE * ( h - 1 ) ;
! 	dst += BYTES_PER_LINE * ( h - 1 ) ;
  }
  else {
! 	y_interval = BYTES_PER_LINE ;
  }
  
  if ( x1 < x0 ) {
***************
*** 356,366 ****
  
  /* Test For Special Case -- Try To Do Fast Blt */
  if ( alu == GXcopy ) {
  	if ( !byte_offset ) { /* Test For Special Case -- VERY Fast Blt */
  		/* Prepare To Set Bit Mask */
- 		SetVideoGraphicsIndex( Bit_MaskIndex ) ;
  		if ( first_edgeMask ) {
! 			outb( 0x3CF, first_edgeMask ) ;
  			/* Set Data Rotate Function To Direct Write */
  			SetVideoGraphics( Data_RotateIndex, VGA_COPY_MODE ) ;
  			for ( currplane = 0 ;
--- 395,405 ----
  
  /* Test For Special Case -- Try To Do Fast Blt */
  if ( alu == GXcopy ) {
+ 
  	if ( !byte_offset ) { /* Test For Special Case -- VERY Fast Blt */
  		/* Prepare To Set Bit Mask */
  		if ( first_edgeMask ) {
! 			SetVideoGraphics( Bit_MaskIndex, first_edgeMask ) ;
  			/* Set Data Rotate Function To Direct Write */
  			SetVideoGraphics( Data_RotateIndex, VGA_COPY_MODE ) ;
  			for ( currplane = 0 ;
***************
*** 372,377 ****
--- 411,417 ----
  					SetVideoGraphics( Read_Map_SelectIndex,
  							  currplane ) ;
  					/* Move First Edge */
+ 					/* GJA -- handles banking */
  					edgeLoop( dst, src, h, y_interval ) ;
  				}
  			}
***************
*** 378,394 ****
  			if ( center_width < 0 ) {
  				return ;
  			}
! 			src += x_interval ;
! 			dst += x_interval ;
  		}
  		/* Set Map Mask */
  		SetVideoSequencer( Mask_MapIndex, writeplanes & VGA_ALLPLANES );
- 		/* Point At The Bit Mask Reg */
- 		SetVideoGraphicsIndex( Bit_MaskIndex ) ;
  		/* Move Center Of Box */
  		if ( center_width ) {
  			/* Set Bit Mask -- ALL OFF */
! 			outb( 0x3CF, 0 ) ;
  			(* ( ( x_interval > 0 )
  			   ? fast_blt_Aligned_Right : fast_blt_Aligned_Left ) )
  				( src, dst, center_width, h, y_interval ) ;
--- 418,433 ----
  			if ( center_width < 0 ) {
  				return ;
  			}
! 			src += x_interval;
! 			dst += x_interval;
  		}
  		/* Set Map Mask */
  		SetVideoSequencer( Mask_MapIndex, writeplanes & VGA_ALLPLANES );
  		/* Move Center Of Box */
  		if ( center_width ) {
  			/* Set Bit Mask -- ALL OFF */
! 			SetVideoGraphics( Bit_MaskIndex, 0 ) ; /* GJA */
! 			/* GJA -- handles banking */
  			(* ( ( x_interval > 0 )
  			   ? fast_blt_Aligned_Right : fast_blt_Aligned_Left ) )
  				( src, dst, center_width, h, y_interval ) ;
***************
*** 397,403 ****
  			return ;
  		}
  		/* Move Second Edge */
! 		outb( 0x3CF, second_edgeMask ) ;
  		/* Adjust Offsets */
  		if ( x_interval > 0 ) {
  			src += center_width ;
--- 436,442 ----
  			return ;
  		}
  		/* Move Second Edge */
! 		SetVideoGraphics( Bit_MaskIndex, second_edgeMask ) ; /* GJA */
  		/* Adjust Offsets */
  		if ( x_interval > 0 ) {
  			src += center_width ;
***************
*** 417,422 ****
--- 456,462 ----
  				/* Set Map Read Select */
  				SetVideoGraphics( Read_Map_SelectIndex,
  						  currplane ) ;
+ 				/* GJA -- handles banking */
  				edgeLoop( dst, src, h, y_interval ) ;
  			}
  		}
***************
*** 438,455 ****
  				s1ptr = src ;
  				d1ptr = dst ;
  				if ( first_edgeMask ) {
! 					outb( 0x3CF, first_edgeMask ) ;
  					fix_video_byte_copy_edgeLoop(
  					  src, dst, byte_offset,
  					  h, y_interval ) ;
  					if ( center_width < 0 ) /* All In One Byte */
  						continue ; /* Next Plane */
! 					outb( 0x3CF, 0xFF ) ;
  					s1ptr = src + x_interval ;
  					d1ptr = dst + x_interval ;
  				}
  				/* Move Center Of Box */
  				if ( center_width ) {
  					(* ( ( x_interval >= 0 )
  					 ? fast_blt_Right : fast_blt_Left ) )
  					( ( ( x_interval >= 0 ) ? s1ptr : s1ptr - 1 ),
--- 478,498 ----
  				s1ptr = src ;
  				d1ptr = dst ;
  				if ( first_edgeMask ) {
! 					SetVideoGraphics( Bit_MaskIndex,
! 						first_edgeMask ) ; /* GJA */
! 					/* GJA -- handles banking */
  					fix_video_byte_copy_edgeLoop(
  					  src, dst, byte_offset,
  					  h, y_interval ) ;
  					if ( center_width < 0 ) /* All In One Byte */
  						continue ; /* Next Plane */
! 					SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* GJA */
  					s1ptr = src + x_interval ;
  					d1ptr = dst + x_interval ;
  				}
  				/* Move Center Of Box */
  				if ( center_width ) {
+ 					/* GJA -- handles banking */
  					(* ( ( x_interval >= 0 )
  					 ? fast_blt_Right : fast_blt_Left ) )
  					( ( ( x_interval >= 0 ) ? s1ptr : s1ptr - 1 ),
***************
*** 467,477 ****
  				}
  				/* Move Second Edge */
  				if ( second_edgeMask ) {
! 					outb( 0x3CF, second_edgeMask ) ;
  					fix_video_byte_copy_edgeLoop(
  					  s1ptr, d1ptr, byte_offset,
  					  h, y_interval ) ;
! 					outb( 0x3CF, 0xFF ) ;
  				}
  			}
  		}
--- 510,521 ----
  				}
  				/* Move Second Edge */
  				if ( second_edgeMask ) {
! 					SetVideoGraphics( Bit_MaskIndex, second_edgeMask) ; /* GJA */
! 					/* GJA -- handles banking */
  					fix_video_byte_copy_edgeLoop(
  					  s1ptr, d1ptr, byte_offset,
  					  h, y_interval ) ;
! 					SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* GJA */
  				}
  			}
  		}
***************
*** 500,513 ****
  		s1ptr = src ;
  		d1ptr = dst ;
  		if ( first_edgeMask ) {
! 			outb( 0x3CF, first_edgeMask ) ;
! 			for ( d1ptr = dst, s1ptr = src, j = h ;
! 		 	      j-- ;
! 			      d1ptr += y_interval, s1ptr += y_interval )
  				fix_video_byte( s1ptr, d1ptr, byte_offset, alu ) ;
  			if ( center_width < 0 ) /* All In One Byte */
  				continue ; /* Next Plane */
! 			outb( 0x3CF, 0xFF ) ;
  			s1ptr = src + x_interval ;
  			d1ptr = dst + x_interval ;
  		}
--- 544,560 ----
  		s1ptr = src ;
  		d1ptr = dst ;
  		if ( first_edgeMask ) {
! 			/* GJA -- Left edge. Setup banks */
! 			VSETW(d1ptr); VSETR(s1ptr);
! 			SetVideoGraphics( Bit_MaskIndex , first_edgeMask) ; /* GJA */
! 			for ( j = h ; j-- ; ) {
  				fix_video_byte( s1ptr, d1ptr, byte_offset, alu ) ;
+ 				VPUSHR(); ADDW(d1ptr, y_interval); VPOPR();
+ 				ADDR(s1ptr, y_interval);
+ 			}
  			if ( center_width < 0 ) /* All In One Byte */
  				continue ; /* Next Plane */
! 			SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* GJA */
  			s1ptr = src + x_interval ;
  			d1ptr = dst + x_interval ;
  		}
***************
*** 514,534 ****
  		/* Move Center Of Box */
  		for ( i = h ;
  		      i-- ;
! 		      s1ptr += y_interval, d1ptr += y_interval )
! 			for ( j = center_width, s2ptr = s1ptr,
! 			      d2ptr = d1ptr ;
! 			      j-- ;
! 			      s2ptr += x_interval, d2ptr += x_interval ) {
  				register unsigned long int tmp1 ;
  
  				if ( byte_offset ) {
  					tmp1 =
! 				  SCRRIGHT8( *( (VgaMemoryPtr) ( s2ptr ) ), byte_offset )
! 				| SCRLEFT8( *( (VgaMemoryPtr) ( s2ptr - 1 ) ),
  					   ( 8 - byte_offset ) ) ;
  				}
  				else
  					tmp1 = *( (VgaMemoryPtr) s2ptr ) ;
  				switch ( alu ) {
  				case GXnor:
  					tmp1 = ~( tmp1
--- 561,587 ----
  		/* Move Center Of Box */
  		for ( i = h ;
  		      i-- ;
! 		      s1ptr += y_interval, d1ptr += y_interval ) {
! 			/* GJA -- Middle part. Setup banks */
! 			d2ptr = d1ptr; VSETW(d2ptr) ;
! 			s2ptr = s1ptr; VSETR(s2ptr);
! 			for ( j = center_width;
! 			      j-- ; ) {
  				register unsigned long int tmp1 ;
  
  				if ( byte_offset ) {
  					tmp1 =
! 				  SCRRIGHT8( *( (VgaMemoryPtr) s2ptr ), byte_offset ) ;
! 					VDECR(s2ptr);
! 					tmp1 |=
! 				  SCRLEFT8( *( (VgaMemoryPtr) s2ptr ),
  					   ( 8 - byte_offset ) ) ;
+ 					VINCR(s2ptr);
  				}
  				else
  					tmp1 = *( (VgaMemoryPtr) s2ptr ) ;
+ 				ADDR(s2ptr, x_interval);
+ 				VPUSHR();
  				switch ( alu ) {
  				case GXnor:
  					tmp1 = ~( tmp1
***************
*** 568,573 ****
--- 621,629 ----
  					break ;
  				}
  				*( (VgaMemoryPtr) d2ptr ) = tmp1 ;
+ 				ADDW(d2ptr, x_interval);
+ 				VPOPR();
+ 			}
  		}
  		/* Adjust Offsets */
  		j = ( h * y_interval ) - ( center_width * x_interval ) ;
***************
*** 575,586 ****
  		d1ptr -= j ;
  		/* Move Second Edge */
  		if ( second_edgeMask ) {
! 			outb( 0x3CF, second_edgeMask ) ;
  			for ( j = h ;
! 		 	      j-- ;
! 			      d1ptr += y_interval, s1ptr += y_interval )
  				fix_video_byte( s1ptr, d1ptr, byte_offset, alu ) ;
! 			outb( 0x3CF, 0xFF ) ;
  		}
  	}
  }
--- 631,646 ----
  		d1ptr -= j ;
  		/* Move Second Edge */
  		if ( second_edgeMask ) {
! 			/* GJA -- Right edge. Setup banks */
! 			VSETW(d1ptr); VSETR(s1ptr);
! 			SetVideoGraphics( Bit_MaskIndex, second_edgeMask ) ; /* GJA */
  			for ( j = h ;
! 		 	      j-- ; ) {
  				fix_video_byte( s1ptr, d1ptr, byte_offset, alu ) ;
! 				ADDR(s1ptr, y_interval);
! 				VPUSHR(); ADDW(d1ptr, y_interval); VPOPR();
! 			}
! 			SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* GJA */
  		}
  	}
  }
diff -c mit/server/ddx/x386/vga16/ibm/vgaData.c:2.1 mit/server/ddx/x386/vga16/ibm/vgaData.c:removed
*** mit/server/ddx/x386/vga16/ibm/vgaData.c:2.1	Fri Mar 11 23:40:42 1994
--- mit/server/ddx/x386/vga16/ibm/vgaData.c	Fri Mar 11 23:40:41 1994
***************
*** 1,359 ****
- /*
-  * Copyright IBM Corporation 1987,1988,1989
-  *
-  * 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 IBM not be
-  * used in advertising or publicity pertaining to distribution of the
-  * software without specific, written prior permission.
-  *
-  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-  * IBM 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: mit/server/ddx/x386/vga16/ibm/vgaData.c,v 2.1 1993/10/02 16:08:21 dawes Exp $ */
- 
- #include "X.h"
- #include "Xproto.h"
- #include "miscstruct.h"
- #include "scrnintstr.h"
- #include "dixfont.h" /* GJA */
- #include "pixmapstr.h"
- #include "window.h"
- #include "gcstruct.h"
- #include "colormapst.h"
- #include "cursorstr.h"
- 
- #include "mistruct.h"
- #include "mfb.h"
- 
- /* #include "OSio.h" */
- /* #include "OScursor.h" */
- 
- #include "ppc.h"
- #include "ppcProcs.h"
- 
- #include "compiler.h"
- #include "vgaVideo.h"
- 
- #include "vgaProcs.h"
- 
- extern void miRecolorCursor() ;
- extern void NoopDDA() ;
- /* extern void ibmAbort(); */
- 
- static PixmapPtr BogusPixmap = (PixmapPtr) 1 ;
- extern ScreenRec vgaScreenRec ; /* Forward Declaration Here */
- 
- PixmapFormatRec	vgaFormats[] = { { 4, 8, 32 } } ;
- 
- VisualRec vgaVisuals[] = {
- 	{
- 	0,			/* unsigned long	vid */
- 	PseudoColor,		/* short       class */
- 	6,			/* short       bitsPerRGBValue */
- 	1 << VGA_MAXPLANES,	/* short	ColormapEntries */
- 	VGA_MAXPLANES,		/* short	nplanes */
- 	0,			/* unsigned long	redMask */
- 	0,			/* unsigned long	greenMask */
- 	0,			/* unsigned long	blueMask */
- 	0,			/* int		offsetRed */
- 	0,			/* int		offsetGreen */
- 	0			/* int		offsetBlue */
- 	}
- } ;
- 
- #define NUM_VISUALS  (sizeof vgaVisuals/sizeof (VisualRec))
- 
- unsigned long int vgaDepthVIDs[NUM_VISUALS];
- 
- DepthRec vgaDepths[] = {
- /*	depth		numVid	vids */
-     {	1,		0,	NULL	},
-     {	VGA_MAXPLANES,	NUM_VISUALS,	vgaDepthVIDs }
- } ;
- 
- #define vgaGCInterestValidateMask \
- ( GCLineStyle | GCLineWidth | GCJoinStyle | GCBackground | GCForeground	\
- | GCFunction | GCPlaneMask | GCFillStyle | GC_CALL_VALIDATE_BIT		\
- | GCClipXOrigin | GCClipYOrigin | GCClipMask | GCSubwindowMode )
- 
- /* START GJA */
- /* int ibmSaveScreen(); /* declaration -- GJA */
- 
- NeverCalled()
- {
- 	ErrorF("NeverCalled was nevertheless called\n");
- 	abort();
- }
- 
- int Unused;
- /* END GJA */
- 
- ppcPrivGC vgaPrototypeGCPriv = {
- 	GXcopy,	/* unsigned char	rop */
- 	0,	/* unsigned char	ropOpStip */
- 	0,	/* unsigned char	ropFillArea */
- 	TRUE,		/* short	fExpose */
- 	FALSE,		/* short	freeCompClip */
- 	NullPixmap,	/* PixmapPtr	pRotatedPixmap */
- 	0,	/* RegionPtr	pCompositeClip */
- 	ppcAreaFill,	/* void 	(* FillArea)() */
- 		{
- 		    VGA_ALLPLANES,	/* unsigned long	planemask */
- 		    1,			/* unsigned long	fgPixel */
- 		    0,			/* unsigned long	bgPixel */
- 		    GXcopy,		/* int			alu */
- 		    FillSolid,		/* int			fillStyle */
- 		}, /* ppcReducedRrop	colorRrop  */
- 	-1,	/* short lastDrawableType */
- 	-1,	/* short lastDrawableDepth */
- 	(void (*)())NeverCalled, /* GJA -- void (* cacheIGBlt)() */
- 	(void (*)())NeverCalled, /* GJA -- void (* cachePGBlt) () */
- 	0	/* pointer devPriv */
- } ;
- 
- GCFuncs vgaGCFuncs = {
- ppcValidateGC,
- NoopDDA,
- NoopDDA,
- ppcDestroyGC,
- ppcChangeClip,
- ppcDestroyClip,
- ppcCopyClip
- };
- 
- GCOps vgaGCOps = {
- 	ppcSolidWindowFS,	/*  void (* FillSpans)() */
- 	ppcSetSpans,		/*  void (* SetSpans)()	 */
- 	miPutImage,		/*  void (* PutImage)()	 */
- 	ppcCopyArea,		/*  RegionPtr (* CopyArea)()	 */
- 	miCopyPlane,		/*  void (* CopyPlane)() */
- 	ppcPolyPoint,		/*  void (* PolyPoint)() */
- 	ppcScrnZeroLine,	/*  void (* Polylines)() */
- 	ppcScrnZeroSegs,	/*  void (* PolySegment)() */
- 	miPolyRectangle,	/*  void (* PolyRectangle)() */
- 	ppcPolyZeroArc,		/*  void (* PolyArc)()	 */
- 	miFillPolygon,		/*  void (* FillPolygon)() */
- 	miPolyFillRect,		/*  void (* PolyFillRect)() */
- 	miPolyFillArc,		/*  void (* PolyFillArc)() */
- 	miPolyText8,		/*  int (* PolyText8)()	 */
- 	miPolyText16,		/*  int (* PolyText16)() */
- 	miImageText8,		/*  void (* ImageText8)() */
- 	miImageText16,		/*  void (* ImageText16)() */
- 	(void (*)()) miImageGlyphBlt,	/*  GJA -- void (* ImageGlyphBlt)() */
- 	(void (*)()) miPolyGlyphBlt,	/*  GJA -- void (* PolyGlyphBlt)() */
- 	miPushPixels,		/*  void (* PushPixels)() */
- 	miMiter			/*  void (* LineHelper)() */
- };
- 
- GC vgaPrototypeGC = {
- 	&vgaScreenRec,		/*  ScreenPtr	pScreen	 */
- 	VGA_MAXPLANES,		/*  int         depth	 */
- 	GXcopy,			/*  int		alu	 */
- 	0,			/*  int		lineWidth */
- 	0,			/*  int		dashOffset */
- 	0,			/*  int		numInDashList */
- 	0,			/*  unsigned char *dash	 */
- 	LineSolid,		/*  int		lineStyle */
- 	CapButt,		/*  int		capStyle */
- 	JoinMiter,		/*  int		joinStyle */
- 	FillSolid,		/*  int		fillStyle */
- 	EvenOddRule,		/*  int		fillRule */
- 	ArcPieSlice,		/*  int		arcMode	 */
- 	ClipByChildren,		/*  int		subWindowMode */
- 	TRUE,			/*  Bool	graphicsExposures */
- 	CT_NONE,		/*  int		clientClipType */
- 	1,			/*  int		miTranslate:1 */
- 	1,			/*  unsigned int tileIsPixel:1 */
- 	0,			/*  unused:16 */
- 	VGA_ALLPLANES,		/*  unsigned long	planemask */
- 	VGA_BLACK_PIXEL,	/*  unsigned long	fgPixel */
- 	VGA_WHITE_PIXEL,	/*  unsigned long	bgPixel */
- 	{ 0, },                  /*  PixUnion	tile	 */
- 	0,			/*  PixmapPtr	stipple	 */
- 	{ 0, 0 },		/*  DDXPointRec	patOrg	 */
- 	0,			/*  FontPtr	font	 */
- 	{ 0, 0 },		/*  DDXPointRec	clipOrg	 */
- 	{ 0, 0 },		/*  DDXPointRec	lastWinOrg */
- 	NULL,			/*  pointer	clientClip */
- 	(1<<(GCLastBit+1))-1,	/*  unsigned long	stateChanges */
- 	0,			/*  unsigned long        serialNumber */
- 	(GCFuncs *)&vgaGCFuncs,	/*  pointer	funcs */
- 	(GCOps *)&vgaGCOps,	/*  pointer	ops */
- 	(DevUnion *)&vgaPrototypeGCPriv /*  DevUnion *devPrivates */
- } ;
- 
- ppcScrnPriv vgaScrnPriv = {
- 	{
- 		{
- 			DRAWABLE_PIXMAP,/* unsigned char	type */
- 			0,		/* unsigned char	class */
- 			VGA_MAXPLANES,	/* unsigned char         depth */
- 			1,		/* unsigned char	bitsPerPixel */
- 			0,		/* unsigned long        id */
- 			0,		/* short        x */
- 			0,		/* short        y */
- 			640,	        /* short        width */
- 			480,	        /* short        height */
- 			0,		/* ScreenPtr    pScreen */
- 			0,		/* unsigned long        serialNumber */
- 		},		/* DrawableRec drawable */
- 		1,		/* int refcnt */
- 		60,	        /* int devKind */
- 		{ 0 }		/* DevUnion devPrivate */
- 	},			/* PixmapRec	pixmap */
- 	0,			/* void	(* devHardwareInitBB)() */
- 	0,			/* void	(* devHardwareInitAB)() */
- 	&vgaPrototypeGC,	/* GCPtr	devPrototypeGC */
- 	&vgaPrototypeGCPriv,	/* ppcPrivGC 	*devPrototypeGCPriv */
- 	vgaChangeGCtype,	/* Mask		(* changeGCtype)() */
- 	vgaChangeWindowGC,	/* Mask		(* changeWindowGC)() */
- 	0,			/* Colormap	InstalledColormap */
- 	vgaBitBlt,		/* void	(* blit)() */
- 	vgaFillSolid,		/* void	(* solidFill)() */
- 	ppcTileRect,		/* void	(* tileFill)() */
- 	vgaFillStipple,		/* void	(* stipFill)() */
- 	ppcOpaqueStipple,	/* void	(* opstipFill)() */
- 	vgaDrawColorImage,	/* void	(* imageFill)() */
- 	vgaReadColorImage,	/* void	(* imageRead)() */
- 	vgaBresLine,		/* void	(* lineBres)() */
- 	vgaHorzLine,		/* void	(* lineHorz)() */
- 	vgaVertLine,		/* void	(* lineVert)() */
- 	(void (*)())NeverCalled,	/* GJA -- void	(* setColor)() */
- 	(void (*)())NeverCalled,	/* void	(* RecolorCursor)() */
- 	vgaDrawMonoImage,	/* void	(* monoFill)() */
- 	(void (*)())NeverCalled,		/* void	(* glyphFill)() */
- 	(unsigned long *(*)()) NoopDDA, /* unsigned long *((* planeRead)()) */
- 	ppcReplicateArea,	/* void	(* replicateArea)() */
- 	NoopDDA,		/* void	(* DestroyGCPriv)() */
- /* High Level Software Cursor Support !! */
- 	&Unused,	/* int	* CursorSemaphore */
- 	NeverCalled,		/* int	(* CheckCursor)() */
- 	(void (*)())NeverCalled	/* void	(* ReplaceCursor)() */
- /*	,0			/* ppcCacheInfoPtr cacheInfo */
- } ;
- 
- ScreenRec vgaScreenRec = {
- 	0,			/* int			myNum */
- 	0,			/* ATOM id */
- 	640,		        /* short		width */
- 	480,		        /* short		height */
- 	240,                    /* short		mmWidth */
- 	180,	                /* short		mmHeight */
- 	sizeof vgaDepths/sizeof (DepthRec), /* short	numDepths */
- 	VGA_MAXPLANES,		/* short   	    	rootDepth */
- 	vgaDepths,		/* DepthPtr       	allowedDepths */
- 	0,			/* unsigned long      	rootVisual */
- 	0,			/* unsigned long	defColormap */
- 	1,			/* short		minInstalledCmaps */
- 	1,			/* short		maxInstalledCmaps */
- 	Always,			/* char                backingStoreSupport */
- 	NotUseful,		/* char                saveUnderSupport */
- 	VGA_WHITE_PIXEL,	/* unsigned long	whitePixel */
- 	VGA_BLACK_PIXEL,	/* unsigned long	blackPixel */
- 	0,			/* unsigned long	rgf */
- 	{ 0 },			/* GCPtr	GCperDepth[MAXFORMATS+1] */
- 	{ 0 },			/* PixmapPtr		PixmapPerDepth[1] */
- 	(pointer) &vgaScrnPriv,	/* pointer		devPrivate */
- 	sizeof vgaVisuals/sizeof (VisualRec), /* short  numVisuals */
- 	&vgaVisuals[0],		/* VisualPtr		visuals */
- 	0,			/* int			WindowPrivateLength */
- 	0,			/* unsigned 		*WindowPrivateSizes */
- 	0,			/* unsigned 		totalWindowSize */
- 	0,			/* int			GCPrivateLen */
- 	0,			/* unsigned 		*GCPrivateSizes */
- 	0,			/* unsigned 		totalGCSize */
- /* Random screen procedures */
- 	vgaScreenClose,		/* Bool (* CloseScreen)() */
- 	ppcQueryBestSize,	/* void (* QueryBestSize)() */
- 	NeverCalled,		/* GJA -- Bool (* SaveScreen)() */
- 	ppcGetImage,		/* void (* GetImage)() */
- 	ppcGetSpans, /* unsigned int  *(* GetSpans)() */
- 	NoopDDA,		/* void (* PointerNonInterestBox)() */
- 	(void (*)())NULL,	/* void (* SourceValidate)() */
- /* Window Procedures */
- 	ppcCreateWindowForXYhardware,	/* Bool (* CreateWindow)() */
- 	ppcDestroyWindow,	/* Bool (* DestroyWindow)() */
- 	ppcPositionWindow,	/* Bool (* PositionWindow)() */
- 	mfbChangeWindowAttributes,	/* Bool (* ChangeWindowAttributes)() */
- 	mfbMapWindow,		/* Bool (* RealizeWindow)() */
- 	mfbUnmapWindow,		/* Bool (* UnrealizeWindow)() */
- 	miValidateTree,		/* int  (* ValidateTree)() */
-         NoopDDA,                /* void  (* PostValidateTree)() -- GJA */
- 	miWindowExposures,	/* void (* WindowExposures)() */
- 	ppcPaintWindow,		/* void (* PaintWindowBackground)() */
- 	ppcPaintWindow,		/* void (* PaintWindowBorder)() */
- 	ppcCopyWindow,		/* void (* CopyWindow)() */
- 	miClearToBackground,	/* void (* ClearToBackground)() */
-         NoopDDA,                /* void (* ClipNotify)() -- GJA */
- /* Pixmap procedures */
- 	ppcCreatePixmap,	/* PixmapPtr (* CreatePixmap)() */
- 	mfbDestroyPixmap,	/* Bool (* DestroyPixmap)() */
- /* Backing store procedures */
- 	NoopDDA,		/* void (* SaveDoomedAreas)() */
- 	(RegionPtr(*)())ppcRestoreAreas,	 /* RegionPtr (* RestoreAreas)() */
- 	NoopDDA,		/* void	 (* ExposeCopy)() */
- 	(RegionPtr(*)())NoopDDA,		/* RegionPtr (* TranslateBackingStore)() */
- 	(RegionPtr(*)())NoopDDA,		/* RegionPtr (* ClearBackingStore)() */
- 	NoopDDA,		/* void (* DrawGuarantee)() */
- /* Font procedures */
- 	mfbRealizeFont,		/* Bool (* RealizeFont)() */
- 	mfbUnrealizeFont,	/* Bool (* UnrealizeFont)() */
- /* Cursor Procedures */
- 	(void (*)())NeverCalled,	/* void (* ConstrainCursor)() */
- 	(void (*)())NeverCalled,	/* void (* CursorLimits)() */
- 	(Bool (*)())NeverCalled,	/* Bool (* DisplayCursor)() */
- 	(Bool (*)())NeverCalled,	/* Bool (* RealizeCursor)() */
- 	(Bool (*)())NeverCalled,	/* Bool (* UnrealizeCursor)() */
- 	(void (*)())NeverCalled,	/* void (* RecolorCursor)() */
- 	(Bool (*)())NeverCalled,	/* Bool (* SetCursorPosition)() */
- /* GC procedures */
- 	ppcCreateGC,		/* Bool (* CreateGC)() */
- /* Colormap procedures */
- 	(Bool (*)())NoopDDA,		/* GJA(?) -- Bool (* CreateColormap)() */
- 	(void (*)())NoopDDA,		/* void (* DestroyColormap)() */
- 	(void (*)())NeverCalled,	/* GJA -- void (* InstallColormap)() */
- 	(void (*)())NeverCalled,	/* GJA -- void (* UninstallColormap)() */
- 	(int (*)())NeverCalled,	/* GJA -- int (* ListInstalledColormaps) () */
- 	(void (*)())NeverCalled,		/* GJA -- void (* StoreColors)() */
- 	ppcResolveColor,	/* GJA -- void (* ResolveColor)() */
- /* Region procedures */
- 	miRegionCreate,		/* RegionPtr (* RegionCreate)() */
- 	miRegionInit,		/* void (* RegionInit)() */
- 	miRegionCopy,		/* Bool (* RegionCopy)() */
- 	miRegionDestroy,	/* void (* RegionDestroy)() */
- 	miRegionUninit,		/* void (* RegionUninit)() */
- 	miIntersect,		/* int (* Intersect)() */
- 	miUnion,		/* int (* Union)() */
- 	miSubtract,		/* int (* Subtract)() */
- 	miInverse,		/* int (* Inverse)() */
- 	miRegionReset,		/* void (* RegionReset)() */
- 	miTranslateRegion,	/* void (* TranslateRegion)() */
- 	miRectIn,		/* int (* RectIn)() */
- 	miPointInRegion,	/* Bool (* PointInRegion)() */
- 	miRegionNotEmpty,	/* Bool (* RegionNotEmpty)() */
- 	miRegionEmpty,		/* void (* RegionEmpty)() */
- 	miRegionExtents,	/* BoxPtr (*RegionExtents)() */
- 	miRegionAppend,		/* Bool (*RegionAppend)() */
- 	miRegionValidate,	/* Bool (*RegionValidate)() */
- 	mfbPixmapToRegion,	/* RegionPtr (*BitmapToRegion)() */
- 	miRectsToRegion,	/* RegionPtr (*RectsToRegion)() */
- 	miSendGraphicsExpose,	/* void	(*SendGraphicsExpose)() */
- /* os layer procedures */
- 	NoopDDA,		/* GJA -- void (* BlockHandler)() */
- 	NoopDDA,		/* GJA -- void (* WakeupHandler)() */
- 	(pointer) 0,		/* pointer blockData */
- 	(pointer) 0,		/* pointer wakeupData */
- 	0			/* DevUnion *devPrivates */
- } ;
--- 0 ----
diff -c mit/server/ddx/x386/vga16/ibm/vgaGC.c:2.1 mit/server/ddx/x386/vga16/ibm/vgaGC.c:2.2
*** mit/server/ddx/x386/vga16/ibm/vgaGC.c:2.1	Fri Mar 11 23:40:42 1994
--- mit/server/ddx/x386/vga16/ibm/vgaGC.c	Fri Mar 11 23:40:42 1994
***************
*** 66,72 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaGC.c,v 2.1 1993/10/15 15:40:04 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaGC.c,v 6.7 89/04/29 21:47:41 jeff Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaGC.c,v */
  
--- 66,72 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaGC.c,v 2.2 1994/02/25 15:02:51 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaGC.c,v 6.7 89/04/29 21:47:41 jeff Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaGC.c,v */
  
***************
*** 94,99 ****
--- 94,101 ----
  #include "vgaProcs.h"
  extern int mfbGCPrivateIndex;
  
+ void v16ZeroPolyArc(), v16PolyFillArc(); /* GJA */
+ 
  Mask
  vgaChangeGCtype( pGC, devPriv )
  register GC *pGC ;
***************
*** 113,120 ****
  	    pGC->ops->CopyArea	= ppcCopyArea ;
  	    pGC->ops->PolyFillRect	= ppcPolyFillRect ;
  	    pGC->ops->PushPixels	= miPushPixels ; /* GJA */
! 	    pGC->ops->PolyArc	= ppcPolyZeroArc ;
! 	    pGC->ops->PolyFillArc	= ppcPolyFillArc ;
  	    pGC->ops->PolySegment	= ppcScrnZeroSegs ;
  	}
  	return;
--- 115,122 ----
  	    pGC->ops->CopyArea	= ppcCopyArea ;
  	    pGC->ops->PolyFillRect	= ppcPolyFillRect ;
  	    pGC->ops->PushPixels	= miPushPixels ; /* GJA */
! 	    pGC->ops->PolyArc	= v16ZeroPolyArc ;
! 	    pGC->ops->PolyFillArc	= v16PolyFillArc ;
  	    pGC->ops->PolySegment	= ppcScrnZeroSegs ;
  	}
  	return;
***************
*** 136,142 ****
  	  case GCLineStyle:
  	  case GCLineWidth:
  	    pGC->ops->PolyArc = ( ( pGC->lineStyle == LineSolid )
! 		? ( ( pGC->lineWidth == 0 ) ? ppcPolyZeroArc
  					    : miPolyArc )
  		: miPolyArc ) ;
  	    pGC->ops->PolySegment = ( ( pGC->lineStyle == LineSolid )
--- 138,144 ----
  	  case GCLineStyle:
  	  case GCLineWidth:
  	    pGC->ops->PolyArc = ( ( pGC->lineStyle == LineSolid )
! 		? ( ( pGC->lineWidth == 0 ) ? v16ZeroPolyArc
  					    : miPolyArc )
  		: miPolyArc ) ;
  	    pGC->ops->PolySegment = ( ( pGC->lineStyle == LineSolid )
diff -c mit/server/ddx/x386/vga16/ibm/vgaIO.c:2.0 mit/server/ddx/x386/vga16/ibm/vgaIO.c:removed
*** mit/server/ddx/x386/vga16/ibm/vgaIO.c:2.0	Fri Mar 11 23:40:43 1994
--- mit/server/ddx/x386/vga16/ibm/vgaIO.c	Fri Mar 11 23:40:42 1994
***************
*** 1,88 ****
- /*
-  * Copyright IBM Corporation 1987,1988,1989
-  *
-  * 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 IBM not be
-  * used in advertising or publicity pertaining to distribution of the
-  * software without specific, written prior permission.
-  *
-  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-  * IBM 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: mit/server/ddx/x386/vga16/ibm/vgaIO.c,v 2.0 1993/08/19 16:09:20 dawes Exp $ */
- 
- #include "X.h"
- #include "resource.h"
- #include "scrnintstr.h"
- #include "servermd.h"	/* GJA */
- #include "mi.h" /* GJA */
- 
- #include "OScompiler.h"
- 
- #include "vgaVideo.h"
- 
- #include "ibmTrace.h"
- 
- /* Global Variables */
- extern int vgaDisplayTubeType ;
- extern ScreenRec vgaScreenRec ;
- extern VisualRec vgaVisuals[] ;
- 
- static int HardwareReady = 0 ;
- 
- Bool
- vga16ScreenInit( pScreen )
- register ScreenPtr const pScreen ;
- {
- 	static int been_here = 0 ;
- 
- 	TRACE( ( "vgaScreenInit(index=%d,pScreen=0x%x,argc=%d,argv=0x%x)\n",
- 		index, pScreen, argc, argv ) ) ;
- 
- 	if ( !been_here ) {
- /*		vgaInitFontCache() ;	MAYBE SOMEDAY */
- 		been_here = TRUE ;
- 	}
- 
- 	vgaVisuals[0].class = ( vgaDisplayTubeType == COLOR_TUBE )
- 			    ? PseudoColor : GrayScale ;
- 	ppc16CommonScreenInit( pScreen, &vgaScreenRec ) ;
- 
- 	return HardwareReady ;
- }
- 
- /*ARGSUSED*/
- Bool
- vgaScreenClose( index, pScreen )
- register const int index ;
- register ScreenPtr const pScreen ;
- {
- TRACE( ( "vgaScreenClose(index=%d,pScreen=0x%x)\n", index, pScreen ) ) ;
- ppcCommonScreenClose( pScreen, index, &vgaScreenRec ) ;
- return 1 ;
- }
- 
- void
- Init16Output( pScreen, virtx, virty )
-     ScreenPtr pScreen;
-     int virtx, virty;
- {
-     extern vga16ScreenInit();
- 
-     vga16Probe(virtx,virty); /* For side effects. GJA */
-     vga16ScreenInit(pScreen);
- 
-     mfbRegisterCopyPlaneProc(pScreen,miCopyPlane); /* GJA -- R4->R5 */
- }
--- 0 ----
diff -c mit/server/ddx/x386/vga16/ibm/vgaImages.c:2.1 mit/server/ddx/x386/vga16/ibm/vgaImages.c:2.3
*** mit/server/ddx/x386/vga16/ibm/vgaImages.c:2.1	Fri Mar 11 23:40:43 1994
--- mit/server/ddx/x386/vga16/ibm/vgaImages.c	Fri Mar 11 23:40:43 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaImages.c,v 2.1 1993/08/28 07:54:20 dawes Exp $ */
  
  #include "X.h"
  
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaImages.c,v 2.3 1994/03/08 04:51:11 dawes Exp $ */
  
  #include "X.h"
  
***************
*** 119,146 ****
  	/* Set Raster Op */
  	SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  	SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_2 ) ;
- 	SetVideoGraphicsIndex( Bit_MaskIndex ) ;
  }
  
  StartByte = (volatile unsigned char *)
! 	( VGABASE + ( y * BYTES_PER_ROW ) + ROW_OFFSET( x ) ) ;
  InitialMask = SCRRIGHT8( LeftmostBit, BIT_OFFSET( x ) ) ;
  if ( invert_source_data )
  	for ( ;
  	      h-- ;
! 	      data += RowIncrement, StartByte += BYTES_PER_ROW ) {
! 		for ( dst = StartByte, src = data,
  		      Pixel_Count = w, currMask = InitialMask ;
  		      Pixel_Count-- ;
  		      src++ ) {
  			/* Set The Bit Mask Reg */
! 			SetVideoGraphicsData( currMask ) ;
  			/* Read To Load vga Data Latches */
  			tmp = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = ~ *src ;
  			if ( currMask & RightmostBit ) {
  				currMask = LeftmostBit ;
! 				dst++ ;
  			}
  			else
  				currMask = SCRRIGHT8( currMask, 1 ) ;
--- 119,146 ----
  	/* Set Raster Op */
  	SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  	SetVideoGraphics( Graphics_ModeIndex, VGA_WRITE_MODE_2 ) ;
  }
  
  StartByte = (volatile unsigned char *)
! 	( VIDBASE + ( y * BYTES_PER_LINE ) + ROW_OFFSET( x ) ) ;
  InitialMask = SCRRIGHT8( LeftmostBit, BIT_OFFSET( x ) ) ;
  if ( invert_source_data )
  	for ( ;
  	      h-- ;
! 	      data += RowIncrement, StartByte += BYTES_PER_LINE ) {
! 		dst = StartByte; VSETRW(dst);
! 		for ( src = data,
  		      Pixel_Count = w, currMask = InitialMask ;
  		      Pixel_Count-- ;
  		      src++ ) {
  			/* Set The Bit Mask Reg */
! 			SetVideoGraphics( Bit_MaskIndex, currMask ) ;
  			/* Read To Load vga Data Latches */
  			tmp = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = ~ *src ;
  			if ( currMask & RightmostBit ) {
  				currMask = LeftmostBit ;
! 				VINCRW(dst) ;
  			}
  			else
  				currMask = SCRRIGHT8( currMask, 1 ) ;
***************
*** 149,167 ****
  else /* invert_source_data == FALSE */
  	for ( ;
  	      h-- ;
! 	      data += RowIncrement, StartByte += BYTES_PER_ROW ) {
! 		for ( dst = StartByte, src = data,
  		      Pixel_Count = w, currMask = InitialMask ;
  		      Pixel_Count-- ;
  		      src++ ) {
  			/* Set The Bit Mask Reg */
! 			SetVideoGraphicsData( currMask ) ;
  			/* Read To Load vga Data Latches */
  			tmp = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = *src ;
  			if ( currMask & RightmostBit ) {
  				currMask = LeftmostBit ;
! 				dst++ ;
  			}
  			else
  				currMask = SCRRIGHT8( currMask, 1 ) ;
--- 149,168 ----
  else /* invert_source_data == FALSE */
  	for ( ;
  	      h-- ;
! 	      data += RowIncrement, StartByte += BYTES_PER_LINE ) {
! 		dst = StartByte; VSETRW(dst);
! 		for ( src = data,
  		      Pixel_Count = w, currMask = InitialMask ;
  		      Pixel_Count-- ;
  		      src++ ) {
  			/* Set The Bit Mask Reg */
! 			SetVideoGraphics( Bit_MaskIndex, currMask ) ; /* GJA */
  			/* Read To Load vga Data Latches */
  			tmp = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = *src ;
  			if ( currMask & RightmostBit ) {
  				currMask = LeftmostBit ;
! 				VINCRW(dst) ;
  			}
  			else
  				currMask = SCRRIGHT8( currMask, 1 ) ;
***************
*** 288,310 ****
  
  #define SINGLE_STEP 	*data++ = tmp & VGA_ALLPLANES ; tmp >>= 4
  
! if ( center_width < 0 )
! 	for ( src = masterSrc ;
! 	      ly-- ;
! 	      src += BYTES_PER_ROW ) {
  		tmp = read8Z( src ) >> ( skip << 2 ) ;
  		for ( dx = lx + 1 ; --dx ; ) {
  			SINGLE_STEP ;
  		}
  		data += pad ;
  	}
! else
  	for ( savCenterWidth = center_width ;
  	      ly-- ;
  	      center_width = savCenterWidth,
! 	      masterSrc += BYTES_PER_ROW ) {
! 		src = masterSrc ;
! 		tmp = read8Z( src++ ) ;
  		if ( dx = skip )
  			tmp >>= ( dx << 2 ) ;
  		else
--- 289,312 ----
  
  #define SINGLE_STEP 	*data++ = tmp & VGA_ALLPLANES ; tmp >>= 4
  
! 
! if ( center_width < 0 ) {
! 	src = masterSrc; VSETRW(src) ;
! 	for ( ; ly-- ; ) {
  		tmp = read8Z( src ) >> ( skip << 2 ) ;
  		for ( dx = lx + 1 ; --dx ; ) {
  			SINGLE_STEP ;
  		}
  		data += pad ;
+ 		src += BYTES_PER_LINE; VCHECKRWO(src) ;
  	}
! } else
  	for ( savCenterWidth = center_width ;
  	      ly-- ;
  	      center_width = savCenterWidth,
! 	      masterSrc += BYTES_PER_LINE ) {
! 		src = masterSrc ; VSETRW(src);
! 		tmp = read8Z( src ) ; VINCRW(src);
  		if ( dx = skip )
  			tmp >>= ( dx << 2 ) ;
  		else
***************
*** 327,339 ****
  
  			/* Fall Through To End Of Inner Loop */
  			if ( center_width > 0 ) {
! 				tmp = read8Z( src++ ) ;
  				center_width-- ;
  				goto LoopTop ;
  			}
  			else if ( ( center_width == 0 )
  			       && ( dx = ( - ignore ) & 07 ) ) {
! 				tmp = read8Z( src++ ) ;
  				center_width-- ;
  				goto BranchPoint ; /* Do Mod 8 edge */
  			}
--- 329,341 ----
  
  			/* Fall Through To End Of Inner Loop */
  			if ( center_width > 0 ) {
! 				tmp = read8Z( src ) ; VINCRW(src);
  				center_width-- ;
  				goto LoopTop ;
  			}
  			else if ( ( center_width == 0 )
  			       && ( dx = ( - ignore ) & 07 ) ) {
! 				tmp = read8Z( src ) ; VINCRW(src);
  				center_width-- ;
  				goto BranchPoint ; /* Do Mod 8 edge */
  			}
diff -c mit/server/ddx/x386/vga16/ibm/vgaLine.c:2.0 mit/server/ddx/x386/vga16/ibm/vgaLine.c:2.2
*** mit/server/ddx/x386/vga16/ibm/vgaLine.c:2.0	Fri Mar 11 23:40:43 1994
--- mit/server/ddx/x386/vga16/ibm/vgaLine.c	Fri Mar 11 23:40:44 1994
***************
*** 43,49 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaLine.c,v 2.0 1993/08/19 16:09:22 dawes Exp $ */
  
  /*
   *  Hardware interface routines for IBM VGA adapter for
--- 43,49 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaLine.c,v 2.2 1994/03/08 04:51:12 dawes Exp $ */
  
  /*
   *  Hardware interface routines for IBM VGA adapter for
***************
*** 134,139 ****
--- 134,141 ----
  register unsigned char single_bit ;
  #endif
  
+ VSETRW(addr);
+ 
  #define SINGLE_STEP \
  if ( et < 0 ) { \
  	mask |= single_bit ; \
***************
*** 144,150 ****
  	et += e2 ; \
  	*( (VgaMemoryPtr) addr ) = mask ; \
  	mask = single_bit ; \
! 	addr += y_increment ; \
  }
  
  /* Set-Up And Set Initial Mask Value */
--- 146,152 ----
  	et += e2 ; \
  	*( (VgaMemoryPtr) addr ) = mask ; \
  	mask = single_bit ; \
! 	ADDRW(addr,y_increment) ; \
  }
  
  /* Set-Up And Set Initial Mask Value */
***************
*** 153,159 ****
  if ( !( single_bit = SCRRIGHT8( single_bit, 1 ) ) ) {
  	tmp = *( (VgaMemoryPtr) addr ) ;
  	single_bit = LeftmostBit ;
! 	*( (VgaMemoryPtr) addr++ ) = mask ;
  	tmp = mask = 0 ;
  }
  if ( ( 8 - tmp ) > --len ) {
--- 155,161 ----
  if ( !( single_bit = SCRRIGHT8( single_bit, 1 ) ) ) {
  	tmp = *( (VgaMemoryPtr) addr ) ;
  	single_bit = LeftmostBit ;
! 	*( (VgaMemoryPtr) addr ) = mask ; VINCRW(addr) ;
  	tmp = mask = 0 ;
  }
  if ( ( 8 - tmp ) > --len ) {
***************
*** 185,191 ****
  	*( (VgaMemoryPtr) addr ) = mask ;
  	if ( len > 7 ) {
  		mask = 0 ;
! 		addr++ ;
  		single_bit = LeftmostBit ;
  		goto Loop_Top ;
  	}
--- 187,193 ----
  	*( (VgaMemoryPtr) addr ) = mask ;
  	if ( len > 7 ) {
  		mask = 0 ;
! 		VINCRW(addr) ;
  		single_bit = LeftmostBit ;
  		goto Loop_Top ;
  	}
***************
*** 192,198 ****
  	else if ( len ) {
  		tmp = len ;
  		mask = 0 ;
! 		addr++ ;
  		len = 8 ;
  		single_bit = LeftmostBit ;
  		goto branchPoint ;
--- 194,200 ----
  	else if ( len ) {
  		tmp = len ;
  		mask = 0 ;
! 		VINCRW(addr) ;
  		len = 8 ;
  		single_bit = LeftmostBit ;
  		goto branchPoint ;
***************
*** 224,229 ****
--- 226,233 ----
  register unsigned char single_bit ;
  #endif
  
+ VSETRW(addr);
+ 
  #define SINGLE_STEP \
  if ( et < 0 ) { \
  	mask |= single_bit ; \
***************
*** 234,240 ****
  	et += e2 ; \
  	*( (VgaMemoryPtr) addr ) = mask ; \
  	mask = single_bit ; \
! 	addr += y_increment ; \
  }
  
  /* Set-Up And Set Initial Mask Value */
--- 238,244 ----
  	et += e2 ; \
  	*( (VgaMemoryPtr) addr ) = mask ; \
  	mask = single_bit ; \
! 	ADDRW(addr, y_increment) ; \
  }
  
  /* Set-Up And Set Initial Mask Value */
***************
*** 243,249 ****
  if ( ( single_bit = SCRLEFT8( single_bit, 1 ) ) == SCRLEFT8( RightmostBit, 8 ) ) {
  	tmp = *( (VgaMemoryPtr) addr ) ;
  	single_bit = RightmostBit ;
! 	*( (VgaMemoryPtr) addr-- ) = mask ;
  	tmp = mask = 0 ;
  }
  if ( ( 8 - tmp ) > --len ) {
--- 247,253 ----
  if ( ( single_bit = SCRLEFT8( single_bit, 1 ) ) == SCRLEFT8( RightmostBit, 8 ) ) {
  	tmp = *( (VgaMemoryPtr) addr ) ;
  	single_bit = RightmostBit ;
! 	*( (VgaMemoryPtr) addr ) = mask ; VDECRW(addr) ;
  	tmp = mask = 0 ;
  }
  if ( ( 8 - tmp ) > --len ) {
***************
*** 275,281 ****
  	*( (VgaMemoryPtr) addr ) = mask ;
  	if ( len > 7 ) {
  		mask = 0 ;
! 		addr-- ;
  		single_bit = RightmostBit ;
  		goto Loop_Top ;
  	}
--- 279,285 ----
  	*( (VgaMemoryPtr) addr ) = mask ;
  	if ( len > 7 ) {
  		mask = 0 ;
! 		VDECRW(addr) ;
  		single_bit = RightmostBit ;
  		goto Loop_Top ;
  	}
***************
*** 282,288 ****
  	else if ( len ) {
  		tmp = len ;
  		mask = 0 ;
! 		addr-- ;
  		len = 8 ;
  		single_bit = RightmostBit ;
  		goto branchPoint ;
--- 286,292 ----
  	else if ( len ) {
  		tmp = len ;
  		mask = 0 ;
! 		VDECRW(addr) ;
  		len = 8 ;
  		single_bit = RightmostBit ;
  		goto branchPoint ;
***************
*** 312,319 ****
  register unsigned char single_bit ;
  #endif
  
  #define SINGLE_STEP \
! addr += y_increment ; \
  if ( et < 0 ) { \
  	tmp = *( (VgaMemoryPtr) addr ) ; \
  	et += e1 ; \
--- 316,325 ----
  register unsigned char single_bit ;
  #endif
  
+ VSETRW(addr);
+ 
  #define SINGLE_STEP \
! ADDRW(addr, y_increment) ; \
  if ( et < 0 ) { \
  	tmp = *( (VgaMemoryPtr) addr ) ; \
  	et += e1 ; \
***************
*** 324,330 ****
  		tmp = *( (VgaMemoryPtr) addr ) ; \
  	} \
  	else { \
! 		tmp = *( (VgaMemoryPtr) ( ++addr ) ) ; \
  		single_bit = LeftmostBit ; \
  	} \
  } \
--- 330,336 ----
  		tmp = *( (VgaMemoryPtr) addr ) ; \
  	} \
  	else { \
! 		VINCRW(addr); tmp = *( (VgaMemoryPtr) ( addr ) ) ;\
  		single_bit = LeftmostBit ; \
  	} \
  } \
***************
*** 398,405 ****
  register unsigned char tmp ;
  #endif /* ATRIO */
  
  #define SINGLE_STEP \
! addr += y_increment ; \
  if ( et < 0 ) { \
  	tmp = *( (VgaMemoryPtr) addr ) ; \
  	et += e1 ; \
--- 404,413 ----
  register unsigned char tmp ;
  #endif /* ATRIO */
  
+ VSETRW(addr);
+ 
  #define SINGLE_STEP \
! ADDRW(addr, y_increment) ; \
  if ( et < 0 ) { \
  	tmp = *( (VgaMemoryPtr) addr ) ; \
  	et += e1 ; \
***************
*** 410,416 ****
  		tmp = *( (VgaMemoryPtr) addr ) ; \
  	} \
  	else { \
! 		tmp = *( (VgaMemoryPtr) ( --addr ) ) ; \
  		single_bit = RightmostBit ; \
  	} \
  } \
--- 418,424 ----
  		tmp = *( (VgaMemoryPtr) addr ) ; \
  	} \
  	else { \
! 		VDECRW(addr); tmp = *( (VgaMemoryPtr) ( addr ) ) ; \
  		single_bit = RightmostBit ; \
  	} \
  } \
***************
*** 571,577 ****
  (* ( ( signdx > 0 ) ? ( axis ? fast_y_line_right : fast_x_line_right )
  		    : ( axis ? fast_y_line_left  : fast_x_line_left ) ) )
  			( et, e1, e2, len,
! 			  ( signdy > 0 ? BYTES_PER_ROW : - BYTES_PER_ROW ),
  			  SCREENADDRESS( x, y ), BIT_OFFSET( x ) ) ;
  
  /* ********** */
--- 579,585 ----
  (* ( ( signdx > 0 ) ? ( axis ? fast_y_line_right : fast_x_line_right )
  		    : ( axis ? fast_y_line_left  : fast_x_line_left ) ) )
  			( et, e1, e2, len,
! 			  ( signdy > 0 ? BYTES_PER_LINE : - BYTES_PER_LINE ),
  			  SCREENADDRESS( x, y ), BIT_OFFSET( x ) ) ;
  
  /* ********** */
diff -c mit/server/ddx/x386/vga16/ibm/vgaOSD.c:2.2 mit/server/ddx/x386/vga16/ibm/vgaOSD.c:removed
*** mit/server/ddx/x386/vga16/ibm/vgaOSD.c:2.2	Fri Mar 11 23:40:44 1994
--- mit/server/ddx/x386/vga16/ibm/vgaOSD.c	Fri Mar 11 23:40:44 1994
***************
*** 1,68 ****
- /***********************************************************
- 		Copyright IBM Corporation 1987,1988
- 
-                       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 IBM not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.  
- 
- IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- IBM 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: mit/server/ddx/x386/vga16/ibm/vgaOSD.c,v 2.2 1993/08/28 07:54:22 dawes Exp $ */
- 
- #include <sys/types.h> /* GJA -- moved this here */
- 
- #include "X.h"
- #include "miscstruct.h"
- #include "scrnintstr.h"
- #include "cursorstr.h"
- #include "pixmapstr.h"
- #include "OScompiler.h"
- 
- #include "vgaVideo.h"
- #include "vgaSave.h"
- #include "ppc.h"
- 
- /* Global Variables */
- int BYTES_PER_ROW, MAX_ROW, MAX_COLUMN, MAX_OFFSCREEN_ROW;
- int vgaDisplayTubeType = 0 ;
- 
- int
- vga16Probe(virtx,virty)
- int virtx, virty;
- {
-   extern ppcScrnPriv vgaScrnPriv;
-   extern ScreenRec vgaScreenRec;
-   int i;
- 
-   /*
-    * patch the original structures
-    */
-   BYTES_PER_ROW = virtx / 8;
-   MAX_ROW       = virty - 1;
-   MAX_COLUMN    = virtx - 1;
- 
-   vgaScrnPriv.pixmap.drawable.width = MAX_COLUMN + 1;
-   vgaScrnPriv.pixmap.drawable.height = MAX_ROW + 1;
-   vgaScrnPriv.pixmap.devKind = (MAX_ROW + 1) / 8;
-   vgaScreenRec.width = MAX_COLUMN + 1;
-   vgaScreenRec.height = MAX_ROW + 1;
- 
-   vgaDisplayTubeType = COLOR_TUBE;
- 
-   return 0;
- }
- 
--- 0 ----
diff -c mit/server/ddx/x386/vga16/ibm/vgaSave.h:2.0 mit/server/ddx/x386/vga16/ibm/vgaSave.h:removed
*** mit/server/ddx/x386/vga16/ibm/vgaSave.h:2.0	Fri Mar 11 23:40:44 1994
--- mit/server/ddx/x386/vga16/ibm/vgaSave.h	Fri Mar 11 23:40:44 1994
***************
*** 1,137 ****
- /*
-  * Copyright IBM Corporation 1987,1988,1989
-  *
-  * 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 IBM not be
-  * used in advertising or publicity pertaining to distribution of the
-  * software without specific, written prior permission.
-  *
-  * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
-  * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
-  * IBM 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.
-  *
- */
- /***********************************************************
- 		Copyright IBM Corporation 1987,1988
- 
-                       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 IBM not be
- used in advertising or publicity pertaining to distribution of the
- software without specific, written prior permission.  
- 
- IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- IBM 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: mit/server/ddx/x386/vga16/ibm/vgaSave.h,v 2.0 1993/08/19 16:09:27 dawes Exp $ */
- /* Header: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/vga/RCS/vgaSave.h,v 6.2 88/11/24 00:35:06 paul Exp */
- /* Source: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/vga/RCS/vgaSave.h,v */
- 
- typedef unsigned char io86reg ;		/* 8 bit hardware registers */
- typedef short int IO_Address ;		/* 64K Intel-Style I/O space */
- 
- typedef unsigned char DAC_TABLE[768] ;
- 
- struct vga_video_hardware_state {
- 	/* Address locations			READ	--	WRITE */
- 	/* General Registers */
- 	io86reg Misc_Output_Reg ;	/*	03CC	--	03C2 */
- 	io86reg Input_Status_0 ;	/*	03C2	--	XXXX */
- 	io86reg Input_Status_1 ;	/*	03?A	--	XXXX */
- 	io86reg Feature_Control ;	/*	03?C	--	03CA */
- 	io86reg Video_Enable ;		/*	03C3	--	SAME */
- 
- 	/* Attribute Registers  03C0 & 03C1 */
- 	io86reg Attr_Addr_Reg ;		/*	03C0	--	SAME */
- 	/* io86reg ??????? */		/*	03C0	--	SAME */
- 	io86reg Palette[16] ;		/*	Attr_Addr_Reg == 00 - 0F */
- 	io86reg Attr_Mode ;		/*	Attr_Addr_Reg == 10 */
- 	io86reg Overscan_Color ;	/*	Attr_Addr_Reg == 11 */
- 	io86reg Color_Plane_En ;	/*	Attr_Addr_Reg == 12 */
- 	io86reg Horiz_PEL_Pan ;		/*	Attr_Addr_Reg == 13 */
- 	io86reg Color_Select ;		/*	Attr_Addr_Reg == 14 */
- 
- 	/* Crt Controller Registers  03?4 & 03?5 */
- 	io86reg Index_Reg ;		/*	03?4	--	SAME */
- 	/* io86reg ??????? */		/*	03?5	--	SAME */
- 	io86reg Horiz_Total ;		/*	Index_Reg == 00   */
- 	io86reg Horiz_End ;		/*	Index_Reg == 01   */
- 	io86reg H_Blank_Start ;		/*	Index_Reg == 02   */
- 	io86reg H_Blank_End ;		/*	Index_Reg == 03   */
- 	io86reg H_Retrace_Start ;	/*	Index_Reg == 04   */
- 	io86reg H_Retrace_End ;		/*	Index_Reg == 05   */
- 	io86reg Vert_Total ;		/*	Index_Reg == 06   */
- 	io86reg Overflow ;		/*	Index_Reg == 07   */
- 	io86reg Preset_Row_Scan ;	/*	Index_Reg == 08   */
- 	io86reg Max_Scan_Line ;		/*	Index_Reg == 09   */
- 	io86reg Cursor_Start ;		/*	Index_Reg == 0A   */
- 	io86reg Cursor_End ;		/*	Index_Reg == 0B   */
- 	io86reg Start_Addr_Hi ;		/*	Index_Reg == 0C   */
- 	io86reg Start_Addr_Lo ;		/*	Index_Reg == 0D   */
- 	io86reg Cursor_Loc_Hi ;		/*	Index_Reg == 0E   */
- 	io86reg Cursor_Loc_Lo ;		/*	Index_Reg == 0F   */
- 	io86reg V_Retrace_Start ;	/*	Index_Reg == 10   */
- 	io86reg V_Retrace_End ;		/*	Index_Reg == 11   */
- 	io86reg V_Display_End ;		/*	Index_Reg == 12   */
- 	io86reg Underline_Loc ;		/*	Index_Reg == 13   */
- 	io86reg Offset ;		/*	Index_Reg == 14   */
- 	io86reg V_Blank_Start ;		/*	Index_Reg == 15   */
- 	io86reg V_Blank_End ;		/*	Index_Reg == 16   */
- 	io86reg CRTC_Mode ;		/*	Index_Reg == 17   */
- 	io86reg Line_Compare ;		/*	Index_Reg == 18   */
- 
- 	/* Sequencer Registers  03C4 & 03C5 */
- 	io86reg Seq_Addr_Reg ;		/*	03C4	--	SAME */
- 	/* io86reg ??????? */		/*	03?5	--	SAME */
- 	io86reg Seq_Reset ;		/*	Seq_Addr_Reg == 00   */
- 	io86reg Clock_Mode ;		/*	Seq_Addr_Reg == 01   */
- 	io86reg Mask_Map ;		/*	Seq_Addr_Reg == 02   */
- 	io86reg Char_Map_Select ;	/*	Seq_Addr_Reg == 03   */
- 	io86reg Memory_Mode ;		/*	Seq_Addr_Reg == 04   */
- 
- 	/* Graphics Registers  03CE & 03CF */
- 	io86reg Graphics_Addr ;		/*	03CE	--	SAME */
- 	/* io86reg ??????? */		/*	03CF	--	SAME */
- 	io86reg Set_Reset ;		/*	Graphics_Addr == 00   */
- 	io86reg Enb_Set_Reset ;		/*	Graphics_Addr == 01   */
- 	io86reg Color_Compare ;		/*	Graphics_Addr == 02   */
- 	io86reg Data_Rotate ;		/*	Graphics_Addr == 03   */
- 	io86reg Read_Map_Select ;	/*	Graphics_Addr == 04   */
- 	io86reg Graphics_Mode ;		/*	Graphics_Addr == 05   */
- 	io86reg Miscellaneous ;		/*	Graphics_Addr == 06   */
- 	io86reg Color_Dont_Care ;	/*	Graphics_Addr == 07   */
- 	io86reg Bit_Mask ;		/*	Graphics_Addr == 08   */
- 
- 	/* Video DAC Registers  03CE & 03CF */
- 	io86reg PEL_WR_Addr ;		/*	03C8	--	SAME */
- 	io86reg PEL_RD_Addr ;		/*	XXXX	--	03C7 */
- 	io86reg DAC_State ;		/*	XXXX	--	03C7 */
- 	io86reg PEL_Data_Reg ;		/*	03C9	--	SAME */
- 	io86reg PEL_Mask_Reg ;		/*	03C6	--	SAME */
- } ;
- 
- /* Global Flag for Virtual Screen Saves */
- extern int vgaDisabled ;
- 
- #define PhysicalVgaAccessDisabled	0x1
- #define VirtualVgaHardwareOpenPending	0x2
- #define VirtualVgaHardwareClosePending	0x4
--- 0 ----
diff -c mit/server/ddx/x386/vga16/ibm/vgaSolid.c:2.0 mit/server/ddx/x386/vga16/ibm/vgaSolid.c:2.2
*** mit/server/ddx/x386/vga16/ibm/vgaSolid.c:2.0	Fri Mar 11 23:40:45 1994
--- mit/server/ddx/x386/vga16/ibm/vgaSolid.c	Fri Mar 11 23:40:45 1994
***************
*** 43,49 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaSolid.c,v 2.0 1993/08/19 16:09:28 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaSolid.c,v 6.2 89/04/29 21:46:50 jeff Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaSolid.c,v */
  
--- 43,49 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaSolid.c,v 2.2 1994/03/08 04:51:14 dawes Exp $ */
  /* Header: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaSolid.c,v 6.2 89/04/29 21:46:50 jeff Exp */
  /* Source: /andrew/X11/r3src/release/server/ddx/ibm/vga/RCS/vgaSolid.c,v */
  
***************
*** 71,78 ****
  register const unsigned int bytewidth ;	/* MUST BE > 0 !! */
  register unsigned int height ;		/* MUST BE > 0 !! */
  {
! register volatile unsigned char *stop_address = destination + bytewidth ;
! register int row_jump = BYTES_PER_ROW - bytewidth ;
  #if !defined(OLDHC) && defined(BSDrt) && !defined(i386)
  register const int notZero = ~0x0 ;
  #else
--- 71,78 ----
  register const unsigned int bytewidth ;	/* MUST BE > 0 !! */
  register unsigned int height ;		/* MUST BE > 0 !! */
  {
! int stop_count = bytewidth ;
! register int row_jump = BYTES_PER_LINE - bytewidth ;
  #if !defined(OLDHC) && defined(BSDrt) && !defined(i386)
  register const int notZero = ~0x0 ;
  #else
***************
*** 80,87 ****
  #endif
  
  #define SINGLE_STORE \
!     ( *( (VgaMemoryPtr) ( destination++ ) ) = notZero )
  
  /* TOP OF FIRST LOOP */
  BranchPoint:
  
--- 80,90 ----
  #endif
  
  #define SINGLE_STORE \
!     ( *( (VgaMemoryPtr) destination ) = notZero ); \
!     VINCRW(destination) ; stop_count--;
  
+ VSETRW(destination);
+ 
  /* TOP OF FIRST LOOP */
  BranchPoint:
  
***************
*** 104,115 ****
  	case 0x2 : SINGLE_STORE ;
  	case 0x1 : SINGLE_STORE ;
  /* FIRST LOOP */
! 		if ( destination != stop_address )
  			goto LoopTop ;
  /* SECOND LOOP */
  		if ( --height ) {
  			destination += row_jump ;
! 			stop_address += BYTES_PER_ROW ;
  			goto BranchPoint ;
  		}
  		else
--- 107,119 ----
  	case 0x2 : SINGLE_STORE ;
  	case 0x1 : SINGLE_STORE ;
  /* FIRST LOOP */
! 		if ( stop_count )
  			goto LoopTop ;
  /* SECOND LOOP */
  		if ( --height ) {
  			destination += row_jump ;
! 			VCHECKRWO(destination);
! 			stop_count = bytewidth ;
  			goto BranchPoint ;
  		}
  		else
***************
*** 125,132 ****
  register const unsigned int bytewidth ;	/* MUST BE > 0 !! */
  register unsigned int height ;		/* MUST BE > 0 !! */
  {
! register volatile unsigned char *stop_address = destination + bytewidth ;
! register int row_jump = BYTES_PER_ROW - bytewidth ;
  #if !defined(OLDHC) && defined(BSDrt) && !defined(i386)
  register const int notZero = ~0x0 ;
  #else
--- 129,136 ----
  register const unsigned int bytewidth ;	/* MUST BE > 0 !! */
  register unsigned int height ;		/* MUST BE > 0 !! */
  {
! int stop_count = bytewidth ;
! register int row_jump = BYTES_PER_LINE - bytewidth ;
  #if !defined(OLDHC) && defined(BSDrt) && !defined(i386)
  register const int notZero = ~0x0 ;
  #else
***************
*** 136,142 ****
  
  #define SINGLE_STORE \
      tmp = *( (VgaMemoryPtr) destination ) ; \
!     ( *( (VgaMemoryPtr) ( destination++ ) ) = notZero )
  
  /* TOP OF FIRST LOOP */
  BranchPoint:
--- 140,149 ----
  
  #define SINGLE_STORE \
      tmp = *( (VgaMemoryPtr) destination ) ; \
!     ( *( (VgaMemoryPtr) destination ) = notZero ) ; \
!     VINCRW(destination) ; stop_count-- ;
! 
! VSETRW(destination);
  
  /* TOP OF FIRST LOOP */
  BranchPoint:
***************
*** 160,171 ****
  	case 0x2 : SINGLE_STORE ;
  	case 0x1 : SINGLE_STORE ;
  /* FIRST LOOP */
! 		if ( destination != stop_address )
  			goto LoopTop ;
  /* SECOND LOOP */
  		if ( --height ) {
  			destination += row_jump ;
! 			stop_address += BYTES_PER_ROW ;
  			goto BranchPoint ;
  		}
  		else
--- 167,179 ----
  	case 0x2 : SINGLE_STORE ;
  	case 0x1 : SINGLE_STORE ;
  /* FIRST LOOP */
! 		if ( stop_count )
  			goto LoopTop ;
  /* SECOND LOOP */
  		if ( --height ) {
  			destination += row_jump ;
! 			VCHECKRWO(destination);
! 			stop_count = bytewidth ;
  			goto BranchPoint ;
  		}
  		else
***************
*** 279,286 ****
   */
  SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  
- /* Point At The Bit Mask Reg */
- SetVideoGraphicsIndex( Bit_MaskIndex ) ;
  /* Do Left Edge */
  if ( tmp = x0 & 07 ) {
  	tmp2 = SCRRIGHT8( ( (unsigned) 0xFF ), tmp ) ;
--- 287,292 ----
***************
*** 290,315 ****
  		lx = 0 ;
  	}
  	/* Set The Bit Mask Reg */
!         SetVideoGraphicsData( tmp2 ) ;
  	if ( invert_existing_data == TRUE ) {
                  SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ;
! 		for ( tmp = ly, dst = VGABASE + BYTE_OFFSET( x0, y0 ) ;
! 		      tmp-- ;
! 		      dst += BYTES_PER_ROW ) {
  			tmp3 = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = tmp2 ;
  		}
                  SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  			/* Un-Set XOR */
- 		SetVideoGraphicsIndex( Bit_MaskIndex ) ;
  	}
! 	for ( tmp = ly, dst = SCREENADDRESS( x0, y0 ) ;
! 	      tmp-- ;
! 	      dst += BYTES_PER_ROW ) {
  		tmp3 = *( (VgaMemoryPtr) dst ) ;
  		*( (VgaMemoryPtr) dst ) = tmp2 ;
  	}
  	if ( !lx ) { /* All Handled In This Byte */
  		return ;
--- 296,322 ----
  		lx = 0 ;
  	}
  	/* Set The Bit Mask Reg */
!         SetVideoGraphics(Bit_MaskIndex, tmp2 ) ;
  	if ( invert_existing_data == TRUE ) {
                  SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ;
! 		dst = SCREENADDRESS( x0, y0 ); VSETRW(dst) ;
! 		for ( tmp = ly;
! 		      tmp-- ; ) {
  			tmp3 = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = tmp2 ;
+ 			dst += BYTES_PER_LINE; VCHECKRWO(dst);
  		}
                  SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  			/* Un-Set XOR */
  	}
! 	dst = SCREENADDRESS( x0, y0 ); VSETRW(dst) ;
! 	for ( tmp = ly;
! 	      tmp-- ; ) {
  		tmp3 = *( (VgaMemoryPtr) dst ) ;
  		*( (VgaMemoryPtr) dst ) = tmp2 ;
+ 		dst += BYTES_PER_LINE; VCHECKRWO(dst) ;
  	}
  	if ( !lx ) { /* All Handled In This Byte */
  		return ;
***************
*** 319,335 ****
  
  /* Fill The Center Of The Box */
  if ( ROW_OFFSET( lx ) ) {
! 	SetVideoGraphicsData( 0xFF ) ;
  	if ( invert_existing_data == TRUE ) {
                  SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ;
! 		fastFillRMW( VGABASE + BYTE_OFFSET( x0, y0 ),
  			     ROW_OFFSET( lx ), ly ) ;
                  SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  			/* Un-Set XOR */
  		/* Point At The Bit Mask Reg */
- 		SetVideoGraphicsIndex( Bit_MaskIndex ) ;
  	}
  	(* ( ( read_write_modify == FALSE ) ? fastFill : fastFillRMW ) )
  		( SCREENADDRESS( x0, y0 ), ROW_OFFSET( lx ), ly ) ;
--- 326,341 ----
  
  /* Fill The Center Of The Box */
  if ( ROW_OFFSET( lx ) ) {
! 	SetVideoGraphics(Bit_MaskIndex, 0xFF ) ;
  	if ( invert_existing_data == TRUE ) {
                  SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ;
! 		fastFillRMW( SCREENADDRESS( x0, y0 ),
  			     ROW_OFFSET( lx ), ly ) ;
                  SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  			/* Un-Set XOR */
  		/* Point At The Bit Mask Reg */
  	}
  	(* ( ( read_write_modify == FALSE ) ? fastFill : fastFillRMW ) )
  		( SCREENADDRESS( x0, y0 ), ROW_OFFSET( lx ), ly ) ;
***************
*** 338,362 ****
  /* Do Right Edge */
  if ( tmp = BIT_OFFSET( lx ) ) { /* x0 Now Is Byte Aligned */
  	/* Set The Bit Mask */
! 	SetVideoGraphicsData( tmp2 = SCRLEFT8( 0xFF, ( 8 - tmp ) ) ) ;
  	if ( invert_existing_data == TRUE ) {
                  SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ;
! 		for ( tmp = ly, dst = VGABASE + BYTE_OFFSET( ( x0 + lx ), y0 ) ;
! 		      tmp-- ;
! 		      dst += BYTES_PER_ROW ) {
  			tmp3 = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = tmp2 ;
  		}
                  SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  			/* Un-Set XOR */
  	}
! 	for ( tmp = ly, dst = SCREENADDRESS( ( x0 + lx ), y0 ) ;
! 	      tmp-- ;
! 	      dst += BYTES_PER_ROW ) {
  		tmp3 = *( (VgaMemoryPtr) dst ) ;
  		*( (VgaMemoryPtr) dst ) = tmp2 ;
  	}
  }
  /* Disable Set/Reset Register */
--- 344,371 ----
  /* Do Right Edge */
  if ( tmp = BIT_OFFSET( lx ) ) { /* x0 Now Is Byte Aligned */
  	/* Set The Bit Mask */
! 	SetVideoGraphics( Bit_MaskIndex,
! 		(tmp2 = SCRLEFT8( 0xFF, ( 8 - tmp ) ) ) ) ;
  	if ( invert_existing_data == TRUE ) {
                  SetVideoGraphics( Set_ResetIndex, VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, VGA_XOR_MODE ) ;
! 		dst = SCREENADDRESS( ( x0 + lx ), y0 ); VSETRW(dst) ;
! 		for ( tmp = ly; 
! 		      tmp-- ; ) {
  			tmp3 = *( (VgaMemoryPtr) dst ) ;
  			*( (VgaMemoryPtr) dst ) = tmp2 ;
+ 			dst += BYTES_PER_LINE; VCHECKRWO(dst) ;
  		}
                  SetVideoGraphics( Set_ResetIndex, color & VGA_ALLPLANES ) ;
  		SetVideoGraphics( Data_RotateIndex, data_rotate_value ) ;
  			/* Un-Set XOR */
  	}
! 	dst = SCREENADDRESS( ( x0 + lx ), y0 ); VSETRW(dst) ;
! 	for ( tmp = ly; 
! 	      tmp-- ; ) {
  		tmp3 = *( (VgaMemoryPtr) dst ) ;
  		*( (VgaMemoryPtr) dst ) = tmp2 ;
+ 		dst += BYTES_PER_LINE ; VCHECKRWO(dst) ;
  	}
  }
  /* Disable Set/Reset Register */
diff -c mit/server/ddx/x386/vga16/ibm/vgaStipple.c:2.2 mit/server/ddx/x386/vga16/ibm/vgaStipple.c:2.4
*** mit/server/ddx/x386/vga16/ibm/vgaStipple.c:2.2	Fri Mar 11 23:40:46 1994
--- mit/server/ddx/x386/vga16/ibm/vgaStipple.c	Fri Mar 11 23:40:46 1994
***************
*** 21,27 ****
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaStipple.c,v 2.2 1993/10/16 17:32:29 dawes Exp $ */
  
  #include "X.h"
  #include "pixmapstr.h"
--- 21,27 ----
   *
  */
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaStipple.c,v 2.4 1994/03/08 04:51:16 dawes Exp $ */
  
  #include "X.h"
  #include "pixmapstr.h"
***************
*** 124,136 ****
  		tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ;
  		w = 0 ;
  	}
! 	SetVideoGraphicsData( tmp2 ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
! 	for ( tmp1 = yshift, rowCounter = h, xDst = SCREENADDRESS( x, y ) ;
  	      rowCounter ;
! 	      rowCounter-- , tmp1++, xDst += BYTES_PER_ROW ) {
  
  		if ( tmp1 >= height )
  			tmp1 -= height ;
--- 124,137 ----
  		tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ;
  		w = 0 ;
  	}
! 	SetVideoGraphics( Bit_MaskIndex, tmp2 ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
! 	xDst = SCREENADDRESS( x, y ); VSETRW(xDst);
! 	for ( tmp1 = yshift, rowCounter = h;
  	      rowCounter ;
! 	      rowCounter-- , tmp1++ ) {
  
  		if ( tmp1 >= height )
  			tmp1 -= height ;
***************
*** 141,146 ****
--- 142,148 ----
  			getbits( xshift /* GJA */, width,
  				 mastersrc
  				 + ( tmp1 * paddedByteWidth ) ) >> (x & 07) ;
+  		xDst += BYTES_PER_LINE; VCHECKRWO(xDst);
  	}
  	NeedValX = (xshift + 8 - (x & 07)) % width;
  	x = ( x + 7 ) & ~07 ;
***************
*** 152,164 ****
  if ( byte_cnt = ROW_OFFSET( w ) ) { /* Fill The Center Of The Box */
  	int SavNeedX = NeedValX ;
  
! 	SetVideoGraphicsData( 0xFF ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
! 	for ( tmp1 = yshift, rowCounter = h, xDst = SCREENADDRESS( x, y ) ;
  	      rowCounter ;
! 	      rowCounter-- , tmp1++, xDst += BYTES_PER_ROW - byte_cnt ) {
  		register const unsigned char *l_ptr ;
  		if ( tmp1 >= height )
  			tmp1 -= height ;
--- 154,167 ----
  if ( byte_cnt = ROW_OFFSET( w ) ) { /* Fill The Center Of The Box */
  	int SavNeedX = NeedValX ;
  
! 	SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
! 	xDst = SCREENADDRESS( x, y ); VSETRW(xDst);
! 	for ( tmp1 = yshift, rowCounter = h;
  	      rowCounter ;
! 	      rowCounter-- , tmp1++ ) {
  		register const unsigned char *l_ptr ;
  		if ( tmp1 >= height )
  			tmp1 -= height ;
***************
*** 167,173 ****
  		 * For Each Byte Across The Pattern In X
  		 */
  		for ( counter = byte_cnt, NeedValX = SavNeedX ;
! 		      counter-- ; xDst++ ) {
  			/* Read To Save */
  			tmp2 = *( (VgaMemoryPtr) xDst) ;
  			/* Write Pattern */
--- 170,176 ----
  		 * For Each Byte Across The Pattern In X
  		 */
  		for ( counter = byte_cnt, NeedValX = SavNeedX ;
! 		      counter-- ; ) {
  			/* Read To Save */
  			tmp2 = *( (VgaMemoryPtr) xDst) ;
  			/* Write Pattern */
***************
*** 175,181 ****
--- 178,186 ----
  				getbits( NeedValX, width, l_ptr ) ;
  			/* GJA -- The '%' is there since width could be < 8 */
  			NeedValX = (NeedValX + 8) % width;
+ 			xDst++; VCHECKRWO(xDst);
  		}
+ 		xDst += BYTES_PER_LINE - byte_cnt; VCHECKRWO(xDst);
  	}
  }
  
***************
*** 182,195 ****
  /* Do Right Edge */
  if ( tmp1 = BIT_OFFSET( w ) ) { /* x Now Is Byte Aligned */
  	/* Set The Bit Mask */
! 	SetVideoGraphicsData( SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ;
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
! 	for ( tmp1 = yshift, rowCounter = h,
! 	      xDst = SCREENADDRESS( ( x + w ), y ) ;
  	      rowCounter ;
! 	      rowCounter-- , tmp1++, xDst += BYTES_PER_ROW ) {
  		if ( tmp1 >= height )
  			tmp1 -= height ;
  		/* Read To Save */
--- 187,200 ----
  /* Do Right Edge */
  if ( tmp1 = BIT_OFFSET( w ) ) { /* x Now Is Byte Aligned */
  	/* Set The Bit Mask */
! 	SetVideoGraphics( Bit_MaskIndex, SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ;
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
! 	xDst = SCREENADDRESS( ( x + w ), y ); VSETRW(xDst);
! 	for ( tmp1 = yshift, rowCounter = h;
  	      rowCounter ;
! 	      rowCounter-- , tmp1++ ) {
  		if ( tmp1 >= height )
  			tmp1 -= height ;
  		/* Read To Save */
***************
*** 199,204 ****
--- 204,210 ----
  			getbits( NeedValX, width,
  				 mastersrc
  				 + ( tmp1 * paddedByteWidth ) ) ;
+ 		xDst += BYTES_PER_LINE ; VCHECKRWO(xDst);
  	}
  }
  
***************
*** 225,231 ****
  unsigned DestinationRow ;
  unsigned int SourceRow ;
  volatile unsigned char *dst ;
! int scr_incr = ( height * BYTES_PER_ROW ) ;
  
  /* Do Left Edge */
  if ( tmp1 = x & 07 ) {
--- 231,237 ----
  unsigned DestinationRow ;
  unsigned int SourceRow ;
  volatile unsigned char *dst ;
! int scr_incr = ( height * BYTES_PER_LINE ) ;
  
  /* Do Left Edge */
  if ( tmp1 = x & 07 ) {
***************
*** 235,247 ****
  		tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ;
  		w = 0 ;
  	}
! 	SetVideoGraphicsData( tmp2 ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
  	for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( x, y ) ;
  	      SourceRow < height ;
! 	      tmp1++, SourceRow++, dst += BYTES_PER_ROW ) {
  		register unsigned bitPattern ;
  
  		if ( tmp1 >= height )
--- 241,253 ----
  		tmp2 &= SCRLEFT8( (unsigned) 0xFF, -w ) ;
  		w = 0 ;
  	}
! 	SetVideoGraphics( Bit_MaskIndex, tmp2 ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
  	for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( x, y ) ;
  	      SourceRow < height ;
! 	      tmp1++, SourceRow++, dst += BYTES_PER_LINE ) {
  		register unsigned bitPattern ;
  
  		if ( tmp1 >= height )
***************
*** 249,265 ****
  		/*
  		 * For Each Time Pattern Repeats In The Y Dimension
  		 */
! 		for ( xDst = dst, DestinationRow = SourceRow,
  		      bitPattern = getbits( xshift, width,
  					    mastersrc
  					+ ( tmp1 * paddedByteWidth ) ) ;
  		      DestinationRow < h ;
- 		      xDst += scr_incr,
  		      DestinationRow += height ) {
  			/* Read To Save */
  			tmp2 = *( (VgaMemoryPtr) xDst ) ;
  			/* Write Pattern */
  			*( (VgaMemoryPtr) xDst ) = bitPattern >> (x & 07);
  		}
  	}
  	NeedValX = (xshift + 8 - (x & 07)) % width;
--- 255,272 ----
  		/*
  		 * For Each Time Pattern Repeats In The Y Dimension
  		 */
! 		xDst = dst; VSETRW(xDst);
! 		for ( DestinationRow = SourceRow,
  		      bitPattern = getbits( xshift, width,
  					    mastersrc
  					+ ( tmp1 * paddedByteWidth ) ) ;
  		      DestinationRow < h ;
  		      DestinationRow += height ) {
  			/* Read To Save */
  			tmp2 = *( (VgaMemoryPtr) xDst ) ;
  			/* Write Pattern */
  			*( (VgaMemoryPtr) xDst ) = bitPattern >> (x & 07);
+ 		        xDst += scr_incr; VCHECKRWO(xDst);
  		}
  	}
  	NeedValX = (xshift + 8 - (x & 07)) % width;
***************
*** 272,284 ****
  if ( byte_cnt = ROW_OFFSET( w ) ) { /* Fill The Center Of The Box */
  	int SavNeedX = NeedValX ;
  
! 	SetVideoGraphicsData( 0xFF ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
  	for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( x, y ) ;
  	      SourceRow < height ;
! 	      tmp1++, SourceRow++, dst += BYTES_PER_ROW - byte_cnt ) {
  		register const unsigned char *l_ptr ;
  		if ( tmp1 >= height )
  			tmp1 -= height ;
--- 279,291 ----
  if ( byte_cnt = ROW_OFFSET( w ) ) { /* Fill The Center Of The Box */
  	int SavNeedX = NeedValX ;
  
! 	SetVideoGraphics( Bit_MaskIndex, 0xFF ) ; /* Set The Bit Mask */
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
  	for ( tmp1 = yshift, SourceRow = 0, dst = SCREENADDRESS( x, y ) ;
  	      SourceRow < height ;
! 	      tmp1++, SourceRow++, dst += BYTES_PER_LINE - byte_cnt ) {
  		register const unsigned char *l_ptr ;
  		if ( tmp1 >= height )
  			tmp1 -= height ;
***************
*** 294,309 ****
  			/*
  			 * For Each Time Pattern Repeats In Y
  			 */
! 			for ( xDst = dst,
! 			      DestinationRow = SourceRow,
  			      bitPattern = getbits( NeedValX, width, l_ptr ) ;
  			      DestinationRow < h ;
- 			      xDst += scr_incr,
  			      DestinationRow += height ) {
  				/* Read To Save */
  				tmp3 = *( (VgaMemoryPtr) xDst) ;
  				/* Write Pattern */
  				*( (VgaMemoryPtr) xDst ) = bitPattern ;
  			}
  			NeedValX = (NeedValX + 8) % width;
  		}
--- 301,316 ----
  			/*
  			 * For Each Time Pattern Repeats In Y
  			 */
! 			xDst = dst; VSETRW(xDst);
! 			for ( DestinationRow = SourceRow,
  			      bitPattern = getbits( NeedValX, width, l_ptr ) ;
  			      DestinationRow < h ;
  			      DestinationRow += height ) {
  				/* Read To Save */
  				tmp3 = *( (VgaMemoryPtr) xDst) ;
  				/* Write Pattern */
  				*( (VgaMemoryPtr) xDst ) = bitPattern ;
+ 			        xDst += scr_incr; VCHECKRWO(xDst);
  			}
  			NeedValX = (NeedValX + 8) % width;
  		}
***************
*** 313,319 ****
  /* Do Right Edge */
  if ( tmp1 = BIT_OFFSET( w ) ) { /* x Now Is Byte Aligned */
  	/* Set The Bit Mask */
! 	SetVideoGraphicsData( SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ;
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
--- 320,326 ----
  /* Do Right Edge */
  if ( tmp1 = BIT_OFFSET( w ) ) { /* x Now Is Byte Aligned */
  	/* Set The Bit Mask */
! 	SetVideoGraphics( Bit_MaskIndex, SCRLEFT8( 0xFF, ( 8 - tmp1 ) ) ) ;
  	/*
  	 * For Each Line In The Source Pixmap
  	 */
***************
*** 320,326 ****
  	for ( tmp1 = yshift, SourceRow = 0,
  	      dst = SCREENADDRESS( ( x + w ), y ) ;
  	      SourceRow < height ;
! 	      tmp1++, SourceRow++, dst += BYTES_PER_ROW ) {
  		register unsigned bitPattern ;
  		if ( tmp1 >= height )
  			tmp1 -= height ;
--- 327,333 ----
  	for ( tmp1 = yshift, SourceRow = 0,
  	      dst = SCREENADDRESS( ( x + w ), y ) ;
  	      SourceRow < height ;
! 	      tmp1++, SourceRow++, dst += BYTES_PER_LINE ) {
  		register unsigned bitPattern ;
  		if ( tmp1 >= height )
  			tmp1 -= height ;
***************
*** 327,342 ****
  		/*
  		 * For Each Time Pattern Repeats In The Y Dimension
  		 */
! 		for ( xDst = dst, DestinationRow = SourceRow,
  		      bitPattern = getbits( NeedValX, width,
  					    mastersrc
  					+ ( tmp1 * paddedByteWidth ) ) ;
  		      DestinationRow < h ;
! 		      xDst += scr_incr, DestinationRow += height ) {
  			/* Read To Save */
  			tmp2 = *( (VgaMemoryPtr) xDst) ;
  			/* Write Pattern */
  			*( (VgaMemoryPtr) xDst ) = bitPattern ;
  		}
  	}
  }
--- 334,351 ----
  		/*
  		 * For Each Time Pattern Repeats In The Y Dimension
  		 */
! 		xDst = dst; VSETRW(xDst);
! 		for ( DestinationRow = SourceRow,
  		      bitPattern = getbits( NeedValX, width,
  					    mastersrc
  					+ ( tmp1 * paddedByteWidth ) ) ;
  		      DestinationRow < h ;
! 		      DestinationRow += height ) {
  			/* Read To Save */
  			tmp2 = *( (VgaMemoryPtr) xDst) ;
  			/* Write Pattern */
  			*( (VgaMemoryPtr) xDst ) = bitPattern ;
+ 		        xDst += scr_incr; VCHECKRWO(xDst);
  		}
  	}
  }
***************
*** 367,375 ****
   * Set The Vga's Alu Function
   */
  SetVideoGraphics( Data_RotateIndex, desiredState >> 8 ) ;
- 
- /* Point At The Bit Mask Reg For Later */
- SetVideoGraphicsIndex( Bit_MaskIndex ) ;
  
  return ;
  }
--- 376,381 ----
diff -c mit/server/ddx/x386/vga16/ibm/vgaVideo.h:2.0 mit/server/ddx/x386/vga16/ibm/vgaVideo.h:2.2
*** mit/server/ddx/x386/vga16/ibm/vgaVideo.h:2.0	Fri Mar 11 23:40:46 1994
--- mit/server/ddx/x386/vga16/ibm/vgaVideo.h	Fri Mar 11 23:40:46 1994
***************
*** 43,49 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaVideo.h,v 2.0 1993/08/19 16:09:30 dawes Exp $ */
  /* Header: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/vga/RCS/vgaVideo.h,v 6.3 88/11/10 22:51:31 paul Exp */
  /* Source: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/vga/RCS/vgaVideo.h,v */
  
--- 43,49 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga16/ibm/vgaVideo.h,v 2.2 1994/03/08 04:51:18 dawes Exp $ */
  /* Header: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/vga/RCS/vgaVideo.h,v 6.3 88/11/10 22:51:31 paul Exp */
  /* Source: /andrew/X11/r3src/earlyRelease/server/ddx/ibm/vga/RCS/vgaVideo.h,v */
  
***************
*** 81,91 ****
  #define IMAGE_BYTE_ORDER LSBFirst
  #endif
  
- extern pointer vgaBase;
  	/* GJA -- Connect IBM code with XFree86 */
  #define SCREEN_ADDR ((int)vgaBase)
  #define VIDEO_MEMORY_BASE ( (volatile unsigned char *) ( SCREEN_ADDR ) )
! #define VGABASE VIDEO_MEMORY_BASE
  
  
  /* Bit Ordering Macros */
--- 81,97 ----
  #define IMAGE_BYTE_ORDER LSBFirst
  #endif
  
  	/* GJA -- Connect IBM code with XFree86 */
+ extern pointer vgaBase;
+ #ifdef UNBANKED_VGA16
  #define SCREEN_ADDR ((int)vgaBase)
+ #else
+ extern pointer vgaVirtBase;
+ #define SCREEN_ADDR ((int)vgaVirtBase)
+ #endif
+ 
  #define VIDEO_MEMORY_BASE ( (volatile unsigned char *) ( SCREEN_ADDR ) )
! #define VIDBASE VIDEO_MEMORY_BASE
  
  
  /* Bit Ordering Macros */
***************
*** 120,126 ****
  
  #define VIDEO_MEM_BYTES_PER_PLANE ( 96 * 1024 )
  
! extern int BYTES_PER_ROW;
  extern int MAX_ROW;
  extern int MAX_COLUMN;
  extern int MAX_OFFSCREEN_ROW;
--- 126,132 ----
  
  #define VIDEO_MEM_BYTES_PER_PLANE ( 96 * 1024 )
  
! extern int BYTES_PER_LINE;
  extern int MAX_ROW;
  extern int MAX_COLUMN;
  extern int MAX_OFFSCREEN_ROW;
***************
*** 128,134 ****
  #define ROW_OFFSET( PIXEL_X_VALUE ) ( ( PIXEL_X_VALUE ) >> 3 )
  #define BIT_OFFSET( PIXEL_X_VALUE ) ( ( PIXEL_X_VALUE ) & 0x7 )
  #define BYTE_OFFSET( PIXEL_X_VALUE, PIXEL_Y_VALUE ) \
! 	( ( ( PIXEL_Y_VALUE ) * BYTES_PER_ROW ) + ( ( PIXEL_X_VALUE ) >> 3 ) )
  #define SCREENADDRESS( PIXEL_X_VALUE, PIXEL_Y_VALUE ) \
  	( VIDEO_MEMORY_BASE + BYTE_OFFSET( PIXEL_X_VALUE, PIXEL_Y_VALUE ) )
  
--- 134,140 ----
  #define ROW_OFFSET( PIXEL_X_VALUE ) ( ( PIXEL_X_VALUE ) >> 3 )
  #define BIT_OFFSET( PIXEL_X_VALUE ) ( ( PIXEL_X_VALUE ) & 0x7 )
  #define BYTE_OFFSET( PIXEL_X_VALUE, PIXEL_Y_VALUE ) \
! 	( ( ( PIXEL_Y_VALUE ) * BYTES_PER_LINE ) + ( ( PIXEL_X_VALUE ) >> 3 ) )
  #define SCREENADDRESS( PIXEL_X_VALUE, PIXEL_Y_VALUE ) \
  	( VIDEO_MEMORY_BASE + BYTE_OFFSET( PIXEL_X_VALUE, PIXEL_Y_VALUE ) )
  
diff -c /dev/null mit/server/ddx/x386/vga16/ibm/wm0.h:2.0
*** /dev/null	Fri Mar 11 23:40:47 1994
--- mit/server/ddx/x386/vga16/ibm/wm0.h	Fri Mar 11 23:40:47 1994
***************
*** 0 ****
--- 1,54 ----
+ /* $XFree86: mit/server/ddx/x386/vga16/ibm/wm0.h,v 2.0 1994/02/01 13:54:48 dawes Exp $ */
+ #include "vgaReg.h"
+ 
+ 
+ /* The following awesome macro steps through all four planes calling
+  * 'call.' 
+  */
+ #define DO_WM0(pgc,call) \
+ { int _fg, _bg, _rop, _pm; \
+   mfbPrivGC *_pPriv = (mfbPrivGC *)((pgc)->devPrivates[mfbGCPrivateIndex].ptr); \
+   _fg = (pgc)->fgPixel; _bg = (pgc)->bgPixel; _rop = _pPriv->rop; \
+   _pm = (pgc)->planemask; \
+   \
+   SetVideoGraphics(Enb_Set_ResetIndex, 0); /* All from CPU */ \
+   SetVideoGraphics(Bit_MaskIndex, 0xFF); /* All bits */ \
+   SetVideoGraphics(Graphics_ModeIndex, 0); /* Write mode 0 */ \
+   SetVideoGraphics(Data_RotateIndex, 0); /* Don't rotate, replace */ \
+   \
+   if ( (pgc)->planemask & 1) { \
+     (pgc)->fgPixel = (_fg>>0)&1; (pgc)->bgPixel = (_bg>>0)&1; \
+     _pPriv->rop = mfbReduceRop((pgc)->alu, (pgc)->fgPixel); \
+     (pgc)->planemask = 1; \
+     SetVideoGraphics(Read_Map_SelectIndex, 0); \
+     SetVideoSequencer(Mask_MapIndex, 1);	/* Plane 0 */ \
+     (call); \
+   } \
+   if ( (pgc)->planemask & 2) { \
+     (pgc)->fgPixel = (_fg>>1)&1; (pgc)->bgPixel = (_bg>>1)&1; \
+     _pPriv->rop = mfbReduceRop((pgc)->alu, (pgc)->fgPixel); \
+     (pgc)->planemask = 1; \
+     SetVideoGraphics(Read_Map_SelectIndex, 1); \
+     SetVideoSequencer(Mask_MapIndex, 2);	/* Plane 1 */ \
+     (call); \
+   } \
+   if ( (pgc)->planemask & 4) { \
+     (pgc)->fgPixel = (_fg>>2)&1; (pgc)->bgPixel = (_bg>>2)&1; \
+     _pPriv->rop = mfbReduceRop((pgc)->alu, (pgc)->fgPixel); \
+     (pgc)->planemask = 1; \
+     SetVideoGraphics(Read_Map_SelectIndex, 2); \
+     SetVideoSequencer(Mask_MapIndex, 4);	/* Plane 2 */ \
+     (call); \
+   } \
+   if ( (pgc)->planemask & 8) { \
+     (pgc)->fgPixel = (_fg>>3)&1; (pgc)->bgPixel = (_bg>>3)&1; \
+     _pPriv->rop = mfbReduceRop((pgc)->alu, (pgc)->fgPixel); \
+     (pgc)->planemask = 1; \
+     SetVideoGraphics(Read_Map_SelectIndex, 3); \
+     SetVideoSequencer(Mask_MapIndex, 8);	/* Plane 3 */ \
+     (call); \
+   } \
+   (pgc)->fgPixel = _fg; (pgc)->bgPixel = _bg; _pPriv->rop = _rop; \
+   (pgc)->planemask = _pm; \
+ }
+ 
diff -c /dev/null mit/server/ddx/x386/vga16/ibm/wm3.c:2.1
*** /dev/null	Fri Mar 11 23:40:47 1994
--- mit/server/ddx/x386/vga16/ibm/wm3.c	Fri Mar 11 23:40:47 1994
***************
*** 0 ****
--- 1,120 ----
+ /* $XFree86: mit/server/ddx/x386/vga16/ibm/wm3.c,v 2.1 1994/02/25 15:02:52 dawes Exp $ */
+ #include "compiler.h"
+ #include "vgaReg.h"
+ #include "vgaVideo.h"
+ #include "X.h"
+ #include "gcstruct.h"
+ #include "wm3.h"
+ 
+ /* Ferraro is wrong. GJA */
+ #define COPY (0 << 3)
+ #define AND  (1 << 3)
+ #define OR   (2 << 3)
+ #define XOR  (3 << 3)
+ 
+ wm3_set_regs(pGC)
+ GC *pGC;
+ {
+     int post_invert = 0;
+     int ALU;
+ 
+     switch(pGC->alu) {
+     case GXclear:        /* rop0 = RROP_BLACK;  rop1 = RROP_BLACK; */
+         pGC->fgPixel = 0;
+         pGC->bgPixel = 0;
+         ALU = COPY;
+         break;
+     case GXand:          /* rop0 = RROP_BLACK;  rop1 = RROP_NOP; */
+         ALU = AND;
+         break;
+     case GXandReverse:   /* rop0 = RROP_BLACK;  rop1 = RROP_INVERT; -- TRICKY */
+         pGC->fgPixel = ~pGC->fgPixel;
+         pGC->bgPixel = ~pGC->bgPixel;
+         ALU = OR;
+         post_invert = 1;
+         break;
+     case GXcopy:         /* rop0 = RROP_BLACK;  rop1 = RROP_WHITE; */
+         ALU = COPY;
+         break;
+     case GXandInverted:  /* rop0 = RROP_NOP;    rop1 = RROP_BLACK; */
+         pGC->fgPixel = ~pGC->fgPixel;
+         pGC->bgPixel = ~pGC->bgPixel;
+         ALU = AND;
+         break;
+     case GXnoop:         /* rop0 = RROP_NOP;    rop1 = RROP_NOP; */
+         return 0;
+     case GXxor:          /* rop0 = RROP_NOP;    rop1 = RROP_INVERT; */
+         ALU = XOR;
+         break;
+     case GXor:           /* rop0 = RROP_NOP;    rop1 = RROP_WHITE; */
+         ALU = OR;
+         break;
+     case GXnor:          /* rop0 = RROP_INVERT; rop1 = RROP_BLACK; -- TRICKY*/
+         ALU = OR;
+         post_invert = 1;
+         break;
+     case GXequiv:        /* rop0 = RROP_INVERT; rop1 = RROP_NOP; */
+         pGC->fgPixel = ~pGC->fgPixel;
+         pGC->bgPixel = ~pGC->bgPixel;
+         ALU = XOR;
+         break;
+     case GXinvert:       /* rop0 = RROP_INVERT; rop1 = RROP_INVERT; */
+         pGC->fgPixel = 0x0F;
+         pGC->bgPixel = 0x0F;
+         ALU = XOR;
+         break;
+     case GXorReverse:    /* rop0 = RROP_INVERT; rop1 = RROP_WHITE; -- TRICKY */
+         pGC->fgPixel = ~pGC->fgPixel;
+         pGC->bgPixel = ~pGC->bgPixel;
+         ALU = AND;
+         post_invert = 1;
+         break;
+     case GXcopyInverted: /* rop0 = RROP_WHITE;  rop1 = RROP_BLACK; */
+         pGC->fgPixel = ~pGC->fgPixel;
+         pGC->bgPixel = ~pGC->bgPixel;
+         ALU = COPY;
+         break;
+     case GXorInverted:   /* rop0 = RROP_WHITE;  rop1 = RROP_NOP; */
+         pGC->fgPixel = ~pGC->fgPixel;
+         pGC->bgPixel = ~pGC->bgPixel;
+         ALU = OR;
+         break;
+     case GXnand:         /* rop0 = RROP_WHITE;  rop1 = RROP_INVERT; -- TRICKY */
+         ALU = OR;
+         post_invert = 1;
+         break;
+     case GXset:          /* rop0 = RROP_WHITE;  rop1 = RROP_WHITE; */
+         pGC->fgPixel = 0x0F;
+         pGC->bgPixel = 0x0F;
+         ALU = COPY;
+         break;
+     }
+ 
+ 
+     SetVideoSequencer(Mask_MapIndex, (pGC->planemask & VGA_ALLPLANES));
+     SetVideoGraphics(Enb_Set_ResetIndex, VGA_ALLPLANES);
+     SetVideoGraphics(Set_ResetIndex, pGC->fgPixel);
+     SetVideoGraphics(Bit_MaskIndex, 0xFF);
+     SetVideoGraphics(Graphics_ModeIndex, 3); /* Write Mode 3 */
+     SetVideoGraphics(Data_RotateIndex, ALU);
+ 
+     return post_invert;
+ }
+ 
+ /*
+    Now we will have to set the alu.
+    Problematic is: How do we handle IsDoubleDash, which draws with both fg
+    and bg colour?
+    The answer is: We take care to store the ink colour in one register only.
+    Then we need set only this register to change the ink.
+  */
+  
+ /* -- MORE NOTES:
+    We might try to 'wrap' the mfb functions in a 16-colour wrapper that does
+    all operations once. However, this does not work:
+    Some operations (esp) CopyArea may for example cause expositions.
+    Such expositions will cause data to be copied in from backing store,
+    and this copying in may damage the contents of the VGA registers.
+    So we must take care to set the VGA registers at each place where they could
+    be modified.
+  */
diff -c /dev/null mit/server/ddx/x386/vga16/ibm/wm3.h:2.0
*** /dev/null	Fri Mar 11 23:40:47 1994
--- mit/server/ddx/x386/vga16/ibm/wm3.h	Fri Mar 11 23:40:47 1994
***************
*** 0 ****
--- 1,41 ----
+ /* $XFree86: mit/server/ddx/x386/vga16/ibm/wm3.h,v 2.0 1994/02/01 13:54:50 dawes Exp $ */
+ #include "vgaReg.h"
+ 
+ /* Do call in Write Mode 3.
+  * We take care of the possibility that two passes are needed.
+  */
+ #define DO_WM3(pgc,call) \
+    { int _tp, _fg, _bg, _alu; \
+ 	_fg = pgc->fgPixel; _bg = pgc->bgPixel; \
+ 	_tp = wm3_set_regs(pgc); \
+         (call); \
+ 	if ( _tp ) { \
+            _alu = pgc->alu; \
+ 	   pgc->alu = GXinvert; \
+ 	   _tp = wm3_set_regs(pgc); \
+ 	   (call); \
+            pgc->alu = _alu; \
+ 	} \
+ 	pgc->fgPixel = _fg; pgc->bgPixel = _bg; \
+     }
+ 
+ #define WM3_SET_INK(ink) \
+     SetVideoGraphics(Set_ResetIndex, ink)
+ 
+ /* GJA -- Move a long word to screen memory.
+  * The reads into 'dummy' are here to load the VGA latches.
+  * This is a RMW operation except for trivial cases.
+  * Notice that we ignore the operation.
+  */
+ #define UPDRW(destp,src) \
+ 	{ volatile char *_dtmp = (volatile char *)(destp); \
+ 	  int _stmp = (src); \
+ 	  volatile int dummy; /* Bit bucket. */ \
+ 	  dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \
+ 	  dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \
+ 	  dummy = *_dtmp; *_dtmp = _stmp; _dtmp++; _stmp >>= 8; \
+ 	  dummy = *_dtmp; *_dtmp = _stmp; }
+ 
+ #define UPDRWB(destp,src) \
+ 	{ volatile int dummy; /* Bit bucket. */ \
+ 	  dummy = *(destp); *(destp) = (src); }
diff -c mit/server/ddx/x386/vga16/vga/Imakefile:2.1 mit/server/ddx/x386/vga16/vga/Imakefile:2.3
*** mit/server/ddx/x386/vga16/vga/Imakefile:2.1	Fri Mar 11 23:40:50 1994
--- mit/server/ddx/x386/vga16/vga/Imakefile	Fri Mar 11 23:40:50 1994
***************
*** 1,16 ****
! XCOMM $XFree86: mit/server/ddx/x386/vga16/vga/Imakefile,v 2.1 1993/10/02 07:15:45 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
  #include <Server.tmpl>
  
  SRCS = 	vgaHW.c vga.c vgaCmap.c
  
! OBJS = 	vgaHW.o vga.o vgaCmap.o
  
  DDXSRC = $(SERVERSRC)/ddx
  X386SRC = $(DDXSRC)/x386/common
  XF86OSSRC = $(DDXSRC)/x386/os-support
! INCLUDES = -I$(X386SRC) -I$(XF86OSSRC) -I../../vga256/vga -I$(DDXSRC)/mfb \
!            -I$(DDXSRC)/mi -I$(DDXSRC)/cfb -I$(SERVERSRC)/include -I$(INCLUDESRC)
  
  SubdirLibraryRule($(OBJS))
  NormalLibraryObjectRule()
--- 1,17 ----
! XCOMM $XFree86: mit/server/ddx/x386/vga16/vga/Imakefile,v 2.3 1994/02/01 13:55:49 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
  #include <Server.tmpl>
  
  SRCS = 	vgaHW.c vga.c vgaCmap.c
  
! OBJS = 	vgaHW.o vga.o vgaCmap.o vgaBank.o
  
  DDXSRC = $(SERVERSRC)/ddx
  X386SRC = $(DDXSRC)/x386/common
  XF86OSSRC = $(DDXSRC)/x386/os-support
! INCLUDES = -I$(X386SRC) -I$(XF86OSSRC) -I../../common_hw -I../../vga256/vga \
!            -I$(DDXSRC)/mfb -I$(DDXSRC)/mi -I$(DDXSRC)/cfb \
!            -I$(SERVERSRC)/include -I$(INCLUDESRC)
  
  SubdirLibraryRule($(OBJS))
  NormalLibraryObjectRule()
***************
*** 17,28 ****
  NormalAsmObjectRule()
  
  #if DirtyStartup
! DEFINES = -DDIRTY_STARTUP
  #endif
  
  
! ObjectFromSpecialSource(vga,../../vga256/vga/vga,-DXF86VGA16)
! ObjectFromSpecialSource(vgaHW,../../vga256/vga/vgaHW,-DXF86VGA16)
! ObjectFromSpecialSource(vgaCmap,../../vga256/vga/vgaCmap,-DXF86VGA16)
  
  DependTarget()
--- 18,31 ----
  NormalAsmObjectRule()
  
  #if DirtyStartup
! STARTUPDEFINES = -DDIRTY_STARTUP
  #endif
  
+ DEFINES = -DXF86VGA16 $(STARTUPDEFINES)
  
! ObjectFromSpecialSource(vga,../../vga256/vga/vga,/**/)
! ObjectFromSpecialSource(vgaHW,../../vga256/vga/vgaHW,/**/)
! ObjectFromSpecialSource(vgaCmap,../../vga256/vga/vgaCmap,/**/)
! ObjectFromSpecialAsmSource(vgaBank,../../vga256/vga/vgaBank,/**/)
  
  DependTarget()
diff -c mit/server/ddx/x386/vga2/vga/Imakefile:2.2 mit/server/ddx/x386/vga2/vga/Imakefile:2.3
*** mit/server/ddx/x386/vga2/vga/Imakefile:2.2	Fri Mar 11 23:40:58 1994
--- mit/server/ddx/x386/vga2/vga/Imakefile	Fri Mar 11 23:40:58 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/vga2/vga/Imakefile,v 2.2 1993/10/02 07:15:59 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
  #include <Server.tmpl>
  
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/vga2/vga/Imakefile,v 2.3 1993/12/26 08:25:18 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
  #include <Server.tmpl>
  
***************
*** 9,15 ****
  DDXSRC = $(SERVERSRC)/ddx
  X386SRC = $(DDXSRC)/x386/common
  XF86OSSRC = $(DDXSRC)/x386/os-support
! INCLUDES = -I$(X386SRC) -I$(XF86OSSRC) -I../../vga256/vga \
             -I$(DDXSRC)/mfb -I$(DDXSRC)/mi \
  	   -I$(DDXSRC)/cfb -I$(SERVERSRC)/include -I$(INCLUDESRC)
  
--- 9,15 ----
  DDXSRC = $(SERVERSRC)/ddx
  X386SRC = $(DDXSRC)/x386/common
  XF86OSSRC = $(DDXSRC)/x386/os-support
! INCLUDES = -I$(X386SRC) -I$(XF86OSSRC) -I../../common_hw -I../../vga256/vga \
             -I$(DDXSRC)/mfb -I$(DDXSRC)/mi \
  	   -I$(DDXSRC)/cfb -I$(SERVERSRC)/include -I$(INCLUDESRC)
  
diff -c mit/server/ddx/x386/vga256/drivers/ati/driver.c:2.12 mit/server/ddx/x386/vga256/drivers/ati/driver.c:2.14
*** mit/server/ddx/x386/vga256/drivers/ati/driver.c:2.12	Fri Mar 11 23:41:04 1994
--- mit/server/ddx/x386/vga256/drivers/ati/driver.c	Fri Mar 11 23:41:04 1994
***************
*** 32,38 ****
   *
   * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
   *
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/ati/driver.c,v 2.12 1993/10/18 12:18:47 dawes Exp $
   */
  
  /*
--- 32,38 ----
   *
   * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
   *
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/ati/driver.c,v 2.14 1993/12/25 14:02:20 dawes Exp $
   */
  
  /*
***************
*** 300,439 ****
  ATIRestore(restore)
  vgaATIPtr restore;
  {
-         int i;
- 	
  	TRACE(("ATIRestore(restore=0x%x)\n", restore));
  
- 	if (vgaIOBase == 0x3B0)
- 		restore->std.MiscOutReg &= 0xFE;
- 	else
- 		restore->std.MiscOutReg |= 0x01;
- 
- 	/* Disable video */
- 	(void) inb(vgaIOBase + 0x0A);	/* reset flip-flop */
- 	outb(0x3C0, 0x00);
- 
  	/* Unlock ATI specials */
  	outw(ATIExtReg, ((inATI(0xb8) & 0xC0) << 8) | 0xb8);
  
- 	/* Load Miscellaneous Output External Register */
- 	outb(0x3C2, restore->std.MiscOutReg);
- 
- 	outw(ATIExtReg, 0x00b2);	/* segment select 0 */
- 
- 	/* For text modes, download Character Generator into Plane 2 */
- 	if (restore->std.FontInfo1 || restore->std.FontInfo2 ||
-             restore->std.TextInfo) {
- 		/*
- 		 * here we switch temporary to 16 color-plane-mode, to simply
- 		 * copy the font-info and saved text
- 		 *
- 		 * BUGALLERT:
- 		 * The vga's segment-select register MUST be set appropriate !
- 		 */
- 
- 		inb(vgaIOBase + 0x0A); /* reset flip-flop */
- 		outb(0x3C0,0x10); outb(0x3C0, 0x01); /* graphics mode */
- 
- #if 0
- 		outw(0x3c3, 0x0001);
- #endif
- 		
- 		if (restore->std.FontInfo1) {
- 			outw(0x3C4, 0x0402);    /* write to plane 2 */
- 			outw(0x3C4, 0x0604);    /* enable plane graphics */
- 			outw(0x3CE, 0x0204);    /* read plane 2 */
- 			outw(0x3CE, 0x0005);    /* write mode 0, read mode 0 */
- 			outw(0x3CE, 0x0506);    /* set graphics */
- 
- 			bcopy(restore->std.FontInfo1, vgaBase, 8192);
- 		}
- 
- 		if (restore->std.FontInfo2) {
- 			outw(0x3C4, 0x0802);	/* write to plane 3 */
- 			outw(0x3C4, 0x0604);	/* enable plane grp */
- 			outw(0x3CE, 0x0304);	/* read plane 3 */
- 			outw(0x3CE, 0x0005);	/* read/write mode 0 */
- 			outw(0x3CE, 0x0506);	/* set graphics */
- 			bcopy(restore->std.FontInfo2, vgaBase, 8192);
- 		}
- 
- 		if (restore->std.TextInfo) {
- 			outw(0x3C4, 0x0202);	/* write to plane 1 */
- 			outw(0x3C4, 0x0604);	/* enable plane grp */
- 			outw(0x3CE, 0x0104);	/* read plane 1 */
- 			outw(0x3CE, 0x0005);	/* read/write mode 0 */
- 			outw(0x3CE, 0x0506);	/* set graphics */
- 			bcopy(restore->std.TextInfo, vgaBase, 4096);
- 
- 			outw(0x3C4, 0x0102);	/* write to plane 0 */
- 			outw(0x3C4, 0x0604);	/* enable plane grp */
- 			outw(0x3CE, 0x0004);	/* read plane 0 */
- 			outw(0x3CE, 0x0005);	/* read/write mode 0 */
- 			outw(0x3CE, 0x0506);	/* set graphics */
- 			bcopy(restore->std.TextInfo + 4096, vgaBase, 4096);
- 		}
- 	}
- 	
- 	/* This sequence is from the "VGA Wonder Programmer's
- 	   Reference Manual."  I assume it is correct :-)
- 	   faith@cs.unc.edu (7Aug92) */
- 
- 	/* Place Sequencer into Reset condition using its Reset Register */
- 	outw(0x3C4, 0x0100);
- 
  	/* Load ATI Extended Registers */
  	outw(ATIExtReg, (restore->ATIReg0 << 8) | 0xb0);
  	outw(ATIExtReg, (restore->ATIReg1 << 8) | 0xb1);
  	outw(ATIExtReg, (restore->ATIReg2 << 8) | 0xb2);
  	outw(ATIExtReg, (restore->ATIReg5 << 8) | 0xb5);
  	outw(ATIExtReg, (restore->ATIReg6 << 8) | 0xb6);
  	outw(ATIExtReg, (restore->ATIRegE << 8) | 0xbe);
! 	outw(ATIExtReg, (restore->ATIReg3 << 8) | 0xb3);
! 	outw(ATIExtReg, (restore->ATIReg8 << 8) | 0xb8);
! 	if (ATIBoard >= ATI_BOARD_PLUS) {
  		outw(ATIExtReg, (restore->ATIReg9 << 8) | 0xb9);
  		outw(ATIExtReg, (restore->ATIRegA6 << 8) | 0xa6);
  		outw(ATIExtReg, (restore->ATIRegA7 << 8) | 0xa7);
  	}
  
! 	/* Load Miscellaneous Output External Register */
! 	outb(0x3C2, restore->std.MiscOutReg);
! 
! 	/* Load Sequence Registers 1 through 4 */
!   	for (i=1; i<5;  i++) outw(0x3C4, (restore->std.Sequencer[i] << 8) | i);
! 
! 	/* Restart Sequencer using Reset Register */
! 	outw(0x3C4, 0x0300);
! 
! 	/* Load all 25 CRT Control Registers */
! 	/* But first, unlock CRTC registers 0 to 7 */
! 	outw(vgaIOBase + 4, ((restore->std.CRTC[0x11] & 0x7F) << 8) | 0x11);
! 	for (i=0; i<25; i++)
! 	      outw(vgaIOBase + 4,(restore->std.CRTC[i] << 8) | i);
! 
! 	/* Reset Attribute Controller address/data flip-flop */
! 	(void) inb(vgaIOBase + 0x0A);
! 
! 	/* Load all 20 Attribute Controller Registers */
! 	for (i=0; i<21; i++) {
! 	   (void) inb(vgaIOBase + 0x0A);
! 	   outb(0x3C0,i);
! 	   outb(0x3C0, restore->std.Attribute[i]);
! 	}
! 
! 	/* Load all 9 Graphics Controller Registers */
! 	for (i=0; i<9; i++) outw(0x3CE, (restore->std.Graphics[i] << 8) | i);
! 
! 	/* Load all 768 DAC Registers */
! 	outb(0x3C8,0x00);
! 	for (i=0; i<768; i++) outb(0x3C9, restore->std.DAC[i]);
! 
! 	/* Reset Attribute Controller address/data flip-flop */
! 	(void) inb(vgaIOBase + 0x0A);
  
! 	/* Turn Attribute Controller on */
! 	outb(0x3C0, 0x20);
  }
  
  /*
--- 300,334 ----
  ATIRestore(restore)
  vgaATIPtr restore;
  {
  	TRACE(("ATIRestore(restore=0x%x)\n", restore));
  
  	/* Unlock ATI specials */
  	outw(ATIExtReg, ((inATI(0xb8) & 0xC0) << 8) | 0xb8);
  
  	/* Load ATI Extended Registers */
  	outw(ATIExtReg, (restore->ATIReg0 << 8) | 0xb0);
  	outw(ATIExtReg, (restore->ATIReg1 << 8) | 0xb1);
  	outw(ATIExtReg, (restore->ATIReg2 << 8) | 0xb2);
+ 	outw(ATIExtReg, (restore->ATIReg3 << 8) | 0xb3);
  	outw(ATIExtReg, (restore->ATIReg5 << 8) | 0xb5);
  	outw(ATIExtReg, (restore->ATIReg6 << 8) | 0xb6);
  	outw(ATIExtReg, (restore->ATIRegE << 8) | 0xbe);
! 
! 	if (ATIBoard == ATI_BOARD_V5)
! 		outw(ATIExtReg, (restore->ATIReg9 << 8) | 0xb9);
! 		
! 	if (ATIBoard >= ATI_BOARD_PLUS)
! 	{
  		outw(ATIExtReg, (restore->ATIReg9 << 8) | 0xb9);
  		outw(ATIExtReg, (restore->ATIRegA6 << 8) | 0xa6);
  		outw(ATIExtReg, (restore->ATIRegA7 << 8) | 0xa7);
  	}
  
! 	/* This one last -- it might lock the special registers (probably will!) */
! 	outw(ATIExtReg, (restore->ATIReg8 << 8) | 0xb8);
  
! 	/* Restore generic parts last */
! 	vgaHWRestore(restore);
  }
  
  /*
***************
*** 452,492 ****
  vgaATIPtr save;
  {
  	unsigned char b2_save,b8_save;
- 	int i;
  
  	TRACE(("ATISave(save=0x%x)\n", save));
  
- 	vgaIOBase = (inb(0x3cc) & 0x01) ? 0x3D0 : 0x3B0;
- 	
- 	/* Disable video */
- 	inb(vgaIOBase + 0x0A); /* reset flip-flop */
- 	outb( 0x3c0, 0x00 );
- 
  	/* Unlock ATI specials */
  	outw(ATIExtReg, (((b8_save = inATI(0xb8)) & 0xC0) << 8) | 0xb8);
  
! 	if (save == NULL) {
! 	   save = (vgaATIPtr)Xcalloc(sizeof(vgaATIRec));
! 	   TRACE(("ATISave: save = 0x%x\n",save));
! 	}
  
  	/*
  	 * now get the fuck'in register
  	 */
- 	save->std.MiscOutReg = inb(0x3CC);
- 
- 
- 	b2_save = inATI(0xb2);
- 	outw(ATIExtReg, 0x00b2);	/* segment select 0 */
  
  	save->ATIReg0 = inATI(0xb0);
  	save->ATIReg1 = inATI(0xb1);
  	save->ATIReg2 = b2_save;
- 	save->ATIReg3 = inATI(0xb3);
  	save->ATIReg5 = inATI(0xb5);
  	save->ATIReg6 = inATI(0xb6);
  	save->ATIReg8 = b8_save;
  	save->ATIRegE = inATI(0xbe);
  	if (ATIBoard >= ATI_BOARD_PLUS) {
  		save->ATIReg9 = inATI(0xb9);
  		save->ATIRegA6 = inATI(0xa6);
--- 347,381 ----
  vgaATIPtr save;
  {
  	unsigned char b2_save,b8_save;
  
  	TRACE(("ATISave(save=0x%x)\n", save));
  
  	/* Unlock ATI specials */
  	outw(ATIExtReg, (((b8_save = inATI(0xb8)) & 0xC0) << 8) | 0xb8);
  
! 	b2_save = inATI(0xb2);
  
+ 	/* Select bank 0 */
+ 	outw(ATIExtReg, 0x00b2);
+ 
+ 	save = (vgaATIPtr) vgaHWSave(save, sizeof(vgaATIRec));
+ 
  	/*
  	 * now get the fuck'in register
  	 */
  
  	save->ATIReg0 = inATI(0xb0);
  	save->ATIReg1 = inATI(0xb1);
  	save->ATIReg2 = b2_save;
  	save->ATIReg5 = inATI(0xb5);
  	save->ATIReg6 = inATI(0xb6);
+ 	save->ATIReg3 = inATI(0xb3);
  	save->ATIReg8 = b8_save;
  	save->ATIRegE = inATI(0xbe);
+ 
+ 	if (ATIBoard == ATI_BOARD_V5)
+ 		save->ATIReg9 = inATI(0xb9);
+ 
  	if (ATIBoard >= ATI_BOARD_PLUS) {
  		save->ATIReg9 = inATI(0xb9);
  		save->ATIRegA6 = inATI(0xa6);
***************
*** 493,584 ****
  		save->ATIRegA7 = inATI(0xa7);
  	}
  
- 	for (i=0; i<25; i++) {
- 	   outb(vgaIOBase + 4,i);
- 	   save->std.CRTC[i] = inb(vgaIOBase + 5);
- 	}
- 	
- 	for (i=0; i<21; i++) {
- 	   inb(vgaIOBase + 0x0A); /* reset flip-flop */
- 	   outb(0x3C0,i);
- 	   save->std.Attribute[i] = inb(0x3C1);
- 	}
- 
- 	for (i=0; i<9;  i++) {
- 	   outb(0x3CE,i); save->std.Graphics[i]  = inb(0x3CF);
- 	}
- 
- 	for (i=0; i<5;  i++) {
- 	   outb(0x3C4,i); save->std.Sequencer[i] = inb(0x3C5);
- 	}
- 	
- 	/*			 
- 	 * save the colorlookuptable 
- 	 */
- 	outb(0x3C6,0xFF);
- 	outb(0x3C7,0x00);
- 	for (i=0; i<768; i++) save->std.DAC[i] = inb(0x3C9); 
- 
- 	/*
- 	 * get the character set of the first non-graphics application
- 	 */
- 	if (((save->std.Attribute[0x10] & 0x01) == 0) &&
- 	    (save->std.FontInfo1 == NULL)) {
- 	   /*
- 	    * Here we switch temporary to 16 color-plane-mode, to simply
- 	    * copy the font-info
- 	    *
- 	    * BUGALLERT: The vga's segment-select register
- 	    *            MUST be set appropriate !
- 	    */
- 	   save->std.FontInfo1 = (pointer)xalloc(8192);
- 	   inb(vgaIOBase + 0x0A); /* reset flip-flop */
- 	   outb(0x3C0,0x10); outb(0x3C0, 0x01); /* graphics mode */
- 	   outw(0x3C4, 0x0402);    /* write to plane 2 */
- 	   outw(0x3C4, 0x0604);    /* enable plane graphics */
- 	   outw(0x3CE, 0x0204);    /* read plane 2 */
- 	   outw(0x3CE, 0x0005);    /* write mode 0, read mode 0 */
- 	   outw(0x3CE, 0x0506);    /* set graphics */
- 
- 	   bcopy(vgaBase, save->std.FontInfo1, 8192);
- 
- #ifndef HAS_USL_VTS
- 	   if (save->std.FontInfo2 == NULL) {
- 		save->std.FontInfo2 = (pointer)xalloc(8192);
- 		/* plane 3 */
- 		outw(0x3C4, 0x0802);
- 		outw(0x3C4, 0x0604);
- 		outw(0x3CE, 0x0304);
- 		outw(0x3CE, 0x0005);
- 		outw(0x3CE, 0x0506);
- 		bcopy(vgaBase, save->std.FontInfo2, 8192);
- 	   }
- 
- 	   if (save->std.TextInfo == NULL) {
- 		save->std.TextInfo = (pointer)xalloc(8192);
- 		/* plane 1 */
- 		outw(0x3C4, 0x0202);
- 		outw(0x3C4, 0x0604);
- 		outw(0x3CE, 0x0104);
- 		outw(0x3CE, 0x0005);
- 		outw(0x3CE, 0x0506);
- 		bcopy(vgaBase, save->std.TextInfo, 4096);
- 		
- 		/* plane 0 */
- 		outw(0x3C4, 0x0102);
- 		outw(0x3C4, 0x0604);
- 		outw(0x3CE, 0x0004);
- 		outw(0x3CE, 0x0005);
- 		outw(0x3CE, 0x0506);
- 		bcopy(vgaBase, save->std.TextInfo + 4096, 4096);
- 	   }
- #endif /* HAS_USL_VTS */
- 	}
- 
- 	/* Enable video */
- 	inb(vgaIOBase + 0x0A); /* reset flip-flop */
- 	outb( 0x3c0, 0x20 );
- 
  	return ((void *) save);
  }
  
--- 382,387 ----
***************
*** 718,725 ****
  		0          | V5_B9_BIT1 | CLOCK_2,               /*75*/
  		0          | V5_B9_BIT1 | CLOCK_3                /*65*/
  	};
! 	int i,fd;
! 	unsigned char byte_42,byte_43,byte_44;
  	unsigned char (*extregTabPtr)[3];
  	unsigned char *clockTabPtr;
  	vgaATIPtr new;	/* was: #define new ((vgaATIPtr)vgaNewVideoState)
--- 521,527 ----
  		0          | V5_B9_BIT1 | CLOCK_2,               /*75*/
  		0          | V5_B9_BIT1 | CLOCK_3                /*65*/
  	};
! 	int i;
  	unsigned char (*extregTabPtr)[3];
  	unsigned char *clockTabPtr;
  	vgaATIPtr new;	/* was: #define new ((vgaATIPtr)vgaNewVideoState)
***************
*** 833,838 ****
--- 635,641 ----
  	new->std.Graphics[5] = 0x00;
  	new->std.Attribute[16] = 0x01;
  
+ #if 0
  	/*
  	 * Experiment. It looks like MiscOutReg is a little different for
  	 * the high resolution modes. I've duplicated the code from
***************
*** 839,857 ****
  	 * vgaHWInit() because it looks like they have different handling
  	 * if the syncs are explicitly mentioned, and I want to preserve
  	 * this.
  
  	if ((mode->Flags & (V_PHSYNC | V_NHSYNC))
  		&& (mode->Flags & (V_PVSYNC | V_NVSYNC)))
  	{
! 		new->MiscOutReg = 0x23;
! 		if (mode->Flags & V_NHSYNC) new->MiscOutReg |= 0x40;
  		if (mode->Flags & V_NVSYNC) new->MiscOutReg |= 0x80;
  	} else {
! 		if      (mode->VDisplay < 400) new->MiscOutReg = 0xA3;
! 		else if (mode->VDisplay < 480) new->MiscOutReg = 0x63;
! 		else if (mode->VDisplay < 768) new->MiscOutReg = 0xE3;
! 		else                           new->MiscOutReg = 0xE3;
  	}
  
  	/*
  	 * Get the extended register values ...
--- 642,662 ----
  	 * vgaHWInit() because it looks like they have different handling
  	 * if the syncs are explicitly mentioned, and I want to preserve
  	 * this.
+ 	 */
  
  	if ((mode->Flags & (V_PHSYNC | V_NHSYNC))
  		&& (mode->Flags & (V_PVSYNC | V_NVSYNC)))
  	{
! 		new->std.MiscOutReg = 0x23;
! 		if (mode->Flags & V_NHSYNC) new->std.MiscOutReg |= 0x40;
  		if (mode->Flags & V_NVSYNC) new->MiscOutReg |= 0x80;
  	} else {
! 		if      (mode->VDisplay < 400) new->std.MiscOutReg = 0xA3;
! 		else if (mode->VDisplay < 480) new->std.MiscOutReg = 0x63;
! 		else if (mode->VDisplay < 768) new->std.MiscOutReg = 0xE3;
! 		else                           new->std.MiscOutReg = 0xE3;
  	}
+ #endif
  
  	/*
  	 * Get the extended register values ...
***************
*** 952,960 ****
  }
  
  static int 
! inATI(index)
  {
! 	outb(ATIExtReg, index);
  	return inb(ATIExtReg + 1);
  }
  
--- 757,766 ----
  }
  
  static int 
! inATI(reg_index)
!      int reg_index;
  {
! 	outb(ATIExtReg, reg_index);
  	return inb(ATIExtReg + 1);
  }
  
***************
*** 1003,1009 ****
     char bios_signature[SIGNATURE_LENGTH];
     char bios_data[BIOS_DATA_SIZE];
     unsigned ports[2];
-    int  fd;
  	 
     TRACE(("ATIProbe()\n"));
  
--- 809,814 ----
***************
*** 1229,1236 ****
  ATIEnterLeave( enter )
     Bool enter;
  {
-   unsigned char temp;
- 
    TRACE(("ATIEnterLeave(%d)\n",enter));
  
    if (enter)
--- 1034,1039 ----
diff -c mit/server/ddx/x386/vga256/drivers/cirrus/Imakefile:2.2 mit/server/ddx/x386/vga256/drivers/cirrus/Imakefile:2.5
*** mit/server/ddx/x386/vga256/drivers/cirrus/Imakefile:2.2	Fri Mar 11 23:41:07 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/Imakefile	Fri Mar 11 23:41:07 1994
***************
*** 1,11 ****
! XCOMM $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/Imakefile,v 2.2 1993/09/21 15:24:23 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:59:27 gildea Exp $
  #include <Server.tmpl>
  
! SRCS = cir_driver.c cir_fill.c cir_blt.c cir_bltC.c cir_im.c cir_bank.s
  
- OBJS = cir_driver.o cir_fill.o cir_blt.o cir_bltC.o cir_im.o cir_bank.o
- 
  #if X386LinkKit
  INCLUDES = -I. -I../../../include -I../..
  #else
--- 1,15 ----
! XCOMM $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/Imakefile,v 2.5 1994/03/06 06:46:14 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 22:59:27 gildea Exp $
  #include <Server.tmpl>
  
! SRCS = cir_driver.c cir_fill.c cir_blt.c cir_bltC.c cir_im.c cir_bank.s \
!        cir_imblt.s cir_colexp.c cir_fillst.c cir_teblt8.c \
!        cir_fillrct.c cir_blitter.c cir_textblt.s
! 
! OBJS = cir_driver.o cir_fill.o cir_blt.o cir_bltC.o cir_im.o cir_bank.o \
!        cir_imblt.o cir_colexp.o cir_fillst.o cir_teblt8.o \
!        cir_fillrct.o cir_blitter.o cir_textblt.o
  
  #if X386LinkKit
  INCLUDES = -I. -I../../../include -I../..
  #else
***************
*** 12,18 ****
  INCLUDES = -I. -I../../../common -I../../../common_hw -I../../../os-support \
             -I../../../../mfb -I../../../../mi -I../../../../../include \
             -I../../../../cfb -I../../cfb.banked -I../../vga \
! 	   -I$(SERVERSRC)/include -I$(INCLUDESRC)
  #endif
  
  NormalLibraryObjectRule()
--- 16,22 ----
  INCLUDES = -I. -I../../../common -I../../../common_hw -I../../../os-support \
             -I../../../../mfb -I../../../../mi -I../../../../../include \
             -I../../../../cfb -I../../cfb.banked -I../../vga \
!            -I$(FONTSRC)/include -I$(SERVERSRC)/include -I$(INCLUDESRC)
  #endif
  
  NormalLibraryObjectRule()
***************
*** 27,32 ****
--- 31,45 ----
  InstallLinkKitNonExecFile(cir_im.c,$(LINKKITDIR)/drivers/vga256/cirrus)
  InstallLinkKitNonExecFile(cir_blt.c,$(LINKKITDIR)/drivers/vga256/cirrus)
  InstallLinkKitNonExecFile(cir_bltC.c,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_imblt.s,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_textblt.s,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_colexp.c,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_fillst.c,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_teblt8.c,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_fillrct.c,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_blitter.c,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_blitter.h,$(LINKKITDIR)/drivers/vga256/cirrus)
+ InstallLinkKitNonExecFile(cir_inline.h,$(LINKKITDIR)/drivers/vga256/cirrus)
  InstallLinkKitNonExecFile(Imakefile,$(LINKKITDIR)/drivers/vga256/cirrus)
  
  DependTarget()
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_blitter.c:2.2
*** /dev/null	Fri Mar 11 23:41:07 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_blitter.c	Fri Mar 11 23:41:08 1994
***************
*** 0 ****
--- 1,394 ----
+ /*
+  *
+  * Copyright 1994 by H. Hanemaayer, Utrecht, The Netherlands
+  *
+  * 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 H. Hanemaayer not be used in
+  * advertising or publicity pertaining to distribution of the software without
+  * specific, written prior permission.  H. Hanemaayer makes no representations
+  * about the suitability of this software for any purpose.  It is provided
+  * "as is" without express or implied warranty.
+  *
+  * H. HANEMAAYER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+  * EVENT SHALL H. HANEMAAYER 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.
+  *
+  * Author:  H. Hanemaayer, <hhanemaa@cs.ruu.nl>
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_blitter.c,v 2.2 1994/03/01 09:57:06 dawes Exp $ */
+ 
+ /*
+  * This file contains all low-level functions that use the BitBLT engine
+  * on the 5426/5428/5434 (except for those that involve system memory,
+  * they are in cir_im.c).
+  */
+  
+ 
+ #include "vga.h"	/* For vgaBase. */
+ #include "compiler.h"
+ 
+ #include "cir_driver.h"
+ #include "cir_blitter.h"
+ 
+ 
+ /* Cirrus raster operations. */
+ 
+ int cirrus_rop[16] = {
+ 	CROP_0,			/* GXclear */
+ 	CROP_AND,		/* GXand */
+ 	CROP_SRC_AND_NOT_DST,	/* GXandReverse */
+ 	CROP_SRC,		/* GXcopy */
+ 	CROP_NOT_SRC_AND_DST,	/* GXandInverted */
+ 	CROP_DST,		/* GXnoop */
+ 	CROP_XOR,		/* GXxor */
+ 	CROP_OR,		/* GXor */
+ 	CROP_NOR,		/* GXnor */
+ 	CROP_XNOR,		/* GXequiv */
+ 	CROP_NOT_DST,		/* GXinvert */
+ 	CROP_SRC_OR_NOT_DST,	/* GXorReverse */
+ 	CROP_NOT_SRC,		/* GXcopyInverted */
+ 	CROP_NOT_SRC_OR_DST,	/* GXorInverted */
+ 	CROP_NAND,		/* GXnand */
+ 	CROP_1			/* GXset */
+ };
+ 
+ 
+ /*
+  * 8x8 pattern fill with color expanded pattern.
+  *
+  * patternword1 contains the first 32 pixels (first pixel in LSByte, MSBit),
+  * patternword2 the second. 
+  */
+  
+ void CirrusBLTColorExpand8x8PatternFill(dstAddr, fgcolor, bgcolor,
+ fillWidth, fillHeight, dstPitch, rop, patternword1, patternword2)
+      unsigned int dstAddr;
+      int fgcolor, bgcolor;
+      int fillHeight, fillWidth, dstPitch;
+      int rop;
+      unsigned long patternword1, patternword2;
+ {
+   unsigned int srcAddr;
+   int i;
+   pointer pDst;
+   extern int CirrusMemTop;
+ 
+   if (!HAVE543X() && fillHeight > 1024) {
+       /* Split into two for 5426 & 5428. */
+       CirrusBLTColorExpand8x8PatternFill(dstAddr, fgcolor, bgcolor,
+           fillWidth, 1024, dstPitch, rop, patternword1, patternword2);
+       CirrusBLTColorExpand8x8PatternFill(dstAddr + dstPitch * 1024,
+           fgcolor, bgcolor, fillWidth, fillHeight - 1024, dstPitch, rop,
+           patternword1, patternword2);
+       return;
+   }
+ 
+   /* NOTE:
+    * I tried System memory source pattern fill, it's not explicitly
+    * disallowed (nor documented) in the databook, but it doesn't work. 
+    */
+ 
+   /* Pattern fill with color expanded video memory source. */
+ 
+   /* Write 8 byte monochrome pattern. */
+   /* Because of 16K bank granularity and 32K window, we don't have to */
+   /* check for bank boundaries. */
+   srcAddr = CirrusMemTop;
+   setwritebank(CirrusMemTop >> 14);
+   *(unsigned long *)(vgaBase + 0x8000 + (srcAddr & 0x3fff)) =
+   	patternword1;
+   *(unsigned long *)(vgaBase + 0x8000 + ((srcAddr & 0x3fff) + 4)) =
+   	patternword2;
+ 
+   SETDESTADDR(dstAddr);
+   SETSRCADDR(srcAddr);
+   SETDESTPITCH(dstPitch);
+   SETWIDTH(fillWidth);
+   SETHEIGHT(fillHeight);
+ 
+   /* 8x8 Pattern Copy, screen to screen blt, forwards, color expand. */
+   SETBLTMODE(PATTERNCOPY | COLOREXPAND);
+   SETROP(rop);
+   SETFOREGROUNDCOLOR(fgcolor);
+   SETBACKGROUNDCOLOR(bgcolor);
+ 
+   /* Do it. */
+   STARTBLT();
+ 
+   WAITUNTILFINISHED();
+ 
+   SETFOREGROUNDCOLOR(0);
+ }
+ 
+ 
+ /*
+  * 8x8 pattern fill.
+  *
+  * Regular 8x8 byte-per-pixel pattern.
+  * 
+  */
+ 
+ void CirrusBLT8x8PatternFill(dstAddr, w, h, pattern, destpitch, rop)
+      unsigned int dstAddr;
+      int w, h, destpitch;
+      int rop;
+      void *pattern;
+ {
+   unsigned int srcAddr;
+   int i;
+   pointer pDst;
+   extern int CirrusMemTop;
+ 
+   if (!HAVE543X() && h > 1024) {
+       /* Split into two for 5426 & 5428. */
+       CirrusBLT8x8PatternFill(dstAddr, w, 1024, pattern, destpitch, rop);
+       CirrusBLT8x8PatternFill(dstAddr + destpitch * 1024, w, h - 1024,
+           pattern, destpitch, rop);
+       return;
+   }
+ 
+   /* Pattern fill with video memory source. */
+ 
+   /* Write 64 byte pattern. */
+   /* Because of 16K bank granularity and 32K window, we don't have to */
+   /* check for bank boundaries. */
+   srcAddr = CirrusMemTop;
+   setwritebank(srcAddr >> 14);
+   memcpy(vgaBase + 0x8000 + (srcAddr & 0x3fff), pattern, 64);
+ 
+   SETDESTADDR(dstAddr);
+   SETSRCADDR(srcAddr);
+   SETDESTPITCH(destpitch);
+   SETWIDTH(w);
+   SETHEIGHT(h);
+ 
+   /* 8x8 Pattern Copy, screen to screen blt, forwards. */
+   SETBLTMODE(PATTERNCOPY);
+   SETROP(rop);
+ 
+   /* Do it. */
+   STARTBLT();
+ 
+   WAITUNTILFINISHED();
+ }
+ 
+ 
+ /*
+  * 16x16 pattern fill.
+  *
+  * Uses two 16x8 byte-per-pixel pattern fills (meant for 8x8 16-bit pixel
+  * fill), vertically interleaved.
+  * 
+  */
+ 
+ void CirrusBLT16x16PatternFill(dstAddr, w, h, pattern, destpitch, rop)
+      unsigned int dstAddr;
+      int w, h, destpitch;
+      int rop;
+      unsigned char *pattern;
+ {
+   unsigned int srcAddr;
+   int i;
+   pointer pDst;
+   int blith, blitpitch;
+   extern int CirrusMemTop;
+ 
+   if (!HAVE543X() && h > 1024) {
+       /* Split into two for 5426 & 5428. */
+       CirrusBLT16x16PatternFill(dstAddr, w, 1024, pattern, destpitch, rop);
+       CirrusBLT16x16PatternFill(dstAddr + destpitch * 1024, w, h - 1024,
+           pattern, destpitch, rop);
+       return;
+   }
+ 
+   /* Pattern fill with video memory source. */
+ 
+   /* Write 128 byte pattern (even lines). */
+   /* Because of 16K bank granularity and 32K window, we don't have to */
+   /* check for bank boundaries. */
+   srcAddr = CirrusMemTop;
+   setwritebank(srcAddr >> 14);
+   for (i = 0; i < 8; i++)
+       memcpy(vgaBase + 0x8000 + (srcAddr & 0x3fff) + i * 16,
+           pattern + i * 32, 16);
+ 
+   blitpitch = destpitch * 2;
+   blith = (h / 2) + (h & 1);
+ 
+   SETDESTADDR(dstAddr);
+   SETSRCADDR(srcAddr);
+   SETDESTPITCH(blitpitch);
+   SETWIDTH(w);
+   SETHEIGHT(blith);
+ 
+   /* 8x8 Pattern Copy, 16-bit pixels, screen to screen blt, forwards. */
+   SETBLTMODE(PATTERNCOPY | PIXELWIDTH16);
+   SETROP(rop);
+ 
+   /* Do it. */
+   STARTBLT();
+ 
+   WAITUNTILFINISHED();
+ 
+   /* Now do uneven lines. */
+   /* Write pattern. */
+   for (i = 0; i < 8; i++)
+ 	  memcpy(vgaBase + 0x8000 + (srcAddr & 0x3fff) + i * 16,
+ 	  	pattern + i * 32 + 16, 16);
+ 
+   dstAddr += destpitch;
+ /*  blitpitch = destpitch * 2; */
+   blith = (h / 2);
+ 
+   SETDESTADDR(dstAddr);
+   SETSRCADDR(srcAddr);
+ /* SETDESTPITCH(blitpitch); */
+   SETWIDTH(w);
+   SETHEIGHT(blith);
+ 
+   /* 8x8 Pattern Copy, 16-bit pixels, screen to screen blt, forwards. */
+ /*  SETBLTMODE(PATTERNCOPY | PIXELWIDTH); */
+ /*  SETROP(rop); */
+ 
+   STARTBLT();
+ 
+   WAITUNTILFINISHED();
+ }
+ 
+ #if 0
+ 
+ /*
+  * 32x32 pattern fill for 5434.
+  *
+  * Uses four 32x8 byte-per-pixel pattern fills (meant for 8x8 32-bit pixel
+  * fill), vertically interleaved.
+  * This is speculative, and untested. I haven't checked with any official
+  * register docs.
+  *
+  * Something like this would also work on the 5426/28 (by filling vertical
+  * bands 16 pixels wide, 4-way interleaved) if the virtual screen width is
+  * less than 1024 (i.e. rarely).
+  */
+ 
+ void CirrusBLT32x32PatternFill(dstAddr, w, h, pattern, destpitch, rop)
+      unsigned int dstAddr;
+      int w, h, destpitch;
+      int rop;
+      void *pattern;
+ {
+   unsigned int srcAddr;
+   int i, k;
+   int blith, blitpitch;
+   extern int CirrusMemTop;
+ 
+   /* No need to split into two for 5434 (handles heights up to 2048). */
+ 
+   /* Pattern fill with video memory source. */
+ 
+   /* Set up write bank for writing pattern. */
+   srcAddr = CirrusMemTop;
+   setwritebank(srcAddr >> 14);
+ 
+   /* Set up BLT parameters that remain constant. */
+   blitpitch = destpitch * 4;	/* Four-way interleaving. */
+   SETDESTPITCH(blitpitch);
+   /* 8x8 Pattern Copy, 32-bit pixels, screen to screen blt, forwards. */
+   SETBLTMODE(PATTERNCOPY | PIXELWIDTH32);
+   SETROP(rop);
+ 
+   for (k = 0; k < 4; k++) {
+       /* Do the lines for which [index % 4 == k]. */
+       /* Write 32x8 pattern. */
+       for (i = 0; i < 8; i++)
+           memcpy(vgaBase + 0x8000 + (srcAddr & 0x3fff) + i * 32,
+ 	  	pattern + i * 32 * 4 + 32 * k, 32);
+       blith = h / 4;
+       if (h & 3 > k)
+   	  blith++;
+       SETDESTADDR(dstAddr);
+       SETSRCADDR(srcAddr);
+       SETWIDTH(w);
+       SETHEIGHT(blith);
+       STARTBLT();
+       WAITUNTILFINISHED();
+ 
+       dstAddr += destpitch;
+   }
+ }
+ 
+ #endif
+ 
+ 
+ /*
+  * BitBLT. Direction can be forwards or backwards. Can be modified to
+  * support special rops.
+  */
+ 
+ void CirrusBLTBitBlt(dstAddr, srcAddr, dstPitch, srcPitch, w, h, dir)
+      unsigned int dstAddr, srcAddr;
+      int dstPitch, srcPitch;
+      int w, h;
+      int dir;			/* >0, increase adrresses, <0, decrease */
+ {
+   if ((!HAVE543X()) && h > 1024) {
+      /* Split into two. */
+      if (dir > 0) {
+          CirrusBLTBitBlt(dstAddr, srcAddr, dstPitch, srcPitch, w, 1024, dir);
+          CirrusBLTBitBlt(dstAddr + dstPitch * 1024, srcAddr + srcPitch * 1024,
+              dstPitch, srcPitch, w, h - 1024, dir);
+      }
+      else {
+          CirrusBLTBitBlt(dstAddr, srcAddr, dstPitch, srcPitch, w, 1024, dir);
+          CirrusBLTBitBlt(dstAddr - dstPitch * 1024, srcAddr - srcPitch * 1024,
+              dstPitch, srcPitch, w, h - 1024, dir);
+      }
+      return;
+   }
+ 
+   SETSRCADDR(srcAddr);
+   SETSRCPITCH(srcPitch);
+   SETDESTADDR(dstAddr);
+   SETDESTPITCH(dstPitch);
+   SETWIDTH(w);
+   SETHEIGHT(h);
+ 
+   if (dir > 0) {
+       SETBLTMODE(FORWARDS);
+   }
+   else {
+       SETBLTMODE(BACKWARDS);
+   }
+ 
+   SETROP(CROP_SRC);
+ 
+   STARTBLT();
+   WAITUNTILFINISHED();
+ }
+ 
+ 
+ void CirrusBLTWaitUntilFinished() {
+   int count, timeout;
+   count = 0;
+   timeout = 0;
+   outb(0x3CE, 0x31);
+   while (inb(0x3CF) & 1) {
+     count++;
+     if (count == 10000000) {
+     	ErrorF("Cirrus: BitBLT engine time-out.\n");
+     	*(unsigned long *)vgaBase = 0;
+     	count = 9990000;
+     	timeout++;
+     	if (timeout == 8)
+     		return;
+     }
+   }
+ }
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_blitter.h:2.1
*** /dev/null	Fri Mar 11 23:41:08 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_blitter.h	Fri Mar 11 23:41:08 1994
***************
*** 0 ****
--- 1,62 ----
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_blitter.h,v 2.1 1994/03/07 14:02:12 dawes Exp $ */
+ 
+ /* Definitions for BitBLT engine communication. */
+ 
+ /* BitBLT modes. */
+ 
+ #define FORWARDS		0x00
+ #define BACKWARDS		0x01
+ #define SYSTEMDEST		0x02
+ #define SYSTEMSRC		0x04
+ #define TRANSPARENCYCOMPARE	0x08
+ #define PIXELWIDTH16		0x10
+ #define PIXELWIDTH32		0x30	/* Speculative, 543x only. */
+ #define PATTERNCOPY		0x40
+ #define COLOREXPAND		0x80
+ 
+ 
+ /* Address: the 5426 adresses 2MBytes, the 5434 can address 4MB. */
+ 
+ #define SETDESTADDR(dstAddr) \
+   outw (0x3CE, (((dstAddr) & 0x000000FF) << 8) | 0x28); \
+   outw (0x3CE, (((dstAddr) & 0x0000FF00)) | 0x29); \
+   outw (0x3CE, (((dstAddr) & 0x003F0000) >> 8) | 0x2A);
+ 
+ #define SETSRCADDR(srcAddr) \
+   outw (0x3CE, (((srcAddr) & 0x000000FF) << 8) | 0x2C); \
+   outw (0x3CE, (((srcAddr) & 0x0000FF00)) | 0x2D); \
+   outw (0x3CE, (((srcAddr) & 0x003F0000) >> 8) | 0x2E);
+ 
+ /* Pitch: the 5426 goes up to 4095, the 5434 can do 8191. */
+ 
+ #define SETDESTPITCH(dstPitch) \
+   outw (0x3CE, (((dstPitch) & 0x000000FF) << 8) | 0x24); \
+   outw (0x3CE, (((dstPitch) & 0x00001F00)) | 0x25);
+ 
+ #define SETSRCPITCH(srcPitch) \
+   outw (0x3CE, (((srcPitch) & 0x000000FF) << 8) | 0x26); \
+   outw (0x3CE, (((srcPitch) & 0x00001F00)) | 0x27);
+ 
+ /* Width: the 5426 goes up to 2048, the 5434 can do 8192. */
+ 
+ #define SETWIDTH(fillWidth) \
+   outw (0x3CE, ((((fillWidth) - 1) & 0x000000FF) << 8) | 0x20); \
+   outw (0x3CE, ((((fillWidth) - 1) & 0x00001F00)) | 0x21);
+ 
+ /* Height: the 5426 goes up to 1024, the 5434 can do 2048. */
+ 
+ #define SETHEIGHT(fillHeight) \
+   outw (0x3CE, ((((fillHeight) - 1) & 0x000000FF) << 8) | 0x22); \
+   outw (0x3CE, (((fillHeight) - 1) & 0x00000700) | 0x23);
+ 
+ #define SETBLTMODE(m) outw(0x3CE, ((m) << 8) | 0x30);
+ 
+ #define SETTRANSPARENCYCOLOR(c) outw(0x3ce, ((c) << 8) | 0x34);
+ 
+ #define SETROP(rop) \
+   outw (0x3CE, ((rop) << 8) | 0x32);
+ 
+ #define STARTBLT() \
+   outw (0x3CE, (0x02 << 8) | 0x31);
+ 
+ #define WAITUNTILFINISHED() CirrusBLTWaitUntilFinished()  
diff -c mit/server/ddx/x386/vga256/drivers/cirrus/cir_blt.c:2.0 mit/server/ddx/x386/vga256/drivers/cirrus/cir_blt.c:2.5
*** mit/server/ddx/x386/vga256/drivers/cirrus/cir_blt.c:2.0	Fri Mar 11 23:41:09 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_blt.c	Fri Mar 11 23:41:09 1994
***************
*** 1,43 ****
  /*
!    Copyright 1989 by the Massachusetts Institute of Technology
! 
!    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 M.I.T. not be used in
!    advertising or publicity pertaining to distribution of the software
!    without specific, written prior permission.  M.I.T. makes no
!    representations about the suitability of this software for any
!    purpose.  It is provided "as is" without express or implied warranty.
! 
!    Author: Keith Packard
! 
!    Modified for the 8514/A by Kevin E. Martin (martin@cs.unc.edu)
! 
!    KEVIN E. MARTIN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
!    INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
!    EVENT SHALL KEVIN E. MARTIN 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: mit/server/ddx/x386/vga256/drivers/cirrus/cir_blt.c,v 2.0 1993/09/21 15:24:25 dawes Exp $ */
! /* $XConsortium: cfbbitblt.c,v 5.39 91/05/24 16:33:25 keith Exp $ */
! 
! /*
!  * Modified by Amancio Hasty and Jon Tombs
!  * Hacked for Cirrus by Bill Reynolds
   *
   * Reworked by: Simon P. Cooper, <scooper@vizlab.rutgers.edu>
   *
!  * Id: cir_blt.c,v 0.7 1993/09/16 01:07:25 scooper Exp
   */
  
  #include "X.h"
  #include "Xmd.h"
  #include "Xproto.h"
  #include "gcstruct.h"
--- 1,40 ----
  /*
!  *
!  * Copyright 1993 by Bill Reynolds, Santa Fe, New Mexico
!  *
!  * 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 Bill Reynolds not be used in
!  * advertising or publicity pertaining to distribution of the software without
!  * specific, written prior permission.  Bill Reynolds makes no representations
!  * about the suitability of this software for any purpose.  It is provided
!  * "as is" without express or implied warranty.
!  *
!  * BILL REYNOLDS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
!  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
!  * EVENT SHALL BILL REYNOLDS 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.
   *
+  * Author:  Bill Reynolds, bill@goshawk.lanl.gov
+  *
   * Reworked by: Simon P. Cooper, <scooper@vizlab.rutgers.edu>
+  * Modifications: Harm Hanemaayer <hhanemaa@cs.ruu.nl>
   *
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_blt.c,v 2.5 1994/03/06 15:19:55 dawes Exp $
!  * Id: cir_im.c,v 0.7 1993/09/16 01:07:25 scooper Exp
   */
  
+ 
+ 
+ #include "misc.h"
+ #include "x386.h"
  #include "X.h"
+ #include "Xos.h"
  #include "Xmd.h"
  #include "Xproto.h"
  #include "gcstruct.h"
***************
*** 48,617 ****
  #include "cfb.h"
  #include "cfbmskbits.h"
  #include "cfb8bit.h"
- #include "fastblt.h"
- #include "compiler.h"
  
! #include "misc.h"
! #include "x386.h"
  #include "vgaBank.h"
  
  extern pointer vgaBase;
- void CirrusFindOrdering ();
- void CirrusImageRead ();
- void CirrusImageWrite ();
- 
- RegionPtr
- CirrusCopyArea (pSrcDrawable, pDstDrawable,
- 		pGC, srcx, srcy, width, height, dstx, dsty)
-      register DrawablePtr pSrcDrawable;
-      register DrawablePtr pDstDrawable;
-      GC *pGC;
-      int srcx, srcy;
-      int width, height;
-      int dstx, dsty;
- {
-   RegionPtr prgnSrcClip;	/* may be a new region, or just a copy */
-   Bool freeSrcClip = FALSE;
  
-   RegionPtr prgnExposed;
-   RegionRec rgnDst;
-   register BoxPtr pbox;
-   int i;
-   register int dx;
-   register int dy;
-   xRectangle origSource;
-   DDXPointRec origDest;
-   int numRects;
-   BoxRec fastBox;
-   int fastClip = 0;		/* for fast clipping with pixmap source */
-   int fastExpose = 0;		/* for fast exposures with pixmap source */
-   int xdir, ydir;
-   xdir = 1, ydir = 1;
- 
- 
-   origSource.x = srcx;
-   origSource.y = srcy;
-   origSource.width = width;
-   origSource.height = height;
-   origDest.x = dstx;
-   origDest.y = dsty;
  
!   if ((pSrcDrawable != pDstDrawable) &&
!       pSrcDrawable->pScreen->SourceValidate)
!     {
!       (*pSrcDrawable->pScreen->SourceValidate) (pSrcDrawable, srcx, srcy, width, height);
!     }
  
-   if (pGC->alu != GXcopy || (pGC->planemask & PMSK) != PMSK)
-     {
-       return cfbCopyArea (pSrcDrawable, pDstDrawable,
- 			  pGC, srcx, srcy, width, height, dstx, dsty);
-     }
  
!   srcx += pSrcDrawable->x;
!   srcy += pSrcDrawable->y;
  
!   /* clip the source */
  
!   if (pSrcDrawable->type == DRAWABLE_PIXMAP)
!     {
!       if ((pSrcDrawable == pDstDrawable) &&
! 	  (pGC->clientClipType == CT_NONE))
! 	{
! 	  prgnSrcClip = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
! 	}
!       else
! 	{
! 	  fastClip = 1;
! 	}
!     }
!   else
!     {
!       if (pGC->subWindowMode == IncludeInferiors)
  	{
! 	  if (!((WindowPtr) pSrcDrawable)->parent)
! 	    {
! 	      /*
! 	         * special case bitblt from root window in
! 	         * IncludeInferiors mode; just like from a pixmap
! 	       */
! 	      fastClip = 1;
! 	    }
! 	  else if ((pSrcDrawable == pDstDrawable) &&
! 		   (pGC->clientClipType == CT_NONE))
  	    {
! 	      prgnSrcClip = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
  	    }
  	  else
  	    {
! 	      prgnSrcClip = NotClippedByChildren ((WindowPtr) pSrcDrawable);
! 	      freeSrcClip = TRUE;
  	    }
  	}
        else
! 	{
! 	  prgnSrcClip = &((WindowPtr) pSrcDrawable)->clipList;
! 	}
!     }
! 
!   fastBox.x1 = srcx;
!   fastBox.y1 = srcy;
!   fastBox.x2 = srcx + width;
!   fastBox.y2 = srcy + height;
! 
!   /* Don't create a source region if we are doing a fast clip */
!   if (fastClip)
!     {
! 
!       fastExpose = 1;
!       /*
!          * clip the source; if regions extend beyond the source size,
!          * make sure exposure events get sent
!        */
!       if (fastBox.x1 < pSrcDrawable->x)
! 	{
! 	  fastBox.x1 = pSrcDrawable->x;
! 	  fastExpose = 0;
! 	}
!       if (fastBox.y1 < pSrcDrawable->y)
! 	{
! 	  fastBox.y1 = pSrcDrawable->y;
! 	  fastExpose = 0;
! 	}
!       if (fastBox.x2 > pSrcDrawable->x + (int) pSrcDrawable->width)
! 	{
! 	  fastBox.x2 = pSrcDrawable->x + (int) pSrcDrawable->width;
! 	  fastExpose = 0;
! 	}
!       if (fastBox.y2 > pSrcDrawable->y + (int) pSrcDrawable->height)
! 	{
! 	  fastBox.y2 = pSrcDrawable->y + (int) pSrcDrawable->height;
! 	  fastExpose = 0;
! 	}
!     }
!   else
!     {
!       (*pGC->pScreen->RegionInit) (&rgnDst, &fastBox, 1);
!       (*pGC->pScreen->Intersect) (&rgnDst, &rgnDst, prgnSrcClip);
!     }
! 
!   dstx += pDstDrawable->x;
!   dsty += pDstDrawable->y;
! 
!   if (pDstDrawable->type == DRAWABLE_WINDOW)
!     {
!       if (!((WindowPtr) pDstDrawable)->realized)
! 	{
! 	  if (!fastClip)
! 	    (*pGC->pScreen->RegionUninit) (&rgnDst);
! 	  if (freeSrcClip)
! 	    (*pGC->pScreen->RegionDestroy) (prgnSrcClip);
! 	  return NULL;
! 	}
!     }
! 
!   dx = srcx - dstx;
!   dy = srcy - dsty;
! 
! 
! 
!   /* Translate and clip the dst to the destination composite clip */
!   if (fastClip)
!     {
!       RegionPtr cclip;
! 
!       /* Translate the region directly */
!       fastBox.x1 -= dx;
!       fastBox.x2 -= dx;
!       fastBox.y1 -= dy;
!       fastBox.y2 -= dy;
! 
!       /* If the destination composite clip is one rectangle we can
!          do the clip directly.  Otherwise we have to create a full
!          blown region and call intersect */
! 
!       /* XXX because CopyPlane uses this routine for 8-to-1 bit
!          * copies, this next line *must* also correctly fetch the
!          * composite clip from an mfb gc
!        */
! 
!       cclip = ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
!       if (REGION_NUM_RECTS (cclip) == 1)
! 	{
! 	  BoxPtr pBox = REGION_RECTS (cclip);
! 
! 	  if (fastBox.x1 < pBox->x1)
! 	    fastBox.x1 = pBox->x1;
! 	  if (fastBox.x2 > pBox->x2)
! 	    fastBox.x2 = pBox->x2;
! 	  if (fastBox.y1 < pBox->y1)
! 	    fastBox.y1 = pBox->y1;
! 	  if (fastBox.y2 > pBox->y2)
! 	    fastBox.y2 = pBox->y2;
! 
! 	  /* Check to see if the region is empty */
! 	  if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2)
! 	    (*pGC->pScreen->RegionInit) (&rgnDst, NullBox, 0);
! 	  else
! 	    (*pGC->pScreen->RegionInit) (&rgnDst, &fastBox, 1);
! 	}
!       else
! 	{
! 	  /* We must turn off fastClip now, since we must create
! 	     a full blown region.  It is intersected with the
! 	     composite clip below. */
! 	  fastClip = 0;
! 	  (*pGC->pScreen->RegionInit) (&rgnDst, &fastBox, 1);
! 	}
!     }
!   else
!     {
!       (*pGC->pScreen->TranslateRegion) (&rgnDst, -dx, -dy);
!     }
! 
!   if (!fastClip)
!     {
!       (*pGC->pScreen->Intersect) (&rgnDst,
! 				  &rgnDst,
! 				  ((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip);
!     }
! 
!   /* Do bit blitting */
!   numRects = REGION_NUM_RECTS (&rgnDst);
!   if (numRects && width && height)
!     {
!       int swidth = pGC->pScreen->width;
! 
!       pbox = REGION_RECTS (&rgnDst);
! 
! 
!       if (pSrcDrawable->type == DRAWABLE_WINDOW
! 	  && pDstDrawable->type == DRAWABLE_WINDOW)
! 	{
! 	  /* Window --> Window */
! 	  unsigned int *ordering;
! 	  BoxPtr prect;
! 
! 	  ordering = (unsigned int *) ALLOCATE_LOCAL (numRects *
! 						      sizeof (unsigned int));
! /*            ErrorF("Cirrus WWcopy\n"); */
! 
! 	  if (!ordering)
! 	    {
! 	      DEALLOCATE_LOCAL (ordering);
! 	      return (RegionPtr) NULL;
! 	    }
! 
! 	  CirrusFindOrdering (pSrcDrawable, pDstDrawable,
! 			      pGC, numRects, pbox, srcx, srcy, dstx, dsty,
! 			      ordering);
! 
! 
! 	  /* As I understand it, we now have a list */
! 	  /* of boxes, pbox[i], which should be */
! 	  /* copied, in the order given in ordering[i] */
! 	  /* to the box given by pbox->x + dx, */
! 	  /* pbox->y + dy (since every point in the */
! 	  /* dest box is the same point in the source */
! 	  /* box with the translational shift, dx,dy) */
! 
! 
! 	  for (i = 0; i < numRects; i++)
! 	    {
! 	      unsigned int srcAddr, dstAddr, boxwidth, boxheight, status;
! 	      volatile unsigned char tmpreg;
! 	      
! 	      prect = &pbox[ordering[i]];
! 
! 	      dstAddr = prect->x1 + prect->y1 * swidth;
! 	      srcAddr = (prect->x1 + dx) + (prect->y1 + dy) * swidth;
! 
! 	      /* BLTBIT screen -> screen copy */
! 
! 	      /* Set the DstAddress */
! 
! 	      outw (0x3CE, ((dstAddr & 0x000000FF) << 8) | 0x28);
! 	      outw (0x3CE, ((dstAddr & 0x0000FF00)) | 0x29);
! 	      outw (0x3CE, ((dstAddr & 0x001F0000) >> 8) | 0x2A);
! 
! 	      /* Set the SrcAddress */
! 
! 	      outw (0x3CE, ((srcAddr & 0x000000FF) << 8) | 0x2C);
! 	      outw (0x3CE, ((srcAddr & 0x0000FF00)) | 0x2D);
! 	      outw (0x3CE, ((srcAddr & 0x001F0000) >> 8) | 0x2E);
! 
! 	      /* Set the Dest Pitch */
! 
! 	      outw (0x3CE, ((swidth & 0x000000FF) << 8) | 0x24);
! 	      outw (0x3CE, ((swidth & 0x00000F00)) | 0x25);
! 
! 	      /* Set the Src Pitch */
! 
! 	      outw (0x3CE, ((swidth & 0x000000FF) << 8) | 0x26);
! 	      outw (0x3CE, ((swidth & 0x00000F00)) | 0x27);
! 
! 	      /* Set the Width */
! 
! 	      boxwidth = prect->x2 - prect->x1;
! 	      boxheight = prect->y2 - prect->y1;
! 
! 	      boxwidth--;
! 	      outw (0x3CE, ((boxwidth & 0x000000FF) << 8) | 0x20);
! 	      outw (0x3CE, ((boxwidth & 0x00000700)) | 0x21);
! 
! 	      /* Set the Height */
! 
! 	      boxheight--;
! 	      outw (0x3CE, ((boxheight & 0x000000FF) << 8) | 0x22);
! 	      outw (0x3CE, ((boxheight & 0x00000300)) | 0x23);
! 
! 	      /* Set the direction */
! 
! 	      outw (0x3CE, (0x00 << 8) | 0x30);
! 
! 	      /* Set the ROP: Copy = 0x0D */
! 	      outw (0x3CE, (0x0D << 8) | 0x32);
! 
! 	      /* Ok, we're all loaded up, let's do it */
! 	      outw (0x3CE, (0x02 << 8) | 0x31);
! 
! 	      do
! 		{
! 		  outb (0x3CE, 0x31);
! 		  tmpreg = inb (0x3CF);
! 		}
! 	      while (tmpreg & 0x01);
! 	      
! 	    }
! 	}
!       else if (pSrcDrawable->type == DRAWABLE_WINDOW
! 	       && pDstDrawable->type != DRAWABLE_WINDOW)
! 	{
! 	  char *pdstBase, *psrcBase;
! 	  int widthSrc, widthDst;	/* add to get to same position in */
! 	  /* next line */
! 
! 	  /* Window --> Pixmap */
! 	  int pixWidth = PixmapBytePad (pDstDrawable->width,
! 					pDstDrawable->depth);
! 	  unsigned char *pdst = ((PixmapPtr) pDstDrawable)->devPrivate.ptr;
! 
! 	  pdstBase = (unsigned char *)
! 	    (((PixmapPtr) pDstDrawable)->devPrivate.ptr);
! 	  psrcBase = (unsigned char *)
! 	    (((PixmapPtr) (pSrcDrawable->pScreen->devPrivate))
! 	     ->devPrivate.ptr);
! 
! 	  widthDst = (int) (((PixmapPtr) pDstDrawable)->devKind);
! 	  widthSrc = (int) ((PixmapPtr)
! 			    (pSrcDrawable->pScreen->devPrivate))->devKind;
! 
! 	  for (i = numRects; --i >= 0; pbox++)
! 	    {
! 	      CirrusImageRead(pdstBase, widthSrc, widthDst, 
! 			      pbox->x1 + dx, pbox->y1 + dy, 
! 			      pbox->x1, pbox->y1, 
! 			      pbox->x2 - pbox->x1,  pbox->y2 - pbox->y1, 
! 			      swidth);
! 	    }
! 
! 	}
!       else if (pSrcDrawable->type != DRAWABLE_WINDOW
! 	       && pDstDrawable->type == DRAWABLE_WINDOW)
  	{
! 	  /* Pixmap --> Window */
! 	  unsigned char *psrcBase, *pdstBase;
! 	  int widthSrc, widthDst;	/* add to get to same position in */
! 	  /* next line */
! 	  int pixWidth = PixmapBytePad (pSrcDrawable->width,
! 					pSrcDrawable->depth);
! 
! 	  unsigned char *psrc = ((PixmapPtr) pSrcDrawable)->devPrivate.ptr;
! 
! 	  psrcBase = (unsigned char *)
! 	    (((PixmapPtr) pSrcDrawable)->devPrivate.ptr);
! 	  pdstBase = (unsigned char *)
! 	    (((PixmapPtr) (pDstDrawable->pScreen->devPrivate))
! 	     ->devPrivate.ptr);
! 
! 
! 	  widthDst = (int) ((PixmapPtr)
! 			    (pDstDrawable->pScreen->devPrivate))->devKind;
! 
! 	  widthSrc = (int) (((PixmapPtr) pSrcDrawable)->devKind);
! 
! 	  for (i = numRects; --i >= 0; pbox++)
  	    {
! 	      int h = pbox->y2 - pbox->y1;
! 	      int w = pbox->x2 - pbox->x1;
! 
! 	      CirrusImageWrite (psrcBase, pixWidth, widthDst,
! 				pbox->x1 + dx, pbox->y1 + dy,
! 				pbox->x1, pbox->y1, w, h);
  	    }
! 
! 	}
!       else
! 	{
! 	  /* Pixmap --> Pixmap */
! 	  unsigned char *psrcBase, *pdstBase;
! 	  int widthSrc, widthDst;	/* add to get to same position in */
! 	  /* next line */
! 	  int pixWidth = PixmapBytePad (pSrcDrawable->width,
! 					pSrcDrawable->depth);
! 
! 	  unsigned char *psrc = ((PixmapPtr) pSrcDrawable)->devPrivate.ptr;
! 
! 	  psrcBase = (unsigned char *)
! 	    (((PixmapPtr) pSrcDrawable)->devPrivate.ptr);
! 
! 	  pdstBase = (unsigned char *)
! 	    (((PixmapPtr) pDstDrawable)->devPrivate.ptr);
! 
! 
! 	  widthDst = (int) (((PixmapPtr) pDstDrawable)->devKind);
! 
! 	  widthSrc = (int) (((PixmapPtr) pSrcDrawable)->devKind);
! 
! 	  for (i = numRects; --i >= 0; pbox++)
  	    {
! 	      int h = pbox->y2 - pbox->y1;
! 	      int w = pbox->x2 - pbox->x1;
! 	      vgaPixBitBlt (pdstBase, psrcBase, widthSrc, widthDst,
! 			    pSrcDrawable->x, pSrcDrawable->y,
! 			    pbox->x1, pbox->y1, w, h, xdir, ydir,
! 			    pGC->alu, pGC->planemask);
  	    }
- 
  	}
  
!     }
! 
!   prgnExposed = NULL;
!   if (((cfbPrivGC *) (pGC->devPrivates[cfbGCPrivateIndex].ptr))->fExpose)
!     {
!       extern RegionPtr miHandleExposures ();
! 
!       /* Pixmap sources generate a NoExposed (we return NULL to do this) */
!       if (!fastExpose)
! 	prgnExposed =
! 	  miHandleExposures (pSrcDrawable, pDstDrawable, pGC,
! 			     origSource.x, origSource.y,
! 			     (int) origSource.width,
! 			     (int) origSource.height,
! 			     origDest.x, origDest.y, 0);
!     }
!   (*pGC->pScreen->RegionUninit) (&rgnDst);
!   if (freeSrcClip)
!     (*pGC->pScreen->RegionDestroy) (prgnSrcClip);
!   return prgnExposed;
! }
! 
! void
! CirrusFindOrdering (pSrcDrawable, pDstDrawable, pGC, numRects, boxes,
! 		    srcx, srcy, dstx, dsty, ordering)
!      DrawablePtr pSrcDrawable;
!      DrawablePtr pDstDrawable;
!      GC *pGC;
!      int numRects;
!      BoxPtr boxes;
!      int srcx;
!      int srcy;
!      int dstx;
!      int dsty;
!      unsigned int *ordering;
! {
!   int i, j, y;
!   int xMax, yMin, yMax;
! 
!   /* If not the same drawable then order of move doesn't matter.
!      Following assumes that boxes are sorted from top
!      to bottom and left to right.
!    */
! 
!   if ((pSrcDrawable != pDstDrawable) &&
!       ((pGC->subWindowMode != IncludeInferiors) ||
!        (pSrcDrawable->type == DRAWABLE_PIXMAP) ||
!        (pDstDrawable->type == DRAWABLE_PIXMAP)))
!     {
!       for (i = 0; i < numRects; i++)
! 	ordering[i] = i;
!     }
!   /* within same drawable, must sequence */
! 
!   /* Scroll up or stationary vertical. */
!   /* Vertical order OK */
! 
!   else
!     /* moves carefully! */
!     {
! 
!       /* Scroll left or stationary horizontal. */
!       /* Horizontal order OK as well */
!       if (dsty <= srcy)
! 	{
! 
! 	  if (dstx <= srcx)
! 	    {
! 	      for (i = 0; i < numRects; i++)
! 		ordering[i] = i;
  	    }
- 	  /* scroll right. must reverse horizontal */
- 	  /* banding of rects. */
  	  else
  	    {
! 	      for (i = 0, j = 1, xMax = 0; i < numRects; j = i + 1, xMax = i)
  		{
! 		  /* find extent of current horizontal band */
! 
! 		  /* band has this y coordinate */
! 		  y = boxes[i].y1;
! 
! 		  while ((j < numRects) && (boxes[j].y1 == y))
! 		    j++;
! 
! 		  /* reverse the horizontal band in the output */
! 		  /* ordering */
! 
! 		  for (j--; j >= xMax; j--, i++)
! 		    ordering[i] = j;
  		}
  	    }
  	}
-       /* Scroll down. Must reverse vertical */
-       /* banding. */
        else
  	{
! 	  /* Scroll left. Horizontal order OK. */
! 	  if (dstx < srcx)
  	    {
! 	      for (i = numRects - 1, j = i - 1, yMin = i, yMax = 0; i >= 0;
! 		   j = i - 1, yMin = i)
  		{
! 		  /* find extent of current horizontal band */
! 
! 		  y = boxes[i].y1;	/* band has this y coordinate */
! 		  while ((j >= 0) && (boxes[j].y1 == y))
! 		    j--;
! 
! 		  /* reverse the horizontal band in the output */
! 		  /* ordering */
! 
! 		  for (j++; j <= yMin; j++, i--, yMax++)
! 		    ordering[yMax] = j;
  		}
  	    }
  	  else
  	    {
! 	      /* Scroll right or horizontal stationary. */
! 	      /* Reverse horizontal order as well (if */
! 	      /* stationary, horizontal order can be */
! 	      /* swapped without penalty and this is */
! 	      /* faster to compute). */
! 
! 	      for (i = 0, j = numRects - 1; i < numRects; i++, j--)
! 		ordering[i] = j;
  	    }
  	}
      }
  }
--- 45,230 ----
  #include "cfb.h"
  #include "cfbmskbits.h"
  #include "cfb8bit.h"
  
! #include "mergerop.h"
  #include "vgaBank.h"
+ #include "compiler.h"
+ #include "os.h"		/* For FatalError */
  
+ #include "cir_driver.h"
+ 
  extern pointer vgaBase;
  
  
! /*
!  * This is the mid-level BitBlt function that calls the appropriate
!  * low level function, depending on size, specific chipset, etc.
!  *
!  * We could also use the BitBLT engine for non-GXcopy blits; do they
!  * ever happen?
!  */
  
  
! void
! CirrusBitBlt (pdstBase, psrcBase, widthSrc, widthDst, x, y,
! 	      x1, y1, w, h, xdir, ydir, alu, planemask)
!      pointer pdstBase, psrcBase;	/* start of src bitmap */
!      int widthSrc, widthDst;
!      int x, y, x1, y1, w, h;	/* Src x,y; Dst x1,y1; Dst (w)idth,(h)eight */
!      int xdir, ydir;
!      int alu;
!      unsigned long planemask;
! {
!   unsigned int psrc, pdst;
!   int i;
  
! #if 0
!   ErrorF("x = %d, y = %d, x1 = %d, y1 = %d, w = %d, h = %d, xdir = %d, ydir = %d\n",
!       x, y, x1, y1, w, h, xdir, ydir);
! #endif      
! 
!   if (alu == GXcopy && (planemask & 0xFF) == 0xFF)
!     {
! 
!       if (!HAVEBITBLTENGINE()) {
!           if (xdir == 1 && ydir == 1) {
!               /* Special case for extended write mode bitblt (scroll up). */
!               if (w >= 32 && (x & 7) == (x1 & 7)) {
!                   CirrusLatchedBitBlt(x, y, x1, y1, w, h, widthDst);
!                   return;
!               }
! #if 1
!               /* Call Cirrus framebuffer memcpy routine for remaining */
!               /* forward blits. */
!               CirrusSimpleBitBlt(x, y, x1, y1, w, h, widthDst);
!               return;
! #endif              
!           }
! 
! 	  if (xdir == 1 && ydir == -1) {
!               /* Special case for reversed extended write mode bitblt */
!               /* (scroll down). */
!               if (w >= 32 && (x & 7) == (x1 & 7)) {
!                   CirrusLatchedBitBltReversed(x, y, x1, y1, w, h, -widthDst);
!                   return;
!               }
!           }
! 
!           /* Let cfb do remaining (non-forward) blits. */
!           vgaBitBlt(pdstBase, psrcBase, widthSrc, widthDst, x, y,
! 	      x1, y1, w, h, xdir, ydir, alu, planemask);
! 	  return;
!       }
! 
!       /* We have a hardware BitBLT engine. */
!       /* For small areas, use the Cirrus framebuffer memcpy routine. */
!       if (w * h < 200) {
! #if 1
!           if (xdir == 1 && ydir == 1) {
!               CirrusSimpleBitBlt(x, y, x1, y1, w, h, widthDst);
!               return;
!           }
! #endif          
!           vgaBitBlt(pdstBase, psrcBase, widthSrc, widthDst, x, y,
!               x1, y1, w, h, xdir, ydir, alu, planemask);
!           return;
!       }
! 
!       /* Use the hardware blit. */
!       /* The line-by-line blits can probably be largely avoided similar to */
!       /* the paradise/wd driver. -- HH */
! 
!       if (widthSrc < 0)
!           widthSrc = -widthSrc;
!       if (widthDst < 0)
!           widthDst = -widthDst;
! 
!       if (xdir == 1 && ydir == -1 && y != y1) {
!           /* Tranform to xdir = -1 blit. */
!           xdir = -1;
!       }
  
!       if (xdir == 1)		/* left to right */
  	{
! 	  if (ydir == 1)	/* top to bottom */
  	    {
! 	      psrc = (y * widthSrc) + x;
! 	      pdst = (y1 * widthDst) + x1;
  	    }
  	  else
+ 	    /* bottom to top */
  	    {
! 	      psrc = ((y + h - 1) * widthSrc) + x;
! 	      pdst = ((y1 + h - 1) * widthDst) + x1;
  	    }
  	}
        else
! 	/* right to left */
  	{
! 	  if (ydir == 1)	/* top to bottom */
  	    {
! 	      psrc = (y * widthSrc) + x + w - 1;
! 	      pdst = (y1 * widthDst) + x1 + w - 1;
  	    }
! 	  else
! 	    /* bottom to top */
  	    {
! 	      psrc = ((y + h - 1) * widthSrc) + x + w - 1;
! 	      pdst = ((y1 + h - 1) * widthDst) + x1 + w - 1;
  	    }
  	}
  
!       /* I could probably do the line by line */
!       /* blits a little faster by breaking the */
!       /* blit regions into rectangles */
!       /* and blitting those, making sure I don't */
!       /* overwrite stuff. However, the */
!       /* difference between the line by line */
!       /* and block blits isn't noticable to */
!       /* me, so I think I'll blow it off. */
!       
!       /* HH: Hmm, it is very noticable; moving up while editing is */
!       /* significantly slower (this is now fixed). */
!      
!       if (xdir == 1)
! 	{
! 	  if (ydir == 1)
! 	    {			/* Nothing special, straight blit */
! 	      CirrusBLTBitBlt(pdst, psrc, widthDst, widthSrc, w, h, 1);
  	    }
  	  else
+ 	    /* Line by line, going up. */
  	    {
! 	      for (i = 0; i < h; i++)
  		{
! 		  CirrusBLTBitBlt(pdst, psrc, widthDst, widthSrc, w, 1, 1);
! 		  psrc -= widthSrc;
! 		  pdst -= widthDst;
  		}
  	    }
  	}
        else
  	{
! 
! 	  if (ydir == 1)	/* Line by line, going down and to the left */
  	    {
! 	      for (i = 0; i < h; i++)
  		{
! 		  CirrusBLTBitBlt(pdst, psrc, widthDst, widthSrc, w, 1, -1);
! 		  psrc += widthSrc;
! 		  pdst += widthDst;
  		}
  	    }
  	  else
+ 	    /* Another stock blit, albeit backwards */
  	    {
! 	      CirrusBLTBitBlt(pdst, psrc, widthDst, widthSrc, w, h, -1);
  	    }
  	}
      }
+   else
+     /* Non GXcopy, or planemask != 0xff. */
+     vgaBitBlt(pdstBase, psrcBase, widthSrc, widthDst, x, y,
+         x1, y1, w, h, xdir, ydir, alu, planemask);
  }
+ 
diff -c mit/server/ddx/x386/vga256/drivers/cirrus/cir_bltC.c:2.0 mit/server/ddx/x386/vga256/drivers/cirrus/cir_bltC.c:2.2
*** mit/server/ddx/x386/vga256/drivers/cirrus/cir_bltC.c:2.0	Fri Mar 11 23:41:09 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_bltC.c	Fri Mar 11 23:41:09 1994
***************
*** 16,22 ****
  
  */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_bltC.c,v 2.0 1993/09/21 15:24:27 dawes Exp $ */
  
  /*
   * Author:  Bill Reynolds, bill@goshawk.lanl.gov
--- 16,22 ----
  
  */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_bltC.c,v 2.2 1994/02/24 12:43:28 dawes Exp $ */
  
  /*
   * Author:  Bill Reynolds, bill@goshawk.lanl.gov
***************
*** 27,32 ****
--- 27,37 ----
   */
  
  
+ /*
+  * This is the high-level BitBlt function. Calls CirrusBitBlt.
+  */
+ 
+ 
  #include	"X.h"
  #include	"Xmd.h"
  #include	"Xproto.h"
***************
*** 41,49 ****
  #include	"fastblt.h"
  #include        "vgaBank.h"
  
! extern void (*ourvgaBitBlt)();
  
  
  CirrusDoBitbltCopy(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
      DrawablePtr	    pSrc, pDst;
      int		    alu;
--- 46,56 ----
  #include	"fastblt.h"
  #include        "vgaBank.h"
  
! #include "cir_driver.h"
  
+ extern void (*ourvgaBitBlt)();
  
+ int
  CirrusDoBitbltCopy(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
      DrawablePtr	    pSrc, pDst;
      int		    alu;
***************
*** 58,65 ****
    int NoCirrus = 0;
    BoxPtr pbox;
    int nbox;
-   int readwrite=0;		/* DBG */
-   
    
    BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
                                    /* temporaries for shuffling rectangles */
--- 65,70 ----
***************
*** 126,132 ****
  	    }
         else			/* Screen -> Mem */
  	    {
! 	    if(NoCirrus)
  		 {
  		 fnp = vgaImageRead;
  		 }
--- 131,137 ----
  	    }
         else			/* Screen -> Mem */
  	    {
! 	    if(NoCirrus || !HAVEBITBLTENGINE())
  		 {
  		 fnp = vgaImageRead;
  		 }
***************
*** 139,145 ****
    else 
         if (CHECKSCREEN(pdstBase)) /* Mem -> Screen */
  	    {
! 	    if(NoCirrus) 
  		 {
  		 fnp = vgaImageWrite;
  		 }
--- 144,150 ----
    else 
         if (CHECKSCREEN(pdstBase)) /* Mem -> Screen */
  	    {
! 	    if(NoCirrus || !HAVEBITBLTENGINE()) 
  		 {
  		 fnp = vgaImageWrite;
  		 }
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_colexp.c:2.6
*** /dev/null	Fri Mar 11 23:41:10 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_colexp.c	Fri Mar 11 23:41:10 1994
***************
*** 0 ****
--- 1,1008 ----
+ /*
+  *
+  * Copyright 1994 by H. Hanemaayer, Utrecht, The Netherlands
+  *
+  * 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 H. Hanemaayer not be used in
+  * advertising or publicity pertaining to distribution of the software without
+  * specific, written prior permission.  H. Hanemaayer makes no representations
+  * about the suitability of this software for any purpose.  It is provided
+  * "as is" without express or implied warranty.
+  *
+  * H. HANEMAAYER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+  * EVENT SHALL H. HANEMAAYER 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.
+  *
+  * Author:  H. Hanemaayer, <hhanemaa@cs.ruu.nl>
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_colexp.c,v 2.6 1994/03/08 04:52:13 dawes Exp $ */
+ 
+ /*
+  * This file contains the low level accelerated functions that use color
+  * expansion/extended write mode and some more framebuffer functions that
+  * take advantage of the 16K bank granularity.
+  */
+  
+ 
+ #include "X.h"
+ #include "Xmd.h"
+ #include "servermd.h"
+ #include "gcstruct.h"
+ #include "window.h"
+ #include "pixmapstr.h"
+ #include "scrnintstr.h"
+ #include "windowstr.h"
+ 
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "cfbrrop.h"
+ #include "mergerop.h"
+ #include "vgaBank.h"
+ #include "vga.h"	/* For vgaInfoRec. */
+ #include "xf86_HWlib.h"
+ 
+ #ifndef __GNUC__
+ #undef __volatile__
+ #define __volatile__ volatile
+ #endif
+ 
+ #include "compiler.h"
+ 
+ 
+ extern pointer vgaBase;
+ 
+ #include "cir_driver.h"
+ #include "cir_inline.h"
+ 
+ 
+ #if __GNUC__ > 1 && defined(GCCUSESGAS)
+ 
+ static __inline__ void latchedcopy8( unsigned char *srcp, unsigned char *destp ) {
+ /* This is critical code. gcc produces unnecessary overhead with the */
+ /* C equivalent. */
+ 	__asm__ __volatile__(
+ 	"movb (%0),%%al\n\t"
+ 	"movb %%al,(%1)\n\t"
+ 	"movb 1(%0),%%al\n\t"
+ 	"movb %%al,1(%1)\n\t"
+ 	"movb 2(%0),%%al\n\t"
+ 	"movb %%al,2(%1)\n\t"
+ 	"movb 3(%0),%%al\n\t"
+ 	"movb %%al,3(%1)\n\t"
+ 	"movb 4(%0),%%al\n\t"
+ 	"movb %%al,4(%1)\n\t"
+ 	"movb 5(%0),%%al\n\t"
+ 	"movb %%al,5(%1)\n\t"
+ 	"movb 6(%0),%%al\n\t"
+ 	"movb %%al,6(%1)\n\t"
+ 	"movb 7(%0),%%al\n\t"
+ 	"movb %%al,7(%1)\n\t"
+ 	: : "r" (srcp), "r" (destp) : "ax"
+ 	);
+ }
+ 
+ static __inline__ void latchedwrite8step4( unsigned char *destp ) {
+ 	__asm__ __volatile__(
+ 	"movb $0,(%0)\n\t"
+ 	"movb $0,4(%0)\n\t"
+ 	"movb $0,8(%0)\n\t"
+ 	"movb $0,12(%0)\n\t"
+ 	"movb $0,16(%0)\n\t"
+ 	"movb $0,20(%0)\n\t"
+ 	"movb $0,24(%0)\n\t"
+ 	"movb $0,28(%0)\n\t"
+ 	: : "r" (destp) : "ax"
+ 	);
+ }
+ 
+ #else /* !defined(__GNUC__) */
+ 
+ static void latchedcopy8( unsigned char *srcp, unsigned char *destp ) {
+ /* This is optimal if the compiler stores the temporary in a register; */
+ /* gcc 2.4.5 does not manage this when inlined. */
+ 	*(destp + 0) = *(srcp + 0);
+ 	*(destp + 1) = *(srcp + 1);
+ 	*(destp + 2) = *(srcp + 2);
+ 	*(destp + 3) = *(srcp + 3);
+ 	*(destp + 4) = *(srcp + 4);
+ 	*(destp + 5) = *(srcp + 5);
+ 	*(destp + 6) = *(srcp + 6);
+ 	*(destp + 7) = *(srcp + 7);
+ }
+ 
+ static void latchedwrite8step4( unsigned char *destp ) {
+ /* This produces somewhat horrible code because of lack of registers when
+  * inlined. */
+ 	*destp = 0;	/* Latch write. */
+ 	*(destp + 4) = 0;
+ 	*(destp + 8) = 0;
+ 	*(destp + 12) = 0;
+ 	*(destp + 16) = 0;
+ 	*(destp + 20) = 0;
+ 	*(destp + 24) = 0;
+ 	*(destp + 28) = 0;
+ }
+ 
+ #endif
+ 
+ 
+ /* Table with bit-reversed equivalent for each possible byte. */
+ 
+ unsigned char byte_reversed[256] = {
+ 	0x00,0x80,0x40,0xc0,0x20,0xa0,0x60,0xe0,
+ 	0x10,0x90,0x50,0xd0,0x30,0xb0,0x70,0xf0,
+ 	0x08,0x88,0x48,0xc8,0x28,0xa8,0x68,0xe8,
+ 	0x18,0x98,0x58,0xd8,0x38,0xb8,0x78,0xf8,
+ 	0x04,0x84,0x44,0xc4,0x24,0xa4,0x64,0xe4,
+ 	0x14,0x94,0x54,0xd4,0x34,0xb4,0x74,0xf4,
+ 	0x0c,0x8c,0x4c,0xcc,0x2c,0xac,0x6c,0xec,
+ 	0x1c,0x9c,0x5c,0xdc,0x3c,0xbc,0x7c,0xfc,
+ 	0x02,0x82,0x42,0xc2,0x22,0xa2,0x62,0xe2,
+ 	0x12,0x92,0x52,0xd2,0x32,0xb2,0x72,0xf2,
+ 	0x0a,0x8a,0x4a,0xca,0x2a,0xaa,0x6a,0xea,
+ 	0x1a,0x9a,0x5a,0xda,0x3a,0xba,0x7a,0xfa,
+ 	0x06,0x86,0x46,0xc6,0x26,0xa6,0x66,0xe6,
+ 	0x16,0x96,0x56,0xd6,0x36,0xb6,0x76,0xf6,
+ 	0x0e,0x8e,0x4e,0xce,0x2e,0xae,0x6e,0xee,
+ 	0x1e,0x9e,0x5e,0xde,0x3e,0xbe,0x7e,0xfe,
+ 	0x01,0x81,0x41,0xc1,0x21,0xa1,0x61,0xe1,
+ 	0x11,0x91,0x51,0xd1,0x31,0xb1,0x71,0xf1,
+ 	0x09,0x89,0x49,0xc9,0x29,0xa9,0x69,0xe9,
+ 	0x19,0x99,0x59,0xd9,0x39,0xb9,0x79,0xf9,
+ 	0x05,0x85,0x45,0xc5,0x25,0xa5,0x65,0xe5,
+ 	0x15,0x95,0x55,0xd5,0x35,0xb5,0x75,0xf5,
+ 	0x0d,0x8d,0x4d,0xcd,0x2d,0xad,0x6d,0xed,
+ 	0x1d,0x9d,0x5d,0xdd,0x3d,0xbd,0x7d,0xfd,
+ 	0x03,0x83,0x43,0xc3,0x23,0xa3,0x63,0xe3,
+ 	0x13,0x93,0x53,0xd3,0x33,0xb3,0x73,0xf3,
+ 	0x0b,0x8b,0x4b,0xcb,0x2b,0xab,0x6b,0xeb,
+ 	0x1b,0x9b,0x5b,0xdb,0x3b,0xbb,0x7b,0xfb,
+ 	0x07,0x87,0x47,0xc7,0x27,0xa7,0x67,0xe7,
+ 	0x17,0x97,0x57,0xd7,0x37,0xb7,0x77,0xf7,
+ 	0x0f,0x8f,0x4f,0xcf,0x2f,0xaf,0x6f,0xef,
+ 	0x1f,0x9f,0x5f,0xdf,0x3f,0xbf,0x7f,0xff,
+ };
+ 
+ /* Bit masks for left edge (indexed with first left-to-right bit number). */
+ 
+ static unsigned char leftbitmask[8] = {
+ 	0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01
+ };
+ 
+ /* Bit masks for right edge (indexed with number of pixels left). */
+ 
+ static unsigned char rightbitmask[8] = {
+ 	0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe
+ };
+ 
+ 
+ /*
+  * This low-level function fills an area with a 32 bits wide monochrome
+  * pattern of given height. The pattern scanlines are stored as 32-bit
+  * integers, with the lowest-order bit corresponding to the leftmost pixel.
+  * It has to reverse the per-byte bit ordering because the Cirrus color
+  * expansion works that way.
+  *
+  * This function should work on all chipsets, i.e. 5420 up to 5428.
+  * On local bus and fast processor, it can be significantly faster than the
+  * 5426 bitblt engine for large solid fills.
+  *
+  * Arguments:
+  * x, y		Coordinates of fill area.
+  * w, h		Size of fill area.
+  * bits_in	Pointer to array of 32-bit monochrome scanlines.
+  * sh		Height of the fill pattern (size of array).
+  * sox, soy	Coordinates of the origin of the pattern.
+  * fg		Foreground color (bit 1 in bitmap data).
+  * bg		Background color (bit 0 in bitmap data).
+  * destpitch	Scanline width of screen; must be a multiple of 8.
+  *
+  * The function assumes vgaBase to be the address of the frame buffer window,
+  * with a 32K write window at offset 0x8000. The width must be greater or
+  * equal to 32.
+  *
+  * There's some optimization potential left; the color expansion itself
+  * can be very fast (bandwidth up to 100Mpix/s) so overhead is costly.
+  */
+ 
+ /* For solid fills, on a 486 VLB at 40 MHz, is it optimal at about
+  * width >= 200) (that is, better than the 5426 blit engine).
+  * It appears it can also be faster on the ISA bus.
+  */
+ 
+ #ifdef __STDC__
+ void CirrusColorExpand32bitFill( int x, int y, int w, int h,
+ unsigned long *bits_in, int sh, int sox, int soy, int bg, int fg,
+ int destpitch )
+ #else
+ void CirrusColorExpand32bitFill( x, y, w, h, bits_in, sh, sox, soy, bg,
+ fg, destpitch )
+ 	int x, y, w, h;
+ 	unsigned long *bits_in;
+ 	int sh, sox, soy, bg, fg, destpitch;
+ #endif
+ {
+ 	unsigned long *new_bits;
+ 	int i, j;
+ 	int destaddr;
+ 	unsigned char *destp;
+ 	int bitoffset;
+ 	int syindex;
+ 	int bank;
+ 	unsigned char *base;	/* Video window base address. */
+ 	char filltype;		/* Opaque, solid or transparent. */
+ 
+ #define OPAQUE 0
+ #define SOLID 1
+ #define TRANSPARENT 2
+ 
+ 	/* Reverse per-byte bit order. */
+ 	new_bits = ALLOCATE_LOCAL(sh * 4);
+ 	filltype = SOLID;
+ 	for (i = 0; i < sh; i++) {
+ 		unsigned long bits;
+ 		if (bits_in[i] == 0xffffffff)
+ 			new_bits[i] = 0xffffffff;
+ 		else {
+ 			filltype = OPAQUE;
+ 			/* Rotate so that data is correctly aligned to */
+ 			/* origin for writing dwords to framebuffer. */
+ 			bits = rotateleft(32 - (sox & 31), bits_in[i]);
+ 			/* Reverse each of the four bytes. */
+ 			((unsigned char *)new_bits)[i * 4] =
+ 				byte_reversed[(unsigned char)bits];
+ 			((unsigned char *)new_bits)[i * 4 + 1] =
+ 				byte_reversed[(unsigned char)(bits >> 8)];
+ 			((unsigned char *)new_bits)[i * 4 + 2] =
+ 				byte_reversed[(unsigned char)(bits >> 16)];
+ 			((unsigned char *)new_bits)[i * 4 + 3] =
+ 				byte_reversed[(unsigned char)(bits >> 24)];
+ 		}
+ 	}
+ 	if (bg == -1)
+ 		filltype = TRANSPARENT;
+ 
+ 	base = vgaBase + 0x8000;	/* Write window. */
+ 	destaddr = y * destpitch + x;
+ 
+ 	/* Enable extended write modes and BY8 addressing. */
+ 	/* Every addressing byte corresponds to 8 pixels. */
+ 	SETMODEEXTENSIONS(EXTENDEDWRITEMODES | BY8ADDRESSING | DOUBLEBANKED);
+ 
+ 	if (filltype == OPAQUE) {
+ 		/* Set extended write mode 5, which writes both foreground */
+ 		/* and background color, and will use the pixel mask */
+ 		/* for edges. */
+ 		SETWRITEMODE(5);
+ 		SETBACKGROUNDCOLOR(bg);
+ 	}
+ 	else {
+ 		/* Set extended write mode 4, which writes the foreground */
+ 		/* at the pixels indicates by the CPU data. */
+ 		/* This will avoid costly OUTs at the edges for solid fills*/
+ 		/* and transparent stipples. */
+ 		SETWRITEMODE(4);
+ 	}
+ 
+ 	SETPIXELMASK(0xff);
+ 	SETFOREGROUNDCOLOR(fg);
+ 
+ 	/* Bit offset of leftmost pixel of area to be filled. */
+ 	bitoffset = destaddr & 7;
+ 
+ 	destaddr >>= 3;			/* Divide address by 8. */
+ 
+ 	bank = destaddr >> 14;		/* 16K units. */
+ 	setwritebank(bank);
+ 	destaddr &= 0x3fff;
+ 
+ 	syindex = (y - soy) % sh;	/* y index into source bitmap. */
+ 
+ 	for (j = 0; j < h; j++) {
+ 		union {
+ 			unsigned long dword;
+ 			unsigned char byte[4];
+ 		} bits;
+ 		int count;
+ 
+ 		if (destaddr >= 0x4000) {
+ 			/* 16K granularity is very helpful here. */
+ 			/* Because of the 32K window, we completely avoid */
+ 			/* page breaks within scanlines. */
+ 			bank++;
+ 			setwritebank(bank);
+ 			destaddr -= 0x4000;
+ 		}
+ 		destp = base + destaddr;
+ 
+ 		/* Rotate stipple bits so that is correctly aligned for */
+ 		/* writing aligned dwords in this scanline. It is a bit */
+ 		/* tricky because scanlines don't necessarily start on */
+ 		/* a dword boundary because of BY8 addressing. */
+ 		if (filltype == SOLID)
+ 			bits.dword = 0xffffffff;
+ 		else
+ 			bits.dword = rotateleft(((destaddr - (x >> 3)) & 3) << 3,
+ 				new_bits[syindex]);
+ 
+ 		count = w;		/* Number of pixels left. */
+ 
+ 		/* Do first byte (left edge). */
+ 		if (bitoffset != 0) {
+ 			if (filltype == SOLID) {
+ 				*destp = leftbitmask[bitoffset];
+ 			}
+ 			else
+ 			if (filltype == TRANSPARENT) {
+ 				*destp = bits.byte[(unsigned)destp & 3]
+ 					& leftbitmask[bitoffset];
+ 			}
+ 			else {
+ 				SETPIXELMASK(leftbitmask[bitoffset]);
+ 				*destp = bits.byte[(unsigned)destp & 3];
+ 				SETPIXELMASK(0xff);
+ 			}
+ 			destp++;
+ 			count -= 8 - bitoffset;
+ 		}
+ 
+ 		/* Fill to dword boundary. */
+ 		switch ((unsigned)destp & 3) {
+ 		case 1 :
+ 			*destp = bits.byte[1];
+ 			*(unsigned short *)(destp + 1) =
+ 				*(unsigned short *)(&bits.byte[2]);
+ 			destp += 3;
+ 			count -= 24;
+ 			break;
+ 		case 2 :
+ 			*(unsigned short *)destp =
+ 				*(unsigned short *)(&bits.byte[2]);
+ 			destp += 2;
+ 			count -= 16;
+ 			break;
+ 		case 3 :
+ 			*destp = bits.byte[3];
+ 			destp++;
+ 			count -= 8;
+ 		}
+ 
+ 		/* Fill dwords (32 pixels). */
+ 		__memsetlong((unsigned long *)destp, bits.dword, count / 32);
+ 		destp += (count / 32) * 4;
+ 		count &= 31;
+ 
+ 		/* Fill remaining bytes (8 pixels). */
+ 		switch (count >> 3) {
+ 		case 1 :
+ 			*destp = bits.byte[0];
+ 			destp++;
+ 			count -= 8;
+ 			break;
+ 		case 2 :
+ 			*(unsigned short *)destp =
+ 				*(unsigned short *)(&bits.byte[0]);
+ 			destp += 2;
+ 			count -= 16;
+ 			break;
+ 		case 3 :
+ 			*(unsigned short *)destp =
+ 				*(unsigned short *)(&bits.byte[0]);
+ 			*(destp + 2) = bits.byte[2];
+ 			destp += 3;
+ 			count -= 24;
+ 		}
+ 
+ 		/* Do last byte (right edge). */
+ 		if (count != 0)
+ 			if (filltype == SOLID)
+ 				*destp = rightbitmask[count];
+ 			else
+ 			if (filltype == TRANSPARENT)
+ 				*destp = bits.byte[(unsigned)destp & 3]
+ 					& rightbitmask[count];
+ 			else {
+ 				SETPIXELMASK(rightbitmask[count]);
+ 				*destp = bits.byte[(unsigned)destp & 3];
+ 				SETPIXELMASK(0xff);
+ 			}
+ 
+ 		destaddr += (destpitch >> 3);
+ 
+ 		syindex++;
+ 		if (syindex == sh)
+ 			syindex = 0;	/* Wrap pattern vertically. */
+ 	}
+ 
+ 	/* Disable extended write modes and BY8 addressing. */
+ 	SETMODEEXTENSIONS(DOUBLEBANKED);
+ 
+ 	SETWRITEMODE(0);
+ 
+ 	SETFOREGROUNDCOLOR(0x00);	/* Disable set/reset. */
+ 
+ 	DEALLOCATE_LOCAL(new_bits);
+ }
+ 
+ 
+ /*
+  * This is the special function for small widths (< 32).
+  * Just uses the banked plain framebuffer.
+  * It is somewhat faster than the cfb.banked equivalents (it takes
+  * advantage of the 16K bank granularity).
+  *
+  * Currently not used because of bug (see xgc time percentage scrollbar).
+  */
+ 
+ #ifdef __STDC__
+ void Cirrus32bitFillSmall( int x, int y, int w, int h,
+ unsigned long *bits_in, int sh, int sox, int soy, int bg, int fg,
+ int destpitch )
+ #else
+ void Cirrus32bitFillSmall( x, y, w, h, bits_in, sh, sox, soy, bg, fg,
+ destpitch )
+ 	int x, y, w, h;
+ 	unsigned long *bits_in;
+ 	int sh, sox, soy, bg, fg, destpitch;
+ #endif
+ {
+ 	int j;
+ 	int destaddr;
+ 	unsigned char *destp;
+ 	int syindex;
+ 	int bank;
+ 	unsigned char *base;	/* Video window base address. */
+ 	unsigned char color[2];
+ 
+ 	base = vgaBase + 0x8000;	/* Write window. */
+ 	destaddr = y * destpitch + x;
+ 
+ 	bank = destaddr >> 14;
+ 	setwritebank(bank);
+ 	destaddr &= 0x3fff;
+ 
+ 	color[0] = bg;
+ 	color[1] = fg;
+ 
+ 	syindex = (y - soy) % sh;	/* y index into source bitmap. */
+ 
+ 	for (j = 0; j < h; j++) {
+ 		unsigned long bits;
+ 		int count;
+ 		
+ 		bits = rotateleft(32 - (sox & 31), bits_in[syindex]);
+ 
+ 		if (destaddr >= 0x4000) {
+ 			bank++;
+ 			setwritebank(bank);
+ 			destaddr -= 0x4000;
+ 		}
+ 		destp = base + destaddr;
+ 
+ 		count = w;
+ 		if (bits == 0xffffffff)
+ 			__memset(destp, fg, w);
+ 		else {
+ 			while (count > 8) {
+ 				*destp = color[bits & 1]; bits >>= 1;
+ 				*(destp + 1) = color[bits & 1]; bits >>= 1;
+ 				*(destp + 2) = color[bits & 1]; bits >>= 1;
+ 				*(destp + 3) = color[bits & 1]; bits >>= 1;
+ 				*(destp + 4) = color[bits & 1]; bits >>= 1;
+ 				*(destp + 5) = color[bits & 1]; bits >>= 1;
+ 				*(destp + 6) = color[bits & 1]; bits >>= 1;
+ 				*(destp + 7) = color[bits & 1]; bits >>= 1;
+ 				destp += 8;
+ 				count -= 8;
+ 			}
+ 			while (count > 0) {
+ 				*destp = color[bits & 1];
+ 				bits >>= 1;
+ 				destp++;
+ 				count--;
+ 			}
+ 		}
+ 
+ 		destaddr += destpitch;
+ 
+ 		syindex++;
+ 		if (syindex == sh)
+ 			syindex = 0;	/* Wrap pattern vertically. */
+ 	}
+ }
+ 
+ 
+ /*
+  * This is a bitblt function. It takes advantage of the 8 data latches that
+  * can be enabled in BY8 addressing mode to do efficient vertical bitblts.
+  * I believe this makes scrolling bearable on the chips that don't
+  * have the bitblt engine, i.e. <= 5424. On a local bus, it may even
+  * rival the bitblt engine in speed.
+  *
+  * Arguments:
+  * x1, y1	Coordinates of source area.
+  * x2, y2	Coordinates of destination area.
+  * w, h		Size of area to be copied.
+  * destpitch	Scanline width of screen in bytes.
+  *
+  * x1 must be equal to x2 (actually works if (x1 % 8 == x2 % 8)).
+  * Copies from top to bottom. For overlapping areas, correct if
+  * (y1 > y2 || (y1 == y2 && x1 > x2).
+  *
+  * The data latches work similar to VGA write mode 1 (for planar modes).
+  * Basically, a read from display memory fills the 8 latches with 8 pixels,
+  * and subsequent writes (CPU data written doesn't matter) will each write
+  * the 8 pixels stored in the latches.
+  */
+  
+ /* #define USE_MEMCPYB */
+ 
+ #ifdef __STDC__
+ void CirrusLatchedBitBlt( int x1, int y1, int x2, int y2, int w, int h,
+ int destpitch )
+ #else
+ void CirrusLatchedBitBlt( x1, y1, x2, y2, w, h, destpitch )
+ 	int x1, y1, x2, y2, w, h, destpitch;
+ #endif
+ {
+ 	int j;
+ 	int destaddr, srcaddr;
+ 	unsigned char *destp, *srcp;
+ 	int writebank, readbank;
+ 	int bitoffset;
+ 
+ 	unsigned char *base;	/* Video window base address. */
+ 
+ 	base = vgaBase;			/* Read window. */
+ 					/* Write window is at offset 0x8000 */
+ 	destaddr = y2 * destpitch + x2;
+ 	srcaddr = y1 * destpitch + x1;
+ 
+ 	/* Enable extended write modes, BY8 addressing, and 8 byte data */
+ 	/* latches. Every addressing byte corresponds to 8 pixels. */
+ 	SETMODEEXTENSIONS(EXTENDEDWRITEMODES | BY8ADDRESSING |
+ 		EIGHTDATALATCHES | DOUBLEBANKED);
+ 
+ 	SETWRITEMODE(1);
+ 
+ 	SETPIXELMASK(0xff);
+ 	SETFOREGROUNDCOLOR(0);		/* Disable set/reset. */
+ 
+ 	/* Bit offset of leftmost pixel of area to be filled. */
+ 	bitoffset = destaddr & 7;
+ 
+ 	destaddr >>= 3;			/* Divide address by 8. */
+ 	srcaddr >>= 3;
+ 
+ 	writebank = destaddr >> 14;	/* 16K units. */
+ 	setwritebank(writebank);
+ 	readbank = srcaddr >> 14;
+ 	setreadbank(readbank);
+ 	destaddr &= 0x3fff;
+ 	srcaddr &= 0x3fff;
+ 
+ 	for (j = 0; j < h; j++) {
+ 		int count;
+ 
+ 		if (destaddr >= 0x4000) {
+ 			/* 16K granularity is very helpful here. */
+ 			/* Because of the 32K window, we completely avoid */
+ 			/* page breaks within scanlines. */
+ 			writebank++;
+ 			setwritebank(writebank);
+ 			destaddr -= 0x4000;
+ 		}
+ 		if (srcaddr >= 0x4000) {
+ 			readbank++;
+ 			setreadbank(readbank);
+ 			srcaddr -= 0x4000;
+ 		}
+ 		/* Address in write window. */
+ 		destp = base + 0x8000 + destaddr;
+ 		/* Address in read window. */
+ 		srcp = base + srcaddr;
+ 
+ 		count = w;		/* Number of pixels left. */
+ 
+ 		/* Do first byte (left edge). */
+ 		if (bitoffset != 0) {
+ 			SETPIXELMASK(leftbitmask[bitoffset]);
+ 			/* Write mode 1 latch read/write. */
+ 			*destp = *srcp;
+ 			SETPIXELMASK(0xff);
+ 			destp++;
+ 			srcp++;
+ 			count -= 8 - bitoffset;
+ 		}
+ 
+ #ifndef USE_MEMCPYB
+ 		/* Using rep movsb here would seem appropriate, but I */
+ 		/* think some recent non-Intel chips actually try */
+ 		/* to optimize that instruction by writing words, which */
+ 		/* would break this. */
+ 		while (count >= 64) {
+ 			/* Write mode 1 latch read/write. */
+ 			latchedcopy8(srcp, destp);
+ 			destp += 8;
+ 			srcp += 8;
+ 			count -= 64;
+ 		}
+ 		while (count >= 8) {
+ 			/* Write mode 1 latch read/write. */
+ 			*destp = *srcp;
+ 			destp++;
+ 			srcp++;
+ 			count -= 8;
+ 		}
+ #else
+ 		__memcpyb(destp, srcp, count >> 3);
+ 		destp += count >> 3;
+ 		srcp += count >> 3;
+ 		count &= 7;
+ #endif
+ 
+ 		/* Do last byte (right edge). */
+ 		if (count != 0) {
+ 			SETPIXELMASK(rightbitmask[count]);
+ 			/* Write mode 1 latch read/write. */
+ 			*destp = *srcp;
+ 			SETPIXELMASK(0xff);
+ 		}
+ 
+ 		destaddr += (destpitch >> 3);
+ 		srcaddr += (destpitch >> 3);
+ 	}
+ 
+ 	/* Disable extended write modes and BY8 addressing. */
+ 	SETMODEEXTENSIONS(DOUBLEBANKED);
+ 
+ 	SETWRITEMODE(0);
+ 
+ 	SETFOREGROUNDCOLOR(0x00);	/* Disable set/reset. */
+ }
+ 
+ 
+ void CirrusLatchedBitBltReversed( x1, y1, x2, y2, w, h, destpitch )
+ 	int x1, y1, x2, y2, w, h, destpitch;
+ {
+ 	int j;
+ 	int destaddr, srcaddr;
+ 	unsigned char *destp, *srcp;
+ 	int writebank, readbank;
+ 	int bitoffset;
+ 
+ 	unsigned char *base;	/* Video window base address. */
+ 
+ 	base = vgaBase;			/* Read window. */
+ 					/* Write window is at offset 0x8000 */
+ 	destaddr = (y2 + h - 1) * destpitch + x2;
+ 	srcaddr = (y1 + h - 1) * destpitch + x1;
+ 
+ 	/* Enable extended write modes, BY8 addressing, and 8 byte data */
+ 	/* latches. Every addressing byte corresponds to 8 pixels. */
+ 	SETMODEEXTENSIONS(EXTENDEDWRITEMODES | BY8ADDRESSING |
+ 		EIGHTDATALATCHES | DOUBLEBANKED);
+ 
+ 	SETWRITEMODE(1);
+ 
+ 	SETPIXELMASK(0xff);
+ 	SETFOREGROUNDCOLOR(0);		/* Disable set/reset. */
+ 
+ 	/* Bit offset of leftmost pixel of area to be filled. */
+ 	bitoffset = destaddr & 7;
+ 
+ 	destaddr >>= 3;			/* Divide address by 8. */
+ 	srcaddr >>= 3;
+ 
+ 	writebank = destaddr >> 14;	/* 16K units. */
+ 	setwritebank(writebank);
+ 	readbank = srcaddr >> 14;
+ 	setreadbank(readbank);
+ 	destaddr &= 0x3fff;
+ 	srcaddr &= 0x3fff;
+ 
+ 	for (j = 0; j < h; j++) {
+ 		int count;
+ 
+ 		if (destaddr < 0) {
+ 			/* 16K granularity is very helpful here. */
+ 			/* Because of the 32K window, we completely avoid */
+ 			/* page breaks within scanlines. */
+ 			writebank--;
+ 			setwritebank(writebank);
+ 			destaddr += 0x4000;
+ 		}
+ 		if (srcaddr < 0) {
+ 			readbank--;
+ 			setreadbank(readbank);
+ 			srcaddr += 0x4000;
+ 		}
+ 		/* Address in write window. */
+ 		destp = base + 0x8000 + destaddr;
+ 		/* Address in read window. */
+ 		srcp = base + srcaddr;
+ 
+ 		count = w;		/* Number of pixels left. */
+ 
+ 		/* Do first byte (left edge). */
+ 		if (bitoffset != 0) {
+ 			SETPIXELMASK(leftbitmask[bitoffset]);
+ 			/* Write mode 1 latch read/write. */
+ 			*destp = *srcp;
+ 			SETPIXELMASK(0xff);
+ 			destp++;
+ 			srcp++;
+ 			count -= 8 - bitoffset;
+ 		}
+ 
+ #ifndef USE_MEMCPYB
+ 		/* Using rep movsb here would seem appropriate, but I */
+ 		/* think some recent non-Intel chips actually try */
+ 		/* to optimize that instruction by writing words, which */
+ 		/* would break this. */
+ 		while (count >= 64) {
+ 			/* Write mode 1 latch read/write. */
+ 			latchedcopy8(srcp, destp);
+ 			destp += 8;
+ 			srcp += 8;
+ 			count -= 64;
+ 		}
+ 		while (count >= 8) {
+ 			/* Write mode 1 latch read/write. */
+ 			*destp = *srcp;
+ 			destp++;
+ 			srcp++;
+ 			count -= 8;
+ 		}
+ #else
+ 		__memcpyb(destp, srcp, count >> 3);
+ 		destp += count >> 3;
+ 		srcp += count >> 3;
+ 		count &= 7;
+ #endif
+ 
+ 		/* Do last byte (right edge). */
+ 		if (count != 0) {
+ 			SETPIXELMASK(rightbitmask[count]);
+ 			/* Write mode 1 latch read/write. */
+ 			*destp = *srcp;
+ 			SETPIXELMASK(0xff);
+ 		}
+ 
+ 		destaddr -= (destpitch >> 3);
+ 		srcaddr -= (destpitch >> 3);
+ 	}
+ 
+ 	/* Disable extended write modes and BY8 addressing. */
+ 	SETMODEEXTENSIONS(DOUBLEBANKED);
+ 
+ 	SETWRITEMODE(0);
+ 
+ 	SETFOREGROUNDCOLOR(0x00);	/* Disable set/reset. */
+ }
+ 
+ 
+ /*
+  * Conventional framebuffer bitblt; no (x1 & 7 == x2 & 7) restriction.
+  */
+ 
+ #ifdef __STDC__
+ void CirrusSimpleBitBlt( int x1, int y1, int x2, int y2, int w, int h,
+ int destpitch )
+ #else
+ void CirrusSimpleBitBlt( x1, y1, x2, y2, w, h, destpitch )
+ 	int x1, y1, x2, y2, w, h, destpitch;
+ #endif
+ {
+ 	int j;
+ 	int destaddr, srcaddr;
+ 	unsigned char *destp, *srcp;
+ 	int writebank, readbank;
+ 	int bitoffset;
+ 	int syindex;
+ 
+ 	unsigned char *base;	/* Video window base address. */
+ 	int saveGRB;
+ 
+ 	base = vgaBase;			/* Read window. */
+ 					/* Write window is at offset 0x8000 */
+ 	destaddr = y2 * destpitch + x2;
+ 	srcaddr = y1 * destpitch + x1;
+ 
+ 	writebank = destaddr >> 14;	/* 16K units. */
+ 	setwritebank(writebank);
+ 	readbank = srcaddr >> 14;
+ 	setreadbank(readbank);
+ 	destaddr &= 0x3fff;
+ 	srcaddr &= 0x3fff;
+ 
+ 	for (j = 0; j < h; j++) {
+ 		if (destaddr >= 0x4000) {
+ 			/* 16K granularity is very helpful here. */
+ 			/* Because of the 32K window, we completely avoid */
+ 			/* page breaks within scanlines. */
+ 			writebank++;
+ 			setwritebank(writebank);
+ 			destaddr -= 0x4000;
+ 		}
+ 		if (srcaddr >= 0x4000) {
+ 			readbank++;
+ 			setreadbank(readbank);
+ 			srcaddr -= 0x4000;
+ 		}
+ 		/* Address in write window. */
+ 		destp = base + 0x8000 + destaddr;
+ 		/* Address in read window. */
+ 		srcp = base + srcaddr;
+ 
+ 		__memcpy(destp, srcp, w);
+ 
+ 		destaddr += destpitch;
+ 		srcaddr += destpitch;
+ 	}
+ }
+ 
+ 
+ /*
+  * This function uses the 8 data latches for fast 32 pixel wide tile fill.
+  *
+  * Arguments:
+  * x, y		Coordinates of the destination area.
+  * w, h		Size of the area.
+  * src		Pointer to tile.
+  * tpitch	Width of a tile line in bytes.
+  * twidth	Width of tile (should be 32).
+  * theight	Height of tile.
+  * toy		Tile y-origin.
+  * [tox]	Tile x-origin. [currently excluded]
+  *
+  * This functions is limited.
+  * It only works for x coordinates that are a multiple of 8, and
+  * width also a multiple of 8.
+  * The width must be >= 32.
+  * x-origin must correspond with the x coordinate.
+  */
+ 
+ #ifdef __STDC__
+ extern void CirrusColorExpandFillTile32( int x, int y, int w, int h,
+ unsigned char *src, int tpitch, int twidth, int theight, int toy, int destpitch )
+ #else
+ extern void CirrusColorExpandFillTile32( x, y, w, h, src, tpitch, twidth,
+ theight, toy, destpitch )
+ 	int x, y, w, h;
+ 	unsigned char *src;
+ 	int tpitch, twidth, theight, toy, destpitch;
+ #endif
+ {
+ 	int i, k;
+ 	int destaddr;
+ 	register unsigned char *destp;
+ 	int writebank;
+ 	int tyindex;
+ 	unsigned char *vtilep, *vtilelinep;
+ 	unsigned char *base;	/* Video window base address. */
+ 	int saveGRB;
+ 	int tcount, chunk8_tcount[4];
+ 
+ 	base = vgaBase;			/* Read window. */
+ 					/* Write window is at offset 0x8000 */
+ 
+ 	/* First write the tile at the top of memory. */
+ 	/* We use max. 256 bytes of memory. */
+         setwritebank(CirrusMemTop >> 14);
+ 	for (i = 0; i < theight; i++) {
+ 		if (i >= h)
+ 			break;
+ 		__memcpy(base + 0x8000 + (CirrusMemTop & 0x3fff) + i * 32,
+ 			src + i * tpitch, twidth);
+ 	}
+ 
+ 	/* Pointer to tile in read window in BY8 addressing mode. */
+ 	setreadbank((CirrusMemTop >> 3) >> 14);
+ 	vtilep = base + ((CirrusMemTop >> 3) & 0x3fff);
+ 
+ 	destaddr = y * destpitch + x;
+ 
+ 	/* Enable extended write modes, BY8 addressing, and 8 byte data */
+ 	/* latches. Every addressing byte corresponds to 8 pixels. */
+ 	SETMODEEXTENSIONS(EXTENDEDWRITEMODES | BY8ADDRESSING |
+ 		EIGHTDATALATCHES | DOUBLEBANKED);
+ 
+ 	SETWRITEMODE(1);
+ 
+ 	SETPIXELMASK(0xff);
+ 	SETFOREGROUNDCOLOR(0);		/* Disable set/reset. */
+ 
+ 	destaddr >>= 3;			/* Divide address by 8. */
+ 
+ 	writebank = destaddr >> 14;	/* 16K units. */
+ 	setwritebank(writebank);
+ 
+ 	/* Current tile line index. */
+ 	tyindex = (y - toy) % theight;
+ 
+ 	vtilelinep = vtilep + tyindex * 4;
+ 
+ 	/* Number of full tile 'widths'. */
+ 	tcount = w / 32;
+ 	/* Calculate how many full 8 pixels chunks we can write per */
+ 	/* scanline for each of the 4 chunks in the tile line. */
+ 	for (i = 0; i < 4; i++) {
+ 		int cnt;
+ 		cnt = tcount;
+ 		if (i < ((w >> 3) & 3))
+ 			/* Partial tile includes this 8 pixel chunk. */
+ 			cnt++;
+ 		chunk8_tcount[i] = cnt;
+ 	}
+ 
+ 	for (i = 0; i < h; i++) {
+ 		unsigned char *linep;
+ 
+ 		if (destaddr >= 0x4000) {
+ 			/* 16K granularity is very helpful here. */
+ 			/* Because of the 32K window, we completely avoid */
+ 			/* page breaks within scanlines. */
+ 			writebank++;
+ 			setwritebank(writebank);
+ 			destaddr -= 0x4000;
+ 		}
+ 		/* Address in write window. */
+ 		linep = base + 0x8000 + destaddr;
+ 
+ 		/* vtilelinep is pointer to tile line in video memory. */
+ 
+ 		for (k = 0; k < 4; k++) {
+ 		/* Handle tile line pixels (k * 8) to ((k + 1) * 8 - 1). */
+ 			unsigned char j;
+ 			__volatile__ unsigned char tmp;
+ 			/* Read 8 tile pixels into latches. */
+ 			tmp = vtilelinep[k];
+ 			/* Now write them at every 32th pixel offset */
+ 			/* in this scanline. */
+ 			destp = linep + k;
+ 			j = chunk8_tcount[k];
+ 			while (j >= 8) {
+ 				latchedwrite8step4(destp);
+ 				destp += 32;
+ 				j -= 8;
+ 			}
+ 			switch (j) {
+ 			/* Fall through. */
+ 			case 7 : *destp = 0; destp += 4;
+ 			case 6 : *destp = 0; destp += 4;
+ 			case 5 : *destp = 0; destp += 4;
+ 			case 4 : *destp = 0; destp += 4;
+ 			case 3 : *destp = 0; destp += 4;
+ 			case 2 : *destp = 0; destp += 4;
+ 			case 1 : *destp = 0;
+ 			case 0 : break;
+ 			}
+ 		}
+ 
+ 		destaddr += (destpitch >> 3);
+ 
+ 		tyindex++;
+ 		vtilelinep += 4;
+ 		if (tyindex == theight) {
+ 			tyindex = 0;
+ 			vtilelinep = vtilep;
+ 		}
+ 	}
+ 
+ 	/* Disable extended write modes and BY8 addressing. */
+ 	SETMODEEXTENSIONS(DOUBLEBANKED);
+ 
+ 	SETWRITEMODE(0);
+ 
+ 	SETFOREGROUNDCOLOR(0x00);	/* Disable set/reset. */
+ }
diff -c mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.c:2.21 mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.c:2.30
*** mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.c:2.21	Fri Mar 11 23:41:11 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.c	Fri Mar 11 23:41:11 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.c,v 2.21 1993/10/16 17:32:55 dawes Exp $
   * Header: /usr/local/src/Xaccel/cirrus/RCS/driver.c,v 1.6 1993/04/04 17:57:44 bill Exp
   *
   * Copyright 1993 by Bill Reynolds, Santa Fe, New Mexico
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.c,v 2.30 1994/03/08 04:52:15 dawes Exp $
   * Header: /usr/local/src/Xaccel/cirrus/RCS/driver.c,v 1.6 1993/04/04 17:57:44 bill Exp
   *
   * Copyright 1993 by Bill Reynolds, Santa Fe, New Mexico
***************
*** 26,31 ****
--- 26,33 ----
   * Modifications: David Dawes, <dawes@physics.su.oz.au>
   * Modifications: Piercarlo Grandi, Aberystwyth (pcg@aber.ac.uk)
   * Modifications: Simon P. Cooper, <scooper@vizlab.rutgers.edu>
+  * Modifications: Wolfgang Jung, <wong@cs.tu-berlin.de>
+  * Modifications: Harm Hanemaayer, <hhanemaa@cs.ruu.nl>
   *
   */
  
***************
*** 68,78 ****
  #define XCONFIG_FLAGS_ONLY
  #include "xf86_Config.h"
  #include "vga.h"
  
  #include "cir_driver.h"
  #include "cfbfuncs.h"
  
! static int cirrusChip;
  
  #define CLGD5420_ID 0x22
  #define CLGD5422_ID 0x23
--- 70,83 ----
  #define XCONFIG_FLAGS_ONLY
  #include "xf86_Config.h"
  #include "vga.h"
+ #include "region.h"
  
  #include "cir_driver.h"
  #include "cfbfuncs.h"
  
! int cirrusChip;
! int cirrusBusType;
! Bool cirrusUseBLTEngine = FALSE;
  
  #define CLGD5420_ID 0x22
  #define CLGD5422_ID 0x23
***************
*** 83,102 ****
  #define CLGD6215_ID 0x22  /* Hmmm... looks like a 5420 or 5422 */
  #define CLGD6225_ID 0x32
  #define CLGD6235_ID 0x06
  
! #define CLGD5420    0
! #define CLGD5422    1
! #define CLGD5424    2
! #define CLGD5426    3
! #define CLGD5428    4
! #define CLGD6205    5
! #define CLGD6215    6
! #define CLGD6225    7
! #define CLGD6235    8
! #define LASTCLGD    CLGD6235
  
- #define Is_62x5(x)  ((x) >= CLGD6205)
- 
  				/* For now, only save a couple of the */
  				/* extensions. */
  typedef struct {
--- 88,97 ----
  #define CLGD6215_ID 0x22  /* Hmmm... looks like a 5420 or 5422 */
  #define CLGD6225_ID 0x32
  #define CLGD6235_ID 0x06
+ #define CLGD543x_ID 0x29
  
! #define Is_62x5(x)  ((x) >= CLGD6205 && (x) <= CLGD6235_ID)
  
  				/* For now, only save a couple of the */
  				/* extensions. */
  typedef struct {
***************
*** 107,112 ****
--- 102,108 ----
    unsigned char SR7;		/* Extended Sequencer */
    unsigned char SRE;		/* VCLK Numerator */
    unsigned char SRF;		/* DRAM Control */
+   unsigned char SR16;		/* Performance Tuning Register */
    unsigned char SR1E;		/* VCLK Denominator */
    unsigned char CR19;		/* Interlace End */
    unsigned char CR1A;		/* Miscellaneous Control */
***************
*** 136,141 ****
--- 132,139 ----
  extern void     cirrusSetWrite2MB();
  extern void     cirrusSetReadWrite2MB();
  
+ extern void *CirrusCopyPlane();
+ 
  int	CirrusMemTop;
  
  vgaVideoChipRec CIRRUS = {
***************
*** 164,169 ****
--- 162,176 ----
    8,				/* ChipRounding */
  };
  
+ /*
+  * Note: To be able to use 16K bank granularity, we would have to half the
+  * read and write window sizes, because (it seems) cfb.banked can't handle
+  * a bank granularity different from the segment size.
+  * This means that we have to define a seperate set of banking routines in
+  * accel functions where the 16K hardware granularity is used.
+  */
+ int cirrusBankShift = 10;
+ 
  typedef struct {
    unsigned char numer;
    unsigned char denom;
***************
*** 202,208 ****
       ((((n) & 0x7F) * CLOCK_FACTOR / ((d) & 0x3E)) >> ((d) & 1))
  
  int cirrusClockLimit[] = {
!   75200,	/* 5420 */
    80100,	/* 5422 */
    80100,	/* 5424 */
    85500,	/* 5426 */
--- 209,215 ----
       ((((n) & 0x7F) * CLOCK_FACTOR / ((d) & 0x3E)) >> ((d) & 1))
  
  int cirrusClockLimit[] = {
!   50200,	/* 5420 */
    80100,	/* 5422 */
    80100,	/* 5424 */
    85500,	/* 5426 */
***************
*** 213,218 ****
--- 220,253 ----
    75200,	/* 6215 */
    75200,	/* 6225 */
    75200,	/* 6235 */
+   /*
+    * The 543x should be able to do 110+ MHz, but requires a mode of operation
+    * not yet supported by this server to do it.  Without this it is limited
+    * to 85MHz.
+    */
+   85500,	/* 543x */
+ };
+ 
+ /* Setting of the CRT FIFO threshold for each dot clock. There is a */
+ /* default setting, and a conservative and aggressive setting selectable */
+ /* by Xconfig option. */
+ 
+ static unsigned char default_FIFO_setting[] = {
+   8, 8, 8, 8, 8, 8, 8, 8,	/* dot clock <= 50 MHz */
+   10, 12, 13, 13,		/* 65, 72, 75, 80 MHz */
+   14, 14, 14, 14		/* 85, 90, 95, 100 MHz */
+ };
+ 
+ static unsigned char conservative_FIFO_setting[] = {
+   8, 8, 8, 8, 8, 8, 8, 8,	/* dot clock <= 50 MHz */
+   12, 14, 14, 14,		/* 65, 72, 75, 80 MHz */
+   14, 14, 14, 14		/* 85, 90, 95, 100 MHz */
+ };
+ 
+ static unsigned char aggressive_FIFO_setting[] = {
+   8, 8, 8, 8, 8, 8, 8, 8,	/* dot clock <= 50 MHz */
+   8, 8, 8, 8,			/* 65, 72, 75, 80 MHz */
+   8, 8, 8, 8			/* 85, 90, 95, 100 MHz */
  };
  
  #define new ((vgacirrusPtr)vgaNewVideoState)
***************
*** 227,232 ****
--- 262,268 ----
    static char *chipsets[] = {"clgd5420", "clgd5422", "clgd5424", "clgd5426",
  			     "clgd5428",
  			     "clgd6205", "clgd6215", "clgd6225", "clgd6235",
+ 			     "clgd543x"
  			    };
  
    if (n + 1 > sizeof(chipsets) / sizeof(char *))
***************
*** 350,355 ****
--- 386,392 ----
   */
  static int
  cirrusNumClocks(chip)
+      int chip;
  {
       cirrusClockRec *rec, *end = cirrusClockTab + NUM_CIRRUS_CLOCKS;
  
***************
*** 426,433 ****
  	  }
       else
  	  {
- 	  unsigned char temp, origVal, newVal;
- 	  
  	  cirrusEnterLeave(ENTER); /* Make the timing regs writable */
  	  
  	  /* Kited the following from the Cirrus */
--- 463,468 ----
***************
*** 501,506 ****
--- 536,546 ----
  	       cirrusChip = CLGD6235;
  	       break;
  
+ 	     /* 'Alpine' family. */
+ 	     case CLGD543x_ID:
+ 	       cirrusChip = CLGD543x;
+ 	       break;
+ 
  	     default:
  	       ErrorF("Unknown Cirrus chipset: type 0x%02, rev %d\n", id, rev);
  	       cirrusEnterLeave(LEAVE);
***************
*** 615,620 ****
--- 655,665 ----
  		    }
  	       }
  	  }
+      if (!OFLG_ISSET(OPTION_NOACCEL, &vga256InfoRec.options)) {
+          vga256InfoRec.videoRam--;
+          ErrorF("%s %s: %s\n", XCONFIG_PROBED, vga256InfoRec.name,
+ 		"available videoram reduced by 1k to allow for scratch space");
+      }
       /* 
        * Banking granularity is 16k for the 5426 or 5428
        * when allowing access to 2MB, and 4k otherwise 
***************
*** 624,632 ****
            CIRRUS.ChipSetRead = cirrusSetRead2MB;
            CIRRUS.ChipSetWrite = cirrusSetWrite2MB;
            CIRRUS.ChipSetReadWrite = cirrusSetReadWrite2MB;
            }
  
- 
       cirrusClockNo = cirrusNumClocks(cirrusChip);
       if (!vga256InfoRec.clocks)
            if (OFLG_ISSET(OPTION_PROBE_CLKS, &vga256InfoRec.options))
--- 669,677 ----
            CIRRUS.ChipSetRead = cirrusSetRead2MB;
            CIRRUS.ChipSetWrite = cirrusSetWrite2MB;
            CIRRUS.ChipSetReadWrite = cirrusSetReadWrite2MB;
+ 	  cirrusBankShift = 8;
            }
  
       cirrusClockNo = cirrusNumClocks(cirrusChip);
       if (!vga256InfoRec.clocks)
            if (OFLG_ISSET(OPTION_PROBE_CLKS, &vga256InfoRec.options))
***************
*** 659,671 ****
       ErrorF("CIRRUS: Warning: Out of spec clocks can be enabled\n");
  #endif
       OFLG_SET(OPTION_NOACCEL, &CIRRUS.ChipOptionFlags);
- #ifdef notyet
       OFLG_SET(OPTION_SLOW_DRAM, &CIRRUS.ChipOptionFlags);
- #endif
       OFLG_SET(OPTION_PROBE_CLKS, &CIRRUS.ChipOptionFlags);
       return(TRUE);
  }
  
  /*
   * cirrusFbInit --
   *      enable speedups for the chips that support it
--- 704,719 ----
       ErrorF("CIRRUS: Warning: Out of spec clocks can be enabled\n");
  #endif
       OFLG_SET(OPTION_NOACCEL, &CIRRUS.ChipOptionFlags);
       OFLG_SET(OPTION_SLOW_DRAM, &CIRRUS.ChipOptionFlags);
       OFLG_SET(OPTION_PROBE_CLKS, &CIRRUS.ChipOptionFlags);
+      OFLG_SET(OPTION_FAST_DRAM, &CIRRUS.ChipOptionFlags);
+      OFLG_SET(OPTION_FIFO_CONSERV, &CIRRUS.ChipOptionFlags);
+      OFLG_SET(OPTION_FIFO_AGGRESSIVE, &CIRRUS.ChipOptionFlags);
+      OFLG_SET(OPTION_NO_2MB_BANKSEL, &CIRRUS.ChipOptionFlags);
       return(TRUE);
  }
  
+ 
  /*
   * cirrusFbInit --
   *      enable speedups for the chips that support it
***************
*** 677,698 ****
  
    useSpeedUp = vga256InfoRec.speedup & SPEEDUP_ANYWIDTH;
    
!   if (((cirrusChip == CLGD5426) || (cirrusChip == CLGD5428)) &&
!       !OFLG_ISSET(OPTION_NOACCEL, &vga256InfoRec.options))
!     {
!       if (useSpeedUp && x386Verbose)
! 	{
! 	  ErrorF ("%s %s: Using accelerator functions\n",
! 		  XCONFIG_PROBED, cirrusIdent (cirrusChip) );
! 	}
! 
!       cfbLowlevFuncs.fillBoxSolid = CirrusFillBoxSolid;
!       cfbLowlevFuncs.fillRectSolidCopy = CirrusFillRectSolidCopy;
!       cfbLowlevFuncs.doBitbltCopy = CirrusDoBitbltCopy;
      }
  
    CirrusMemTop = vga256InfoRec.virtualX * vga256InfoRec.virtualY;
! }  
  
  /*
   * cirrusEnterLeave -- 
--- 725,869 ----
  
    useSpeedUp = vga256InfoRec.speedup & SPEEDUP_ANYWIDTH;
    
!   /* There doesn't seem to be an easy way to detect the bus type. */
!   /* An we can't write to video memory yet to measure it. */
!   /* It appears color expansion works well even on a slow bus, so we */
!   /* use it with any type of bus. The busspeed is hardwired to fast. */
!   cirrusBusType = CIRRUS_FASTBUS;
! 
!   cirrusUseBLTEngine = FALSE;
!   if ((cirrusChip == CLGD5426 || cirrusChip == CLGD5428 ||
!   cirrusChip == CLGD543x))
!       {
!       cirrusUseBLTEngine = TRUE;
! #if 0
!       /* Don't use the BitBLT engine on the 5426 and 5428 when using */
!       /* the second megabyte. */
!       if ((vga256InfoRec.virtualX * vga256InfoRec.virtualY + 256 >
!       1024 * 1024) && cirrusChip != CLGD543x)
!           {
!           cirrusUseBLTEngine = FALSE;
!           ErrorF("%s %s: BitBLT engine functions disabled for 2 Mbyte operation\n",
!             XCONFIG_PROBED, cirrusIdent(cirrusChip));
!           }
! #endif
!       }
! 
!   /*
!    * Report the internal MCLK value of the card, and change it if the
!    * "fast_dram" or "slow_dram" option is defined.
!    */
!   if (cirrusChip == CLGD5424 || cirrusChip == CLGD5426 ||
!       cirrusChip == CLGD5428 || cirrusChip == CLGD543x)
!       {
!       outb(0x3c4, 0x1f);
!       ErrorF("%s %s: Internal memory clock register value is 0x%02x\n",
!         XCONFIG_PROBED, cirrusIdent(cirrusChip), inb(0x3c5));
!       
!       if (OFLG_ISSET(OPTION_FAST_DRAM, &vga256InfoRec.options))
!           {
!       	  /*
!       	   * Change MCLK value. The databook is not very clear about this.
!       	   * I believe most cheap cards are misconfigured to a value that
!       	   * is too low (because they don't compensate for extended RAS
!       	   * timing).
!       	   *
!       	   * The BIOS default usually is 0x1c (50 MHz).
!       	   * On one card tested, with 80ns DRAM, 0x26 seems stable.
!       	   */
! 	  outw(0x3c4, 0x221f);		/* Set to 0x22 (about 62 MHz). */
!           ErrorF("%s %s: Internal memory clock register set to 0x22\n",
!             XCONFIG_GIVEN, cirrusIdent(cirrusChip));
! 	  }
! 
!       if (OFLG_ISSET(OPTION_SLOW_DRAM, &vga256InfoRec.options))
!           {
!           outw(0x3c4, 0x1c1f);		/* Set to 0x1c (50.1 MHz). */
!           ErrorF("%s %s: Internal memory clock register set to 0x1c\n",
!             XCONFIG_GIVEN, cirrusIdent(cirrusChip));
!           }
!       }
! 
!   /* Accel functions available on all chips. */
!   if (!OFLG_ISSET(OPTION_NOACCEL, &vga256InfoRec.options)) {
!     if (x386Verbose)
!       {
!         ErrorF ("%s %s: Using accelerator functions\n",
! 	    XCONFIG_PROBED, cirrusIdent (cirrusChip) );
!       }
!  
!     cfbLowlevFuncs.doBitbltCopy = CirrusDoBitbltCopy;
!     cfbLowlevFuncs.fillRectSolidCopy = CirrusFillRectSolidCopy;
!     cfbLowlevFuncs.fillBoxSolid = CirrusFillBoxSolid;
!     cfbLowlevFuncs.fillRectTransparentStippled32 =
!     	CirrusFillRectTransparentStippled32;
!     cfbLowlevFuncs.fillRectOpaqueStippled32 =
!     	CirrusFillRectOpaqueStippled32;
! 
!     /* Hook special op. fills (and tiles): */
!     cfbTEOps1Rect.PolyFillRect = CirrusPolyFillRect;
!     cfbNonTEOps1Rect.PolyFillRect = CirrusPolyFillRect;
!     cfbTEOps.PolyFillRect = CirrusPolyFillRect;
!     cfbNonTEOps.PolyFillRect = CirrusPolyFillRect;
! 
! #if 0
!     /* Cirrus line drawing acceleration. */
!     /* There's currently a problem with clipping regions. */
!     cfbLowlevFuncs.lineSS = CirrusLineSS;
!     cfbTEOps1Rect.Polylines = CirrusLineSS;
!     cfbTEOps.Polylines = CirrusLineSS;
!     cfbNonTEOps1Rect.Polylines = CirrusLineSS;
!     cfbNonTEOps.Polylines = CirrusLineSS;
!     cfbLowlevFuncs.segmentSS = CirrusSegmentSS;
!     cfbTEOps1Rect.PolySegment = CirrusSegmentSS;
!     cfbTEOps.PolySegment = CirrusSegmentSS;
!     cfbNonTEOps1Rect.PolySegment = CirrusSegmentSS;
!     cfbNonTEOps.PolySegment = CirrusSegmentSS;
! #endif
! 
! #if 0
!     /* Hook FillSpans: */
!     cfbTEOps1Rect.FillSpans = CirrusFillSpans;
!     cfbTEOps.FillSpans = CirrusFillSpans;
! #endif    
! 
!     if (HAVEBITBLTENGINE()) {
!         ErrorF ("%s %s: Using BitBLT engine\n",
! 	    XCONFIG_PROBED, cirrusIdent (cirrusChip) );
! #if 0
!         cfbTEOps1Rect.CopyPlane = CirrusCopyPlane;
!         cfbNonTEOps1Rect.CopyPlane = CirrusCopyPlane;
!         cfbTEOps.CopyPlane = CirrusCopyPlane;
!         cfbNonTEOps.CopyPlane = CirrusCopyPlane;
! #endif        
! 
!         cfbLowlevFuncs.teGlyphBlt8 = CirrusImageGlyphBlt;
!         cfbTEOps1Rect.ImageGlyphBlt = CirrusImageGlyphBlt;
!         cfbTEOps.ImageGlyphBlt = CirrusImageGlyphBlt;
! #if 0
!         cfbTEOps1Rect.PolyGlyphBlt = CirrusPolyGlyphBlt;
!         cfbTEOps.PolyGlyphBlt = CirrusPolyGlyphBlt;
! #endif
      }
+   }
  
    CirrusMemTop = vga256InfoRec.virtualX * vga256InfoRec.virtualY;
! 
!   /*
!    * This is now taken care of by decrementing vga256InfoRec.videoRam
!    * in the Probe().
!    */
! #if 0
!   if (CirrusMemTop + 256 >= vga256InfoRec.videoRam * 1024)
!       {
!       vga256InfoRec.virtualY--;
!       ErrorF ("%s %s: Virtual height modified to %d (need scratch space)\n",
!           XCONFIG_PROBED, cirrusIdent (cirrusChip), vga256InfoRec.virtualY);
!       }
!       CirrusMemTop = vga256InfoRec.virtualX * vga256InfoRec.virtualY;
! #endif
! 
! }
  
  /*
   * cirrusEnterLeave -- 
***************
*** 751,756 ****
--- 922,930 ----
    outw(0x3CE, 0x0009);	/* select bank 0 */
    outw(0x3CE, 0x000A);
  
+   outb(0x3C4,0x0F);		/* Restoring this registers avoids */
+   outb(0x3C5,restore->SRF);	/* textmode corruption on 2Mb cards. */
+ 
    vgaHWRestore(restore);
  
  /*  unsigned char GR9;		 Graphics Offset1 */
***************
*** 759,764 ****
--- 933,939 ----
  /*  unsigned char SR7;		 Extended Sequencer */
  /*  unsigned char SRE;		 VCLK Numerator */
  /*  unsigned char SRF;		 DRAM Control */
+ /*  unsigned char SR16;		 Performance Tuning Register */
  /*  unsigned char SR1E;		 VCLK Denominator */
  /*  unsigned char CR19;		 Interlace End */
  /*  unsigned char CR1A;		 Miscellaneous Control */
***************
*** 784,791 ****
         outb(0x3C5,restore->SRE);
         }
  
!   outb(0x3C4,0x0F);
!   outb(0x3C5,restore->SRF);
  
    if (restore->std.NoClock >= 0)
         {
--- 959,971 ----
         outb(0x3C5,restore->SRE);
         }
  
!   if (cirrusChip == CLGD5424 || cirrusChip == CLGD5426 || cirrusChip == CLGD5428
!   || cirrusChip == CLGD543x)
!        {
!        /* Restore the Performance Tuning Register on these 4 chips only. */
!        outb(0x3C4,0x16);
!        outb(0x3C5,restore->SR16);
!        }
  
    if (restore->std.NoClock >= 0)
         {
***************
*** 873,878 ****
--- 1053,1066 ----
    outb(0x3C4,0x0F);
    save->SRF = inb(0x3C5);
  
+   if (cirrusChip == CLGD5424 || cirrusChip == CLGD5426
+   || cirrusChip == CLGD5428 || cirrusChip == CLGD543x)
+        {
+        /* Save the Performance Tuning Register on these 4 chips only. */
+         outb(0x3C4,0x16);
+         save->SR16 = inb(0x3C5);
+        }
+ 
    outb(0x3C4,0x1E);
    save->SR1E = inb(0x3C5);
  
***************
*** 916,923 ****
  cirrusInit(mode)
       DisplayModePtr mode;
  {
-      unsigned char temp1;
-      
    if (!vgaHWInit(mode,sizeof(vgacirrusRec)))
      return(FALSE);
  
--- 1104,1109 ----
***************
*** 927,932 ****
--- 1113,1119 ----
  /*  unsigned char SR7;		 Extended Sequencer */
  /*  unsigned char SRE;		 VCLK Numerator */
  /*  unsigned char SRF;		 DRAM Control */
+ /*  unsigned char SR16;		 Performance Tuning Register */
  /*  unsigned char SR1E;		 VCLK Denominator */
  /*  unsigned char CR19;		 Interlace End */
  /*  unsigned char CR1A;		 Miscellaneous Control */
***************
*** 975,991 ****
  				/* Enable Dual Banking */
       new->GRB = 0x01;
  
! 				/* Setting the 5 bit to either 1 or 0 works. */
! 				/* I don't understand the difference. The */
! 				/* book says this bit is the "CRT FIFO */
! 				/* Depth". */
       outb(0x3C4,0x0F);
       new->SRF = inb(0x3C5);
  
       if (CIRRUS.ChipSetRead != cirrusSetRead)
  	  {
  	  new->GRB |= 0x20;	/* Set 16k bank granularity */
! 	  new->SRF |= 0x80;	/* Enable the second MB */
  	  }
  
       new->SR7 = 0x01;		/* Tell it to use 256 Colors */
--- 1162,1219 ----
  				/* Enable Dual Banking */
       new->GRB = 0x01;
  
! 
       outb(0x3C4,0x0F);
       new->SRF = inb(0x3C5);
  
+      /* This following bit was not set correctly. */
+      /* It is vital for correct operation at high dot clocks. */
+  
+      if (cirrusChip == CLGD5422 || cirrusChip == CLGD5424 || 
+ 	 cirrusChip == CLGD5426	|| cirrusChip == CLGD5428 ||
+ 	 cirrusChip == CLGD543x) 
+ 	 {
+          new->SRF |= 0x20;	/* Enable 64 byte FIFO. */
+          }
+ 
+      if (cirrusChip == CLGD5424 || cirrusChip == CLGD5426 ||
+          cirrusChip == CLGD5428 || cirrusChip == CLGD543x)
+          {
+ 
+ 	 /* Now set the CRT FIFO threshold (in 4 byte words). */
+ 	 outb(0x3C4,0x16);
+ 	 new->SR16 = inb(0x3C5) & 0xF0;
+ 
+ 	 /* We have an option for conservative, or aggressive setting. */
+ 	 /* The default is something in between. */
+ 
+ 	 if (OFLG_ISSET(OPTION_FIFO_CONSERV, &vga256InfoRec.options))
+ 	     {
+ 	     if (!(mode->Flags & V_INTERLACE))	/* For interlaced, use 0. */
+ 	         new->SR16 |= conservative_FIFO_setting[new->std.NoClock];
+              }
+          else
+ 	 if (OFLG_ISSET(OPTION_FIFO_AGGRESSIVE, &vga256InfoRec.options))
+ 	     {
+ 	     if (!(mode->Flags & V_INTERLACE))	/* For interlaced, use 0. */
+ 	         new->SR16 |= aggressive_FIFO_setting[new->std.NoClock];
+              }
+          else
+              {
+ 	     if (!(mode->Flags & V_INTERLACE))	/* For interlaced, use 0. */
+ 	         new->SR16 |= default_FIFO_setting[new->std.NoClock];
+              }
+          }
+ 
       if (CIRRUS.ChipSetRead != cirrusSetRead)
  	  {
  	  new->GRB |= 0x20;	/* Set 16k bank granularity */
! 	  if (vga256InfoRec.virtualX * vga256InfoRec.virtualY + 256 >
! 	  (1024 * 1024)
! 	  && !OFLG_ISSET(OPTION_NO_2MB_BANKSEL, &vga256InfoRec.options))
! 	      new->SRF |= 0x80;	/* Enable the second MB */
! 	  			/* This may be a bad thing for some */
! 	  			/* 2Mb cards. */
  	  }
  
       new->SR7 = 0x01;		/* Tell it to use 256 Colors */
diff -c mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.h:2.0 mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.h:2.6
*** mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.h:2.0	Fri Mar 11 23:41:12 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.h	Fri Mar 11 23:41:12 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.h,v 2.0 1993/09/21 15:24:30 dawes Exp $
   *
   * Copyright 1993 by Simon P. Cooper, New Brunswick, New Jersey, USA.
   *
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_driver.h,v 2.6 1994/03/07 14:02:22 dawes Exp $
   *
   * Copyright 1993 by Simon P. Cooper, New Brunswick, New Jersey, USA.
   *
***************
*** 22,35 ****
   * PERFORMANCE OF THIS SOFTWARE.
   *
   * Author:  Simon P. Cooper, <scooper@vizlab.rutgers.edu>
   *
   * Id: cir_driver.h,v 0.7 1993/09/16 01:07:25 scooper Exp
   */
  
  extern void CirrusFillBoxSolid();
! extern void CirrusFillRectSolidCopy();
! extern int  CirrusDoBitbltCopy();
  
  #define CROP_0			0x00	/*     0 */
  #define CROP_1			0x0E	/*     1 */
  #define CROP_SRC		0x0D	/*     S */
--- 22,159 ----
   * PERFORMANCE OF THIS SOFTWARE.
   *
   * Author:  Simon P. Cooper, <scooper@vizlab.rutgers.edu>
+  * Modified: Harm Hanemaayer, <hhanemaa@cs.ruu.nl>
   *
   * Id: cir_driver.h,v 0.7 1993/09/16 01:07:25 scooper Exp
   */
  
+ #include <X11/Xfuncproto.h>
+ 
+ _XFUNCPROTOBEGIN
+ 
+ extern void CirrusFillRectSolidCopy();		/* GXcopy fill. */
+ extern void CirrusFillRectSolidGeneral();	/* Non-GXcopy fill. */
+ /* In cir_blt.c: */
+ extern void CirrusBitBlt();
+ 
+ /* LowlevelFuncs: */
+ 
+ extern int CirrusDoBitbltCopy();
  extern void CirrusFillBoxSolid();
! 
! extern void CirrusFillRectOpaqueStippled32();
! extern void CirrusFillRectTransparentStippled32();
! extern void CirrusFillRectTile();
! 
! /* Higher level functions: */
! 
! extern void CirrusSegmentSS();
! extern void CirrusLineSS();
! 
! extern void CirrusImageGlyphBlt();
! extern void CirrusPolyGlyphBlt();
! 
! extern void CirrusPolyFillRect();
! extern void CirrusFillSpans();
! 
! /* Low-level graphics display functions: */
! 
! /* In cir_blt.c: */
! extern void CirrusBitBlt();
! 
! /* In cir_imageblt.s:  */
! #if NeedFunctionPrototypes
! extern void CirrusImageWriteTransfer( int w, int h, void *srcaddr,
! 	int srcwidth, void *vaddr );
! extern void CirrusImageReadTransfer( int w, int h, void *srcaddr,
! 	int srcwidth, void *vaddr );
! #else
! extern void CirrusImageWriteTransfer();
! extern void CirrusImageReadTransfer();
! #endif
! 
! /* In cir_colorexp.c: */
! #if NeedFunctionPrototypes
! extern void CirrusColorExpand32bitFill( int x, int y, int w, int h,
! 	unsigned long *bits, int sh, int sox, int soy, int bg, int fg,
! 	int destpitch );
! extern void Cirrus32bitFillSmall( int x, int y, int w, int h,
! 	unsigned long *bits, int sh, int sox, int soy, int bg, int fg,
! 	int destpitch );
! extern void CirrusLatchedBitBlt( int x1, int y1, int x2, int y2,
! 	int w, int h, int destpitch );
! extern void CirrusLatchedBitBltReversed( int x1, int y1, int x2, int y2,
! 	int w, int h, int destpitch );
! extern void CirrusSimpleBitBlt( int x1, int y1, int x2, int y2,
!   	int w, int h, int destpitch );
! extern void CirrusColorExpandFillTile32( int x, int y, int w, int h,
! 	unsigned char *src, int tpitch, int twidth, int theight, int toy,
! 	int destpitch );
! #else
! extern void CirrusColorExpand32bitFill();
! extern void Cirrus32bitFillSmall();
! extern void CirrusLatchedBitBlt();
! extern void CirrusLatchedBitBltReversed();
! extern void CirrusSimpleBitBlt();
! extern void CirrusColorExpandFillTile32();
! #endif
! /* In cir_blitter.c: */
! #if NeedFunctionPrototypes
! extern void CirrusBLTColorExpand8x8PatternFill( unsigned destaddr, int fg,
! 	int bg,	int w, int h, int destpitch, int rop, unsigned long pword1,
! 	unsigned long pword2 );
! extern void CirrusBLT8x8PatternFill( unsigned destaddr, int w, int h,
! 	void *pattern, int destpitch, int rop );
! extern void CirrusBLT16x16PatternFill( unsigned destaddr, int w, int h,
! 	unsigned char *pattern, int destpitch, int rop );
! extern void CirrusBLTBitBlt( unsigned dstAddr, unsigned srcAddr,
! 	int dstPitch, int srcPitch, int w, int h, int dir );
! extern void CirrusBLTWaitUntilFinished(void);	
! #else
! extern void CirrusBLTColorExpand8x8PatternFill();
! extern void CirrusBLT8x8PatternFill();
! extern void CirrusBLT16x16PatternFill();
! extern void CirrusBLTBitBlt();
! extern void CirrusBLTWaitUntilFinished();
! #endif
! /* In cir_im.c: */
! extern void CirrusImageWrite();
! extern void CirrusImageRead();
! #if NeedPrototypes
! extern void CirrusWriteBitmap( int x, int y, int w, int h,
! 	unsigned char *srcp, int bwidth, int bw, int bh, int box, int boy,
! 	int bg, int fg, int destpitch, int alu );
! #else
! extern void CirrusWriteBitmap();
! #endif
! 
! _XFUNCPROTOEND
! 
! /* Card type variables; used for selection of accel routines. */
! 
! extern int cirrusChip;
! extern int cirrusBusType;
! extern Bool cirrusUseBLTEngine;
! 
! extern int CirrusMemTop;
! extern int cirrusBankShift;
! 
! #define CLGD5420    0
! #define CLGD5422    1
! #define CLGD5424    2
! #define CLGD5426    3
! #define CLGD5428    4
! #define CLGD6205    5
! #define CLGD6215    6
! #define CLGD6225    7
! #define CLGD6235    8
! #define CLGD543x    9
! #define LASTCLGD    CLGD543x
! 
! #define CIRRUS_SLOWBUS 0
! #define CIRRUS_FASTBUS 1
  
+ 
  #define CROP_0			0x00	/*     0 */
  #define CROP_1			0x0E	/*     1 */
  #define CROP_SRC		0x0D	/*     S */
***************
*** 47,49 ****
--- 171,233 ----
  #define CROP_XOR		0x59	/*  S~=D */
  #define CROP_XNOR		0x95	/*   S=D */
  
+ /* Array that maps from alu to Cirrus ROP. */
+ 
+ extern int cirrus_rop[];
+ 
+ /* Look-up table for per-byte bit order reversal. */
+ 
+ extern unsigned char byte_reversed[];
+ 
+ 
+ #define HAVE543X() (cirrusChip == CLGD543x)
+ 
+ #define HAVEBITBLTENGINE() (cirrusUseBLTEngine)
+ 
+ #define SETWRITEMODE(n) \
+ 	{ \
+ 		unsigned char tmp; \
+ 		outb(0x3ce, 0x05); \
+ 		tmp = inb(0x3cf) & 0xf8; \
+ 		outb(0x3cf, tmp | (n)); \
+ 	}
+ 
+ #define SETFOREGROUNDCOLOR(c) \
+ 	outw(0x3ce, 0x01 + ((c) << 8));
+ 
+ #define SETBACKGROUNDCOLOR(c) \
+ 	outw(0x3ce, 0x00 + ((c) << 8));
+ 
+ #define SETPIXELMASK(m) \
+ 	outw(0x3c4, 0x02 + ((m) << 8));
+ 
+ #define EIGHTDATALATCHES	0x08
+ #define EXTENDEDWRITEMODES	0x04
+ #define BY8ADDRESSING		0x02
+ #define DOUBLEBANKED		0x01
+ #define SINGLEBANKED		0x00
+ 
+ #define SETMODEEXTENSIONS(m) \
+ 	{ \
+ 		unsigned char tmp; \
+ 		outb(0x3ce, 0x0b); \
+ 		tmp = inb(0x3cf) & 0xe0; \
+ 		outb(0x3cf, tmp | (m)); \
+ 	}
+ 
+ /* We use a seperate banking routine with 16K granularity for some accel. */
+ /* functions. Knows about different bank granularity for 2Mb cards. */
+ 
+ #define setwritebank(n) \
+ 	outw(0x3ce, 0x0a + ((n) << cirrusBankShift));
+ 
+ #define setreadbank(n) \
+ 	outw(0x3ce, 0x09 + ((n) << cirrusBankShift));
+ 
+ #define setbank setreadbank
+ 
+ 
+ #if !defined(__GNUC__) || defined(NO_INLINE)
+ #undef __inline__
+ #define __inline__ /**/
+ #endif
diff -c mit/server/ddx/x386/vga256/drivers/cirrus/cir_fill.c:2.1 mit/server/ddx/x386/vga256/drivers/cirrus/cir_fill.c:2.3
*** mit/server/ddx/x386/vga256/drivers/cirrus/cir_fill.c:2.1	Fri Mar 11 23:41:12 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_fill.c	Fri Mar 11 23:41:12 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_fill.c,v 2.1 1993/09/24 17:09:13 dawes Exp $
   *
   * Copyright 1993 by Bill Reynolds, Santa Fe, New Mexico
   *
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_fill.c,v 2.3 1994/02/24 12:43:35 dawes Exp $
   *
   * Copyright 1993 by Bill Reynolds, Santa Fe, New Mexico
   *
***************
*** 24,33 ****
--- 24,39 ----
   * Author:  Bill Reynolds, bill@goshawk.lanl.gov
   *
   * Reworked by: Simon P. Cooper, <scooper@vizlab.rutgers.edu>
+  * Modified by: Harm Hanemaayer, <hhanemaa@cs.ruu.nl>
   *
   * Id: cir_fill.c,v 0.7 1993/09/16 01:07:25 scooper Exp
   */
  
+ /*
+  * This file contains mid-level solid fill functions that call different
+  * low-level functions depending on size, card configuration etc.
+  */
+ 
  #include "X.h"
  #include "Xmd.h"
  #include "servermd.h"
***************
*** 42,47 ****
--- 48,54 ----
  #include "cfbrrop.h"
  #include "mergerop.h"
  #include "vgaBank.h"
+ #include "vga.h"	/* For vgaBase. */
  
  #include "compiler.h"
  
***************
*** 51,135 ****
  
  void CirrusFillBoxSolid();
  
  void
! CirrusFillSolid(dstAddr,pdstBase,pat,fillHeight,fillWidth,dstPitch,rop)
!      unsigned int dstAddr;
!      unsigned char *pdstBase;
!      unsigned long pat;
!      int fillHeight,fillWidth,dstPitch;
!      int rop;
  {
!   volatile unsigned char tmpreg;
!   unsigned int srcAddr;
!   int i;
!   pointer pDst;
!   extern int CirrusMemTop;
!   extern pointer vgaBase;
! 
!   /* Write out the initial 8x8 pattern, */
!   /* We'll write it above the displayable */
!   /* board memory */
!      
!   srcAddr = CirrusMemTop + 4;
!   pDst = pdstBase + srcAddr;
! 
!   BANK_FLAG(pDst);
!   SETW(pDst);
!   for(i=0;i<16;i++)
!     {
!       *((*(int **)&pDst)++) = pat;
!       CHECKWO(pDst);
!     }
!      
!   /* BLTBIT screen -> screen copy */
! 
!   /* Set the DstAddress */
! 
!   outw (0x3CE, ((dstAddr & 0x000000FF) << 8) | 0x28);
!   outw (0x3CE, ((dstAddr & 0x0000FF00)) | 0x29);
!   outw (0x3CE, ((dstAddr & 0x001F0000) >> 8) | 0x2A);
! 
!   /* Set the SrcAddress */
! 
!   outw (0x3CE, ((srcAddr & 0x000000FF) << 8) | 0x2C);
!   outw (0x3CE, ((srcAddr & 0x0000FF00)) | 0x2D);
!   outw (0x3CE, ((srcAddr & 0x001F0000) >> 8) | 0x2E);
! 
!   /* Set the Dest Pitch */
! 
!   outw (0x3CE, ((dstPitch & 0x000000FF) << 8) | 0x24);
!   outw (0x3CE, ((dstPitch & 0x00000F00)) | 0x25);
!   
!   fillWidth--;
!   outw (0x3CE, ((fillWidth & 0x000000FF) << 8) | 0x20);
!   outw (0x3CE, ((fillWidth & 0x00000700)) | 0x21);
! 
!   /* Set the Height */
! 
!   fillHeight--;
!   outw (0x3CE, ((fillHeight & 0x000000FF) << 8) | 0x22);
!   outw (0x3CE, ((fillHeight & 0x00000300)) | 0x23);
! 
!   /* Set: 8x8 Pattern Copy, Screen <-> screen blt, forwards */
! 
!   outw (0x3CE, (0x40 << 8) | 0x30);
  
!   /* Set the ROP: Copy = 0x0D */
!   outw (0x3CE, (rop << 8) | 0x32);
  
-   /* Ok, we're all loaded up, let's do it */
-   outw (0x3CE, (0x02 << 8) | 0x31);
  
!   do
!     {
!       outb (0x3CE, 0x31);
!       tmpreg = inb (0x3CF);
!     }
!   while (tmpreg & 0x01);
! }
  
  void
! CirrusFillRectSolidCopy (pDrawable, pGC, nBox, pBox)
      DrawablePtr	    pDrawable;
      GCPtr	    pGC;
      int		    nBox;
--- 58,82 ----
  
  void CirrusFillBoxSolid();
  
+ 
  void
! CirrusFillRectSolidCopy (pDrawable, pGC, nBox, pBox)
!     DrawablePtr	    pDrawable;
!     GCPtr	    pGC;
!     int		    nBox;
!     BoxPtr	    pBox;
  {
!   unsigned long rrop_xor,rrop_and;
!   RROP_FETCH_GC(pGC);
  
!   CirrusFillBoxSolid (pDrawable, nBox, pBox, rrop_xor, 0, pGC->alu);
! }
  
  
! /* This is what CirrusPolyFillRect uses for non-GXcopy fills. */
  
  void
! CirrusFillRectSolidGeneral (pDrawable, pGC, nBox, pBox)
      DrawablePtr	    pDrawable;
      GCPtr	    pGC;
      int		    nBox;
***************
*** 137,145 ****
  {
    unsigned long rrop_xor,rrop_and;
    RROP_FETCH_GC(pGC);
!   CirrusFillBoxSolid (pDrawable, nBox, pBox, rrop_xor, 0, GXcopy);
  }
  
  void
  CirrusFillBoxSolid (pDrawable, nBox, pBox, pixel1, pixel2, alu)
      DrawablePtr	    pDrawable;
--- 84,138 ----
  {
    unsigned long rrop_xor,rrop_and;
    RROP_FETCH_GC(pGC);
! 
!   if ((pGC->planemask & 0xff) == 0xff)
!       CirrusFillBoxSolid(pDrawable, nBox, pBox, pGC->fgPixel, pGC->bgPixel,
!           pGC->alu);
!   else
!       cfbFillRectSolidGeneral(pDrawable, pGC, nBox, pBox);
! }
! 
! 
! #ifdef DETERMINE_BUSSPEED
! 
! /* Function to determine bus speed. This is a bad hack, but we need to */
! /* know how fast the bus is for good acceleration selection. */
! 
! static int busspeed_initialized = 0;
! 
! static void CirrusDetermineBusSpeed() {
! 	int starttime, difftime;
! 	int count;
! 	starttime = GetTimeInMillis();
! 	/* Write 1Mb to the card. */
! 	count = 20;
! 	while (count > 0) {
! 		memset(vgaBase, 0, 50000);
! 		count--;
! 	}
! 	difftime = GetTimeInMillis() - starttime;
! 	if (difftime == 0)
! 		difftime = 1;
! 	cirrusBusType = CIRRUS_SLOWBUS;
! 	if (1000 / difftime >= 8)
! 		cirrusBusType = CIRRUS_FASTBUS;
! #if 0
! 	if (x386Verbose)
! #endif	
! 		ErrorF("Cirrus: Approximate bus speed (memset): %dMb/s %s\n",
! 			1000 / difftime,
! 			cirrusBusType == CIRRUS_FASTBUS ?
! 			"(fast color expansion via bus)" :
! 			"(emphasis on BitBLT engine)"
! 			);
! 	busspeed_initialized = 1;
  }
  
+ #endif
+ 
+ 
+ /* General mid-level solid fill. Makes a choice of low-level routines. */
+ 
  void
  CirrusFillBoxSolid (pDrawable, nBox, pBox, pixel1, pixel2, alu)
      DrawablePtr	    pDrawable;
***************
*** 150,165 ****
      int	            alu;
  {
    unsigned char   *pdstBase;
-   unsigned long   fill2;
-   unsigned char   *pdst;
-   register int    hcount, vcount, count;
-   int             widthPitch;
    Bool            flag;
!   int		    widthDst;
    int             h;
!   unsigned long   fill1;
!   int             m;
!   int		    w;
  
    if (pDrawable->type == DRAWABLE_WINDOW)
      {
--- 143,159 ----
      int	            alu;
  {
    unsigned char   *pdstBase;
    Bool            flag;
!   int		  widthDst;
    int             h;
!   int		  w;
! 
! #ifdef DETERMINE_BUSSPEED
!   /* Hook into the initial server root fill to determine */
!   /* the bus speed (another hack). */
!   if (!busspeed_initialized)
!       CirrusDetermineBusSpeed();
! #endif
  
    if (pDrawable->type == DRAWABLE_WINDOW)
      {
***************
*** 174,222 ****
        widthDst = (int)(((PixmapPtr)pDrawable)->devKind);
      }
  
!   flag = CHECKSCREEN(pdstBase);
!   fill1 = PFILL(pixel1);
!   fill2 = PFILL(pixel2);
!     
!   if(flag)			/* i.e. We're filling a box on the screen */
      {
        for (; nBox; nBox--, pBox++)
  	{
  	  unsigned int dstAddr;
  	      
- 	  dstAddr = pBox->y1 * widthDst + pBox->x1;
  	  h = pBox->y2 - pBox->y1;
  	  w = pBox->x2 - pBox->x1;
  	  
! 	  switch (alu)
! 	    {
! 	    case GXcopy:
! 	      CirrusFillSolid(dstAddr,pdstBase,fill1,h,w,widthDst,CROP_SRC);
! 	      break;
! 
! 	    case GXor:
! 	      CirrusFillSolid(dstAddr,pdstBase,fill1,h,w,widthDst,CROP_OR);
! 	      break;
! 
! 	    case GXand:
! 	      CirrusFillSolid(dstAddr,pdstBase,fill1,h,w,widthDst,CROP_AND);
! 	      break;
! 
! 	    case GXxor:
!       	      CirrusFillSolid(dstAddr,pdstBase,fill1,h,w,widthDst,CROP_XOR);
! 	      break;
! 
! 	    case GXset:
! 	      /* This is a hack, but it should be doing the right thing */
! 
!       	      CirrusFillSolid(dstAddr,pdstBase,fill1,h,w,widthDst,CROP_AND);
!       	      CirrusFillSolid(dstAddr,pdstBase,fill2,h,w,widthDst,CROP_XOR);
! 	      break;
! 	      
! 	    default: 
! 	      return; 
! 	      break;
! 	    }
  	}
      }
    else cfbFillBoxSolid (pDrawable, nBox, pBox, pixel1, pixel2, alu);
--- 168,247 ----
        widthDst = (int)(((PixmapPtr)pDrawable)->devKind);
      }
  
!   flag = CHECKSCREEN(pdstBase);	/* On screen? */
! 
!   if (alu != GXcopy && !HAVEBITBLTENGINE())
!       /* We can't handle non-GXcopy fills without the blit engine. */
!       flag = 0;
! 
!   if (flag)
      {
+ 
        for (; nBox; nBox--, pBox++)
  	{
  	  unsigned int dstAddr;
  	      
  	  h = pBox->y2 - pBox->y1;
  	  w = pBox->x2 - pBox->x1;
  	  
!           dstAddr = pBox->y1 * widthDst + pBox->x1;
! 
!           if (alu == GXcopy) {
!               unsigned long bits;
! 
!               /* For small widths, we use the specific function for small */
!               /* widths (which is not really accelerated). */          
!               if (w < 32) {
!                   bits = 0xffffffff;
!        	          Cirrus32bitFillSmall(pBox->x1, pBox->y1, w, h,
!        	              &bits, 1, 0, 0, pixel1, pixel1, widthDst);
!        	          continue;
!        	      }
! 	
! 	      /* We use the color expansion function for solid fills in the
! 	       * following cases:
! 	       * - If the chip has no bitblt engine (i.e. 5420/2/4).
! 	       * - If we have a bitblt engine, but the card is local bus
! 	       *   and the width is big enough, with different cut-off
! 	       *   points for the 5426 and 5428.
! 	       *   For 5434 (speculative), the bitblt engine is used.
! 	       */
! 	      if (!HAVEBITBLTENGINE() ||
! 	          (cirrusBusType == CIRRUS_FASTBUS &&
! 	          ((cirrusChip == CLGD5426 && w >= 200) ||
! 	           (cirrusChip == CLGD5428 && w >= 250)))) {
!                   bits = 0xffffffff;
!                   CirrusColorExpand32bitFill(pBox->x1, pBox->y1, w, h,
!         	      &bits, 1, 0, 0, pixel1, pixel1, widthDst);
!         	  continue;
!               }
! 
!               /* Avoid the blitter setup overhead for remaining small fills. */
!               if (w * h < 100) {
!                   bits = 0xffffffff;
!        	          Cirrus32bitFillSmall(pBox->x1, pBox->y1, w, h,
!        	              &bits, 1, 0, 0, pixel1, pixel1, widthDst);
!        	          continue;
!        	      }
! 
!               /* Use the blitter. */
!               CirrusBLTColorExpand8x8PatternFill(dstAddr, pixel1, pixel2, w,
!                   h, widthDst, CROP_SRC, 0xffffffff, 0xffffffff);
! 
!           }
!           else {	/* alu != GXcopy */
!               /* This is a joke. The alu is always GXcopy. */
!               /* When this is changed, we'll be able use the blitter for */
!               /* almost all operations (notably Invert will help the */
!               /* xstone benchmark, for what it's worth). */
!              
!               /* OK, it should be fixed now. It is used. And we support all */
!               /* rops. */
!               /* [Note: Invert basically doubled the blit xstones...] */
! 
! 	      CirrusBLTColorExpand8x8PatternFill(dstAddr, pixel1, pixel2, w,
! 	          h, widthDst, cirrus_rop[alu], 0xffffffff, 0xffffffff);
!           }
  	}
      }
    else cfbFillBoxSolid (pDrawable, nBox, pBox, pixel1, pixel2, alu);
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_fillrct.c:2.0
*** /dev/null	Fri Mar 11 23:41:13 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_fillrct.c	Fri Mar 11 23:41:13 1994
***************
*** 0 ****
--- 1,262 ----
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_fillrct.c,v 2.0 1994/02/24 12:43:37 dawes Exp $ */
+ /*
+  * Fill rectangles.
+  */
+ 
+ /*
+ Copyright 1989 by the Massachusetts Institute of Technology
+ 
+ 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 M.I.T. not be used in
+ advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission.  M.I.T. makes no
+ representations about the suitability of this software for any
+ purpose.  It is provided "as is" without express or implied warranty.
+ */
+ 
+ /* $XConsortium: cfbfillrct.c,v 5.13 90/05/15 18:40:19 keith Exp $ */
+ 
+ /* Modified for Cirrus by Harm Hanemaayer, <hhanemaa@cs.ruu.nl> */
+ 
+ 
+ /*
+  * This file contains the high level PolyFillRect function.
+  *
+  * We need to reproduce this to be able to use our own non-GXcopy
+  * solid fills, and tiles.
+  */
+ 
+ 
+ #include "X.h"
+ #include "Xmd.h"
+ #include "servermd.h"
+ #include "gcstruct.h"
+ #include "window.h"
+ #include "pixmapstr.h"
+ #include "scrnintstr.h"
+ #include "windowstr.h"
+ 
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "cfbrrop.h"
+ #include "mergerop.h"
+ #include "cfbfuncs.h"
+ 
+ #include "cir_driver.h"
+ 
+ extern cfbFillRectSolidGeneral();
+ 
+ #if PPW == 4
+ extern void cfb8FillRectStippledUnnatural();
+ #endif
+ 
+ extern cfbFillRectTileOdd();
+ extern cfbFillRectTile32Copy();
+ extern cfbFillRectTile32General();
+ 
+ 
+ #define NUM_STACK_RECTS	1024
+ 
+ void
+ CirrusPolyFillRect(pDrawable, pGC, nrectFill, prectInit)
+     DrawablePtr pDrawable;
+     register GCPtr pGC;
+     int		nrectFill; 	/* number of rectangles to fill */
+     xRectangle	*prectInit;  	/* Pointer to first rectangle to fill */
+ {
+     xRectangle	    *prect;
+     RegionPtr	    prgnClip;
+     register BoxPtr pbox;
+     register BoxPtr pboxClipped;
+     BoxPtr	    pboxClippedBase;
+     BoxPtr	    pextent;
+     BoxRec	    stackRects[NUM_STACK_RECTS];
+     cfbPrivGC	    *priv;
+     int		    numRects;
+     void	    (*BoxFill)();
+     int		    n;
+     int		    xorg, yorg;
+     RROP_DECLARE
+ 
+     priv = (cfbPrivGC *) pGC->devPrivates[cfbGCPrivateIndex].ptr;
+     prgnClip = priv->pCompositeClip;
+ 
+     BoxFill = 0;
+     switch (pGC->fillStyle)
+     {
+     case FillSolid:
+ 	RROP_FETCH_GCPRIV(priv)
+ 	switch (priv->rop) {
+ 	case GXcopy:
+ 	    BoxFill = cfbLowlevFuncs.fillRectSolidCopy;
+ 	    break;
+ 	default:
+ 	    /* BoxFill = cfbFillRectSolidGeneral; */
+ 	    BoxFill = CirrusFillRectSolidGeneral;
+ 	    break;
+ 	}
+ 	break;
+     case FillTiled:
+     	/* Hmm, it seems FillRectTileOdd always gets called. --HH */
+ #if 0    
+ 	if (!((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr)->
+ 	pRotatedPixmap)
+             BoxFill = cfbFillRectTileOdd;
+ 	else
+ #endif
+ 	if (1)
+ 	{
+ 	    if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK)
+ 		/* BoxFill = cfbFillRectTile32Copy; */
+ 		BoxFill = CirrusFillRectTile;
+ 	    else
+ 		BoxFill = cfbFillRectTileOdd;
+ 	}
+ 	break;
+ #if (PPW == 4)
+     case FillStippled:
+ 	if (!((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr)->
+ 							pRotatedPixmap)
+ 	    BoxFill = cfb8FillRectStippledUnnatural;
+ 	else
+ 	    BoxFill = cfbLowlevFuncs.fillRectTransparentStippled32;
+ 	break;
+     case FillOpaqueStippled:
+ 	if (!((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr)->
+ 							pRotatedPixmap)
+ 	    BoxFill = cfb8FillRectStippledUnnatural;
+ 	else
+ 	    BoxFill = cfbLowlevFuncs.fillRectOpaqueStippled32;
+ 	break;
+ #endif
+     }
+     prect = prectInit;
+     xorg = pDrawable->x;
+     yorg = pDrawable->y;
+     if (xorg || yorg)
+     {
+ 	prect = prectInit;
+ 	n = nrectFill;
+ 	while(n--)
+ 	{
+ 	    prect->x += xorg;
+ 	    prect->y += yorg;
+ 	    prect++;
+ 	}
+     }
+ 
+     prect = prectInit;
+ 
+     numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
+     if (numRects > NUM_STACK_RECTS)
+     {
+ 	pboxClippedBase = (BoxPtr)ALLOCATE_LOCAL(numRects * sizeof(BoxRec));
+ 	if (!pboxClippedBase)
+ 	    return;
+     }
+     else
+ 	pboxClippedBase = stackRects;
+ 
+     pboxClipped = pboxClippedBase;
+ 	
+     if (REGION_NUM_RECTS(prgnClip) == 1)
+     {
+ 	int x1, y1, x2, y2, bx2, by2;
+ 
+ 	pextent = REGION_RECTS(prgnClip);
+ 	x1 = pextent->x1;
+ 	y1 = pextent->y1;
+ 	x2 = pextent->x2;
+ 	y2 = pextent->y2;
+     	while (nrectFill--)
+     	{
+ 	    if ((pboxClipped->x1 = prect->x) < x1)
+ 		pboxClipped->x1 = x1;
+     
+ 	    if ((pboxClipped->y1 = prect->y) < y1)
+ 		pboxClipped->y1 = y1;
+     
+ 	    bx2 = (int) prect->x + (int) prect->width;
+ 	    if (bx2 > x2)
+ 		bx2 = x2;
+ 	    pboxClipped->x2 = bx2;
+     
+ 	    by2 = (int) prect->y + (int) prect->height;
+ 	    if (by2 > y2)
+ 		by2 = y2;
+ 	    pboxClipped->y2 = by2;
+ 
+ 	    prect++;
+ 	    if ((pboxClipped->x1 < pboxClipped->x2) &&
+ 		(pboxClipped->y1 < pboxClipped->y2))
+ 	    {
+ 		pboxClipped++;
+ 	    }
+     	}
+     }
+     else
+     {
+ 	int x1, y1, x2, y2, bx2, by2;
+ 
+ 	pextent = (*pGC->pScreen->RegionExtents)(prgnClip);
+ 	x1 = pextent->x1;
+ 	y1 = pextent->y1;
+ 	x2 = pextent->x2;
+ 	y2 = pextent->y2;
+     	while (nrectFill--)
+     	{
+ 	    BoxRec box;
+     
+ 	    if ((box.x1 = prect->x) < x1)
+ 		box.x1 = x1;
+     
+ 	    if ((box.y1 = prect->y) < y1)
+ 		box.y1 = y1;
+     
+ 	    bx2 = (int) prect->x + (int) prect->width;
+ 	    if (bx2 > x2)
+ 		bx2 = x2;
+ 	    box.x2 = bx2;
+     
+ 	    by2 = (int) prect->y + (int) prect->height;
+ 	    if (by2 > y2)
+ 		by2 = y2;
+ 	    box.y2 = by2;
+     
+ 	    prect++;
+     
+ 	    if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
+ 	    	continue;
+     
+ 	    n = REGION_NUM_RECTS (prgnClip);
+ 	    pbox = REGION_RECTS(prgnClip);
+     
+ 	    /* clip the rectangle to each box in the clip region
+ 	       this is logically equivalent to calling Intersect()
+ 	    */
+ 	    while(n--)
+ 	    {
+ 		pboxClipped->x1 = max(box.x1, pbox->x1);
+ 		pboxClipped->y1 = max(box.y1, pbox->y1);
+ 		pboxClipped->x2 = min(box.x2, pbox->x2);
+ 		pboxClipped->y2 = min(box.y2, pbox->y2);
+ 		pbox++;
+ 
+ 		/* see if clipping left anything */
+ 		if(pboxClipped->x1 < pboxClipped->x2 && 
+ 		   pboxClipped->y1 < pboxClipped->y2)
+ 		{
+ 		    pboxClipped++;
+ 		}
+ 	    }
+     	}
+     }
+     if (pboxClipped != pboxClippedBase)
+ 	(*BoxFill) (pDrawable, pGC,
+ 		    pboxClipped-pboxClippedBase, pboxClippedBase);
+     if (pboxClippedBase != stackRects)
+     	DEALLOCATE_LOCAL(pboxClippedBase);
+ }
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_fillst.c:2.1
*** /dev/null	Fri Mar 11 23:41:13 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_fillst.c	Fri Mar 11 23:41:13 1994
***************
*** 0 ****
--- 1,418 ----
+ /*
+  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_fillst.c,v 2.1 1994/03/09 10:56:05 dawes Exp $
+  *
+  * Copyright 1993 by H. Hanemaayer, Utrecht, The Netherlands
+  *
+  * 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 H. Hanemaayer not be used in
+  * advertising or publicity pertaining to distribution of the software without
+  * specific, written prior permission.  H. Hanemaayer makes no representations
+  * about the suitability of this software for any purpose.  It is provided
+  * "as is" without express or implied warranty.
+  *
+  * H. HANEMAAYER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+  * EVENT SHALL H. HANEMAAYER 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.
+  *
+  * Author:  H. Hanemaayer, <hhanemaa@cs.ruu.nl>
+  *
+  */
+ 
+ /*
+  * These are the functions for stipples and tiles, which call low-level
+  * functions.
+  */
+ 
+ #include "X.h"
+ #include "Xmd.h"
+ #include "servermd.h"
+ #include "gcstruct.h"
+ #include "window.h"
+ #include "pixmapstr.h"
+ #include "scrnintstr.h"
+ #include "windowstr.h"
+ 
+ #include "cfb.h"
+ #include "cfbmskbits.h"
+ #include "cfbrrop.h"
+ #include "cfb8bit.h"	/* For cfb8StippleRRop. */
+ #include "mergerop.h"
+ #include "vgaBank.h"
+ #include "x386.h"
+ #include "vga.h"	/* For vga256InfoRec */
+ 
+ #include "compiler.h"
+ 
+ #include "cir_driver.h"
+ 
+ 
+ /*
+  * This function uses the color expand fill for opaque stipples.
+  * I'm not entirely sure about the origin of the stipple; I assume
+  * it should be (0, 0).
+  */
+ 
+ void CirrusFillRectOpaqueStippled32(pDrawable, pGC, nBox, pBox)
+ 	DrawablePtr pDrawable;
+ 	GCPtr pGC;
+ 	int nBox;		/* number of boxes to fill */
+ 	register BoxPtr pBox;	/* pointer to list of boxes to fill */
+ {
+ 	unsigned long *src;
+ 	int stippleHeight;
+ 	cfbPrivGCPtr devPriv;
+ 	PixmapPtr stipple;
+ 	int destPitch;
+ 
+ 	devPriv = ((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ 	stipple = devPriv->pRotatedPixmap;
+ 
+ 	destPitch = (int)
+ 		(((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind);
+ 
+ 	cfb8CheckOpaqueStipple(pGC->alu, pGC->fgPixel, pGC->bgPixel,
+ 		pGC->planemask);
+ 
+ 	stippleHeight = stipple->drawable.height;
+ 	src = (unsigned long *)stipple->devPrivate.ptr;
+ 
+ 	for (;nBox; nBox--, pBox++) {
+ 		int w = pBox->x2 - pBox->x1;
+ 		/* Small stipples are slightly broken. Disabled until fixed. */
+ 		if (cfb8StippleRRop == GXcopy && w >= 64) {
+ 			if (w >= 64)
+ 				CirrusColorExpand32bitFill(pBox->x1, pBox->y1,
+ 					w, pBox->y2 - pBox->y1, src,
+ 					stippleHeight, 0, 0, pGC->bgPixel,
+ 					pGC->fgPixel, destPitch);
+ 			else
+ 				Cirrus32bitFillSmall(pBox->x1,
+ 					pBox->y1, w, pBox->y2 - pBox->y1, src,
+ 					stippleHeight, 0, 0, pGC->bgPixel,
+ 					pGC->fgPixel, destPitch);
+ 		}
+ 		else {
+ 			/* Special raster op. */
+ 			/* Let cfb do this one. */
+ 			speedupcfb8FillRectOpaqueStippled32(
+ 				pDrawable, pGC, 1, pBox);
+ 		}
+ 	}
+ }
+ 
+ 
+ /*
+  * This function uses the color expand fill for transparent stipples.
+  */
+ 
+ void CirrusFillRectTransparentStippled32(pDrawable, pGC, nBox, pBox)
+ 	DrawablePtr pDrawable;
+ 	GCPtr pGC;
+ 	int nBox;		/* number of boxes to fill */
+ 	register BoxPtr pBox;	/* pointer to list of boxes to fill */
+ {
+ 	unsigned long *src;
+ 	int stippleHeight;
+ 	cfbPrivGCPtr devPriv;
+ 	PixmapPtr stipple;
+ 	int destPitch;
+ 
+ 	devPriv = ((cfbPrivGCPtr) pGC->devPrivates[cfbGCPrivateIndex].ptr);
+ 	stipple = devPriv->pRotatedPixmap;
+ 
+ 	destPitch = (int)
+ 		(((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind);
+ 
+ 	cfb8CheckStipple(pGC->alu, pGC->fgPixel, pGC->planemask);
+ 
+ 	stippleHeight = stipple->drawable.height;
+ 	src = (unsigned long *)stipple->devPrivate.ptr;
+ 
+ 	for (;nBox; nBox--, pBox++) {
+ 		int w = pBox->x2 - pBox->x1;
+ 		if (cfb8StippleRRop == GXcopy && w >= 64)
+ 			/* Background pixel -1 means transparent. */
+ 			CirrusColorExpand32bitFill(pBox->x1, pBox->y1, w,
+ 				pBox->y2 - pBox->y1, src, stippleHeight,
+ 				0, 0, -1, pGC->fgPixel,
+ 				destPitch);
+ 		else {
+ 			/* Special raster op. */
+ 			/* Let cfb do this one. */
+ 			speedupcfb8FillRectTransparentStippled32(
+ 				pDrawable, pGC, 1, pBox);
+ 		}
+ 	}
+ }
+ 
+ 
+ /*
+  * Cirrus Tile fill.
+  * There's no clear way to do tiling efficiently. There are lots of
+  * different ways.
+  * Uses a specific latched-write function for 32 pixels wide tiles.
+  * For 8x8 and 16x16 tiles, the BitBLT engine fill is used. For larger
+  * tiles, we use repeated BitBlt.
+  *
+  * There's potential for using the 8x8 BitBLT engine pattern fill for
+  * (1, 2, 4, 8, 16) x (1, 2, 4, 8) tiles, and more sizes by splitting
+  * the area into 'bands' (the BitBLT engine should also work for any rop).
+  * Also you can 'interleave' by using a doubled pitch (with a virtual screen
+  * width < 2048, this works for height 16 because the pitch range goes up to
+  * 4095).
+  * On the 5434 (which can handle a pitch up to 8191) 4-way interleaving
+  * can be used, so that we can use the BitBlt engine for 32x32 tiling
+  * with 4 vertical subdivisions, and 16 pixels wide bands horizontally.
+  * The 5434 may support a 32 byte wide pattern (for truecolor 8x8 pattern
+  * fill), which would make it easier.
+  *
+  * Currently the accel routine is very restrictive.
+  * I think for the 5434, the cfb routine (which does a very good
+  * job) may be more efficient than the 32xH latched write fill (h != 32)
+  * because of the 32-bit host interface.
+  */
+ 
+ void rotatepattern( unsigned char *pattern, unsigned char *src, int pixWidth,
+ int width, int height, int hrot, int vrot ) {
+ 	int i;
+ 	for (i = 0; i < height; i++) {
+ 		int j;
+ 		unsigned char *srcline;
+ 		srcline = src + ((i + vrot) & (height - 1)) * pixWidth;
+ 		for (j = 0; j < width; j++) {
+ 			*pattern = *(srcline + ((j + hrot) & (width - 1)));
+ 			pattern++;
+ 		}
+ 	}
+ }
+ 
+ void CirrusFillRectTile(pDrawable, pGC, nBox, pBox)
+ 	DrawablePtr pDrawable;
+ 	GCPtr pGC;
+ 	int nBox;		/* number of boxes to fill */
+ 	register BoxPtr pBox;	/* pointer to list of boxes to fill */
+ {
+ 	unsigned long *src;
+ 	int stippleHeight;
+ 	PixmapPtr pPix;
+ 	int destPitch;
+ 	int width, height;
+ 	int pixWidth;
+ 	int xrot, yrot;
+ 	void *pattern;
+ 
+ 	pPix = pGC->tile.pixmap;
+ 	width = pPix->drawable.width;
+ 	height = pPix->drawable.height;
+ 	pixWidth = PixmapBytePad(width, pPix->drawable.depth);
+ 
+ 	destPitch = (int)
+ 		(((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind);
+ 
+ 	src = (unsigned long *)pPix->devPrivate.ptr;
+         xrot = pDrawable->x + pGC->patOrg.x;
+ 	yrot = pDrawable->y + pGC->patOrg.y;
+ 
+ 	if (HAVEBITBLTENGINE()) {
+ 		if (width == 8 && height == 8)
+ 			goto tile8x8;
+ 		if (width == 16 && height == 16 && (vga256InfoRec.virtualX
+ 		< 2048 || (HAVE543X() && vga256InfoRec.virtualX < 4096)))
+ 			goto tile16x16;
+ #if 0
+ 		/* Not yet. */
+ 		if (width == 32 && height == 32 && HAVE543X() &&
+ 		vga256InfoRec.virtualX < 2048))
+ 			goto tile32x32;
+ #endif
+ #if 0	/* broken. */
+ 		if (width * height >= 500 && (width != 32 || height > 32 ||
+ 		cirrusBusType == CIRRUS_SLOWBUS || HAVE543X()))
+ 			goto tileblit;
+ #endif			
+ 	}
+ 	/* On local bus (but not on the 543x), or if there's no blit engine,
+ 	 * use the extended write mode function for 32x32 tiles. 
+ 	 */
+ 	if (width == 32 && height <= 32)
+ 		goto tile32;
+ 
+ 	cfbFillRectTileOdd(pDrawable, pGC, nBox, pBox);
+ 	return;
+ 
+ tile8x8:
+ 	/* 8x8 BitBLT tile fill. */
+ 	pattern = ALLOCATE_LOCAL(8 * 8);
+ 	/* This could be speeded up by avoiding the pattern being copied
+ 	 * to video memory each time. */
+ 	for (;nBox; nBox--, pBox++) {
+ 		int w, h;
+ 		rotatepattern(pattern, (unsigned char *)src, pixWidth, 8, 8,
+ 			(pBox->x1 - xrot) & 7, (pBox->y1 - yrot) & 7);
+ 		w = pBox->x2 - pBox->x1;
+ 		h = pBox->y2 - pBox->y1;
+ 		if (w * h < 500)
+ 			cfbFillRectTileOdd(pDrawable, pGC, 1, pBox);
+ 		else {
+ 			CirrusBLT8x8PatternFill(pBox->y1 * destPitch +
+ 				pBox->x1, w, h,	pattern, destPitch,
+ 				CROP_SRC);
+ 		}
+ 	}
+ 	DEALLOCATE_LOCAL(pattern);
+ 	return;
+ 
+ tile16x16:
+ 	/* 16x16 BitBLT tile fill. */
+ 	pattern = ALLOCATE_LOCAL(16 * 16);
+ 	for (;nBox; nBox--, pBox++) {
+ 		int w, h;
+ 		rotatepattern(pattern, (unsigned char *)src, pixWidth, 16, 16,
+ 			(pBox->x1 - xrot) & 15, (pBox->y1 - yrot) & 15);
+ 		w = pBox->x2 - pBox->x1;
+ 		h = pBox->y2 - pBox->y1;
+ 		if (w * h < 250)
+ 			cfbFillRectTileOdd(pDrawable, pGC, 1, pBox);
+ 		else {
+ 			/* Low level function uses vertical interleaving. */
+ 			CirrusBLT16x16PatternFill(pBox->y1 * destPitch +
+ 				pBox->x1, w, h, pattern, destPitch, CROP_SRC);
+ 		}
+ 	}
+ 	DEALLOCATE_LOCAL(pattern);
+ 	return;
+ 
+ #if 0
+ tile32x32:
+ 	/* 32x32 BitBLT tile fill (for 5434). */
+ 	pattern = ALLOCATE_LOCAL(32 * 32);
+ 	for (;nBox; nBox--, pBox++) {
+ 		int w, h;
+ 		rotatepattern(pattern, src, pixWidth, 32, 32,
+ 			(pBox->x1 - xrot) & 31, (pBox->y1 - yrot) & 31);
+ 		w = pBox->x2 - pBox->x1;
+ 		h = pBox->y2 - pBox->y1;
+ 		if (w * h < 500)
+ 			cfbFillRectTileOdd(pDrawable, pGC, 1, pBox);
+ 		else {
+ 			/* Low level function uses vertical interleaving. */
+ 			CirrusBLT32x32PatternFill(pBox->y1 * destPitch +
+ 				pBox->x1, w, h, pattern, destPitch, CROP_SRC);
+ 		}
+ 	}
+ 	DEALLOCATE_LOCAL(pattern);
+ 	return;
+ #endif	
+ 
+ tileblit:
+ 	/* Tile with repeated BitBLT. For largish tiles. */
+ 	for (;nBox; nBox--, pBox++) {
+ 		int w, h, x, y;
+ 		int blitx, blith, blity;
+ 		BoxRec box;
+ 		x = pBox->x1;
+ 		y = pBox->y1;
+ 		w = pBox->x2 - x;
+ 		h = pBox->y2 - y;
+ 		/* Don't use the blitter for small tile fills. */
+ 		if (w * h < 250) {
+ 			cfbFillRectTileOdd(pDrawable, pGC, 1, pBox);
+ 			continue;
+ 		}
+ 		box.x1 = x;
+ 		box.y1 = y;
+ 		box.x2 = x + min(width, w);
+ 		box.y2 = y + height;
+ 		/* Draw first tile. */
+ 		cfbFillRectTileOdd(pDrawable, pGC, 1, &box);
+ 		/* Repeat tile horizontally. */
+ 		blitx = x + width;	/* Will skip if width > w. */
+ 		blith = height;
+ 		if (h < height)
+ 			blith = h;
+ 		while (blitx <= x + w - width) {
+ 			CirrusBLTBitBlt(y * destPitch + blitx, y * destPitch +
+ 				x, destPitch, destPitch, width, blith, 1);
+ 			blitx += width;
+ 		}
+ 		/* Right edge. */
+ 		if (blitx < x + w)
+ 			CirrusBLTBitBlt(y * destPitch + blitx, y * destPitch +
+ 				x, destPitch, destPitch, x + w - blitx,
+ 				blith, 1);
+ 		/* Repeat row of tiles vertically. */
+ 		blity = y + height;	/* Will skip if height > h. */
+ 		while (blity < y + h - height) {
+ 			CirrusBLTBitBlt(blity * destPitch + x, y * destPitch +
+ 				x, destPitch, destPitch, w, height, 1);
+ 			blity += height;
+ 		}
+ 		/* Bottom edge. */
+ 		if (blity < y + h)
+ 			CirrusBLTBitBlt(blity * destPitch + x, y * destPitch +
+ 				x, destPitch, destPitch, w, y + h - blity, 1);
+ 	}
+ 	return;
+ 
+ tile32:
+ 	/* The accel routine will only write on 32-aligned x-coords. */
+ 	pattern = ALLOCATE_LOCAL(32 * 32);
+ 	rotatepattern(pattern, (unsigned char *)src, pixWidth, 32, 32,
+ 		      (0 - xrot) & 31, 0);
+ 	for (;nBox; nBox--, pBox++) {
+ 		int w, h, x, y;
+ 		w = pBox->x2 - pBox->x1;
+ 		h = pBox->y2 - pBox->y1;
+ 		if (w < 32 || w * h < 80000)
+ 			cfbFillRectTileOdd(pDrawable, pGC, 1, pBox);
+ 		else {
+ 			int nx, nw;
+ 			int left, right;
+ 			x = pBox->x1;
+ 			y = pBox->y1;
+ 			/* Determine 32-pixel aligned part of area. */
+ 			if (x & 31 == 0)
+ 				left = 0;
+ 			else
+ 				left = 32 - (x & 31);
+ 			nx = x + left;
+ 			/* Width must be multiple of 8 (or better 32). */
+ 			nw = (w - left) & ~31;
+ 			right = w - left - nw;
+ 			if (nw == 0)
+ 				cfbFillRectTileOdd(pDrawable, pGC, 1, pBox);
+ 			else {
+ 				BoxRec box[2];
+ 				/* Do main part. */
+ 				CirrusColorExpandFillTile32(nx, y, nw, h,
+ 					pattern, 32, width, height, yrot,
+ 					destPitch);
+ 				/* Left edge. */
+ 				box[0].x1 = x;
+ 				box[0].y1 = y;
+ 				box[0].x2 = x + left;
+ 				box[0].y2 = y + h;
+ 				/* Right edge. */
+ 				if (right == 0)
+ 					cfbFillRectTileOdd(pDrawable, pGC,
+ 						1, &box);
+ 				else {
+ 					box[1].x1 = x + left + nw;
+ 					box[1].y1 = y;
+ 					box[1].x2 = box[1].x1 + right;
+ 					box[1].y2 = y + h;
+ 					cfbFillRectTileOdd(pDrawable, pGC, 2,
+ 						&box);
+ 				}
+ 			}
+ 		}
+ 	}
+ 	DEALLOCATE_LOCAL(pattern);
+ }
diff -c mit/server/ddx/x386/vga256/drivers/cirrus/cir_im.c:2.2 mit/server/ddx/x386/vga256/drivers/cirrus/cir_im.c:2.6
*** mit/server/ddx/x386/vga256/drivers/cirrus/cir_im.c:2.2	Fri Mar 11 23:41:14 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_im.c	Fri Mar 11 23:41:14 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_im.c,v 2.2 1993/10/02 16:09:18 dawes Exp $
   *
   * Copyright 1993 by Bill Reynolds, Santa Fe, New Mexico
   *
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_im.c,v 2.6 1994/03/06 06:46:25 dawes Exp $
   *
   * Copyright 1993 by Bill Reynolds, Santa Fe, New Mexico
   *
***************
*** 24,33 ****
--- 24,43 ----
   * Author:  Bill Reynolds, bill@goshawk.lanl.gov
   *
   * Reworked by: Simon P. Cooper, <scooper@vizlab.rutgers.edu>
+  * Modifications: Harm Hanemaayer <hhanemaa@cs.ruu.nl>
   *
   * Id: cir_im.c,v 0.7 1993/09/16 01:07:25 scooper Exp
   */
  
+ 
+ /*
+  * Image read/write BLT functions.
+  * WARNING: The scanline/total size byte padding for BitBLT engine functions
+  * that involve system memory is EXTREMELY tricky. There are many different
+  * cases. The databook can be misleading in places.
+  */
+ 
+ 
  #include "misc.h"
  #include "x386.h"
  #include "X.h"
***************
*** 46,227 ****
  #include "mergerop.h"
  #include "vgaBank.h"
  #include "compiler.h"
! #include "os.h"		/* For FatalError */
  
  #include "cir_driver.h"
! 
! extern pointer vgaBase;
! 
! #define BLITADDRESS (vgaBase+4)
! 
! extern void vgaImageWrite ();
! extern void vgaImageRead ();
! extern void SpeedUpBitBlt ();
! 
! CirrusBltLine (dstAddr, srcAddr, dstPitch, srcPitch, w, h, dir)
!      unsigned int dstAddr, srcAddr;
!      unsigned int dstPitch, srcPitch;
!      unsigned int w, h;
!      int dir;			/* >0, increase adrresses, <0, decrease */
! {
!   volatile unsigned char tmpreg;
! 
!   /* Set the SrcAddress */
! 
!   outw (0x3CE, ((srcAddr & 0x000000FF) << 8) | 0x2C);
!   outw (0x3CE, ((srcAddr & 0x0000FF00)) | 0x2D);
!   outw (0x3CE, ((srcAddr & 0x001F0000) >> 8) | 0x2E);
! 
!   /* Set the Src Pitch */
! 
!   outw (0x3CE, ((srcPitch & 0x000000FF) << 8) | 0x26);
!   outw (0x3CE, ((srcPitch & 0x00000F00)) | 0x27);
! 
!   /* Set the DstAddress */
! 
!   outw (0x3CE, ((dstAddr & 0x000000FF) << 8) | 0x28);
!   outw (0x3CE, ((dstAddr & 0x0000FF00)) | 0x29);
!   outw (0x3CE, ((dstAddr & 0x001F0000) >> 8) | 0x2A);
! 
!   /* Set the Dest Pitch */
  
-   outw (0x3CE, ((dstPitch & 0x000000FF) << 8) | 0x24);
-   outw (0x3CE, ((dstPitch & 0x00000F00)) | 0x25);
  
!   /* Set the Width */
  
!   w--;
!   outw (0x3CE, ((w & 0x000000FF) << 8) | 0x20);
!   outw (0x3CE, ((w & 0x00000700)) | 0x21);
! 
!   /* Set the Height */
! 
!   h--;
!   outw (0x3CE, ((h & 0x000000FF) << 8) | 0x22);
!   outw (0x3CE, ((h & 0x00000300)) | 0x23);
! 
!   /* Set the direction */
!   if (dir > 0)
!     {
!       outw (0x3CE, (0x00 << 8) | 0x30);
!     }
!   else
!     {
!       outw (0x3CE, (0x01 << 8) | 0x30);
!     }
! 
!   /* Set the ROP: Copy = 0x0D */
!   outw (0x3CE, (CROP_SRC << 8) | 0x32);
  
!   /* Ok, we're all loaded up, let's do it */
!   outw (0x3CE, (0x02 << 8) | 0x31);
  
!   do
!     {
!       outb (0x3CE, 0x31);
!       tmpreg = inb (0x3CF);
!     }
!   while (tmpreg & 0x01);
  
  }
  
! void
! CirrusBitBlt (pdstBase, psrcBase, widthSrc, widthDst, x, y,
! 	      x1, y1, w, h, xdir, ydir, alu, planemask)
!      pointer pdstBase, psrcBase;	/* start of src bitmap */
!      int widthSrc, widthDst;
!      int x, y, x1, y1, w, h;	/* Src x,y; Dst x1,y1; Dst (w)idth,(h)eight */
!      int xdir, ydir;
!      int alu;
!      unsigned long planemask;
! {
!   unsigned int psrc, pdst, ppdst;
!   int i;
  
-   if (widthSrc < 0)
-     widthSrc *= -1;
-   if (widthDst < 0)
-     widthDst *= -1;
  
!   if (alu == GXcopy && (planemask & 0xFF) == 0xFF)
!     {
!       if (xdir == 1)		/* left to right */
! 	{
! 	  if (ydir == 1)	/* top to bottom */
! 	    {
! 	      psrc = (y * widthSrc) + x;
! 	      pdst = (y1 * widthDst) + x1;
! 	    }
! 	  else
! 	    /* bottom to top */
! 	    {
! 	      psrc = ((y + h - 1) * widthSrc) + x;
! 	      pdst = ((y1 + h - 1) * widthDst) + x1;
! 	    }
! 	}
!       else
! 	/* right to left */
! 	{
! 	  if (ydir == 1)	/* top to bottom */
! 	    {
! 	      psrc = (y * widthSrc) + x + w - 1;
! 	      pdst = (y1 * widthDst) + x1 + w - 1;
! 	    }
! 	  else
! 	    /* bottom to top */
! 	    {
! 	      psrc = ((y + h - 1) * widthSrc) + x + w - 1;
! 	      pdst = ((y1 + h - 1) * widthDst) + x1 + w - 1;
! 	    }
! 	}
  
!       /* I could probably do the line by line */
!       /* blits a little faster by breaking the */
!       /* blit regions into rectangles */
!       /* and blitting those, making sure I don't */
!       /* overwrite stuff. However, the */
!       /* difference between the line by line */
!       /* and block blits isn't noticable to */
!       /* me, so I think I'll blow it off. */
  
!       if (xdir == 1)
! 	{
! 	  if (ydir == 1)
! 	    {			/* Nothing special, straight blit */
! 	      CirrusBltLine (pdst, psrc, widthDst, widthSrc, w, h, 1);
! 	    }
! 	  else
! 	    /* Line by line, going up. */
! 	    {
! 	      for (i = 0; i < h; i++)
! 		{
! 		  CirrusBltLine (pdst, psrc, widthDst, widthSrc, w, 1, 1);
! 		  psrc -= widthSrc;
! 		  pdst -= widthDst;
! 		}
! 	    }
  	}
-       else
- 	{
  
! 	  if (ydir == 1)	/* Line by line, going down and to the left */
! 	    {
! 	      for (i = 0; i < h; i++)
! 		{
! 		  CirrusBltLine (pdst, psrc, widthDst, widthSrc, w, 1, -1);
! 		  psrc += widthSrc;
! 		  pdst += widthDst;
! 		}
! 	    }
! 	  else
! 	    /* Another stock blit, albeit backwards */
! 	    {
! 	      CirrusBltLine (pdst, psrc, widthDst, widthSrc, w, h, -1);
! 	    }
  	}
!     }
  }
  
  void
  CirrusImageWrite (pdstBase, psrcBase, widthSrc, widthDst, x, y,
  		  x1, y1, w, h, xdir, ydir, alu, planemask)
--- 56,221 ----
  #include "mergerop.h"
  #include "vgaBank.h"
  #include "compiler.h"
! #include "vga.h"	/* For vgaBase. */
  
  #include "cir_driver.h"
! #include "cir_blitter.h"
  
  
! /* #if __GNUC__ > 1 */
! #if 0	/* Broken. */
  
! /*
!  * This another piece of critical code which is very difficult to do
!  * efficiently in C. Transfers 16-bit words, reversing the per-byte
!  * bit order. 
!  */
  
! static __inline__ transferwords( unsigned char *base, unsigned char *srcp,
! int count ) {
! 	int dummy, temp;
! 	asm(
! 	"cmpl $4,%3\n\t"
! 	"jb 2f\n\t"
! 
! 	"1:\n\t"
! 	"movzbl 2(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%al\n\t"
! 	"movzbl 3(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%ah\n\t"
! 	"shll $16,%%eax\n\t"
! 	"movzbl (%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%al\n\t"
! 	"movzbl 1(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%ah\n\t"
! 	/* We now have per-byte bit order reversed word of data in eax. */
! 	"movl %%eax,(%0)\n\t"
! 
! 	/* Now do the second word. */
! 	"movzbl 6(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%al\n\t"
! 	"movzbl 7(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%ah\n\t"
! 	"shll $16,%%eax\n\t"
! 	"movzbl 4(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%al\n\t"
! 	"movzbl 5(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%ah\n\t"
! 	"movl %%eax,(%0)\n\t"
! 
! 	"addl $8,%1\n\t"
! 	"subl $4,%3\n\t"
! 	"cmpl $4,%3\n\t"
! 	"jae 1b\n\t"
! 
! 	"2:\n\t"
! 	"andl %3,%3\n\t"
! 	"jz 4f\n\t"
! 
! 	"3:\n\t"
! 	"movzbl (%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%al\n\t"
! 	"movzbl 1(%1),%2\n\t"
! 	"movb _byte_reversed(%2),%%ah\n\t"
! 	"movw %%ax,(%0)\n\t"
! 	"addl $2,%1\n\t"
! 	"decl %3\n\t"
! 	"jnz 3b\n\t"
! 
! 	"4:\n\t"
! 	:
! 	: "r" (base), "r" (srcp), "r" (temp), "r" (count), "ax" (dummy)
! 	: "ax", "1", "2", "3"
! 	);
! }
  
! #else
  
+ static __inline__ transferwords( unsigned char *base, unsigned char *srcp, int count ) {
+ 	while (count > 4) {
+ 		unsigned long bits;
+ 		unsigned short data;
+ 		bits = *(unsigned short *)srcp;
+ 		data = byte_reversed[(unsigned char)bits] +
+ 			(byte_reversed[(unsigned char)(bits >> 8)] << 8);
+ 		*(unsigned short *)base = data;
+ 		bits = *(unsigned short *)(srcp + 2);
+ 		data = byte_reversed[(unsigned char)bits] +
+ 			(byte_reversed[(unsigned char)(bits >> 8)] << 8);
+ 		*(unsigned short *)base = data;
+ 		bits = *(unsigned short *)(srcp + 4);
+ 		data = byte_reversed[(unsigned char)bits] +
+ 			(byte_reversed[(unsigned char)(bits >> 8)] << 8);
+ 		*(unsigned short *)base = data;
+ 		bits = *(unsigned short *)(srcp + 6);
+ 		data = byte_reversed[(unsigned char)bits] +
+ 			(byte_reversed[(unsigned char)(bits >> 8)] << 8);
+ 		*(unsigned short *)base = data;
+ 		srcp += 8;
+ 		count -= 4;
+ 	}
+ 	while (count > 0) {
+ 		unsigned long bits;
+ 		unsigned short data;
+ 		bits = *(unsigned short *)srcp;
+ 		data = byte_reversed[(unsigned char)bits] +
+ 			(byte_reversed[(unsigned char)(bits >> 8)] << 8);
+ 		*(unsigned short *)base = data;
+ 		srcp += 2;
+ 		count--;
+ 	}
  }
  
! #endif
  
  
! 
! /*
!  * This should replace the assembler CirrusImageReadTransfer routine,
!  * which may make wrong assumptions.
!  *
!  * We need to read a multiple of 4 bytes in total. We must not pad scanlines.
!  * We may only read words.
!  *
!  * [Doesn't seem to work; maybe the scanlines are padded after all.]
!  *
!  */
  
! #if 0
  
! static void CirrusImageReadTransfer( int w, int h, void *destp, int destpitch,
! void *base ) {
! 	unsigned char *buffer, *bufferp;
! 	int i;
! 	int size;
! 	int nbytes;
! 	size = w * h;
! 	/* Number of bytes, rounded up to multiple of 4. */
! 	nbytes = (size + 3) & ~3;
! 	buffer = ALLOCATE_LOCAL(nbytes);
! 
! 	/* Read raw data into buffer. */
! 	bufferp = buffer;
! 	while (nbytes > 0) {
! 		int chunk;
! 		chunk = min(65536, nbytes);
! 		memcpy(bufferp, vgaBase, chunk);
! 		bufferp += chunk;
! 		nbytes -= chunk;
  	}
  
! 	/* Copy raw data to destination pixmap. */
! 	bufferp = buffer;
! 	for (i = 0; i < h; i++) {
! 		memcpy(destp + i * destpitch, bufferp, w);
! 		bufferp += w;
  	}
! 	DEALLOCATE_LOCAL(buffer);
  }
  
+ #endif
+ 
+ 
  void
  CirrusImageWrite (pdstBase, psrcBase, widthSrc, widthDst, x, y,
  		  x1, y1, w, h, xdir, ydir, alu, planemask)
***************
*** 232,284 ****
       int alu;
       unsigned long planemask;
  {
-   unsigned long *plSrc;
-   volatile unsigned char status;
-   volatile unsigned long *pDst;
    pointer psrc;
    unsigned int dstAddr;
-   unsigned int word_count, word_rem;
-   int i, j;
  
!   if (alu == GXcopy && (planemask & 0xFF) == 0xFF)
      {
        int width, height;
  
        psrc = psrcBase + (y * widthSrc) + x;
        dstAddr = (y1 * widthDst) + x1;
  
!       /* Set the DstAddress */
! 
!       outw (0x3CE, ((dstAddr & 0x000000FF) << 8) | 0x28);
!       outw (0x3CE, ((dstAddr & 0x0000FF00)) | 0x29);
!       outw (0x3CE, ((dstAddr & 0x001F0000) >> 8) | 0x2A);
! 
!       /* Set the Dest Pitch */
! 
!       outw (0x3CE, ((widthDst & 0x000000FF) << 8) | 0x24);
!       outw (0x3CE, ((widthDst & 0x00000F00)) | 0x25);
! 
!       /* Set the Width */
! 
!       width = w - 1;
!       outw (0x3CE, ((width & 0x000000FF) << 8) | 0x20);
!       outw (0x3CE, ((width & 0x00000700)) | 0x21);
! 
!       /* Set the Height */
! 
!       height = h - 1;
!       outw (0x3CE, ((height & 0x000000FF) << 8) | 0x22);
!       outw (0x3CE, ((height & 0x00000300)) | 0x23);
! 
        /* Set the direction and source (System Memory) */
! 
!       outw (0x3CE, (0x04 << 8) | 0x30);
! 
!       /* Set the ROP: Copy = 0x0D */
!       outw (0x3CE, (0x0D << 8) | 0x32);
! 
!       /* Lets play DMA controller ... */
!       outw (0x3CE, (0x02 << 8) | 0x31);
  
        /*
         * We must transfer 4 bytes per blit line.  This is cautious code and I
--- 226,258 ----
       int alu;
       unsigned long planemask;
  {
    pointer psrc;
    unsigned int dstAddr;
  
!   if ((planemask & 0xFF) == 0xFF)
      {
        int width, height;
  
+       if (!HAVE543X() && h > 1024) {
+           /* Split into two. */
+           CirrusImageWrite(pdstBase, psrcBase, widthSrc, widthDst, x, y,
+               x1, y1, w, 1024, xdir, ydir, alu, planemask);
+           CirrusImageWrite(pdstBase, psrcBase, widthSrc, widthDst, x, y +
+               1024, x1, y1 + 1024, w, h - 1024, xdir, ydir, alu, planemask);
+           return;
+       }
+ 
        psrc = psrcBase + (y * widthSrc) + x;
        dstAddr = (y1 * widthDst) + x1;
  
!       SETDESTADDR(dstAddr);
!       SETDESTPITCH(widthDst);
!       SETWIDTH(w);
!       SETHEIGHT(h);
        /* Set the direction and source (System Memory) */
!       SETBLTMODE(SYSTEMSRC);
!       SETROP(cirrus_rop[alu]);
!       STARTBLT();
  
        /*
         * We must transfer 4 bytes per blit line.  This is cautious code and I
***************
*** 288,360 ****
         * Don't try this on your Sparc :-)
         */
  
!       pDst = (unsigned long *) BLITADDRESS;
  
!       word_count = w >> 2;
!       word_rem = w & 0x3;
! 
!       switch (word_rem)
! 	{
! 
! 	case 0:
! 	  for (i = 0; i < h; i++)
! 	    {
! 	      plSrc = (unsigned long *) psrc;
! 	      for (j = 0; j < word_count; j++)
! 		*pDst = *plSrc++;
! 	      psrc += widthSrc;
! 	    }
! 	  break;
! 
! 	case 1:		/* One byte extra */
! 	  for (i = 0; i < h; i++)
! 	    {
! 	      plSrc = (unsigned long *) psrc;
! 	      for (j = 0; j < word_count; j++)
! 		*pDst = *plSrc++;
! 
! 	      *pDst = (unsigned long) (*(unsigned char *) plSrc);
! 
! 	      psrc += widthSrc;
! 	    }
! 	  break;
! 
! 	case 2:		/* Two bytes extra */
! 	  for (i = 0; i < h; i++)
! 	    {
! 	      plSrc = (unsigned long *) psrc;
! 	      for (j = 0; j < word_count; j++)
! 		*pDst = *plSrc++;
! 
! 	      *pDst = (unsigned long) (*(unsigned short *) plSrc);
! 
! 	      psrc += widthSrc;
! 	    }
! 	  break;
! 
! 	case 3:
! 
! 	  for (i = 0; i < h; i++)
! 	    {
! 	      plSrc = (unsigned long *) psrc;
! 	      for (j = 0; j < word_count; j++)
! 		*pDst = *plSrc++;
! 
! 	      (*(unsigned char **)&plSrc)--;
! 	      *pDst = (*plSrc) >> 8;
! 
! 	      psrc += widthSrc;
! 	    }
! 	  break;
! 
! 	}
! 
!       do
! 	{
! 	  outb (0x3CE, 0x31);
! 	  status = inb (0x3CF);
! 	}
!       while (status & 0x01);
      }
    else
      {
--- 262,270 ----
         * Don't try this on your Sparc :-)
         */
  
!       CirrusImageWriteTransfer(w, h, psrc, widthSrc, vgaBase);
  
!       WAITUNTILFINISHED();
      }
    else
      {
***************
*** 375,427 ****
       int alu;
       unsigned long planemask;
  {
-   unsigned long *plDst;
-   volatile unsigned char status;
-   volatile unsigned long *pSrc;
    pointer pdst;
    unsigned int srcAddr;
-   unsigned int word_count, word_rem;
-   int i, j;
  
!   if (alu == GXcopy && (planemask & 0xFF) == 0xFF)
      {
        int width, height;
  
        pdst = pdstBase + (y1 * widthDst) + x1;
        srcAddr = (y * widthSrc) + x;
  
!       /* Set the SrcAddress */
! 
!       outw (0x3CE, ((srcAddr & 0x000000FF) << 8) | 0x2C);
!       outw (0x3CE, ((srcAddr & 0x0000FF00)) | 0x2D);
!       outw (0x3CE, ((srcAddr & 0x001F0000) >> 8) | 0x2E);
!       
!       /* Set the Src Pitch */
! 
!       outw (0x3CE, ((widthSrc & 0x000000FF) << 8) | 0x26);
!       outw (0x3CE, ((widthSrc & 0x00000F00)) | 0x27);
! 
!       /* Set the Width */
! 
!       width = w - 1;
!       outw (0x3CE, ((width & 0x000000FF) << 8) | 0x20);
!       outw (0x3CE, ((width & 0x00000700)) | 0x21);
! 
!       /* Set the Height */
! 
!       height = h - 1;
!       outw (0x3CE, ((height & 0x000000FF) << 8) | 0x22);
!       outw (0x3CE, ((height & 0x00000300)) | 0x23);
! 
        /* Set the direction and destination (System Memory) */
! 
!       outw (0x3CE, (0x02 << 8) | 0x30);
! 
!       /* Set the ROP: Copy = 0x0D */
!       outw (0x3CE, (0x0D << 8) | 0x32);
! 
!       /* Lets play DMA controller ... */
!       outw (0x3CE, (0x02 << 8) | 0x31);
  
        /*
         * We must transfer 4 bytes per blit line.  This is cautious code and I
--- 285,317 ----
       int alu;
       unsigned long planemask;
  {
    pointer pdst;
    unsigned int srcAddr;
  
!   if ((planemask & 0xFF) == 0xFF)
      {
        int width, height;
  
+       if (!HAVE543X() && h > 1024) {
+           /* Split into two. */
+           CirrusImageRead(pdstBase, psrcBase, widthSrc, widthDst, x, y,
+               x1, y1, w, 1024, xdir, ydir, alu, planemask);
+           CirrusImageRead(pdstBase, psrcBase, widthSrc, widthDst, x, y +
+               1024, x1, y1 + 1024, w, h - 1024, xdir, ydir, alu, planemask);
+           return;
+       }
+ 
        pdst = pdstBase + (y1 * widthDst) + x1;
        srcAddr = (y * widthSrc) + x;
  
!       SETSRCADDR(srcAddr);
!       SETSRCPITCH(widthSrc);
!       SETWIDTH(w);
!       SETHEIGHT(h);
        /* Set the direction and destination (System Memory) */
!       SETBLTMODE(SYSTEMDEST);
!       SETROP(cirrus_rop[alu]);
!       STARTBLT();
  
        /*
         * We must transfer 4 bytes per blit line.  This is cautious code and I
***************
*** 430,510 ****
         * is used to our advantage when dealing with the 3 byte remainder.
         * Don't try this on your Sparc :-)
         */
  
!       pSrc = (unsigned long *) BLITADDRESS;
  
-       word_count = w >> 2;
-       word_rem = w & 0x3;
  
!       switch (word_rem)
! 	{
  
! 	case 0:
! 	  for (i = 0; i < h; i++)
! 	    {
! 	      plDst = (unsigned long *) pdst;
! 	      for (j = 0; j < word_count; j++)
! 		*plDst++ = *pSrc;
! 	      pdst += widthDst;
! 	    }
! 	  break;
! 
! 	case 1:		/* One byte extra */
! 	  for (i = 0; i < h; i++)
! 	    {
! 	      plDst = (unsigned long *) pdst;
! 	      for (j = 0; j < word_count; j++)
! 		*plDst++ = *pSrc;
! 
! 	      *(unsigned char *)plDst = (unsigned char) *pSrc;
! 
! 	      pdst += widthDst;
! 	    }
! 	  break;
! 
! 	case 2:		/* Two bytes extra */
! 	  for (i = 0; i < h; i++)
! 	    {
! 	      plDst = (unsigned long *) pdst;
! 	      for (j = 0; j < word_count; j++)
! 		*plDst++ = *pSrc;
! 
! 	      *(unsigned short *)plDst = (unsigned short) *pSrc;
! 
! 	      pdst += widthDst;
! 	    }
! 	  break;
! 
! 	case 3:
! 
! 	  for (i = 0; i < h; i++)
! 	    { unsigned long tpix;
! 
! 	      plDst = (unsigned long *) pdst;
! 	      for (j = 0; j < word_count; j++)
! 		*plDst++ = *pSrc;
! 
! 	      tpix = *pSrc;
! 
! 	      *(*(unsigned short **)&plDst)++ = (unsigned short) tpix;
! 	      *(unsigned char  *)plDst = (unsigned char)(tpix >>16);
! 	      
! 	      pdst += widthDst;
! 	    }
! 	  break;
  
  	}
  
!       do
  	{
! 	  outb (0x3CE, 0x31);
! 	  status = inb (0x3CF);
  	}
!       while (status & 0x01);
!     }
!   else
!     {
!       vgaImageRead(pdstBase, psrcBase, widthSrc, widthDst, x, y,
! 		   x1, y1, w, h, xdir, ydir, alu, planemask);
!     }
  }
--- 320,454 ----
         * is used to our advantage when dealing with the 3 byte remainder.
         * Don't try this on your Sparc :-)
         */
+        
+       /*
+        * I doubt whether the reading of a multiple of 4 bytes *per
+        * blit line* is right; I think we just need to read a multiple of
+        * 4 bytes in total. We must not pad scanlines.
+        * See databook D8-6.
+        *
+        */
+ 
+       CirrusImageReadTransfer(w, h, pdst, widthDst, vgaBase);
  
!       WAITUNTILFINISHED();
!     }
!   else
!     {
!       vgaImageRead(pdstBase, psrcBase, widthSrc, widthDst, x, y,
! 		   x1, y1, w, h, xdir, ydir, alu, planemask);
!     }
! }
  
  
! #if 0
  
! /*
!  * Cirrus two-color bitmap write function (used by CopyPlane).
!  * We use the BitBLT engine with color expansion system memory source,
!  * reversing the per-byte bit order as we go.
!  *
!  * Currently doesn't handle origin offset and tiling (i.e. box and boy should
!  * correspond to top-left corner of area, and bw == w, bh == h).
!  *
!  * bwidth is the 'pitch' of the bitmap in bytes.
!  */
! 
! #ifdef __STDC__
! void CirrusWriteBitmap( int x, int y, int w, int h,
! unsigned char *srcp, int bwidth, int bw, int bh, int box, int boy, int bg,
! int fg, int destpitch, int alu )
! #else
! void CirrusWriteBitmap( x, y, w, h, srcp, bwidth, bw, bh, box, boy, bg,
! fg, destpitch, alu )
! 	int x, y, w, h;
! 	unsigned char *srcp;
! 	int bwidth, bw, bh, box, boy, bg, fg, destpitch, alu;
! #endif
! {
! 	int destaddr;
! 	int i;
! 	int bytewidth;	/* Area width in bytes. */
! 
! #if 0
! 	ErrorF("CirrusWriteBitmap size (%d, %d), pixwidth = %d, bw = %d\n",
! 		w, h, bwidth, bw);
! #endif		
! 
! 	if (w != bw || h != bh) {
! 		ErrorF("Bitmap not same size as area.\n");
! 		return;
! 	}
  
+ 	if (!HAVE543X() && h > 1024) {
+ 		/* Split into two. */
+ 		CirrusWriteBitmap(x, y, w, 1024, srcp, bwidth, bw, 1024, box,
+ 			boy, bg, fg, destpitch, alu);
+ 		CirrusWriteBitmap(x, y + 1024, w, h - 1024, srcp + bwidth *
+ 			1024, bwidth, bw, h - 1024, box, boy, bg, fg,
+ 			destpitch, alu);
+ 		return;
  	}
  
! 	/* Bug: need to handle origin. */
! 
! 	destaddr = y * destpitch + x;
! 
! 	/* Number of bytes in area line. */
! 	bytewidth = (w + 7) / 8;
! 
! 	SETDESTADDR(destaddr);
! 	SETDESTPITCH(destpitch);
! 	SETSRCADDR(0);
! 	SETSRCPITCH(0);
! 	SETWIDTH(w);
! 	SETHEIGHT(h);
! 	SETBLTMODE(SYSTEMSRC | COLOREXPAND);
! 	SETROP(cirrus_rop[alu]);
! 
! 	SETBACKGROUNDCOLOR(bg);
! 	SETFOREGROUNDCOLOR(fg);
! 
! 	STARTBLT();
! 
! 	/* We must be very cautious here. For each bitmap line, we must pad
! 	 * to a byte boundary, but we may not transfer bytes; and for the
! 	 * total operation, we must transfer a multiple of 4 bytes. Failure
! 	 * to do this locks the machine.
! 	 */
! 
  	{
! 		unsigned char *buffer;
! 		int size;
! 		size = bytewidth * h;
! 		buffer = (unsigned char *)ALLOCATE_LOCAL(size + 3);
! 		for (i = 0; i < h; i++) {
! 			memcpy(buffer + i * bytewidth, srcp + i * bwidth,
! 				bytewidth);
! 		}
! 		/* Make sure we transfer a multiple of four bytes. */
! 		switch (size & 3)  {
! 		case 0 :
! 			/* Transfer (size / 2) 16-bit words. */
! 			transferwords(vgaBase, buffer, size / 2);
! 			break;
! 		case 1 :
! 			transferwords(vgaBase, buffer, (size + 3) / 2);
! 			break;
! 		case 2 :
! 			transferwords(vgaBase, buffer, (size + 2) / 2);
! 			break;
! 		case 3 :
! 			transferwords(vgaBase, buffer, (size + 1) / 2);
! 			break;
! 		}
! 		DEALLOCATE_LOCAL(buffer);
  	}
! 
! 	WAITUNTILFINISHED();
! 
! 	SETBACKGROUNDCOLOR(0x0f);
! 	SETFOREGROUNDCOLOR(0);
  }
+ 
+ #endif
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_imblt.s:2.0
*** /dev/null	Fri Mar 11 23:41:15 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_imblt.s	Fri Mar 11 23:41:15 1994
***************
*** 0 ****
--- 1,324 ----
+ /*
+  *
+  * Copyright 1993 by H. Hanemaayer, Utrecht, The Netherlands
+  *
+  * 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 H. Hanemaayer not be used in
+  * advertising or publicity pertaining to distribution of the software without
+  * specific, written prior permission.  H. Hanemaayer makes no representations
+  * about the suitability of this software for any purpose.  It is provided
+  * "as is" without express or implied warranty.
+  *
+  * H. HANEMAAYER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+  * EVENT SHALL H. HANEMAAYER 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.
+  *
+  * Author:  H. Hanemaayer, <hhanemaa@cs.ruu.nl>
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_imblt.s,v 2.0 1994/02/24 12:43:41 dawes Exp $ */
+ 
+ /*
+  * This low-level routine copies bitmap data to video memory for the
+  * blitter, which must be setup for system-memory-to-video-memory BLT.
+  * The video address where the data is written doesn't matter. Each bitmap
+  * scanline transmitted is padded to a multiple of 4 bytes; the bitmap is
+  * transfered in dwords (this is effectively 16-bit words because of the
+  * 16-bit host interface of the 5426/28).
+  *
+  * This function is used by the 5426 and 5428.
+  *
+  * Prototype:
+  * CirrusImageWriteTransfer( int width, int height, void *srcaddr,
+  *     int srcwidth, void *vaddr )
+  *
+  * width is the bitmap width in bytes.
+  * height is the height of the bitmap.
+  * srcaddr is the address of the bitmap data.
+  * srcwidth is the length of a bitmap scanline in bytes.
+  * vaddr is a video memory address (doesn't really matter).
+  * 
+  * REP MOVS could be used here, but it is not a very optimal instruction
+  * for this type of stuff (high setup cost).
+  *
+  * With a fast CPU, this function doesn't seem to be very much faster than
+  * the C loop in the 2.0 server (~30% on a VLB 486 at 40 MHz).
+  * For a slower CPU, it helps a lot.
+  */
+ 
+ #include "assyntax.h"
+ 
+  	FILE("cir_imageblt.S")
+ 
+ 	AS_BEGIN
+ 
+ /* Definition of stack frame function arguments. */
+ 
+ #define width_arg	REGOFF(8,EBP)
+ #define height_arg	REGOFF(12,EBP)
+ #define srcaddr_arg	REGOFF(16,EBP)
+ #define srcwidth_arg	REGOFF(20,EBP)
+ #define vaddr_arg	REGOFF(24,EBP)
+ 
+ #define nu_dwords_var	REGOFF(-4,EBP)
+ 
+ /* I assume %eax and %edx can be trashed. */
+ /* Saving %ebx and %ecx may be unnecessary. */
+ 
+ 	SEG_TEXT
+ 
+ 	ALIGNTEXT4
+ 
+ 	GLOBL GLNAME(CirrusImageWriteTransfer)
+ GLNAME(CirrusImageWriteTransfer):
+ 
+ 	PUSH_L	(EBP)
+ 	MOV_L	(ESP,EBP)
+ 	SUB_L 	(CONST(0x04),ESP)	/* Allocate one local variable. */
+ 	PUSH_L	(EBX)
+ 	PUSH_L	(ECX)
+ 	PUSH_L	(ESI)
+ 	PUSH_L	(EDI)
+ 
+ 	MOV_L	(width_arg,EAX)
+ 	MOV_L   (EAX,EBX)
+ 	SHR_L	(CONST(0x02),EAX)	/* #dwords. */
+ 	MOV_L	(EAX,nu_dwords_var)	/* Store in local variable. */
+ 	AND_B   (CONST(0x03),BL)	/* Remainder. */
+ 
+ 	MOV_L   (srcaddr_arg,ESI)	/* Source address. */
+ 	MOV_L	(vaddr_arg,EDI)		/* Video address for blit. */
+ 
+ 	MOV_L	(height_arg,EDX)
+ 	TEST_L	(EDX,EDX)
+ 	JMP	(.loop_entry)
+ 	ALIGNTEXT4
+ 
+ .line_loop:
+ 	MOV_L	(nu_dwords_var,ECX)	/* ECX = #dwords. */
+ 
+ .unrolled_word_loop:
+ 	CMP_L	(CONST(0x08),ECX)	/* Do we have 8 dwords left? */
+ 	JL	(.word_loop_check)	/* If not, jump over unrolled loop. */
+ 
+ 	MOV_L	(REGIND(ESI),EAX)	/* Unrolled loop. */
+ 	MOV_L	(EAX,REGIND(EDI))	/* Transfer 8 dwords. */
+ 	MOV_L	(REGOFF(4,ESI),EAX)
+ 	MOV_L	(EAX,REGIND(EDI))
+ 	MOV_L	(REGOFF(8,ESI),EAX)
+ 	MOV_L	(EAX,REGIND(EDI))
+ 	MOV_L	(REGOFF(12,ESI),EAX)
+ 	MOV_L	(EAX,REGIND(EDI))
+ 	MOV_L	(REGOFF(16,ESI),EAX)
+ 	MOV_L	(EAX,REGIND(EDI))
+ 	MOV_L	(REGOFF(20,ESI),EAX)
+ 	MOV_L	(EAX,REGIND(EDI))
+ 	MOV_L	(REGOFF(24,ESI),EAX)
+ 	MOV_L	(EAX,REGIND(EDI))
+ 	MOV_L	(REGOFF(28,ESI),EAX)
+ 	MOV_L	(EAX,REGIND(EDI))
+ 
+ 	ADD_L	(CONST(0x20),ESI)
+ 	SUB_L	(CONST(0x08),ECX)
+ 	JMP	(.unrolled_word_loop)
+ 	ALIGNTEXT4
+ 
+ .word_loop_check:
+ 	CMP_L	(CONST(0),ECX)
+ 	JZ	(.do_remainder)		/* No dwords left. */
+ 
+ .word_loop:
+ 	MOV_L	(REGIND(ESI),EAX)	/* Transfer a dword. */
+ 	MOV_L	(EAX,REGIND(EDI))
+ 
+ 	/* Check-and-unroll could be used here. */
+ 
+ 	ADD_L	(CONST(0x04),ESI)
+ 	DEC_L	(ECX)
+ 	JNZ	(.word_loop)
+ 
+ .do_remainder:
+ 	CMP_B	(CONST(0),BL)
+ 	JE 	(.line_finished)	/* No bytes left, line finished. */
+ 	CMP_B	(CONST(1),BL)
+ 	JE	(.one_byte_remaining)
+ 	CMP_B	(CONST(2),BL)
+ 	JE	(.two_bytes_remaining)
+ 
+ 	/* Three bytes remaining. */
+ 	MOV_L	(REGOFF(-1,ESI),EAX)
+ 	SHR_L	(CONST(8),EAX)
+ 	ADD_L	(CONST(0x03),ESI)
+ 	MOV_L	(EAX,REGIND(EDI))		/* Write dword. */
+ 	JMP	(.line_finished)
+ 
+ .one_byte_remaining:
+ 	MOV_B	(REGIND(ESI),AL)
+ 	INC_L	(ESI)
+ 	MOV_L	(EAX,REGIND(EDI))	/* Write dword with remainder. */
+ 	JMP	(.line_finished)
+ 
+ .two_bytes_remaining:
+ 	MOV_W	(REGIND(ESI),AX)
+ 	ADD_L	(CONST(0x02),ESI)
+ 	MOV_L	(EAX,REGIND(EDI))	/* Write dword with remainder. */
+ 
+ .line_finished:
+ 	ADD_L	(srcwidth_arg,ESI)	/* Adjust source pointer for */
+ 	SUB_L	(width_arg,ESI)		/* bitmap pitch. */
+ 	DEC_L	(EDX)
+ .loop_entry:
+ 	JNZ 	(.line_loop)
+ 
+ 	POP_L	(EDI)
+ 	POP_L	(ESI)
+ 	POP_L	(ECX)
+ 	POP_L	(EBX)
+ 	ADD_L 	(CONST(0x04),ESP)	/* De-allocate local variable. */
+ 	POP_L	(EBP)
+ 	RET
+ 
+ 
+ /* 
+  * This may be wrong. For image reads, scanlines are not padded two a multiple
+  * of 4 bytes (if I understand the databook correctly).
+  */
+ 
+ /* 
+  * This is the equivalent function for image read blits.
+  *
+  * Prototype:
+  * CirrusImageReadTransfer( int width, int height, void *destaddr,
+  *     int destwidth, void *vaddr )
+  *
+  * width is the bitmap width in bytes.
+  * height is the height of the bitmap.
+  * destaddr is the address of the bitmap data.
+  * destwidth is the length of a bitmap scanline in bytes.
+  * vaddr is a video memory address (doesn't really matter).
+  * 
+  * Digit '2' appended to labels to avoid clashes.
+  */
+ 
+ /* These stack frame arguments correspond with srcaddr and srcwidth. */
+ /* The other arguments are in the same place on the stack. */
+ 
+ #define destaddr_arg	REGOFF(16,EBP)
+ #define destwidth_arg	REGOFF(20,EBP)
+ 
+ 
+ 	GLOBL GLNAME(CirrusImageReadTransfer)
+ GLNAME(CirrusImageReadTransfer):
+ 
+ 	PUSH_L	(EBP)
+ 	MOV_L	(ESP,EBP)
+ 	SUB_L 	(CONST(0x04),ESP)	/* Allocate one local variable. */
+ 	PUSH_L	(EBX)
+ 	PUSH_L	(ECX)
+ 	PUSH_L	(ESI)
+ 	PUSH_L	(EDI)
+ 
+ 	MOV_L	(width_arg,EAX)
+ 	MOV_L   (EAX,EBX)
+ 	SHR_L	(CONST(0x02),EAX)	/* #dwords. */
+ 	MOV_L	(EAX,nu_dwords_var)	/* Store in local variable. */
+ 	AND_B   (CONST(0x03),BL)	/* Remainder. */
+ 
+ 	MOV_L   (destaddr_arg,ESI)	/* Destination address. */
+ 	MOV_L	(vaddr_arg,EDI)		/* Video address for blit. */
+ 
+ 	MOV_L	(height_arg,EDX)
+ 	TEST_L	(EDX,EDX)
+ 	JMP	(.loop_entry2)
+ 
+ .line_loop2:
+ 	MOV_L	(nu_dwords_var,ECX)	/* ECX = #dwords. */
+ 
+ .unrolled_word_loop2:
+ 	CMP_L	(CONST(0x08),ECX)	/* Do we have 8 dwords left? */
+ 	JL	(.word_loop_check2)	/* If not, jump over unrolled loop. */
+ 
+ 	MOV_L	(REGIND(EDI),EAX)	/* Unrolled loop. */
+ 	MOV_L	(EAX,REGIND(ESI))	/* Transfer 8 dwords. */
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_L	(EAX,REGOFF(4,ESI))
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_L	(EAX,REGOFF(8,ESI))
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_L	(EAX,REGOFF(12,ESI))
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_L	(EAX,REGOFF(16,ESI))
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_L	(EAX,REGOFF(20,ESI))
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_L	(EAX,REGOFF(24,ESI))
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_L	(EAX,REGOFF(28,ESI))
+ 
+ 	ADD_L	(CONST(0x20),ESI)
+ 	SUB_L	(CONST(0x08),ECX)
+ 	JMP	(.unrolled_word_loop2)
+ 
+ .word_loop_check2:
+ 	CMP_L	(CONST(0),ECX)
+ 	JZ	(.do_remainder2)	/* No dwords left. */
+ 
+ .word_loop2:
+ 	MOV_L	(REGIND(EDI),EAX)	/* Transfer a dword. */
+ 	MOV_L	(EAX,REGIND(ESI))
+ 
+ 	/* Check-and-unroll could be used here. */
+ 
+ 	ADD_L	(CONST(0x04),ESI)
+ 	DEC_L	(ECX)
+ 	JNZ	(.word_loop2)
+ 
+ .do_remainder2:
+ 	CMP_B	(CONST(0),BL)
+ 	JE 	(.line_finished2)	/* No bytes left, line finished. */
+ 	CMP_B	(CONST(1),BL)
+ 	JE	(.one_byte_remaining2)
+ 	CMP_B	(CONST(2),BL)
+ 	JE	(.two_bytes_remaining2)
+ 
+ 	/* Three bytes remaining. */
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_W	(AX,REGIND(ESI))
+ 	SHR_L	(CONST(16),EAX)
+ 	MOV_B	(AL,REGOFF(2,ESI))
+ 	ADD_L	(CONST(0x03),ESI)
+ 	JMP	(.line_finished2)
+ 
+ .one_byte_remaining2:
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_B	(AL,REGIND(ESI))
+ 	INC_L	(ESI)
+ 	JMP	(.line_finished2)
+ 
+ .two_bytes_remaining2:
+ 	MOV_L	(REGIND(EDI),EAX)
+ 	MOV_W	(AX,REGIND(ESI))
+ 	ADD_L	(CONST(0x02),ESI)
+ 
+ .line_finished2:
+ 	ADD_L	(destwidth_arg,ESI)	/* Adjust source pointer for */
+ 	SUB_L	(width_arg,ESI)		/* bitmap pitch. */
+ 	DEC_L	(EDX)
+ .loop_entry2:
+ 	JNZ 	(.line_loop2)
+ 
+ 	POP_L	(EDI)
+ 	POP_L	(ESI)
+ 	POP_L	(ECX)
+ 	POP_L	(EBX)
+ 	ADD_L 	(CONST(0x04),ESP)	/* De-allocate local variable. */
+ 	POP_L	(EBP)
+ 	RET
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_inline.h:2.4
*** /dev/null	Fri Mar 11 23:41:15 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_inline.h	Fri Mar 11 23:41:15 1994
***************
*** 0 ****
--- 1,144 ----
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_inline.h,v 2.4 1994/03/05 02:00:46 dawes Exp $ */
+ 
+ /* Some inline assembler functions. */
+ 
+ #if __GNUC__ > 1 && defined(GCCUSESGAS)
+ 
+ static __inline__ unsigned long rotateleft( int n, unsigned long bits ) {
+ 	__asm__ __volatile__("roll %%cl,%0\n\t"
+ 	: "=r" (bits)		/* outputs */
+ 	: "0" (bits), "c" (n)	/* inputs */
+ 	);
+ 	return bits;
+ }
+ 
+ /* Define __inline__ string operations. */
+ 
+ static __inline__ void __memsetlong( unsigned long *s, unsigned long c,
+ 				     int count ) {
+ 	__asm__ __volatile__("rep ; stosl\n\t"
+ 	:
+ 	: "a" (c), "D" (s), "c" (count)
+ 	: "cx", "di");
+ } 
+ 
+ static __inline__ void __memset( void * s, char c, int count ) {
+ 	__asm__ __volatile__(
+ 	"cld\n\t"
+ 	"cmpl $12,%%edx\n\t"
+ 	"jl 1f\n\t"			/* if (count >= 12) */
+ 
+ 	"movzbl %%al,%%ax\n\t"
+ 	"movl %%eax,%%ecx\n\t"
+ 	"shll $8,%%ecx\n\t"		/* c |= c << 8 */
+ 	"orl %%ecx,%%eax\n\t"
+ 	"movl %%eax,%%ecx\n\t"
+ 	"shll $16,%%ecx\n\t"		/* c |= c << 16 */
+ 	"orl %%ecx,%%eax\n\t" 
+ 	
+ 	"movl %%edx,%%ecx\n\t"
+ 	"negl %%ecx\n\t"
+ 	"andl $3,%%ecx\n\t"		/* (-s % 4) */
+ 	"subl %%ecx,%%edx\n\t"		/* count -= (-s % 4) */
+ 	"rep ; stosb\n\t"		/* align to longword boundary */
+ 	
+ 	"movl %%edx,%%ecx\n\t"
+ 	"shrl $2,%%ecx\n\t"
+ 	"rep ; stosl\n\t"		/* fill longwords */
+ 	
+ 	"andl $3,%%edx\n"		/* fill last few bytes */
+ 	"1:\tmovl %%edx,%%ecx\n\t"	/* <= 12 entry point */
+ 	"rep ; stosb\n\t"
+ 	: :"a" (c),"D" (s),"d" (count)
+ 	:"ax","cx","dx","di");
+ }
+ 
+ static __inline__ void __memcpy( void *to, void *from, int n ) {
+ __asm__ __volatile__("cld\n\t"
+ 	"movl %%edi,%%ecx\n\t"
+ 	"andl $1,%%ecx\n\t"
+ 	"subl %%ecx,%%edx\n\t"
+ 	"rep ; movsb\n\t"		/* 16-bit align destination */
+ 	"movl %%edx,%%ecx\n\t"
+ 	"shrl $2,%%ecx\n\t"
+ 	"rep ; movsl\n\t"
+ 	"testb $1,%%dl\n\t"
+ 	"je 1f\n\t"
+ 	"movsb\n"
+ 	"1:\ttestb $2,%%dl\n\t"
+ 	"je 2f\n\t"
+ 	"movsw\n"
+ 	"2:\n"
+ 	::"d" (n),"D" ((long) to),"S" ((long) from)
+ 	: "cx","dx","di","si");
+ }
+ 
+ static __inline__ void __memcpyb( unsigned char *to, unsigned char *from,
+ 				  int n ) {
+ 	__asm__ __volatile__("cld\n\t"
+ 	"rep ; movsb\n\t"
+ 	: :"c" (n),"D" ((long) to),"S" ((long) from)
+ 	: "cx","di","si");
+ }
+ 
+ #else
+ 
+ #define __memset memset
+ 
+ #define __memcpy MemToBus
+ 
+ #define rotateleft(n, bits) (((bits) << (n)) | ((bits) >> (32 - (n))))
+ 
+ #ifdef __STDC__
+ static void __memsetlong( unsigned long *s, unsigned long c, int count )
+ #else
+ static void __memsetlong( s, c, count )
+ unsigned long *s, c;
+ int count;
+ #endif
+ {
+ 	while (count > 4) {
+ 		*s = c;
+ 		*(s + 1) = c;
+ 		*(s + 2) = c;
+ 		*(s + 3) = c;
+ 		s += 4;
+ 		count -= 4;
+ 	}
+ 	while (count > 0) {
+ 		*s = c;
+ 		s++;
+ 		count --;
+ 	}
+ }
+ 
+ #ifdef __STDC__
+ static void __memcpyb( unsigned char *destp, unsigned char *srcp, int count )
+ #else
+ static void __memcpyb( destp, srcp, count )
+ unsigned char *destp, *srcp;
+ int count;
+ #endif
+ {
+ 	while (count >= 8) {
+ 		*destp = *srcp;
+ 		*(destp + 1) = *(srcp + 1);
+ 		*(destp + 2) = *(srcp + 2);
+ 		*(destp + 3) = *(srcp + 3);
+ 		*(destp + 4) = *(srcp + 4);
+ 		*(destp + 5) = *(srcp + 5);
+ 		*(destp + 6) = *(srcp + 6);
+ 		*(destp + 7) = *(srcp + 7);
+ 		destp += 8;
+ 		srcp += 8;
+ 		count -= 8;
+ 	}
+ 	while (count > 0) {
+ 		*destp = *srcp;
+ 		destp++;
+ 		srcp++;
+ 		count--;
+ 	}
+ }
+ 
+ #endif
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_teblt8.c:2.3
*** /dev/null	Fri Mar 11 23:41:16 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_teblt8.c	Fri Mar 11 23:41:16 1994
***************
*** 0 ****
--- 1,562 ----
+ /*
+  * TEGblt - ImageText expanded glyph fonts only.  For
+  * 8 bit displays, in Copy mode with no clipping.
+  */
+ 
+ 
+ /*
+ Copyright 1989 by the Massachusetts Institute of Technology
+ 
+ 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 M.I.T. not be used in
+ advertising or publicity pertaining to distribution of the software
+ without specific, written prior permission.  M.I.T. makes no
+ representations about the suitability of this software for any
+ purpose.  It is provided "as is" without express or implied warranty.
+ */
+ 
+ /* $XConsortium: cfbteblt8.c,v 5.14 91/04/10 11:41:38 keith Exp $ */
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_teblt8.c,v 2.3 1994/03/06 06:46:26 dawes Exp $ */
+ 
+ /*
+  * Modified for Cirrus by Harm Hanemaayer (hhanemaa@cs.ruu.nl).
+  *
+  * We accelerate straightforward text writing for fonts with widths up to 16
+  * pixels. Added CirrusPolyGlyphBlt for transparent text.
+  */
+  
+ 
+ #include	"X.h"
+ #include	"Xmd.h"
+ #include	"Xproto.h"
+ #include	"servermd.h"
+ #include	"cfb.h"
+ #include	"fontstruct.h"
+ #include	"dixfontstr.h"
+ #include	"gcstruct.h"
+ #include	"windowstr.h"
+ #include	"scrnintstr.h"
+ #include	"pixmapstr.h"
+ #include	"regionstr.h"
+ #include	"cfbmskbits.h"
+ #include	"cfb8bit.h"
+ #include	"vga.h"	/* For vgaBase. */
+ #include        "vgaBank.h"
+ /* #include        "vgaFasm.h" */
+ #include        "cfbfuncs.h"
+ 
+ #include "compiler.h"
+ 
+ #include "cir_driver.h"
+ #include "cir_blitter.h"
+ 
+ 
+ extern void speedupcfbTEGlyphBlt8();	/* Doesn't support clipping. */
+ extern void cfbImageGlyphBlt8();
+ extern void miPolyGlyphBlt();
+ 
+ 
+ void CirrusTransferTextWidth8();
+ void CirrusTransferTextWidth6();
+ void CirrusTransferText();		/* General, for widths <= 16. */
+ 
+ 
+ void CirrusImageGlyphBlt(pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase)
+     DrawablePtr pDrawable;
+     GC 		*pGC;
+     int 	xInit, yInit;
+     unsigned int nglyph;
+     CharInfoPtr *ppci;		/* array of character info */
+     unsigned char *pglyphBase;	/* start of array of glyphs */
+ {
+     FontPtr		pfont = pGC->font;
+     unsigned long	*pdstBase;
+     int			widthDst;
+     int			widthGlyph;
+     int			h;
+     int			x, y;
+     BoxRec		bbox;		/* for clipping */
+ 
+     	int glyphWidth;		/* Character width in pixels. */
+     	int glyphWidthBytes;	/* Character width in bytes (padded). */
+ 	int i;
+ 	/* Characters are padded to 4 bytes. */
+ 	unsigned long **glyphp;
+ 	int shift, line;
+ 	unsigned dworddata;
+ 	int destaddr, blitwidth;
+ 
+ 	glyphWidth = FONTMAXBOUNDS(pfont,characterWidth);
+ 	glyphWidthBytes = GLYPHWIDTHBYTESPADDED(*ppci);
+ 
+ #if 0	
+ 	ErrorF("CirrusImageGlyphBlt: glyphWidthBytes = %d, glyphWidth = %d\n",
+ 		glyphWidthBytes, glyphWidth);
+ #endif		
+ 
+     h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ 
+     if ((h | glyphWidth) == 0) return;
+ 
+     x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing) + pDrawable->x;
+     y = yInit - FONTASCENT(pfont) + pDrawable->y;
+     bbox.x1 = x;
+     bbox.x2 = x + (glyphWidth * nglyph);
+     bbox.y1 = y;
+     bbox.y2 = y + h;
+ 
+     switch ((*pGC->pScreen->RectIn)(
+                 ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip, &bbox))
+     {
+       case rgnPART:
+ 	cfbImageGlyphBlt8(pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
+       case rgnOUT:
+ 	return;
+     }
+ 
+ 	/* We only accelerate fonts 16 or less pixels wide. */
+ 	if (glyphWidthBytes != 4 || glyphWidth > 16) {
+ #if 0		/* There seems to be a problem using speedup. */
+ 		/* Use speedup. */
+ 	        speedupcfbTEGlyphBlt8(pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
+ #else
+ 	        cfbImageGlyphBlt8(pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
+ #endif
+ 		return;	        
+ 	}
+ 
+ 
+     if (!cfb8CheckPixels (pGC->fgPixel, pGC->bgPixel))
+ 	cfb8SetPixels (pGC->fgPixel, pGC->bgPixel);
+ 
+     cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase)
+     widthDst *= 4;	/* Convert to bytes. */
+ 
+ #if 0
+ 	ErrorF("CirrusImageGlyphBlt: widthDst = %d, size = (%d, %d), bg = %d, fg = %d\n",
+ 		widthDst, glyphWidth * nglyph, h, pGC->bgPixel, pGC->fgPixel);
+ #endif		
+ 
+ 	destaddr = y * widthDst + x;
+ 	SETDESTADDR(destaddr);
+ 	SETDESTPITCH(widthDst);
+ 	SETSRCADDR(0);
+ 	SETSRCPITCH(0);
+ 	blitwidth = glyphWidth * nglyph;
+ 	SETWIDTH(blitwidth);
+ 	SETHEIGHT(h);
+ 
+ 	SETBACKGROUNDCOLOR(pGC->bgPixel);
+ 	SETFOREGROUNDCOLOR(pGC->fgPixel);
+ 
+ 	SETBLTMODE(SYSTEMSRC | COLOREXPAND);
+ 	SETROP(CROP_SRC);
+ 	STARTBLT();
+ 
+ 	/* Problem: must synthesize bitmap. The current code works reasonably
+ 	 * efficiently for 6 and 8 pixel wide fonts, other widths (up to 16)
+ 	 * are less efficiently handled.
+ 	 */
+ 
+ 	/* Collect list of pointers to glyph bitmaps. */
+ 	glyphp = ALLOCATE_LOCAL(nglyph * sizeof(unsigned long *));
+ 	for (i = 0; i < nglyph; i++ ) {
+ 		glyphp[i] = (unsigned long *)FONTGLYPHBITS(pglyphBase, *ppci++);
+ 	}
+ 
+ 	/* Write bitmap to video memory (for BitBlt engine to process). */
+ 	/* Gather bytes until we have a dword to write. Doubleword is   */
+ 	/* LSByte first, and MSBit first in each byte, as required for  */
+ 	/* the blit data. */
+ 
+ 	switch (glyphWidth) {
+ 	case 8 :
+ 		/* 8 pixel wide font, easier and faster. */
+ 		CirrusTransferTextWidth8(nglyph, h, glyphp);
+ 		break;
+ 	case 6 :
+ 		CirrusTransferTextWidth6(nglyph, h, glyphp);
+ 		break;
+ 	default :
+ 		CirrusTransferText(nglyph, h, glyphp, glyphWidth, vgaBase);
+ 		break;
+ 	}
+ 
+ 	WAITUNTILFINISHED();
+ 
+ 	SETBACKGROUNDCOLOR(0x0f);
+ 	SETFOREGROUNDCOLOR(0);
+ 	
+ 	DEALLOCATE_LOCAL(glyphp);
+ }
+ 
+ 
+ #if 0
+ 
+ void CirrusPolyGlyphBlt(pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase)
+     DrawablePtr pDrawable;
+     GC 		*pGC;
+     int 	xInit, yInit;
+     unsigned int nglyph;
+     CharInfoPtr *ppci;		/* array of character info */
+     unsigned char *pglyphBase;	/* start of array of glyphs */
+ {
+     FontPtr		pfont = pGC->font;
+     unsigned long	*pdstBase;
+     int			widthDst;
+     int			widthGlyph;
+     int			h;
+     int			x, y;
+     BoxRec		bbox;		/* for clipping */
+ 
+     	int glyphWidth;		/* Character width in pixels. */
+     	int glyphWidthBytes;	/* Character width in bytes (padded). */
+ 	int i;
+ 	/* Characters are padded to 4 bytes. */
+ 	unsigned long **glyphp;
+ 	int shift, line;
+ 	unsigned dworddata;
+ 	int destaddr, blitwidth;
+ 	void (*PolyGlyph)();
+ 
+ 	PolyGlyph = NULL;
+ 	if (pGC->fillStyle != FillSolid)
+ 		PolyGlyph = miPolyGlyphBlt;
+ 
+         if (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
+             FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
+ 	    FONTMINBOUNDS(pGC->font,characterWidth) < 0)
+ 		PolyGlyph = miPolyGlyphBlt;
+ 
+ 	/* Special raster ops that don't seem to work. */
+ 	if (pGC->alu == GXset || pGC->alu == GXcopyInverted)
+ 		PolyGlyph = cfbPolyGlyphRop8;
+ 
+ 	if (PolyGlyph != NULL) {
+ 		(*PolyGlyph)(pDrawable, pGC, xInit, yInit, nglyph, ppci,
+ 			pglyphBase);
+ 		return;
+ 	}
+ 
+ 	glyphWidth = FONTMAXBOUNDS(pfont,characterWidth);
+ 	glyphWidthBytes = GLYPHWIDTHBYTESPADDED(*ppci);
+ 
+     h = FONTASCENT(pfont) + FONTDESCENT(pfont);
+ 
+     if ((h | glyphWidth) == 0) return;
+ 
+     x = xInit + FONTMAXBOUNDS(pfont,leftSideBearing) + pDrawable->x;
+     y = yInit - FONTASCENT(pfont) + pDrawable->y;
+     bbox.x1 = x;
+     bbox.x2 = x + (glyphWidth * nglyph);
+     bbox.y1 = y;
+     bbox.y2 = y + h;
+ 
+     switch ((*pGC->pScreen->RectIn)(
+                 ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip, &bbox))
+     {
+       case rgnPART:
+         if (pGC->alu == GXcopy)
+         	PolyGlyph = cfbPolyGlyphBlt8;
+         else
+         	PolyGlyph = cfbPolyGlyphRop8;
+ 	(*PolyGlyph)(pDrawable, pGC, xInit, yInit, nglyph, ppci, pglyphBase);
+       case rgnOUT:
+ 	return;
+     }
+ 
+ 	/* We only accelerate fonts 16 or less pixels wide. */
+ 	if (glyphWidthBytes != 4 || glyphWidth > 16) {
+ 	        if (pGC->alu == GXcopy)
+         		PolyGlyph = cfbPolyGlyphBlt8;
+ 	        else
+         		PolyGlyph = cfbPolyGlyphRop8;
+ 		(*PolyGlyph)(pDrawable, pGC, xInit, yInit, nglyph, ppci,
+ 			pglyphBase);
+ 		return;	        
+ 	}
+ 
+ 
+     if (!cfb8CheckPixels (pGC->fgPixel, pGC->bgPixel))
+ 	cfb8SetPixels (pGC->fgPixel, pGC->bgPixel);
+ 
+     cfbGetLongWidthAndPointer(pDrawable, widthDst, pdstBase)
+     widthDst *= 4;	/* Convert to bytes. */
+ 
+ 	destaddr = y * widthDst + x;
+ 	SETDESTADDR(destaddr);
+ 	SETDESTPITCH(widthDst);
+ 	SETSRCADDR(0);
+ 	SETSRCPITCH(0);
+ 	blitwidth = glyphWidth * nglyph;
+ 	SETWIDTH(blitwidth);
+ 	SETHEIGHT(h);
+ 
+ 	SETBACKGROUNDCOLOR(pGC->bgPixel);
+ 	SETFOREGROUNDCOLOR(pGC->fgPixel);
+ 	SETTRANSPARENCYCOLOR(pGC->bgPixel);
+ 
+ 	SETBLTMODE(SYSTEMSRC | COLOREXPAND | TRANSPARENCYCOMPARE);
+ 	SETROP(cirrus_rop[pGC->alu]);
+ 	STARTBLT();
+ 
+ 	/* Problem: must synthesize bitmap. The current code works reasonably
+ 	 * efficiently for 6 and 8 pixel wide fonts, other widths (up to 16)
+ 	 * are less efficiently handled.
+ 	 */
+ 
+ 	/* Collect list of pointers to glyph bitmaps. */
+ 	glyphp = ALLOCATE_LOCAL(nglyph * sizeof(unsigned long *));
+ 	for (i = 0; i < nglyph; i++ ) {
+ 		glyphp[i] = (unsigned long *)FONTGLYPHBITS(pglyphBase, *ppci++);
+ 	}
+ 
+ 	/* Write bitmap to video memory (for BitBlt engine to process). */
+ 	/* Gather bytes until we have a dword to write. Doubleword is   */
+ 	/* LSByte first, and MSBit first in each byte, as required for  */
+ 	/* the blit data. */
+ 
+ 	switch (glyphWidth) {
+ 	case 8 :
+ 		/* 8 pixel wide font, easier and faster. */
+ 		CirrusTransferTextWidth8(nglyph, h, glyphp);
+ 		break;
+ 	case 6 :
+ 		CirrusTransferTextWidth6(nglyph, h, glyphp);
+ 		break;
+ 	default :
+ 		CirrusTransferText(nglyph, h, glyphp, glyphWidth, vgaBase);
+ 		break;
+ 	}
+ 
+ 	WAITUNTILFINISHED();
+ 
+ 	SETBACKGROUNDCOLOR(0x0f);
+ 	SETFOREGROUNDCOLOR(0);
+ 	
+ 	DEALLOCATE_LOCAL(glyphp);
+ }
+ 
+ #endif
+ 
+ 
+ 
+ /*
+  * Low-level text transfer routines.
+  */
+ 
+ void CirrusTransferTextWidth8(nglyph, h, glyphp)
+ 	int nglyph;
+ 	int h;
+ 	unsigned long **glyphp;
+ {
+ 	int shift;
+ 	unsigned long dworddata;
+ 	int i, line;
+ 
+ 	shift = 0;
+ 	dworddata = 0;
+ 	line = 0;
+ 	while (line < h) {
+ 		i = 0;
+ 		/* Unroll loop. */
+ 		while (shift == 0 && nglyph - i >= 8) {
+ 			/* This only gets used if the text width is a */
+ 			/* multiple of 4 characters. Should do 'alignment' */
+ 			/* for shift values 8, 16 and 24, and then this. */
+ 			dworddata = byte_reversed[glyphp[i][line]];
+ 			dworddata += byte_reversed[glyphp[i + 1][line]] << 8;
+ 			dworddata += byte_reversed[glyphp[i + 2][line]] << 16;
+ 			dworddata += byte_reversed[glyphp[i + 3][line]] << 24;
+ 			*(unsigned long *)vgaBase = dworddata;
+ 			dworddata = byte_reversed[glyphp[i + 4][line]];
+ 			dworddata += byte_reversed[glyphp[i + 5][line]] << 8;
+ 			dworddata += byte_reversed[glyphp[i + 6][line]] << 16;
+ 			dworddata += byte_reversed[glyphp[i + 7][line]] << 24;
+ 			*(unsigned long *)vgaBase = dworddata;
+ 			i += 8;
+ 			dworddata = 0;
+ 		}
+ 
+ 		while (i < nglyph) {
+ 			dworddata += byte_reversed[glyphp[i][line]] << shift;
+ 			shift += 8;
+ 			if (shift == 32) {
+ 				/* Write the dword. */
+ 				*(unsigned long *)vgaBase = dworddata;
+ 				shift = 0;
+ 				dworddata = 0;
+ 			}
+ 			i++;
+ 		}
+ 		line++;
+ 	}
+ 	if (shift != 0)
+ 		*(unsigned long *)vgaBase = dworddata;
+ }
+ 
+ 
+ void CirrusTransferTextWidth6(nglyph, h, glyphp)
+ 	int nglyph;
+ 	int h;
+ 	unsigned long **glyphp;
+ {
+ 	int shift;
+ 	unsigned long dworddata;
+ 	int i, line;
+ 
+ 	/* Special case for fixed font. Tricky, bit order is very awkward. */
+ 	/* We maintain a word straightforwardly LSB, and do the bit order  */
+ 	/* converting when writing 16-bit words. */
+ 
+ 	dworddata = 0;
+ 	line = 0;
+ 	shift = 0;
+ 	while (line < h) {
+ 		i = 0;
+ 		while (i < nglyph) {
+ 			if (shift == 0 && nglyph - i >= 8) {
+ 				/* Speed up 8 character chunks. */
+ 				/* Bit order conversion is done directly. */
+ 				/* 3 16-bit words written (48 bits). */
+ 				unsigned byte2, byte3, byte6, byte7;
+ 				dworddata = byte_reversed[glyphp[i][line]];
+ 				byte2 = byte_reversed[glyphp[i + 1][line]];
+ 				dworddata += byte2 >> 6;
+ 				dworddata += (byte2 & 0x3c) << 10;
+ 				byte3 = byte_reversed[glyphp[i + 2][line]];
+ 				dworddata += (byte3 & 0xf0) << 4;
+ 				dworddata += (byte3 & 0x0c) << 20;
+ 				dworddata += byte_reversed[glyphp[i + 3][line]] << 14;
+ 				dworddata += byte_reversed[glyphp[i + 4][line]] << 24;
+ 				byte6 = byte_reversed[glyphp[i + 5][line]];
+ 				dworddata += (byte6 & 0xc0) << 18;
+ 				*(unsigned long *)vgaBase = dworddata;
+ 				dworddata = (byte6 & 0x3c) << 2;
+ 				byte7 = byte_reversed[glyphp[i + 6][line]];
+ 				dworddata += (byte7 & 0xf0) >> 4;
+ 				dworddata += (byte7 & 0x0c) << 12;
+ 				dworddata += byte_reversed[glyphp[i + 7][line]] << 6;
+ 				*(unsigned short *)vgaBase = dworddata;
+ 				i += 8;
+ 				dworddata = 0;
+ 			}
+ 			else {
+ 				dworddata += glyphp[i][line] << shift;
+ 				shift += 6;
+ 				i++;
+ 			}
+ 			if (shift >= 16) {
+ 				/* Write a 16-bit word. */
+ 				*(unsigned short *)vgaBase =
+ 					byte_reversed[dworddata & 0xff] +
+ 					(byte_reversed[(dworddata & 0xff00) >> 8] << 8);
+ 				shift -= 16;
+ 				dworddata >>= 16;
+ 			}
+ 		}
+ 		if (shift > 0) {
+ 			/* Make sure last bits of scanline are padded to byte
+ 			 * boundary. */
+ 			shift = (shift + 7) & ~7;
+ 			if (shift >= 16) {
+ 				/* Write a 16-bit word. */
+ 				*(unsigned short *)vgaBase =
+ 					byte_reversed[dworddata & 0xff] +
+ 					(byte_reversed[(dworddata & 0xff00) >> 8] << 8);
+ 				shift -= 16;
+ 				dworddata >>= 16;
+ 			}
+ 		}
+ 		line++;
+ 	}
+ 
+ 	{
+ 		/* There are (shift) bits left. */
+ 		unsigned data;
+ 		int bytes;
+ 		data = byte_reversed[dworddata & 0xff] +
+ 			(byte_reversed[(dworddata & 0xff00) >> 8] << 8);
+ 		/* Number of bytes of real bitmap data. */
+ 		bytes = ((nglyph * 6 + 7) >> 3) * h;
+ 		/* We must transfer a multiple of 4 bytes in total. */
+ 		if ((bytes - ((shift + 7) >> 3)) & 2)
+ 			*(unsigned short *)vgaBase = data;
+ 		else
+ 			if (shift != 0)
+ 				*(unsigned long *)vgaBase = data;
+ 	}
+ }
+ 
+ 
+ #if 0
+ 
+ void CirrusTransferText(nglyph, h, glyphp, glyphwidth, base)
+ 	int nglyph;
+ 	int h;
+ 	unsigned long **glyphp;
+ 	unsigned char *base;
+ {
+ 	int shift;
+ 	unsigned long dworddata;
+ 	int i, line;
+ 
+ 	/* Other character widths. Tricky, bit order is very awkward.  */
+ 	/* We maintain a word straightforwardly LSB, and do the */
+ 	/* bit order converting when writing 16-bit words. */
+ 
+ 	dworddata = 0;
+ 	line = 0;
+ 	shift = 0;
+ 	while (line < h) {
+ 		i = 0;
+ 		while (i < nglyph) {
+ 			dworddata += glyphp[i][line] << shift;
+ 			shift += glyphwidth;
+ 			if (shift >= 16) {
+ 				/* Write a 16-bit word. */
+ 				*(unsigned short *)base =
+ 					byte_reversed[dworddata & 0xff] +
+ 					(byte_reversed[(dworddata & 0xff00) >> 8] << 8);
+ 				shift -= 16;
+ 				dworddata >>= 16;
+ 			}
+ 			i++;
+ 		}
+ 		if (shift > 0) {
+ 			/* Make sure last bits of scanline are padded to byte
+ 			 * boundary. */
+ 			shift = (shift + 7) & ~7;
+ 			if (shift >= 16) {
+ 				/* Write a 16-bit word. */
+ 				*(unsigned short *)base =
+ 					byte_reversed[dworddata & 0xff] +
+ 					(byte_reversed[(dworddata & 0xff00) >> 8] << 8);
+ 				shift -= 16;
+ 				dworddata >>= 16;
+ 			}
+ 		}
+ 		line++;
+ 	}
+ 
+ 	{
+ 		/* There are (shift) bits left. */
+ 		unsigned data;
+ 		int bytes;
+ 		data = byte_reversed[dworddata & 0xff] +
+ 			(byte_reversed[(dworddata & 0xff00) >> 8] << 8);
+ 		/* Number of bytes of real bitmap data. */
+ 		bytes = ((nglyph * glyphwidth + 7) >> 3) * h;
+ 		/* We must transfer a multiple of 4 bytes in total. */
+ 		if ((bytes - ((shift + 7) >> 3)) & 2)
+ 			*(unsigned short *)base = data;
+ 		else
+ 			if (shift != 0)
+ 				*(unsigned long *)base = data;
+ 	}
+ }
+ 
+ #endif
diff -c /dev/null mit/server/ddx/x386/vga256/drivers/cirrus/cir_textblt.s:2.2
*** /dev/null	Fri Mar 11 23:41:16 1994
--- mit/server/ddx/x386/vga256/drivers/cirrus/cir_textblt.s	Fri Mar 11 23:41:16 1994
***************
*** 0 ****
--- 1,183 ----
+ /*
+  *
+  * Copyright 1993 by H. Hanemaayer, Utrecht, The Netherlands
+  *
+  * 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 H. Hanemaayer not be used in
+  * advertising or publicity pertaining to distribution of the software without
+  * specific, written prior permission.  H. Hanemaayer makes no representations
+  * about the suitability of this software for any purpose.  It is provided
+  * "as is" without express or implied warranty.
+  *
+  * H. HANEMAAYER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+  * EVENT SHALL H. HANEMAAYER 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.
+  *
+  * Author:  H. Hanemaayer, <hhanemaa@cs.ruu.nl>
+  *
+  */
+ 
+ /* $XFree86: mit/server/ddx/x386/vga256/drivers/cirrus/cir_textblt.s,v 2.2 1994/03/08 04:52:18 dawes Exp $ */
+ 
+ /*
+  * This low-level routine writes a text string bitmap video memory for the
+  * blitter, which must be setup for system-memory-to-video-memory BLT.
+  * The video address where the data is written doesn't matter. Each bitmap
+  * scanline transmitted is padded to a byte boundary; the bitmap is
+  * transfered in 16-bit words. This means that bytes from different scanlines
+  * have to be combined if necessary.
+  *
+  * This function is used by the 5426 and 5428.
+  *
+  * Prototype:
+  * CirrusTextTransfer( int nglyph, int height, unsigned long **glyphp,
+  *     int glyphwidth, void *vaddr )
+  *
+  * nglyph is the number of characters
+  * height is the height of the area.
+  * glyphp is an array of pointers to character bitmaps (stored as one 32-bit
+  *     word per line)
+  * glyphwidth is the width of the font in pixels.
+  * vaddr is a video memory address (doesn't really matter).
+  * 
+  */
+ 
+ #include "assyntax.h"
+ 
+  	FILE("cir_textblt.S")
+ 
+ 	AS_BEGIN
+ 
+ /* Definition of stack frame function arguments. */
+ 
+ #define nglyph_arg	REGOFF(8,EBP)
+ #define height_arg	REGOFF(12,EBP)
+ #define glyphp_arg	REGOFF(16,EBP)
+ #define glyphwidth_arg	REGOFF(20,EBP)
+ #define vaddr_arg	REGOFF(24,EBP)
+ 
+ #define BYTE_REVERSED	GLNAME(byte_reversed)
+ 
+ /* I assume %eax and %edx can be trashed. */
+ /* Saving %ebx and %ecx may be unnecessary. */
+ 
+ 	SEG_TEXT
+ 
+ 	ALIGNTEXT4
+ 
+ 	GLOBL GLNAME(CirrusTransferText)
+ GLNAME(CirrusTransferText):
+ 
+ 	PUSH_L	(EBP)
+ 	MOV_L	(ESP,EBP)
+ 	PUSH_L	(EBX)
+ 	PUSH_L	(ECX)
+ 	PUSH_L	(ESI)
+ 	PUSH_L	(EDI)
+ 
+ 	XOR_L   (EDX,EDX)		/* line = 0 */
+ 	MOV_B	(CONST(0),CL)		/* shift = 0 */
+ 	MOV_B	(glyphwidth_arg,CH)
+ 	MOV_L	(EDX,EAX)		/* dworddata = 0 */
+ 
+ .line_loop:
+ 	CMP_L	(height_arg,EDX)
+ 	JGE	(.finished)
+ 
+ 	MOV_L	(glyphp_arg,EDI)	/* glyphp */
+ 	MOV_L	(nglyph_arg,ESI)
+ 	LEA_L	(REGBISD(EDI,ESI,4,0),ESI) /* &(glyphp[nglyph]) */
+ 
+ .char_loop:
+ 	CMP_L	(ESI,EDI)
+ 	JGE 	(.line_finished)
+ 
+ 	MOV_L	(REGIND(EDI),EBX)	/* glyphp[chari] */
+ 	MOV_L	(REGBISD(EBX,EDX,4,0),EBX) /* data = glyphp[chari][line] */
+ 	SHL_L	(CL,EBX)
+ 	ADD_L	(EBX,EAX)		/* dworddata += data << shift */
+ 	ADD_B	(CH,CL)			/* shift += glyphwidth */
+ 	ADD_L	(CONST(4),EDI)		/* glyphp += 4 */
+ 	CMP_B	(CONST(16),CL)		/* shift < 16? */
+ 	JL	(.char_loop)
+ 
+ 	/* Write a 16-bit word. */
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(AL,BL)
+ 	MOV_B	(REGOFF(BYTE_REVERSED,EBX),AL)
+ 	MOV_B	(AH,BL)
+ 	MOV_B	(REGOFF(BYTE_REVERSED,EBX),AH)
+ 	MOV_L	(vaddr_arg,EBX)
+ 	MOV_W	(AX,REGIND(EBX))	/* *(short)vaddr = dworddata */
+ 	SUB_B	(CONST(16),CL)		/* shift -= 16 */
+ 	SHR_L	(CONST(16),EAX)		/* dworddata >>= 16 */
+ 	JMP	(.char_loop)
+ 
+ .line_finished:
+ 	INC_L	(EDX)			/* line++ */
+ 	AND_B	(CL,CL)
+ 	JZ 	(.line_loop)
+ 
+ 	/* Make sure last bits of scanline are padded to a byte boundary. */
+ 	ADD_B	(CONST(7),CL)
+ 	AND_B	(CONST(24),CL)
+ 	CMP_B	(CONST(16),CL)		/* extra 16-bit word to write? */
+ 	JL 	(.line_loop)
+ 
+ 	/* Write a 16-bit word. */
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(AL,BL)
+ 	MOV_B	(REGOFF(BYTE_REVERSED,EBX),AL)
+ 	MOV_B	(AH,BL)
+ 	MOV_B	(REGOFF(BYTE_REVERSED,EBX),AH)
+ 	MOV_L	(vaddr_arg,EBX)
+ 	MOV_W	(AX,REGIND(EBX))	/* *(short)vaddr = dworddata */
+ 	SUB_B	(CONST(16),CL)		/* shift -= 16 */
+ 	SHR_L	(CONST(16),EAX)		/* dworddata >>= 16 */
+ 	JMP	(.line_loop)
+ 
+ .finished:
+ 	/* Handle the last fews bits and alignment. */
+ 	XOR_L	(EBX,EBX)
+ 	MOV_B	(AL,BL)
+ 	MOV_B	(REGOFF(BYTE_REVERSED,EBX),DL)
+ 	MOV_B	(AH,BL)
+ 	MOV_B	(REGOFF(BYTE_REVERSED,EBX),DH)
+ 
+ 	/* bytes = ((nglyph * glyphwidth + 7) >> 3) * h; */
+ 	MOV_L	(nglyph_arg,EAX)
+ 	IMUL_L	(glyphwidth_arg,EAX)
+ 	ADD_L	(CONST(7),EAX)
+ 	SHR_L	(CONST(3),EAX)
+ 	IMUL_L	(height_arg,EAX)
+ 
+ 	AND_L	(CONST(0x000000ff),ECX)
+ 	ADD_B	(CONST(7),CL)
+ 	SHR_B	(CONST(3),CL)		/* ((shift + 7) >> 3) */
+ 	SUB_L	(ECX,EAX)		/* bytes - ((shift + 7) >> 3) */
+ 	/* Make sure we transfer a multiple of 4 bytes in total. */
+ 	TEST_B	(CONST(2),AL)
+ 	JZ	(.skipword)
+ 	MOV_L	(vaddr_arg,EBX)		/* write 16-bit word */
+ 	MOV_W	(DX,REGIND(EBX))
+ 	JMP	(.end)
+ .skipword:
+ 	AND_B	(CL,CL)
+ 	JZ	(.end)			/* if shift != 0 */
+ 	MOV_L	(vaddr_arg,EBX)
+ 	MOV_L	(EDX,REGIND(EBX))	/* then write 32-bit word */
+ 
+ .end:
+ 	POP_L	(EDI)
+ 	POP_L	(ESI)
+ 	POP_L	(ECX)
+ 	POP_L	(EBX)
+ 	POP_L	(EBP)
+ 	RET
diff -c mit/server/ddx/x386/vga256/drivers/compaq/cpq_driver.c:2.10 mit/server/ddx/x386/vga256/drivers/compaq/cpq_driver.c:2.12
*** mit/server/ddx/x386/vga256/drivers/compaq/cpq_driver.c:2.10	Fri Mar 11 23:41:17 1994
--- mit/server/ddx/x386/vga256/drivers/compaq/cpq_driver.c	Fri Mar 11 23:41:17 1994
***************
*** 21,27 ****
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/compaq/cpq_driver.c,v 2.10 1993/10/06 14:56:03 dawes Exp $ */
  
  /*
    This XFree86 driver is intended to blow up your screen
--- 21,27 ----
   *
   */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/compaq/cpq_driver.c,v 2.12 1994/03/01 09:57:22 dawes Exp $ */
  
  /*
    This XFree86 driver is intended to blow up your screen
***************
*** 56,61 ****
--- 56,62 ----
  	unsigned char PageRegister1;
  	unsigned char ControlRegister0;
  	unsigned char EnvironmentReg;
+ 	unsigned char CRTCOverflow;
  } vgaCOMPAQRec, *vgaCOMPAQPtr;
  
  
***************
*** 155,165 ****
  static Bool
  COMPAQProbe()
  {
! 	unsigned char SetReset;        /* Set/Reset Data */
!         unsigned char Rotate;
!         unsigned char EnvironmentReg;
!         unsigned char BLTConf;
!         unsigned char temp;
  
  	/*
  	 * Set up I/O ports to be used by this card
--- 156,163 ----
  static Bool
  COMPAQProbe()
  {
!         unsigned char temp, ver;
! 	Bool found = FALSE;
  
  	/*
  	 * Set up I/O ports to be used by this card
***************
*** 173,237 ****
  		COMPAQEnterLeave(ENTER);
  	} 
  	else {
! 		char buf[BUFSIZE];
! 		char *signature = "COMPAQ";
! 		char *ati_signature = "761295520";
! 
!     		/* check for COMPAQ VGC */
! 		if (xf86ReadBIOS(VGABIOS_START, 0, (unsigned char *)buf,
! 				 BUFSIZE) != BUFSIZE)
! 			return(FALSE);
! 		if ((buf[0] != (char)0x55) || (buf[1] != (char)0xAA))
! 			return(FALSE);
! 		if (xf86ReadBIOS(VGABIOS_START, (buf[2] * 512) - 0x16,
! 				 (unsigned char *)buf,
! 				 SIGNATURE_LENGTH) != SIGNATURE_LENGTH)
! 			return(FALSE);
! 		if (strncmp(signature, buf, SIGNATURE_LENGTH))
! 			return FALSE;
! 
! 		/*
! 		 * Now make sure it isn't an ATI card with a COMPAQ signature
! 		 * in the BIOS
! 		 */
! 
! 		if (xf86ReadBIOS(VGABIOS_START, 0x31, (unsigned char *)buf,
! 				 ATI_SIGNATURE_LENGTH) != ATI_SIGNATURE_LENGTH)
! 			return(FALSE);
! 		if (!strncmp(ati_signature, buf, ATI_SIGNATURE_LENGTH))
! 			return(FALSE);
! 
!     		COMPAQEnterLeave(ENTER);
! 
! 		/* at least it is some COMPAQ :-) */
! 		/* check for seperate SR and BLTConf registers. */
! 		outb(0x3ce, 0x00); SetReset = inb(0x3cf);
! 		outb(0x3ce, 0x03); Rotate = inb(0x3cf);
! 		outb(0x3ce, 0x0f); EnvironmentReg = inb(0x3cf);
! 		outb(0x3cf, 0x05); /* unlock */
! 		outb(0x3ce, 0x10); BLTConf = inb(0x3cf);
! 	
! 		if ((BLTConf & 0x0f) == SetReset) {
! 			/* try another pattern */
! 			temp = ~SetReset & 0xff;
! 			outw(0x3ce, temp << 8 | 0x00);	/*change Set/Rst Data*/
! 			outb(0x3ce, 0x10);		/*read BLTConf reg   */
! 			if ((inb(0x3cf) & 0x0f) == temp) {
! 				/* restore changed registers */
! 				outw(0x3ce, SetReset << 8 | 0x00);
! 				outw(0x3ce, EnvironmentReg << 8 | 0x0f);
! 				COMPAQEnterLeave(LEAVE);
! 				return FALSE;
  			}
! 			/* restore */
! 			outw(0x3ce, SetReset << 8 | 0x00);
  		}
- 		outw(0x3ce, EnvironmentReg << 8 | 0x0f);
  	}
      
  	/* Detect how much memory is installed, that's easy :-) */
! 	if (!vga256InfoRec.videoRam)
! 		vga256InfoRec.videoRam = 512;
  
  	if (!vga256InfoRec.clocks)
  		vgaGetClocks(4, COMPAQClockSelect);  /* 4? clocks available */
--- 171,234 ----
  		COMPAQEnterLeave(ENTER);
  	} 
  	else {
! 		COMPAQEnterLeave(ENTER);
! 		temp = rdinx(0x3ce, 0x0f);
! 		wrinx(0x3ce, 0x0f, 0x00);
! 		if (!testinx(0x3ce, 0x45)) {
! 			wrinx(0x3ce, 0x0f, 0x05);
! 			if (testinx(0x3ce, 0x45)) {
! 				ver = rdinx(0x3ce, 0x0c) >> 3;
! 				switch (ver) {
! 				case 0x05:	/* AVGA */
! 				case 0x06:	/* QVision/1024 */
! 				case 0x0E:	/* QVision/1024 or /1280 */
! 				case 0x10:	/* AVGA Portable */
! 					found = TRUE;
! 					break;
! 				case 0x03:	/* IVGS */
! 				default:	/* Unknown */
! 					break;
! 				}
! 				
  			}
! 		}
! 		wrinx(0x3ce, 0x0f, temp);
! 		if (!found) {
! 			COMPAQEnterLeave(LEAVE);
! 			return(FALSE);
  		}
  	}
      
  	/* Detect how much memory is installed, that's easy :-) */
! 	if (!vga256InfoRec.videoRam) {
! 		if ((rdinx(0x3ce, 0x0c) & 0xb8) == 0x30) {
! 			/* QVision */
! 			temp = rdinx(0x3ce, 0x0f);
! 			wrinx(0x3ce, 0x0f, 0x05);
! 			switch(rdinx(0x3ce, 0x54)) {
! 			case 0x00:
! 				vga256InfoRec.videoRam = 1024;
! 				break;
! 			case 0x02:
! 				vga256InfoRec.videoRam = 512;
! 				break;
! 			case 0x04:
! 				vga256InfoRec.videoRam = 1024;
! 				break;
! 			case 0x08:
! 				vga256InfoRec.videoRam = 2048;
! 				break;
! 			default:	/* guess */
! 				vga256InfoRec.videoRam = 512;
! 				break;
! 			}
! 			wrinx(0x3ce, 0x0f, temp);
! 		}
! 		else {
! 			/* AVGA */
! 			vga256InfoRec.videoRam = 512;
! 		}
! 	}
  
  	if (!vga256InfoRec.clocks)
  		vgaGetClocks(4, COMPAQClockSelect);  /* 4? clocks available */
***************
*** 277,282 ****
--- 274,280 ----
  
  	/* Compaq doesn't like the sequencer reset in vgaHWRestore */
  	outw(0x3ce, restore->ControlRegister0 << 8 | 0x40);
+ 	outw(0x3ce, restore->CRTCOverflow << 8 | 0x42);
  	outw(0x3ce, restore->PageRegister0 << 8 | 0x45);
  	outw(0x3ce, restore->PageRegister1 << 8 | 0x46);
  
***************
*** 292,310 ****
  static void *COMPAQSave(save)
  vgaCOMPAQPtr save;
  {
! 	unsigned char temp0, temp1, temp2, temp3;
  
  	outb(0x3ce, 0x0f); temp0 = inb(0x3cf);       /* Environment Register */
  	outb(0x3ce, 0x40); temp1 = inb(0x3cf);       /* Control Register 0 */
! 	outb(0x3ce, 0x45); temp2 = inb(0x3cf);       /* Page Register 0 */
! 	outb(0x3ce, 0x46); temp3 = inb(0x3cf);       /* Page Register 1 */
  
  	save = (vgaCOMPAQPtr)vgaHWSave(save, sizeof(vgaCOMPAQRec));
  
  	save->EnvironmentReg = temp0;
  	save->ControlRegister0 = temp1;
! 	save->PageRegister0 = temp2;
! 	save->PageRegister1 = temp3;
  
  	return ((void *) save);
  }
--- 290,310 ----
  static void *COMPAQSave(save)
  vgaCOMPAQPtr save;
  {
! 	unsigned char temp0, temp1, temp2, temp3, temp4;
  
  	outb(0x3ce, 0x0f); temp0 = inb(0x3cf);       /* Environment Register */
  	outb(0x3ce, 0x40); temp1 = inb(0x3cf);       /* Control Register 0 */
! 	outb(0x3ce, 0x42); temp2 = inb(0x3cf);       /* CRTC Overflow */
! 	outb(0x3ce, 0x45); temp3 = inb(0x3cf);       /* Page Register 0 */
! 	outb(0x3ce, 0x46); temp4 = inb(0x3cf);       /* Page Register 1 */
  
  	save = (vgaCOMPAQPtr)vgaHWSave(save, sizeof(vgaCOMPAQRec));
  
  	save->EnvironmentReg = temp0;
  	save->ControlRegister0 = temp1;
! 	save->CRTCOverflow = temp2;
! 	save->PageRegister0 = temp3;
! 	save->PageRegister1 = temp4;
  
  	return ((void *) save);
  }
***************
*** 344,349 ****
--- 344,350 ----
  #else
  	new->ControlRegister0 = 0x01;
  #endif
+ 	new->CRTCOverflow = 0x0;
  
  	new->EnvironmentReg = 0x05;
  	new->PageRegister0 = 0x0;
***************
*** 369,374 ****
--- 370,376 ----
  
  	outw(vgaIOBase + 4, (Base & 0x00FF00) | 0x0C);
  	outw(vgaIOBase + 4, ((Base & 0x00FF) << 8) | 0x0D);
+ 	outw(0x3ce, ((Base & 0x030000) >> 6) | 0x42);
  }
  
  /*
***************
*** 379,396 ****
  COMPAQSaveScreen(mode)
  int mode;
  {
! 	static unsigned char save1, save2, save3;
  
  	if (mode == SS_START)
  	{
! 		outb(0x3ce, 0x45); save1 = inb(0x3cf);  /* Page Register 0 */
! 		outb(0x3ce, 0x46); save2 = inb(0x3cf);  /* Page Register 1 */
! 		outb(0x3ce, 0x40); save3 = inb(0x3cf);  /* Control Register 0 */
  	}
  	else
  	{
! 		outw(0x3ce, save3 << 8 | 0x40);
! 		outw(0x3ce, save2 << 8 | 0x46);
! 		outw(0x3ce, save1 << 8 | 0x45);
  	}
  }
--- 381,427 ----
  COMPAQSaveScreen(mode)
  int mode;
  {
! 
! 	/*
! 	 * Allow pairs of calls to COMPAWSaveScreen() to be nested.
! 	 * It may be sufficient to ignore all but the outer-most pair,
! 	 * but this method is probably safest for now.
! 	 */
! 
! #define MAX_NEST_DEPTH 2
! #ifdef CR0
! #undef CR0
! #endif
  
+ 	static struct save {
+ 		unsigned char PR0, PR1, CR0;
+ 	} regsave[MAX_NEST_DEPTH + 1];
+ 
+ 	static int nest_depth = 0;
+ 
  	if (mode == SS_START)
  	{
! 		if (nest_depth > MAX_NEST_DEPTH)
! 		{
! 		    ErrorF("COMPAQSaveScreen: Warning: too much nesting\n");
! 		    nest_depth++;
! 		    return;
! 		}
! 		outb(0x3ce, 0x45);
! 		regsave[nest_depth].PR0 = inb(0x3cf);  /* Page Register 0 */
! 		outb(0x3ce, 0x46);
! 		regsave[nest_depth].PR1 = inb(0x3cf);  /* Page Register 1 */
! 		outb(0x3ce, 0x40);
! 		regsave[nest_depth].CR0 = inb(0x3cf);  /* Control Register 0 */
! 		nest_depth++;
  	}
  	else
  	{
! 		nest_depth--;
! 		if (nest_depth > MAX_NEST_DEPTH)
! 			return;
! 		outw(0x3ce, regsave[nest_depth].CR0 << 8 | 0x40);
! 		outw(0x3ce, regsave[nest_depth].PR1 << 8 | 0x46);
! 		outw(0x3ce, regsave[nest_depth].PR0 << 8 | 0x45);
  	}
  }
diff -c mit/server/ddx/x386/vga256/drivers/ncr/ncr_driver.c:2.9 mit/server/ddx/x386/vga256/drivers/ncr/ncr_driver.c:2.10
*** mit/server/ddx/x386/vga256/drivers/ncr/ncr_driver.c:2.9	Fri Mar 11 23:41:21 1994
--- mit/server/ddx/x386/vga256/drivers/ncr/ncr_driver.c	Fri Mar 11 23:41:21 1994
***************
*** 1,6 ****
  /* Copyright 1992 NCR Corporation - Dayton, Ohio, USA */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/ncr/ncr_driver.c,v 2.9 1993/09/22 15:47:40 dawes Exp $ */
  
  /*
   * Copyright 1992,1993 NCR Corporation, Inc.
--- 1,6 ----
  /* Copyright 1992 NCR Corporation - Dayton, Ohio, USA */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/ncr/ncr_driver.c,v 2.10 1993/12/25 14:02:42 dawes Exp $ */
  
  /*
   * Copyright 1992,1993 NCR Corporation, Inc.
***************
*** 420,426 ****
  NCRSave(save)
       vgaNCRPtr save;
  {
!   unsigned char PHostOffsetH, PHostOffsetL, SHostOffsetH, SHostOffsetL, temp;
  
    outb(0x3C4,0x18); PHostOffsetH = inb(0x3C5); outb(0x3C5, 0x00);
    outb(0x3C4,0x19); PHostOffsetL = inb(0x3C5); outb(0x3C5, 0x00);
--- 420,426 ----
  NCRSave(save)
       vgaNCRPtr save;
  {
!   unsigned char PHostOffsetH, PHostOffsetL, SHostOffsetH, SHostOffsetL;
  
    outb(0x3C4,0x18); PHostOffsetH = inb(0x3C5); outb(0x3C5, 0x00);
    outb(0x3C4,0x19); PHostOffsetL = inb(0x3C5); outb(0x3C5, 0x00);
diff -c mit/server/ddx/x386/vga256/drivers/oak/oak_driver.c:2.1 mit/server/ddx/x386/vga256/drivers/oak/oak_driver.c:2.2
*** mit/server/ddx/x386/vga256/drivers/oak/oak_driver.c:2.1	Fri Mar 11 23:41:22 1994
--- mit/server/ddx/x386/vga256/drivers/oak/oak_driver.c	Fri Mar 11 23:41:22 1994
***************
*** 36,42 ****
  
  /*************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/oak/oak_driver.c,v 2.1 1993/10/02 07:16:14 dawes Exp $ */
  
  /*
   * These are X and server generic header files.
--- 36,42 ----
  
  /*************************************************************************/
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/oak/oak_driver.c,v 2.2 1993/12/25 14:02:48 dawes Exp $ */
  
  /*
   * These are X and server generic header files.
***************
*** 97,104 ****
--- 97,106 ----
  extern void *   OAKSave();
  extern void     OAKRestore();
  static void     OAKAdjust();
+ #if 0
  static void     OAKSaveScreen();
  static void     OAKGetMode();
+ #endif
  /*
   * These are the bank select functions.  There are defined in oak_bank.s
   */
diff -c mit/server/ddx/x386/vga256/drivers/pvga1/driver.c:2.18 mit/server/ddx/x386/vga256/drivers/pvga1/driver.c:2.23
*** mit/server/ddx/x386/vga256/drivers/pvga1/driver.c:2.18	Fri Mar 11 23:41:24 1994
--- mit/server/ddx/x386/vga256/drivers/pvga1/driver.c	Fri Mar 11 23:41:24 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/pvga1/driver.c,v 2.18 1993/10/12 15:52:31 dawes Exp $
   * $XConsortium: driver.c,v 1.2 91/08/20 15:13:33 gildea Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/pvga1/driver.c,v 2.23 1994/03/05 02:01:01 dawes Exp $
   * $XConsortium: driver.c,v 1.2 91/08/20 15:13:33 gildea Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
***************
*** 29,34 ****
--- 29,37 ----
   * Accelerated support for 90C31 added by Mike Tierney <floyd@eng.umd.edu>
   */
  
+ /*
+  * 16 (17) clock support added by Anders Bostrom <erabosa@lmera.ericsson.se>
+  */
  
  #include "X.h"
  #include "input.h"
***************
*** 69,74 ****
--- 72,78 ----
    unsigned char InterlaceEnd;
    unsigned char MiscCtrl1;
    unsigned char MiscCtrl2;
+   unsigned char MiscCtrl4;
    unsigned char InterfaceCtrl;  /* WD90C1x */
    unsigned char MemoryInterface; /* WD90C1x, WD90C3x */
    unsigned char FlatPanelCtrl; /* WD90C2x */
***************
*** 116,123 ****
  
  #define new ((vgaPVGA1Ptr)vgaNewVideoState)
  
- #define MCLK	8		/* (VCLK == MCLK) is clock index 8 */
- 
  #define C_PVGA1	0		/* PVGA1 */
  #define WD90C00	1		/* WD90C00 */
  #define WD90C10	2		/* WD90C1x */
--- 120,125 ----
***************
*** 125,132 ****
  #define WD90C31	4		/* WD90C31 */
  #define WD90C20 5		/* WD90C2x */
  static int WDchipset;
! static int MClk;
  static unsigned char save_cs2 = 0;
  
  #define IS_WD90C3X(x)	(((x) == WD90C30) || ((x) == WD90C31))
  
--- 127,136 ----
  #define WD90C31	4		/* WD90C31 */
  #define WD90C20 5		/* WD90C2x */
  static int WDchipset;
! static int MClk = 45000;
! static int MClkIndex = 8;
  static unsigned char save_cs2 = 0;
+ static Bool use_cs2 = TRUE;
  
  #define IS_WD90C3X(x)	(((x) == WD90C30) || ((x) == WD90C31))
  
***************
*** 170,176 ****
  PVGA1ClockSelect(no)
       int no;
  {
!   static unsigned char save1, save2, save3;
    unsigned char temp;
  
    switch(no)
--- 174,180 ----
  PVGA1ClockSelect(no)
       int no;
  {
!   static unsigned char save1, save2, save3, save4;
    unsigned char temp;
  
    switch(no)
***************
*** 177,183 ****
    {
      case CLK_REG_SAVE:
        save1 = inb(0x3CC);
!       if (vga256InfoRec.clocks > 4)
        {
          outb(0x3CE, 0x0C); save2 = inb(0x3CF);
        }
--- 181,187 ----
    {
      case CLK_REG_SAVE:
        save1 = inb(0x3CC);
!       if (use_cs2)
        {
          outb(0x3CE, 0x0C); save2 = inb(0x3CF);
        }
***************
*** 185,194 ****
        {
          outb(vgaIOBase + 4, 0x2E); save3 = inb(vgaIOBase + 5);
        }
        break;
      case CLK_REG_RESTORE:
        outb(0x3C2, save1);
!       if (vga256InfoRec.clocks > 4)
        {
          outw(0x3CE, 0x0C | (save2 << 8));
        }
--- 189,202 ----
        {
          outb(vgaIOBase + 4, 0x2E); save3 = inb(vgaIOBase + 5);
        }
+       if (IS_WD90C3X(WDchipset))
+       {
+         outb(0x3C4, 0x12); save4 = inb(0x3C5);
+       }
        break;
      case CLK_REG_RESTORE:
        outb(0x3C2, save1);
!       if (use_cs2)
        {
          outw(0x3CE, 0x0C | (save2 << 8));
        }
***************
*** 196,226 ****
        {
          outw(vgaIOBase + 4, 0x2E | (save3 << 8));
        }
!       break;
!     case MCLK:
!       /*
!        * On all of the chipsets after PVGA1, you can feed MCLK as VCLK.  Hence
!        * a 9th clock.
!        */
!       outb(vgaIOBase+4, 0x2E);
!       temp = inb(vgaIOBase+5);
!       outb(vgaIOBase+5, temp | 0x10);
        break;
      default:
!       /*
!        * Disable feeding MCLK to VCLK
!        */
!       if (WDchipset != C_PVGA1)
        {
!           outb(vgaIOBase+4, 0x2E);
!           temp = inb(vgaIOBase+5);
!           outb(vgaIOBase+5, temp & 0xEF);
        }
!       temp = inb(0x3CC);
!       outb(0x3C2, ( temp & 0xf3) | ((no << 2) & 0x0C));
!       if (vga256InfoRec.clocks > 4)
        {
!         outw(0x3CE, 0x0C | ((((no & 0x04) >> 1) ^ save_cs2) << 8));
        }
    }
    return(TRUE);
--- 204,246 ----
        {
          outw(vgaIOBase + 4, 0x2E | (save3 << 8));
        }
!       if (IS_WD90C3X(WDchipset))
!       {
!         outw(0x3C4, 0x12 | (save4 << 8));
!       }
        break;
      default:
!       if (no == MClkIndex)
        {
!         /*
!          * On all of the chipsets after PVGA1, you can feed MCLK as VCLK.
!          */
!         outb(vgaIOBase+4, 0x2E);
!         temp = inb(vgaIOBase+5);
!         outb(vgaIOBase+5, temp | 0x10);
        }
!       else
        {
!         /*
!          * Disable feeding MCLK to VCLK
!          */
!         if (WDchipset != C_PVGA1)
!         {
!             outb(vgaIOBase+4, 0x2E);
!             temp = inb(vgaIOBase+5);
!             outb(vgaIOBase+5, temp & 0xEF);
!         }
!         temp = inb(0x3CC);
!         outb(0x3C2, ( temp & 0xf3) | ((no << 2) & 0x0C));
!         if (use_cs2)
!         {
!           outw(0x3CE, 0x0C | ((((no & 0x04) >> 1) ^ save_cs2) << 8));
!         }
!         if (IS_WD90C3X(WDchipset))
!         {
!           outb(0x3C4, 0x12); temp = inb(0x3C5);
!           outb(0x3C5, temp & 0xfb | ((no & 0x8) >> 1) ^ 0x4);
!         }
        }
    }
    return(TRUE);
***************
*** 299,317 ****
  	    }
  	    else if (testinx2(0x3C4, 0x14, 0x0F)) {
  		/* 
! 		 * WD90C3x - these registers MAY hold the numeric signature;
! 		 * they're not documented.  We'll see.  Odds are that this
! 		 * check will get turned around into != '0', to handle the
! 		 * later WD chipsets.
  		 */
  		sig[0] = rdinx(vgaIOBase+0x04, 0x36);
  		sig[1] = rdinx(vgaIOBase+0x04, 0x37);
!     		ErrorF("%s %s: WD: Signature for WD90C3X=[0x%02x 0x%02x]\n", 
             	       XCONFIG_PROBED, vga256InfoRec.name, sig[0], sig[1]);
! 		if (sig[1] == '1')
  		    WDchipset = WD90C31;
! 		else
  		    WDchipset = WD90C30;
  	    }
  	    else {
  		/* WD90C1x */
--- 319,353 ----
  	    }
  	    else if (testinx2(0x3C4, 0x14, 0x0F)) {
  		/* 
! 		 * WD90C24, 26, 30, 31.
  		 */
  		sig[0] = rdinx(vgaIOBase+0x04, 0x36);
  		sig[1] = rdinx(vgaIOBase+0x04, 0x37);
!     		ErrorF("%s %s: WD: Signature for WD90C[23]X=[0x%02x 0x%02x]\n", 
             	       XCONFIG_PROBED, vga256InfoRec.name, sig[0], sig[1]);
! 		if ((sig[0] == '3') && (sig[1] == '1'))
  		    WDchipset = WD90C31;
! 		else if ((sig[0] == '3') && (sig[1] == '0'))
! 		    WDchipset = WD90C30;
! 		else if ((sig[0] == '2') && (sig[1] == '4')) {
  		    WDchipset = WD90C30;
+ 		    ErrorF("%s %s: WD: Detected 90C24, treating it at 90C30\n",
+ 			   XCONFIG_PROBED, vga256InfoRec.name);
+ 		}
+ 		else if ((sig[0] == '2') && (sig[1] == '6')) {
+ 		    ErrorF("%s %s: WD: Detected 90C26.  This MAY work as a\n"
+ 			   XCONFIG_PROBED, vga256InfoRec.name);
+ 		    ErrorF("%s %s:     90C30, but we don't know for sure.\n",
+ 			   XCONFIG_PROBED, vga256InfoRec.name);
+         	    PVGA1EnterLeave(LEAVE);
+ 		    return(FALSE);
+ 		}
+ 		else {
+ 		    ErrorF("%s %s: WD: Unsupported chipset detected.\n"
+ 			   XCONFIG_PROBED, vga256InfoRec.name);
+         	    PVGA1EnterLeave(LEAVE);
+ 		    return(FALSE);
+ 		}		    
  	    }
  	    else {
  		/* WD90C1x */
***************
*** 382,393 ****
  	    numclocks = 8;
  	else
  	    numclocks = 4;
      else
  	numclocks = 9;
  
!     if (!vga256InfoRec.clocks) vgaGetClocks(numclocks, PVGA1ClockSelect);
      if (WDchipset != C_PVGA1) {
! 	if (vga256InfoRec.clocks != 9) {
  	    ErrorF("%s %s: %s: No MCLK specified in 'Clocks' line.  %s\n",
  		   XCONFIG_GIVEN, vga256InfoRec.name, 
  		   vga256InfoRec.chipset, "Using default 45");
--- 418,440 ----
  	    numclocks = 8;
  	else
  	    numclocks = 4;
+     else if (IS_WD90C3X(WDchipset))
+ 	numclocks = 17;
      else
  	numclocks = 9;
  
!     if (numclocks > 8)
!         MClkIndex = numclocks - 1;
! 
!     if ((WDchipset == C_PVGA1 || WDchipset == WD90C00) &&
! 	!OFLG_ISSET(OPTION_8CLKS, &vga256InfoRec.options)) {
!         use_cs2 = FALSE;
!     }
!     if (!vga256InfoRec.clocks) {
! 	vgaGetClocks(numclocks, PVGA1ClockSelect);
!     }
      if (WDchipset != C_PVGA1) {
! 	if (vga256InfoRec.clocks != MClkIndex + 1) {
  	    ErrorF("%s %s: %s: No MCLK specified in 'Clocks' line.  %s\n",
  		   XCONFIG_GIVEN, vga256InfoRec.name, 
  		   vga256InfoRec.chipset, "Using default 45");
***************
*** 394,400 ****
  	    MClk = 45000;
  	}
  	else
! 	    MClk = vga256InfoRec.clock[MCLK];
      }
  
      vga256InfoRec.bankedMono = TRUE;
--- 441,447 ----
  	    MClk = 45000;
  	}
  	else
! 	    MClk = vga256InfoRec.clock[MClkIndex];
      }
  
      vga256InfoRec.bankedMono = TRUE;
***************
*** 503,508 ****
--- 550,558 ----
        outw(vgaIOBase + 4, 0x8529);   /* unlock PVGA1 Register Bank 2 */
        outb(vgaIOBase + 4, 0x11); temp = inb(vgaIOBase + 5);
        outb(vgaIOBase + 5, temp & 0x7F);
+       /* Unlock sequencer extended registers */
+       outb(0x3C4, 0x06); temp = inb (0x3C5);
+       outb(0x3C5, temp | 0x48);
      }
    else
      {
***************
*** 549,555 ****
--- 599,609 ----
    outb(0x3CF, (temp & 0xF7) | (restore->MemorySize & 0x08));
         
    if (new->std.NoClock >= 0)
+   {
      outw(0x3CE, (restore->VideoSelect << 8) | 0x0C);
+     if (IS_WD90C3X(WDchipset))
+       outw(0x3C4, (restore->MiscCtrl4 << 8) | 0x12);
+   }
  #ifndef MONOVGA
    outw(0x3CE, (restore->CRTCCtrl << 8)    | 0x0D);
    outw(0x3CE, (restore->VideoCtrl << 8)   | 0x0E);
***************
*** 639,644 ****
--- 693,702 ----
    save->PR0B = PR0B;
    outb(0x3CE, 0x0B); save->MemorySize  = inb(0x3CF);
    outb(0x3CE, 0x0C); save->VideoSelect = inb(0x3CF);
+   if (IS_WD90C3X(WDchipset))
+   {
+     outb(0x3C4, 0x12); save->MiscCtrl4 = inb(0x3C5);
+   }
  #ifndef MONOVGA
    outb(0x3CE, 0x0D); save->CRTCCtrl    = inb(0x3CF);
    outb(0x3CE, 0x0E); save->VideoCtrl   = inb(0x3CF);
***************
*** 702,708 ****
--- 760,769 ----
     */
    new->MemorySize = 0x08;
    if (new->std.NoClock >= 0)
+   {
      new->VideoSelect = ((new->std.NoClock & 0x4) >> 1) ^ save_cs2;
+     new->MiscCtrl4 = ((new->std.NoClock & 0x8) >> 1) ^ 0x4;
+   }
  #ifndef MONOVGA
    new->CRTCCtrl = 0x00;
    new->VideoCtrl = 0x01;
***************
*** 720,728 ****
        new->InterlaceStart = 0x00;
        new->InterlaceEnd = 0x00;
      }
!   /* 9th clock select */
    new->MiscCtrl1 = 0x00;
!   if ((new->std.NoClock == MCLK) && (WDchipset != C_PVGA1))
      new->MiscCtrl1 |= 0x10;
    new->MiscCtrl2 = 0x00;
  
--- 781,789 ----
        new->InterlaceStart = 0x00;
        new->InterlaceEnd = 0x00;
      }
!   /* MCLK clock select */
    new->MiscCtrl1 = 0x00;
!   if ((new->std.NoClock == MClkIndex) && (WDchipset != C_PVGA1))
      new->MiscCtrl1 |= 0x10;
    new->MiscCtrl2 = 0x00;
  
***************
*** 741,749 ****
  
    if (IS_WD90C3X(WDchipset))
      {
!       new->MemoryInterface = 0xC1;
!       if (vga256InfoRec.clock[new->std.NoClock] > MClk)
!         new->MiscCtrl1 |= 0x40;
  
        if (WDchipset == WD90C31)
  	{
--- 802,812 ----
  
    if (IS_WD90C3X(WDchipset))
      {
!       if (vga256InfoRec.clock[new->std.NoClock] > MClk) {
! 	new->MemoryInterface = 0x41;
! 	new->MiscCtrl1 |= 0x40;
!       } else
! 	new->MemoryInterface = 0xC1;
  
        if (WDchipset == WD90C31)
  	{
diff -c mit/server/ddx/x386/vga256/drivers/pvga1/pvgablt.c:2.1 mit/server/ddx/x386/vga256/drivers/pvga1/pvgablt.c:2.2
*** mit/server/ddx/x386/vga256/drivers/pvga1/pvgablt.c:2.1	Fri Mar 11 23:41:24 1994
--- mit/server/ddx/x386/vga256/drivers/pvga1/pvgablt.c	Fri Mar 11 23:41:24 1994
***************
*** 21,27 ****
  
  /* WD90C31 code: Mike Tierney <floyd@eng.umd.edu> */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/pvga1/pvgablt.c,v 2.1 1993/09/22 15:48:12 dawes Exp $ */
  /* $XConsortium: cfbblt.c,v 1.7 91/05/06 15:13:21 rws Exp $ */
  
  #include	"X.h"
--- 21,27 ----
  
  /* WD90C31 code: Mike Tierney <floyd@eng.umd.edu> */
  
! /* $XFree86: mit/server/ddx/x386/vga256/drivers/pvga1/pvgablt.c,v 2.2 1993/12/25 14:03:16 dawes Exp $ */
  /* $XConsortium: cfbblt.c,v 1.7 91/05/06 15:13:21 rws Exp $ */
  
  #include	"X.h"
***************
*** 43,48 ****
--- 43,49 ----
  #include "paradise.h"
  
  
+ void
  pvgacfbDoBitbltCopy(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
      DrawablePtr	    pSrc, pDst;
      int		    alu;
***************
*** 67,95 ****
      int ydir;			/* 1 = top down, -1 = bottom up */
      int blit_dir;
  
-     unsigned long *psrcLine, *pdstLine;	
- 				/* pointers to line with current src and dst */
-     register unsigned char *psrc;/* pointer to current src longword */
-     register unsigned char *pdst;/* pointer to current dst longword */
- 
      MROP_DECLARE_REG()
  
- 				/* following used for looping through a line */
-     unsigned long startmask, endmask;	/* masks for writing ends of dst */
-     int nlMiddle;		/* whole longwords in dst */
-     int xoffSrc, xoffDst;
-     register int leftShift, rightShift;
-     register unsigned long bits;
-     register unsigned long bits1;
-     register int nl;		/* temp copy of nlMiddle */
- 
- 				/* place to store full source word */
-     int nstart;			/* number of ragged bits at start of dst */
-     int nend;			/* number of ragged bits at end of dst */
-     int srcStartOver;		/* pulling nstart bits from src
- 				   overflows into the next word? */
      int careful;
-     int tmpSrc;
      int srcaddr, dstaddr;
  
  
--- 68,76 ----
diff -c mit/server/ddx/x386/vga256/drivers/pvga1/pvgasolid.c:2.1 mit/server/ddx/x386/vga256/drivers/pvga1/pvgasolid.c:2.2
*** mit/server/ddx/x386/vga256/drivers/pvga1/pvgasolid.c:2.1	Fri Mar 11 23:41:25 1994
--- mit/server/ddx/x386/vga256/drivers/pvga1/pvgasolid.c	Fri Mar 11 23:41:25 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/pvga1/pvgasolid.c,v 2.1 1993/09/22 15:48:14 dawes Exp $
   * $XConsortium: cfbsolid.c,v 1.4 91/04/26 21:33:55 keith Exp $
   *
   * Copyright 1990 Massachusetts Institute of Technology
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/pvga1/pvgasolid.c,v 2.2 1993/12/25 14:03:18 dawes Exp $
   * $XConsortium: cfbsolid.c,v 1.4 91/04/26 21:33:55 keith Exp $
   *
   * Copyright 1990 Massachusetts Institute of Technology
***************
*** 40,45 ****
--- 40,46 ----
  #include "cfbmskbits.h"
  #include "cfbrrop.h"
  
+ extern void pvgacfbFillBoxSolid();
  
  void
  pvgacfbFillRectSolidCopy (pDrawable, pGC, nBox, pBox)
diff -c mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c:2.10 mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c:2.15
*** mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c:2.10	Fri Mar 11 23:41:27 1994
--- mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c	Fri Mar 11 23:41:28 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c,v 2.10 1993/09/22 15:48:20 dawes Exp $
   * Copyright 1992 by Alan Hourihane, Wigan, England.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/drivers/tvga8900/driver.c,v 2.15 1994/03/07 14:06:32 dawes Exp $
   * Copyright 1992 by Alan Hourihane, Wigan, England.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
***************
*** 57,62 ****
--- 57,66 ----
  #include "xf86_Config.h"
  #include "vga.h"
  
+ #ifdef XF86VGA16
+ #define MONOVGA
+ #endif
+ 
  typedef struct {
  	vgaHWRec std;          		/* std IBM VGA register 	*/
  	unsigned char ConfPort;		/* For memory selection 	*/
***************
*** 273,278 ****
--- 277,283 ----
      	{
        		unsigned char origVal, newVal;
        		char *TVGAName;
+ 		char *TreatAs = NULL;
  	
        		TVGA8900EnterLeave(ENTER);
  
***************
*** 279,284 ****
--- 284,291 ----
        		/* 
         		 * Check first that we have a Trident card.
         		 */
+ 		outb(0x3C4, 0x0B);
+ 		temp = inb(0x3C5);	/* Save old value */
  		outw(0x3C4, 0x000B);	/* Switch to Old Mode */
  		inb(0x3C5);		/* Now to New Mode */
        		outb(0x3C4, 0x0E);
***************
*** 295,300 ****
--- 302,309 ----
  			/*
  			 * Nope, so quit
  			 */
+ 			outb(0x3C4, 0x0B);	/* Restore value of 0x0B */
+ 			outb(0x3C5, temp);
  	  		TVGA8900EnterLeave(LEAVE);
  	  		return(FALSE);
  		}
***************
*** 323,341 ****
  			TVGAchipset = TVGA8900C;
        			TVGAName = "TVGA8900C";
        			break;
-       		case 0x33:
- 			TVGAchipset = TVGA8900CL;
-       			TVGAName = "TVGA8900CL";
-       			break;
        		case 0x23:
  			TVGAchipset = TVGA9000;
        			TVGAName = "TVGA9000";
        			break;
        		default:
        			TVGAName = "UNKNOWN";
        		}
        		ErrorF("%s Trident chipset version: 0x%02x (%s)\n", 
                         XCONFIG_PROBED, temp, TVGAName);
  		if (TVGAchipset == -1)
  		{
  			if (temp == 0x01)
--- 332,390 ----
  			TVGAchipset = TVGA8900C;
        			TVGAName = "TVGA8900C";
        			break;
        		case 0x23:
  			TVGAchipset = TVGA9000;
        			TVGAName = "TVGA9000";
        			break;
+       		case 0x33:
+ 			TVGAchipset = TVGA8900CL;
+       			TVGAName = "TVGA8900CL/D";
+       			break;
+ 		case 0x43:
+ 			TVGAchipset = TVGA9000;		/* Guess - dwex */
+ 			TVGAName = "TVGA9000i";
+ 			TreatAs = "TVGA9000";
+ 			break;
+ 		case 0x53:
+ 			TVGAchipset = TVGA8900CL;	/* This works - dwex */
+ 			TVGAName = "TVGA9200CX";
+ 			TreatAs = "TVGA8900CL";
+ 			break;
+ 		case 0x63:
+ 			TVGAchipset = TVGA8900CL;	/* Guess - dwex */
+ 			TVGAName = "TVGA9100B";
+ 			TreatAs = "TVGA8900CL";
+ 			break;
+ 		case 0x73:
+ 		case 0xF3:
+ 			TVGAchipset = TVGA8900CL;	/* This works - dwex */
+ 			TVGAName = "TVGA9420";
+ 			TreatAs = "TVGA8900CL";
+ 			break;
+ 		case 0x83:
+ 			TVGAchipset = TVGA8900CL;	/* Guess - dwex */
+ 			TVGAName = "TVGA8200";
+ 			TreatAs = "TVGA8900CL";
+ 			break;
+ 		case 0x93:
+ 			TVGAchipset = TVGA8900CL;	/* This works - dwex */
+ 			TVGAName = "TVGA9400CX";
+ 			TreatAs = "TVGA8900CL";
+ 			break;
+ 		case 0xA3:
+ 			TVGAchipset = TVGA8900CL;	/* Guess - dwex */
+ 			TVGAName = "TVGA9320";
+ 			TreatAs = "TVGA8900CL";
        		default:
        			TVGAName = "UNKNOWN";
        		}
        		ErrorF("%s Trident chipset version: 0x%02x (%s)\n", 
                         XCONFIG_PROBED, temp, TVGAName);
+ 		if (TreatAs != (char *)NULL)
+ 		{
+ 			ErrorF("%s \tDriver will treat chipset as: %s\n",
+ 			       XCONFIG_PROBED, TreatAs);
+ 		}
  		if (TVGAchipset == -1)
  		{
  			if (temp == 0x01)
***************
*** 459,465 ****
       	vgaTVGA8900Ptr restore;
  {
  	unsigned char temp;
- 	int i;
  
  	/*
  	 * Go to Old Mode.
--- 508,513 ----
***************
*** 518,524 ****
       	vgaTVGA8900Ptr save;
  {
  	unsigned char temp;
- 	int i;
  	
  	/*
  	 * Get current bank
--- 566,571 ----
diff -c mit/server/ddx/x386/vga256/enhanced/SpeedUpBlt.c:1.4 mit/server/ddx/x386/vga256/enhanced/SpeedUpBlt.c:2.0
*** mit/server/ddx/x386/vga256/enhanced/SpeedUpBlt.c:1.4	Fri Mar 11 23:41:32 1994
--- mit/server/ddx/x386/vga256/enhanced/SpeedUpBlt.c	Fri Mar 11 23:41:32 1994
***************
*** 1,4 ****
! /* $XFree86: mit/server/ddx/x386/vga256/enhanced/SpeedUpBlt.c,v 1.4 1993/03/27 09:05:46 dawes Exp $ */
  /*******************************************************************************
                          Copyr 1992 by Glenn G. Lai
  
--- 1,4 ----
! /* $XFree86: mit/server/ddx/x386/vga256/enhanced/SpeedUpBlt.c,v 2.0 1993/12/25 14:03:41 dawes Exp $ */
  /*******************************************************************************
                          Copyr 1992 by Glenn G. Lai
  
***************
*** 39,47 ****
      int	x, y, x1, y1, w, h;
      int	xdir, ydir;
  {
- 
- extern FILE *glenn;
- 
      if (sBase >= (unsigned char*)VGABASE)
  	if (dBase >= (unsigned char*)VGABASE) {
  	    unsigned src, dst;
--- 39,44 ----
diff -c mit/server/ddx/x386/vga256/enhanced/vgaBitBlt.c:1.7 mit/server/ddx/x386/vga256/enhanced/vgaBitBlt.c:2.1
*** mit/server/ddx/x386/vga256/enhanced/vgaBitBlt.c:1.7	Fri Mar 11 23:41:33 1994
--- mit/server/ddx/x386/vga256/enhanced/vgaBitBlt.c	Fri Mar 11 23:41:33 1994
***************
*** 1,4 ****
! /* $XFree86: mit/server/ddx/x386/vga256/enhanced/vgaBitBlt.c,v 1.7 1993/03/27 09:05:48 dawes Exp $ */
  /*
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
--- 1,4 ----
! /* $XFree86: mit/server/ddx/x386/vga256/enhanced/vgaBitBlt.c,v 2.1 1994/02/19 09:32:11 dawes Exp $ */
  /*
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
***************
*** 217,234 ****
  #define BUFSIZE 4096
  
        unsigned char buf[BUFSIZE];
!       int m,n;
  
        if (alu == GXcopy && (planemask & 0xFF) == 0xFF) {
                if (w == 0)     
                        return;
!               if ((m=BUFSIZE/w) <= 0)
                        return;
                if (ydir == 1) {
                        while (h) {
                                n = m>h ? h : m;
!                               (void)vgaImageRead(buf, psrcBase, widthSrc,w,x,y,0,0,w,n,xdir,ydir,alu,planemask);
!                               (void)vgaImageWrite(pdstBase, buf,w,widthDst,0,0,x1,y1,w,n,xdir,ydir,alu,planemask);
                                y += n;
                                y1 += n;
                                h -= n;
--- 217,236 ----
  #define BUFSIZE 4096
  
        unsigned char buf[BUFSIZE];
!       int m,n,ww;
  
        if (alu == GXcopy && (planemask & 0xFF) == 0xFF) {
                if (w == 0)     
                        return;
!               if (widthSrc != widthDst)     
                        return;
+               ww = widthSrc >= 0 ? widthSrc : -widthSrc;
+               m = BUFSIZE/ww;
                if (ydir == 1) {
                        while (h) {
                                n = m>h ? h : m;
!                               (void)vgaImageRead(buf, psrcBase, widthSrc,ww,x,y,0,0,w,n,xdir,ydir,alu,planemask);
!                               (void)vgaImageWrite(pdstBase, buf,ww,widthDst,0,0,x1,y1,w,n,xdir,ydir,alu,planemask);
                                y += n;
                                y1 += n;
                                h -= n;
***************
*** 242,249 ****
                                y -= n;
                                y1 -= n;
                                h -= n;
!                               (void)vgaImageRead(buf+BUFSIZE-w,psrcBase,widthSrc,w,x,y,0,0,w,n,xdir,ydir,alu,planemask);
!                               (void)vgaImageWrite(pdstBase,buf+BUFSIZE-w,w,widthDst,0,0,x1,y1,w,n,xdir,ydir,alu,planemask);
                        }
                }
        }
--- 244,251 ----
                                y -= n;
                                y1 -= n;
                                h -= n;
!                               (void)vgaImageRead(buf+BUFSIZE-ww,psrcBase,widthSrc,ww,x,y,0,0,w,n,xdir,ydir,alu,planemask);
!                               (void)vgaImageWrite(pdstBase,buf+BUFSIZE-ww,ww,widthDst,0,0,x1,y1,w,n,xdir,ydir,alu,planemask);
                        }
                }
        }
***************
*** 515,521 ****
  
  {
    register unsigned char *psrc, *pdst;
!   int hcount, vcount, count, srcPitch, dstPitch, tmp;
  
    if (alu == GXcopy && (planemask & 0xFF) == 0xFF) {
      if (xdir == 1) { /* left to right */
--- 517,523 ----
  
  {
    register unsigned char *psrc, *pdst;
!   int srcPitch, dstPitch;
  
    if (alu == GXcopy && (planemask & 0xFF) == 0xFF) {
      if (xdir == 1) { /* left to right */
diff -c mit/server/ddx/x386/vga256/enhanced/vgaFasm.h:2.0 mit/server/ddx/x386/vga256/enhanced/vgaFasm.h:2.2
*** mit/server/ddx/x386/vga256/enhanced/vgaFasm.h:2.0	Fri Mar 11 23:41:33 1994
--- mit/server/ddx/x386/vga256/enhanced/vgaFasm.h	Fri Mar 11 23:41:33 1994
***************
*** 1,4 ****
! /* $XFree86: mit/server/ddx/x386/vga256/enhanced/vgaFasm.h,v 2.0 1993/07/12 16:10:14 dawes Exp $ */
  /* Copyright 1992 by James Tsillas, Arlignton, Massachusetts.
  
  		All Rights Reserved
--- 1,4 ----
! /* $XFree86: mit/server/ddx/x386/vga256/enhanced/vgaFasm.h,v 2.2 1993/12/10 14:36:55 dawes Exp $ */
  /* Copyright 1992 by James Tsillas, Arlignton, Massachusetts.
  
  		All Rights Reserved
***************
*** 22,28 ****
  
  
  #ifndef RROP_NAME_CAT
! #if __STDC__ && !defined(UNIXCPP)
  #define RROP_NAME_CAT(prefix,suffix)    prefix##suffix
  #else
  #define RROP_NAME_CAT(prefix,suffix)    prefix/**/suffix
--- 22,28 ----
  
  
  #ifndef RROP_NAME_CAT
! #if (__STDC__ && !defined(UNIXCPP)) || (defined (SOLX86) && defined (__STDC__) && !defined (__GNUC__))
  #define RROP_NAME_CAT(prefix,suffix)    prefix##suffix
  #else
  #define RROP_NAME_CAT(prefix,suffix)    prefix/**/suffix
***************
*** 72,83 ****
      pdst++;
  
  /* The in-line assembler here only works for gcc2 */
! #if __GNUC__ > 1
  #define ESI __asm__ ("esi")
  #define EDI __asm__ ("edi")
  
  #define fBitBltC(xdir, dst, src, w, count, sP, dP) \
!   __asm__ volatile ("pushl %8          \n\
                       pushl %7          \n\
                       pushl %6          \n\
                       pushl %5          \n\
--- 72,83 ----
      pdst++;
  
  /* The in-line assembler here only works for gcc2 */
! #if __GNUC__ > 1 && defined(__STDC__)
  #define ESI __asm__ ("esi")
  #define EDI __asm__ ("edi")
  
  #define fBitBltC(xdir, dst, src, w, count, sP, dP) \
!   __asm__ __volatile__ ("pushl %8      \n\
                       pushl %7          \n\
                       pushl %6          \n\
                       pushl %5          \n\
***************
*** 96,104 ****
  		    : "edx", "ecx", "eax");
  
  #if MROP == Mcopy
! #define CLD __asm__ volatile ("cld")
  #define fCopyAL1_X(psrc, pdst, nl, srcR, widS, psrcS, rep) \
!   __asm__ volatile (".label00: orl %6, %6             \n\
                                 jz .label02            \n\
                                 movl %6, %%ecx         \n\
                                 cmpl %%ecx, %2         \n\
--- 96,104 ----
  		    : "edx", "ecx", "eax");
  
  #if MROP == Mcopy
! #define CLD __asm__ __volatile__ ("cld")
  #define fCopyAL1_X(psrc, pdst, nl, srcR, widS, psrcS, rep) \
!   __asm__ __volatile__ (".label00: orl %6, %6         \n\
                                 jz .label02            \n\
                                 movl %6, %%ecx         \n\
                                 cmpl %%ecx, %2         \n\
***************
*** 134,140 ****
  	"repz\n");
  #endif
  #define fCopyAL2_X(psrc, pdst, nl, srcR, widS, psrcS, rep) \
!   __asm__ volatile (".label10: orl %6, %6             \n\
                                 jz .label12            \n\
                                 movl %6, %%ecx         \n\
                                 cmpl %%ecx, %2         \n\
--- 134,140 ----
  	"repz\n");
  #endif
  #define fCopyAL2_X(psrc, pdst, nl, srcR, widS, psrcS, rep) \
!   __asm__ __volatile__ (".label10: orl %6, %6         \n\
                                 jz .label12            \n\
                                 movl %6, %%ecx         \n\
                                 cmpl %%ecx, %2         \n\
***************
*** 170,176 ****
  	"repz\n");
  #endif
  #define fCopyAL3_X(psrc, pdst, nl, srcR, widS, psrcS, rep) \
!   __asm__ volatile (".label20: orl %6, %6             \n\
                                 jz .label22            \n\
                                 movl %6, %%ecx         \n\
                                 cmpl %%ecx, %2         \n\
--- 170,176 ----
  	"repz\n");
  #endif
  #define fCopyAL3_X(psrc, pdst, nl, srcR, widS, psrcS, rep) \
!   __asm__ __volatile__ (".label20: orl %6, %6         \n\
                                 jz .label22            \n\
                                 movl %6, %%ecx         \n\
                                 cmpl %%ecx, %2         \n\
***************
*** 206,212 ****
  	"repz\n");
  #endif
  #define fCopyUL(psrc, pdst, bits, lShift, rShift)      \
!   __asm__ volatile ("           movl %4, %%edx         \n\
                                  movl %5, %%ecx         \n\
                                  shrl %%cl, %%edx       \n\
                                  lodsl                  \n\
--- 206,212 ----
  	"repz\n");
  #endif
  #define fCopyUL(psrc, pdst, bits, lShift, rShift)      \
!   __asm__ __volatile__ ("       movl %4, %%edx         \n\
                                  movl %5, %%ecx         \n\
                                  shrl %%cl, %%edx       \n\
                                  lodsl                  \n\
***************
*** 235,243 ****
  #define CLD
  #endif  /* Mcopy */
  #if RROP == GXcopy
! #define CLD __asm__ volatile ("cld")
  #define RROP_SOLID_L_X(pdst, nl, fill, rep) \
!   __asm__ volatile ( rep##                  \
                       "stosl"                \
  		    : "=D" ((unsigned long *) (pdst))  \
  		    : "D0" ((unsigned long *) (pdst)), \
--- 235,243 ----
  #define CLD
  #endif  /* Mcopy */
  #if RROP == GXcopy
! #define CLD __asm__ __volatile__ ("cld")
  #define RROP_SOLID_L_X(pdst, nl, fill, rep) \
!   __asm__ __volatile__ ( rep##                  \
                       "stosl"                \
  		    : "=D" ((unsigned long *) (pdst))  \
  		    : "D0" ((unsigned long *) (pdst)), \
diff -c mit/server/ddx/x386/vga256/vga/Imakefile:2.2 mit/server/ddx/x386/vga256/vga/Imakefile:2.3
*** mit/server/ddx/x386/vga256/vga/Imakefile:2.2	Fri Mar 11 23:41:35 1994
--- mit/server/ddx/x386/vga256/vga/Imakefile	Fri Mar 11 23:41:35 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/ddx/x386/vga256/vga/Imakefile,v 2.2 1993/10/02 07:16:23 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
  #include <Server.tmpl>
  
--- 1,4 ----
! XCOMM $XFree86: mit/server/ddx/x386/vga256/vga/Imakefile,v 2.3 1993/12/26 08:25:34 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.1 91/07/16 23:02:00 gildea Exp $
  #include <Server.tmpl>
  
***************
*** 9,15 ****
  DDXSRC = $(SERVERSRC)/ddx
  X386SRC = $(DDXSRC)/x386/common
  XF86OSSRC = $(DDXSRC)/x386/os-support
! INCLUDES = -I$(X386SRC) -I$(XF86OSSRC) -I. -I$(DDXSRC)/mfb -I$(DDXSRC)/mi \
             -I$(SERVERSRC)/include  -I../cfb.banked -I$(DDXSRC)/cfb \
             -I$(INCLUDESRC)
  
--- 9,16 ----
  DDXSRC = $(SERVERSRC)/ddx
  X386SRC = $(DDXSRC)/x386/common
  XF86OSSRC = $(DDXSRC)/x386/os-support
! INCLUDES = -I$(X386SRC) -I$(XF86OSSRC) -I../../common_hw -I. -I$(DDXSRC)/mfb \
!            -I$(DDXSRC)/mi \
             -I$(SERVERSRC)/include  -I../cfb.banked -I$(DDXSRC)/cfb \
             -I$(INCLUDESRC)
  
diff -c mit/server/ddx/x386/vga256/vga/vga.c:2.26 mit/server/ddx/x386/vga256/vga/vga.c:2.31
*** mit/server/ddx/x386/vga256/vga/vga.c:2.26	Fri Mar 11 23:41:36 1994
--- mit/server/ddx/x386/vga256/vga/vga.c	Fri Mar 11 23:41:36 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/vga/vga.c,v 2.26 1993/10/17 14:49:37 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/vga/vga.c,v 2.31 1994/02/01 13:57:05 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
***************
*** 27,32 ****
--- 27,33 ----
  
  
  #include "X.h"
+ #include "Xmd.h"
  #include "input.h"
  #include "scrnintstr.h"
  #include "pixmapstr.h"
***************
*** 39,44 ****
--- 40,46 ----
  
  #include "x386.h"
  #include "x386Priv.h"
+ #include "x386Procs.h"
  #include "xf86_OSlib.h"
  #include "xf86_Config.h"
  #if !defined(MONOVGA) && !defined(XF86VGA16)
***************
*** 68,73 ****
--- 70,76 ----
  
  extern Bool x386Exiting, x386Resetting, x386ProbeFailed;
  extern void NoopDDA();
+ extern Bool miDCInitialize();
  
  ScrnInfoRec vga256InfoRec = {
    FALSE,		/* Bool configured */
***************
*** 105,110 ****
--- 108,114 ----
    DEFAULT_MAX_CLOCK,	/* int maxClock */
    0,			/* int videoRam */
    0xC0000,		/* int BIOSbase */
+   0,			/* unsigned long MemBase, unused for this driver */
    240, 180,		/* int width, height */
    0,			/* unsigned long speedup */
    NULL,			/* DisplayModePtr modes */
***************
*** 156,167 ****
  int vgaSegmentSize;
  int vgaSegmentShift;
  int vgaSegmentMask;
- #ifndef XF86VGA16
  void *vgaReadBottom;
  void *vgaReadTop;
  void *vgaWriteBottom;
  void *vgaWriteTop =    (pointer)&writeseg; /* dummy for linking */
- #endif
  Bool vgaReadFlag;
  Bool vgaWriteFlag;
  Bool vgaUse2Banks;
--- 160,169 ----
***************
*** 171,176 ****
--- 173,179 ----
  int vgaIOBase;
  
  static ScreenPtr savepScreen = NULL;
+ static PixmapPtr ppix = NULL;
  static Bool (* saveInitFunc)();
  static void * (* saveSaveFunc)();
  static void (* saveRestoreFunc)();
***************
*** 285,291 ****
  	rounding = 32;
  #else /* MONOVGA */
  #ifdef XF86VGA16
! 	needmem = Drivers[i]->ChipMapSize * 8;
  	rounding = 32;
  #else
  	needmem = vga256InfoRec.videoRam * 1024;
--- 288,294 ----
  	rounding = 32;
  #else /* MONOVGA */
  #ifdef XF86VGA16
! 	needmem = vga256InfoRec.videoRam / 4 * 1024 * 8;
  	rounding = 32;
  #else
  	needmem = vga256InfoRec.videoRam * 1024;
***************
*** 352,383 ****
  	vgaSegmentSize = Drivers[i]->ChipSegmentSize;
  	vgaSegmentShift = Drivers[i]->ChipSegmentShift;
  	vgaSegmentMask = Drivers[i]->ChipSegmentMask;
- #ifndef XF86VGA16
  	vgaReadBottom = (pointer)Drivers[i]->ChipReadBottom;
  	vgaReadTop = (pointer)Drivers[i]->ChipReadTop;
  	vgaWriteBottom = (pointer)Drivers[i]->ChipWriteBottom;
  	vgaWriteTop = (pointer)Drivers[i]->ChipWriteTop;
- #endif
  	vgaUse2Banks = Drivers[i]->ChipUse2Banks;
  	vgaInterlaceType = Drivers[i]->ChipInterlaceType;
  	vgaOptionFlags = Drivers[i]->ChipOptionFlags;
  
- #if 0
- 	for (j=0; xf86_OptionTab[j].token >= 0; j++)
- 	  if ((OFLG_ISSET(xf86_OptionTab[j].token, &vga256InfoRec.options)))
- 	    if (OFLG_ISSET(xf86_OptionTab[j].token, &vgaOptionFlags))
-             {
- 	      if (x386Verbose)
- 		ErrorF("%s %s: Option \"%s\"\n", XCONFIG_GIVEN,
-                        vga256InfoRec.name, xf86_OptionTab[j].name);
- 	    }
- 	    else
-               ErrorF("%s: Option flag \"%s\" is not defined for chipset %s\n",
- 		     vga256InfoRec.name, xf86_OptionTab[j].name, 
- 		     vga256InfoRec.chipset);
- #else
  	xf86VerifyOptions(&vgaOptionFlags, &vga256InfoRec);
- #endif
  
  	if (vga256InfoRec.virtualX > 0 &&
  	    vga256InfoRec.virtualX * vga256InfoRec.virtualY > needmem)
--- 355,369 ----
***************
*** 424,431 ****
  	  {
  	    vga256InfoRec.virtualX -= vga256InfoRec.virtualX % rounding;
  	    ErrorF(
! 	     "%s: Virtual width rounded down to a multiple of %d (%d)\n",
! 	     vga256InfoRec.name, rounding, vga256InfoRec.virtualX);
              if (vga256InfoRec.virtualX < maxX)
              {
                ErrorF(
--- 410,418 ----
  	  {
  	    vga256InfoRec.virtualX -= vga256InfoRec.virtualX % rounding;
  	    ErrorF(
! 	     "%s %s: Virtual width rounded down to a multiple of %d (%d)\n",
! 	     XCONFIG_PROBED, vga256InfoRec.name, rounding,
! 	     vga256InfoRec.virtualX);
              if (vga256InfoRec.virtualX < maxX)
              {
                ErrorF(
***************
*** 473,488 ****
  	  ourmfbDoBitbltCopyInverted = mfbDoBitbltCopyInverted;
  	}
  #else
- #if 0
- 	if ((vga256InfoRec.speedup & ~SPEEDUP_ANYCHIPSET) &&
-             StrCaseCmp(vga256InfoRec.chipset,"et4000"))
- 	  {
- 	    ErrorF(
-               "%s: SpeedUp code selection modified because chipset != et4000\n",
-               vga256InfoRec.name);
- 	    vga256InfoRec.speedup &= SPEEDUP_ANYCHIPSET;
- 	  }
- #endif
  	if ((vga256InfoRec.speedup & ~SPEEDUP_ANYWIDTH) &&
              vga256InfoRec.virtualX != 1024)
  	  {
--- 460,465 ----
***************
*** 525,531 ****
  	vgaHWCursor.Initialized = FALSE;
  	(*vgaFbInitFunc)();
  
! #endif
  #endif /* !XF86VGA16 */
  
  	return TRUE;
--- 502,508 ----
  	vgaHWCursor.Initialized = FALSE;
  	(*vgaFbInitFunc)();
  
! #endif /* MONOVGA */
  #endif /* !XF86VGA16 */
  
  	return TRUE;
***************
*** 553,559 ****
      char           **argv;       /* The arguments themselves. Don't change! */
  {
    int displayResolution = 75;    /* default to 75dpi */
-   int mapSize;
    extern int monitorResolution;
  
    if (serverGeneration == 1) {
--- 530,535 ----
***************
*** 574,587 ****
        vgaVirtBase = vgaBase;
      }
  #else
- #ifdef XF86VGA16
-     vgaVirtBase = vgaBase;
- #else
      vgaVirtBase = (pointer)VGABASE;
  #endif
- #endif
  
- #ifndef XF86VGA16
      vgaReadBottom  = (void *)((unsigned int)vgaReadBottom
  			      + (unsigned int)vgaBase); 
      vgaReadTop     = (void *)((unsigned int)vgaReadTop
--- 550,558 ----
***************
*** 590,596 ****
  			      + (unsigned int)vgaBase); 
      vgaWriteTop    = (void *)((unsigned int)vgaWriteTop
  			      + (unsigned int)vgaBase); 
- #endif
    }
  
    if (!(vgaInitFunc)(vga256InfoRec.modes))
--- 561,566 ----
***************
*** 728,739 ****
       Bool enter;
       int screen_idx;
  {
-   pointer p;
    BoxRec  pixBox;
    RegionRec pixReg;
    DDXPointRec pixPt;
    PixmapPtr   pspix;
-   static PixmapPtr ppix = NULL;
    ScreenPtr   pScreen = savepScreen;
  
    if (!x386Resetting && !x386Exiting)
--- 698,707 ----
***************
*** 879,884 ****
--- 847,853 ----
   */
  Bool
  vgaCloseScreen(screen_idx)
+      int screen_idx;
  {
    /*
     * Hmm... The server may shut down even if it is not running on the
***************
*** 885,891 ****
     * current vt. Let's catch this case here.
     */
    x386Exiting = TRUE;
!   if (x386VTSema) vgaEnterLeaveVT(LEAVE, screen_idx);
    return(TRUE);
  }
  
--- 854,869 ----
     * current vt. Let's catch this case here.
     */
    x386Exiting = TRUE;
!   if (x386VTSema)
!     vgaEnterLeaveVT(LEAVE, screen_idx);
!   else if (ppix) {
!     /*
!      * 7-Jan-94 CEG: The server is not running on the current vt.
!      * Free the screen snapshot taken when the server vt was left.
!      */
!     (savepScreen->DestroyPixmap)(ppix);
!     ppix = NULL;
!   }
    return(TRUE);
  }
  
diff -c mit/server/ddx/x386/vga256/vga/vga.h:2.8 mit/server/ddx/x386/vga256/vga/vga.h:2.9
*** mit/server/ddx/x386/vga256/vga/vga.h:2.8	Fri Mar 11 23:41:37 1994
--- mit/server/ddx/x386/vga256/vga/vga.h	Fri Mar 11 23:41:37 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/vga/vga.h,v 2.8 1993/09/22 15:48:32 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/vga/vga.h,v 2.9 1994/02/13 04:19:35 dawes Exp $
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
   * Permission to use, copy, modify, distribute, and sell this software and its
***************
*** 129,135 ****
  extern int vgaIOBase;
  extern int vgaInterlaceType;
  
! #ifndef S3_SERVER
  #include "vgaBank.h"
  #endif
  
--- 129,135 ----
  extern int vgaIOBase;
  extern int vgaInterlaceType;
  
! #if !defined(S3_SERVER) && !defined(MACH32_SERVER)
  #include "vgaBank.h"
  #endif
  
***************
*** 186,191 ****
--- 186,194 ----
  #endif
  #ifdef S3_SERVER
  #define vga256InfoRec s3InfoRec
+ #endif
+ #ifdef MACH32_SERVER
+ #define vga256InfoRec mach32InfoRec
  #endif
  extern ScrnInfoRec vga256InfoRec;
  
diff -c mit/server/ddx/x386/vga256/vga/vgaAsm.h:1.5 mit/server/ddx/x386/vga256/vga/vgaAsm.h:2.0
*** mit/server/ddx/x386/vga256/vga/vgaAsm.h:1.5	Fri Mar 11 23:41:37 1994
--- mit/server/ddx/x386/vga256/vga/vgaAsm.h	Fri Mar 11 23:41:37 1994
***************
*** 1,43 ****
! /* $XFree86: mit/server/ddx/x386/vga256/vga/vgaAsm.h,v 1.5 1993/02/24 10:43:59 dawes Exp $ */
  
  /* Definitions for VGA bank assembler routines */
  
! #ifdef __386BSD__
! #ifdef ACK_ASSEMBLER
! #define VGABASE 0xFF000000
  #else
! #define VGABASE $0xFF000000
  #endif
- #else
- #ifdef ACK_ASSEMBLER
- #define VGABASE 0xF0000000
- #else
- #define VGABASE $0xF0000000
- #endif
- #endif
  
- #ifndef __ASSYNTAX_H__
- #define vgaSetReadWrite _vgaSetReadWrite
- #define vgaReadWriteNext _vgaReadWriteNext
- #define vgaReadWritePrev _vgaReadWritePrev
- #define vgaSetRead _vgaSetRead
- #define vgaReadNext _vgaReadNext
- #define vgaReadPrev _vgaReadPrev
- #define vgaSetWrite _vgaSetWrite
- #define vgaWriteNext _vgaWriteNext
- #define vgaWritePrev _vgaWritePrev
- #define vgaSaveBank _vgaSaveBank
- #define vgaRestoreBank _vgaRestoreBank
- #define vgaPushRead _vgaPushRead
- #define vgaPopRead _vgaPopRead
- #define vgaSegmentShift _vgaSegmentShift
- #define vgaSegmentMask _vgaSegmentMask
- #define vgaSegmentSize _vgaSegmentSize
- #define vgaSetReadFunc _vgaSetReadFunc
- #define vgaSetWriteFunc _vgaSetWriteFunc
- #define vgaSetReadWriteFunc _vgaSetReadWriteFunc
- #define vgaReadBottom _vgaReadBottom
- #define vgaReadTop _vgaReadTop
- #define vgaWriteBottom _vgaWriteBottom
- #define vgaWriteTop _vgaWriteTop
- #endif
--- 1,10 ----
! /* $XFree86: mit/server/ddx/x386/vga256/vga/vgaAsm.h,v 2.0 1994/02/10 21:27:08 dawes Exp $ */
  
  /* Definitions for VGA bank assembler routines */
  
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
! #define VGABASE CONST(0xFF000000)
  #else
! #define VGABASE CONST(0xF0000000)
  #endif
  
diff -c mit/server/ddx/x386/vga256/vga/vgaBank.h:1.12 mit/server/ddx/x386/vga256/vga/vgaBank.h:2.0
*** mit/server/ddx/x386/vga256/vga/vgaBank.h:1.12	Fri Mar 11 23:41:37 1994
--- mit/server/ddx/x386/vga256/vga/vgaBank.h	Fri Mar 11 23:41:37 1994
***************
*** 1,4 ****
! /* $XFree86: mit/server/ddx/x386/vga256/vga/vgaBank.h,v 1.12 1993/03/27 09:05:54 dawes Exp $ */
  /*
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
--- 1,4 ----
! /* $XFree86: mit/server/ddx/x386/vga256/vga/vgaBank.h,v 2.0 1994/02/10 21:27:10 dawes Exp $ */
  /*
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
   *
***************
*** 70,76 ****
  extern unsigned SpeedUpRowsPrev[];
  
  
! #ifdef __386BSD__
  #define VGABASE 0xFF000000
  #else
  #define VGABASE 0xF0000000
--- 70,76 ----
  extern unsigned SpeedUpRowsPrev[];
  
  
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__bsdi__)
  #define VGABASE 0xFF000000
  #else
  #define VGABASE 0xF0000000
diff -c mit/server/ddx/x386/vga256/vga/vgaHW.c:2.14 mit/server/ddx/x386/vga256/vga/vgaHW.c:2.17
*** mit/server/ddx/x386/vga256/vga/vgaHW.c:2.14	Fri Mar 11 23:41:38 1994
--- mit/server/ddx/x386/vga256/vga/vgaHW.c	Fri Mar 11 23:41:38 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/vga/vgaHW.c,v 2.14 1993/10/12 15:52:40 dawes Exp $
   * $XConsortium: vgaHW.c,v 1.3 91/08/26 15:40:56 gildea Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
--- 1,5 ----
  /*
!  * $XFree86: mit/server/ddx/x386/vga256/vga/vgaHW.c,v 2.17 1994/03/03 12:50:39 dawes Exp $
   * $XConsortium: vgaHW.c,v 1.3 91/08/26 15:40:56 gildea Exp $
   *
   * Copyright 1990,91 by Thomas Roell, Dinkelscherben, Germany.
***************
*** 25,34 ****
--- 25,66 ----
   * Author:  Thomas Roell, roell@informatik.tu-muenchen.de
   */
  
+ #ifdef ISC202
+ #include <sys/types.h>
+ #define WIFEXITED(a)  ((a & 0x00ff) == 0)  /* LSB will be 0 */
+ #define WEXITSTATUS(a) ((a & 0xff00) >> 8)
+ #define WIFSIGNALED(a) ((a & 0xff00) == 0) /* MSB will be 0 */
+ #define WTERMSIG(a) (a & 0x00ff)
+ #else
+ #if defined(ISC) && !defined(_POSIX_SOURCE)
+ #define _POSIX_SOURCE
+ #include <sys/types.h>
+ #include <sys/wait.h>
+ #undef _POSIX_SOURCE
+ #else
+ #if defined(_MINIX) || defined(AMOEBA)
+ #include <sys/types.h>
+ #endif
+ #include <sys/wait.h>
+ #endif
+ #endif
+ 
  #if !defined(AMOEBA) && !defined(_MINIX)
  #define _NEED_SYSI86
  #endif
  
+ #include "X.h"
+ #include "input.h"
+ #include "scrnintstr.h"
+ 
+ #include "compiler.h"
+ 
+ #include "x386.h"
+ #include "x386Priv.h"
+ #include "xf86_OSlib.h"
+ #include "xf86_HWlib.h"
+ #include "vga.h"
+ 
  #ifndef MONOVGA
  #ifndef SCO
  #ifndef SAVE_FONT1
***************
*** 37,43 ****
  #endif
  #endif
  
! #if defined(__386BSD__) || defined(MACH386) || defined(linux) || defined(AMOEBA) || defined(_MINIX)
  #ifndef NEED_SAVED_CMAP
  #define NEED_SAVED_CMAP
  #endif
--- 69,75 ----
  #endif
  #endif
  
! #if defined(__BSD__) || defined(MACH386) || defined(linux) || defined(AMOEBA) || defined(_MINIX)
  #ifndef NEED_SAVED_CMAP
  #define NEED_SAVED_CMAP
  #endif
***************
*** 61,67 ****
  /* bytes per plane to save for font data */
  #define FONT_AMOUNT 8192
  
! #if defined(__386BSD__) || defined(MACH386)
  #include <sys/time.h>
  #endif
  
--- 93,99 ----
  /* bytes per plane to save for font data */
  #define FONT_AMOUNT 8192
  
! #if defined(__BSD__) || defined(MACH386)
  #include <sys/time.h>
  #endif
  
***************
*** 71,106 ****
  #define WSTOPSIG(x) (x.w_stopsig)
  #endif
  
! #ifdef ISC202
! #include <sys/types.h>
! #define WIFEXITED(a)  ((a & 0x00ff) == 0)  /* LSB will be 0 */
! #define WEXITSTATUS(a) ((a & 0xff00) >> 8)
! #define WIFSIGNALED(a) ((a & 0xff00) == 0) /* MSB will be 0 */
! #define WTERMSIG(a) (a & 0x00ff)
! #else
! #if defined(ISC) && !defined(_POSIX_SOURCE)
! #define _POSIX_SOURCE
! #include <sys/types.h>
! #include <sys/wait.h>
! #undef _POSIX_SOURCE
! #else
! #if defined(_MINIX) || defined(AMOEBA)
! #include <sys/types.h>
! #endif
! #include <sys/wait.h>
! #endif
! #endif
! 
! #include "X.h"
! #include "input.h"
! #include "scrnintstr.h"
! 
! #include "compiler.h"
! 
! #include "x386.h"
! #include "x386Priv.h"
! #include "xf86_OSlib.h"
! #include "vga.h"
  
  #ifdef MONOVGA
  /* DAC indices for white and black */
--- 103,109 ----
  #define WSTOPSIG(x) (x.w_stopsig)
  #endif
  
! extern void SetTimeSinceLastInputEvent();
  
  #ifdef MONOVGA
  /* DAC indices for white and black */
***************
*** 537,543 ****
   * vgaHWSave --
   *      save the current video mode
   */
- static int saveflag=0;
  
  void *
  vgaHWSave(save, size)
--- 540,545 ----
***************
*** 962,967 ****
       int num;
       Bool (*ClockFunc)();
  {
!   xf86GetClocks(num, ClockFunc, vgaProtect, vgaSaveScreen, (vgaIOBase + 0x0A),
! 		0x08, 1, 28322, &vga256InfoRec);
  }
--- 964,969 ----
       int num;
       Bool (*ClockFunc)();
  {
!   xf86GetClocks(num, ClockFunc, vgaProtect, (void (*)())vgaSaveScreen,
! 		(vgaIOBase + 0x0A), 0x08, 1, 28322, &vga256InfoRec);
  }
diff -c mit/server/include/Imakefile:2.1 mit/server/include/Imakefile:2.3
*** mit/server/include/Imakefile:2.1	Fri Mar 11 23:41:43 1994
--- mit/server/include/Imakefile	Fri Mar 11 23:41:43 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/include/Imakefile,v 2.1 1993/09/22 15:49:32 dawes Exp $
  
  all::
  
--- 1,4 ----
! XCOMM $XFree86: mit/server/include/Imakefile,v 2.3 1994/02/28 14:12:41 dawes Exp $
  
  all::
  
***************
*** 5,10 ****
--- 5,12 ----
  InstallLinkKitNonExecFile(colormap.h,$(LINKKITDIR)/include)
  InstallLinkKitNonExecFile(cursor.h,$(LINKKITDIR)/include)
  InstallLinkKitNonExecFile(dix.h,$(LINKKITDIR)/include)
+ InstallLinkKitNonExecFile(dixfont.h,$(LINKKITDIR)/include)
+ InstallLinkKitNonExecFile(dixfontstr.h,$(LINKKITDIR)/include)
  InstallLinkKitNonExecFile(gc.h,$(LINKKITDIR)/include)
  InstallLinkKitNonExecFile(gcstruct.h,$(LINKKITDIR)/include)
  InstallLinkKitNonExecFile(input.h,$(LINKKITDIR)/include)
***************
*** 23,26 ****
  InstallLinkKitNonExecFile(window.h,$(LINKKITDIR)/include)
  InstallLinkKitNonExecFile(windowstr.h,$(LINKKITDIR)/include)
  
! DependTarget()
--- 25,28 ----
  InstallLinkKitNonExecFile(window.h,$(LINKKITDIR)/include)
  InstallLinkKitNonExecFile(windowstr.h,$(LINKKITDIR)/include)
  
! depend::
diff -c mit/server/include/os.h:2.0 mit/server/include/os.h:2.1
*** mit/server/include/os.h:2.0	Fri Mar 11 23:41:43 1994
--- mit/server/include/os.h	Fri Mar 11 23:41:43 1994
***************
*** 22,28 ****
  
  ******************************************************************/
  
! /* $XFree86: mit/server/include/os.h,v 2.0 1993/10/16 17:33:15 dawes Exp $ */
  /* $XConsortium: os.h,v 1.44 91/07/18 23:01:12 keith Exp $ */
  
  #ifndef OS_H
--- 22,28 ----
  
  ******************************************************************/
  
! /* $XFree86: mit/server/include/os.h,v 2.1 1993/12/25 14:04:31 dawes Exp $ */
  /* $XConsortium: os.h,v 1.44 91/07/18 23:01:12 keith Exp $ */
  
  #ifndef OS_H
***************
*** 144,149 ****
--- 144,150 ----
  #ifndef CAHILL_MALLOC
  void		Xfree();
  unsigned long	*Xalloc();
+ unsigned long	*Xcalloc();
  unsigned long	*Xrealloc();
  #else
  void		debug_Xfree();
diff -c mit/server/include/pixmapstr.h:2.0 mit/server/include/pixmapstr.h:2.1
*** mit/server/include/pixmapstr.h:2.0	Fri Mar 11 23:41:44 1994
--- mit/server/include/pixmapstr.h	Fri Mar 11 23:41:44 1994
***************
*** 1,4 ****
! /* $XFree86: mit/server/include/pixmapstr.h,v 2.0 1993/07/24 07:15:21 dawes Exp $ */
  /* $XConsortium: pixmapstr.h,v 5.0 89/06/09 15:00:35 keith Exp $ */
  /***********************************************************
  Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XFree86: mit/server/include/pixmapstr.h,v 2.1 1993/11/09 10:31:11 dawes Exp $ */
  /* $XConsortium: pixmapstr.h,v 5.0 89/06/09 15:00:35 keith Exp $ */
  /***********************************************************
  Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 50,60 ****
  
  typedef struct _Pixmap {
      DrawableRec		drawable;
-     int			slot;		/* Offscreen cache slot number */
-     int			cacheId;	/* Pixmap id number */
      int			refcnt;
      int			devKind;
      DevUnion		devPrivate;
  } PixmapRec;
  
  #endif /* PIXMAPSTRUCT_H */
--- 50,60 ----
  
  typedef struct _Pixmap {
      DrawableRec		drawable;
      int			refcnt;
      int			devKind;
      DevUnion		devPrivate;
+     int			slot;		/* Offscreen cache slot number */
+     int			cacheId;	/* Pixmap id number */
  } PixmapRec;
  
  #endif /* PIXMAPSTRUCT_H */
diff -c mit/server/include/servermd.h:2.0 mit/server/include/servermd.h:2.2
*** mit/server/include/servermd.h:2.0	Fri Mar 11 23:41:44 1994
--- mit/server/include/servermd.h	Fri Mar 11 23:41:44 1994
***************
*** 23,29 ****
  ******************************************************************/
  #ifndef SERVERMD_H
  #define SERVERMD_H 1
! /* $XFree86: mit/server/include/servermd.h,v 2.0 1993/08/19 16:10:28 dawes Exp $ */
  /* $XConsortium: servermd.h,v 1.60 91/06/30 11:29:35 rws Exp $ */
  
  /*
--- 23,30 ----
  ******************************************************************/
  #ifndef SERVERMD_H
  #define SERVERMD_H 1
! 
! /* $XFree86: mit/server/include/servermd.h,v 2.2 1994/02/10 21:27:23 dawes Exp $ */
  /* $XConsortium: servermd.h,v 1.60 91/06/30 11:29:35 rws Exp $ */
  
  /*
***************
*** 98,103 ****
--- 99,108 ----
   *	Currently defined for SPARC.
   */
  
+ #if !defined(MACH) && !defined(MACH386) && !defined(__OSF__)
+ #include <sys/param.h>
+ #endif
+ 
  #ifdef vax
  
  #define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the VAX only */
***************
*** 108,114 ****
  
  #endif /* vax */
  
! #ifdef sun
  
  #if defined(sun386) || defined(sun5)
  # define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the SUN only */
--- 113,119 ----
  
  #endif /* vax */
  
! #if defined(sun) && !defined (SOLX86)
  
  #if defined(sun386) || defined(sun5)
  # define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the SUN only */
***************
*** 132,138 ****
  #define	GLYPHPADBYTES		4
  #define GETLEFTBITS_ALIGNMENT	1
  
! #endif /* sun */
  
  #ifdef apollo
  
--- 137,143 ----
  #define	GLYPHPADBYTES		4
  #define GETLEFTBITS_ALIGNMENT	1
  
! #endif /* sun && !SOLX86 */
  
  #ifdef apollo
  
***************
*** 252,258 ****
  
  #endif /* luna */
  
! #if defined(SYSV386) || defined(__386BSD__) || defined(MACH386) || defined(linux) || (defined(AMOEBA) && defined(i80386)) || defined(_MINIX) || defined(__OSF__)
  
  #ifndef IMAGE_BYTE_ORDER
  #define IMAGE_BYTE_ORDER	LSBFirst
--- 257,263 ----
  
  #endif /* luna */
  
! #if defined(SYSV386) || defined(SOLX86) || (defined(BSD) && defined(__i386__)) || defined(MACH386) || defined(linux) || (defined(AMOEBA) && defined(i80386)) || defined(_MINIX) || defined(__OSF__)
  
  #ifndef IMAGE_BYTE_ORDER
  #define IMAGE_BYTE_ORDER	LSBFirst
***************
*** 278,284 ****
  #define GETLEFTBITS_ALIGNMENT	1
  #define AVOID_MEMORY_READ
  
! #endif /* SYSV386 || __386BSD__ || MACH386 || linux || (AMOEBA && i80386) || _MINIX */
  
  /* size of buffer to use with GetImage, measured in bytes. There's obviously
   * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
--- 283,289 ----
  #define GETLEFTBITS_ALIGNMENT	1
  #define AVOID_MEMORY_READ
  
! #endif /* SYSV386 || SOLX86 || (BSD && __i386__) || MACH386 || linux || (AMOEBA && i80386) || _MINIX */
  
  /* size of buffer to use with GetImage, measured in bytes. There's obviously
   * a trade-off between the amount of stack (or whatever ALLOCATE_LOCAL gives
diff -c mit/server/os/Imakefile:2.1 mit/server/os/Imakefile:2.2
*** mit/server/os/Imakefile:2.1	Fri Mar 11 23:41:46 1994
--- mit/server/os/Imakefile	Fri Mar 11 23:41:46 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/server/os/Imakefile,v 2.1 1993/09/21 15:25:17 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.49 91/08/22 14:23:54 rws Exp $
  #include <Server.tmpl>
  
--- 1,4 ----
! XCOMM $XFree86: mit/server/os/Imakefile,v 2.2 1993/12/23 13:26:25 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.49 91/08/22 14:23:54 rws Exp $
  #include <Server.tmpl>
  
***************
*** 77,93 ****
  #endif /* SpecialMalloc */
  #ifdef XFree86Version
       OS_DEFINES = -DXFREE86
  #endif
  #if WantServerLocks
     LOCK_DEFINES = -DSERVER_LOCK
- #else
-    LOCK_DEFINES =
  #endif /* WantServerLocks */
      DBM_DEFINES = NdbmDefines
      ADM_DEFINES = -DADMPATH=\"$(ADMDIR)/X\%smsgs\"
!         DEFINES = ConnectionFlags $(OS_DEFINES) $(XDMAUTHDEFS) $(RPCDEFS) \
! 		  $(SIGNAL_DEFINES) $(LOCK_DEFINES) $(PART_NET) \
! 		  $(MALLOC_DEFINES)
         INCLUDES = -I.  -I../include -I$(INCLUDESRC) -I$(TOP)/lib/Xau
      EXT_DEFINES = ExtensionDefines
         LINTLIBS = ../dix/llib-ldix.ln
--- 77,90 ----
  #endif /* SpecialMalloc */
  #ifdef XFree86Version
       OS_DEFINES = -DXFREE86
+     RGB_DEFINES = -DUSE_RGB_TXT
  #endif
  #if WantServerLocks
     LOCK_DEFINES = -DSERVER_LOCK
  #endif /* WantServerLocks */
      DBM_DEFINES = NdbmDefines
      ADM_DEFINES = -DADMPATH=\"$(ADMDIR)/X\%smsgs\"
!         DEFINES = ConnectionFlags $(OS_DEFINES) $(XDMAUTHDEFS) $(RPCDEFS) $(SIGNAL_DEFINES) $(LOCK_DEFINES) $(PART_NET) $(MALLOC_DEFINES) $(RGB_DEFINES)
         INCLUDES = -I.  -I../include -I$(INCLUDESRC) -I$(TOP)/lib/Xau
      EXT_DEFINES = ExtensionDefines
         LINTLIBS = ../dix/llib-ldix.ln
***************
*** 159,167 ****
  	$(RM) $@
  	cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
  #else
! # if defined(XFree86Version)
! SpecialObjectRule(oscolor.o,oscolor.c $(ICONFIGFILES),-DUSE_RGB_TXT)
! # else
  SpecialObjectRule(oscolor.o,oscolor.c $(ICONFIGFILES),$(DBM_DEFINES))
  # endif
  #endif
--- 156,162 ----
  	$(RM) $@
  	cc -c $(DBM_DEFINES) $(CDEBUGFLAGS) $(ALLDEFINES) $*.c
  #else
! # if !defined(XFree86Version)
  SpecialObjectRule(oscolor.o,oscolor.c $(ICONFIGFILES),$(DBM_DEFINES))
  # endif
  #endif
diff -c mit/server/os/oscolor.c:2.3 mit/server/os/oscolor.c:2.4
*** mit/server/os/oscolor.c:2.3	Fri Mar 11 23:41:47 1994
--- mit/server/os/oscolor.c	Fri Mar 11 23:41:47 1994
***************
*** 21,27 ****
  SOFTWARE.
  
  ******************************************************************/
! /* $XFree86: mit/server/os/oscolor.c,v 2.3 1993/09/29 11:13:02 dawes Exp $ */
  /* $XConsortium: oscolor.c,v 1.20 91/06/30 15:58:30 rws Exp $ */
  
  
--- 21,27 ----
  SOFTWARE.
  
  ******************************************************************/
! /* $XFree86: mit/server/os/oscolor.c,v 2.4 1994/02/10 21:27:30 dawes Exp $ */
  /* $XConsortium: oscolor.c,v 1.20 91/06/30 15:58:30 rws Exp $ */
  
  
***************
*** 31,37 ****
  #include <sdbm.h>
  #else
  #ifdef NDBM
! #ifdef __386BSD__
  #include <sys/types.h>
  #endif
  #ifdef SDBM
--- 31,38 ----
  #include <sdbm.h>
  #else
  #ifdef NDBM
! #include <X11/Xos.h>
! #if (BSD >= 199103)
  #include <sys/types.h>
  #endif
  #ifdef SDBM
diff -c mit/server/os/osinit.c:2.1 mit/server/os/osinit.c:2.2
*** mit/server/os/osinit.c:2.1	Fri Mar 11 23:41:47 1994
--- mit/server/os/osinit.c	Fri Mar 11 23:41:47 1994
***************
*** 21,27 ****
  SOFTWARE.
  
  ******************************************************************/
! /* $XFree86: mit/server/os/osinit.c,v 2.1 1993/09/23 15:53:37 dawes Exp $ */
  /* $XConsortium: osinit.c,v 1.40 91/11/29 15:21:07 rws Exp $ */
  #include "X.h"
  #include "os.h"
--- 21,27 ----
  SOFTWARE.
  
  ******************************************************************/
! /* $XFree86: mit/server/os/osinit.c,v 2.2 1994/02/10 21:27:32 dawes Exp $ */
  /* $XConsortium: osinit.c,v 1.40 91/11/29 15:21:07 rws Exp $ */
  #include "X.h"
  #include "os.h"
***************
*** 68,74 ****
  #endif
  
      if (!been_here) {
! #if !defined(SCO) && !defined(__386BSD__)
  	fclose(stdin);
  	fclose(stdout);
  #endif
--- 68,74 ----
  #endif
  
      if (!been_here) {
! #if !defined(SCO) && !(BSD >= 199103)
  	fclose(stdin);
  	fclose(stdout);
  #endif
diff -c mit/Imakefile:1.4 mit/Imakefile:2.0
*** mit/Imakefile:1.4	Fri Mar 11 23:41:48 1994
--- mit/Imakefile	Fri Mar 11 23:41:48 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/Imakefile,v 1.4 1993/03/27 07:42:06 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.105 91/07/27 14:13:23 rws Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags
--- 1,4 ----
! XCOMM $XFree86: mit/Imakefile,v 2.0 1993/12/17 10:56:22 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.105 91/07/27 14:13:23 rws Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags
***************
*** 10,17 ****
  #if BuildServer
  SERVERDIRSTOMAKE = server rgb
  #endif
          SUBDIRS = config include lib extensions fonts $(SERVERDIRSTOMAKE) \
! 			clients demos util man
    LNINSTALLDIRS = $(LIBSRC) $(EXTENSIONSRC)
  
  
--- 10,24 ----
  #if BuildServer
  SERVERDIRSTOMAKE = server rgb
  #endif
+ 
+ #if !BuildServersOnly
+      CLIENTDIRS = clients
+        DEMODIRS = demos
+         MANDIRS = man
+ #endif
+ 
          SUBDIRS = config include lib extensions fonts $(SERVERDIRSTOMAKE) \
! 			$(CLIENTDIRS) $(DEMODIRS) util $(MANDIRS)
    LNINSTALLDIRS = $(LIBSRC) $(EXTENSIONSRC)
  
  
diff -c mit/bug-report:1.1.1.8 mit/bug-report:1.1.1.9
*** mit/bug-report:1.1.1.8	Fri Mar 11 23:41:49 1994
--- mit/bug-report	Fri Mar 11 23:41:49 1994
***************
*** 2,8 ****
  Subject: [area]: [synopsis]   [replace with actual area and short description]
  
  VERSION:
!     R5, public-patch-25
      [MIT public patches will edit this line to indicate the patch level]
  
  CLIENT MACHINE and OPERATING SYSTEM:
--- 2,8 ----
  Subject: [area]: [synopsis]   [replace with actual area and short description]
  
  VERSION:
!     R5, public-patch-26
      [MIT public patches will edit this line to indicate the patch level]
  
  CLIENT MACHINE and OPERATING SYSTEM:
diff -c mit/config/Imake.tmpl:2.6 mit/config/Imake.tmpl:2.10
*** mit/config/Imake.tmpl:2.6	Fri Mar 11 23:41:54 1994
--- mit/config/Imake.tmpl	Fri Mar 11 23:41:54 1994
***************
*** 7,13 ****
  #endif
  XCOMM -------------------------------------------------------------------------
  XCOMM Makefile generated from IMAKE_TEMPLATE and INCLUDE_IMAKEFILE
! XCOMM $XFree86: mit/config/Imake.tmpl,v 2.6 1993/10/02 07:11:59 dawes Exp $
  XCOMM $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  XCOMM
  XCOMM Platform-specific parameters may be set in the appropriate <vendor>.cf
--- 7,13 ----
  #endif
  XCOMM -------------------------------------------------------------------------
  XCOMM Makefile generated from IMAKE_TEMPLATE and INCLUDE_IMAKEFILE
! XCOMM $XFree86: mit/config/Imake.tmpl,v 2.10 1994/02/28 13:54:37 dawes Exp $
  XCOMM $XConsortium: Imake.tmpl,v 1.139 91/09/16 08:52:48 rws Exp $
  XCOMM
  XCOMM Platform-specific parameters may be set in the appropriate <vendor>.cf
***************
*** 74,85 ****
  #define VaxArchitecture
  #endif
  
! #ifdef sun
  #define MacroIncludeFile <sun.cf>
  #define MacroFile sun.cf
  #undef sun
  #define SunArchitecture
! #endif /* sun */
  
  #ifdef hpux
  #define MacroIncludeFile <hp.cf>
--- 74,85 ----
  #define VaxArchitecture
  #endif
  
! #if defined(sun) && !defined(SOLX86) 
  #define MacroIncludeFile <sun.cf>
  #define MacroFile sun.cf
  #undef sun
  #define SunArchitecture
! #endif /* sun && !SOLX86 */
  
  #ifdef hpux
  #define MacroIncludeFile <hp.cf>
***************
*** 231,236 ****
--- 231,243 ----
  #endif /* MOTOROLA */
  
  #ifdef SYSV386
+ # ifdef SOLX86
+ #  undef SOLX86
+ #  define SVR4
+ #  define i386SVR4Architecture
+ #  undef i386SVR3Architecture
+ #  define i386SVR4Solarisx86 
+ # endif
  # define MacroIncludeFile <x386.cf>
  # define MacroFile x386.cf
  # undef i386
***************
*** 284,294 ****
  # endif /* SVR4 */
  #endif /* SYSV386 */
  
! #if defined(__386BSD__) || defined(__NetBSD__)
  # define MacroIncludeFile <x386.cf>
  # define MacroFile x386.cf
  # define i386BsdArchitecture
! # undef __386BSD__
  # ifdef __NetBSD__
  #  define i386NetBsd
  #  undef __NetBSD__
--- 291,303 ----
  # endif /* SVR4 */
  #endif /* SYSV386 */
  
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
  # define MacroIncludeFile <x386.cf>
  # define MacroFile x386.cf
  # define i386BsdArchitecture
! # ifdef __386BSD__
! #  undef __386BSD__
! # endif /* __386BSD__ */
  # ifdef __NetBSD__
  #  define i386NetBsd
  #  undef __NetBSD__
***************
*** 296,306 ****
  # ifdef NetBSD
  #  undef NetBSD
  # endif /* NetBSD */
! # ifdef FreeBSD
  #  define i386FreeBsd
  #  undef FreeBSD
  # endif /* FreeBSD */
! #endif /* __386BSD__ || __NetBSD__ */
  
  #ifdef __bsdi__
  # define MacroIncludeFile <x386.cf>
--- 305,318 ----
  # ifdef NetBSD
  #  undef NetBSD
  # endif /* NetBSD */
! # ifdef __FreeBSD__
  #  define i386FreeBsd
+ #  undef __FreeBSD__
+ # endif /* __FreeBSD__ */
+ # ifdef FreeBSD
  #  undef FreeBSD
  # endif /* FreeBSD */
! #endif /* __386BSD__ || __NetBSD__ || __FreeBSD__ */
  
  #ifdef __bsdi__
  # define MacroIncludeFile <x386.cf>
***************
*** 767,772 ****
--- 779,790 ----
  #define LdCombineFlags -X -r
  #endif
  #endif
+ #if defined(MakeLdRunPath) && AlternateUsrLibDir
+ #define LdRunPath MakeLdRunPath($(USRLIBDIR))
+ #define LdLinkPath MakeLdLinkPath($(USRLIBDIR))
+ #else
+ #define LdRunPath /* */
+ #endif
  #ifndef TagsCmd
  #define TagsCmd ctags
  #endif
***************
*** 794,799 ****
--- 812,826 ----
  #ifndef NeqnCmd
  #define NeqnCmd neqn
  #endif
+ #ifndef LexCmd
+ #define LexCmd lex
+ #endif
+ #ifndef LexLib
+ #define LexLib
+ #endif
+ #ifndef YaccCmd
+ #define YaccCmd yacc
+ #endif
  #ifndef ExpandManNames
  #if SystemV
  #define ExpandManNames NO
***************
*** 826,837 ****
    BOOTSTRAPCFLAGS = BootstrapCFlags	/* set if cpp does not have uniq sym */
                 CC = CcCmd
                 AS = AsCmd
- #ifdef LexCmd
                LEX = LexCmd
! #endif
! #ifdef YaccCmd
               YACC = YaccCmd
- #endif
  #if HasFortran
                 FC = FortranCmd
        FDEBUGFLAGS = FortranDebugFlags
--- 853,861 ----
    BOOTSTRAPCFLAGS = BootstrapCFlags	/* set if cpp does not have uniq sym */
                 CC = CcCmd
                 AS = AsCmd
                LEX = LexCmd
!            LEXLIB = LexLib
               YACC = YaccCmd
  #if HasFortran
                 FC = FortranCmd
        FDEBUGFLAGS = FortranDebugFlags
***************
*** 944,949 ****
--- 968,976 ----
        CDEBUGFLAGS = DefaultCDebugFlags
          CCOPTIONS = DefaultCCOptions	/* to distinguish from param flags */
      ANSICCOPTIONS = AnsiCCOptions
+ 
+         LDRUNPATH = LdRunPath
+        LDLINKPATH = LdLinkPath
  /*
   * STD_INCLUDES contains system-specific includes
   * TOP_INCLUDES specifies how to get to /usr/include or its build substitute
***************
*** 966,974 ****
  #endif
  #if !CrossCompiling
  #if AlternateUsrLibDir && defined(UseInstalled)
!         LDOPTIONS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR)
  #else
!         LDOPTIONS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS)
  #endif
  #else
          LDOPTIONS =
--- 993,1001 ----
  #endif
  #if !CrossCompiling
  #if AlternateUsrLibDir && defined(UseInstalled)
!         LDOPTIONS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) -L$(USRLIBDIR) $(LDRUNPATH)
  #else
!         LDOPTIONS = $(ANSICCOPTIONS) $(CDEBUGFLAGS) $(CCOPTIONS) $(LOCAL_LDFLAGS) $(LDRUNPATH)
  #endif
  #else
          LDOPTIONS =
diff -c mit/config/Imakefile:2.4 mit/config/Imakefile:2.5
*** mit/config/Imakefile:2.4	Fri Mar 11 23:41:55 1994
--- mit/config/Imakefile	Fri Mar 11 23:41:55 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/config/Imakefile,v 2.4 1993/09/04 16:19:13 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.14 91/12/02 11:24:14 rws Exp $
  
  /*
--- 1,4 ----
! XCOMM $XFree86: mit/config/Imakefile,v 2.5 1994/03/03 12:40:20 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.14 91/12/02 11:24:14 rws Exp $
  
  /*
***************
*** 95,100 ****
--- 95,101 ----
  BuildIncludes($(HEADERS),config,..)
  
  InstallMultipleDestFlags(install,$(CFFILES),$(CONFIGDIR),$(INSTDATFLAGS))
+ InstallNonExecFile(README,$(CONFIGDIR))
  
  depend::
  
diff -c mit/config/Project.tmpl:2.1 mit/config/Project.tmpl:2.5
*** mit/config/Project.tmpl:2.1	Fri Mar 11 23:41:55 1994
--- mit/config/Project.tmpl	Fri Mar 11 23:41:55 1994
***************
*** 1,6 ****
  XCOMM -------------------------------------------------------------------------
  XCOMM X Window System Build Parameters
! XCOMM $XFree86: mit/config/Project.tmpl,v 2.1 1993/09/17 16:10:43 dawes Exp $
  XCOMM $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $
  
  /*****************************************************************************
--- 1,6 ----
  XCOMM -------------------------------------------------------------------------
  XCOMM X Window System Build Parameters
! XCOMM $XFree86: mit/config/Project.tmpl,v 2.5 1994/02/27 11:25:48 dawes Exp $
  XCOMM $XConsortium: Project.tmpl,v 1.138.1.1 92/11/11 09:49:19 rws Exp $
  
  /*****************************************************************************
***************
*** 20,25 ****
--- 20,28 ----
  #ifndef BuildServer
  #define BuildServer		YES
  #endif
+ #ifndef BuildServersOnly
+ #define BuildServersOnly	NO
+ #endif
  #ifndef BuildFonts
  #define BuildFonts		BuildServer
  #endif
***************
*** 412,419 ****
  #ifndef UseCCMakeDepend			/* use slow cc -E script */
  #define UseCCMakeDepend NO
  #endif
  #ifndef DependDir
! #if UseCCMakeDepend
  #define DependDir $(SCRIPTSRC)
  #else
  #define DependDir $(UTILSRC)/makedepend
--- 415,425 ----
  #ifndef UseCCMakeDepend			/* use slow cc -E script */
  #define UseCCMakeDepend NO
  #endif
+ #ifndef UseGccMakeDepend		/* Slowish but correct gcc -M */
+ #define UseGccMakeDepend NO
+ #endif
  #ifndef DependDir
! #if UseCCMakeDepend || UseGccMakeDepend
  #define DependDir $(SCRIPTSRC)
  #else
  #define DependDir $(UTILSRC)/makedepend
***************
*** 423,430 ****
--- 429,440 ----
  #define ContribDir $(TOP)/../contrib	/* contrib is outside core tree */
  #endif
  #ifndef DependCmd
+ #if UseGccMakeDepend
+ #define DependCmd $(DEPENDSRC)/gccmakedep
+ #else
  #define DependCmd $(DEPENDSRC)/makedepend
  #endif
+ #endif
  #ifndef RemoveTargetProgramByMoving
  #define RemoveTargetProgramByMoving NO
  #endif
***************
*** 552,558 ****
--- 562,572 ----
  
  #ifdef UseInstalled
              IMAKE = imake		/* assume BINDIR in path */
+ #if UseGccMakeDepend
+            DEPEND = gccmakedep		/* assume BINDIR in path */
+ #else
             DEPEND = makedepend		/* assume BINDIR in path */
+ #endif
                RGB = rgb			/* assume BINDIR in path */
  #ifdef SnfFonts
              FONTC = bdftosnf		/* assume BINDIR in path */
diff -c /dev/null mit/config/bsdLib.rules:2.1
*** /dev/null	Fri Mar 11 23:41:56 1994
--- mit/config/bsdLib.rules	Fri Mar 11 23:41:56 1994
***************
*** 0 ****
--- 1,73 ----
+ XCOMM $XFree86: mit/config/bsdLib.rules,v 2.1 1993/12/03 13:11:55 dawes Exp $
+ XCOMM $XConsortium: sunLib.rules,v 1.7 91/12/20 11:19:47 rws Exp $
+ 
+ /*
+  * NetBSD/FreeBSD shared library rules
+  */
+ 
+ #ifndef HasSharedLibraries
+ #define HasSharedLibraries YES
+ #endif
+ #ifndef ForceNormalLib
+ #define ForceNormalLib YES
+ #endif
+ #ifndef SharedDataSeparation
+ #define SharedDataSeparation NO
+ #endif
+ #ifndef SharedCodeDef
+ #define SharedCodeDef
+ #endif
+ #ifndef SharedLibraryDef
+ #define SharedLibraryDef -DBSDSHLIB
+ #endif
+ #ifndef ShLibIncludeFile
+ #define ShLibIncludeFile <bsdLib.tmpl>
+ #endif
+ #ifndef SharedLibraryLoadFlags
+ #define SharedLibraryLoadFlags -Bshareable
+ #endif
+ #ifndef PositionIndependentCFlags
+ #define PositionIndependentCFlags -fpic
+ #endif
+ 
+ /*
+  * InstallSharedLibrary - generate rules to install the shared library.
+  */
+ #ifndef InstallSharedLibrary
+ #define	InstallSharedLibrary(libname,rev,dest)				@@\
+ install:: Concat(lib,libname.so.rev) 					@@\
+ 	MakeDir($(DESTDIR)dest)						@@\
+ 	$(INSTALL) -c $(INSTLIBFLAGS) Concat(lib,libname.so.rev) $(DESTDIR)dest @@\
+ 
+ #endif /* InstallSharedLibrary */
+ 
+ /*
+  * NormalSharedLibraryTarget - generate rules to create a shared library;
+  * build it into a different name so that the we do not hose people by having
+  * the library gone for long periods.
+  */
+ #ifndef SharedLibraryTarget
+ #define SharedLibraryTarget(libname,rev,solist,down,up)			@@\
+ AllTarget(Concat(lib,libname.so.rev))					@@\
+ 									@@\
+ Concat(lib,libname.so.rev):  solist					@@\
+ 	$(RM) $@~							@@\
+ 	(cd down; $(LD) -o up/$@~ $(SHLIBLDFLAGS) solist $(REQUIREDLIBS)) @@\
+ 	$(RM) $@ 							@@\
+ 	$(MV) $@~ $@  							@@\
+ 									@@\
+ clean::									@@\
+ 	$(RM) Concat(lib,libname.so.rev)
+ 
+ #endif /* SharedLibraryTarget */
+ 
+ /*
+  * SharedLibraryDataTarget - generate rules to create shlib data file;
+  */
+ #ifndef SharedLibraryDataTarget
+ #define SharedLibraryDataTarget(libname,rev,salist)
+ #endif /* SharedLibraryDataTarget */
+ 
+ #ifndef InstallSharedLibraryData
+ #define InstallSharedLibraryData(libname,rev,dest)
+ #endif /* InstallSharedLibraryData */
diff -c /dev/null mit/config/bsdLib.tmpl:2.1
*** /dev/null	Fri Mar 11 23:41:56 1994
--- mit/config/bsdLib.tmpl	Fri Mar 11 23:41:56 1994
***************
*** 0 ****
--- 1,79 ----
+ XCOMM $XFree86: mit/config/bsdLib.tmpl,v 2.1 1993/12/17 10:57:09 dawes Exp $
+ XCOMM $XConsortium: sunLib.tmpl,v 1.14.1.2 92/11/11 09:52.02 rws Exp $
+ 
+ /*
+  * SunOS shared library template
+  */
+ 
+ #ifndef SharedXlibRev
+ #define SharedXlibRev 2.0
+ #endif
+ #ifndef SharedOldXRev
+ #define SharedOldXRev 2.0
+ #endif
+ #ifndef SharedXtRev
+ #define SharedXtRev 2.0
+ #endif
+ #ifndef SharedXawRev
+ #define SharedXawRev 2.0
+ #endif
+ #ifndef SharedXmuRev
+ #define SharedXmuRev 2.0
+ #endif
+ #ifndef SharedXextRev
+ #define SharedXextRev 2.0
+ #endif
+ #ifndef SharedXinputRev
+ #define SharedXinputRev 2.0
+ #endif
+ #ifndef SharedXTrapRev
+ #define SharedXTrapRev 2.0
+ #endif
+ #ifndef SharedPexRev
+ #define SharedPexRev 2.0
+ #endif
+ 
+ SHLIBLDFLAGS = SharedLibraryLoadFlags
+ PICFLAGS = PositionIndependentCFlags
+ 
+ /*
+  * and now a little bit of magic for using imake without source tree; if we
+  * are using shared libraries, we really do not need to depend on anything
+  */
+ #if SharedLibXext
+   DEPEXTENSIONLIB = /* _UseCat($(USRLIBDIR),$(EXTENSIONSRC)/lib,/libXext.so.$(SOXEXTREV)) */
+      EXTENSIONLIB = _Use(-lXext,-L$(EXTENSIONSRC)/lib -lXext)
+ #endif
+ #if SharedLibX
+           DEPXLIB = $(DEPEXTENSIONLIB) /* _UseCat($(USRLIBDIR),$(XLIBSRC),/libX11.so.$(SOXLIBREV)) */
+              XLIB = $(EXTENSIONLIB) _Use(-lX11,-L$(XLIBSRC) -lX11)
+ #endif
+ #if SharedLibXmu
+ /* Sun shared libraries are deficient in link semantics */
+         DEPXMULIB = _UseCat($(USRLIBDIR),$(XMUSRC),/libXmu.so.$(SOXMUREV))
+        XMULIBONLY = _Use(-lXmu,-L$(XMUSRC) -lXmu)
+            XMULIB = _Use(-lXmu,-L$(XMUSRC) -lXmu -L$(TOOLKITSRC) -lXt -L$(EXTENSIONSRC)/lib -lXext -L$(XLIBSRC) -lX11)
+ #if !defined(UseInstalled) && !defined(XawClientLibs)
+ #define XawClientLibs $(XAWLIB) $(XMULIBONLY) $(XTOOLLIB) $(XLIB)
+ #endif
+ #endif
+ #if SharedOldLibX
+        DEPOLDXLIB = /* _UseCat($(USRLIBDIR),$(OLDXLIBSRC),/liboldX.so.$(SOOLDXREV)) */
+           OLDXLIB = _Use(-loldX,-L$(OLDXLIBSRC) -loldX)
+ #endif
+ #if SharedLibXt
+       DEPXTOOLLIB = _UseCat($(USRLIBDIR),$(TOOLKITSRC),/libXt.so.$(SOXTREV))
+          XTOOLLIB = _Use(-lXt,-L$(TOOLKITSRC) -lXt)
+ #endif
+ #if SharedLibXaw
+         DEPXAWLIB = _UseCat($(USRLIBDIR),$(AWIDGETSRC),/libXaw.so.$(SOXAWREV))
+            XAWLIB = _Use(-lXaw,-L$(AWIDGETSRC) -lXaw)
+ #endif
+ #if SharedLibXinput
+         DEPXILIB = /* _UseCat($(USRLIBDIR),$(XILIBSRC),/libXi.so.$(SOXINPUTREV)) */
+            XILIB = _Use(-lXi,-L$(XILIBSRC) -lXi)
+ #endif
+ #if SharedLibPex
+         DEPPEXLIB = /* _UseCat($(USRLIBDIR),$(PEXLIBSRC),/libPEX5.so.$(SOPEXREV)) */
+            PEXLIB = _Use(-lPEX5,-L$(PEXLIBSRC) -lPEX5)
+ #endif
diff -c mit/config/imake.c:2.0 mit/config/imake.c:2.1
*** mit/config/imake.c:2.0	Fri Mar 11 23:41:57 1994
--- mit/config/imake.c	Fri Mar 11 23:41:57 1994
***************
*** 1,4 ****
! /* $XFree86: mit/config/imake.c,v 2.0 1993/07/15 09:58:49 dawes Exp $ */
  /* $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $ */
  
  /*****************************************************************************\
--- 1,4 ----
! /* $XFree86: mit/config/imake.c,v 2.1 1993/12/18 11:42:21 dawes Exp $ */
  /* $XConsortium: imake.c,v 1.65 91/07/25 17:50:17 rws Exp $ */
  
  /*****************************************************************************\
***************
*** 158,168 ****
--- 158,174 ----
  #if defined(macII) && !defined(__STDC__)  /* stdlib.h fails to define these */
  char *malloc(), *realloc();
  #endif /* macII */
+ #ifdef __NetBSD__
+ #include <sys/param.h>
+ #endif /* __NetBSD__ */
  #ifdef X_NOT_STDC_ENV
  extern char	*getenv();
  #endif
  #include <errno.h>
  extern int	errno;
+ #ifndef X_NO_STRERROR
+ #include <string.h>
+ #endif
  #include "imakemdep.h"
  
  
***************
*** 444,450 ****
--- 450,458 ----
  LogFatal(x0,x1)
  	char *x0, *x1;
  {
+ #ifdef X_NO_STRERROR
  	extern char	*sys_errlist[];
+ #endif
  	static boolean	entered = FALSE;
  
  	if (entered)
***************
*** 453,459 ****
--- 461,471 ----
  
  	fprintf(stderr, "%s: ", program);
  	if (errno)
+ #ifdef X_NO_STRERROR
  		fprintf(stderr, "%s: ", sys_errlist[ errno ]);
+ #else
+ 		fprintf(stderr, "%s: ", strerror(errno));
+ #endif
  	fprintf(stderr, x0,x1);
  	fprintf(stderr, "  Stop.\n");
  	wrapup();
***************
*** 498,503 ****
--- 510,519 ----
  			LogFatalI("Cannot fdopen fd %d for output.", pipefd[1]);
  #ifdef CROSS_COMPILE
  		fprintf(pipeFile, "#define INCLUDE_PLATFORM\t<platform.def>\n");
+ #endif
+ #ifdef __NetBSD__
+ 		fprintf(pipeFile, "#define __NetBSD__version__\t%d\n",
+ 			NetBSD);
  #endif
  		fprintf(pipeFile, "#define IMAKE_TEMPLATE\t\"%s\"\n",
  			template);
diff -c mit/config/imakemdep.h:2.2 mit/config/imakemdep.h:2.7
*** mit/config/imakemdep.h:2.2	Fri Mar 11 23:41:57 1994
--- mit/config/imakemdep.h	Fri Mar 11 23:41:57 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/config/imakemdep.h,v 2.2 1993/09/22 15:29:57 dawes Exp $
   * $XConsortium: imakemdep.h,v 1.38 91/08/25 11:36:39 rws Exp $
   * 
   * This file contains machine-dependent constants for the imake utility.
--- 1,5 ----
  /*
!  * $XFree86: mit/config/imakemdep.h,v 2.7 1994/02/12 11:03:52 dawes Exp $
   * $XConsortium: imakemdep.h,v 1.38 91/08/25 11:36:39 rws Exp $
   * 
   * This file contains machine-dependent constants for the imake utility.
***************
*** 74,80 ****
  
  #ifdef SYSV386
  # ifdef SVR4
! #  define imake_ccflags "-Xc -DSVR4"
  # else
  #  define imake_ccflags "-DSYSV"
  # endif
--- 74,84 ----
  
  #ifdef SYSV386
  # ifdef SVR4
! #  ifdef SOLX86
! #    define imake_ccflags "-DSOLX86 -DSVR4"
! #  else
! #    define imake_ccflags "-Xc -DSVR4"
! #  endif
  # else
  #  define imake_ccflags "-DSYSV"
  # endif
***************
*** 133,144 ****
  #if defined(_IBMR2) && !defined(DEFAULT_CPP)
  #define DEFAULT_CPP "/usr/lpp/X11/Xamples/util/cpp/cpp"
  #endif
! #ifdef __386BSD__
  #define DEFAULT_CPP "/usr/libexec/cpp"
  #endif
  #ifdef __bsdi__
  #define DEFAULT_CPP "/usr/bin/cpp"
  #endif
  
  /*
   * Step 5:  cpp_argv
--- 137,151 ----
  #if defined(_IBMR2) && !defined(DEFAULT_CPP)
  #define DEFAULT_CPP "/usr/lpp/X11/Xamples/util/cpp/cpp"
  #endif
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__)
  #define DEFAULT_CPP "/usr/libexec/cpp"
  #endif
  #ifdef __bsdi__
  #define DEFAULT_CPP "/usr/bin/cpp"
  #endif
+ #ifdef SOLX86
+ #define DEFAULT_CPP "/usr/ccs/lib/cpp"
+ #endif 
  
  /*
   * Step 5:  cpp_argv
***************
*** 169,180 ****
  #ifdef unix
  	"-Uunix",	/* remove unix symbol so that filename unix.c okay */
  #endif
! #ifdef __386BSD__
  	"-traditional",
  #endif
- #ifdef __bsdi__
- 	"-traditional -D__386bsd__",
- #endif
  #ifdef __OSF__
  	"-traditional",
  #endif
--- 176,184 ----
  #ifdef unix
  	"-Uunix",	/* remove unix symbol so that filename unix.c okay */
  #endif
! #if defined(__386BSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined (__bsdi__)
  	"-traditional",
  #endif
  #ifdef __OSF__
  	"-traditional",
  #endif
***************
*** 248,253 ****
--- 252,260 ----
  #endif /* MOTOROLA */
  #ifdef SYSV386           /* System V/386 folks */
  	"-DSYSV386",
+ # ifdef SOLX86			 /* Solaris 2.1 x86 */
+     "-DSOLX86"
+ # endif
  # ifdef SVR4
  	"-DSVR4",
  # endif
***************
*** 284,291 ****
  # endif
  #endif
  #ifdef __386BSD__
! # ifdef FreeBSD
! 	"-DFreeBSD",
  # endif
  #endif
  #ifdef linux
--- 291,299 ----
  # endif
  #endif
  #ifdef __386BSD__
! # ifdef __FreeBSD__
! /* __FreeBSD__ is not defined by the OS in FreeBSD 1.0.2 or earlier. */
! 	"-D__FreeBSD__",
  # endif
  #endif
  #ifdef linux
***************
*** 400,406 ****
  	{"bsd43", "1"},
  #endif
  #ifdef hcx
! 	{"hcx", 1},
  #endif
  #ifdef __386BSD__
  	{"__386BSD__", "1"},
--- 408,414 ----
  	{"bsd43", "1"},
  #endif
  #ifdef hcx
! 	{"hcx", "1"},
  #endif
  #ifdef __386BSD__
  	{"__386BSD__", "1"},
***************
*** 407,412 ****
--- 415,423 ----
  #endif
  #ifdef __NetBSD__
  	{"__NetBSD__", "1"},
+ #endif
+ #ifdef __FreeBSD__
+ 	{"__FreeBSD__", "1"},
  #endif
  #ifdef __bsdi__
  	{"__bsdi__", "1"},
diff -c mit/config/lnuxLib.rules:2.5 mit/config/lnuxLib.rules:2.8
*** mit/config/lnuxLib.rules:2.5	Fri Mar 11 23:41:58 1994
--- mit/config/lnuxLib.rules	Fri Mar 11 23:41:58 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/config/lnuxLib.rules,v 2.5 1993/10/06 14:53:01 dawes Exp $
  /*
   * Linux shared library rules (DLL version)
   */
--- 1,4 ----
! XCOMM $XFree86: mit/config/lnuxLib.rules,v 2.8 1994/03/08 06:10:55 dawes Exp $
  /*
   * Linux shared library rules (DLL version)
   */
***************
*** 6,12 ****
  #define HasSharedLibraries YES
  #endif
  #ifndef ForceNormalLib
! #define ForceNormalLib YES
  #endif
  
  #ifndef SharedLibX
--- 6,12 ----
  #define HasSharedLibraries YES
  #endif
  #ifndef ForceNormalLib
! #define ForceNormalLib NO
  #endif
  
  #ifndef SharedLibX
***************
*** 61,69 ****
  
  DLL_BINDIR = /usr/dll/bin
  
  #ifndef UseInstalled
! XCOMM this is only needed to build the server
! XCOMM to build your own dll libs, fill in a suitable set of JUMP_xxx vars
  
  XCOMM libX11.so (X11)
  JUMP_ROOT_X11 = $(XLIBSRC)
--- 61,110 ----
  
  DLL_BINDIR = /usr/dll/bin
  
+ /*
+  * These definitions are now extended to work with the X sources and
+  * external sources wishing to build shared libs.
+  *
+  * A library can create it's own shlibs (.so) or can be incorporated into
+  * another "host" lib. All libraries generate stub (.sa) files.
+  * A "host" lib does all the work to generate the stubs for itself and its
+  * "guests", invoking the "guest" Makefiles to create the objects for
+  * inclusion into the "host" shlib. A "guest" lib will ask the "host" to
+  * create the stubfiles, then copy its own into its directory.
+  * Most external libs are "host" libs; the concept of "guest" is a holdover
+  * from older libs during the days of scarce shared library address space.
+  *
+  * To create a simple "host" shared lib, Xfoo, define:
+  *
+  *  JUMP_ROOT_Xfoo = <source directory>
+  *  JUMP_IS_HOST_Xfoo = YES
+  *  JUMP_STUBLIBS_Xfoo = libXfoo.sa
+  *  JUMP_DIR_Xfoo = $(JUMP_ROOT_Xfoo)/shared		<work directory>
+  *  JUMP_VARS_Xfoo = $(JUMP_ROOT_Xfoo)/jump_vars	<see DLL docs>
+  *  JUMP_FUNCS_Xfoo = $(JUMP_ROOT_Xfoo)/jump_funcs	<see DLL docs>
+  *  JUMP_IGNORE_Xfoo = $(JUMP_ROOT_Xfoo)/jump_ignore	<see DLL docs>
+  *  JUMP_ADDRESS_Xfoo = 0xXXXXXXXX			<fill in with address>
+  *  JUMP_JUMPTABLESIZE_Xfoo = 0x4000			<adjust if necessary>
+  *  JUMP_GOTSIZE_Xfoo = 4096				<adjust if necessary>
+  *  JUMP_STUBNAMES_Xfoo = libXfoo			<and others>
+  *  JUMP_STUBS_IMPORT_Xfoo = /usr/lib/libc.sa		<and others>
+  *  JUMP_LDLIBS_Xfoo = `$(CC) --print` -lc		<and others>
+  *
+  * To create a complex "host", you need to add
+  *  JUMP_SIBARS_Xt = jump/libXbar.a~			<and others>
+  * These are the archives of the shared objects of the "guest" libs. They
+  * need to be added to the JUMP_LDLIBS_Xfoo lines.
+  *
+  * For further clarification, study the definitions of libXaw, a simple "host"
+  * lib, libXt, a complex "host" lib, and libXmu, one of libXts "guests".
+  *
+  * As a hint of how to start (with the DLL docs), touch jump_vars, jump_funcs
+  * and jump_ignore, then compile. Then massage the jump.vars and jump.funcs
+  * files in the shared subdirectory into jump_xxx files.
+  */
+ 
  #ifndef UseInstalled
! XCOMM These are only needed to build the server
  
  XCOMM libX11.so (X11)
  JUMP_ROOT_X11 = $(XLIBSRC)
***************
*** 78,84 ****
  JUMP_GOTSIZE_X11 = 4096
  JUMP_STUBNAMES_X11 = libX11
  JUMP_STUBS_IMPORT_X11 = /usr/lib/libc.sa
! JUMP_LDLIBS_X11 = -lgcc -lc
  
  XCOMM libXt.so (Xt, Xmu, Xext, Xi, Xtst)
  JUMP_ROOT_Xt = $(TOOLKITSRC)
--- 119,125 ----
  JUMP_GOTSIZE_X11 = 4096
  JUMP_STUBNAMES_X11 = libX11
  JUMP_STUBS_IMPORT_X11 = /usr/lib/libc.sa
! JUMP_LDLIBS_X11 = `$(CC) --print` -lc
  
  XCOMM libXt.so (Xt, Xmu, Xext, Xi, Xtst)
  JUMP_ROOT_Xt = $(TOOLKITSRC)
***************
*** 180,186 ****
  XCOMM This logic is such to compile the libs in their proper order,	@@\
  XCOMM remain dependent on subsidiary libs, and yet minimize local work	@@\
  									@@\
! JUMP_DIR=jump								@@\
  JUMP_LIB=Concat(lib,libname)						@@\
  									@@\
  XCOMM  this is needed for newer gnumake versions			@@\
--- 221,227 ----
  XCOMM This logic is such to compile the libs in their proper order,	@@\
  XCOMM remain dependent on subsidiary libs, and yet minimize local work	@@\
  									@@\
! JUMP_DIR=./jump								@@\
  JUMP_LIB=Concat(lib,libname)						@@\
  									@@\
  XCOMM  this is needed for newer gnumake versions			@@\
***************
*** 256,261 ****
--- 297,303 ----
  									@@\
  $(JUMP_DIR):								@@\
  	$(RM) jump							@@\
+ 	LibMkdir($(Concat(JUMP_DIR_,libname)))				@@\
  	$(LN) $(Concat(JUMP_DIR_,libname)) jump				@@\
  									@@\
  jumpsetup_0:								@@\
diff -c mit/config/site.def:2.23 mit/config/site.def:2.41
*** mit/config/site.def:2.23	Fri Mar 11 23:41:58 1994
--- mit/config/site.def	Fri Mar 11 23:41:59 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/config/site.def,v 2.23 1993/10/16 17:28:07 dawes Exp $
  XCOMM site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  
  /*****************************************************************************
--- 1,4 ----
! XCOMM $XFree86: mit/config/site.def,v 2.41 1994/03/07 13:53:40 dawes Exp $
  XCOMM site:  $XConsortium: site.def,v 1.2 91/07/30 20:26:44 rws Exp $
  
  /*****************************************************************************
***************
*** 41,46 ****
--- 41,53 ----
   *****************************************************************************/
  
  /*
+  * To build only the servers with a cut-down source tree, uncomment
+  * this.
+  */
+ 
+ /* #define BuildServersOnly	YES */
+ 
+ /*
   * If you are using ISC's original make (which has a hash table bug),
   * uncomment this. You will not get dependencies as a result in
   * mit/lib/X, but better then nothing. (Using GNU make instead is recommended.)
***************
*** 52,62 ****
   *	defaults:
   *		SVR4:		NO
   *		SVR3:		YES
!  *		Linux:		YES
   */
  /* #define ForceNormalLib	YES */
  
  /*
   * HasLibCrypt: If your system uses a separate libcrypt.a, uncomment this.
   *	    defaults:
   *		NetBsd, FreeBsd YES
--- 59,78 ----
   *	defaults:
   *		SVR4:		NO
   *		SVR3:		YES
!  *		Linux:		NO
!  *		NetBSD, FreeBSD YES
   */
  /* #define ForceNormalLib	YES */
  
  /*
+  * To build shared libs on NetBSD uncomment this.
+  *	defaults:
+  *		FreeBSD:	YES
+  *		others:		NO
+  */
+ /* #define BuildBsdSharedLibs	YES */
+ 
+ /*
   * HasLibCrypt: If your system uses a separate libcrypt.a, uncomment this.
   *	    defaults:
   *		NetBsd, FreeBsd YES
***************
*** 64,69 ****
--- 80,94 ----
   */
  /* #define HasLibCrypt		YES */
  
+ /*
+  * UseGccMakeDepend: Uses 'gcc -M' to generate Makefile dependency lists.
+  *                   This is much slower than the "standard" makedepend
+  *                   but is more accurate.
+  *	    defaults:
+  *		same as HasGcc
+  */
+ /* #define UseGccMakeDepend	NO */
+ 
  /*****************************************************************************
   *                                                                           *
   * Compiler parameters                                                       *
***************
*** 91,96 ****
--- 116,133 ----
  /* #define HasGcc2		NO */
  
  /*
+  * ProWorksHome: location of the ProWorks compiler on Solaris x86, and can
+  *               be ignored if you are using gcc.
+  *	    defaults:
+  *		Solaris x86:	/opt/SUNWspro
+  *
+  *    NOTE: ProWorks installs by default into /opt/SUNWspro. Use this option
+  *    to override the default location if ProWorks is installed in a
+  *    place other than /opt/SUNWspro
+  */
+ /* #define ProWorksHome  /opt/SUNWspro */
+ 
+ /*
   * GccUsesGas: Required if your gcc uses gas as its assembler.
   *          defaults:
   *		SVR3,4		NO
***************
*** 157,180 ****
   */
  /* #define HasShadowPasswd	NO */
  
- /*
-  * If you are not using GNU dbm, sdbm or SVR4's ndbm, uncomment this.
-  *          defaults:
-  *		ISC:		NO
-  *		others:		YES
-  */
- /* #define HasNdbm		NO */
- 
- /*
-  * HasSdbm: Required if you are using libsdbm.a  (HasNdbm should also be set)
-  *	    defaults:
-  *		SVR3,4:		YES
-  *		ISC:		NO
-  *		Mach, 386bsd:	NO
-  *		linux:		NO
-  */
- /* #define HasSdbm		YES */
- 
  /*****************************************************************************
   *                                                                           *
   * Select features to be built/not built                                     *
--- 194,199 ----
***************
*** 184,189 ****
--- 203,219 ----
  /* You need the DES stuff from MIT to use this */
  /* #define HasXdmAuth	YES */
  
+ /*
+  * To include MIT-SHM support for BSD systems, uncomment the following
+  *	    defaults:
+  *		SVR3,4:		YES
+  *		linux:		YES
+  *		Mach, OSF/1	NO
+  *		FreeBSD		YES
+  *		other BSD	NO
+  */
+ /* #define HasShm		YES */
+ 
  /* To exclude XTEST support, uncomment the following */
  /* #define BuildXTest	NO */
  
***************
*** 276,284 ****
  /*
   * Select drivers in 16-colour server
   *
!  * Default: et4000 generic
   */
! /* #define X386Vga16Drivers	et4000 generic */
  
  /*
   * Select (S)VGA drivers in monochrome server
--- 306,314 ----
  /*
   * Select drivers in 16-colour server
   *
!  * Default: et4000 tvga8900 generic
   */
! /* #define X386Vga16Drivers	et4000 tvga8900 generic */
  
  /*
   * Select (S)VGA drivers in monochrome server
***************
*** 296,305 ****
   * To include the generic banked monochrome driver in the monochrome server,
   * uncomment this with one of the following low level drivers
   * 	hgc1280		[Hyundai HGC-1280 1280x1024]
   *	...
   *	(list is subject to grow)
   */
! /* #define X386Bdm2Drivers		hgc1280 */
  
  /*
   * Select drivers in the accelerated S3 server
--- 326,337 ----
   * To include the generic banked monochrome driver in the monochrome server,
   * uncomment this with one of the following low level drivers
   * 	hgc1280		[Hyundai HGC-1280 1280x1024]
+  *	sigma		[Sigma L-View]
+  *	visa		[???]
   *	...
   *	(list is subject to grow)
   */
! /* #define X386Bdm2Drivers		hgc1280 sigma visa */
  
  /*
   * Select drivers in the accelerated S3 server
***************
*** 309,314 ****
--- 341,349 ----
  /* Uncomment this to include support for SVR3 mmap driver */
  /* #define HasSVR3mmapDrv	YES */
  
+ /* Uncomment this to include support for Solaris aperture driver */
+ /* #define HasSolx86apertureDrv	YES */
+ 
  /* Uncomment this if you want to build a debuggable server */
  /* #define DebuggableServer	YES */
  
***************
*** 341,351 ****
  
  /*
   * Set logging parameters for xterm.  By default, logging is off because of
!  * security problems.  It can be turned on with -DALLOWLOGGING, and security
!  * can (hopefully) be improved with -DFORKFORLOGFILE.
   */
  
! #define XtermLogFlags		-DALLOWLOGGING -DFORKFORLOGFILE
  
  /*****************************************************************************
   *                                                                           *
--- 376,386 ----
  
  /*
   * Set logging parameters for xterm.  By default, logging is off because of
!  * security problems.  It can be turned on by defining XtermLogFlags to be
!  * -DALLOWLOGGING  -- BUT THIS IS A SECURITY RISK.
   */
  
! /* #define XtermLogFlags		-DALLOWLOGGING */
  
  /*****************************************************************************
   *                                                                           *
diff -c mit/config/sv4Lib.rules:1.7 mit/config/sv4Lib.rules:2.0
*** mit/config/sv4Lib.rules:1.7	Fri Mar 11 23:41:59 1994
--- mit/config/sv4Lib.rules	Fri Mar 11 23:41:59 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/config/sv4Lib.rules,v 1.7 1993/03/27 08:55:08 dawes Exp $
  XCOMM $XConsortium: sv4Lib.rules,v 1.8 91/07/19 15:38:53 rws Exp $
  
  /*
--- 1,4 ----
! XCOMM $XFree86: mit/config/sv4Lib.rules,v 2.0 1993/12/10 14:32:22 dawes Exp $
  XCOMM $XConsortium: sv4Lib.rules,v 1.8 91/07/19 15:38:53 rws Exp $
  
  /*
***************
*** 69,79 ****
--- 69,96 ----
   * the library gone for long periods.
   */
  #ifndef SharedLibraryTarget
+ #if defined(i386Solarisx86)
  #define SharedLibraryTarget(libname,rev,solist,down,up)			@@\
  AllTarget(Concat(lib,libname.so.rev))					@@\
  									@@\
  Concat(lib,libname.so.rev):  solist					@@\
  	$(RM) $@~							@@\
+ 	(cd down; $(LD) -o up/$@~ $(SHLIBLDFLAGS) -h $@ solist $(REQUIREDLIBS) $(LDLINKPATH)) @@\
+ 	$(RM) $@							@@\
+ 	$(MV) $@~ $@							@@\
+ 	$(RM) Concat(lib,libname.so)					@@\
+ 	$(LN) $@ Concat(lib,libname.so)					@@\
+ 									@@\
+ clean::									@@\
+ 	$(RM) Concat(lib,libname.so.rev) Concat(lib,libname.so)
+ 
+ #else
+ #define SharedLibraryTarget(libname,rev,solist,down,up)			@@\
+ 									@@\
+ AllTarget(Concat(lib,libname.so.rev))					@@\
+ 									@@\
+ Concat(lib,libname.so.rev):  solist					@@\
+ 	$(RM) $@~							@@\
  	(cd down; $(LD) -o up/$@~ $(SHLIBLDFLAGS) -h $@ solist)		@@\
  	$(RM) $@ 							@@\
  	$(MV) $@~ $@							@@\
***************
*** 82,87 ****
--- 99,105 ----
  									@@\
  clean::									@@\
  	$(RM) Concat(lib,libname.so.rev) Concat(lib,libname.so)
+ #endif /* Solaris x86 */
  
  #endif /* SharedLibraryTarget */
  
diff -c mit/config/x386.cf:2.28 mit/config/x386.cf:2.41
*** mit/config/x386.cf:2.28	Fri Mar 11 23:42:00 1994
--- mit/config/x386.cf	Fri Mar 11 23:42:00 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/config/x386.cf,v 2.28 1993/10/21 15:48:52 dawes Exp $
  XCOMM platform:  $XConsortium: x386.cf,v 1.7 91/08/16 19:30:10 gildea Exp $
  
  /*****************************************************************************
--- 1,4 ----
! XCOMM $XFree86: mit/config/x386.cf,v 2.41 1994/03/06 06:41:16 dawes Exp $
  XCOMM platform:  $XConsortium: x386.cf,v 1.7 91/08/16 19:30:10 gildea Exp $
  
  /*****************************************************************************
***************
*** 45,64 ****
  # ifndef GnuCpp
  #  define GnuCpp		NO
  # endif
- # ifndef HasSdbm
- #  ifdef i386Isc
- #   define HasSdbm		NO
- #  else
- #   define HasSdbm		YES
- #  endif
- # endif
- # ifndef HasNdbm
- #  ifdef i386Isc
- #   define HasNdbm		NO
- #  else
- #   define HasNdbm		YES
- #  endif
- # endif
  # ifndef HasShadowPasswd
  #  define HasShadowPasswd	YES
  # endif
--- 45,50 ----
***************
*** 123,134 ****
  #   define GnuCpp		NO
  #  endif
  # endif
- # ifndef HasSdbm
- #  define HasSdbm		NO
- # endif
- # ifndef HasNdbm
- #  define HasNdbm		YES
- # endif
  # ifndef HasShadowPasswd
  #  define HasShadowPasswd	NO
  # endif
--- 109,114 ----
***************
*** 173,184 ****
  # ifndef PreProcessCmd
  #  define PreProcessCmd		/lib/cpp
  # endif
- # ifndef HasSdbm
- #  define HasSdbm		NO
- # endif
- # ifndef HasNdbm
- #  define HasNdbm		YES
- # endif
  # ifndef HasShadowPasswd
  #  define HasShadowPasswd	NO
  # endif
--- 153,158 ----
***************
*** 221,226 ****
--- 195,203 ----
  #ifndef Target_486
  # define Target_486		YES
  #endif
+ #ifndef Target_Pentium
+ # define Target_Pentium		NO
+ #endif
  #ifndef CompressAllFonts
  # define CompressAllFonts	YES
  #endif
***************
*** 365,371 ****
  #endif
  
  #ifndef X386Vga16Drivers
! # define X386Vga16Drivers	et4000 generic
  #endif
  
  #ifndef X386Vga2Drivers
--- 342,348 ----
  #endif
  
  #ifndef X386Vga16Drivers
! # define X386Vga16Drivers	et4000 tvga8900 generic
  #endif
  
  #ifndef X386Vga2Drivers
***************
*** 421,429 ****
--- 398,418 ----
  # endif
  #endif
  
+ #if Target_Pentium
+ # if defined (i386SVR4Solarisx86)
+ #    define ProworksMOption -xpentium
+ # endif
+ #endif
+ 
  #if Target_486
+ # if defined (i386SVR4Solarisx86)
+ #    define ProworksMOption -x486
+ # endif
  # define Gcc2MOption -m486
  #else
+ # if defined (i386SVR4Solarisx86)
+ #    define ProworksMOption -x386
+ # endif
  # define Gcc2MOption -m386
  #endif
  
***************
*** 444,450 ****
  #if GnuCpp
  # define StandardCppDefines -traditional StandardDefines
  #else
! # define StandardCppDefines StandardDefines
  #endif
  
  #if HasGcc2 && !HasGcc
--- 433,443 ----
  #if GnuCpp
  # define StandardCppDefines -traditional StandardDefines
  #else
! # if defined (i386SVR4Solarisx86)
! #   define StandardCppDefines -P StandardDefines
! # else
! #   define StandardCppDefines StandardDefines
! # endif
  #endif
  
  #if HasGcc2 && !HasGcc
***************
*** 452,457 ****
--- 445,456 ----
  # define HasGcc			YES
  #endif
  
+ #if HasGcc
+ # ifndef UseGccMakeDepend
+ #  define UseGccMakeDepend	YES
+ # endif
+ #endif
+ 
  #if SpecialMalloc
  # define MallocFlags		-DCAHILL_MALLOC -I/usr/local/debug_include
  #else
***************
*** 565,585 ****
  # define LinkKitDir		$(USRLIBDIR)/Server
  #endif
  
- #if HasSdbm && !HasNdbm
- # undef HasNdbm
- # define HasNdbm		YES
- #endif
- 
- #if HasNdbm
- #ifndef NdbmDefines
- # if HasSdbm
- #  define NdbmDefines		-DNDBM -DSDBM
- # else
- #  define NdbmDefines		-DNDBM
- # endif
- #endif
- #endif
- 
  
  #if defined(i386SVR3Architecture)
  
--- 564,569 ----
***************
*** 853,862 ****
  
  
  /*
!  * V/386 Release 4.0
   */
  #if defined(i386SVR4Architecture)
  
  #define SystemV4		YES
  
  /* No vendor defines required for SVR4 */
--- 837,952 ----
  
  
  /*
!  * System V Release 4.0 (SVR4)
   */
  #if defined(i386SVR4Architecture)
+ #if defined(i386SVR4Solarisx86)
+ /*
+  * SUN Microsystems -- Solaris 2.1 x86 FCS (SVR4)
+  */
+ #define SystemV4                YES
+ #define OSName                  Solaris 2.1 x86 FCS (System V Release 4.0)
+ #define OSMajorVersion          4
+ #define OSMinorVersion          0
+ #define OSRelease               -DSVR4 -DSYSV386
+ #define OSDefines               -DSOLX86
+ #define OSVendor                SUN Microsystems
+ 
+ #ifndef HasSharedLibraries
+ # define HasSharedLibraries     YES
+ #endif
+ 
+ #ifndef HasSolx86apertureDrv
+ # define HasSolx86apertureDrv	NO
+ #endif
+ #if HasSolx86apertureDrv
+ # define SOLX86apertureFlags	-DHAS_SOLX86_APERTUREDRV
+ #else
+ # define SOLX86apertureFlags	/**/
+ #endif
+ 
+ #define CppCmd                  /usr/ccs/lib/cpp
+ #define PreProcessCmd           /usr/ccs/lib/cpp
+ 
+ #if HasGcc
+ # define CcCmd                  gcc
+ # define AnsiCCOptions          /* -ansi */
+ # if HasGcc2
+ #  define DefaultCCOptions      Gcc2MOption -fpcc-struct-return -Di386
+ #  define OptimizedCDebugFlags  -O2
+ #  define MakeLdRunPath(dir)  	Concat3(-Xlinker -R,dir,$${LD_RUN_PATH+\:$$LD_RUN_PATH})
+ #  define MakeLdLinkPath(dir) 	Concat3(-R,dir,$${LD_RUN_PATH+\:$$LD_RUN_PATH})
+ # else
+ #  define DefaultCCOptions      -fpcc-struct-return -fstrength-reduce -Di386
+ #  define MakeLdRunPath(dir)  	Concat3(-R,dir,$${LD_RUN_PATH+\:$$LD_RUN_PATH})
+ #  define MakeLdLinkPath(dir) 	Concat3(-R,dir,$${LD_RUN_PATH+\:$$LD_RUN_PATH})
+ #  if HasSharedLibraries
+ #   define LibraryCcCmd         gcc
+ #   define LibraryAnsiCCOptions /* -ansi */
+ #   define LibraryCCOptions     -O2 -Di386 -Dasm=__asm
+ #  endif
+ # endif
+ #else						/* Use ProWorks compiler */
+ # define NeedConstPrototoypes   YES
+ # define NeedFunctionPrototypes YES
+ # define NeedNestedPrototypes   YES
+ # define NeedVarargsPrototypes  YES
+ # define NeedWidePrototypes     NO
+ # if !defined (ProWorksHome)
+ #  undef ProWorksHome
+ #  define ProWorksHome          /opt/SUNWspro
+ # endif
+ # if defined((ProworksMOption) /* XXX: ProWorks 2.0:broken -x486, -xpentium..*/
+ #  undef ProworksMOption
+ #  define ProworksMOption	/**/
+ # endif
+ # define CcCmd                  ProWorksHome/bin/cc
+ # define AnsiCCOptions          /* */
+ # define DefaultCCOptions       -Xc ProworksMOption -DPROWORKS -DINCLUDE_ALLOCA_H -Di386 -Dasm=__asm
+ # define ServerCcCmd			ProWorksHome/bin/cc 
+ # define ServerCCOptions		-Xa ProworksMOption -DPROWORKS -DINCLUDE_ALLOCA_H -Di386 -Dasm=__asm
+ # define AllocateLocalDefines   -DINCLUDE_ALLOCA_H
+ # define MakeLdRunPath(dir)   	Concat3(-R,dir,$${LD_RUN_PATH+\:$$LD_RUN_PATH})
+ # define MakeLdLinkPath(dir)  	Concat3(-R,dir,$${LD_RUN_PATH+\:$$LD_RUN_PATH})
+ # if HasSharedLibraries
+ #  define LibraryCcCmd          ProWorksHome/bin/cc 
+ #  define LibraryAnsiCCOptions  /* */
+ #  define LibraryCCOptions      -Xc ProworksMOption -DPROWORKS -DINCLUDE_ALLOCA_H -Di386 -Dasm=__asm
+ #  define SharedAllocateLocalDefines -DINCLUDE_ALLOCA_H
+ # endif
+ #endif
+ 
+ /* Make sure we don't use /usr/ucb/ld */
+ #ifndef LdCmd
+ # define LdCmd                  /usr/ccs/bin/ld
+ #endif
+ 
+ #define ServerExtraDefines      GccGasOption -DXDMCP MallocFlags LinkKitFlags \
+                                 -DAVOID_GLYPHBLT SOLX86apertureFlags
+ 
+ #if SCOLocalConnSysv4
+ # define Acp                    -DSVR4_ACP
+ #else
+ # define Acp                    /**/
+ #endif
  
+ #define ConnectionFlags         -DUNIXCONN -DTCPCONN -DCLIENTS_LOCALCONN \
+                                 -DSERVER_LOCALCONN Acp
+ 
+ #define NeedBerklib             YES
+ 
+ #if defined(UseInstalled) && !X386LinkKit
+ # define ExtraLibraries         -lsocket -lnsl GnuMallocLib $(XBSDLIB)
+ #else
+ # define ExtraLibraries         -lsocket -lnsl GnuMallocLib
+ #endif
+ 
+ #include <sv4Lib.rules>
+ 
+ #else
+ /*
+  * USL-based V/386 System V Release 4.0 
+  */
  #define SystemV4		YES
  
  /* No vendor defines required for SVR4 */
***************
*** 927,932 ****
--- 1017,1023 ----
  
  #include <sv4Lib.rules>
  
+ #endif /* i386SVR4Solarisx86 */
  #endif /* i386SVR4Architecture */
  
  #if defined(i386BsdArchitecture)
***************
*** 953,973 ****
  #define OSMajorVersion		4
  #define OSMinorVersion		3
  #define OSRelease		/* nothing */
! #ifdef i386Bsdi
! # define OSDefines		-D__386BSD__
  #else
! # ifdef i386FreeBsd
! #  define OSDefines		-DFreeBSD
! # else
! #  ifdef i386NetBsd
! #   define OSDefines		-D__386BSD__
! #  else
! #   define OSDefines		/* nothing */
! #  endif
! # endif
  #endif
  #define OSVendor		/* nothing */
  
  #ifdef i386Bsdi
  # define CppCmd			/usr/bin/cpp
  #else
--- 1044,1062 ----
  #define OSMajorVersion		4
  #define OSMinorVersion		3
  #define OSRelease		/* nothing */
! /* Not sure if this is needed */
! #ifdef i386FreeBsd
! # define OSDefines		-D__FreeBSD__
  #else
! # define OSDefines		/* nothing */
  #endif
  #define OSVendor		/* nothing */
  
+ /* NetBSD 0.9 and later */
+ #if defined(i386NetBsd) && (__NetBSD__version__ >= 1993070)
+ # define LexLib			-ll
+ #endif
+ 
  #ifdef i386Bsdi
  # define CppCmd			/usr/bin/cpp
  #else
***************
*** 974,979 ****
--- 1063,1082 ----
  # define CppCmd			/usr/libexec/cpp
  #endif
  
+ #ifndef BuildBsdSharedLibs
+ # if defined(i386FreeBsd)
+ #  define BuildBsdSharedLibs	YES
+ # else
+ #  define BuildBsdSharedLibs	NO
+ # endif
+ #endif
+ 
+ #if defined(i386NetBsd) || defined(i386FreeBsd)
+ # if BuildBsdSharedLibs
+ #  include <bsdLib.rules>
+ # endif
+ #endif
+ 
  #if HasGcc
  # define AnsiCCOptions		/**/
  # if HasGcc2
***************
*** 1003,1008 ****
--- 1106,1117 ----
  #endif
  #define AdmDir			/var/log
  
+ #if defined(i386FreeBsd)
+ # ifndef HasShm
+ #  define HasShm		YES
+ # endif
+ #endif
+ 
  #if OSMajorVersion >= 4 && OSMinorVersion >= 3
  # define SetTtyGroup		YES
  #endif
***************
*** 1099,1105 ****
  #define OSName			Linux
  #define OSVendor		/**/
  #define OSMajorVersion		99
! #define OSMinorVersion		12
  #define OSRelease		-Dlinux
  #define OSDefines		-D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE
  
--- 1208,1214 ----
  #define OSName			Linux
  #define OSVendor		/**/
  #define OSMajorVersion		99
! #define OSMinorVersion		15h
  #define OSRelease		-Dlinux
  #define OSDefines		-D_POSIX_SOURCE -D_BSD_SOURCE -D_GNU_SOURCE
  
***************
*** 1137,1153 ****
  #define ExtraLibraries		GnuMallocLib
  
  #define HasPutenv		YES
! #define HasShm			YES
  
  #include <lnuxLib.rules>
  
- /*
-  * cross compilation for hlu
-  */
- #ifdef CROSS_COMPILE
- #include <hlu.cf>
- #endif /* CROSS_COMPILE */
- 
  #endif /* LinuxArchitecture */
  
  /*
--- 1246,1257 ----
  #define ExtraLibraries		GnuMallocLib
  
  #define HasPutenv		YES
! #ifndef HasShm
! # define HasShm			YES
! #endif
  
  #include <lnuxLib.rules>
  
  #endif /* LinuxArchitecture */
  
  /*
***************
*** 1193,1202 ****
  #define ServerCCOptions		-Di386=1 DefaultCCOptions
  #endif /* HasGcc */
  
! #define	HasShm			NO
  #define HasSharedLibraries	NO /* I haven't debugged this yet */
  #define HasLargeTmp		YES
- #define HasNdbm			YES
  #define HasPutenv		YES
  #define HasSockets		YES
  #define HasVFork		NO
--- 1297,1307 ----
  #define ServerCCOptions		-Di386=1 DefaultCCOptions
  #endif /* HasGcc */
  
! #ifndef HasShm
! # define	HasShm		NO
! #endif
  #define HasSharedLibraries	NO /* I haven't debugged this yet */
  #define HasLargeTmp		YES
  #define HasPutenv		YES
  #define HasSockets		YES
  #define HasVFork		NO
diff -c mit/config/xf86_vers.def:2.7 mit/config/xf86_vers.def:2.11
*** mit/config/xf86_vers.def:2.7	Fri Mar 11 23:42:01 1994
--- mit/config/xf86_vers.def	Fri Mar 11 23:42:01 1994
***************
*** 1,9 ****
  XCOMM -------------------------------------------------------------------------
  XCOMM XFree86 version definition
! XCOMM $XFree86: mit/config/xf86_vers.def,v 2.7 1993/10/08 16:11:07 dawes Exp $
  
  #ifndef XFree86Version
! # define XFree86Version 2000
  #endif
  
  #ifndef XVendorString
--- 1,9 ----
  XCOMM -------------------------------------------------------------------------
  XCOMM XFree86 version definition
! XCOMM $XFree86: mit/config/xf86_vers.def,v 2.11 1994/03/05 01:56:48 dawes Exp $
  
  #ifndef XFree86Version
! # define XFree86Version 2100
  #endif
  
  #ifndef XVendorString
diff -c mit/lib/Imakefile:1.3 mit/lib/Imakefile:2.0
*** mit/lib/Imakefile:1.3	Fri Mar 11 23:42:02 1994
--- mit/lib/Imakefile	Fri Mar 11 23:42:02 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/lib/Imakefile,v 1.3 1993/03/20 03:12:28 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.18 91/07/22 22:53:06 rws Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
--- 1,4 ----
! XCOMM $XFree86: mit/lib/Imakefile,v 2.0 1993/12/17 10:58:18 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.18 91/07/22 22:53:06 rws Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
***************
*** 26,32 ****
--- 26,36 ----
  #endif
  LINTSUBDIRS = Xau X oldX Xt Xmu Xaw $(XDMCPDIR)
  
+ #if BuildServersOnly
+ SUBDIRS = $(OTHERDIRS) Xau $(XDMCPDIR)
+ #else
  SUBDIRS = $(OTHERDIRS) $(LINTSUBDIRS) nls
+ #endif
  
  MakeSubdirs($(SUBDIRS))
  DependSubdirs($(SUBDIRS))
diff -c mit/lib/X/XlibInt.c:2.0 mit/lib/X/XlibInt.c:2.1
*** mit/lib/X/XlibInt.c:2.0	Fri Mar 11 23:42:29 1994
--- mit/lib/X/XlibInt.c	Fri Mar 11 23:42:29 1994
***************
*** 1,4 ****
! /* $XFree86: mit/lib/X/XlibInt.c,v 2.0 1993/07/28 11:56:08 dawes Exp $ */
  /*
   * $XConsortium: XlibInt.c,v 11.156.1.1 92/11/11 10:10:50 rws Exp $
   */
--- 1,4 ----
! /* $XFree86: mit/lib/X/XlibInt.c,v 2.1 1993/11/07 14:05:53 dawes Exp $ */
  /*
   * $XConsortium: XlibInt.c,v 11.156.1.1 92/11/11 10:10:50 rws Exp $
   */
***************
*** 1319,1325 ****
  }
  
  
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
  #define _SysErrorMsg(x) strerror(x)
  #else
  #ifndef USL_SHARELIB
--- 1319,1325 ----
  }
  
  
! #ifndef X_NO_STRERROR
  #define _SysErrorMsg(x) strerror(x)
  #else
  #ifndef USL_SHARELIB
***************
*** 1335,1341 ****
  }
  
  #endif 	/* USL sharedlibs in don't define for SVR3.2 */
! #endif /* __STDC__ */
  
  
  /*
--- 1335,1341 ----
  }
  
  #endif 	/* USL sharedlibs in don't define for SVR3.2 */
! #endif /* !X_NO_STRERROR */
  
  
  /*
diff -c mit/lib/X/Xsi/XlcLoad.c:1.5 mit/lib/X/Xsi/XlcLoad.c:2.0
*** mit/lib/X/Xsi/XlcLoad.c:1.5	Fri Mar 11 23:42:38 1994
--- mit/lib/X/Xsi/XlcLoad.c	Fri Mar 11 23:42:38 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/lib/X/Xsi/XlcLoad.c,v 1.5 1993/04/09 11:28:08 dawes Exp $
   * $XConsortium: XlcLoad.c,v 1.44 92/12/14 09:22:48 rws Exp $
   */
  
--- 1,5 ----
  /*
!  * $XFree86: mit/lib/X/Xsi/XlcLoad.c,v 2.0 1994/02/10 21:23:39 dawes Exp $
   * $XConsortium: XlcLoad.c,v 1.44 92/12/14 09:22:48 rws Exp $
   */
  
***************
*** 39,45 ****
  #include "Xi18nint.h"
  #include <X11/Xos.h>
  
! #ifdef __386BSD__
  #define fgetline Xfgetline
  #endif
  
--- 39,45 ----
  #include "Xi18nint.h"
  #include <X11/Xos.h>
  
! #if (BSD >= 199103)
  #define fgetline Xfgetline
  #endif
  
diff -c mit/lib/Xaw/AsciiSrc.c:1.6 mit/lib/Xaw/AsciiSrc.c:2.0
*** mit/lib/Xaw/AsciiSrc.c:1.6	Fri Mar 11 23:42:48 1994
--- mit/lib/Xaw/AsciiSrc.c	Fri Mar 11 23:42:49 1994
***************
*** 1,4 ****
! /* $XFree86: mit/lib/Xaw/AsciiSrc.c,v 1.6 1993/04/06 14:36:06 dawes Exp $ */
  /* $XConsortium: AsciiSrc.c,v 1.55 91/07/25 18:09:27 rws Exp $ */
  
  /*
--- 1,4 ----
! /* $XFree86: mit/lib/Xaw/AsciiSrc.c,v 2.0 1993/11/07 14:06:48 dawes Exp $ */
  /* $XConsortium: AsciiSrc.c,v 1.55 91/07/25 18:09:27 rws Exp $ */
  
  /*
***************
*** 93,99 ****
  static String MyStrncpy(), StorePiecesInString();
  static Boolean SetValues(), WriteToFile();
  extern int errno;
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
  #include <string.h>
  #else
  extern int sys_nerr;
--- 93,99 ----
  static String MyStrncpy(), StorePiecesInString();
  static Boolean SetValues(), WriteToFile();
  extern int errno;
! #ifndef X_NO_STRERROR
  #include <string.h>
  #else
  extern int sys_nerr;
***************
*** 1004,1010 ****
  	    char msg[11];
  	    
  	    params[0] = src->ascii_src.string;
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
  	    params[1] = strerror(errno);
  #else
  	    if (errno <= sys_nerr)
--- 1004,1010 ----
  	    char msg[11];
  	    
  	    params[0] = src->ascii_src.string;
! #ifndef X_NO_STRERROR
  	    params[1] = strerror(errno);
  #else
  	    if (errno <= sys_nerr)
diff -c mit/lib/Xaw/MailboxP.h:2.0 mit/lib/Xaw/MailboxP.h:2.1
*** mit/lib/Xaw/MailboxP.h:2.0	Fri Mar 11 23:42:49 1994
--- mit/lib/Xaw/MailboxP.h	Fri Mar 11 23:42:49 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/lib/Xaw/MailboxP.h,v 2.0 1993/07/28 11:56:34 dawes Exp $
   * $XConsortium: MailboxP.h,v 1.20 91/07/19 21:52:57 rws Exp $
   *
   * Copyright 1988 Massachusetts Institute of Technology
--- 1,5 ----
  /*
!  * $XFree86: mit/lib/Xaw/MailboxP.h,v 2.1 1994/02/10 21:23:56 dawes Exp $
   * $XConsortium: MailboxP.h,v 1.20 91/07/19 21:52:57 rws Exp $
   *
   * Copyright 1988 Massachusetts Institute of Technology
***************
*** 23,28 ****
--- 23,30 ----
  #include <X11/Xaw/Mailbox.h>
  #include <X11/Xaw/SimpleP.h>
  
+ #include <X11/Xos.h>
+ 
  #ifdef SYSV
  #ifdef SCO
  #define MAILBOX_DIRECTORY "/usr/spool/mail"
***************
*** 30,36 ****
  #define MAILBOX_DIRECTORY "/usr/mail"
  #endif
  #else
! #if defined(SVR4) || defined(__386BSD__)
  #define MAILBOX_DIRECTORY "/var/mail"
  #else
  #define MAILBOX_DIRECTORY "/usr/spool/mail"
--- 32,38 ----
  #define MAILBOX_DIRECTORY "/usr/mail"
  #endif
  #else
! #if defined(SVR4) || (BSD >= 199103)
  #define MAILBOX_DIRECTORY "/var/mail"
  #else
  #define MAILBOX_DIRECTORY "/usr/spool/mail"
diff -c mit/lib/Xaw/TextPop.c:1.7 mit/lib/Xaw/TextPop.c:2.0
*** mit/lib/Xaw/TextPop.c:1.7	Fri Mar 11 23:42:50 1994
--- mit/lib/Xaw/TextPop.c	Fri Mar 11 23:42:50 1994
***************
*** 1,4 ****
! /* $XFree86: mit/lib/Xaw/TextPop.c,v 1.7 1993/05/04 15:00:00 dawes Exp $ */
  /* $XConsortium: TextPop.c,v 1.22 91/07/25 18:10:22 rws Exp $ */
  
  /***********************************************************
--- 1,4 ----
! /* $XFree86: mit/lib/Xaw/TextPop.c,v 2.0 1993/11/07 14:06:51 dawes Exp $ */
  /* $XConsortium: TextPop.c,v 1.22 91/07/25 18:10:22 rws Exp $ */
  
  /***********************************************************
***************
*** 69,75 ****
  #ifdef SCO
  extern int open();
  #endif
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
  #include <string.h>
  #else
  extern int sys_nerr;
--- 69,75 ----
  #ifdef SCO
  extern int open();
  #endif
! #ifndef X_NO_STRERROR
  #include <string.h>
  #else
  extern int sys_nerr;
***************
*** 252,258 ****
      }
      else
        sprintf( msg, "*** Error: %s ***",
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
  	      strerror(errno));
  #else
  	      (errno > 0 && errno < sys_nerr) ?
--- 252,258 ----
      }
      else
        sprintf( msg, "*** Error: %s ***",
! #ifndef X_NO_STRERROR
  	      strerror(errno));
  #else
  	      (errno > 0 && errno < sys_nerr) ?
diff -c mit/lib/Xmu/Imakefile:2.0 mit/lib/Xmu/Imakefile:2.1
*** mit/lib/Xmu/Imakefile:2.0	Fri Mar 11 23:42:58 1994
--- mit/lib/Xmu/Imakefile	Fri Mar 11 23:42:58 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/lib/Xmu/Imakefile,v 2.0 1993/08/28 07:44:51 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.74 91/12/20 11:20:22 rws Exp $
  XCOMM
  XCOMM This library contains miscellaneous utility routines and is not part
--- 1,4 ----
! XCOMM $XFree86: mit/lib/Xmu/Imakefile,v 2.1 1994/01/13 08:49:30 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.74 91/12/20 11:20:22 rws Exp $
  XCOMM
  XCOMM This library contains miscellaneous utility routines and is not part
***************
*** 172,178 ****
  #endif
  
  #if DoSharedLib
! #if SunPost411FCSLd
  libXmu.so.$(SOXMUREV): $(EXTENSIONSRC)/lib/libXext.so.$(SOXEXTREV)
  
  $(EXTENSIONSRC)/lib/libXext.so.$(SOXEXTREV):
--- 172,178 ----
  #endif
  
  #if DoSharedLib
! #if defined(SunPost411FCSLd) || defined(i386BsdArchitecture)
  libXmu.so.$(SOXMUREV): $(EXTENSIONSRC)/lib/libXext.so.$(SOXEXTREV)
  
  $(EXTENSIONSRC)/lib/libXext.so.$(SOXEXTREV):
diff -c mit/lib/Xt/Convert.c:1.5 mit/lib/Xt/Convert.c:2.0
*** mit/lib/Xt/Convert.c:1.5	Fri Mar 11 23:43:05 1994
--- mit/lib/Xt/Convert.c	Fri Mar 11 23:43:05 1994
***************
*** 1,5 ****
! /* $XFree86: mit/lib/Xt/Convert.c,v 1.5 1993/03/27 09:12:25 dawes Exp $ */
! /* $XConsortium: Convert.c,v 1.67 92/08/31 17:02:24 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,5 ----
! /* $XFree86: mit/lib/Xt/Convert.c,v 2.0 1993/11/13 04:23:32 dawes Exp $ */
! /* $XConsortium: Convert.c,v 1.68 93/07/12 14:52:00 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 995,1000 ****
--- 995,1002 ----
  	    CEXT(p->next)->prev = CEXT(p)->prev;
      } else {
  	*prev = p->next;
+ 	if (p->next && p->next->has_ext)
+ 	    CEXT(p->next)->prev = prev;
      }
      if (p->must_be_freed) {
  	register int i;
diff -c mit/lib/Xt/Display.c:1.6 mit/lib/Xt/Display.c:2.0
*** mit/lib/Xt/Display.c:1.6	Fri Mar 11 23:43:05 1994
--- mit/lib/Xt/Display.c	Fri Mar 11 23:43:05 1994
***************
*** 1,5 ****
! /* $XFree86: mit/lib/Xt/Display.c,v 1.6 1993/05/26 02:12:39 dawes Exp $ */
! /* $XConsortium: Display.c,v 1.89 93/03/15 15:27:35 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,5 ----
! /* $XFree86: mit/lib/Xt/Display.c,v 2.0 1993/11/13 04:23:34 dawes Exp $ */
! /* $XConsortium: Display.c,v 1.89.1.1 93/07/20 16:32:36 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 341,346 ****
--- 341,347 ----
  #ifndef NO_IDENTIFY_WINDOWS
  	app->identify_windows = False;
  #endif
+ 	app->free_bindings = NULL;
  	return app;
  }
  
***************
*** 371,376 ****
--- 372,378 ----
  	*prev_app = app->next;
  	if (app->process->defaultAppContext == app)
  	    app->process->defaultAppContext = NULL;
+ 	if (app->free_bindings) _XtDoFreeBindings (app);
  	XtFree((char *)app);
  }
  
diff -c mit/lib/Xt/Event.c:1.1.1.2 mit/lib/Xt/Event.c:1.1.1.3
*** mit/lib/Xt/Event.c:1.1.1.2	Fri Mar 11 23:43:06 1994
--- mit/lib/Xt/Event.c	Fri Mar 11 23:43:06 1994
***************
*** 1,4 ****
! /* $XConsortium: Event.c,v 1.137 92/11/19 17:24:47 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: Event.c,v 1.137.1.1 93/07/20 16:35:37 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 1085,1090 ****
--- 1085,1091 ----
      if (_XtSafeToDestroy(app)) {
  	if (_XtAppDestroyCount != 0) _XtDestroyAppContexts();
  	if (_XtDpyDestroyCount != 0) _XtCloseDisplays();
+ 	if (app->free_bindings) _XtDoFreeBindings(app);
      }
      
      return (was_dispatched != XtDidNothing);
diff -c mit/lib/Xt/InitialI.h:2.0 mit/lib/Xt/InitialI.h:2.1
*** mit/lib/Xt/InitialI.h:2.0	Fri Mar 11 23:43:07 1994
--- mit/lib/Xt/InitialI.h	Fri Mar 11 23:43:07 1994
***************
*** 1,5 ****
! /* $XFree86: mit/lib/Xt/InitialI.h,v 2.0 1993/09/22 15:32:59 dawes Exp $ */
! /* $XConsortium: InitialI.h,v 1.64 93/01/08 16:04:57 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,5 ----
! /* $XFree86: mit/lib/Xt/InitialI.h,v 2.1 1993/11/13 04:23:36 dawes Exp $ */
! /* $XConsortium: InitialI.h,v 1.64.1.1 93/07/20 16:26:20 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 143,148 ****
--- 143,149 ----
      DestroyRec* destroy_list;
      Widget in_phase2_destroy;
      LangProcRec langProcRec;
+     struct _TMBindCacheRec * free_bindings;
  } XtAppStruct;
  
  #ifdef XTTRACEMEMORY
***************
*** 346,351 ****
--- 347,358 ----
  #if NeedFunctionPrototypes
      XtAppContext /* app */,
      int		 /* dispatch_level */
+ #endif
+ );
+ 
+ extern void _XtDoFreeBindings(
+ #if NeedFunctionPrototypes
+     XtAppContext /* app */
  #endif
  );
  
diff -c mit/lib/Xt/Keyboard.c:1.1.1.2 mit/lib/Xt/Keyboard.c:1.1.1.3
*** mit/lib/Xt/Keyboard.c:1.1.1.2	Fri Mar 11 23:43:07 1994
--- mit/lib/Xt/Keyboard.c	Fri Mar 11 23:43:07 1994
***************
*** 1,4 ****
! /* $XConsortium: Keyboard.c,v 1.26 92/10/06 14:01:53 converse Exp $ */
  
  /********************************************************
  
--- 1,4 ----
! /* $XConsortium: Keyboard.c,v 1.28 93/07/14 14:38:07 converse Exp $ */
  
  /********************************************************
  
***************
*** 689,699 ****
      XtPointer call_data;
  {
      XtSetKeyboardFocus((Widget)closure, None);
-     /* invalidate FindKeyDestination's ancestor list if it is still for us */
-     if (pseudoTraceDepth &&
- 	pseudoTraceDisplay == XtDisplay((Widget)closure) &&
- 	_GetWindowedAncestor(widget) == pseudoTrace[0])
- 	pseudoTraceDepth = 0;
  }
  
  void XtSetKeyboardFocus(widget, descendant)
--- 689,694 ----
***************
*** 719,728 ****
  	/* all the rest handles focus ins and focus outs and misc gunk */
  	
  	if (oldDesc) {
! 	    if (!oldDesc->core.being_destroyed) {
! 		XtRemoveCallback (oldDesc, XtNdestroyCallback, 
! 				  FocusDestroyCallback, (XtPointer) widget);
! 	    }
  
  	    if (!oldTarget->core.being_destroyed) {
  		if (pwi->map_handler_added) {
--- 714,726 ----
  	/* all the rest handles focus ins and focus outs and misc gunk */
  	
  	if (oldDesc) {
! 	    /* invalidate FindKeyDestination's ancestor list */
! 	    if (pseudoTraceDepth && pseudoTraceDisplay == XtDisplay(widget) &&
! 		oldTarget == pseudoTrace[0])
! 		pseudoTraceDepth = 0;
! 
! 	    XtRemoveCallback(oldDesc, XtNdestroyCallback, 
! 			     FocusDestroyCallback, (XtPointer)widget);
  
  	    if (!oldTarget->core.being_destroyed) {
  		if (pwi->map_handler_added) {
diff -c mit/lib/Xt/TMaction.c:1.1.1.2 mit/lib/Xt/TMaction.c:1.1.1.3
*** mit/lib/Xt/TMaction.c:1.1.1.2	Fri Mar 11 23:43:08 1994
--- mit/lib/Xt/TMaction.c	Fri Mar 11 23:43:08 1994
***************
*** 1,4 ****
! /* $XConsortium: TMaction.c,v 1.18 93/05/13 15:14:24 converse Exp $ */
  /*LINTLIBRARY*/
  
  /***********************************************************
--- 1,4 ----
! /* $XConsortium: TMaction.c,v 1.18.1.1 93/07/20 16:43:49 kaleb Exp $ */
  /*LINTLIBRARY*/
  
  /***********************************************************
***************
*** 419,424 ****
--- 419,425 ----
      Widget		w;
      XtActionProc 	*procs;
  {
+     XtAppContext	app = XtWidgetToApplicationContext (w);
      TMClassCache	classCache = GetClassCache(w);
      TMBindCache		*bindCachePtr = (TMBindCache *)&classCache->bindCache;
      TMBindCache		bindCache;
***************
*** 448,454 ****
  			_XtGlobalTM.numBindCache--;
  #endif /* TRACE_TM */
  		      *bindCachePtr = bindCache->next;
! 		      XtFree((XtPointer)bindCache);
  		  }
  		break;
  	    }
--- 449,456 ----
  			_XtGlobalTM.numBindCache--;
  #endif /* TRACE_TM */
  		      *bindCachePtr = bindCache->next;
! 		      bindCache->next = app->free_bindings;
! 		      app->free_bindings = bindCache;
  		  }
  		break;
  	    }
***************
*** 942,945 ****
--- 944,957 ----
      }
  }
  
+ void _XtDoFreeBindings(app)
+     XtAppContext app;
+ {
+     TMBindCache bcp;
  
+     while (app->free_bindings) {
+ 	bcp = app->free_bindings->next;
+ 	XtFree ((char *) app->free_bindings);
+ 	app->free_bindings = bcp;
+     }
+ }
diff -c mit/lib/Xt/TMparse.c:1.4 mit/lib/Xt/TMparse.c:2.0
*** mit/lib/Xt/TMparse.c:1.4	Fri Mar 11 23:43:09 1994
--- mit/lib/Xt/TMparse.c	Fri Mar 11 23:43:09 1994
***************
*** 1,5 ****
! /* $XFree86: mit/lib/Xt/TMparse.c,v 1.4 1993/05/19 05:30:31 dawes Exp $ */
! /* $XConsortium: TMparse.c,v 1.134 92/12/30 13:02:26 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,5 ----
! /* $XFree86: mit/lib/Xt/TMparse.c,v 2.0 1993/11/13 04:23:38 dawes Exp $ */
! /* $XConsortium: TMparse.c,v 1.135 93/08/05 11:54:10 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 1930,1935 ****
--- 1930,1937 ----
        return (XtTranslations)NULL;
  
      source = CheckForPoundSign(source, defaultOp, &actualOp);
+     if (isAccelerator && actualOp == XtTableReplace)
+ 	actualOp = defaultOp;
  
      parseTree->isSimple = True;
      parseTree->mappingNotifyInterest = False;
diff -c mit/lib/Xt/TranslateI.h:1.1.1.2 mit/lib/Xt/TranslateI.h:1.1.1.3
*** mit/lib/Xt/TranslateI.h:1.1.1.2	Fri Mar 11 23:43:10 1994
--- mit/lib/Xt/TranslateI.h	Fri Mar 11 23:43:10 1994
***************
*** 1,4 ****
! /* $XConsortium: TranslateI.h,v 1.45 92/12/22 17:17:33 converse Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
--- 1,4 ----
! /* $XConsortium: TranslateI.h,v 1.46 93/08/18 11:26:41 kaleb Exp $ */
  
  /***********************************************************
  Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
***************
*** 112,118 ****
      unsigned int	isSimple:1;
      unsigned int	hasActions:1;
      unsigned int	hasCycles:1;
!     int			more:13;
      TMShortCard		typeIndex;
      TMShortCard		modIndex;
  }TMBranchHeadRec, *TMBranchHead;
--- 112,118 ----
      unsigned int	isSimple:1;
      unsigned int	hasActions:1;
      unsigned int	hasCycles:1;
!     unsigned int	more:13;
      TMShortCard		typeIndex;
      TMShortCard		modIndex;
  }TMBranchHeadRec, *TMBranchHead;
diff -c mit/lib/Xt/fd.h:2.0 mit/lib/Xt/fd.h:2.1
*** mit/lib/Xt/fd.h:2.0	Fri Mar 11 23:43:11 1994
--- mit/lib/Xt/fd.h	Fri Mar 11 23:43:11 1994
***************
*** 1,6 ****
  /*
! * $XFree86: mit/lib/Xt/fd.h,v 2.0 1993/09/22 15:33:03 dawes Exp $
! * $XConsortium: fd.h,v 1.14 89/10/05 13:32:53 swick Exp $
  * $oHeader: fd.h,v 1.4 88/08/26 14:49:54 asente Exp $
  */
  
--- 1,6 ----
  /*
! * $XFree86: mit/lib/Xt/fd.h,v 2.1 1993/11/13 04:23:41 dawes Exp $
! * $XConsortium: fd.h,v 1.15 93/07/08 13:29:55 kaleb Exp $
  * $oHeader: fd.h,v 1.4 88/08/26 14:49:54 asente Exp $
  */
  
***************
*** 31,37 ****
  #ifndef _Xt_fd_set
  #define _Xt_fd_set
  
! #if defined(CRAY) && !defined(FD_SETSIZE)
  #include <sys/select.h>		/* defines FD stuff except howmany() */
  #endif
  
--- 31,37 ----
  #ifndef _Xt_fd_set
  #define _Xt_fd_set
  
! #if (defined(SVR4) || defined(CRAY) || defined(AIXV3)) && !defined(FD_SETSIZE)
  #include <sys/select.h>		/* defines FD stuff except howmany() */
  #endif
  
diff -c mit/rgb/Imakefile:2.1 mit/rgb/Imakefile:2.2
*** mit/rgb/Imakefile:2.1	Fri Mar 11 23:43:21 1994
--- mit/rgb/Imakefile	Fri Mar 11 23:43:21 1994
***************
*** 1,17 ****
! XCOMM $XFree86: mit/rgb/Imakefile,v 2.1 1993/08/30 15:19:04 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.23 91/09/09 16:09:09 rws Exp $
          RGB_DB = DefaultRGBDatabase
     SITE_RGB_DB = -DRGB_DB=\"$(RGB_DB)\"
        DEPLIBS = 
        DEFINES = NdbmDefines $(SITE_RGB_DB)
-      INCLUDES = -I$(SERVERSRC)/include
-  INSTALLFLAGS = $(INSTLIBFLAGS)
          SRCS1 = rgb.c
          OBJS1 = rgb.o
          SRCS2 = showrgb.c
          OBJS2 = showrgb.o
           SRCS = $(SRCS1) $(SRCS2)
           OBJS = $(OBJS1) $(OBJS2)
       PROGRAMS = rgb showrgb
  #if i386Bsd
      DATAFILES = rgb.db
--- 1,24 ----
! XCOMM $XFree86: mit/rgb/Imakefile,v 2.2 1993/11/07 14:07:09 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.23 91/09/09 16:09:09 rws Exp $
          RGB_DB = DefaultRGBDatabase
     SITE_RGB_DB = -DRGB_DB=\"$(RGB_DB)\"
        DEPLIBS = 
+ #ifdef XFree86Version
+       DEFINES = -DUSE_RGB_TXT $(SITE_RGB_DB)
+ #else
        DEFINES = NdbmDefines $(SITE_RGB_DB)
          SRCS1 = rgb.c
          OBJS1 = rgb.o
+ #endif
+      INCLUDES = -I$(SERVERSRC)/include
+  INSTALLFLAGS = $(INSTLIBFLAGS)
          SRCS2 = showrgb.c
          OBJS2 = showrgb.o
           SRCS = $(SRCS1) $(SRCS2)
           OBJS = $(OBJS1) $(OBJS2)
+ #ifdef XFree86Version
+      PROGRAMS = showrgb
+ #else /* !XFree86Version */
       PROGRAMS = rgb showrgb
  #if i386Bsd
      DATAFILES = rgb.db
***************
*** 34,39 ****
--- 41,47 ----
  #if Amoeba || Minix
         DBMLIB = ../lib/sdbm/libsdbm.a
  #endif
+ #endif /* !XFree86Version */
  
  #if !CrossCompiling
  all:: $(PROGRAMS) $(DATADEP)
***************
*** 41,46 ****
--- 49,58 ----
  all:: showrgb
  #endif
  
+ #ifdef XFree86Version
+ SingleProgramTarget(showrgb,$(OBJS2),NullParameter,NullParameter)
+ SpecialObjectRule(showrgb.o,showrgb.c $(ICONFIGFILES),$(_NOOP_))
+ #else
  #if Amoeba || Minix
  SingleProgramTarget(rgb,$(OBJS1),$(DBMLIB),NullParameter)
  SingleProgramTarget(showrgb,$(OBJS2),$(DBMLIB),NullParameter)
***************
*** 50,55 ****
--- 62,68 ----
  #endif
  SpecialObjectRule(rgb.o,rgb.c $(ICONFIGFILES),$(_NOOP_))
  SpecialObjectRule(showrgb.o,showrgb.c $(ICONFIGFILES),$(_NOOP_))
+ #endif
  #if !CrossCompiling
  InstallMultiple($(DATAFILES) rgb.txt,$(LIBDIR))
  #else
***************
*** 63,68 ****
--- 76,82 ----
  InstallProgramWithFlags(showrgb,$(BINDIR),)
  InstallManPage(showrgb,$(MANDIR))
  
+ #ifndef XFree86Version
  #if !CrossCompiling
  $(DATADEP):  rgb rgb.txt
  	$(RM) $(DATAFILES)
***************
*** 70,75 ****
--- 84,90 ----
  
  clean::
  	$(RM) $(DATAFILES)
+ #endif
  #endif
  
  DependTarget()
diff -c mit/rgb/rgb.c:1.11 mit/rgb/rgb.c:2.1
*** mit/rgb/rgb.c:1.11	Fri Mar 11 23:43:22 1994
--- mit/rgb/rgb.c	Fri Mar 11 23:43:22 1994
***************
*** 1,4 ****
! /* $XFree86: mit/rgb/rgb.c,v 1.11 1993/04/09 11:30:21 dawes Exp $ */
  /* Copyright 1985, Massachusetts Institute of Technology */
  
  /* reads from standard input lines of the form:
--- 1,4 ----
! /* $XFree86: mit/rgb/rgb.c,v 2.1 1994/02/10 21:24:09 dawes Exp $ */
  /* Copyright 1985, Massachusetts Institute of Technology */
  
  /* reads from standard input lines of the form:
***************
*** 9,18 ****
  static char *rcsid_rgb_c = "$XConsortium: rgb.c,v 11.14 91/06/30 16:38:56 rws Exp $";
  #endif
  
- #ifdef __386BSD__
- #include <sys/types.h>
- #endif
- 
  #ifdef NDBM
  #ifdef SDBM
  #include <sdbm.h>
--- 9,14 ----
***************
*** 33,38 ****
--- 29,39 ----
  #undef NULL
  #include <stdio.h>
  #include <X11/Xos.h>
+ 
+ #if (BSD >= 199103)
+ #include <sys/types.h>
+ #endif
+ 
  #include "rgb.h"
  #include "site.h"
  #include <ctype.h>
***************
*** 39,47 ****
  
  #include <errno.h>
  extern int errno;			/* some systems are still stupid */
  extern int sys_nerr;
- #ifndef linux
  extern char *sys_errlist[];
  #endif
  
  #ifndef X_NOT_STDC_ENV
--- 40,50 ----
  
  #include <errno.h>
  extern int errno;			/* some systems are still stupid */
+ #ifdef X_NO_STRERROR
  extern int sys_nerr;
  extern char *sys_errlist[];
+ #else
+ #include <string.h>
  #endif
  
  #ifndef X_NOT_STDC_ENV
***************
*** 52,61 ****
--- 55,68 ----
  
  char *ProgramName;
  
+ #ifdef X_NO_STRERROR
  char *SysError ()
  {
      return ((errno >= 0 && errno < sys_nerr) ? sys_errlist[errno] : "?");
  }
+ #else
+ #define SysError() strerror(errno)
+ #endif
  
  main(argc, argv)
      int argc;
***************
*** 93,99 ****
  	}
      }
  
! #ifndef __386BSD__
      strcpy (name, dbname);
      strcat (name, ".dir");
      fd = open (name, O_WRONLY|O_CREAT, 0666);
--- 100,106 ----
  	}
      }
  
! #if !(BSD >= 199103)
      strcpy (name, dbname);
      strcat (name, ".dir");
      fd = open (name, O_WRONLY|O_CREAT, 0666);
diff -c mit/rgb/showrgb.c:1.10 mit/rgb/showrgb.c:2.2
*** mit/rgb/showrgb.c:1.10	Fri Mar 11 23:43:22 1994
--- mit/rgb/showrgb.c	Fri Mar 11 23:43:22 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/rgb/showrgb.c,v 1.10 1993/04/09 11:30:22 dawes Exp $
   * $XConsortium: showrgb.c,v 1.8 91/06/30 16:39:03 rws Exp $
   *
   * Copyright 1989 Massachusetts Institute of Technology
--- 1,5 ----
  /*
!  * $XFree86: mit/rgb/showrgb.c,v 2.2 1994/02/10 21:24:10 dawes Exp $
   * $XConsortium: showrgb.c,v 1.8 91/06/30 16:39:03 rws Exp $
   *
   * Copyright 1989 Massachusetts Institute of Technology
***************
*** 24,33 ****
   * Author:  Jim Fulton, MIT X Consortium
   */
  
! #ifdef __386BSD__
! #include <sys/types.h>
! #endif
! 
  #ifdef NDBM
  #ifdef SDBM
  #include <sdbm.h>
--- 24,30 ----
   * Author:  Jim Fulton, MIT X Consortium
   */
  
! #ifndef USE_RGB_TXT
  #ifdef NDBM
  #ifdef SDBM
  #include <sdbm.h>
***************
*** 45,54 ****
--- 42,57 ----
  #define dbm_fetch(db,key) (fetch(key))
  #define dbm_close(db) dbmclose()
  #endif
+ #endif
  
  #undef NULL
  #include <stdio.h>
  #include <X11/Xos.h>
+ 
+ #if (BSD >= 199103)
+ #include <sys/types.h>
+ #endif
+ 
  #include "rgb.h"			/* off in server/include/ */
  #include "site.h"
  #include <X11/Xfuncs.h>
***************
*** 81,86 ****
--- 84,91 ----
      exit (0);
  }
  
+ #ifndef USE_RGB_TXT
+ 
  dumprgb (filename)
      char *filename;
  {
***************
*** 128,130 ****
--- 133,181 ----
  
      dbm_close (rgb_dbm);
  }
+ 
+ #else /* USE_RGB_TXT */
+ 
+ dumprgb (filename)
+     char *filename;
+ {
+     FILE *rgb;
+     char *path;
+     char line[BUFSIZ];
+     char name[BUFSIZ];
+     int lineno = 0;
+     int red, green, blue;
+    
+     path = (char *)malloc(strlen(filename) + 5);
+     strcpy(path, filename);
+     strcat(path, ".txt");
+ 
+     if (!(rgb = fopen(path, "r"))) {
+ 	fprintf (stderr, "%s:  unable to open rgb database \"%s\"\n",
+ 		 ProgramName, filename);
+ 	free(path);
+ 	exit (1);
+     }
+ 
+     while(fgets(line, sizeof(line), rgb)) {
+ 	lineno++;
+ 	if (sscanf(line, "%d %d %d %[^\n]\n", &red, &green, &blue, name) == 4) {
+ 	    if (red >= 0 && red <= 0xff &&
+ 		green >= 0 && green <= 0xff &&
+ 		blue >= 0 && blue <= 0xff) {
+ 		printf ("%3u %3u %3u\t\t%s\n", red, green, blue, name);
+ 	    } else {
+ 		fprintf(stderr, "%s:  value for \"%s\" out of range: %s:%d\n",
+ 		        ProgramName, name, path, lineno);
+ 	    }
+ 	} else if (*line && *line != '#') {
+ 	    fprintf(stderr, "%s:  syntax error: %s:%d\n", ProgramName,
+ 		    path, lineno);
+ 	}
+     }
+ 
+     free(path);
+     fclose(rgb);
+ }
+ 
+ #endif /* USE_RGB_TXT */
diff -c mit/util/makedepend/def.h:2.0 mit/util/makedepend/def.h:2.1
*** mit/util/makedepend/def.h:2.0	Fri Mar 11 23:43:26 1994
--- mit/util/makedepend/def.h	Fri Mar 11 23:43:26 1994
***************
*** 1,13 ****
  /*
!  * $XFree86: mit/util/makedepend/def.h,v 2.0 1993/10/02 07:16:30 dawes Exp $
   * $XConsortium: def.h,v 1.17 91/05/13 10:23:29 rws Exp $
   */
! #include <X11/Xosdefs.h>
  #include <stdio.h>
  #include <ctype.h>
  #ifndef X_NOT_POSIX
  #ifndef _POSIX_SOURCE
! #ifndef __386BSD__
  #define _POSIX_SOURCE
  #endif
  #endif
--- 1,13 ----
  /*
!  * $XFree86: mit/util/makedepend/def.h,v 2.1 1994/02/10 21:27:52 dawes Exp $
   * $XConsortium: def.h,v 1.17 91/05/13 10:23:29 rws Exp $
   */
! #include <X11/Xos.h>
  #include <stdio.h>
  #include <ctype.h>
  #ifndef X_NOT_POSIX
  #ifndef _POSIX_SOURCE
! #if !(BSD >= 199103)
  #define _POSIX_SOURCE
  #endif
  #endif
diff -c mit/util/makedepend/main.c:1.4 mit/util/makedepend/main.c:2.0
*** mit/util/makedepend/main.c:1.4	Fri Mar 11 23:43:26 1994
--- mit/util/makedepend/main.c	Fri Mar 11 23:43:26 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/util/makedepend/main.c,v 1.4 1993/03/27 08:54:40 dawes Exp $
   * $XConsortium: main.c,v 1.56 91/07/25 11:50:59 rws Exp $
   */
  #include "def.h"
--- 1,5 ----
  /*
!  * $XFree86: mit/util/makedepend/main.c,v 2.0 1994/02/10 21:27:54 dawes Exp $
   * $XConsortium: main.c,v 1.56 91/07/25 11:50:59 rws Exp $
   */
  #include "def.h"
***************
*** 9,15 ****
  
  #ifndef X_NOT_POSIX
  #ifndef _POSIX_SOURCE
! #ifndef __386BSD__
  #define _POSIX_SOURCE
  #endif
  #endif
--- 9,15 ----
  
  #ifndef X_NOT_POSIX
  #ifndef _POSIX_SOURCE
! #if !(BSD >= 199103)
  #define _POSIX_SOURCE
  #endif
  #endif
diff -c mit/util/scripts/Imakefile:2.0 mit/util/scripts/Imakefile:2.2
*** mit/util/scripts/Imakefile:2.0	Fri Mar 11 23:43:31 1994
--- mit/util/scripts/Imakefile	Fri Mar 11 23:43:31 1994
***************
*** 1,9 ****
! XCOMM $XFree86: mit/util/scripts/Imakefile,v 2.0 1993/09/10 05:50:07 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.23 92/04/14 18:46:59 rws Exp $
  #if UseCCMakeDepend
  MDEP_PROG = makedepend
  #endif
!          PROGRAMS = xmkmf $(MDEP_PROG) mergelib lndir xon
  
  all:: $(PROGRAMS)
  
--- 1,12 ----
! XCOMM $XFree86: mit/util/scripts/Imakefile,v 2.2 1994/02/19 09:32:33 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.23 92/04/14 18:46:59 rws Exp $
  #if UseCCMakeDepend
  MDEP_PROG = makedepend
  #endif
! #if HasGcc
! GMDEP_PROG = gccmakedep
! #endif
!          PROGRAMS = xmkmf $(MDEP_PROG) $(GMDEP_PROG) mergelib lndir xon
  
  all:: $(PROGRAMS)
  
***************
*** 23,28 ****
--- 26,34 ----
  #if UseCCMakeDepend
  CppScriptTarget(makedepend,mdepend.cpp,-DPREPROC='"'"$(PREPROCESSCMD)"'"',$(ICONFIGFILES))
  #endif
+ #if HasGcc
+ CppScriptTarget(gccmakedep,gccmdep.cpp,-DCCCMD='"'"$(CC)"'"' -DRMCMD='"'"$(RM)"'"' -DLNCMD='"'"$(LN)"'"' -DMVCMD='"'"$(MV)"'"',$(ICONFIGFILES))
+ #endif
  CppScriptTarget(mergelib,mergelib.cpp,"-DARCMD=$(AR)" "-DRANLIB=$(RANLIB)",$(ICONFIGFILES))
  CppScriptTarget(lndir,lndir.cpp,-DLSAF=$(LSAFFLAG),NullParameter)
  CppScriptTarget(xon,xon.cpp,-DRSHCMD=$(RSHCMD),NullParameter)
***************
*** 37,42 ****
--- 43,51 ----
  InstallManPage(mkdirhier,$(MANDIR))
  #if UseCCMakeDepend
  InstallNamedScript(makedepend,makedepend,$(BINDIR))
+ #endif
+ #if HasGcc
+ InstallNamedScript(gccmakedep,gccmakedep,$(BINDIR))
  #endif
  InstallNamedScript(lndir,lndir,$(BINDIR))
  InstallManPage(lndir,$(MANDIR))
diff -c /dev/null mit/util/scripts/gccmdep.cpp:2.3
*** /dev/null	Fri Mar 11 23:43:31 1994
--- mit/util/scripts/gccmdep.cpp	Fri Mar 11 23:43:31 1994
***************
*** 0 ****
--- 1,126 ----
+ XCOMM!/bin/sh
+ 
+ XCOMM
+ XCOMM makedepend which uses 'gcc -M'
+ XCOMM
+ XCOMM $XFree86: mit/util/scripts/gccmdep.cpp,v 2.3 1994/03/07 14:06:54 dawes Exp $
+ XCOMM
+ XCOMM Based on mdepend.cpp and code supplied by Hongjiu Lu <hjl@nynexst.com>
+ XCOMM
+ 
+ TMP=/tmp/mdep$$
+ CC=CCCMD
+ RM=RMCMD
+ LN=LNCMD
+ MV=MVCMD
+ 
+ trap "$RM ${TMP}*; exit 1" 1 2 15
+ trap "$RM ${TMP}*; exit 0" 1 2 13
+ 
+ files=
+ makefile=
+ endmarker=
+ magic_string='# DO NOT DELETE'
+ append=n
+ args=
+ asmfiles=
+ 
+ while [ $# != 0 ]; do
+     if [ "$endmarker"x != x -a "$endmarker" = "$1" ]; then
+ 	endmarker=
+     else
+ 	case "$1" in
+ 	    -D*|-I*)
+ 		args="$args '$1'"
+ 		;;
+ 	    -g|-o)
+ 		;;
+ 	    *)
+ 		if [ "$endmarker"x = x ]; then
+ 		    case $1 in
+ XCOMM ignore these flags
+ 			-w|-o|-cc)
+ 			    shift
+ 			    ;;
+ 			-v)
+ 			    ;;
+ 			-s)
+ 			    magic_string="$2"
+ 			    shift
+ 			    ;;
+ 			-f)
+ 			    makefile="$2"
+ 			    shift
+ 			    ;;
+ 			--*)
+ 			    endmarker=`echo $1 | sed 's/^\-\-//'`
+ 			    if [ "$endmarker"x = x ]; then
+ 				endmarker="--"
+ 			    fi
+ 			    ;;
+ 			-a)
+ 			    append=y
+ 			    ;;
+ 			-*)
+ 			    echo "Unknown option '$1' ignored" 1>&2
+ 			    ;;
+ 			*)
+ 			    files="$files $1"
+ 			    ;;
+ 		    esac
+ 		fi
+ 		;;
+ 	esac
+     fi
+     shift
+ done
+ 
+ if [ x"$files" = x ]; then
+ XCOMM Nothing to do
+     exit 0
+ fi
+ 
+ case "$makefile" in
+     '')
+ 	if [ -r makefile ]; then
+ 	    makmefile=makefile
+ 	elif [ -r Makefile ]; then
+ 	    makefile=Makefile
+ 	else
+ 	    echo 'no makefile or Makefile found' 1>&2
+ 	    exit 1
+ 	fi
+ 	;;
+ esac
+ 
+ if [ x"$append" = xn ]; then
+     sed -e "/^$magic_string/,\$d" < $makefile > $TMP
+     echo "$magic_string" >> $TMP
+ else
+     cp $makefile $TMP
+ fi
+ 
+ XCOMM need to link .s files to .S
+ for i in $files; do
+     case $i in
+ 	*.s)
+ 	    dir=`dirname $i`
+ 	    base=`basename $i .s`
+ 	    (cd $dir; $RM ${base}.S; $LN ${base}.s ${base}.S)
+ 	    asmfiles="$asmfiles ${base}.S"
+ 	    ;;
+     esac
+ done
+ 
+ CMD="$CC -M $args `echo $files | sed 's,\.s,\.S,g'` | sed 's,\.S,\.s,'"
+ CMD="$CMD >> $TMP"
+ eval $CMD
+ $RM ${makefile}.bak
+ $MV $makefile ${makefile}.bak
+ $MV $TMP $makefile
+ 
+ if [ x"$asmfiles" != x ]; then
+     $RM $asmfiles
+ fi
+ $RM ${TMP}*
+ exit 0
diff -c mit/include/Xmd.h:1.1.1.1 mit/include/Xmd.h:2.0
*** mit/include/Xmd.h:1.1.1.1	Fri Mar 11 23:43:50 1994
--- mit/include/Xmd.h	Fri Mar 11 23:43:50 1994
***************
*** 23,28 ****
--- 23,29 ----
  ******************************************************************/
  #ifndef XMD_H
  #define XMD_H 1
+ /* $XFree86: mit/include/Xmd.h,v 2.0 1993/12/10 14:33:26 dawes Exp $ */
  /* $XConsortium: Xmd.h,v 1.41 91/05/10 10:00:03 jap Exp $ */
  /*
   *  Xmd.h: MACHINE DEPENDENT DECLARATIONS.
***************
*** 60,66 ****
   * The extra indirection in the __STDC__ case is to get macro arguments to
   * expand correctly before the concatenation, rather than afterward.
   */
! #if __STDC__ && !defined(UNIXCPP)
  #define _SIZEOF(x) sz_##x
  #define SIZEOF(x) _SIZEOF(x)
  #else
--- 61,67 ----
   * The extra indirection in the __STDC__ case is to get macro arguments to
   * expand correctly before the concatenation, rather than afterward.
   */
! #if (__STDC__ && !defined(UNIXCPP)) || (defined (SOLX86) && defined (__STDC__))
  #define _SIZEOF(x) sz_##x
  #define SIZEOF(x) _SIZEOF(x)
  #else
diff -c mit/include/Xos.h:2.3 mit/include/Xos.h:2.4
*** mit/include/Xos.h:2.3	Fri Mar 11 23:43:51 1994
--- mit/include/Xos.h	Fri Mar 11 23:43:51 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/include/Xos.h,v 2.3 1993/09/22 15:31:01 dawes Exp $
   * $XConsortium: Xos.h,v 1.47 91/08/17 17:14:38 rws Exp $
   * 
   * Copyright 1987 by the Massachusetts Institute of Technology
--- 1,5 ----
  /*
!  * $XFree86: mit/include/Xos.h,v 2.4 1994/02/10 21:23:22 dawes Exp $
   * $XConsortium: Xos.h,v 1.47 91/08/17 17:14:38 rws Exp $
   * 
   * Copyright 1987 by the Massachusetts Institute of Technology
***************
*** 33,38 ****
--- 33,43 ----
  #include <stdio.h>
  #endif
  
+ /* Get value of BSD */
+ #if !defined(MACH) && !defined(MACH386) && !defined(__OSF__)
+ #include <sys/param.h>
+ #endif
+ 
  #include <X11/Xosdefs.h>
  
  /*
***************
*** 198,204 ****
  #include <sys/bsdtypes.h>
  #endif
  
! #ifdef __386BSD__
  #include <machine/endian.h>
  #endif
  
--- 203,209 ----
  #include <sys/bsdtypes.h>
  #endif
  
! #if (BSD >= 199103)
  #include <machine/endian.h>
  #endif
  
diff -c mit/include/Xosdefs.h:1.3 mit/include/Xosdefs.h:2.0
*** mit/include/Xosdefs.h:1.3	Fri Mar 11 23:43:51 1994
--- mit/include/Xosdefs.h	Fri Mar 11 23:43:51 1994
***************
*** 1,7 ****
  /*
   * O/S-dependent (mis)feature macro definitions
   *
!  * $XFree86: mit/include/Xosdefs.h,v 1.3 1993/05/19 05:32:44 dawes Exp $
   * $XConsortium: Xosdefs.h,v 1.7 91/07/19 23:22:19 rws Exp $
   *
   * Copyright 1991 Massachusetts Institute of Technology
--- 1,7 ----
  /*
   * O/S-dependent (mis)feature macro definitions
   *
!  * $XFree86: mit/include/Xosdefs.h,v 2.0 1993/11/07 14:04:50 dawes Exp $
   * $XConsortium: Xosdefs.h,v 1.7 91/07/19 23:22:19 rws Exp $
   *
   * Copyright 1991 Massachusetts Institute of Technology
***************
*** 34,39 ****
--- 34,42 ----
   * X_NOT_POSIX means does not have POSIX header files.  Lack of this
   * symbol does NOT mean that the POSIX environment is the default.
   * You may still have to define _POSIX_SOURCE to get it.
+  *
+  * X_NO_STRERROR means does not have strerror(), or that it shouldn't
+  * be used for shared lib compatibility reasons
   */
  
  #ifdef NOSTDHDRS
***************
*** 41,46 ****
--- 44,52 ----
  #ifndef X_NOT_STDC_ENV
  #define X_NOT_STDC_ENV
  #endif
+ #ifndef X_NO_STRERROR
+ #define X_NO_STRERROR
+ #endif
  #endif
  
  #ifdef sony
***************
*** 98,101 ****
--- 104,114 ----
  #ifdef AMOEBA
  #define	_POSIX_SOURCE
  #endif
+ 
+ #if !defined(__STDC__) || defined(SYSV) || defined(SVR4) || defined(sun)
+ #ifndef X_NO_STRERROR
+ #define X_NO_STRERROR
+ #endif
+ #endif
+ 
  #endif /* _XOSDEFS_H_ */
diff -c mit/fonts/Imakefile:1.1.1.1 mit/fonts/Imakefile:2.1
*** mit/fonts/Imakefile:1.1.1.1	Fri Mar 11 23:43:55 1994
--- mit/fonts/Imakefile	Fri Mar 11 23:43:55 1994
***************
*** 1,3 ****
--- 1,4 ----
+ XCOMM $XFree86: mit/fonts/Imakefile,v 2.1 1994/02/24 13:28:15 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.28 91/07/16 23:03:55 gildea Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'
***************
*** 14,21 ****
  SERVERDIRS = server
  #endif
  
  /* clients must be built before font dirs */
! SUBDIRS = lib clients $(FONTDIRS) $(PEXDIRS) $(SERVERDIRS)
  
  MakeSubdirs($(SUBDIRS))
  DependSubdirs($(SUBDIRS))
--- 15,30 ----
  SERVERDIRS = server
  #endif
  
+ #if BuildFonts || BuildPexExt || BuildFontServer
+ CLIENTS = clients
+ #endif
+ 
  /* clients must be built before font dirs */
! #if BuildServersOnly
! SUBDIRS = include lib
! #else
! SUBDIRS = include lib $(CLIENTS) $(FONTDIRS) $(PEXDIRS) $(SERVERDIRS)
! #endif
  
  MakeSubdirs($(SUBDIRS))
  DependSubdirs($(SUBDIRS))
diff -c /dev/null mit/fonts/include/Imakefile:2.1
*** /dev/null	Fri Mar 11 23:44:01 1994
--- mit/fonts/include/Imakefile	Fri Mar 11 23:44:01 1994
***************
*** 0 ****
--- 1,9 ----
+ XCOMM $XFree86: mit/fonts/include/Imakefile,v 2.1 1994/02/28 13:55:18 dawes Exp $
+ 
+ all::
+ 
+ InstallLinkKitNonExecFile(fontstruct.h,$(LINKKITDIR)/include)
+ InstallLinkKitNonExecFile(font.h,$(LINKKITDIR)/include)
+ InstallLinkKitNonExecFile(fsmasks.h,$(LINKKITDIR)/include)
+ 
+ depend::
diff -c mit/fonts/lib/fs/FSlibInt.c:1.4 mit/fonts/lib/fs/FSlibInt.c:2.0
*** mit/fonts/lib/fs/FSlibInt.c:1.4	Fri Mar 11 23:44:09 1994
--- mit/fonts/lib/fs/FSlibInt.c	Fri Mar 11 23:44:09 1994
***************
*** 1,4 ****
! /* $XFree86: mit/fonts/lib/fs/FSlibInt.c,v 1.4 1993/06/02 14:36:49 dawes Exp $ */
  /* $XConsortium: FSlibInt.c,v 1.9 91/07/22 11:29:28 rws Exp $ */
  
  /* @(#)FSlibInt.c	3.3	91/05/02
--- 1,4 ----
! /* $XFree86: mit/fonts/lib/fs/FSlibInt.c,v 2.0 1993/11/07 14:04:06 dawes Exp $ */
  /* $XConsortium: FSlibInt.c,v 1.9 91/07/22 11:29:28 rws Exp $ */
  
  /* @(#)FSlibInt.c	3.3	91/05/02
***************
*** 996,1002 ****
  _SysErrorMsg(n)
      int         n;
  {
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
      return strerror(n);
  #else
      extern char *sys_errlist[];
--- 996,1002 ----
  _SysErrorMsg(n)
      int         n;
  {
! #ifndef X_NO_STRERROR
      return strerror(n);
  #else
      extern char *sys_errlist[];
diff -c mit/extensions/Imakefile:1.1.1.1 mit/extensions/Imakefile:2.0
*** mit/extensions/Imakefile:1.1.1.1	Fri Mar 11 23:44:20 1994
--- mit/extensions/Imakefile	Fri Mar 11 23:44:20 1994
***************
*** 1,3 ****
--- 1,4 ----
+ XCOMM $XFree86: mit/extensions/Imakefile,v 2.0 1993/12/17 10:57:30 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.13 91/07/16 23:10:30 gildea Exp $
  #define IHaveSubdirs
  #define PassCDebugFlags
***************
*** 9,15 ****
--- 10,20 ----
    SERVERSUBDIRS = server/PEX/dipex/swap
  #endif
  #endif
+ #if BuildServersOnly
+         SUBDIRS = $(SERVERSUBDIRS)
+ #else
          SUBDIRS = $(SERVERSUBDIRS) lib include test
+ #endif
  
  MakeSubdirs($(SUBDIRS))
  DependSubdirs($(SUBDIRS))
diff -c mit/extensions/server/shm.c:1.2 mit/extensions/server/shm.c:2.1
*** mit/extensions/server/shm.c:1.2	Fri Mar 11 23:44:54 1994
--- mit/extensions/server/shm.c	Fri Mar 11 23:44:54 1994
***************
*** 17,28 ****
  
  /* THIS IS NOT AN X CONSORTIUM STANDARD */
  
! /* $XFree86: mit/extensions/server/shm.c,v 1.2 1993/05/05 12:32:28 dawes Exp $ */
  /* $XConsortium: shm.c,v 1.11 91/07/12 09:54:58 rws Exp $ */
  
  #include <sys/types.h>
  #include <sys/ipc.h>
  #include <sys/shm.h>
  #define NEED_REPLIES
  #define NEED_EVENTS
  #include "X.h"
--- 17,29 ----
  
  /* THIS IS NOT AN X CONSORTIUM STANDARD */
  
! /* $XFree86: mit/extensions/server/shm.c,v 2.1 1994/03/01 12:26:12 dawes Exp $ */
  /* $XConsortium: shm.c,v 1.11 91/07/12 09:54:58 rws Exp $ */
  
  #include <sys/types.h>
  #include <sys/ipc.h>
  #include <sys/shm.h>
+ #include <sys/param.h>
  #define NEED_REPLIES
  #define NEED_EVENTS
  #include "X.h"
***************
*** 106,116 ****
--- 107,157 ----
      } \
  }
  
+ #ifdef BSD
+ #include <sys/signal.h>
+ 
+ static Bool badSysCall = FALSE;
+ 
+ static void
+ SigSysHandler(signo)
+ int signo;
+ {
+     badSysCall = TRUE;
+ }
+ 
+ static Bool CheckForShmSyscall()
+ {
+     void (*oldHandler)();
+     int shmid = -1;
+ 
+     /* If no SHM support in the kernel, the bad syscall will generate SIGSYS */
+     oldHandler = signal(SIGSYS, SigSysHandler);
+ 
+     badSysCall = FALSE;
+     shmid = shmget(IPC_PRIVATE, 4096, IPC_CREAT);
+     /* Clean up */
+     if (shmid != -1)
+     {
+ 	shmctl(shmid, IPC_RMID, (struct shmid_ds *)NULL);
+     }
+     signal(SIGSYS, oldHandler);
+     return(!badSysCall);
+ }
+ #endif
+     
  void
  ShmExtensionInit()
  {
      ExtensionEntry *extEntry;
      int i;
+ 
+ #ifdef BSD
+     if (!CheckForShmSyscall())
+     {
+ 	ErrorF("MIT-SHM extension disabled due to lack of kernel support\n");
+ 	return;
+     }
+ #endif
  
      sharedPixmaps = xTrue;
      pixmapFormat = shmPixFormat[0];
diff -c mit/clients/twm/Imakefile:2.0 mit/clients/twm/Imakefile:2.1
*** mit/clients/twm/Imakefile:2.0	Sat Mar 12 00:14:53 1994
--- mit/clients/twm/Imakefile	Sat Mar 12 00:14:53 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/clients/twm/Imakefile,v 2.0 1993/08/28 07:37:50 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.33 91/07/17 00:48:06 gildea Exp $
  XCOMM
  XCOMM Here is an Imakefile for twm.  It depends on having TWMDIR defined
--- 1,4 ----
! XCOMM $XFree86: mit/clients/twm/Imakefile,v 2.1 1993/12/18 11:40:02 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.33 91/07/17 00:48:06 gildea Exp $
  XCOMM
  XCOMM Here is an Imakefile for twm.  It depends on having TWMDIR defined
***************
*** 9,15 ****
  
           YFLAGS = -d
          DEPLIBS = $(DEPXMULIB) $(DEPEXTENSIONLIB) $(DEPXLIB)
! LOCAL_LIBRARIES = $(XMULIB) $(EXTENSIONLIB) $(XLIB)
         LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
          DEFINES = $(SIGNAL_DEFINES)
  
--- 9,15 ----
  
           YFLAGS = -d
          DEPLIBS = $(DEPXMULIB) $(DEPEXTENSIONLIB) $(DEPXLIB)
! LOCAL_LIBRARIES = $(XMULIB) $(EXTENSIONLIB) $(LEXLIB) $(XLIB)
         LINTLIBS = $(LINTXMU) $(LINTEXTENSIONLIB) $(LINTXLIB)
          DEFINES = $(SIGNAL_DEFINES)
  
diff -c mit/clients/twm/lex.l:1.4 mit/clients/twm/lex.l:2.0
*** mit/clients/twm/lex.l:1.4	Sat Mar 12 00:14:54 1994
--- mit/clients/twm/lex.l	Sat Mar 12 00:14:54 1994
***************
*** 28,34 ****
  
  /***********************************************************************
   *
!  * $XFree86: mit/clients/twm/lex.l,v 1.4 1993/03/20 06:05:36 dawes Exp $
   * $XConsortium: lex.l,v 1.62 89/12/10 17:46:33 jim Exp $
   *
   * .twmrc lex file
--- 28,34 ----
  
  /***********************************************************************
   *
!  * $XFree86: mit/clients/twm/lex.l,v 2.0 1994/02/10 21:20:40 dawes Exp $
   * $XConsortium: lex.l,v 1.62 89/12/10 17:46:33 jim Exp $
   *
   * .twmrc lex file
***************
*** 38,43 ****
--- 38,44 ----
   ***********************************************************************/
  
  /* #include <stdio.h> */		/* lex already includes stdio.h */
+ #include <X11/Xos.h>
  #include "gram.h"
  #include "parse.h"
  extern char *ProgramName;
***************
*** 44,50 ****
  
  extern int ParseError;
  
! #if defined(__386BSD__) || defined(linux) || ((defined(AMOEBA) || defined(_MINIX)) && defined(yywrap))
  #undef YY_INPUT
  #define YY_INPUT(buf,result,size) ((result) = doinput((buf),(size)))
  doinput (buf, size)
--- 45,51 ----
  
  extern int ParseError;
  
! #if (BSD >= 199103) || defined(linux) || ((defined(AMOEBA) || defined(_MINIX)) && defined(yywrap))
  #undef YY_INPUT
  #define YY_INPUT(buf,result,size) ((result) = doinput((buf),(size)))
  doinput (buf, size)
***************
*** 112,118 ****
  #endif
  int yylineno;
  
! #if !defined(__386BSD__) && !defined(linux)
  #undef unput
  #undef input
  #undef output
--- 113,119 ----
  #endif
  int yylineno;
  
! #if !(BSD >= 199103) && !defined(linux)
  #undef unput
  #undef input
  #undef output
diff -c mit/clients/xconsole/xconsole.c:2.0 mit/clients/xconsole/xconsole.c:2.1
*** mit/clients/xconsole/xconsole.c:2.0	Sat Mar 12 00:15:03 1994
--- mit/clients/xconsole/xconsole.c	Sat Mar 12 00:15:03 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/clients/xconsole/xconsole.c,v 2.0 1993/07/28 11:52:33 dawes Exp $
   * $XConsortium: xconsole.c,v 1.9 91/07/25 14:23:46 rws Exp $
   *   Versiun 1.9.1 - changes for /dev/osm and SVR4 - dwex@mtgzfs3.att.com
   *
--- 1,5 ----
  /*
!  * $XFree86: mit/clients/xconsole/xconsole.c,v 2.1 1993/12/10 14:25:10 dawes Exp $
   * $XConsortium: xconsole.c,v 1.9 91/07/25 14:23:46 rws Exp $
   *   Versiun 1.9.1 - changes for /dev/osm and SVR4 - dwex@mtgzfs3.att.com
   *
***************
*** 141,147 ****
  #include    <sys/stropts.h>		/* for I_PUSH */
  #endif
  
! #ifdef TIOCCONS
  #define USE_PTY
  static int  tty_fd, pty_fd;
  static char ttydev[64], ptydev[64];
--- 141,151 ----
  #include    <sys/stropts.h>		/* for I_PUSH */
  #endif
  
! #if defined(TIOCCONS) || defined(SOLX86)
! #ifdef SOLX86
! #include <sys/strredir.h>
! static int SolX86cons;
! #endif
  #define USE_PTY
  static int  tty_fd, pty_fd;
  static char ttydev[64], ptydev[64];
***************
*** 148,154 ****
  #endif
  #endif
  
! #if (defined(SYSV) || defined(SVR4)) && defined(SYSV386)
  #define USE_OSM
  #include <signal.h>
  static int child_pid;
--- 152,158 ----
  #endif
  #endif
  
! #if ((defined(SYSV) || defined(SVR4)) && defined(SYSV386)) && !defined(SOLX86)
  #define USE_OSM
  #include <signal.h>
  static int child_pid;
***************
*** 173,179 ****
  #ifdef USE_FILE
  	    	input = fopen (FILE_NAME, "r");
  #endif
! #ifdef USE_PTY
  		int	on = 1;
  
  		if (get_pty (&pty_fd, &tty_fd, ttydev, ptydev) == 0 &&
--- 177,183 ----
  #ifdef USE_FILE
  	    	input = fopen (FILE_NAME, "r");
  #endif
! #if defined(USE_PTY) && !defined(SOLX86)
  		int	on = 1;
  
  		if (get_pty (&pty_fd, &tty_fd, ttydev, ptydev) == 0 &&
***************
*** 182,187 ****
--- 186,200 ----
  		    input = fdopen (pty_fd, "r");
  		}
  #endif
+ #ifdef SOLX86
+ 		int 	on = 1;
+ 		if (get_pty(&pty_fd, &tty_fd, ttydev, ptydev) == 0)
+ 		{
+ 		    SolX86cons = open("/dev/console", O_RDONLY);
+ 		    input = fdopen(pty_fd, "r");
+ 		    ioctl(SolX86cons, SRIOCSREDIR, tty_fd);
+ 		}
+ #endif
  	    }
  #ifdef USE_OSM
  	    /* Don't have to be owner of /dev/console when using /dev/osm. */
***************
*** 234,239 ****
--- 247,255 ----
      }
  #ifdef USE_PTY
      close (tty_fd);
+ #ifdef SOLX86
+     close (SolX86cons);
+ #endif
  #endif
  }
  
diff -c mit/clients/xdm/chooser.c:2.4 mit/clients/xdm/chooser.c:2.5
*** mit/clients/xdm/chooser.c:2.4	Sat Mar 12 00:15:08 1994
--- mit/clients/xdm/chooser.c	Sat Mar 12 00:15:08 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/clients/xdm/chooser.c,v 2.4 1993/09/12 11:34:12 dawes Exp $
   * $XConsortium: chooser.c,v 1.10 91/08/25 10:49:47 keith Exp $
   *
   * Copyright 1990 Massachusetts Institute of Technology
--- 1,5 ----
  /*
!  * $XFree86: mit/clients/xdm/chooser.c,v 2.5 1994/02/10 21:21:03 dawes Exp $
   * $XConsortium: chooser.c,v 1.10 91/08/25 10:49:47 keith Exp $
   *
   * Copyright 1990 Massachusetts Institute of Technology
***************
*** 319,331 ****
  	    	    struct hostent  *hostent;
  		    char	    *host;
      	
! #ifdef __386BSD__
  	    	    hostent = gethostbyaddr ((const char *)hostAddr.data,
  					     hostAddr.length, AF_INET);
  #else
  	    	    hostent = gethostbyaddr (hostAddr.data,
  					     hostAddr.length, AF_INET);
! #endif /* __386BSD__ */
  	    	    if (hostent)
  	    	    {
  			XdmcpDisposeARRAY8 (hostname);
--- 319,331 ----
  	    	    struct hostent  *hostent;
  		    char	    *host;
      	
! #if (BSD >= 199103)
  	    	    hostent = gethostbyaddr ((const char *)hostAddr.data,
  					     hostAddr.length, AF_INET);
  #else
  	    	    hostent = gethostbyaddr (hostAddr.data,
  					     hostAddr.length, AF_INET);
! #endif /* (BSD >= 199103) */
  	    	    if (hostent)
  	    	    {
  			XdmcpDisposeARRAY8 (hostname);
diff -c mit/clients/xdm/dm.c:1.6 mit/clients/xdm/dm.c:2.1
*** mit/clients/xdm/dm.c:1.6	Sat Mar 12 00:15:09 1994
--- mit/clients/xdm/dm.c	Sat Mar 12 00:15:09 1994
***************
*** 1,7 ****
  /*
   * xdm - display manager daemon
   *
!  * $XFree86: mit/clients/xdm/dm.c,v 1.6 1993/03/25 08:59:28 dawes Exp $
   * $XConsortium: dm.c,v 1.64 91/07/31 16:55:01 keith Exp $
   *
   * Copyright 1988 Massachusetts Institute of Technology
--- 1,7 ----
  /*
   * xdm - display manager daemon
   *
!  * $XFree86: mit/clients/xdm/dm.c,v 2.1 1994/02/19 09:23:40 dawes Exp $
   * $XConsortium: dm.c,v 1.64 91/07/31 16:55:01 keith Exp $
   *
   * Copyright 1988 Massachusetts Institute of Technology
***************
*** 682,688 ****
      if (pidFile[0] != '\0') {
  	pidFd = open (pidFile, 2);
  	if (pidFd == -1 && errno == ENOENT)
! #ifndef __386BSD__
  	    pidFd = creat (pidFile, 0666);
  #else
  	    { /* workaround failure of lock after creat on 386bsd */
--- 682,688 ----
      if (pidFile[0] != '\0') {
  	pidFd = open (pidFile, 2);
  	if (pidFd == -1 && errno == ENOENT)
! #if !(BSD >= 199103)
  	    pidFd = creat (pidFile, 0666);
  #else
  	    { /* workaround failure of lock after creat on 386bsd */
diff -c mit/clients/xdm/dm.h:2.1 mit/clients/xdm/dm.h:2.2
*** mit/clients/xdm/dm.h:2.1	Sat Mar 12 00:15:10 1994
--- mit/clients/xdm/dm.h	Sat Mar 12 00:15:10 1994
***************
*** 1,7 ****
  /*
   * xdm - display manager daemon
   *
!  * $XFree86: mit/clients/xdm/dm.h,v 2.1 1993/09/09 06:55:51 dawes Exp $
   * $XConsortium: dm.h,v 1.51 91/09/19 16:28:35 keith Exp $
   *
   * Copyright 1988 Massachusetts Institute of Technology
--- 1,7 ----
  /*
   * xdm - display manager daemon
   *
!  * $XFree86: mit/clients/xdm/dm.h,v 2.2 1994/02/10 21:21:07 dawes Exp $
   * $XConsortium: dm.h,v 1.51 91/09/19 16:28:35 keith Exp $
   *
   * Copyright 1988 Massachusetts Institute of Technology
***************
*** 241,247 ****
  };
  
  /* setgroups is not covered by POSIX, arg type varies */
! #if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__386BSD__)
  #define GID_T gid_t
  #else
  #define GID_T int
--- 241,247 ----
  };
  
  /* setgroups is not covered by POSIX, arg type varies */
! #if defined(SYSV) || defined(SVR4) || defined(linux) || (BSD >= 199103)
  #define GID_T gid_t
  #else
  #define GID_T int
***************
*** 323,329 ****
  #define SIGVAL void
  #endif
  
! #if defined(X_NOT_POSIX) || defined(__386BSD__)
  #ifdef SYSV
  #define SIGNALS_RESET_WHEN_CAUGHT
  #define UNRELIABLE_SIGNALS
--- 323,329 ----
  #define SIGVAL void
  #endif
  
! #if defined(X_NOT_POSIX) || (BSD >= 199103)
  #ifdef SYSV
  #define SIGNALS_RESET_WHEN_CAUGHT
  #define UNRELIABLE_SIGNALS
diff -c mit/clients/xdm/server.c:1.3 mit/clients/xdm/server.c:2.0
*** mit/clients/xdm/server.c:1.3	Sat Mar 12 00:15:11 1994
--- mit/clients/xdm/server.c	Sat Mar 12 00:15:11 1994
***************
*** 34,39 ****
--- 34,43 ----
  extern int  errno;
  static serverPause ();
  
+ #ifndef X_NO_STRERROR
+ #include <string.h>
+ #endif
+ 
  static Display	*dpy;
  
  /* ARGSUSED */
***************
*** 48,53 ****
--- 52,58 ----
      ++receivedUsr1;
  }
  
+ #ifdef X_NO_STRERROR
  static char *_SysErrorMsg (n)
      int n;
  {
***************
*** 57,62 ****
--- 62,70 ----
  
      return (s ? s : "no such error");
  }
+ #else
+ #define _SysErrorMsg(n) strerror(n)
+ #endif
  
  StartServerOnce (d)
  struct display	*d;
diff -c mit/clients/xdm/session.c:2.0 mit/clients/xdm/session.c:2.2
*** mit/clients/xdm/session.c:2.0	Sat Mar 12 00:15:11 1994
--- mit/clients/xdm/session.c	Sat Mar 12 00:15:12 1994
***************
*** 37,42 ****
--- 37,46 ----
  # include <rpc/key_prot.h>
  #endif
  
+ #ifndef X_NO_STRERROR
+ #include <string.h>
+ #endif
+ 
  extern int  errno;
  extern char **setEnv();
  
***************
*** 90,99 ****
--- 94,107 ----
  IOErrorHandler (dpy)
      Display *dpy;
  {
+ #ifdef X_NO_STRERROR
      extern char *sys_errlist[];
      extern int sys_nerr;
      char *s = ((errno >= 0 && errno < sys_nerr) ? sys_errlist[errno]
  						: "unknown error");
+ #else
+     char *s = strerror(errno);
+ #endif
  
      LogError("fatal IO error %d (%s)\n", errno, s);
      exit(RESERVER_DISPLAY);
***************
*** 405,419 ****
  #else /* AIXV3 */
  #ifdef NGROUPS_MAX
  	setgid (verify->groups[0]);
! #ifdef __386BSD__
  	setgroups (verify->ngroups, (const int *)verify->groups);
  #else
  	setgroups (verify->ngroups, verify->groups);
! #endif /* __386BSD__ */
  #else
  	setgid (verify->gid);
  #endif
! #ifdef __386BSD__
  	setlogin(name);
  #endif
  	setuid (verify->uid);
--- 413,427 ----
  #else /* AIXV3 */
  #ifdef NGROUPS_MAX
  	setgid (verify->groups[0]);
! #if (BSD >= 199103)
  	setgroups (verify->ngroups, (const int *)verify->groups);
  #else
  	setgroups (verify->ngroups, verify->groups);
! #endif /* (BSD >= 199103) */
  #else
  	setgid (verify->gid);
  #endif
! #if (BSD >= 199103)
  	setlogin(name);
  #endif
  	setuid (verify->uid);
diff -c mit/clients/xdm/xdmshell.c:1.9 mit/clients/xdm/xdmshell.c:2.0
*** mit/clients/xdm/xdmshell.c:1.9	Sat Mar 12 00:15:12 1994
--- mit/clients/xdm/xdmshell.c	Sat Mar 12 00:15:12 1994
***************
*** 1,4 ****
! /* $XFree86: mit/clients/xdm/xdmshell.c,v 1.9 1993/05/05 13:43:08 dawes Exp $ */
  /*
   * xdmshell - simple program for running xdm from login
   *
--- 1,4 ----
! /* $XFree86: mit/clients/xdm/xdmshell.c,v 2.0 1993/12/18 11:40:53 dawes Exp $ */
  /*
   * xdmshell - simple program for running xdm from login
   *
***************
*** 36,45 ****
  #include "dm.h"
  #include <errno.h>
  extern int errno;
! #ifndef linux
  extern int sys_nerr;
  extern char *sys_errlist[];
! #endif /* !linux */
  
  #ifdef macII
  #define ON_CONSOLE_ONLY
--- 36,47 ----
  #include "dm.h"
  #include <errno.h>
  extern int errno;
! #ifdef X_NO_STRERROR
  extern int sys_nerr;
  extern char *sys_errlist[];
! #else
! #include <string.h>
! #endif
  
  #ifdef macII
  #define ON_CONSOLE_ONLY
***************
*** 62,67 ****
--- 64,70 ----
  
  char *ProgramName;
  
+ #ifdef X_NO_STRERROR
  static char *SysErrorMsg (n)
      int n;
  {
***************
*** 68,73 ****
--- 71,79 ----
      char *s = (n > 0 && n < sys_nerr) ? sys_errlist[n] : "unknown";
      return (s ? s : "null system error");
  }
+ #else
+ #define SysErrorMsg(n) strerror(n)
+ #endif
  
  
  static int exec_args (filename, args)
diff -c mit/clients/xinit/startx.cpp:2.0 mit/clients/xinit/startx.cpp:2.1
*** mit/clients/xinit/startx.cpp:2.0	Sat Mar 12 00:15:19 1994
--- mit/clients/xinit/startx.cpp	Sat Mar 12 00:15:19 1994
***************
*** 1,6 ****
  XCOMM!/bin/sh
  
! XCOMM $XFree86: mit/clients/xinit/startx.cpp,v 2.0 1993/10/13 15:49:15 dawes Exp $
  XCOMM $XConsortium: startx.cpp,v 1.4 91/08/22 11:41:29 rws Exp $
  XCOMM 
  XCOMM This is just a sample implementation of a slightly less primitive 
--- 1,6 ----
  XCOMM!/bin/sh
  
! XCOMM $XFree86: mit/clients/xinit/startx.cpp,v 2.1 1994/02/10 21:21:19 dawes Exp $
  XCOMM $XConsortium: startx.cpp,v 1.4 91/08/22 11:41:29 rws Exp $
  XCOMM 
  XCOMM This is just a sample implementation of a slightly less primitive 
***************
*** 88,93 ****
  kbd_mode -a
  #endif
  
! #if defined(__386BSD__) && !defined(__bsdi__)
  kbd_mode -a
  #endif
--- 88,93 ----
  kbd_mode -a
  #endif
  
! #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__386BSD__)
  kbd_mode -a
  #endif
diff -c mit/clients/xinit/xinit.c:1.12 mit/clients/xinit/xinit.c:2.4
*** mit/clients/xinit/xinit.c:1.12	Sat Mar 12 00:15:20 1994
--- mit/clients/xinit/xinit.c	Sat Mar 12 00:15:20 1994
***************
*** 1,4 ****
! /* $XFree86: mit/clients/xinit/xinit.c,v 1.12 1993/05/05 13:43:18 dawes Exp $ */
  /* $XConsortium: xinit.c,v 11.54 91/12/23 17:26:08 gildea Exp $ */
  
  /* Copyright    Massachusetts Institute of Technology    1986	*/
--- 1,4 ----
! /* $XFree86: mit/clients/xinit/xinit.c,v 2.4 1994/03/01 11:59:58 dawes Exp $ */
  /* $XConsortium: xinit.c,v 11.54 91/12/23 17:26:08 gildea Exp $ */
  
  /* Copyright    Massachusetts Institute of Technology    1986	*/
***************
*** 40,46 ****
  #define SHELL "sh"
  #endif
  
! #if (defined(SYSV) && !defined(hpux)) || defined(_MINIX) || defined(macII) || defined(__OSF__)
  #define vfork() fork()
  #endif
  
--- 40,46 ----
  #define SHELL "sh"
  #endif
  
! #if (defined(SYSV) && !defined(hpux)) || defined(_MINIX) || defined(macII) || defined(__OSF__) || defined(SOLX86)
  #define vfork() fork()
  #endif
  
***************
*** 83,88 ****
--- 83,93 ----
  #ifdef XFREE86
      "XF86_SVGA   SVGA colour display on i386 PC",
      "XF86_Mono   monochrome display on i386 PC",
+     "XF86_VGA16  16 colour VGA display on i386 PC",
+     "XF86_S3     S3 colour display on i386 PC",
+     "XF86_8514   IBM 8514/A colour display on i386 PC",
+     "XF86_Mach8  ATI Mach8 colour display on i386 PC",
+     "XF86_Mach32 ATI Mach32 colour display on i386 PC",
  #endif
      NULL};
  
***************
*** 112,118 ****
  char *program;
  Display *xd;			/* server connection */
  #ifndef SYSV
! #if defined(SVR4) || defined(_POSIX_SOURCE) || defined(__386BSD__)
  int status;
  #else
  union wait	status;
--- 117,123 ----
  char *program;
  Display *xd;			/* server connection */
  #ifndef SYSV
! #if defined(SVR4) || defined(_POSIX_SOURCE) || (BSD >= 199103)
  int status;
  #else
  union wait	status;
***************
*** 389,395 ****
  			break;
  		alarm(0);
  #else /* SYSV */
! #if defined(SVR4) || defined(_POSIX_SOURCE) || defined(__386BSD__)
  		if ((pidfound = waitpid(serverpid, &status, WNOHANG)) == serverpid)
  			break;
  #else
--- 394,400 ----
  			break;
  		alarm(0);
  #else /* SYSV */
! #if defined(SVR4) || defined(_POSIX_SOURCE) || (BSD >= 199103)
  		if ((pidfound = waitpid(serverpid, &status, WNOHANG)) == serverpid)
  			break;
  #else
***************
*** 409,415 ****
  		if (++i > timeout)
  			break;
  	}
! 	if ( i > 0 ) fputc( '\n', stderr );     /* tidy up after message */
  	laststring = string;
  	return( serverpid != pidfound );
  }
--- 414,423 ----
  		if (++i > timeout)
  			break;
  	}
! #ifdef linux
! 	if (timeout)
! #endif
! 	  if ( i > 0 ) fputc( '\n', stderr );     /* tidy up after message */
  	laststring = string;
  	return( serverpid != pidfound );
  }
***************
*** 628,634 ****
  	exit(ERR_EXIT);
  }
  
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
  #include <string.h>
  #else
  extern char	*sys_errlist[];
--- 636,642 ----
  	exit(ERR_EXIT);
  }
  
! #ifndef X_NO_STRERROR
  #include <string.h>
  #else
  extern char	*sys_errlist[];
***************
*** 638,644 ****
  	char	*fmt;
  {
  	fprintf(stderr, "%s:  ", program);
! #if defined(__STDC__) && !(defined(SYSV) || defined(SVR4))
  	fprintf (stderr, "%s (errno %d):  ", strerror(errno), errno);
  #else
  	if (errno > 0 && errno < sys_nerr)
--- 646,652 ----
  	char	*fmt;
  {
  	fprintf(stderr, "%s:  ", program);
! #ifndef X_NO_STRERROR
  	fprintf (stderr, "%s (errno %d):  ", strerror(errno), errno);
  #else
  	if (errno > 0 && errno < sys_nerr)
diff -c mit/clients/xload/get_load.c:2.3 mit/clients/xload/get_load.c:2.5
*** mit/clients/xload/get_load.c:2.3	Sat Mar 12 00:15:23 1994
--- mit/clients/xload/get_load.c	Sat Mar 12 00:15:23 1994
***************
*** 1,7 ****
  /*
   * get_load - get system load
   *
!  * $XFree86: mit/clients/xload/get_load.c,v 2.3 1993/10/16 17:27:45 dawes Exp $
   * $XConsortium: get_load.c,v 1.26 91/07/25 14:20:25 rws Exp $
   *
   * Copyright 1989 Massachusetts Institute of Technology
--- 1,7 ----
  /*
   * get_load - get system load
   *
!  * $XFree86: mit/clients/xload/get_load.c,v 2.5 1994/02/10 21:21:27 dawes Exp $
   * $XConsortium: get_load.c,v 1.26 91/07/25 14:20:25 rws Exp $
   *
   * Copyright 1989 Massachusetts Institute of Technology
***************
*** 91,100 ****
  #include <sys/param.h>
  #endif /* hcx */
  
- #ifdef __386BSD__
- #include <sys/param.h>
- #endif /* __386BSD__ */
- 
  #if defined(UTEK) || defined(alliant) || (defined(MOTOROLA) && defined(SVR4))
  #define FSCALE	100.0
  #endif
--- 91,96 ----
***************
*** 488,494 ****
   */
  #ifndef KERNEL_FILE
  # ifdef SVR4
! #  define KERNEL_FILE "/stand/unix"
  # else
  #  ifdef SYSV
  #   define KERNEL_FILE "/unix"
--- 484,494 ----
   */
  #ifndef KERNEL_FILE
  # ifdef SVR4
! #  ifdef SOLX86
! #    define KERNEL_FILE "/kernel/unix"
! #  else
! #    define KERNEL_FILE "/stand/unix"
! #  endif
  # else
  #  ifdef SYSV
  #   define KERNEL_FILE "/unix"
***************
*** 515,523 ****
  
  
  #ifndef KERNEL_LOAD_VARIABLE
! #    ifdef __386BSD__
  #        define KERNEL_LOAD_VARIABLE "_averunnable"
! #    endif /* __386BSD__ */
  
  #    ifdef alliant
  #        define KERNEL_LOAD_VARIABLE "_Loadavg"
--- 515,523 ----
  
  
  #ifndef KERNEL_LOAD_VARIABLE
! #    if (BSD >= 199103)
  #        define KERNEL_LOAD_VARIABLE "_averunnable"
! #    endif /* BSD >= 199103 */
  
  #    ifdef alliant
  #        define KERNEL_LOAD_VARIABLE "_Loadavg"
***************
*** 633,639 ****
  	nl[i].n_value = (int)nl[i].n_value - v.v_kvoffset;
      }
  #else /* not macII */
! #if (!defined(SVR4) || !defined(__STDC__)) && !defined(sgi) && !defined(MOTOROLA) && !defined(__386BSD__) && !defined(_MINIX)
      extern void nlist();
  #endif
  
--- 633,639 ----
  	nl[i].n_value = (int)nl[i].n_value - v.v_kvoffset;
      }
  #else /* not macII */
! #if (!defined(SVR4) || !defined(__STDC__)) && !defined(sgi) && !defined(MOTOROLA) && !(BSD >= 199103) && !defined(_MINIX)
      extern void nlist();
  #endif
  
***************
*** 685,691 ****
  	(void) lseek(kmem, loadavg_seek, 0);
  #endif
  
! #if defined(sun) || defined (UTEK) || defined(sequent) || defined(alliant) || defined(SVR4) || defined(sgi) || defined(hcx) || defined(__386BSD__)
  	{
  		long temp;
  		(void) read(kmem, (char *)&temp, sizeof(long));
--- 685,691 ----
  	(void) lseek(kmem, loadavg_seek, 0);
  #endif
  
! #if defined(sun) || defined (UTEK) || defined(sequent) || defined(alliant) || defined(SVR4) || defined(sgi) || defined(hcx) || (BSD >= 199103)
  	{
  		long temp;
  		(void) read(kmem, (char *)&temp, sizeof(long));
diff -c mit/clients/xmag/xmag.c:1.1.1.1 mit/clients/xmag/xmag.c:2.0
*** mit/clients/xmag/xmag.c:1.1.1.1	Sat Mar 12 00:15:31 1994
--- mit/clients/xmag/xmag.c	Sat Mar 12 00:15:31 1994
***************
*** 1,3 ****
--- 1,4 ----
+ /* $XFree86: mit/clients/xmag/xmag.c,v 2.0 1993/12/10 14:30:40 dawes Exp $ */
  /* $XConsortium: xmag.c,v 1.22 91/09/12 17:24:04 rws Exp $ */
  /*
   * Copyright 1991 Massachusetts Institute of Technology
***************
*** 888,894 ****
  
  
  
! static Widget pane1, pane2, pane3, cclose, replace, new, select, paste, label;
  
  /*
   * PopupNewScale() -- Create and popup a new scale composite.
--- 889,895 ----
  
  
  
! static Widget pane1, pane2, pane3, cclose, replace, new, w_select, paste, label;
  
  /*
   * PopupNewScale() -- Create and popup a new scale composite.
***************
*** 917,925 ****
    new = XtCreateManagedWidget("new", commandWidgetClass, pane2,
  			      (Arg *) NULL, 0);
    XtAddCallback(new, XtNcallback, NewCB, (XtPointer)NULL);
!   select = XtCreateManagedWidget("select", commandWidgetClass, pane2,
  			      (Arg *) NULL, 0);
!   XtAddCallback(select, XtNcallback, SelectCB, (XtPointer)data);
    paste = XtCreateManagedWidget("paste", commandWidgetClass, pane2,
  			      (Arg *) NULL, 0);
    XtAddCallback(paste, XtNcallback, PasteCB, (XtPointer)data);
--- 918,926 ----
    new = XtCreateManagedWidget("new", commandWidgetClass, pane2,
  			      (Arg *) NULL, 0);
    XtAddCallback(new, XtNcallback, NewCB, (XtPointer)NULL);
!   w_select = XtCreateManagedWidget("select", commandWidgetClass, pane2,
  			      (Arg *) NULL, 0);
!   XtAddCallback(w_select, XtNcallback, SelectCB, (XtPointer)data);
    paste = XtCreateManagedWidget("paste", commandWidgetClass, pane2,
  			      (Arg *) NULL, 0);
    XtAddCallback(paste, XtNcallback, PasteCB, (XtPointer)data);
diff -c mit/clients/xman/ScrollByL.c:1.6 mit/clients/xman/ScrollByL.c:2.0
*** mit/clients/xman/ScrollByL.c:1.6	Sat Mar 12 00:15:36 1994
--- mit/clients/xman/ScrollByL.c	Sat Mar 12 00:15:36 1994
***************
*** 1,7 ****
  /*
   * xman - X window system manual page display program.
   *
!  * $XFree86: mit/clients/xman/ScrollByL.c,v 1.6 1993/03/27 08:42:42 dawes Exp $
   * $XConsortium: ScrollByL.c,v 1.27 91/07/26 18:30:47 dave Exp $
   *
   * Copyright 1987, 1988 Massachusetts Institute of Technology
--- 1,7 ----
  /*
   * xman - X window system manual page display program.
   *
!  * $XFree86: mit/clients/xman/ScrollByL.c,v 2.0 1993/12/23 13:22:03 dawes Exp $
   * $XConsortium: ScrollByL.c,v 1.27 91/07/26 18:30:47 dave Exp $
   *
   * Copyright 1987, 1988 Massachusetts Institute of Technology
***************
*** 1071,1083 ****
  
      case BACKSPACE:		/* Backspacing for nroff bolding */
        if (c[-1] == c[1] && c[1] != BACKSPACE) {	/* overstriking one char */
! 	bufp--;		/* Zap 1st instance of char to bolden */
! 	if (bufp > buf) {
  	  x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
  			   WHICH(italicflag, FALSE));
  	  h_col += bufp - buf;
- 	  bufp = buf;
  	}
  	*bufp++ = c[1];
  	x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, BOLD);
  	h_col += bufp - buf;
--- 1071,1083 ----
  
      case BACKSPACE:		/* Backspacing for nroff bolding */
        if (c[-1] == c[1] && c[1] != BACKSPACE) {	/* overstriking one char */
! 	if (bufp>buf) {
! 	  bufp--;		/* Zap 1st instance of char to bolden */
  	  x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
  			   WHICH(italicflag, FALSE));
  	  h_col += bufp - buf;
  	}
+ 	bufp = buf;
  	*bufp++ = c[1];
  	x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf, BOLD);
  	h_col += bufp - buf;
***************
*** 1086,1092 ****
  
  	/*
  	 *     Nroff bolding looks like:
! 	 *	 	     C\bC\bC\bCN...
  	 * c points to ----^      ^
  	 * it needs to point to --^
  	 */
--- 1086,1092 ----
  
  	/*
  	 *     Nroff bolding looks like:
! 	 *               C\bC\bC\bCN...
  	 * c points to ----^      ^
  	 * it needs to point to --^
  	 */
***************
*** 1100,1109 ****
  				/* If we run into a bullet, print out */
  				/* everything that's accumulated to this */
  				/* point, then the bullet, then resume. */
! 	  bufp--;
! 	  x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 			   WHICH(italicflag, FALSE));
! 	  h_col += bufp - buf;
  	  bufp = buf;
  	  *bufp = (char)183;
  	  x_loc = DumpText(w, x_loc, y_loc, buf, 1, SYMBOL);
--- 1100,1111 ----
  				/* If we run into a bullet, print out */
  				/* everything that's accumulated to this */
  				/* point, then the bullet, then resume. */
! 	  if (bufp>buf) {
! 	    bufp--;
! 	    x_loc = DumpText(w, x_loc, y_loc, buf, bufp - buf,
! 			     WHICH(italicflag, FALSE));
! 	    h_col += bufp - buf;
! 	  }
  	  bufp = buf;
  	  *bufp = (char)183;
  	  x_loc = DumpText(w, x_loc, y_loc, buf, 1, SYMBOL);
***************
*** 1111,1117 ****
  	  c++;
  	}
  	else {		/* 'real' backspace - back up output ptr */
! 	  bufp--;
  	}
        }
        break;
--- 1113,1120 ----
  	  c++;
  	}
  	else {		/* 'real' backspace - back up output ptr */
! 	  if (bufp>buf)
! 	    bufp--;
  	}
        }
        break;
diff -c mit/clients/xman/misc.c:2.0 mit/clients/xman/misc.c:2.1
*** mit/clients/xman/misc.c:2.0	Sat Mar 12 00:15:37 1994
--- mit/clients/xman/misc.c	Sat Mar 12 00:15:37 1994
***************
*** 1,7 ****
  /*
   * xman - X window system manual page display program.
   *
!  * $XFree86: mit/clients/xman/misc.c,v 2.0 1993/07/28 11:52:57 dawes Exp $
   * $XConsortium: misc.c,v 1.29 91/09/03 18:21:49 dave Exp $
   *
   * Copyright 1987, 1988 Massachusetts Institute of Technology
--- 1,7 ----
  /*
   * xman - X window system manual page display program.
   *
!  * $XFree86: mit/clients/xman/misc.c,v 2.1 1994/02/10 21:21:40 dawes Exp $
   * $XConsortium: misc.c,v 1.29 91/09/03 18:21:49 dave Exp $
   *
   * Copyright 1987, 1988 Massachusetts Institute of Technology
***************
*** 22,28 ****
--- 22,30 ----
  
  #include "globals.h"
  #include "vendor.h"
+ #if 0
  #include <X11/Xos.h> 		/* sys/types.h and unistd.h included in here */
+ #endif
  #include <sys/stat.h>
  #include <errno.h>
  #include <X11/Xaw/Dialog.h>
diff -c mit/clients/xman/vendor.h:2.1 mit/clients/xman/vendor.h:2.2
*** mit/clients/xman/vendor.h:2.1	Sat Mar 12 00:15:38 1994
--- mit/clients/xman/vendor.h	Sat Mar 12 00:15:38 1994
***************
*** 1,5 ****
  /*
!  * $XFree86: mit/clients/xman/vendor.h,v 2.1 1993/07/28 11:53:01 dawes Exp $
   * $XConsortium: vendor.h,v 1.7 91/08/20 14:27:57 gildea Exp $
   *
   * Copyright 1991 Massachusetts Institute of Technology
--- 1,5 ----
  /*
!  * $XFree86: mit/clients/xman/vendor.h,v 2.2 1994/02/10 21:21:43 dawes Exp $
   * $XConsortium: vendor.h,v 1.7 91/08/20 14:27:57 gildea Exp $
   *
   * Copyright 1991 Massachusetts Institute of Technology
***************
*** 17,22 ****
--- 17,24 ----
  
  /* Vendor-specific definitions */
  
+ #include <X11/Xos.h>
+ 
  #define SUFFIX "suffix"
  #define FOLD "fold"
  #define FOLDSUFFIX "foldsuffix"
***************
*** 36,46 ****
  #  define SEARCHDIR  MAN
  #endif
  
! #if ( defined(sgi) || defined(SYSV386) || defined(__386BSD__) || defined(linux) )
  # define SEARCHOTHER CAT
  #endif
  
! #if defined(__386BSD__)
  # define MANCONF "/etc/man.conf"
  #endif
  
--- 38,48 ----
  #  define SEARCHDIR  MAN
  #endif
  
! #if ( defined(sgi) || defined(SYSV386) || (BSD >= 199103) || defined(linux) )
  # define SEARCHOTHER CAT
  #endif
  
! #if (BSD >= 199103)
  # define MANCONF "/etc/man.conf"
  #endif
  
***************
*** 55,63 ****
  #ifdef macII
  #  define SYSMANPATH "/usr/catman/u_man:/usr/catman/a_man"
  #endif /* macII */
! #if defined(SVR4) || defined(__386BSD__)
  #  define SYSMANPATH "/usr/share/man"
! #endif /* SVR4 || __386BSD__ */
  #ifdef hcx
  #  define SYSMANPATH "/usr/catman/local_man:/usr/catman/u_man:/usr/catman/a_man:/usr/catman/p_man:/usr/catman/ada_man"
  #endif /* hcx */
--- 57,65 ----
  #ifdef macII
  #  define SYSMANPATH "/usr/catman/u_man:/usr/catman/a_man"
  #endif /* macII */
! #if defined(SVR4) || (BSD >= 199103)
  #  define SYSMANPATH "/usr/share/man"
! #endif /* SVR4 || (BSD >= 199103) */
  #ifdef hcx
  #  define SYSMANPATH "/usr/catman/local_man:/usr/catman/u_man:/usr/catman/a_man:/usr/catman/p_man:/usr/catman/ada_man"
  #endif /* hcx */
***************
*** 128,134 ****
  #if defined( ultrix )
  #  define FORMAT "| nroff -man"             /* The format command. */
  #else
! #  ifdef __386BSD__
  #    define FORMAT "| eqn | tbl | nroff -man"
  #  else
  #    ifdef linux
--- 130,136 ----
  #if defined( ultrix )
  #  define FORMAT "| nroff -man"             /* The format command. */
  #else
! #  if (BSD >= 199103)
  #    define FORMAT "| eqn | tbl | nroff -man"
  #  else
  #    ifdef linux
diff -c mit/clients/xmh/command.c:1.4 mit/clients/xmh/command.c:2.0
*** mit/clients/xmh/command.c:1.4	Sat Mar 12 00:15:42 1994
--- mit/clients/xmh/command.c	Sat Mar 12 00:15:42 1994
***************
*** 1,4 ****
! /* $XFree86: mit/clients/xmh/command.c,v 1.4 1993/05/05 13:45:20 dawes Exp $ */
  /* $XConsortium: command.c,v 2.44 91/07/16 20:33:52 converse Exp $ */
  
  /*
--- 1,4 ----
! /* $XFree86: mit/clients/xmh/command.c,v 2.0 1993/12/18 11:41:23 dawes Exp $ */
  /* $XConsortium: command.c,v 2.44 91/07/16 20:33:52 converse Exp $ */
  
  /*
***************
*** 46,51 ****
--- 46,55 ----
  #endif
  #endif
  
+ #ifndef X_NO_STRERROR
+ #include <string.h>
+ #endif
+ 
  /* number of user input events to queue before malloc */
  #define TYPEAHEADSIZE 20
  
***************
*** 85,95 ****
  static void SystemError(text)
      char* text;
  {
      extern int sys_nerr;
      extern char* sys_errlist[];
      char msg[BUFSIZ];
!     sprintf( msg, "%s; errno = %d %s", text, errno, 
! 	     (errno < sys_nerr) ? sys_errlist[errno] : NULL );
      XtWarning( msg );
  }
  
--- 89,107 ----
  static void SystemError(text)
      char* text;
  {
+ #ifdef X_NO_STRERROR
      extern int sys_nerr;
      extern char* sys_errlist[];
+ #endif
+     char *s;
      char msg[BUFSIZ];
! 
! #ifdef X_NO_STRERROR
!     s = (errno < sys_nerr) ? sys_errlist[errno] : "";
! #else
!     s = strerror(errno);
! #endif
!     sprintf( msg, "%s; errno = %d %s", text, errno, s);
      XtWarning( msg );
  }
  
diff -c mit/clients/xterm/Imakefile:2.1 mit/clients/xterm/Imakefile:2.2
*** mit/clients/xterm/Imakefile:2.1	Sat Mar 12 00:15:52 1994
--- mit/clients/xterm/Imakefile	Sat Mar 12 00:15:52 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/clients/xterm/Imakefile,v 2.1 1993/10/03 10:22:16 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.56 92/03/11 17:35:22 gildea Exp $
  XCOMM
  XCOMM                         Attention xterm porters
--- 1,4 ----
! XCOMM $XFree86: mit/clients/xterm/Imakefile,v 2.2 1993/11/13 05:13:21 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.56 92/03/11 17:35:22 gildea Exp $
  XCOMM
  XCOMM                         Attention xterm porters
***************
*** 37,43 ****
     MAIN_DEFINES = $(UTMPDEF) $(TTYGROUPDEF) $(PUCCPTYDDEF) \
  		  -DOSMAJORVERSION=$(OSMAJORVERSION) \
  		  -DOSMINORVERSION=$(OSMINORVERSION)
!    MISC_DEFINES = $(XTERMLOGFLAGS)
  
            SRCS1 = button.c charproc.c cursor.c data.c input.c \
  		  main.c menu.c misc.c screen.c scrollbar.c tabs.c \
--- 37,44 ----
     MAIN_DEFINES = $(UTMPDEF) $(TTYGROUPDEF) $(PUCCPTYDDEF) \
  		  -DOSMAJORVERSION=$(OSMAJORVERSION) \
  		  -DOSMINORVERSION=$(OSMINORVERSION)
!    MISC_DEFINES = 
!         DEFINES = $(XTERMLOGFLAGS)
  
            SRCS1 = button.c charproc.c cursor.c data.c input.c \
  		  main.c menu.c misc.c screen.c scrollbar.c tabs.c \
diff -c mit/clients/xterm/Tekproc.c:1.7 mit/clients/xterm/Tekproc.c:2.1
*** mit/clients/xterm/Tekproc.c:1.7	Sat Mar 12 00:15:53 1994
--- mit/clients/xterm/Tekproc.c	Sat Mar 12 00:15:53 1994
***************
*** 1,6 ****
  /*
!  * $XFree86: mit/clients/xterm/Tekproc.c,v 1.7 1993/03/21 06:48:35 dawes Exp $
!  * $XConsortium: Tekproc.c,v 1.107 91/06/25 19:49:48 gildea Exp $
   *
   * Warning, there be crufty dragons here.
   */
--- 1,6 ----
  /*
!  * $XFree86: mit/clients/xterm/Tekproc.c,v 2.1 1993/11/13 04:22:55 dawes Exp $
!  * $XConsortium: Tekproc.c,v 1.112 93/02/25 17:17:40 gildea Exp $
   *
   * Warning, there be crufty dragons here.
   */
***************
*** 51,56 ****
--- 51,57 ----
  #include <time.h>
  #include <assert.h>
  #endif /* _MINIX */
+ #include <signal.h>
  
  /*
   * Check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
***************
*** 79,85 ****
  
  #define TekColormap DefaultColormap( screen->display, \
  				    DefaultScreen(screen->display) )
! #define DefaultGCID DefaultGC(screen->display, DefaultScreen(screen->display))->gid
  
  /* Tek defines */
  
--- 80,86 ----
  
  #define TekColormap DefaultColormap( screen->display, \
  				    DefaultScreen(screen->display) )
! #define DefaultGCID XGContextFromGC(DefaultGC(screen->display, DefaultScreen(screen->display)))
  
  /* Tek defines */
  
***************
*** 193,199 ****
--- 194,202 ----
      /* menu actions */
      { "allow-send-events",	HandleAllowSends },
      { "set-visual-bell",	HandleSetVisualBell },
+ #ifdef ALLOWLOGGING
      { "set-logging",		HandleLogging },
+ #endif
      { "redraw",			HandleRedraw },
      { "send-signal",		HandleSendSignal },
      { "quit",			HandleQuit },
***************
*** 340,347 ****
  	register int c, x, y;
  	char ch;
  
! 	for( ; ; )
! 		switch(Tparsestate[c = input()]) {
  		 case CASE_REPORT:
  			/* report address */
  			if(screen->TekGIN) {
--- 343,351 ----
  	register int c, x, y;
  	char ch;
  
! 	for( ; ; ) {
! 	    c = input();
! 	    switch(Tparsestate[c]) {
  		 case CASE_REPORT:
  			/* report address */
  			if(screen->TekGIN) {
***************
*** 361,370 ****
--- 365,376 ----
  			/* special return to vt102 mode */
  			Tparsestate = curstate;
  			TekRecord->ptr[-1] = NAK; /* remove from recording */
+ #ifdef ALLOWLOGGING
  			if(screen->logging) {
  				FlushLog(screen);
  				screen->logstart = buffer;
  			}
+ #endif
  			return;
  
  		 case CASE_SPT_STATE:
***************
*** 631,636 ****
--- 637,643 ----
  			Tparsestate = curstate;
  			break;
  		}
+ 	}
  }			
  
  static int rcnt;
***************
*** 680,689 ****
  			/* XXX resolve polling since it wastes CPU cycles */
  			if ((Tbcnt = cb_full(screen->tty_outq)) > 0) {
  #endif /* AMOEBA */
  				if(screen->logging)
  					FlushLog(screen);
  #ifndef AMOEBA
! 				Tbcnt = read(screen->respond, Tbptr = Tbuffer, BUF_SIZE);
  #else
  				Tbptr = Tbuffer;
  				if ((Tbcnt = cb_gets(screen->tty_outq, Tbptr, Tbcnt, BUF_SIZE)) == 0) {
--- 687,698 ----
  			/* XXX resolve polling since it wastes CPU cycles */
  			if ((Tbcnt = cb_full(screen->tty_outq)) > 0) {
  #endif /* AMOEBA */
+ #ifdef ALLOWLOGGING
  				if(screen->logging)
  					FlushLog(screen);
+ #endif
  #ifndef AMOEBA
! 				Tbcnt = read(screen->respond, (char *)(Tbptr = Tbuffer), BUF_SIZE);
  #else
  				Tbptr = Tbuffer;
  				if ((Tbcnt = cb_gets(screen->tty_outq, Tbptr, Tbcnt, BUF_SIZE)) == 0) {
***************
*** 1376,1383 ****
   * The following is called the create the tekWidget
   */
  
! static void TekInitialize(request, new)
      Widget request, new;
  {
      /* look for focus related events on the shell, because we need
       * to care about the shell's border being part of our focus.
--- 1385,1394 ----
   * The following is called the create the tekWidget
   */
  
! static void TekInitialize(request, new, args, num_args)
      Widget request, new;
+     ArgList args;
+     Cardinal *num_args;
  {
      /* look for focus related events on the shell, because we need
       * to care about the shell's border being part of our focus.
***************
*** 1775,1790 ****
  }
  
  
  /* write copy of screen to a file */
  
  TekCopy()
  {
- 	register TekLink *Tp;
- 	register int tekcopyfd;
  	register TScreen *screen = &term->screen;
  	register struct tm *tp;
  	long l;
  	char buf[32];
  
  	time(&l);
  	tp = localtime(&l);
--- 1786,1810 ----
  }
  
  
+ #ifndef X_NOT_POSIX
+ #define HAS_WAITPID
+ #endif
+ 
  /* write copy of screen to a file */
  
  TekCopy()
  {
  	register TScreen *screen = &term->screen;
  	register struct tm *tp;
  	long l;
  	char buf[32];
+ 	int waited;
+ 	int pid;
+ #ifndef HAS_WAITPID
+ 	int (*chldfunc)();
+ 
+ 	chldfunc = signal(SIGCHLD, SIG_DFL);
+ #endif
  
  	time(&l);
  	tp = localtime(&l);
***************
*** 1799,1819 ****
  		Bell();
  		return;
  	}
! 	if((tekcopyfd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0644)) < 0) {
! 		Bell();
! 		return;
! 	}
! 	chown(buf, screen->uid, screen->gid);
! 	sprintf(buf, "\033%c\033%c", screen->page.fontsize + '8',
! 	 screen->page.linetype + '`');
! 	write(tekcopyfd, buf, 4);
! 	Tp = &Tek0; 
! 	do {
  		write(tekcopyfd, (char *)Tp->data, Tp->count);
  		Tp = Tp->next;
! 	} while(Tp);
! 	close(tekcopyfd);
  }
- 
- 
- 
--- 1819,1871 ----
  		Bell();
  		return;
  	}
! 
! 	/* Write the file in an unprivileged child process because
! 	   using access before the open still leaves a small window
! 	   of opportunity. */
! 	pid = fork();
! 	switch (pid)
! 	{
! 	case 0:			/* child */
! 	{
! 	    register int tekcopyfd;
! 	    char initbuf[5];
! 	    register TekLink *Tp;
! 
! 	    setgid(screen->gid);
! 	    setuid(screen->uid);
! 	    tekcopyfd = open(buf, O_WRONLY | O_CREAT | O_TRUNC, 0666);
! 	    if (tekcopyfd < 0)
! 		_exit(1);
! 	    sprintf(initbuf, "\033%c\033%c", screen->page.fontsize + '8',
! 		    screen->page.linetype + '`');
! 	    write(tekcopyfd, initbuf, 4);
! 	    Tp = &Tek0; 
! 	    do {
  		write(tekcopyfd, (char *)Tp->data, Tp->count);
  		Tp = Tp->next;
! 	    } while(Tp);
! 	    close(tekcopyfd);
! 	    _exit(0);
! 	}
! 	case -1:		/* error */
! 	    Bell();
! 	    return;
! 	default:		/* parent */
! #ifdef HAS_WAITPID
! 	    waitpid(pid, NULL, 0);
! #else
! 	    waited = wait(NULL);
! 	    signal(SIGCHLD, chldfunc);
! 	    /*
! 	      Since we had the signal handler uninstalled for a while,
! 	      we might have missed the termination of our screen child.
! 	      If we can check for this possibility without hanging, do so.
! 	      */
! 	    do
! 		if (waited == term->screen.pid)
! 		    Cleanup(0);
! 	    while ( (waited=nonblocking_wait()) > 0);
! #endif
! 	}
  }
diff -c mit/clients/xterm/charproc.c:1.7 mit/clients/xterm/charproc.c:2.0
*** mit/clients/xterm/charproc.c:1.7	Sat Mar 12 00:15:54 1994
--- mit/clients/xterm/charproc.c	Sat Mar 12 00:15:55 1994
***************
*** 1,6 ****
  /*
!  * $XFree86: mit/clients/xterm/charproc.c,v 1.7 1993/03/21 06:48:40 dawes Exp $
!  * $XConsortium: charproc.c,v 1.176 92/03/13 18:00:30 gildea Exp $
   */
  
  /*
--- 1,6 ----
  /*
!  * $XFree86: mit/clients/xterm/charproc.c,v 2.0 1993/11/13 04:22:59 dawes Exp $
!  * $XConsortium: charproc.c,v 1.176.1.1 93/11/03 17:24:20 gildea Exp $
   */
  
  /*
***************
*** 103,111 ****
--- 103,113 ----
  #define XtNtekGeometry "tekGeometry"
  #define XtNinternalBorder "internalBorder"
  #define XtNjumpScroll "jumpScroll"
+ #ifdef ALLOWLOGGING
  #define XtNlogFile "logFile"
  #define XtNlogging "logging"
  #define XtNlogInhibit "logInhibit"
+ #endif
  #define XtNloginShell "loginShell"
  #define XtNmarginBell "marginBell"
  #define XtNpointerColor "pointerColor"
***************
*** 145,153 ****
--- 147,157 ----
  #define XtCEightBitOutput "EightBitOutput"
  #define XtCGeometry "Geometry"
  #define XtCJumpScroll "JumpScroll"
+ #ifdef ALLOWLOGGING
  #define XtCLogfile "Logfile"
  #define XtCLogging "Logging"
  #define XtCLogInhibit "LogInhibit"
+ #endif
  #define XtCLoginShell "LoginShell"
  #define XtCMarginBell "MarginBell"
  #define XtCMultiClickTime "MultiClickTime"
***************
*** 290,296 ****
--- 294,302 ----
      /* menu actions */
      { "allow-send-events",	HandleAllowSends },
      { "set-visual-bell",	HandleSetVisualBell },
+ #ifdef ALLOWLOGGING
      { "set-logging",		HandleLogging },
+ #endif
      { "redraw",			HandleRedraw },
      { "send-signal",		HandleSendSignal },
      { "quit",			HandleQuit },
***************
*** 381,386 ****
--- 387,393 ----
  {XtNjumpScroll, XtCJumpScroll, XtRBoolean, sizeof(Boolean),
  	XtOffsetOf(XtermWidgetRec, screen.jumpscroll),
  	XtRBoolean, (caddr_t) &defaultTRUE},
+ #ifdef ALLOWLOGGING
  {XtNlogFile, XtCLogfile, XtRString, sizeof(char *),
  	XtOffsetOf(XtermWidgetRec, screen.logfile),
  	XtRString, (caddr_t) NULL},
***************
*** 390,395 ****
--- 397,403 ----
  {XtNlogInhibit, XtCLogInhibit, XtRBoolean, sizeof(Boolean),
  	XtOffsetOf(XtermWidgetRec, misc.logInhibit),
  	XtRBoolean, (caddr_t) &defaultFALSE},
+ #endif
  {XtNloginShell, XtCLoginShell, XtRBoolean, sizeof(Boolean),
  	XtOffsetOf(XtermWidgetRec, misc.login_shell),
  	XtRBoolean, (caddr_t) &defaultFALSE},
***************
*** 1360,1367 ****
--- 1368,1377 ----
  #else
  	if ((bcnt = cb_full(screen->tty_outq)) > 0 && eventMode == NORMAL) {
  #endif /* AMOEBA */
+ #ifdef ALLOWLOGGING
  	    if (screen->logging)
  		FlushLog(screen);
+ #endif
  #ifndef AMOEBA
  	    bcnt = read(screen->respond, (char *)(bptr = buffer), BUF_SIZE);
  #else
***************
*** 1877,1886 ****
--- 1887,1898 ----
  			break;
  		case 38:		/* DECTEK			*/
  			if(func == bitset && !(screen->inhibit & I_TEK)) {
+ #ifdef ALLOWLOGGING
  				if(screen->logging) {
  					FlushLog(screen);
  					screen->logstart = Tbuffer;
  				}
+ #endif
  				screen->TekEmu = TRUE;
  			}
  			break;
***************
*** 1902,1907 ****
--- 1914,1920 ----
  			(*func)(&termw->flags, REVERSEWRAP);
  			update_reversewrap();
  			break;
+ #ifdef ALLOWLOGGING
  		case 46:		/* logging		*/
  #ifdef ALLOWLOGFILEONOFF
  			/*
***************
*** 1917,1922 ****
--- 1930,1936 ----
  			Bell();
  #endif /* ALLOWLOGFILEONOFF */
  			break;
+ #endif
  		case 47:		/* alternate buffer */
  			if (!termw->misc.titeInhibit) {
  			    if(func == bitset)
***************
*** 1991,1999 ****
--- 2005,2015 ----
  		case 45:		/* reverse wraparound	*/
  			screen->save_modes[13] = termw->flags & REVERSEWRAP;
  			break;
+ #ifdef ALLOWLOGGING
  		case 46:		/* logging		*/
  			screen->save_modes[14] = screen->logging;
  			break;
+ #endif
  		case 47:		/* alternate buffer		*/
  			screen->save_modes[15] = screen->alternate;
  			break;
***************
*** 2108,2113 ****
--- 2124,2130 ----
  			termw->flags |= screen->save_modes[13] & REVERSEWRAP;
  			update_reversewrap();
  			break;
+ #ifdef ALLOWLOGGING
  		case 46:		/* logging		*/
  #ifdef ALLOWLOGFILEONOFF
  			if(screen->save_modes[14])
***************
*** 2117,2122 ****
--- 2134,2140 ----
  #endif /* ALLOWLOGFILEONOFF */
  			/* update_logging done by StartLog and CloseLog */
  			break;
+ #endif
  		case 47:		/* alternate buffer */
  			if (!termw->misc.titeInhibit) {
  			    if(screen->save_modes[15])
***************
*** 2462,2468 ****
--- 2480,2488 ----
     new->screen.cursorcolor = request->screen.cursorcolor;
     new->screen.border = request->screen.border;
     new->screen.jumpscroll = request->screen.jumpscroll;
+ #ifdef ALLOWLOGGING
     new->screen.logfile = request->screen.logfile;
+ #endif
     new->screen.marginbell = request->screen.marginbell;
     new->screen.mousecolor = request->screen.mousecolor;
     new->screen.mousecolorback = request->screen.mousecolorback;
diff -c mit/clients/xterm/data.c:1.3 mit/clients/xterm/data.c:2.0
*** mit/clients/xterm/data.c:1.3	Sat Mar 12 00:15:55 1994
--- mit/clients/xterm/data.c	Sat Mar 12 00:15:56 1994
***************
*** 1,5 ****
  /*
!  *	$XConsortium: data.c,v 1.10 91/02/06 14:23:58 gildea Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  *	$XConsortium: data.c,v 1.11 93/02/25 17:21:27 gildea Exp $
   */
  
  /*
***************
*** 89,95 ****
--- 89,97 ----
  int X_mask;
  char *ptydev;
  char *ttydev;
+ #ifdef ALLOWLOGGING
  char log_def_name[] = "XtermLog.XXXXX";
+ #endif
  int T_lastx = -1;
  int T_lasty = -1;
  
diff -c mit/clients/xterm/data.h:1.4 mit/clients/xterm/data.h:2.0
*** mit/clients/xterm/data.h:1.4	Sat Mar 12 00:15:56 1994
--- mit/clients/xterm/data.h	Sat Mar 12 00:15:56 1994
***************
*** 1,6 ****
  /*
!  * 	$XFree86: mit/clients/xterm/data.h,v 1.4 1993/03/20 06:12:24 dawes Exp $
!  *	$XConsortium: data.h,v 1.9 91/02/05 19:44:30 gildea Exp $
   */
  /*
   * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
--- 1,6 ----
  /*
!  * 	$XFree86: mit/clients/xterm/data.h,v 2.0 1993/11/13 04:23:04 dawes Exp $
!  *	$XConsortium: data.h,v 1.10 93/02/25 17:21:28 gildea Exp $
   */
  /*
   * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
***************
*** 36,42 ****
--- 36,44 ----
  extern Char *Tpushb;
  extern Char *Tpushback;
  extern Char *bptr;
+ #ifdef ALLOWLOGGING
  extern char log_def_name[];
+ #endif
  extern char *ptydev;
  extern char *ttydev;
  extern char *xterm_name;
diff -c mit/clients/xterm/error.h:2.1 mit/clients/xterm/error.h:2.2
*** mit/clients/xterm/error.h:2.1	Sat Mar 12 00:15:56 1994
--- mit/clients/xterm/error.h	Sat Mar 12 00:15:56 1994
***************
*** 1,6 ****
  /*
!  *	$XFree86: mit/clients/xterm/error.h,v 2.1 1993/10/03 11:27:44 dawes Exp $
!  *	$XConsortium: error.h,v 1.8 91/07/17 17:43:54 rws Exp $
   */
  
  
--- 1,6 ----
  /*
!  *	$XFree86: mit/clients/xterm/error.h,v 2.2 1993/11/13 04:23:06 dawes Exp $
!  *	$XConsortium: error.h,v 1.9 93/02/25 17:21:29 gildea Exp $
   */
  
  
***************
*** 78,89 ****
  #define	ERROR_BMALLOC2	71	/* SaltTextAway: malloc() failed */
  
  /* misc.c */
  #define	ERROR_LOGEXEC	80	/* StartLog: exec() failed */
  #define	ERROR_XERROR	83	/* xerror: XError event */
  #define	ERROR_XIOERROR	84	/* xioerror: X I/O error */
  #define ERROR_WINNAME   85      /* get_terminal: malloc failed */
- #define	ERROR_LOGOPEN	86	/* StartLog: error opening log in child */
- #define	ERROR_LOGWRITE	87	/* StartLog: error writing log in child */
  /* screen.c */
  #define	ERROR_SCALLOC	90	/* Alloc: calloc() failed on base */
  #define	ERROR_SCALLOC2	91	/* Alloc: calloc() failed on rows */
--- 78,91 ----
  #define	ERROR_BMALLOC2	71	/* SaltTextAway: malloc() failed */
  
  /* misc.c */
+ #ifdef ALLOWLOGGING
+ #ifdef ALLOWLOGFILEEXEC
  #define	ERROR_LOGEXEC	80	/* StartLog: exec() failed */
+ #endif
+ #endif
  #define	ERROR_XERROR	83	/* xerror: XError event */
  #define	ERROR_XIOERROR	84	/* xioerror: X I/O error */
  #define ERROR_WINNAME   85      /* get_terminal: malloc failed */
  /* screen.c */
  #define	ERROR_SCALLOC	90	/* Alloc: calloc() failed on base */
  #define	ERROR_SCALLOC2	91	/* Alloc: calloc() failed on rows */
diff -c mit/clients/xterm/input.c:1.3 mit/clients/xterm/input.c:2.1
*** mit/clients/xterm/input.c:1.3	Sat Mar 12 00:15:57 1994
--- mit/clients/xterm/input.c	Sat Mar 12 00:15:57 1994
***************
*** 128,134 ****
--- 128,138 ----
  			unparseputc(kypd_num[keysym-XK_KP_Space], pty);
  		key = TRUE;
          } else if (IsCursorKey(keysym) &&
+ #if 1
+         	keysym < XK_Prior && keysym != XK_Home) {
+ #else
          	keysym != XK_Prior && keysym != XK_Next) {
+ #endif
         		if (keyboard->flags & CURSOR_APL) {
  			reply.a_type = SS3;
  			unparseseq(&reply, pty);
***************
*** 140,146 ****
--- 144,155 ----
  		}
  		key = TRUE;
  	 } else if (IsFunctionKey(keysym) || IsMiscFunctionKey(keysym) ||
+ #if 1
+ 		keysym == XK_Home ||
+ 		(keysym >= XK_Prior && keysym < XK_Select) ||
+ #else
  	 	keysym == XK_Prior || keysym == XK_Next ||
+ #endif
  	 	keysym == DXK_Remove) {
  		reply.a_type = CSI;
  		reply.a_nparam = 1;
***************
*** 230,235 ****
--- 239,249 ----
  		case XK_Select:	return(4);
  		case XK_Prior:	return(5);
  		case XK_Next:	return(6);
+ #if 1
+ 		case XK_Home:   return(7);
+ 		case XK_End:    return(8);
+ 		case XK_Begin:  return(9);
+ #endif
  		default:	return(-1);
  	}
  }
diff -c mit/clients/xterm/main.c:2.0 mit/clients/xterm/main.c:2.4
*** mit/clients/xterm/main.c:2.0	Sat Mar 12 00:15:59 1994
--- mit/clients/xterm/main.c	Sat Mar 12 00:15:59 1994
***************
*** 1,6 ****
! /* $XFree86: mit/clients/xterm/main.c,v 2.0 1993/07/28 11:53:15 dawes Exp $ */
  #ifndef lint
! static char *rid="$XConsortium: main.c,v 1.200 92/03/11 17:36:12 gildea Exp $";
  #endif /* lint */
  
  /*
--- 1,6 ----
! /* $XFree86: mit/clients/xterm/main.c,v 2.4 1994/03/01 12:00:31 dawes Exp $ */
  #ifndef lint
! static char *rid="$XConsortium: main.c,v 1.200.1.1 93/11/02 17:14:14 gildea Exp $";
  #endif /* lint */
  
  /*
***************
*** 205,211 ****
  #define USE_POSIX_WAIT
  #endif
  
! #ifdef __386BSD__
  #define USE_POSIX_WAIT
  #define LASTLOG
  #define WTMP
--- 205,211 ----
  #define USE_POSIX_WAIT
  #endif
  
! #if (BSD >= 199103)
  #define USE_POSIX_WAIT
  #define LASTLOG
  #define WTMP
***************
*** 227,233 ****
  #include <utmp.h>
  #endif
  #ifdef LASTLOG
! #ifndef __386BSD__
  #include <lastlog.h>
  #endif
  #endif
--- 227,233 ----
  #include <utmp.h>
  #endif
  #ifdef LASTLOG
! #if !(BSD >= 199103)
  #include <lastlog.h>
  #endif
  #endif
***************
*** 469,475 ****
  static int inhibit;
  static char passedPty[2];	/* name if pty if slave */
  
! #ifdef TIOCCONS
  static int Console;
  #include <X11/Xmu/SysUtil.h>	/* XmuGetHostname */
  #define MIT_CONSOLE_LEN	12
--- 469,479 ----
  static int inhibit;
  static char passedPty[2];	/* name if pty if slave */
  
! #if defined(TIOCCONS) || defined(SOLX86)
! #ifdef SOLX86
! static int SolX86cons;
! #include <sys/strredir.h>
! #endif /* ! SOLX86 */
  static int Console;
  #include <X11/Xmu/SysUtil.h>	/* XmuGetHostname */
  #define MIT_CONSOLE_LEN	12
***************
*** 565,570 ****
--- 569,575 ----
  {"-fb",		"*boldFont",	XrmoptionSepArg,	(caddr_t) NULL},
  {"-j",		"*jumpScroll",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+j",		"*jumpScroll",	XrmoptionNoArg,		(caddr_t) "off"},
+ /* parse logging options anyway for compatibility */
  {"-l",		"*logging",	XrmoptionNoArg,		(caddr_t) "on"},
  {"+l",		"*logging",	XrmoptionNoArg,		(caddr_t) "off"},
  {"-lf",		"*logFile",	XrmoptionSepArg,	(caddr_t) NULL},
***************
*** 643,650 ****
--- 648,660 ----
  { "-fb fontname",          "bold text font" },
  { "-/+im",		   "use insert mode for TERMCAP" },
  { "-/+j",                  "turn on/off jump scroll" },
+ #ifdef ALLOWLOGGING
  { "-/+l",                  "turn on/off logging" },
  { "-lf filename",          "logging filename" },
+ #else
+ { "-/+l",                  "turn on/off logging (not supported)" },
+ { "-lf filename",          "logging filename (not supported)" },
+ #endif
  { "-/+ls",                 "turn on/off login shell" },
  { "-/+mb",                 "turn on/off margin bell" },
  { "-mc milliseconds",      "multiclick time in milliseconds" },
***************
*** 674,680 ****
  { "-T string",             "title name for window" },
  { "-n string",             "icon name for window" },
  #ifndef AMOEBA
! #ifdef TIOCCONS
  { "-C",                    "intercept console messages" },
  #else
  { "-C",                    "intercept console messages (not supported)" },
--- 684,690 ----
  { "-T string",             "title name for window" },
  { "-n string",             "icon name for window" },
  #ifndef AMOEBA
! #if defined(TIOCCONS) || defined(SOLX86)
  { "-C",                    "intercept console messages" },
  #else
  { "-C",                    "intercept console messages (not supported)" },
***************
*** 742,748 ****
      exit (0);
  }
  
! #ifdef TIOCCONS
  /* ARGSUSED */
  static Boolean
  ConvertConsoleSelection(w, selection, target, type, value, length, format)
--- 752,758 ----
      exit (0);
  }
  
! #if defined(TIOCCONS) || defined(SOLX86)
  /* ARGSUSED */
  static Boolean
  ConvertConsoleSelection(w, selection, target, type, value, length, format)
***************
*** 822,828 ****
  char **argv;
  {
  	register TScreen *screen;
! 	register int i, pty;
  	int Xsocket, mode;
  	char *base_name();
  	int xerror(), xioerror();
--- 832,838 ----
  char **argv;
  {
  	register TScreen *screen;
! 	register int pty;
  	int Xsocket, mode;
  	char *base_name();
  	int xerror(), xioerror();
***************
*** 911,916 ****
--- 921,934 ----
  #ifndef _POSIX_SOURCE	/* What is the appropriate define? */
  	d_tio.c_line = 0;
  #endif /* _POSIX_SOURCE */
+ #ifdef linux
+ 	d_tio.c_cc[VINTR] = 'C' & 0x3f;		/* '^C'  */
+ 	d_tio.c_cc[VQUIT] = '\\' & 0x3f;	/* '^\'	*/
+ 	d_tio.c_cc[VERASE] = 0x7f;		/* DEL	*/
+ 	d_tio.c_cc[VKILL] = 'U' & 0x3f;		/* '^U'	*/
+     	d_tio.c_cc[VEOF] = 'D' & 0x3f;		/* '^D'	*/
+ 	d_tio.c_cc[VEOL] = '@' & 0x3f;		/* '^@'	*/
+ #else
  	d_tio.c_cc[VINTR] = 0x7f;		/* DEL  */
  	d_tio.c_cc[VQUIT] = '\\' & 0x3f;	/* '^\'	*/
  	d_tio.c_cc[VERASE] = '#';		/* '#'	*/
***************
*** 917,922 ****
--- 935,941 ----
  	d_tio.c_cc[VKILL] = '@';		/* '@'	*/
      	d_tio.c_cc[VEOF] = 'D' & 0x3f;		/* '^D'	*/
  	d_tio.c_cc[VEOL] = '@' & 0x3f;		/* '^@'	*/
+ #endif
  #ifdef VSWTCH
  	d_tio.c_cc[VSWTCH] = '@' & 0x3f;	/* '^@'	*/
  #endif	/* VSWTCH */
***************
*** 949,955 ****
--- 968,978 ----
          d_ltc.t_lnextc = '\377';
  #endif	/* TIOCSLTC */
  #ifdef USE_TERMIOS
+ #ifdef linux
+ 	d_tio.c_cc[VSUSP] = 'Z' & 0x3f;
+ #else
  	d_tio.c_cc[VSUSP] = '\000';
+ #endif
  #ifdef VDSUSP
  	d_tio.c_cc[VDSUSP] = '\000';
  #endif /* VDSUSP */
***************
*** 1031,1037 ****
  		/* NOTREACHED */
  #ifndef AMOEBA
  	     case 'C':
! #ifdef TIOCCONS
  		{
  		    struct stat sbuf;
  
--- 1054,1060 ----
  		/* NOTREACHED */
  #ifndef AMOEBA
  	     case 'C':
! #if defined(TIOCCONS) || defined(SOLX86)
  		{
  		    struct stat sbuf;
  
***************
*** 1104,1110 ****
--- 1127,1135 ----
  	}
  
  	inhibit = 0;
+ #ifdef ALLOWLOGGING
  	if (term->misc.logInhibit) 	    inhibit |= I_LOG;
+ #endif
  	if (term->misc.signalInhibit)		inhibit |= I_SIGNAL;
  	if (term->misc.tekInhibit)			inhibit |= I_TEK;
  
***************
*** 1149,1161 ****
  		exit(ERROR_INIT);
  
  #ifndef AMOEBA
- 	/* set up stderr properly */
- 	i = -1;
  #ifdef DEBUG
! 	if(debug)
! 		i = open ("xterm.debug.log", O_WRONLY | O_CREAT | O_TRUNC,
! 		 0666);
! #endif	/* DEBUG */
  	if(i >= 0) {
  #ifdef _MINIX
  		stderr->_fd = i;
--- 1174,1189 ----
  		exit(ERROR_INIT);
  
  #ifndef AMOEBA
  #ifdef DEBUG
!     {
! 	/* Set up stderr properly.  Opening this log file cannot be
! 	 done securely by a privileged xterm process (although we try),
! 	 so the debug feature is disabled by default. */
! 	int i = -1;
! 	if(debug) {
! 	        creat_as (getuid(), getgid(), "xterm.debug.log", 0666);
! 		i = open ("xterm.debug.log", O_WRONLY | O_TRUNC, 0666);
! 	}
  	if(i >= 0) {
  #ifdef _MINIX
  		stderr->_fd = i;
***************
*** 1181,1186 ****
--- 1209,1216 ----
  		/* mark this file as close on exec */
  		(void) fcntl(i, F_SETFD, 1);
  	}
+     }
+ #endif	/* DEBUG */
  #endif /* AMOEBA */
  
  	/* open a terminal for client */
***************
*** 1206,1214 ****
--- 1236,1246 ----
  	}
  #endif /* AMOEBA */
  
+ #ifdef ALLOWLOGGING
  	if (term->misc.log_on) {
  		StartLog(screen);
  	}
+ #endif
  	screen->inhibit = inhibit;
  
  #ifdef AIXV3
***************
*** 1657,1662 ****
--- 1689,1699 ----
  	screen->uid = getuid();
  	screen->gid = getgid();
  
+ #ifdef linux
+ 	memset(termcap, 0, sizeof(termcap));
+ 	memset(newtc, 0, sizeof(newtc));
+ #endif
+ 
  #ifdef SIGTTOU
  	/* so that TIOCSWINSZ || TIOCSIZE doesn't block */
  	signal(SIGTTOU,SIG_IGN);
***************
*** 1794,1800 ****
  				       False);
  	if (!screen->TekEmu)
  	    VTInit();		/* realize now so know window size for tty driver */
! #ifdef TIOCCONS
  	if (Console) {
  	    /*
  	     * Inform any running xconsole program
--- 1831,1837 ----
  				       False);
  	if (!screen->TekEmu)
  	    VTInit();		/* realize now so know window size for tty driver */
! #if defined(TIOCCONS) || defined(SOLX86)
  	if (Console) {
  	    /*
  	     * Inform any running xconsole program
***************
*** 2238,2244 ****
  			    HsSysError (cp_pipe[1], ERROR_TIOCKSETC);
  #endif /* sony */
  #endif	/* !USE_SYSV_TERMIO */
! #ifdef TIOCCONS
  		    if (Console) {
  			int on = 1;
  			if (ioctl (tty, TIOCCONS, (char *)&on) == -1)
--- 2275,2282 ----
  			    HsSysError (cp_pipe[1], ERROR_TIOCKSETC);
  #endif /* sony */
  #endif	/* !USE_SYSV_TERMIO */
! #if defined(TIOCCONS) || defined(SOLX86)
! #ifndef SOLX86
  		    if (Console) {
  			int on = 1;
  			if (ioctl (tty, TIOCCONS, (char *)&on) == -1)
***************
*** 2245,2250 ****
--- 2283,2297 ----
  			    fprintf(stderr, "%s: cannot open console\n",
  				    xterm_name);
  		    }
+ #else
+ 		    if (Console) {
+ 			int on = 1;
+ 			SolX86cons = open("/dev/console", O_RDONLY);
+ 			if( ioctl(SolX86cons, SRIOCSREDIR, tty) == -1)
+ 				fprintf(stderr, "%s: cannot open console\n", 
+ 					xterm_name);
+ 		    }
+ #endif /* SOLX86 */
  #endif	/* TIOCCONS */
  		}
  
***************
*** 3150,3155 ****
--- 3197,3207 ----
  	int fd;			/* for /etc/wtmp */
  	int i;
  #endif
+ 
+ #ifdef PUCC_PTYD
+ 	closepty(ttydev, ptydev, (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN), Ptyfd);
+ #endif /* PUCC_PTYD */
+ 
  	/* cleanup the utmp entry we forged earlier */
  	if (!resource.utmpInhibit
  #ifdef USE_HANDSHAKE		/* without handshake, no way to know */
***************
*** 3206,3220 ****
          close(pty); /* close explicitly to avoid race with slave side */
  #endif
  
! #ifdef DEBUG
! 	if (debug) {
! 		printf("Exit(n=%d)\n", n);
! 		fflush(stdout);
! 	}
! #endif
! 
  	if(screen->logging)
  		CloseLog(screen);
  
  #ifndef AMOEBA
  	if (!am_slave) {
--- 3258,3271 ----
          close(pty); /* close explicitly to avoid race with slave side */
  #endif
  
! #ifdef ALLOWLOGGING
  	if(screen->logging)
  		CloseLog(screen);
+ #endif
+ 
+ #ifdef SOLX86
+ 	if(Console) close(SolX86cons);
+ #endif
  
  #ifndef AMOEBA
  	if (!am_slave) {
***************
*** 3280,3349 ****
  #endif /* USE_TERMCAP_ENVVARS */
  }
  
! /* ARGSUSED */
! static SIGNAL_T reapchild (n)
!     int n;
  {
  #ifdef USE_POSIX_WAIT
          pid_t pid;
  
  	pid = waitpid(-1, NULL, WNOHANG);
- 	if (pid <= 0) {
- #ifdef USE_SYSV_SIGNALS
- 		(void) signal(SIGCHLD, reapchild);
- #endif /* USE_SYSV_SIGNALS */
- 		SIGNAL_RETURN;
- 	}
  #else /* USE_POSIX_WAIT */
  #if defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP))
! 	int status, pid;
! 
! 	pid = wait(&status);
! 	if (pid == -1) {
! 		(void) signal(SIGCHLD, reapchild);
! 		SIGNAL_RETURN;
! 	}
  #else	/* defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP)) */
  	union wait status;
  	register int pid;
! 	
! #ifdef DEBUG
! 	if (debug) fputs ("Exiting\n", stderr);
! #endif	/* DEBUG */
! 	pid  = wait3 (&status, WNOHANG, (struct rusage *)NULL);
! 	if (!pid) {
! #ifdef USE_SYSV_SIGNALS
! 		(void) signal(SIGCHLD, reapchild);
! #endif /* USE_SYSV_SIGNALS */
! 		SIGNAL_RETURN;
! 	}
  #endif /* defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP) */
  #endif /* USE_POSIX_WAIT else */
  
! #ifdef PUCC_PTYD
! 		closepty(ttydev, ptydev, (resource.utmpInhibit ?  OPTY_NOP : OPTY_LOGIN), Ptyfd);
! #endif /* PUCC_PTYD */
  
- 	if (pid != term->screen.pid) {
  #ifdef USE_SYSV_SIGNALS
! 		(void) signal(SIGCHLD, reapchild);
! #endif	/* USE_SYSV_SIGNALS */
! 		SIGNAL_RETURN;
! 	}
! 	
! 	/*
! 	 * Use pid instead of process group (which would have to get before
! 	 * the wait call above) so that we don't accidentally hose other
! 	 * applications.  Otherwise, somebody could write a program which put
! 	 * itself in somebody else's process group.  Also, we call Exit instead
! 	 * of Cleanup so that we don't do a killpg on -1 by accident.  Some
! 	 * operating systems seem to do very nasty things with that.
! 	 */
! 	if (pid > 1) {
! 	    kill_process_group (pid, SIGHUP);
  	}
! 	Exit (0);
! 	SIGNAL_RETURN;
  }
  
  /* VARARGS1 */
--- 3331,3387 ----
  #endif /* USE_TERMCAP_ENVVARS */
  }
  
! /*
!  * Does a non-blocking wait for a child process.  If the system
!  * doesn't support non-blocking wait, do nothing.
!  * Returns the pid of the child, or 0 or -1 if none or error.
!  */
! int
! nonblocking_wait()
  {
  #ifdef USE_POSIX_WAIT
          pid_t pid;
  
  	pid = waitpid(-1, NULL, WNOHANG);
  #else /* USE_POSIX_WAIT */
  #if defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP))
! 	/* cannot do non-blocking wait */
! 	int pid = 0;
  #else	/* defined(USE_SYSV_SIGNALS) && (defined(CRAY) || !defined(SIGTSTP)) */
  	union wait status;
  	register int pid;
! 
! 	pid = wait3 (&status, WNOHANG, (struct rusage *)NULL);
  #endif /* defined(USE_SYSV_SIGNALS) && !defined(SIGTSTP) */
  #endif /* USE_POSIX_WAIT else */
  
! 	return pid;
! }
! 
! /* ARGSUSED */
! static SIGNAL_T reapchild (n)
!     int n;
! {
!     int pid;
! 
!     pid = wait(NULL);
  
  #ifdef USE_SYSV_SIGNALS
!     /* cannot re-enable signal before waiting for child
!        because then SVR4 loops.  Sigh.  HP-UX 9.01 too. */
!     (void) signal(SIGCHLD, reapchild);
! #endif
! 
!     do {
! 	if (pid == term->screen.pid) {
! #ifdef DEBUG
! 	    if (debug) fputs ("Exiting\n", stderr);
! #endif
! 	    Cleanup (0);
  	}
!     } while ( (pid=nonblocking_wait()) > 0);
! 
!     SIGNAL_RETURN;
  }
  
  /* VARARGS1 */
diff -c mit/clients/xterm/menu.c:1.4 mit/clients/xterm/menu.c:2.0
*** mit/clients/xterm/menu.c:1.4	Sat Mar 12 00:16:01 1994
--- mit/clients/xterm/menu.c	Sat Mar 12 00:16:01 1994
***************
*** 1,5 ****
! /* $XFree86: mit/clients/xterm/menu.c,v 1.4 1993/03/20 06:12:29 dawes Exp $ */
! /* $XConsortium: menu.c,v 1.61 92/04/20 18:46:39 rws Exp $ */
  /*
  Copyright 1989 Massachusetts Institute of Technology
  
--- 1,5 ----
! /* $XFree86: mit/clients/xterm/menu.c,v 2.0 1993/11/13 04:23:11 dawes Exp $ */
! /* $XConsortium: menu.c,v 1.62 93/02/25 17:21:30 gildea Exp $ */
  /*
  Copyright 1989 Massachusetts Institute of Technology
  
***************
*** 33,39 ****
  
  void do_hangup();
  
! static void do_securekbd(), do_allowsends(), do_visualbell(), do_logging(),
      do_redraw(), do_suspend(), do_continue(), do_interrupt(), 
      do_terminate(), do_kill(), do_quit(), do_scrollbar(), do_jumpscroll(),
      do_reversevideo(), do_autowrap(), do_reversewrap(), do_autolinefeed(),
--- 33,42 ----
  
  void do_hangup();
  
! static void do_securekbd(), do_allowsends(), do_visualbell(),
! #ifdef ALLOWLOGGING
!     do_logging(),
! #endif
      do_redraw(), do_suspend(), do_continue(), do_interrupt(), 
      do_terminate(), do_kill(), do_quit(), do_scrollbar(), do_jumpscroll(),
      do_reversevideo(), do_autowrap(), do_reversewrap(), do_autolinefeed(),
***************
*** 52,58 ****
--- 55,63 ----
  MenuEntry mainMenuEntries[] = {
      { "securekbd",	do_securekbd, NULL },		/*  0 */
      { "allowsends",	do_allowsends, NULL },		/*  1 */
+ #ifdef ALLOWLOGGING
      { "logging",	do_logging, NULL },		/*  2 */
+ #endif
      { "redraw",		do_redraw, NULL },		/*  3 */
      { "line1",		NULL, NULL },			/*  4 */
      { "suspend",	do_suspend, NULL },		/*  5 */
***************
*** 156,162 ****
--- 161,169 ----
  					    XtNumber(mainMenuEntries));
  	    update_securekbd();
  	    update_allowsends();
+ #ifdef ALLOWLOGGING
  	    update_logging();
+ #endif
  #if !defined(SIGTSTP) || defined(AMOEBA)
  	    set_sensitivity (screen->mainMenu,
  			     mainMenuEntries[mainMenu_suspend].widget, FALSE);
***************
*** 359,364 ****
--- 366,372 ----
      update_visualbell();
  }
  
+ #ifdef ALLOWLOGGING
  static void do_logging (gw, closure, data)
      Widget gw;
      caddr_t closure, data;
***************
*** 372,378 ****
      }
      /* update_logging done by CloseLog and StartLog */
  }
! 
  
  static void do_redraw (gw, closure, data)
      Widget gw;
--- 380,386 ----
      }
      /* update_logging done by CloseLog and StartLog */
  }
! #endif
  
  static void do_redraw (gw, closure, data)
      Widget gw;
***************
*** 880,885 ****
--- 888,894 ----
  		   params, *param_count, w, NULL, NULL);
  }
  
+ #ifdef ALLOWLOGGING
  void HandleLogging(w, event, params, param_count)
      Widget w;
      XEvent *event;
***************
*** 889,894 ****
--- 898,904 ----
      handle_toggle (do_logging, (int) term->screen.logging,
  		   params, *param_count, w, NULL, NULL);
  }
+ #endif
  
  /* ARGSUSED */
  void HandleRedraw(w, event, params, param_count)
diff -c mit/clients/xterm/menu.h:1.3 mit/clients/xterm/menu.h:2.0
*** mit/clients/xterm/menu.h:1.3	Sat Mar 12 00:16:02 1994
--- mit/clients/xterm/menu.h	Sat Mar 12 00:16:02 1994
***************
*** 1,4 ****
! /* $XConsortium: menu.h,v 1.23 91/06/25 19:49:44 gildea Exp $ */
  
  /* Copyright 1989 Massachusetts Institute of Technology */
  
--- 1,4 ----
! /* $XConsortium: menu.h,v 1.24 93/02/25 17:21:31 gildea Exp $ */
  
  /* Copyright 1989 Massachusetts Institute of Technology */
  
***************
*** 26,32 ****
--- 26,34 ----
  
  extern void HandleAllowSends();
  extern void HandleSetVisualBell();
+ #ifdef ALLOWLOGGING
  extern void HandleLogging();
+ #endif
  extern void HandleRedraw();
  extern void HandleSendSignal();
  extern void HandleQuit();
***************
*** 65,71 ****
--- 67,75 ----
   */
  #define mainMenu_securekbd 0
  #define mainMenu_allowsends 1
+ #ifdef ALLOWLOGGING
  #define mainMenu_logging 2
+ #endif
  #define mainMenu_redraw 3
  #define mainMenu_line1 4
  #define mainMenu_suspend 5
***************
*** 169,179 ****
  		    mainMenuEntries[mainMenu_allowsends].widget, \
  		    term->screen.allowSendEvents)
  
  #define update_logging() \
    update_menu_item (term->screen.mainMenu, \
  		    mainMenuEntries[mainMenu_logging].widget, \
  		    term->screen.logging)
! 
  
  #define update_scrollbar() \
    update_menu_item (term->screen.vtMenu, \
--- 173,184 ----
  		    mainMenuEntries[mainMenu_allowsends].widget, \
  		    term->screen.allowSendEvents)
  
+ #ifdef ALLOWLOGGING
  #define update_logging() \
    update_menu_item (term->screen.mainMenu, \
  		    mainMenuEntries[mainMenu_logging].widget, \
  		    term->screen.logging)
! #endif
  
  #define update_scrollbar() \
    update_menu_item (term->screen.vtMenu, \
diff -c mit/clients/xterm/misc.c:2.1 mit/clients/xterm/misc.c:2.3
*** mit/clients/xterm/misc.c:2.1	Sat Mar 12 00:16:02 1994
--- mit/clients/xterm/misc.c	Sat Mar 12 00:16:02 1994
***************
*** 1,6 ****
  /*
!  *	$XFree86: mit/clients/xterm/misc.c,v 2.1 1993/10/03 14:53:01 dawes Exp $
!  *	$XConsortium: misc.c,v 1.92 92/03/13 17:02:08 gildea Exp $
   */
  
  /*
--- 1,6 ----
  /*
!  *	$XFree86: mit/clients/xterm/misc.c,v 2.3 1993/11/13 04:23:16 dawes Exp $
!  *	$XConsortium: misc.c,v 1.95.1.1 93/11/04 08:56:48 gildea Exp $
   */
  
  /*
***************
*** 445,450 ****
--- 445,519 ----
  	}
  }
  
+ #if defined(ALLOWLOGGING) || defined(DEBUG)
+ 
+ #ifndef X_NOT_POSIX
+ #define HAS_WAITPID
+ #endif
+ 
+ /*
+  * create a file only if we could with the permissions of the real user id.
+  * We could emulate this with careful use of access() and following
+  * symbolic links, but that is messy and has race conditions.
+  * Forking is messy, too, but we can't count on setreuid() or saved set-uids
+  * being available.
+  */
+ void
+ creat_as(uid, gid, pathname, mode)
+     int uid;
+     int gid;
+     char *pathname;
+     int mode;
+ {
+     int fd;
+     int waited;
+     int pid;
+ #ifndef HAS_WAITPID
+     int (*chldfunc)();
+ 
+     chldfunc = signal(SIGCHLD, SIG_DFL);
+ #endif
+     pid = fork();
+     switch (pid)
+     {
+     case 0:			/* child */
+ 	setgid(gid);
+ 	setuid(uid);
+ 	fd = open(pathname, O_WRONLY|O_CREAT|O_APPEND, mode);
+ 	if (fd >= 0) {
+ 	    close(fd);
+ 	    _exit(0);
+ 	} else
+ 	    _exit(1);
+     case -1:			/* error */
+ 	return;
+     default:			/* parent */
+ #ifdef HAS_WAITPID
+ 	waitpid(pid, NULL, 0);
+ #else
+ 	waited = wait(NULL);
+ 	signal(SIGCHLD, chldfunc);
+ 	/*
+ 	  Since we had the signal handler uninstalled for a while,
+ 	  we might have missed the termination of our screen child.
+ 	  If we can check for this possibility without hanging, do so.
+ 	*/
+ 	do
+ 	    if (waited == term->screen.pid)
+ 		Cleanup(0);
+ 	while ( (waited=nonblocking_wait()) > 0);
+ #endif
+     }
+ }
+ #endif
+ 
+ #ifdef ALLOWLOGGING
+ /*
+  * logging is a security hole, since it allows a setuid program to
+  * write arbitrary data to an arbitrary file.  So it is disabled
+  * by default.
+  */ 
+ 
  StartLog(screen)
  register TScreen *screen;
  {
***************
*** 456,462 ****
  	register char *cp;
  	register int i;
  	static char *log_default;
! #if defined(ALLOWLOGFILEEXEC) || defined(FORKFORLOGFILE)
  	void logpipe();
  #ifdef SYSV
  	/* SYSV has another pointer which should be part of the
--- 525,531 ----
  	register char *cp;
  	register int i;
  	static char *log_default;
! #if defined(ALLOWLOGFILEEXEC)
  	void logpipe();
  #ifdef SYSV
  	/* SYSV has another pointer which should be part of the
***************
*** 536,594 ****
  		return;
  #endif
  	} else {
! #ifdef FORKFORLOGFILE
! 		int p[2];
! 
! 		if(pipe(p) < 0 || (i = fork()) < 0)
  			return;
- 		if(i == 0) {	/* child */
- 			int logfd;
- 			char buf[256];
- 			int nread;
- 
- 			close(p[1]);
- 			close(fileno(stdin));
- 			close(fileno(stdout));
- 			close(fileno(stderr));
- 			close(ConnectionNumber(screen->display));
- 			close(screen->respond);
- 			signal(SIGHUP, SIG_DFL);
- 			signal(SIGCHLD, SIG_DFL);
- 			setgid(screen->gid);
- 			setuid(screen->uid);
- 			if((logfd = open(screen->logfile, O_WRONLY | O_APPEND |
- 							 O_CREAT, 0644)) < 0)
- 				exit(ERROR_LOGOPEN);
- 			while ((nread = read(p[0], buf, sizeof(buf))) > 0)
- 				if (write(logfd, buf, nread) != nread) {
- 					close(p[0]);
- 					close(logfd);
- 					exit(ERROR_LOGWRITE);
- 				}
- 			close(p[0]);
- 			close(logfd);
- 			exit(0);
  		}
! 		close(p[0]);
! 		screen->logfd = p[1];
! 		signal(SIGPIPE, logpipe);
! #else
! 		if(access(screen->logfile, F_OK) == 0) {
! 			if(access(screen->logfile, W_OK) < 0)
! 				return;
! 		} else if(cp = rindex(screen->logfile, '/')) {
! 			*cp = 0;
! 			i = access(screen->logfile, W_OK);
! 			*cp = '/';
! 			if(i < 0)
! 				return;
! 		} else if(access(".", W_OK) < 0)
! 			return;
! 		if((screen->logfd = open(screen->logfile, O_WRONLY | O_APPEND |
! 		 O_CREAT, 0644)) < 0)
  			return;
- 		chown(screen->logfile, screen->uid, screen->gid);
- #endif /* FORKFORLOGFILE */
  	}
  	screen->logstart = screen->TekEmu ? Tbptr : bptr;
  	screen->logging = TRUE;
--- 605,624 ----
  		return;
  #endif
  	} else {
! 		if(access(screen->logfile, F_OK) != 0) {
! 		    if (errno == ENOENT)
! 			creat_as(screen->uid, screen->gid,
! 				 screen->logfile, 0644);
! 		    else
  			return;
  		}
! 
! 		if(access(screen->logfile, F_OK) != 0
! 		   || access(screen->logfile, W_OK) != 0)
! 		    return;
! 		if((screen->logfd = open(screen->logfile, O_WRONLY | O_APPEND,
! 					 0644)) < 0)
  			return;
  	}
  	screen->logstart = screen->TekEmu ? Tbptr : bptr;
  	screen->logging = TRUE;
***************
*** 619,625 ****
  	screen->logstart = screen->TekEmu ? Tbuffer : buffer;
  }
  
! #if defined(ALLOWLOGFILEEXEC) || defined(FORKFORLOGFILE)
  void logpipe()
  {
  	register TScreen *screen = &term->screen;
--- 649,655 ----
  	screen->logstart = screen->TekEmu ? Tbuffer : buffer;
  }
  
! #if defined(ALLOWLOGFILEEXEC)
  void logpipe()
  {
  	register TScreen *screen = &term->screen;
***************
*** 630,636 ****
  	if(screen->logging)
  		CloseLog(screen);
  }
! #endif /* ALLOWLOGFILEEXEC || FORKFORLOGFILE */
  
  
  do_osc(func)
--- 660,667 ----
  	if(screen->logging)
  		CloseLog(screen);
  }
! #endif /* ALLOWLOGFILEEXEC */
! #endif /* ALLOWLOGGING */
  
  
  do_osc(func)
***************
*** 670,675 ****
--- 701,707 ----
  		Changetitle(buf);
  		break;
  
+ #ifdef ALLOWLOGGING
  	 case 46:	/* new log file */
  #ifdef ALLOWLOGFILECHANGES
  		/*
***************
*** 687,692 ****
--- 719,725 ----
  		Bell();
  #endif
  		break;
+ #endif /* ALLOWLOGGING */
  
  	case 50:
  		SetVTFont (fontMenu_fontescape, True, buf, NULL);
***************
*** 742,748 ****
  char *SysErrorMsg (n)
      int n;
  {
! #if __STDC__
      return strerror(n);
  #else
      extern char *sys_errlist[];
--- 775,781 ----
  char *SysErrorMsg (n)
      int n;
  {
! #ifndef X_NO_STRERROR
      return strerror(n);
  #else
      extern char *sys_errlist[];
***************
*** 749,755 ****
      extern int sys_nerr;
  
      return ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error");
! #endif /* __STDC__ */
  }
  
  
--- 782,788 ----
      extern int sys_nerr;
  
      return ((n >= 0 && n < sys_nerr) ? sys_errlist[n] : "unknown error");
! #endif /* !X_NO_STRERROR */
  }
  
  
***************
*** 957,966 ****
--- 990,1001 ----
      register TScreen *screen = &term->screen;
  
      if (screen->TekEmu) {
+ #ifdef ALLOWLOGGING
  	if (screen->logging) {
  	    FlushLog (screen);
  	    screen->logstart = buffer;
  	}
+ #endif
  	longjmp(Tekend, 1);
      } 
      return;
***************
*** 971,980 ****
--- 1006,1017 ----
      register TScreen *screen = &term->screen;
  
      if (!screen->TekEmu) {
+ #ifdef ALLOWLOGGING
  	if(screen->logging) {
  	    FlushLog(screen);
  	    screen->logstart = Tbuffer;
  	}
+ #endif
  	screen->TekEmu = TRUE;
  	longjmp(VTend, 1);
      } 
diff -c mit/clients/xterm/ptyx.h:1.5 mit/clients/xterm/ptyx.h:2.0
*** mit/clients/xterm/ptyx.h:1.5	Sat Mar 12 00:16:03 1994
--- mit/clients/xterm/ptyx.h	Sat Mar 12 00:16:03 1994
***************
*** 1,6 ****
  /*
!  *	$XFree86: mit/clients/xterm/ptyx.h,v 1.5 1993/05/24 12:34:23 dawes Exp $
!  *	$XConsortium: ptyx.h,v 1.60 91/06/24 20:45:02 gildea Exp $
   */
  
  /*
--- 1,6 ----
  /*
!  *	$XFree86: mit/clients/xterm/ptyx.h,v 2.0 1993/11/13 04:23:18 dawes Exp $
!  *	$XConsortium: ptyx.h,v 1.60.1.1 93/11/03 17:29:39 gildea Exp $
   */
  
  /*
***************
*** 238,249 ****
  					/* and position information	*/
  	int		select;		/* xterm selected		*/
  	Boolean		visualbell;	/* visual bell mode		*/
- 	int		logging;	/* logging mode			*/
  	Boolean		allowSendEvents;/* SendEvent mode		*/
  	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
  	int		logfd;		/* file descriptor of log	*/
  	char		*logfile;	/* log file name		*/
  	unsigned char	*logstart;	/* current start of log buffer	*/
  	int		inhibit;	/* flags for inhibiting changes	*/
  
  /* VT window parameters */
--- 238,251 ----
  					/* and position information	*/
  	int		select;		/* xterm selected		*/
  	Boolean		visualbell;	/* visual bell mode		*/
  	Boolean		allowSendEvents;/* SendEvent mode		*/
  	Boolean		grabbedKbd;	/* keyboard is grabbed		*/
+ #ifdef ALLOWLOGGING
+ 	int		logging;	/* logging mode			*/
  	int		logfd;		/* file descriptor of log	*/
  	char		*logfile;	/* log file name		*/
  	unsigned char	*logstart;	/* current start of log buffer	*/
+ #endif
  	int		inhibit;	/* flags for inhibiting changes	*/
  
  /* VT window parameters */
***************
*** 402,408 ****
--- 404,412 ----
      char *T_geometry;
      char *f_n;
      char *f_b;
+ #ifdef ALLOWLOGGING
      Boolean log_on;
+ #endif
      Boolean login_shell;
      Boolean re_verse;
      int resizeGravity;
***************
*** 544,550 ****
--- 548,556 ----
  #define	TOGGLE		1
  
  /* flags for inhibit */
+ #ifdef ALLOWLOGGING
  #define	I_LOG		0x01
+ #endif
  #define	I_SIGNAL	0x02
  #define	I_TEK		0x04
  
diff -c mit/clients/xterm/terminfo:1.2 mit/clients/xterm/terminfo:2.0
*** mit/clients/xterm/terminfo:1.2	Sat Mar 12 00:16:04 1994
--- mit/clients/xterm/terminfo	Sat Mar 12 00:16:04 1994
***************
*** 1,18 ****
  xterm|vs100|xterm terminal emulator,
! 	ind=^J, cols#80, lines#65,
! 	clear=\E[H\E[2J, cub1=^H, am, cup=\E[%i%p1%d;%p2%dH,
! 	cuf1=\E[C, cuu1=\E[A, el=\E[K, ed=\E[J,
! 	cud=\E[%p1%dB, cuu=\E[%p1%dA, cub=\E[%p1%dD,
! 	cuf=\E[%p1%dC, km,
! 	knp=\E[6~, kpp=\E[5~,
! 	smso=\E[7m, rmso=\E[m, smul=\E[4m, rmul=\E[m,
! 	bold=\E[1m, rev=\E[7m, blink=@, sgr0=\E[m,
! 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, rs2=@
! 	kf1=\EOP, kf2=\EOQ, kf3=\EOR, kf4=\EOS, ht=^I, ri=\EM,
! 	vt@, xon@, csr=\E[%i%p1%d;%p2%dr,
! 	il=\E[%p1%dL, dl=\E[%p1%dM, il1=\E[L, dl1=\E[M,
! 	ich=\E[%p1%d@, dch=\E[%p1%dP, ich1=\E[@, dch1=\E[P,
! 	use=vt100-am,
  xterms|vs100s|xterm terminal emulator (small screen 24x80),
  	cols#80, lines#24,
  	use=xterm,
--- 1,24 ----
  xterm|vs100|xterm terminal emulator,
! 	am, xenl, km, msgr,
! 	cols#80, it#8, lines#65,
! 	bel=^G, cr=\r, csr=\E[%i%p1%d;%p2%dr, tbc=\E[3g,
! 	clear=\E[H\E[2J, el=\E[K, ed=\E[J, cup=\E[%i%p1%d;%p2%dH,
! 	cud1=\n, home=\E[H, cub1=\b, cuf1=\E[C,
! 	cuu1=\E[A, dch1=\E[P, dl1=\E[M, blink=@,
! 	bold=\E[1m, rev=\E[7m, smso=\E[7m, sgr0=\E[m,
! 	rmso=\E[m, ich1=\E[@, il1=\E[L, kbs=\b,
! 	kdch1=\E[3~, kdl1=\E[31~, kel=\E[8~, kcud1=\EOB, kf0=\EOq,
! 	kf1=\E[11~, kf10=\E[21~, kf2=\E[12~, kf3=\E[13~,
! 	kf4=\E[14~, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~,
! 	kf8=\E[19~, kf9=\E[20~, khome=\E[7~, kich1=\E[2~,
! 	kil1=\E[30~, kcub1=\EOD, knp=\E[6~, kpp=\E[5~,
! 	kcuf1=\EOC, kcuu1=\EOA, rmkx=\E[?1l\E>, smkx=\E[?1h\E=,
! 	dch=\E[%p1%dP, dl=\E[%p1%dM, cud=\E[%p1%dB, ich=\E[%p1%d@,
! 	il=\E[%p1%dL, cub=\E[%p1%dD, cuf=\E[%p1%dC, cuu=\E[%p1%dA,
! 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H, rc=\E8, sc=\E7,
! 	ind=\n, ri=\EM,
! 	sgr=\E[%?%p1%t;7%;%?%p2%t;4%;%?%p3%t;7%;%?%p4%t;5%;%?%p6%t;1%;m,
! 	hts=\EH, ht=\t, kf11=\E[23~, kf12=\E[24~,
  xterms|vs100s|xterm terminal emulator (small screen 24x80),
  	cols#80, lines#24,
  	use=xterm,
diff -c mit/clients/xterm/xterm.man:1.3 mit/clients/xterm/xterm.man:2.0
*** mit/clients/xterm/xterm.man:1.3	Sat Mar 12 00:16:05 1994
--- mit/clients/xterm/xterm.man	Sat Mar 12 00:16:05 1994
***************
*** 1,4 ****
! .\" $XConsortium: xterm.man,v 1.72 91/08/23 18:46:18 gildea Exp $
  .TH XTERM 1 "Release 5" "X Version 11"
  .SH NAME
  xterm \- terminal emulator for X
--- 1,4 ----
! .\" $XConsortium: xterm.man,v 1.72.1.1 93/11/03 18:03:48 gildea Exp $
  .TH XTERM 1 "Release 5" "X Version 11"
  .SH NAME
  xterm \- terminal emulator for X
***************
*** 39,45 ****
  .PP
  Many of the special
  .I xterm
! features (like logging) may be modified under program control
  through a set of escape sequences different from the standard VT102 escape
  sequences.  
  (See the
--- 39,45 ----
  .PP
  Many of the special
  .I xterm
! features may be modified under program control
  through a set of escape sequences different from the standard VT102 escape
  sequences.  
  (See the
***************
*** 93,103 ****
  on exit.  
  .PP
  In either VT102 or Tektronix mode, there are escape sequences to change the
! name of the windows and to specify a new log file name.
  See \fIXterm Control Sequences\fP for details.
- Enabling the escape sequence to change the
- log file name is a compile-time option;
- by default this escape sequence is ignored for security reasons.
  .SH OPTIONS
  The \fIxterm\fP terminal emulator 
  accepts all of the standard X Toolkit command line options as well as
--- 93,100 ----
  on exit.  
  .PP
  In either VT102 or Tektronix mode, there are escape sequences to change the
! name of the windows.
  See \fIXterm Control Sequences\fP for details.
  .SH OPTIONS
  The \fIxterm\fP terminal emulator 
  accepts all of the standard X Toolkit command line options as well as
***************
*** 203,227 ****
  .B \+j
  This option indicates that \fIxterm\fP should not do jump scrolling.
  .TP 8
- .B \-l
- This option indicates that \fIxterm\fP should send all terminal output to
- a log file as well as to the screen.  This option can be enabled or disabled
- using the ``VT Options'' menu.
- .TP 8
- .B \+l
- This option indicates that \fIxterm\fP should not do logging.
- .TP 8
- .BI \-lf " filename"
- This option specifies the name of the file to which the output log described
- above is written.  If \fIfile\fP begins with a pipe symbol (|), the rest of 
- the string is assumed to be a command to be used as the endpoint of a pipe.
- The ability to log to a pipe is a compile-time option which is
- disabled by default for security reasons.
- The default filename is ``\fBXtermLog.\fIXXXXX\fR'' (where \fIXXXXX\fP
- is the process id of \fIxterm\fP) and is created in the directory from which
- \fIxterm\fP was started (or the user's home directory in the case of a
- login window).
- .TP 8
  .B \-ls
  This option indicates that the shell that is started in the \fIxterm\fP window
  be a login shell (i.e. the first character of argv[0] will be a dash,
--- 200,205 ----
***************
*** 634,652 ****
  .B "jumpScroll (\fPclass\fB JumpScroll)"
  Specifies whether or not jump scroll should be used.  The default is ``true.''
  .TP 8
- .B "logFile (\fPclass\fB Logfile)"
- Specifies the name of the file to which a terminal session is logged.  The
- default is ``\fBXtermLog.\fIXXXXX\fR'' (where \fIXXXXX\fP
- is the process id of \fIxterm\fP).
- .TP 8
- .B "logging (\fPclass\fB Logging)"
- Specifies whether or not a terminal session should be logged.  The default is
- ``false.''
- .TP 8
- .B "logInhibit (\fPclass\fB LogInhibit)"
- Specifies whether or not terminal session logging should be inhibited.  The
- default is ``false.''
- .TP 8
  .B "loginShell (\fPclass\fB LoginShell)"
  Specifies whether or not the shell to be run in the window should be started
  as a login shell.  The default is ``false.''
--- 612,617 ----
***************
*** 804,812 ****
  .B "allowsends (\fPclass\fB SmeBSB)"
  This entry invokes the \fBallow-send-events(toggle)\fP action.
  .TP 8
- .B "logging (\fPclass\fB SmeBSB)"
- This entry invokes the \fBset-logging(toggle)\fP action.
- .TP 8
  .B "redraw (\fPclass\fB SmeBSB)"
  This entry invokes the \fBredraw()\fP action.
  .TP 8
--- 769,774 ----
***************
*** 1375,1384 ****
  This action set or toggles the \fBallowSendEvents\fP resource and is also
  invoked by the \fBallowsends\fP entry in \fImainMenu\fP.
  .TP 8
- .B "set-logging(\fIon/off/toggle\fP)"
- This action toggles the \fBlogging\fP resource and is also invoked
- by the \fBlogging\fP entry in \fImainMenu\fP.
- .TP 8
  .B "redraw()"
  This action redraws the window and is also invoked by the
  \fIredraw\fP entry in \fImainMenu\fP.
--- 1337,1342 ----
***************
*** 1630,1637 ****
  widgets that don't know about each other.  Ideally, you'd like to be able to
  pick and choose emulator widgets and stick them into a single control widget.
  .PP
! There needs to be a dialog box to allow entry of log file name
! and the COPY file name.
  .SH COPYRIGHT
  Copyright 1989, Massachusetts Institute of Technology.
  .br
--- 1588,1594 ----
  widgets that don't know about each other.  Ideally, you'd like to be able to
  pick and choose emulator widgets and stick them into a single control widget.
  .PP
! There needs to be a dialog box to allow entry of the Tek COPY file name.
  .SH COPYRIGHT
  Copyright 1989, Massachusetts Institute of Technology.
  .br
diff -c mit/demos/xgc/Imakefile:1.4 mit/demos/xgc/Imakefile:2.0
*** mit/demos/xgc/Imakefile:1.4	Sat Mar 12 00:16:13 1994
--- mit/demos/xgc/Imakefile	Sat Mar 12 00:16:13 1994
***************
*** 1,4 ****
! XCOMM $XFree86: mit/demos/xgc/Imakefile,v 1.4 1993/03/27 08:54:04 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.9 91/07/16 23:08:10 gildea Exp $
          DEFINES = 
             SRCS = dashlist.c planemask.c getfile.c tests.c text.c \
--- 1,4 ----
! XCOMM $XFree86: mit/demos/xgc/Imakefile,v 2.0 1993/12/18 11:43:23 dawes Exp $
  XCOMM $XConsortium: Imakefile,v 1.9 91/07/16 23:08:10 gildea Exp $
          DEFINES = 
             SRCS = dashlist.c planemask.c getfile.c tests.c text.c \
***************
*** 12,18 ****
             OBJS = dashlist.o planemask.o getfile.o tests.o text.o \
                    choice.o main.o interpret.o record.o testfrac.o \
                    gram.o lex.o
! LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(XLIB)
          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
    SYS_LIBRARIES = -lm
           YFLAGS = -d
--- 12,18 ----
             OBJS = dashlist.o planemask.o getfile.o tests.o text.o \
                    choice.o main.o interpret.o record.o testfrac.o \
                    gram.o lex.o
! LOCAL_LIBRARIES = $(XAWLIB) $(XMULIB) $(XTOOLLIB) $(LEXLIB) $(XLIB)
          DEPLIBS = $(DEPXAWLIB) $(DEPXMULIB) $(DEPXTOOLLIB) $(DEPXLIB)
    SYS_LIBRARIES = -lm
           YFLAGS = -d
diff -c mit/fonts/PEX/lex.l:2.0 mit/fonts/PEX/lex.l:2.2
*** mit/fonts/PEX/lex.l:2.0	Sat Mar 12 00:16:25 1994
--- mit/fonts/PEX/lex.l	Sat Mar 12 00:16:25 1994
***************
*** 1,5 ****
  %{
! /* $XFree86: mit/fonts/PEX/lex.l,v 2.0 1993/07/24 04:50:22 dawes Exp $ */
  /* $XConsortium: lex.l,v 5.4 91/08/26 10:55:26 gildea Exp $ */
  
  /*****************************************************************
--- 1,5 ----
  %{
! /* $XFree86: mit/fonts/PEX/lex.l,v 2.2 1994/03/10 07:05:29 dawes Exp $ */
  /* $XConsortium: lex.l,v 5.4 91/08/26 10:55:26 gildea Exp $ */
  
  /*****************************************************************
***************
*** 68,73 ****
--- 68,76 ----
  			}
  [()]			;
  %%
+ #ifndef yywrap
+ yywrap() { return(1);}
+ #endif
  
  int
  res_words(str)
***************
*** 120,128 ****
  		str++;
  		n -= 2;	/* one for EOL, one for end quote */
  	}
! 	if ((yylval.cval = (char *)malloc(n)) != NULL)
  	{
  		strncpy(yylval.cval, str, n);
  		return STRING;
  	}
  	else
--- 123,132 ----
  		str++;
  		n -= 2;	/* one for EOL, one for end quote */
  	}
! 	if ((yylval.cval = (char *)malloc(n+1)) != NULL)
  	{
  		strncpy(yylval.cval, str, n);
+ 		yylval.cval[n] = '\0';
  		return STRING;
  	}
  	else
diff -c mit/fonts/PEX/to_wfont.y:1.3 mit/fonts/PEX/to_wfont.y:2.1
*** mit/fonts/PEX/to_wfont.y:1.3	Sat Mar 12 00:16:25 1994
--- mit/fonts/PEX/to_wfont.y	Sat Mar 12 00:16:25 1994
***************
*** 1,5 ****
  %{
! /* $XFree86: mit/fonts/PEX/to_wfont.y,v 1.3 1993/05/18 15:36:27 dawes Exp $ */
  /* $XConsortium: to_wfont.y,v 5.3 91/04/04 16:00:26 gildea Exp $ */
  
  /*****************************************************************
--- 1,5 ----
  %{
! /* $XFree86: mit/fonts/PEX/to_wfont.y,v 2.1 1994/02/10 21:23:00 dawes Exp $ */
  /* $XConsortium: to_wfont.y,v 5.3 91/04/04 16:00:26 gildea Exp $ */
  
  /*****************************************************************
***************
*** 328,334 ****
  
  yyerror()
  {
! #if defined(linux) || defined(__386BSD__)
  	int      yylineno;
  #else
  	extern int      yylineno;
--- 328,334 ----
  
  yyerror()
  {
! #if defined(linux) || (BSD >= 199103)
  	int      yylineno;
  #else
  	extern int      yylineno;
***************
*** 619,628 ****
  	free(table);
  	free(sp_table);
  	free(strokes);
! 	for (i=0; i < head.num_props; i++, head.properties++) {
! 	  if (head.properties != NULL)
! 	    free((char *) head.properties);
! 	}
  }
  
  check_nstroke()
--- 619,625 ----
  	free(table);
  	free(sp_table);
  	free(strokes);
! 	free(head.properties);
  }
  
  check_nstroke()
