diff -u -r xc/config/cf/Imake.cf xc-new/config/cf/Imake.cf
--- xc/config/cf/Imake.cf	Wed Jun 25 05:31:34 1997
+++ xc-new/config/cf/Imake.cf	Sat Apr  3 11:46:27 1999
@@ -408,6 +408,10 @@
 #  define i386Architecture
 #  undef i386
 # endif /* i386 */
+# if defined(__sparc__) || defined(sparc)
+#  define SparcArchitecture
+#  undef sparc
+# endif
 # ifdef __alpha
 #  define AlphaArchitecture
 #  undef __alpha
diff -u -r xc/config/cf/sun.cf xc-new/config/cf/sun.cf
--- xc/config/cf/sun.cf	Tue Dec  9 15:28:07 1997
+++ xc-new/config/cf/sun.cf	Sat Apr  3 14:07:32 1999
@@ -236,7 +236,7 @@
 #define HasPutenv	  YES
 #ifndef i386Architecture
 # ifndef Xsun24Server
-#  define Xsun24Server	  NO		/* color, mono, multiple depths */
+#  define Xsun24Server	  YES		/* color, mono, multiple depths */
 # endif
 # ifndef XsunServer
 #  define XsunServer	  YES		/* color and mono, 8 bit only */
diff -u -r xc/programs/Xserver/Imakefile xc-new/programs/Xserver/Imakefile
--- xc/programs/Xserver/Imakefile	Thu Dec 11 09:13:14 1997
+++ xc-new/programs/Xserver/Imakefile	Sat Apr  3 11:58:05 1999
@@ -11,7 +11,7 @@
 #include <Server.tmpl>
 
 #define PreFbLibs $(DIX) $(OS) $(FONT) $(XPDDX)
-#define BarePostFbLibs $(MFB) $(XPFBLIBS) $(MI)
+#define BarePostFbLibs $(MFB) $(XPFBLIBS) $(MI) $(CBRT)
 #define PostFbLibs BarePostFbLibs $(EXTENSIONS)
 #define NoMfbBarePostFbLibs $(XPFBLIBS) $(MI)
 #ifndef BuildXinerama
@@ -261,9 +261,9 @@
 CFB8DIR = cfb
 DDXDIR1 = hw/sun
 #ifndef AmoebaArchitecture
-SUNOBJS = hw/sun/sunInit.o
+SUNOBJS = hw/sun/sunInit.o hw/sun/sunGX.o hw/sun/sunCfb.o
 #else
-SUNOBJS = hw/sun/sunInitColor.o
+SUNOBJS = hw/sun/sunInitColor.o hw/sun/sunGX.o hw/sun/sunCfb.o
 #endif
 #if BuildLowMem
 SUNDIRS = $(STDDIRS) $(LMFCFBDIR) $(DDXDIR1) $(DEPDIRS)
@@ -290,7 +290,7 @@
 CFB32DIR = cfb32
 DDXDIR1 = hw/sun
 SUN24DIRS = $(STDDIRS) $(MFBDIR) $(CFB8DIR) $(CFB16DIR) $(CFB32DIR) $(DDXDIR1) $(DEPDIRS)
-SUN24OBJS = hw/sun/sunInitMulti.o
+SUN24OBJS = hw/sun/sunInitMulti.o hw/sun/sunGX.o hw/sun/sunCfb.o hw/sun/sunCfb24.o
 SUN24LIBS = hw/sun/LibraryTargetName(sun) CFBLibs
 SetUIDServerTarget(Xsun24,$(SUN24DIRS),$(SUN24OBJS),$(SUN24LIBS),$(SYSLIBS))
 #ifndef ServerToInstall
diff -u -r xc/programs/Xserver/cfb/stipsparc.s xc-new/programs/Xserver/cfb/stipsparc.s
--- xc/programs/Xserver/cfb/stipsparc.s	Mon Feb  9 12:08:38 1998
+++ xc-new/programs/Xserver/cfb/stipsparc.s	Sat Apr  3 11:59:07 1999
@@ -80,7 +80,7 @@
 #define ForEachBits	LY4
 #define NextBits	LY5
 
-#ifdef SVR4
+#ifdef SVR4 || ( defined(linux) && defined(__ELF__) )
 #ifdef TETEXT
 #define	_cfbStippleStack	cfbStippleStackTE
 #else
diff -u -r xc/programs/Xserver/cfb/stipsprc32.s xc-new/programs/Xserver/cfb/stipsprc32.s
--- xc/programs/Xserver/cfb/stipsprc32.s	Mon Feb  9 12:08:44 1998
+++ xc-new/programs/Xserver/cfb/stipsprc32.s	Sat Apr  3 11:59:41 1999
@@ -76,7 +76,7 @@
 #define ForEachBits	LY4
 #define NextBits	LY5
 
-#ifdef SVR4
+#ifdef SVR4 || ( defined(linux) && defined(__ELF__) )
 #ifdef TETEXT
 #define	_cfb32StippleStack	cfb32StippleStackTE
 #else
diff -u -r xc/programs/Xserver/hw/sun/Imakefile xc-new/programs/Xserver/hw/sun/Imakefile
--- xc/programs/Xserver/hw/sun/Imakefile	Thu Nov 13 13:48:40 1997
+++ xc-new/programs/Xserver/hw/sun/Imakefile	Sat Apr  3 12:17:14 1999
@@ -21,9 +21,15 @@
 SRCS =	$(SRCS1) $(SRCS2) kbd_mode.c constype.c
 
 #ifdef i386Architecture
-OFILES = sunInit.o
+OFILES = sunInit.o sunGX.o sunCfb.o sunCfb24.o
 #else
-OFILES = sunInit.o sunInitMono.o sunInExMono.o sunInitMulti.o
+OFILES = sunInit.o sunInitMono.o sunInExMono.o sunInitMulti.o sunGX.o sunCfb.o sunCfb24.o
+#endif
+
+#ifdef LinuxArchitecture
+LINUXOBJS = linux.o
+#else
+LINUXOBJS =
 #endif
 
 OBJS1 = sunCfb.o \
@@ -34,7 +40,8 @@
 	sunKbd.o \
 	sunMfb.o \
 	sunMouse.o \
-	sunKeyMap.o
+	sunKeyMap.o \
+	$(LINUXOBJS)
 
 #if BuildLowMem
 OBJS2 =
@@ -57,6 +64,10 @@
 
 NormalLibraryTarget(sun,$(OBJS))
 NormalLintTarget($(SRCS1))
+
+SpecialCObjectRule(sunCfb,,)
+SpecialCObjectRule(sunCfb24,,)
+SpecialCObjectRule(sunGX,,)
 
 #ifndef i386Architecture
 sunInExMono.o: $(ICONFIGFILES)
diff -u -r xc/programs/Xserver/hw/sun/constype.c xc-new/programs/Xserver/hw/sun/constype.c
--- xc/programs/Xserver/hw/sun/constype.c	Thu Oct 31 12:28:08 1996
+++ xc-new/programs/Xserver/hw/sun/constype.c	Sat Apr  3 12:09:02 1999
@@ -58,7 +58,11 @@
 	dev = argv[1];
 	argc--; argv++;
     } else
+#ifndef linux
 	dev = "/dev/fb";
+#else
+	dev = "/dev/fb0";
+#endif
     error = wu_fbid(dev, &fbname, &fbtype );
     if (argc > 1 && strncmp (argv[1], "-num", strlen(argv[1])) == 0)
 	print_num = 1;
@@ -77,7 +81,11 @@
 #include <sys/fbio.h>
 #else
 #ifndef CSRG_BASED
+# ifndef linux
 #include <sun/fbio.h>
+# else
+#include <asm/fbio.h>
+# endif
 #else
 #include <machine/fbio.h>
 #endif
diff -u -r xc/programs/Xserver/hw/sun/kbd_mode.c xc-new/programs/Xserver/hw/sun/kbd_mode.c
--- xc/programs/Xserver/hw/sun/kbd_mode.c	Tue Feb 10 11:15:48 1998
+++ xc-new/programs/Xserver/hw/sun/kbd_mode.c	Sat Apr  3 12:14:33 1999
@@ -53,8 +53,33 @@
 #endif
 #else
 #ifndef CSRG_BASED
+# ifndef linux
 #include <sundev/kbio.h>
 #include <sundev/kbd.h>
