source: rtems/c/src/exec/score/headers/watchdog.h @ 5e9b32b

4.104.114.84.95
Last change on this file since 5e9b32b was 5e9b32b, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 26, 1995 at 7:27:15 PM

posix support initially added

  • Property mode set to 100644
File size: 8.8 KB
Line 
1/*  watchdog.h
2 *
3 *  This include file contains all the constants and structures associated
4 *  with watchdog timers.   This Handler provides mechanisms which can be
5 *   used to initialize and manipulate watchdog timers.
6 *
7 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
8 *  On-Line Applications Research Corporation (OAR).
9 *  All rights assigned to U.S. Government, 1994.
10 *
11 *  This material may be reproduced by or for the U.S. Government pursuant
12 *  to the copyright license under the clause at DFARS 252.227-7013.  This
13 *  notice must appear in all copies of this file and its derivatives.
14 *
15 *  $Id$
16 */
17
18#ifndef __WATCHDOG_h
19#define __WATCHDOG_h
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <rtems/score/object.h>
26
27/*
28 *  The following type defines the control block used to manage
29 *  intervals.
30 */
31
32typedef unsigned32 Watchdog_Interval;
33
34/*
35 *  The following types define a pointer to a watchdog service routine.
36 */
37
38typedef void Watchdog_Service_routine;
39
40typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )(
41                 Objects_Id,
42                 void *
43             );
44
45/*
46 *  Constant for indefinite wait.  (actually an illegal interval)
47 */
48
49#define WATCHDOG_NO_TIMEOUT  0
50
51/*
52 *  The following enumerated type details the modes in which the
53 *  Watchdog_Insert routine may operate.  The watchdog may be
54 *  activated automatically at insert time or later, explicitly
55 *  by the caller.
56 */
57
58typedef enum {
59  WATCHDOG_ACTIVATE_NOW, /* activate watchdog as part of insertion */
60  WATCHDOG_NO_ACTIVATE   /* watchdog will be explicitly activated */
61} Watchdog_Insert_modes;
62
63/*
64 *  The following enumerated type lists the states in which a
65 *  watchdog timer may be at any given time.
66 */
67
68typedef enum {
69  WATCHDOG_INACTIVE,     /* off all chains */
70  WATCHDOG_ACTIVE,       /* on chain, allowed to fire */
71  WATCHDOG_REINSERT,     /* on chain, reset without firing if expires */
72  WATCHDOG_REMOVE_IT     /* on chain, remove without firing if expires */
73} Watchdog_States;
74
75/*
76 *  The following enumerated type details the manner in which
77 *  a watchdog chain may be adjusted by the Watchdog_Adjust
78 *  routine.  The direction indicates a movement FORWARD
79 *  or BACKWARD in time.
80 */
81
82typedef enum {
83  WATCHDOG_FORWARD,      /* adjust delta value forward */
84  WATCHDOG_BACKWARD      /* adjust delta value backward */
85} Watchdog_Adjust_directions;
86
87/*
88 *  The following record defines the control block used
89 *  to manage each watchdog timer.
90 */
91
92typedef struct {
93  Chain_Node        Node;
94  Watchdog_States   state;
95  Watchdog_Interval initial;
96  Watchdog_Interval delta_interval;
97  Watchdog_Service_routine_entry  routine;
98  Objects_Id        id;
99  void             *user_data;
100}   Watchdog_Control;
101
102/*
103 *  The following are used for synchronization purposes
104 *  during an insert on a watchdog delta chain.
105 */
106
107EXTERN volatile unsigned32  _Watchdog_Sync_level;
108EXTERN volatile unsigned32  _Watchdog_Sync_count;
109
110/*
111 *  The following defines the watchdog chains which are managed
112 *  on ticks and second boundaries.
113 */
114
115EXTERN Chain_Control _Watchdog_Ticks_chain;
116EXTERN Chain_Control _Watchdog_Seconds_chain;
117
118/*
119 *  _Watchdog_Handler_initialization
120 *
121 *  DESCRIPTION:
122 *
123 *  This routine initializes the watchdog handler.  The watchdog
124 *  synchronization flag is initialized and the watchdog chains are
125 *  initialized and emptied.
126 */
127
128void _Watchdog_Handler_initialization( void );
129
130/*
131 *
132 *  _Watchdog_Initialize
133 *
134 *  DESCRIPTION:
135 *
136 *  This routine initializes the specified watchdog.  The watchdog is
137 *  made inactive, the watchdog id and handler routine are set to the
138 *  specified values.
139 */
140
141STATIC INLINE void _Watchdog_Initialize(
142   Watchdog_Control *the_watchdog,
143   Watchdog_Service_routine_entry  routine,
144   Objects_Id        id,
145   void             *user_data
146);
147
148/*
149 *  _Watchdog_Remove
150 *
151 *  DESCRIPTION:
152 *
153 *  This routine removes THE_WATCHDOG from the watchdog chain on which
154 *  it resides and returns the state THE_WATCHDOG timer was in.
155 */
156
157Watchdog_States _Watchdog_Remove (
158  Watchdog_Control *the_watchdog
159);
160
161/*
162 *
163 *  _Watchdog_Is_active
164 *
165 *  DESCRIPTION:
166 *
167 *  This routine returns TRUE if the watchdog timer is in the ACTIVE
168 *  state, and FALSE otherwise.
169 */
170
171STATIC INLINE boolean _Watchdog_Is_active(
172  Watchdog_Control *the_watchdog
173);
174
175/*
176 *
177 *  _Watchdog_Activate
178 *
179 *  DESCRIPTION:
180 *
181 *  This routine activates THE_WATCHDOG timer which is already
182 *  on a watchdog chain.
183 */
184
185STATIC INLINE void _Watchdog_Activate(
186  Watchdog_Control *the_watchdog
187);
188
189/*
190 *
191 *  _Watchdog_Deactivate
192 *
193 *  DESCRIPTION:
194 *
195 *  This routine deactivates THE_WATCHDOG timer which will remain
196 *  on a watchdog chain.
197 */
198
199STATIC INLINE void _Watchdog_Deactivate(
200  Watchdog_Control *the_watchdog
201);
202
203/*
204 *
205 *  _Watchdog_Tickle_ticks
206 *
207 *  DESCRIPTION:
208 *
209 *  This routine is invoked at each clock tick to update the ticks
210 *  watchdog chain.
211 */
212
213STATIC INLINE void _Watchdog_Tickle_ticks( void );
214
215/*
216 *
217 *  _Watchdog_Tickle_seconds
218 *
219 *  DESCRIPTION:
220 *
221 *  This routine is invoked at each clock tick to update the seconds
222 *  watchdog chain.
223 */
224
225STATIC INLINE void _Watchdog_Tickle_seconds( void );
226
227/*
228 *
229 *  _Watchdog_Insert_ticks
230 *
231 *  DESCRIPTION:
232 *
233 *  This routine inserts THE_WATCHDOG into the ticks watchdog chain
234 *  for a time of UNITS ticks.  The INSERT_MODE indicates whether
235 *  THE_WATCHDOG is to be activated automatically or later, explicitly
236 *  by the caller.
237 */
238
239STATIC INLINE void _Watchdog_Insert_ticks(
240  Watchdog_Control      *the_watchdog,
241  Watchdog_Interval      units,
242  Watchdog_Insert_modes  insert_mode
243);
244
245/*
246 *
247 *  _Watchdog_Insert_seconds
248 *
249 *  DESCRIPTION:
250 *
251 *  This routine inserts THE_WATCHDOG into the seconds watchdog chain
252 *  for a time of UNITS seconds.  The INSERT_MODE indicates whether
253 *  THE_WATCHDOG is to be activated automatically or later, explicitly
254 *  by the caller.
255 */
256
257STATIC INLINE void _Watchdog_Insert_seconds(
258  Watchdog_Control      *the_watchdog,
259  Watchdog_Interval      units,
260  Watchdog_Insert_modes  insert_mode
261);
262
263/*
264 *
265 *  _Watchdog_Adjust_seconds
266 *
267 *  DESCRIPTION:
268 *
269 *  This routine adjusts the seconds watchdog chain in the forward
270 *  or backward DIRECTION for UNITS seconds.  This is invoked when the
271 *  current time of day is changed.
272 */
273
274STATIC INLINE void _Watchdog_Adjust_seconds(
275  Watchdog_Adjust_directions direction,
276  Watchdog_Interval          units
277);
278
279/*
280 *
281 *  _Watchdog_Adjust_ticks
282 *
283 *  DESCRIPTION:
284 *
285 *  This routine adjusts the ticks watchdog chain in the forward
286 *  or backward DIRECTION for UNITS ticks.
287 */
288
289STATIC INLINE void _Watchdog_Adjust_ticks(
290  Watchdog_Adjust_directions direction,
291  Watchdog_Interval          units
292);
293
294/*
295 *
296 *  _Watchdog_Reset
297 *
298 *  DESCRIPTION:
299 *
300 *  This routine resets THE_WATCHDOG timer to its state at INSERT
301 *  time.  This routine is valid only on interval watchdog timers
302 *  and is used to make an interval watchdog timer fire "every" so
303 *  many ticks.
304 */
305
306STATIC INLINE void _Watchdog_Reset(
307  Watchdog_Control *the_watchdog
308);
309
310/*
311 *
312 *  _Watchdog_Next
313 *
314 *  DESCRIPTION:
315 *
316 *  This routine returns a pointer to the watchdog timer following
317 *  THE_WATCHDOG on the watchdog chain.
318 */
319
320STATIC INLINE Watchdog_Control *_Watchdog_Next(
321  Watchdog_Control *the_watchdog
322);
323
324/*
325 *
326 *  _Watchdog_Previous
327 *
328 *  DESCRIPTION:
329 *
330 *  This routine returns a pointer to the watchdog timer preceding
331 *  THE_WATCHDOG on the watchdog chain.
332 */
333
334STATIC INLINE Watchdog_Control *_Watchdog_Previous(
335  Watchdog_Control *the_watchdog
336);
337
338/*
339 *
340 *  _Watchdog_First
341 *
342 *  DESCRIPTION:
343 *
344 *  This routine returns a pointer to the first watchdog timer
345 *  on the watchdog chain HEADER.
346 */
347
348STATIC INLINE Watchdog_Control *_Watchdog_First(
349  Chain_Control *header
350);
351
352/*
353 *
354 *  _Watchdog_Last
355 *
356 *  DESCRIPTION:
357 *
358 *  This routine returns a pointer to the last watchdog timer
359 *  on the watchdog chain HEADER.
360 */
361STATIC INLINE Watchdog_Control *_Watchdog_Last(
362  Chain_Control *header
363);
364
365/*
366 *  _Watchdog_Adjust
367 *
368 *  DESCRIPTION:
369 *
370 *  This routine adjusts the HEADER watchdog chain in the forward
371 *  or backward DIRECTION for UNITS ticks.
372 */
373
374void _Watchdog_Adjust (
375  Chain_Control              *header,
376  Watchdog_Adjust_directions  direction,
377  Watchdog_Interval           units
378);
379
380/*
381 *  _Watchdog_Insert
382 *
383 *  DESCRIPTION:
384 *
385 *  This routine inserts THE_WATCHDOG into the HEADER watchdog chain
386 *  for a time of UNITS.  The INSERT_MODE indicates whether
387 *  THE_WATCHDOG is to be activated automatically or later, explicitly
388 *  by the caller.
389 *
390 */
391
392void _Watchdog_Insert (
393  Chain_Control         *header,
394  Watchdog_Control      *the_watchdog,
395  Watchdog_Insert_modes  insert_mode
396);
397
398/*
399 *  _Watchdog_Tickle
400 *
401 *  DESCRIPTION:
402 *
403 *  This routine is invoked at appropriate intervals to update
404 *  the HEADER watchdog chain.
405 */
406
407void _Watchdog_Tickle (
408  Chain_Control *header
409);
410
411#include <rtems/score/watchdog.inl>
412
413#ifdef __cplusplus
414}
415#endif
416
417#endif
418/* end of include file */
Note: See TracBrowser for help on using the repository browser.