source: rtems/c/src/exec/score/include/rtems/score/watchdog.h @ 8d0b7d96

4.104.114.84.95
Last change on this file since 8d0b7d96 was 8d0b7d96, checked in by Joel Sherrill <joel.sherrill@…>, on 12/01/95 at 22:03:55

Insert mode argument to _Watchdog_Insert removed. Now are watchdog timers
are automatically activated upon insertion.

  • Property mode set to 100644
File size: 8.3 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 lists the states in which a
53 *  watchdog timer may be at any given time.
54 */
55
56typedef enum {
57  WATCHDOG_INACTIVE,       /* off all chains */
58  WATCHDOG_BEING_INSERTED, /* off all chains, searching for insertion point */
59  WATCHDOG_ACTIVE,         /* on chain, allowed to fire */
60  WATCHDOG_REMOVE_IT       /* on chain, remove without firing if expires */
61} Watchdog_States;
62
63/*
64 *  The following enumerated type details the manner in which
65 *  a watchdog chain may be adjusted by the Watchdog_Adjust
66 *  routine.  The direction indicates a movement FORWARD
67 *  or BACKWARD in time.
68 */
69
70typedef enum {
71  WATCHDOG_FORWARD,      /* adjust delta value forward */
72  WATCHDOG_BACKWARD      /* adjust delta value backward */
73} Watchdog_Adjust_directions;
74
75/*
76 *  The following record defines the control block used
77 *  to manage each watchdog timer.
78 */
79
80typedef struct {
81  Chain_Node        Node;
82  Watchdog_States   state;
83  Watchdog_Interval initial;
84  Watchdog_Interval delta_interval;
85  Watchdog_Service_routine_entry  routine;
86  Objects_Id        id;
87  void             *user_data;
88}   Watchdog_Control;
89
90/*
91 *  The following are used for synchronization purposes
92 *  during an insert on a watchdog delta chain.
93 */
94
95EXTERN volatile unsigned32  _Watchdog_Sync_level;
96EXTERN volatile unsigned32  _Watchdog_Sync_count;
97
98/*
99 *  The following defines the watchdog chains which are managed
100 *  on ticks and second boundaries.
101 */
102
103EXTERN Chain_Control _Watchdog_Ticks_chain;
104EXTERN Chain_Control _Watchdog_Seconds_chain;
105
106/*
107 *  _Watchdog_Handler_initialization
108 *
109 *  DESCRIPTION:
110 *
111 *  This routine initializes the watchdog handler.  The watchdog
112 *  synchronization flag is initialized and the watchdog chains are
113 *  initialized and emptied.
114 */
115
116void _Watchdog_Handler_initialization( void );
117
118/*
119 *
120 *  _Watchdog_Initialize
121 *
122 *  DESCRIPTION:
123 *
124 *  This routine initializes the specified watchdog.  The watchdog is
125 *  made inactive, the watchdog id and handler routine are set to the
126 *  specified values.
127 */
128
129STATIC INLINE void _Watchdog_Initialize(
130   Watchdog_Control *the_watchdog,
131   Watchdog_Service_routine_entry  routine,
132   Objects_Id        id,
133   void             *user_data
134);
135
136/*
137 *  _Watchdog_Remove
138 *
139 *  DESCRIPTION:
140 *
141 *  This routine removes THE_WATCHDOG from the watchdog chain on which
142 *  it resides and returns the state THE_WATCHDOG timer was in.
143 */
144
145Watchdog_States _Watchdog_Remove (
146  Watchdog_Control *the_watchdog
147);
148
149/*
150 *
151 *  _Watchdog_Is_active
152 *
153 *  DESCRIPTION:
154 *
155 *  This routine returns TRUE if the watchdog timer is in the ACTIVE
156 *  state, and FALSE otherwise.
157 */
158
159STATIC INLINE boolean _Watchdog_Is_active(
160  Watchdog_Control *the_watchdog
161);
162
163/*
164 *
165 *  _Watchdog_Activate
166 *
167 *  DESCRIPTION:
168 *
169 *  This routine activates THE_WATCHDOG timer which is already
170 *  on a watchdog chain.
171 */
172
173STATIC INLINE void _Watchdog_Activate(
174  Watchdog_Control *the_watchdog
175);
176
177/*
178 *
179 *  _Watchdog_Deactivate
180 *
181 *  DESCRIPTION:
182 *
183 *  This routine deactivates THE_WATCHDOG timer which will remain
184 *  on a watchdog chain.
185 */
186
187STATIC INLINE void _Watchdog_Deactivate(
188  Watchdog_Control *the_watchdog
189);
190
191/*
192 *
193 *  _Watchdog_Tickle_ticks
194 *
195 *  DESCRIPTION:
196 *
197 *  This routine is invoked at each clock tick to update the ticks
198 *  watchdog chain.
199 */
200
201STATIC INLINE void _Watchdog_Tickle_ticks( void );
202
203/*
204 *
205 *  _Watchdog_Tickle_seconds
206 *
207 *  DESCRIPTION:
208 *
209 *  This routine is invoked at each clock tick to update the seconds
210 *  watchdog chain.
211 */
212
213STATIC INLINE void _Watchdog_Tickle_seconds( void );
214
215/*
216 *
217 *  _Watchdog_Insert_ticks
218 *
219 *  DESCRIPTION:
220 *
221 *  This routine inserts THE_WATCHDOG into the ticks watchdog chain
222 *  for a time of UNITS ticks.  The INSERT_MODE indicates whether
223 *  THE_WATCHDOG is to be activated automatically or later, explicitly
224 *  by the caller.
225 */
226
227STATIC INLINE void _Watchdog_Insert_ticks(
228  Watchdog_Control      *the_watchdog,
229  Watchdog_Interval      units
230);
231
232/*
233 *
234 *  _Watchdog_Insert_seconds
235 *
236 *  DESCRIPTION:
237 *
238 *  This routine inserts THE_WATCHDOG into the seconds watchdog chain
239 *  for a time of UNITS seconds.  The INSERT_MODE indicates whether
240 *  THE_WATCHDOG is to be activated automatically or later, explicitly
241 *  by the caller.
242 */
243
244STATIC INLINE void _Watchdog_Insert_seconds(
245  Watchdog_Control      *the_watchdog,
246  Watchdog_Interval      units
247);
248
249/*
250 *
251 *  _Watchdog_Adjust_seconds
252 *
253 *  DESCRIPTION:
254 *
255 *  This routine adjusts the seconds watchdog chain in the forward
256 *  or backward DIRECTION for UNITS seconds.  This is invoked when the
257 *  current time of day is changed.
258 */
259
260STATIC INLINE void _Watchdog_Adjust_seconds(
261  Watchdog_Adjust_directions direction,
262  Watchdog_Interval          units
263);
264
265/*
266 *
267 *  _Watchdog_Adjust_ticks
268 *
269 *  DESCRIPTION:
270 *
271 *  This routine adjusts the ticks watchdog chain in the forward
272 *  or backward DIRECTION for UNITS ticks.
273 */
274
275STATIC INLINE void _Watchdog_Adjust_ticks(
276  Watchdog_Adjust_directions direction,
277  Watchdog_Interval          units
278);
279
280/*
281 *
282 *  _Watchdog_Reset
283 *
284 *  DESCRIPTION:
285 *
286 *  This routine resets THE_WATCHDOG timer to its state at INSERT
287 *  time.  This routine is valid only on interval watchdog timers
288 *  and is used to make an interval watchdog timer fire "every" so
289 *  many ticks.
290 */
291
292STATIC INLINE void _Watchdog_Reset(
293  Watchdog_Control *the_watchdog
294);
295
296/*
297 *
298 *  _Watchdog_Next
299 *
300 *  DESCRIPTION:
301 *
302 *  This routine returns a pointer to the watchdog timer following
303 *  THE_WATCHDOG on the watchdog chain.
304 */
305
306STATIC INLINE Watchdog_Control *_Watchdog_Next(
307  Watchdog_Control *the_watchdog
308);
309
310/*
311 *
312 *  _Watchdog_Previous
313 *
314 *  DESCRIPTION:
315 *
316 *  This routine returns a pointer to the watchdog timer preceding
317 *  THE_WATCHDOG on the watchdog chain.
318 */
319
320STATIC INLINE Watchdog_Control *_Watchdog_Previous(
321  Watchdog_Control *the_watchdog
322);
323
324/*
325 *
326 *  _Watchdog_First
327 *
328 *  DESCRIPTION:
329 *
330 *  This routine returns a pointer to the first watchdog timer
331 *  on the watchdog chain HEADER.
332 */
333
334STATIC INLINE Watchdog_Control *_Watchdog_First(
335  Chain_Control *header
336);
337
338/*
339 *
340 *  _Watchdog_Last
341 *
342 *  DESCRIPTION:
343 *
344 *  This routine returns a pointer to the last watchdog timer
345 *  on the watchdog chain HEADER.
346 */
347STATIC INLINE Watchdog_Control *_Watchdog_Last(
348  Chain_Control *header
349);
350
351/*
352 *  _Watchdog_Adjust
353 *
354 *  DESCRIPTION:
355 *
356 *  This routine adjusts the HEADER watchdog chain in the forward
357 *  or backward DIRECTION for UNITS ticks.
358 */
359
360void _Watchdog_Adjust (
361  Chain_Control              *header,
362  Watchdog_Adjust_directions  direction,
363  Watchdog_Interval           units
364);
365
366/*
367 *  _Watchdog_Insert
368 *
369 *  DESCRIPTION:
370 *
371 *  This routine inserts THE_WATCHDOG into the HEADER watchdog chain
372 *  for a time of UNITS.  The INSERT_MODE indicates whether
373 *  THE_WATCHDOG is to be activated automatically or later, explicitly
374 *  by the caller.
375 *
376 */
377
378void _Watchdog_Insert (
379  Chain_Control         *header,
380  Watchdog_Control      *the_watchdog
381);
382
383/*
384 *  _Watchdog_Tickle
385 *
386 *  DESCRIPTION:
387 *
388 *  This routine is invoked at appropriate intervals to update
389 *  the HEADER watchdog chain.
390 */
391
392void _Watchdog_Tickle (
393  Chain_Control *header
394);
395
396#include <rtems/score/watchdog.inl>
397
398#ifdef __cplusplus
399}
400#endif
401
402#endif
403/* end of include file */
Note: See TracBrowser for help on using the repository browser.