xref: /netbsd/sys/sys/wdog.h (revision 1f60b395)
1*1f60b395Sdholland /*	$NetBSD: wdog.h,v 1.6 2016/01/26 06:27:38 dholland Exp $	*/
2cb5b106fSthorpej 
3cb5b106fSthorpej /*-
4cb5b106fSthorpej  * Copyright (c) 2000 Zembu Labs, Inc.
5cb5b106fSthorpej  * All rights reserved.
6cb5b106fSthorpej  *
7cb5b106fSthorpej  * Author: Jason R. Thorpe <thorpej@zembu.com>
8cb5b106fSthorpej  *
9cb5b106fSthorpej  * Redistribution and use in source and binary forms, with or without
10cb5b106fSthorpej  * modification, are permitted provided that the following conditions
11cb5b106fSthorpej  * are met:
12cb5b106fSthorpej  * 1. Redistributions of source code must retain the above copyright
13cb5b106fSthorpej  *    notice, this list of conditions and the following disclaimer.
14cb5b106fSthorpej  * 2. Redistributions in binary form must reproduce the above copyright
15cb5b106fSthorpej  *    notice, this list of conditions and the following disclaimer in the
16cb5b106fSthorpej  *    documentation and/or other materials provided with the distribution.
17cb5b106fSthorpej  * 3. All advertising materials mentioning features or use of this software
18cb5b106fSthorpej  *    must display the following acknowledgement:
19cb5b106fSthorpej  *	This product includes software developed by Zembu Labs, Inc.
20cb5b106fSthorpej  * 4. Neither the name of Zembu Labs nor the names of its employees may
21cb5b106fSthorpej  *    be used to endorse or promote products derived from this software
22cb5b106fSthorpej  *    without specific prior written permission.
23cb5b106fSthorpej  *
24cb5b106fSthorpej  * THIS SOFTWARE IS PROVIDED BY ZEMBU LABS, INC. ``AS IS'' AND ANY EXPRESS
25cb5b106fSthorpej  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR-
26cb5b106fSthorpej  * RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS-
27cb5b106fSthorpej  * CLAIMED.  IN NO EVENT SHALL ZEMBU LABS BE LIABLE FOR ANY DIRECT, INDIRECT,
28cb5b106fSthorpej  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29cb5b106fSthorpej  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30cb5b106fSthorpej  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31cb5b106fSthorpej  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32cb5b106fSthorpej  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33cb5b106fSthorpej  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34cb5b106fSthorpej  */
35cb5b106fSthorpej 
36cb5b106fSthorpej #ifndef _SYS_WDOG_H_
37cb5b106fSthorpej #define	_SYS_WDOG_H_
38cb5b106fSthorpej 
39cb5b106fSthorpej #include <sys/ioccom.h>
40cb5b106fSthorpej 
41cb5b106fSthorpej /*
42cb5b106fSthorpej  * Definitions for manipulating watchdog timers.
43cb5b106fSthorpej  */
44cb5b106fSthorpej 
45cb5b106fSthorpej /* This must match struct device's "dv_xname" size. */
46cb5b106fSthorpej #define	WDOG_NAMESIZE	16
47cb5b106fSthorpej 
48cb5b106fSthorpej struct wdog_mode {
49cb5b106fSthorpej 	char wm_name[WDOG_NAMESIZE];
50cb5b106fSthorpej 	int wm_mode;		/* timer mode */
512a9a9741Sdholland 	unsigned int wm_period;	/* timer period (seconds) */
52cb5b106fSthorpej };
53cb5b106fSthorpej 
54cb5b106fSthorpej /*
55cb5b106fSthorpej  * GMODE -- get mode of watchdog specified by wm_name.
56cb5b106fSthorpej  *
57*1f60b395Sdholland  * SMODE -- set mode of watchdog specified by wm_name.  If
58cb5b106fSthorpej  *          wm_mode is not DISARMED, the watchdog is armed,
59cb5b106fSthorpej  *          if another watchdog is not already running.
60cb5b106fSthorpej  */
61cb5b106fSthorpej #define	WDOGIOC_GMODE		_IOWR('w', 0, struct wdog_mode)
62cb5b106fSthorpej #define	WDOGIOC_SMODE		 _IOW('w', 1, struct wdog_mode)
63cb5b106fSthorpej 
64cb5b106fSthorpej /*
65cb5b106fSthorpej  * WHICH -- returns the mode information of the currently armed
66cb5b106fSthorpej  *          watchdog timer.
67cb5b106fSthorpej  */
68cb5b106fSthorpej #define	WDOGIOC_WHICH		 _IOR('w', 2, struct wdog_mode)
69cb5b106fSthorpej 
70cb5b106fSthorpej /*
71cb5b106fSthorpej  * TICKLE -- tickle the currently armed watchdog timer if the
72cb5b106fSthorpej  *           mode of that timer is UTICKLE.
73cb5b106fSthorpej  */
74cb5b106fSthorpej #define	WDOGIOC_TICKLE		  _IO('w', 3)
75cb5b106fSthorpej 
76cb5b106fSthorpej /*
77cb5b106fSthorpej  * GTICKLER -- get the PID of the last process to tickle the timer.
78cb5b106fSthorpej  */
79cb5b106fSthorpej #define	WDOGIOC_GTICKLER	 _IOR('w', 4, pid_t)
80cb5b106fSthorpej 
81cb5b106fSthorpej /*
82cb5b106fSthorpej  * GWDOGS -- fill in the character array with the names of all of
83cb5b106fSthorpej  *           the watchdog timers present on the system.  The names
84cb5b106fSthorpej  *           will be padded out to WDOG_NAMESIZE.  Thus, the argument
85cb5b106fSthorpej  *           should be (count * WDOG_NAMESIZE) bytes long.
86cb5b106fSthorpej  */
87cb5b106fSthorpej struct wdog_conf {
88cb5b106fSthorpej 	char *wc_names;
89cb5b106fSthorpej 	int wc_count;
90cb5b106fSthorpej };
91cb5b106fSthorpej #define	WDOGIOC_GWDOGS		_IOWR('w', 5, struct wdog_conf)
92cb5b106fSthorpej 
93cb5b106fSthorpej #define	WDOG_MODE_DISARMED	0	/* watchdog is disarmed */
94cb5b106fSthorpej #define	WDOG_MODE_KTICKLE	1	/* kernel tickles watchdog */
95cb5b106fSthorpej #define	WDOG_MODE_UTICKLE	2	/* user tickles watchdog */
96ddd2ade2Ssmb #define	WDOG_MODE_ETICKLE	3	/* external program tickles watchdog */
97cb5b106fSthorpej 
98cb5b106fSthorpej #define	WDOG_MODE_MASK		0x03
99cb5b106fSthorpej 
100cb5b106fSthorpej #define	WDOG_FEATURE_ALARM	0x10	/* enable audible alarm on expire */
101cb5b106fSthorpej 
102cb5b106fSthorpej #define	WDOG_FEATURE_MASK	0x10
103cb5b106fSthorpej 
104cb5b106fSthorpej #define	WDOG_PERIOD_DEFAULT	((u_int)-1)
105cb5b106fSthorpej 
106cb5b106fSthorpej /* Period is expressed in seconds. */
107cb5b106fSthorpej #define	WDOG_PERIOD_TO_TICKS(period)	((period) * hz)
108cb5b106fSthorpej 
109cb5b106fSthorpej #endif /* _SYS_WDOG_H_ */
110