POW(4) x68k POW(4)

NAME

powX68k power switch device

DESCRIPTION

File /dev/pow0 is a device used to access the x68k power switch / bootstrap information and the RTC alarm timer. The following operations are allowed using the ioctl(2) system call:

POWIOGPOWERINFO
Get power switch status
POWIOGALARMINFO
Get RTC alarm timer status
POWIOSALARMINFO
Set RTC alarm timer

Any power switch events are reported to powerd(8).

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

The members of the structure mean:

pow_switch_boottime:
The power switch status at the system start time. The status can be checked by testing for the following definitions with the logical “and” (&):

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

Getting the 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; 
};

The members mean:

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 “Programmers' 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.

Setting the alarm timer

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

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

SEE ALSO

ioctl(2), powerd(8), rtcalarm(8)

C Compiler PRO-68K Programmers' Manual', Chapter 3 IOCS Calls, Section ALARMSET, Sharp.

AUTHORS

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

SPECIAL THANKS

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

BUGS

The file /dev/pow0 can only be opened by one process at a time.
December 20, 2008 NetBSD 5.99