+# else
+#include <asm/kbio.h>
+/*
+ * Commands to the Sun-2 keyboard.
+ */
+#define KBD_CMD_RESET           0x01    /* Reset keyboard as if power-up */
+#define KBD_CMD_BELL            0x02    /* Turn on the bell */
+#define KBD_CMD_NOBELL          0x03    /* Turn off the bell */
+#define KBD_CMD_LED1            0x04    /* Turn on LED 1 */
+#define KBD_CMD_NOLED1          0x05    /* Turn off LED 1 */
+#define KBD_CMD_LED2            0x06    /* Turn on LED 2 */
+#define KBD_CMD_NOLED2          0x07    /* Turn off LED 2 */
+/*
+ * Commands to the Type 3 keyboard.  KBD_CMD_BELL & KBD_CMD_NOBELL work
+ * as well.
+ */
+#define KBD_CMD_CLICK           0x0A    /* Turn on the click annunciator */
+#define KBD_CMD_NOCLICK         0x0B    /* Turn off the click annunciator */
+/*
+ * Commands to the Type 4 keyboard, in addition to those above.
+ */
+#define KBD_CMD_SETLED          0x0E    /* Set keyboard LED's */
+#define KBD_CMD_GETLAYOUT       0x0F    /* Request that keyboard indicate layout */
+# endif
 #else
 #include <machine/kbio.h>
 #include <machine/kbd.h>
@@ -107,9 +132,27 @@
     led = 0;
     if (ioctl(kbd_fd, KIOCSLED, &led))
 	die("Couldn't set LEDs");
+    led = 0xE;
+    if (ioctl(kbd_fd, KIOCSLED, &led))
+       die("Couldn't set LEDs");
+    sleep(1);
+    led = 0x1;
+    if (ioctl(kbd_fd, KIOCSLED, &led))
+       die("Couldn't set LEDs");
+    sleep(1);
+    led = 0;
+    if (ioctl(kbd_fd, KIOCSLED, &led))
+       die("Couldn't set LEDs");
 #endif
 #ifdef KIOCCMD
     click = KBD_CMD_NOCLICK;
+    if (ioctl(kbd_fd, KIOCCMD, &click))
+	die("Couldn't set click");
+    click = KBD_CMD_BELL;
+    if (ioctl(kbd_fd, KIOCCMD, &click))
+       die("Couldn't set click");
+    sleep(1);
+    click = KBD_CMD_NOBELL;
     if (ioctl(kbd_fd, KIOCCMD, &click))
 	die("Couldn't set click");
 #endif
Only in xc-new/programs/Xserver/hw/sun: linux.c
diff -u -r xc/programs/Xserver/hw/sun/sun.h xc-new/programs/Xserver/hw/sun/sun.h
--- xc/programs/Xserver/hw/sun/sun.h	Thu Oct 16 13:25:07 1997
+++ xc-new/programs/Xserver/hw/sun/sun.h	Mon Apr  5 13:44:32 1999
@@ -33,10 +33,15 @@
 /* system headers common to both SunOS and Solaris */
 #include <sys/param.h>
 #include <sys/file.h>
-#include <sys/filio.h>
 #include <sys/ioctl.h>
 #include <sys/resource.h>
 
+#ifndef linux
+#include <sys/filio.h>
+#else
+#include <linux/termios.h>
+#endif
+
 #ifdef SVR4
 # ifdef X_POSIX_C_SOURCE
 #  define _POSIX_C_SOURCE X_POSIX_C_SOURCE
@@ -51,7 +56,7 @@
 
 #include <fcntl.h>
 
-#ifndef __bsdi_
+#if !defined(__bsdi_) && !defined(linux)
 # ifndef CSRG_BASED
 #  ifndef i386
 #   include <poll.h>
@@ -86,7 +91,7 @@
 # include <stropts.h>
 # define usleep(usec) poll((struct pollfd *) 0, (size_t) 0, usec / 1000)
 #else
-# ifndef CSRG_BASED
+# ifndef CSRG_BASED && !defined (linux)
 #  include <sun/fbio.h>
 #  include <sundev/kbd.h>
 #  include <sundev/kbio.h>
@@ -99,6 +104,49 @@
 extern int setrlimit();
 extern int getpagesize();
 # else
+#  ifdef linux
+#define KB_KLUNK        0x00            /* Micro Switch 103SD32-2 */
+#define KB_VT100        0x01            /* Keytronics VT100 compatible */
+#define KB_SUN2         0x02            /* Sun-2 custom keyboard */
+#define KB_SUN3         0x03            /* Type 3 Sun keyboard */
+#define KB_SUN4         0x04            /* Type 4 Sun keyboard */
+#define KB_VT220        0x81            /* Emulation vt220 */
+#define KB_VT220I       0x82            /* International vt220 Emulation */
+#define KB_ASCII        0x0F            /* Ascii terminal masquerading as kbd */
+/*
+ * Commands to the Sun-2 keyboard.
+ */
+#define KBD_CMD_RESET           0x01    /* Reset keyboard as if power-up */
+#define KBD_CMD_BELL            0x02    /* Turn on the bell */
+#define KBD_CMD_NOBELL          0x03    /* Turn off the bell */
+#define KBD_CMD_LED1            0x04    /* Turn on LED 1 */
+#define KBD_CMD_NOLED1          0x05    /* Turn off LED 1 */
+#define KBD_CMD_LED2            0x06    /* Turn on LED 2 */
+#define KBD_CMD_NOLED2          0x07    /* Turn off LED 2 */
+/*
+ * Commands to the Type 3 keyboard.  KBD_CMD_BELL & KBD_CMD_NOBELL work
+ * as well.
+ */
+#define KBD_CMD_CLICK           0x0A    /* Turn on the click annunciator */
+#define KBD_CMD_NOCLICK         0x0B    /* Turn off the click annunciator */
+/*
+ * Commands to the Type 4 keyboard, in addition to those above.
+ */
+#define KBD_CMD_SETLED          0x0E    /* Set keyboard LED's */
+#define KBD_CMD_GETLAYOUT       0x0F    /* Request that keyboard indicate layout */
+/*
+ * Type 4 keyboard LED masks (used to set LED's)
+ */
+#define LED_NUM_LOCK    0x1
+#define LED_COMPOSE     0x2
+#define LED_SCROLL_LOCK 0x4
+#define LED_CAPS_LOCK   0x8
+# include <asm/fbio.h>
+# include <asm/kbio.h>
+# include <asm/vuid_event.h>
+# include <asm/memreg.h>
+# include <signal.h>
+#endif
 #  ifdef CSRG_BASED
 #   include <machine/fbio.h>
 #   include <machine/kbd.h>
@@ -118,8 +166,13 @@
  * Sun doesn't see fit to add the TCX to <sys/fbio.h>
  */
 #ifndef SVR4
+# ifdef linux
+#define XFBTYPE_TCX		FBTYPE_TCXCOLOR
+#define XFBTYPE_LASTPLUSONE	22
+# else
 /* On SunOS 4.1.x the TCX pretends to be a CG3 */
-#define XFBTYPE_LASTPLUSONE	FBTYPE_LASTPLUSONE	
+#define XFBTYPE_LASTPLUSONE	FBTYPE_LASTPLUSONE
+# endif
 #else
 #define XFBTYPE_TCX		21
 #define XFBTYPE_LASTPLUSONE	22
@@ -200,6 +253,10 @@
 # define BWTWO2DEV	"/dev/bwtwo2"
 # define BWTWO3DEV	"/dev/bwtwo3"
 # define CGEIGHT0DEV	"/dev/cgeight0"
+# define TCX0DEV	"/dev/tcx0"
+# define TCX1DEV	"/dev/tcx1"
+# define TCX2DEV	"/dev/tcx2"
+# define TCX3DEV	"/dev/tcx3"
 #endif
 
 /*
@@ -260,6 +317,18 @@
     struct fbtype   info;	/* Frame buffer characteristics */
     void	    (*EnterLeave)();/* screen switch */
     unsigned char*  fbPriv;	/* fbattr stuff, for the real type */
+    int		    cursor_type;
+    void *          cursor_regs;
+#ifdef linux
+    struct fbcmap   origcmap;
+    void           (*vtchange)(
+#if NeedFunctionPrototypes
+    int /* screen */,
+    int /* enter */
+#endif
+    );
+    void *         private;
+#endif
 } fbFd;
 
 typedef Bool (*sunFbInitProc)(
@@ -276,6 +345,12 @@
     char*		name;	/* /usr/include/fbio names */
 } sunFbDataRec;
 
+#ifdef linux
+extern int		vtOn;
+#else
+#define vtOn		-1
+#endif
+
 #ifdef XKB
 extern Bool		noXkbExtension;
 #endif
@@ -491,5 +566,37 @@
     Colormap* /* pCmapList */
 #endif
 );
