diff options
author | iwasaki <iwasaki@FreeBSD.org> | 2000-08-31 11:15:03 +0000 |
---|---|---|
committer | iwasaki <iwasaki@FreeBSD.org> | 2000-08-31 11:15:03 +0000 |
commit | e6fd189e34948ac9c5cb54d8b3d73331464e8fa4 (patch) | |
tree | 0e85cd7294dba971c868643e569d3c13077403a9 /sys | |
parent | f1908a0e71bec8c9a827e27d6586ce8cbb25cd90 (diff) | |
download | FreeBSD-src-e6fd189e34948ac9c5cb54d8b3d73331464e8fa4.zip FreeBSD-src-e6fd189e34948ac9c5cb54d8b3d73331464e8fa4.tar.gz |
Cleanup on power off code under ACPI.
- Remove DELAY() kludge before power off.
- Move EVENTHANDLER_REGISTER to acpi_attach().
- Pass RB_POWEROFF flag to shutdown_nice().
Reviewed by: msmith
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/acpi/acpi.c | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/sys/dev/acpi/acpi.c b/sys/dev/acpi/acpi.c index fbbbde7..f2e3eae 100644 --- a/sys/dev/acpi/acpi.c +++ b/sys/dev/acpi/acpi.c @@ -37,6 +37,7 @@ #include <sys/sysctl.h> #include <sys/eventhandler.h> /* for EVENTHANDLER_REGISTER */ +#include <sys/reboot.h> /* for RB_POWEROFF */ #include <machine/clock.h> /* for DELAY */ #include <machine/bus.h> @@ -877,9 +878,11 @@ acpi_soft_off(void *data, int howto) { acpi_softc_t *sc; + if (!(howto & RB_POWEROFF)) { + return; + } sc = (acpi_softc_t *) data; - /* wait 1sec before turning off the system power */ - DELAY(1000*1000); + acpi_execute_pts(sc, ACPI_S_STATE_S5); acpi_trans_sleeping_state(sc, ACPI_S_STATE_S5); } @@ -888,15 +891,6 @@ acpi_set_sleeping_state(acpi_softc_t *sc, u_int8_t state) { u_int8_t slp_typ_a, slp_typ_b; - /* Prepare to sleep */ - acpi_execute_pts(sc, state); - - /* PowerResource manipulation */ - acpi_powerres_set_sleeping_state(sc, state); - if (acpi_debug) { - acpi_powerres_debug(sc); - } - if (!sc->system_state_initialized) { return; } @@ -909,6 +903,17 @@ acpi_set_sleeping_state(acpi_softc_t *sc, u_int8_t state) return; /* unsupported sleeping type */ } + if (state < ACPI_S_STATE_S5) { + /* Prepare to sleep */ + acpi_execute_pts(sc, state); + + /* PowerResource manipulation */ + acpi_powerres_set_sleeping_state(sc, state); + if (acpi_debug) { + acpi_powerres_debug(sc); + } + } + /* * XXX currently supported S1 and S5 only. */ @@ -916,19 +921,17 @@ acpi_set_sleeping_state(acpi_softc_t *sc, u_int8_t state) case ACPI_S_STATE_S0: case ACPI_S_STATE_S1: acpi_trans_sleeping_state(sc, state); - acpi_execute_wak(sc, state); break; case ACPI_S_STATE_S5: /* Power the system off using ACPI */ - EVENTHANDLER_REGISTER(shutdown_final, acpi_soft_off, sc, - SHUTDOWN_PRI_LAST); - shutdown_nice(); /* XXX */ + shutdown_nice(RB_POWEROFF); break; default: break; } if (state < ACPI_S_STATE_S5) { + acpi_execute_wak(sc, state); acpi_powerres_set_sleeping_state(sc, 0); if (acpi_debug) { acpi_powerres_debug(sc); @@ -1330,6 +1333,9 @@ acpi_attach(device_t dev) acpi_powerres_debug(sc); } + EVENTHANDLER_REGISTER(shutdown_final, acpi_soft_off, sc, + SHUTDOWN_PRI_LAST); + acpi_pmap_release(); make_dev(&acpi_cdevsw, 0, 0, 5, 0660, "acpi"); |