source: rtems/cpukit/score/include/rtems/score/watchdog.h @ fbbe5fd

4.104.114.84.95
Last change on this file since fbbe5fd was fbbe5fd, checked in by Joel Sherrill <joel.sherrill@…>, on 07/18/03 at 14:47:55

2003-07-18 Till Straumann <strauman@…>

PR 430/rtems

  • include/rtems/score/watchdog.h: _Watchdog_Ticks_since_boot should be a VOLATILE variable.
  • src/watchdoginsert.c: 'restart' algorithm needs to enforce reloading the list head in case a TICK interrupt during ISR_Flash() modified the list. This is achieved by a proper VOLATILE cast. Also _Watchdog_Sync_count++ should be protected by _ISR_Disable (prevent corruption in case ISR calls watchdoginsert)
  • src/watchdogadjust.c: ISR protection added.
  • src/watchdogtickle.c: ISR protection added. NOTE: PowerPC BSPs using the new exception processing MUST BE UPDATED to maintain _ISR_Nest_level. See also PR288 which provides fixes for the affected BSPs distributed with RTEMS.
  • Property mode set to 100644
File size: 4.5 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-1999.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.OARcorp.com/rtems/license.html.
13 *
14 *  $Id$
15 */
16
17#ifndef __WATCHDOG_h
18#define __WATCHDOG_h
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24#include <rtems/score/object.h>
25
26/*
27 *  The following type defines the control block used to manage
28 *  intervals.
29 */
30
31#define WATCHDOG_MAXIMUM_INTERVAL ((Watchdog_Interval) 0xffffffff)
32
33typedef unsigned32 Watchdog_Interval;
34
35/*
36 *  The following types define a pointer to a watchdog service routine.
37 */
38
39typedef void Watchdog_Service_routine;
40
41typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )(
42                 Objects_Id,
43                 void *
44             );
45
46/*
47 *  Constant for indefinite wait.  (actually an illegal interval)
48 */
49
50#define WATCHDOG_NO_TIMEOUT  0
51
52/*
53 *  The following enumerated type lists the states in which a
54 *  watchdog timer may be at any given time.
55 */
56
57typedef enum {
58  WATCHDOG_INACTIVE,       /* off all chains */
59  WATCHDOG_BEING_INSERTED, /* off all chains, searching for insertion point */
60  WATCHDOG_ACTIVE,         /* on chain, allowed to fire */
61  WATCHDOG_REMOVE_IT       /* on chain, remove without firing if expires */
62} Watchdog_States;
63
64/*
65 *  The following enumerated type details the manner in which
66 *  a watchdog chain may be adjusted by the Watchdog_Adjust
67 *  routine.  The direction indicates a movement FORWARD
68 *  or BACKWARD in time.
69 */
70
71typedef enum {
72  WATCHDOG_FORWARD,      /* adjust delta value forward */
73  WATCHDOG_BACKWARD      /* adjust delta value backward */
74} Watchdog_Adjust_directions;
75
76/*
77 *  The following record defines the control block used
78 *  to manage each watchdog timer.
79 */
80
81typedef struct {
82  Chain_Node                      Node;
83  Watchdog_States                 state;
84  Watchdog_Interval               initial;
85  Watchdog_Interval               delta_interval;
86  Watchdog_Interval               start_time;
87  Watchdog_Interval               stop_time;
88  Watchdog_Service_routine_entry  routine;
89  Objects_Id                      id;
90  void                           *user_data;
91}   Watchdog_Control;
92
93/*
94 *  The following are used for synchronization purposes
95 *  during an insert on a watchdog delta chain.
96 */
97
98SCORE_EXTERN volatile unsigned32  _Watchdog_Sync_level;
99SCORE_EXTERN volatile unsigned32  _Watchdog_Sync_count;
100
101/*
102 *  The following contains the number of ticks since the
103 *  system was booted.
104 */
105
106SCORE_EXTERN volatile Watchdog_Interval _Watchdog_Ticks_since_boot;
107
108/*
109 *  The following defines the watchdog chains which are managed
110 *  on ticks and second boundaries.
111 */
112
113SCORE_EXTERN Chain_Control _Watchdog_Ticks_chain;
114SCORE_EXTERN Chain_Control _Watchdog_Seconds_chain;
115
116/*
117 *  _Watchdog_Handler_initialization
118 *
119 *  DESCRIPTION:
120 *
121 *  This routine initializes the watchdog handler.  The watchdog
122 *  synchronization flag is initialized and the watchdog chains are
123 *  initialized and emptied.
124 */
125
126void _Watchdog_Handler_initialization( void );
127
128/*
129 *  _Watchdog_Remove
130 *
131 *  DESCRIPTION:
132 *
133 *  This routine removes THE_WATCHDOG from the watchdog chain on which
134 *  it resides and returns the state THE_WATCHDOG timer was in.
135 */
136
137Watchdog_States _Watchdog_Remove (
138  Watchdog_Control *the_watchdog
139);
140
141/*
142 *  _Watchdog_Adjust
143 *
144 *  DESCRIPTION:
145 *
146 *  This routine adjusts the HEADER watchdog chain in the forward
147 *  or backward DIRECTION for UNITS ticks.
148 */
149
150void _Watchdog_Adjust (
151  Chain_Control              *header,
152  Watchdog_Adjust_directions  direction,
153  Watchdog_Interval           units
154);
155
156/*
157 *  _Watchdog_Insert
158 *
159 *  DESCRIPTION:
160 *
161 *  This routine inserts THE_WATCHDOG into the HEADER watchdog chain
162 *  for a time of UNITS.  The INSERT_MODE indicates whether
163 *  THE_WATCHDOG is to be activated automatically or later, explicitly
164 *  by the caller.
165 *
166 */
167
168void _Watchdog_Insert (
169  Chain_Control         *header,
170  Watchdog_Control      *the_watchdog
171);
172
173/*
174 *  _Watchdog_Tickle
175 *
176 *  DESCRIPTION:
177 *
178 *  This routine is invoked at appropriate intervals to update
179 *  the HEADER watchdog chain.
180 */
181
182void _Watchdog_Tickle (
183  Chain_Control *header
184);
185
186#ifndef __RTEMS_APPLICATION__
187#include <rtems/score/watchdog.inl>
188#endif
189
190#ifdef __cplusplus
191}
192#endif
193
194#endif
195/* end of include file */
Note: See TracBrowser for help on using the repository browser.