+
+#ifdef linux
+
+extern void sunDoBitBlt(
+#if NeedFunctionPrototypes
+    DrawablePtr /* ppix */,
+    DrawablePtr /* pspix */,
+    int /* bpp */,
+    RegionPtr /* pixReg */,
+    DDXPointPtr /* pixPt */
+#endif
+);
+
+extern void sunRefreshColormap(
+#if NeedFunctionPrototypes
+    int /* idx */
+#endif
+);
+
+extern PixmapPtr sunGetScreenPixmap(
+#if NeedFunctionPrototypes
+    int /* screen */
+#endif
+);
+
+extern void linuxSetConsoleFb(
+#if NeedFunctionPrototypes
+    int /* idx */
+#endif
+);
+
+#endif
 
 #endif
diff -u -r xc/programs/Xserver/hw/sun/sunCfb.c xc-new/programs/Xserver/hw/sun/sunCfb.c
--- xc/programs/Xserver/hw/sun/sunCfb.c	Tue Feb 10 11:16:02 1998
+++ xc-new/programs/Xserver/hw/sun/sunCfb.c	Sat Apr  3 13:53:13 1999
@@ -92,6 +92,7 @@
 {
     struct fbcmap sunCmap;
 
+    if (!vtOn) return;
     sunCmap.index = dex;
     sunCmap.count = count;
     sunCmap.red = &rmap[dex];
@@ -259,7 +260,7 @@
 
     for (i = 1; i < argc; i++)
 	if (strcmp (argv[i], "-mono") == 0)
-	    ErrorF ("-mono not appropriate for CG3/CG4/CG6\n");
+	    ErrorF ("-mono not appropriate for CG3/CG4/CG6/TCX\n");
 }
 
 /*
@@ -285,21 +286,31 @@
 	cfbCreateDefColormap, sunSaveScreen, 0);
 }
 
-Bool sunTCXInit (screen, pScreen, argc, argv)
+#define TCX_MMAP_CURSOR_OFFSET 0x70004000
+Bool sunTCX8Init (screen, pScreen, argc, argv)
     int	    	  screen;    	/* what screen am I going to be */
     ScreenPtr	  pScreen;  	/* The Screen to initialize */
     int	    	  argc;	    	/* The number of the Server's arguments. */
     char    	  **argv;   	/* The arguments themselves. Don't change! */
 {
+    Bool ret;
+    char *p;
+
     checkMono (argc, argv);
     sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
-    return sunInitCommon (screen, pScreen, (off_t) 0,
+    ret = sunInitCommon (screen, pScreen, (off_t) 0,
 	sunCfbScreenInit, CGScreenInit,
 	cfbCreateDefColormap, sunSaveScreen, 0);
+    if ((p = sunMemoryMap (4096, (off_t) TCX_MMAP_CURSOR_OFFSET,
+        sunFbs[screen].fd)) != NULL) {
+        sunFbs[screen].cursor_type = FBTYPE_SUNFAST_COLOR; /* thc is same as on cg6 */
+        sunFbs[screen].cursor_regs = ((char *)p) + 0x8fc;
+    }
+    return ret;
 }
 
 #if !defined(i386) && !defined(__bsdi__) /* { */
-
+#ifndef linux /* Only have definitions for cg6 */
 #ifdef SVR4
 #include <sys/cg2reg.h>
 #else
@@ -448,11 +459,12 @@
 	sunCfbScreenInit, CGScreenInit,
 	cfbCreateDefColormap, sunSaveScreen, (int) ((CG4Ptr) 0)->cpixel);
 }
-
+#endif /* !linux */
 #ifdef FBTYPE_SUNFAST_COLOR /* { */
 
 #define CG6_MMAP_OFFSET 0x70000000
 #define CG6_IMAGE_OFFSET 0x16000
+#define CG6_CURSOR_OFFSET 0x58fc
 
 Bool sunCG6Init (screen, pScreen, argc, argv)
     int		screen;    	/* The index of pScreen in the ScreenInfo */
@@ -477,6 +489,8 @@
 #undef FBSIZE
     }
     sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+    sunFbs[screen].cursor_type = FBTYPE_SUNFAST_COLOR;
+    sunFbs[screen].cursor_regs = sunFbs[screen].fb + CG6_CURSOR_OFFSET;
     if (!sunCfbSetupScreen (pScreen, 
 	    sunFbs[screen].fb + CG6_IMAGE_OFFSET,
 	    sunFbs[screen].info.fb_width, 
diff -u -r xc/programs/Xserver/hw/sun/sunCfb24.c xc-new/programs/Xserver/hw/sun/sunCfb24.c
--- xc/programs/Xserver/hw/sun/sunCfb24.c	Tue Feb 10 11:15:57 1998
+++ xc-new/programs/Xserver/hw/sun/sunCfb24.c	Sat Apr  3 13:54:35 1999
@@ -46,7 +46,7 @@
 #define PIXPG_24BIT_COLOR_INDEX (PIXPG_24BIT_COLOR << 25)
 #define PR_FORCE_UPDATE (1 << 24)
 
-static void CG24UpdateColormap(pScreen, index, count, rmap, gmap, bmap)
+static void sunCG8UpdateColormap(pScreen, index, count, rmap, gmap, bmap)
     ScreenPtr	pScreen;
     int		index, count;
     u_char	*rmap, *gmap, *bmap;
@@ -60,10 +60,10 @@
     sunCmap.blue = &bmap[index];
 
     if (ioctl(sunFbs[pScreen->myNum].fd, FBIOPUTCMAP, &sunCmap) == -1)
-	FatalError( "CG24UpdateColormap: FBIOPUTCMAP failed\n");
+	FatalError( "sunCG8UpdateColormap: FBIOPUTCMAP failed\n");
 }
 
-static void CG24StoreColors (pmap, ndef, pdefs)
+static void sunCG8StoreColors (pmap, ndef, pdefs)
     ColormapPtr pmap;
     int ndef;
     xColorItem* pdefs;
@@ -91,12 +91,12 @@
       bmap[(i & pVisual->blueMask) >> pVisual->offsetBlue] = (pdefs->blue >> 8);
     pdefs++;
   }
-  CG24UpdateColormap (pmap->pScreen, 0, 256, rmap, gmap, bmap);
+  sunCG8UpdateColormap (pmap->pScreen, 0, 256, rmap, gmap, bmap);
 }
 
 #define CG8_COLOR_OFFSET 0x40000
 
