diff --git a/sys/man/8/acpi b/sys/man/8/acpi index 82919d366..f31775b8e 100644 --- a/sys/man/8/acpi +++ b/sys/man/8/acpi @@ -7,6 +7,9 @@ acpi \- Advanced Configuration and Power Interface .PP .B aux/acpi [ +.B -H +] +[ .B -m .I mountpoint ] @@ -27,6 +30,12 @@ posted at .BI /srv/ service as well. .PP +With the +.B -H +option, +.I aux/acpi +will turn off the power immediately. +.PP The directory contains the following files. .TP .B battery @@ -57,7 +66,7 @@ will turn off the power. .SH SOURCE .B /sys/src/cmd/aux/acpi.c .SH SEE ALSO -.IR imx8pm (8) +.IR reform (1) .SH BUGS ACPI itself. .SH HISTORY diff --git a/sys/src/cmd/aux/acpi.c b/sys/src/cmd/aux/acpi.c index 277880cdb..cfdd22477 100644 --- a/sys/src/cmd/aux/acpi.c +++ b/sys/src/cmd/aux/acpi.c @@ -293,7 +293,7 @@ amlwrite(Amlio *io, int addr, int wid, uvlong v) (*io->write)(io, b, 1<<(wid-1), addr); } -static void +static int poweroff(void) { int n; @@ -302,7 +302,7 @@ poweroff(void) if(facp.ok == 0){ werrstr("no FACP"); - return; + return -1; } wirecpu0(); @@ -362,6 +362,7 @@ poweroff(void) sleep(100); werrstr("acpi failed"); + return -1; } static void @@ -420,7 +421,7 @@ fswrite(Req *r) static void usage(void) { - fprint(2, "usage: aux/acpi [-Dp] [-m mountpoint] [-s service]\n"); + fprint(2, "usage: aux/acpi [-DHp] [-m mountpoint] [-s service]\n"); exits("usage"); } @@ -436,11 +437,12 @@ threadmain(int argc, char **argv) { char *mtpt, *srv; void *r, **rr; - int fd, n, l; + int fd, n, l, halt; Tbl *t; mtpt = "/dev"; srv = nil; + halt = 0; ARGBEGIN{ case 'D': chatty9p = 1; @@ -454,6 +456,9 @@ threadmain(int argc, char **argv) case 'p': amldebug++; break; + case 'H': + halt = 1; + break; default: usage(); }ARGEND @@ -550,6 +555,9 @@ threadmain(int argc, char **argv) } close(fd); + if(halt && poweroff() < 0) + sysfatal("%r"); + amlenum(amlroot, "_HID", enumec, nil); amlenum(amlroot, "_BIF", enumbat, nil); amlenum(amlroot, "_PSL", enumtmp, nil);