Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/adb add a sysctl to optionally ender ddb when pressi...
details: https://anonhg.NetBSD.org/src/rev/417d47eedaf8
branches: trunk
changeset: 339540:417d47eedaf8
user: macallan <macallan%NetBSD.org@localhost>
date: Mon Jul 27 19:27:04 2015 +0000
description:
add a sysctl to optionally ender ddb when pressing the power button
diffstat:
sys/dev/adb/adb_kbd.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 51 insertions(+), 5 deletions(-)
diffs (112 lines):
diff -r 70f505138bff -r 417d47eedaf8 sys/dev/adb/adb_kbd.c
--- a/sys/dev/adb/adb_kbd.c Mon Jul 27 18:09:27 2015 +0000
+++ b/sys/dev/adb/adb_kbd.c Mon Jul 27 19:27:04 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: adb_kbd.c,v 1.24 2014/11/08 17:21:51 macallan Exp $ */
+/* $NetBSD: adb_kbd.c,v 1.25 2015/07/27 19:27:04 macallan Exp $ */
/*
* Copyright (C) 1998 Colin Wood
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.24 2014/11/08 17:21:51 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: adb_kbd.c,v 1.25 2015/07/27 19:27:04 macallan Exp $");
#include <sys/param.h>
#include <sys/device.h>
@@ -88,6 +88,7 @@
int sc_rawkbd;
#endif
bool sc_emul_usb;
+ bool sc_power_dbg;
uint32_t sc_power;
uint8_t sc_buffer[16];
@@ -231,6 +232,7 @@
sc->sc_power = 0xffff;
sc->sc_timestamp = 0;
sc->sc_emul_usb = FALSE;
+ sc->sc_power_dbg = FALSE;
aprint_normal(" addr %d: ", sc->sc_adbdev->current_addr);
@@ -354,6 +356,14 @@
aprint_verbose_dev(sc->sc_dev, "extended protocol enabled\n");
}
+#ifdef ADBKBD_DEBUG
+ cmd = ADBTALK(sc->sc_adbdev->current_addr, 1);
+ sc->sc_msg_len = 0;
+ sc->sc_ops->send(sc->sc_ops->cookie, sc->sc_poll, cmd, 0, NULL);
+ adbkbd_wait(sc, 10);
+ printf("buffer: %02x %02x\n", sc->sc_buffer[0], sc->sc_buffer[1]);
+#endif
+
if (adbkbd_is_console && (adbkbd_console_attached == 0)) {
wskbd_cnattach(&adbkbd_consops, sc, &adbkbd_keymapdata);
adbkbd_console_attached = 1;
@@ -469,9 +479,13 @@
{
struct adbkbd_softc *sc = cookie;
- sysmon_pswitch_event(&sc->sc_sm_pbutton,
- ADBK_PRESS(sc->sc_pe) ? PSWITCH_EVENT_PRESSED :
- PSWITCH_EVENT_RELEASED);
+ if (sc->sc_power_dbg) {
+ Debugger();
+ } else {
+ sysmon_pswitch_event(&sc->sc_sm_pbutton,
+ ADBK_PRESS(sc->sc_pe) ? PSWITCH_EVENT_PRESSED :
+ PSWITCH_EVENT_RELEASED);
+ }
}
static inline void
@@ -800,6 +814,32 @@
}
}
+static int
+adbkbd_sysctl_dbg(SYSCTLFN_ARGS)
+{
+ struct sysctlnode node = *rnode;
+ struct adbkbd_softc *sc=(struct adbkbd_softc *)node.sysctl_data;
+ const int *np = newp;
+ bool reg;
+
+ DPRINTF("%s\n", __func__);
+ reg = sc->sc_power_dbg;
+ if (np) {
+ /* we're asked to write */
+ node.sysctl_data = ®
+ if (sysctl_lookup(SYSCTLFN_CALL(&node)) == 0) {
+
+ sc->sc_power_dbg = *(bool *)node.sysctl_data;
+ return 0;
+ }
+ return EINVAL;
+ } else {
+ node.sysctl_data = ®
+ node.sysctl_size = sizeof(reg);
+ return (sysctl_lookup(SYSCTLFN_CALL(&node)));
+ }
+}
+
static void
adbkbd_setup_sysctl(struct adbkbd_softc *sc)
{
@@ -818,6 +858,12 @@
CTLTYPE_BOOL, "emulate_usb", "USB keyboard emulation",
adbkbd_sysctl_usb, 1, (void *)sc, 0, CTL_MACHDEP,
me->sysctl_num, CTL_CREATE, CTL_EOL);
+ ret = sysctl_createv(NULL, 0, NULL,
+ (void *)&node,
+ CTLFLAG_READWRITE | CTLFLAG_OWNDESC,
+ CTLTYPE_BOOL, "power_ddb", "power button triggers ddb",
+ adbkbd_sysctl_dbg, 1, (void *)sc, 0, CTL_MACHDEP,
+ me->sysctl_num, CTL_CREATE, CTL_EOL);
#if NWSMOUSE > 0
if (sc->sc_wsmousedev != NULL) {
ret = sysctl_createv(NULL, 0, NULL,
Home |
Main Index |
Thread Index |
Old Index