-static void CG24ScreenInit (pScreen)
+static void sunCG8ScreenInit (pScreen)
     ScreenPtr pScreen;
 {
 #ifndef STATIC_COLOR
@@ -112,8 +112,8 @@
     pScreen->InstallColormap = sunInstallColormap;
     pScreen->UninstallColormap = sunUninstallColormap;
     pScreen->ListInstalledColormaps = sunListInstalledColormaps;
-    pScreen->StoreColors = CG24StoreColors;
-    pPrivate->UpdateColormap = CG24UpdateColormap;
+    pScreen->StoreColors = sunCG8StoreColors;
+    pPrivate->UpdateColormap = sunCG8UpdateColormap;
     if (sunFlipPixels) {
 	Pixel pixel = pScreen->whitePixel;
 	pScreen->whitePixel = pScreen->blackPixel;
@@ -130,7 +130,156 @@
 {
     sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
     return sunInitCommon (screen, pScreen, (off_t) 0,
-	cfb32ScreenInit, CG24ScreenInit,
+	cfb32ScreenInit, sunCG8ScreenInit,
 	cfbCreateDefColormap, sunSaveScreen, CG8_COLOR_OFFSET);
 }
 
+#define TCX_MMAP_RAM_OFFSET	0x01000000
+#define TCX_MMAP_CURSOR_OFFSET 	0x70004000
+#define TCX_MMAP_CONTROL_OFFSET 0x28000000
+
+#define TCX_CPLANE_MODE        0x3000000
+
+static void sunTCX24UpdateColormap(pScreen, index, count, rmap, gmap, bmap)
+    ScreenPtr  pScreen;
+    int                index, count;
+    u_char     *rmap, *gmap, *bmap;
+{
+    struct fbcmap sunCmap;
+    
+    sunCmap.index = index;
+    sunCmap.count = count;
+    sunCmap.red = &rmap[index];
+    sunCmap.green = &gmap[index];
+    sunCmap.blue = &bmap[index];
+    
+    if (ioctl(sunFbs[pScreen->myNum].fd, FBIOPUTCMAP, &sunCmap) == -1)
+        FatalError( "sunTCX24UpdateColormap: FBIOPUTCMAP failed\n");
+}
+
+static void sunTCX24StoreColors (pmap, ndef, pdefs)
+    ColormapPtr pmap;
+    int ndef;
+    xColorItem* pdefs;
+{
+  struct fbcmap cmap;
+  u_char rmap[256], gmap[256], bmap[256];
+  SetupScreen (pmap->pScreen);
+  VisualPtr pVisual = pmap->pVisual;
+  int i;
+ 
+  if (pPrivate->installedMap != NULL && pPrivate->installedMap != pmap)
+    return;
+  for (i = 0; i < 256; i++) {
+    rmap[i] = pmap->red[i].co.local.red >> 8;
+    gmap[i] = pmap->green[i].co.local.green >> 8;
+    bmap[i] = pmap->blue[i].co.local.blue >> 8;
+  }
+  while (ndef--) {
+    i = pdefs->pixel;
+    if (pdefs->flags & DoRed)
+      rmap[(i & pVisual->redMask) >> pVisual->offsetRed] = (pdefs->red >> 8);
+    if (pdefs->flags & DoGreen)
+      gmap[(i & pVisual->greenMask) >> pVisual->offsetGreen] = (pdefs->green >> 8);
+    if (pdefs->flags & DoBlue)                                        
+      bmap[(i & pVisual->blueMask) >> pVisual->offsetBlue] = (pdefs->blue >> 8);
+    pdefs++;
+  }
+  sunTCX24UpdateColormap (pmap->pScreen, 0, 256, rmap, gmap, bmap);
+}
+
+static void sunTCX24ScreenInit (pScreen)
+    ScreenPtr pScreen;
+{
+    SetupScreen (pScreen);
+
+    pScreen->InstallColormap = sunInstallColormap;
+    pScreen->UninstallColormap = sunUninstallColormap;
+    pScreen->ListInstalledColormaps = sunListInstalledColormaps;
+    pScreen->StoreColors = sunTCX24StoreColors;
+    pPrivate->UpdateColormap = sunTCX24UpdateColormap;
+    if (sunFlipPixels) {
+       Pixel pixel = pScreen->whitePixel;
+       pScreen->whitePixel = pScreen->blackPixel;
+       pScreen->blackPixel = pixel;
+    }
+}
+
+#ifdef linux
+static void tcx_vtchange (screen, enter)
+    int screen;
+    int enter;
+{
+    unsigned   *p, *q;
+    
+    memset (sunFbs[screen].fb, 0, sunFbs[screen].info.fb_width * sunFbs[screen].info.fb_height * 4);
+    if (enter)
+        for (p = sunFbs[screen].private, q = p + sunFbs[screen].info.fb_width * sunFbs[screen].info.fb_height; p < q; p++)
+           *p = (*p & 0xffffff) | TCX_CPLANE_MODE;
+}
+#endif
+
+Bool sunTCX24Init (screen, pScreen, argc, argv)
+    int		screen;     /* what screen am I going to be */
+    ScreenPtr	pScreen;    /* The Screen to initialize */
+    int		argc;       /* The number of the Server's arguments. */
+    char	**argv;     /* The arguments themselves. Don't change! */
+{
+    pointer    fb;
+    unsigned   *p, *q;
+
+    if (!sunScreenAllocate (pScreen))
+       return FALSE;
+    if (!sunFbs[screen].fb) {
+#define FBSIZE (size_t) sunFbs[screen].info.fb_width * sunFbs[screen].info.fb_height * 4
+       if ((fb = sunMemoryMap (FBSIZE,
+                            (off_t) TCX_MMAP_RAM_OFFSET, 
+                            sunFbs[screen].fd)) == NULL) {
+           return FALSE;
+        }
+       sunFbs[screen].fb = fb;
+       if ((p = sunMemoryMap (4096,
+                           (off_t) TCX_MMAP_CURSOR_OFFSET,
+                           sunFbs[screen].fd)) != NULL) {
+           sunFbs[screen].cursor_type = FBTYPE_SUNFAST_COLOR; /* thc is same as on cg6 */
+           sunFbs[screen].cursor_regs = ((char *)p) + 0x8fc;
+       }
+
+       if ((p = sunMemoryMap (FBSIZE,
+                           (off_t) TCX_MMAP_CONTROL_OFFSET,
+                           sunFbs[screen].fd)) == NULL) {
+           return FALSE;
+       }
+#ifdef linux
+       sunFbs[screen].vtchange = tcx_vtchange;
+       sunFbs[screen].private = (void *)p;
+#endif     
+       memset (fb, 0, FBSIZE);
+       for (q = p + (FBSIZE / 4); p < q; p++)
+           *p = (*p & 0xffffff) | TCX_CPLANE_MODE;
+#undef FBSIZE
+    }
+    sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+    if (!cfb32SetupScreen (pScreen, 
+           sunFbs[screen].fb,
+           sunFbs[screen].info.fb_width, 
+           sunFbs[screen].info.fb_height,
+           monitorResolution, monitorResolution, 
+           sunFbs[screen].info.fb_width))
+       return FALSE;
+    if (!cfbSetVisualTypes (24, 1 << TrueColor, 8))
+        return FALSE;
+    if (!cfb32FinishScreenInit (pScreen, 
+           sunFbs[screen].fb,
+           sunFbs[screen].info.fb_width, 
+           sunFbs[screen].info.fb_height,
+           monitorResolution, monitorResolution, 
+           sunFbs[screen].info.fb_width))
+       return FALSE;
+    sunTCX24ScreenInit (pScreen);
+    if (!sunScreenInit (pScreen)) {
+       return FALSE;
+    }
+    sunSaveScreen (pScreen, SCREEN_SAVER_OFF);
+    return cfbCreateDefColormap(pScreen);
+}
diff -u -r xc/programs/Xserver/hw/sun/sunCursor.c xc-new/programs/Xserver/hw/sun/sunCursor.c
--- xc/programs/Xserver/hw/sun/sunCursor.c	Tue Feb 10 11:16:06 1998
+++ xc-new/programs/Xserver/hw/sun/sunCursor.c	Sat Apr  3 13:55:49 1999
@@ -40,7 +40,7 @@
 
 static void sunLoadCursor();
 
-static Bool
+Bool
 sunRealizeCursor (pScreen, pCursor)
     ScreenPtr	pScreen;
     CursorPtr	pCursor;
@@ -48,6 +48,7 @@
     SetupCursor(pScreen);
     int	    x, y;
 
+    if (!vtOn) return TRUE;
     /* miRecolorCursor does this */
     if (pCurPriv->pCursor == pCursor)
     {
@@ -121,6 +122,7 @@
     DDXPointRec	ptSrc;
     unsigned char   source_temp[1024], mask_temp[1024];
 
+    if (!vtOn) return;
     fbcursor.set = FB_CUR_SETALL;
     fbcursor.enable = 1;
     fbcursor.pos.x = x;
@@ -184,6 +186,33 @@
     SetupCursor(pScreen);
     struct fbcurpos pos;
 
+#ifdef linux
+    if (!vtOn) return;
+    /* Ugly hack to save some syscalls when we can do it easily in userland -
+     * moving mouse pointer happens pretty often while using X */
+    switch (sunFbs[pScreen->myNum].cursor_type) {
+    case FBTYPE_SUNFAST_COLOR:
+       *(volatile unsigned int *)sunFbs[pScreen->myNum].cursor_regs =
+           ((x - pCurPriv->pCursor->bits->xhot) << 16) |
+           ((y - pCurPriv->pCursor->bits->yhot) & 0xffff);
+       return;
+    case FBTYPE_MDICOLOR:
+       *(volatile unsigned char *)sunFbs[pScreen->myNum].cursor_regs |= 4;
+       *(((volatile unsigned short *)sunFbs[pScreen->myNum].cursor_regs)+2) = 
+           ((x - pCurPriv->pCursor->bits->xhot) & 0xfff);
+       *(((volatile unsigned short *)sunFbs[pScreen->myNum].cursor_regs)+3) = 
+           ((y - pCurPriv->pCursor->bits->yhot) & 0xfff);
+       return;
+    case FBTYPE_SUNLEO:
+       *(volatile unsigned int *)sunFbs[pScreen->myNum].cursor_regs &= ~0x80;
+       *(((volatile unsigned int *)sunFbs[pScreen->myNum].cursor_regs)+1) =
+           ((x - pCurPriv->pCursor->bits->xhot) & 0x7ff) |
+           (((y - pCurPriv->pCursor->bits->yhot) & 0x7ff) << 11);
+       *(volatile unsigned int *)sunFbs[pScreen->myNum].cursor_regs |= 0x30;
+       *(volatile unsigned int *)sunFbs[pScreen->myNum].cursor_regs |= 0x80;
+       return;
+    }
+#endif
     pos.x = x;
     pos.y = y;
     ioctl (sunFbs[pScreen->myNum].fd, FBIOSCURPOS, &pos);
@@ -268,6 +297,7 @@
     SetupCursor (pScreen);
     struct fbcursor fbcursor;
 
+    if (!vtOn) return;
     if (pCurPriv->has_cursor)
     {
     	fbcursor.set = FB_CUR_SETCUR;
diff -u -r xc/programs/Xserver/hw/sun/sunFbs.c xc-new/programs/Xserver/hw/sun/sunFbs.c
--- xc/programs/Xserver/hw/sun/sunFbs.c	Tue Feb 10 11:16:11 1998
+++ xc-new/programs/Xserver/hw/sun/sunFbs.c	Sat Apr  3 12:52:47 1999
@@ -98,7 +98,7 @@
     mapsize = ((int) len + pagemask) & ~pagemask;
     addr = 0;
 
-#if !defined(__bsdi__) && !defined(_MAP_NEW)
+#if !defined(linux) && !defined(__bsdi__) && !defined(_MAP_NEW)
     if ((addr = (caddr_t) valloc (mapsize)) == NULL) {
 	Error ("Couldn't allocate frame buffer memory");
 	(void) close (fd);
@@ -113,11 +113,11 @@
      */
     if ((int)(mapaddr = (pointer) mmap (addr,
 		mapsize,
-		PROT_READ | PROT_WRITE, MAP_PRIVATE,
+		PROT_READ | PROT_WRITE, MAP_PRIVATE | _MAP_NEW,
 		fd, off)) == -1)
 	mapaddr = (pointer) mmap (addr,
 		    mapsize,
-		    PROT_READ | PROT_WRITE, MAP_SHARED,
+		    PROT_READ | PROT_WRITE, MAP_SHARED | _MAP_NEW,
 		    fd, off);
     if (mapaddr == (pointer) -1) {
 	Error ("mapping frame buffer memory");
diff -u -r xc/programs/Xserver/hw/sun/sunGX.c xc-new/programs/Xserver/hw/sun/sunGX.c
--- xc/programs/Xserver/hw/sun/sunGX.c	Tue Feb 10 11:16:15 1998
+++ xc-new/programs/Xserver/hw/sun/sunGX.c	Mon Apr  5 13:54:48 1999
@@ -413,7 +413,8 @@
     int width, height;
     int dstx, dsty;
 {
-    if (pSrcDrawable->type != DRAWABLE_WINDOW)
+    if (pSrcDrawable->type != DRAWABLE_WINDOW || 
+        vtOn == pSrcDrawable->pScreen->myNum)
 	return cfbCopyArea (pSrcDrawable, pDstDrawable,
             pGC, srcx, srcy, width, height, dstx, dsty);
     return cfbBitBlt (pSrcDrawable, pDstDrawable,
@@ -547,6 +548,9 @@
     RegionPtr		ret;
     int			(*doBitBlt)();
 
+    if (vtOn == pSrcDrawable->pScreen->myNum) 
+        return cfbCopyPlane(pSrcDrawable, pDstDrawable, pGC, srcx, srcy, width, height, dstx, dsty, bitPlane);
+
     if (pSrcDrawable->bitsPerPixel == 1 && pDstDrawable->bitsPerPixel == 8)
     {
     	if (bitPlane == 1)
@@ -659,6 +663,11 @@
     int		    n;
     int		    xorg, yorg;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        cfbPolyFillRect(pDrawable, pGC, nrectFill, prectInit);
+        return;
+    }
+
     priv = (cfbPrivGC *) pGC->devPrivates[cfbGCPrivateIndex].ptr;
     prgnClip = priv->pCompositeClip;
     prect = prectInit;
@@ -810,6 +819,11 @@
     register int    r;
     BoxPtr	    extents;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        (gxPriv->FillSpans)(pDrawable, pGC, n, ppt, pwidth, fSorted);
+        return;
+    }
+
     GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask)
     if (gxPriv->stipple)
 	GXStippleInit(gx,gxPriv->stipple);
@@ -1069,6 +1083,11 @@
     int			old_width = 0;
 #endif
 
+    if (vtOn == pDraw->pScreen->myNum) {
+        (gxPriv->PolyFillArc)(pDraw, pGC, narcs, parcs);
+        return;
+    }
+
     GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask);
     if (gxPriv->stipple)
 	GXStippleInit(gx,gxPriv->stipple);
@@ -1186,6 +1205,10 @@
     } GXPointRec, *GXPointPtr;
     GXPointPtr	    tri, qua;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        (gxPriv->FillPolygon)(pDrawable, pGC, shape, mode, count, ptsIn);
+        return;
+    }
     if (count < 3)
 	return;
     if (shape != Convex && count > 4)
@@ -1319,6 +1342,11 @@
     int		    r;
     unsigned char   *baseAddr, *loAddr, *hiAddr, *saveAddr = 0, save;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        (gxPriv->PolySegment)(pDrawable, pGC, nseg, pSeg);
+        return;
+    }
+
     GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask);
     if (gxPriv->stipple)
 	GXStippleInit(gx,gxPriv->stipple);
@@ -1386,6 +1414,11 @@
     Bool	    careful;
     Bool	    capNotLast;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        (gxPriv->Polylines)(pDrawable, pGC, mode, npt, ppt);
+        return;
+    }
+
     if (!--npt)
 	return;
     GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_O,pGC->planemask);
