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-1998. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * Copyright assigned to U.S. Government, 1994. |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.OARcorp.com/rtems/license.html. |
---|
14 | * |
---|
15 | * $Id$ |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef __WATCHDOG_h |
---|
19 | #define __WATCHDOG_h |
---|
20 | |
---|
21 | #ifdef __cplusplus |
---|
22 | extern "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 | |
---|
32 | typedef unsigned32 Watchdog_Interval; |
---|
33 | |
---|
34 | /* |
---|
35 | * The following types define a pointer to a watchdog service routine. |
---|
36 | */ |
---|
37 | |
---|
38 | typedef void Watchdog_Service_routine; |
---|
39 | |
---|
40 | typedef 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 | |
---|
56 | typedef 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 | |
---|
70 | typedef 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 | |
---|
80 | typedef struct { |
---|
81 | Chain_Node Node; |
---|
82 | Watchdog_States state; |
---|
83 | Watchdog_Interval initial; |
---|
84 | Watchdog_Interval delta_interval; |
---|
85 | Watchdog_Interval start_time; |
---|
86 | Watchdog_Interval stop_time; |
---|
87 | Watchdog_Service_routine_entry routine; |
---|
88 | Objects_Id id; |
---|
89 | void *user_data; |
---|
90 | } Watchdog_Control; |
---|
91 | |
---|
92 | /* |
---|
93 | * The following are used for synchronization purposes |
---|
94 | * during an insert on a watchdog delta chain. |
---|
95 | */ |
---|
96 | |
---|
97 | SCORE_EXTERN volatile unsigned32 _Watchdog_Sync_level; |
---|
98 | SCORE_EXTERN volatile unsigned32 _Watchdog_Sync_count; |
---|
99 | |
---|
100 | /* |
---|
101 | * The following contains the number of ticks since the |
---|
102 | * system was booted. |
---|
103 | */ |
---|
104 | |
---|
105 | SCORE_EXTERN Watchdog_Interval _Watchdog_Ticks_since_boot; |
---|
106 | |
---|
107 | /* |
---|
108 | * The following defines the watchdog chains which are managed |
---|
109 | * on ticks and second boundaries. |
---|
110 | */ |
---|
111 | |
---|
112 | SCORE_EXTERN Chain_Control _Watchdog_Ticks_chain; |
---|
113 | SCORE_EXTERN Chain_Control _Watchdog_Seconds_chain; |
---|
114 | |
---|
115 | /* |
---|
116 | * _Watchdog_Handler_initialization |
---|
117 | * |
---|
118 | * DESCRIPTION: |
---|
119 | * |
---|
120 | * This routine initializes the watchdog handler. The watchdog |
---|
121 | * synchronization flag is initialized and the watchdog chains are |
---|
122 | * initialized and emptied. |
---|
123 | */ |
---|
124 | |
---|
125 | void _Watchdog_Handler_initialization( void ); |
---|
126 | |
---|
127 | /* |
---|
128 | * _Watchdog_Remove |
---|
129 | * |
---|
130 | * DESCRIPTION: |
---|
131 | * |
---|
132 | * This routine removes THE_WATCHDOG from the watchdog chain on which |
---|
133 | * it resides and returns the state THE_WATCHDOG timer was in. |
---|
134 | */ |
---|
135 | |
---|
136 | Watchdog_States _Watchdog_Remove ( |
---|
137 | Watchdog_Control *the_watchdog |
---|
138 | ); |
---|
139 | |
---|
140 | /* |
---|
141 | * _Watchdog_Adjust |
---|
142 | * |
---|
143 | * DESCRIPTION: |
---|
144 | * |
---|
145 | * This routine adjusts the HEADER watchdog chain in the forward |
---|
146 | * or backward DIRECTION for UNITS ticks. |
---|
147 | */ |
---|
148 | |
---|
149 | void _Watchdog_Adjust ( |
---|
150 | Chain_Control *header, |
---|
151 | Watchdog_Adjust_directions direction, |
---|
152 | Watchdog_Interval units |
---|
153 | ); |
---|
154 | |
---|
155 | /* |
---|
156 | * _Watchdog_Insert |
---|
157 | * |
---|
158 | * DESCRIPTION: |
---|
159 | * |
---|
160 | * This routine inserts THE_WATCHDOG into the HEADER watchdog chain |
---|
161 | * for a time of UNITS. The INSERT_MODE indicates whether |
---|
162 | * THE_WATCHDOG is to be activated automatically or later, explicitly |
---|
163 | * by the caller. |
---|
164 | * |
---|
165 | */ |
---|
166 | |
---|
167 | void _Watchdog_Insert ( |
---|
168 | Chain_Control *header, |
---|
169 | Watchdog_Control *the_watchdog |
---|
170 | ); |
---|
171 | |
---|
172 | /* |
---|
173 | * _Watchdog_Tickle |
---|
174 | * |
---|
175 | * DESCRIPTION: |
---|
176 | * |
---|
177 | * This routine is invoked at appropriate intervals to update |
---|
178 | * the HEADER watchdog chain. |
---|
179 | */ |
---|
180 | |
---|
181 | void _Watchdog_Tickle ( |
---|
182 | Chain_Control *header |
---|
183 | ); |
---|
184 | |
---|
185 | #ifndef __RTEMS_APPLICATION__ |
---|
186 | #include <rtems/score/watchdog.inl> |
---|
187 | #endif |
---|
188 | |
---|
189 | #ifdef __cplusplus |
---|
190 | } |
---|
191 | #endif |
---|
192 | |
---|
193 | #endif |
---|
194 | /* end of include file */ |
---|