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

4.104.114.84.95
Last change on this file since ac7d5ef0 was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 10.1 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 __RTEMS_WATCHDOG_h
19#define __RTEMS_WATCHDOG_h
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25#include <rtems/object.h>
26
27/*
28 *  The following type defines the control block used to manage
29 *  intervals.
30 */
31
32typedef unsigned32 rtems_interval;
33
34/*
35 *  The following types define a pointer to a watchdog/timer service routine.
36 */
37
38typedef void rtems_timer_service_routine;
39
40typedef rtems_timer_service_routine ( *rtems_timer_service_routine_entry )(
41                 Objects_Id,
42                 void *
43             );
44
45/*
46 *  Constant for indefinite wait.  (actually an illegal interval)
47 */
48
49#define RTEMS_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  rtems_interval initial;
96  rtems_interval delta_interval;
97  rtems_timer_service_routine_entry  routine;
98  Objects_Id        id;
99  void             *user_data;
100}   Watchdog_Control;
101
102/*
103 *  The following type is used for synchronization purposes
104 *  during an insert on a watchdog delta chain.
105 *
106 *  NOTE:  Watchdog_Pointer is only used to insure that
107 *         Watchdog_Synchronization_pointer is a pointer
108 *         which is volatile rather than a pointer to a
109 *         volatile block of memory.
110 */
111
112typedef Watchdog_Control          *Watchdog_Pointer;
113typedef volatile Watchdog_Pointer  Watchdog_Synchronization_pointer;
114
115/*
116 *  The following defines the watchdog chains which are managed
117 *  on ticks and second boundaries.
118 */
119
120EXTERN Chain_Control _Watchdog_Ticks_chain;
121EXTERN Chain_Control _Watchdog_Seconds_chain;
122
123/*
124 *  The following defines the synchronization variable used to
125 *  allow interrupts to be enabled while inserting a watchdog
126 *  on a watchdog chain.
127 */
128
129EXTERN Watchdog_Synchronization_pointer _Watchdog_Sync;
130
131/*
132 *  _Watchdog_Handler_initialization
133 *
134 *  DESCRIPTION:
135 *
136 *  This routine initializes the watchdog handler.  The watchdog
137 *  synchronization flag is initialized and the watchdog chains are
138 *  initialized and emptied.
139 */
140
141void _Watchdog_Handler_initialization( void );
142
143/*
144 *
145 *  _Watchdog_Initialize
146 *
147 *  DESCRIPTION:
148 *
149 *  This routine initializes the specified watchdog.  The watchdog is
150 *  made inactive, the watchdog id and handler routine are set to the
151 *  specified values.
152 */
153
154STATIC INLINE void _Watchdog_Initialize(
155   Watchdog_Control *the_watchdog,
156   rtems_timer_service_routine_entry  routine,
157   Objects_Id        id,
158   void             *user_data
159);
160
161/*
162 *  _Watchdog_Remove
163 *
164 *  DESCRIPTION:
165 *
166 *  This routine removes THE_WATCHDOG from the watchdog chain on which
167 *  it resides and returns the state THE_WATCHDOG timer was in.
168 */
169
170Watchdog_States _Watchdog_Remove (
171  Watchdog_Control *the_watchdog
172);
173
174/*
175 *
176 *  _Watchdog_Is_active
177 *
178 *  DESCRIPTION:
179 *
180 *  This routine returns TRUE if the watchdog timer is in the ACTIVE
181 *  state, and FALSE otherwise.
182 */
183
184STATIC INLINE boolean _Watchdog_Is_active(
185  Watchdog_Control *the_watchdog
186);
187
188/*
189 *
190 *  _Watchdog_Activate
191 *
192 *  DESCRIPTION:
193 *
194 *  This routine activates THE_WATCHDOG timer which is already
195 *  on a watchdog chain.
196 */
197
198STATIC INLINE void _Watchdog_Activate(
199  Watchdog_Control *the_watchdog
200);
201
202/*
203 *
204 *  _Watchdog_Deactivate
205 *
206 *  DESCRIPTION:
207 *
208 *  This routine deactivates THE_WATCHDOG timer which will remain
209 *  on a watchdog chain.
210 */
211
212STATIC INLINE void _Watchdog_Deactivate(
213  Watchdog_Control *the_watchdog
214);
215
216/*
217 *
218 *  _Watchdog_Tickle_ticks
219 *
220 *  DESCRIPTION:
221 *
222 *  This routine is invoked at each clock tick to update the ticks
223 *  watchdog chain.
224 */
225
226STATIC INLINE void _Watchdog_Tickle_ticks( void );
227
228/*
229 *
230 *  _Watchdog_Tickle_seconds
231 *
232 *  DESCRIPTION:
233 *
234 *  This routine is invoked at each clock tick to update the seconds
235 *  watchdog chain.
236 */
237
238STATIC INLINE void _Watchdog_Tickle_seconds( void );
239
240/*
241 *
242 *  _Watchdog_Insert_ticks
243 *
244 *  DESCRIPTION:
245 *
246 *  This routine inserts THE_WATCHDOG into the ticks watchdog chain
247 *  for a time of UNITS ticks.  The INSERT_MODE indicates whether
248 *  THE_WATCHDOG is to be activated automatically or later, explicitly
249 *  by the caller.
250 */
251
252STATIC INLINE void _Watchdog_Insert_ticks(
253  Watchdog_Control      *the_watchdog,
254  rtems_interval      units,
255  Watchdog_Insert_modes  insert_mode
256);
257
258/*
259 *
260 *  _Watchdog_Insert_seconds
261 *
262 *  DESCRIPTION:
263 *
264 *  This routine inserts THE_WATCHDOG into the seconds watchdog chain
265 *  for a time of UNITS seconds.  The INSERT_MODE indicates whether
266 *  THE_WATCHDOG is to be activated automatically or later, explicitly
267 *  by the caller.
268 */
269
270STATIC INLINE void _Watchdog_Insert_seconds(
271  Watchdog_Control      *the_watchdog,
272  rtems_interval      units,
273  Watchdog_Insert_modes  insert_mode
274);
275
276/*
277 *
278 *  _Watchdog_Adjust_seconds
279 *
280 *  DESCRIPTION:
281 *
282 *  This routine adjusts the seconds watchdog chain in the forward
283 *  or backward DIRECTION for UNITS seconds.  This is invoked when the
284 *  current time of day is changed.
285 */
286
287STATIC INLINE void _Watchdog_Adjust_seconds(
288  Watchdog_Adjust_directions direction,
289  rtems_interval          units
290);
291
292/*
293 *
294 *  _Watchdog_Adjust_ticks
295 *
296 *  DESCRIPTION:
297 *
298 *  This routine adjusts the ticks watchdog chain in the forward
299 *  or backward DIRECTION for UNITS ticks.
300 */
301
302STATIC INLINE void _Watchdog_Adjust_ticks(
303  Watchdog_Adjust_directions direction,
304  rtems_interval          units
305);
306
307/*
308 *
309 *  _Watchdog_Reset
310 *
311 *  DESCRIPTION:
312 *
313 *  This routine resets THE_WATCHDOG timer to its state at INSERT
314 *  time.  This routine is valid only on interval watchdog timers
315 *  and is used to make an interval watchdog timer fire "every" so
316 *  many ticks.
317 */
318
319STATIC INLINE void _Watchdog_Reset(
320  Watchdog_Control *the_watchdog
321);
322
323/*
324 *
325 *  _Watchdog_Next
326 *
327 *  DESCRIPTION:
328 *
329 *  This routine returns a pointer to the watchdog timer following
330 *  THE_WATCHDOG on the watchdog chain.
331 */
332
333STATIC INLINE Watchdog_Control *_Watchdog_Next(
334  Watchdog_Control *the_watchdog
335);
336
337/*
338 *
339 *  _Watchdog_Previous
340 *
341 *  DESCRIPTION:
342 *
343 *  This routine returns a pointer to the watchdog timer preceding
344 *  THE_WATCHDOG on the watchdog chain.
345 */
346
347STATIC INLINE Watchdog_Control *_Watchdog_Previous(
348  Watchdog_Control *the_watchdog
349);
350
351/*
352 *
353 *  _Watchdog_First
354 *
355 *  DESCRIPTION:
356 *
357 *  This routine returns a pointer to the first watchdog timer
358 *  on the watchdog chain HEADER.
359 */
360
361STATIC INLINE Watchdog_Control *_Watchdog_First(
362  Chain_Control *header
363);
364
365/*
366 *
367 *  _Watchdog_Last
368 *
369 *  DESCRIPTION:
370 *
371 *  This routine returns a pointer to the last watchdog timer
372 *  on the watchdog chain HEADER.
373 */
374STATIC INLINE Watchdog_Control *_Watchdog_Last(
375  Chain_Control *header
376);
377
378/*
379 *
380 *  _Watchdog_Get_sync
381 *
382 *  DESCRIPTION:
383 *
384 *  This routine returns the current synchronization timer.  This
385 *  routine is used so that interrupts can be enabled while a
386 *  watchdog timer is being inserted into a watchdog chain.
387 */
388
389STATIC INLINE Watchdog_Control *_Watchdog_Get_sync( void );
390
391/*
392 *
393 *  _Watchdog_Set_sync
394 *
395 *  DESCRIPTION:
396 *
397 *  This routine sets the current synchronization timer.  This
398 *  routine is used so that interrupts can be enabled while a
399 *  watchdog timer is being inserted into a watchdog chain.
400 */
401
402STATIC INLINE void _Watchdog_Set_sync(
403  Watchdog_Control *the_watchdog
404);
405
406/*
407 *
408 *  _Watchdog_Clear_sync
409 *
410 *  DESCRIPTION:
411 *
412 *  This routine will set the watchdog synchronization flag to a
413 *  NULL address indicating synchronization is unnecessary.
414 */
415
416STATIC INLINE void _Watchdog_Clear_sync( void );
417
418/*
419 *  _Watchdog_Adjust
420 *
421 *  DESCRIPTION:
422 *
423 *  This routine adjusts the HEADER watchdog chain in the forward
424 *  or backward DIRECTION for UNITS ticks.
425 */
426
427void _Watchdog_Adjust (
428  Chain_Control              *header,
429  Watchdog_Adjust_directions  direction,
430  rtems_interval           units
431);
432
433/*
434 *  _Watchdog_Insert
435 *
436 *  DESCRIPTION:
437 *
438 *  This routine inserts THE_WATCHDOG into the HEADER watchdog chain
439 *  for a time of UNITS.  The INSERT_MODE indicates whether
440 *  THE_WATCHDOG is to be activated automatically or later, explicitly
441 *  by the caller.
442 *
443 */
444
445void _Watchdog_Insert (
446  Chain_Control         *header,
447  Watchdog_Control      *the_watchdog,
448  Watchdog_Insert_modes  insert_mode
449);
450
451/*
452 *  _Watchdog_Tickle
453 *
454 *  DESCRIPTION:
455 *
456 *  This routine is invoked at appropriate intervals to update
457 *  the HEADER watchdog chain.
458 */
459
460void _Watchdog_Tickle (
461  Chain_Control *header
462);
463
464#include <rtems/watchdog.inl>
465
466#ifdef __cplusplus
467}
468#endif
469
470#endif
471/* end of include file */
Note: See TracBrowser for help on using the repository browser.