CVS commit: src/sys/arch/luna68k/dev

2022-11-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Nov 22 16:17:29 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Use explicit struct to represent RX queue buffer data structure.

No binary change.

Maybe the similar change should be applied to MI com(4) and zsc(4)?


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/luna68k/dev/siotty.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-11-22 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Nov 22 16:17:29 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Use explicit struct to represent RX queue buffer data structure.

No binary change.

Maybe the similar change should be applied to MI com(4) and zsc(4)?


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/sys/arch/luna68k/dev/siotty.c

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/dev/siotty.c
diff -u src/sys/arch/luna68k/dev/siotty.c:1.51 src/sys/arch/luna68k/dev/siotty.c:1.52
--- src/sys/arch/luna68k/dev/siotty.c:1.51	Sat Sep 25 15:18:38 2021
+++ src/sys/arch/luna68k/dev/siotty.c	Tue Nov 22 16:17:29 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.51 2021/09/25 15:18:38 tsutsui Exp $ */
+/* $NetBSD: siotty.c,v 1.52 2022/11/22 16:17:29 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.51 2021/09/25 15:18:38 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.52 2022/11/22 16:17:29 tsutsui Exp $");
 
 #include "opt_ddb.h"
 #include "siotty.h"
@@ -76,6 +76,13 @@ static const struct speedtab siospeedtab
 	{ -1,	0, },
 };
 
+struct siotty_rxqdata {
+	uint8_t data;
+	uint8_t stat;
+};
+
+typedef struct siotty_rxqdata rxqdata_t;
+
 struct siotty_softc {
 	device_t	sc_dev;
 	struct tty	*sc_tty;
@@ -86,10 +93,10 @@ struct siotty_softc {
 	u_int		sc_hwflags;
 #define	SIOTTY_HW_CONSOLE	0x0001
 
-	uint8_t		*sc_rbuf;
-	uint8_t		*sc_rbufend;
-	uint8_t	* volatile sc_rbget;
-	uint8_t	* volatile sc_rbput;
+	rxqdata_t	*sc_rbuf;
+	rxqdata_t	*sc_rbufend;
+	rxqdata_t * volatile sc_rbget;
+	rxqdata_t * volatile sc_rbput;
 	volatile u_int	sc_rbavail;
 
 	uint8_t		*sc_tba;
@@ -192,8 +199,9 @@ siotty_attach(device_t parent, device_t 
 
 	aprint_normal("\n");
 
-	sc->sc_rbuf = kmem_alloc(siotty_rbuf_size * 2, KM_SLEEP);
-	sc->sc_rbufend = sc->sc_rbuf + (siotty_rbuf_size * 2);
+	sc->sc_rbuf = kmem_alloc(siotty_rbuf_size * sizeof(rxqdata_t),
+	KM_SLEEP);
+	sc->sc_rbufend = sc->sc_rbuf + siotty_rbuf_size;
 	sc->sc_rbput = sc->sc_rbget = sc->sc_rbuf;
 	sc->sc_rbavail = siotty_rbuf_size;
 
@@ -217,7 +225,7 @@ siottyintr(void *arg)
 {
 	struct siotty_softc *sc;
 	struct sioreg *sio;
-	uint8_t *put, *end;
+	rxqdata_t *put, *end;
 	uint8_t c;
 	uint16_t rr;
 	int cc;
@@ -241,9 +249,9 @@ siottyintr(void *arg)
 c = sio->sio_data;
 cn_check_magic(sc->sc_tty->t_dev, c,
 siotty_cnm_state);
-put[0] = c;
-put[1] = rr & 0xff;
-put += 2;
+put->data = c;
+put->stat = rr & 0xff;
+put++;
 if (put >= end)
 	put = sc->sc_rbuf;
 cc--;
@@ -294,7 +302,7 @@ siottysoft(void *arg)
 static void
 siotty_rxsoft(struct siotty_softc *sc, struct tty *tp)
 {
-	uint8_t *get, *end;
+	rxqdata_t *get, *end;
 	u_int cc, scc;
 	unsigned int code;
 	uint8_t stat;
@@ -309,15 +317,15 @@ siotty_rxsoft(struct siotty_softc *sc, s
 	}
 
 	while (cc > 0) {
-		code = get[0];
-		stat = get[1];
+		code = get->data;
+		stat = get->stat;
 		if ((stat & RR_FRAMING) != 0)
 			code |= TTY_FE;
 		else if ((stat & RR_PARITY) != 0)
 			code |= TTY_PE;
 
 		(*tp->t_linesw->l_rint)(code, tp);
-		get += 2;
+		get++;
 		if (get >= end)
 			get = sc->sc_rbuf;
 		cc--;



CVS commit: src/sys/arch/luna68k/dev

2022-10-03 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Oct  3 17:42:36 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c omrasops.c omrasopsvar.h

Log Message:
Remove global hwplanecount and use ri_depth in struct rasops instead.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/luna68k/dev/omrasops.c
cvs rdiff -u -r1.7 -r1.8 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/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.48 src/sys/arch/luna68k/dev/lunafb.c:1.49
--- src/sys/arch/luna68k/dev/lunafb.c:1.48	Sat Oct  1 14:02:08 2022
+++ src/sys/arch/luna68k/dev/lunafb.c	Mon Oct  3 17:42:35 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.48 2022/10/01 14:02:08 tsutsui Exp $ */
+/* $NetBSD: lunafb.c,v 1.49 2022/10/03 17:42:35 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.48 2022/10/01 14:02:08 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.49 2022/10/03 17:42:35 tsutsui Exp $");
 
 #include 
 #include 
@@ -175,8 +175,6 @@ CFATTACH_DECL_NEW(fb, sizeof(struct omfb
 
 extern int hwplanemask;	/* hardware planemask; retrieved at boot */
 
-int hwplanecount;	/* for omrasops */
-
 static int omfb_console;
 int  omfb_cnattach(void);
 
