diff options
author | George Koehler <gkoehler@cvs.openbsd.org> | 2022-10-21 22:42:37 +0000 |
---|---|---|
committer | George Koehler <gkoehler@cvs.openbsd.org> | 2022-10-21 22:42:37 +0000 |
commit | ebdd629c20fba9b043a7e3387800de2d01a9ba53 (patch) | |
tree | 41688fb3cd2ad7600b77e067745d207fb2771ee9 /sys/dev | |
parent | 50a0af2a43e70dc00de390c2c0d8f73169e5134d (diff) |
hw.power, machdep.lidaction, machdep.pwraction for macppc
I can now use the power button to power off my macppcs running
OpenBSD. The new sysctls machdep.lidaction and machdep.pwraction act
like acpibtn(4), but we are missing code to suspend or hibernate a
macppc. Small kernels (bsd.rd) continue to ignore the power button.
adb(4) sends an environment interrupt when I unplug my PowerBook's AC
or close its lid. Rename PMU_INT_WAKEUP to PMU_INT_ENVIRONMENT like
other BSDs and Linux. Handle PMU_ENV_LID_CLOSED as a lid sensor and
PMU_ENV_AC_POWER by setting sysctl hw.power. Power buttons can either
use PMU_ENV_POWER_BUTTON or go through akbd(4); handle both kinds of
power buttons in the same way. Other models of macppc, with different
power buttons or lids, might not work yet. The lid sensor looks like,
$ sysctl hw.sensors
hw.sensors.adb0.indicator0=On (lid open)
kettenis@ warned against calling prsignal() from interrupt context,
and pointed me to task_add(9).
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/adb/adb.h | 4 | ||||
-rw-r--r-- | sys/dev/adb/akbd.c | 9 |
2 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/adb/adb.h b/sys/dev/adb/adb.h index 35d0fb0db56..f05eb1eab8a 100644 --- a/sys/dev/adb/adb.h +++ b/sys/dev/adb/adb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: adb.h,v 1.5 2011/06/16 10:44:33 mpi Exp $ */ +/* $OpenBSD: adb.h,v 1.6 2022/10/21 22:42:36 gkoehler Exp $ */ /* $NetBSD: adbsys.h,v 1.4 2000/12/19 02:59:24 tsubai Exp $ */ /*- @@ -139,6 +139,8 @@ typedef struct { } ADBDataBlock; int adbprint(void *, const char *); +void adb_lid_closed_intr(void); +void adb_power_button_intr(void); int adb_op_sync(Ptr, short); int set_adb_info(ADBSetInfoBlock *, int); diff --git a/sys/dev/adb/akbd.c b/sys/dev/adb/akbd.c index 801f5b7f09a..e2d89cad418 100644 --- a/sys/dev/adb/akbd.c +++ b/sys/dev/adb/akbd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: akbd.c,v 1.15 2022/04/06 18:59:27 naddy Exp $ */ +/* $OpenBSD: akbd.c,v 1.16 2022/10/21 22:42:36 gkoehler Exp $ */ /* $NetBSD: akbd.c,v 1.17 2005/01/15 16:00:59 chs Exp $ */ /* @@ -467,13 +467,14 @@ akbd_processevent(struct akbd_softc *sc, adb_event_t *event) case 2: /* * The reset (or power) key sends 0x7f7f on press and - * 0xffff on release, and we ignore it. + * 0xffff on release. */ if (event->bytes[0] == event->bytes[1] && ADBK_KEYVAL(event->bytes[0]) == ADBK_RESET) { - if (event->bytes[0] == ADBK_KEYDOWN(ADBK_RESET)) + if (event->bytes[0] == ADBK_KEYDOWN(ADBK_RESET)) { SET(sc->sc_caps, CL_DOWN_RESET); - else { + adb_power_button_intr(); + } else { if (ISSET(sc->sc_caps, CL_DOWN_RESET)) CLR(sc->sc_caps, CL_DOWN_RESET); else if (ISSET(sc->sc_caps, CL_DOWN_ADB)) { |