
	APM BIOS Driver for Linux

	by Stephen Rothwell       Stephen.Rothwell@pd.necisa.oz.au

This driver interfaces to an Advanced Power Management (APM) BIOS on
a system (usually a laptop) to allow the control of power management
and the reporting of power management events under Linux.

Currently the driver works with Linux versions 1.2.0, but it should
be possible to get it to work with newer versions of the kernel.

INSTALLATION:

There are a set of kernel patches to be applied called kernel.patch.
Use
	patch -p0 <kernel.patch	(from /usr/src)
or
	patch -p1 <kernel.patch (from /usr/src/linux)

There are also some new files to install:
	apm_bios.h belongs in include/linux/apm_bios.h
	apm_bios.c belongs in drivers/char/apm_bios.c
Copy these to the appropriate directories in /usr/src/linux.

Then do
	make config;make depend;make
in /usr/src/linux.

There is a very simple apm daemon: apmd.c.

DETAILS:

The driver itself just prints some debugging information at startup
and then polls the APM BIOS every second to get events.  It then
passes these evnts onto any other drivers that have registered and
also to user processes if they has the apm_bios device open.  If there
is no user process with the device open, and the driver gets a SUSPEND
event, it tells the APM BIOS to suspend the system and then when the
BIOS returns, resets the system time.  If it gets a RESUME event, it
just resets the system time.  Any other event just gets logged (using
printk).  This logging can be disabled in the driver (see APM_DEBUG in
apm_bios.c).

There are a few configuration paramaters in the apm_bios.c file.  These
are set near the top with some #define's.  See the file for details.

The major number for the device is dynamically allocated.  You can use
	cat /proc/devices
to find it.  Then you must use
	mknod /dev/apm_bios c <major> 0
to create the device.  This device may be read to get notification of
APM events.  Each event is returned as an unsigned short (currently in
Intel order - least significant byte first).  Select and O_NONBLOCK
also both work.

There are currently only two ioctls.  These allow a user process to
put the machine into suspend or standby mode.

Many processes can have the device open, but only root can successfully
use the ioctl's.

There is now a /proc/apm file.  This currently returns the status of
the Power Management (including the battery status).