.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $FreeBSD: src/usr.sbin/acpi/acpiconf/acpiconf.8,v 1.13 2004/06/04 19:20:43 ru Exp $
-.\" $DragonFly: src/usr.sbin/acpi/acpiconf/acpiconf.8,v 1.1 2004/07/05 00:22:43 dillon Exp $
+.\" $FreeBSD: src/usr.sbin/acpi/acpiconf/acpiconf.8,v 1.15.20.1 2009/04/15 03:14:26 kensmith Exp $
.\"
-.Dd January 12, 2001
+.Dd August 16, 2004
.Dt ACPICONF 8
.Os
.Sh NAME
.Nd control ACPI power management
.Sh SYNOPSIS
.Nm
-.Op Fl deh
+.Op Fl h
.Op Fl i Ar batt
.Op Fl s Ar type
.Sh DESCRIPTION
functions.
The following command-line options are recognized:
.Bl -tag -width ".Fl s Ar type"
-.It Fl d
-Disables ACPI power management.
-.It Fl e
-Enables ACPI power management.
.It Fl h
Displays a summary of available options.
.It Fl i Ar batt
* SUCH DAMAGE.
*
* $Id: acpiconf.c,v 1.5 2000/08/08 14:12:19 iwasaki Exp $
- * $FreeBSD: src/usr.sbin/acpi/acpiconf/acpiconf.c,v 1.14 2004/03/05 02:48:22 takawata Exp $
- * $DragonFly: src/usr.sbin/acpi/acpiconf/acpiconf.c,v 1.3 2008/09/29 06:59:45 hasso Exp $
+ * $FreeBSD: src/usr.sbin/acpi/acpiconf/acpiconf.c,v 1.26.8.1 2009/04/15 03:14:26 kensmith Exp $
*/
#include <sys/param.h>
#include "acpi.h"
#define ACPIDEV "/dev/acpi"
-#define RC_SUSPEND_PATH "/etc/rc.suspend"
-#define RC_RESUME_PATH "/etc/rc.resume"
static int acpifd;
err(EX_OSFILE, ACPIDEV);
}
-static int
-acpi_enable_disable(int enable)
+/* Prepare to sleep and then wait for the signal that sleeping can occur. */
+static void
+acpi_sleep(int sleep_type)
{
- if (ioctl(acpifd, enable, NULL) == -1) {
- if (enable == ACPIIO_ENABLE)
- err(EX_IOERR, "enable failed");
- else
- err(EX_IOERR, "disable failed");
- }
-
- return (0);
+ int ret;
+
+ /* Notify OS that we want to sleep. devd(8) gets this notify. */
+ ret = ioctl(acpifd, ACPIIO_REQSLPSTATE, &sleep_type);
+ if (ret != 0)
+ err(EX_IOERR, "request sleep type (%d) failed", sleep_type);
}
-static int
-acpi_sleep(int sleep_type)
+/* Ack or abort a pending suspend request. */
+static void
+acpi_sleep_ack(int err_val)
{
- 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);
- }
-
+ ret = ioctl(acpifd, ACPIIO_ACKSLPSTATE, &err_val);
if (ret != 0)
- err(EX_IOERR, "sleep type (%d) failed", sleep_type);
-
- return (0);
+ err(EX_IOERR, "ack sleep type failed");
}
/* should be a acpi define, but doesn't appear to be */
static void
usage(const char* prog)
{
- printf("usage: %s [-deh] [-i batt] [-s 1-5]\n", prog);
+ printf("usage: %s [-h] [-i batt] [-k ack] [-s 1-4]\n", prog);
exit(0);
}
sleep_type = -1;
acpi_init();
- while ((c = getopt(argc, argv, "dehi:s:")) != -1) {
+ while ((c = getopt(argc, argv, "hi:k:s:")) != -1) {
switch (c) {
case 'i':
acpi_battinfo(atoi(optarg));
break;
- case 'd':
- acpi_enable_disable(ACPIIO_DISABLE);
- break;
- case 'e':
- acpi_enable_disable(ACPIIO_ENABLE);
+ case 'k':
+ acpi_sleep_ack(atoi(optarg));
break;
case 's':
if (optarg[0] == 'S')
sleep_type = optarg[1] - '0';
else
sleep_type = optarg[0] - '0';
- if (sleep_type < 0 || sleep_type > 5)
+ if (sleep_type < 1 || sleep_type > 4)
errx(EX_USAGE, "invalid sleep type (%d)",
sleep_type);
break;
argc -= optind;
argv += optind;
- if (sleep_type != -1) {
- sleep(1); /* wait 1 sec. for key-release event */
+ if (sleep_type != -1)
acpi_sleep(sleep_type);
- }
close(acpifd);
exit (0);