1 | /* timer.h |
---|
2 | * |
---|
3 | * This include file contains all the constants, structures, and |
---|
4 | * prototypes associated with the Timer Manager. This manager provides |
---|
5 | * facilities to configure, initiate, cancel, and delete timers which will |
---|
6 | * fire at specified intervals of time. |
---|
7 | * |
---|
8 | * Directives provided are: |
---|
9 | * |
---|
10 | * + create a timer |
---|
11 | * + get an ID of a timer |
---|
12 | * + delete a timer |
---|
13 | * + set a timer to fire after a number of ticks have passed |
---|
14 | * + set a timer to fire when a specified date and time has been reached |
---|
15 | * + reset a timer |
---|
16 | * + cancel a time |
---|
17 | * |
---|
18 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994. |
---|
19 | * On-Line Applications Research Corporation (OAR). |
---|
20 | * All rights assigned to U.S. Government, 1994. |
---|
21 | * |
---|
22 | * This material may be reproduced by or for the U.S. Government pursuant |
---|
23 | * to the copyright license under the clause at DFARS 252.227-7013. This |
---|
24 | * notice must appear in all copies of this file and its derivatives. |
---|
25 | * |
---|
26 | * $Id$ |
---|
27 | */ |
---|
28 | |
---|
29 | #ifndef __RTEMS_TIMER_h |
---|
30 | #define __RTEMS_TIMER_h |
---|
31 | |
---|
32 | #ifdef __cplusplus |
---|
33 | extern "C" { |
---|
34 | #endif |
---|
35 | |
---|
36 | #include <rtems/object.h> |
---|
37 | #include <rtems/tod.h> |
---|
38 | #include <rtems/watchdog.h> |
---|
39 | |
---|
40 | /* |
---|
41 | * The following enumerated type details the classes to which a timer |
---|
42 | * may belong. |
---|
43 | */ |
---|
44 | |
---|
45 | typedef enum { |
---|
46 | TIMER_INTERVAL, |
---|
47 | TIMER_TIME_OF_DAY, |
---|
48 | TIMER_DORMANT |
---|
49 | } Timer_Classes; |
---|
50 | |
---|
51 | /* |
---|
52 | * The following defines the type of a Timer Service Routine. |
---|
53 | */ |
---|
54 | |
---|
55 | typedef rtems_timer_service_routine_entry Timer_Service; |
---|
56 | |
---|
57 | /* |
---|
58 | * The following defines the information control block used to manage |
---|
59 | * this class of objects. |
---|
60 | */ |
---|
61 | |
---|
62 | EXTERN Objects_Information _Timer_Information; |
---|
63 | |
---|
64 | /* |
---|
65 | * The following records define the control block used to manage |
---|
66 | * each timer. |
---|
67 | */ |
---|
68 | |
---|
69 | typedef struct { |
---|
70 | Objects_Control Object; |
---|
71 | Watchdog_Control Ticker; |
---|
72 | Timer_Classes the_class; |
---|
73 | } Timer_Control; |
---|
74 | |
---|
75 | /* |
---|
76 | * _Timer_Manager_initialization |
---|
77 | * |
---|
78 | * DESCRIPTION: |
---|
79 | * |
---|
80 | * This routine performs the initialization necessary for this manager. |
---|
81 | */ |
---|
82 | |
---|
83 | void _Timer_Manager_initialization( |
---|
84 | unsigned32 maximum_timers |
---|
85 | ); |
---|
86 | |
---|
87 | /* |
---|
88 | * rtems_timer_create |
---|
89 | * |
---|
90 | * DESCRIPTION: |
---|
91 | * |
---|
92 | * This routine implements the rtems_timer_create directive. The |
---|
93 | * timer will have the name name. It returns the id of the |
---|
94 | * created timer in ID. |
---|
95 | */ |
---|
96 | |
---|
97 | rtems_status_code rtems_timer_create( |
---|
98 | Objects_Name name, |
---|
99 | Objects_Id *id |
---|
100 | ); |
---|
101 | |
---|
102 | /* |
---|
103 | * rtems_timer_ident |
---|
104 | * |
---|
105 | * DESCRIPTION: |
---|
106 | * |
---|
107 | * This routine implements the rtems_timer_ident directive. |
---|
108 | * This directive returns the timer ID associated with name. |
---|
109 | * If more than one timer is named name, then the timer |
---|
110 | * to which the ID belongs is arbitrary. |
---|
111 | */ |
---|
112 | |
---|
113 | rtems_status_code rtems_timer_ident( |
---|
114 | Objects_Name name, |
---|
115 | Objects_Id *id |
---|
116 | ); |
---|
117 | |
---|
118 | /* |
---|
119 | * rtems_timer_cancel |
---|
120 | * |
---|
121 | * DESCRIPTION: |
---|
122 | * |
---|
123 | * This routine implements the rtems_timer_cancel directive. It is used |
---|
124 | * to stop the timer associated with ID from firing. |
---|
125 | */ |
---|
126 | |
---|
127 | rtems_status_code rtems_timer_cancel( |
---|
128 | Objects_Id id |
---|
129 | ); |
---|
130 | |
---|
131 | /* |
---|
132 | * rtems_timer_delete |
---|
133 | * |
---|
134 | * DESCRIPTION: |
---|
135 | * |
---|
136 | * This routine implements the rtems_timer_delete directive. The |
---|
137 | * timer indicated by ID is deleted. |
---|
138 | */ |
---|
139 | |
---|
140 | rtems_status_code rtems_timer_delete( |
---|
141 | Objects_Id id |
---|
142 | ); |
---|
143 | |
---|
144 | /* |
---|
145 | * rtems_timer_fire_after |
---|
146 | * |
---|
147 | * DESCRIPTION: |
---|
148 | * |
---|
149 | * This routine implements the rtems_timer_fire_after directive. It |
---|
150 | * initiates the timer associated with ID to fire in ticks clock |
---|
151 | * ticks. When the timer fires, the routine will be invoked. |
---|
152 | */ |
---|
153 | |
---|
154 | rtems_status_code rtems_timer_fire_after( |
---|
155 | Objects_Id id, |
---|
156 | rtems_interval ticks, |
---|
157 | Timer_Service routine, |
---|
158 | void *user_data |
---|
159 | ); |
---|
160 | |
---|
161 | /* |
---|
162 | * rtems_timer_fire_when |
---|
163 | * |
---|
164 | * DESCRIPTION: |
---|
165 | * |
---|
166 | * This routine implements the rtems_timer_fire_when directive. It |
---|
167 | * initiates the timer associated with ID to fire at wall_time |
---|
168 | * When the timer fires, the routine will be invoked. |
---|
169 | */ |
---|
170 | |
---|
171 | rtems_status_code rtems_timer_fire_when( |
---|
172 | Objects_Id id, |
---|
173 | rtems_time_of_day *wall_time, |
---|
174 | Timer_Service routine, |
---|
175 | void *user_data |
---|
176 | ); |
---|
177 | |
---|
178 | /* |
---|
179 | * rtems_timer_reset |
---|
180 | * |
---|
181 | * DESCRIPTION: |
---|
182 | * |
---|
183 | * This routine implements the rtems_timer_reset directive. It is used |
---|
184 | * to reinitialize the interval timer associated with ID just as if |
---|
185 | * rtems_timer_fire_after were re-invoked with the same arguments that |
---|
186 | * were used to initiate this timer. |
---|
187 | */ |
---|
188 | |
---|
189 | rtems_status_code rtems_timer_reset( |
---|
190 | Objects_Id id |
---|
191 | ); |
---|
192 | |
---|
193 | /* |
---|
194 | * _Timer_Allocate |
---|
195 | * |
---|
196 | * DESCRIPTION: |
---|
197 | * |
---|
198 | * This function allocates a timer control block from |
---|
199 | * the inactive chain of free timer control blocks. |
---|
200 | */ |
---|
201 | |
---|
202 | STATIC INLINE Timer_Control *_Timer_Allocate( void ); |
---|
203 | |
---|
204 | /* |
---|
205 | * _Timer_Free |
---|
206 | * |
---|
207 | * DESCRIPTION: |
---|
208 | * |
---|
209 | * This routine frees a timer control block to the |
---|
210 | * inactive chain of free timer control blocks. |
---|
211 | */ |
---|
212 | |
---|
213 | STATIC INLINE void _Timer_Free ( |
---|
214 | Timer_Control *the_timer |
---|
215 | ); |
---|
216 | |
---|
217 | /* |
---|
218 | * _Timer_Get |
---|
219 | * |
---|
220 | * DESCRIPTION: |
---|
221 | * |
---|
222 | * This function maps timer IDs to timer control blocks. |
---|
223 | * If ID corresponds to a local timer, then it returns |
---|
224 | * the timer control pointer which maps to ID and location |
---|
225 | * is set to OBJECTS_LOCAL. Otherwise, location is set |
---|
226 | * to OBJECTS_ERROR and the returned value is undefined. |
---|
227 | */ |
---|
228 | |
---|
229 | STATIC INLINE Timer_Control *_Timer_Get ( |
---|
230 | Objects_Id id, |
---|
231 | Objects_Locations *location |
---|
232 | ); |
---|
233 | |
---|
234 | /* |
---|
235 | * _Timer_Is_interval_class |
---|
236 | * |
---|
237 | * DESCRIPTION: |
---|
238 | * |
---|
239 | * This function returns TRUE if the class is that of an INTERVAL |
---|
240 | * timer, and FALSE otherwise. |
---|
241 | */ |
---|
242 | |
---|
243 | STATIC INLINE boolean _Timer_Is_interval_class ( |
---|
244 | Timer_Classes the_class |
---|
245 | ); |
---|
246 | |
---|
247 | /* |
---|
248 | * _Timer_Is_time_of_day_class |
---|
249 | * |
---|
250 | * DESCRIPTION: |
---|
251 | * |
---|
252 | * This function returns TRUE if the class is that of an INTERVAL |
---|
253 | * timer, and FALSE otherwise. |
---|
254 | */ |
---|
255 | |
---|
256 | STATIC INLINE boolean _Timer_Is_timer_of_day_class ( |
---|
257 | Timer_Classes the_class |
---|
258 | ); |
---|
259 | |
---|
260 | /* |
---|
261 | * _Timer_Is_dormant_class |
---|
262 | * |
---|
263 | * DESCRIPTION: |
---|
264 | * |
---|
265 | * This function returns TRUE if the class is that of a DORMANT |
---|
266 | * timer, and FALSE otherwise. |
---|
267 | */ |
---|
268 | |
---|
269 | STATIC INLINE boolean _Timer_Is_dormant_class ( |
---|
270 | Timer_Classes the_class |
---|
271 | ); |
---|
272 | |
---|
273 | /* |
---|
274 | * _Timer_Is_null |
---|
275 | * |
---|
276 | * DESCRIPTION: |
---|
277 | * |
---|
278 | * This function returns TRUE if the_timer is NULL and FALSE otherwise. |
---|
279 | */ |
---|
280 | |
---|
281 | STATIC INLINE boolean _Timer_Is_null ( |
---|
282 | Timer_Control *the_timer |
---|
283 | ); |
---|
284 | |
---|
285 | #include <rtems/timer.inl> |
---|
286 | |
---|
287 | #ifdef __cplusplus |
---|
288 | } |
---|
289 | #endif |
---|
290 | |
---|
291 | #endif |
---|
292 | /* end of include file */ |
---|