@@ -1508,6 +1541,11 @@
     int		    r;
     int		    x, y;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        miPolyRectangle (pDrawable, pGC, nrect, prect);
+        return;
+    }
+
     GXDrawInit(gx,pGC->fgPixel,gx_solid_rop_table[pGC->alu]|POLY_N,pGC->planemask);
     if (gxPriv->stipple)
 	GXStippleInit(gx,gxPriv->stipple);
@@ -1546,6 +1584,12 @@
     BoxPtr	    extents;
     BoxRec	    box;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+        (gxPriv->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+        return;
+    }
+
     clip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
     extents = &clip->extents;
 
@@ -1629,6 +1673,12 @@
     RegionPtr	    clip;
     unsigned long   rop;
 
+    if (vtOn == pDrawable->pScreen->myNum) {
+        sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+        (gxPriv->ImageGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+        return;
+    }
+
     widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
     h = FONTASCENT(pfont) + FONTDESCENT(pfont);
     clip = ((cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr))->pCompositeClip;
@@ -1739,6 +1789,11 @@
     CharInfoPtr *ppci;		/* array of character info */
     pointer pglyphBase;		/* start of array of glyphs */
 {
+    if (vtOn == pDrawable->pScreen->myNum) {
+        sunGXPrivGCPtr gxPriv = sunGXGetGCPrivate (pGC);
+        (gxPriv->PolyGlyphBlt)(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
+        return;
+    }
     sunGXTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, (char *) 1);
 }
 
@@ -2375,6 +2430,18 @@
 		pGC->ops->devPrivate.val = 1;
 	    }
 	}
+#ifdef linux
+       if (newops = cfbMatchCommon (pGC, devPriv))
+       {
+           gxPriv->FillSpans = newops->FillSpans;
+           gxPriv->PolyFillArc = newops->PolyFillArc;
+           gxPriv->FillPolygon = newops->FillPolygon;
+           gxPriv->PolySegment = newops->PolySegment;
+           gxPriv->Polylines = newops->Polylines;
+           gxPriv->PolyGlyphBlt = newops->PolyGlyphBlt;
+           gxPriv->ImageGlyphBlt = newops->ImageGlyphBlt;
+       }
+#endif
     }
 
     canGX = pGC->fillStyle == FillSolid || gxPriv->stipple;
@@ -2384,7 +2451,14 @@
     {
 	pGC->ops->FillPolygon = miFillPolygon;
 	if (devPriv->oneRect && canGX)
+        {
+#ifdef linux
+           gxPriv->FillPolygon = miFillPolygon;
+           if (pGC->fillStyle == FillSolid)
+               gxPriv->FillPolygon = (devPriv->rop == GXcopy) ? cfbFillPoly1RectCopy : cfbFillPoly1RectGeneral;
+#endif
 	    pGC->ops->FillPolygon = sunGXFillPoly1Rect;
+        }
 	if (pGC->lineWidth == 0)
 	{
 	    if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid))
