aboutsummaryrefslogtreecommitdiff
path: root/nx-X11/programs/Xserver/hw/sunLynx
diff options
context:
space:
mode:
Diffstat (limited to 'nx-X11/programs/Xserver/hw/sunLynx')
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/Imakefile78
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/btreg.h81
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/btvar.h74
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h206
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/fbio.h186
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/patch.Console428
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0493
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sun.h486
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c372
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c292
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c648
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c389
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c1080
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c649
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c509
-rw-r--r--nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h88
16 files changed, 6059 insertions, 0 deletions
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/Imakefile b/nx-X11/programs/Xserver/hw/sunLynx/Imakefile
new file mode 100644
index 000000000..e7e8e916c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/Imakefile
@@ -0,0 +1,78 @@
+XCOMM $Xorg: Imakefile,v 1.3 2000/08/17 19:48:36 cpqbld Exp $
+
+
+
+XCOMM $XFree86: xc/programs/Xserver/hw/sunLynx/Imakefile,v 3.1 1996/12/27 06:51:30 dawes Exp $
+
+#include <Server.tmpl>
+
+SRCS1 = sunLyInit.c \
+ sunLyIo.c \
+ sunLyUtil.c \
+ sunLyMouse.c\
+ sunLyCfb.c \
+ sunLyFbs.c \
+ sunLyKbd.c \
+ sunCursor.c \
+ sunMfb.c \
+ sunGX.c \
+ sunKeyMap.c
+
+XCOMM SRCS = $(SRCS1) kbd_mode.c constype.c
+SRCS = $(SRCS1)
+
+#if XsunLynxMonoServer
+OFILES = sunInitMono.o sunInExMono.o
+#endif
+
+OBJS = sunLyInit.o \
+ sunLyIo.o \
+ sunLyUtil.o \
+ sunLyMouse.o\
+ sunLyCfb.o \
+ sunLyFbs.o \
+ sunLyKbd.o \
+ sunCursor.o \
+ sunMfb.o \
+ sunGX.o \
+ sunKeyMap.o
+
+ INCLUDES = -I. -I../.. -I../../mi -I../../mfb -I../../cfb -I../../cfb32 \
+ -I../../include -I../../os -I$(XINCLUDESRC) -I$(FONTINCSRC)
+ LINTLIBS = ../../dix/llib-ldix.ln ../../os/llib-los.ln \
+ ../mfb/llib-lmfb.ln ../mi/llib-lmi.ln ../cfb/llib-lcfb.ln
+
+NormalLibraryObjectRule()
+
+XCOMM all:: $(OFILES) kbd_mode constype
+all:: $(OFILES)
+
+lintlib:
+
+NormalLibraryTarget(sun,$(OBJS))
+NormalLintTarget($(SRCS1))
+
+sunInExMono.o: $(ICONFIGFILES)
+ObjectFromSpecialSource(sunInExMono,../../mi/miinitext,$(EXT_DEFINES) -UXIEEXT -UPEXEXT -UXF86VIDMODE)
+ObjectFromSpecialSource(sunInitMono,sunLyInit,-DSUNMAXDEPTH=1)
+
+#if 0
+SingleProgramTarget(kbd_mode, kbd_mode.o,,)
+SingleProgramTarget(constype, constype.o,,)
+InstallProgram(kbd_mode,$(BINDIR))
+InstallProgram(constype,$(BINDIR))
+InstallManPage(kbd_mode,$(MANDIR))
+InstallManPage(constype,$(MANDIR))
+InstallManPage(Xsun,$(MANDIR))
+InstallManPageAliases(Xsun,$(MANDIR),XsunMono)
+#endif
+
+LinkSourceFile(sunGX.h,../sun)
+LinkSourceFile(circleset.h,../sun)
+ObjectFromSpecialSource(sunKeyMap,../sun/sunKeyMap,/**/)
+ObjectFromSpecialSource(sunMfb,../sun/sunMfb,/**/)
+ObjectFromSpecialSource(sunGX,../sun/sunGX,/**/)
+ObjectFromSpecialSource(sunCursor,../sun/sunCursor,/**/)
+
+DependTarget()
+
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/btreg.h b/nx-X11/programs/Xserver/hw/sunLynx/btreg.h
new file mode 100644
index 000000000..cca573cc6
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/btreg.h
@@ -0,0 +1,81 @@
+/* $Xorg: btreg.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)btreg.h 8.2 (Berkeley) 1/21/94
+ */
+/* $NetBSD: btreg.h,v 1.2 1994/11/20 20:51:55 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/btreg.h,v 3.1 1996/12/27 06:51:31 dawes Exp $ */
+
+/*
+ * Several Sun color frame buffers use some kind of Brooktree video
+ * DAC (e.g., the Bt458, -- in any case, Brooktree make the only
+ * decent color frame buffer chips).
+ *
+ * Color map control on these is a bit funky in a SPARCstation.
+ * To update the color map one would normally do byte writes, but
+ * the hardware takes longword writes. Since there are three
+ * registers for each color map entry (R, then G, then B), we have
+ * to set color 1 with a write to address 0 (setting 0's R/G/B and
+ * color 1's R) followed by a second write to address 1 (setting
+ * color 1's G/B and color 2's R/G). Software must therefore keep
+ * a copy of the current map.
+ *
+ * The colormap address register increments automatically, so the
+ * above write is done as:
+ *
+ * bt->bt_addr = 0;
+ * bt->bt_cmap = R0G0B0R1;
+ * bt->bt_cmap = G1B1R2G2;
+ * ...
+ *
+ * Yow!
+ *
+ * Bonus complication: on the cg6, only the top 8 bits of each 32 bit
+ * register matter, even though the cg3 takes all the bits from all
+ * bytes written to it.
+ */
+struct bt_regs {
+ u_int bt_addr; /* map address register */
+ u_int bt_cmap; /* colormap data register */
+ u_int bt_ctrl; /* control register */
+ u_int bt_omap; /* overlay (cursor) map register */
+};
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/btvar.h b/nx-X11/programs/Xserver/hw/sunLynx/btvar.h
new file mode 100644
index 000000000..054df6f87
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/btvar.h
@@ -0,0 +1,74 @@
+/* $Xorg: btvar.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)btvar.h 8.2 (Berkeley) 1/21/94
+ */
+/* $NetBSD: btvar.h,v 1.2 1994/11/20 20:51:56 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/btvar.h,v 3.1 1996/12/27 06:51:32 dawes Exp $ */
+
+/*
+ * Brooktree color frame buffer state variables (see btreg.h).
+ *
+ * Unfortunately, remarkably little code can be shared between the
+ * cg3 and cg6 drivers here, as the cg3 registers do longword-ops
+ * `as expected', but the cg6 ones use only the upper byte.
+ *
+ * Still, the software color map manipulation is not completely trivial.
+ */
+union bt_cmap {
+ u_char cm_map[256][3]; /* 256 R/G/B entries */
+ u_int cm_chip[256 * 3 / 4]; /* the way the chip gets loaded */
+};
+
+/*
+ * Routines in bt_subr.c.
+ */
+int bt_getcmap __P((struct fbcmap *, union bt_cmap *, int));
+int bt_putcmap __P((struct fbcmap *, union bt_cmap *, int));
+
+/*
+ * Compute (x / 4) * 3 and (x / 4) * 4. These are used in turning
+ * RGB indices (which are in multiples of three) into `chip RGB' values
+ * (which are in multiples of four).
+ */
+#define BT_D4M3(x) ((((x) >> 2) << 1) + ((x) >> 2)) /* (x / 4) * 3 */
+#define BT_D4M4(x) ((x) & ~3) /* (x / 4) * 4 */
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h b/nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h
new file mode 100644
index 000000000..0c44c2a58
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/cgsixreg.h
@@ -0,0 +1,206 @@
+/* $Xorg: cgsixreg.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)cgsixreg.h 8.4 (Berkeley) 1/21/94
+ */
+/* $NetBSD: cgsixreg.h,v 1.3 1994/11/20 20:52:00 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/cgsixreg.h,v 3.1 1996/12/27 06:51:33 dawes Exp $ */
+
+/*
+ * CG6 display registers. (Note, I got tired of writing `cgsix' about
+ * halfway through and changed everything to cg6, but I probably missed
+ * some. Unfortunately, the way config works, we need to spell out `six'
+ * in some places anyway.)
+ *
+ * The cg6 is a complicated beastie. We have been unable to extract any
+ * documentation and most of the following are guesses based on a limited
+ * amount of reverse engineering.
+ *
+ * A cg6 is composed of numerous groups of control registers, all with TLAs:
+ * FBC - frame buffer control?
+ * FHC - fbc hardware configuration / control? register (32 bits)
+ * DHC - ???
+ * TEC - transform engine control?
+ * THC - TEC Hardware Configuration
+ * ROM - a 64Kbyte ROM with who knows what in it.
+ * colormap - see below
+ * frame buffer memory (video RAM)
+ * possible other stuff
+ *
+ * Like the cg3, the cg6 uses a Brooktree Video DAC (see btreg.h).
+ *
+ * Various revisions of the cgsix have various hardware bugs. So far,
+ * we have only seen rev 1 & 2.
+ */
+
+/* bits in FHC register */
+#define FHC_FBID_MASK 0xff000000 /* bits 24..31 are frame buffer ID */
+#define FHC_FBID_SHIFT 24
+#define FHC_REV_MASK 0x00f00000 /* bits 20..23 are revision */
+#define FHC_REV_SHIFT 20
+#define FHC_FROP_DISABLE 0x00080000 /* disable fast/font? rasterops */
+#define FHC_ROW_DISABLE 0x00040000 /* ??? */
+#define FHC_SRC_DISABLE 0x00020000 /* ??? */
+#define FHC_DST_DISABLE 0x00010000 /* disable destination cache */
+#define FHC_RESET 0x00008000 /* ??? */
+#define FHC_XXX0 0x00004000 /* ??? */
+#define FHC_LEBO 0x00002000 /* set little endian byte order? */
+#define FHC_RES_MASK 0x00001800 /* bits 11&12 are resolution */
+#define FHC_RES_1024 0x00000000 /* res = 1024x768 */
+#define FHC_RES_1152 0x00000800 /* res = 1152x900 */
+#define FHC_RES_1280 0x00001000 /* res = 1280x1024 */
+#define FHC_RES_1600 0x00001800 /* res = 1600x1200 */
+#define FHC_CPU_MASK 0x00000600 /* bits 9&10 are cpu type */
+#define FHC_CPU_SPARC 0x00000000 /* cpu = sparc */
+#define FHC_CPU_68020 0x00000200 /* cpu = 68020 */
+#define FHC_CPU_386 0x00000400 /* cpu = 80386 */
+#define FHC_CPU_XXX 0x00000600 /* ??? */
+#define FHC_TEST 0x00000100 /* ??? test window ??? */
+#define FHC_TESTX_MASK 0x000000f0 /* bits 4..7 are test window X */
+#define FHC_TESTX_SHIFT 4
+#define FHC_TESTY_MASK 0x0000000f /* bits 0..3 are test window Y */
+#define FHC_TESTY_SHIFT 0
+
+/*
+ * The layout of the THC.
+ */
+struct cg6_thc {
+ u_int thc_xxx0[512]; /* ??? */
+ u_int thc_hsync1; /* horizontal sync timing */
+ u_int thc_hsync2; /* more hsync timing */
+ u_int thc_hsync3; /* yet more hsync timing */
+ u_int thc_vsync1; /* vertical sync timing */
+ u_int thc_vsync2; /* only two of these */
+ u_int thc_refresh; /* refresh counter */
+ u_int thc_misc; /* miscellaneous control & status */
+ u_int thc_xxx1[56]; /* ??? */
+ u_int thc_cursxy; /* cursor x,y position (16 bits each) */
+ u_int thc_cursmask[32]; /* cursor mask bits */
+ u_int thc_cursbits[32]; /* what to show where mask enabled */
+};
+
+/* bits in thc_misc */
+#define THC_MISC_XXX0 0xfff00000 /* unused */
+#define THC_MISC_REVMASK 0x000f0000 /* cg6 revision? */
+#define THC_MISC_REVSHIFT 16
+#define THC_MISC_XXX1 0x0000e000 /* unused */
+#define THC_MISC_RESET 0x00001000 /* ??? */
+#define THC_MISC_XXX2 0x00000800 /* unused */
+#define THC_MISC_VIDEN 0x00000400 /* video enable */
+#define THC_MISC_SYNC 0x00000200 /* not sure what ... */
+#define THC_MISC_VSYNC 0x00000100 /* ... these really are */
+#define THC_MISC_SYNCEN 0x00000080 /* sync enable */
+#define THC_MISC_CURSRES 0x00000040 /* cursor resolution */
+#define THC_MISC_INTEN 0x00000020 /* v.retrace intr enable */
+#define THC_MISC_INTR 0x00000010 /* intr pending / ack bit */
+#define THC_MISC_XXX 0x0000000f /* ??? */
+
+/* cursor x / y position value for `off' */
+#define THC_CURSOFF (65536-32) /* i.e., USHRT_MAX+1-32 */
+
+/*
+ * Partial description of TEC (needed to get around FHC rev 1 bugs).
+ */
+struct cg6_tec_xxx {
+ u_int tec_mv; /* matrix stuff */
+ u_int tec_clip; /* clipping stuff */
+ u_int tec_vdc; /* ??? */
+};
+
+/*
+ * This structure exists only to compute the layout of the CG6
+ * hardware. Each of the individual substructures lives on a
+ * separate `page' (where a `page' is at least 4K), and many are
+ * very far apart. We avoid large offsets (which make for lousy
+ * code) by using pointers to the individual interesting pieces,
+ * and map them in independently (to avoid using up PTEs unnecessarily).
+ */
+struct cg6_layout {
+ /* ROM at 0 */
+ union {
+ long un_id; /* ID = ?? */
+ char un_rom[65536]; /* 64K rom */
+ char un_pad[0x200000];
+ } cg6_rom_un;
+
+ /* Brooktree DAC at 0x200000 */
+ union {
+ struct bt_regs un_btregs;
+ char un_pad[0x040000];
+ } cg6_bt_un;
+
+ /* DHC, whatever that is, at 0x240000 */
+ union {
+ char un_pad[0x40000];
+ } cg6_dhc_un;
+
+ /* ALT, whatever that is, at 0x280000 */
+ union {
+ char un_pad[0x80000];
+ } cg6_alt_un;
+
+ /* FHC register at 0x300000 */
+ union {
+ int un_fhc;
+ char un_pad[0x1000];
+ } cg6_fhc_un;
+
+ /* THC at 0x301000 */
+ union {
+ struct cg6_thc un_thc;
+ char un_pad[0x400000 - 0x1000];
+ } cg6_thc_un;
+
+ /* FBC at 0x700000 */
+ union {
+ char un_pad[0x1000];
+ } cg6_fbc_un;
+
+ /* TEC at 0x701000 */
+ union {
+ char un_pad[0x100000 - 0x1000];
+ struct cg6_tec_xxx un_tec;
+ } cg6_tec_un;
+
+ /* Video RAM at 0x800000 */
+ char cg6_ram[1024 * 1024]; /* approx.? */
+};
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/fbio.h b/nx-X11/programs/Xserver/hw/sunLynx/fbio.h
new file mode 100644
index 000000000..324036999
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/fbio.h
@@ -0,0 +1,186 @@
+/* $Xorg: fbio.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * Copyright (c) 1992 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software developed by the Computer Systems
+ * Engineering group at Lawrence Berkeley Laboratory under DARPA
+ * contract BG 91-66 and contributed to Berkeley.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)fbio.h 7.2 (Berkeley) 4/1/92
+ */
+
+/*
+ * Frame buffer ioctls (from Sprite, trimmed to essentials for X11).
+ */
+/* $NetBSD: fbio.h,v 1.3 1994/11/20 20:53:03 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/fbio.h,v 3.1 1996/12/27 06:51:34 dawes Exp $ */
+
+/*
+ * Frame buffer type codes.
+ */
+#define FBTYPE_SUN1BW 0 /* multibus mono */
+#define FBTYPE_SUN1COLOR 1 /* multibus color */
+#define FBTYPE_SUN2BW 2 /* memory mono */
+#define FBTYPE_SUN2COLOR 3 /* color w/rasterop chips */
+#define FBTYPE_SUN2GP 4 /* GP1/GP2 */
+#define FBTYPE_SUN5COLOR 5 /* RoadRunner accelerator */
+#define FBTYPE_SUN3COLOR 6 /* memory color */
+#define FBTYPE_MEMCOLOR 7 /* memory 24-bit */
+#define FBTYPE_SUN4COLOR 8 /* memory color w/overlay */
+
+#define FBTYPE_NOTSUN1 9 /* reserved for customer */
+#define FBTYPE_NOTSUN2 10 /* reserved for customer */
+#define FBTYPE_NOTSUN3 11 /* reserved for customer */
+
+#define FBTYPE_SUNFAST_COLOR 12 /* accelerated 8bit */
+#define FBTYPE_SUNROP_COLOR 13 /* MEMCOLOR with rop h/w */
+#define FBTYPE_SUNFB_VIDEO 14 /* Simple video mixing */
+#define FBTYPE_RESERVED5 15 /* reserved, do not use */
+#define FBTYPE_RESERVED4 16 /* reserved, do not use */
+#define FBTYPE_RESERVED3 17 /* reserved, do not use */
+#define FBTYPE_RESERVED2 18 /* reserved, do not use */
+#define FBTYPE_RESERVED1 19 /* reserved, do not use */
+
+#define FBTYPE_LASTPLUSONE 20 /* max number of fbs (change as add) */
+
+/*
+ * Frame buffer descriptor as returned by FBIOGTYPE.
+ */
+struct fbtype {
+ int fb_type; /* as defined above */
+ int fb_height; /* in pixels */
+ int fb_width; /* in pixels */
+ int fb_depth; /* bits per pixel */
+ int fb_cmsize; /* size of color map (entries) */
+ int fb_size; /* total size in bytes */
+};
+#define FBIOGTYPE _IOR('F', 0, struct fbtype)
+
+#ifdef notdef
+/*
+ * General purpose structure for passing info in and out of frame buffers
+ * (used for gp1) -- unsupported.
+ */
+struct fbinfo {
+ int fb_physaddr; /* physical frame buffer address */
+ int fb_hwwidth; /* fb board width */
+ int fb_hwheight; /* fb board height */
+ int fb_addrdelta; /* phys addr diff between boards */
+ u_char *fb_ropaddr; /* fb virtual addr */
+ int fb_unit; /* minor devnum of fb */
+};
+#define FBIOGINFO _IOR('F', 2, struct fbinfo)
+#endif
+
+/*
+ * Color map I/O.
+ */
+struct fbcmap {
+ int index; /* first element (0 origin) */
+ int count; /* number of elements */
+ u_char *red; /* red color map elements */
+ u_char *green; /* green color map elements */
+ u_char *blue; /* blue color map elements */
+};
+#define FBIOPUTCMAP _IOW('F', 3, struct fbcmap)
+#define FBIOGETCMAP _IOW('F', 4, struct fbcmap)
+
+/*
+ * Set/get attributes.
+ */
+#define FB_ATTR_NDEVSPECIFIC 8 /* no. of device specific values */
+#define FB_ATTR_NEMUTYPES 4 /* no. of emulation types */
+
+struct fbsattr {
+ int flags; /* flags; see below */
+ int emu_type; /* emulation type (-1 if unused) */
+ int dev_specific[FB_ATTR_NDEVSPECIFIC]; /* catchall */
+};
+#define FB_ATTR_AUTOINIT 1 /* emulation auto init flag */
+#define FB_ATTR_DEVSPECIFIC 2 /* dev. specific stuff valid flag */
+
+struct fbgattr {
+ int real_type; /* real device type */
+ int owner; /* PID of owner, 0 if myself */
+ struct fbtype fbtype; /* fbtype info for real device */
+ struct fbsattr sattr; /* see above */
+ int emu_types[FB_ATTR_NEMUTYPES]; /* possible emulations */
+ /* (-1 if unused) */
+};
+/* FBIOSATTR _IOW('F', 5, struct fbsattr) -- unsupported */
+#define FBIOGATTR _IOR('F', 6, struct fbgattr)
+
+/*
+ * Video control.
+ */
+#define FBVIDEO_OFF 0
+#define FBVIDEO_ON 1
+
+#define FBIOSVIDEO _IOW('F', 7, int)
+#define FBIOGVIDEO _IOR('F', 8, int)
+
+/*
+ * hardware cursor control
+ */
+struct fbcurpos {
+ short x;
+ short y;
+};
+
+#define FB_CUR_SETCUR 0x01
+#define FB_CUR_SETPOS 0x02
+#define FB_CUR_SETHOT 0x04
+#define FB_CUR_SETCMAP 0x08
+#define FB_CUR_SETSHAPE 0x10
+#define FB_CUR_SETALL 0x1F
+
+struct fbcursor {
+ short set; /* what to set */
+ short enable; /* enable/disable cursor */
+ struct fbcurpos pos; /* cursor's position */
+ struct fbcurpos hot; /* cursor's hot spot */
+ struct fbcmap cmap; /* color map info */
+ struct fbcurpos size; /* cursor's bit map size */
+ char *image; /* cursor's image bits */
+ char *mask; /* cursor's mask bits */
+};
+
+/* set/get cursor attributes/shape */
+#define FBIOSCURSOR _IOW('F', 24, struct fbcursor)
+#define FBIOGCURSOR _IOWR('F', 25, struct fbcursor)
+
+/* set/get cursor position */
+#define FBIOSCURPOS _IOW('F', 26, struct fbcurpos)
+#define FBIOGCURPOS _IOW('F', 27, struct fbcurpos)
+
+/* get max cursor size */
+#define FBIOGCURMAX _IOR('F', 28, struct fbcurpos)
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/patch.Console b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console
new file mode 100644
index 000000000..58a2d80f3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console
@@ -0,0 +1,428 @@
+diff -crP /cdrom/usr/include/kbd.h /usr/include/kbd.h
+*** /cdrom/usr/include/kbd.h Wed Dec 31 16:00:00 1969
+--- /usr/include/kbd.h Sun May 11 23:22:45 1997
+***************
+*** 0 ****
+--- 1,90 ----
++ /* $NetBSD: kbd.h,v 1.4 1995/07/06 05:36:29 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbd.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * Keyboard `registers'. (This should be called kbd_reg.h but we need to
++ * be compatible.)
++ */
++
++ /*
++ * Control codes sent from type 2, 3, and 4 keyboards.
++ *
++ * Note that KBD_RESET is followed by a keyboard ID, while KBD_IDLE is not.
++ * KBD_IDLE does not take the place of any `up' transitions (it merely occurs
++ * after them).
++ */
++ #define KBD_RESET 0xff /* keyboard `reset' response */
++ #define KBD_IDLE 0x7f /* keyboard `all keys are up' code */
++ #define KBD_LAYOUT 0xfe /* keyboard `get layout' response */
++
++ /* Keyboard IDs */
++ #define KB_SUN2 2 /* type 2 keyboard */
++ #define KB_SUN3 3 /* type 3 keyboard */
++ #define KB_SUN4 4 /* type 4 keyboard */
++
++ /* Key codes are in 0x00..0x7e; KBD_UP is set if the key goes up */
++ #define KBD_KEYMASK 0x7f /* keyboard key mask */
++ #define KBD_UP 0x80 /* keyboard `up' transition */
++
++ /* Keyboard codes needed to recognize the L1-A sequence */
++ #define KBD_L1 1 /* keyboard code for `L1' key */
++ #define KBD_A 77 /* keyboard code for `A' key */
++
++ /* Control codes sent to the various keyboards */
++ #define KBD_CMD_RESET 1 /* reset keyboard */
++ #define KBD_CMD_BELL 2 /* turn bell on */
++ #define KBD_CMD_NOBELL 3 /* turn bell off */
++ #define KBD_CMD_CLICK 10 /* turn keyclick on */
++ #define KBD_CMD_NOCLICK 11 /* turn keyclick off */
++ #define KBD_CMD_SETLED 14 /* set LED state (type 4 kbd) */
++ #define KBD_CMD_GLAYOUT 15 /* get DIP switch (type 4 kbd) */
++
++ #define LED_NUM_LOCK 0x1
++ #if !defined(Lynx) || !defined(LED_COMPOSE)
++ #define LED_COMPOSE 0x2
++ #endif
++ #define LED_SCROLL_LOCK 0x4
++ #define LED_CAPS_LOCK 0x8
+diff -crP /cdrom/usr/include/kbio.h /usr/include/kbio.h
+*** /cdrom/usr/include/kbio.h Wed Dec 31 16:00:00 1969
+--- /usr/include/kbio.h Sun May 11 23:22:46 1997
+***************
+*** 0 ****
+--- 1,115 ----
++ /* $NetBSD: kbio.h,v 1.4 1995/05/10 16:07:27 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbio.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * The following is a minimal emulation of Sun's `kio' structures
++ * and related operations necessary to make X11 happy (i.e., make it
++ * compile, and make old X11 binaries run).
++ */
++
++ /*
++ * The kiockey structure apparently gets and/or sets keyboard mappings.
++ * It seems to be kind of useless, but X11 uses it (according to the
++ * comments) to figure out when a Sun 386i has a type-4 keyboard but
++ * claims to have a type-3 keyboard. We need just enough to cause the
++ * appropriate ioctl to return the appropriate magic value.
++ *
++ * KIOCGETKEY fills in kio_entry from kio_station. Not sure what tablemask
++ * is for; X sets it before the call, so it is not an output, but we do not
++ * care anyway. KIOCSDIRECT is supposed to tell the kernel whether to send
++ * keys to the console or to X; we just send them to X whenever the keyboard
++ * is open at all. (XXX may need to change this later)
++ *
++ * Keyboard commands and types are defined in kbd.h as they are actually
++ * real hardware commands and type numbers.
++ */
++ struct okiockey { /* Out-dated key translation structure */
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_char kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ struct kiockey {
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_short kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ /*
++ * Values for kio_tablemask. These determine which table to read/modify
++ * in KIOC[SG]KEY ioctls. Currently, we only have "non-shift" and "shift"
++ * tables.
++ */
++ #define KIOC_NOMASK 0x0
++ #define KIOC_CAPSMASK 0x1
++ #define KIOC_SHIFTMASK 0xe
++ #define KIOC_CTRLMASK 0x30
++ #define KIOC_ALTGMASK 0x200
++ #define KIOC_NUMLMASK 0x800
++
++ #define HOLE 0x302 /* value for kio_entry to say `really type 3' */
++
++ #define KIOCTRANS _IOW('k', 0, int) /* set translation mode */
++ /* (we only accept TR_UNTRANS_EVENT) */
++ #define KIOCGETKEY _IOWR('k', 2, struct okiockey) /* fill in kio_entry */
++ #define KIOCGTRANS _IOR('k', 5, int) /* get translation mode */
++ #define KIOCCMD _IOW('k', 8, int) /* X uses this to ring bell */
++ #define KIOCTYPE _IOR('k', 9, int) /* get keyboard type */
++ #define KIOCSDIRECT _IOW('k', 10, int) /* keys to console? */
++ #define KIOCSKEY _IOW('k', 12, struct kiockey) /* set xlat mode */
++ #ifndef Lynx
++ #define KIOCGKEY _IOWR('k', 13, struct kiockey) /* get xlat mode */
++ #endif
++ #define KIOCLAYOUT _IOR('k', 20, int) /* get keyboard layout */
++ #define KIOCSLED _IOW('k', 14, char) /* set LED state */
++ #define KIOCGLED _IOR('k', 15, char) /* get LED state */
++
++ #define TR_NONE 0 /* X compat, unsupported */
++ #define TR_ASCII 1 /* X compat, unsupported */
++ #define TR_EVENT 2 /* X compat, unsupported */
++ #define TR_UNTRANS_EVENT 3
+diff -crP /cdrom/sys/drivers/console/Makefile /sys/drivers/console/Makefile
+*** /cdrom/sys/drivers/console/Makefile Sun Feb 9 04:43:06 1997
+--- /sys/drivers/console/Makefile Sun May 11 23:24:04 1997
+***************
+*** 24,30 ****
+
+ LIBRARY= drivers
+
+! SPECIAL_CFLAGS=-DMOUSESUPPORT
+
+ include ../../OBJ_RULES
+
+--- 24,30 ----
+
+ LIBRARY= drivers
+
+! SPECIAL_CFLAGS=-DMOUSESUPPORT -DXSERVERSUPPORT
+
+ include ../../OBJ_RULES
+
+diff -crP /cdrom/sys/drivers/console/atc.h /sys/drivers/console/atc.h
+*** /cdrom/sys/drivers/console/atc.h Sun Feb 9 04:43:06 1997
+--- /sys/drivers/console/atc.h Sun May 11 23:22:46 1997
+***************
+*** 108,113 ****
+--- 108,119 ----
+ #ifdef MOUSESUPPORT
+ struct ttystatics mousechannel;
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ int kbd_pending;
++ int kbd_id; /* keyboard type */
++ int kbd_layout; /* layout on type 4 */
++ int kbd_click; /* kbd click on? */
++ #endif
+ };
+
+ struct kbd_registers_type {
+diff -crP /cdrom/sys/drivers/console/atcdrvr.c /sys/drivers/console/atcdrvr.c
+*** /cdrom/sys/drivers/console/atcdrvr.c Sun Feb 9 04:43:06 1997
+--- /sys/drivers/console/atcdrvr.c Sun May 11 23:25:15 1997
+***************
+*** 38,43 ****
+--- 38,47 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ char *screen_address; /* is this supposed to be in the driver info? */
+
+***************
+*** 305,310 ****
+--- 309,318 ----
+ int m;
+ int ps;
+ extern int set_kb_lights();
++ #ifdef XSERVERSUPPORT
++ extern int kbd_docmd();
++ int err;
++ #endif
+
+ if (!atc_flag){ pseterr(EIO); return(SYSERR);}
+ #ifdef MOUSESUPPORT
+***************
+*** 354,365 ****
+--- 362,398 ----
+ #ifdef TIOLED
+ case TIOLED:
+ #endif
++ #ifdef XSERVERSUPPORT
++ case KIOCSLED:
++ #endif
+ h->curled = *arg;
+ if (h->ledstate == -1) {
+ if (timeout(set_kb_lights,h,1) != -1)
+ h->ledstate = 0;
+ }
+ return 0;
++ #ifdef XSERVERSUPPORT
++ case KIOCTYPE:
++ if (wbounds(arg) < sizeof(int)) {
++ pseterr(EFAULT);
++ return SYSERR;
++ }
++ *(int *)arg = h->kbd_id;
++ return OK;
++ case KIOCLAYOUT:
++ if (wbounds(arg) < sizeof(int)) {
++ pseterr(EFAULT);
++ return SYSERR;
++ }
++ *(int *)arg = h->kbd_layout;
++ return OK;
++ case KIOCCMD:
++ if (err = kbd_docmd(h, *(int *)arg)) {
++ pseterr(err);
++ return SYSERR;
++ }
++ return OK;
++ #endif
+ case VT_OPENQRY:
+ if (h->multimode == SCM_ONE) {
+ if (!(h->open & 1)) {
+***************
+*** 578,583 ****
+--- 611,622 ----
+ h->open = 0;
+ h->break_code = 0;
+ h->info = info;
++ #ifdef XSERVERSUPPORT
++ h->kbd_pending = 0;
++ h->kbd_id = KB_SUN4; /* query KBD later.... */
++ h->kbd_layout = 0; /* US_ASCII */
++ h->kbd_click = 0; /* silent movie */
++ #endif
+ #ifdef MOUSESUPPORT
+ tmgr_install(&h->mousechannel, &info->sg, 0, mouse_xmit_ena, h);
+ #endif /* MOUSESUPPORT */
+diff -crP /cdrom/sys/drivers/console/atkey.c /sys/drivers/console/atkey.c
+*** /cdrom/sys/drivers/console/atkey.c Sun Feb 9 04:43:07 1997
+--- /sys/drivers/console/atkey.c Sun May 11 23:22:46 1997
+***************
+*** 26,31 ****
+--- 26,35 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ #define NOTHING_USEFUL -1
+ #define FILL NOTHING_USEFUL
+diff -crP /cdrom/sys/drivers/console/atutils.c /sys/drivers/console/atutils.c
+*** /cdrom/sys/drivers/console/atutils.c Sun Feb 9 04:43:07 1997
+--- /sys/drivers/console/atutils.c Sun May 11 23:22:46 1997
+***************
+*** 361,367 ****
+ }
+
+
+! static int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+--- 361,370 ----
+ }
+
+
+! #ifndef XSERVERSUPPORT
+! static
+! #endif
+! int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+***************
+*** 400,402 ****
+--- 403,449 ----
+ break;
+ }
+ }
++
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++
++ /*
++ * Execute a keyboard command; return 0 on success.
++ */
++ kbd_docmd(h, cmd)
++ register struct kdhglobals *h;
++ int cmd;
++ {
++ switch (cmd) {
++
++ case KBD_CMD_BELL:
++ case KBD_CMD_NOBELL:
++ /* Supported by type 2, 3, and 4 keyboards */
++ break;
++
++ case KBD_CMD_CLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 1;
++ break;
++ }
++ return (EINVAL);
++
++ case KBD_CMD_NOCLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 0;
++ break;
++ }
++ return (EINVAL);
++
++ default:
++ return (EINVAL); /* ENOTTY? EOPNOTSUPP? */
++ }
++
++ if (timeout(byte_to_keyboard, cmd, 1) < 0)
++ return (ENOSPC); /* ERESTART? */
++ return (0);
++ }
++ #endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0 b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0
new file mode 100644
index 000000000..41e2d10c3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/patch.Console-2.4.0
@@ -0,0 +1,493 @@
+diff -cPr --exclude-from=Excl.include /mnt/DEV_OS.microSPARC/usr/include/kbd.h /usr/include/kbd.h
+*** /mnt/DEV_OS.microSPARC/usr/include/kbd.h
+--- /usr/include/kbd.h Wed Jul 24 09:37:49 1996
+***************
+*** 0 ****
+--- 1,90 ----
++ /* $NetBSD: kbd.h,v 1.4 1995/07/06 05:36:29 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbd.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * Keyboard `registers'. (This should be called kbd_reg.h but we need to
++ * be compatible.)
++ */
++
++ /*
++ * Control codes sent from type 2, 3, and 4 keyboards.
++ *
++ * Note that KBD_RESET is followed by a keyboard ID, while KBD_IDLE is not.
++ * KBD_IDLE does not take the place of any `up' transitions (it merely occurs
++ * after them).
++ */
++ #define KBD_RESET 0xff /* keyboard `reset' response */
++ #define KBD_IDLE 0x7f /* keyboard `all keys are up' code */
++ #define KBD_LAYOUT 0xfe /* keyboard `get layout' response */
++
++ /* Keyboard IDs */
++ #define KB_SUN2 2 /* type 2 keyboard */
++ #define KB_SUN3 3 /* type 3 keyboard */
++ #define KB_SUN4 4 /* type 4 keyboard */
++
++ /* Key codes are in 0x00..0x7e; KBD_UP is set if the key goes up */
++ #define KBD_KEYMASK 0x7f /* keyboard key mask */
++ #define KBD_UP 0x80 /* keyboard `up' transition */
++
++ /* Keyboard codes needed to recognize the L1-A sequence */
++ #define KBD_L1 1 /* keyboard code for `L1' key */
++ #define KBD_A 77 /* keyboard code for `A' key */
++
++ /* Control codes sent to the various keyboards */
++ #define KBD_CMD_RESET 1 /* reset keyboard */
++ #define KBD_CMD_BELL 2 /* turn bell on */
++ #define KBD_CMD_NOBELL 3 /* turn bell off */
++ #define KBD_CMD_CLICK 10 /* turn keyclick on */
++ #define KBD_CMD_NOCLICK 11 /* turn keyclick off */
++ #define KBD_CMD_SETLED 14 /* set LED state (type 4 kbd) */
++ #define KBD_CMD_GLAYOUT 15 /* get DIP switch (type 4 kbd) */
++
++ #define LED_NUM_LOCK 0x1
++ #if !defined(Lynx) || !defined(LED_COMPOSE)
++ #define LED_COMPOSE 0x2
++ #endif
++ #define LED_SCROLL_LOCK 0x4
++ #define LED_CAPS_LOCK 0x8
+diff -cPr --exclude-from=Excl.include /mnt/DEV_OS.microSPARC/usr/include/kbio.h /usr/include/kbio.h
+*** /mnt/DEV_OS.microSPARC/usr/include/kbio.h
+--- /usr/include/kbio.h Wed Aug 14 16:29:26 1996
+***************
+*** 0 ****
+--- 1,115 ----
++ /* $NetBSD: kbio.h,v 1.4 1995/05/10 16:07:27 pk Exp $ */
++
++ /*
++ * Copyright (c) 1992, 1993
++ * The Regents of the University of California. All rights reserved.
++ *
++ * This software was developed by the Computer Systems Engineering group
++ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
++ * contributed to Berkeley.
++ *
++ * All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Lawrence Berkeley Laboratory.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ * notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ * notice, this list of conditions and the following disclaimer in the
++ * documentation and/or other materials provided with the distribution.
++ * 3. All advertising materials mentioning features or use of this software
++ * must display the following acknowledgement:
++ * This product includes software developed by the University of
++ * California, Berkeley and its contributors.
++ * 4. Neither the name of the University nor the names of its contributors
++ * may be used to endorse or promote products derived from this software
++ * without specific prior written permission.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
++ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
++ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
++ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
++ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
++ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
++ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
++ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
++ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
++ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
++ * SUCH DAMAGE.
++ *
++ * @(#)kbio.h 8.1 (Berkeley) 6/11/93
++ */
++
++ /*
++ * The following is a minimal emulation of Sun's `kio' structures
++ * and related operations necessary to make X11 happy (i.e., make it
++ * compile, and make old X11 binaries run).
++ */
++
++ /*
++ * The kiockey structure apparently gets and/or sets keyboard mappings.
++ * It seems to be kind of useless, but X11 uses it (according to the
++ * comments) to figure out when a Sun 386i has a type-4 keyboard but
++ * claims to have a type-3 keyboard. We need just enough to cause the
++ * appropriate ioctl to return the appropriate magic value.
++ *
++ * KIOCGETKEY fills in kio_entry from kio_station. Not sure what tablemask
++ * is for; X sets it before the call, so it is not an output, but we do not
++ * care anyway. KIOCSDIRECT is supposed to tell the kernel whether to send
++ * keys to the console or to X; we just send them to X whenever the keyboard
++ * is open at all. (XXX may need to change this later)
++ *
++ * Keyboard commands and types are defined in kbd.h as they are actually
++ * real hardware commands and type numbers.
++ */
++ struct okiockey { /* Out-dated key translation structure */
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_char kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ struct kiockey {
++ int kio_tablemask; /* whatever */
++ u_char kio_station; /* key number */
++ u_short kio_entry; /* HOLE if not present */
++ char kio_text[10]; /* the silly escape sequences (unsupported) */
++ };
++
++ /*
++ * Values for kio_tablemask. These determine which table to read/modify
++ * in KIOC[SG]KEY ioctls. Currently, we only have "non-shift" and "shift"
++ * tables.
++ */
++ #define KIOC_NOMASK 0x0
++ #define KIOC_CAPSMASK 0x1
++ #define KIOC_SHIFTMASK 0xe
++ #define KIOC_CTRLMASK 0x30
++ #define KIOC_ALTGMASK 0x200
++ #define KIOC_NUMLMASK 0x800
++
++ #define HOLE 0x302 /* value for kio_entry to say `really type 3' */
++
++ #define KIOCTRANS _IOW('k', 0, int) /* set translation mode */
++ /* (we only accept TR_UNTRANS_EVENT) */
++ #define KIOCGETKEY _IOWR('k', 2, struct okiockey) /* fill in kio_entry */
++ #define KIOCGTRANS _IOR('k', 5, int) /* get translation mode */
++ #define KIOCCMD _IOW('k', 8, int) /* X uses this to ring bell */
++ #define KIOCTYPE _IOR('k', 9, int) /* get keyboard type */
++ #define KIOCSDIRECT _IOW('k', 10, int) /* keys to console? */
++ #define KIOCSKEY _IOW('k', 12, struct kiockey) /* set xlat mode */
++ #ifndef Lynx
++ #define KIOCGKEY _IOWR('k', 13, struct kiockey) /* get xlat mode */
++ #endif
++ #define KIOCLAYOUT _IOR('k', 20, int) /* get keyboard layout */
++ #define KIOCSLED _IOW('k', 14, char) /* set LED state */
++ #define KIOCGLED _IOR('k', 15, char) /* get LED state */
++
++ #define TR_NONE 0 /* X compat, unsupported */
++ #define TR_ASCII 1 /* X compat, unsupported */
++ #define TR_EVENT 2 /* X compat, unsupported */
++ #define TR_UNTRANS_EVENT 3
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/Makefile sys/drivers/console/Makefile
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/Makefile Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/Makefile Fri Aug 2 09:03:05 1996
+***************
+*** 31,37 ****
+ # (keyboard) duart. The mouse is attached to this port. It must be
+ # defined for the X server to work.
+ #
+! SPECIAL_CFLAGS = -DMOUSESUPPORT -O
+
+ FILES = atcdrvr.xxx gfont.xxx atkey.xxx atbeep.xxx atterm.xxx atutils.xxx
+ HFILES =
+--- 31,37 ----
+ # (keyboard) duart. The mouse is attached to this port. It must be
+ # defined for the X server to work.
+ #
+! SPECIAL_CFLAGS = -DMOUSESUPPORT -DXSERVERSUPPORT -O
+
+ FILES = atcdrvr.xxx gfont.xxx atkey.xxx atbeep.xxx atterm.xxx atutils.xxx
+ HFILES =
+***************
+*** 117,122 ****
+--- 117,130 ----
+
+ # Just Do It.
+ FORCE:
++
++ atkey.kdb.o : atkey.c
++ $(KERN_CC) -c -o atkey.kdb.o $(SPECIAL_CFLAGS) $(KERN_CFLAGS) \
++ $(SPECIAL_INCLUDES) $(KERN_INCLUDES) -DSKDB atkey.c
++
++ atkey.nokdb.o : atkey.c
++ $(KERN_CC) -c -o atkey.kdb.o $(SPECIAL_CFLAGS) $(KERN_CFLAGS) \
++ $(SPECIAL_INCLUDES) $(KERN_INCLUDES) atkey.c
+
+ # Dependencies as of 5/20/1992
+
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atc.h sys/drivers/console/atc.h
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atc.h Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atc.h Wed Jul 24 11:49:21 1996
+***************
+*** 191,196 ****
+--- 191,202 ----
+ #ifdef MOUSESUPPORT
+ struct ttystatics mousechannel;
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ int kbd_pending;
++ int kbd_id; /* keyboard type */
++ int kbd_layout; /* layout on type 4 */
++ int kbd_click; /* kbd click on? */
++ #endif
+ };
+
+ struct kbd_registers_type {
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atcdrvr.c sys/drivers/console/atcdrvr.c
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atcdrvr.c Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atcdrvr.c Wed Aug 14 16:28:23 1996
+***************
+*** 270,275 ****
+--- 270,279 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ char *screen_address; /* is this supposed to be in the driver info? */
+
+***************
+*** 537,542 ****
+--- 541,550 ----
+ int m;
+ int ps;
+ extern int set_kb_lights();
++ #ifdef XSERVERSUPPORT
++ extern int kbd_docmd();
++ int err;
++ #endif
+
+ if (!atc_flag){ pseterr(EIO); return(SYSERR);}
+ #ifdef MOUSESUPPORT
+***************
+*** 586,597 ****
+ #ifdef TIOLED
+ case TIOLED:
+ #endif
+ h->curled = *arg;
+ if (h->ledstate == -1) {
+ if (timeout(set_kb_lights,h,1) != -1)
+ h->ledstate = 0;
+ }
+! break;
+ case VT_OPENQRY:
+ if (h->multimode == SCM_ONE) {
+ if (!(h->open & 1)) {
+--- 594,630 ----
+ #ifdef TIOLED
+ case TIOLED:
+ #endif
++ #ifdef XSERVERSUPPORT
++ case KIOCSLED:
++ #endif
+ h->curled = *arg;
+ if (h->ledstate == -1) {
+ if (timeout(set_kb_lights,h,1) != -1)
+ h->ledstate = 0;
+ }
+! return OK;
+! #ifdef XSERVERSUPPORT
+! case KIOCTYPE:
+! if (wbounds(arg) < sizeof(int)) {
+! pseterr(EFAULT);
+! return SYSERR;
+! }
+! *(int *)arg = h->kbd_id;
+! return OK;
+! case KIOCLAYOUT:
+! if (wbounds(arg) < sizeof(int)) {
+! pseterr(EFAULT);
+! return SYSERR;
+! }
+! *(int *)arg = h->kbd_layout;
+! return OK;
+! case KIOCCMD:
+! if (err = kbd_docmd(h, *(int *)arg)) {
+! pseterr(err);
+! return SYSERR;
+! }
+! return OK;
+! #endif
+ case VT_OPENQRY:
+ if (h->multimode == SCM_ONE) {
+ if (!(h->open & 1)) {
+***************
+*** 810,815 ****
+--- 843,854 ----
+ h->open = 0;
+ h->break_code = 0;
+ h->info = info;
++ #ifdef XSERVERSUPPORT
++ h->kbd_pending = 0;
++ h->kbd_id = KB_SUN4; /* query KBD later.... */
++ h->kbd_layout = 0; /* US_ASCII */
++ h->kbd_click = 0; /* silent movie */
++ #endif
+ #ifdef MOUSESUPPORT
+ tmgr_install(&h->mousechannel, &info->sg, 0, mouse_xmit_ena, h);
+ #endif /* MOUSESUPPORT */
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atkey.c sys/drivers/console/atkey.c
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atkey.c Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atkey.c Mon Sep 23 09:19:36 1996
+***************
+*** 162,167 ****
+--- 162,171 ----
+ #ifdef MOUSESUPPORT
+ #include "am8530.h"
+ #endif /* MOUSESUPPORT */
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++ #endif
+
+ #define NOTHING_USEFUL -1
+ #define FILL NOTHING_USEFUL
+***************
+*** 474,480 ****
+ #undef DEBUG
+
+ j = *(volatile unsigned char *)KV_KBD_DATA;
+!
+ /* Do the quick scan mode check first. If scanning, stuff and exit */
+ screen_num = (h->g - &h->screen[0]);
+ if (h->screen[screen_num].scan_mode) {
+--- 478,503 ----
+ #undef DEBUG
+
+ j = *(volatile unsigned char *)KV_KBD_DATA;
+! #ifdef XSERVERSUPPORT
+! if (h->kbd_pending == KBD_RESET) {
+! h->kbd_pending = 0;
+! h->kbd_id = j;
+! if (j == KB_SUN4) {
+! extern int byte_to_keyboard();
+! timeout(byte_to_keyboard, KBD_CMD_GLAYOUT, 1);
+! }
+! goto EOIandExit;
+! }
+! if (h->kbd_pending == KBD_LAYOUT) {
+! h->kbd_pending = 0;
+! h->kbd_layout = j;
+! goto EOIandExit;
+! }
+! if (j == KBD_RESET || j == KBD_LAYOUT) {
+! h->kbd_pending = j;
+! goto EOIandExit;
+! }
+! #endif
+ /* Do the quick scan mode check first. If scanning, stuff and exit */
+ screen_num = (h->g - &h->screen[0]);
+ if (h->screen[screen_num].scan_mode) {
+diff -cPr --exclude=*.[oa] /mnt/DEV_OS.microSPARC/sys/drivers/console/atutils.c sys/drivers/console/atutils.c
+*** /mnt/DEV_OS.microSPARC/sys/drivers/console/atutils.c Fri Apr 26 23:27:51 1996
+--- sys/drivers/console/atutils.c Tue Aug 13 11:54:38 1996
+***************
+*** 456,462 ****
+ }
+
+
+! static int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+--- 456,465 ----
+ }
+
+
+! #ifndef XSERVERSUPPORT
+! static
+! #endif
+! int byte_to_keyboard(byt)
+ unsigned char byt;
+ {
+ int i;
+***************
+*** 495,497 ****
+--- 498,544 ----
+ break;
+ }
+ }
++
++ #ifdef XSERVERSUPPORT
++ #include <kbd.h>
++ #include <kbio.h>
++
++ /*
++ * Execute a keyboard command; return 0 on success.
++ */
++ kbd_docmd(h, cmd)
++ register struct kdhglobals *h;
++ int cmd;
++ {
++ switch (cmd) {
++
++ case KBD_CMD_BELL:
++ case KBD_CMD_NOBELL:
++ /* Supported by type 2, 3, and 4 keyboards */
++ break;
++
++ case KBD_CMD_CLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 1;
++ break;
++ }
++ return (EINVAL);
++
++ case KBD_CMD_NOCLICK:
++ /* Unsupported by type 2 keyboards */
++ if (h->kbd_id != KB_SUN2) {
++ h->kbd_click = 0;
++ break;
++ }
++ return (EINVAL);
++
++ default:
++ return (EINVAL); /* ENOTTY? EOPNOTSUPP? */
++ }
++
++ if (timeout(byte_to_keyboard, cmd, 1) < 0)
++ return (ENOSPC); /* ERESTART? */
++ return (0);
++ }
++ #endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sun.h b/nx-X11/programs/Xserver/hw/sunLynx/sun.h
new file mode 100644
index 000000000..edca59c19
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sun.h
@@ -0,0 +1,486 @@
+/* $Xorg: sun.h,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+
+/* This is sun.h modified for LynxOS */
+
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sun.h,v 3.7 2001/07/25 15:05:02 dawes Exp $ */
+
+#ifndef _SUN_H_
+#define _SUN_H_
+
+/* X headers */
+#include <X11/Xos.h>
+#undef index /* don't mangle silly Sun structure member names */
+#include <X11/X.h>
+#include <X11/Xproto.h>
+
+/* general system headers */
+#ifndef NOSTDHDRS
+# include <stdlib.h>
+#else
+# include <malloc.h>
+extern char *getenv();
+#endif
+
+/* system headers common to both SunOS and Solaris */
+#include <sys/param.h>
+#include <sys/file.h>
+#ifndef Lynx
+# include <sys/filio.h>
+#else
+# include <sys/termio.h> /* include this before ioctl.h ... */
+#endif
+#include <sys/ioctl.h>
+#include <sys/resource.h>
+
+#ifdef SVR4
+# ifdef X_POSIX_C_SOURCE
+# define _POSIX_C_SOURCE X_POSIX_C_SOURCE
+# include <signal.h>
+# undef _POSIX_C_SOURCE
+# else
+# define _POSIX_SOURCE
+# include <signal.h>
+# undef _POSIX_SOURCE
+# endif
+#endif
+
+#include <fcntl.h>
+
+#ifndef __bsdi__
+# if !defined(__NetBSD__) && !defined(__OpenBSD__)
+# ifndef Lynx
+# ifndef i386
+# include <poll.h>
+# else
+# include <sys/poll.h>
+# endif
+# endif
+# endif
+#else
+# include <unistd.h>
+#endif
+
+#include <errno.h>
+#include <memory.h>
+
+/*
+ * Sun specific headers Sun moved in Solaris, and are different for NetBSD.
+ *
+ * Even if only needed by one source file, I have put them here
+ * to simplify finding them...
+ */
+#ifdef SVR4
+# include <sys/fbio.h>
+# include <sys/kbd.h>
+# include <sys/kbio.h>
+# include <sys/msio.h>
+# include <sys/vuid_event.h>
+# include <sys/memreg.h>
+# include <stropts.h>
+# define usleep(usec) poll((struct pollfd *) 0, (size_t) 0, usec / 1000)
+#else
+# if !defined(__NetBSD__) && !defined(__OpenBSD__) && !defined(Lynx)
+# include <sun/fbio.h>
+# include <sundev/kbd.h>
+# include <sundev/kbio.h>
+# include <sundev/msio.h>
+# include <sundev/vuid_event.h>
+# include <pixrect/pixrect.h>
+# include <pixrect/memreg.h>
+extern int ioctl();
+extern int getrlimit();
+extern int setrlimit();
+extern int getpagesize();
+# else
+# if defined (__NetBSD__) || defined (__OpenBSD__)
+# include <machine/fbio.h>
+# include <machine/kbd.h>
+# include <machine/kbio.h>
+# include <machine/vuid_event.h>
+# endif
+# ifdef __bsdi__
+# include <sys/fbio.h>
+# include </sys/sparc/dev/kbd.h>
+# include </sys/sparc/dev/kbio.h>
+# include </sys/sparc/dev/vuid_event.h>
+# endif
+# ifdef Lynx
+# ifndef __P
+# define __P(x) x
+# endif
+# include <signal.h>
+# ifdef PATCHED_CONSOLE
+# include <kbio.h>
+# include <kbd.h>
+# else
+# define KB_SUN2 2 /* type 2 keyboard */
+# define KB_SUN3 3 /* type 3 keyboard */
+# define KB_SUN4 4 /* type 4 keyboard */
+# define KIOCSLED TIOCLED
+# define LED_NUM_LOCK NUM_LOCK
+# define LED_SCROLL_LOCK SCROL_LOCK
+# define LED_CAPS_LOCK CAPS_LOCK
+# define LED_COMPOSE COMPOSE_LED
+# endif
+# include <smem.h>
+# include "fbio.h"
+# include "vuid_event.h"
+# define FBIORESET _IO('F', 29)
+# endif
+# endif
+#endif
+extern int gettimeofday();
+
+/*
+ * Server specific headers
+ */
+#include "misc.h"
+#undef abs /* don't munge function prototypes in headers, sigh */
+#include "scrnintstr.h"
+#ifdef NEED_EVENTS
+# include "inputstr.h"
+#endif
+#include "input.h"
+#include "colormapst.h"
+#include "colormap.h"
+#include "cursorstr.h"
+#include "cursor.h"
+#include "dixstruct.h"
+#include "dix.h"
+#include "opaque.h"
+#include "resource.h"
+#include "servermd.h"
+#include "windowstr.h"
+
+/*
+ * ddx specific headers
+ */
+#ifndef PSZ
+#define PSZ 8
+#endif
+
+#include "mi/mibstore.h"
+#include "mi/mipointer.h"
+
+extern int monitorResolution;
+
+
+/* Frame buffer devices */
+#ifdef SVR4
+# define CGTWO0DEV "/dev/fbs/cgtwo0"
+# define CGTWO1DEV "/dev/fbs/cgtwo1"
+# define CGTWO2DEV "/dev/fbs/cgtwo2"
+# define CGTWO3DEV "/dev/fbs/cgtwo3"
+# define CGTHREE0DEV "/dev/fbs/cgthree0"
+# define CGTHREE1DEV "/dev/fbs/cgthree1"
+# define CGTHREE2DEV "/dev/fbs/cgthree2"
+# define CGTHREE3DEV "/dev/fbs/cgthree3"
+# define CGFOUR0DEV "/dev/fbs/cgfour0"
+# define CGSIX0DEV "/dev/fbs/cgsix0"
+# define CGSIX1DEV "/dev/fbs/cgsix1"
+# define CGSIX2DEV "/dev/fbs/cgsix2"
+# define CGSIX3DEV "/dev/fbs/cgsix3"
+# define BWTWO0DEV "/dev/fbs/bwtwo0"
+# define BWTWO1DEV "/dev/fbs/bwtwo1"
+# define BWTWO2DEV "/dev/fbs/bwtwo2"
+# define BWTWO3DEV "/dev/fbs/bwtwo3"
+# define CGEIGHT0DEV "/dev/fbs/cgeight0"
+#else
+# define CGTWO0DEV "/dev/cgtwo0"
+# define CGTWO1DEV "/dev/cgtwo1"
+# define CGTWO2DEV "/dev/cgtwo2"
+# define CGTWO3DEV "/dev/cgtwo3"
+# define CGTHREE0DEV "/dev/cgthree0"
+# define CGTHREE1DEV "/dev/cgthree1"
+# define CGTHREE2DEV "/dev/cgthree2"
+# define CGTHREE3DEV "/dev/cgthree3"
+# define CGFOUR0DEV "/dev/cgfour0"
+# define CGSIX0DEV "/dev/cgsix0"
+# define CGSIX1DEV "/dev/cgsix1"
+# define CGSIX2DEV "/dev/cgsix2"
+# define CGSIX3DEV "/dev/cgsix3"
+# define BWTWO0DEV "/dev/bwtwo0"
+# define BWTWO1DEV "/dev/bwtwo1"
+# define BWTWO2DEV "/dev/bwtwo2"
+# define BWTWO3DEV "/dev/bwtwo3"
+# define CGEIGHT0DEV "/dev/cgeight0"
+#endif
+
+/*
+ * MAXEVENTS is the maximum number of events the mouse and keyboard functions
+ * will read on a given call to their GetEvents vectors.
+ */
+#ifndef Lynx
+#define MAXEVENTS 32
+#else
+/* currently our mouse stuff is pretty naive, so we need a lot of events */
+#define MAXEVENTS 256
+#endif
+
+/*
+ * Data private to any sun keyboard.
+ */
+typedef struct {
+ int fd;
+ int type; /* Type of keyboard */
+ int layout; /* The layout of the keyboard */
+ int click; /* kbd click save state */
+ Leds leds; /* last known LED state */
+} sunKbdPrivRec, *sunKbdPrivPtr;
+
+extern sunKbdPrivRec sunKbdPriv;
+
+/*
+ * Data private to any sun pointer device.
+ */
+typedef struct {
+ int fd;
+ int bmask; /* last known button state */
+} sunPtrPrivRec, *sunPtrPrivPtr;
+
+extern sunPtrPrivRec sunPtrPriv;
+
+typedef struct {
+ BYTE key;
+ CARD8 modifiers;
+} SunModmapRec;
+
+typedef struct {
+ int width, height;
+ Bool has_cursor;
+ CursorPtr pCursor; /* current cursor */
+} sunCursorRec, *sunCursorPtr;
+
+typedef struct {
+ ColormapPtr installedMap;
+ CloseScreenProcPtr CloseScreen;
+ void (*UpdateColormap)();
+ sunCursorRec hardwareCursor;
+ Bool hasHardwareCursor;
+} sunScreenRec, *sunScreenPtr;
+
+#define GetScreenPrivate(s) ((sunScreenPtr) ((s)->devPrivates[sunScreenIndex].ptr))
+#define SetupScreen(s) sunScreenPtr pPrivate = GetScreenPrivate(s)
+
+typedef struct {
+#ifndef Lynx
+ unsigned char* fb; /* Frame buffer itself */
+#else
+ unsigned char* fbuf; /* Frame buffer itself */
+ void* ramdac; /* Color LookUp table */
+ void* fb; /* GX FB control registers:
+ * sunGX.c relies on this name
+ */
+ void* tec; /* GX TEC registers */
+ void* thc; /* GX THC registers */
+ void* fhc; /* GX FHC registers */
+#endif
+ int fd; /* frame buffer for ioctl()s, */
+ struct fbtype info; /* Frame buffer characteristics */
+ void (*EnterLeave)();/* screen switch */
+ unsigned char* fbPriv; /* fbattr stuff, for the real type */
+} fbFd;
+
+typedef Bool (*sunFbInitProc)(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+
+typedef struct {
+ sunFbInitProc init; /* init procedure for this fb */
+ char* name; /* /usr/include/fbio names */
+} sunFbDataRec;
+
+#ifdef XKB
+extern Bool noXkbExtension;
+#endif
+
+extern Bool sunAutoRepeatHandlersInstalled;
+extern long sunAutoRepeatInitiate;
+extern long sunAutoRepeatDelay;
+extern sunFbDataRec sunFbData[];
+extern fbFd sunFbs[];
+extern Bool sunSwapLkeys;
+extern Bool sunFlipPixels;
+extern Bool sunActiveZaphod;
+extern Bool sunFbInfo;
+extern Bool sunCG4Frob;
+extern Bool sunNoGX;
+extern int sunScreenIndex;
+extern int* sunProtected;
+
+extern Bool sunCursorInitialize(
+ ScreenPtr /* pScreen */
+);
+
+extern void sunDisableCursor(
+ ScreenPtr /* pScreen */
+);
+
+extern int sunChangeKbdTranslation(
+ int /* fd */,
+ Bool /* makeTranslated */
+);
+
+extern void sunNonBlockConsoleOff(
+#if defined(SVR4) || defined(CSRG_BASED) || defined(Lynx)
+ void
+#else
+ char* /* arg */
+#endif
+);
+
+extern void sunEnqueueEvents(
+ void
+);
+
+extern void sunEnqueueKbdEvents(
+ void
+);
+
+extern void sunEnqueueMseEvents(
+ void
+);
+
+extern int sunGXInit(
+ ScreenPtr /* pScreen */,
+ fbFd* /* fb */
+);
+
+extern Bool sunSaveScreen(
+ ScreenPtr /* pScreen */,
+ int /* on */
+);
+
+extern Bool sunScreenInit(
+ ScreenPtr /* pScreen */
+);
+
+extern pointer sunMemoryMap(
+ size_t /* len */,
+ off_t /* off */,
+ int /* fd */
+#ifdef Lynx
+ , char * /* name */
+#endif
+);
+
+extern Bool sunScreenAllocate(
+ ScreenPtr /* pScreen */
+);
+
+extern Bool sunInitCommon(
+ int /* scrn */,
+ ScreenPtr /* pScrn */,
+ off_t /* offset */,
+ Bool (* /* init1 */)(),
+ void (* /* init2 */)(),
+ Bool (* /* cr_cm */)(),
+ Bool (* /* save */)(),
+ int /* fb_off */
+);
+
+extern Firm_event* sunKbdGetEvents(
+ int /* fd */,
+ Bool /* on */,
+ int* /* pNumEvents */,
+ Bool* /* pAgain */
+);
+
+extern Firm_event* sunMouseGetEvents(
+ int /* fd */,
+ Bool /* on */,
+ int* /* pNumEvents */,
+ Bool* /* pAgain */
+);
+
+extern void sunKbdEnqueueEvent(
+ DeviceIntPtr /* device */,
+ Firm_event* /* fe */
+);
+
+extern void sunMouseEnqueueEvent(
+ DeviceIntPtr /* device */,
+ Firm_event* /* fe */
+);
+
+extern int sunKbdProc(
+ DeviceIntPtr /* pKeyboard */,
+ int /* what */
+);
+
+extern int sunMouseProc(
+ DeviceIntPtr /* pMouse */,
+ int /* what */
+);
+
+extern void sunKbdWait(
+ void
+);
+
+/*-
+ * TVTOMILLI(tv)
+ * Given a struct timeval, convert its time into milliseconds...
+ */
+#define TVTOMILLI(tv) (((tv).tv_usec/1000)+((tv).tv_sec*1000))
+
+extern Bool sunCfbSetupScreen(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern Bool sunCfbFinishScreenInit(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern Bool sunCfbScreenInit(
+ ScreenPtr /* pScreen */,
+ pointer /* pbits */, /* pointer to screen bitmap */
+ int /* xsize */, /* in pixels */
+ int /* ysize */,
+ int /* dpix */, /* dots per inch */
+ int /* dpiy */, /* dots per inch */
+ int /* width */, /* pixel width of frame buffer */
+ int /* bpp */ /* bits per pixel of root */
+);
+
+extern void sunInstallColormap(
+ ColormapPtr /* cmap */
+);
+
+extern void sunUninstallColormap(
+ ColormapPtr /* cmap */
+);
+
+extern int sunListInstalledColormaps(
+ ScreenPtr /* pScreen */,
+ Colormap* /* pCmapList */
+);
+
+#endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c
new file mode 100644
index 000000000..48f63c759
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyCfb.c
@@ -0,0 +1,372 @@
+/* $Xorg: sunLyCfb.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
+/*
+ * This is sunCfb.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyCfb.c,v 3.4 2001/01/17 22:36:53 dawes Exp $ */
+
+/*
+Copyright 1990, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ * Copyright 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "sun.h"
+#include "cfb/cfb.h"
+#include "mi/miline.h"
+
+#define GXZEROLINEBIAS (OCTANT1 | OCTANT3 | OCTANT4 | OCTANT6)
+
+static void CGUpdateColormap(pScreen, dex, count, rmap, gmap, bmap)
+ ScreenPtr pScreen;
+ int dex, count;
+ u_char *rmap, *gmap, *bmap;
+{
+ struct fbcmap sunCmap;
+
+ sunCmap.index = dex;
+ sunCmap.count = count;
+ sunCmap.red = &rmap[dex];
+ sunCmap.green = &gmap[dex];
+ sunCmap.blue = &bmap[dex];
+
+ if (sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap) < 0) {
+ Error("CGUpdateColormap");
+ FatalError( "CGUpdateColormap: FBIOPUTCMAP failed\n" );
+ }
+}
+
+void sunInstallColormap(cmap)
+ ColormapPtr cmap;
+{
+ SetupScreen(cmap->pScreen);
+ register int i;
+ register Entry *pent;
+ register VisualPtr pVisual = cmap->pVisual;
+ u_char rmap[256], gmap[256], bmap[256];
+ unsigned long rMask, gMask, bMask;
+ int oRed, oGreen, oBlue;
+
+ if (cmap == pPrivate->installedMap)
+ return;
+ if (pPrivate->installedMap)
+ WalkTree(pPrivate->installedMap->pScreen, TellLostMap,
+ (pointer) &(pPrivate->installedMap->mid));
+ if ((pVisual->class | DynamicClass) == DirectColor) {
+ if (pVisual->ColormapEntries < 256) {
+ rMask = pVisual->redMask;
+ gMask = pVisual->greenMask;
+ bMask = pVisual->blueMask;
+ oRed = pVisual->offsetRed;
+ oGreen = pVisual->offsetGreen;
+ oBlue = pVisual->offsetBlue;
+ } else {
+ rMask = gMask = bMask = 255;
+ oRed = oGreen = oBlue = 0;
+ }
+ for (i = 0; i < 256; i++) {
+ rmap[i] = cmap->red[(i & rMask) >> oRed].co.local.red >> 8;
+ gmap[i] = cmap->green[(i & gMask) >> oGreen].co.local.green >> 8;
+ bmap[i] = cmap->blue[(i & bMask) >> oBlue].co.local.blue >> 8;
+ }
+ } else {
+ for (i = 0, pent = cmap->red;
+ i < pVisual->ColormapEntries;
+ i++, pent++) {
+ if (pent->fShared) {
+ rmap[i] = pent->co.shco.red->color >> 8;
+ gmap[i] = pent->co.shco.green->color >> 8;
+ bmap[i] = pent->co.shco.blue->color >> 8;
+ }
+ else {
+ rmap[i] = pent->co.local.red >> 8;
+ gmap[i] = pent->co.local.green >> 8;
+ bmap[i] = pent->co.local.blue >> 8;
+ }
+ }
+ }
+ pPrivate->installedMap = cmap;
+ (*pPrivate->UpdateColormap) (cmap->pScreen, 0, 256, rmap, gmap, bmap);
+ WalkTree(cmap->pScreen, TellGainedMap, (pointer) &(cmap->mid));
+}
+
+void sunUninstallColormap(cmap)
+ ColormapPtr cmap;
+{
+ SetupScreen(cmap->pScreen);
+ if (cmap == pPrivate->installedMap) {
+ Colormap defMapID = cmap->pScreen->defColormap;
+
+ if (cmap->mid != defMapID) {
+ ColormapPtr defMap = (ColormapPtr) LookupIDByType(defMapID,
+ RT_COLORMAP);
+
+ if (defMap)
+ (*cmap->pScreen->InstallColormap)(defMap);
+ else
+ ErrorF("sunFbs: Can't find default colormap\n");
+ }
+ }
+}
+
+int sunListInstalledColormaps(pScreen, pCmapList)
+ ScreenPtr pScreen;
+ Colormap *pCmapList;
+{
+ SetupScreen(pScreen);
+ *pCmapList = pPrivate->installedMap->mid;
+ return (1);
+}
+
+static void CGStoreColors(pmap, ndef, pdefs)
+ ColormapPtr pmap;
+ int ndef;
+ xColorItem *pdefs;
+{
+ SetupScreen(pmap->pScreen);
+ u_char rmap[256], gmap[256], bmap[256];
+ xColorItem expanddefs[256];
+ register int i;
+
+ if (pPrivate->installedMap != NULL && pPrivate->installedMap != pmap)
+ return;
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ ndef = cfbExpandDirectColors(pmap, ndef, pdefs, expanddefs);
+ pdefs = expanddefs;
+ }
+ while (ndef--) {
+ i = pdefs->pixel;
+ rmap[i] = pdefs->red >> 8;
+ gmap[i] = pdefs->green >> 8;
+ bmap[i] = pdefs->blue >> 8;
+ (*pPrivate->UpdateColormap) (pmap->pScreen, i, 1, rmap, gmap, bmap);
+ pdefs++;
+ }
+}
+
+static void CGScreenInit (pScreen)
+ ScreenPtr pScreen;
+{
+#ifndef STATIC_COLOR /* { */
+ SetupScreen (pScreen);
+ pScreen->InstallColormap = sunInstallColormap;
+ pScreen->UninstallColormap = sunUninstallColormap;
+ pScreen->ListInstalledColormaps = sunListInstalledColormaps;
+ pScreen->StoreColors = CGStoreColors;
+ pPrivate->UpdateColormap = CGUpdateColormap;
+ if (sunFlipPixels) {
+ Pixel pixel = pScreen->whitePixel;
+ pScreen->whitePixel = pScreen->blackPixel;
+ pScreen->blackPixel = pixel;
+ }
+#endif /* } */
+}
+
+static void checkMono (argc, argv)
+ int argc;
+ char** argv;
+{
+ int i;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp (argv[i], "-mono") == 0)
+ ErrorF ("-mono not appropriate for CG3/CG6\n");
+}
+
+Bool sunCG3Init (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! */
+{
+ unsigned long addr;
+
+ checkMono (argc, argv);
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYLOC, &addr) < 0) {
+ perror("TIO_QUERYLOC");
+ FatalError("%s:%d can't query FB addr sunFbs[%d].fd=%d\n",
+ __FILE__, __LINE__, screen, sunFbs[screen]);
+ }
+ return sunInitCommon (screen, pScreen, (off_t) addr,
+ sunCfbScreenInit, CGScreenInit,
+ cfbCreateDefColormap, sunSaveScreen, 0);
+}
+
+Bool sunCG6Init (screen, pScreen, argc, argv)
+ int screen; /* The index of pScreen in the ScreenInfo */
+ ScreenPtr pScreen; /* The Screen to initialize */
+ int argc; /* The number of the Server's arguments. */
+ char** argv; /* The arguments themselves. Don't change! */
+{
+ unsigned long dacoffset;
+ unsigned long addr;
+ pointer fbc;
+ pointer fhc;
+ pointer fb;
+
+ checkMono (argc, argv);
+ if (!sunScreenAllocate (pScreen))
+ return FALSE;
+ if (!sunFbs[screen].fbuf) {
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYLOC, &addr) < 0) {
+ perror("TIO_QUERYLOC");
+ FatalError("%s:%d can't query FB addr sunFbs[%d].fd=%d\n",
+ __FILE__, __LINE__, screen, sunFbs[screen]);
+ }
+ if ((fb = sunMemoryMap(0x00100000, (off_t) addr + 0x00800000UL,
+ sunFbs[screen].fd, "FB")) == NULL)
+ return FALSE;
+
+ if ((fbc = sunMemoryMap(0x2000, (off_t) addr + 0x00700000UL,
+ sunFbs[screen].fd, "FBC_TEC")) == NULL)
+ return FALSE;
+
+ if ((fhc = sunMemoryMap(0x2000, (off_t) addr + 0x00300000UL,
+ sunFbs[screen].fd, "FHC_THC")) == NULL)
+ return FALSE;
+
+ sunFbs[screen].fhc = fhc;
+ sunFbs[screen].thc = (char *)fhc + 0x1000;
+ sunFbs[screen].fb = fbc;
+ sunFbs[screen].tec = (char *)fbc + 0x1000;
+ sunFbs[screen].fbuf = fb;
+
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYRAMDAC, &dacoffset) < 0)
+ FatalError("can't query DAC addr\n");
+ if ((sunFbs[screen].ramdac =
+ sunMemoryMap((size_t) sunFbs[screen].info.fb_cmsize * 3,
+ (unsigned long)addr + dacoffset,
+ sunFbs[screen].fd, "DAC")) == NULL)
+ return FALSE;
+ }
+
+ sunFbs[screen].EnterLeave = (void (*)())NoopDDA;
+ if (!sunCfbSetupScreen (pScreen,
+ sunFbs[screen].fbuf,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_depth))
+ return FALSE;
+ if (sunNoGX == FALSE) {
+ /* cleanup CG& hardware state */
+ if (sunIoctl(&sunFbs[screen], FBIORESET, 0) < 0)
+ perror("FBIORESET");
+ if (!sunGXInit (pScreen, &sunFbs[screen]))
+ return FALSE;
+ }
+ if (!sunCfbFinishScreenInit(pScreen,
+ sunFbs[screen].fbuf,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[screen].info.fb_width,
+ sunFbs[screen].info.fb_depth))
+ return FALSE;
+ miInitializeBackingStore(pScreen);
+ if (sunNoGX == FALSE) {
+ miSetZeroLineBias(pScreen, GXZEROLINEBIAS);
+ }
+ CGScreenInit (pScreen);
+ if (!sunScreenInit (pScreen))
+ return FALSE;
+ sunSaveScreen (pScreen, SCREEN_SAVER_OFF);
+ return cfbCreateDefColormap(pScreen);
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c
new file mode 100644
index 000000000..25448d91d
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyFbs.c
@@ -0,0 +1,292 @@
+/* $Xorg: sunLyFbs.c,v 1.4 2001/02/09 02:04:44 xorgcvs Exp $ */
+/*
+ * This is sunFbs.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyFbs.c,v 3.6 2001/12/14 19:59:44 dawes Exp $ */
+
+/*
+Copyright 1990, 1993, 1998 The Open Group
+
+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.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ * Copyright 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+#include "sun.h"
+#include <smem.h>
+
+int sunScreenIndex;
+
+static unsigned long generation = 0;
+
+pointer sunMemoryMap (
+ size_t len,
+ off_t off,
+ int fd,
+ char *name
+ )
+{
+ int pagemask, mapsize;
+ caddr_t addr;
+ pointer mapaddr;
+
+ pagemask = getpagesize() - 1;
+ mapsize = ((int) len + pagemask) & ~pagemask;
+ addr = 0;
+
+ mapaddr = smem_create(name, (char *)off, mapsize, SM_READ|SM_WRITE);
+ if (mapaddr == (pointer) -1) {
+ Error ("mapping frame buffer memory");
+ (void) close (fd);
+ mapaddr = (pointer) NULL;
+ }
+ return mapaddr;
+}
+
+Bool sunScreenAllocate (
+ ScreenPtr pScreen)
+{
+ sunScreenPtr pPrivate;
+ extern int AllocateScreenPrivateIndex();
+
+ if (generation != serverGeneration)
+ {
+ sunScreenIndex = AllocateScreenPrivateIndex();
+ if (sunScreenIndex < 0)
+ return FALSE;
+ generation = serverGeneration;
+ }
+ pPrivate = (sunScreenPtr) xalloc (sizeof (sunScreenRec));
+ if (!pPrivate)
+ return FALSE;
+
+ pScreen->devPrivates[sunScreenIndex].ptr = (pointer) pPrivate;
+ return TRUE;
+}
+
+Bool sunSaveScreen (
+ ScreenPtr pScreen,
+ int on)
+{
+ int state;
+
+ if (on != SCREEN_SAVER_FORCER)
+ {
+ if (on == SCREEN_SAVER_ON)
+ state = 0;
+ else
+ state = 1;
+ (void) sunIoctl(&sunFbs[pScreen->myNum], FBIOSVIDEO, &state);
+ }
+ return( TRUE );
+}
+
+static Bool closeScreen (i, pScreen)
+ int i;
+ ScreenPtr pScreen;
+{
+ SetupScreen(pScreen);
+ Bool ret;
+ struct fbcmap sunCmap;
+ unsigned char color;
+
+ (void) OsSignal (SIGIO, SIG_IGN);
+ sunDisableCursor (pScreen);
+ pScreen->CloseScreen = pPrivate->CloseScreen;
+ ret = (*pScreen->CloseScreen) (i, pScreen);
+ (void) (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+ /* probably this doesn't belong here: restore black&white cmap */
+ sunCmap.count = 1;
+ sunCmap.index = 0;
+ sunCmap.red = sunCmap.green = sunCmap.blue = &color;
+ color = 0xff;
+ (void) sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap);
+ sunCmap.index = 0xff;
+ color = 0;
+ (void) sunIoctl(&sunFbs[pScreen->myNum], FBIOPUTCMAP, &sunCmap);
+ xfree ((pointer) pPrivate);
+ return ret;
+}
+
+Bool sunScreenInit (
+ ScreenPtr pScreen)
+{
+ SetupScreen(pScreen);
+ extern void sunBlockHandler();
+ extern void sunWakeupHandler();
+ static ScreenPtr autoRepeatScreen;
+ extern miPointerScreenFuncRec sunPointerScreenFuncs;
+
+ pPrivate->installedMap = 0;
+ pPrivate->CloseScreen = pScreen->CloseScreen;
+ pScreen->CloseScreen = closeScreen;
+ pScreen->SaveScreen = sunSaveScreen;
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ /*
+ * Block/Unblock handlers
+ */
+ if (sunAutoRepeatHandlersInstalled == FALSE) {
+ autoRepeatScreen = pScreen;
+ sunAutoRepeatHandlersInstalled = TRUE;
+ }
+
+ if (pScreen == autoRepeatScreen) {
+ pScreen->BlockHandler = sunBlockHandler;
+ pScreen->WakeupHandler = sunWakeupHandler;
+ }
+#ifdef XKB
+ } else {
+ /* this works around a weird behaviour on LynxOS 2.4.0:
+ * usually we have no problems using true SIGIO driven mouse input
+ * as it is used on the other UN*X Suns. On LynxOS we have a
+ * strange behaviour upon the very first server startup after a
+ * reboot. We won't get SIGIOs from the mouse device. The mouse
+ * will only move if we get SIGIOs from the keyboard.
+ * The solution (for now) is to use a WakeupHandler and
+ * poll the mouse file descriptor.
+ */
+ pScreen->WakeupHandler = sunWakeupHandler;
+ }
+#endif
+ if (!sunCursorInitialize (pScreen))
+ miDCInitialize (pScreen, &sunPointerScreenFuncs);
+ return TRUE;
+}
+
+Bool sunInitCommon (
+ int scrn,
+ ScreenPtr pScrn,
+ off_t offset,
+ Bool (*init1)(),
+ void (*init2)(),
+ Bool (*cr_cm)(),
+ Bool (*save)(),
+ int fb_off)
+{
+ unsigned char* fb = sunFbs[scrn].fbuf;
+ unsigned char* dac = sunFbs[scrn].ramdac;
+
+ if (!sunScreenAllocate (pScrn))
+ return FALSE;
+ if (!fb) {
+ if ((fb = sunMemoryMap ((size_t) sunFbs[scrn].info.fb_size,
+ (unsigned long)offset + 0x00800000UL,
+ sunFbs[scrn].fd, "FB")) == NULL)
+ return FALSE;
+ sunFbs[scrn].fbuf = fb;
+ if (!dac)
+ {
+ unsigned long dacoffset;
+
+ if (ioctl(sunFbs[scrn].fd, TIO_QUERYRAMDAC, &dacoffset) < 0)
+ FatalError("can't query DAC addr\n");
+ if ((dac = sunMemoryMap((size_t) sunFbs[scrn].info.fb_cmsize * 3,
+ (unsigned long)offset + dacoffset,
+ sunFbs[scrn].fd, "DAC")) == NULL)
+ return FALSE;
+
+ sunFbs[scrn].ramdac = dac;
+ }
+ }
+ /* mfbScreenInit() or cfbScreenInit() */
+ if (!(*init1)(pScrn, fb + fb_off,
+ sunFbs[scrn].info.fb_width,
+ sunFbs[scrn].info.fb_height,
+ monitorResolution, monitorResolution,
+ sunFbs[scrn].info.fb_width,
+ sunFbs[scrn].info.fb_depth))
+ return FALSE;
+ miInitializeBackingStore(pScrn);
+ /* sunCGScreenInit() if cfb... */
+ if (init2)
+ (*init2)(pScrn);
+ if (!sunScreenInit(pScrn))
+ return FALSE;
+ (void) (*save) (pScrn, SCREEN_SAVER_OFF);
+ return (*cr_cm)(pScrn);
+}
+
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c
new file mode 100644
index 000000000..941b363eb
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyInit.c
@@ -0,0 +1,648 @@
+/* $Xorg: sunLyInit.c,v 1.3 2000/08/17 19:48:36 cpqbld Exp $ */
+/*
+ * This is sunInit.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyInit.c,v 3.8 2001/01/17 22:36:53 dawes Exp $ */
+
+/*
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*******************************************************/
+
+#include "sun.h"
+#include "gcstruct.h"
+#include "mi.h"
+#include "mibstore.h"
+#include "cfb.h"
+
+Bool onConsole = FALSE; /* wether stdin is /dev/con */
+
+/* maximum pixmap depth */
+#ifndef SUNMAXDEPTH
+#define SUNMAXDEPTH 8
+#endif
+
+extern Bool sunBW2Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define BW2I sunBW2Init
+#if SUNMAXDEPTH == 1 /* { */
+#define CG3I NULL
+#define CG6I NULL
+#else /* }{ */
+extern Bool sunCG3Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG3I sunCG3Init
+#ifdef FBTYPE_SUNFAST_COLOR /* { */
+extern Bool sunCG6Init(
+ int /* screen */,
+ ScreenPtr /* pScreen */,
+ int /* argc */,
+ char** /* argv */
+);
+#define CG6I sunCG6Init
+#else /* }{ */
+#define CG6I NULL
+#endif /* } */
+#endif /* } */
+
+extern KeySymsRec sunKeySyms[];
+extern SunModmapRec *sunModMaps[];
+extern int sunMaxLayout;
+extern KeySym* sunType4KeyMaps[];
+extern SunModmapRec* sunType4ModMaps[];
+
+static Bool sunDevsInited = FALSE;
+
+Bool sunAutoRepeatHandlersInstalled; /* FALSE each time InitOutput called */
+Bool sunSwapLkeys = FALSE;
+Bool sunFlipPixels = FALSE;
+Bool sunFbInfo = FALSE;
+Bool sunCG4Frob = FALSE;
+Bool sunNoGX = FALSE;
+
+sunKbdPrivRec sunKbdPriv = {
+ -1, /* fd */
+ -1, /* type */
+ -1, /* layout */
+ 0, /* click */
+ (Leds)0, /* leds */
+};
+
+sunPtrPrivRec sunPtrPriv = {
+ -1, /* fd */
+ 0 /* Current button state */
+};
+
+/*
+ * The name member in the following table corresponds to the
+ * FBTYPE_* macros defined in /usr/include/sun/fbio.h file
+ */
+sunFbDataRec sunFbData[FBTYPE_LASTPLUSONE] = {
+ { NULL, "SUN1BW (bw1)" },
+ { NULL, "SUN1COLOR (cg1)" },
+ { BW2I, "SUN2BW (bw2)" },
+ { NULL, "SUN2COLOR (cg2)" },
+ { NULL, "SUN2GP (gp1/gp2)" },
+ { NULL, "SUN5COLOR (cg5/386i accel)" },
+ { CG3I, "SUN3COLOR (cg3)" },
+ { NULL, "MEMCOLOR (cg8)" },
+ { NULL, "SUN4COLOR (cg4)" },
+ { NULL, "NOTSUN1" },
+ { NULL, "NOTSUN2" },
+ { NULL, "NOTSUN3" },
+ { CG6I, "SUNFAST_COLOR (cg6/gx)" }, /* last we need */
+};
+
+/*
+ * a list of devices to try if there is no environment or command
+ * line list of devices
+ */
+#if SUNMAXDEPTH == 1 /* { */
+static char *fallbackList[] = {
+ "/dev/bwtwo",
+};
+#else /* }{ */
+static char *fallbackList[] = {
+ "/dev/bwtwo", "/dev/cgthree", "/dev/cgsix",
+};
+#endif /* } */
+
+#define FALLBACK_LIST_LEN sizeof fallbackList / sizeof fallbackList[0]
+
+fbFd sunFbs[MAXSCREENS];
+
+static PixmapFormatRec formats[] = {
+ { 1, 1, BITMAP_SCANLINE_PAD } /* 1-bit deep */
+#if SUNMAXDEPTH > 1
+ ,{ 8, 8, BITMAP_SCANLINE_PAD} /* 8-bit deep */
+#endif
+};
+#define NUMFORMATS (sizeof formats)/(sizeof formats[0])
+
+/*
+ * OpenFrameBuffer --
+ * Open a frame buffer according to several rules.
+ * Find the device to use by looking in the sunFbData table,
+ * an XDEVICE envariable, a -dev switch or using /dev/fb if trying
+ * to open screen 0 and all else has failed.
+ *
+ * Results:
+ * The fd of the framebuffer.
+ */
+static int OpenFrameBuffer(device, screen)
+ char *device; /* e.g. "/dev/cgtwo0" */
+ int screen; /* what screen am I going to be */
+{
+ int ret;
+ unsigned long dacoffset;
+ struct fbgattr *fbattr = NULL;
+ static int devFbUsed;
+ static struct fbgattr bw2 = {
+ 0, 0,
+ { FBTYPE_SUN2BW, 900, 1152, 1, 0, 0x00100000 },
+ { 0, -1},
+ -1
+ };
+ static struct fbgattr cg3 = {
+ 0, 0,
+ { FBTYPE_SUN3COLOR, 900, 1152, 8, 256, 0x00100000 },
+ { 0, -1},
+ -1
+ };
+ static struct fbgattr cg6 = {
+ 0, 0,
+ { FBTYPE_SUNFAST_COLOR, 900, 1152, 8, 256, 0x00100000 },
+ { 0, -1},
+ -1
+ };
+
+
+ sunFbs[screen].fd = sunKbdPriv.fd; /* /dev/con or /dev/kbd */
+ devFbUsed = TRUE;
+ /* apply some magic to work out what we're running on.
+ * why couldn't they just spend some time on a little
+ * FBIOGATTR ioctl()
+ */
+
+ ret = FALSE;
+ if (ioctl(sunFbs[screen].fd, TIO_QUERYRAMDAC, &dacoffset) < 0)
+ FatalError("can't query DAC addr\n");
+ if (dacoffset == 0x400000) {
+ if (strcmp(device, "/dev/cgthree") == 0)
+ fbattr = &cg3;
+ }
+ else if (dacoffset == 0x200000) {
+ if (strcmp(device, "/dev/cgsix") == 0)
+ fbattr = &cg6;
+ }
+#ifdef PATCHED_CONSOLE
+ else if (dacoffset == 0) {
+ if (strcmp(device, "/dev/bw2") == 0)
+ fbattr = &bw2;
+ }
+#endif
+ else
+ ErrorF("bogus DAC addr 0x%x, maybe it's the silly BWTWO bug\n", dacoffset);
+
+ if (fbattr) {
+ ret = TRUE;
+ sunFbs[screen].info = fbattr->fbtype;
+ }
+ sunFbs[screen].fbPriv = (pointer) fbattr;
+ if (fbattr && fbattr->fbtype.fb_type < FBTYPE_LASTPLUSONE &&
+ !sunFbData[fbattr->fbtype.fb_type].init) {
+ int _i;
+
+ ret = FALSE;
+ for (_i = 0; _i < FB_ATTR_NEMUTYPES; _i++) {
+ if (sunFbData[fbattr->emu_types[_i]].init) {
+ sunFbs[screen].info.fb_type = fbattr->emu_types[_i];
+ ret = TRUE;
+ if (sunFbInfo)
+ ErrorF ("%s is emulating a %s\n", device,
+ sunFbData[fbattr->fbtype.fb_type].name);
+ break;
+ }
+ }
+ }
+ if (sunFbInfo)
+ ErrorF ("%s is really a %s\n", device,
+ sunFbData[fbattr ? fbattr->fbtype.fb_type : sunFbs[screen].info.fb_type].name);
+ if (!ret)
+ sunFbs[screen].fd = -1;
+ return ret;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * SigIOHandler --
+ * Signal handler for SIGIO - input is available.
+ *
+ * Results:
+ * sunSigIO is set - ProcessInputEvents() will be called soon.
+ *
+ * Side Effects:
+ * None
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+/*static*/ void SigIOHandler(sig)
+ int sig;
+{
+ int olderrno = errno;
+ sunEnqueueEvents();
+ errno = olderrno;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunNonBlockConsoleOff --
+ * Turn non-blocking mode on the console off, so you don't get logged
+ * out when the server exits.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+void sunNonBlockConsoleOff(
+ void
+)
+{
+ int i;
+
+#if 0
+ if (sunKbdPriv.fd >= 0)
+ {
+ i = fcntl(sunKbdPriv.fd, F_GETFL, 0);
+ if (i >= 0 && (i & FNDELAY)) {
+ (void) fcntl(sunKbdPriv.fd, F_SETFL, i & ~FNDELAY);
+ }
+ }
+#endif
+ for (i = 0; i < MAXSCREENS; i++) {
+ if (sunFbs[i].fbuf) {
+ smem_create(NULL, (char*)sunFbs[i].fbuf, 0, SM_DETACH);
+ smem_remove("FB");
+ sunFbs[i].fbuf = NULL;
+ }
+ if (sunFbs[i].ramdac) {
+ smem_create(NULL, (char*)sunFbs[i].ramdac, 0, SM_DETACH);
+ smem_remove("DAC");
+ sunFbs[i].ramdac = NULL;
+ }
+ if (sunFbs[i].fhc) {
+ smem_create(NULL, (char*)sunFbs[i].fhc, 0, SM_DETACH);
+ smem_remove("FHC_THC");
+ sunFbs[i].fhc = NULL;
+ sunFbs[i].thc = NULL;
+ }
+ if (sunFbs[i].fb) {
+ smem_create(NULL, (char*)sunFbs[i].fb, 0, SM_DETACH);
+ smem_remove("FBC_TEC");
+ sunFbs[i].fb = NULL;
+ sunFbs[i].tec = NULL;
+ }
+ }
+}
+
+static char** GetDeviceList (argc, argv)
+ int argc;
+ char **argv;
+{
+ int i;
+ char *envList = NULL;
+ char *cmdList = NULL;
+ char **deviceList = (char **)NULL;
+
+ for (i = 1; i < argc; i++)
+ if (strcmp (argv[i], "-dev") == 0 && i+1 < argc) {
+ cmdList = argv[i + 1];
+ break;
+ }
+ if (!cmdList)
+ envList = getenv ("XDEVICE");
+
+ if (cmdList || envList) {
+ char *_tmpa;
+ char *_tmpb;
+ int _i1;
+ deviceList = (char **) xalloc ((MAXSCREENS + 1) * sizeof (char *));
+ _tmpa = (cmdList) ? cmdList : envList;
+ for (_i1 = 0; _i1 < MAXSCREENS; _i1++) {
+ _tmpb = strtok (_tmpa, ":");
+ if (_tmpb)
+ deviceList[_i1] = _tmpb;
+ else
+ deviceList[_i1] = NULL;
+ _tmpa = NULL;
+ }
+ deviceList[MAXSCREENS] = NULL;
+ }
+ if (!deviceList) {
+ /* no environment and no cmdline, so default */
+ deviceList =
+ (char **) xalloc ((FALLBACK_LIST_LEN + 1) * sizeof (char *));
+ for (i = 0; i < FALLBACK_LIST_LEN; i++)
+ deviceList[i] = fallbackList[i];
+ deviceList[FALLBACK_LIST_LEN] = NULL;
+ }
+ return deviceList;
+}
+
+static void getKbdType()
+{
+#if defined(PATCHED_CONSOLE)
+ int ii;
+
+ for (ii = 0; ii < 3; ii++) {
+#if 0
+ sunKbdWait();
+#endif
+ if (ioctl (sunKbdPriv.fd, KIOCTYPE, &sunKbdPriv.type) < 0 && errno == EINVAL) {
+ ErrorF("failed to get keyboard type, maybe wrong console driver:");
+ ErrorF(" assuming Type 4 keyboard\n");
+ sunKbdPriv.type = KB_SUN4;
+ return;
+ }
+ switch (sunKbdPriv.type) {
+ case KB_SUN2:
+ case KB_SUN3:
+ case KB_SUN4:
+ return;
+ default:
+ sunChangeKbdTranslation(sunKbdPriv.fd, FALSE);
+ continue;
+ }
+ }
+ FatalError ("Unsupported keyboard type %d\n", sunKbdPriv.type);
+#else
+ sunKbdPriv.type = KB_SUN4;
+#endif
+}
+
+void OsVendorInit(
+ void
+)
+{
+ static int inited;
+ if (!inited) {
+ /* weird hack to prevent logout on X server shutdown */
+ if (onConsole)
+ sunKbdPriv.fd = open ("/dev/con", O_RDWR, 0);
+ else
+ sunKbdPriv.fd = open ("/dev/kbd", O_RDWR, 0);
+ sunPtrPriv.fd = open ("/dev/mouse", O_RDWR, 0);
+
+ getKbdType ();
+ if (sunKbdPriv.type == KB_SUN4) {
+#if defined(PATCHED_CONSOLE)
+ if ( ioctl (sunKbdPriv.fd, KIOCLAYOUT, &sunKbdPriv.layout) < 0 && errno == EINVAL) {
+ ErrorF("failed to get keyboard layout, maybe wrong console driver:");
+ ErrorF(" assuming layout 0\n");
+ sunKbdPriv.layout = 0;
+ }
+ if (sunKbdPriv.layout < 0 ||
+ sunKbdPriv.layout > sunMaxLayout ||
+ sunType4KeyMaps[sunKbdPriv.layout] == NULL)
+ FatalError ("Unsupported keyboard type 4 layout %d\n",
+ sunKbdPriv.layout);
+#else
+ sunKbdPriv.layout = 0; /* default: Type 4 */
+#endif
+ sunKeySyms[KB_SUN4].map = sunType4KeyMaps[sunKbdPriv.layout];
+ sunModMaps[KB_SUN4] = sunType4ModMaps[sunKbdPriv.layout];
+ }
+ inited = 1;
+ }
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * InitOutput --
+ * Initialize screenInfo for all actually accessible framebuffers.
+ * The
+ *
+ * Results:
+ * screenInfo init proc field set
+ *
+ * Side Effects:
+ * None
+ *
+ *-----------------------------------------------------------------------
+ */
+
+void InitOutput(pScreenInfo, argc, argv)
+ ScreenInfo *pScreenInfo;
+ int argc;
+ char **argv;
+{
+ int i, scr;
+ char **devList;
+ static int setup_on_exit = 0;
+ extern Bool RunFromSmartParent;
+
+ if (!monitorResolution)
+ monitorResolution = 90;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ pScreenInfo->numPixmapFormats = NUMFORMATS;
+ for (i=0; i< NUMFORMATS; i++)
+ pScreenInfo->formats[i] = formats[i];
+#ifdef XKB
+ if (noXkbExtension)
+#endif
+ sunAutoRepeatHandlersInstalled = FALSE;
+ if (!sunDevsInited) {
+ /* first time ever */
+ for (scr = 0; scr < MAXSCREENS; scr++)
+ sunFbs[scr].fd = -1;
+ devList = GetDeviceList (argc, argv);
+ for (i = 0, scr = 0; devList[i] != NULL && scr < MAXSCREENS; i++)
+ if (OpenFrameBuffer (devList[i], scr))
+ scr++;
+ sunDevsInited = TRUE;
+ xfree (devList);
+ }
+ for (scr = 0; scr < MAXSCREENS; scr++)
+ if (sunFbs[scr].fd != -1)
+ (void) AddScreen (sunFbData[sunFbs[scr].info.fb_type].init,
+ argc, argv);
+ (void) OsSignal(SIGWINCH, SIG_IGN);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * InitInput --
+ * Initialize all supported input devices...what else is there
+ * besides pointer and keyboard?
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Two DeviceRec's are allocated and registered as the system pointer
+ * and keyboard devices.
+ *
+ *-----------------------------------------------------------------------
+ */
+void InitInput(argc, argv)
+ int argc;
+ char **argv;
+{
+ DevicePtr p, k;
+ extern Bool mieqInit();
+
+ k = AddInputDevice(sunKbdProc, TRUE);
+ p = AddInputDevice(sunMouseProc, TRUE);
+ if (!p || !k)
+ FatalError("failed to create input devices in InitInput");
+
+ RegisterPointerDevice(p);
+ RegisterKeyboardDevice(k);
+ miRegisterPointerDevice(screenInfo.screens[0], p);
+ (void) mieqInit (k, p);
+
+#define SET_FLOW(fd) fcntl(fd, F_SETFL, FASYNC)
+ (void) OsSignal(SIGIO, SigIOHandler);
+#define WANT_SIGNALS(fd) fcntl(fd, F_SETOWN, getpid())
+ if (sunKbdPriv.fd >= 0) {
+ if (SET_FLOW(sunKbdPriv.fd) == -1 || WANT_SIGNALS(sunKbdPriv.fd) == -1) {
+ (void) close (sunKbdPriv.fd);
+ sunKbdPriv.fd = -1;
+ FatalError("Async kbd I/O failed in InitInput");
+ }
+ }
+ /* SIGIO doesn't work reliable for the mouse device,
+ * esp. for the first server after a reboot. We enable it
+ * anyway, gives smoother movements
+ */
+ if (sunPtrPriv.fd >= 0) {
+ if (SET_FLOW(sunPtrPriv.fd) == -1 || WANT_SIGNALS(sunPtrPriv.fd) == -1) {
+ (void) close (sunPtrPriv.fd);
+ sunPtrPriv.fd = -1;
+ FatalError("ASYNC mouse I/O failed in InitInput");
+ }
+ }
+}
+
+
+#if SUNMAXDEPTH == 8
+
+Bool
+sunCfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbSetupScreen(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbFinishScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy,
+ width);
+}
+
+Bool
+sunCfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, bpp)
+ register ScreenPtr pScreen;
+ pointer pbits; /* pointer to screen bitmap */
+ int xsize, ysize; /* in pixels */
+ int dpix, dpiy; /* dots per inch */
+ int width; /* pixel width of frame buffer */
+ int bpp; /* bits per pixel of root */
+{
+ return cfbScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width);
+}
+#endif /* SUNMAXDEPTH */
+
+#ifdef DPMSExtension
+/**************************************************************
+ * DPMSSet(), DPMSGet(), DPMSSupported()
+ *
+ * stubs
+ *
+ ***************************************************************/
+
+void DPMSSet (level)
+ int level;
+{
+}
+
+int DPMSGet (level)
+ int* level;
+{
+ return -1;
+}
+
+Bool DPMSSupported ()
+{
+ return FALSE;
+}
+#endif
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c
new file mode 100644
index 000000000..7b1d68519
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyIo.c
@@ -0,0 +1,389 @@
+/* $Xorg: sunLyIo.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*-
+ * This is sunIo.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyIo.c,v 3.5 2001/05/25 18:40:59 dawes Exp $ */
+
+ /*
+ *
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#define NEED_EVENTS
+#include "sun.h"
+#include <stat.h>
+
+/*-
+ *-----------------------------------------------------------------------
+ * ProcessInputEvents --
+ * Retrieve all waiting input events and pass them to DIX in their
+ * correct chronological order. Only reads from the system pointer
+ * and keyboard.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Events are passed to the DIX layer.
+ *
+ *-----------------------------------------------------------------------
+ */
+void
+ProcessInputEvents ()
+{
+ mieqProcessInputEvents ();
+ miPointerUpdate ();
+}
+
+/*
+ *-----------------------------------------------------------------------
+ * sunEnqueueEvents
+ * When a SIGIO is received, read device hard events and
+ * enqueue them using the mi event queue
+ */
+
+void sunEnqueueEvents (
+ void
+)
+{
+ Firm_event *ptrEvents, /* Current pointer event */
+ *kbdEvents; /* Current keyboard event */
+ int numPtrEvents, /* Number of remaining pointer events */
+ numKbdEvents; /* Number of remaining keyboard events */
+ int nPE, /* Original number of pointer events */
+ nKE; /* Original number of keyboard events */
+ Bool PtrAgain, /* need to (re)read */
+ KbdAgain; /* need to (re)read */
+ DeviceIntPtr pPointer;
+ DeviceIntPtr pKeyboard;
+ sunKbdPrivPtr kbdPriv;
+ sunPtrPrivPtr ptrPriv;
+
+ pPointer = (DeviceIntPtr)LookupPointerDevice();
+ pKeyboard = (DeviceIntPtr)LookupKeyboardDevice();
+ ptrPriv = (sunPtrPrivPtr) pPointer->public.devicePrivate;
+ kbdPriv = (sunKbdPrivPtr) pKeyboard->public.devicePrivate;
+ if (!pPointer->public.on || !pKeyboard->public.on)
+ return;
+
+ numPtrEvents = 0;
+ PtrAgain = TRUE;
+ numKbdEvents = 0;
+ KbdAgain = TRUE;
+
+ /*
+ * So long as one event from either device remains unprocess, we loop:
+ * Take the oldest remaining event and pass it to the proper module
+ * for processing. The DDXEvent will be sent to ProcessInput by the
+ * function called.
+ */
+ while (1) {
+ /*
+ * Get events from both the pointer and the keyboard, storing the number
+ * of events gotten in nPE and nKE and keeping the start of both arrays
+ * in pE and kE
+ */
+ if ((numPtrEvents == 0) && PtrAgain) {
+ ptrEvents = sunMouseGetEvents (ptrPriv->fd, pPointer->public.on,
+ &nPE, &PtrAgain);
+ numPtrEvents = nPE;
+ }
+ if ((numKbdEvents == 0) && KbdAgain) {
+ kbdEvents = sunKbdGetEvents (kbdPriv->fd, pKeyboard->public.on,
+ &nKE, &KbdAgain);
+ numKbdEvents = nKE;
+ }
+ if ((numPtrEvents == 0) && (numKbdEvents == 0))
+ break;
+ if (numPtrEvents && numKbdEvents) {
+ if (timercmp (&kbdEvents->time, &ptrEvents->time, <)) {
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ } else if (numKbdEvents) {
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ }
+}
+
+void sunEnqueueKbdEvents (
+ void
+)
+{
+ Firm_event *kbdEvents; /* Current keyboard event */
+ int numKbdEvents; /* Number of remaining keyboard events */
+ int nKE; /* Original number of keyboard events */
+ Bool KbdAgain; /* need to (re)read */
+ DeviceIntPtr pKeyboard;
+ sunKbdPrivPtr kbdPriv;
+
+ pKeyboard = (DeviceIntPtr)LookupKeyboardDevice();
+ kbdPriv = (sunKbdPrivPtr) pKeyboard->public.devicePrivate;
+ if (!pKeyboard->public.on)
+ return;
+
+ numKbdEvents = 0;
+ KbdAgain = TRUE;
+
+ /*
+ * So long as one event from the device remains unprocess, we loop:
+ * Take the oldest remaining event and pass it to the proper module
+ * for processing. The DDXEvent will be sent to ProcessInput by the
+ * function called.
+ */
+ while (1) {
+ /*
+ * Get events from both the keyboard, storing the number
+ * of events gotten in nKE and keeping the start of the array
+ * in kE
+ */
+ if ((numKbdEvents == 0) && KbdAgain) {
+ kbdEvents = sunKbdGetEvents (kbdPriv->fd, pKeyboard->public.on,
+ &nKE, &KbdAgain);
+ numKbdEvents = nKE;
+ }
+ if (numKbdEvents == 0)
+ break;
+ sunKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ }
+}
+
+void sunEnqueueMseEvents (
+ void
+)
+{
+ Firm_event *ptrEvents; /* Current pointer event */
+ int numPtrEvents; /* Number of remaining pointer events */
+ int nPE; /* Original number of pointer events */
+ Bool PtrAgain; /* need to (re)read */
+ DeviceIntPtr pPointer;
+ sunPtrPrivPtr ptrPriv;
+
+ pPointer = (DeviceIntPtr)LookupPointerDevice();
+ ptrPriv = (sunPtrPrivPtr) pPointer->public.devicePrivate;
+ if (!pPointer->public.on)
+ return;
+
+ numPtrEvents = 0;
+ PtrAgain = TRUE;
+
+ /*
+ * So long as one events from the device remain unprocess, we loop:
+ * Take the oldest remaining event and pass it to the proper module
+ * for processing. The DDXEvent will be sent to ProcessInput by the
+ * function called.
+ */
+ while (1) {
+ /*
+ * Get events from the pointer, storing the number
+ * of events gotten in nPE and keeping the start of the arrays
+ * in pE
+ */
+ if ((numPtrEvents == 0) && PtrAgain) {
+ ptrEvents = sunMouseGetEvents (ptrPriv->fd, pPointer->public.on,
+ &nPE, &PtrAgain);
+ numPtrEvents = nPE;
+ }
+ if (numPtrEvents == 0)
+ break;
+
+ sunMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+}
+
+/*
+ * DDX - specific abort routine. Called by AbortServer().
+ */
+void AbortDDX()
+{
+ int i;
+ ScreenPtr pScreen;
+ DevicePtr devPtr;
+
+ (void) OsSignal (SIGIO, SIG_IGN);
+ if (sunKbdPriv.fd != -1) {
+ if (devPtr = LookupKeyboardDevice())
+ (void) sunChangeKbdTranslation (((sunKbdPrivPtr)(devPtr->devicePrivate))->fd, FALSE);
+ }
+ sunNonBlockConsoleOff ();
+ for (i = 0; i < screenInfo.numScreens; i++)
+ {
+ pScreen = screenInfo.screens[i];
+ (*pScreen->SaveScreen) (pScreen, SCREEN_SAVER_OFF);
+ sunDisableCursor (pScreen);
+ }
+}
+
+/* Called by GiveUp(). */
+void
+ddxGiveUp()
+{
+ AbortDDX ();
+}
+
+/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
+void ddxInitGlobals(void)
+{
+}
+
+int
+ddxProcessArgument (argc, argv, i)
+ int argc;
+ char *argv[];
+ int i;
+{
+ extern void UseMsg();
+ extern Bool onConsole;
+ struct stat s0, scon;
+
+ if (fstat(0, &s0) != -1 && stat("/dev/con", &scon) != -1)
+ onConsole = !memcmp(&s0, &scon, sizeof(s0));
+
+#ifndef XKB
+ if (strcmp (argv[i], "-ar1") == 0) { /* -ar1 int */
+ if (++i >= argc) UseMsg ();
+ sunAutoRepeatInitiate = 1000 * (long)atoi(argv[i]);
+ if (sunAutoRepeatInitiate > 1000000)
+ sunAutoRepeatInitiate = 999000;
+ return 2;
+ }
+ if (strcmp (argv[i], "-ar2") == 0) { /* -ar2 int */
+ if (++i >= argc) UseMsg ();
+ sunAutoRepeatDelay = 1000 * (long)atoi(argv[i]);
+ if (sunAutoRepeatDelay > 1000000)
+ sunAutoRepeatDelay = 999000;
+ return 2;
+ }
+#endif
+ if (strcmp (argv[i], "-swapLkeys") == 0) { /* -swapLkeys */
+ sunSwapLkeys = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-debug") == 0) { /* -debug */
+ return 1;
+ }
+ if (strcmp (argv[i], "-dev") == 0) { /* -dev /dev/mumble */
+ if (++i >= argc) UseMsg ();
+ return 2;
+ }
+ if (strcmp (argv[i], "-mono") == 0) { /* -mono */
+ return 1;
+ }
+ if (strcmp (argv[i], "-zaphod") == 0) { /* -zaphod */
+ sunActiveZaphod = FALSE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-flipPixels") == 0) { /* -flipPixels */
+ sunFlipPixels = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-fbinfo") == 0) { /* -fbinfo */
+ sunFbInfo = TRUE;
+ return 1;
+ }
+ if (strcmp (argv[i], "-kbd") == 0) { /* -kbd */
+ if (++i >= argc) UseMsg();
+ return 2;
+ }
+ if (strcmp (argv[i], "-protect") == 0) { /* -protect */
+ if (++i >= argc) UseMsg();
+ return 2;
+ }
+ if (strcmp (argv[i], "-noGX") == 0) {
+ sunNoGX = TRUE;
+ return 1;
+ }
+ return 0;
+}
+
+void
+ddxUseMsg()
+{
+#ifndef XKB
+ ErrorF("-ar1 int set autorepeat initiate time\n");
+ ErrorF("-ar2 int set autorepeat interval time\n");
+#endif
+ ErrorF("-swapLkeys swap keysyms on L1..L10\n");
+ ErrorF("-debug disable non-blocking console mode\n");
+ ErrorF("-dev fn[:fn][:fn] name of device[s] to open\n");
+ ErrorF("-mono force monochrome-only screen\n");
+ ErrorF("-zaphod disable active Zaphod mode\n");
+ ErrorF("-fbinfo tell more about the found frame buffer(s)\n");
+#ifdef UNDOCUMENTED
+ ErrorF("-noGX treat the GX as a dumb frame buffer\n");
+#endif
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c
new file mode 100644
index 000000000..46fe7eb6c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyKbd.c
@@ -0,0 +1,1080 @@
+/* $Xorg: sunLyKbd.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*
+ * This is sunKbd.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyKbd.c,v 3.6 2001/08/01 00:44:49 tsi Exp $ */
+
+/*-
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#define NEED_EVENTS
+#include "sun.h"
+#include "keysym.h"
+#include "Sunkeysym.h"
+#include "osdep.h"
+
+#include <X11/Xpoll.h>
+
+#ifdef XKB
+#include <X11/extensions/XKB.h>
+#include <X11/extensions/XKBstr.h>
+#include <X11/extensions/XKBsrv.h>
+#endif
+
+#define SUN_LED_MASK 0x0f
+#define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */
+#define MAX_KEYCODE 255 /* limited by the protocol */
+#ifndef KB_SUN4
+#define KB_SUN4 4
+#endif
+
+#define AUTOREPEAT_INITIATE 400
+#define AUTOREPEAT_DELAY 50
+
+#define tvminus(tv, tv1, tv2) /* tv = tv1 - tv2 */ \
+ if ((tv1).tv_usec < (tv2).tv_usec) { \
+ (tv1).tv_usec += 1000000; \
+ (tv1).tv_sec -= 1; \
+ } \
+ (tv).tv_usec = (tv1).tv_usec - (tv2).tv_usec; \
+ (tv).tv_sec = (tv1).tv_sec - (tv2).tv_sec;
+
+#define tvplus(tv, tv1, tv2) /* tv = tv1 + tv2 */ \
+ (tv).tv_sec = (tv1).tv_sec + (tv2).tv_sec; \
+ (tv).tv_usec = (tv1).tv_usec + (tv2).tv_usec; \
+ if ((tv).tv_usec > 1000000) { \
+ (tv).tv_usec -= 1000000; \
+ (tv).tv_sec += 1; \
+ }
+
+extern KeySymsRec sunKeySyms[];
+extern SunModmapRec* sunModMaps[];
+
+long sunAutoRepeatInitiate = 1000 * AUTOREPEAT_INITIATE;
+long sunAutoRepeatDelay = 1000 * AUTOREPEAT_DELAY;
+
+static int autoRepeatKeyDown = 0;
+static int autoRepeatReady;
+static int autoRepeatFirst;
+static struct timeval autoRepeatLastKeyDownTv;
+static struct timeval autoRepeatDeltaTv;
+
+void sunKbdWait()
+{
+ static struct timeval lastChngKbdTransTv;
+ struct timeval tv;
+ struct timeval lastChngKbdDeltaTv;
+ unsigned int lastChngKbdDelta;
+
+ X_GETTIMEOFDAY(&tv);
+ if (!lastChngKbdTransTv.tv_sec)
+ lastChngKbdTransTv = tv;
+ tvminus(lastChngKbdDeltaTv, tv, lastChngKbdTransTv);
+ lastChngKbdDelta = TVTOMILLI(lastChngKbdDeltaTv);
+ if (lastChngKbdDelta < 750) {
+ unsigned wait;
+ /*
+ * We need to guarantee at least 750 milliseconds between
+ * calls to KIOCTRANS. YUCK!
+ */
+ wait = (750L - lastChngKbdDelta) * 1000L;
+ usleep (wait);
+ X_GETTIMEOFDAY(&tv);
+ }
+ lastChngKbdTransTv = tv;
+}
+
+static void SwapLKeys(keysyms)
+ KeySymsRec* keysyms;
+{
+ unsigned int i;
+ KeySym k;
+
+ for (i = 2; i < keysyms->maxKeyCode * keysyms->mapWidth; i++)
+ if (keysyms->map[i] == XK_L1 ||
+ keysyms->map[i] == XK_L2 ||
+ keysyms->map[i] == XK_L3 ||
+ keysyms->map[i] == XK_L4 ||
+ keysyms->map[i] == XK_L5 ||
+ keysyms->map[i] == XK_L6 ||
+ keysyms->map[i] == XK_L7 ||
+ keysyms->map[i] == XK_L8 ||
+ keysyms->map[i] == XK_L9 ||
+ keysyms->map[i] == XK_L10) {
+ /* yes, I could have done a clever two line swap! */
+ k = keysyms->map[i - 2];
+ keysyms->map[i - 2] = keysyms->map[i];
+ keysyms->map[i] = k;
+ }
+}
+
+static void SetLights (ctrl, fd)
+ KeybdCtrl* ctrl;
+ int fd;
+{
+#ifdef KIOCSLED
+ static unsigned char led_tab[16] = {
+ 0,
+ LED_NUM_LOCK,
+ LED_SCROLL_LOCK,
+ LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_COMPOSE,
+ LED_COMPOSE | LED_NUM_LOCK,
+ LED_COMPOSE | LED_SCROLL_LOCK,
+ LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK,
+ LED_CAPS_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_SCROLL_LOCK,
+ LED_CAPS_LOCK | LED_SCROLL_LOCK | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_NUM_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK,
+ LED_CAPS_LOCK | LED_COMPOSE | LED_SCROLL_LOCK | LED_NUM_LOCK
+ };
+ if (ioctl (fd, KIOCSLED, (caddr_t)&led_tab[ctrl->leds & 0x0f]) == -1)
+#if defined(PATCHED_CONSOLE)
+ Error("Failed to set keyboard lights");
+#else
+ ; /* silly driver bug always returns error */
+#endif
+#endif
+}
+
+
+static void ModLight (device, on, led)
+ DeviceIntPtr device;
+ Bool on;
+ int led;
+{
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if(on) {
+ ctrl->leds |= led;
+ pPriv->leds |= led;
+ } else {
+ ctrl->leds &= ~led;
+ pPriv->leds &= ~led;
+ }
+ SetLights (ctrl, pPriv->fd);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunBell --
+ * Ring the terminal/keyboard bell
+ *
+ * Results:
+ * Ring the keyboard bell for an amount of time proportional to
+ * "loudness."
+ *
+ * Side Effects:
+ * None, really...
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void bell (
+ int fd,
+ int duration)
+{
+#if defined(PATCHED_CONSOLE)
+ int kbdCmd; /* Command to give keyboard */
+
+ kbdCmd = KBD_CMD_BELL;
+ if (ioctl (fd, KIOCCMD, &kbdCmd) == -1) {
+ Error("Failed to activate bell");
+ return;
+ }
+ if (duration) usleep (duration);
+ kbdCmd = KBD_CMD_NOBELL;
+ if (ioctl (fd, KIOCCMD, &kbdCmd) == -1)
+ Error ("Failed to deactivate bell");
+#endif
+}
+
+static void sunBell (
+ int percent,
+ DeviceIntPtr device,
+ pointer ctrl,
+ int unused)
+{
+ KeybdCtrl* kctrl = (KeybdCtrl*) ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (percent == 0 || kctrl->bell == 0)
+ return;
+
+ bell (pPriv->fd, kctrl->bell_duration * 1000);
+}
+
+static void sunEnqueueEvent (xE)
+ xEvent* xE;
+{
+ sigset_t holdmask;
+
+ (void) sigaddset (&holdmask, SIGIO);
+ (void) sigprocmask (SIG_BLOCK, &holdmask, (sigset_t*)NULL);
+ mieqEnqueue (xE);
+ (void) sigprocmask (SIG_UNBLOCK, &holdmask, (sigset_t*)NULL);
+}
+
+
+#define XLED_NUM_LOCK 0x1
+#define XLED_COMPOSE 0x4
+#define XLED_SCROLL_LOCK 0x2
+#define XLED_CAPS_LOCK 0x8
+
+static KeyCode LookupKeyCode (keysym, keysymsrec)
+ KeySym keysym;
+ KeySymsPtr keysymsrec;
+{
+ KeyCode i;
+ int ii, index = 0;
+
+ for (i = keysymsrec->minKeyCode; i < keysymsrec->maxKeyCode; i++)
+ for (ii = 0; ii < keysymsrec->mapWidth; ii++)
+ if (keysymsrec->map[index++] == keysym)
+ return i;
+}
+
+static void pseudoKey(device, down, keycode)
+ DeviceIntPtr device;
+ Bool down;
+ KeyCode keycode;
+{
+ int bit;
+ CARD8 modifiers;
+ CARD16 mask;
+ BYTE* kptr;
+
+ kptr = &device->key->down[keycode >> 3];
+ bit = 1 << (keycode & 7);
+ modifiers = device->key->modifierMap[keycode];
+ if (down) {
+ /* fool dix into thinking this key is now "down" */
+ int i;
+ *kptr |= bit;
+ device->key->prev_state = device->key->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ if (mask & modifiers) {
+ device->key->modifierKeyCount[i]++;
+ device->key->state += mask;
+ modifiers &= ~mask;
+ }
+ } else {
+ /* fool dix into thinking this key is now "up" */
+ if (*kptr & bit) {
+ int i;
+ *kptr &= ~bit;
+ device->key->prev_state = device->key->state;
+ for (i = 0, mask = 1; modifiers; i++, mask <<= 1)
+ if (mask & modifiers) {
+ if (--device->key->modifierKeyCount[i] <= 0) {
+ device->key->state &= ~mask;
+ device->key->modifierKeyCount[i] = 0;
+ }
+ modifiers &= ~mask;
+ }
+ }
+ }
+}
+
+static void DoLEDs(device, ctrl, pPriv)
+ DeviceIntPtr device; /* Keyboard to alter */
+ KeybdCtrl* ctrl;
+ sunKbdPrivPtr pPriv;
+{
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if ((ctrl->leds & XLED_CAPS_LOCK) && !(pPriv->leds & XLED_CAPS_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Caps_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_CAPS_LOCK) && (pPriv->leds & XLED_CAPS_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Caps_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_NUM_LOCK) && !(pPriv->leds & XLED_NUM_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Num_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_NUM_LOCK) && (pPriv->leds & XLED_NUM_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Num_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_SCROLL_LOCK) && !(pPriv->leds & XLED_SCROLL_LOCK))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(XK_Scroll_Lock, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_SCROLL_LOCK) && (pPriv->leds & XLED_SCROLL_LOCK))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(XK_Scroll_Lock, &device->key->curKeySyms));
+
+ if ((ctrl->leds & XLED_COMPOSE) && !(pPriv->leds & XLED_COMPOSE))
+ pseudoKey(device, TRUE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+
+ if (!(ctrl->leds & XLED_COMPOSE) && (pPriv->leds & XLED_COMPOSE))
+ pseudoKey(device, FALSE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+#ifdef XKB
+ }
+#endif
+ pPriv->leds = ctrl->leds & 0x0f;
+ SetLights (ctrl, pPriv->fd);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdCtrl --
+ * Alter some of the keyboard control parameters
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Some...
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void sunKbdCtrl (
+ DeviceIntPtr device,
+ KeybdCtrl* ctrl)
+{
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (pPriv->fd < 0) return;
+
+ if (ctrl->click != pPriv->click) {
+ int kbdClickCmd;
+
+ pPriv->click = ctrl->click;
+#if defined(PATCHED_CONSOLE)
+ kbdClickCmd = pPriv->click ? KBD_CMD_CLICK : KBD_CMD_NOCLICK;
+ if (ioctl (pPriv->fd, KIOCCMD, &kbdClickCmd) == -1)
+ Error("Failed to set keyclick");
+#endif
+ }
+ if (pPriv->type == KB_SUN4 && pPriv->leds != ctrl->leds & 0x0f)
+ DoLEDs(device, ctrl, pPriv);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunInitKbdNames --
+ * Handle the XKB initialization
+ *
+ * Results:
+ * None.
+ *
+ * Comments:
+ * This function needs considerable work, in conjunctions with
+ * the need to add geometry descriptions of Sun Keyboards.
+ * It would also be nice to have #defines for all the keyboard
+ * layouts so that we don't have to have these hard-coded
+ * numbers.
+ *
+ *-----------------------------------------------------------------------
+ */
+#ifdef XKB
+static void sunInitKbdNames (
+ XkbComponentNamesRec* names,
+ sunKbdPrivPtr pKbd)
+{
+#ifndef XKBBUFSIZE
+#define XKBBUFSIZE 64
+#endif
+ static char keycodesbuf[XKBBUFSIZE];
+ static char geometrybuf[XKBBUFSIZE];
+ static char symbolsbuf[XKBBUFSIZE];
+
+ names->keymap = NULL;
+ names->compat = "compat/complete";
+ names->types = "types/complete";
+ names->keycodes = keycodesbuf;
+ names->geometry = geometrybuf;
+ names->symbols = symbolsbuf;
+ (void) strcpy (keycodesbuf, "keycodes/");
+ (void) strcpy (geometrybuf, "geometry/");
+ (void) strcpy (symbolsbuf, "symbols/");
+
+ /* keycodes & geometry */
+ switch (pKbd->type) {
+ case KB_SUN2:
+ (void) strcat (names->keycodes, "sun(type2)");
+ (void) strcat (names->geometry, "sun(type2)");
+ (void) strcat (names->symbols, "us(sun2)");
+ break;
+ case KB_SUN3:
+ (void) strcat (names->keycodes, "sun(type3)");
+ (void) strcat (names->geometry, "sun(type3)");
+ (void) strcat (names->symbols, "us(sun3)");
+ break;
+ case KB_SUN4:
+ if (pKbd->layout == 19) {
+ (void) strcat (names->keycodes, "sun(US101A)");
+ (void) strcat (names->geometry, "pc101-NG"); /* XXX */
+ (void) strcat (names->symbols, "us(pc101)");
+ } else if (pKbd->layout < 33) {
+ (void) strcat (names->keycodes, "sun(type4)");
+ (void) strcat (names->geometry, "sun(type4)");
+ if (sunSwapLkeys)
+ (void) strcat (names->symbols, "sun/us(sun4ol)");
+ else
+ (void) strcat (names->symbols, "sun/us(sun4)");
+ } else {
+ (void) strcat (names->keycodes, "sun(type5)");
+ if (pKbd->layout == 34 || pKbd->layout == 81)
+ (void) strcat (names->geometry, "sun(type5unix)");
+ else
+ (void) strcat (names->geometry, "sun(type5)");
+ if (sunSwapLkeys)
+ (void) strcat (names->symbols, "sun/us(sun5ol)");
+ else
+ (void) strcat (names->symbols, "sun/us(sun5)");
+ }
+ break;
+ default:
+ names->keycodes = names->geometry = NULL;
+ break;
+ }
+
+ /* extra symbols */
+ if (pKbd->type == KB_SUN4) {
+ switch (pKbd->layout) {
+ case 0: case 1: case 33: case 34: case 80: case 81:
+ break;
+ case 3:
+ (void) strcat (names->symbols, "+ca"); break;
+ case 4: case 36: case 83:
+ (void) strcat (names->symbols, "+dk"); break;
+ case 5: case 37: case 84:
+ (void) strcat (names->symbols, "+de"); break;
+ case 6: case 38: case 85:
+ (void) strcat (names->symbols, "+it"); break;
+ case 8: case 40: case 87:
+ (void) strcat (names->symbols, "+no"); break;
+ case 9: case 41: case 88:
+ (void) strcat (names->symbols, "+pt"); break;
+ case 10: case 42: case 89:
+ (void) strcat (names->symbols, "+es"); break;
+ case 11: case 43: case 90:
+ (void) strcat (names->symbols, "+se"); break;
+ case 12: case 44: case 91:
+ (void) strcat (names->symbols, "+fr_CH"); break;
+ case 13: case 45: case 92:
+ (void) strcat (names->symbols, "+de_CH"); break;
+ case 14: case 46: case 93:
+ (void) strcat (names->symbols, "+gb"); break; /* s/b en_UK */
+ case 52:
+ (void) strcat (names->symbols, "+pl"); break;
+ case 53:
+ (void) strcat (names->symbols, "+cs"); break;
+ case 54:
+ (void) strcat (names->symbols, "+ru"); break;
+#if 0
+ /* don't have symbols defined for these yet, let them default */
+ case 2:
+ (void) strcat (names->symbols, "+fr_BE"); break;
+ case 7: case 39: case 86:
+ (void) strcat (names->symbols, "+nl"); break;
+ case 50: case 97:
+ (void) strcat (names->symbols, "+fr_CA"); break;
+ case 16: case 47: case 94:
+ (void) strcat (names->symbols, "+ko"); break;
+ case 17: case 48: case 95:
+ (void) strcat (names->symbols, "+tw"); break;
+ case 32: case 49: case 96:
+ (void) strcat (names->symbols, "+jp"); break;
+ case 51:
+ (void) strcat (names->symbols, "+hu"); break;
+#endif
+ /*
+ * by setting the symbols to NULL XKB will use the symbols in
+ * the "default" keymap.
+ */
+ default:
+ names->symbols = NULL; return; break;
+ }
+ }
+}
+#endif /* XKB */
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdProc --
+ * Handle the initialization, etc. of a keyboard.
+ *
+ * Results:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+int sunKbdProc (
+ DeviceIntPtr device,
+ int what)
+{
+ static int once;
+ static struct termio kbdtty;
+ struct termio tty;
+ int i;
+ DevicePtr pKeyboard = (DevicePtr) device;
+ sunKbdPrivPtr pPriv;
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ extern int XkbDfltRepeatDelay, XkbDfltRepeatInterval;
+
+ static CARD8 *workingModMap = NULL;
+ static KeySymsRec *workingKeySyms;
+
+ switch (what) {
+ case DEVICE_INIT:
+ if (pKeyboard != LookupKeyboardDevice()) {
+ ErrorF ("Cannot open non-system keyboard\n");
+ return (!Success);
+ }
+
+ if (!workingKeySyms) {
+ workingKeySyms = &sunKeySyms[sunKbdPriv.type];
+
+ if (sunKbdPriv.type == KB_SUN4 && sunSwapLkeys)
+ SwapLKeys(workingKeySyms);
+
+ if (workingKeySyms->minKeyCode < MIN_KEYCODE) {
+ workingKeySyms->minKeyCode += MIN_KEYCODE;
+ workingKeySyms->maxKeyCode += MIN_KEYCODE;
+ }
+ if (workingKeySyms->maxKeyCode > MAX_KEYCODE)
+ workingKeySyms->maxKeyCode = MAX_KEYCODE;
+ }
+
+ if (!workingModMap) {
+ workingModMap=(CARD8 *)xalloc(MAP_LENGTH);
+ (void) memset(workingModMap, 0, MAP_LENGTH);
+ for(i=0; sunModMaps[sunKbdPriv.type][i].key != 0; i++)
+ workingModMap[sunModMaps[sunKbdPriv.type][i].key + MIN_KEYCODE] =
+ sunModMaps[sunKbdPriv.type][i].modifiers;
+ }
+
+ (void) memset ((void *) defaultKeyboardControl.autoRepeats,
+ ~0, sizeof defaultKeyboardControl.autoRepeats);
+
+#ifdef XKB
+ if (noXkbExtension) {
+ sunAutoRepeatInitiate = XkbDfltRepeatDelay * 1000;
+ sunAutoRepeatDelay = XkbDfltRepeatInterval * 1000;
+#endif
+ autoRepeatKeyDown = 0;
+#ifdef XKB
+ }
+#endif
+ pKeyboard->devicePrivate = (pointer)&sunKbdPriv;
+ pKeyboard->on = FALSE;
+
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ InitKeyboardDeviceStruct(pKeyboard,
+ workingKeySyms, workingModMap,
+ sunBell, sunKbdCtrl);
+#ifdef XKB
+ } else {
+ XkbComponentNamesRec names;
+ sunInitKbdNames (&names, &sunKbdPriv);
+ XkbInitKeyboardDeviceStruct((DeviceIntPtr) pKeyboard, &names,
+ workingKeySyms, workingModMap,
+ sunBell, sunKbdCtrl);
+ }
+#endif
+ break;
+
+ case DEVICE_ON:
+ pPriv = (sunKbdPrivPtr)pKeyboard->devicePrivate;
+ /*
+ * Set the keyboard into "direct" mode and turn on
+ * event translation.
+ */
+ if (sunChangeKbdTranslation(pPriv->fd, TRUE) == -1)
+ FatalError("Can't set keyboard translation\n");
+ /*
+ * for LynxOS, save current termio setting and
+ * set the keyboard into raw mode
+ */
+ if (!once)
+ {
+ ioctl(pPriv->fd, TCGETA, &kbdtty);
+ once = 1;
+ }
+ tty = kbdtty;
+ tty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ tty.c_oflag = 0;
+ tty.c_cflag = CREAD | CS8;
+ tty.c_lflag = 0;
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 0;
+ if (ioctl(pPriv->fd, TCSETAW, &tty) < 0)
+ perror("ioctl TCSETAW");
+ AddEnabledDevice(pPriv->fd);
+ pKeyboard->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ pPriv = (sunKbdPrivPtr)pKeyboard->devicePrivate;
+ if (pPriv->type == KB_SUN4) {
+ /* dumb bug in Sun's keyboard! Turn off LEDS before resetting */
+ pPriv->leds = 0;
+ ctrl->leds = 0;
+ SetLights(ctrl, pPriv->fd);
+ }
+ /*
+ * Restore original keyboard directness and translation.
+ */
+ if (sunChangeKbdTranslation(pPriv->fd,FALSE) == -1)
+ FatalError("Can't reset keyboard translation\n");
+ /* restore saved termio setting */
+ if (ioctl(pPriv->fd, TCSETAW, &kbdtty) < 0)
+ perror("ioctl TCSETAW");
+ pKeyboard->on = FALSE;
+ RemoveEnabledDevice(pPriv->fd);
+ break;
+ default:
+ FatalError("Unknown keyboard operation\n");
+ }
+ return Success;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdGetEvents --
+ * Return the events waiting in the wings for the given keyboard.
+ *
+ * Results:
+ * A pointer to an array of Firm_events or (Firm_event *)0 if no events
+ * The number of events contained in the array.
+ * A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+
+Firm_event* sunKbdGetEvents (
+ int fd,
+ Bool on,
+ int* pNumEvents,
+ Bool* pAgain)
+{
+ int nBytes; /* number of bytes of events available. */
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+
+ char buf[64];
+
+ if ((nBytes = read(fd, buf, sizeof(buf))) == -1) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR)
+ {
+ *pNumEvents = 0;
+ if (errno == EINTR)
+ *pAgain = TRUE;
+ else
+ *pAgain = FALSE;
+ } else {
+ Error ("Reading keyboard");
+ FatalError ("Could not read the keyboard");
+ }
+ } else {
+ int i;
+ struct timeval now;
+
+ if (on) {
+ X_GETTIMEOFDAY(&now);
+ *pNumEvents = nBytes;
+ *pAgain = (nBytes == sizeof(buf)); /* very unlikely... */
+ for (i = 0; i < nBytes; i++)
+ {
+ evBuf[i].id = buf[i] & 0x7f;
+ evBuf[i].value = (buf[i] & 0x80) ? VKEY_UP : VKEY_DOWN;
+ evBuf[i].time = now;
+ }
+ } else {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ }
+ }
+ return evBuf;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunKbdEnqueueEvent --
+ *
+ *-----------------------------------------------------------------------
+ */
+static xEvent autoRepeatEvent;
+static int composeCount;
+
+static Bool DoSpecialKeys(device, xE, fe)
+ DeviceIntPtr device;
+ xEvent* xE;
+ Firm_event* fe;
+{
+ int shift_index, map_index, bit;
+ KeySym ksym;
+ BYTE* kptr;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr)device->public.devicePrivate;
+ BYTE keycode = xE->u.u.detail;
+ CARD8 keyModifiers = device->key->modifierMap[keycode];
+
+ /* look up the present idea of the keysym */
+ shift_index = 0;
+ if (device->key->state & ShiftMask)
+ shift_index ^= 1;
+ if (device->key->state & LockMask)
+ shift_index ^= 1;
+ map_index = (fe->id - 1) * device->key->curKeySyms.mapWidth;
+ ksym = device->key->curKeySyms.map[shift_index + map_index];
+ if (ksym == NoSymbol)
+ ksym = device->key->curKeySyms.map[map_index];
+
+ /*
+ * Toggle functionality is hardcoded. This is achieved by always
+ * discarding KeyReleases on these keys, and converting every other
+ * KeyPress into a KeyRelease.
+ */
+ if (xE->u.u.type == KeyRelease
+ && (ksym == XK_Num_Lock
+ || ksym == XK_Scroll_Lock
+ || ksym == SunXK_Compose
+ || (keyModifiers & LockMask)))
+ return TRUE;
+
+ kptr = &device->key->down[keycode >> 3];
+ bit = 1 << (keycode & 7);
+ if ((*kptr & bit) &&
+ (ksym == XK_Num_Lock || ksym == XK_Scroll_Lock ||
+ ksym == SunXK_Compose || (keyModifiers & LockMask)))
+ xE->u.u.type = KeyRelease;
+
+ if (pPriv->type == KB_SUN4) {
+ if (ksym == XK_Num_Lock) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_NUM_LOCK);
+ } else if (ksym == XK_Scroll_Lock) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_SCROLL_LOCK);
+ } else if (ksym == SunXK_Compose) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_COMPOSE);
+ if (xE->u.u.type == KeyPress) composeCount = 2;
+ else composeCount = 0;
+ } else if (keyModifiers & LockMask) {
+ ModLight (device, xE->u.u.type == KeyPress, XLED_CAPS_LOCK);
+ }
+ if (xE->u.u.type == KeyRelease) {
+ if (composeCount > 0 && --composeCount == 0) {
+ pseudoKey(device, FALSE,
+ LookupKeyCode(SunXK_Compose, &device->key->curKeySyms));
+ ModLight (device, FALSE, XLED_COMPOSE);
+ }
+ }
+ }
+
+ if ((xE->u.u.type == KeyPress) && (keyModifiers == 0)) {
+ /* initialize new AutoRepeater event & mark AutoRepeater on */
+ autoRepeatEvent = *xE;
+ autoRepeatFirst = TRUE;
+ autoRepeatKeyDown++;
+ autoRepeatLastKeyDownTv = fe->time;
+ }
+ return FALSE;
+}
+
+void sunKbdEnqueueEvent (
+ DeviceIntPtr device,
+ Firm_event *fe)
+{
+ xEvent xE;
+ BYTE keycode;
+ CARD8 keyModifiers;
+
+ keycode = (fe->id & 0x7f) + MIN_KEYCODE;
+
+ keyModifiers = device->key->modifierMap[keycode];
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if (autoRepeatKeyDown && (keyModifiers == 0) &&
+ ((fe->value == VKEY_DOWN) || (keycode == autoRepeatEvent.u.u.detail))) {
+ /*
+ * Kill AutoRepeater on any real non-modifier key down, or auto key up
+ */
+ autoRepeatKeyDown = 0;
+ }
+#ifdef XKB
+ }
+#endif
+ xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
+ xE.u.u.type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
+ xE.u.u.detail = keycode;
+#ifdef XKB
+ if (noXkbExtension) {
+#endif
+ if (DoSpecialKeys(device, &xE, fe))
+ return;
+#ifdef XKB
+ }
+#endif /* ! XKB */
+ mieqEnqueue (&xE);
+}
+
+void sunEnqueueAutoRepeat ()
+{
+ int delta;
+ int i, mask;
+ DeviceIntPtr device = (DeviceIntPtr)LookupKeyboardDevice();
+ KeybdCtrl* ctrl = &device->kbdfeed->ctrl;
+ sunKbdPrivPtr pPriv = (sunKbdPrivPtr) device->public.devicePrivate;
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn) {
+ autoRepeatKeyDown = 0;
+ return;
+ }
+ i=(autoRepeatEvent.u.u.detail >> 3);
+ mask=(1 << (autoRepeatEvent.u.u.detail & 7));
+ if (!(ctrl->autoRepeats[i] & mask)) {
+ autoRepeatKeyDown = 0;
+ return;
+ }
+
+ /*
+ * Generate auto repeat event. XXX one for now.
+ * Update time & pointer location of saved KeyPress event.
+ */
+
+ delta = TVTOMILLI(autoRepeatDeltaTv);
+ autoRepeatFirst = FALSE;
+
+ /*
+ * Fake a key up event and a key down event
+ * for the last key pressed.
+ */
+ autoRepeatEvent.u.keyButtonPointer.time += delta;
+ autoRepeatEvent.u.u.type = KeyRelease;
+
+ /*
+ * hold off any more inputs while we get these safely queued up
+ * further SIGIO are
+ */
+ sunEnqueueEvent (&autoRepeatEvent);
+ autoRepeatEvent.u.u.type = KeyPress;
+ sunEnqueueEvent (&autoRepeatEvent);
+ if (ctrl->click) bell (pPriv->fd, 0);
+
+ /* Update time of last key down */
+ tvplus(autoRepeatLastKeyDownTv, autoRepeatLastKeyDownTv,
+ autoRepeatDeltaTv);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunChangeKbdTranslation
+ * Makes operating system calls to set keyboard translation
+ * and direction on or off.
+ *
+ * Results:
+ * -1 if failure, else 0.
+ *
+ * Side Effects:
+ * Changes kernel management of keyboard.
+ *
+ *-----------------------------------------------------------------------
+ */
+int sunChangeKbdTranslation(
+ int fd,
+ Bool makeTranslated)
+{
+ int tmp;
+ sigset_t hold_mask, old_mask;
+ int toread;
+ char junk[8192];
+
+ (void) sigfillset(&hold_mask);
+ (void) sigprocmask(SIG_BLOCK, &hold_mask, &old_mask);
+ if (makeTranslated) {
+ if (ioctl (fd, TIO_ENSCANMODE, &tmp) == -1) {
+ Error ("Setting keyboard translation TIO_ENSCANMODE");
+ ErrorF ("sunChangeKbdTranslation: kbdFd=%d\n", fd);
+ return -1;
+ }
+ } else {
+ if (ioctl (fd, TIO_DISSCANMODE, &tmp) == -1) {
+ Error ("Setting keyboard translation TIO_DISSCANMODE");
+ ErrorF ("sunChangeKbdTranslation: kbdFd=%d\n", fd);
+ }
+ }
+ if (ioctl (fd, FIONREAD, &toread) != -1 && toread > 0) {
+ while (toread) {
+ tmp = toread;
+ if (toread > sizeof (junk))
+ tmp = sizeof (junk);
+ (void) read (fd, junk, tmp);
+ toread -= tmp;
+ }
+ }
+ (void) sigprocmask(SIG_SETMASK, &old_mask, (sigset_t *)NULL);
+ return 0;
+}
+
+/*ARGSUSED*/
+Bool LegalModifier(key, pDev)
+ unsigned int key;
+ DevicePtr pDev;
+{
+ return TRUE;
+}
+
+/*ARGSUSED*/
+void sunBlockHandler(nscreen, pbdata, pptv, pReadmask)
+ int nscreen;
+ pointer pbdata;
+ struct timeval **pptv;
+ pointer pReadmask;
+{
+ KeybdCtrl* ctrl = &((DeviceIntPtr)LookupKeyboardDevice())->kbdfeed->ctrl;
+ static struct timeval artv = { 0, 0 }; /* autorepeat timeval */
+
+ if (!autoRepeatKeyDown)
+ return;
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn)
+ return;
+
+ if (autoRepeatFirst == TRUE)
+ artv.tv_usec = sunAutoRepeatInitiate;
+ else
+ artv.tv_usec = sunAutoRepeatDelay;
+ *pptv = &artv;
+
+}
+
+/*ARGSUSED*/
+void sunWakeupHandler(nscreen, pbdata, err, pReadmask)
+ int nscreen;
+ pointer pbdata;
+ unsigned long err;
+ pointer pReadmask;
+{
+ KeybdCtrl* ctrl = &((DeviceIntPtr)LookupKeyboardDevice())->kbdfeed->ctrl;
+ struct timeval tv;
+
+ /* this works around a weird behaviour on LynxOS 2.4.0:
+ * usually we have no problems using true SIGIO driven mouse input
+ * as it is used on the other UN*X Suns. On LynxOS we have a
+ * strange behaviour upon the very first server startup after a
+ * reboot. We won't get SIGIOs from the mouse device. The mouse
+ * will only move if we get SIGIOs from the keyboard.
+ * The solution (for now) is to use an additional WakeupHandler and
+ * poll the mouse file descriptor.
+ */
+ struct fd_set devicesWithInput;
+ struct fd_set device;
+ extern struct fd_set EnabledDevices;
+
+ XFD_ANDSET(&devicesWithInput, ((struct fd_set *) pReadmask), &EnabledDevices);
+
+ FD_ZERO(&device);
+ FD_SET(sunPtrPriv.fd, &device);
+ XFD_ANDSET(&device, &device, &devicesWithInput);
+ if (XFD_ANYSET(&device)) {
+ sigset_t newsigmask;
+
+ (void) sigemptyset (&newsigmask);
+ (void) sigaddset (&newsigmask, SIGIO);
+ (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+ sunEnqueueMseEvents();
+ (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+ }
+
+#ifdef XKB
+ if (!noXkbExtension)
+ return;
+#endif
+
+ if (ctrl->autoRepeat != AutoRepeatModeOn)
+ return;
+
+ if (autoRepeatKeyDown) {
+ X_GETTIMEOFDAY(&tv);
+ tvminus(autoRepeatDeltaTv, tv, autoRepeatLastKeyDownTv);
+ if (autoRepeatDeltaTv.tv_sec > 0 ||
+ (!autoRepeatFirst && autoRepeatDeltaTv.tv_usec >
+ sunAutoRepeatDelay) ||
+ (autoRepeatDeltaTv.tv_usec >
+ sunAutoRepeatInitiate))
+ autoRepeatReady++;
+ }
+
+ if (autoRepeatReady)
+ {
+ sunEnqueueAutoRepeat ();
+ autoRepeatReady = 0;
+ }
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c
new file mode 100644
index 000000000..00df3db7c
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyMouse.c
@@ -0,0 +1,649 @@
+/* $Xorg: sunLyMouse.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*
+ * This is sunMouse.c modified for LynxOS
+ * Copyright 1996 by Thomas Mueller
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyMouse.c,v 3.3 2001/01/17 22:36:53 dawes Exp $ */
+
+/*-
+ * Copyright 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or The Open Group
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and The Open Group make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#define NEED_EVENTS
+#include "sun.h"
+
+Bool sunActiveZaphod = TRUE;
+
+static Bool sunCursorOffScreen();
+static void sunCrossScreen();
+static void sunWarpCursor();
+
+miPointerScreenFuncRec sunPointerScreenFuncs = {
+ sunCursorOffScreen,
+ sunCrossScreen,
+ sunWarpCursor,
+};
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseCtrl --
+ * Alter the control parameters for the mouse. Since acceleration
+ * etc. is done from the PtrCtrl record in the mouse's device record,
+ * there's nothing to do here.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+/*ARGSUSED*/
+static
+void sunMouseCtrl (
+ DeviceIntPtr device,
+ PtrCtrl* ctrl)
+{
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseProc --
+ * Handle the initialization, etc. of a mouse
+ *
+ * Results:
+ * none.
+ *
+ * Side Effects:
+ *
+ * Note:
+ * When using sunwindows, all input comes off a single fd, stored in the
+ * global windowFd. Therefore, only one device should be enabled and
+ * disabled, even though the application still sees both mouse and
+ * keyboard. We have arbitrarily chosen to enable and disable windowFd
+ * in the keyboard routine sunKbdProc rather than in sunMouseProc.
+ *
+ *-----------------------------------------------------------------------
+ */
+int sunMouseProc (
+ DeviceIntPtr device,
+ int what)
+{
+ struct termio tty;
+ DevicePtr pMouse = (DevicePtr) device;
+ int format;
+ static int oformat;
+ BYTE map[4];
+ char *dev;
+
+ switch (what) {
+ case DEVICE_INIT:
+ if (pMouse != LookupPointerDevice()) {
+ ErrorF ("Cannot open non-system mouse");
+ return !Success;
+ }
+ if (sunPtrPriv.fd == -1)
+ return !Success;
+ pMouse->devicePrivate = (pointer) &sunPtrPriv;
+ pMouse->on = FALSE;
+ map[1] = 1;
+ map[2] = 2;
+ map[3] = 3;
+ InitPointerDeviceStruct(
+ pMouse, map, 3, miPointerGetMotionEvents,
+ sunMouseCtrl, miPointerGetMotionBufferSize());
+ break;
+
+ case DEVICE_ON:
+ /* set mouse to raw mode */
+ if (ioctl(sunPtrPriv.fd, TCGETA, &tty) != -1) {
+ tty.c_iflag = (IGNPAR | IGNBRK) & (~PARMRK) & (~ISTRIP);
+ tty.c_oflag = 0;
+ tty.c_cflag = CREAD | CS8;
+ tty.c_lflag = 0;
+ tty.c_line = 0;
+ tty.c_cc[VTIME] = 0;
+ tty.c_cc[VMIN] = 0;
+ if (ioctl(sunPtrPriv.fd, TCSETAW, &tty) < 0)
+ perror("ioctl TCSETAW");
+ } else
+ perror("ioctl TCGETA");
+ sunPtrPriv.bmask = 0;
+ AddEnabledDevice (sunPtrPriv.fd);
+ pMouse->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ pMouse->on = FALSE;
+ break;
+
+ case DEVICE_OFF:
+ pMouse->on = FALSE;
+ RemoveEnabledDevice (sunPtrPriv.fd);
+ break;
+ }
+ return Success;
+}
+
+/* mouse protocol code from XFree86 */
+
+#define P_MS 0 /* Microsoft */
+#define P_MSC 1 /* Mouse Systems Corp */
+#define P_MM 2 /* MMseries */
+#define P_LOGI 3 /* Logitech */
+#define P_BM 4 /* BusMouse ??? */
+#define P_LOGIMAN 5 /* MouseMan / TrackMan
+ [CHRIS-211092] */
+#define P_PS2 6 /* PS/2 mouse */
+#define P_MMHIT 7 /* MM_HitTab */
+
+static int
+xf86MouseProtocol(rBuf, nBytes, evBuf)
+ unsigned char *rBuf;
+ int nBytes;
+ Firm_event evBuf[];
+{
+ int i, buttons, dx, dy;
+ static int pBufP = 0;
+ static unsigned char pBuf[8];
+ static int lastButtons;
+ int change;
+ int numEvents = 0;
+
+ const int mseType = P_MSC;
+ const int chordMiddle = 0;
+
+ static unsigned char proto[8][5] = {
+ /* hd_mask hd_id dp_mask dp_id nobytes */
+ { 0x40, 0x40, 0x40, 0x00, 3 }, /* MicroSoft */
+ { 0xf8, 0x80, 0x00, 0x00, 5 }, /* MouseSystems */
+ { 0xe0, 0x80, 0x80, 0x00, 3 }, /* MMSeries */
+ { 0xe0, 0x80, 0x80, 0x00, 3 }, /* Logitech */
+ { 0xf8, 0x80, 0x00, 0x00, 5 }, /* BusMouse */
+ { 0x40, 0x40, 0x40, 0x00, 3 }, /* MouseMan
+ [CHRIS-211092] */
+ { 0xc0, 0x00, 0x00, 0x00, 3 }, /* PS/2 mouse */
+ { 0xe0, 0x80, 0x80, 0x00, 3 }, /* MM_HitTablet */
+ };
+
+ for ( i=0; i < nBytes; i++) {
+ /*
+ * Hack for resyncing: We check here for a package that is:
+ * a) illegal (detected by wrong data-package header)
+ * b) invalid (0x80 == -128 and that might be wrong for MouseSystems)
+ * c) bad header-package
+ *
+ * NOTE: b) is a voilation of the MouseSystems-Protocol, since values of
+ * -128 are allowed, but since they are very seldom we can easily
+ * use them as package-header with no button pressed.
+ * NOTE/2: On a PS/2 mouse any byte is valid as a data byte. Furthermore,
+ * 0x80 is not valid as a header byte. For a PS/2 mouse we skip
+ * checking data bytes.
+ * For resyncing a PS/2 mouse we require the two most significant
+ * bits in the header byte to be 0. These are the overflow bits,
+ * and in case of an overflow we actually lose sync. Overflows
+ * are very rare, however, and we quickly gain sync again after
+ * an overflow condition. This is the best we can do. (Actually,
+ * we could use bit 0x08 in the header byte for resyncing, since
+ * that bit is supposed to be always on, but nobody told
+ * Microsoft...)
+ */
+ if (pBufP != 0 && mseType != P_PS2 &&
+ ((rBuf[i] & proto[mseType][2]) != proto[mseType][3]
+ || rBuf[i] == 0x80))
+ {
+ pBufP = 0; /* skip package */
+ }
+
+ if (pBufP == 0 &&
+ (rBuf[i] & proto[mseType][0]) != proto[mseType][1])
+ {
+ /*
+ * Hack for Logitech MouseMan Mouse - Middle button
+ *
+ * Unfortunately this mouse has variable length packets: the standard
+ * Microsoft 3 byte packet plus an optional 4th byte whenever the
+ * middle button status changes.
+ *
+ * We have already processed the standard packet with the movement
+ * and button info. Now post an event message with the old status
+ * of the left and right buttons and the updated middle button.
+ */
+
+ /*
+ * Even worse, different MouseMen and TrackMen differ in the 4th
+ * byte: some will send 0x00/0x20, others 0x01/0x21, or even
+ * 0x02/0x22, so I have to strip off the lower bits. [CHRIS-211092]
+ */
+ if ((mseType == P_MS || mseType == P_LOGIMAN)
+ && (char)(rBuf[i] & ~0x23) == 0)
+ {
+ buttons = ((int)(rBuf[i] & 0x20) >> 4)
+ | (lastButtons & 0x05);
+
+ change = buttons ^ lastButtons;
+ /* a little naive, but sufficient for now */
+ if (change & 4)
+ {
+ evBuf[numEvents].id = MS_LEFT;
+ evBuf[numEvents].value = (buttons & 4) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 2)
+ {
+ evBuf[numEvents].id = MS_MIDDLE;
+ evBuf[numEvents].value = (buttons & 2) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 1)
+ {
+ evBuf[numEvents].id = MS_RIGHT;
+ evBuf[numEvents].value = (buttons & 1) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ lastButtons = buttons;
+ }
+
+ continue; /* skip package */
+ }
+
+
+ pBuf[pBufP++] = rBuf[i];
+ if (pBufP != proto[mseType][4]) continue;
+
+
+ /*
+ * assembly full package
+ */
+ switch(mseType) {
+
+ case P_LOGIMAN: /* MouseMan / TrackMan [CHRIS-211092] */
+ case P_MS: /* Microsoft */
+ if (chordMiddle)
+ buttons = (((int) pBuf[0] & 0x30) == 0x30) ? 2 :
+ ((int)(pBuf[0] & 0x20) >> 3)
+ | ((int)(pBuf[0] & 0x10) >> 4);
+ else {
+ buttons = (lastButtons & 2)
+ | ((int)(pBuf[0] & 0x20) >> 3)
+ | ((int)(pBuf[0] & 0x10) >> 4);
+ }
+ dx = (char)((pBuf[0] & 0x03) << 6) | (pBuf[1] & 0x3F);
+ dy = (char)((pBuf[0] & 0x0C) << 4) | (pBuf[2] & 0x3F);
+ break;
+
+ case P_MSC: /* Mouse Systems Corp */
+ buttons = (~pBuf[0]) & 0x07;
+ dx = (char)(pBuf[1]) + (char)(pBuf[3]);
+ dy = - ((char)(pBuf[2]) + (char)(pBuf[4]));
+ break;
+
+
+ case P_MMHIT: /* MM_HitTablet */
+ buttons = pBuf[0] & 0x07;
+ if (buttons != 0)
+ buttons = 1 << (buttons - 1);
+ dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
+ dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
+ break;
+
+ case P_MM: /* MM Series */
+ case P_LOGI: /* Logitech Mice */
+ buttons = pBuf[0] & 0x07;
+ dx = (pBuf[0] & 0x10) ? pBuf[1] : - pBuf[1];
+ dy = (pBuf[0] & 0x08) ? - pBuf[2] : pBuf[2];
+ break;
+
+ case P_BM: /* BusMouse */
+ buttons = (~pBuf[0]) & 0x07;
+ dx = pBuf[1];
+ dy = - pBuf[2];
+ break;
+
+ case P_PS2: /* PS/2 mouse */
+ buttons = (pBuf[0] & 0x04) >> 1 | /* Middle */
+ (pBuf[0] & 0x02) >> 1 | /* Right */
+ (pBuf[0] & 0x01) << 2; /* Left */
+ dx = (pBuf[0] & 0x10) ? pBuf[1]-256 : pBuf[1];
+ dy = (pBuf[0] & 0x20) ? -(pBuf[2]-256) : -pBuf[2];
+ break;
+ }
+
+ /* a little naive, but sufficient for now */
+ change = buttons ^ lastButtons;
+ if (change & 4)
+ {
+ evBuf[numEvents].id = MS_LEFT;
+ evBuf[numEvents].value = (buttons & 4) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 2)
+ {
+ evBuf[numEvents].id = MS_MIDDLE;
+ evBuf[numEvents].value = (buttons & 2) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ if (change & 1)
+ {
+ evBuf[numEvents].id = MS_RIGHT;
+ evBuf[numEvents].value = (buttons & 1) ? VKEY_DOWN : VKEY_UP;
+ ++numEvents;
+ }
+ lastButtons = buttons;
+
+ if (dx)
+ {
+ evBuf[numEvents].id = LOC_X_DELTA;
+ evBuf[numEvents].value = dx;
+ ++numEvents;
+ }
+ if (dy)
+ {
+ evBuf[numEvents].id = LOC_Y_DELTA;
+ evBuf[numEvents].value = -dy;
+ ++numEvents;
+ }
+ pBufP = 0;
+ }
+ return numEvents;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseGetEvents --
+ * Return the events waiting in the wings for the given mouse.
+ *
+ * Results:
+ * A pointer to an array of Firm_events or (Firm_event *)0 if no events
+ * The number of events contained in the array.
+ * A boolean as to whether more events might be available.
+ *
+ * Side Effects:
+ * None.
+ *-----------------------------------------------------------------------
+ */
+
+Firm_event* sunMouseGetEvents (
+ int fd,
+ Bool on,
+ int* pNumEvents,
+ Bool* pAgain)
+{
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+ int nBytes; /* number of bytes available. */
+ char buf[8];
+
+ if ((nBytes = read(fd, buf, sizeof(buf))) == -1) {
+ if (errno == EWOULDBLOCK || errno == EAGAIN || errno == EINTR) {
+ *pNumEvents = 0;
+ if (errno == EINTR)
+ *pAgain = TRUE;
+ else
+ *pAgain = FALSE;
+ } else {
+ Error ("sunMouseGetEvents read");
+ FatalError ("Could not read from mouse");
+ }
+ } else {
+ if (on) {
+ *pAgain = (nBytes == sizeof(buf)); /* very unlikely... */
+ if (*pNumEvents = xf86MouseProtocol(buf, nBytes, evBuf))
+ {
+ struct timeval now;
+ int i;
+
+ X_GETTIMEOFDAY(&now);
+ for (i=0;i<*pNumEvents;i++)
+ evBuf[i].time = now;
+ }
+ } else {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ }
+ }
+ return evBuf;
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * MouseAccelerate --
+ * Given a delta and a mouse, return the acceleration of the delta.
+ *
+ * Results:
+ * The corrected delta
+ *
+ * Side Effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------
+ */
+static short
+MouseAccelerate (device, delta)
+ DeviceIntPtr device;
+ int delta;
+{
+ int sgn = sign(delta);
+ PtrCtrl *pCtrl;
+ short ret;
+
+ delta = abs(delta);
+ pCtrl = &device->ptrfeed->ctrl;
+ if (delta > pCtrl->threshold) {
+ ret =
+ (short) sgn *
+ (pCtrl->threshold + ((delta - pCtrl->threshold) * pCtrl->num) /
+ pCtrl->den);
+ } else {
+ ret = (short) sgn * delta;
+ }
+ return ret;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * sunMouseEnqueueEvent --
+ * Given a Firm_event for a mouse, pass it off the the dix layer
+ * properly converted...
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The cursor may be redrawn...? devPrivate/x/y will be altered.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+void sunMouseEnqueueEvent (
+ DeviceIntPtr device,
+ Firm_event *fe)
+{
+ xEvent xE;
+ sunPtrPrivPtr pPriv; /* Private data for pointer */
+ int bmask; /* Temporary button mask */
+ unsigned long time;
+ int x, y;
+
+ pPriv = (sunPtrPrivPtr)device->public.devicePrivate;
+
+ time = xE.u.keyButtonPointer.time = TVTOMILLI(fe->time);
+
+ switch (fe->id) {
+ case MS_LEFT:
+ case MS_MIDDLE:
+ case MS_RIGHT:
+ /*
+ * A button changed state. Sometimes we will get two events
+ * for a single state change. Should we get a button event which
+ * reflects the current state of affairs, that event is discarded.
+ *
+ * Mouse buttons start at 1.
+ */
+ xE.u.u.detail = (fe->id - MS_LEFT) + 1;
+ bmask = 1 << xE.u.u.detail;
+ if (fe->value == VKEY_UP) {
+ if (pPriv->bmask & bmask) {
+ xE.u.u.type = ButtonRelease;
+ pPriv->bmask &= ~bmask;
+ } else {
+ return;
+ }
+ } else {
+ if ((pPriv->bmask & bmask) == 0) {
+ xE.u.u.type = ButtonPress;
+ pPriv->bmask |= bmask;
+ } else {
+ return;
+ }
+ }
+ mieqEnqueue (&xE);
+ break;
+ case LOC_X_DELTA:
+ miPointerDeltaCursor (MouseAccelerate(device,fe->value),0,time);
+ break;
+ case LOC_Y_DELTA:
+ /*
+ * For some reason, motion up generates a positive y delta
+ * and motion down a negative delta, so we must subtract
+ * here instead of add...
+ */
+ miPointerDeltaCursor (0,-MouseAccelerate(device,fe->value),time);
+ break;
+ case LOC_X_ABSOLUTE:
+ miPointerPosition (&x, &y);
+ miPointerAbsoluteCursor (fe->value, y, time);
+ break;
+ case LOC_Y_ABSOLUTE:
+ miPointerPosition (&x, &y);
+ miPointerAbsoluteCursor (x, fe->value, time);
+ break;
+ default:
+ FatalError ("sunMouseEnqueueEvent: unrecognized id\n");
+ break;
+ }
+}
+
+/*ARGSUSED*/
+static Bool
+sunCursorOffScreen (pScreen, x, y)
+ ScreenPtr *pScreen;
+ int *x, *y;
+{
+ int index, ret = FALSE;
+ extern Bool PointerConfinedToScreen();
+
+ if (PointerConfinedToScreen()) return TRUE;
+ /*
+ * Active Zaphod implementation:
+ * increment or decrement the current screen
+ * if the x is to the right or the left of
+ * the current screen.
+ */
+ if (sunActiveZaphod &&
+ screenInfo.numScreens > 1 && (*x >= (*pScreen)->width || *x < 0)) {
+ index = (*pScreen)->myNum;
+ if (*x < 0) {
+ index = (index ? index : screenInfo.numScreens) - 1;
+ *pScreen = screenInfo.screens[index];
+ *x += (*pScreen)->width;
+ } else {
+ *x -= (*pScreen)->width;
+ index = (index + 1) % screenInfo.numScreens;
+ *pScreen = screenInfo.screens[index];
+ }
+ ret = TRUE;
+ }
+ return ret;
+}
+
+static void
+sunCrossScreen (pScreen, entering)
+ ScreenPtr pScreen;
+ Bool entering;
+{
+ if (sunFbs[pScreen->myNum].EnterLeave)
+ (*sunFbs[pScreen->myNum].EnterLeave) (pScreen, entering ? 0 : 1);
+}
+
+static void
+sunWarpCursor (pScreen, x, y)
+ ScreenPtr pScreen;
+ int x, y;
+{
+ sigset_t newsigmask;
+
+ (void) sigemptyset (&newsigmask);
+ (void) sigaddset (&newsigmask, SIGIO);
+ (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+ miPointerWarpCursor (pScreen, x, y);
+ (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c b/nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c
new file mode 100644
index 000000000..e260acfee
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/sunLyUtil.c
@@ -0,0 +1,509 @@
+/* $Xorg: sunLyUtil.c,v 1.3 2000/08/17 19:48:37 cpqbld Exp $ */
+/*
+ * CG3 and CG6 utility functions for LynxOS, derived from NetBSD
+ * Copyright 1996 by Thomas Mueller
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER BE LIABLE FOR ANY SPECIAL, INDIRECT OR
+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
+ * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/sunLyUtil.c,v 3.1 1996/12/27 06:51:42 dawes Exp $ */
+
+/* $NetBSD: bt_subr.c,v 1.4 1994/11/20 20:51:54 deraadt Exp $ */
+
+/*
+ * Copyright (c) 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)bt_subr.c 8.2 (Berkeley) 1/21/94
+ */
+
+/* adaption for LynxOS microSPARC 2.4.0 and X11R6[.1]
+ * Copyright 1996 by Thomas Mueller <tm@systrix.de>
+ *
+ * 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 Mueller not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. Thomas Mueller makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * THOMAS MUELLER DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL THOMAS MUELLER 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.
+ *
+ */
+
+#include "sun.h"
+#include "btreg.h"
+#include "btvar.h"
+#include "cgsixreg.h"
+#define useracc(a,b,c) (1)
+
+/*
+ * Common code for dealing with Brooktree video DACs.
+ * (Contains some software-only code as well, since the colormap
+ * ioctls are shared between the cgthree and cgsix drivers.)
+ */
+
+/*
+ * Implement an FBIOGETCMAP-like ioctl.
+ */
+int
+bt_getcmap(struct fbcmap *p, union bt_cmap *cm, int cmsize)
+{
+ u_int i;
+ u_int start;
+ u_int count;
+ u_char *cp;
+
+ start = p->index;
+ count = p->count;
+ if (start >= cmsize || start + count > cmsize)
+ return (EINVAL);
+ if (!useracc(p->red, count, B_WRITE) ||
+ !useracc(p->green, count, B_WRITE) ||
+ !useracc(p->blue, count, B_WRITE))
+ return (EFAULT);
+ for (cp = &cm->cm_map[start][0], i = 0; i < count; cp += 3, i++) {
+ p->red[i] = cp[0];
+ p->green[i] = cp[1];
+ p->blue[i] = cp[2];
+ }
+ return (0);
+}
+
+/*
+ * Implement the software portion of an FBIOPUTCMAP-like ioctl.
+ */
+int
+bt_putcmap(struct fbcmap *p, union bt_cmap *cm, int cmsize)
+{
+ u_int i;
+ int start;
+ int count;
+ u_char *cp;
+
+ start = p->index;
+ count = p->count;
+ if (start >= cmsize || start + count > cmsize)
+ return (EINVAL);
+ if (!useracc(p->red, count, B_READ) ||
+ !useracc(p->green, count, B_READ) ||
+ !useracc(p->blue, count, B_READ))
+ return (EFAULT);
+ for (cp = &cm->cm_map[start][0], i = 0; i < count; cp += 3, i++) {
+ cp[0] = p->red[i];
+ cp[1] = p->green[i];
+ cp[2] = p->blue[i];
+ }
+ return (0);
+}
+
+union cursor_cmap { /* colormap, like bt_cmap, but tiny */
+ u_char cm_map[2][3]; /* 2 R/G/B entries */
+ u_int cm_chip[2]; /* 2 chip equivalents */
+};
+
+struct cg6_cursor { /* cg6 hardware cursor status */
+ short cc_enable; /* cursor is enabled */
+ struct fbcurpos cc_pos; /* position */
+ struct fbcurpos cc_hot; /* hot-spot */
+ struct fbcurpos cc_size; /* size of mask & image fields */
+ u_int cc_bits[2][32]; /* space for mask & image bits */
+ union cursor_cmap cc_color; /* cursor colormap */
+};
+
+static union bt_cmap sc_cmap; /* local copy of LUT */
+static int blanked = 1; /* to jump-start it ... */
+static struct cg6_cursor sc_cursor; /* cursor info */
+
+/*
+ * Clean up hardware state (e.g., after bootup or after X crashes).
+ */
+static void
+cg6_reset(fbFd * fb)
+{
+ volatile struct cg6_tec_xxx *tec;
+ int fhc;
+ short fhcrev;
+ volatile struct bt_regs *bt;
+
+ /* hide the cursor, just in case */
+ ((volatile struct cg6_thc *) (fb->thc))->thc_cursxy =
+ (THC_CURSOFF << 16) | THC_CURSOFF;
+
+ /* turn off frobs in transform engine (makes X11 work) */
+ tec = fb->tec;
+ tec->tec_mv = 0;
+ tec->tec_clip = 0;
+ tec->tec_vdc = 0;
+
+ /* take care of hardware bugs in old revisions */
+ fhcrev = (*(int *) fb->fhc >> FHC_REV_SHIFT) &
+ (FHC_REV_MASK >> FHC_REV_SHIFT);
+ if (fhcrev < 5) {
+ /*
+ * Keep current resolution; set cpu to 68020, set test
+ * window (size 1Kx1K), and for rev 1, disable dest cache.
+ */
+ fhc = (*(int *) fb->fhc & FHC_RES_MASK) | FHC_CPU_68020 |
+ FHC_TEST |
+ (11 << FHC_TESTX_SHIFT) | (11 << FHC_TESTY_SHIFT);
+ if (fhcrev < 2)
+ fhc |= FHC_DST_DISABLE;
+ *(int *) fb->fhc = fhc;
+ }
+ /* Enable cursor in Brooktree DAC. */
+ bt = fb->ramdac;
+ bt->bt_addr = 0x06 << 24;
+ bt->bt_ctrl |= 0x03 << 24;
+}
+
+static void
+cg6_loadcursor(fbFd * fb)
+{
+ volatile struct cg6_thc *thc;
+ u_int edgemask;
+ u_int m;
+ int i;
+
+ /*
+ * Keep the top size.x bits. Here we *throw out* the top
+ * size.x bits from an all-one-bits word, introducing zeros in
+ * the top size.x bits, then invert all the bits to get what
+ * we really wanted as our mask. But this fails if size.x is
+ * 32---a sparc uses only the low 5 bits of the shift count---
+ * so we have to special case that.
+ */
+ edgemask = ~0;
+ if (sc_cursor.cc_size.x < 32)
+ edgemask = ~(edgemask >> sc_cursor.cc_size.x);
+ thc = (volatile struct cg6_thc *) fb->thc;
+ for (i = 0; i < 32; i++) {
+ m = sc_cursor.cc_bits[0][i] & edgemask;
+ thc->thc_cursmask[i] = m;
+ thc->thc_cursbits[i] = m & sc_cursor.cc_bits[1][i];
+ }
+}
+
+static void
+cg6_setcursor(fbFd * fb)
+{
+ /* we need to subtract the hot-spot value here */
+#define COORD(f) (sc_cursor.cc_pos.f - sc_cursor.cc_hot.f)
+ ((volatile struct cg6_thc *) (fb->thc))->thc_cursxy = sc_cursor.cc_enable ?
+ ((COORD(x) << 16) | (COORD(y) & 0xffff)) :
+ (THC_CURSOFF << 16) | THC_CURSOFF;
+#undef COORD
+}
+
+/*
+ * Load the cursor (overlay `foreground' and `background') colors.
+ */
+static void
+cg6_loadomap(fbFd * fb)
+{
+ volatile struct bt_regs *bt;
+ u_int i;
+
+ bt = (volatile struct bt_regs *) fb->ramdac;
+ bt->bt_addr = 0x01 << 24; /* set background color */
+ i = sc_cursor.cc_color.cm_chip[0];
+ bt->bt_omap = i; /* R */
+ bt->bt_omap = i << 8; /* G */
+ bt->bt_omap = i << 16; /* B */
+
+ bt->bt_addr = 0x03 << 24; /* set foreground color */
+ bt->bt_omap = i << 24; /* R */
+ i = sc_cursor.cc_color.cm_chip[1];
+ bt->bt_omap = i; /* G */
+ bt->bt_omap = i << 8; /* B */
+}
+
+/*
+ * Load a subset of the current (new) colormap into the color DAC.
+ */
+static void
+cg6_loadcmap(fbFd * fb, union bt_cmap *cm, int start, int ncolors)
+{
+ volatile struct bt_regs *bt;
+ u_int *ip;
+ u_int i;
+ int count;
+
+ ip = &cm->cm_chip[BT_D4M3(start)]; /* start/4 * 3 */
+ count = BT_D4M3(start + ncolors - 1) - BT_D4M3(start) + 3;
+ bt = (struct bt_regs *) fb->ramdac;
+ bt->bt_addr = BT_D4M4(start) << 24;
+ while (--count >= 0) {
+ i = *ip++;
+ /* hardware that makes one want to pound boards with hammers */
+ bt->bt_cmap = i;
+ bt->bt_cmap = i << 8;
+ bt->bt_cmap = i << 16;
+ bt->bt_cmap = i << 24;
+ }
+}
+
+/*
+ * Undo the effect of an FBIOSVIDEO that turns the video off on a CG6
+ */
+static void
+cg6_unblank(fbFd * dev)
+{
+ volatile struct cg6_thc *thc = (volatile struct cg6_thc *) dev->thc;
+ unsigned long x;
+ unsigned long y;
+
+ if (blanked) {
+ thc->thc_misc = (thc->thc_misc & ~THC_MISC_VIDEN) | THC_MISC_VIDEN;
+ }
+ blanked = 0;
+}
+
+/*
+ * Load a subset of the current (new) colormap into the Brooktree DAC.
+ */
+static void
+cg3_loadcmap(fbFd * fb, union bt_cmap *cm, int start, int ncolors)
+{
+ volatile struct bt_regs *bt;
+ u_int *ip;
+ int count;
+
+ ip = &cm->cm_chip[BT_D4M3(start)]; /* start/4 * 3 */
+ count = BT_D4M3(start + ncolors - 1) - BT_D4M3(start) + 3;
+ bt = (struct bt_regs *) fb->ramdac;
+ bt->bt_addr = BT_D4M4(start);
+ while (--count >= 0)
+ bt->bt_cmap = *ip++;
+}
+
+/*
+ * Undo the effect of an FBIOSVIDEO that turns the video off on a CG3
+ */
+static void
+cg3_unblank(fbFd * dev)
+{
+ volatile struct bt_regs *bt;
+
+ if (blanked) {
+ bt = (struct bt_regs *) dev->ramdac;
+ /* restore color 0 (and R of color 1) */
+ bt->bt_addr = 0;
+ bt->bt_cmap = sc_cmap.cm_chip[0];
+
+ /* restore read mask */
+ bt->bt_addr = 0x06; /* command reg */
+ bt->bt_ctrl = 0x73; /* overlay plane */
+ bt->bt_addr = 0x04; /* read mask */
+ bt->bt_ctrl = 0xff; /* color planes */
+ }
+ blanked = 0;
+}
+
+int
+sunIoctl(fbFd * fb, int cmd, void *arg)
+{
+ int error;
+ int v;
+ int i;
+ u_int count;
+ union cursor_cmap tcm;
+
+ switch (cmd) {
+ default:
+ errno = EINVAL;
+ return -1;
+ case FBIOPUTCMAP:
+#define q ((struct fbcmap *)arg)
+ if (error = bt_putcmap(q, &sc_cmap, 256))
+ return error;
+ if (fb->thc) { /* CG6 */
+ cg6_loadcmap(fb, &sc_cmap, q->index, q->count);
+ } else { /* CG3 */
+ cg3_loadcmap(fb, &sc_cmap, q->index, q->count);
+ }
+ break;
+ case FBIOSVIDEO:
+ if (fb->thc) { /* CG6 */
+ if (*(int *) arg)
+ cg6_unblank(fb);
+ else {
+ if (!blanked) {
+ volatile struct cg6_thc *thc =
+ (volatile struct cg6_thc *) fb->thc;
+
+ thc->thc_misc = (thc->thc_misc & ~THC_MISC_VIDEN);
+ }
+ blanked = 1;
+ }
+ } else { /* CG3 */
+ if (*(int *) arg)
+ cg3_unblank(fb);
+ else {
+ if (!blanked) {
+ volatile struct bt_regs *bt;
+
+ bt = (struct bt_regs *) fb->ramdac;
+ bt->bt_addr = 0x06; /* command reg */
+ bt->bt_ctrl = 0x70; /* overlay plane */
+ bt->bt_addr = 0x04; /* read mask */
+ bt->bt_ctrl = 0x00; /* color planes */
+
+ /*
+ * Set color 0 to black -- note that this overwrites R of
+ * color 1.
+ */
+ bt->bt_addr = 0;
+ bt->bt_cmap = 0;
+
+ }
+ blanked = 1;
+ }
+ }
+ break;
+/* these are for both FBIOSCURSOR and FBIOGCURSOR */
+#define p ((struct fbcursor *)arg)
+#define cc (&sc_cursor)
+
+ case FBIOSCURSOR:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ /*
+ * For setcmap and setshape, verify parameters, so that
+ * we do not get halfway through an update and then crap
+ * out with the software state screwed up.
+ */
+ v = p->set;
+ if (v & FB_CUR_SETCMAP) {
+ /*
+ * This use of a temporary copy of the cursor
+ * colormap is not terribly efficient, but these
+ * copies are small (8 bytes)...
+ */
+ tcm = cc->cc_color;
+ error = bt_putcmap(&p->cmap, (union bt_cmap *) &tcm, 2);
+ if (error)
+ return (error);
+ }
+ if (v & FB_CUR_SETSHAPE) {
+ if ((u_int) p->size.x > 32 || (u_int) p->size.y > 32)
+ return (EINVAL);
+ count = p->size.y * 32 / NBBY;
+ if (!useracc(p->image, count, B_READ) ||
+ !useracc(p->mask, count, B_READ))
+ return (EFAULT);
+ }
+ /* parameters are OK; do it */
+ if (v & (FB_CUR_SETCUR | FB_CUR_SETPOS | FB_CUR_SETHOT)) {
+ if (v & FB_CUR_SETCUR)
+ cc->cc_enable = p->enable;
+ if (v & FB_CUR_SETPOS)
+ cc->cc_pos = p->pos;
+ if (v & FB_CUR_SETHOT)
+ cc->cc_hot = p->hot;
+ cg6_setcursor(fb);
+ }
+ if (v & FB_CUR_SETCMAP) {
+ cc->cc_color = tcm;
+ cg6_loadomap(fb); /* XXX defer to vertical retrace */
+ }
+ if (v & FB_CUR_SETSHAPE) {
+ cc->cc_size = p->size;
+ count = p->size.y * 32 / NBBY;
+ bzero((caddr_t) cc->cc_bits, sizeof cc->cc_bits);
+ bcopy(p->mask, (caddr_t) cc->cc_bits[0], count);
+ bcopy(p->image, (caddr_t) cc->cc_bits[1], count);
+ cg6_loadcursor(fb);
+ }
+ break;
+ case FBIOSCURPOS:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ sc_cursor.cc_pos = *(struct fbcurpos *) arg;
+ cg6_setcursor(fb);
+ break;
+
+ case FBIOGCURMAX:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ /* max cursor size is 32x32 */
+ ((struct fbcurpos *) arg)->x = 32;
+ ((struct fbcurpos *) arg)->y = 32;
+ break;
+ case FBIORESET:
+ if (!fb->thc) { /* reject non CG6 */
+ errno = EINVAL;
+ return -1;
+ }
+ cg6_reset(fb);
+ }
+ return 0;
+}
diff --git a/nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h b/nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h
new file mode 100644
index 000000000..37b3fd5b3
--- /dev/null
+++ b/nx-X11/programs/Xserver/hw/sunLynx/vuid_event.h
@@ -0,0 +1,88 @@
+/* $Xorg: vuid_event.h,v 1.3 2000/08/17 19:48:38 cpqbld Exp $ */
+/*
+ * Copyright (c) 1992, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
+ * contributed to Berkeley.
+ *
+ * All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Lawrence Berkeley Laboratory.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * @(#)vuid_event.h 8.1 (Berkeley) 6/11/93
+ */
+/* $NetBSD: vuid_event.h,v 1.2 1994/11/20 20:53:39 deraadt Exp $ */
+/* $XFree86: xc/programs/Xserver/hw/sunLynx/vuid_event.h,v 3.1 1996/12/27 06:51:43 dawes Exp $ */
+
+/*
+ * The following is a minimal emulation of Sun's `Firm_event' structures
+ * and related operations necessary to make X11 happy (i.e., make it
+ * compile, and make old X11 binaries run).
+ */
+typedef struct firm_event {
+ u_short id; /* key or MS_* or LOC_[XY]_DELTA */
+ u_short pad; /* unused, at least by X11 */
+ int value; /* VKEY_{UP,DOWN} or locator delta */
+ struct timeval time;
+} Firm_event;
+
+/*
+ * Special `id' fields. These weird numbers simply match the old binaries.
+ * Others are in 0..0x7f and are keyboard key numbers (keyboard dependent!).
+ */
+#define MS_LEFT 0x7f20 /* left mouse button */
+#define MS_MIDDLE 0x7f21 /* middle mouse button */
+#define MS_RIGHT 0x7f22 /* right mouse button */
+#define LOC_X_DELTA 0x7f80 /* mouse delta-X */
+#define LOC_Y_DELTA 0x7f81 /* mouse delta-Y */
+#define LOC_X_ABSOLUTE 0x7f82 /* X compat, unsupported */
+#define LOC_Y_ABSOLUTE 0x7f83 /* X compat, unsupported */
+
+/*
+ * Special `value' fields. These apply to keys and mouse buttons. The
+ * value of a mouse delta is the delta. Note that positive deltas are
+ * left and up (not left and down as you might expect).
+ */
+#define VKEY_UP 0 /* key or button went up */
+#define VKEY_DOWN 1 /* key or button went down */
+
+/*
+ * The following ioctls are clearly intended to take things in and out
+ * of `firm event' mode. Since we always run in this mode (as far as
+ * /dev/kbd and /dev/mouse are concerned, anyway), we always claim to
+ * be in this mode and reject anything else.
+ */
+#define VUIDSFORMAT _IOW('v', 1, int)
+#define VUIDGFORMAT _IOR('v', 2, int)
+#define VUID_FIRM_EVENT 1 /* the only format we support */