Module Name:    src
Committed By:   msaitoh
Date:           Sun Nov  9 07:34:12 UTC 2014

Modified Files:
        src/sys/arch/luna68k/conf [netbsd-6]: GENERIC files.luna68k
        src/sys/arch/luna68k/dev [netbsd-6]: lunafb.c lunaws.c omrasops.c
            omrasopsvar.h
Added Files:
        src/sys/arch/luna68k/dev [netbsd-6]: omkbdmap.c omkbdmap.h

Log Message:
Pull up following revision(s) (requested by tsutsui in ticket #1182):
        sys/arch/luna68k/conf/files.luna68k: revision 1.24
        sys/arch/luna68k/conf/GENERIC: revision 1.113 via patch
        sys/arch/luna68k/dev/omrasops.c: revision 1.17-1.19
        sys/arch/luna68k/dev/lunaws.c: revision 1.30
        sys/arch/luna68k/dev/omkbdmap.c: revision 1.1-1.2
        sys/arch/luna68k/dev/omkbdmap.h: revision 1.1
        sys/arch/luna68k/dev/lunafb.c: revision 1.31-1.36
        sys/arch/luna68k/dev/omrasopsvar.h: revision 1.3
- Setup Bt458 color palette to support ANSI color text on 8bpp framebuffer.
  Mostly taken from OpenBSD/luna88k.  Also sync some comments.
  Tested on LUNA-II, and mlterm-fb with 8bpp wallpaper also works fine.
  Thanks to Kenji Aoyama (OpenBSD/luna88k maintainer) for providing
  his spare 8bpp board.
- Use C99 struct initialization for wsdisplay_accessops.
- Use kmem(9) instead of malloc(9).
- Pull LUNA's keyboard driver changes from OpenBSD/luna88k. Now LUNA's
  keyboard works on Xorg server without tweaks by xmodmap(1) etc.
  - split keyboard mapping definitions to new files, omkbdmap.[ch]
  - add WSDISPLAY_COMPAT_RAWKBD support
    (actually the name is wrong; it doesn't emit raw keycode but
     converts MD code into PS/2 one as "raw keycode on x86" for Xorg server)
  - allow to enter into ddb by CTRL+ALT(zenmen)+ESC
  - remove unnecessary return values
- Add consistent prefix to a softc member name.
- Implement WSDISPLAYIO_SMODE ioctl for proper mmap and colormap handling.
  Tested on LUNA with 4bpp framebuffer.
  - allow mmap framebuffer memories only in WSDISPLAYIO_DUMBFB
  - initialize palette for ANSI text colors on back to WSDISPLAYIO_MODE_EMUL
- Pull readability changes from OpenBSD/luna88k.
  Tested on LUNA-II with 8bpp framebuffer.
  - prepare and use unpack_attr() function to get fg and bg from attribute
  - use proper variable names to clarify meanings
- Put dumb optimizations to avoid conditionals in putchar drawing loops.
  ~10% improvements of time cat results on LUNA-II 8bpp framebuffer.
- Fix unintended RCS Id substitution.
- Pull LUNA's framebuffer improvements by Kenji Aoyama from OpenBSD/luna88k.
  This Makes 4bpp wscons putchar ~30% on LUNA-II.
  http://marc.info/?l=openbsd-cvs&m=141199909120631&w=2
  > Use raster(logic) operation, or ROP, function on LUNA frame buffer.
  > It makes 4bpp wscons putchar ~20% faster.
  Also use the similar ROP in 1bpp putchar and cursor functions
  and the 1bpp putchar is also ~5% faster.
  While here, reduce diffs from OpenBSD a bit.
  Tested on all 1bpp/4bpp/8bpp framebuffers.
- Add options WSDISPLAY_COMPAT_RAWKBD for Xorg server.


To generate a diff of this commit:
cvs rdiff -u -r1.97.2.2 -r1.97.2.3 src/sys/arch/luna68k/conf/GENERIC
cvs rdiff -u -r1.23 -r1.23.6.1 src/sys/arch/luna68k/conf/files.luna68k
cvs rdiff -u -r1.25.8.2 -r1.25.8.3 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.23.8.2 -r1.23.8.3 src/sys/arch/luna68k/dev/lunaws.c
cvs rdiff -u -r0 -r1.2.2.2 src/sys/arch/luna68k/dev/omkbdmap.c
cvs rdiff -u -r0 -r1.1.8.2 src/sys/arch/luna68k/dev/omkbdmap.h
cvs rdiff -u -r1.11.8.2 -r1.11.8.3 src/sys/arch/luna68k/dev/omrasops.c
cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/luna68k/dev/omrasopsvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/luna68k/conf/GENERIC
diff -u src/sys/arch/luna68k/conf/GENERIC:1.97.2.2 src/sys/arch/luna68k/conf/GENERIC:1.97.2.3
--- src/sys/arch/luna68k/conf/GENERIC:1.97.2.2	Sun Jan 12 12:08:36 2014
+++ src/sys/arch/luna68k/conf/GENERIC	Sun Nov  9 07:34:12 2014
@@ -1,4 +1,4 @@
-# $NetBSD: GENERIC,v 1.97.2.2 2014/01/12 12:08:36 bouyer Exp $
+# $NetBSD: GENERIC,v 1.97.2.3 2014/11/09 07:34:12 msaitoh Exp $
 #
 # GENERIC machine description file
 # 
@@ -22,7 +22,7 @@ include		"arch/luna68k/conf/std.luna68k"
 
 options 	INCLUDE_CONFIG_FILE	# embed config file in kernel binary
 
-#ident 		"GENERIC-$Revision: 1.97.2.2 $"
+#ident 		"GENERIC-$Revision: 1.97.2.3 $"
 
 maxusers	8
 
@@ -138,6 +138,7 @@ options 	NFS_BOOT_DHCP	# superset of BOO
 
 # WS console uses SUN or VT100 terminal emulation
 options 	WSEMUL_VT100
+options 	WSDISPLAY_COMPAT_RAWKBD
 options 	FONT_OMRON12x20
 
 config		netbsd root on ? type ?

Index: src/sys/arch/luna68k/conf/files.luna68k
diff -u src/sys/arch/luna68k/conf/files.luna68k:1.23 src/sys/arch/luna68k/conf/files.luna68k:1.23.6.1
--- src/sys/arch/luna68k/conf/files.luna68k:1.23	Tue Nov 15 13:25:44 2011
+++ src/sys/arch/luna68k/conf/files.luna68k	Sun Nov  9 07:34:12 2014
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: files.luna68k,v 1.23 2011/11/15 13:25:44 tsutsui Exp $
+#	$NetBSD: files.luna68k,v 1.23.6.1 2014/11/09 07:34:12 msaitoh Exp $
 #
 maxpartitions 8
 maxusers 2 8 64
@@ -42,9 +42,11 @@ file arch/luna68k/dev/sio.c 		sio
 device siotty: tty
 attach siotty at sio
 file arch/luna68k/dev/siotty.c		siotty needs-flag
+
 device ws: wskbddev,wsmousedev
 attach ws at sio
 file arch/luna68k/dev/lunaws.c		ws
+file arch/luna68k/dev/omkbdmap.c	ws
 
 device fb: wsemuldisplaydev
 attach fb at mainbus

Index: src/sys/arch/luna68k/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.25.8.2 src/sys/arch/luna68k/dev/lunafb.c:1.25.8.3
--- src/sys/arch/luna68k/dev/lunafb.c:1.25.8.2	Sun Jan 12 12:25:03 2014
+++ src/sys/arch/luna68k/dev/lunafb.c	Sun Nov  9 07:34:12 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.25.8.2 2014/01/12 12:25:03 bouyer Exp $ */
+/* $NetBSD: lunafb.c,v 1.25.8.3 2014/11/09 07:34:12 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,14 +31,14 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.25.8.2 2014/01/12 12:25:03 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.25.8.3 2014/11/09 07:34:12 msaitoh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/conf.h>
 #include <sys/device.h>
 #include <sys/ioctl.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
 #include <sys/mman.h>
 #include <sys/proc.h>
 #include <sys/tty.h>
@@ -75,11 +75,8 @@ struct bt458 {
 };
 
 #define	OMFB_RFCNT	0xB1000000	/* video h-origin/v-origin */
-#define	OMFB_PLANEMASK	0xB1040000	/* planemask register */
-#define	OMFB_FB_WADDR	0xB1080008	/* common plane */
-#define	OMFB_FB_RADDR	0xB10C0008	/* plane #0 */
-#define	OMFB_ROPFUNC	0xB12C0000	/* ROP function code */
 #define	OMFB_RAMDAC	0xC1100000	/* Bt454/Bt458 RAMDAC */
+
 #define	OMFB_SIZE	(0xB1300000 - 0xB1080000 + PAGE_SIZE)
 
 struct hwcmap {
@@ -126,13 +123,15 @@ struct om_hwdevconfig {
 struct omfb_softc {
 	device_t sc_dev;		/* base device */
 	struct om_hwdevconfig *sc_dc;	/* device configuration */
-	int nscreens;
+	int sc_nscreens;
+	int sc_mode;
 };
 
 static int  omgetcmap(struct omfb_softc *, struct wsdisplay_cmap *);
 static int  omsetcmap(struct omfb_softc *, struct wsdisplay_cmap *);
 
 static struct om_hwdevconfig omfb_console_dc;
+static void omfb_resetcmap(struct om_hwdevconfig *);
 static void omfb_getdevconfig(paddr_t, struct om_hwdevconfig *);
 
 static struct wsscreen_descr omfb_stdscreen = {
@@ -156,12 +155,14 @@ static int   omfb_show_screen(void *, vo
 			      void (*) (void *, int, int), void *);
 
 static const struct wsdisplay_accessops omfb_accessops = {
-	omfbioctl,
-	omfbmmap,
-	omfb_alloc_screen,
-	omfb_free_screen,
-	omfb_show_screen,
-	0 /* load_font */
+	.ioctl        = omfbioctl,
+	.mmap         = omfbmmap,
+	.alloc_screen = omfb_alloc_screen,
+	.free_screen  = omfb_free_screen,
+	.show_screen  = omfb_show_screen,
+	.load_font    = NULL,
+	.pollc        = NULL,
+	.scroll       = NULL
 };
 
 static int  omfbmatch(device_t, cfdata_t, void *);
@@ -202,15 +203,16 @@ omfbattach(device_t parent, device_t sel
 
 	if (omfb_console) {
 		sc->sc_dc = &omfb_console_dc;
-		sc->nscreens = 1;
+		sc->sc_nscreens = 1;
 	} else {
-		sc->sc_dc = malloc(sizeof(struct om_hwdevconfig),
-		    M_DEVBUF, M_WAITOK | M_ZERO);
+		sc->sc_dc = kmem_zalloc(sizeof(struct om_hwdevconfig),
+		    KM_SLEEP);
 		omfb_getdevconfig(OMFB_FB_WADDR, sc->sc_dc);
 	}
 	aprint_normal(": %d x %d, %dbpp\n", sc->sc_dc->dc_wid, sc->sc_dc->dc_ht,
 	    sc->sc_dc->dc_depth);
 
+	sc->sc_mode = WSDISPLAYIO_MODE_EMUL;
 	waa.console = omfb_console;
 	waa.scrdata = &omfb_screenlist;
 	waa.accessops = &omfb_accessops;
@@ -238,6 +240,7 @@ omfbioctl(void *v, void *vs, u_long cmd,
 {
 	struct omfb_softc *sc = v;
 	struct om_hwdevconfig *dc = sc->sc_dc;
+	int new_mode;
 
 	switch (cmd) {
 	case WSDISPLAYIO_GTYPE:
@@ -263,6 +266,15 @@ omfbioctl(void *v, void *vs, u_long cmd,
 	case WSDISPLAYIO_PUTCMAP:
 		return omsetcmap(sc, (struct wsdisplay_cmap *)data);
 
+	case WSDISPLAYIO_SMODE:
+		new_mode = *(int *)data;
+		if (new_mode != sc->sc_mode) {
+			sc->sc_mode = new_mode;
+			if (new_mode == WSDISPLAYIO_MODE_EMUL)
+				omfb_resetcmap(dc);
+		}
+		return 0;
+
 	case WSDISPLAYIO_SVIDEO:
 	case WSDISPLAYIO_GVIDEO:
 	case WSDISPLAYIO_GCURPOS:
@@ -286,13 +298,21 @@ omfbmmap(void *v, void *vs, off_t offset
 	struct om_hwdevconfig *dc = sc->sc_dc;
 	paddr_t cookie = -1;
 
-#if 0	/* XXX: quick workaround to make X.Org mono server work */
-	if (offset >= 0 && offset < OMFB_SIZE)
-		cookie = m68k_btop(m68k_trunc_page(dc->dc_videobase) + offset);
-#else
-	if (offset >= 0 && offset < dc->dc_rowbytes * dc->dc_ht * dc->dc_depth)
-		cookie = m68k_btop(m68k_trunc_page(OMFB_FB_RADDR) + offset);
+	switch (sc->sc_mode) {
+#if 0
+	case WSDISPLAYIO_MODE_MAPPED:
+		if (offset >= 0 && offset < OMFB_SIZE)
+			cookie = m68k_btop(m68k_trunc_page(dc->dc_videobase) +
+			    offset);
+		break;
 #endif
+	case WSDISPLAYIO_MODE_DUMBFB:
+		if (offset >= 0 &&
+		    offset < dc->dc_rowbytes * dc->dc_ht * dc->dc_depth)
+			cookie = m68k_btop(m68k_trunc_page(OMFB_FB_RADDR) +
+			    offset);
+		break;
+	}
 
 	return cookie;
 }
@@ -362,42 +382,10 @@ omsetcmap(struct omfb_softc *sc, struct 
 }
 
 static void
-omfb_getdevconfig(paddr_t paddr, struct om_hwdevconfig *dc)
+omfb_resetcmap(struct om_hwdevconfig *dc)
 {
-	int bpp, i;
-	struct rasops_info *ri;
-	union {
-		struct { short h, v; } p;
-		uint32_t u;
-	} rfcnt;
-
-	switch (hwplanemask) {
-	case 0xff:
-		bpp = 8;	/* XXX check monochrome bit in DIPSW */
-		break;
-	default:
-	case 0x0f:
-#if 1
-		/*
-		 * XXX
-		 * experiment resulted in WHITE on SKYBLUE after Xorg server
-		 * touches pallete. Disable 4bpp for now.
-		 */
-		bpp = 4;	/* XXX check monochrome bit in DIPSW */
-		break;
-#endif
-	case 1:
-		bpp = 1;
-		break;
-	}
-	dc->dc_wid = 1280;
-	dc->dc_ht = 1024;
-	dc->dc_depth = bpp;
-	dc->dc_rowbytes = 2048 / 8;
-	dc->dc_cmsize = (bpp == 1) ? 0 : 1 << bpp;
-	dc->dc_videobase = paddr;
+	int i;
 
-	/* WHITE on BLACK */
 	if (hwplanemask == 0x01) {
 		struct bt454 *odac = (struct bt454 *)OMFB_RAMDAC;
 
@@ -431,7 +419,11 @@ omfb_getdevconfig(paddr_t paddr, struct 
 	} else if (hwplanemask == 0xff) {
 		struct bt458 *ndac = (struct bt458 *)OMFB_RAMDAC;
 
-		/* Initialize the Bt458 */
+		/*
+		 * Initialize the Bt458.  When we write to control registers,
+		 * the address is not incremented automatically. So we specify
+		 * it ourselves for each control register.
+		 */
 		ndac->bt_addr = 0x04;
 		ndac->bt_ctrl = 0xff; /* all planes will be read */
 		ndac->bt_addr = 0x05;
@@ -441,16 +433,49 @@ omfb_getdevconfig(paddr_t paddr, struct 
 		ndac->bt_addr = 0x07;
 		ndac->bt_ctrl = 0x00; /* no test mode */
 
+		/*
+		 * Set ANSI 16 colors.  We only supports 4bpp console right
+		 * now, repeat 16 colors in 256 colormap.
+		 */
 		ndac->bt_addr = 0;
-		ndac->bt_cmap = dc->dc_cmap.r[0] = 0;
-		ndac->bt_cmap = dc->dc_cmap.g[0] = 0;
-		ndac->bt_cmap = dc->dc_cmap.b[0] = 0;
-		for (i = 1; i < 256; i++) {
-			ndac->bt_cmap = dc->dc_cmap.r[i] = 255;
-			ndac->bt_cmap = dc->dc_cmap.g[i] = 255;
-			ndac->bt_cmap = dc->dc_cmap.b[i] = 255;
+		for (i = 0; i < 256; i++) {
+			ndac->bt_cmap = dc->dc_cmap.r[i] = ansicmap[i % 16].r;
+			ndac->bt_cmap = dc->dc_cmap.g[i] = ansicmap[i % 16].g;
+			ndac->bt_cmap = dc->dc_cmap.b[i] = ansicmap[i % 16].b;
 		}
 	}
+}
+
+static void
+omfb_getdevconfig(paddr_t paddr, struct om_hwdevconfig *dc)
+{
+	int bpp, i;
+	struct rasops_info *ri;
+	union {
+		struct { short h, v; } p;
+		uint32_t u;
+	} rfcnt;
+
+	switch (hwplanemask) {
+	case 0xff:
+		bpp = 8;	/* XXX check monochrome bit in DIPSW */
+		break;
+	default:
+	case 0x0f:
+		bpp = 4;	/* XXX check monochrome bit in DIPSW */
+		break;
+	case 1:
+		bpp = 1;
+		break;
+	}
+	dc->dc_wid = 1280;
+	dc->dc_ht = 1024;
+	dc->dc_depth = bpp;
+	dc->dc_rowbytes = 2048 / 8;
+	dc->dc_cmsize = (bpp == 1) ? 0 : 1 << bpp;
+	dc->dc_videobase = paddr;
+
+	omfb_resetcmap(dc);
 
 	/* adjust h/v origin on screen */
 	rfcnt.p.h = 7;
@@ -477,7 +502,7 @@ omfb_getdevconfig(paddr_t paddr, struct 
 		ri->ri_flg |= RI_NO_AUTO;
 	ri->ri_hw = dc;
 
-	if (bpp == 4)
+	if (bpp == 4 || bpp == 8)
 		omrasops4_init(ri, 34, 80);
 	else
 		omrasops1_init(ri, 34, 80);
@@ -497,14 +522,14 @@ omfb_alloc_screen(void *v, const struct 
 	struct omfb_softc *sc = v;
 	struct rasops_info *ri = &sc->sc_dc->dc_ri;
 
-	if (sc->nscreens > 0)
+	if (sc->sc_nscreens > 0)
 		return ENOMEM;
 
 	*cookiep = ri;
 	*curxp = 0;
 	*curyp = 0;
 	(*ri->ri_ops.allocattr)(ri, 0, 0, 0, attrp);
-	sc->nscreens++;
+	sc->sc_nscreens++;
 	return 0;
 }
 
@@ -516,7 +541,7 @@ omfb_free_screen(void *v, void *cookie)
 	if (sc->sc_dc == &omfb_console_dc)
 		panic("omfb_free_screen: console");
 
-	sc->nscreens--;
+	sc->sc_nscreens--;
 }
 
 static int

Index: src/sys/arch/luna68k/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.23.8.2 src/sys/arch/luna68k/dev/lunaws.c:1.23.8.3
--- src/sys/arch/luna68k/dev/lunaws.c:1.23.8.2	Sun Jan 12 12:21:16 2014
+++ src/sys/arch/luna68k/dev/lunaws.c	Sun Nov  9 07:34:12 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.23.8.2 2014/01/12 12:21:16 bouyer Exp $ */
+/* $NetBSD: lunaws.c,v 1.23.8.3 2014/11/09 07:34:12 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,8 +31,9 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.23.8.2 2014/01/12 12:21:16 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.23.8.3 2014/11/09 07:34:12 msaitoh Exp $");
 
+#include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
 
 #include <sys/param.h>
@@ -46,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1
 #include <dev/wscons/wsksymvar.h>
 #include <dev/wscons/wsmousevar.h>
 
+#include <luna68k/dev/omkbdmap.h>
 #include <luna68k/dev/sioreg.h>
 #include <luna68k/dev/siovar.h>
 
@@ -78,16 +80,15 @@ struct ws_softc {
 	int		sc_msbuttons, sc_msdx, sc_msdy;
 #endif
 	void		*sc_si;
+	int		sc_rawkbd;
 };
 
 static void omkbd_input(void *, int);
-static int  omkbd_decode(void *, int, u_int *, int *);
+static void omkbd_decode(void *, int, u_int *, int *);
 static int  omkbd_enable(void *, int);
 static void omkbd_set_leds(void *, int);
 static int  omkbd_ioctl(void *, u_long, void *, int, struct lwp *);
 
-struct wscons_keydesc omkbd_keydesctab[];
-
 static const struct wskbd_mapdata omkbd_keymapdata = {
 	omkbd_keydesctab,
 	KB_JP,
@@ -268,143 +269,48 @@ omkbd_input(void *v, int data)
 	u_int type;
 	int key;
 
-	if (omkbd_decode(v, data, &type, &key))
-		wskbd_input(sc->sc_wskbddev, type, key);
+	omkbd_decode(v, data, &type, &key);
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	if (sc->sc_rawkbd) {
+		uint8_t cbuf[2];
+		int c, j = 0;
+
+		c = omkbd_raw[key];
+		if (c != 0x00) {
+			/* fake extended scancode if necessary */
+			if (c & 0x80)
+				cbuf[j++] = 0xe0;
+			cbuf[j] = c & 0x7f;
+			if (type == WSCONS_EVENT_KEY_UP)
+				cbuf[j] |= 0x80;
+			j++;
+
+			wskbd_rawinput(sc->sc_wskbddev, cbuf, j);
+		}
+	} else
+#endif
+	{
+		if (sc->sc_wskbddev != NULL)
+			wskbd_input(sc->sc_wskbddev, type, key);
+	}
 }
 
-static int
+static void
 omkbd_decode(void *v, int datain, u_int *type, int *dataout)
 {
 
 	*type = (datain & 0x80) ? WSCONS_EVENT_KEY_UP : WSCONS_EVENT_KEY_DOWN;
 	*dataout = datain & 0x7f;
-	return 1;
 }
 
-#define KC(n) KS_KEYCODE(n)
-
-static const keysym_t omkbd_keydesc_1[] = {
-/*  pos      command		normal		shifted */
-    KC(0x9),			KS_Tab,
-    KC(0xa),			KS_Control_L,
-    KC(0xb),			KS_Mode_switch,	/* Kana */
-    KC(0xc),			KS_Shift_R,
-    KC(0xd),			KS_Shift_L,
-    KC(0xe),			KS_Caps_Lock,
-    KC(0xf),			KS_Meta_L,	/* Zenmen */
-    KC(0x10),			KS_Escape,
-    KC(0x11),			KS_BackSpace,
-    KC(0x12),			KS_Return,
-    KC(0x14),			KS_space,
-    KC(0x15),			KS_Delete,
-    KC(0x16),			KS_Alt_L,	/* Henkan */
-    KC(0x17),			KS_Alt_R,	/* Kakutei */
-    KC(0x18),			KS_f11,		/* Shokyo */
-    KC(0x19),			KS_f12,		/* Yobidashi */
-    KC(0x1a),			KS_f13,		/* Bunsetsu L */
-    KC(0x1b),			KS_f14,		/* Bunsetsu R */
-    KC(0x1c),			KS_KP_Up,
-    KC(0x1d),			KS_KP_Left,
-    KC(0x1e),			KS_KP_Right,
-    KC(0x1f),			KS_KP_Down,
- /* KC(0x20),			KS_f11, */
- /* KC(0x21),			KS_f12, */
-    KC(0x22),			KS_1,		KS_exclam,
-    KC(0x23),			KS_2,		KS_quotedbl,
-    KC(0x24),			KS_3,		KS_numbersign,
-    KC(0x25),			KS_4,		KS_dollar,
-    KC(0x26),			KS_5,		KS_percent,
-    KC(0x27),			KS_6,		KS_ampersand,
-    KC(0x28),			KS_7,		KS_apostrophe,
-    KC(0x29),			KS_8,		KS_parenleft,
-    KC(0x2a),			KS_9,		KS_parenright,
-    KC(0x2b),			KS_0,
-    KC(0x2c),			KS_minus,	KS_equal,
-    KC(0x2d),			KS_asciicircum,	KS_asciitilde,
-    KC(0x2e),			KS_backslash,	KS_bar,
- /* KC(0x30),			KS_f13, */
- /* KC(0x31),			KS_f14, */
-    KC(0x32),			KS_q,
-    KC(0x33),			KS_w,
-    KC(0x34),			KS_e,
-    KC(0x35),			KS_r,
-    KC(0x36),			KS_t,
-    KC(0x37),			KS_y,
-    KC(0x38),			KS_u,
-    KC(0x39),			KS_i,
-    KC(0x3a),			KS_o,
-    KC(0x3b),			KS_p,
-    KC(0x3c),			KS_at,		KS_grave,
-    KC(0x3d),			KS_bracketleft,	KS_braceleft,
-    KC(0x42),			KS_a,
-    KC(0x43),			KS_s,
-    KC(0x44),			KS_d,
-    KC(0x45),			KS_f,
-    KC(0x46),			KS_g,
-    KC(0x47),			KS_h,
-    KC(0x48),			KS_j,
-    KC(0x49),			KS_k,
-    KC(0x4a),			KS_l,
-    KC(0x4b),			KS_semicolon,	KS_plus,
-    KC(0x4c),			KS_colon,	KS_asterisk,
-    KC(0x4d),			KS_bracketright, KS_braceright,
-    KC(0x52),			KS_z,
-    KC(0x53),			KS_x,
-    KC(0x54),			KS_c,
-    KC(0x55),			KS_v,
-    KC(0x56),			KS_b,
-    KC(0x57),			KS_n,
-    KC(0x58),			KS_m,
-    KC(0x59),			KS_comma,	KS_less,
-    KC(0x5a),			KS_period,	KS_greater,
-    KC(0x5b),			KS_slash,	KS_question,
-    KC(0x5c),			KS_underscore,
-    KC(0x60),			KS_KP_Delete,
-    KC(0x61),			KS_KP_Add,
-    KC(0x62),			KS_KP_Subtract,
-    KC(0x63),			KS_KP_7,
-    KC(0x64),			KS_KP_8,
-    KC(0x65),			KS_KP_9,
-    KC(0x66),			KS_KP_4,
-    KC(0x67),			KS_KP_5,
-    KC(0x68),			KS_KP_6,
-    KC(0x69),			KS_KP_1,
-    KC(0x6a),			KS_KP_2,
-    KC(0x6b),			KS_KP_3,
-    KC(0x6c),			KS_KP_0,
-    KC(0x6d),			KS_KP_Decimal,
-    KC(0x6e),			KS_KP_Enter,
-    KC(0x72),			KS_f1,
-    KC(0x73),			KS_f2,
-    KC(0x74),			KS_f3,
-    KC(0x75),			KS_f4,
-    KC(0x76),			KS_f5,
-    KC(0x77),			KS_f6,
-    KC(0x78),			KS_f7,
-    KC(0x79),			KS_f8,
-    KC(0x7a),			KS_f9,
-    KC(0x7b),			KS_f10,
-    KC(0x7c),			KS_KP_Multiply,
-    KC(0x7d),			KS_KP_Divide,
-    KC(0x7e),			KS_KP_Equal,
-    KC(0x7f),			KS_KP_Separator,
-};
-
-#define	SIZE(map) (sizeof(map)/sizeof(keysym_t))
-
-struct wscons_keydesc omkbd_keydesctab[] = {
-	{ KB_JP, 0, SIZE(omkbd_keydesc_1), omkbd_keydesc_1, },
-	{ 0, 0, 0, 0 },
-};
-
 static void
 ws_cngetc(void *v, u_int *type, int *data)
 {
 	int code;
 
-	do {
-		code = syscngetc((dev_t)1);
-	} while (!omkbd_decode(v, code, type, data));
+	code = syscngetc((dev_t)1);
+	omkbd_decode(v, code, type, data);
 }
 
 static void
@@ -444,6 +350,9 @@ omkbd_set_leds(void *v, int leds)
 static int
 omkbd_ioctl(void *v, u_long cmd, void *data, int flag, struct lwp *l)
 {
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	struct ws_softc *sc = v;
+#endif
 
 	switch (cmd) {
 	case WSKBDIO_GTYPE:
@@ -453,6 +362,14 @@ omkbd_ioctl(void *v, u_long cmd, void *d
 	case WSKBDIO_GETLEDS:
 	case WSKBDIO_COMPLEXBELL:	/* XXX capable of complex bell */
 		return 0;
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+	case WSKBDIO_SETMODE:
+		sc->sc_rawkbd = *(int *)data == WSKBD_RAW;
+		return 0;
+	case WSKBDIO_GETMODE:
+		*(int *)data = sc->sc_rawkbd;
+		return 0;
+#endif
 	}
 	return EPASSTHROUGH;
 }

Index: src/sys/arch/luna68k/dev/omrasops.c
diff -u src/sys/arch/luna68k/dev/omrasops.c:1.11.8.2 src/sys/arch/luna68k/dev/omrasops.c:1.11.8.3
--- src/sys/arch/luna68k/dev/omrasops.c:1.11.8.2	Sun Jan 12 12:25:03 2014
+++ src/sys/arch/luna68k/dev/omrasops.c	Sun Nov  9 07:34:12 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.11.8.2 2014/01/12 12:25:03 bouyer Exp $ */
+/* $NetBSD: omrasops.c,v 1.11.8.3 2014/11/09 07:34:12 msaitoh Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.11.8.2 2014/01/12 12:25:03 bouyer Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.11.8.3 2014/11/09 07:34:12 msaitoh Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
@@ -68,6 +68,7 @@ static void	om1_eraserows(void *, int, i
 static void	om4_eraserows(void *, int, int, long);
 static int	om1_allocattr(void *, int, int, int, long *);
 static int	om4_allocattr(void *, int, int, int, long *);
+static void	om4_unpack_attr(long, int *, int *, int *);
 
 static int	omrasops_init(struct rasops_info *, int, int);
 
@@ -77,13 +78,6 @@ static int	omrasops_init(struct rasops_i
 #define	ALIGNMASK	(0x1f)
 #define	BYTESDONE	(4)
 
-#define	W(p) (*(uint32_t *)(p))
-#define	R(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000))
-#define	P0(p) (*(uint32_t *)((uint8_t *)(p) + 0x40000))
-#define	P1(p) (*(uint32_t *)((uint8_t *)(p) + 0x80000))
-#define	P2(p) (*(uint32_t *)((uint8_t *)(p) + 0xc0000))
-#define	P3(p) (*(uint32_t *)((uint8_t *)(p) + 0x100000))
-
 /*
  * macros to handle unaligned bit copy ops.
  * See src/sys/dev/rasops/rasops_mask.h for MI version.
@@ -95,13 +89,13 @@ static int	omrasops_init(struct rasops_i
 #define	FASTGETBITS(psrc, x, w, dst)					\
 	asm("bfextu %3{%1:%2},%0"					\
 	    : "=d" (dst) 						\
-	    : "di" (x), "di" (w), "o" ((uint32_t *)(psrc)))
+	    : "di" (x), "di" (w), "o" (*(uint32_t *)(psrc)))
 
 /* luna68k version PUTBITS() that puts w bits from bit x at pdst memory */
 /* XXX this macro assumes (x + w) <= 32 to handle unaligned residual bits */
 #define	FASTPUTBITS(src, x, w, pdst)					\
 	asm("bfins %3,%0{%1:%2}"					\
-	    : "+o" ((uint32_t *)(pdst))					\
+	    : "+o" (*(uint32_t *)(pdst))				\
 	    : "di" (x), "di" (w), "d" (src)				\
 	    : "memory" );
 
@@ -136,16 +130,23 @@ om1_putchar(void *cookie, int row, int s
 	rmask = ALL1BITS << (-width & ALIGNMASK);
 	if (width <= BLITWIDTH) {
 		lmask &= rmask;
+		/* set lmask as ROP mask value, with THROUGH mode */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = lmask;
+
 		while (height > 0) {
 			glyph = 0;
 			for (i = ri->ri_font->stride; i != 0; i--)
 				glyph = (glyph << 8) | *fb++;
 			glyph <<= (4 - ri->ri_font->stride) * NBBY;
 			glyph = (glyph >> align) ^ inverse;
-			P0(p) = (P0(p) & ~lmask) | (glyph & lmask);
+
+			*W(p) = glyph;
+
 			p += scanspan;
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	} else {
 		uint8_t *q = p;
 		uint32_t lhalf, rhalf;
@@ -156,14 +157,26 @@ om1_putchar(void *cookie, int row, int s
 				glyph = (glyph << 8) | *fb++;
 			glyph <<= (4 - ri->ri_font->stride) * NBBY;
 			lhalf = (glyph >> align) ^ inverse;
-			P0(p) = (P0(p) & ~lmask) | (lhalf & lmask);
+			/* set lmask as ROP mask value, with THROUGH mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+			    lmask;
+			
+			*W(p) = lhalf;
+
 			p += BYTESDONE;
+
 			rhalf = (glyph << (BLITWIDTH - align)) ^ inverse;
-			P0(p) = (rhalf & rmask) | (P0(p) & ~rmask);
+			/* set rmask as ROP mask value, with THROUGH mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+			    rmask;
+
+			*W(p) = rhalf;
 
 			p = (q += scanspan);
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	}
 }
 
@@ -173,9 +186,10 @@ om4_putchar(void *cookie, int row, int s
 	struct rasops_info *ri = cookie;
 	uint8_t *p;
 	int scanspan, startx, height, width, align, y;
-	uint32_t lmask, rmask, glyph;
-	uint32_t glyphbg, fg, bg;
-	int i;
+	uint32_t lmask, rmask, glyph, glyphbg, fgpat, bgpat;
+	uint32_t fgmask0, fgmask1, fgmask2, fgmask3;
+	uint32_t bgmask0, bgmask1, bgmask2, bgmask3;
+	int i, fg, bg;
 	uint8_t *fb;
 
 	scanspan = ri->ri_stride;
@@ -184,14 +198,30 @@ om4_putchar(void *cookie, int row, int s
 	height = ri->ri_font->fontheight;
 	fb = (uint8_t *)ri->ri_font->data +
 	    (uc - ri->ri_font->firstchar) * ri->ri_fontscale;
+	om4_unpack_attr(attr, &fg, &bg, NULL);
+	fgmask0 = (fg & 0x01) ? ALL1BITS : ALL0BITS;
+	fgmask1 = (fg & 0x02) ? ALL1BITS : ALL0BITS;
+	fgmask2 = (fg & 0x04) ? ALL1BITS : ALL0BITS;
+	fgmask3 = (fg & 0x08) ? ALL1BITS : ALL0BITS;
+	bgmask0 = (bg & 0x01) ? ALL1BITS : ALL0BITS;
+	bgmask1 = (bg & 0x02) ? ALL1BITS : ALL0BITS;
+	bgmask2 = (bg & 0x04) ? ALL1BITS : ALL0BITS;
+	bgmask3 = (bg & 0x08) ? ALL1BITS : ALL0BITS;
 
 	p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
 	align = startx & ALIGNMASK;
 	width = ri->ri_font->fontwidth + align;
 	lmask = ALL1BITS >> align;
 	rmask = ALL1BITS << (-width & ALIGNMASK);
+
+	/* select all planes for later ROP function target */
+	*(volatile uint32_t *)OMFB_PLANEMASK = 0xff;
+
 	if (width <= BLITWIDTH) {
 		lmask &= rmask;
+		/* set lmask as ROP mask value, with THROUGH mode */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = lmask;
+
 		while (height > 0) {
 			glyph = 0;
 			for (i = ri->ri_font->stride; i != 0; i--)
@@ -199,21 +229,25 @@ om4_putchar(void *cookie, int row, int s
 			glyph <<= (4 - ri->ri_font->stride) * NBBY;
 			glyph = (glyph >> align);
 			glyphbg = glyph ^ ALL1BITS;
-			fg = (attr & 0x01000000) ? glyph : 0;
-			bg = (attr & 0x00010000) ? glyphbg : 0;
-			P0(p) = (P0(p) & ~lmask) | ((fg | bg) & lmask);
-			fg = (attr & 0x02000000) ? glyph : 0;
-			bg = (attr & 0x00020000) ? glyphbg : 0;
-			P1(p) = (P1(p) & ~lmask) | ((fg | bg) & lmask);
-			fg = (attr & 0x04000000) ? glyph : 0;
-			bg = (attr & 0x00040000) ? glyphbg : 0;
-			P2(p) = (P2(p) & ~lmask) | ((fg | bg) & lmask);
-			fg = (attr & 0x08000000) ? glyph : 0;
-			bg = (attr & 0x00080000) ? glyphbg : 0;
-			P3(p) = (P3(p) & ~lmask) | ((fg | bg) & lmask);
+
+			fgpat = glyph   & fgmask0;
+			bgpat = glyphbg & bgmask0;
+			*P0(p) = (fgpat | bgpat);
+			fgpat = glyph   & fgmask1;
+			bgpat = glyphbg & bgmask1;
+			*P1(p) = (fgpat | bgpat);
+			fgpat = glyph   & fgmask2;
+			bgpat = glyphbg & bgmask2;
+			*P2(p) = (fgpat | bgpat);
+			fgpat = glyph   & fgmask3;
+			bgpat = glyphbg & bgmask3;
+			*P3(p) = (fgpat | bgpat);
+
 			p += scanspan;
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	} else {
 		uint8_t *q = p;
 		uint32_t lhalf, rhalf;
@@ -226,38 +260,52 @@ om4_putchar(void *cookie, int row, int s
 			glyph <<= (4 - ri->ri_font->stride) * NBBY;
 			lhalf = (glyph >> align);
 			lhalfbg = lhalf ^ ALL1BITS;
-			fg = (attr & 0x01000000) ? lhalf : 0;
-			bg = (attr & 0x00010000) ? lhalfbg : 0;
-			P0(p) = (P0(p) & ~lmask) | ((fg | bg) & lmask);
-			fg = (attr & 0x02000000) ? lhalf : 0;
-			bg = (attr & 0x00020000) ? lhalfbg : 0;
-			P1(p) = (P1(p) & ~lmask) | ((fg | bg) & lmask);
-			fg = (attr & 0x04000000) ? lhalf : 0;
-			bg = (attr & 0x00040000) ? lhalfbg : 0;
-			P2(p) = (P2(p) & ~lmask) | ((fg | bg) & lmask);
-			fg = (attr & 0x08000000) ? lhalf : 0;
-			bg = (attr & 0x00080000) ? lhalfbg : 0;
-			P3(p) = (P3(p) & ~lmask) | ((fg | bg) & lmask);
+			/* set lmask as ROP mask value, with THROUGH mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+			    lmask;
+
+			fgpat = lhalf   & fgmask0;
+			bgpat = lhalfbg & bgmask0;
+			*P0(p) = (fgpat | bgpat);
+			fgpat = lhalf   & fgmask1;
+			bgpat = lhalfbg & bgmask1;
+			*P1(p) = (fgpat | bgpat);
+			fgpat = lhalf   & fgmask2;
+			bgpat = lhalfbg & bgmask2;
+			*P2(p) = (fgpat | bgpat);
+			fgpat = lhalf   & fgmask3;
+			bgpat = lhalfbg & bgmask3;
+			*P3(p) = (fgpat | bgpat);
+
 			p += BYTESDONE;
+
 			rhalf = (glyph << (BLITWIDTH - align));
 			rhalfbg = rhalf ^ ALL1BITS;
-			fg = (attr & 0x01000000) ? rhalf : 0;
-			bg = (attr & 0x00010000) ? rhalfbg : 0;
-			P0(p) = ((fg | bg) & rmask) | (P0(p) & ~rmask);
-			fg = (attr & 0x02000000) ? rhalf : 0;
-			bg = (attr & 0x00020000) ? rhalfbg : 0;
-			P1(p) = ((fg | bg) & rmask) | (P1(p) & ~rmask);
-			fg = (attr & 0x04000000) ? rhalf : 0;
-			bg = (attr & 0x00040000) ? rhalfbg : 0;
-			P2(p) = ((fg | bg) & rmask) | (P2(p) & ~rmask);
-			fg = (attr & 0x08000000) ? rhalf : 0;
-			bg = (attr & 0x00080000) ? rhalfbg : 0;
-			P3(p) = ((fg | bg) & rmask) | (P3(p) & ~rmask);
+			/* set rmask as ROP mask value, with THROUGH mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] =
+			    rmask;
+
+			fgpat = rhalf   & fgmask0;
+			bgpat = rhalfbg & bgmask0;
+			*P0(p) = (fgpat | bgpat);
+			fgpat = rhalf   & fgmask1;
+			bgpat = rhalfbg & bgmask1;
+			*P1(p) = (fgpat | bgpat);
+			fgpat = rhalf   & fgmask2;
+			bgpat = rhalfbg & bgmask2;
+			*P2(p) = (fgpat | bgpat);
+			fgpat = rhalf   & fgmask3;
+			bgpat = rhalfbg & bgmask3;
+			*P3(p) = (fgpat | bgpat);
 
 			p = (q += scanspan);
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	}
+	/* select plane #0 only; XXX need this ? */
+	*(volatile uint32_t *)OMFB_PLANEMASK = 0x01;
 }
 
 static void
@@ -284,22 +332,22 @@ om1_erasecols(void *cookie, int row, int
 		lmask &= rmask;
 		fill  &= lmask;
 		while (height > 0) {
-			P0(p) = (P0(p) & ~lmask) | fill;
+			*P0(p) = (*P0(p) & ~lmask) | fill;
 			p += scanspan;
 			height--;
 		}
 	} else {
 		uint8_t *q = p;
 		while (height > 0) {
-			P0(p) = (P0(p) & ~lmask) | (fill & lmask);
+			*P0(p) = (*P0(p) & ~lmask) | (fill & lmask);
 			width -= 2 * BLITWIDTH;
 			while (width > 0) {
 				p += BYTESDONE;
-				P0(p) = fill;
+				*P0(p) = fill;
 				width -= BLITWIDTH;
 			}
 			p += BYTESDONE;
-			P0(p) = (fill & rmask) | (P0(p) & ~rmask);
+			*P0(p) = (fill & rmask) | (*P0(p) & ~rmask);
 
 			p = (q += scanspan);
 			width = w + align;
@@ -313,7 +361,7 @@ om4_erasecols(void *cookie, int row, int
 {
 	struct rasops_info *ri = cookie;
 	uint8_t *p;
-	int scanspan, startx, height, width, align, w, y;
+	int scanspan, startx, height, width, align, w, y, fg, bg;
 	uint32_t lmask, rmask, fill0, fill1, fill2, fill3;
 
 	scanspan = ri->ri_stride;;
@@ -321,10 +369,11 @@ om4_erasecols(void *cookie, int row, int
 	startx = ri->ri_font->fontwidth * startcol;
 	height = ri->ri_font->fontheight;
 	w = ri->ri_font->fontwidth * ncols;
-	fill0 = ((attr & 0x00010000) != 0) ? ALL1BITS : ALL0BITS;
-	fill1 = ((attr & 0x00020000) != 0) ? ALL1BITS : ALL0BITS;
-	fill2 = ((attr & 0x00040000) != 0) ? ALL1BITS : ALL0BITS;
-	fill3 = ((attr & 0x00080000) != 0) ? ALL1BITS : ALL0BITS;
+	om4_unpack_attr(attr, &fg, &bg, NULL);
+	fill0 = ((bg & 0x01) != 0) ? ALL1BITS : ALL0BITS;
+	fill1 = ((bg & 0x02) != 0) ? ALL1BITS : ALL0BITS;
+	fill2 = ((bg & 0x04) != 0) ? ALL1BITS : ALL0BITS;
+	fill3 = ((bg & 0x08) != 0) ? ALL1BITS : ALL0BITS;
 
 	p = (uint8_t *)ri->ri_bits + y * scanspan + ((startx / 32) * 4);
 	align = startx & ALIGNMASK;
@@ -338,34 +387,34 @@ om4_erasecols(void *cookie, int row, int
 		fill2 &= lmask;
 		fill3 &= lmask;
 		while (height > 0) {
-			P0(p) = (P0(p) & ~lmask) | fill0;
-			P1(p) = (P1(p) & ~lmask) | fill1;
-			P2(p) = (P2(p) & ~lmask) | fill2;
-			P3(p) = (P3(p) & ~lmask) | fill3;
+			*P0(p) = (*P0(p) & ~lmask) | fill0;
+			*P1(p) = (*P1(p) & ~lmask) | fill1;
+			*P2(p) = (*P2(p) & ~lmask) | fill2;
+			*P3(p) = (*P3(p) & ~lmask) | fill3;
 			p += scanspan;
 			height--;
 		}
 	} else {
 		uint8_t *q = p;
 		while (height > 0) {
-			P0(p) = (P0(p) & ~lmask) | (fill0 & lmask);
-			P1(p) = (P1(p) & ~lmask) | (fill1 & lmask);
-			P2(p) = (P2(p) & ~lmask) | (fill2 & lmask);
-			P3(p) = (P3(p) & ~lmask) | (fill3 & lmask);
+			*P0(p) = (*P0(p) & ~lmask) | (fill0 & lmask);
+			*P1(p) = (*P1(p) & ~lmask) | (fill1 & lmask);
+			*P2(p) = (*P2(p) & ~lmask) | (fill2 & lmask);
+			*P3(p) = (*P3(p) & ~lmask) | (fill3 & lmask);
 			width -= 2 * BLITWIDTH;
 			while (width > 0) {
 				p += BYTESDONE;
-				P0(p) = fill0;
-				P1(p) = fill1;
-				P2(p) = fill2;
-				P3(p) = fill3;
+				*P0(p) = fill0;
+				*P1(p) = fill1;
+				*P2(p) = fill2;
+				*P3(p) = fill3;
 				width -= BLITWIDTH;
 			}
 			p += BYTESDONE;
-			P0(p) = (fill0 & rmask) | (P0(p) & ~rmask);
-			P1(p) = (fill1 & rmask) | (P1(p) & ~rmask);
-			P2(p) = (fill2 & rmask) | (P2(p) & ~rmask);
-			P3(p) = (fill3 & rmask) | (P3(p) & ~rmask);
+			*P0(p) = (fill0 & rmask) | (*P0(p) & ~rmask);
+			*P1(p) = (fill1 & rmask) | (*P1(p) & ~rmask);
+			*P2(p) = (fill2 & rmask) | (*P2(p) & ~rmask);
+			*P3(p) = (fill3 & rmask) | (*P3(p) & ~rmask);
 
 			p = (q += scanspan);
 			width = w + align;
@@ -393,15 +442,15 @@ om1_eraserows(void *cookie, int startrow
 	rmask = ALL1BITS << (-width & ALIGNMASK);
 	q = p;
 	while (height > 0) {
-		P0(p) = fill;				/* always aligned */
+		*P0(p) = fill;				/* always aligned */
 		width -= 2 * BLITWIDTH;
 		while (width > 0) {
 			p += BYTESDONE;
-			P0(p) = fill;
+			*P0(p) = fill;
 			width -= BLITWIDTH;
 		}
 		p += BYTESDONE;
-		P0(p) = (fill & rmask) | (P0(p) & ~rmask);
+		*P0(p) = (fill & rmask) | (*P0(p) & ~rmask);
 		p = (q += scanspan);
 		width = w;
 		height--;
@@ -413,41 +462,42 @@ om4_eraserows(void *cookie, int startrow
 {
 	struct rasops_info *ri = cookie;
 	uint8_t *p, *q;
-	int scanspan, starty, height, width, w;
+	int scanspan, starty, height, width, w, fg, bg;
 	uint32_t rmask, fill0, fill1, fill2, fill3;
 
 	scanspan = ri->ri_stride;
 	starty = ri->ri_font->fontheight * startrow;
 	height = ri->ri_font->fontheight * nrows;
 	w = ri->ri_emuwidth;
-	fill0 = ((attr & 0x00010000) != 0) ? ALL1BITS : ALL0BITS;
-	fill1 = ((attr & 0x00020000) != 0) ? ALL1BITS : ALL0BITS;
-	fill2 = ((attr & 0x00040000) != 0) ? ALL1BITS : ALL0BITS;
-	fill3 = ((attr & 0x00080000) != 0) ? ALL1BITS : ALL0BITS;
+	om4_unpack_attr(attr, &fg, &bg, NULL);
+	fill0 = ((bg & 0x01) != 0) ? ALL1BITS : ALL0BITS;
+	fill1 = ((bg & 0x02) != 0) ? ALL1BITS : ALL0BITS;
+	fill2 = ((bg & 0x04) != 0) ? ALL1BITS : ALL0BITS;
+	fill3 = ((bg & 0x08) != 0) ? ALL1BITS : ALL0BITS;
 
 	p = (uint8_t *)ri->ri_bits + starty * scanspan;
 	width = w;
 	rmask = ALL1BITS << (-width & ALIGNMASK);
 	q = p;
 	while (height > 0) {
-		P0(p) = fill0;				/* always aligned */
-		P1(p) = fill1;
-		P2(p) = fill2;
-		P3(p) = fill3;
+		*P0(p) = fill0;				/* always aligned */
+		*P1(p) = fill1;
+		*P2(p) = fill2;
+		*P3(p) = fill3;
 		width -= 2 * BLITWIDTH;
 		while (width > 0) {
 			p += BYTESDONE;
-			P0(p) = fill0;
-			P1(p) = fill1;
-			P2(p) = fill2;
-			P3(p) = fill3;
+			*P0(p) = fill0;
+			*P1(p) = fill1;
+			*P2(p) = fill2;
+			*P3(p) = fill3;
 			width -= BLITWIDTH;
 		}
 		p += BYTESDONE;
-		P0(p) = (fill0 & rmask) | (P0(p) & ~rmask);
-		P1(p) = (fill1 & rmask) | (P1(p) & ~rmask);
-		P2(p) = (fill2 & rmask) | (P2(p) & ~rmask);
-		P3(p) = (fill3 & rmask) | (P3(p) & ~rmask);
+		*P0(p) = (fill0 & rmask) | (*P0(p) & ~rmask);
+		*P1(p) = (fill1 & rmask) | (*P1(p) & ~rmask);
+		*P2(p) = (fill2 & rmask) | (*P2(p) & ~rmask);
+		*P3(p) = (fill3 & rmask) | (*P3(p) & ~rmask);
 		p = (q += scanspan);
 		width = w;
 		height--;
@@ -477,15 +527,15 @@ om1_copyrows(void *cookie, int srcrow, i
 	rmask = ALL1BITS << (-width & ALIGNMASK);
 	q = p;
 	while (height > 0) {
-		P0(p + offset) = P0(p);			/* always aligned */
+		*P0(p + offset) = *P0(p);		/* always aligned */
 		width -= 2 * BLITWIDTH;
 		while (width > 0) {
 			p += BYTESDONE;
-			P0(p + offset) = P0(p);
+			*P0(p + offset) = *P0(p);
 			width -= BLITWIDTH;
 		}
 		p += BYTESDONE;
-		P0(p + offset) = (P0(p) & rmask) | (P0(p + offset) & ~rmask);
+		*P0(p + offset) = (*P0(p) & rmask) | (*P0(p + offset) & ~rmask);
 
 		p = (q += scanspan);
 		width = w;
@@ -516,24 +566,24 @@ om4_copyrows(void *cookie, int srcrow, i
 	rmask = ALL1BITS << (-width & ALIGNMASK);
 	q = p;
 	while (height > 0) {
-		P0(p + offset) = P0(p);			/* always aligned */
-		P1(p + offset) = P1(p);
-		P2(p + offset) = P2(p);
-		P3(p + offset) = P3(p);
+		*P0(p + offset) = *P0(p);		/* always aligned */
+		*P1(p + offset) = *P1(p);
+		*P2(p + offset) = *P2(p);
+		*P3(p + offset) = *P3(p);
 		width -= 2 * BLITWIDTH;
 		while (width > 0) {
 			p += BYTESDONE;
-			P0(p + offset) = P0(p);
-			P1(p + offset) = P1(p);
-			P2(p + offset) = P2(p);
-			P3(p + offset) = P3(p);
+			*P0(p + offset) = *P0(p);
+			*P1(p + offset) = *P1(p);
+			*P2(p + offset) = *P2(p);
+			*P3(p + offset) = *P3(p);
 			width -= BLITWIDTH;
 		}
 		p += BYTESDONE;
-		P0(p + offset) = (P0(p) & rmask) | (P0(p + offset) & ~rmask);
-		P1(p + offset) = (P1(p) & rmask) | (P1(p + offset) & ~rmask);
-		P2(p + offset) = (P2(p) & rmask) | (P2(p + offset) & ~rmask);
-		P3(p + offset) = (P3(p) & rmask) | (P3(p + offset) & ~rmask);
+		*P0(p + offset) = (*P0(p) & rmask) | (*P0(p + offset) & ~rmask);
+		*P1(p + offset) = (*P1(p) & rmask) | (*P1(p + offset) & ~rmask);
+		*P2(p + offset) = (*P2(p) & rmask) | (*P2(p + offset) & ~rmask);
+		*P3(p + offset) = (*P3(p) & rmask) | (*P3(p + offset) & ~rmask);
 
 		p = (q += scanspan);
 		width = w;
@@ -615,7 +665,7 @@ om1_copycols(void *cookie, int startrow,
 
 			for (cnt = full; cnt; cnt--) {
 				GETBITS(P0(sp), sboff, 32, tmp);
-				P0(dp) = tmp;
+				*P0(dp) = tmp;
 				sp += BYTESDONE;
 				dp += BYTESDONE;
 			}
@@ -653,7 +703,7 @@ om1_copycols(void *cookie, int startrow,
 				sp -= BYTESDONE;
 				dp -= BYTESDONE;
 				GETBITS(P0(sp), sboff, 32, tmp);
-				P0(dp) = tmp;
+				*P0(dp) = tmp;
 			}
 
 			if (lmask != 0) {
@@ -757,13 +807,13 @@ om4_copycols(void *cookie, int startrow,
 
 			for (cnt = full; cnt; cnt--) {
 				GETBITS(P0(sp), sboff, 32, tmp);
-				P0(dp) = tmp;
+				*P0(dp) = tmp;
 				GETBITS(P1(sp), sboff, 32, tmp);
-				P1(dp) = tmp;
+				*P1(dp) = tmp;
 				GETBITS(P2(sp), sboff, 32, tmp);
-				P2(dp) = tmp;
+				*P2(dp) = tmp;
 				GETBITS(P3(sp), sboff, 32, tmp);
-				P3(dp) = tmp;
+				*P3(dp) = tmp;
 				sp += BYTESDONE;
 				dp += BYTESDONE;
 			}
@@ -813,13 +863,13 @@ om4_copycols(void *cookie, int startrow,
 				sp -= BYTESDONE;
 				dp -= BYTESDONE;
 				GETBITS(P0(sp), sboff, 32, tmp);
-				P0(dp) = tmp;
+				*P0(dp) = tmp;
 				GETBITS(P1(sp), sboff, 32, tmp);
-				P1(dp) = tmp;
+				*P1(dp) = tmp;
 				GETBITS(P2(sp), sboff, 32, tmp);
-				P2(dp) = tmp;
+				*P2(dp) = tmp;
 				GETBITS(P3(sp), sboff, 32, tmp);
-				P3(dp) = tmp;
+				*P3(dp) = tmp;
 			}
 
 			if (lmask != 0) {
@@ -878,7 +928,7 @@ om1_cursor(void *cookie, int on, int row
 	struct rasops_info *ri = cookie;
 	uint8_t *p;
 	int scanspan, startx, height, width, align, y;
-	uint32_t lmask, rmask, image;
+	uint32_t lmask, rmask;
 
 	if (!on) {
 		/* make sure it's on */
@@ -905,25 +955,35 @@ om1_cursor(void *cookie, int on, int row
 	rmask = ALL1BITS << (-width & ALIGNMASK);
 	if (width <= BLITWIDTH) {
 		lmask &= rmask;
+		/* set lmask as ROP mask value, with INV2 mode */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask;
+
 		while (height > 0) {
-			image = P0(p);
-			P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
+			*P0(p) = ALL1BITS;
 			p += scanspan;
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	} else {
 		uint8_t *q = p;
 
 		while (height > 0) {
-			image = P0(p);
-			P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
+			/* set lmask as ROP mask value, with INV2 mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask;
+			*W(p) = ALL1BITS;
+
 			p += BYTESDONE;
-			image = P0(p);
-			P0(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
+
+			/* set lmask as ROP mask value, with INV2 mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = rmask;
+			*W(p) = ALL1BITS;
 
 			p = (q += scanspan);
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	}
 	ri->ri_flg ^= RI_CURSOR;
 }
@@ -934,7 +994,7 @@ om4_cursor(void *cookie, int on, int row
 	struct rasops_info *ri = cookie;
 	uint8_t *p;
 	int scanspan, startx, height, width, align, y;
-	uint32_t lmask, rmask, image;
+	uint32_t lmask, rmask;
 
 	if (!on) {
 		/* make sure it's on */
@@ -959,46 +1019,45 @@ om4_cursor(void *cookie, int on, int row
 	width = ri->ri_font->fontwidth + align;
 	lmask = ALL1BITS >> align;
 	rmask = ALL1BITS << (-width & ALIGNMASK);
+
+	/* select all planes for later ROP function target */
+	*(volatile uint32_t *)OMFB_PLANEMASK = 0xff;
+
 	if (width <= BLITWIDTH) {
 		lmask &= rmask;
+		/* set lmask as ROP mask value, with INV2 mode */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask;
+
 		while (height > 0) {
-			image = P0(p);
-			P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
-			image = P1(p);
-			P1(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
-			image = P2(p);
-			P2(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
-			image = P3(p);
-			P3(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
+			*W(p) = ALL1BITS;
 			p += scanspan;
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	} else {
 		uint8_t *q = p;
 
 		while (height > 0) {
-			image = P0(p);
-			P0(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
-			image = P1(p);
-			P1(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
-			image = P2(p);
-			P2(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
-			image = P3(p);
-			P3(p) = (image & ~lmask) | ((image ^ ALL1BITS) & lmask);
+			/* set lmask as ROP mask value, with INV2 mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = lmask;
+			*W(p) = ALL1BITS;
+
 			p += BYTESDONE;
-			image = P0(p);
-			P0(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
-			image = P1(p);
-			P1(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
-			image = P2(p);
-			P2(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
-			image = P3(p);
-			P3(p) = ((image ^ ALL1BITS) & rmask) | (image & ~rmask);
+
+			/* set rmask as ROP mask value, with INV2 mode */
+			((volatile uint32_t *)OMFB_ROPFUNC)[ROP_INV2] = rmask;
+			*W(p) = ALL1BITS;
 
 			p = (q += scanspan);
 			height--;
 		}
+		/* reset mask value */
+		((volatile uint32_t *)OMFB_ROPFUNC)[ROP_THROUGH] = ALL1BITS;
 	}
+	/* select plane #0 only; XXX need this ? */
+	*(volatile uint32_t *)OMFB_PLANEMASK = 0x01;
+
 	ri->ri_flg ^= RI_CURSOR;
 }
 
@@ -1044,6 +1103,14 @@ om4_allocattr(void *id, int fg, int bg, 
 	return 0;
 }
 
+static void
+om4_unpack_attr(long attr, int *fg, int *bg, int *underline)
+{
+
+	*fg = ((u_int)attr >> 24) & 0xf;
+	*bg = ((u_int)attr >> 16) & 0xf;
+}
+
 /*
  * Init subset of rasops(9) for omrasops.
  */

Index: src/sys/arch/luna68k/dev/omrasopsvar.h
diff -u src/sys/arch/luna68k/dev/omrasopsvar.h:1.1.2.3 src/sys/arch/luna68k/dev/omrasopsvar.h:1.1.2.4
--- src/sys/arch/luna68k/dev/omrasopsvar.h:1.1.2.3	Sun Jan 12 12:25:03 2014
+++ src/sys/arch/luna68k/dev/omrasopsvar.h	Sun Nov  9 07:34:12 2014
@@ -1,30 +1,69 @@
-/* $NetBSD: omrasopsvar.h,v 1.1.2.3 2014/01/12 12:25:03 bouyer Exp $ */
+/* $NetBSD: omrasopsvar.h,v 1.1.2.4 2014/11/09 07:34:12 msaitoh Exp $ */
+/*
+ * Copyright (c) 2013 Kenji Aoyama
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, 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.
+ */
+
+/*
+ * Base addresses of LUNA's frame buffer
+ * XXX: We consider only 1bpp and 4bpp for now
+ */
 
-/*-
- * Copyright (c) 2012 The NetBSD Foundation, Inc.
- * All rights reserved.
+#define OMFB_PLANEMASK	0xB1040000	/* BMSEL register */
+#define OMFB_FB_WADDR	0xB1080008	/* common plane */
+#define OMFB_FB_RADDR	0xB10C0008	/* plane #0 */
+#define OMFB_ROPFUNC	0xB12C0000	/* common ROP function */
+
+/*
+ * Helper macros
+ */
+#define W(addr)  ((uint32_t *)(addr))
+#define R(addr)  ((uint32_t *)((uint8_t *)(addr) +  0x40000))
+#define P0(addr) ((uint32_t *)((uint8_t *)(addr) +  0x40000))
+#define P1(addr) ((uint32_t *)((uint8_t *)(addr) +  0x80000))
+#define P2(addr) ((uint32_t *)((uint8_t *)(addr) +  0xC0000))
+#define P3(addr) ((uint32_t *)((uint8_t *)(addr) + 0x100000))
+
+/*
+ * ROP function
  *
- * 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.
+ * LUNA's frame buffer uses Hitach HM53462 video RAM, which has raster
+ * (logic) operation, or ROP, function.  To use ROP function on LUNA, write
+ * a 32bit `mask' value to the specified address corresponding to each ROP
+ * logic.
  *
- * 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.
+ * D: the data writing to the video RAM
+ * M: the data already stored on the video RAM
  */
 
+/* operation		index	the video RAM contents will be */
+#define ROP_ZERO	 0	/* all 0	*/
+#define ROP_AND1	 1	/* D & M	*/ 
+#define ROP_AND2	 2	/* ~D & M	*/
+/* Not used on LUNA	 3			*/
+#define ROP_AND3	 4	/* D & ~M	*/
+#define ROP_THROUGH	 5	/* D		*/
+#define ROP_EOR		 6	/* (~D & M) | (D & ~M)	*/
+#define ROP_OR1		 7	/* D | M	*/
+#define ROP_NOR		 8	/* ~D | ~M	*/
+#define ROP_ENOR	 9	/* (D & M) | (~D & ~M)	*/
+#define ROP_INV1	10	/* ~D		*/
+#define ROP_OR2		11	/* ~D | M	*/
+#define ROP_INV2	12	/* ~M		*/
+#define ROP_OR3		13	/* D | ~M	*/
+#define ROP_NAND	14	/* ~D | ~M	*/
+#define ROP_ONE		15	/* all 1	*/
+
 int omrasops1_init(struct rasops_info *, int, int);
 int omrasops4_init(struct rasops_info *, int, int);

Added files:

Index: src/sys/arch/luna68k/dev/omkbdmap.c
diff -u /dev/null src/sys/arch/luna68k/dev/omkbdmap.c:1.2.2.2
--- /dev/null	Sun Nov  9 07:34:12 2014
+++ src/sys/arch/luna68k/dev/omkbdmap.c	Sun Nov  9 07:34:12 2014
@@ -0,0 +1,303 @@
+/*	$NetBSD: omkbdmap.c,v 1.2.2.2 2014/11/09 07:34:12 msaitoh Exp $	*/
+/*	$OpenBSD: omkbdmap.c,v 1.2 2013/11/16 18:31:44 miod Exp $	*/
+
+/* Partially from:
+ *	$NetBSD: omkbdmap.c,v 1.2.2.2 2014/11/09 07:34:12 msaitoh Exp $
+ *
+ * Copyright (c) 2000 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Tohru Nishimura.
+ *
+ * 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.
+ */
+
+#include "opt_wsdisplay_compat.h"
+
+#include <sys/types.h>
+
+#include <dev/wscons/wsksymdef.h>
+#include <dev/wscons/wsksymvar.h>
+
+#include <luna68k/dev/omkbdmap.h>
+
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+
+/*
+ * Translate LUNA keycodes to US keyboard XT scancodes, for proper
+ * X11-over-wsmux operation.
+ *
+ * XXX: Needs re-think how we should treat RAWKBD code on NetBSD.
+ */
+const uint8_t omkbd_raw[0x80] = {
+	0x00,		/* 0x00 */
+	0x00,		/* 0x01 */
+	0x00,		/* 0x02 */
+	0x00,		/* 0x03 */
+	0x00,		/* 0x04 */
+	0x00,		/* 0x05 */
+	0x00,		/* 0x06 */
+	0x00,		/* 0x07 */
+	0x00,		/* 0x08 */
+	0x0f,		/* 0x09 */
+	0x1d,		/* 0x0a */
+	0x70,		/* 0x0b: Kana / No RAWKEY_XXX symbol */
+	0x36,		/* 0x0c */
+	0x2a,		/* 0x0d */
+	0x3a,		/* 0x0e */
+	0x38,		/* 0x0f: Zenmen */
+	0x01,		/* 0x10 */
+	0x0e,		/* 0x11 */
+	0x1c,		/* 0x12 */
+	0x00,		/* 0x13 */
+	0x39,		/* 0x14 */
+	0xd3,		/* 0x15 */
+	0x38,		/* 0x16: Henkan */
+	0xb8,		/* 0x17: Kakutei */
+	0x57,		/* 0x18: Shokyo */
+	0x58,		/* 0x19: Yobidashi */
+	0x00,		/* 0x1a: Bunsetsu L / f13 */
+	0x00,		/* 0x1b: Bunsetsu R / f14 */
+	0x48,		/* 0x1c */
+	0x4b,		/* 0x1d */
+	0x4d,		/* 0x1e */
+	0x50,		/* 0x1f */
+	0x57,		/* 0x20 */
+	0x58,		/* 0x21 */
+	0x02,		/* 0x22: exclam */
+	0x03,		/* 0x23: quotedbl */
+	0x04,		/* 0x24: numbersign */
+	0x05,		/* 0x25: dollar */
+	0x06,		/* 0x26: percent */
+	0x07,		/* 0x27: ampersand */
+	0x08,		/* 0x28: apostrophe */
+	0x09,		/* 0x29: parenleft */
+	0x0a,		/* 0x2a: parenright  */
+	0x0b,		/* 0x2b */
+	0x0c,		/* 0x2c: equal */
+	0x0d,		/* 0x2d: asciitilde */
+	0x7d,		/* 0x2e: bar */
+	0x00, 		/* 0x2f */
+	0x00, 		/* 0x30: f13 */
+	0x00, 		/* 0x31: f14 */
+	0x10,		/* 0x32 */
+	0x11,		/* 0x33 */
+	0x12,		/* 0x34 */
+	0x13,		/* 0x35 */
+	0x14,		/* 0x36 */
+	0x15,		/* 0x37 */
+	0x16,		/* 0x38 */
+	0x17,		/* 0x39 */
+	0x18,		/* 0x3a */
+	0x19,		/* 0x3b */
+	0x1a,		/* 0x3c: grave */
+	0x1b,		/* 0x3d: braceleft */
+	0x00,		/* 0x3e */
+	0x00,		/* 0x3f */
+	0x00,		/* 0x40 */
+	0x00,		/* 0x41 */
+	0x1e,		/* 0x42 */
+	0x1f,		/* 0x43 */
+	0x20,		/* 0x44 */
+	0x21,		/* 0x45 */
+	0x22,		/* 0x46 */
+	0x23,		/* 0x47 */
+	0x24,		/* 0x48 */
+	0x25,		/* 0x49 */
+	0x26,		/* 0x4a */
+	0x27,		/* 0x4b: plus */
+	0x28,		/* 0x4c: asterisk */
+	0x2b,		/* 0x4d: braceright */
+	0x00,		/* 0x4e */
+	0x00,		/* 0x4f */
+	0x00,		/* 0x50 */
+	0x00,		/* 0x51 */
+	0x2c,		/* 0x52 */
+	0x2d,		/* 0x53 */
+	0x2e,		/* 0x54 */
+	0x2f,		/* 0x55 */
+	0x30,		/* 0x56 */
+	0x31,		/* 0x57 */
+	0x32,		/* 0x58 */
+	0x33,		/* 0x59: less */
+	0x34,		/* 0x5a: greater */
+	0x35,		/* 0x5b: question */
+	0x73,		/* 0x5c: underscore */
+	0x00,		/* 0x5d */
+	0x00,		/* 0x5e */
+	0x00,		/* 0x5f */
+	0x53,		/* 0x60 */
+	0x4e,		/* 0x61 */
+	0x4a,		/* 0x62 */
+	0x47,		/* 0x63: KP 7 */
+	0x48,		/* 0x64: KP 8 */
+	0x49,		/* 0x65: KP 9 */
+	0x4b,		/* 0x66: KP 4 */
+	0x4c,		/* 0x67: KP 5 */
+	0x4d,		/* 0x68: KP 6 */
+	0x4f,		/* 0x69: KP 1 */
+	0x50,		/* 0x6a: KP 2 */
+	0x51,		/* 0x6b: KP 3 */
+	0x52,		/* 0x6c: KP 0 */
+	0x53,		/* 0x6d: KP Decimal */
+	0x9c,		/* 0x6e */
+	0x00,		/* 0x6f */
+	0x00,		/* 0x70 */
+	0x00,		/* 0x71 */
+	0x3b,		/* 0x72 */
+	0x3c,		/* 0x73 */
+	0x3d,		/* 0x74 */
+	0x3e,		/* 0x75 */
+	0x3f,		/* 0x76 */
+	0x40,		/* 0x77 */
+	0x41,		/* 0x78 */
+	0x42,		/* 0x79 */
+	0x43,		/* 0x7a */
+	0x44,		/* 0x7b */
+	0x37,		/* 0x7c */
+	0xb5,		/* 0x7d */
+	0x76,		/* 0x7E */
+	0x00,		/* 0x7f: KP Separator */
+};
+#endif
+
+#define KC(n) KS_KEYCODE(n)
+
+static const keysym_t omkbd_keydesc_jp[] = {
+/*	pos		command		normal		shifted */
+	KC(0x09),			KS_Tab,
+	KC(0x0a),   KS_Cmd1,		KS_Control_L,
+	KC(0x0b),			KS_Mode_switch,	/* Kana */
+	KC(0x0c),			KS_Shift_R,
+	KC(0x0d),			KS_Shift_L,
+	KC(0x0e),			KS_Caps_Lock,
+	KC(0x0f),   KS_Cmd2,		KS_Meta_L,	/* Zenmen */
+	KC(0x10),   KS_Cmd_Debugger,	KS_Escape,
+	KC(0x11),			KS_BackSpace,
+	KC(0x12),			KS_Return,
+	KC(0x14),			KS_space,
+	KC(0x15),			KS_Delete,
+	KC(0x16),			KS_Alt_L,	/* Henkan */
+	KC(0x17),			KS_Alt_R,	/* Kakutei */
+	KC(0x18),			KS_f11,		/* Shokyo */
+	KC(0x19),			KS_f12,		/* Yobidashi */
+	KC(0x1a),			KS_f13,		/* Bunsetsu L */
+	KC(0x1b),			KS_f14,		/* Bunsetsu R */
+	KC(0x1c),			KS_KP_Up,
+	KC(0x1d),			KS_KP_Left,
+	KC(0x1e),			KS_KP_Right,
+	KC(0x1f),			KS_KP_Down,
+	/* 0x20, 			KS_f11, */
+	/* 0x21,			KS_f12, */
+	KC(0x22),			KS_1,		KS_exclam,
+	KC(0x23),			KS_2,		KS_quotedbl,
+	KC(0x24),			KS_3,		KS_numbersign,
+	KC(0x25),			KS_4,		KS_dollar,
+	KC(0x26),			KS_5,		KS_percent,
+	KC(0x27),			KS_6,		KS_ampersand,
+	KC(0x28),			KS_7,		KS_apostrophe,
+	KC(0x29),			KS_8,		KS_parenleft,
+	KC(0x2a),			KS_9,		KS_parenright,
+	KC(0x2b),			KS_0,
+	KC(0x2c),			KS_minus,	KS_equal,
+	KC(0x2d),			KS_asciicircum,	KS_asciitilde,
+	KC(0x2e),			KS_backslash,	KS_bar,
+
+	/* 0x30,			KS_f13, */
+	/* 0x31,			KS_f14, */
+	KC(0x32),			KS_q,
+	KC(0x33),			KS_w,
+	KC(0x34),			KS_e,
+	KC(0x35),			KS_r,
+	KC(0x36),			KS_t,
+	KC(0x37),			KS_y,
+	KC(0x38),			KS_u,
+	KC(0x39),			KS_i,
+	KC(0x3a),			KS_o,
+	KC(0x3b),			KS_p,
+	KC(0x3c),			KS_at,		KS_grave,
+	KC(0x3d),			KS_bracketleft,	KS_braceleft,
+
+	KC(0x42),			KS_a,
+	KC(0x43),			KS_s,
+	KC(0x44),			KS_d,
+	KC(0x45),			KS_f,
+	KC(0x46),			KS_g,
+	KC(0x47),			KS_h,
+	KC(0x48),			KS_j,
+	KC(0x49),			KS_k,
+	KC(0x4a),			KS_l,
+	KC(0x4b),			KS_semicolon,	KS_plus,
+	KC(0x4c),			KS_colon,	KS_asterisk,
+	KC(0x4d),			KS_bracketright, KS_braceright,
+
+	KC(0x52),			KS_z,
+	KC(0x53),			KS_x,
+	KC(0x54),			KS_c,
+	KC(0x55),			KS_v,
+	KC(0x56),			KS_b,
+	KC(0x57),			KS_n,
+	KC(0x58),			KS_m,
+	KC(0x59),			KS_comma,	KS_less,
+	KC(0x5a),			KS_period,	KS_greater,
+	KC(0x5b),			KS_slash,	KS_question,
+	KC(0x5c),			KS_underscore,
+
+	KC(0x60),			KS_KP_Delete,
+	KC(0x61),			KS_KP_Add,
+	KC(0x62),			KS_KP_Subtract,
+	KC(0x63),			KS_KP_7,
+	KC(0x64),			KS_KP_8,
+	KC(0x65),			KS_KP_9,
+	KC(0x66),			KS_KP_4,
+	KC(0x67),			KS_KP_5,
+	KC(0x68),			KS_KP_6,
+	KC(0x69),			KS_KP_1,
+	KC(0x6a),			KS_KP_2,
+	KC(0x6b),			KS_KP_3,
+	KC(0x6c),			KS_KP_0,
+	KC(0x6d),			KS_KP_Decimal,
+	KC(0x6e),			KS_KP_Enter,
+
+	KC(0x72),			KS_f1,
+	KC(0x73),			KS_f2,
+	KC(0x74),			KS_f3,
+	KC(0x75),			KS_f4,
+	KC(0x76),			KS_f5,
+	KC(0x77),			KS_f6,
+	KC(0x78),			KS_f7,
+	KC(0x79),			KS_f8,
+	KC(0x7a),			KS_f9,
+	KC(0x7b),			KS_f10,
+	KC(0x7c),			KS_KP_Multiply,
+	KC(0x7d),			KS_KP_Divide,
+	KC(0x7e),			KS_KP_Equal,
+	KC(0x7f),			KS_KP_Separator,
+};
+
+#define	SIZE(map) (sizeof(map)/sizeof(keysym_t))
+
+const struct wscons_keydesc omkbd_keydesctab[] = {
+       { KB_JP, 0, SIZE(omkbd_keydesc_jp), omkbd_keydesc_jp, },
+       { 0, 0, 0, 0 },
+};

Index: src/sys/arch/luna68k/dev/omkbdmap.h
diff -u /dev/null src/sys/arch/luna68k/dev/omkbdmap.h:1.1.8.2
--- /dev/null	Sun Nov  9 07:34:12 2014
+++ src/sys/arch/luna68k/dev/omkbdmap.h	Sun Nov  9 07:34:12 2014
@@ -0,0 +1,23 @@
+/*	$NetBSD: omkbdmap.h,v 1.1.8.2 2014/11/09 07:34:12 msaitoh Exp $	*/
+/*	$OpenBSD: omkbdmap.h,v 1.1 2013/05/22 11:35:02 aoyama Exp $	*/
+
+/*
+ * Copyright (c) 2013 Kenji Aoyama
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, 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.
+ */
+
+extern const struct wscons_keydesc omkbd_keydesctab[];
+#ifdef WSDISPLAY_COMPAT_RAWKBD
+extern const uint8_t omkbd_raw[0x80];
+#endif

Reply via email to