@@ -2415,6 +2489,10 @@
 	    {
 		if (devPriv->oneRect && canGX && widOK)
 		{
+#ifdef linux
+                   gxPriv->PolySegment = cfb8SegmentSS1Rect;
+                   gxPriv->Polylines = cfb8LineSS1Rect;
+#endif
 		    pGC->ops->PolySegment = sunGXPolySeg1Rect;
 		    pGC->ops->Polylines = sunGXPolylines1Rect;
 		}
@@ -2461,6 +2539,13 @@
         {
 	    if (pGC->fillStyle == FillSolid) 
 	    {
+#ifdef linux
+               gxPriv->PolyGlyphBlt = 
+#ifdef WriteBitGroup
+                       (devPriv->rop == GXcopy) ? cfbPolyGlyphBlt8 : 
+#endif
+                       miPolyGlyphBlt;
+#endif
 		if (TERMINALFONT (pGC->font))
 		    pGC->ops->PolyGlyphBlt = sunGXPolyTEGlyphBlt;
 		else
@@ -2478,9 +2563,14 @@
 
 
     if (new_fillspans) {
-	if (canGX)
-	    pGC->ops->FillSpans = sunGXFillSpans;
-	else switch (pGC->fillStyle) {
+	switch (pGC->fillStyle) {
+        case FillSolid:
+           switch(devPriv->rop) {
+               case GXcopy: pGC->ops->FillSpans = cfbSolidSpansCopy; break;
+               case GXxor: pGC->ops->FillSpans = cfbSolidSpansXor; break;
+               default: pGC->ops->FillSpans = cfbSolidSpansGeneral; break;
+           }
+           break;
 	case FillTiled:
 	    if (devPriv->pRotatedPixmap)
 	    {
@@ -2507,6 +2597,12 @@
 	default:
 	    FatalError("cfbValidateGC: illegal fillStyle\n");
 	}
+        if (canGX) {
+#ifdef linux
+           gxPriv->FillSpans = pGC->ops->FillSpans;
+#endif     
+           pGC->ops->FillSpans = sunGXFillSpans;
+        }
     } /* end of new_fillspans */
 
     if (new_fillarea) {
@@ -2514,6 +2610,11 @@
 	pGC->ops->PolyFillArc = miPolyFillArc;
 	if (canGX)
 	{
+#ifdef linux
+           gxPriv->PolyFillArc = miPolyFillArc;
+           if (pGC->fillStyle == FillSolid)
+               gxPriv->PolyFillArc = (devPriv->rop == GXcopy) ? cfbPolyFillArcSolidCopy : cfbPolyFillArcSolidGeneral;      
+#endif
 	    pGC->ops->PolyFillArc = sunGXPolyFillArc;
 	    pGC->ops->PolyFillRect = sunGXPolyFillRect;
 	    if (devPriv->oneRect)
@@ -2549,6 +2650,20 @@
     gxPriv = sunGXGetGCPrivate(pGC);
     gxPriv->type = DRAWABLE_WINDOW;
     gxPriv->stipple = 0;
+#ifdef linux    
+    gxPriv->FillSpans = cfbSolidSpansCopy;
+    gxPriv->PolyFillArc = cfbPolyFillArcSolidCopy;
+    gxPriv->FillPolygon = miFillPolygon;
+    gxPriv->PolySegment = cfbSegmentSS;
+    gxPriv->Polylines = cfbLineSS;
+#ifdef WriteBitGroup    
+    gxPriv->PolyGlyphBlt = cfbImageGlyphBlt8;
+    gxPriv->ImageGlyphBlt = cfbPolyGlyphBlt8;
+#else
+    gxPriv->PolyGlyphBlt = miImageGlyphBlt;
+    gxPriv->ImageGlyphBlt = miPolyGlyphBlt;
+#endif
+#endif
     return TRUE;
 }
 
@@ -2728,6 +2843,11 @@
     WindowPtr	pBgWin;
     pPrivWin = (cfbPrivWin *)(pWin->devPrivates[cfbWindowPrivateIndex].ptr);
 
+    if (vtOn == pWin->drawable.pScreen->myNum) {
+       cfbPaintWindow(pWin, pRegion, what);
+        return;
+    }
+
     switch (what) {
     case PW_BACKGROUND:
 	stipple = sunGXGetWindowPrivate(pWin);
@@ -2822,6 +2942,11 @@
     register int i, nbox;
     WindowPtr pwinRoot;
     extern WindowPtr *WindowTable;
+
+    if (!vtOn) {
+       cfbCopyWindow(pWin, ptOldOrg, prgnSrc);
+       return;
+    }
 
     pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
 
diff -u -r xc/programs/Xserver/hw/sun/sunGX.h xc-new/programs/Xserver/hw/sun/sunGX.h
--- xc/programs/Xserver/hw/sun/sunGX.h	Tue Feb 10 11:16:24 1998
+++ xc-new/programs/Xserver/hw/sun/sunGX.h	Sat Apr  3 13:11:01 1999
@@ -224,6 +224,89 @@
 typedef struct _sunGXPrivGC {
     int		    type;
     sunGXStipplePtr stipple;
+
+    void       (* FillSpans)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*nInit*/,
+               DDXPointPtr /*pptInit*/,
+               int * /*pwidthInit*/,
+               int /*fSorted*/
+#endif
+);
+
+    void       (* Polylines)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*mode*/,
+               int /*npt*/,
+               DDXPointPtr /*pptInit*/
+#endif
+);
+
+    void       (* PolySegment)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*nseg*/,
+               xSegment * /*pSegs*/
+#endif
+);
+
+    void       (* PolyArc)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*narcs*/,
+               xArc * /*parcs*/
+#endif
+);
+
+    void       (* FillPolygon)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*shape*/,
+               int /*mode*/,
+               int /*count*/,
+               DDXPointPtr /*pPts*/
+#endif
+);
+
+    void       (* PolyFillArc)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*narcs*/,
+               xArc * /*parcs*/
+#endif
+);
+
+    void       (* ImageGlyphBlt)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*x*/,
+               int /*y*/,
+               unsigned int /*nglyph*/,
+               CharInfoPtr * /*ppci*/,
+               pointer /*pglyphBase*/
+#endif
+);
+
+    void       (* PolyGlyphBlt)(
+#if NeedNestedPrototypes
+               DrawablePtr /*pDrawable*/,
+               GCPtr /*pGC*/,
+               int /*x*/,
+               int /*y*/,
+               unsigned int /*nglyph*/,
+               CharInfoPtr * /*ppci*/,
+               pointer /*pglyphBase*/
+#endif
+);
 } sunGXPrivGCRec, *sunGXPrivGCPtr;
 
 #define sunGXGetGCPrivate(g)	    ((sunGXPrivGCPtr) \
diff -u -r xc/programs/Xserver/hw/sun/sunInit.c xc-new/programs/Xserver/hw/sun/sunInit.c
--- xc/programs/Xserver/hw/sun/sunInit.c	Tue Feb 10 11:16:29 1998
+++ xc-new/programs/Xserver/hw/sun/sunInit.c	Sat Apr  3 14:06:11 1999
@@ -50,6 +50,10 @@
 #include    "mi.h"
 #include    "mibstore.h"
 #include    "cfb.h"
+#include    <errno.h>
+#ifdef linux
+#include    <sys/stat.h>
+#endif
 
 /* maximum pixmap depth */
 #ifndef SUNMAXDEPTH
@@ -91,7 +95,7 @@
 #endif
 );
 #define CG3I sunCG3Init
-#if defined(i386) || defined(__bsdi__) /* { */
+#if defined(linux) || defined(i386) || defined(__bsdi__) /* { */
 #define CG2I NULL
 #define CG4I NULL
 #else /* }{ */
@@ -266,13 +270,15 @@
 #endif /* } */
 #if SUNMAXDEPTH > 8 /* { */
     CGEIGHT0DEV,
-#if 0
 #ifdef XFBTYPE_TCX
     TCX0DEV,
 #endif
-#endif
 #endif /* } */
+#ifndef linux
     "/dev/fb"
+#else
+    "/dev/fb0"
+#endif
 };
 #endif /* } */
 
@@ -292,6 +298,40 @@
 };
 #define NUMFORMATS	(sizeof formats)/(sizeof formats[0])
 
