1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
FreeBSD apmd Package Release Notes (19990711 version)
1. What is "apmd"?
==================
The apmd package provides a means of handling various APM events from
userland code. Using apmd.conf, the apmd(8) configuration file, you
can select the APM events to be handled from userland and specify the
commands for a given event, allowing APM behaviour to be configured
flexibly.
2. How to install the apmd package
==================================
2.1 Making the apmd control device file
---------------------------------------
apmd(8) uses the new special device file /dev/apmctl. This should be
created as follows:
# cd /dev
# mknod apmctl c 39 8
2.2 Applying the kernel patch and building a new kernel
-------------------------------------------------------
The next step is to apply the patch against the sys source tree.
Go to the source directory (eg. /usr/src/ or /usr/PAO3/src/) and run
the patch command as follows:
# gzip -cd [somewhere]/apmd-sys-R320.diff | patch
For PAO3 users, the patch file name would be apmd-sys-PAO3.diff
instead of apmd-sys-R320.diff. After this step has completed
successfully, build and install a new kernel and reboot your system.
2.3 Making the apmd program
---------------------------
Go to src/usr.sbin/ and extract the apmd tarball as follows:
# tar xzpvf [somewhere]/apmd-usr.sbin.tar.gz
Before doing a make all, you need to copy apm_bios.h in the sys source
tree to /usr/include/machine/ first:
# cp /sys/i386/include/apm_bios.h /usr/include/machine/
Then do the build and install steps in the apmd directory:
# cd src/usr.sbin/apmd
# make depend all install
2.4 Setting up the configuration file and userland script
---------------------------------------------------------
In src/usr.sbin/apm/etc/ there are example configuration and userland
script files which are invoked automatically when the APM BIOS informs
apmd of an event, such as suspend request. Copy these files to
/etc/ as follows:
# cp src/usr.sbin/apm/etc/* /etc/
3. Running the apmd daemon program
==================================
To run apmd(8) in background mode, simply type ``apmd''.
# apmd
To make a running apmd reload /etc/apmd.conf, send a SIGHUP signal to
the apmd(8) process.
# kill -HUP [apmd pid]
or
# killall -HUP apmd
apmd has some command line options. For the details, please
refer to the manpage of apmd.
4. Configuration file
=====================
The structure of the apmd configuration file is quite simple. For
example:
apm_event SUSPENDREQ {
exec "sync && sync && sync";
exec "sleep 1";
exec "zzz";
}
Will cause apmd to recieve the APM event SUSPENDREQ (which may be
posted by an LCD close), run the sync command 3 times and wait for a
while, then execute zzz (apm -z) to put the system in the suspend
state.
4.1 The apm_event keyword
-------------------------
`apm_event' is the keyword which indicates the start of configuration for
each events.
4.2 APM events
--------------
If you wish to execute the same commands for different events, the
event names should be delimited by a comma. The following are valid
event names:
o Events ignored by the kernel if apmd is running:
STANDBYREQ
SUSPENDREQ
USERSUSPENDREQ
BATTERYLOW
o Events passed to apmd after kernel handling:
NORMRESUME
CRITRESUME
STANDBYRESUME
POWERSTATECHANGE
UPDATETIME
Other events will not be sent to apmd.
4.3 command line syntax
-----------------------
In the example above, the three lines begining with `exec' are commands
for the event. Each line should be terminated with a semicolon. The
command list for the event should be enclosed by `{' and `}'. apmd(8)
uses /bin/sh for double-quotation enclosed command execution, just as
with system(3). Each command is executed in order until the end of
the list is reached or a command finishes with a non-zero status code.
apmd(8) will report any failed command's status code via syslog(3)
and will then reject the request event posted by APM BIOS.
4.4 Built-in functions
----------------------
You can also specify apmd built-in functions instead of command lines.
A built-in function name should be terminated with a semicolon, just as
with a command line.
The following built-in functions are currently supported:
o reject;
Reject last request posted by the APM BIOS. This can be used to reject a
SUSPEND request when the LCD is closed and put the system in a STANDBY
state instead.
5. EXAMPLES
===========
Sample configuration commands include:
apm_event SUSPENDREQ {
exec "/etc/rc.suspend";
}
apm_event USERSUSPENDREQ {
exec "sync && sync && sync";
exec "sleep 1";
exec "apm -z";
}
apm_event NORMRESUME, STANDBYRESUME {
exec "/etc/rc.resume";
}
# resume event configuration for serial mouse users by
# reinitializing a moused(8) connected to a serial port.
#
#apm_event NORMRESUME {
# exec "kill -HUP `cat /var/run/moused.pid`";
#}
# suspend request event configuration for ATA HDD users:
# execute standby instead of suspend.
#
#apm_event SUSPENDREQ {
# reject;
# exec "sync && sync && sync";
# exec "sleep 1";
# exec "apm -Z";
#}
6. Call for developers
======================
The initial version of apmd(8) was implemented primarily to test the
kernel support code and was ALPHA quality. Based on that code, the
current version was developed by KOIE Hidetaka <hide@koie.org>.
However, we're still looking around for interesting new features and
ideas, so if you have any thoughts, please let us know.
Documentation is also sparse, and the manpage have just written.
If you wish to collaborate on this work, please e-mail me:
iwasaki@freebsd.org.
June 1, 1999
Created by: iwasaki@FreeBSD.org
Edited by: jkh@FreeBSD.org
nick@foobar.org
$FreeBSD$
|