Module Name:    src
Committed By:   uwe
Date:           Mon Aug  7 23:57:40 UTC 2017

Modified Files:
        src/sys/dev/hpc: hpckbd.c

Log Message:
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.31 -r1.32 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.31 src/sys/dev/hpc/hpckbd.c:1.32
--- src/sys/dev/hpc/hpckbd.c:1.31	Mon Jun 12 09:23:39 2017
+++ src/sys/dev/hpc/hpckbd.c	Mon Aug  7 23:57:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpckbd.c,v 1.31 2017/06/12 09:23:39 manu Exp $ */
+/*	$NetBSD: hpckbd.c,v 1.32 2017/08/07 23:57:40 uwe Exp $ */
 
 /*-
  * Copyright (c) 1999-2001 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.31 2017/06/12 09:23:39 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpckbd.c,v 1.32 2017/08/07 23:57:40 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -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)

Reply via email to