+#if SUNMAXDEPTH > 1 /* { */
+#ifdef XFBTYPE_TCX /* { */
+extern Bool sunTCX8Init(
+#if NeedFunctionPrototypes
+    int /* screen */,
+    ScreenPtr /* pScreen */,
+    int /* argc */,
+    char** /* argv */
+#endif
+);
+
+#if SUNMAXDEPTH > 8
+extern Bool sunTCX24Init(
+#if NeedFunctionPrototypes
+    int /* screen */,
+    ScreenPtr /* pScreen */,
+    int /* argc */,
+    char** /* argv */
+#endif
+);
+#endif
+
+static Bool sunTCXInit(int screen, ScreenPtr pScreen, int argc, char** argv)
+{
+#if SUNMAXDEPTH > 8
+    if (sunFbs [screen].info.fb_depth > 8) /* Is it 24bit deep TCX or just tcx-8-bit? */
+       return sunTCX24Init (screen, pScreen, argc, argv);
+    else
+#endif
+        return sunTCX8Init (screen, pScreen, argc, argv);
+}
+#endif /* } */
+#endif /* } */
+
 /*
  * OpenFrameBuffer --
  *	Open a frame buffer according to several rules.
@@ -311,7 +351,11 @@
     static int		devFbUsed;
 
     sunFbs[screen].fd = -1;
+#ifndef linux
     if (strcmp (device, "/dev/fb") == 0 && devFbUsed)
+#else
+    if (strcmp (device, "/dev/fb0") == 0 && devFbUsed)
+#endif
 	return FALSE;
     if (access (device, R_OK | W_OK) == -1)
 	return FALSE;
@@ -343,9 +387,9 @@
 	    if (fbattr)
 		sunFbs[screen].info = fbattr->fbtype;
 	    sunFbs[screen].fbPriv = (pointer) fbattr;
-	    if (fbattr && 
-		fbattr->fbtype.fb_type < XFBTYPE_LASTPLUSONE && 
-		!sunFbData[fbattr->fbtype.fb_type].init) {
+	    if ((fbattr) && 
+		(fbattr->fbtype.fb_type < XFBTYPE_LASTPLUSONE) && 
+		(!sunFbData[fbattr->fbtype.fb_type].init)) {
 		int _i;
 		ret = FALSE;
 		for (_i = 0; _i < FB_ATTR_NEMUTYPES; _i++) {
@@ -366,6 +410,17 @@
     }
     if (!ret)
 	sunFbs[screen].fd = -1;
+#ifdef linux
+    else {
+        sunFbs[screen].origcmap.index = 0;
+        sunFbs[screen].origcmap.count = 16;
+        sunFbs[screen].origcmap.red = (unsigned char *)xalloc(64);
+        sunFbs[screen].origcmap.green = (unsigned char *)xalloc(64);
+        sunFbs[screen].origcmap.blue = (unsigned char *)xalloc(64);
+        if (ioctl (sunFbs[screen].fd, FBIOGETCMAP, &(sunFbs[screen].origcmap)) < 0)
+            sunFbs[screen].origcmap.count = 0;
+    }
+#endif
     return ret;
 }
 
@@ -474,7 +529,7 @@
  * matter since no 386i has ever been shipped with a type 3 keyboard.
  * SunOS 4.1 no longer needs this kludge.
  */
-#if !defined(i386) && !defined(KIOCGKEY)
+#if !defined(i386) && defined(KIOCGKEY)
 #define TYPE4KEYBOARDOVERRIDE
 #endif
 
@@ -556,6 +611,10 @@
     }
 }
 
+#ifdef linux
+extern void OpenLinuxConsole();
+#endif
+
 /*-
  *-----------------------------------------------------------------------
  * InitOutput --
@@ -615,6 +674,9 @@
 	    ErrorF("InitOutput: can't put stderr in non-block mode\n");
 	}
     }
+#ifdef linux
+    OpenLinuxConsole();
+#endif
     pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
     pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
     pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
@@ -638,6 +700,18 @@
 	sunDevsInited = TRUE;
 	xfree (devList);
     }
+#ifdef linux
+    for (scr = 0; scr < MAXSCREENS; scr++)
+       if (sunFbs[scr].fd != -1) {
+           struct stat mystat;
+           
+           if (fstat (sunFbs[scr].fd, &mystat) >= 0)
+               if ((mystat.st_rdev & 0xff) == 0) {
+                   linuxSetConsoleFb (scr);
+                   break;
+               }
+       }
+#endif
     for (scr = 0; scr < MAXSCREENS; scr++)
 	if (sunFbs[scr].fd != -1)
 	    (void) AddScreen (sunFbData[sunFbs[scr].info.fb_type].init, 
@@ -666,11 +740,18 @@
 {
     DevicePtr	p, k;
     extern Bool mieqInit();
+#ifdef linux
+    extern DevicePtr linuxMouse, linuxKeyboard;
+#endif
 
     p = AddInputDevice(sunMouseProc, TRUE);
     k = AddInputDevice(sunKbdProc, TRUE);
     if (!p || !k)
 	FatalError("failed to create input devices in InitInput");
+#ifdef linux
+    linuxMouse = p;
+    linuxKeyboard = k;
+#endif
 
     RegisterPointerDevice(p);
     RegisterKeyboardDevice(k);
@@ -681,7 +762,19 @@
     (void) OsSignal(SIGPOLL, SigIOHandler);
 #define WANT_SIGNALS(fd) ioctl(fd, I_SETSIG, S_INPUT | S_HIPRI)
 #else
+#ifdef linux
+    {
+       struct sigaction act;
+
+       sigemptyset(&act.sa_mask);
+       sigaddset(&act.sa_mask, SIGIO);
+       act.sa_flags = SA_RESTART;
+       act.sa_handler = SigIOHandler;
+       sigaction(SIGIO, &act, 0);
+    }
+#else
     (void) OsSignal(SIGIO, SigIOHandler);
+#endif
 #define WANT_SIGNALS(fd) fcntl(fd, F_SETOWN, getpid())
 #endif
     if (sunKbdPriv.fd >= 0) {
@@ -886,14 +979,14 @@
 	bsFuncs = &cfbBSFuncRec;
 	break;
     case 16:
-	pScreen->CloseScreen = cfb16CloseScreen;
+	pScreen->CloseScreen = cfbCloseScreen;
 	pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr =
 	    pScreen->devPrivate;
 	pScreen->devPrivate = oldDevPrivate;
 	bsFuncs = &cfb16BSFuncRec;
 	break;
     case 32:
-	pScreen->CloseScreen = cfb32CloseScreen;
+	pScreen->CloseScreen = cfbCloseScreen;
 	pScreen->devPrivates[cfb32ScreenPrivateIndex].ptr =
 	    pScreen->devPrivate;
 	pScreen->devPrivate = oldDevPrivate;
@@ -923,6 +1016,74 @@
 
 #endif  /* SUNMAXDEPTH == 32 */
 #endif  /* SUNMAXDEPTH */
