POW(4)

NAME
pow - X68k power switch device

DESCRIPTION
Files /dev/pow and /dev/pow1 are devices used to access the x68k power switch / bootstrap information and the RTC alarm timer. The following operations are allowed using ioctl(2) system call:
POWIOGPOWERINFO
    Getting power switch status
POWIOGALARMINFO
    Getting RTC alarm timer status
POWIOSALARMINFO
    Setting RTC alarm timer
POWIOSSIGNAL
    Setting signal number which is sent at changing the power status

GETTING POWER SWITCH STATUS

    #include <sys/ioctl.h>
    #include <machine/powioctl.h>
    ioctl (fd, POWIOCGPOWERINFO, &powerinfo);
    struct x68k_powerinfo powerinfo;

Returns the power switch status etc. in the following structure.

    struct x68k_powerinfo {
    	int pow_switch_boottime;
    	int pow_switch_current;
    	time_t pow_boottime;
    	unsigned int pow_bootcount;
    	time_t pow_usedtotal;
    };

Each member means:
pow_switch_boottime:
    The power switch status at the system start time. The status is known by applying logical and (&) with:
    POW_ALARMSW
        True if the system started by the RTC alarm timer
    POW_EXTERNALSW
        True if the EXPWON signal of the I/O slot is on
    POW_FRONTSW
        True if the front power switch is on
    EXPWON-related information is not tested.
pow_switch_current:
    Current power switch status. See above.
pow_boottime:
    The time when NetBSD started.
pow_bootcount:
pow_usedtotal:
    Host's boot information from the system memory switch. Total usage in count (pow_bootcount) and second (pow_usedtotal).

ACCESSING RTC ALARM TIMER

    #include <sys/ioctl.h>
    #include <machine/powioctl.h>
    ioctl (fd, POWIOCGALARMINFO, &alarminfo);
    struct x68k_alarminfo alarminfo;

Returns x68k's alarm timer information in the following structure.

    struct x68k_alarminfo {
    	int al_enable;
    	unsigned int al_ontime;
    	int al_dowhat;
    	time_t al_offtime;
    };

Each of the members means:

al_enable:
    True if the alarm timer is enable.

al_ontime:
    Internal expression of the alarm timer. See `C Compiler PRO-68K Programmers' Manual' Chapter 3 Section ALARMSET.

al_dowhat:
    What to do when started by the alarm timer. See `Programers' manual'.

al_offtime:
    Display the time in seconds since the alarm is activated until the power is turned off (though the resolution is resolved to minutes). Be cautious when using IOCS and the like as these require minute time units. 0 indicates an infinity.

    ioctl (fd, POWIOCSALARMINFO, &alarminfo);
    struct x68k_alarminfo alarminfo;

Sets the alarm timer according to the argument alarminfo (see above).

SIGNAL

    #include <sys/ioctl.h>
    #include <machine/powioctl.h>
    ioctl (fd, POWIOCSSIGNAL, &signum);
    int signum;

Signal signum is sent when the state of the power switch (front or external) changes. It becomes invalid when close(2) is called. Note that this function is not provided with /dev/pow1.

SEE ALSO
ioctl(2), poffd(8), rtcalarm(8) `C Compiler PRO-68K Programmers' Manual', Chapter 3 IOCS Calls, Section ALARMSET, Sharp

AUTHOR
Minoura Makoto <minoura@flab.fujitsu.co.jp>.

SPECIAL THANKS
Liam Hahne Minn <hahne@sail.t.u-tokyo.ac.jp>.

BUGS
The file /dev/pow can only be opened by one process at a time.