summaryrefslogtreecommitdiffstats
path: root/usr.sbin/acpi
diff options
context:
space:
mode:
authornjl <njl@FreeBSD.org>2003-12-30 17:28:06 +0000
committernjl <njl@FreeBSD.org>2003-12-30 17:28:06 +0000
commitdc92f60c73455d47a4f12fcc4033cda71d5e3010 (patch)
tree7df2978487882efbbd26988ce7aa085b9147d6fc /usr.sbin/acpi
parentaf0a8468003fa6f8023d5ca404fc9a2b2a276057 (diff)
downloadFreeBSD-src-dc92f60c73455d47a4f12fcc4033cda71d5e3010.zip
FreeBSD-src-dc92f60c73455d47a4f12fcc4033cda71d5e3010.tar.gz
Add support for /etc/rc.suspend and /etc/rc.resume for ACPI. They are
called directly from acpiconf(8). Change both scripts to take a subsystem (apm|acpi) and sleep level (suspend,standby|1-5) argument.
Diffstat (limited to 'usr.sbin/acpi')
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.89
-rw-r--r--usr.sbin/acpi/acpiconf/acpiconf.c26
2 files changed, 31 insertions, 4 deletions
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.8 b/usr.sbin/acpi/acpiconf/acpiconf.8
index 47f90c8..b3d8bd3 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.8
+++ b/usr.sbin/acpi/acpiconf/acpiconf.8
@@ -58,7 +58,8 @@ Enters the specified sleep mode.
Recognized types are
.Cm 1
(only the CPU clock is stopped),
-.Cm 2 ,
+.Cm 2
+(not implemented on most systems but similar to S1),
.Cm 3
(the CPU context is lost and memory context is preserved),
.Cm 4
@@ -69,6 +70,12 @@ and
Sleep states may also be given as S1, S2, etc.
The supported states depend on BIOS implementation, including ACPI
byte code (AML).
+If the
+.Pa /etc/rc.suspend
+and
+.Pa /etc/rc.resume
+scripts are executable, they will be run before and after entering
+the given sleep state.
.El
.Sh SEE ALSO
.Xr acpi 4 ,
diff --git a/usr.sbin/acpi/acpiconf/acpiconf.c b/usr.sbin/acpi/acpiconf/acpiconf.c
index 9be6ad8..377f0f9 100644
--- a/usr.sbin/acpi/acpiconf/acpiconf.c
+++ b/usr.sbin/acpi/acpiconf/acpiconf.c
@@ -37,10 +37,11 @@
#include <unistd.h>
#include <dev/acpica/acpiio.h>
-
#include <contrib/dev/acpica/acpi.h>
-#define ACPIDEV "/dev/acpi"
+#define ACPIDEV "/dev/acpi"
+#define RC_SUSPEND_PATH "/etc/rc.suspend"
+#define RC_RESUME_PATH "/etc/rc.resume"
static int acpifd;
@@ -68,7 +69,26 @@ acpi_enable_disable(int enable)
static int
acpi_sleep(int sleep_type)
{
- if (ioctl(acpifd, ACPIIO_SETSLPSTATE, &sleep_type) == -1)
+ char cmd[64];
+ int ret;
+
+ /* Run the suspend rc script, if available. */
+ if (access(RC_SUSPEND_PATH, X_OK) == 0) {
+ snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_SUSPEND_PATH,
+ sleep_type);
+ system(cmd);
+ }
+
+ ret = ioctl(acpifd, ACPIIO_SETSLPSTATE, &sleep_type);
+
+ /* Run the resume rc script, if available. */
+ if (access(RC_RESUME_PATH, X_OK) == 0) {
+ snprintf(cmd, sizeof(cmd), "%s acpi %d", RC_RESUME_PATH,
+ sleep_type);
+ system(cmd);
+ }
+
+ if (ret != 0)
err(EX_IOERR, "sleep type (%d) failed", sleep_type);
return (0);
OpenPOWER on IntegriCloud