@@ -460,7 +458,7 @@ omfb_resetcmap(struct om_hwdevconfig *dc
 static void
 omfb_getdevconfig(paddr_t paddr, struct om_hwdevconfig *dc)
 {
-	int i;
+	int bpp, i;
 	struct rasops_info *ri;
 	union {
 		struct { short h, v; } p;
@@ -469,21 +467,21 @@ omfb_getdevconfig(paddr_t paddr, struct 
 
 	switch (hwplanemask) {
 	case 0xff:
-		hwplanecount = 8;	/* XXX check monochrome bit in DIPSW */
+		bpp = 8;	/* XXX check monochrome bit in DIPSW */
 		break;
 	default:
 	case 0x0f:
-		hwplanecount = 4;	/* XXX check monochrome bit in DIPSW */
+		bpp = 4;	/* XXX check monochrome bit in DIPSW */
 		break;
 	case 1:
-		hwplanecount = 1;
+		bpp = 1;
 		break;
 	}
 	dc->dc_wid = 1280;
 	dc->dc_ht = 1024;
-	dc->dc_depth = hwplanecount;
+	dc->dc_depth = bpp;
 	dc->dc_rowbytes = 2048 / 8;
-	dc->dc_cmsize = (hwplanecount == 1) ? 0 : 1 << hwplanecount;
+	dc->dc_cmsize = (bpp == 1) ? 0 : 1 << bpp;
 	dc->dc_videobase = paddr;
 
 	omfb_resetcmap(dc);
@@ -513,7 +511,7 @@ omfb_getdevconfig(paddr_t paddr, struct 
 		ri->ri_flg |= RI_NO_AUTO;
 	ri->ri_hw = dc;
 
-	if (hwplanecount == 4 || hwplanecount == 8)
+	if (bpp == 4 || bpp == 8)
 		omrasops4_init(ri, 34, 80);
 	else
 		omrasops1_init(ri, 34, 80);

Index: src/sys/arch/luna68k/dev/omrasops.c
diff -u src/sys/arch/luna68k/dev/omrasops.c:1.24 src/sys/arch/luna68k/dev/omrasops.c:1.25
--- src/sys/arch/luna68k/dev/omrasops.c:1.24	Sat Oct  1 13:51:55 2022
+++ src/sys/arch/luna68k/dev/omrasops.c	Mon Oct  3 17:42:35 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.24 2022/10/01 13:51:55 tsutsui Exp $ */
+/* $NetBSD: omrasops.c,v 1.25 2022/10/03 17:42:35 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.24 2022/10/01 13:51:55 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.25 2022/10/03 17:42:35 tsutsui Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
@@ -100,8 +100,8 @@ static void	om_eraserows(void *, int, in
 static int	om_allocattr(void *, int, int, int, long *);
 
 static void	om_fill(int, int, uint8_t *, int, int, uint32_t, int, int);
-static void	om_fill_color(int, uint8_t *, int, int, int, int);
-static void	om_rascopy_single(uint8_t *, uint8_t *, int16_t, int16_t,
+static void	om_fill_color(int, int, uint8_t *, int, int, int, int);
+static void	om_rascopy_single(int, uint8_t *, uint8_t *, int16_t, int16_t,
 uint8_t[]);
 static void	om4_rascopy_multi(uint8_t *, uint8_t *, int16_t, int16_t);
 static void	om_unpack_attr(long, uint8_t *, uint8_t *, int *);
@@ -330,8 +330,8 @@ om_fill(int planemask, int rop, uint8_t 
 }
 
 static void
-om_fill_color(int color, uint8_t *dstptr, int dstbitoffs, int dstspan,
-int width, int height)
+om_fill_color(int planecount, int color, uint8_t *dstptr, int dstbitoffs,
+int dstspan, int width, int height)
 {
 	uint32_t mask;
 	uint32_t prev_mask;
@@ -340,7 +340,7 @@ om_fill_color(int color, uint8_t *dstptr
 
 	ASSUME(width > 0);
 	ASSUME(height > 0);
-	ASSUME(omfb_planecount > 0);
+	ASSUME(planecount > 0);
 
 	/* select all planes */
 	om_set_planemask(hwplanemask);
@@ -364,7 +364,7 @@ om_fill_color(int color, uint8_t *dstptr
 		}
 
 		if (prev_mask != mask) {
-			for (plane = 0; plane < omfb_planecount; plane++) {
+			for (plane = 0; plane < planecount; plane++) {
 if ((color & (1U << plane)) != 0)
 	rop = 

CVS commit: src/sys/arch/luna68k/dev

2022-10-03 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Oct  3 17:42:36 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c omrasops.c omrasopsvar.h

Log Message:
Remove global hwplanecount and use ri_depth in struct rasops instead.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/luna68k/dev/omrasops.c
cvs rdiff -u -r1.7 -r1.8 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.



CVS commit: src/sys/arch/luna68k/dev

2022-10-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  1 14:02:08 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Set an actual framebuffer depth (bpp) to rasops ri_depth.

The previous value was derived from OpenBSD/luna88k but
it has not been referenced even via ioctl(2).


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/luna68k/dev/lunafb.c

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/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.47 src/sys/arch/luna68k/dev/lunafb.c:1.48
--- src/sys/arch/luna68k/dev/lunafb.c:1.47	Sun Sep 25 11:28:40 2022
+++ src/sys/arch/luna68k/dev/lunafb.c	Sat Oct  1 14:02:08 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.47 2022/09/25 11:28:40 isaki Exp $ */
+/* $NetBSD: lunafb.c,v 1.48 2022/10/01 14:02:08 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.47 2022/09/25 11:28:40 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.48 2022/10/01 14:02:08 tsutsui Exp $");
 
 #include 
 #include 
@@ -505,7 +505,7 @@ omfb_getdevconfig(paddr_t paddr, struct 
 	ri = >dc_ri;
 	ri->ri_width = dc->dc_wid;
 	ri->ri_height = dc->dc_ht;
-	ri->ri_depth = 1;	/* since planes are independently addressed */
+	ri->ri_depth = dc->dc_depth;
 	ri->ri_stride = dc->dc_rowbytes;
 	ri->ri_bits = (void *)dc->dc_videobase;
 	ri->ri_flg = RI_CENTER;



CVS commit: src/sys/arch/luna68k/dev

2022-10-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  1 14:02:08 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Set an actual framebuffer depth (bpp) to rasops ri_depth.

The previous value was derived from OpenBSD/luna88k but
it has not been referenced even via ioctl(2).


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/luna68k/dev/lunafb.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-10-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  1 13:51:55 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: omrasops.c

Log Message:
Explicitly limit a number of rasops rows per size of rowattr[].


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/luna68k/dev/omrasops.c

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/dev/omrasops.c
diff -u src/sys/arch/luna68k/dev/omrasops.c:1.23 src/sys/arch/luna68k/dev/omrasops.c:1.24
--- src/sys/arch/luna68k/dev/omrasops.c:1.23	Sun Sep 25 11:28:40 2022
+++ src/sys/arch/luna68k/dev/omrasops.c	Sat Oct  1 13:51:55 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.23 2022/09/25 11:28:40 isaki Exp $ */
+/* $NetBSD: omrasops.c,v 1.24 2022/10/01 13:51:55 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.23 2022/09/25 11:28:40 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.24 2022/10/01 13:51:55 tsutsui Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
@@ -113,7 +113,8 @@ static int	omrasops_init(struct rasops_i
  * This number of elements is derived from howmany(1024, fontheight = 24).
  * But it is currently initialized with row = 34, so it is used only up to 34.
  */
-static rowattr_t rowattr[43];
+#define OMRASOPS_MAX_ROWS	43
+static rowattr_t rowattr[OMRASOPS_MAX_ROWS];
 
 #define	ALL1BITS	(~0U)
 #define	ALL0BITS	(0U)
@@ -1801,6 +1802,8 @@ omrasops_init(struct rasops_info *ri, in
 {
 	int wsfcookie, bpp;
 
+	if (wantrows > OMRASOPS_MAX_ROWS)
+		wantrows = OMRASOPS_MAX_ROWS;
 	if (wantrows == 0)
 		wantrows = 34;
 	if (wantrows < 10)



CVS commit: src/sys/arch/luna68k/dev

2022-10-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  1 13:51:55 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: omrasops.c

Log Message:
Explicitly limit a number of rasops rows per size of rowattr[].


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/luna68k/dev/omrasops.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-10-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  1 13:41:12 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: omrasopsvar.h psgpam_enc.c xplxfirm.c

Log Message:
Remove trailing whitespaces.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/luna68k/dev/omrasopsvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/luna68k/dev/psgpam_enc.c \
src/sys/arch/luna68k/dev/xplxfirm.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-10-01 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  1 13:41:12 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: omrasopsvar.h psgpam_enc.c xplxfirm.c

Log Message:
Remove trailing whitespaces.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/luna68k/dev/omrasopsvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/luna68k/dev/psgpam_enc.c \
src/sys/arch/luna68k/dev/xplxfirm.c

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/dev/omrasopsvar.h
diff -u src/sys/arch/luna68k/dev/omrasopsvar.h:1.6 src/sys/arch/luna68k/dev/omrasopsvar.h:1.7
--- src/sys/arch/luna68k/dev/omrasopsvar.h:1.6	Sun Sep 25 11:28:40 2022
+++ src/sys/arch/luna68k/dev/omrasopsvar.h	Sat Oct  1 13:41:12 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasopsvar.h,v 1.6 2022/09/25 11:28:40 isaki Exp $ */
+/* $NetBSD: omrasopsvar.h,v 1.7 2022/10/01 13:41:12 tsutsui Exp $ */
 /*
  * Copyright (c) 2013 Kenji Aoyama
  *
@@ -52,7 +52,7 @@ extern int hwplanecount;
 
 /* operation		index	the video RAM contents will be */
 #define ROP_ZERO	 0	/* all 0	*/
-#define ROP_AND1	 1	/* D & M	*/ 
+#define ROP_AND1	 1	/* D & M	*/
 #define ROP_AND2	 2	/* ~D & M	*/
 /* Not used on LUNA	 3			*/
 #define ROP_AND3	 4	/* D & ~M	*/

Index: src/sys/arch/luna68k/dev/psgpam_enc.c
diff -u src/sys/arch/luna68k/dev/psgpam_enc.c:1.1 src/sys/arch/luna68k/dev/psgpam_enc.c:1.2
--- src/sys/arch/luna68k/dev/psgpam_enc.c:1.1	Fri Jun 10 21:42:23 2022
+++ src/sys/arch/luna68k/dev/psgpam_enc.c	Sat Oct  1 13:41:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: psgpam_enc.c,v 1.1 2022/06/10 21:42:23 tsutsui Exp $	*/
+/*	$NetBSD: psgpam_enc.c,v 1.2 2022/10/01 13:41:12 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2018 Yosuke Sugahara. All rights reserved.
@@ -70,12 +70,12 @@ dynamic_offset(struct psgpam_codecvar *c
 	 * } else {
 	 *   increment offset
 	 * }
-	 */ 
+	 */
 	if (v <= ctx->offset) {
 		ctx->offset = v;
 	} else {
 		if (--ctx->expire < 0) {
-			ctx->offset += 1; 
+			ctx->offset += 1;
 			ctx->expire = ctx->expire_initial;
 		}
 	}
Index: src/sys/arch/luna68k/dev/xplxfirm.c
diff -u src/sys/arch/luna68k/dev/xplxfirm.c:1.1 src/sys/arch/luna68k/dev/xplxfirm.c:1.2
--- src/sys/arch/luna68k/dev/xplxfirm.c:1.1	Fri Jun 10 21:42:23 2022
+++ src/sys/arch/luna68k/dev/xplxfirm.c	Sat Oct  1 13:41:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: xplxfirm.c,v 1.1 2022/06/10 21:42:23 tsutsui Exp $	*/
+/*	$NetBSD: xplxfirm.c,v 1.2 2022/10/01 13:41:12 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2018 Yosuke Sugahara. All rights reserved.
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  */
 
-/* 
+/*
  * XXX TODO:
  * - consider how xplx.inc should be handled
  */



CVS commit: src/sys/arch/luna68k/dev

2022-09-25 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Sep 25 11:28:40 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c omrasops.c omrasopsvar.h

Log Message:
lunafb: Improve drawing performance using VRAM ROP features.
- Drawing a character on 4bpp normally needs 4 times writes, but by using
  VRAM ROP actively, it can be reduced to write only once.
  The same goes for copyrows.  If the whole row consists of only two colors
  (one foreground and one background), it can be copied by reading once and
  writing once, regardless of the number of planes.  Only if the row consists
  of more than two colors, it will be copied plane by plane.
- On 8bpp board, it acts as 4bpp (16 colors).
- On 4bpp board on the real LUNA-I(68030/20MHz), monochrome scroll is about
  4 times faster even without asm.  Using asm improves it by additional 5%
  (asm is enabled by default).
- By tsutsui@-san's report, even color scroll is about about 2 times faster
  on his 8bpp board on the real LUNA-II(68040).
This was first developped by Y.Sugahara back in late 2019, and was modified
a lot by me in 2022.
http://mail-index.netbsd.org/port-luna68k/2022/09/23/msg72.html


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/luna68k/dev/omrasops.c
cvs rdiff -u -r1.5 -r1.6 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.



CVS commit: src/sys/arch/luna68k/dev

2022-09-25 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Sep 25 11:28:40 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c omrasops.c omrasopsvar.h

Log Message:
lunafb: Improve drawing performance using VRAM ROP features.
- Drawing a character on 4bpp normally needs 4 times writes, but by using
  VRAM ROP actively, it can be reduced to write only once.
  The same goes for copyrows.  If the whole row consists of only two colors
  (one foreground and one background), it can be copied by reading once and
  writing once, regardless of the number of planes.  Only if the row consists
  of more than two colors, it will be copied plane by plane.
- On 8bpp board, it acts as 4bpp (16 colors).
- On 4bpp board on the real LUNA-I(68030/20MHz), monochrome scroll is about
  4 times faster even without asm.  Using asm improves it by additional 5%
  (asm is enabled by default).
- By tsutsui@-san's report, even color scroll is about about 2 times faster
  on his 8bpp board on the real LUNA-II(68040).
This was first developped by Y.Sugahara back in late 2019, and was modified
a lot by me in 2022.
http://mail-index.netbsd.org/port-luna68k/2022/09/23/msg72.html


To generate a diff of this commit:
cvs rdiff -u -r1.46 -r1.47 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/luna68k/dev/omrasops.c
cvs rdiff -u -r1.5 -r1.6 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/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.46 src/sys/arch/luna68k/dev/lunafb.c:1.47
--- src/sys/arch/luna68k/dev/lunafb.c:1.46	Thu Jul 14 20:13:21 2022
+++ src/sys/arch/luna68k/dev/lunafb.c	Sun Sep 25 11:28:40 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.46 2022/07/14 20:13:21 tsutsui Exp $ */
+/* $NetBSD: lunafb.c,v 1.47 2022/09/25 11:28:40 isaki Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.46 2022/07/14 20:13:21 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.47 2022/09/25 11:28:40 isaki Exp $");
 
 #include 
 #include 
@@ -76,6 +76,8 @@ struct bt458 {
 
 #define	OMFB_RFCNT	BMAP_RFCNT	/* video h-origin/v-origin */
 #define	OMFB_RAMDAC	BMAP_PALLET2	/* Bt454/Bt458 RAMDAC */
+#define	OMFB_FB_WADDR	(BMAP_BMP + 8)	/* common bitmap plane */
+#define	OMFB_FB_RADDR	(BMAP_BMAP0 + 8)/* bitmap plane #0 */
 
 #define	OMFB_SIZE	(BMAP_FN0 - BMAP_BMP + PAGE_SIZE)
 
@@ -173,6 +175,8 @@ CFATTACH_DECL_NEW(fb, sizeof(struct omfb
 
 extern int hwplanemask;	/* hardware planemask; retrieved at boot */
 
+int hwplanecount;	/* for omrasops */
+
 static int omfb_console;
 int  omfb_cnattach(void);
 
@@ -456,7 +460,7 @@ omfb_resetcmap(struct om_hwdevconfig *dc
 static void
 omfb_getdevconfig(paddr_t paddr, struct om_hwdevconfig *dc)
 {
-	int bpp, i;
+	int i;
 	struct rasops_info *ri;
 	union {
 		struct { short h, v; } p;
@@ -465,21 +469,21 @@ omfb_getdevconfig(paddr_t paddr, struct 
 
 	switch (hwplanemask) {
 	case 0xff:
-		bpp = 8;	/* XXX check monochrome bit in DIPSW */
+		hwplanecount = 8;	/* XXX check monochrome bit in DIPSW */
 		break;
 	default:
 	case 0x0f:
-		bpp = 4;	/* XXX check monochrome bit in DIPSW */
+		hwplanecount = 4;	/* XXX check monochrome bit in DIPSW */
 		break;
 	case 1:
-		bpp = 1;
+		hwplanecount = 1;
 		break;
 	}
 	dc->dc_wid = 1280;
 	dc->dc_ht = 1024;
-	dc->dc_depth = bpp;
+	dc->dc_depth = hwplanecount;
 	dc->dc_rowbytes = 2048 / 8;
-	dc->dc_cmsize = (bpp == 1) ? 0 : 1 << bpp;
+	dc->dc_cmsize = (hwplanecount == 1) ? 0 : 1 << hwplanecount;
 	dc->dc_videobase = paddr;
 
 	omfb_resetcmap(dc);
@@ -509,7 +513,7 @@ omfb_getdevconfig(paddr_t paddr, struct 
 		ri->ri_flg |= RI_NO_AUTO;
 	ri->ri_hw = dc;
 
-	if (bpp == 4 || bpp == 8)
+	if (hwplanecount == 4 || hwplanecount == 8)
 		omrasops4_init(ri, 34, 80);
 	else
 		omrasops1_init(ri, 34, 80);

Index: src/sys/arch/luna68k/dev/omrasops.c
diff -u src/sys/arch/luna68k/dev/omrasops.c:1.22 src/sys/arch/luna68k/dev/omrasops.c:1.23
--- src/sys/arch/luna68k/dev/omrasops.c:1.22	Sun Sep 25 11:22:36 2022
+++ src/sys/arch/luna68k/dev/omrasops.c	Sun Sep 25 11:28:40 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.22 2022/09/25 11:22:36 isaki Exp $ */
+/* $NetBSD: omrasops.c,v 1.23 2022/09/25 11:28:40 isaki Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.22 2022/09/25 11:22:36 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.23 2022/09/25 11:28:40 isaki Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
@@ -41,6 +41,15 @@ __KERNEL_RCSID(0, "$NetBSD: omrasops.c,v
  *	- first column is at 32bit aligned address,
  *	- font glyphs are stored in 32bit padded.
  */
+/*
+ * BMSEL affects both of
+ * 1) which plane a 

CVS commit: src/sys/arch/luna68k/dev

2022-09-25 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Sep 25 11:22:36 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: omrasops.c

Log Message:
Cosmetic changes.  Fix a typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/luna68k/dev/omrasops.c

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/dev/omrasops.c
diff -u src/sys/arch/luna68k/dev/omrasops.c:1.21 src/sys/arch/luna68k/dev/omrasops.c:1.22
--- src/sys/arch/luna68k/dev/omrasops.c:1.21	Wed Jul 31 02:09:02 2019
+++ src/sys/arch/luna68k/dev/omrasops.c	Sun Sep 25 11:22:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasops.c,v 1.21 2019/07/31 02:09:02 rin Exp $ */
+/* $NetBSD: omrasops.c,v 1.22 2022/09/25 11:22:36 isaki Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.21 2019/07/31 02:09:02 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: omrasops.c,v 1.22 2022/09/25 11:22:36 isaki Exp $");
 
 /*
  * Designed speficically for 'm68k bitorder';
@@ -80,7 +80,7 @@ static int	omrasops_init(struct rasops_i
 
 /*
  * macros to handle unaligned bit copy ops.
- * See src/sys/dev/rasops/rasops_mask.h for MI version.
+ * See src/sys/dev/rasops/rasops_masks.h for MI version.
  * Also refer src/sys/arch/hp300/dev/maskbits.h.
  * (which was implemented for ancient src/sys/arch/hp300/dev/grf_hy.c)
  */
@@ -97,7 +97,7 @@ static int	omrasops_init(struct rasops_i
 	asm("bfins %3,%0{%1:%2}"	\
 	: "+o" (*(uint32_t *)(pdst))\
 	: "di" (x), "di" (w), "d" (src)\
-	: "memory" );
+	: "memory" )
 
 #define	GETBITS(psrc, x, w, dst)	FASTGETBITS(psrc, x, w, dst)
 #define	PUTBITS(src, x, w, pdst)	FASTPUTBITS(src, x, w, pdst)
@@ -629,7 +629,7 @@ om1_copycols(void *cookie, int startrow,
 
 	lmask = (db == 0) ? 0 : ALL1BITS >> db;
 	eb = (db + w) & ALIGNMASK;
-	rmask = (eb == 0) ? 0 : ALL1BITS << (32 - eb); 
+	rmask = (eb == 0) ? 0 : ALL1BITS << (32 - eb);
 	lnum = (32 - db) & ALIGNMASK;
 	rnum = (dstx + w) & ALIGNMASK;
 
@@ -765,7 +765,7 @@ om4_copycols(void *cookie, int startrow,
 
 	lmask = (db == 0) ? 0 : ALL1BITS >> db;
 	eb = (db + w) & ALIGNMASK;
-	rmask = (eb == 0) ? 0 : ALL1BITS << (32 - eb); 
+	rmask = (eb == 0) ? 0 : ALL1BITS << (32 - eb);
 	lnum = (32 - db) & ALIGNMASK;
 	rnum = (dstx + w) & ALIGNMASK;
 



CVS commit: src/sys/arch/luna68k/dev

2022-09-25 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sun Sep 25 11:22:36 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: omrasops.c

Log Message:
Cosmetic changes.  Fix a typo in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/luna68k/dev/omrasops.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-07-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Jul 14 20:13:21 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Misc KNF and cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/luna68k/dev/lunafb.c

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/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.45 src/sys/arch/luna68k/dev/lunafb.c:1.46
--- src/sys/arch/luna68k/dev/lunafb.c:1.45	Thu Jul 14 19:55:56 2022
+++ src/sys/arch/luna68k/dev/lunafb.c	Thu Jul 14 20:13:21 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.45 2022/07/14 19:55:56 tsutsui Exp $ */
+/* $NetBSD: lunafb.c,v 1.46 2022/07/14 20:13:21 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.45 2022/07/14 19:55:56 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.46 2022/07/14 20:13:21 tsutsui Exp $");
 
 #include 
 #include 
@@ -322,20 +322,24 @@ static int
 omgetcmap(struct omfb_softc *sc, struct wsdisplay_cmap *p)
 {
 	u_int index = p->index, count = p->count;
-	int cmsize, error;
+	u_int cmsize;
+	int error;
 
 	cmsize = sc->sc_dc->dc_cmsize;
 	if (index >= cmsize || count > cmsize - index)
 		return EINVAL;
 
 	error = copyout(>sc_dc->dc_cmap.r[index], p->red, count);
-	if (error)
+	if (error != 0)
 		return error;
 	error = copyout(>sc_dc->dc_cmap.g[index], p->green, count);
-	if (error)
+	if (error != 0)
 		return error;
 	error = copyout(>sc_dc->dc_cmap.b[index], p->blue, count);
-	return error;
+	if (error != 0)
+		return error;
+
+	return 0;
 }
 
 static int
@@ -343,20 +347,22 @@ omsetcmap(struct omfb_softc *sc, struct 
 {
 	struct hwcmap cmap;
 	u_int index = p->index, count = p->count;
-	int cmsize, i, error;
+	u_int cmsize;
+	int i, error;
 
 	cmsize = sc->sc_dc->dc_cmsize;
+
 	if (index >= cmsize || count > cmsize - index)
 		return EINVAL;
 
 	error = copyin(p->red, [index], count);
-	if (error)
+	if (error != 0)
 		return error;
 	error = copyin(p->green, [index], count);
-	if (error)
+	if (error != 0)
 		return error;
 	error = copyin(p->blue, [index], count);
-	if (error)
+	if (error != 0)
 		return error;
 
 	memcpy(>sc_dc->dc_cmap.r[index], [index], count);
@@ -495,7 +501,7 @@ omfb_getdevconfig(paddr_t paddr, struct 
 	ri = >dc_ri;
 	ri->ri_width = dc->dc_wid;
 	ri->ri_height = dc->dc_ht;
-	ri->ri_depth = 1;   /* since planes are independently addressed */
+	ri->ri_depth = 1;	/* since planes are independently addressed */
 	ri->ri_stride = dc->dc_rowbytes;
 	ri->ri_bits = (void *)dc->dc_videobase;
 	ri->ri_flg = RI_CENTER;



CVS commit: src/sys/arch/luna68k/dev

2022-07-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Jul 14 20:13:21 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Misc KNF and cosmetics.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/sys/arch/luna68k/dev/lunafb.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-07-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Jul 14 19:55:56 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Fix pasto.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/luna68k/dev/lunafb.c

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/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.44 src/sys/arch/luna68k/dev/lunafb.c:1.45
--- src/sys/arch/luna68k/dev/lunafb.c:1.44	Sun Jul  3 11:30:48 2022
+++ src/sys/arch/luna68k/dev/lunafb.c	Thu Jul 14 19:55:56 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.44 2022/07/03 11:30:48 andvar Exp $ */
+/* $NetBSD: lunafb.c,v 1.45 2022/07/14 19:55:56 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.44 2022/07/03 11:30:48 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.45 2022/07/14 19:55:56 tsutsui Exp $");
 
 #include 
 #include 
@@ -253,7 +253,7 @@ omfbioctl(void *v, void *vs, u_long cmd,
 		wsd_fbip->width = dc->dc_wid;
 		wsd_fbip->depth = dc->dc_depth;
 		wsd_fbip->cmsize = dc->dc_cmsize;
-#undef fbt
+#undef wsd_fbip
 		return 0;
 
 	case WSDISPLAYIO_LINEBYTES:



CVS commit: src/sys/arch/luna68k/dev

2022-07-14 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Thu Jul 14 19:55:56 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Fix pasto.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/luna68k/dev/lunafb.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-06-24 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jun 25 01:54:37 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Add rnd(9) entropy source from keyboard and mouse.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/luna68k/dev/lunaws.c

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/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.40 src/sys/arch/luna68k/dev/lunaws.c:1.41
--- src/sys/arch/luna68k/dev/lunaws.c:1.40	Sat Oct  9 20:59:47 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Sat Jun 25 01:54:37 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.40 2021/10/09 20:59:47 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.41 2022/06/25 01:54:37 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.40 2021/10/09 20:59:47 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.41 2022/06/25 01:54:37 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -40,6 +40,7 @@ __KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -130,6 +131,7 @@ struct ws_softc {
 	int		sc_rawkbd;
 
 	struct ws_conscookie *sc_conscookie;
+	krndsource_t	sc_rndsource;
 };
 
 static void omkbd_input(struct ws_softc *, int);
@@ -241,6 +243,8 @@ wsattach(device_t parent, device_t self,
 	sc->sc_tx_done = false;
 
 	sc->sc_si = softint_establish(SOFTINT_SERIAL, wssoftintr, sc);
+	rnd_attach_source(>sc_rndsource, device_xname(self),
+	RND_TYPE_TTY, RND_FLAG_DEFAULT);
 
 	/* enable interrupt */
 	setsioreg(sc->sc_ctl, WR1, sc->sc_wr[WR1]);
@@ -274,11 +278,12 @@ wsintr(void *arg)
 {
 	struct ws_softc *sc = arg;
 	struct sioreg *sio = sc->sc_ctl;
-	uint8_t code;
-	uint16_t rr;
+	uint8_t code = 0;
+	uint16_t rr, rndcsr = 0;
 	bool handled = false;
 
 	rr = getsiocsr(sio);
+	rndcsr = rr;
 	if ((rr & RR_RXRDY) != 0) {
 		do {
 			code = sio->sio_data;
@@ -299,8 +304,10 @@ wsintr(void *arg)
 			handled = true;
 		}
 	}
-	if (handled)
+	if (handled) {
 		softint_schedule(sc->sc_si);
+		rnd_add_uint32(>sc_rndsource, (rndcsr << 8) | code);
+	}
 }
 
 static void



CVS commit: src/sys/arch/luna68k/dev

2022-06-24 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jun 25 01:54:37 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Add rnd(9) entropy source from keyboard and mouse.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/sys/arch/luna68k/dev

2022-06-11 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jun 11 14:45:37 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: psgpam.c

Log Message:
Match psgpam(4) only on LUNA-I.  LUNA-II doesn't have YM2149 at XP.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/luna68k/dev/psgpam.c

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/dev/psgpam.c
diff -u src/sys/arch/luna68k/dev/psgpam.c:1.1 src/sys/arch/luna68k/dev/psgpam.c:1.2
--- src/sys/arch/luna68k/dev/psgpam.c:1.1	Fri Jun 10 21:42:23 2022
+++ src/sys/arch/luna68k/dev/psgpam.c	Sat Jun 11 14:45:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: psgpam.c,v 1.1 2022/06/10 21:42:23 tsutsui Exp $	*/
+/*	$NetBSD: psgpam.c,v 1.2 2022/06/11 14:45:37 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 2018 Yosuke Sugahara. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: psgpam.c,v 1.1 2022/06/10 21:42:23 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psgpam.c,v 1.2 2022/06/11 14:45:37 tsutsui Exp $");
 
 #include 
 #include 
@@ -196,6 +196,10 @@ psgpam_match(device_t parent, cfdata_t c
 	if (psgpam_matched)
 		return 0;
 
+	/* Only the first generation LUNA has YM2149 at XP */
+	if (machtype != LUNA_I)
+		return 0;
+
 	if (strcmp(xa->xa_name, psgpam_cd.cd_name))
 		return 0;
 



CVS commit: src/sys/arch/luna68k/dev

2022-06-11 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Jun 11 14:45:37 UTC 2022

Modified Files:
src/sys/arch/luna68k/dev: psgpam.c

Log Message:
Match psgpam(4) only on LUNA-I.  LUNA-II doesn't have YM2149 at XP.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/luna68k/dev/psgpam.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-10-09 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  9 20:59:47 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Handle wskbd(9) .set_leds op in cngetc(9) using wskbd_cnattach(9) cookie.

XXX1: LUNA's keyboards emulate "mechanical lock" for CAP and Kana keys,
  i.e. it sends "DOWN" code only when CAP/Kana LEDs are turned on
  and send "UP" code only when the LEDs are turned off.
  The MD omkbd_input() via wskbd_input(9) for the normal wskbd(4)
  (i.e. ttyE0) devices handles this quirk, but MI wskbd_cngetc()
  in sys/dev/wscons/wskbd.c can do nothing for this.

XXX2: I wonder if we should have an independent .set_leds op for cons(9)
  as cnbell(9), rather than referring a device specific softc stuff
  during .set_leds op in struct wskbd_accessop (registered during
  autoconf(9) via struct wskbddev_attach_args passed to config_found(9))
  even for wskbd cngetc(9) op in struct wskbd_consops (registered
  via early wskbd_cnattach(9)).


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/luna68k/dev/lunaws.c

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/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.39 src/sys/arch/luna68k/dev/lunaws.c:1.40
--- src/sys/arch/luna68k/dev/lunaws.c:1.39	Sat Sep 25 15:18:38 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Sat Oct  9 20:59:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.39 2021/09/25 15:18:38 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.40 2021/10/09 20:59:47 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.39 2021/09/25 15:18:38 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.40 2021/10/09 20:59:47 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -101,6 +101,12 @@ static const uint8_t ch1_regs[6] = {
 	WR5_TX8BIT | WR5_TXENBL,		/* Tx */
 };
 
+struct ws_conscookie {
+	struct sioreg	*cc_sio;
+	int		cc_polling;
+	struct ws_softc	*cc_sc;
+};
+
 struct ws_softc {
 	device_t	sc_dev;
 	struct sioreg	*sc_ctl;
@@ -122,6 +128,8 @@ struct ws_softc {
 	int		sc_msreport;
 	void		*sc_si;
 	int		sc_rawkbd;
+
+	struct ws_conscookie *sc_conscookie;
 };
 
 static void omkbd_input(struct ws_softc *, int);
@@ -155,6 +163,7 @@ static const struct wskbd_consops ws_con
 	.pollc = ws_cnpollc,
 	.bell  = ws_cnbell,
 };
+static struct ws_conscookie ws_conscookie;
 
 #if NWSMOUSE > 0
 static int  omms_enable(void *);
@@ -214,6 +223,10 @@ wsattach(device_t parent, device_t self,
 	siosc->sc_intrhand[channel].ih_func = wsintr;
 	siosc->sc_intrhand[channel].ih_arg = sc;
 
+	sc->sc_conscookie = _conscookie;
+	sc->sc_conscookie->cc_sc = sc;
+	sc->sc_conscookie->cc_polling = 0;
+
 	setsioreg(sc->sc_ctl, WR0, sc->sc_wr[WR0]);
 	setsioreg(sc->sc_ctl, WR4, sc->sc_wr[WR4]);
 	setsioreg(sc->sc_ctl, WR3, sc->sc_wr[WR3]);
@@ -514,13 +527,11 @@ omkbd_get_buzcmd(struct ws_softc *sc, st
 static void
 ws_cngetc(void *cookie, u_int *type, int *data)
 {
-	struct ws_softc *sc = cookie;	/* currently unused */
-	struct sioreg *sio, *sio_base;
+	struct ws_conscookie *conscookie = cookie;
+	struct sioreg *sio = conscookie->cc_sio;
+	struct ws_softc *sc = conscookie->cc_sc;	/* currently unused */
 	int code;
 
-	sio_base = (struct sioreg *)OBIO_SIO;
-	sio = _base[1];	/* channel B */
-
 	code = siogetc(sio);
 	omkbd_decode(sc, code, type, data);
 }
@@ -528,19 +539,20 @@ ws_cngetc(void *cookie, u_int *type, int
 static void
 ws_cnpollc(void *cookie, int on)
 {
+	struct ws_conscookie *conscookie = cookie;
+
+	conscookie->cc_polling = on;
 }
 
 static void
 ws_cnbell(void *cookie, u_int pitch, u_int period, u_int volume)
 {
-	struct ws_softc *sc = cookie;	/* currently unused */
-	struct sioreg *sio, *sio_base;
+	struct ws_conscookie *conscookie = cookie;
+	struct sioreg *sio = conscookie->cc_sio;
+	struct ws_softc *sc = conscookie->cc_sc;	/* currently unused */
 	struct wskbd_bell_data wbd;
 	uint8_t buzcmd;
 
-	sio_base = (struct sioreg *)OBIO_SIO;
-	sio = _base[1];	/* channel B */
-
 	/*
 	 * XXX cnbell(9) man page should describe each args..
 	 * (it looks similar to the struct wskbd_bell_data)
@@ -560,11 +572,14 @@ ws_cnbell(void *cookie, u_int pitch, u_i
 /* EXPORT */ void
 ws_cnattach(void)
 {
-	static int voidfill;
+	struct sioreg *sio_base;
+
+	sio_base = (struct sioreg *)OBIO_SIO;
+	ws_conscookie.cc_sio = _base[1];	/* channel B */
 
 	/* XXX need CH.B initialization XXX */
 
-	wskbd_cnattach(_consops, , _keymapdata);
+	wskbd_cnattach(_consops, _conscookie, _keymapdata);
 }
 
 static int
@@ -578,35 +593,41 @@ static void
 omkbd_set_leds(void *cookie, int leds)
 {
 	struct ws_softc *sc = cookie;
-	uint8_t ledcmd;
+	uint8_t capsledcmd, kanaledcmd;
 
-	/*
-	 * XXX:
-	 *  Why does MI wskbd(4) use a common 

CVS commit: src/sys/arch/luna68k/dev

2021-10-09 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Oct  9 20:59:47 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Handle wskbd(9) .set_leds op in cngetc(9) using wskbd_cnattach(9) cookie.

XXX1: LUNA's keyboards emulate "mechanical lock" for CAP and Kana keys,
  i.e. it sends "DOWN" code only when CAP/Kana LEDs are turned on
  and send "UP" code only when the LEDs are turned off.
  The MD omkbd_input() via wskbd_input(9) for the normal wskbd(4)
  (i.e. ttyE0) devices handles this quirk, but MI wskbd_cngetc()
  in sys/dev/wscons/wskbd.c can do nothing for this.

XXX2: I wonder if we should have an independent .set_leds op for cons(9)
  as cnbell(9), rather than referring a device specific softc stuff
  during .set_leds op in struct wskbd_accessop (registered during
  autoconf(9) via struct wskbddev_attach_args passed to config_found(9))
  even for wskbd cngetc(9) op in struct wskbd_consops (registered
  via early wskbd_cnattach(9)).


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Sep 20 08:31:09 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Add a comment that .set_leds function won't work correctly on cngetc(9).

I'm afraid all other keyboard drivers that have .set_leds function
(like sgimips/dev/zs_kbd.c) have the same issue.
Maybe we needs 'polled' flag in .set_leds function, or an independent
.set_leds accessop in struct wskbd_consops for cons(9).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/luna68k/dev/lunaws.c

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/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.37 src/sys/arch/luna68k/dev/lunaws.c:1.38
--- src/sys/arch/luna68k/dev/lunaws.c:1.37	Sun Sep 19 11:43:54 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Mon Sep 20 08:31:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.37 2021/09/19 11:43:54 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.38 2021/09/20 08:31:09 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.37 2021/09/19 11:43:54 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.38 2021/09/20 08:31:09 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -571,6 +571,16 @@ omkbd_set_leds(void *cookie, int leds)
 	struct ws_softc *sc = cookie;
 	uint8_t ledcmd;
 
+	/*
+	 * XXX:
+	 *  Why does MI wskbd(4) use a common .set_leds function
+	 *  for both kernel cons(9) and normal tty devices!?
+	 *
+	 *  When CAP key is pressed in cngetc(9) (like ddb(4) etc.)
+	 *  after wskbd(4) is attached, all LED commands are queued
+	 *  into txq[] and will never be sent until ddb(4) returns.
+	 */
+
 	sc->sc_leds = leds;
 	if ((leds & WSKBD_LED_CAPS) != 0) {
 		ledcmd = OMKBD_LED_ON_CAPS;



CVS commit: src/sys/arch/luna68k/dev

2021-09-20 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Mon Sep 20 08:31:09 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Add a comment that .set_leds function won't work correctly on cngetc(9).

I'm afraid all other keyboard drivers that have .set_leds function
(like sgimips/dev/zs_kbd.c) have the same issue.
Maybe we needs 'polled' flag in .set_leds function, or an independent
.set_leds accessop in struct wskbd_consops for cons(9).


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Sep 19 11:43:54 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Use more C99 designated initializer.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/luna68k/dev/lunaws.c

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/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.36 src/sys/arch/luna68k/dev/lunaws.c:1.37
--- src/sys/arch/luna68k/dev/lunaws.c:1.36	Sun Sep 19 07:55:17 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Sun Sep 19 11:43:54 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.36 2021/09/19 07:55:17 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.37 2021/09/19 11:43:54 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.36 2021/09/19 07:55:17 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.37 2021/09/19 11:43:54 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -161,9 +161,9 @@ static int  omms_ioctl(void *, u_long, v
 static void omms_disable(void *);
 
 static const struct wsmouse_accessops omms_accessops = {
-	omms_enable,
-	omms_ioctl,
-	omms_disable,
+	.enable  = omms_enable,
+	.ioctl   = omms_ioctl,
+	.disable = omms_disable,
 };
 #endif
 



CVS commit: src/sys/arch/luna68k/dev

2021-09-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Sep 19 11:43:54 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Use more C99 designated initializer.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Sep 19 07:55:18 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Handle CAP and Kana modifier key specification quirk of LUNA's keyboard.

LUNA's keyboard doesn't send any keycode when these modifier keys are
released.  Instead, it sends a pressed or released code per how each
modifier LED status will be changed when the modifier keys are pressed.
To handle this quirk in MI wskbd(4) layer, we have to send a faked
"pressed and released" sequence on passing keycodes to wskbd_input(9).

Tested on LUNA both on ttyE0 and WSKBD_RAW mode (on Xorg server).


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/luna68k/dev/lunaws.c

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/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.35 src/sys/arch/luna68k/dev/lunaws.c:1.36
--- src/sys/arch/luna68k/dev/lunaws.c:1.35	Sat Sep 18 13:44:02 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Sun Sep 19 07:55:17 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.35 2021/09/18 13:44:02 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.36 2021/09/19 07:55:17 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.35 2021/09/18 13:44:02 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.36 2021/09/19 07:55:17 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -401,6 +401,14 @@ omkbd_input(struct ws_softc *sc, int dat
 		int c, j = 0;
 
 		c = omkbd_raw[key];
+		if (c == 0x70 /* Kana */ ||
+		c == 0x3a /* CAP  */) {
+			/* See comment in !sc->sc_rawkbd case */
+			cbuf[0] = c;
+			wskbd_rawinput(sc->sc_wskbddev, cbuf, 1);
+			cbuf[0] = c | 0x80;
+			wskbd_rawinput(sc->sc_wskbddev, cbuf, 1);
+		} else
 		if (c != 0x00) {
 			/* fake extended scancode if necessary */
 			if (c & 0x80)
@@ -415,8 +423,27 @@ omkbd_input(struct ws_softc *sc, int dat
 	} else
 #endif
 	{
-		if (sc->sc_wskbddev != NULL)
-			wskbd_input(sc->sc_wskbddev, type, key);
+		if (sc->sc_wskbddev != NULL) {
+			if (key == 0x0b /* Kana */ ||
+			key == 0x0e /* CAP  */) {
+/*
+ * LUNA's keyboard doesn't send any keycode
+ * when these modifier keys are released.
+ * Instead, it sends a pressed or released code
+ * per how each modifier LED status will be
+ * changed when the modifier keys are pressed.
+ * To handle this quirk in MI wskbd(4) layer,
+ * we have to send a faked
+ * "pressed and released" sequence here.
+ */
+wskbd_input(sc->sc_wskbddev,
+WSCONS_EVENT_KEY_DOWN, key);
+wskbd_input(sc->sc_wskbddev,
+WSCONS_EVENT_KEY_UP, key);
+			} else {
+wskbd_input(sc->sc_wskbddev, type, key);
+			}
+		}
 	}
 }
 



CVS commit: src/sys/arch/luna68k/dev

2021-09-19 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Sep 19 07:55:18 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Handle CAP and Kana modifier key specification quirk of LUNA's keyboard.

LUNA's keyboard doesn't send any keycode when these modifier keys are
released.  Instead, it sends a pressed or released code per how each
modifier LED status will be changed when the modifier keys are pressed.
To handle this quirk in MI wskbd(4) layer, we have to send a faked
"pressed and released" sequence on passing keycodes to wskbd_input(9).

Tested on LUNA both on ttyE0 and WSKBD_RAW mode (on Xorg server).


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-18 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep 18 13:44:02 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Implement transmitting keyboard LED and buzzer control commands.

- enable TX on uPD7201 for keyboard port
- prepare TX queue and handle it in hardware interrupt and softint(9)
- send proper LED commands on WSKBDIO_SETLEDS
  (XXX: KANA LED is not handled in wscons)
- return current LED settings on WSKBDIO_GETLEDS
- implement WSKBDIO_COMPLEXBELL by parsing struct wskbd_bell_data and
  send proper buzzer commands
- handle pitch, period, and volume in cnbell(9)
  (XXX: no description in cnbell(9) man pages)
- use proper queued TX function for omms_enable() and omms_disable()
- add DPRINTF()s for debug
- use C99 designated initializer and misc cosmetics

Tested on LUNA and its keyboard (3W4SD-098NDT).


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/luna68k/dev/lunaws.c

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/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.34 src/sys/arch/luna68k/dev/lunaws.c:1.35
--- src/sys/arch/luna68k/dev/lunaws.c:1.34	Sat Sep  4 18:38:03 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Sat Sep 18 13:44:02 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.34 2021/09/04 18:38:03 tsutsui Exp $ */
+/* $NetBSD: lunaws.c,v 1.35 2021/09/18 13:44:02 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.34 2021/09/04 18:38:03 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.35 2021/09/18 13:44:02 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -57,10 +57,43 @@ __KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1
 #define OMKBD_RXQ_LEN		64
 #define OMKBD_RXQ_LEN_MASK	(OMKBD_RXQ_LEN - 1)
 #define OMKBD_NEXTRXQ(x)	(((x) + 1) & OMKBD_RXQ_LEN_MASK)
+#define OMKBD_TXQ_LEN		16
+#define OMKBD_TXQ_LEN_MASK	(OMKBD_TXQ_LEN - 1)
+#define OMKBD_NEXTTXQ(x)	(((x) + 1) & OMKBD_TXQ_LEN_MASK)
+
+/* Keyboard commands */
+/*  000Xb : LED commands */
+#define OMKBD_LED_ON_KANA	0x10	/* kana LED on */
+#define OMKBD_LED_OFF_KANA	0x00	/* kana LED off */
+#define OMKBD_LED_ON_CAPS	0x11	/* caps LED on */
+#define OMKBD_LED_OFF_CAPS	0x01	/* caps LED off */
+/*  010Xb : buzzer commands */
+#define OMKBD_BUZZER		0x40
+#define OMKBD_BUZZER_PERIOD	0x18
+#define OMKBD_BUZZER_40MS	0x00
+#define OMKBD_BUZZER_150MS	0x08
+#define OMKBD_BUZZER_400MS	0x10
+#define OMKBD_BUZZER_700MS	0x18
+#define OMKBD_BUZZER_PITCH	0x07
+#define OMKBD_BUZZER_6000HZ	0x00
+#define OMKBD_BUZZER_3000HZ	0x01
+#define OMKBD_BUZZER_1500HZ	0x02
+#define OMKBD_BUZZER_1000HZ	0x03
+#define OMKBD_BUZZER_600HZ	0x04
+#define OMKBD_BUZZER_300HZ	0x05
+#define OMKBD_BUZZER_150HZ	0x06
+#define OMKBD_BUZZER_100HZ	0x07
+/*  011Xb : mouse on command */
+#define OMKBD_MOUSE_ON		0x60
+/*  001Xb : mouse off command */
+#define OMKBD_MOUSE_OFF		0x20
+
+#define OMKBD_BUZZER_DEFAULT	\
+	(OMKBD_BUZZER | OMKBD_BUZZER_40MS | OMKBD_BUZZER_1500HZ)
 
 static const uint8_t ch1_regs[6] = {
 	WR0_RSTINT,/* Reset E/S Interrupt */
-	WR1_RXALLS,/* Rx per char, No Tx */
+	WR1_RXALLS | WR1_TXENBL,		/* Rx per char, Tx */
 	0,	/* */
 	WR3_RX8BIT | WR3_RXENBL,		/* Rx */
 	WR4_BAUD96 | WR4_STOP1 | WR4_NPARITY,	/* Tx/Rx */
@@ -75,6 +108,12 @@ struct ws_softc {
 	uint8_t		sc_rxq[OMKBD_RXQ_LEN];
 	u_int		sc_rxqhead;
 	u_int		sc_rxqtail;
+	uint8_t		sc_txq[OMKBD_TXQ_LEN];
+	u_int		sc_txqhead;
+	u_int		sc_txqtail;
+	bool		sc_tx_busy;
+	bool		sc_tx_done;
+	int		sc_leds;
 #if NWSMOUSE > 0
 	device_t	sc_wsmousedev;
 	int		sc_msbuttons, sc_msdx, sc_msdy;
@@ -84,28 +123,36 @@ struct ws_softc {
 	int		sc_rawkbd;
 };
 
-static void omkbd_input(void *, int);
-static void omkbd_decode(void *, int, u_int *, int *);
+static void omkbd_input(struct ws_softc *, int);
+static void omkbd_send(struct ws_softc *, uint8_t);
+static void omkbd_decode(struct ws_softc *, 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 *);
 
+static void omkbd_complex_buzzer(struct ws_softc *, struct wskbd_bell_data *);
+static uint8_t omkbd_get_buzcmd(struct ws_softc *, struct wskbd_bell_data *,
+uint8_t);
+
 static const struct wskbd_mapdata omkbd_keymapdata = {
-	omkbd_keydesctab,
-	KB_JP,
+	.keydesc = omkbd_keydesctab,
+	.layout  = KB_JP,
 };
 static const struct wskbd_accessops omkbd_accessops = {
-	omkbd_enable,
-	omkbd_set_leds,
-	omkbd_ioctl,
+	.enable   = omkbd_enable,
+	.set_leds = omkbd_set_leds,
+	.ioctl= omkbd_ioctl,
 };
 
 void	ws_cnattach(void);
 static void ws_cngetc(void *, u_int *, int *);
 static void ws_cnpollc(void *, int);
+static void ws_cnbell(void *, u_int, u_int, u_int);
 static const struct 

CVS commit: src/sys/arch/luna68k/dev

2021-09-18 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep 18 13:44:02 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Implement transmitting keyboard LED and buzzer control commands.

- enable TX on uPD7201 for keyboard port
- prepare TX queue and handle it in hardware interrupt and softint(9)
- send proper LED commands on WSKBDIO_SETLEDS
  (XXX: KANA LED is not handled in wscons)
- return current LED settings on WSKBDIO_GETLEDS
- implement WSKBDIO_COMPLEXBELL by parsing struct wskbd_bell_data and
  send proper buzzer commands
- handle pitch, period, and volume in cnbell(9)
  (XXX: no description in cnbell(9) man pages)
- use proper queued TX function for omms_enable() and omms_disable()
- add DPRINTF()s for debug
- use C99 designated initializer and misc cosmetics

Tested on LUNA and its keyboard (3W4SD-098NDT).


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 18:38:03 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Ignore mouse packets properly even if wsmouse(4) isn't configured.

The internal state of wskbd(4) could be mangled if mouse (which was
connected behind keyboard) was enabled by unexpected keyboard reset.
This could happen on the INSTALL kernel (no wsmouse(4) on it).

Based on a patch from moveccr, with several tweaks by me.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/luna68k/dev/lunaws.c

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/dev/lunaws.c
diff -u src/sys/arch/luna68k/dev/lunaws.c:1.33 src/sys/arch/luna68k/dev/lunaws.c:1.34
--- src/sys/arch/luna68k/dev/lunaws.c:1.33	Sat Aug  7 16:18:57 2021
+++ src/sys/arch/luna68k/dev/lunaws.c	Sat Sep  4 18:38:03 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: lunaws.c,v 1.33 2021/08/07 16:18:57 thorpej Exp $ */
+/* $NetBSD: lunaws.c,v 1.34 2021/09/04 18:38:03 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.33 2021/08/07 16:18:57 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunaws.c,v 1.34 2021/09/04 18:38:03 tsutsui Exp $");
 
 #include "opt_wsdisplay_compat.h"
 #include "wsmouse.h"
@@ -77,9 +77,9 @@ struct ws_softc {
 	u_int		sc_rxqtail;
 #if NWSMOUSE > 0
 	device_t	sc_wsmousedev;
-	int		sc_msreport;
 	int		sc_msbuttons, sc_msdx, sc_msdy;
 #endif
+	int		sc_msreport;
 	void		*sc_si;
 	int		sc_rawkbd;
 };
@@ -184,9 +184,9 @@ wsattach(device_t parent, device_t self,
 	b.accesscookie = (void *)sc;
 	sc->sc_wsmousedev = config_found(self, , wsmousedevprint,
 	CFARGS(.iattr = "wsmousedev"));
-	sc->sc_msreport = 0;
 	}
 #endif
+	sc->sc_msreport = 0;
 }
 
 /*ARGSUSED*/
@@ -225,41 +225,42 @@ wssoftintr(void *arg)
 	while (sc->sc_rxqhead != sc->sc_rxqtail) {
 		code = sc->sc_rxq[sc->sc_rxqhead];
 		sc->sc_rxqhead = OMKBD_NEXTRXQ(sc->sc_rxqhead);
-#if NWSMOUSE > 0
 		/*
-		 * if (code >= 0x80 && code <= 0x87), then
+		 * if (code >= 0x80 && code <= 0x87), i.e.
+		 * if ((code & 0xf8) == 0x80), then
 		 * it's the first byte of 3 byte long mouse report
 		 *	code[0] & 07 -> LMR button condition
 		 *	code[1], [2] -> x,y delta
 		 * otherwise, key press or release event.
 		 */
-		if (sc->sc_msreport == 0) {
-			if (code < 0x80 || code > 0x87) {
-omkbd_input(sc, code);
-continue;
-			}
-			code = (code & 07) ^ 07;
-			/* LMR->RML: wsevent counts 0 for leftmost */
-			sc->sc_msbuttons = (code & 02);
-			if ((code & 01) != 0)
-sc->sc_msbuttons |= 04;
-			if ((code & 04) != 0)
-sc->sc_msbuttons |= 01;
-			sc->sc_msreport = 1;
-		} else if (sc->sc_msreport == 1) {
+		if (sc->sc_msreport == 1) {
+#if NWSMOUSE > 0
 			sc->sc_msdx = (int8_t)code;
+#endif
 			sc->sc_msreport = 2;
+			continue;
 		} else if (sc->sc_msreport == 2) {
+#if NWSMOUSE > 0
 			sc->sc_msdy = (int8_t)code;
 			wsmouse_input(sc->sc_wsmousedev,
 			sc->sc_msbuttons, sc->sc_msdx, sc->sc_msdy, 0, 0,
 			WSMOUSE_INPUT_DELTA);
-
+#endif
 			sc->sc_msreport = 0;
+			continue;
 		}
-#else
-		omkbd_input(sc, code);
+		if ((code & 0xf8) == 0x80) {
+#if NWSMOUSE > 0
+			/* buttons: Negative logic to positive */
+			code = ~code;
+			/* LMR->RML: wsevent counts 0 for leftmost */
+			sc->sc_msbuttons =
+			((code & 1) << 2) | (code & 2) | ((code & 4) >> 2);
 #endif
+			sc->sc_msreport = 1;
+			continue;
+		}
+		omkbd_input(sc, code);
 	}
 }
 
@@ -380,10 +381,7 @@ omkbd_ioctl(void *v, u_long cmd, void *d
 static int
 omms_enable(void *v)
 {
-	struct ws_softc *sc = v;
-
 	syscnputc((dev_t)1, 0x60); /* enable 3 byte long mouse reporting */
-	sc->sc_msreport = 0;
 	return 0;
 }
 
@@ -402,9 +400,6 @@ omms_ioctl(void *v, u_long cmd, void *da
 static void
 omms_disable(void *v)
 {
-	struct ws_softc *sc = v;
-
 	syscnputc((dev_t)1, 0x20); /* quiet mouse */
-	sc->sc_msreport = 0;
 }
 #endif



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 18:38:03 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: lunaws.c

Log Message:
Ignore mouse packets properly even if wsmouse(4) isn't configured.

The internal state of wskbd(4) could be mangled if mouse (which was
connected behind keyboard) was enabled by unexpected keyboard reset.
This could happen on the INSTALL kernel (no wsmouse(4) on it).

Based on a patch from moveccr, with several tweaks by me.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/luna68k/dev/lunaws.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 12:54:19 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Fix several styles and formats.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/luna68k/dev/siotty.c

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/dev/siotty.c
diff -u src/sys/arch/luna68k/dev/siotty.c:1.49 src/sys/arch/luna68k/dev/siotty.c:1.50
--- src/sys/arch/luna68k/dev/siotty.c:1.49	Sat Sep  4 12:44:23 2021
+++ src/sys/arch/luna68k/dev/siotty.c	Sat Sep  4 12:54:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.49 2021/09/04 12:44:23 tsutsui Exp $ */
+/* $NetBSD: siotty.c,v 1.50 2021/09/04 12:54:19 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,9 +31,10 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.49 2021/09/04 12:44:23 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.50 2021/09/04 12:54:19 tsutsui Exp $");
 
 #include "opt_ddb.h"
+#include "siotty.h"
 
 #include 
 #include 
@@ -105,7 +106,6 @@ u_int siotty_rbuf_size = SIOTTY_RING_SIZ
 
 static struct cnm_state	siotty_cnm_state;
 
-#include "siotty.h"
 static void siostart(struct tty *);
 static int  sioparam(struct tty *, struct termios *);
 static void siottyintr(void *);
@@ -415,14 +415,16 @@ sioparam(struct tty *tp, struct termios 
 	tp->t_ospeed = t->c_ospeed;
 	tp->t_cflag = t->c_cflag;
 
-	sc->sc_wr[WR3] &= 0x3f;
-	sc->sc_wr[WR5] &= 0x9f;
+	sc->sc_wr[WR3] &= ~WR3_RX8BIT;
+	sc->sc_wr[WR5] &= ~WR5_TX8BIT;
 	switch (tp->t_cflag & CSIZE) {
 	case CS7:
-		sc->sc_wr[WR3] |= WR3_RX7BIT; sc->sc_wr[WR5] |= WR5_TX7BIT;
+		sc->sc_wr[WR3] |= WR3_RX7BIT;
+		sc->sc_wr[WR5] |= WR5_TX7BIT;
 		break;
 	case CS8:
-		sc->sc_wr[WR3] |= WR3_RX8BIT; sc->sc_wr[WR5] |= WR5_TX8BIT;
+		sc->sc_wr[WR3] |= WR3_RX8BIT;
+		sc->sc_wr[WR5] |= WR5_TX8BIT;
 		break;
 	}
 	if ((tp->t_cflag & PARENB) != 0) {
@@ -524,9 +526,9 @@ sioopen(dev_t dev, int flag, int mode, s
 		/* raise RTS and DTR here; but, DTR lead is not wired */
 		/* then check DCD condition; but, DCD lead is not wired */
 #if 0
-		if ((sc->sc_flags & TIOCFLAG_SOFTCAR) != 0
-		|| (tp->t_cflag & MDMBUF) != 0
-		|| (getsiocsr(sc->sc_ctl) & RR_DCD) != 0)
+		if ((sc->sc_flags & TIOCFLAG_SOFTCAR) != 0 ||
+		(tp->t_cflag & MDMBUF) != 0 ||
+		(getsiocsr(sc->sc_ctl) & RR_DCD) != 0)
 			tp->t_state |= TS_CARR_ON;
 		else
 			tp->t_state &= ~TS_CARR_ON;
@@ -558,8 +560,8 @@ sioclose(dev_t dev, int flag, int mode, 
 	s = splserial();
 	siomctl(sc, TIOCM_BREAK, DMBIC);
 #if 0 /* because unable to feed DTR signal */
-	if ((tp->t_cflag & HUPCL) != 0
-	|| tp->t_wopen || (tp->t_state & TS_ISOPEN) == 0) {
+	if ((tp->t_cflag & HUPCL) != 0 ||
+	tp->t_wopen || (tp->t_state & TS_ISOPEN) == 0) {
 		siomctl(sc, TIOCM_DTR, DMBIC);
 		/* Yield CPU time to others for 1 second, then ... */
 		siomctl(sc, TIOCM_DTR, DMBIS);



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 12:54:19 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Fix several styles and formats.


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/arch/luna68k/dev/siotty.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 12:44:23 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Use C99 designated initializer.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/luna68k/dev/siotty.c

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/dev/siotty.c
diff -u src/sys/arch/luna68k/dev/siotty.c:1.48 src/sys/arch/luna68k/dev/siotty.c:1.49
--- src/sys/arch/luna68k/dev/siotty.c:1.48	Sat Sep  4 12:38:13 2021
+++ src/sys/arch/luna68k/dev/siotty.c	Sat Sep  4 12:44:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.48 2021/09/04 12:38:13 tsutsui Exp $ */
+/* $NetBSD: siotty.c,v 1.49 2021/09/04 12:44:23 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.48 2021/09/04 12:38:13 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.49 2021/09/04 12:44:23 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -692,16 +692,16 @@ getsiocsr(struct sioreg *sio)
 /*-  console interface --*/
 
 struct consdev syscons = {
-	NULL,
-	NULL,
-	syscngetc,
-	syscnputc,
-	nullcnpollc,
-	NULL,
-	NULL,
-	NULL,
-	NODEV,
-	CN_REMOTE,
+	.cn_probe = NULL,
+	.cn_init  = NULL,
+	.cn_getc  = syscngetc,
+	.cn_putc  = syscnputc,
+	.cn_pollc = nullcnpollc,
+	.cn_bell  = NULL,
+	.cn_halt  = NULL,
+	.cn_flush = NULL,
+	.cn_dev   = NODEV,
+	.cn_pri   = CN_REMOTE,
 };
 
 /* EXPORT */ void



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 12:44:23 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Use C99 designated initializer.


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/sys/arch/luna68k/dev/siotty.c

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



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 12:38:13 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Use proper macro for device register addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/luna68k/dev/siotty.c

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/dev/siotty.c
diff -u src/sys/arch/luna68k/dev/siotty.c:1.47 src/sys/arch/luna68k/dev/siotty.c:1.48
--- src/sys/arch/luna68k/dev/siotty.c:1.47	Tue Dec 29 17:17:14 2020
+++ src/sys/arch/luna68k/dev/siotty.c	Sat Sep  4 12:38:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.47 2020/12/29 17:17:14 tsutsui Exp $ */
+/* $NetBSD: siotty.c,v 1.48 2021/09/04 12:38:13 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.47 2020/12/29 17:17:14 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.48 2021/09/04 12:38:13 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1
 #include 
 #include 
 
+#include 
 #include 
 
 #include 
@@ -711,7 +712,7 @@ syscninit(int channel)
  * boot/reset/poweron.  ROM monitor emits one line message on CH.A.
  */
 	struct sioreg *sio;
-	sio = (struct sioreg *)0x5100 + channel;
+	sio = (struct sioreg *)OBIO_SIO + channel;
 
 	syscons.cn_dev = makedev(cdevsw_lookup_major(_cdevsw),
  channel);
@@ -735,7 +736,7 @@ syscngetc(dev_t dev)
 	struct sioreg *sio;
 	int s, c;
 
-	sio = (struct sioreg *)0x5100 + ((int)dev & 0x1);
+	sio = (struct sioreg *)OBIO_SIO + ((int)dev & 0x1);
 	s = splhigh();
 	while ((getsiocsr(sio) & RR_RXRDY) == 0)
 		continue;
@@ -751,7 +752,7 @@ syscnputc(dev_t dev, int c)
 	struct sioreg *sio;
 	int s;
 
-	sio = (struct sioreg *)0x5100 + ((int)dev & 0x1);
+	sio = (struct sioreg *)OBIO_SIO + ((int)dev & 0x1);
 	s = splhigh();
 	while ((getsiocsr(sio) & RR_TXRDY) == 0)
 		continue;



CVS commit: src/sys/arch/luna68k/dev

2021-09-04 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sat Sep  4 12:38:13 UTC 2021

Modified Files:
src/sys/arch/luna68k/dev: siotty.c

Log Message:
Use proper macro for device register addresses.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/sys/arch/luna68k/dev/siotty.c

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



CVS commit: src/sys/arch/luna68k/dev

2019-09-22 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Sep 22 06:06:01 UTC 2019

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Correct size of framebuffer; page offset appears only once,
not every color depths.

Pointed out by Araki Ken. Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/luna68k/dev/lunafb.c

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



CVS commit: src/sys/arch/luna68k/dev

2019-09-22 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Sep 22 06:06:01 UTC 2019

Modified Files:
src/sys/arch/luna68k/dev: lunafb.c

Log Message:
Correct size of framebuffer; page offset appears only once,
not every color depths.

Pointed out by Araki Ken. Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/luna68k/dev/lunafb.c

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/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.40 src/sys/arch/luna68k/dev/lunafb.c:1.41
--- src/sys/arch/luna68k/dev/lunafb.c:1.40	Tue Jul 23 14:34:11 2019
+++ src/sys/arch/luna68k/dev/lunafb.c	Sun Sep 22 06:06:01 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.40 2019/07/23 14:34:11 rin Exp $ */
+/* $NetBSD: lunafb.c,v 1.41 2019/09/22 06:06:01 rin Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.40 2019/07/23 14:34:11 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.41 2019/09/22 06:06:01 rin Exp $");
 
 #include 
 #include 
@@ -308,8 +308,8 @@ omfbmmap(void *v, void *vs, off_t offset
 #endif
 	case WSDISPLAYIO_MODE_DUMBFB:
 		if (offset >= 0 &&
-		offset < (m68k_page_offset(OMFB_FB_RADDR) +
-		dc->dc_rowbytes * dc->dc_ht) * dc->dc_depth)
+		offset < m68k_page_offset(OMFB_FB_RADDR) +
+		dc->dc_rowbytes * dc->dc_ht * dc->dc_depth)
 			cookie = m68k_btop(m68k_trunc_page(OMFB_FB_RADDR) +
 			offset);
 		break;



CVS commit: src/sys/arch/luna68k/dev

2019-09-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Sep 22 05:49:16 UTC 2019

Modified Files:
src/sys/arch/luna68k/dev: omrasopsvar.h

Log Message:
Spell out "Hitachi" correctly in comment.
No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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.



CVS commit: src/sys/arch/luna68k/dev

2019-09-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sun Sep 22 05:49:16 UTC 2019

Modified Files:
src/sys/arch/luna68k/dev: omrasopsvar.h

Log Message:
Spell out "Hitachi" correctly in comment.
No binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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/dev/omrasopsvar.h
diff -u src/sys/arch/luna68k/dev/omrasopsvar.h:1.4 src/sys/arch/luna68k/dev/omrasopsvar.h:1.5
--- src/sys/arch/luna68k/dev/omrasopsvar.h:1.4	Sun Jun 30 05:04:48 2019
+++ src/sys/arch/luna68k/dev/omrasopsvar.h	Sun Sep 22 05:49:16 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: omrasopsvar.h,v 1.4 2019/06/30 05:04:48 tsutsui Exp $ */
+/* $NetBSD: omrasopsvar.h,v 1.5 2019/09/22 05:49:16 rin Exp $ */
 /*
  * Copyright (c) 2013 Kenji Aoyama
  *
@@ -40,7 +40,7 @@
 /*
  * ROP function
  *
- * LUNA's frame buffer uses Hitach HM53462 video RAM, which has raster
+ * LUNA's frame buffer uses Hitachi 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.



CVS commit: src/sys/arch/luna68k/dev

2019-06-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jun 30 02:11:56 UTC 2019

Modified Files:
src/sys/arch/luna68k/dev: if_le.c lcd.c lunafb.c siotty.c

Log Message:
Misc KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/luna68k/dev/if_le.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/luna68k/dev/lcd.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/luna68k/dev/siotty.c

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/dev/if_le.c
diff -u src/sys/arch/luna68k/dev/if_le.c:1.7 src/sys/arch/luna68k/dev/if_le.c:1.8
--- src/sys/arch/luna68k/dev/if_le.c:1.7	Mon Sep 23 17:27:09 2013
+++ src/sys/arch/luna68k/dev/if_le.c	Sun Jun 30 02:11:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: if_le.c,v 1.7 2013/09/23 17:27:09 tsutsui Exp $ */
+/* $NetBSD: if_le.c,v 1.8 2019/06/30 02:11:56 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 1992, 1993
@@ -73,7 +73,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.7 2013/09/23 17:27:09 tsutsui Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_le.c,v 1.8 2019/06/30 02:11:56 tsutsui Exp $");
 
 #include "opt_inet.h"
 
@@ -152,7 +152,7 @@ lerdcsr(struct lance_softc *sc, uint16_t
 
 	ler1->ler1_rap = port;
 	val = ler1->ler1_rdp;
-	return (val);
+	return val;
 }
 
 static int
@@ -161,9 +161,9 @@ le_match(device_t parent, cfdata_t cf, v
 	struct mainbus_attach_args *ma = aux;
 
 	if (strcmp(ma->ma_name, le_cd.cd_name))
-		return (0);
+		return 0;
 
-	return (1);
+	return 1;
 }
 
 void

Index: src/sys/arch/luna68k/dev/lcd.c
diff -u src/sys/arch/luna68k/dev/lcd.c:1.9 src/sys/arch/luna68k/dev/lcd.c:1.10
--- src/sys/arch/luna68k/dev/lcd.c:1.9	Thu Mar  8 03:12:02 2018
+++ src/sys/arch/luna68k/dev/lcd.c	Sun Jun 30 02:11:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: lcd.c,v 1.9 2018/03/08 03:12:02 mrg Exp $ */
+/* $NetBSD: lcd.c,v 1.10 2019/06/30 02:11:56 tsutsui Exp $ */
 /* $OpenBSD: lcd.c,v 1.7 2015/02/10 22:42:35 miod Exp $ */
 
 /*-
@@ -32,7 +32,7 @@
 
 #include 		/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lcd.c,v 1.9 2018/03/08 03:12:02 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lcd.c,v 1.10 2019/06/30 02:11:56 tsutsui Exp $");
 
 #include 
 #include 
@@ -71,10 +71,10 @@ __KERNEL_RCSID(0, "$NetBSD: lcd.c,v 1.9 
 #define LCD_MAXBUFLEN	80
 
 struct pio {
-	volatile u_int8_t portA;
-	volatile u_int8_t portB;
-	volatile u_int8_t portC;
-	volatile u_int8_t cntrl;
+	volatile uint8_t portA;
+	volatile uint8_t portB;
+	volatile uint8_t portC;
+	volatile uint8_t cntrl;
 };
 
 /* Autoconf stuff */
@@ -344,6 +344,7 @@ lcdshow(char *s)
 void
 greeting(void)
 {
+
 	lcdctrl(LCD_INIT);
 	lcdctrl(LCD_ENTRY);
 	lcdctrl(LCD_ON);

Index: src/sys/arch/luna68k/dev/lunafb.c
diff -u src/sys/arch/luna68k/dev/lunafb.c:1.37 src/sys/arch/luna68k/dev/lunafb.c:1.38
--- src/sys/arch/luna68k/dev/lunafb.c:1.37	Wed Jan 24 05:35:58 2018
+++ src/sys/arch/luna68k/dev/lunafb.c	Sun Jun 30 02:11:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: lunafb.c,v 1.37 2018/01/24 05:35:58 riastradh Exp $ */
+/* $NetBSD: lunafb.c,v 1.38 2019/06/30 02:11:56 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.37 2018/01/24 05:35:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: lunafb.c,v 1.38 2019/06/30 02:11:56 tsutsui Exp $");
 
 #include 
 #include 
@@ -346,7 +346,7 @@ omsetcmap(struct omfb_softc *sc, struct 
 
 	cmsize = sc->sc_dc->dc_cmsize;
 	if (index >= cmsize || count > cmsize - index)
-		return (EINVAL);
+		return EINVAL;
 
 	error = copyin(p->red, [index], count);
 	if (error)

Index: src/sys/arch/luna68k/dev/siotty.c
diff -u src/sys/arch/luna68k/dev/siotty.c:1.44 src/sys/arch/luna68k/dev/siotty.c:1.45
--- src/sys/arch/luna68k/dev/siotty.c:1.44	Fri Aug 21 10:48:06 2015
+++ src/sys/arch/luna68k/dev/siotty.c	Sun Jun 30 02:11:56 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: siotty.c,v 1.44 2015/08/21 10:48:06 christos Exp $ */
+/* $NetBSD: siotty.c,v 1.45 2019/06/30 02:11:56 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.44 2015/08/21 10:48:06 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: siotty.c,v 1.45 2019/06/30 02:11:56 tsutsui Exp $");
 
 #include "opt_ddb.h"
 
@@ -602,7 +602,7 @@ siopoll(dev_t dev, int events, struct lw
 
 	sc = device_lookup_private(_cd, minor(dev));
 	tp = sc->sc_tty;
-	return ((*tp->t_linesw->l_poll)(tp, events, l));
+	return (*tp->t_linesw->l_poll)(tp, events, l);
 }
 
 int



CVS commit: src/sys/arch/luna68k/dev

2019-06-29 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Sun Jun 30 02:11:56 UTC 2019

Modified Files:
src/sys/arch/luna68k/dev: if_le.c lcd.c lunafb.c siotty.c

Log Message:
Misc KNF.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/luna68k/dev/if_le.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/luna68k/dev/lcd.c
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/luna68k/dev/lunafb.c
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/luna68k/dev/siotty.c

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



Re: CVS commit: src/sys/arch/luna68k/dev

2014-01-02 Thread David Holland
On Thu, Jan 02, 2014 at 01:25:56PM +0900, Izumi Tsutsui wrote:
   This could lead to problems in the future. I would put it back.
  
  How? 
   - it was added by me recently
   - netbsd-6 doesn't have it
   - no other serial driver except com(4) has it

ISTM that if the field exists, it should always be initialized (in all
tty drivers); if it doesn't need to be initialized, it shouldn't
exist...

The tty code is a mess but someday someone will fix it up.

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/arch/luna68k/dev

2014-01-02 Thread David Holland
On Thu, Jan 02, 2014 at 11:11:34AM -0500, Christos Zoulas wrote:
  | ISTM that if the field exists, it should always be initialized (in all
  | tty drivers); if it doesn't need to be initialized, it shouldn't
  | exist...
  | 
  | The tty code is a mess but someday someone will fix it up.
  
  grep -rw t_softc /usr/src/sys reveals:
  
  ./dev/ic/com.c: tp-t_softc = sc;
  ./sys/tty.h:void*t_softc;   /* pointer to driver's 
  softc. */
  
  And the change was done a long time ago, and still nothing uses it.
  
  date: 2013-02-24 01:20:24 -0500;  author: matt;  state: Exp;  lines: +2 -1;
  Add a t_softc member to struct tty in which a driver can store a pointer
  to its softc.  (analogous to if_softc in struct ifnet).
  
  What's the plan?

Dunno... Cc: added

(my plan has been to invade with torches and pitchforks, but I've been
putting off even looking at it while namei and vfs stuff remain a mess)

-- 
David A. Holland
dholl...@netbsd.org


Re: CVS commit: src/sys/arch/luna68k/dev

2014-01-01 Thread Christos Zoulas
In article 20140102033235.cfeb...@cvs.netbsd.org,
Izumi Tsutsui source-changes-d@NetBSD.org wrote:
-=-=-=-=-=-

Module Name:   src
Committed By:  tsutsui
Date:  Thu Jan  2 03:32:35 UTC 2014

Modified Files:
   src/sys/arch/luna68k/dev: siotty.c

Log Message:
Remove initialization of unused t_softc in struct tty (to make pullup easier).

This could lead to problems in the future. I would put it back.

christos



Re: CVS commit: src/sys/arch/luna68k/dev

2014-01-01 Thread Christos Zoulas
On Jan 2,  1:25pm, tsut...@ceres.dti.ne.jp (Izumi Tsutsui) wrote:
-- Subject: Re: CVS commit: src/sys/arch/luna68k/dev

|  This could lead to problems in the future. I would put it back.
| 
|  - it was added by me recently
|  - netbsd-6 doesn't have it
|  - no other serial driver except com(4) has it

I don't know, if nothing uses it, it is not needed, if things start
using it, it should be initialized everywhere.

christos


Re: CVS commit: src/sys/arch/luna68k/dev

2014-01-01 Thread Izumi Tsutsui
christos@ wrote:

 On Jan 2,  1:25pm, tsut...@ceres.dti.ne.jp (Izumi Tsutsui) wrote:
 -- Subject: Re: CVS commit: src/sys/arch/luna68k/dev
 
 |  This could lead to problems in the future. I would put it back.
 | 
 |  - it was added by me recently
 |  - netbsd-6 doesn't have it
 |  - no other serial driver except com(4) has it
 
 I don't know, if nothing uses it, it is not needed, if things start
 using it, it should be initialized everywhere.

Then you shouldn't put it back unless you know how it will be used.

There was no explanation why it was needed in related commit logs,
and if it's really necessary in all drivers it was an API change
and should be announced properly.

Anyway I don't see reason why it's necessary.
All other tty drivers use device_lookup_private(9) with
struct cfdriver and UNIT(tp-t_dev) to get softc in drivers.

---
Izumi Tsutsui


Re: CVS commit: src/sys/arch/luna68k/dev

2014-01-01 Thread Christos Zoulas
On Jan 2,  2:03pm, tsut...@ceres.dti.ne.jp (Izumi Tsutsui) wrote:
-- Subject: Re: CVS commit: src/sys/arch/luna68k/dev

| Then you shouldn't put it back unless you know how it will be used.

I am not putting it back.

| There was no explanation why it was needed in related commit logs,
| and if it's really necessary in all drivers it was an API change
| and should be announced properly.

I don't know either. Let's discuss in tech-kern.

| Anyway I don't see reason why it's necessary.
| All other tty drivers use device_lookup_private(9) with
| struct cfdriver and UNIT(tp-t_dev) to get softc in drivers.

OK fine then.

christos