+
+#ifdef linux
+void
+sunDoBitBlt(ppix, pspix, bpp, pixReg, pixPt)
+    DrawablePtr ppix, pspix;
+    int bpp;
+    RegionPtr pixReg;
+    DDXPointPtr pixPt;
+{
+    switch (bpp) {
+       case 1:
+           mfbDoBitblt(ppix, pspix, GXcopy, pixReg, pixPt);
+           break;
+#if SUNMAXDEPTH > 1
+       case 8:
+           cfbDoBitblt(ppix, pspix, GXcopy, pixReg, pixPt, 0xFF);
+           break;
+#endif
+#if SUNMAXDEPTH > 8
+       case 16:
+           cfb16DoBitblt(ppix, pspix, GXcopy, pixReg, pixPt, 0xFFFF);
+           break;
+       case 24:
+       case 32:
+           cfb32DoBitblt(ppix, pspix, GXcopy, pixReg, pixPt, 0xFFFFFFFF);
+           break;
+#endif
+    }
+}
+
+void
+sunRefreshColormap(idx)
+    int idx;
+{
+    SetupScreen(screenInfo.screens[idx]);
+    ColormapPtr cmap;
+
+#if SUNMAXDEPTH > 1
+    /* Hack to restore correct cmap */
+    cmap = pPrivate->installedMap;
+    if (cmap) {
+       WalkTree(cmap->pScreen,TellLostMap,(pointer) &(cmap->mid));
+       pPrivate->installedMap = NULL;
+       sunInstallColormap(cmap);
+    }
+#endif
+}
+
+PixmapPtr
+sunGetScreenPixmap(screen)
+    int screen;
+{
+    ScreenPtr pScreen = screenInfo.screens [screen];
+    
+    switch (pScreen->rootDepth) {
+       case 1: return (PixmapPtr) pScreen->devPrivate;
+#if SUNMAXDEPTH > 1
+       case 8: return (PixmapPtr) pScreen->devPrivate;
+#endif    
+#if SUNMAXDEPTH > 8
+       case 16: return (PixmapPtr) pScreen->devPrivates [cfb16ScreenPrivateIndex].ptr;
+       case 24:
+       case 32: return (PixmapPtr) pScreen->devPrivates [cfb32ScreenPrivateIndex].ptr;
+#endif
+       default: ErrorF ("Wrong depth %d\n", pScreen->rootDepth); return NULL;
+    }
+}
+#endif
 
 #ifdef DPMSExtension
 /**************************************************************
diff -u -r xc/programs/Xserver/hw/sun/sunIo.c xc-new/programs/Xserver/hw/sun/sunIo.c
--- xc/programs/Xserver/hw/sun/sunIo.c	Tue Feb 10 11:16:35 1998
+++ xc-new/programs/Xserver/hw/sun/sunIo.c	Mon Apr  5 14:08:28 1999
@@ -188,7 +188,13 @@
 void
 ddxGiveUp()
 {
+#ifdef linux
+    extern void CloseLinuxConsole();
+#endif
     AbortDDX ();
+#ifdef linux
+    CloseLinuxConsole();
+#endif
 }
 
 int
@@ -199,6 +205,13 @@
 {
     extern void UseMsg();
 
+#ifdef linux
+    extern int linuxProcessArgument(int argc, char *argv[], int i);
+    int ret;
+    
+    ret = linuxProcessArgument(argc, argv, i);
+    if (ret) return ret;
+#endif
 #ifdef XKB
     int noxkb = 0, n;
     /* 
@@ -289,5 +302,10 @@
 #ifdef UNDOCUMENTED
     ErrorF("-cg4frob            don't use the mono plane of the cgfour\n");
     ErrorF("-noGX               treat the GX as a dumb frame buffer\n");
+#endif
+#ifdef linux
+    ErrorF("vtXX                use the specified VT number\n");
+    ErrorF("-keeptty               ");
+    ErrorF("don't detach controlling tty (for debugging only)\n");
 #endif
 }
diff -u -r xc/programs/Xserver/hw/sun/sunKbd.c xc-new/programs/Xserver/hw/sun/sunKbd.c
--- xc/programs/Xserver/hw/sun/sunKbd.c	Tue Feb 10 11:16:39 1998
+++ xc-new/programs/Xserver/hw/sun/sunKbd.c	Sat Apr  3 13:34:38 1999
@@ -80,6 +80,11 @@
 extern KeySymsRec sunKeySyms[];
 extern SunModmapRec* sunModMaps[];
 
+#ifdef linux
+extern int consoleFd;
+#include <linux/vt.h>
+#endif
+
 long	  	  sunAutoRepeatInitiate = 1000 * AUTOREPEAT_INITIATE;
 long	  	  sunAutoRepeatDelay = 1000 * AUTOREPEAT_DELAY;
 
@@ -863,6 +868,10 @@
     xEvent		xE;
     BYTE		keycode;
     CARD8		keyModifiers;
+#ifdef linux
+    KeySym		ksym;
+    extern Bool		NoVT;
+#endif
 
     keycode = (fe->id & 0x7f) + MIN_KEYCODE;
 
@@ -883,6 +892,33 @@
     xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
     xE.u.u.type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
     xE.u.u.detail = keycode;
+
+#ifdef linux
+    if ((device->key->state & ControlMask)
+       && (device->key->state & Mod3Mask))
+       switch (ksym = device->key->curKeySyms.map[(fe->id - 1) * device->key->curKeySyms.mapWidth]) {
+               case XK_BackSpace:
+                       if (xE.u.u.type == KeyPress)
+                           GiveUp(0);
+                       return;
+               case XK_F1:
+               case XK_F2:
+               case XK_F3:
+               case XK_F4:
+               case XK_F5:
+               case XK_F6:
+               case XK_F7:
+               case XK_F8:
+               case XK_F9:
+               case XK_F10:
+               case XK_F11:
+               case XK_F12:
+                       if (!NoVT && xE.u.u.type == KeyPress)
+                           ioctl(consoleFd, VT_ACTIVATE, ksym - XK_F1 + 1);
+                       return;
+       }
+#endif
+
 #ifdef XKB
     if (noXkbExtension) {
 #endif
diff -u -r xc/programs/Xserver/include/servermd.h xc-new/programs/Xserver/include/servermd.h
--- xc/programs/Xserver/include/servermd.h	Mon Feb  9 12:29:54 1998
+++ xc-new/programs/Xserver/include/servermd.h	Mon Apr  5 11:20:18 1999
@@ -131,7 +131,8 @@
     (defined(__uxp__) && (defined(sparc) || defined(mc68000))) || \
     (defined(Lynx) && defined(__sparc__)) || \
     ((defined(__NetBSD__) || defined(__OpenBSD__)) && \
-     (defined(__sparc__) || defined(__mc68000__)))
+     (defined(__sparc__) || defined(__mc68000__))) || \
+    (defined(__linux__) && defined(sparc))
 
 #if defined(sun386) || defined(sun5)
 # define IMAGE_BYTE_ORDER	LSBFirst        /* Values for the SUN only */
@@ -311,7 +312,7 @@
      (defined(__NetBSD__) && defined(__i386__)) || \
      defined(__FreeBSD__) || \
      defined(MACH386) || \
-     defined(linux) || \
+     (defined(linux) && !defined(sparc)) || \
      (defined(AMOEBA) && defined(i80386)) || \
      defined(MINIX) || \
      defined(WIN32))
diff -u -r xc/programs/Xserver/mi/miarc.c xc-new/programs/Xserver/mi/miarc.c
--- xc/programs/Xserver/mi/miarc.c	Mon Feb  9 12:45:42 1998
+++ xc-new/programs/Xserver/mi/miarc.c	Sat Apr  3 13:37:48 1999
@@ -64,7 +64,7 @@
 #include "Xfuncproto.h"
 
 static double miDsin(), miDcos(), miDasin(), miDatan2();
-double	cbrt(
+extern double	cbrt(
 #if NeedFunctionPrototypes
 	     double
 #endif
diff -u -r xc/programs/rgb/Imakefile xc-new/programs/rgb/Imakefile
--- xc/programs/rgb/Imakefile	Wed Nov 13 12:49:33 1996
+++ xc-new/programs/rgb/Imakefile	Sat Apr  3 13:40:41 1999
@@ -20,7 +20,12 @@
          OBJS = $(OBJS1) $(OBJS2)
      PROGRAMS = $(RGB_PROG) ProgramTargetName(showrgb)
 #if !UseRgbTxt
-#ifdef BSD386Architecture
+
+#if defined(SparcArchitecture) && defined(LinuxArchitecture)
+#define LinuxSparc
+#endif
+
+#ifdef BSD386Architecture || defined(LinuxSparc)
     DATAFILES = rgb.db
       DATADEP = rgb.db
 #else
@@ -39,6 +44,9 @@
        DBMLIB = DBMLibrary -lucb
 #endif
 #endif /*!UseRgbTxt */
+#if defined(LinuxSparc)
+       DBMLIB = -ldb
+#endif
 
 all:: $(PROGRAMS) $(DATADEP)
 
diff -u -r xc/programs/xterm/main.c xc-new/programs/xterm/main.c
--- xc/programs/xterm/main.c	Mon Feb  9 12:16:58 1998
+++ xc-new/programs/xterm/main.c	Sat Apr  3 13:42:51 1999
@@ -358,6 +358,40 @@
 #endif
 #endif
 
+#ifdef linux /* Lets undefine all the SunOS specific stuff */
+#undef TIOCHPCL
+#undef TIOCMODG
+#undef TIOCMODS
+#undef TIOCGETP
+#undef TIOCSETP
+#undef TIOCSETN
+#undef TIOCFLUSH
+#undef TIOCSETC
+#undef TIOCGETC
+#undef TIOCTCNTL
+#undef TIOCSIGNAL
+#undef TIOCSETX
+#undef TIOCGETX
+#undef TIOCSSIZE
+#undef TIOCGSIZE
+#undef TIOCUCNTL
+#undef TIOCREMOTE
+#undef TIOCSTART
+#undef TIOCSTOP
+#undef TIOCGLTC
+#undef TIOCSLTC
+#undef TIOCCDTR
+#undef TIOCSDTR
+#undef TIOCCBRK
+#undef TIOCSBRK
+#undef TIOCLGET
+#undef TIOCLSET
+#undef TIOCLBIC
+#undef TIOCLBIS
+#undef TIOCISPACE
+#undef TIOCISIZE
+#endif
+
 #ifndef X_NOT_STDC_ENV
 #include <stdlib.h>
 #else
@@ -405,7 +439,7 @@
 static struct ltchars d_ltc;
 #endif	/* TIOCSLTC */
 
-#ifdef __sgi
+#if defined(__sgi) || (defined(linux) && defined(sparc))
 #undef TIOCLSET /* XXX why is this undef-ed again? */
 #endif
 
@@ -437,6 +471,9 @@
 /* allow use of system default characters if defined and reasonable */
 #ifndef CEOF
 #define CEOF ('D'&037)
+#endif
+#ifndef CDSUSP
+#define CDSUSP ('Y'&037)
 #endif
 #ifndef CSUSP
 #define CSUSP ('Z'&037)
