source: rtems/cpukit/score/include/rtems/score/watchdogimpl.h @ 9b44339c

4.115
Last change on this file since 9b44339c was 9b44339c, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 24, 2014 at 6:53:45 AM

score: Delete _Watchdog_Report()

Delete _Watchdog_Report_chain(). These two functions use printk() with
thread dispatching and interrupts disabled. So they are pretty useless
in real applications. They are not part of the application APIs. They
are only used in one test and do nothing useful in this test.

  • Property mode set to 100644
File size: 10.0 KB
Line 
1/**
2 * @file
3 *
4 * @brief Inlined Routines in the Watchdog Handler
5 *
6 * This file contains the static inline implementation of all inlined
7 * routines in the Watchdog Handler.
8 */
9
10/*
11 *  COPYRIGHT (c) 1989-2004.
12 *  On-Line Applications Research Corporation (OAR).
13 *
14 *  The license and distribution terms for this file may be
15 *  found in the file LICENSE in this distribution or at
16 *  http://www.rtems.org/license/LICENSE.
17 */
18
19#ifndef _RTEMS_SCORE_WATCHDOGIMPL_H
20#define _RTEMS_SCORE_WATCHDOGIMPL_H
21
22#include <rtems/score/watchdog.h>
23#include <rtems/score/chainimpl.h>
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
29/**
30 *  @addtogroup ScoreWatchdog
31 *  @{
32 */
33
34/**
35 *  @brief Control block used to manage intervals.
36 *
37 *  The following type defines the control block used to manage
38 *  intervals.
39 */
40#define WATCHDOG_MAXIMUM_INTERVAL ((Watchdog_Interval) 0xffffffff)
41
42/**
43 * @brief Watchdog initializer for static initialization.
44 *
45 * @see _Watchdog_Initialize().
46 */
47#define WATCHDOG_INITIALIZER( routine, id, user_data ) \
48  { \
49    { NULL, NULL }, \
50    WATCHDOG_INACTIVE, \
51    0, 0, 0, 0, \
52    ( routine ), ( id ), ( user_data ) \
53  }
54
55/**
56 *  @brief the manner in which a watchdog chain may
57 *  be adjusted by the @ref _Watchdog_Adjust routine.
58 *
59 *  The following enumerated type details the manner in which
60 *  a watchdog chain may be adjusted by the @ref _Watchdog_Adjust
61 *  routine.  The direction indicates a movement FORWARD
62 *  or BACKWARD in time.
63 */
64typedef enum {
65  /** adjust delta value forward */
66  WATCHDOG_FORWARD,
67  /** adjust delta value backward */
68  WATCHDOG_BACKWARD
69} Watchdog_Adjust_directions;
70
71/**
72 *  @brief Watchdog synchronization level.
73 *
74 *  This used for synchronization purposes
75 *  during an insert on a watchdog delta chain.
76 */
77SCORE_EXTERN volatile uint32_t    _Watchdog_Sync_level;
78
79/**
80 *  @brief Watchdog synchronization count.
81 *
82 *  This used for synchronization purposes
83 *  during an insert on a watchdog delta chain.
84 */
85SCORE_EXTERN volatile uint32_t    _Watchdog_Sync_count;
86
87/**
88 *  @brief The number of ticks since the system was booted.
89 *
90 *  This contains the number of ticks since the system was booted.
91 */
92
93SCORE_EXTERN volatile Watchdog_Interval _Watchdog_Ticks_since_boot;
94
95/**
96 *  @brief Watchdog chain which is managed at ticks.
97 *
98 *  This is the watchdog chain which is managed at ticks.
99 */
100SCORE_EXTERN Chain_Control _Watchdog_Ticks_chain;
101
102/**
103 *  @brief Watchdog chain which is managed at second boundaries.
104 *
105 *  This is the watchdog chain which is managed at second boundaries.
106 */
107SCORE_EXTERN Chain_Control _Watchdog_Seconds_chain;
108
109/**
110 *  @brief Initialize the watchdog handler.
111 *
112 *  This routine initializes the watchdog handler.  The watchdog
113 *  synchronization flag is initialized and the watchdog chains are
114 *  initialized and emptied.
115 */
116void _Watchdog_Handler_initialization( void );
117
118/**
119 *  @brief Removes @a the_watchdog from the watchdog chain.
120 *
121 *  This routine removes @a the_watchdog from the watchdog chain on which
122 *  it resides and returns the state @a the_watchdog timer was in.
123 *
124 *  @param[in] the_watchdog will be removed
125 *  @retval the state in which @a the_watchdog was in when removed
126 */
127Watchdog_States _Watchdog_Remove (
128  Watchdog_Control *the_watchdog
129);
130
131/**
132 *  @brief Adjusts the @a header watchdog chain in the forward
133 *  or backward @a direction for @a units ticks.
134 *
135 *  This routine adjusts the @a header watchdog chain in the forward
136 *  or backward @a direction for @a units ticks.
137 *
138 *  @param[in] header is the watchdog chain to adjust
139 *  @param[in] direction is the direction to adjust @a header
140 *  @param[in] units is the number of units to adjust @a header
141 */
142void _Watchdog_Adjust (
143  Chain_Control              *header,
144  Watchdog_Adjust_directions  direction,
145  Watchdog_Interval           units
146);
147
148/**
149 *  @brief Adjusts the @a header watchdog chain in the forward
150 *  @a direction for @a units_arg ticks.
151 *
152 *  This routine adjusts the @a header watchdog chain in the forward
153 *  @a direction for @a units_arg ticks.
154 *
155 *  @param[in] header is the watchdog chain to adjust
156 *  @param[in] units_arg is the number of units to adjust @a header
157 *  @param[in] to_fire is a pointer to an initialized Chain_Control to which
158 *             all watchdog instances that are to be fired will be placed.
159 *
160 *  @note This always adjusts forward.
161 */
162void _Watchdog_Adjust_to_chain(
163  Chain_Control               *header,
164  Watchdog_Interval            units_arg,
165  Chain_Control               *to_fire
166
167);
168
169/**
170 *  @brief Inserts @a the_watchdog into the @a header watchdog chain
171 *  for a time of @a units.
172 *
173 *  This routine inserts @a the_watchdog into the @a header watchdog chain
174 *  for a time of @a units.
175 *  Update the delta interval counters.
176 *
177 *  @param[in] header is @a the_watchdog list to insert @a the_watchdog on
178 *  @param[in] the_watchdog is the watchdog to insert
179 */
180void _Watchdog_Insert (
181  Chain_Control         *header,
182  Watchdog_Control      *the_watchdog
183);
184
185/**
186 *  @brief This routine is invoked at appropriate intervals to update
187 *  the @a header watchdog chain.
188 *
189 *  This routine is invoked at appropriate intervals to update
190 *  the @a header watchdog chain.
191 *  This routine decrements the delta counter in response to a tick.
192 *
193 *  @param[in] header is the watchdog chain to tickle
194 */
195void _Watchdog_Tickle (
196  Chain_Control *header
197);
198
199/**
200 * This routine initializes the specified watchdog.  The watchdog is
201 * made inactive, the watchdog id and handler routine are set to the
202 * specified values.
203 */
204
205RTEMS_INLINE_ROUTINE void _Watchdog_Initialize(
206  Watchdog_Control               *the_watchdog,
207  Watchdog_Service_routine_entry  routine,
208  Objects_Id                      id,
209  void                           *user_data
210)
211{
212  the_watchdog->state     = WATCHDOG_INACTIVE;
213  the_watchdog->routine   = routine;
214  the_watchdog->id        = id;
215  the_watchdog->user_data = user_data;
216}
217
218/**
219 * This routine returns true if the watchdog timer is in the ACTIVE
220 * state, and false otherwise.
221 */
222
223RTEMS_INLINE_ROUTINE bool _Watchdog_Is_active(
224  Watchdog_Control *the_watchdog
225)
226{
227
228  return ( the_watchdog->state == WATCHDOG_ACTIVE );
229
230}
231
232/**
233 * This routine activates THE_WATCHDOG timer which is already
234 * on a watchdog chain.
235 */
236
237RTEMS_INLINE_ROUTINE void _Watchdog_Activate(
238  Watchdog_Control *the_watchdog
239)
240{
241
242  the_watchdog->state = WATCHDOG_ACTIVE;
243
244}
245
246/**
247 * This routine deactivates THE_WATCHDOG timer which will remain
248 * on a watchdog chain.
249 */
250
251RTEMS_INLINE_ROUTINE void _Watchdog_Deactivate(
252  Watchdog_Control *the_watchdog
253)
254{
255
256  the_watchdog->state = WATCHDOG_REMOVE_IT;
257
258}
259
260/**
261 * This routine is invoked at each clock tick to update the ticks
262 * watchdog chain.
263 */
264
265RTEMS_INLINE_ROUTINE void _Watchdog_Tickle_ticks( void )
266{
267
268  _Watchdog_Tickle( &_Watchdog_Ticks_chain );
269
270}
271
272/**
273 * This routine is invoked at each clock tick to update the seconds
274 * watchdog chain.
275 */
276
277RTEMS_INLINE_ROUTINE void _Watchdog_Tickle_seconds( void )
278{
279
280  _Watchdog_Tickle( &_Watchdog_Seconds_chain );
281
282}
283
284/**
285 * This routine inserts THE_WATCHDOG into the ticks watchdog chain
286 * for a time of UNITS ticks.  The INSERT_MODE indicates whether
287 * THE_WATCHDOG is to be activated automatically or later, explicitly
288 * by the caller.
289 */
290
291RTEMS_INLINE_ROUTINE void _Watchdog_Insert_ticks(
292  Watchdog_Control      *the_watchdog,
293  Watchdog_Interval      units
294)
295{
296
297  the_watchdog->initial = units;
298
299  _Watchdog_Insert( &_Watchdog_Ticks_chain, the_watchdog );
300
301}
302
303/**
304 * This routine inserts THE_WATCHDOG into the seconds watchdog chain
305 * for a time of UNITS seconds.  The INSERT_MODE indicates whether
306 * THE_WATCHDOG is to be activated automatically or later, explicitly
307 * by the caller.
308 */
309
310RTEMS_INLINE_ROUTINE void _Watchdog_Insert_seconds(
311  Watchdog_Control      *the_watchdog,
312  Watchdog_Interval      units
313)
314{
315
316  the_watchdog->initial = units;
317
318  _Watchdog_Insert( &_Watchdog_Seconds_chain, the_watchdog );
319
320}
321
322/**
323 * This routine adjusts the seconds watchdog chain in the forward
324 * or backward DIRECTION for UNITS seconds.  This is invoked when the
325 * current time of day is changed.
326 */
327
328RTEMS_INLINE_ROUTINE void _Watchdog_Adjust_seconds(
329  Watchdog_Adjust_directions direction,
330  Watchdog_Interval          units
331)
332{
333
334  _Watchdog_Adjust( &_Watchdog_Seconds_chain, direction, units );
335
336}
337
338/**
339 * This routine adjusts the ticks watchdog chain in the forward
340 * or backward DIRECTION for UNITS ticks.
341 */
342
343RTEMS_INLINE_ROUTINE void _Watchdog_Adjust_ticks(
344  Watchdog_Adjust_directions direction,
345  Watchdog_Interval          units
346)
347{
348
349  _Watchdog_Adjust( &_Watchdog_Ticks_chain, direction, units );
350
351}
352
353/**
354 * This routine resets THE_WATCHDOG timer to its state at INSERT
355 * time.  This routine is valid only on interval watchdog timers
356 * and is used to make an interval watchdog timer fire "every" so
357 * many ticks.
358 */
359
360RTEMS_INLINE_ROUTINE void _Watchdog_Reset(
361  Watchdog_Control *the_watchdog
362)
363{
364
365  (void) _Watchdog_Remove( the_watchdog );
366
367  _Watchdog_Insert( &_Watchdog_Ticks_chain, the_watchdog );
368
369}
370
371/**
372 * This routine returns a pointer to the watchdog timer following
373 * THE_WATCHDOG on the watchdog chain.
374 */
375
376RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Next(
377  Watchdog_Control *the_watchdog
378)
379{
380
381  return ( (Watchdog_Control *) the_watchdog->Node.next );
382
383}
384
385/**
386 * This routine returns a pointer to the watchdog timer preceding
387 * THE_WATCHDOG on the watchdog chain.
388 */
389
390RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Previous(
391  Watchdog_Control *the_watchdog
392)
393{
394
395  return ( (Watchdog_Control *) the_watchdog->Node.previous );
396
397}
398
399/**
400 * This routine returns a pointer to the first watchdog timer
401 * on the watchdog chain HEADER.
402 */
403
404RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_First(
405  Chain_Control *header
406)
407{
408
409  return ( (Watchdog_Control *) _Chain_First( header ) );
410
411}
412
413/**
414 * This routine returns a pointer to the last watchdog timer
415 * on the watchdog chain HEADER.
416 */
417
418RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Last(
419  Chain_Control *header
420)
421{
422
423  return ( (Watchdog_Control *) _Chain_Last( header ) );
424
425}
426
427/** @} */
428
429#ifdef __cplusplus
430}
431#endif
432
433#endif
434/* end of include file */
Note: See TracBrowser for help on using the repository browser.