NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/48360: wskbd - support for cn_magic
>Number: 48360
>Category: kern
>Synopsis: wskbd - support for cn_magic
>Confidential: no
>Severity: non-critical
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: change-request
>Submitter-Id: net
>Arrival-Date: Sat Nov 02 09:45:00 +0000 2013
>Originator: Nat Sloss
>Release: NetBSD 6.1.1
>Organization:
>Environment:
NetBSD beast 6.1.1_PATCH NetBSD 6.1.1_PATCH (PCIPAE) #13: Sat Nov 2 18:07:05
EST 2013 build@test:/usr/src/sys/arch/i386/compile/obj/PCIPAE i386
>Description:
wscons does not support cn_magic - setting hw.cnmagic has no effect.
So I have a simple patch that adds support, although it probably needs some
reworking.
Also I did not know the byte sequence for C-A-Esc so I used KS_Cmd_Debugger.
As a consequence the debugger can also be entered with " (curcumflex modifier)"
KS_circumflex, which I did not know how to enter from my keyboard in /bin/ksh.
But Apart from that it works well.
I also found that even without this patch the debugger can be entered from any
virtual terminal except vt5 (used for x windows) this was not the case in
NetBSD 5.0.1.
>How-To-Repeat:
Refer to above.
>Fix:
Apply this patch:
Index: src/sys/dev/wscons/wskbd.c
===================================================================
RCS file: /cvsroot/src/sys/dev/wscons/wskbd.c,v
retrieving revision 1.130
diff -u -r1.130 wskbd.c
--- src/sys/dev/wscons/wskbd.c 26 Oct 2010 05:12:34 -0000 1.130
+++ src/sys/dev/wscons/wskbd.c 2 Nov 2013 09:23:10 -0000
@@ -207,6 +207,7 @@
wskbd_hotkey_plugin *sc_hotkey;
void *sc_hotkeycookie;
+ dev_t cn_magicdev; /* device for cnmagic */
};
#define MOD_SHIFT_L (1 << 0)
@@ -241,6 +242,19 @@
dst |= (src & MOD_META_L) ? MOD_META_L : 0; \
dst |= (src & MOD_META_R) ? MOD_META_R : 0; \
} while (0)
+#define ws_check_magic(k, s) \
+ do { \
+ int _v = (s).cnm_magic[(s).cnm_state]; \
+ if ((k) == CNS_MAGIC_VAL(_v)) { \
+ (s).cnm_state = CNS_MAGIC_NEXT(_v); \
+ if ((s).cnm_state == CNS_TERM) { \
+ cn_trap(); \
+ (s).cnm_state = 0; \
+ } \
+ } else { \
+ (s).cnm_state = 0; \
+ } \
+ } while (/* CONSTCOND */ 0)
static int wskbd_match(device_t, cfdata_t, void *);
static void wskbd_attach(device_t, device_t, void *);
@@ -350,6 +364,9 @@
static bool wskbd_suspend(device_t dv, const pmf_qual_t *);
static void wskbd_repeat(void *v);
+#include <dev/cons.h>
+static struct cnm_state ws_cnm_state;
+
static int wskbd_console_initted;
static struct wskbd_softc *wskbd_console_device;
static struct wskbd_internal wskbd_console_data;
@@ -438,6 +455,11 @@
if (ap->console) {
sc->id = &wskbd_console_data;
+
+ sc->cn_magicdev = cn_tab->cn_dev;
+ cn_init_magic(&ws_cnm_state);
+ cn_set_magic("\x20\xf4"); /* default magic */
+
} else {
sc->id = malloc(sizeof(struct wskbd_internal),
M_DEVBUF, M_WAITOK|M_ZERO);
@@ -526,7 +548,7 @@
wskbd_console_data.t_consops = consops;
wskbd_console_data.t_consaccesscookie = conscookie;
-
+
#if NWSDISPLAY > 0
wsdisplay_set_cons_kbd(wskbd_cngetc, wskbd_cnpollc, wskbd_cnbell);
#endif
@@ -1583,7 +1605,9 @@
return (0);
#if defined(DDB) || defined(KGDB)
+
if (ksym == KS_Cmd_Debugger) {
+#if 0
if (sc->sc_isconsole) {
#ifdef DDB
console_debugger();
@@ -1592,6 +1616,7 @@
kgdb_connect(1);
#endif
}
+#endif
/* discard this key (ddb discarded command modifiers) */
*type = WSCONS_EVENT_KEY_UP;
return (1);
@@ -1713,9 +1738,17 @@
}
/* if this key has a command, process it first */
- if (sc != NULL && kp->command != KS_voidSymbol)
+ if (sc != NULL && kp->command != KS_voidSymbol) {
iscommand = internal_command(sc, &type, kp->command,
kp->group1[0]);
+ if (sc->sc_isconsole && iscommand) {
+ if (kp->command & 0xff)
+ ws_check_magic((kp->command & 0xff),
ws_cnm_state);
+ if ((kp->command >> 8) & 0xff)
+ ws_check_magic(((kp->command >> 8) & 0xff),
ws_cnm_state);
+ }
+
+ }
/* Now update modifiers */
switch (kp->group1[0]) {
@@ -1868,12 +1901,32 @@
if (id->t_flags & WSKFL_METAESC) {
id->t_symbols[0] = KS_Escape;
id->t_symbols[1] = res;
+ if (sc != NULL && sc->sc_isconsole) {
+ if (res & 0xff)
+ ws_check_magic((res & 0xff),
ws_cnm_state);
+ if ((res >> 8) & 0xff)
+ ws_check_magic(((res >> 8) &
0xff), ws_cnm_state);
+ if (KS_Escape & 0xff)
+ ws_check_magic((KS_Escape &
0xff), ws_cnm_state);
+ if ((KS_Escape >> 8) & 0xff)
+ ws_check_magic(((KS_Escape >>
8) & 0xff), ws_cnm_state);
+ }
+
return (2);
} else
res |= 0x80;
}
+
}
id->t_symbols[0] = res;
+
+ if (sc != NULL && sc->sc_isconsole) {
+ if (res & 0xff)
+ ws_check_magic((res & 0xff), ws_cnm_state);
+ if ((res >> 8) & 0xff)
+ ws_check_magic(((res >> 8) & 0xff), ws_cnm_state);
+ }
+
return (1);
}
It works - but it definately needs reworking.
NB: This patch is my own work, which I submit under the NetBSD license.
I hope others find this useful.
Regards,
Nat.
Home |
Main Index |
Thread Index |
Old Index