1 | /** |
---|
2 | * @file rtems/score/watchdog.inl |
---|
3 | * |
---|
4 | * This file contains the static inline implementation of all inlined |
---|
5 | * routines in the Watchdog Handler. |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2004. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.com/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #ifndef _RTEMS_SCORE_WATCHDOG_H |
---|
18 | # error "Never use <rtems/score/watchdog.inl> directly; include <rtems/score/watchdog.h> instead." |
---|
19 | #endif |
---|
20 | |
---|
21 | #ifndef _RTEMS_SCORE_WATCHDOG_INL |
---|
22 | #define _RTEMS_SCORE_WATCHDOG_INL |
---|
23 | |
---|
24 | /** |
---|
25 | * @addtogroup ScoreWatchdog |
---|
26 | * @{ |
---|
27 | */ |
---|
28 | |
---|
29 | /** |
---|
30 | * This routine initializes the specified watchdog. The watchdog is |
---|
31 | * made inactive, the watchdog id and handler routine are set to the |
---|
32 | * specified values. |
---|
33 | */ |
---|
34 | |
---|
35 | RTEMS_INLINE_ROUTINE void _Watchdog_Initialize( |
---|
36 | Watchdog_Control *the_watchdog, |
---|
37 | Watchdog_Service_routine_entry routine, |
---|
38 | Objects_Id id, |
---|
39 | void *user_data |
---|
40 | ) |
---|
41 | { |
---|
42 | the_watchdog->state = WATCHDOG_INACTIVE; |
---|
43 | the_watchdog->routine = routine; |
---|
44 | the_watchdog->id = id; |
---|
45 | the_watchdog->user_data = user_data; |
---|
46 | } |
---|
47 | |
---|
48 | /** |
---|
49 | * This routine returns true if the watchdog timer is in the ACTIVE |
---|
50 | * state, and false otherwise. |
---|
51 | */ |
---|
52 | |
---|
53 | RTEMS_INLINE_ROUTINE bool _Watchdog_Is_active( |
---|
54 | Watchdog_Control *the_watchdog |
---|
55 | ) |
---|
56 | { |
---|
57 | |
---|
58 | return ( the_watchdog->state == WATCHDOG_ACTIVE ); |
---|
59 | |
---|
60 | } |
---|
61 | |
---|
62 | /** |
---|
63 | * This routine activates THE_WATCHDOG timer which is already |
---|
64 | * on a watchdog chain. |
---|
65 | */ |
---|
66 | |
---|
67 | RTEMS_INLINE_ROUTINE void _Watchdog_Activate( |
---|
68 | Watchdog_Control *the_watchdog |
---|
69 | ) |
---|
70 | { |
---|
71 | |
---|
72 | the_watchdog->state = WATCHDOG_ACTIVE; |
---|
73 | |
---|
74 | } |
---|
75 | |
---|
76 | /** |
---|
77 | * This routine deactivates THE_WATCHDOG timer which will remain |
---|
78 | * on a watchdog chain. |
---|
79 | */ |
---|
80 | |
---|
81 | RTEMS_INLINE_ROUTINE void _Watchdog_Deactivate( |
---|
82 | Watchdog_Control *the_watchdog |
---|
83 | ) |
---|
84 | { |
---|
85 | |
---|
86 | the_watchdog->state = WATCHDOG_REMOVE_IT; |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | /** |
---|
91 | * This routine is invoked at each clock tick to update the ticks |
---|
92 | * watchdog chain. |
---|
93 | */ |
---|
94 | |
---|
95 | RTEMS_INLINE_ROUTINE void _Watchdog_Tickle_ticks( void ) |
---|
96 | { |
---|
97 | |
---|
98 | _Watchdog_Tickle( &_Watchdog_Ticks_chain ); |
---|
99 | |
---|
100 | } |
---|
101 | |
---|
102 | /** |
---|
103 | * This routine is invoked at each clock tick to update the seconds |
---|
104 | * watchdog chain. |
---|
105 | */ |
---|
106 | |
---|
107 | RTEMS_INLINE_ROUTINE void _Watchdog_Tickle_seconds( void ) |
---|
108 | { |
---|
109 | |
---|
110 | _Watchdog_Tickle( &_Watchdog_Seconds_chain ); |
---|
111 | |
---|
112 | } |
---|
113 | |
---|
114 | /** |
---|
115 | * This routine inserts THE_WATCHDOG into the ticks watchdog chain |
---|
116 | * for a time of UNITS ticks. The INSERT_MODE indicates whether |
---|
117 | * THE_WATCHDOG is to be activated automatically or later, explicitly |
---|
118 | * by the caller. |
---|
119 | */ |
---|
120 | |
---|
121 | RTEMS_INLINE_ROUTINE void _Watchdog_Insert_ticks( |
---|
122 | Watchdog_Control *the_watchdog, |
---|
123 | Watchdog_Interval units |
---|
124 | ) |
---|
125 | { |
---|
126 | |
---|
127 | the_watchdog->initial = units; |
---|
128 | |
---|
129 | _Watchdog_Insert( &_Watchdog_Ticks_chain, the_watchdog ); |
---|
130 | |
---|
131 | } |
---|
132 | |
---|
133 | /** |
---|
134 | * This routine inserts THE_WATCHDOG into the seconds watchdog chain |
---|
135 | * for a time of UNITS seconds. The INSERT_MODE indicates whether |
---|
136 | * THE_WATCHDOG is to be activated automatically or later, explicitly |
---|
137 | * by the caller. |
---|
138 | */ |
---|
139 | |
---|
140 | RTEMS_INLINE_ROUTINE void _Watchdog_Insert_seconds( |
---|
141 | Watchdog_Control *the_watchdog, |
---|
142 | Watchdog_Interval units |
---|
143 | ) |
---|
144 | { |
---|
145 | |
---|
146 | the_watchdog->initial = units; |
---|
147 | |
---|
148 | _Watchdog_Insert( &_Watchdog_Seconds_chain, the_watchdog ); |
---|
149 | |
---|
150 | } |
---|
151 | |
---|
152 | /** |
---|
153 | * This routine adjusts the seconds watchdog chain in the forward |
---|
154 | * or backward DIRECTION for UNITS seconds. This is invoked when the |
---|
155 | * current time of day is changed. |
---|
156 | */ |
---|
157 | |
---|
158 | RTEMS_INLINE_ROUTINE void _Watchdog_Adjust_seconds( |
---|
159 | Watchdog_Adjust_directions direction, |
---|
160 | Watchdog_Interval units |
---|
161 | ) |
---|
162 | { |
---|
163 | |
---|
164 | _Watchdog_Adjust( &_Watchdog_Seconds_chain, direction, units ); |
---|
165 | |
---|
166 | } |
---|
167 | |
---|
168 | /** |
---|
169 | * This routine adjusts the ticks watchdog chain in the forward |
---|
170 | * or backward DIRECTION for UNITS ticks. |
---|
171 | */ |
---|
172 | |
---|
173 | RTEMS_INLINE_ROUTINE void _Watchdog_Adjust_ticks( |
---|
174 | Watchdog_Adjust_directions direction, |
---|
175 | Watchdog_Interval units |
---|
176 | ) |
---|
177 | { |
---|
178 | |
---|
179 | _Watchdog_Adjust( &_Watchdog_Ticks_chain, direction, units ); |
---|
180 | |
---|
181 | } |
---|
182 | |
---|
183 | /** |
---|
184 | * This routine resets THE_WATCHDOG timer to its state at INSERT |
---|
185 | * time. This routine is valid only on interval watchdog timers |
---|
186 | * and is used to make an interval watchdog timer fire "every" so |
---|
187 | * many ticks. |
---|
188 | */ |
---|
189 | |
---|
190 | RTEMS_INLINE_ROUTINE void _Watchdog_Reset( |
---|
191 | Watchdog_Control *the_watchdog |
---|
192 | ) |
---|
193 | { |
---|
194 | |
---|
195 | (void) _Watchdog_Remove( the_watchdog ); |
---|
196 | |
---|
197 | _Watchdog_Insert( &_Watchdog_Ticks_chain, the_watchdog ); |
---|
198 | |
---|
199 | } |
---|
200 | |
---|
201 | /** |
---|
202 | * This routine returns a pointer to the watchdog timer following |
---|
203 | * THE_WATCHDOG on the watchdog chain. |
---|
204 | */ |
---|
205 | |
---|
206 | RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Next( |
---|
207 | Watchdog_Control *the_watchdog |
---|
208 | ) |
---|
209 | { |
---|
210 | |
---|
211 | return ( (Watchdog_Control *) the_watchdog->Node.next ); |
---|
212 | |
---|
213 | } |
---|
214 | |
---|
215 | /** |
---|
216 | * This routine returns a pointer to the watchdog timer preceding |
---|
217 | * THE_WATCHDOG on the watchdog chain. |
---|
218 | */ |
---|
219 | |
---|
220 | RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Previous( |
---|
221 | Watchdog_Control *the_watchdog |
---|
222 | ) |
---|
223 | { |
---|
224 | |
---|
225 | return ( (Watchdog_Control *) the_watchdog->Node.previous ); |
---|
226 | |
---|
227 | } |
---|
228 | |
---|
229 | /** |
---|
230 | * This routine returns a pointer to the first watchdog timer |
---|
231 | * on the watchdog chain HEADER. |
---|
232 | */ |
---|
233 | |
---|
234 | RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_First( |
---|
235 | Chain_Control *header |
---|
236 | ) |
---|
237 | { |
---|
238 | |
---|
239 | return ( (Watchdog_Control *) _Chain_First( header ) ); |
---|
240 | |
---|
241 | } |
---|
242 | |
---|
243 | /** |
---|
244 | * This routine returns a pointer to the last watchdog timer |
---|
245 | * on the watchdog chain HEADER. |
---|
246 | */ |
---|
247 | |
---|
248 | RTEMS_INLINE_ROUTINE Watchdog_Control *_Watchdog_Last( |
---|
249 | Chain_Control *header |
---|
250 | ) |
---|
251 | { |
---|
252 | |
---|
253 | return ( (Watchdog_Control *) _Chain_Last( header ) ); |
---|
254 | |
---|
255 | } |
---|
256 | |
---|
257 | /**@}*/ |
---|
258 | |
---|
259 | #endif |
---|
260 | /* end of include file */ |
---|