summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/acpi/acpi.c45
-rw-r--r--sys/dev/acpi/acpivar.h39
2 files changed, 51 insertions, 33 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)
{
diff --git a/sys/dev/acpi/acpivar.h b/sys/dev/acpi/acpivar.h
index 5065b1083a2..5eb917bd667 100644
--- a/sys/dev/acpi/acpivar.h
+++ b/sys/dev/acpi/acpivar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: acpivar.h,v 1.6 2005/12/16 18:11:55 jordan Exp $ */
+/* $OpenBSD: acpivar.h,v 1.7 2005/12/16 18:59:41 jordan Exp $ */
/*
* Copyright (c) 2005 Thorsten Lockert <tholo@sigmasoft.com>
*
@@ -22,7 +22,7 @@
/* #define ACPI_DEBUG */
#ifdef ACPI_DEBUG
-#define dprintf(x...) do { if (acpi_debug) printf(x); } while(0)
+#define dprintf(x...) do { if (acpi_debug) printf(x); } while(0)
#define dnprintf(n,x...) do { if (acpi_debug > (n)) printf(x); } while(0)
#else
#define dprintf(x...)
@@ -55,30 +55,30 @@ struct acpi_q {
typedef SIMPLEQ_HEAD(, acpi_q) acpi_qhead_t;
#define ACPIREG_PM1A_STS 0x00
-#define ACPIREG_PM1A_EN 0x01
+#define ACPIREG_PM1A_EN 0x01
#define ACPIREG_PM1A_CNT 0x02
#define ACPIREG_PM1B_STS 0x03
-#define ACPIREG_PM1B_EN 0x04
+#define ACPIREG_PM1B_EN 0x04
#define ACPIREG_PM1B_CNT 0x05
-#define ACPIREG_PM2_CNT 0x06
-#define ACPIREG_PM_TMR 0x07
+#define ACPIREG_PM2_CNT 0x06
+#define ACPIREG_PM_TMR 0x07
#define ACPIREG_GPE0_STS 0x08
-#define ACPIREG_GPE0_EN 0x09
+#define ACPIREG_GPE0_EN 0x09
#define ACPIREG_GPE1_STS 0x0A
-#define ACPIREG_GPE1_EN 0x0B
-#define ACPIREG_SMICMD 0x0C
-#define ACPIREG_MAXREG 0x0D
+#define ACPIREG_GPE1_EN 0x0B
+#define ACPIREG_SMICMD 0x0C
+#define ACPIREG_MAXREG 0x0D
/* Special registers */
-#define ACPIREG_PM1_STS 0x0E
-#define ACPIREG_PM1_EN 0x0F
-#define ACPIREG_PM1_CNT 0x10
+#define ACPIREG_PM1_STS 0x0E
+#define ACPIREG_PM1_EN 0x0F
+#define ACPIREG_PM1_CNT 0x10
struct acpi_reg_map {
bus_space_handle_t ioh;
- int addr;
- int size;
- const char *name;
+ int addr;
+ int size;
+ const char *name;
};
struct acpi_softc {
@@ -103,8 +103,8 @@ struct acpi_softc {
struct acpi_facs *sc_facs; /* Shared with firmware! */
struct klist *sc_note;
- struct acpi_reg_map sc_pmregs[ACPIREG_MAXREG];
- bus_space_handle_t sc_ioh_pm1a_evt;
+ struct acpi_reg_map sc_pmregs[ACPIREG_MAXREG];
+ bus_space_handle_t sc_ioh_pm1a_evt;
void *sc_interrupt;
#ifdef __HAVE_GENERIC_SOFT_INTERRUPTS
@@ -125,7 +125,7 @@ struct acpi_table {
#define ACPI_IOC_GETFACS _IOR('A', 0, struct acpi_facs)
#define ACPI_IOC_GETTABLE _IOWR('A', 1, struct acpi_table)
-#define ACPI_IOC_SETSLEEPSTATE _IOW('A', 2, int)
+#define ACPI_IOC_SETSLEEPSTATE _IOW('A', 2, int)
#define ACPI_EV_PWRBTN 0x0001 /* Power button was pushed */
#define ACPI_EV_SLPBTN 0x0002 /* Sleep button was pushed */
@@ -149,6 +149,7 @@ u_int acpi_checksum(const void *, size_t);
void acpi_attach_machdep(struct acpi_softc *);
int acpi_interrupt(void *);
void acpi_enter_sleep_state(struct acpi_softc *, int);
+void acpi_powerdown(void);
#endif
#endif /* !_DEV_ACPI_ACPIVAR_H_ */