Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 10 Jun 1999 21:55:46 +0900
From:      Mitsuru IWASAKI <iwasaki@jp.FreeBSD.org>
To:        freebsd-hackers@FreeBSD.ORG, freebsd-mobile@FreeBSD.ORG
Subject:   apmd for FreeBSD
Message-ID:  <199906101257.VAA16619@tasogare.imasy.or.jp>

next in thread | raw e-mail | index | archive | help
Hi, folks.

graham> ooh apmd, cool.
graham> I was wondering if someone had started somthing like this, I'm excited.

Sorry to late, now first version of apmd package for FreeBSD is available at

apmd(8):
http://home.jp.freebsd.org/~iwasaki/apm/19990610/apmd-usr.sbin.tar.gz

3.2-RELEASE kernel patch:
http://home.jp.freebsd.org/~iwasaki/apm/19990610/apmd-sys-R320.diff.gz

if you are using PAO3, kernel patch would be

PAO3 kernel patch:
http://home.jp.freebsd.org/~iwasaki/apm/19990610/apmd-sys-PAO3.diff.gz

The kernel patches for 2.2-STABLE and -CURRENT are not available for now.
Please make contact with me if you need them.

Any comments, suggestions, bug-reports, improvements are very much 
appreciated.
I'm looking forward working with you :-)

-------------------------------------------------------------------
FreeBSD apmd Package Release Notes (19990610 version)

1. What's apmd package
======================

This apmd package provides a means of handling various APM events from
userland code.  From 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.  You should create
the device file before using apmd 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/apm as follows:

# mkdir /etc/apm
# cp src/usr.sbin/apm/etc/* /etc/apm/


3. Running the apmd daemon program
==================================

To run apmd(8) in background mode, simply type ``apmd''.

# apmd

To make a running apmd reload /etc/apm/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 detials, please 
refer to the source code :-)

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
--------------

`SUSPENDREQ' is one of the APM event names.  You can specify 2 or more
events delimited by a comma, executing the same commands for these
events.  The following are available 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 our example, the next 3 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 failing command's status code via syslog(3).

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 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. SAMPLES
==========

apm_event SUSPENDREQ {
	exec "/etc/apm/rc.suspend";
}

apm_event USERSUSPENDREQ {
	exec "sync && sync && sync";
	exec "sleep 1";
	exec "apm -z";
}

apm_event NORMRESUME, STANDBYRESUME {
	exec "/etc/apm/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>.  We,
however, are still groping the features of apmd and its
implementation, also inviting your ideas.  Documenation is also
sparse, and the manpages have not yet been written.  We are looking
for people who can collaborate with me on this work: Please e-mail
iwasaki@jp.freebsd.org if you are interested in working on this.


June 1, 1999
Created by: iwasaki@jp.FreeBSD.org
Edited by: jkh@FreeBSD.org




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-mobile" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199906101257.VAA16619>