]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/watchdog.4
Remove deprecated GEOM classes
[FreeBSD/FreeBSD.git] / share / man / man4 / watchdog.4
1 .\" Copyright (c) 2004 Poul-Henning Kamp <phk@FreeBSD.org>
2 .\" Copyright (c) 2003, 2004 Sean M. Kelly <smkelly@FreeBSD.org>
3 .\" All rights reserved.
4 .\"
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
7 .\" are met:
8 .\" 1. Redistributions of source code must retain the above copyright
9 .\"    notice, this list of conditions and the following disclaimer.
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd January 2, 2018
29 .Dt WATCHDOG 4
30 .Os
31 .Sh NAME
32 .Nm watchdog
33 .Nd "hardware and software watchdog"
34 .Sh SYNOPSIS
35 .In sys/watchdog.h
36 .Sh DESCRIPTION
37 The
38 .Nm
39 facility is used for controlling hardware and software watchdogs.
40 .Pp
41 The device
42 .Pa /dev/fido
43 supports several optional
44 .Xr ioctl 2
45 calls for configuration, and
46 responds to a single operational
47 .Xr ioctl
48 call,
49 .Dv WDIOCPATPAT .
50 It takes a single argument which represents a timeout value specified as a
51 power of two nanoseconds, or-ed with a flag selecting active or passive control
52 of the watchdog.
53 .Pp
54 .Dv WD_ACTIVE
55 indicates that the
56 .Nm
57 will be kept from timing out from userland, for instance by the
58 .Xr watchdogd 8
59 daemon.
60 .Dv WD_PASSIVE
61 indicates that the
62 .Nm
63 will be kept from timing out from the kernel.
64 .Pp
65 The
66 .Dv WDIOCPATPAT
67 .Xr ioctl 2
68 call will return success if just one of the available
69 .Xr watchdog 9
70 implementations supports setting the timeout to the specified timeout.
71 This
72 means that at least one watchdog is armed.
73 By default, this will be a hardware watchdog if one is present, but if
74 no hardware watchdog is able to process the request, a default software
75 watchdog is enabled.
76 If the call fails, for instance if
77 none of
78 .Xr watchdog 9
79 implementations support the timeout length, all watchdogs are disabled and must
80 be explicitly re-enabled.
81 .Pp
82 To disable the watchdogs pass
83 .Dv WD_TO_NEVER .
84 If disarming the watchdog(s) failed an error is returned.
85 The watchdog might
86 still be armed!
87 .Pp
88 The optional configuration
89 .Xr ioctl
90 commands are listed here, along with the type of the parameter used.
91 Examples of their use can be found in
92 .Xr watchdogd 8 .
93 .Bl -tag -width "WDIOC_SETSOFTTIMEOUTACT int  "
94 .It Dv WDIOC_SETTIMEOUT Fa int
95 set/reset the timer
96 .It Dv WDIOC_GETTIMEOUT Fa int
97 get total timeout
98 .It Dv WDIOC_GETTIMELEFT Fa int
99 get time left
100 .It Dv WDIOC_GETPRETIMEOUT Fa int
101 get the pre-timeout
102 .It Dv WDIOC_SETPRETIMEOUT Fa int
103 set the pre-timeout
104 .It Dv WDIOC_SETPRETIMEOUTACT Fa int
105 Set the action when a pre-timeout occurs (see
106 .Li WD_SOFT_*
107 below).
108 .It Dv WDIOC_SETSOFT Fa int
109 Use an internal software watchdog instead of hardware.
110 There is also an external software watchdog, which is used by default
111 if no hardware watchdog was attached.
112 .It Dv WDIOC_SETSOFTTIMEOUTACT Fa int
113 Set the action whan a soft timeout occurs.
114 .El
115 .Pp
116 The actions that may be specified for the pre-timeout or the internal software
117 watchdog are listed here.
118 Multiple actions can be specified by ORing values together.
119 .Bl -tag -width  WD_SOFT_PRINT
120 .It Dv WD_SOFT_PANIC
121 panic
122 .It Dv WD_SOFT_DDB
123 enter debugger
124 .It Dv WD_SOFT_LOG
125 log(9)
126 .It Dv WD_SOFT_PRINT
127 printf(9)
128 .El
129 .Sh RETURN VALUES
130 The
131 .Dv WDIOCPATPAT
132 .Xr ioctl
133 returns zero on success and non-zero on failure.
134 .Bl -tag -width Er
135 .It Bq Er EOPNOTSUPP
136 No watchdog present in the kernel or
137 none of the watchdogs supports the requested timeout value
138 (timeout value other than 0).
139 .It Bq Er EOPNOTSUPP
140 Watchdog could not be disabled (timeout value of 0).
141 .It Bq Er EINVAL
142 Invalid flag combination passed.
143 .El
144 .Pp
145 The configuration
146 .Xr ioctl
147 operations return zero on success and non-zero on failure.
148 .Sh EXAMPLES
149 .Bd -literal -offset indent
150 #include <paths.h>
151 #include <sys/watchdog.h>
152
153 #define WDPATH  "/dev/" _PATH_WATCHDOG
154 int wdfd = -1;
155
156 static void
157 wd_init(void)
158 {
159         wdfd = open(WDPATH, O_RDWR);
160         if (wdfd == -1)
161                 err(1, WDPATH);
162 }
163 static void
164 wd_reset(u_int timeout)
165 {
166         if (ioctl(wdfd, WDIOCPATPAT, &timeout) == -1)
167                 err(1, "WDIOCPATPAT");
168 }
169
170 /* in main() */
171 wd_init();
172 wd_reset(WD_ACTIVE|WD_TO_8SEC);
173 /* potential freeze point */
174 wd_reset(WD_TO_NEVER);
175 .Ed
176 .Pp
177 Enables a watchdog to recover from a potentially freezing piece of code.
178 .Pp
179 .Dl "options SW_WATCHDOG"
180 .Pp
181 in your kernel config forces a software watchdog in the kernel
182 to be configured even if a hardware watchdog is configured,
183 dropping to KDB or panicking when firing, depending
184 on the KDB and KDB_UNATTENDED kernel configuration options.
185 .Sh SEE ALSO
186 .Xr watchdogd 8 ,
187 .Xr watchdog 9
188 .Sh HISTORY
189 The
190 .Nm
191 code first appeared in
192 .Fx 5.1 .
193 .Sh AUTHORS
194 .An -nosplit
195 The
196 .Nm
197 facility was written by
198 .An Poul-Henning Kamp Aq Mt phk@FreeBSD.org .
199 The software watchdog code and this manual page were written by
200 .An Sean Kelly Aq Mt smkelly@FreeBSD.org .
201 Some contributions were made by
202 .An Jeff Roberson Aq Mt jeff@FreeBSD.org .
203 .Sh BUGS
204 The
205 .Dv WD_PASSIVE
206 option has not yet been implemented.