148730SiwasakiFreeBSD apmd Package Release Notes (19990711 version)
248730Siwasaki
348730Siwasaki1. What is "apmd"?
448730Siwasaki==================
548730Siwasaki
648730SiwasakiThe apmd package provides a means of handling various APM events from
748730Siwasakiuserland code.  Using apmd.conf, the apmd(8) configuration file, you
848730Siwasakican select the APM events to be handled from userland and specify the
948730Siwasakicommands for a given event, allowing APM behaviour to be configured
1048730Siwasakiflexibly.
1148730Siwasaki
1248730Siwasaki
1348730Siwasaki2. How to install the apmd package
1448730Siwasaki==================================
1548730Siwasaki
1648730Siwasaki2.1 Making the apmd control device file
1748730Siwasaki---------------------------------------
1848730Siwasaki
1948730Siwasakiapmd(8) uses the new special device file /dev/apmctl.  This should be
2048730Siwasakicreated as follows:
2148730Siwasaki
2248730Siwasaki# cd /dev
2348730Siwasaki# mknod apmctl c 39 8
2448730Siwasaki
2548730Siwasaki2.2 Applying the kernel patch and building a new kernel
2648730Siwasaki-------------------------------------------------------
2748730Siwasaki
2848730SiwasakiThe next step is to apply the patch against the sys source tree.
2948730SiwasakiGo to the source directory (eg. /usr/src/ or /usr/PAO3/src/) and run
3048730Siwasakithe patch command as follows:
3148730Siwasaki
3248730Siwasaki# gzip -cd [somewhere]/apmd-sys-R320.diff | patch
3348730Siwasaki
3448730SiwasakiFor PAO3 users, the patch file name would be apmd-sys-PAO3.diff
3548730Siwasakiinstead of apmd-sys-R320.diff.  After this step has completed
3648730Siwasakisuccessfully, build and install a new kernel and reboot your system.
3748730Siwasaki
3848730Siwasaki2.3 Making the apmd program
3948730Siwasaki---------------------------
4048730Siwasaki
4148730SiwasakiGo to src/usr.sbin/ and extract the apmd tarball as follows:
4248730Siwasaki
4348730Siwasaki# tar xzpvf [somewhere]/apmd-usr.sbin.tar.gz 
4448730Siwasaki
4548730SiwasakiBefore doing a make all, you need to copy apm_bios.h in the sys source
4648730Siwasakitree to /usr/include/machine/ first:
4748730Siwasaki
4848730Siwasaki# cp /sys/i386/include/apm_bios.h /usr/include/machine/
4948730Siwasaki
5048730SiwasakiThen do the build and install steps in the apmd directory:
5148730Siwasaki
5248730Siwasaki# cd src/usr.sbin/apmd
5348730Siwasaki# make depend all install
5448730Siwasaki
5548730Siwasaki2.4 Setting up the configuration file and userland script
5648730Siwasaki---------------------------------------------------------
5748730Siwasaki
5848730SiwasakiIn src/usr.sbin/apm/etc/ there are example configuration and userland
5948730Siwasakiscript files which are invoked automatically when the APM BIOS informs
6048730Siwasakiapmd of an event, such as suspend request.  Copy these files to
6148730Siwasaki/etc/ as follows:
6248730Siwasaki
6348730Siwasaki# cp src/usr.sbin/apm/etc/* /etc/
6448730Siwasaki
6548730Siwasaki
6648730Siwasaki3. Running the apmd daemon program
6748730Siwasaki==================================
6848730Siwasaki
6948730SiwasakiTo run apmd(8) in background mode, simply type ``apmd''.
7048730Siwasaki
7148730Siwasaki# apmd
7248730Siwasaki
7348730SiwasakiTo make a running apmd reload /etc/apmd.conf, send a SIGHUP signal to
7448730Siwasakithe apmd(8) process.
7548730Siwasaki
7648730Siwasaki# kill -HUP [apmd pid]
7748730Siwasakior
7848730Siwasaki# killall -HUP apmd
7948730Siwasaki
8048730Siwasakiapmd has some command line options.  For the details, please 
8148730Siwasakirefer to the manpage of apmd.
8248730Siwasaki
8348730Siwasaki4. Configuration file
8448730Siwasaki=====================
8548730Siwasaki
8648730SiwasakiThe structure of the apmd configuration file is quite simple.  For
8748730Siwasakiexample:
8848730Siwasaki
8948730Siwasakiapm_event SUSPENDREQ {
9048730Siwasaki	exec "sync && sync && sync";
9148730Siwasaki	exec "sleep 1";
9248730Siwasaki	exec "zzz";
9348730Siwasaki}
9448730Siwasaki
95208289SuqsWill cause apmd to receive the APM event SUSPENDREQ (which may be
9648730Siwasakiposted by an LCD close), run the sync command 3 times and wait for a
9748730Siwasakiwhile, then execute zzz (apm -z) to put the system in the suspend
9848730Siwasakistate.
9948730Siwasaki
10048730Siwasaki4.1 The apm_event keyword
10148730Siwasaki-------------------------
10248730Siwasaki`apm_event' is the keyword which indicates the start of configuration for
10348730Siwasakieach events.
10448730Siwasaki
10548730Siwasaki4.2 APM events
10648730Siwasaki--------------
10748730Siwasaki
10848730SiwasakiIf you wish to execute the same commands for different events, the
10948730Siwasakievent names should be delimited by a comma.  The following are valid
11048730Siwasakievent names:
11148730Siwasaki
11248730Siwasakio Events ignored by the kernel if apmd is running:
11348730Siwasaki
11448730SiwasakiSTANDBYREQ
11548730SiwasakiSUSPENDREQ
11648730SiwasakiUSERSUSPENDREQ
11748730SiwasakiBATTERYLOW
11848730Siwasaki
11948730Siwasakio Events passed to apmd after kernel handling:
12048730Siwasaki
12148730SiwasakiNORMRESUME
12248730SiwasakiCRITRESUME
12348730SiwasakiSTANDBYRESUME
12448730SiwasakiPOWERSTATECHANGE
12548730SiwasakiUPDATETIME
12648730Siwasaki
12748730Siwasaki
12848730SiwasakiOther events will not be sent to apmd.
12948730Siwasaki
13048730Siwasaki4.3 command line syntax
13148730Siwasaki-----------------------
13248730Siwasaki
133208289SuqsIn the example above, the three lines beginning with `exec' are commands
13448730Siwasakifor the event.  Each line should be terminated with a semicolon.  The
13548730Siwasakicommand list for the event should be enclosed by `{' and `}'. apmd(8)
13648730Siwasakiuses /bin/sh for double-quotation enclosed command execution, just as
13748730Siwasakiwith system(3).  Each command is executed in order until the end of
13848730Siwasakithe list is reached or a command finishes with a non-zero status code. 
13948730Siwasakiapmd(8) will report any failed command's status code via syslog(3)
14048730Siwasakiand will then reject the request event posted by APM BIOS.
14148730Siwasaki
14248730Siwasaki4.4 Built-in functions
14348730Siwasaki----------------------
14448730Siwasaki
14548730SiwasakiYou can also specify apmd built-in functions instead of command lines.
14648730SiwasakiA built-in function name should be terminated with a semicolon, just as
14748730Siwasakiwith a command line.
14848730SiwasakiThe following built-in functions are currently supported:
14948730Siwasaki
15048730Siwasakio reject;
15148730Siwasaki
15248730Siwasaki  Reject last request posted by the APM BIOS.  This can be used to reject a
15348730Siwasaki  SUSPEND request when the LCD is closed and put the system in a STANDBY
15448730Siwasaki  state instead.
15548730Siwasaki
15648730Siwasaki
15748730Siwasaki
15848730Siwasaki5. EXAMPLES
15948730Siwasaki===========
16048730Siwasaki
16148730SiwasakiSample configuration commands include:
16248730Siwasaki
16348730Siwasakiapm_event SUSPENDREQ {
16448730Siwasaki	exec "/etc/rc.suspend";
16548730Siwasaki}
16648730Siwasaki
16748730Siwasakiapm_event USERSUSPENDREQ {
16848730Siwasaki	exec "sync && sync && sync";
16948730Siwasaki	exec "sleep 1";
17048730Siwasaki	exec "apm -z";
17148730Siwasaki}
17248730Siwasaki
17348730Siwasakiapm_event NORMRESUME, STANDBYRESUME {
17448730Siwasaki	exec "/etc/rc.resume";
17548730Siwasaki}
17648730Siwasaki
17748730Siwasaki# resume event configuration for serial mouse users by
17848730Siwasaki# reinitializing a moused(8) connected to a serial port.
17948730Siwasaki#
18048730Siwasaki#apm_event NORMRESUME {
18148730Siwasaki#	exec "kill -HUP `cat /var/run/moused.pid`";
18248730Siwasaki#}
18348730Siwasaki
18448730Siwasaki# suspend request event configuration for ATA HDD users:
18548730Siwasaki# execute standby instead of suspend.
18648730Siwasaki#
18748730Siwasaki#apm_event SUSPENDREQ {
18848730Siwasaki#	reject;
18948730Siwasaki#	exec "sync && sync && sync";
19048730Siwasaki#	exec "sleep 1";
19148730Siwasaki#	exec "apm -Z";
19248730Siwasaki#}
19348730Siwasaki
19448730Siwasaki
19548730Siwasaki6. Call for developers
19648730Siwasaki======================
19748730Siwasaki
19848730SiwasakiThe initial version of apmd(8) was implemented primarily to test the
19948730Siwasakikernel support code and was ALPHA quality.  Based on that code, the
20048730Siwasakicurrent version was developed by KOIE Hidetaka <hide@koie.org>. 
20148730SiwasakiHowever, we're still looking around for interesting new features and
20248730Siwasakiideas, so if you have any thoughts, please let us know. 
20348730SiwasakiDocumentation is also sparse, and the manpage have just written.  
20448730SiwasakiIf you wish to collaborate on this work, please e-mail me:
20548730Siwasakiiwasaki@freebsd.org.
20648730Siwasaki
20748730Siwasaki
20848730SiwasakiJune 1, 1999
20948730SiwasakiCreated by: iwasaki@FreeBSD.org
21048730SiwasakiEdited by: jkh@FreeBSD.org
21148730Siwasaki           nick@foobar.org
21248730Siwasaki
21350479Speter$FreeBSD$
214