1 | /** |
---|
2 | * @file watchdog.h |
---|
3 | * |
---|
4 | * This include file contains all the constants and structures associated |
---|
5 | * with watchdog timers. This Handler provides mechanisms which can be |
---|
6 | * used to initialize and manipulate watchdog timers. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 1989-2004. |
---|
11 | * On-Line Applications Research Corporation (OAR). |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.com/license/LICENSE. |
---|
16 | * |
---|
17 | * $Id$ |
---|
18 | */ |
---|
19 | |
---|
20 | #ifndef __WATCHDOG_h |
---|
21 | #define __WATCHDOG_h |
---|
22 | |
---|
23 | /** |
---|
24 | * @defgroup ScoreWatchdog Watchdog Handler |
---|
25 | * |
---|
26 | * This group contains functionality which XXX |
---|
27 | */ |
---|
28 | /**@{*/ |
---|
29 | |
---|
30 | #ifdef __cplusplus |
---|
31 | extern "C" { |
---|
32 | #endif |
---|
33 | |
---|
34 | #include <rtems/score/object.h> |
---|
35 | |
---|
36 | /** @brief Maximum Interval Length |
---|
37 | * |
---|
38 | * The following type defines the control block used to manage |
---|
39 | * intervals. |
---|
40 | */ |
---|
41 | #define WATCHDOG_MAXIMUM_INTERVAL ((Watchdog_Interval) 0xffffffff) |
---|
42 | |
---|
43 | /** @brief Watchdog Interval Type |
---|
44 | * |
---|
45 | * This type is used to specify the length of intervals. |
---|
46 | */ |
---|
47 | typedef uint32_t Watchdog_Interval; |
---|
48 | |
---|
49 | /** @brief Watchdog Service Routine Return Type |
---|
50 | * |
---|
51 | * This type defines the return type from a Watchdog Service Routine. |
---|
52 | */ |
---|
53 | typedef void Watchdog_Service_routine; |
---|
54 | |
---|
55 | /** @brief Watchdog Service Routine Pointer Type |
---|
56 | * |
---|
57 | * This type define a pointer to a watchdog service routine. |
---|
58 | */ |
---|
59 | typedef Watchdog_Service_routine ( *Watchdog_Service_routine_entry )( |
---|
60 | Objects_Id, |
---|
61 | void * |
---|
62 | ); |
---|
63 | |
---|
64 | /** @brief No timeout constant |
---|
65 | * |
---|
66 | * This is the constant for indefinite wait. It is actually an |
---|
67 | * illegal interval. |
---|
68 | */ |
---|
69 | #define WATCHDOG_NO_TIMEOUT 0 |
---|
70 | |
---|
71 | /** @brief Watchdog States Type |
---|
72 | * |
---|
73 | * This enumerated type is the set of the states in which a |
---|
74 | * watchdog timer may be at any given time. |
---|
75 | */ |
---|
76 | |
---|
77 | typedef enum { |
---|
78 | /** This is the state when the watchdog is off all chains */ |
---|
79 | WATCHDOG_INACTIVE, |
---|
80 | /** This is the state when the watchdog is off all chains, but we are |
---|
81 | * currently searching for the insertion point. |
---|
82 | */ |
---|
83 | WATCHDOG_BEING_INSERTED, |
---|
84 | /** This is the state when the watchdog is on a chain, and allowed to fire. */ |
---|
85 | WATCHDOG_ACTIVE, |
---|
86 | /** This is the state when the watchdog is on a chain, but we should |
---|
87 | * remove without firing if it expires. |
---|
88 | */ |
---|
89 | WATCHDOG_REMOVE_IT |
---|
90 | } Watchdog_States; |
---|
91 | |
---|
92 | /** @brief Watchdog Adjustment Directions Type |
---|
93 | * |
---|
94 | * The following enumerated type details the manner in which |
---|
95 | * a watchdog chain may be adjusted by the @ref _Watchdog_Adjust |
---|
96 | * routine. The direction indicates a movement FORWARD |
---|
97 | * or BACKWARD in time. |
---|
98 | */ |
---|
99 | typedef enum { |
---|
100 | /** adjust delta value forward */ |
---|
101 | WATCHDOG_FORWARD, |
---|
102 | /** adjust delta value backward */ |
---|
103 | WATCHDOG_BACKWARD |
---|
104 | } Watchdog_Adjust_directions; |
---|
105 | |
---|
106 | /** @brief Watchdog Control Structure |
---|
107 | * |
---|
108 | * The following record defines the control block used |
---|
109 | * to manage each watchdog timer. |
---|
110 | */ |
---|
111 | typedef struct { |
---|
112 | Chain_Node Node; |
---|
113 | Watchdog_States state; |
---|
114 | Watchdog_Interval initial; |
---|
115 | Watchdog_Interval delta_interval; |
---|
116 | Watchdog_Interval start_time; |
---|
117 | Watchdog_Interval stop_time; |
---|
118 | Watchdog_Service_routine_entry routine; |
---|
119 | Objects_Id id; |
---|
120 | void *user_data; |
---|
121 | } Watchdog_Control; |
---|
122 | |
---|
123 | /** @brief Watchdog Synchronization Level |
---|
124 | * |
---|
125 | * This used for synchronization purposes |
---|
126 | * during an insert on a watchdog delta chain. |
---|
127 | */ |
---|
128 | SCORE_EXTERN volatile uint32_t _Watchdog_Sync_level; |
---|
129 | |
---|
130 | /** @brief Watchdog Synchronization Count |
---|
131 | * |
---|
132 | * This used for synchronization purposes |
---|
133 | * during an insert on a watchdog delta chain. |
---|
134 | */ |
---|
135 | SCORE_EXTERN volatile uint32_t _Watchdog_Sync_count; |
---|
136 | |
---|
137 | /** @brief Ticks Since System Boot |
---|
138 | * |
---|
139 | * This contains the number of ticks since the system was booted. |
---|
140 | */ |
---|
141 | |
---|
142 | SCORE_EXTERN volatile Watchdog_Interval _Watchdog_Ticks_since_boot; |
---|
143 | |
---|
144 | /** @brief Per Ticks Watchdog List |
---|
145 | * |
---|
146 | * This is the watchdog chain which is managed at ticks. |
---|
147 | */ |
---|
148 | SCORE_EXTERN Chain_Control _Watchdog_Ticks_chain; |
---|
149 | |
---|
150 | /** @brief Per Seconds Watchdog List |
---|
151 | * |
---|
152 | * This is the watchdog chain which is managed at second boundaries. |
---|
153 | */ |
---|
154 | SCORE_EXTERN Chain_Control _Watchdog_Seconds_chain; |
---|
155 | |
---|
156 | /** @brief Watchdog Handler Initialization |
---|
157 | * |
---|
158 | * This routine initializes the watchdog handler. The watchdog |
---|
159 | * synchronization flag is initialized and the watchdog chains are |
---|
160 | * initialized and emptied. |
---|
161 | */ |
---|
162 | void _Watchdog_Handler_initialization( void ); |
---|
163 | |
---|
164 | /** @brief Remove Watchdog from List |
---|
165 | * |
---|
166 | * This routine removes @a the_watchdog from the watchdog chain on which |
---|
167 | * it resides and returns the state @a the_watchdog timer was in. |
---|
168 | * |
---|
169 | * @param the_watchdog (in) will be removed |
---|
170 | * @return the state in which @a the_watchdog was in when removed |
---|
171 | */ |
---|
172 | Watchdog_States _Watchdog_Remove ( |
---|
173 | Watchdog_Control *the_watchdog |
---|
174 | ); |
---|
175 | |
---|
176 | /** @brief Watchdog Adjust |
---|
177 | * |
---|
178 | * This routine adjusts the @a header watchdog chain in the forward |
---|
179 | * or backward @a direction for @a units ticks. |
---|
180 | * |
---|
181 | * @param header (in) is the watchdog chain to adjust |
---|
182 | * @param direction (in) is the direction to adjust @a header |
---|
183 | * @param units (in) is the number of units to adjust @a header |
---|
184 | */ |
---|
185 | void _Watchdog_Adjust ( |
---|
186 | Chain_Control *header, |
---|
187 | Watchdog_Adjust_directions direction, |
---|
188 | Watchdog_Interval units |
---|
189 | ); |
---|
190 | |
---|
191 | /** @brief Watchdog Insert |
---|
192 | * |
---|
193 | * This routine inserts @a the_watchdog into the @a header watchdog chain |
---|
194 | * for a time of @a units. |
---|
195 | * |
---|
196 | * @param header (in) is @a the_watchdog list to insert @a the_watchdog on |
---|
197 | * @param the_watchdog (in) is the watchdog to insert |
---|
198 | */ |
---|
199 | void _Watchdog_Insert ( |
---|
200 | Chain_Control *header, |
---|
201 | Watchdog_Control *the_watchdog |
---|
202 | ); |
---|
203 | |
---|
204 | /** @brief Watchdog Tickle |
---|
205 | * |
---|
206 | * This routine is invoked at appropriate intervals to update |
---|
207 | * the @a header watchdog chain. |
---|
208 | * |
---|
209 | * @param header (in) is the watchdog chain to tickle |
---|
210 | */ |
---|
211 | |
---|
212 | void _Watchdog_Tickle ( |
---|
213 | Chain_Control *header |
---|
214 | ); |
---|
215 | |
---|
216 | #ifndef __RTEMS_APPLICATION__ |
---|
217 | #include <rtems/score/watchdog.inl> |
---|
218 | #endif |
---|
219 | |
---|
220 | #ifdef __cplusplus |
---|
221 | } |
---|
222 | #endif |
---|
223 | |
---|
224 | /**@}*/ |
---|
225 | |
---|
226 | #endif |
---|
227 | /* end of include file */ |
---|