CVS commit: [netbsd-8] src/sys/dev/hpc

2018-09-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Sep 23 17:20:08 UTC 2018

Modified Files:
src/sys/dev/hpc [netbsd-8]: hpckbd.c

Log Message:
Pull up following revision(s) (requested by rin in ticket #1021):

sys/dev/hpc/hpckbd.c: revision 1.33
sys/dev/hpc/hpckbd.c: revision 1.34
sys/dev/hpc/hpckbd.c: revision 1.35

Apply workaround introduced in r1.31 to hpcmips.

Fix kernel crash when console is attached. Now, my MC/R550 boots multiuser.
Thanks Masahiko Ito for encouraging me to do bisection to find this out.
XXX pullup-8, pullup-7

Fix comment formatting in previous.

Clarify the comment in the "unconst" version of hpckbd_keymap_setup.
Both sh3 (P1) and mips (kseg0) have the kernel directly mapped.


To generate a diff of this commit:
cvs rdiff -u -r1.30.30.2 -r1.30.30.3 src/sys/dev/hpc/hpckbd.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/dev/hpc/hpckbd.c
diff -u src/sys/dev/hpc/hpckbd.c:1.30.30.2 src/sys/dev/hpc/hpckbd.c:1.30.30.3
--- src/sys/dev/hpc/hpckbd.c:1.30.30.2	Wed Aug  9 05:57:32 2017
+++ src/sys/dev/hpc/hpckbd.c	Sun Sep 23 17:20:08 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpckbd.c,v 1.30.30.2 2017/08/09 05:57:32 snj Exp $ */
+/*	$NetBSD: hpckbd.c,v 1.30.30.3 2018/09/23 17:20:08 martin Exp $ */
 
 /*-
  * Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.30.30.2 2017/08/09 05:57:32 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.30.30.3 2018/09/23 17:20:08 martin Exp $");
 
 #include 
 #include 
@@ -261,10 +261,11 @@ hpckbd_getevent(struct hpckbd_core* hc, 
 }
 
 
-#ifdef hpcsh
+#if defined(hpcsh) || defined(hpcmips)
 /*
- * XXX: Use the old wrong code for now as hpcsh attaches console very
- * early and it's convenient to be able to do early DDB on wscons.
+ * XXX: Use the old wrong code for now as hpcsh and hpcmips attach
+ * console very early when malloc(9) is not yet available.  It is
+ * convenient to be able to do early DDB on wscons.
  */
 void
 hpckbd_keymap_setup(struct hpckbd_core *hc,
@@ -278,8 +279,9 @@ hpckbd_keymap_setup(struct hpckbd_core *
 	 * XXX The way this is done is really wrong.  The __UNCONST()
 	 * is a hint as to what is wrong.  This actually ends up modifying
 	 * initialized data which is marked "const".
-	 * The reason we get away with it here is that on sh3 kernel
-	 * is directly mapped.
+	 *
+	 * The reason we get away with it here is that on sh3 and mips
+	 * the kernel is directly mapped.
 	 */
 	desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc);
 	for (i = 0; desc[i].name != 0; i++) {



CVS commit: [netbsd-8] src/sys/dev/hpc

2017-08-08 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Wed Aug  9 05:57:32 UTC 2017

Modified Files:
src/sys/dev/hpc [netbsd-8]: hpckbd.c

Log Message:
Pull up following revision(s) (requested by uwe in ticket #202):
sys/dev/hpc/hpckbd.c: revision 1.32
XXX: On hpcsh only - bring back old incorrect hpckbd_keymap_setup()
fixed in 1.31.  The old one with UNCONST does work on hpcsh b/c the
kernel is directly mapped.  The new one does not work on hpcsh b/c it
calls consinit() very early when malloc() is not yet available.
The real fix for this is to fix the constness of wscons keymap
structures that is self-contradictory.


To generate a diff of this commit:
cvs rdiff -u -r1.30.30.1 -r1.30.30.2 src/sys/dev/hpc/hpckbd.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/dev/hpc/hpckbd.c
diff -u src/sys/dev/hpc/hpckbd.c:1.30.30.1 src/sys/dev/hpc/hpckbd.c:1.30.30.2
--- src/sys/dev/hpc/hpckbd.c:1.30.30.1	Fri Jun 30 06:25:43 2017
+++ src/sys/dev/hpc/hpckbd.c	Wed Aug  9 05:57:32 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpckbd.c,v 1.30.30.1 2017/06/30 06:25:43 snj Exp $ */
+/*	$NetBSD: hpckbd.c,v 1.30.30.2 2017/08/09 05:57:32 snj Exp $ */
 
 /*-
  * Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.30.30.1 2017/06/30 06:25:43 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.30.30.2 2017/08/09 05:57:32 snj Exp $");
 
 #include 
 #include 
@@ -260,6 +260,40 @@ hpckbd_getevent(struct hpckbd_core* hc, 
 	return (1);
 }
 
+
+#ifdef hpcsh
+/*
+ * XXX: Use the old wrong code for now as hpcsh attaches console very
+ * early and it's convenient to be able to do early DDB on wscons.
+ */
+void
+hpckbd_keymap_setup(struct hpckbd_core *hc,
+		const keysym_t *map, int mapsize)
+{
+	int i;
+	struct wscons_keydesc *desc;
+
+	/* fix keydesc table */
+	/* 
+	 * XXX The way this is done is really wrong.  The __UNCONST()
+	 * is a hint as to what is wrong.  This actually ends up modifying
+	 * initialized data which is marked "const".
+	 * The reason we get away with it here is that on sh3 kernel
+	 * is directly mapped.
+	 */
+	desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc);
+	for (i = 0; desc[i].name != 0; i++) {
+		if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {
+			desc[i].map = map;
+			desc[i].map_size = mapsize;
+		}
+	}
+
+	return;
+}
+
+#else
+
 void
 hpckbd_keymap_setup(struct hpckbd_core *hc,
 		const keysym_t *map, int mapsize)
@@ -294,6 +328,7 @@ hpckbd_keymap_setup(struct hpckbd_core *
 
 	return;
 }
+#endif
 
 void
 hpckbd_keymap_lookup(struct hpckbd_core *hc)



CVS commit: [netbsd-8] src/sys/dev/hpc

2017-06-29 Thread Soren Jacobsen
Module Name:src
Committed By:   snj
Date:   Fri Jun 30 06:25:43 UTC 2017

Modified Files:
src/sys/dev/hpc [netbsd-8]: hpckbd.c

Log Message:
Pull up following revision(s) (requested by manu in ticket #61):
sys/dev/hpc/hpckbd.c: revision 1.31
Restore wscons keymaps feature on hpcarm
hpc ports need to alter keydesc data at runtime in order to load
alternate keymaps. But since keydesc is const initialized data, it
is mapped read only and the operation should fail.
It seems older compiler failed to enforce the read-only mapping and
this is why it used to work, but on recent NetBSD releases, the
feature is broken.
We fix it by duplicating the keydesc data once into a malloc'ed area
that can be modified.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.30.30.1 src/sys/dev/hpc/hpckbd.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/dev/hpc/hpckbd.c
diff -u src/sys/dev/hpc/hpckbd.c:1.30 src/sys/dev/hpc/hpckbd.c:1.30.30.1
--- src/sys/dev/hpc/hpckbd.c:1.30	Sat Oct 27 17:18:17 2012
+++ src/sys/dev/hpc/hpckbd.c	Fri Jun 30 06:25:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpckbd.c,v 1.30 2012/10/27 17:18:17 chs Exp $ */
+/*	$NetBSD: hpckbd.c,v 1.30.30.1 2017/06/30 06:25:43 snj Exp $ */
 
 /*-
  * Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
@@ -30,11 +30,12 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.30 2012/10/27 17:18:17 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.30.30.1 2017/06/30 06:25:43 snj Exp $");
 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -264,22 +265,30 @@ hpckbd_keymap_setup(struct hpckbd_core *
 		const keysym_t *map, int mapsize)
 {
 	int i;
-	struct wscons_keydesc *desc;
+	const struct wscons_keydesc *desc;
+	static struct wscons_keydesc *ndesc = NULL;
 
-	/* fix keydesc table */
 	/* 
-	 * XXX The way this is done is really wrong.  The __UNCONST()
-	 * is a hint as to what is wrong.  This actually ends up modifying
-	 * initialized data which is marked "const".
-	 * The reason we get away with it here is apparently that text
-	 * and read-only data gets mapped read/write on the platforms
-	 * using this code.
+	 * fix keydesc table. Since it is const data, we must 
+	 * copy it once before changingg it.
 	 */
-	desc = (struct wscons_keydesc *)__UNCONST(hpckbd_keymapdata.keydesc);
+
+	if (ndesc == NULL) {
+		size_t sz;
+
+		for (sz = 0; hpckbd_keymapdata.keydesc[sz].name != 0; sz++);
+
+		ndesc = malloc(sz * sizeof(*ndesc), M_DEVBUF, M_WAITOK);
+		memcpy(ndesc, hpckbd_keymapdata.keydesc, sz * sizeof(*ndesc));
+
+		hpckbd_keymapdata.keydesc = ndesc;
+	}
+
+	desc = hpckbd_keymapdata.keydesc;
 	for (i = 0; desc[i].name != 0; i++) {
 		if ((desc[i].name & KB_MACHDEP) && desc[i].map == NULL) {
-			desc[i].map = map;
-			desc[i].map_size = mapsize;
+			ndesc[i].map = map;
+			ndesc[i].map_size = mapsize;
 		}
 	}