The latest user-land changes from the author. I added a big warning to the
apm.4 man-page. I also hope the Makefiles make sense now. Submitted by: HOSOKAWA Tatsumi
This commit is contained in:
parent
dcf7506baa
commit
7874667561
@ -1,6 +1,6 @@
|
||||
# @(#)Makefile 8.1 (Berkeley) 6/18/93
|
||||
|
||||
MAN4= clnp.4 cltp.4 drum.4 esis.4 fd.4 icmp.4 idp.4 inet.4 ip.4 \
|
||||
MAN4= apm.4 clnp.4 cltp.4 drum.4 esis.4 fd.4 icmp.4 idp.4 inet.4 ip.4 \
|
||||
iso.4 lkm.4 lo.4 netintro.4 ns.4 nsip.4 null.4 pty.4 route.4 \
|
||||
spp.4 tcp.4 termios.4 tp.4 tty.4 udp.4 unix.4 yp.4
|
||||
MLINKS+=fd.4 stderr.4 fd.4 stdin.4 fd.4 stdout.4
|
||||
|
146
share/man/man4/apm.4
Normal file
146
share/man/man4/apm.4
Normal file
@ -0,0 +1,146 @@
|
||||
.\" LP (Laptop Package)
|
||||
.\"
|
||||
.\" Copyright (c) 1994 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
|
||||
.\"
|
||||
.\" This software may be used, modified, copied, and distributed, in
|
||||
.\" both source and binary form provided that the above copyright and
|
||||
.\" these terms are retained. Under no circumstances is the author
|
||||
.\" responsible for the proper functioning of this software, nor does
|
||||
.\" the author assume any responsibility for damages incurred with its
|
||||
.\" use.
|
||||
.Dd November 1, 1994
|
||||
.Dt APM 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm apm
|
||||
.Nd APM BIOS interface
|
||||
.Sh SYNOPSIS
|
||||
.Cd options APM
|
||||
.Cd device apm0 at isa?
|
||||
.Sh DESCRIPTION
|
||||
.Nm apm
|
||||
is an interface to the Intel / Microsoft APM (Advanced Power Management) BIOS
|
||||
on laptop PCs.
|
||||
.Pp
|
||||
.Nm apm
|
||||
provides the following power management functions.
|
||||
.Bl -enum -offset indent
|
||||
.It
|
||||
When the system wakes up from suspended mode,
|
||||
.Nm apm
|
||||
adjusts the system clock to RTC.
|
||||
.It
|
||||
When the system wakes up from suspended mode,
|
||||
.Nm apm
|
||||
passes a message to
|
||||
.Xr syslogd 8
|
||||
comprising of system wakeup time and elapsed time during suspended mode.
|
||||
.It
|
||||
.Nm apm
|
||||
slows CPU clock when there are no system activities (runnable processes,
|
||||
interrupts, etc.). This function is available only on systems whose APM
|
||||
supports CPU idling.
|
||||
.It
|
||||
.Nm apm
|
||||
exports an application interface as a character device. Applications
|
||||
can control APM, or retrieve APM status information via this interface.
|
||||
.Nm apm
|
||||
exports the following interfaces. These symbols are defined in
|
||||
.Dq Pa /usr/include/machine/apm_bios.h.
|
||||
.Bl -tag -width 4n -offset indent
|
||||
.It Sy APMIO_SUSPEND
|
||||
Suspend system.
|
||||
.It Sy APMIO_GET
|
||||
Get power management information.
|
||||
.It Sy APMIO_ENABLE
|
||||
.It Sy APMIO_DISABLE
|
||||
Enable / Disable power management.
|
||||
.It Sy APMIO_HALTCPU
|
||||
.It Sy APMIO_NOTHALTCPU
|
||||
Control execution of HLT in the kernel context switch routine.
|
||||
.Pp
|
||||
Some APM implementations execute the HLT
|
||||
.Pq Halt CPU until an interrupt occurs
|
||||
instruction in the
|
||||
.Dq Pa Idle CPU
|
||||
call, while others do not. Thus enabling this may result in
|
||||
redundant HLT executions because
|
||||
.Dq Pa Idle CPU
|
||||
is called from the kernel context switch routine that inherently executes
|
||||
HLT. This may reduce peak system performance.
|
||||
.Pp
|
||||
Also the system hangs up if HLT instruction is disabled in the kernel
|
||||
context switch routine, and if the APM implementation of the machine
|
||||
does not execute HLT in
|
||||
.Dq Pa Idle CPU.
|
||||
On some implementations that do not support CPU clock slowdown, APM
|
||||
might not execute HLT.
|
||||
.Nm apm
|
||||
disables
|
||||
.Sy APMIO_NOTHALTCPU
|
||||
operation on such machines.
|
||||
.Pp
|
||||
The current version of
|
||||
.Nm apm
|
||||
does not call
|
||||
.Dq Pa Idle CPU
|
||||
from the kernel context switch routine if clock slowdown is not supported,
|
||||
and it executes HLT instruction by default. Therefore, there is
|
||||
no need to use these two operations in most cases.
|
||||
.El
|
||||
.Pp
|
||||
These interfaces are used by
|
||||
.Xr apm 8
|
||||
and
|
||||
.Xr apmconf 8 .
|
||||
.It
|
||||
.Nm apm
|
||||
polls APM events and handles the following events.
|
||||
.Bl -column PMEV_POWERSTATECHANGEXXX "suspend system xxxxx"
|
||||
.It Sy "Name " "Action " "Description"
|
||||
.It Dv "PMEV_STANDBYREQ " No "suspend system " "standby request"
|
||||
.It Dv "PMEV_SUSPENDREQ " No "suspend system " "suspend request"
|
||||
.It Dv "PMEV_USERSUSPENDREQ " No "suspend system " "user suspend request"
|
||||
.It Dv "PMEV_CRITSUSPEND " No "suspend system " "critical suspend request"
|
||||
.It Dv "PMEV_NORMRESUME " No "resume system " "normal resume"
|
||||
.It Dv "PMEV_CRITRESUME " No "resume system " "critical resume"
|
||||
.It Dv "PMEV_STANDBYRESUME " No "resume system " "standby resume"
|
||||
.It Dv "PMEV_BATTERYLOW " No "notify message " "battery low"
|
||||
.It Dv "PMEV_UPDATETIME " No "adjust clock " "update time"
|
||||
.El
|
||||
.El
|
||||
.Sh BUGS
|
||||
WARNING! Many, if not most, of the implementations of APM-bios in laptops
|
||||
today are buggy. You may be putting your LCD-display and batteries at
|
||||
a risk by using this interface. (The reason this isn't a problem for
|
||||
MS-windows is that they use the real-mode interface.) If you see any
|
||||
weird behaviour from your system with this code in use, unplug the
|
||||
power and batteries ASAP, if not imidiately, and disable this code.
|
||||
.Pp
|
||||
We are very interested in getting this code working, so please send you
|
||||
observations of any anormalous behaviour to us.
|
||||
.Pp
|
||||
When
|
||||
.Nm apm
|
||||
is active, calling the BIOS setup routine by using hotkeys,
|
||||
may cause serious trouble when resuming the system.
|
||||
BIOS setup programs should be called during bootstrap, or from DOS.
|
||||
.Pp
|
||||
Some APM implementations cannot handle events such as pushing the
|
||||
power button or closing the cover. On such implementations, the system
|
||||
.Ar must
|
||||
be suspended
|
||||
.Ar only
|
||||
by using
|
||||
.Xr apm 8
|
||||
or
|
||||
.Xr zzz 8 .
|
||||
.Pp
|
||||
Disk spindown, LCD backlight control, and power on demand have not
|
||||
been supported on the current version.
|
||||
.Sh SEE ALSO
|
||||
.Xr apm 8 ,
|
||||
.Xr zzz 8 ,
|
||||
.Xr apmconf 8
|
||||
.Sh AUTHOR
|
||||
HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> (Keio Univ., Japan)
|
146
share/man/man4/man4.i386/apm.4
Normal file
146
share/man/man4/man4.i386/apm.4
Normal file
@ -0,0 +1,146 @@
|
||||
.\" LP (Laptop Package)
|
||||
.\"
|
||||
.\" Copyright (c) 1994 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
|
||||
.\"
|
||||
.\" This software may be used, modified, copied, and distributed, in
|
||||
.\" both source and binary form provided that the above copyright and
|
||||
.\" these terms are retained. Under no circumstances is the author
|
||||
.\" responsible for the proper functioning of this software, nor does
|
||||
.\" the author assume any responsibility for damages incurred with its
|
||||
.\" use.
|
||||
.Dd November 1, 1994
|
||||
.Dt APM 4
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm apm
|
||||
.Nd APM BIOS interface
|
||||
.Sh SYNOPSIS
|
||||
.Cd options APM
|
||||
.Cd device apm0 at isa?
|
||||
.Sh DESCRIPTION
|
||||
.Nm apm
|
||||
is an interface to the Intel / Microsoft APM (Advanced Power Management) BIOS
|
||||
on laptop PCs.
|
||||
.Pp
|
||||
.Nm apm
|
||||
provides the following power management functions.
|
||||
.Bl -enum -offset indent
|
||||
.It
|
||||
When the system wakes up from suspended mode,
|
||||
.Nm apm
|
||||
adjusts the system clock to RTC.
|
||||
.It
|
||||
When the system wakes up from suspended mode,
|
||||
.Nm apm
|
||||
passes a message to
|
||||
.Xr syslogd 8
|
||||
comprising of system wakeup time and elapsed time during suspended mode.
|
||||
.It
|
||||
.Nm apm
|
||||
slows CPU clock when there are no system activities (runnable processes,
|
||||
interrupts, etc.). This function is available only on systems whose APM
|
||||
supports CPU idling.
|
||||
.It
|
||||
.Nm apm
|
||||
exports an application interface as a character device. Applications
|
||||
can control APM, or retrieve APM status information via this interface.
|
||||
.Nm apm
|
||||
exports the following interfaces. These symbols are defined in
|
||||
.Dq Pa /usr/include/machine/apm_bios.h.
|
||||
.Bl -tag -width 4n -offset indent
|
||||
.It Sy APMIO_SUSPEND
|
||||
Suspend system.
|
||||
.It Sy APMIO_GET
|
||||
Get power management information.
|
||||
.It Sy APMIO_ENABLE
|
||||
.It Sy APMIO_DISABLE
|
||||
Enable / Disable power management.
|
||||
.It Sy APMIO_HALTCPU
|
||||
.It Sy APMIO_NOTHALTCPU
|
||||
Control execution of HLT in the kernel context switch routine.
|
||||
.Pp
|
||||
Some APM implementations execute the HLT
|
||||
.Pq Halt CPU until an interrupt occurs
|
||||
instruction in the
|
||||
.Dq Pa Idle CPU
|
||||
call, while others do not. Thus enabling this may result in
|
||||
redundant HLT executions because
|
||||
.Dq Pa Idle CPU
|
||||
is called from the kernel context switch routine that inherently executes
|
||||
HLT. This may reduce peak system performance.
|
||||
.Pp
|
||||
Also the system hangs up if HLT instruction is disabled in the kernel
|
||||
context switch routine, and if the APM implementation of the machine
|
||||
does not execute HLT in
|
||||
.Dq Pa Idle CPU.
|
||||
On some implementations that do not support CPU clock slowdown, APM
|
||||
might not execute HLT.
|
||||
.Nm apm
|
||||
disables
|
||||
.Sy APMIO_NOTHALTCPU
|
||||
operation on such machines.
|
||||
.Pp
|
||||
The current version of
|
||||
.Nm apm
|
||||
does not call
|
||||
.Dq Pa Idle CPU
|
||||
from the kernel context switch routine if clock slowdown is not supported,
|
||||
and it executes HLT instruction by default. Therefore, there is
|
||||
no need to use these two operations in most cases.
|
||||
.El
|
||||
.Pp
|
||||
These interfaces are used by
|
||||
.Xr apm 8
|
||||
and
|
||||
.Xr apmconf 8 .
|
||||
.It
|
||||
.Nm apm
|
||||
polls APM events and handles the following events.
|
||||
.Bl -column PMEV_POWERSTATECHANGEXXX "suspend system xxxxx"
|
||||
.It Sy "Name " "Action " "Description"
|
||||
.It Dv "PMEV_STANDBYREQ " No "suspend system " "standby request"
|
||||
.It Dv "PMEV_SUSPENDREQ " No "suspend system " "suspend request"
|
||||
.It Dv "PMEV_USERSUSPENDREQ " No "suspend system " "user suspend request"
|
||||
.It Dv "PMEV_CRITSUSPEND " No "suspend system " "critical suspend request"
|
||||
.It Dv "PMEV_NORMRESUME " No "resume system " "normal resume"
|
||||
.It Dv "PMEV_CRITRESUME " No "resume system " "critical resume"
|
||||
.It Dv "PMEV_STANDBYRESUME " No "resume system " "standby resume"
|
||||
.It Dv "PMEV_BATTERYLOW " No "notify message " "battery low"
|
||||
.It Dv "PMEV_UPDATETIME " No "adjust clock " "update time"
|
||||
.El
|
||||
.El
|
||||
.Sh BUGS
|
||||
WARNING! Many, if not most, of the implementations of APM-bios in laptops
|
||||
today are buggy. You may be putting your LCD-display and batteries at
|
||||
a risk by using this interface. (The reason this isn't a problem for
|
||||
MS-windows is that they use the real-mode interface.) If you see any
|
||||
weird behaviour from your system with this code in use, unplug the
|
||||
power and batteries ASAP, if not imidiately, and disable this code.
|
||||
.Pp
|
||||
We are very interested in getting this code working, so please send you
|
||||
observations of any anormalous behaviour to us.
|
||||
.Pp
|
||||
When
|
||||
.Nm apm
|
||||
is active, calling the BIOS setup routine by using hotkeys,
|
||||
may cause serious trouble when resuming the system.
|
||||
BIOS setup programs should be called during bootstrap, or from DOS.
|
||||
.Pp
|
||||
Some APM implementations cannot handle events such as pushing the
|
||||
power button or closing the cover. On such implementations, the system
|
||||
.Ar must
|
||||
be suspended
|
||||
.Ar only
|
||||
by using
|
||||
.Xr apm 8
|
||||
or
|
||||
.Xr zzz 8 .
|
||||
.Pp
|
||||
Disk spindown, LCD backlight control, and power on demand have not
|
||||
been supported on the current version.
|
||||
.Sh SEE ALSO
|
||||
.Xr apm 8 ,
|
||||
.Xr zzz 8 ,
|
||||
.Xr apmconf 8
|
||||
.Sh AUTHOR
|
||||
HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> (Keio Univ., Japan)
|
@ -1,10 +1,6 @@
|
||||
# $Id: Makefile,v 1.1 1994/10/01 03:23:23 davidg Exp $
|
||||
|
||||
PROG= apm
|
||||
# CFLAGS+= -I/sys/i386/include
|
||||
# BINGRP= apm
|
||||
# BINMODE= 550
|
||||
# LINKS= ${DESTDIR}/usr/sbin/apm ${DESTDIR}/usr/sbin/zzz
|
||||
NOMAN= 1
|
||||
|
||||
LINKS= ${BINDIR}apm /usr/sbin/zzz
|
||||
MANDIR= /usr/share/man/man
|
||||
MAN8= apm.8
|
||||
MLINKS= apm.8 zzz.8
|
||||
.include <bsd.prog.mk>
|
||||
|
88
usr.sbin/apm/apm.8
Normal file
88
usr.sbin/apm/apm.8
Normal file
@ -0,0 +1,88 @@
|
||||
.\" LP (Laptop Package)
|
||||
.\"
|
||||
.\" Copyright (c) 1994 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
|
||||
.\"
|
||||
.\" This software may be used, modified, copied, and distributed, in
|
||||
.\" both source and binary form provided that the above copyright and
|
||||
.\" these terms are retained. Under no circumstances is the author
|
||||
.\" responsible for the proper functioning of this software, nor does
|
||||
.\" the author assume any responsibility for damages incurred with its
|
||||
.\" use.
|
||||
.Dd November 1, 1994
|
||||
.Dt APM 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm apm, zzz
|
||||
.Nd control the APM BIOS and display its information
|
||||
.Sh SYNOPSIS
|
||||
.Nm apm
|
||||
.Op Fl z
|
||||
.Op Fl b
|
||||
.Op Fl a
|
||||
.Op Fl l
|
||||
.Pp
|
||||
.Nm zzz
|
||||
.Sh DESCRIPTION
|
||||
.Nm apm
|
||||
controls the Intel / Microsoft APM (Advanced Power Management) BIOS and
|
||||
displays the current status of APM on laptop PCs.
|
||||
.Nm zzz
|
||||
suspends the system by controlling APM.
|
||||
.Pp
|
||||
The following options are available for
|
||||
.Nm apm
|
||||
(no options are available for
|
||||
.Nm zzz.
|
||||
)
|
||||
If no options are specified,
|
||||
.Nm apm
|
||||
displays information and current status of APM in verbose mode.
|
||||
.Bl -tag -width indent
|
||||
.It Fl z
|
||||
Suspend the system. It is equivalent to
|
||||
.Nm zzz.
|
||||
.Pp
|
||||
.It Fl b
|
||||
Display an integer value reflecting the current battery status.
|
||||
The values 0, 1, 2, 3, correspond to the
|
||||
.Dq high
|
||||
status,
|
||||
.Dq low
|
||||
status,
|
||||
.Dq critical
|
||||
status,
|
||||
.Dq charging
|
||||
status respectively.
|
||||
.Pp
|
||||
.It Fl a
|
||||
Display the current AC-line status as an integer value. The values
|
||||
0 and 1 correspond to the
|
||||
.Dq off-line
|
||||
state and
|
||||
.Dq on-line
|
||||
state, respectively.
|
||||
.Pp
|
||||
.It Fl l
|
||||
Display the remaining battery percentage. If your laptop does not
|
||||
support this function, 255 is displayed.
|
||||
.Sh BUGS
|
||||
Some APM implementations do not support parameters needed by
|
||||
.Nm apm.
|
||||
On such systems,
|
||||
.Nm apm
|
||||
displays them as unknown.
|
||||
.Pp
|
||||
Some APM implementations cannot handle events such as pushing the
|
||||
power button or closing the cover. On such implementations, the system
|
||||
.Ar must
|
||||
be suspended
|
||||
.Ar only
|
||||
by using
|
||||
.Nm apm
|
||||
or
|
||||
.Nm zzz.
|
||||
.Sh SEE ALSO
|
||||
.Xr apm 4 ,
|
||||
.Xr apmconf 8
|
||||
.Sh AUTHOR
|
||||
HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> (Keio Univ., Japan)
|
@ -17,9 +17,9 @@
|
||||
#include <string.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <machine/apm_bios.h>
|
||||
#include <apm_bios.h>
|
||||
|
||||
#define APMDEV "/dev/apm"
|
||||
#define APMDEV "/dev/apm0"
|
||||
|
||||
int main_argc;
|
||||
char **main_argv;
|
||||
@ -103,7 +103,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
for (i = argc - 1; i >= 1; i--) {
|
||||
if (argv[i][0] != '-') {
|
||||
fprintf(stderr, "%s: Unknown option '%s'.", argv[0], argv[i]);
|
||||
fprintf(stderr, "%s: Unknown option '%s'.\n", argv[0], argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
for (j = 1; argv[i][j]; j++) {
|
||||
switch (argv[i][j]) {
|
||||
@ -123,6 +124,9 @@ int main(int argc, char *argv[])
|
||||
batt_life = 1;
|
||||
all_info = 0;
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s Unknown option '%s'.\n", argv[0], argv[i]);
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,5 @@
|
||||
# $Id$
|
||||
|
||||
PROG= apmconf
|
||||
# BINMODE= 550
|
||||
# BINOWN= root
|
||||
NOMAN= 1
|
||||
MAN8= apmconf.8
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
60
usr.sbin/apmconf/apmconf.8
Normal file
60
usr.sbin/apmconf/apmconf.8
Normal file
@ -0,0 +1,60 @@
|
||||
.\" LP (Laptop Package)
|
||||
.\"
|
||||
.\" Copyright (c) 1994 by HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp>
|
||||
.\"
|
||||
.\" This software may be used, modified, copied, and distributed, in
|
||||
.\" both source and binary form provided that the above copyright and
|
||||
.\" these terms are retained. Under no circumstances is the author
|
||||
.\" responsible for the proper functioning of this software, nor does
|
||||
.\" the author assume any responsibility for damages incurred with its
|
||||
.\" use.
|
||||
.Dd November 1, 1994
|
||||
.Dt APMCONF 8
|
||||
.Os
|
||||
.Sh NAME
|
||||
.Nm apmconf
|
||||
.Nd configure APM BIOS driver
|
||||
.Sh SYNOPSIS
|
||||
.Nm apmconf
|
||||
.Op Fl e
|
||||
.Op Fl d
|
||||
.Op Fl h
|
||||
.Op Fl t
|
||||
.Sh DESCRIPTION
|
||||
.Nm apmconf
|
||||
is used to configure the APM (Advanced Power Management) BIOS driver
|
||||
.Xr apm 4
|
||||
on laptop PCs.
|
||||
.Pp
|
||||
The following options are available.
|
||||
.Bl -tag -width indent
|
||||
.It Fl e
|
||||
Enable power management.
|
||||
.It Fl d
|
||||
Disable power management.
|
||||
.El
|
||||
.Pp
|
||||
These options enable/disable power management functions provided by
|
||||
.Xr apm 4 .
|
||||
.Bl -tag -width indent
|
||||
.It Fl h
|
||||
Enable HLT instruction in kernel context switch routine.
|
||||
.It Fl t
|
||||
Disable HLT instruction in kernel context switch routine.
|
||||
.El
|
||||
.Pp
|
||||
These options are not necessary for almost all APM implementations,
|
||||
but for some implementations whose
|
||||
.Dq Pa Idle CPU
|
||||
call executes both CPU clock slowdown and HLT instruction,
|
||||
.Fl t
|
||||
is necessary to prevent the system from reducing its peak performance.
|
||||
See
|
||||
.Xr apm 4
|
||||
for details.
|
||||
.Sh SEE ALSO
|
||||
.Xr apm 4 ,
|
||||
.Xr apm 8 ,
|
||||
.Xr zzz 8
|
||||
.Sh AUTHOR
|
||||
HOSOKAWA, Tatsumi <hosokawa@mt.cs.keio.ac.jp> (Keio Univ., Japan)
|
@ -20,10 +20,8 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <machine/apm_bios.h>
|
||||
|
||||
#define CONFIGFILE "/etc/apm.conf"
|
||||
#define APMDEV "/dev/apm"
|
||||
#define APMDEV "/dev/apm0"
|
||||
|
||||
static int verbose = 0;
|
||||
static int enable = 0, disable = 0;
|
||||
static int haltcpu = 0, nothaltcpu = 0;
|
||||
static int main_argc;
|
||||
@ -34,18 +32,13 @@ parse_option(void)
|
||||
{
|
||||
int i, option;
|
||||
char *optarg;
|
||||
enum {OPT_NONE, OPT_VERBOSE,
|
||||
OPT_ENABLE, OPT_DISABLE, OPT_HALTCPU, OPT_NOTHALTCPU} mode;
|
||||
enum {OPT_NONE, OPT_ENABLE, OPT_DISABLE, OPT_HALTCPU, OPT_NOTHALTCPU} mode;
|
||||
|
||||
for (i = 1; i < main_argc; i++) {
|
||||
option = 0;
|
||||
mode = OPT_NONE;
|
||||
if (main_argv[i][0] == '-') {
|
||||
switch (main_argv[i][1]) {
|
||||
case 'v':
|
||||
mode = OPT_VERBOSE;
|
||||
option = 0;
|
||||
break;
|
||||
case 'e':
|
||||
mode = OPT_ENABLE;
|
||||
option = 0;
|
||||
@ -76,9 +69,6 @@ parse_option(void)
|
||||
}
|
||||
|
||||
switch (mode) {
|
||||
case OPT_VERBOSE:
|
||||
verbose = 1;
|
||||
break;
|
||||
case OPT_ENABLE:
|
||||
enable = 1;
|
||||
break;
|
||||
@ -95,44 +85,20 @@ parse_option(void)
|
||||
}
|
||||
}
|
||||
|
||||
static struct apm_eqv_event eqv_event[APM_MAX_EQUIV_EVENTS];
|
||||
static int eqv_num = 0;
|
||||
|
||||
|
||||
#define PMEV_SYMBOL(name) {#name, name}
|
||||
#define ARRAY_SIZEOF(array) (sizeof(array) / sizeof(array[0]))
|
||||
|
||||
typedef struct pmev_symbol {
|
||||
char *name;
|
||||
int id;
|
||||
} *pmev_symbol_t;
|
||||
|
||||
static struct pmev_symbol pmev_symbols[] = {
|
||||
PMEV_SYMBOL(PMEV_NOEVENT),
|
||||
PMEV_SYMBOL(PMEV_STANDBYREQ),
|
||||
PMEV_SYMBOL(PMEV_SUSPENDREQ),
|
||||
PMEV_SYMBOL(PMEV_NORMRESUME),
|
||||
PMEV_SYMBOL(PMEV_CRITRESUME),
|
||||
PMEV_SYMBOL(PMEV_BATTERYLOW),
|
||||
PMEV_SYMBOL(PMEV_POWERSTATECHANGE),
|
||||
PMEV_SYMBOL(PMEV_UPDATETIME),
|
||||
PMEV_SYMBOL(PMEV_CRITSUSPEND),
|
||||
PMEV_SYMBOL(PMEV_USERSTANDBYREQ),
|
||||
PMEV_SYMBOL(PMEV_USERSUSPENDREQ),
|
||||
PMEV_SYMBOL(PMEV_STANDBYRESUME),
|
||||
};
|
||||
|
||||
static int
|
||||
pmev(char *name, int *id)
|
||||
static apm_eqv_event_t
|
||||
get_eqv_event(int id)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAY_SIZEOF(pmev_symbols); i++) {
|
||||
if (strcasecmp(pmev_symbols[i].name, name) == 0) {
|
||||
*id = pmev_symbols[i].id;
|
||||
return 0;
|
||||
for (i = 0; i < eqv_num; i++) {
|
||||
if (id == eqv_event[i].aee_event) {
|
||||
return &eqv_event[i];
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user