summaryrefslogtreecommitdiff
path: root/sys/dev/acpi/acpi.c
diff options
context:
space:
mode:
authorJordan Hargrave <jordan@cvs.openbsd.org>2005-12-16 18:59:42 +0000
committerJordan Hargrave <jordan@cvs.openbsd.org>2005-12-16 18:59:42 +0000
commite78549fa516a71b200faa5d49d79791551bdebc9 (patch)
treef037561afe524390d16ebafc3a7ddd88cde2ada0 /sys/dev/acpi/acpi.c
parent4a550814464b5fa814d29d13d9f69143362bd870 (diff)
Added hooks for powerdown/power button press
Diffstat (limited to 'sys/dev/acpi/acpi.c')
-rw-r--r--sys/dev/acpi/acpi.c45
1 files changed, 31 insertions, 14 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c
index 3d9024d429e..b431c9b3bd1 100644
--- a/sys/dev/acpi/acpi.c
+++ b/sys/dev/acpi/acpi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpi.c,v 1.9 2005/12/16 18:11:55 jordan Exp $ */
+/* $OpenBSD: acpi.c,v 1.10 2005/12/16 18:59:41 jordan Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -31,6 +31,9 @@
#include <dev/acpi/amltypes.h>
#include <dev/acpi/dsdt.h>
+#include <sys/signalvar.h>
+#include <sys/proc.h>
+
#ifdef ACPI_DEBUG
int acpi_debug = 20;
#endif
@@ -71,6 +74,7 @@ struct cfdriver acpi_cd = {
NULL, "acpi", DV_DULL
};
+int acpi_s5;
int acpi_evindex;
struct acpi_softc *acpi_softc;
@@ -721,13 +725,19 @@ void
acpi_softintr(void *arg)
{
struct acpi_softc *sc = arg;
-
+ extern int kbd_reset;
+
if (sc->sc_powerbtn) {
sc->sc_powerbtn = 0;
acpi_evindex++;
dnprintf(1,"power button pressed\n");
KNOTE(sc->sc_note, ACPI_EVENT_COMPOSE(ACPI_EV_PWRBTN,
acpi_evindex));
+ acpi_s5 = 1;
+ if (kbd_reset == 1) {
+ kbd_reset = 0;
+ psignal(initproc, SIGUSR1);
+ }
}
if (sc->sc_sleepbtn) {
sc->sc_sleepbtn = 0;
@@ -738,6 +748,25 @@ acpi_softintr(void *arg)
}
}
+
+void
+acpi_enter_sleep_state(struct acpi_softc *sc, int state)
+{
+#ifdef ACPI_ENABLE
+ u_int16_t flag;
+
+ flag = acpi_read_pmreg(sc, ACPIREG_PM1_CNT);
+ acpi_write_pmreg(sc, ACPIREG_PM1_CNT, flag |= (state << 10));
+ acpi_write_pmreg(sc, ACPIREG_PM1_CNT, flag |= ACPI_PM1_SLP_EN);
+#endif
+}
+
+void
+acpi_powerdown(void)
+{
+ acpi_enter_sleep_state(acpi_softc, 5);
+}
+
int
acpiopen(dev_t dev, int flag, int mode, struct proc *p)
{
@@ -754,18 +783,6 @@ acpiopen(dev_t dev, int flag, int mode, struct proc *p)
return (error);
}
-void
-acpi_enter_sleep_state(struct acpi_softc *sc, int state)
-{
-#ifdef ACPI_ENABLE
- u_int16_t flag;
-
- flag = acpi_read_pmreg(sc, ACPIREG_PM1_CNT);
- acpi_write_pmreg(sc, ACPIREG_PM1_CNT, flag |= (state << 10));
- acpi_write_pmreg(sc, ACPIREG_PM1_CNT, flag |= ACPI_PM1_SLP_EN);
-#endif
-}
-
int
acpiclose(dev_t dev, int flag, int mode, struct proc *p)
{