Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-8]: src/sys/dev/hpc Pull up following revision(s) (requested by m...
details: https://anonhg.NetBSD.org/src/rev/81ef6930434c
branches: netbsd-8
changeset: 850762:81ef6930434c
user: snj <snj%NetBSD.org@localhost>
date: Fri Jun 30 06:25:43 2017 +0000
description:
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.
diffstat:
sys/dev/hpc/hpckbd.c | 35 ++++++++++++++++++++++-------------
1 files changed, 22 insertions(+), 13 deletions(-)
diffs (65 lines):
diff -r bf2f93181f4d -r 81ef6930434c sys/dev/hpc/hpckbd.c
--- a/sys/dev/hpc/hpckbd.c Fri Jun 30 06:23:17 2017 +0000
+++ b/sys/dev/hpc/hpckbd.c Fri Jun 30 06:25:43 2017 +0000
@@ -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 <sys/cdefs.h>
-__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 <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
+#include <sys/malloc.h>
#include <sys/tty.h>
@@ -264,22 +265,30 @@
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;
}
}
Home |
Main Index |
Thread Index |
Old Index