Skip to content

Instantly share code, notes, and snippets.

@tsutsui
Last active August 29, 2015 13:56
Show Gist options
  • Save tsutsui/9151686 to your computer and use it in GitHub Desktop.
Save tsutsui/9151686 to your computer and use it in GitHub Desktop.
Work-in-progress files for X11R7 based NetBSD/x68k Xserver
Index: src/distrib/sets/lists/xetc/md.x68k
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/xetc/md.x68k,v
retrieving revision 1.3
diff -u -p -d -r1.3 md.x68k
--- src/distrib/sets/lists/xetc/md.x68k 2 Sep 2008 02:24:12 -0000 1.3
+++ src/distrib/sets/lists/xetc/md.x68k 22 Feb 2014 10:41:16 -0000
@@ -1,2 +1,3 @@
# $NetBSD: md.x68k,v 1.3 2008/09/02 02:24:12 lukem Exp $
./etc/X11/X68kConfig -unknown- x11
+./etc/X11/X68kConfig -unknown- xorg
Index: src/distrib/sets/lists/xserver/md.x68k
===================================================================
RCS file: /cvsroot/src/distrib/sets/lists/xserver/md.x68k,v
retrieving revision 1.17
diff -u -p -d -r1.17 md.x68k
--- src/distrib/sets/lists/xserver/md.x68k 9 Feb 2009 16:28:54 -0000 1.17
+++ src/distrib/sets/lists/xserver/md.x68k 22 Feb 2014 10:41:16 -0000
@@ -4,3 +4,8 @@
./usr/X11R6/man/cat1/X68k.0 -unknown- .cat,x11
./usr/X11R6/man/html1/X68k.html -unknown- html,x11
./usr/X11R6/man/man1/X68k.1 -unknown- .man,x11
+./usr/X11R7/bin/X -unknown- xorg
+./usr/X11R7/bin/X68k -unknown- xorg
+./usr/X11R7/man/cat1/X68k.0 -unknown- .cat,xorg
+./usr/X11R7/man/html1/X68k.html -unknown- html,xorg
+./usr/X11R7/man/man1/X68k.1 -unknown- .man,xorg
Index: src/external/mit/xorg/server/xorg-server/hw/Makefile
===================================================================
RCS file: /cvsroot/src/external/mit/xorg/server/xorg-server/hw/Makefile,v
retrieving revision 1.4
diff -u -p -d -r1.4 Makefile
--- src/external/mit/xorg/server/xorg-server/hw/Makefile 14 Feb 2009 10:46:06 -0000 1.4
+++ src/external/mit/xorg/server/xorg-server/hw/Makefile 22 Feb 2014 10:13:13 -0000
@@ -7,11 +7,11 @@ SUBDIR= xnest vfb
SUBDIR+= xfree86
.endif
-.if 0
.if ${XSERVER_X68K} != "no"
SUBDIR+=netbsd/x68k
.endif
+.if 0
.if ${XSERVER_XALPHANETBSD} != "no"
SUBDIR+=netbsd/alpha
.endif
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/Imakefile 2014-02-21 18:48:42.000000000 +0000
@@ -0,0 +1,24 @@
+XCOMM $NetBSD: Imakefile,v 1.1.1.1 2004/01/07 12:51:46 minoura Exp $
+#include <Server.tmpl>
+
+SRCS = x68kInit.c x68kConfig.c x68kIo.c \
+ x68kMouse.c x68kKbd.c x68kKeyMap.c\
+ x68kFb.c x68kGraph.c x68kText.c
+
+OBJS = x68kInit.o x68kConfig.o x68kIo.o \
+ x68kMouse.o x68kKbd.o x68kKeyMap.o\
+ x68kFb.o x68kGraph.o x68kText.o
+
+SpecialObjectRule(x68kConfig.o,x68kConfig.c,'-DX11_LIBDIR="$(LIBDIR)"')
+
+INCLUDES = -I. -I../../../include -I../../../mfb -I../../../cfb -I../../../mi -I../../../os -I$(XINCLUDESRC)
+
+NormalLibraryObjectRule()
+
+NormalLibraryTarget(x68k,$(OBJS))
+
+InstallNonExecFileNoClobber(X68kConfig,$(LIBDIR))
+
+DependTarget()
+
+InstallManPage(X68k,$(MANDIR))
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/X68k.man 2014-02-21 18:48:42.000000000 +0000
@@ -0,0 +1,223 @@
+.\" $NetBSD: X68k.man,v 1.2 2008/04/30 13:48:30 martin Exp $
+.\"
+.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Minoura Makoto.
+.\"
+.\" 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.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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.
+.\"
+.Dd Nov 10, 1998
+.Dt X68K 1
+.Os NetBSD
+.Sh NAME
+.Nm X68k
+.Nd X Window System Display Server for NetBSD/x68k
+.Sh SYNOPSIS
+.Nm
+.Op Ar options ...
+.Sh DESCRIPTION
+.Nm
+is the server for Version 11 of the X Window System on X68k hardware
+running
+.Nx .
+It will normally be started by the
+.Xr xdm 1
+daemon or by a script that runs the program
+.Xr xinit 1 .
+.Sh SUPPORTED HARDWARE
+.Nm
+supports both the x68k built-in text bitmap screen and graphics
+bitmap screen.
+When it is configured to use the text screen, it can be used as
+a monochrome server. Otherwise, it can be used as 4-bit, 8-bit or 15-bit
+16-bit color/monochrome server.
+
+.Nm
+supports the x68k standard full-size and compact type keyboards. The
+initial arrangement of the keys on the keyboards can be configured
+either as the typewriter style (
+.So ASCII Sc
+arrangement) or as the JIS standard style (
+.So JIS Sc
+arrangement). Once it is started, the arrangement is freely configured with
+.Xr xmodmap 1
+or
+.Xr xkbcomp 1
+utility.
+
+The pointing device can be either the standard mouse or the
+mouse-trackball. Although the x68k can have two mice connected,
+it recognizes only one of them; if two mice are connected,
+the result is undefined.
+
+.Sh OPTIONS
+In addition to the normal server options described in the
+.Xr Xserver 1
+manual page,
+.Nm
+acdepts the following command line switch:
+.Bl -tag -width indent
+.It Fl x68kconfig Ar config_file
+Specify the configuration filename.
+.El
+
+.Sh CONFIGURATION FILE
+.Nm
+configuration is specified in the configuration file called X68kConfig.
+If the configuration filename is specified on the command line option
+.Ar x68kconfig ,
+the named file is used to read the configuration. Otherwise
+.Nm
+searches for the file
+.Pa /etc/X68kConfig .
+If it is not found,
+.Pa <XRoot>/lib/X11/X68kConfig
+is used instead, where
+.Pa <XRoot>
+is replaced by the root of the X11 install tree (ordinary
+.Pa /usr/X11R6 ) .
+
+X68kConfig has a Lisp-like syntax. Comments start with the character
+.So ; Sc ,
+and ends at the end of line.
+
+There are 4 functions recognized:
+.Bl -tag -width indent
+.It Fn ModeDef
+Define a display mode. 18 arguments are required:
+
+.Fa name Fa type Fa depth Fa class Fa width Fa height Fa regs...
+.Fa r0 Fa r1 Fa r2 Fa r3 Fa r4
+.Fa r5 Fa r6 Fa r7 Fa r8 Fa r20
+.Fa videoc-r0 Fa dotclk
+
+.Fa Name
+is the name defined by this ModeDef definition.
+
+.Fa Type
+is either
+.Fa Text
+or
+.Fa Graphic ,
+and specifies the screen to be used by this mode. Note that the type
+Graphic requires the
+.Pa /dev/grf1
+device driver configured in your kernel.
+
+.Fa Depth
+is the framebuffer depth for this mode. If
+.Fa type
+is Text, this must be 1. Otherwise it can be chosen from 4, 8 and 15.
+
+.Fa Class
+specifies the display class, and be chosen from either StaticGray,
+PseudoColor and TrueColor.
+
+.Fa Width
+and
+.Fa height
+are the size of the screen by pixel.
+
+Remaining arguments are set to the registers of the CRT controler
+and the video controler of the x68k.
+Be carefull to change these values, or it may
+DAMAGE THE DISPLAY HARDWARE!!
+
+.It Fn Mode
+One argument
+.Fa name
+is required. Set the display mode to
+.Fa name
+as defined by the
+.Fn ModeDef
+function.
+.It Fn Mouse
+One argument
+.Fa type
+is required. Specify the pointing device type; currently
+.Fa standard
+is the only acceptable argument.
+.It Fn Keyboard
+One argument
+.Fa type
+is required. Specify the initial arrangement of the keyboard.
+.Fa Type
+is either standard or ascii, which means the JIS arrangement and
+the typewriter arrangement respectively.
+.El
+
+See
+.Sx EXAMPLE
+section for an example of
+.Pa X68kConfig .
+
+.Sh FILES
+.Pa /etc/X68kConfig ,
+.Pa /usr/X11R6/lib/X11/X68kConfig
+
+.Sh EXAMPLE
+Following is the example configuration file:
+.Bd -unfilled -offset indent
+;; Example configuration file for X68k.
+;; These lines are comments.
+
+; Define standard monochrome mode:
+(ModeDef Monochrome768x512
+; type depth class width height
+ Text 1 StaticGray 768 512
+; CRTC-R00 -R01 -R02 -R03 -R04 -R05 -R06 -R07 -R08
+ 137 14 28 124 567 5 40 552 27
+; CRTC-R20 VIDEOC-R0 dotclk
+ 1046 4 0)
+
+; Configure the display as Monochrome768x512 defined above:
+(Mode Monochrome768x512)
+
+; Specify the input devices:
+(Mouse standard)
+(Keyboard standard)
+.Ed
+
+.Sh SEE ALSO
+.Xr Xserver 1 ,
+.Xr X 1 ,
+.Xr xdm 1 ,
+.Xr xinit 1 ,
+.Xr xmodmap 1 ,
+.Xr xkbdcomp 1
+
+.Sh HISTORY
+.Nm
+was originally written by Yamasaki Yasushi <yamapu@osk3.3web.ne.jp>
+as XFree68 in May 1996, and was little modified by Minoura Makoto
+<minoura@netbsd.org> to fit with the
+.Nx
+source tree in Jan. 1998. Officially appeared in
+.Nx 1.4 .
+
+.Sh BUGS
+.Nm
+may damage your display hardware, depending on the configuration.
+
+The keyboard geometry database is not correct currently.
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/X68kConfig 2014-02-21 18:48:42.000000000 +0000
@@ -0,0 +1,113 @@
+;; $NetBSD: X68kConfig,v 1.1.1.1 2004/01/07 12:51:46 minoura Exp $
+;;----------------------------------------------------------------
+;; X68kConfig: sample configuration for X68k
+;; written by Yasushi Yamasaki
+;;----------------------------------------------------------------
+
+;;----------------------------------------------------------------
+;; standard modes
+;;----------------------------------------------------------------
+
+;
+; 768x512x1bit Monochrome
+; CRTC-R20 = 0x0416(1046) VIDEOC-R0 = 0x0004
+;
+(ModeDef Monochrome768x512
+; type depth class width height
+ Text 1 StaticGray 768 512
+; CRTC-R00 -R01 -R02 -R03 -R04 -R05 -R06 -R07 -R08
+ 137 14 28 124 567 5 40 552 27
+; CRTC-R20 VIDEOC-R0 dotclk
+ 1046 4 0)
+
+;
+; 768x512x4bit StaticGray
+; CRTC-R20 = 0x0416(1046) VIDEOC-R0 = 0x0004
+;
+(ModeDef Static16Gray768x512 Graphic 4 StaticGray 768 512
+ 137 14 28 124 567 5 40 552 27
+ 1046 4 0)
+
+;
+; 768x512x4bit PseudoColor
+; CRTC-R20 = 0x0416(1046) VIDEOC-R0 = 0x0004
+;
+(ModeDef Pseudo16Color768x512 Graphic 4 PseudoColor 768 512
+ 137 14 28 124 567 5 40 552 27
+ 1046 4 0)
+
+;
+; 512x512x8bit PseudoColor
+; CRTC-R20 = 0x0115(277) VIDEOC-R0 = 0x0001
+;
+(ModeDef Pseudo256Color512x512 Graphic 8 PseudoColor 512 512
+ 91 9 17 81 567 5 40 552 27
+ 277 1 0)
+
+;
+; 512x512x15bit TrueColor
+; CRTC-R20 = 0x0315(789) VIDEOC-R0 = 0x0003
+;
+(ModeDef True32768Color512x512 Graphic 15 TrueColor 512 512
+ 91 9 17 81 567 5 40 552 27
+ 789 3 0)
+
+;;----------------------------------------------------------------
+;; tricky modes
+;;----------------------------------------------------------------
+
+;
+; 1024x768x1bit Monochrome
+; CRTC-R20 = 0x041a(1050) VIDEOC-R0 = 0x0004
+;
+(ModeDef Monochrome1024x768 Text 1 StaticGray 1024 768
+ 164 9 26 154 415 2 28 412 27
+ 1050 4 0)
+
+;
+; 1024x768x4bit PseudoColor
+; CRTC-R20 = 0x041a(1050) VIDEOC-R0 = 0x0004
+;
+(ModeDef Pseudo16Color1024x768 Graphic 4 PseudoColor 1024 768
+ 164 9 26 154 415 2 28 412 27
+ 1050 4 0)
+
+;
+; 1024x762x4bit StaticGray
+; CRTC-R20 = 0x041a(1050) VIDEOC-R0 = 0x0004
+;
+(ModeDef NeedsMultiScan Graphic 4 StaticGray 1024 768
+ 154 9 16 144 405 2 18 402 27
+ 1050 4 0)
+
+;
+; 512x512x15bit TrueColor
+; CRTC-R20 = 0x0316(790) VIDEOC-R0 = 0x0003
+;
+(ModeDef True32768ColorSquare Graphic 15 TrueColor 512 512
+ 137 14 28 124 567 5 40 552 27
+ 790 3 0)
+
+;;----------------------------------------------------------------
+;; mode selection
+;;----------------------------------------------------------------
+
+(Mode Pseudo16Color768x512) ; choose 768x512x4bit PseudoColor
+;(Mode Pseudo256Color512x512)
+;(Mode Static16Gray768x512)
+;(Mode True32768Color512x512)
+;(Mode Monochrome768x512)
+;(Mode Monochrome1024x768)
+;(Mode Pseudo16Color1024x768)
+;(Mode NeedsMultiScan)
+
+;;----------------------------------------------------------------
+;; input devices
+;;----------------------------------------------------------------
+
+(Mouse standard) ; standard x68k mouse
+(Keyboard standard) ; standard x68k keyboard
+; (Keyboard ascii) ; ascii map
+
+
+;;---------------------------- EOF -------------------------------
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68k.h 2014-02-22 07:59:01.000000000 +0000
@@ -0,0 +1,182 @@
+/* $NetBSD: x68k.h,v 1.3 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+/* system */
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <unistd.h>
+
+/* machine dependent */
+#include <machine/vuid_event.h>
+#include <machine/kbd.h>
+#include <machine/kbio.h>
+#include <machine/grfioctl.h>
+
+/* generic X */
+#include <X.h>
+#include <Xmd.h>
+#define XK_KATAKANA
+#include <keysym.h>
+#define NEED_EVENTS
+#include <Xproto.h>
+
+/* dix */
+#include <misc.h>
+#include <scrnintstr.h>
+#include <screenint.h>
+#include <input.h>
+#include <inputstr.h>
+#include <servermd.h>
+#include <colormap.h>
+#include <colormapst.h>
+
+/* mi */
+#include <mipointer.h>
+
+#include "x68kReg.h"
+
+/*
+ * X68k dependent screen record
+ */
+typedef struct _X68kScreenRec {
+ int type; /* frame buffer type */
+ int class; /* visual class */
+ int fd; /* file descriptor */
+ int depth; /* depth */
+ int fb_width; /* frame buffer width */
+ int fb_height; /* frame buffer height */
+ int scr_width; /* screen width */
+ int scr_height; /* screen height */
+ int dpi; /* dots per inch */
+ caddr_t fb; /* frame buffer VA */
+ volatile FbReg *reg; /* control register VA */
+ X68kFbReg x68kreg; /* control register */
+ int mapsize; /* size of mapped memory */
+ ColormapPtr installedMap; /* installed colormap */
+} X68kScreenRec;
+
+/*
+ * frame buffer procedures
+ */
+typedef struct _X68kFbProcRec {
+ Bool (*open)(X68kScreenRec *); /* open procedure */
+ Bool (*init)(int, ScreenPtr, int, char *[]); /* initialize procedure */
+ void (*close)(X68kScreenRec *); /* close procedure */
+} X68kFbProcRec;
+
+/* frame buffer types */
+#define X68K_FB_NULL 0
+#define X68K_FB_TEXT 1 /* text VRAM frame buffer */
+#define X68K_FB_GRAPHIC 2 /* graphic VRAM frame buffer */
+#if 0
+#define X68K_FB_CIRRUS 3 /* not yet */
+#endif
+#define X68K_FB_TYPES 2
+
+typedef struct _X68kMousePriv {
+ int fd;
+ int bmask;
+} X68kMousePriv, *X68kMousePrivPtr;
+
+typedef struct _X68kKbdPriv {
+ int type;
+ int fd;
+ Leds leds;
+} X68kKbdPriv, *X68kKbdPrivPtr;
+
+/* keyboard types */
+#define X68K_KB_STANDARD 0 /* standard keyboard */
+#define X68K_KB_ASCII 1 /* ascii map keyboard */
+
+#define MAXEVENTS 32
+#define TVTOMILLI(tv) (((tv).tv_usec/1000)+((tv).tv_sec*1000))
+
+extern DevPrivateKeyRec x68kScreenPrivateKeyRec;
+#define x68kScreenPrivateKey (&x68kScreenPrivateKeyRec)
+#define x68kScreenPriv(pScreen) ((X68kScreenRec *) \
+ dixLookupPrivate(&(pScreen)->devPrivates, x68kScreenPrivateKey))
+
+/* in x68kConfig.c */
+X68kScreenRec *x68kGetScreenRec(int);
+X68kScreenRec *x68kGetScreenRecByType(int);
+X68kFbProcRec *x68kGetFbProcRec(int index);
+void x68kRegisterPixmapFormats(ScreenInfo *);
+int x68kConfig(void);
+extern char *configFilename;
+
+/* x68kFB.c */
+Bool x68kFbCommonOpen(X68kScreenRec *, char *);
+void x68kFbCommonClose(X68kScreenRec *);
+Bool x68kSaveScreen(ScreenPtr, int);
+extern int x68kScreenIndex;
+extern int x68kGeneration;
+
+/* x68kGraph.c */
+Bool x68kGraphOpen(X68kScreenRec *);
+Bool x68kGraphInit(int, ScreenPtr, int, char *[]);
+void x68kGraphClose(X68kScreenRec *);
+
+/* in x68kInit.c */
+extern EventList *x68kEvents;
+
+/* in x68kIo.c */
+void x68kSigIOHandler(int);
+
+/* in x68kMouse.c */
+int x68kMouseProc(DeviceIntPtr, int);
+Firm_event *x68kMouseGetEvents(int, int *, Bool *);
+void x68kMouseEnqueueEvent(DeviceIntPtr, Firm_event *);
+extern miPointerScreenFuncRec x68kPointerScreenFuncs;
+extern DeviceIntPtr x68kPointerDevice;
+
+/* in x68kKbd.c */
+int x68kKbdProc(DeviceIntPtr, int);
+Firm_event *x68kKbdGetEvents(int, int *, Bool *);
+void x68kKbdEnqueueEvent(DeviceIntPtr, Firm_event *);
+extern X68kKbdPriv x68kKbdPriv;
+extern DeviceIntPtr x68kKeyboardDevice;
+
+/* in x68kKeyMap.c */
+extern KeySymsRec jisKeySyms, asciiKeySyms, *x68kKeySyms;
+
+/* x68kText.c */
+Bool x68kTextOpen(X68kScreenRec *);
+Bool x68kTextInit(int, ScreenPtr, int, char *[]);
+void x68kTextClose(X68kScreenRec *);
+
+/* EOF x68k.h */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kConfig.c 2014-02-21 18:48:42.000000000 +0000
@@ -0,0 +1,635 @@
+/* $NetBSD: x68kConfig.c,v 1.4 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+#include <stdarg.h>
+#include "x68k.h"
+#include "opaque.h"
+
+static PixmapFormatRec *x68kFormat = NULL;
+static PixmapFormatRec defaultFormat = {
+ 1,
+ 1,
+ BITMAP_SCANLINE_PAD
+};
+static X68kScreenRec x68kScreen[X68K_FB_TYPES];
+static X68kFbProcRec x68kFbProc[X68K_FB_TYPES];
+
+/*-------------------------------------------------------------------------
+ * function "x68kGetScreenRec"
+ *
+ * purpose: get corresponding screen record
+ * argument: (int)sindex : screen index
+ * returns: (X68kScreenRec *) : X68k dependent screen record
+ *-----------------------------------------------------------------------*/
+X68kScreenRec *x68kGetScreenRec(int sindex)
+{
+ return &x68kScreen[sindex];
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kGetScreenRecByType"
+ *
+ * purpose: search screen record by type
+ * argument: (int)type : screen type
+ * returns: (X68kScreenRec *) : X68k dependent screen record
+ *-----------------------------------------------------------------------*/
+X68kScreenRec *x68kGetScreenRecByType(int type)
+{
+ int i;
+
+ for (i = 0; i < X68K_FB_TYPES; i++) {
+ if (x68kScreen[i].type == type)
+ return &x68kScreen[i];
+ }
+ return NULL;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kGetFbProcRec"
+ *
+ * purpose: get corresponding frame buffer procedure record
+ * argument: (int)sindex : screen index
+ * returns: (X68kFbProcRec *) : frame buffer procedure record
+ *-----------------------------------------------------------------------*/
+X68kFbProcRec *x68kGetFbProcRec(int sindex)
+{
+ return &x68kFbProc[sindex];
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kRegisterPixmapFormats"
+ *
+ * purpose: register pixmap formats into ScreenInfo struct
+ * argument: (ScreenInfo *)pScreenInfo
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void x68kRegisterPixmapFormats(ScreenInfo *pScreenInfo)
+{
+ /* supports only one pixmap format for each screen type */
+ pScreenInfo->numPixmapFormats = 1;
+ pScreenInfo->formats[0] = defaultFormat;
+
+ if (x68kFormat)
+ pScreenInfo->formats[pScreenInfo->numPixmapFormats++] = *x68kFormat;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kConfig"
+ *
+ * purpose: process general configuration by reading "X68kConfig" file
+ * /usr/X11R6/lib/X11/ is the default location of this file
+ * argument: nothing
+ * returns: the number of screens
+ *-----------------------------------------------------------------------*/
+char *hostConfigFilename = "/etc/X68kConfig";
+char *siteConfigFilename = X11_LIBDIR "/X68kConfig";
+char *configFilename = NULL;
+static FILE *config;
+char modeSet = FALSE;
+
+static int parseCommand(void);
+
+int x68kConfig(void)
+{
+ if (configFilename)
+ config = fopen(configFilename, "r");
+ else {
+ configFilename = hostConfigFilename;
+ config = fopen(configFilename, "r");
+ if (config == NULL) {
+ configFilename = siteConfigFilename;
+ config = fopen(configFilename, "r");
+ }
+ }
+ if (config == NULL)
+ FatalError("Can't open X68kConfig file");
+ while (parseCommand())
+ ;
+ fclose(config);
+ if (!modeSet)
+ FatalError("No mode set.");
+ return 1;
+}
+
+
+/*-------------------------------------------------------------------------
+ * X68KConfig parsing part
+ *-----------------------------------------------------------------------*/
+void parseError(int line, char *str, ...);
+
+enum TokenType {
+ TOKEN_EOF,
+ TOKEN_SYMBOL,
+ TOKEN_LITERAL,
+ TOKEN_OPEN_PARENTHESIS,
+ TOKEN_CLOSE_PARENTHESIS
+};
+
+typedef struct {
+ enum TokenType type;
+ int line;
+ union {
+ char *symbol;
+ int literal;
+ } content;
+} Token;
+
+/*-------------------------------------------------------------------------
+ * function "getToken"
+ *
+ * purpose: cut out a token from configration file stream
+ * argument: nothing
+ * returns: (Token *) : cut token
+ *-----------------------------------------------------------------------*/
+static Token *getToken(void)
+{
+ int c;
+ static int line = 1;
+ Token *ret;
+
+ ret = (Token *)xalloc(sizeof(Token));
+ if (ret == NULL)
+ FatalError("Out of memory");
+ while (TRUE) {
+ /* slip white spaces */
+ do {
+ c = fgetc(config);
+ if (c == '\n')
+ line++;
+ } while (isspace(c));
+ if (c != ';')
+ break;
+ /* skip a comment */
+ do {
+ c = fgetc(config);
+ } while (c != '\n');
+ line++;
+ }
+ ret->line = line;
+ if (c == EOF) {
+ ret->type = TOKEN_EOF;
+ return ret;
+ }
+ /* is a symbol? */
+ if (isalpha(c)) {
+ int i = 0;
+ ret->content.symbol = (char *)xalloc(32 * sizeof(char));
+ if (ret->content.symbol == NULL)
+ FatalError("Out of memory");
+ do {
+ if (i < 31)
+ ret->content.symbol[i++] = c;
+ c = fgetc(config);
+ } while (isalnum(c) || c == '_');
+ ungetc(c, config);
+ ret->content.symbol[i] = '\0';
+ ret->type = TOKEN_SYMBOL;
+ return ret;
+ }
+ /* is a literal number? */
+ if (isdigit(c)) {
+ char tmp[32];
+ int i = 0;
+ do {
+ if (i < 31)
+ tmp[i++] = c;
+ c = fgetc(config);
+ } while (isdigit(c));
+ ungetc(c, config);
+ tmp[i] = '\0';
+ if (sscanf(tmp, "%d", &ret->content.literal) != 1)
+ parseError(line, "illegal literal value");
+ ret->type = TOKEN_LITERAL;
+ return ret;
+ }
+ /* others */
+ switch(c) {
+ case '(':
+ ret->type = TOKEN_OPEN_PARENTHESIS;
+ break;
+ case ')':
+ ret->type = TOKEN_CLOSE_PARENTHESIS;
+ break;
+ default:
+ parseError(line, NULL);
+ }
+ return ret;
+}
+
+typedef struct {
+ char *symbol;
+ void (*proc)(int argc, Token **argv);
+} Command;
+
+static void parseModeDef(int argc, Token **argv);
+static void parseMouse(int argc, Token **argv);
+static void parseKeyboard(int argc, Token **argv);
+static void parseMode(int argc, Token **argv);
+
+Command command[] = {
+ { "ModeDef", parseModeDef },
+ { "Mouse", parseMouse },
+ { "Keyboard", parseKeyboard },
+ { "Mode", parseMode },
+};
+#define NCOMMANDS (sizeof(command)/sizeof(command[0]))
+
+/*-------------------------------------------------------------------------
+ * function "parseCommand"
+ *
+ * purpose: parse generic command. every command parsing departs here.
+ * argument: nothing
+ * returns: (int) : FALSE if there's no rest
+ * TRUE otherwise
+ *-----------------------------------------------------------------------*/
+static int parseCommand(void)
+{
+ Token **argv = 0, *token;
+ int argc = 0;
+ int i;
+
+ token = getToken();
+ if (token->type == TOKEN_EOF)
+ return FALSE;
+ if (token->type != TOKEN_OPEN_PARENTHESIS)
+ parseError(token->line, "missing parenthesis");
+ xfree(token);
+
+ /* get command name and arguments */
+ while (TRUE) {
+ token = getToken();
+ if (token->type == TOKEN_EOF)
+ parseError(token->line, "reached EOF");
+ if (token->type == TOKEN_CLOSE_PARENTHESIS) {
+ xfree(token);
+ break;
+ }
+ argc++;
+ argv = (Token **)xrealloc(argv, sizeof(Token *) * argc);
+ if (argv == NULL)
+ FatalError("Out of memory");
+ argv[argc-1] = token;
+ }
+ if (argc == 0)
+ return TRUE;
+
+ /* call corresponding command procedure */
+ if (argv[0]->type != TOKEN_SYMBOL)
+ parseError(argv[0]->line, "command name required");
+ for (i = 0; i < NCOMMANDS; i++) {
+ if (strcasecmp(command[i].symbol, argv[0]->content.symbol) == 0) {
+ /* parse command */
+ command[i].proc(argc, argv);
+ break;
+ }
+ }
+ if (i == NCOMMANDS)
+ parseError(argv[0]->line, "unknown command `%s'",
+ argv[0]->content.symbol);
+
+ /* free arguments */
+ for (i = 0; i < argc; i++) {
+ if (argv[i]->type == TOKEN_SYMBOL)
+ xfree(argv[i]->content.symbol);
+ xfree(argv[i]);
+ }
+ xfree(argv);
+ return TRUE;
+}
+
+/*-------------------------------------------------------------------------
+ * function "checkArguments"
+ *
+ * purpose: examine the number of arguments and the type of each
+ * argument.
+ * argument: (int)n : correct number of arguments
+ * (enum TokenType *)type : table of types
+ * (int)argc_m1 : actual number of arguments
+ * (Token **)argv : command and arguments
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void checkArguments(int n, enum TokenType *type,
+ int argc_m1, Token **argv)
+{
+ int i;
+
+ if (argc_m1 < n)
+ parseError(argv[0]->line, "too few arguments to command `%s'",
+ argv[0]->content.symbol);
+ if (argc_m1 > n)
+ parseError(argv[0]->line, "too many arguments to command `%s'",
+ argv[0]->content.symbol);
+ for (i = 0; i < n; i++) {
+ if (argv[i+1]->type != type[i])
+ parseError(argv[i+1]->line,
+ "type mismatch. argument %d to command `%s'",
+ i+1, argv[0]->content.symbol);
+ }
+}
+
+typedef struct _Mode {
+ struct _Mode *next;
+ char *name;
+ int type;
+ int depth;
+ int class;
+ int width, height;
+ X68kFbReg reg;
+} Mode;
+
+Mode *modeList = NULL;
+
+/*-------------------------------------------------------------------------
+ * function "parseModeDef"
+ *
+ * purpose: define a mode
+ * argument: (int)argc, (Token **)argv : command and arguments
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void parseModeDef(int argc, Token **argv)
+{
+ enum TokenType argtype[] = {
+ /* name type depth class */
+ TOKEN_SYMBOL, TOKEN_SYMBOL, TOKEN_LITERAL, TOKEN_SYMBOL,
+ /* width height */
+ TOKEN_LITERAL, TOKEN_LITERAL,
+ /* register values */
+ TOKEN_LITERAL, TOKEN_LITERAL, TOKEN_LITERAL, TOKEN_LITERAL,
+ TOKEN_LITERAL, TOKEN_LITERAL, TOKEN_LITERAL, TOKEN_LITERAL,
+ TOKEN_LITERAL, TOKEN_LITERAL, TOKEN_LITERAL, TOKEN_LITERAL
+ };
+ Mode *mode;
+ char *symbol;
+ int class, width, height;
+
+ checkArguments(18, argtype, argc-1, argv);
+
+ mode = (Mode *)xalloc(sizeof(Mode));
+ if (mode == NULL)
+ FatalError("Out of memory");
+ mode->name = strdup(argv[1]->content.symbol);
+
+ /* parse frame buffer type */
+ symbol = argv[2]->content.symbol;
+ if (strcasecmp("Text", symbol) == 0)
+ mode->type = X68K_FB_TEXT;
+ else if (strcasecmp("Graphic", symbol) == 0)
+ mode->type = X68K_FB_GRAPHIC;
+ else
+ parseError(argv[2]->line, "unknown frame buffer type");
+ mode->depth = argv[3]->content.literal;
+
+ /* parse frame buffer class */
+ symbol = argv[4]->content.symbol;
+ if (strcasecmp("StaticGray", symbol) == 0)
+ mode->class = StaticGray;
+ else if (strcasecmp("GrayScale", symbol) == 0)
+ mode->class = GrayScale;
+ else if (strcasecmp("StaticColor", symbol) == 0)
+ mode->class = StaticColor;
+ else if (strcasecmp("PseudoColor", symbol) == 0)
+ mode->class = PseudoColor;
+ else if (strcasecmp("TrueColor", symbol) == 0)
+ mode->class = TrueColor;
+ else if (strcasecmp("DirectColor", symbol) == 0)
+ mode->class = DirectColor;
+ else
+ parseError(argv[4]->line, "unknown frame buffer class");
+
+ class = mode->class;
+ width = mode->width = argv[5]->content.literal;
+ height = mode->height = argv[6]->content.literal;
+
+ /* examine whether type, depth, class, width, and height are
+ a legal combination or not, and then set mode registers */
+ switch (mode->type) {
+ case X68K_FB_TEXT:
+ if (mode->depth == 1 && class == StaticGray &&
+ width <= 1024 && height <= 1024) {
+ mode->reg.videoc.r1 = 0x21e4;
+ mode->reg.videoc.r2 = 0x0020;
+ goto legal;
+ }
+ break;
+ case X68K_FB_GRAPHIC:
+ switch (mode->depth) {
+ case 4:
+ if ( (class == StaticGray || class == PseudoColor) &&
+ width <= 1024 && height <= 1024 ) {
+ mode->reg.videoc.r1 = 0x21e4;
+ mode->reg.videoc.r2 = 0x0010;
+ goto legal;
+ }
+ break;
+ case 8:
+ if (class == PseudoColor &&
+ width <= 512 && height <= 512) {
+ mode->reg.videoc.r1 = 0x21e4;
+ mode->reg.videoc.r2 = 0x0003;
+ goto legal;
+ }
+ break;
+ case 15:
+ if (class == TrueColor &&
+ width <= 512 && height <= 512) {
+ mode->reg.videoc.r1 = 0x21e4;
+ mode->reg.videoc.r2 = 0x000f;
+ goto legal;
+ }
+ break;
+ }
+ break;
+ }
+ parseError(argv[0]->line, "illegal combination of mode parameters");
+ legal:
+
+ /* store register values */
+ mode->reg.crtc.r00 = argv[7]->content.literal;
+ mode->reg.crtc.r01 = argv[8]->content.literal;
+ mode->reg.crtc.r02 = argv[9]->content.literal;
+ mode->reg.crtc.r03 = argv[10]->content.literal;
+ mode->reg.crtc.r04 = argv[11]->content.literal;
+ mode->reg.crtc.r05 = argv[12]->content.literal;
+ mode->reg.crtc.r06 = argv[13]->content.literal;
+ mode->reg.crtc.r07 = argv[14]->content.literal;
+ mode->reg.crtc.r08 = argv[15]->content.literal;
+ mode->reg.crtc.r20 = argv[16]->content.literal;
+ mode->reg.videoc.r0 = argv[17]->content.literal;
+ mode->reg.dotClock = argv[18]->content.literal;
+
+ /* set scroll registers to zero */
+ mode->reg.crtc.r12 = 0; mode->reg.crtc.r13 = 0;
+ mode->reg.crtc.r14 = 0; mode->reg.crtc.r15 = 0;
+ mode->reg.crtc.r16 = 0; mode->reg.crtc.r17 = 0;
+ mode->reg.crtc.r18 = 0; mode->reg.crtc.r19 = 0;
+
+ /* add new mode to linked mode list */
+ mode->next = modeList;
+ modeList = mode;
+}
+
+/*-------------------------------------------------------------------------
+ * function "parseMode"
+ *
+ * purpose: choose a mode from predefined modes
+ * argument: (int)argc, (Token **)argv : command and arguments
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void parseMode(int argc, Token **argv)
+{
+ enum TokenType argtype[]= { TOKEN_SYMBOL };
+ Mode *mode;
+
+ checkArguments(1, argtype, argc-1, argv);
+
+ /* search mode to set from mode list */
+ for (mode = modeList; mode != NULL; mode = mode->next) {
+ if (strcmp(mode->name, argv[1]->content.symbol) == 0)
+ break;
+ }
+ if (mode == NULL)
+ parseError(argv[1]->line, "undefined mode `%s'",
+ argv[1]->content.symbol);
+
+ x68kScreen[0].type = mode->type;
+ x68kScreen[0].depth = mode->depth;
+ x68kScreen[0].class = mode->class;
+ x68kScreen[0].dpi = 75;
+ x68kScreen[0].x68kreg = mode->reg;
+ x68kScreen[0].scr_width = mode->width;
+ x68kScreen[0].scr_height = mode->height;
+
+ switch (mode->type) {
+ /* for TVRAM frame buffer */
+ case X68K_FB_TEXT:
+ x68kFbProc[0].open = x68kTextOpen;
+ x68kFbProc[0].init = x68kTextInit;
+ x68kFbProc[0].close = x68kTextClose;
+ x68kScreen[0].fb_width = 1024;
+ x68kScreen[0].fb_height = 1024;
+ break;
+ /* for GVRAM frame buffer */
+ case X68K_FB_GRAPHIC:
+ x68kFbProc[0].open = x68kGraphOpen;
+ x68kFbProc[0].init = x68kGraphInit;
+ x68kFbProc[0].close = x68kGraphClose;
+ x68kFormat = (PixmapFormatRec*) xalloc (sizeof(PixmapFormatRec));
+ x68kFormat->scanlinePad = BITMAP_SCANLINE_PAD;
+ x68kFormat->bitsPerPixel = 16;
+ switch (mode->depth) {
+ case 4:
+ x68kFormat->depth = 4;
+ x68kScreen[0].fb_width = 1024;
+ x68kScreen[0].fb_height = 1024;
+ break;
+ case 8:
+ x68kFormat->depth = 8;
+ x68kScreen[0].fb_width = 512;
+ x68kScreen[0].fb_height = 512;
+ break;
+ case 15:
+ x68kFormat->depth = 15;
+ x68kScreen[0].fb_width = 512;
+ x68kScreen[0].fb_height = 512;
+ }
+ }
+ modeSet = TRUE;
+}
+
+/*-------------------------------------------------------------------------
+ * function "parseMouse"
+ *
+ * purpose: set mouse attribute.
+ * argument: (int)argc, (Token **)argv : command and arguments
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void parseMouse(int argc, Token **argv)
+{
+ enum TokenType argtype[] = { TOKEN_SYMBOL };
+
+ checkArguments(1, argtype, argc-1, argv);
+ /* only `standard' mouse allowed */
+ if (strcasecmp("standard", argv[1]->content.symbol) != 0)
+ parseError(argv[1]->line, "unknown mouse type `%s'",
+ argv[1]->content.symbol);
+}
+
+/*-------------------------------------------------------------------------
+ * function "parseKeyboard"
+ *
+ * purpose: select keyboard map
+ * argument: (int)argc, (Token **)argv : command and arguments
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void parseKeyboard(int argc, Token **argv)
+{
+ enum TokenType argtype[] = { TOKEN_SYMBOL };
+
+ checkArguments(1, argtype, argc-1, argv);
+ if (strcasecmp("standard", argv[1]->content.symbol) == 0) {
+ x68kKeySyms = &jisKeySyms;
+ x68kKbdPriv.type = X68K_KB_STANDARD;
+ } else if (strcasecmp("ascii", argv[1]->content.symbol) == 0) {
+ x68kKeySyms = &asciiKeySyms;
+ x68kKbdPriv.type = X68K_KB_ASCII;
+ } else
+ parseError(argv[1]->line, "unknown keyboard type `%s'",
+ argv[1]->content.symbol);
+}
+
+/*-------------------------------------------------------------------------
+ * function "parseError"
+ *
+ * purpose: print error message to stderr and abort Xserver.
+ * this uses the same procedure of the function "FatalError"
+ * argument: (int)line : the line in which some error was detected
+ * (char *)str : error message
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void parseError(int line, char *str, ...)
+{
+ va_list arglist;
+
+ fprintf(stderr, "%s:%d: ", configFilename, line);
+ if (str != NULL) {
+ va_start(arglist, str);
+ vfprintf(stderr, str, arglist);
+ va_end(arglist);
+ fputc('\n', stderr);
+ } else
+ fprintf(stderr, "parse error\n");
+ fflush(stderr);
+ if (CoreDump)
+ abort();
+ exit(1);
+}
+
+/* EOF x68kConfig.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kFb.c 2014-02-22 09:16:19.000000000 +0000
@@ -0,0 +1,182 @@
+/* $NetBSD: x68kFb.c,v 1.3 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+#include "x68k.h"
+
+static void x68kRegSetup(X68kScreenRec *pPriv);
+
+DevPrivateKeyRec x68kScreenPrivateKeyRec;
+int x68kGeneration;
+
+/*-------------------------------------------------------------------------
+ * function "x68kFbCommonOpen"
+ *
+ * purpose: open and map frame buffer, and obtain some FB-specific
+ * infomation. then set controller to approppriate mode as
+ * configured in X68kConfig.
+ * argument: (X68kScreenRec *)pPriv : X68k private screen record
+ * (char *)device : name of frame buffer device
+ * returns: (Bool): TRUE if succeeded
+ * FALSE otherwise
+ *-----------------------------------------------------------------------*/
+Bool x68kFbCommonOpen(X68kScreenRec *pPriv, char *device)
+{
+ struct grfinfo gi;
+
+ /* open frame buffer */
+ if ( ( pPriv->fd = open(device, O_RDWR, 0)) < 0) {
+ Error( "Can't open frame buffer" );
+ return FALSE;
+ }
+ /* get frame buffer infomation */
+ if ( ioctl( pPriv->fd, GRFIOCGINFO, &gi ) == -1 ) {
+ Error( "Can't get grfinfo" );
+ return FALSE;
+ }
+ pPriv->mapsize = gi.gd_regsize + gi.gd_fbsize;
+
+ /* map control registers and frame buffer */
+ pPriv->reg = (FbReg *)mmap(0, pPriv->mapsize, PROT_READ | PROT_WRITE,
+ MAP_FILE | MAP_SHARED, pPriv->fd, 0 );
+ if ( pPriv->reg == (FbReg *)-1) {
+ Error( "Can't map frame buffer" );
+ return FALSE;
+ }
+ pPriv->fb = (caddr_t)pPriv->reg + gi.gd_regsize;
+
+ x68kRegSetup( pPriv );
+
+ return TRUE;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kFbCommonClose"
+ *
+ * purpose: unmap and close frame buffer, and
+ * change video mode to normal ITE mode
+ * argument: (X68kScreenRec *)pPriv : X68k private screen record
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void x68kFbCommonClose(X68kScreenRec *pPriv)
+{
+ X68kFbReg graphNone = {
+ { 137,14, 28, 124,
+ 567, 5, 40, 552,
+ 27, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0, 0, 0, 0,
+ 0x0416, 0, 0, 0, 0 },
+ { 0x0004, 0x21e4, 0x0020 },
+ 0
+ };
+ /* change video mode */
+ pPriv->x68kreg = graphNone;
+ x68kRegSetup(pPriv);
+
+ /* unmap and close frame buffer */
+ if ( munmap((caddr_t)pPriv->reg, pPriv->mapsize) == -1 )
+ Error("Can't unmap frame buffer");
+ close(pPriv->fd);
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kRegSetup"
+ *
+ * purpose: set up CRT controller and Video controller
+ * with register values in pPriv->x68kreg
+ * argument: (X68kScreenRec *)pPriv : X68k private screen record
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+#define CRTCSET(r) pPriv->reg->crtc.r = pPriv->x68kreg.crtc.r
+#define VIDEOCSET(r) pPriv->reg->videoc.r = pPriv->x68kreg.videoc.r
+
+static void x68kRegSetup(X68kScreenRec *pPriv)
+{
+ u_short pr20 = pPriv->reg->crtc.r20;
+
+ /* timing registers */
+ if ( (pr20 & 0x0003) < (pPriv->x68kreg.crtc.r20 & 0x0003) ||
+ ( (pr20 & 0x0003) == (pPriv->x68kreg.crtc.r20 & 0x0003) &&
+ (pr20 & 0x0010) < (pPriv->x68kreg.crtc.r20 & 0x0010) ) ) {
+
+ /* to higher resolution */
+ CRTCSET(r00); CRTCSET(r01); CRTCSET(r02);CRTCSET(r03);
+ CRTCSET(r04); CRTCSET(r05); CRTCSET(r06);CRTCSET(r07);
+ CRTCSET(r20);
+ } else {
+ /* to lower resolution */
+ CRTCSET(r20); CRTCSET(r01); CRTCSET(r02);CRTCSET(r03);
+ CRTCSET(r04); CRTCSET(r05); CRTCSET(r06);CRTCSET(r07);
+ CRTCSET(r00);
+ }
+ CRTCSET(r08);
+
+ /* scroll registers */
+ CRTCSET(r12); CRTCSET(r13); CRTCSET(r14);CRTCSET(r15);
+ CRTCSET(r16); CRTCSET(r17); CRTCSET(r18);CRTCSET(r19);
+
+ /* mode controlling registers */
+ VIDEOCSET(r0); VIDEOCSET(r1); VIDEOCSET(r2);
+
+ /* dot clock bit */
+ pPriv->reg->sysport.r4 = (pPriv->x68kreg.dotClock)? 0x000e: 0x000c;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kSaveScreen" [ screen function ]
+ *
+ * purpose: activate/deactivate screen saver
+ * argument: (ScreenPtr)ipScreen : target screen to save
+ * (int)mode : on/off
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+Bool x68kSaveScreen(ScreenPtr pScreen, Bool on)
+{
+ X68kScreenRec *pPriv = x68kScreenPriv(pScreen);
+ static int status = FALSE;
+ static u_short r2;
+
+ if (on == SCREEN_SAVER_ON || on == SCREEN_SAVER_CYCLE) {
+ if (!status) {
+ r2 = pPriv->reg->videoc.r2;
+ pPriv->reg->videoc.r2 = 0x0000;
+ status = TRUE;
+ }
+ } else {
+ if (status) {
+ pPriv->reg->videoc.r2 = r2;
+ status = FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/* EOF x68kFb.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kGraph.c 2014-02-22 09:17:46.000000000 +0000
@@ -0,0 +1,508 @@
+/* $NetBSD: x68kGraph.c,v 1.5 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+/* $XConsortium: sunCfb.c,v 1.15.1.2 95/01/12 18:54:42 kaleb Exp $ */
+
+/*
+Copyright (c) 1990 X Consortium
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of the X Consortium shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from the X Consortium.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+/*
+ * Copyright (c) 1987 by the Regents of the University of California
+ * Copyright (c) 1987 by Adam de Boor, UC Berkeley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/****************************************************************/
+/* Modified from sunCG4C.c for X11R3 by Tom Jarmolowski */
+/****************************************************************/
+
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "x68k.h"
+#include "mi.h"
+#include "micmap.h"
+
+#include "fb.h"
+
+/* local functions */
+static Bool x68kCfbFinishScreenInit(ScreenPtr pScreen, pointer pbits,
+ int xsize, int ysize,
+ int dpix, int dpiy, int width);
+static void x68kInstallColormap(ColormapPtr cmap);
+static void x68kUninstallColormap(ColormapPtr cmap);
+static int x68kListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapList);
+static void x68kStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs);
+
+static void x68kUpdateColormap(ScreenPtr pScreen, int dex, int count,
+ u_char *rmap, u_char *gmap, u_char *bmap);
+
+/*-------------------------------------------------------------------------
+ * function "x68kGraphOpen" [ X68kFBProc function ]
+ *
+ * purpose: call common frame buffer opening procedure
+ * then set hardware colormap for several static color modes.
+ * argument: (X68kScreenRec *)pPriv : X68k private screen record
+ * returns: (Bool): TRUE if successed
+ * FALSE otherwise
+ *-----------------------------------------------------------------------*/
+Bool x68kGraphOpen(X68kScreenRec *pPriv)
+{
+ if( !x68kFbCommonOpen(pPriv, "/dev/grf1") )
+ return FALSE;
+
+ /* initialize hardware colormap
+ in cases of static visual class */
+ if (pPriv->depth == 15 && pPriv->class == TrueColor) {
+ /* for 32768 TrueColor mode */
+ int i;
+ u_short x = 0x0001;
+ for ( i = 0; i < 256; ) {
+ pPriv->reg->gpal[i++] = x;
+ pPriv->reg->gpal[i++] = x;
+ x += 0x0202;
+ }
+ }
+ if (pPriv->depth == 4 && pPriv->class == StaticGray ) {
+ /* for 16 StaticGray mode */
+ int i;
+ for( i = 0; i < 16; i++ )
+ pPriv->reg->gpal[i] = (i*2 << 11) | (i*2 << 6) | (i*2 << 1);
+ }
+ return TRUE;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kGraphClose" [ X68kFBProc function ]
+ *
+ * purpose: close graphic frame buffer
+ * argument: (X68kScreenRec *)pPriv : X68k private screen record
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void x68kGraphClose(X68kScreenRec *pPriv)
+{
+ x68kFbCommonClose(pPriv);
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kGraphInit" [ called by DIX AddScreen ]
+ *
+ * purpose: initialize graphic frame buffer
+ * argument: (int)screen : screen index
+ * (ScreenPtr)pScreen : DIX screen record
+ * (int)argc, (char **)argv : standard C arguments
+ * returns: (Bool) : TRUE if succeeded
+ * FALSE otherwise
+ *-----------------------------------------------------------------------*/
+Bool x68kGraphInit(int screen, ScreenPtr pScreen, int argc, char *argv[])
+{
+ X68kScreenRec *pPriv;
+
+ /* get private screen record set by X68KConfig */
+ pPriv = x68kGetScreenRecByType(X68K_FB_GRAPHIC);
+
+ /* store private record into screen */
+ if ( x68kGeneration != serverGeneration ) {
+ if ( !dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof(X68kScreenRec))) {
+ Error("dixRegisterPrivateKey failed");
+ return FALSE;
+ }
+ x68kGeneration = serverGeneration;
+ }
+
+ /* register normal cfb screen functions */
+ if (!fbSetupScreen(pScreen, pPriv->fb,
+ pPriv->scr_width, pPriv->scr_height,
+ pPriv->dpi, pPriv->dpi, pPriv->fb_width,
+ pPriv->depth)) {
+ ErrorF ("%s - fbSetupScreen failed\n", __func__);
+ return FALSE;
+ }
+
+ /* register colormap functions */
+ pScreen->InstallColormap = x68kInstallColormap;
+ pScreen->UninstallColormap = x68kUninstallColormap;
+ pScreen->ListInstalledColormaps = x68kListInstalledColormaps;
+ pScreen->StoreColors = x68kStoreColors;
+
+ /* visual initialization and etc.. */
+ if (!x68kCfbFinishScreenInit(pScreen, pPriv->fb,
+ pPriv->scr_width, pPriv->scr_height,
+ pPriv->dpi, pPriv->dpi, pPriv->fb_width))
+ return FALSE;
+
+ if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) )
+ return FALSE;
+
+ pScreen->whitePixel = 1;
+ pScreen->blackPixel = 0;
+ if ( !miCreateDefColormap(pScreen) )
+ return FALSE;
+
+ return TRUE;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kCfbFinishScreenInit"
+ *
+ * purpose: initialize visuals and perform miscellaneous settings
+ * argument: (ScreenPtr)pScreen : DIX screen record
+ * (pointer)pbits : frame buffer
+ * (int)xsize, (int)ysize : screen size
+ * (int)dpix, (int)dpiy : screen resolution in dots per inch
+ * (int)width : pixel width of frame buffer
+ * returns: (Bool) : TRUE if succeeded
+ * FALSE otherwise
+ *-----------------------------------------------------------------------*/
+static Bool x68kCfbFinishScreenInit(
+ ScreenPtr pScreen,
+ pointer pbits,
+ int xsize, int ysize,
+ int dpix, int dpiy,
+ int width)
+{
+ X68kScreenRec *pPriv = x68kScreenPriv(pScreen);
+ pointer oldDevPrivate;
+ VisualPtr visuals;
+ int nvisuals;
+ DepthPtr depths;
+ int ndepths;
+ VisualID defaultVisual;
+ int rootdepth = 0;
+
+ /* for 15/16bit TrueColor visual mode */
+ if (pPriv->depth == 15 && pPriv->class == TrueColor) {
+ VisualID *vid = NULL;
+
+ ndepths = 1;
+ nvisuals = 1;
+ depths = (DepthPtr)xalloc( sizeof(DepthRec) );
+ visuals = (VisualPtr)xalloc( sizeof(VisualRec) );
+ vid = (VisualID *)xalloc( sizeof(VisualID) );
+ if( !depths || !visuals || !vid ) {
+ xfree( depths );
+ xfree( visuals );
+ xfree( vid );
+ return FALSE;
+ }
+ depths[0].depth = 15;
+ depths[0].numVids = 1;
+ depths[0].vids = vid;
+ visuals[0].class = TrueColor;
+ visuals[0].bitsPerRGBValue = 5;
+ visuals[0].ColormapEntries = 1 << 5;
+ visuals[0].nplanes = 15;
+ visuals[0].vid = *vid = FakeClientID(0);
+ visuals[0].greenMask = 0xf800;
+ visuals[0].redMask = 0x07c0;
+ visuals[0].blueMask = 0x003e;
+ visuals[0].offsetGreen = 11;
+ visuals[0].offsetRed = 6;
+ visuals[0].offsetBlue = 1;
+ rootdepth = 15;
+ defaultVisual = *vid;
+ }
+ /* for 4/16bit StaticGray visual mode */
+ else if (pPriv->depth == 4 && pPriv->class == StaticGray ) {
+ VisualID *vid = NULL;
+
+ ndepths = 1;
+ nvisuals = 1;
+ depths = (DepthPtr)xalloc( sizeof(DepthRec) );
+ visuals = (VisualPtr)xalloc( sizeof(VisualRec) );
+ vid = (VisualID *)xalloc( sizeof(VisualID) );
+ if( !depths || !visuals || !vid ) {
+ xfree( depths );
+ xfree( visuals );
+ xfree( vid );
+ return FALSE;
+ }
+ depths[0].depth = 4;
+ depths[0].numVids = 1;
+ depths[0].vids = vid;
+ visuals[0].class = StaticGray;
+ visuals[0].bitsPerRGBValue = 4;
+ visuals[0].ColormapEntries = 1 << 4;
+ visuals[0].nplanes = 4;
+ visuals[0].vid = *vid = FakeClientID(0);
+ visuals[0].greenMask = 0;
+ visuals[0].redMask = 0;
+ visuals[0].blueMask = 0;
+ visuals[0].offsetGreen = 0;
+ visuals[0].offsetRed = 0;
+ visuals[0].offsetBlue = 0;
+ rootdepth = 4;
+ defaultVisual = *vid;
+ }
+ /* for other modes ( supports all visuals ) */
+ else if (!miInitVisuals(&visuals, &depths, &nvisuals, &ndepths,
+ &rootdepth, &defaultVisual, 1 << (16 - 1),
+ 5, PseudoColor))
+ return FALSE;
+
+ oldDevPrivate = pScreen->devPrivate;
+ if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width,
+ rootdepth, ndepths, depths,
+ defaultVisual, nvisuals, visuals))
+ return FALSE;
+
+ pScreen->CloseScreen = fbCloseScreen;
+ pScreen->SaveScreen = x68kSaveScreen;
+ miInitializeBackingStore (pScreen);
+#if 0 /* XXX FORCE_SEPARATE_PRIVATE */
+ pScreen->CreateScreenResources = cfb16CreateScreenResources;
+ pScreen->devPrivates[cfb16ScreenPrivateIndex].ptr =
+ pScreen->devPrivate;
+ pScreen->devPrivate = oldDevPrivate;
+#endif
+
+ return TRUE;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kInstallColormap" [ screen function ]
+ *
+ * purpose: install colormap, then update hardware colormap.
+ * argument: (ColormapPtr)cmap : colormap to install
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void x68kInstallColormap(ColormapPtr cmap)
+{
+ X68kScreenRec *pPriv = x68kScreenPriv(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 == pPriv->installedMap)
+ return;
+ if (pPriv->installedMap)
+ WalkTree(pPriv->installedMap->pScreen, TellLostMap,
+ (pointer) &(pPriv->installedMap->mid));
+
+ if (pPriv->class & DynamicClass) {
+ if ((cmap->pVisual->class | DynamicClass) == DirectColor) {
+ rMask = pVisual->redMask;
+ gMask = pVisual->greenMask;
+ bMask = pVisual->blueMask;
+ oRed = pVisual->offsetRed;
+ oGreen = pVisual->offsetGreen;
+ oBlue = pVisual->offsetBlue;
+ for (i = 0; i < 1<<(pPriv->depth); i++) {
+ rmap[i] = cmap->red[(i & rMask) >> oRed].co.local.red >> 11;
+ gmap[i] = cmap->green[(i & gMask) >> oGreen].co.local.green >> 11;
+ bmap[i] = cmap->blue[(i & bMask) >> oBlue].co.local.blue >> 11;
+ }
+ } else {
+ for (i = 0, pent = cmap->red;
+ i < pVisual->ColormapEntries;
+ i++, pent++) {
+ if (pent->fShared) {
+ rmap[i] = pent->co.shco.red->color >> 11;
+ gmap[i] = pent->co.shco.green->color >> 11;
+ bmap[i] = pent->co.shco.blue->color >> 11;
+ }
+ else {
+ rmap[i] = pent->co.local.red >> 11;
+ gmap[i] = pent->co.local.green >> 11;
+ bmap[i] = pent->co.local.blue >> 11;
+ }
+ }
+ }
+ x68kUpdateColormap(cmap->pScreen, 0, 1<<(pPriv->depth), rmap, gmap, bmap);
+ }
+ pPriv->installedMap = cmap;
+ WalkTree(cmap->pScreen, TellGainedMap, (pointer) &(cmap->mid));
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kUninstallColormap" [ screen function ]
+ *
+ * purpose: uninstall colormap
+ * argument: (ColormapPtr)cmap : colormap to uninstall
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void x68kUninstallColormap(ColormapPtr cmap)
+{
+ X68kScreenRec *pPriv = x68kScreenPriv(cmap->pScreen);
+
+ if (cmap == pPriv->installedMap) {
+ Colormap defMapID = cmap->pScreen->defColormap;
+
+ if (cmap->mid != defMapID) {
+ ColormapPtr defMap = (ColormapPtr) LookupIDByType(defMapID,
+ RT_COLORMAP);
+ (*cmap->pScreen->InstallColormap)(defMap);
+ }
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kListInstalledColormaps" [ screen function ]
+ *
+ * purpose: Get the list of currently installed colormaps.
+ * In X68k, installed colormap in always only one.
+ * argument: (ScreenPtr)pScreen : screen
+ * (Colormap *)pCmapList : colormap list got
+ * returns: (int)
+ *-----------------------------------------------------------------------*/
+static int x68kListInstalledColormaps(ScreenPtr pScreen, Colormap *pCmapList)
+{
+ X68kScreenRec *pPriv = x68kScreenPriv(pScreen);
+ *pCmapList = pPriv->installedMap->mid;
+ return 1;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kStoreColors" [ screen function ]
+ *
+ * purpose: store specified color items
+ * argument: (ColormapPtr)pmap : colormap
+ * (int)ndef : the number of items
+ * (xColorItem *)pdefs : items
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void x68kStoreColors(ColormapPtr pmap, int ndef, xColorItem *pdefs)
+{
+ X68kScreenRec *pPriv = x68kScreenPriv(pmap->pScreen);
+ u_char rmap[256], gmap[256], bmap[256];
+ xColorItem expanddefs[256];
+ register int i;
+
+ if (pPriv->installedMap != NULL && pPriv->installedMap != pmap)
+ return;
+ if ((pmap->pVisual->class | DynamicClass) == DirectColor) {
+ ndef = fbExpandDirectColors(pmap, ndef, pdefs, expanddefs);
+ pdefs = expanddefs;
+ }
+ while (ndef--) {
+ i = pdefs->pixel;
+ rmap[i] = pdefs->red >> 11;
+ gmap[i] = pdefs->green >> 11;
+ bmap[i] = pdefs->blue >> 11;
+ x68kUpdateColormap(pmap->pScreen, i, 1, rmap, gmap, bmap);
+ pdefs++;
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kUpdateColormap"
+ *
+ * purpose: update hardware colormap
+ * argument: (ScreenPtr)pScreen: screen
+ * (int)dex : colormap index
+ * (int)count : count for updating
+ * (u_char *)[rgb]map: each map
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void x68kUpdateColormap(ScreenPtr pScreen, int dex, int count,
+ u_char *rmap, u_char *gmap, u_char *bmap)
+{
+ X68kScreenRec *pPriv = x68kScreenPriv(pScreen);
+ volatile u_short *pal = pPriv->reg->gpal;
+
+ for( ; count > 0; count--,dex++ ) {
+ pal[dex] = (u_short)gmap[dex] << 11 |
+ (u_short)rmap[dex] << 6 |
+ (u_short)bmap[dex] << 1;
+ }
+}
+
+/* EOF x68kGraph.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kInit.c 2014-02-21 19:20:03.000000000 +0000
@@ -0,0 +1,231 @@
+/* $NetBSD: x68kInit.c,v 1.7 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+/*
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+*******************************************************/
+
+#include "Xos.h"
+#include "x68k.h"
+#include "mi.h"
+
+static int nscreens;
+
+void OsVendorInit(void)
+{
+}
+
+EventList *x68kEvents = NULL;
+
+/*-------------------------------------------------------------------------
+ * function "InitOutput" [ called by DIX ]
+ *
+ * purpose: initialize outputs ( screens )
+ * argument: (ScreenInfo *)pScreenInfo : screen info struct
+ * (int)argc, (char *)argv : standard arguments
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void InitOutput(ScreenInfo *pScreenInfo,
+ int argc,
+ char *argv[])
+{
+ int i;
+ X68kScreenRec *screen;
+ X68kFbProcRec *fb;
+
+ pScreenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
+ pScreenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
+ pScreenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
+ pScreenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
+
+ /* read configuration file */
+ nscreens = x68kConfig();
+
+ /* register pixmap formats */
+ x68kRegisterPixmapFormats(pScreenInfo);
+
+ /* open and initialize frame buffer for each screen */
+ for (i = 0; i < nscreens; i++) {
+ screen = x68kGetScreenRec(i);
+ fb = x68kGetFbProcRec(i);
+ if ( !(*fb->open)(screen) )
+ return;
+ if ( AddScreen(fb->init, argc, argv) < 0 )
+ FatalError("AddScreen failed\n");
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * function "InitInput" [ called by DIX ]
+ *
+ * purpose: initialize inputs ( keyboard and mouse )
+ * argument: (int)argc, (char *)argv : standard arguments
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void InitInput(int argc, char *argv[])
+{
+ int rc;
+ rc = AllocDevicePair(serverClient, "Xnest",
+ &x68kPointerDevice,
+ &x68kKeyboardDevice,
+ x68kMouseProc,
+ x68kKbdProc,
+ FALSE);
+
+ GetEventList(&x68kEvents);
+
+ if ( !mieqInit() )
+ FatalError("mieqInit failed\n");
+
+ /* setup SIGIO handler for asynchronous event handling */
+ (void)OsSignal(SIGIO, x68kSigIOHandler);
+}
+
+void
+CloseInput(void)
+{
+}
+
+/*-------------------------------------------------------------------------
+ * function "AbortDDX" [ called by OS ]
+ *
+ * purpose: free signal handler and close frame buffers
+ * argument: nothing
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void AbortDDX(void)
+{
+ int i;
+ X68kScreenRec *screen;
+ X68kFbProcRec *fb;
+
+ /* give up SIGIO handling */
+ (void) OsSignal(SIGIO, SIG_IGN);
+
+ /* close all frame buffers */
+ for (i = 0; i < nscreens; i++) {
+ screen = x68kGetScreenRec(i);
+ fb = x68kGetFbProcRec(i);
+ (*fb->close)(screen);
+ }
+}
+
+/*-------------------------------------------------------------------------
+ * function "ddxGiveUp" [ called by DIX ]
+ *
+ * purpose: do nothing but call AbortDDX.
+ * argument: nothing
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void ddxGiveUp(void)
+{
+ AbortDDX();
+}
+
+/*-------------------------------------------------------------------------
+ * function "ddxProcessArgument" [ called by OS ]
+ *
+ * purpose: process X68k dependent arguments
+ * currently only `x68kconfig' will be recognized.
+ * argument: (int)argc, (char **)argv: standard C arguments
+ * (int)i : index of current argument
+ * returns: number of arguments eaten
+ *-----------------------------------------------------------------------*/
+int ddxProcessArgument(int argc, char *argv[], int i)
+{
+
+ if (strcmp(argv[i], "-x68kconfig") == 0) {
+ if (++i >= argc)
+ UseMsg();
+ configFilename = strdup(argv[i]);
+ return 2;
+ }
+ return 0;
+}
+
+/*-------------------------------------------------------------------------
+ * function "ddxUseMsg" [ called by OS ]
+ *
+ * purpose: print X68k dependent usage
+ * argument: nothing
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void ddxUseMsg(void)
+{
+ ErrorF("\nX68k dependent options\n");
+ ErrorF("-x68kconfig filename specify configuration file\n");
+}
+
+void OsVendorFatalError(void)
+{
+}
+
+/* EOF x68kInit.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kIo.c 2014-02-22 02:29:11.000000000 +0000
@@ -0,0 +1,196 @@
+/* $NetBSD: x68kIo.c,v 1.4 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+/*-
+ *
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ *
+ *
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#include "x68k.h"
+#include "mi.h"
+
+static void x68kEnqueueEvents(void);
+
+/*--------------------------------------------------------------------
+ * function "x68kSigIOHandler"
+ *
+ * purpose: handles signals from input devices.
+ * enqueue inputs into mi event queue
+ * argument: (int)sig
+ * returns: nothing
+ *------------------------------------------------------------------*/
+void x68kSigIOHandler(sig)
+int sig;
+{
+ int olderrno = errno;
+
+ x68kEnqueueEvents();
+ errno = olderrno;
+}
+
+/*--------------------------------------------------------------------
+ * ProcessInputEvents --
+ * Retrieve all waiting input events and pass them to DIX in their
+ * correct chronological order. Only reads from the system pointer
+ * and keyboard.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Events are passed to the DIX layer.
+ *
+ *-----------------------------------------------------------------*/
+void ProcessInputEvents(void)
+{
+ (void) mieqProcessInputEvents ();
+// miPointerUpdateSprite ();
+}
+
+/*--------------------------------------------------------------------
+ * x68kEnqueueEvents
+ * When a SIGIO is received, read device hard events and
+ * enqueue them using the mi event queue
+ */
+
+static void x68kEnqueueEvents(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;
+ X68kKbdPrivPtr kbdPriv;
+ X68kMousePrivPtr ptrPriv;
+
+ pPointer = inputInfo.pointer;
+ pKeyboard = inputInfo.keyboard;
+ ptrPriv = (X68kMousePrivPtr) pPointer->public.devicePrivate;
+ kbdPriv = (X68kKbdPrivPtr) pKeyboard->public.devicePrivate;
+ if (!pPointer->public.on || !pKeyboard->public.on)
+ return;
+
+ numPtrEvents = 0;
+ PtrAgain = TRUE;
+ numKbdEvents = 0;
+ KbdAgain = TRUE;
+ ptrEvents = NULL; /* XXX gcc */
+ kbdEvents = NULL; /* XXX gcc */
+
+ /*
+ * 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 = x68kMouseGetEvents (ptrPriv->fd, &nPE, &PtrAgain);
+ numPtrEvents = nPE;
+ }
+ if ((numKbdEvents == 0) && KbdAgain) {
+ kbdEvents = x68kKbdGetEvents (kbdPriv->fd, &nKE, &KbdAgain);
+ numKbdEvents = nKE;
+ }
+ if ((numPtrEvents == 0) && (numKbdEvents == 0))
+ break;
+ if (numPtrEvents && numKbdEvents) {
+ if (timercmp (&kbdEvents->time, &ptrEvents->time, <)) {
+ x68kKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ x68kMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ } else if (numKbdEvents) {
+ x68kKbdEnqueueEvent (pKeyboard, kbdEvents);
+ numKbdEvents--;
+ kbdEvents++;
+ } else {
+ x68kMouseEnqueueEvent (pPointer, ptrEvents);
+ numPtrEvents--;
+ ptrEvents++;
+ }
+ }
+}
+
+/* EOF x68kIo.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKbd.c 2014-02-22 09:18:17.000000000 +0000
@@ -0,0 +1,391 @@
+/* $NetBSD: x68kKbd.c,v 1.5 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+
+#include "x68k.h"
+#include "mi.h"
+
+#include <X11/X.h>
+#include <X11/Xproto.h>
+#include <X11/keysym.h>
+#include "screenint.h"
+#include "inputstr.h"
+#include "misc.h"
+#include "scrnintstr.h"
+#include "servermd.h"
+
+#include <X11/extensions/XKB.h>
+#include "xkbsrv.h"
+
+#define MIN_KEYCODE 7 /* necessary to avoid the mouse buttons */
+#define MAX_KEYCODE 255 /* limited by the protocol */
+
+X68kKbdPriv x68kKbdPriv;
+DeviceIntPtr x68kKeyboardDevice = NULL;
+
+static void x68kInitModMap(KeySymsRec *, CARD8 *);
+#if 0
+static void x68kInitKbdNames(XkbComponentNamesRec *, X68kKbdPrivPtr);
+#endif
+static void x68kKbdBell(int, DeviceIntPtr, pointer, int);
+static void x68kKbdCtrl(DeviceIntPtr, KeybdCtrl *);
+static void x68kSetLeds(X68kKbdPrivPtr, u_char);
+
+/*------------------------------------------------------------------------
+ * x68kKbdProc --
+ * Handle the initialization, etc. of a keyboard.
+ *
+ * Results:
+ * None.
+ *
+ *----------------------------------------------------------------------*/
+int x68kKbdProc(DeviceIntPtr pDev, /* Keyboard to manipulate */
+ int what) /* What to do to it */
+{
+ DevicePtr pKeyboard = &pDev->public;
+ CARD8 x68kModMap[MAP_LENGTH];
+ int mode;
+#if 0
+ XkbRMLVOSet rmlvo;
+#endif
+
+ switch (what) {
+ case DEVICE_INIT:
+ pKeyboard->devicePrivate = (pointer)&x68kKbdPriv;
+ if( (x68kKbdPriv.fd = open("/dev/kbd", O_RDONLY)) == -1 ) {
+ Error("Can't open keyboard device");
+ return !Success;
+ }
+ pKeyboard->on = FALSE;
+ x68kInitModMap(x68kKeySyms, x68kModMap);
+
+#if 0
+ x68kInitKbdNames(&rmlvo, pKeyboard->devicePrivate);
+#endif
+ InitKeyboardDeviceStruct(pDev, NULL,
+ x68kKbdBell, x68kKbdCtrl);
+ XkbApplyMappingChange(pDev, x68kKeySyms,
+ x68kKeySyms->minKeyCode,
+ x68kKeySyms->maxKeyCode - x68kKeySyms->minKeyCode + 1,
+ x68kModMap, serverClient);
+ break;
+
+ case DEVICE_ON:
+ mode = 1;
+ if ( fcntl(x68kKbdPriv.fd, F_SETOWN, getpid()) == -1 ||
+ fcntl(x68kKbdPriv.fd, F_SETFL, O_NONBLOCK|O_ASYNC) == -1 ||
+ ioctl(x68kKbdPriv.fd, KIOCSDIRECT, &mode) == -1 ) {
+ Error("Async keyboard I/O failed");
+ return !Success;
+ }
+ x68kSetLeds(&x68kKbdPriv, (u_char)x68kKbdPriv.leds);
+ (void) AddEnabledDevice(x68kKbdPriv.fd);
+ pKeyboard->on = TRUE;
+ break;
+
+ case DEVICE_CLOSE:
+ case DEVICE_OFF:
+ RemoveEnabledDevice(x68kKbdPriv.fd);
+ pKeyboard->on = FALSE;
+ break;
+ default:
+ FatalError("Unknown keyboard operation\n");
+ }
+ return Success;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kInitModMap"
+ *
+ * purpose: initialize modmap with keysym table
+ * argument: (KeySymsRec *)x68kKeySyms : keysym table
+ * (CARD8 *)x68kModMap : result
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void x68kInitModMap(KeySymsRec *KeySyms, CARD8 *x68kModMap)
+{
+ int i;
+
+ for (i = 0; i < MAP_LENGTH; i++)
+ x68kModMap[i] = NoSymbol;
+ if (KeySyms->minKeyCode < MIN_KEYCODE) {
+ KeySyms->minKeyCode += MIN_KEYCODE;
+ KeySyms->maxKeyCode += MIN_KEYCODE;
+ }
+#if 0
+ if (KeySyms->maxKeyCode > MAX_KEYCODE)
+ KeySyms->maxKeyCode += MAX_KEYCODE;
+#endif
+ for (i = KeySyms->minKeyCode;
+ i < KeySyms->maxKeyCode; i++) {
+ switch (KeySyms->map[(i-KeySyms->minKeyCode)*4]) {
+ case XK_Shift_L:
+ case XK_Shift_R:
+ x68kModMap[i] = ShiftMask;
+ break;
+ case XK_Control_L:
+ case XK_Control_R:
+ x68kModMap[i] = ControlMask;
+ break;
+ case XK_Alt_L:
+ case XK_Alt_R:
+ x68kModMap[i] = Mod1Mask;
+ break;
+ case XK_Meta_L:
+ case XK_Meta_R:
+ x68kModMap[i] = Mod2Mask;
+ break;
+ case XK_Caps_Lock:
+ x68kModMap[i] = LockMask;
+ break;
+ }
+ }
+}
+
+#if 0
+/*-------------------------------------------------------------------------
+ * function "x68kInitKbdNames"
+ *
+ * purpose: store xkb database names
+ * argument: (XkbComponentNamesRec *)names
+ * (X68kKbdPrivPtr)pKbd
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void x68kInitKbdNames(XkbComponentNamesRec* names, X68kKbdPrivPtr pKbd)
+{
+ names->keymap = NULL;
+ names->types = "types/complete";
+ names->compat = "compat/complete";
+ switch (pKbd->type) {
+ case X68K_KB_STANDARD:
+ names->keycodes = "keycodes/x68k(x68k)";
+ names->geometry = "geometry/sharp(x68k)";
+ names->symbols = "symbols/sharp/jp(standard)";
+ break;
+ case X68K_KB_ASCII:
+ names->keycodes = "keycodes/x68k(x68k)";
+ names->geometry = "geometry/sharp(x68k)";
+ names->symbols = "symbols/sharp/jp(ascii)";
+ break;
+ }
+}
+#endif
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kKbdGetEvents --
+ * 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* x68kKbdGetEvents(int fd, int *pNumEvents, Bool *pAgain)
+{
+ int nBytes; /* number of bytes of events available. */
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+
+ if ((nBytes = read (fd, evBuf, sizeof(evBuf))) == -1) {
+ if (errno == EWOULDBLOCK) {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ } else {
+ Error("Reading keyboard");
+ FatalError ("Could not read the keyboard");
+ }
+ } else {
+ *pNumEvents = nBytes / sizeof (Firm_event);
+ *pAgain = (nBytes == sizeof (evBuf));
+ }
+ return evBuf;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kKbdEnqueueEvent --
+ *
+ *-----------------------------------------------------------------------
+ */
+void x68kKbdEnqueueEvent(DeviceIntPtr pDev, Firm_event *fe)
+{
+ BYTE keycode;
+ int type;
+ int i, nevents;
+
+ GetEventList(&x68kEvents);
+ type = ((fe->value == VKEY_UP) ? KeyRelease : KeyPress);
+ keycode = (fe->id & 0x7f) + MIN_KEYCODE;
+ nevents = GetKeyboardEvents(x68kEvents, pDev, type, keycode);
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(pDev, (InternalEvent*)(x68kEvents + i)->event);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kKbdBell --
+ * Ring the terminal/keyboard bell
+ *
+ * Results:
+ * Ring the keyboard bell for an amount of time proportional to
+ * "loudness."
+ *
+ * Side Effects:
+ * None, really...
+ *
+ *-----------------------------------------------------------------------
+ */
+
+static void x68kKbdBell(int percent, DeviceIntPtr pDev,
+ pointer ctrl, int unused )
+{
+ int kbdCmd; /* Command to give keyboard */
+ KeybdCtrl* kctrl = (KeybdCtrl*) ctrl;
+ X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate;
+
+ if (percent == 0 || kctrl->bell == 0)
+ return;
+
+ kbdCmd = KBD_CMD_BELL;
+ if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1) {
+ Error("Failed to activate bell");
+ return;
+ }
+ usleep (kctrl->bell_duration * 1000);
+ kbdCmd = KBD_CMD_NOBELL;
+ if (ioctl (pPriv->fd, KIOCCMD, &kbdCmd) == -1)
+ Error("Failed to deactivate bell");
+}
+
+void
+DDXRingBell(int volume, int pitch, int duration)
+{
+ /* XXX */
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kKbdCtrl --
+ * Alter some of the keyboard control parameters
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Some...
+ *
+ *-----------------------------------------------------------------------
+ */
+#define XKB_LED_ZENKAKU 0x40
+#define XKB_LED_HIRAGANA 0x20
+#define XKB_LED_INSERT 0x10
+#define XKB_LED_CAPS_LOCK 0x08
+#define XKB_LED_CODE_INPUT 0x04
+#define XKB_LED_ROMAJI 0x02
+#define XKB_LED_KANA_LOCK 0x01
+
+static void x68kKbdCtrl (DeviceIntPtr pDev, KeybdCtrl *ctrl)
+{
+ X68kKbdPrivPtr pPriv = (X68kKbdPrivPtr)pDev->public.devicePrivate;
+
+#ifdef XKB
+ if (pPriv->leds != ctrl->leds) {
+ x68kSetLeds(pPriv, (u_char)ctrl->leds);
+ pPriv->leds = ctrl->leds;
+ }
+#endif
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kSetLeds"
+ *
+ * purpose: set keyboard leds to specified state
+ * argument: (X68kKbdPrivPtr)pPriv
+ * (u_char)data;
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+static void x68kSetLeds(X68kKbdPrivPtr pPriv, u_char data)
+{
+ /* bit sequence of led indicator in xkb and hardware are same */
+ if (ioctl(pPriv->fd, KIOCSLED, &data) == -1)
+ Error("Failed to set keyboard lights");
+}
+
+Bool LegalModifier(unsigned int key, DeviceIntPtr pDev)
+{
+ return TRUE;
+}
+
+/* EOF x68kKbd.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kKeyMap.c 2014-02-21 18:48:42.000000000 +0000
@@ -0,0 +1,290 @@
+/* $NetBSD: x68kKeyMap.c,v 1.1.1.1 2004/01/07 12:51:44 minoura Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+#include "x68k.h"
+
+/*-------------------------------------------------------------------------
+ * x68k standard keyboard map
+ *-----------------------------------------------------------------------*/
+static KeySym jisKeymap[] = {
+ /* normal shifted kana kana, shifted */
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 0x01 */
+ XK_1, XK_exclam, XK_kana_NU, NoSymbol, /* 0x02 */
+ XK_2, XK_quotedbl, XK_kana_FU, NoSymbol, /* 0x03 */
+ XK_3, XK_numbersign, XK_kana_A, XK_kana_a, /* 0x04 */
+ XK_4, XK_dollar, XK_kana_U, XK_kana_u, /* 0x05 */
+ XK_5, XK_percent, XK_kana_E, XK_kana_e, /* 0x06 */
+ XK_6, XK_ampersand, XK_kana_O, XK_kana_o, /* 0x07 */
+ XK_7, XK_quoteright, XK_kana_YA, XK_kana_ya, /* 0x08 */
+ XK_8, XK_parenleft, XK_kana_YU, XK_kana_yu, /* 0x09 */
+ XK_9, XK_parenright, XK_kana_YO, XK_kana_yo, /* 0x0a */
+ XK_0, NoSymbol, XK_kana_WA, XK_kana_WO, /* 0x0b */
+ XK_minus, XK_equal, XK_kana_HO, NoSymbol, /* 0x0c */
+ XK_asciicircum, XK_asciitilde, XK_kana_HE, NoSymbol, /* 0x0d */
+ XK_backslash, XK_bar, XK_prolongedsound, NoSymbol, /* 0x0e */
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 0x0f */
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 0x10 */
+ XK_Q, NoSymbol, XK_kana_TA, NoSymbol, /* 0x11 */
+ XK_W, NoSymbol, XK_kana_TE, NoSymbol, /* 0x12 */
+ XK_E, NoSymbol, XK_kana_I, XK_kana_i, /* 0x13 */
+ XK_R, NoSymbol, XK_kana_SU, NoSymbol, /* 0x14 */
+ XK_T, NoSymbol, XK_kana_KA, NoSymbol, /* 0x15 */
+ XK_Y, NoSymbol, XK_kana_N, NoSymbol, /* 0x16 */
+ XK_U, NoSymbol, XK_kana_NA, NoSymbol, /* 0x17 */
+ XK_I, NoSymbol, XK_kana_NI, NoSymbol, /* 0x18 */
+ XK_O, NoSymbol, XK_kana_RA, NoSymbol, /* 0x19 */
+ XK_P, NoSymbol, XK_kana_SE, NoSymbol, /* 0x1a */
+ XK_at, XK_quoteleft, XK_voicedsound, NoSymbol, /* 0x1b */
+ XK_bracketleft, XK_braceleft, XK_semivoicedsound, NoSymbol,/* 0x1c */
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 0x1d */
+ XK_A, NoSymbol, XK_kana_CHI, NoSymbol, /* 0x1e */
+ XK_S, NoSymbol, XK_kana_TO, NoSymbol, /* 0x1f */
+ XK_D, NoSymbol, XK_kana_SHI, NoSymbol, /* 0x20 */
+ XK_F, NoSymbol, XK_kana_HA, NoSymbol, /* 0x21 */
+ XK_G, NoSymbol, XK_kana_KI, NoSymbol, /* 0x22 */
+ XK_H, NoSymbol, XK_kana_KU, NoSymbol, /* 0x23 */
+ XK_J, NoSymbol, XK_kana_MA, NoSymbol, /* 0x24 */
+ XK_K, NoSymbol, XK_kana_NO, NoSymbol, /* 0x25 */
+ XK_L, NoSymbol, XK_kana_RI, NoSymbol, /* 0x26 */
+ XK_semicolon, XK_plus, XK_kana_RE, NoSymbol, /* 0x27 */
+ XK_colon, XK_asterisk, XK_kana_KE, NoSymbol, /* 0x28 */
+ XK_bracketright,XK_braceright, XK_kana_MU, XK_kana_closingbracket, /* 0x29 */
+ XK_Z, NoSymbol, XK_kana_TSU, NoSymbol, /* 0x2a */
+ XK_X, NoSymbol, XK_kana_SA, NoSymbol, /* 0x2b */
+ XK_C, NoSymbol, XK_kana_SO, NoSymbol, /* 0x2c */
+ XK_V, NoSymbol, XK_kana_HI, NoSymbol, /* 0x2d */
+ XK_B, NoSymbol, XK_kana_KO, NoSymbol, /* 0x2e */
+ XK_N, NoSymbol, XK_kana_MI, NoSymbol, /* 0x2f */
+ XK_M, NoSymbol, XK_kana_MO, NoSymbol, /* 0x30 */
+ XK_comma, XK_less, XK_kana_NE, XK_kana_comma, /* 0x31 */
+ XK_period, XK_greater, XK_kana_RU, XK_kana_fullstop, /* 0x32 */
+ XK_slash, XK_question, XK_kana_ME, XK_kana_middledot,/* 0x33 */
+ NoSymbol, XK_underscore, XK_kana_RO, NoSymbol, /* 0x34 */
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /* 0x35 */
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 0x36 */
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 0x37 */
+ XK_Page_Up, NoSymbol, NoSymbol, NoSymbol, /* 0x38 */
+ XK_Page_Down, NoSymbol, NoSymbol, NoSymbol, /* 0x39 */
+ XK_Undo, NoSymbol, NoSymbol, NoSymbol, /* 0x3a */
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 0x3b */
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 0x3c */
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 0x3d */
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 0x3e */
+ XK_Clear, NoSymbol, NoSymbol, NoSymbol, /* 0x3f */
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 0x40 */
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 0x41 */
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 0x42 */
+ XK_KP_7, NoSymbol, NoSymbol, NoSymbol, /* 0x43 */
+ XK_KP_8, NoSymbol, NoSymbol, NoSymbol, /* 0x44 */
+ XK_KP_9, NoSymbol, NoSymbol, NoSymbol, /* 0x45 */
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /* 0x46 */
+ XK_KP_4, NoSymbol, NoSymbol, NoSymbol, /* 0x47 */
+ XK_KP_5, NoSymbol, NoSymbol, NoSymbol, /* 0x48 */
+ XK_KP_6, NoSymbol, NoSymbol, NoSymbol, /* 0x49 */
+ XK_KP_Equal, NoSymbol, NoSymbol, NoSymbol, /* 0x4a */
+ XK_KP_1, NoSymbol, NoSymbol, NoSymbol, /* 0x4b */
+ XK_KP_2, NoSymbol, NoSymbol, NoSymbol, /* 0x4c */
+ XK_KP_3, NoSymbol, NoSymbol, NoSymbol, /* 0x4d */
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 0x4e */
+ XK_KP_0, NoSymbol, NoSymbol, NoSymbol, /* 0x4f */
+ XK_comma, NoSymbol, NoSymbol, NoSymbol, /* 0x50 */
+ XK_period, NoSymbol, NoSymbol, NoSymbol, /* 0x51 */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x52 */
+ XK_Touroku, NoSymbol, NoSymbol, NoSymbol, /* 0x53 */
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /* 0x54 */
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 0x55 */
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /* 0x56 */
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /* 0x57 */
+ XK_Alt_R, NoSymbol, NoSymbol, NoSymbol, /* 0x58 */
+ XK_Control_R, NoSymbol, NoSymbol, NoSymbol, /* 0x59 */
+ XK_Kana_Lock, NoSymbol, NoSymbol, NoSymbol, /* 0x5a */
+ XK_Romaji, NoSymbol, NoSymbol, NoSymbol, /* 0x5b */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x5c */
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 0x5d */
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 0x5e */
+ XK_Hiragana_Katakana, NoSymbol, NoSymbol, NoSymbol, /* 0x5f */
+ XK_Zenkaku_Hankaku, NoSymbol, NoSymbol, NoSymbol, /* 0x60 */
+ XK_Break, NoSymbol, NoSymbol, NoSymbol, /* 0x61 */
+ XK_Print, NoSymbol, NoSymbol, NoSymbol, /* 0x62 */
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 0x63 */
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 0x64 */
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 0x65 */
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 0x66 */
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 0x67 */
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 0x68 */
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 0x69 */
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 0x6a */
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 0x6b */
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 0x6c */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x6d */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x6e */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x6f */
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 0x70 */
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 0x71 */
+ XK_Super_L, NoSymbol, NoSymbol, NoSymbol, /* 0x72 */
+ XK_Super_R, NoSymbol, NoSymbol, NoSymbol, /* 0x73 */
+};
+
+KeySymsRec jisKeySyms = {
+ /* map minKeyCode maxKeyCode mapWidth */
+ jisKeymap, 0x01, 0x73, 4
+};
+
+/*-------------------------------------------------------------------------
+ * ascii keyboard map
+ *-----------------------------------------------------------------------*/
+static KeySym asciiKeymap[] = {
+ /* normal shifted kana kana, shifted */
+ XK_Escape, NoSymbol, NoSymbol, NoSymbol, /* 0x01 */
+ XK_1, XK_exclam, XK_kana_NU, NoSymbol, /* 0x02 */
+ XK_2, XK_at, XK_kana_FU, NoSymbol, /* 0x03 */
+ XK_3, XK_numbersign, XK_kana_A, XK_kana_a, /* 0x04 */
+ XK_4, XK_dollar, XK_kana_U, XK_kana_u, /* 0x05 */
+ XK_5, XK_percent, XK_kana_E, XK_kana_e, /* 0x06 */
+ XK_6, XK_asciicircum, XK_kana_O, XK_kana_o, /* 0x07 */
+ XK_7, XK_ampersand, XK_kana_YA, XK_kana_ya, /* 0x08 */
+ XK_8, XK_asterisk, XK_kana_YU, XK_kana_yu, /* 0x09 */
+ XK_9, XK_parenleft, XK_kana_YO, XK_kana_yo, /* 0x0a */
+ XK_0, XK_parenright, XK_kana_WA, XK_kana_WO, /* 0x0b */
+ XK_minus, XK_underscore, XK_kana_HO, NoSymbol, /* 0x0c */
+ XK_equal, XK_plus, XK_kana_HE, NoSymbol, /* 0x0d */
+ XK_backslash, XK_bar, XK_prolongedsound, NoSymbol, /* 0x0e */
+ XK_BackSpace, NoSymbol, NoSymbol, NoSymbol, /* 0x0f */
+ XK_Tab, NoSymbol, NoSymbol, NoSymbol, /* 0x10 */
+ XK_Q, NoSymbol, XK_kana_TA, NoSymbol, /* 0x11 */
+ XK_W, NoSymbol, XK_kana_TE, NoSymbol, /* 0x12 */
+ XK_E, NoSymbol, XK_kana_I, XK_kana_i, /* 0x13 */
+ XK_R, NoSymbol, XK_kana_SU, NoSymbol, /* 0x14 */
+ XK_T, NoSymbol, XK_kana_KA, NoSymbol, /* 0x15 */
+ XK_Y, NoSymbol, XK_kana_N, NoSymbol, /* 0x16 */
+ XK_U, NoSymbol, XK_kana_NA, NoSymbol, /* 0x17 */
+ XK_I, NoSymbol, XK_kana_NI, NoSymbol, /* 0x18 */
+ XK_O, NoSymbol, XK_kana_RA, NoSymbol, /* 0x19 */
+ XK_P, NoSymbol, XK_kana_SE, NoSymbol, /* 0x1a */
+ XK_bracketleft, XK_braceleft, XK_voicedsound, NoSymbol, /* 0x1b */
+ XK_bracketright,XK_braceright, XK_semivoicedsound, NoSymbol,/* 0x1c */
+ XK_Return, NoSymbol, NoSymbol, NoSymbol, /* 0x1d */
+ XK_A, NoSymbol, XK_kana_CHI, NoSymbol, /* 0x1e */
+ XK_S, NoSymbol, XK_kana_TO, NoSymbol, /* 0x1f */
+ XK_D, NoSymbol, XK_kana_SHI, NoSymbol, /* 0x20 */
+ XK_F, NoSymbol, XK_kana_HA, NoSymbol, /* 0x21 */
+ XK_G, NoSymbol, XK_kana_KI, NoSymbol, /* 0x22 */
+ XK_H, NoSymbol, XK_kana_KU, NoSymbol, /* 0x23 */
+ XK_J, NoSymbol, XK_kana_MA, NoSymbol, /* 0x24 */
+ XK_K, NoSymbol, XK_kana_NO, NoSymbol, /* 0x25 */
+ XK_L, NoSymbol, XK_kana_RI, NoSymbol, /* 0x26 */
+ XK_semicolon, XK_colon, XK_kana_RE, NoSymbol, /* 0x27 */
+ XK_quoteright, XK_quotedbl, XK_kana_KE, NoSymbol, /* 0x28 */
+ XK_quoteleft, XK_asciitilde, XK_kana_MU, XK_kana_closingbracket, /* 0x29 */
+ XK_Z, NoSymbol, XK_kana_TSU, NoSymbol, /* 0x2a */
+ XK_X, NoSymbol, XK_kana_SA, NoSymbol, /* 0x2b */
+ XK_C, NoSymbol, XK_kana_SO, NoSymbol, /* 0x2c */
+ XK_V, NoSymbol, XK_kana_HI, NoSymbol, /* 0x2d */
+ XK_B, NoSymbol, XK_kana_KO, NoSymbol, /* 0x2e */
+ XK_N, NoSymbol, XK_kana_MI, NoSymbol, /* 0x2f */
+ XK_M, NoSymbol, XK_kana_MO, NoSymbol, /* 0x30 */
+ XK_comma, XK_less, XK_kana_NE, XK_kana_comma, /* 0x31 */
+ XK_period, XK_greater, XK_kana_RU, XK_kana_fullstop, /* 0x32 */
+ XK_slash, XK_question, XK_kana_ME, XK_kana_middledot,/* 0x33 */
+ NoSymbol, NoSymbol, XK_kana_RO, NoSymbol, /* 0x34 */
+ XK_space, NoSymbol, NoSymbol, NoSymbol, /* 0x35 */
+ XK_Home, NoSymbol, NoSymbol, NoSymbol, /* 0x36 */
+ XK_Delete, NoSymbol, NoSymbol, NoSymbol, /* 0x37 */
+ XK_Page_Up, NoSymbol, NoSymbol, NoSymbol, /* 0x38 */
+ XK_Page_Down, NoSymbol, NoSymbol, NoSymbol, /* 0x39 */
+ XK_Undo, NoSymbol, NoSymbol, NoSymbol, /* 0x3a */
+ XK_Left, NoSymbol, NoSymbol, NoSymbol, /* 0x3b */
+ XK_Up, NoSymbol, NoSymbol, NoSymbol, /* 0x3c */
+ XK_Right, NoSymbol, NoSymbol, NoSymbol, /* 0x3d */
+ XK_Down, NoSymbol, NoSymbol, NoSymbol, /* 0x3e */
+ XK_Clear, NoSymbol, NoSymbol, NoSymbol, /* 0x3f */
+ XK_KP_Divide, NoSymbol, NoSymbol, NoSymbol, /* 0x40 */
+ XK_KP_Multiply, NoSymbol, NoSymbol, NoSymbol, /* 0x41 */
+ XK_KP_Subtract, NoSymbol, NoSymbol, NoSymbol, /* 0x42 */
+ XK_KP_7, NoSymbol, NoSymbol, NoSymbol, /* 0x43 */
+ XK_KP_8, NoSymbol, NoSymbol, NoSymbol, /* 0x44 */
+ XK_KP_9, NoSymbol, NoSymbol, NoSymbol, /* 0x45 */
+ XK_KP_Add, NoSymbol, NoSymbol, NoSymbol, /* 0x46 */
+ XK_KP_4, NoSymbol, NoSymbol, NoSymbol, /* 0x47 */
+ XK_KP_5, NoSymbol, NoSymbol, NoSymbol, /* 0x48 */
+ XK_KP_6, NoSymbol, NoSymbol, NoSymbol, /* 0x49 */
+ XK_KP_Equal, NoSymbol, NoSymbol, NoSymbol, /* 0x4a */
+ XK_KP_1, NoSymbol, NoSymbol, NoSymbol, /* 0x4b */
+ XK_KP_2, NoSymbol, NoSymbol, NoSymbol, /* 0x4c */
+ XK_KP_3, NoSymbol, NoSymbol, NoSymbol, /* 0x4d */
+ XK_KP_Enter, NoSymbol, NoSymbol, NoSymbol, /* 0x4e */
+ XK_KP_0, NoSymbol, NoSymbol, NoSymbol, /* 0x4f */
+ XK_comma, NoSymbol, NoSymbol, NoSymbol, /* 0x50 */
+ XK_period, NoSymbol, NoSymbol, NoSymbol, /* 0x51 */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x52 */
+ XK_Touroku, NoSymbol, NoSymbol, NoSymbol, /* 0x53 */
+ XK_Help, NoSymbol, NoSymbol, NoSymbol, /* 0x54 */
+ XK_Alt_L, NoSymbol, NoSymbol, NoSymbol, /* 0x55 */
+ XK_Meta_L, NoSymbol, NoSymbol, NoSymbol, /* 0x56 */
+ XK_Meta_R, NoSymbol, NoSymbol, NoSymbol, /* 0x57 */
+ XK_Alt_R, NoSymbol, NoSymbol, NoSymbol, /* 0x58 */
+ XK_Control_R, NoSymbol, NoSymbol, NoSymbol, /* 0x59 */
+ XK_Kana_Lock, NoSymbol, NoSymbol, NoSymbol, /* 0x5a */
+ XK_Romaji, NoSymbol, NoSymbol, NoSymbol, /* 0x5b */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x5c */
+ XK_Caps_Lock, NoSymbol, NoSymbol, NoSymbol, /* 0x5d */
+ XK_Insert, NoSymbol, NoSymbol, NoSymbol, /* 0x5e */
+ XK_Hiragana_Katakana, NoSymbol, NoSymbol, NoSymbol, /* 0x5f */
+ XK_Zenkaku_Hankaku, NoSymbol, NoSymbol, NoSymbol, /* 0x60 */
+ XK_Break, NoSymbol, NoSymbol, NoSymbol, /* 0x61 */
+ XK_Print, NoSymbol, NoSymbol, NoSymbol, /* 0x62 */
+ XK_F1, NoSymbol, NoSymbol, NoSymbol, /* 0x63 */
+ XK_F2, NoSymbol, NoSymbol, NoSymbol, /* 0x64 */
+ XK_F3, NoSymbol, NoSymbol, NoSymbol, /* 0x65 */
+ XK_F4, NoSymbol, NoSymbol, NoSymbol, /* 0x66 */
+ XK_F5, NoSymbol, NoSymbol, NoSymbol, /* 0x67 */
+ XK_F6, NoSymbol, NoSymbol, NoSymbol, /* 0x68 */
+ XK_F7, NoSymbol, NoSymbol, NoSymbol, /* 0x69 */
+ XK_F8, NoSymbol, NoSymbol, NoSymbol, /* 0x6a */
+ XK_F9, NoSymbol, NoSymbol, NoSymbol, /* 0x6b */
+ XK_F10, NoSymbol, NoSymbol, NoSymbol, /* 0x6c */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x6d */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x6e */
+ NoSymbol, NoSymbol, NoSymbol, NoSymbol, /* 0x6f */
+ XK_Shift_L, NoSymbol, NoSymbol, NoSymbol, /* 0x70 */
+ XK_Control_L, NoSymbol, NoSymbol, NoSymbol, /* 0x71 */
+ XK_Super_L, NoSymbol, NoSymbol, NoSymbol, /* 0x72 */
+ XK_Super_R, NoSymbol, NoSymbol, NoSymbol, /* 0x73 */
+};
+
+KeySymsRec asciiKeySyms = {
+ /* map minKeyCode maxKeyCode mapWidth */
+ asciiKeymap, 0x01, 0x73, 4
+};
+
+KeySymsRec *x68kKeySyms = &jisKeySyms;
+
+/* EOF x68kKeyMap.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kMouse.c 2014-02-22 09:19:06.000000000 +0000
@@ -0,0 +1,360 @@
+/* $NetBSD: x68kMouse.c,v 1.4 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+/*-
+ * Copyright (c) 1987 by the Regents of the University of California
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. The University of California
+ * makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without
+ * express or implied warranty.
+ */
+
+/************************************************************
+Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
+
+ All Rights Reserved
+
+Permission to use, copy, modify, and distribute this
+software and its documentation for any purpose and without
+fee is hereby granted, provided that the above copyright no-
+tice appear in all copies and that both that copyright no-
+tice and this permission notice appear in supporting docu-
+mentation, and that the names of Sun or X Consortium
+not be used in advertising or publicity pertaining to
+distribution of the software without specific prior
+written permission. Sun and X Consortium make no
+representations about the suitability of this software for
+any purpose. It is provided "as is" without any express or
+implied warranty.
+
+SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
+NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
+ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
+OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
+THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+********************************************************/
+/*
+ * Copyright 1991, 1992, 1993 Kaleb S. Keithley
+ *
+ * Permission to use, copy, modify, and distribute this
+ * software and its documentation for any purpose and without
+ * fee is hereby granted, provided that the above copyright
+ * notice appear in all copies. Kaleb S. Keithley makes no
+ * representations about the suitability of this software for
+ * any purpose. It is provided "as is" without express or
+ * implied warranty.
+ */
+
+#include "x68k.h"
+#include "mi.h"
+#include "input.h"
+#include "inpututils.h"
+
+#include "exevents.h"
+#include <X11/Xatom.h>
+#include "xserver-properties.h"
+
+static Bool x68kCursorOffScreen(ScreenPtr *, int *, int *);
+static void x68kCrossScreen(ScreenPtr, int);
+static void x68kWarpCursor(DeviceIntPtr, ScreenPtr, int, int);
+static void x68kMouseCtrl(DeviceIntPtr, PtrCtrl*);
+
+miPointerScreenFuncRec x68kPointerScreenFuncs = {
+ x68kCursorOffScreen,
+ x68kCrossScreen,
+ x68kWarpCursor,
+};
+
+DeviceIntPtr x68kPointerDevice = NULL;
+
+static X68kMousePriv x68kMousePriv;
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kMouseProc --
+ * Handle the initialization, etc. of a mouse
+ *
+ * Results:
+ * none.
+ *
+ * Side Effects:
+ *-----------------------------------------------------------------------
+ */
+int x68kMouseProc(DeviceIntPtr device, int what)
+{
+ DevicePtr pMouse = &device->public;
+ int format;
+ static int oformat;
+ BYTE map[4];
+ Atom btn_labels[3] = {0};
+ Atom axes_labels[2] = { 0, 0 };
+
+ switch (what) {
+ case DEVICE_INIT:
+ pMouse->devicePrivate = (pointer) &x68kMousePriv;
+ if( (x68kMousePriv.fd = open("/dev/mouse", O_RDONLY)) == -1 ) {
+ Error("Can't open mouse device");
+ return !Success;
+ }
+ pMouse->on = FALSE;
+ map[1] = 1;
+ map[2] = 2;
+ map[2] = 3;
+ btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
+ btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
+ btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
+ axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
+ axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
+
+ InitPointerDeviceStruct(pMouse, map, 3, btn_labels,
+ x68kMouseCtrl, GetMotionHistorySize(),
+ 2, axes_labels);
+ break;
+
+ case DEVICE_ON:
+ if (ioctl (x68kMousePriv.fd, VUIDGFORMAT, &oformat) == -1) {
+ Error("x68kMouseProc ioctl VUIDGFORMAT");
+ return !Success;
+ }
+ format = VUID_FIRM_EVENT;
+ if (ioctl (x68kMousePriv.fd, VUIDSFORMAT, &format) == -1) {
+ Error("x68kMouseProc ioctl VUIDSFORMAT");
+ return !Success;
+ }
+ if ( fcntl(x68kMousePriv.fd, F_SETOWN, getpid()) == -1 ||
+ fcntl(x68kMousePriv.fd, F_SETFL, O_NONBLOCK | O_ASYNC) == -1
+ ) {
+ Error("Async mouse I/O failed");
+ return !Success;
+ }
+ x68kMousePriv.bmask = 0;
+ AddEnabledDevice(x68kMousePriv.fd);
+ pMouse->on = TRUE;
+ break;
+
+ case DEVICE_OFF:
+ pMouse->on = FALSE;
+ RemoveEnabledDevice(x68kMousePriv.fd);
+ break;
+
+ case DEVICE_CLOSE:
+ if (ioctl (x68kMousePriv.fd, VUIDSFORMAT, &oformat) == -1)
+ Error("x68kMouseProc ioctl VUIDSFORMAT");
+ break;
+
+ }
+ return Success;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kMouseCtrl --
+ * 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 x68kMouseCtrl(DeviceIntPtr device, PtrCtrl* ctrl)
+{
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kMouseGetEvents --
+ * 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* x68kMouseGetEvents(int fd, int *pNumEvents, Bool *pAgain)
+{
+ int nBytes; /* number of bytes of events available. */
+ static Firm_event evBuf[MAXEVENTS]; /* Buffer for Firm_events */
+
+ if ((nBytes = read (fd, (char *)evBuf, sizeof(evBuf))) == -1) {
+ if (errno == EWOULDBLOCK) {
+ *pNumEvents = 0;
+ *pAgain = FALSE;
+ } else {
+ Error("x68kMouseGetEvents read");
+ FatalError ("Could not read from mouse");
+ }
+ } else {
+ *pNumEvents = nBytes / sizeof (Firm_event);
+ *pAgain = (nBytes == sizeof (evBuf));
+ }
+ return evBuf;
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * x68kMouseEnqueueEvent --
+ * 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 x68kMouseEnqueueEvent(DeviceIntPtr device, Firm_event *fe)
+{
+ X68kMousePrivPtr pPriv; /* Private data for pointer */
+ int bmask; /* Temporary button mask */
+ time_t etime;
+ int type, buttons, flag;
+ int i, nevents, valuators[2];
+ ValuatorMask mask;
+
+ GetEventList(&x68kEvents);
+
+ pPriv = (X68kMousePrivPtr)device->public.devicePrivate;
+
+ etime = 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.
+ */
+ buttons = (fe->id - MS_LEFT) + 1;
+ bmask = 1 << buttons;
+ if (fe->value == VKEY_UP) {
+ if (pPriv->bmask & bmask) {
+ type = ButtonRelease;
+ pPriv->bmask &= ~bmask;
+ } else {
+ return;
+ }
+ } else {
+ if ((pPriv->bmask & bmask) == 0) {
+ type = ButtonPress;
+ pPriv->bmask |= bmask;
+ } else {
+ return;
+ }
+ }
+ flag = POINTER_RELATIVE;
+ valuator_mask_set_range(&mask, 0, 0, NULL);
+ nevents = GetPointerEvents(x68kEvents, device,
+ type, buttons, flag, &mask);
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(device, (InternalEvent*)(x68kEvents + i)->event);
+ break;
+ case LOC_X_DELTA:
+ valuators[0] = fe->value;
+ valuators[1] = 0;
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ flag = POINTER_RELATIVE | POINTER_ACCELERATE;
+ nevents = GetPointerEvents(x68kEvents, device,
+ MotionNotify, 0, flag, &mask);
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(device, (InternalEvent*)(x68kEvents + i)->event);
+ 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...
+ */
+ valuators[0] = 0;
+ valuators[1] = -fe->value;
+ valuator_mask_set_range(&mask, 0, 2, valuators);
+ flag = POINTER_RELATIVE | POINTER_ACCELERATE;
+ nevents = GetPointerEvents(x68kEvents, device,
+ MotionNotify, 0, flag, &mask);
+ for (i = 0; i < nevents; i++)
+ mieqEnqueue(device, (InternalEvent*)(x68kEvents + i)->event);
+ break;
+ case LOC_X_ABSOLUTE:
+ case LOC_Y_ABSOLUTE:
+ /* XXX not sure how to get current X and Y position */
+ default:
+ FatalError ("%s: unrecognized id\n", __func__);
+ break;
+ }
+}
+
+/*ARGSUSED*/
+static Bool x68kCursorOffScreen(ScreenPtr *pScreen, int *x, int *y)
+{
+ return FALSE;
+}
+
+static void x68kCrossScreen(ScreenPtr pScreen, int entering)
+{
+}
+
+static void x68kWarpCursor(DeviceIntPtr pDev, ScreenPtr pScreen, int x, int y)
+{
+ sigset_t newsigmask;
+
+ (void) sigemptyset (&newsigmask);
+ (void) sigaddset (&newsigmask, SIGIO);
+ (void) sigprocmask (SIG_BLOCK, &newsigmask, (sigset_t *)NULL);
+ miPointerWarpCursor (pDev, pScreen, x, y);
+ (void) sigprocmask (SIG_UNBLOCK, &newsigmask, (sigset_t *)NULL);
+}
+
+/* EOF x68kMouse.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kReg.h 2014-02-21 18:48:42.000000000 +0000
@@ -0,0 +1,95 @@
+/* $NetBSD: x68kReg.h,v 1.1.1.1 2004/01/07 12:51:43 minoura Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+/*
+ * CRT controller
+ */
+typedef struct {
+ u_short r00, r01, r02, r03, r04, r05, r06, r07;
+ u_short r08, r09, r10, r11, r12, r13, r14, r15;
+ u_short r16, r17, r18, r19, r20, r21, r22, r23;
+ char pad0[0x450];
+ u_short ctrl;
+ char pad1[0x1b7e];
+} Crtc;
+
+typedef struct {
+ u_short r00, r01, r02, r03, r04, r05, r06, r07;
+ u_short r08, r09, r10, r11, r12, r13, r14, r15;
+ u_short r16, r17, r18, r19, r20, r21, r22, r23;
+ u_short ctrl;
+} X68kCrtc;
+
+/*
+ * video controller
+ */
+typedef struct {
+ u_short r0;
+ char pad0[0xfe];
+ u_short r1;
+ char pad1[0xfe];
+ u_short r2;
+ char pad2[0x19fe];
+} Videoc;
+
+typedef struct {
+ u_short r0;
+ u_short r1;
+ u_short r2;
+} X68kVideoc;
+
+/* system port */
+typedef struct {
+ u_short r1, r2, r3, r4;
+ u_short pad0[2];
+ u_short r5, r6;
+ u_short pad[0x1ff0];
+} Sysport;
+
+/*
+ * control registers
+ */
+typedef struct {
+ Crtc crtc;
+ u_short gpal[256]; /* graphic palette */
+ u_short tpal[256]; /* text palette */
+ Videoc videoc;
+ u_short pad0[0xa000];
+ Sysport sysport;
+} FbReg;
+
+typedef struct {
+ X68kCrtc crtc;
+ X68kVideoc videoc;
+ char dotClock;
+} X68kFbReg;
+
+/* EOF x68kReg.h */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ xsrc/external/mit/xorg-server/dist/hw/netbsd/x68k/x68kText.c 2014-02-22 09:19:17.000000000 +0000
@@ -0,0 +1,126 @@
+/* $NetBSD: x68kText.c,v 1.3 2011/05/20 05:12:42 tsutsui Exp $ */
+/*-------------------------------------------------------------------------
+ * Copyright (c) 1996 Yasushi Yamasaki
+ * All rights reserved.
+ *
+ * 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 Yasushi Yamasaki
+ * 4. The name of the author may not be used to endorse or promote products
+ * derived from this software without specific prior written permission
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *-----------------------------------------------------------------------*/
+
+#include "x68k.h"
+#include "mi.h"
+#include "micmap.h"
+#include "fb.h"
+
+/*-------------------------------------------------------------------------
+ * function "x68kTextOpen" [ X68kFBProc function ]
+ *
+ * purpose: call common frame buffer opening procedure
+ * and enable TVRAM simultaneous access mode
+ * argument: (X68kScreenRec *)pPriv : X68k private screen record
+ * returns: (Bool): TRUE if succeeded
+ * FALSE otherwise
+ *-----------------------------------------------------------------------*/
+static u_short r21;
+static u_short tpal0;
+static u_short tpal15;
+
+Bool x68kTextOpen(X68kScreenRec *pPriv)
+{
+ if( !x68kFbCommonOpen(pPriv, "/dev/grf0") )
+ return FALSE;
+
+ /* enable TVRAM simultaneous access mode */
+ r21 = pPriv->reg->crtc.r21;
+ pPriv->reg->crtc.r21 = 0x01f0;
+
+ /* initialize scroll registers */
+ pPriv->reg->crtc.r10 = pPriv->reg->crtc.r11 = 0;
+
+ tpal0 = pPriv->reg->tpal[0];
+ tpal15 = pPriv->reg->tpal[15];
+
+ pPriv->reg->tpal[0] = 0;
+ pPriv->reg->tpal[15] = 0xFFFE;
+
+ return TRUE;
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kTextClose" [ X68kFBProc function ]
+ *
+ * purpose: close text frame buffer
+ * argument: nothing
+ * returns: nothing
+ *-----------------------------------------------------------------------*/
+void x68kTextClose(X68kScreenRec *pPriv)
+{
+ pPriv->reg->crtc.r21 = r21; /* recover TVRAM mode */
+ pPriv->reg->tpal[0] = tpal0;
+ pPriv->reg->tpal[15] = tpal15;
+ x68kFbCommonClose(pPriv);
+}
+
+/*-------------------------------------------------------------------------
+ * function "x68kTextInit" [ called by DIX AddScreen ]
+ *
+ * purpose: initialize text frame buffer
+ * argument: (int)screen : screen index
+ * (ScreenPtr)pScreen : DIX screen record
+ * (int)argc, (char **)argv : standard C arguments
+ * returns: (Bool) TRUE if succeeded
+ * FALSE otherwise
+ *-----------------------------------------------------------------------*/
+Bool x68kTextInit(int screen, ScreenPtr pScreen, int argc, char *argv[])
+{
+ X68kScreenRec *pPriv;
+
+ /* get private screen record set by X68KConfig */
+ pPriv = x68kGetScreenRecByType(X68K_FB_TEXT);
+
+ if ( x68kGeneration != serverGeneration ) {
+ if ( !dixRegisterPrivateKey(&x68kScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof(X68kScreenRec))) {
+ Error("dixRegisterPrivateKey failed");
+ return FALSE;
+ }
+ x68kGeneration = serverGeneration;
+ }
+
+ if ( !fbScreenInit(pScreen, pPriv->fb,
+ pPriv->scr_width, pPriv->scr_height,
+ pPriv->dpi, pPriv->dpi, pPriv->fb_width, 1) )
+ return FALSE;
+ pScreen->whitePixel = 1;
+ pScreen->blackPixel = 0;
+ if ( !miDCInitialize(pScreen, &x68kPointerScreenFuncs) )
+ return FALSE;
+ if ( !miCreateDefColormap(pScreen) )
+ return FALSE;
+ pScreen->SaveScreen = x68kSaveScreen;
+
+ return TRUE;
+}
+
+/* EOF x68kText.c */
--- /dev/null 2014-02-22 10:14:14.000000000 +0000
+++ src/external/mit/xorg/server/xorg-server/hw/netbsd/x68k/Makefile 2014-02-22 09:55:30.000000000 +0000
@@ -0,0 +1,93 @@
+# $NetBSD$
+
+.include <bsd.own.mk>
+
+PROG= X68k
+BINMODE= 4711
+
+SYMLINKS= ${X11BINDIR}/X68k ${X11BINDIR}/X
+
+FILES= X68kConfig
+FILESDIR= ${X11ETCDIR}
+
+.include "../../../Makefile.serverlib"
+.include "../../../Makefile.servermod"
+
+WARNS?= 2
+
+.PATH: ${X11SRCDIR.xorg-server}/hw/netbsd/x68k
+.PATH: ${X11SRCDIR.xorg-server}/Xext
+.PATH: ${X11SRCDIR.xorg-server}/Xi
+.PATH: ${X11SRCDIR.xorg-server}/mi
+.PATH: ${X11SRCDIR.xorg-server}/fb
+SRCS= x68kInit.c x68kConfig.c x68kIo.c x68kMouse.c x68kKbd.c x68kKeyMap.c \
+ x68kFb.c x68kGraph.c x68kText.c \
+ dpmsstubs.c stubs.c miinitext.c fbcmap_mi.c
+
+# trim fonts / extensions / XSERVERINCDIR if possible
+CPPFLAGS+= -I${X11SRCDIR.xorg-server}/hw/netbsd/x68k \
+ -I${X11SRCDIR.xorg-server}/mi \
+ -I${X11SRCDIR.xorg-server}/Xext \
+ -I${X11SRCDIR.xorg-server}/fb \
+ -I${X11SRCDIR.xorg-server}/mi \
+ -I${X11SRCDIR.xorg-server}/include \
+ -I${X11SRCDIR.xorg-server}/os \
+ -I${X11SRCDIR.xorg-server}/render \
+ -I${DESTDIR}${X11INCDIR}/X11 \
+ -I${X11SRCDIR.xorg-server}/include/fonts \
+ -I${X11SRCDIR.xorg-server}/include/extensions
+
+CPPFLAGS+= -UXFree86LOADER -UXF86VIDMODE -UXFreeXDGA -UXF86MISC \
+ -UXF86DRI -UXF86BIGFONT -UCOMPOSITE
+
+CPPFLAGS.x68kConfig.c= -DX11_LIBDIR=\"${X11ETCDIR}\"
+
+.include "../../../Makefile.Xserver"
+
+LDADD+= ${LDADD.dix} \
+ ${LDADD.fb} \
+ ${LDADD.mi} \
+ ${LDADD.xkb} \
+ ${LDADD.xkbstubs} \
+ ${LDADD.randr} \
+ ${LDADD.Xext} \
+ ${LDADD.composite} \
+ ${LDADD.render} \
+ ${LDADD.os} \
+ ${LDADD.xfixes} \
+ ${LDADD.damageext} \
+ ${LDADD.miext/damage} \
+ ${LDADD.miext/shadow} \
+ ${LDADD.miext/sync} \
+ ${LDADD.Xi} \
+ -lXfont \
+ -lpixman-1 \
+ -lXext \
+ -lX11 \
+ -lz \
+ -lm
+
+DPADD+= ${LDADD.dix} \
+ ${DPADD.fb} \
+ ${DPADD.mi} \
+ ${DPADD.xkb} \
+ ${DPADD.randr} \
+ ${DPADD.Xext} \
+ ${DPADD.composite} \
+ ${DPADD.render} \
+ ${DPADD.os} \
+ ${DPADD.xfixes} \
+ ${DPADD.damageext} \
+ ${DPADD.miext/damage} \
+ ${DPADD.miext/shadow} \
+ ${DPADD.miext/sync} \
+ ${DPADD.Xi} \
+ ${LIBXFONT} \
+ ${LIBPIXMAN-1} \
+ ${LIBXEXT} \
+ ${LIBX11} \
+ ${LIBZ} \
+ ${LIBM}
+
+.include <bsd.x11.mk>
+.include <bsd.prog.mk>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment