1 | /* tasks.h |
---|
2 | * |
---|
3 | * This include file contains all constants and structures associated |
---|
4 | * with RTEMS tasks. This manager provides a comprehensive set of directives |
---|
5 | * to create, delete, and administer tasks. |
---|
6 | * |
---|
7 | * Directives provided are: |
---|
8 | * |
---|
9 | * + create a task |
---|
10 | * + get an ID of a task |
---|
11 | * + start a task |
---|
12 | * + restart a task |
---|
13 | * + delete a task |
---|
14 | * + suspend a task |
---|
15 | * + resume a task |
---|
16 | * + set a task's priority |
---|
17 | * + change the current task's mode |
---|
18 | * + get a task notepad entry |
---|
19 | * + set a task notepad entry |
---|
20 | * + wake up after interval |
---|
21 | * + wake up when specified |
---|
22 | * |
---|
23 | * COPYRIGHT (c) 1989-1999. |
---|
24 | * On-Line Applications Research Corporation (OAR). |
---|
25 | * |
---|
26 | * The license and distribution terms for this file may be |
---|
27 | * found in the file LICENSE in this distribution or at |
---|
28 | * http://www.OARcorp.com/rtems/license.html. |
---|
29 | * |
---|
30 | * $Id$ |
---|
31 | */ |
---|
32 | |
---|
33 | #ifndef __RTEMS_RTEMS_TASKS_h |
---|
34 | #define __RTEMS_RTEMS_TASKS_h |
---|
35 | |
---|
36 | #ifdef __cplusplus |
---|
37 | extern "C" { |
---|
38 | #endif |
---|
39 | |
---|
40 | #include <rtems/score/object.h> |
---|
41 | #include <rtems/score/states.h> |
---|
42 | #include <rtems/score/thread.h> |
---|
43 | #include <rtems/rtems/types.h> |
---|
44 | #include <rtems/rtems/eventset.h> |
---|
45 | #include <rtems/rtems/asr.h> |
---|
46 | #include <rtems/rtems/attr.h> |
---|
47 | #include <rtems/rtems/status.h> |
---|
48 | |
---|
49 | /* |
---|
50 | * Constant to be used as the ID of current task |
---|
51 | */ |
---|
52 | |
---|
53 | #define RTEMS_SELF OBJECTS_ID_OF_SELF |
---|
54 | |
---|
55 | /* |
---|
56 | * This constant is passed to the rtems_task_wake_after directive as the |
---|
57 | * interval when a task wishes to yield the CPU. |
---|
58 | */ |
---|
59 | |
---|
60 | #define RTEMS_YIELD_PROCESSOR WATCHDOG_NO_TIMEOUT |
---|
61 | |
---|
62 | /* |
---|
63 | * Define the type for an RTEMS API task priority. |
---|
64 | */ |
---|
65 | |
---|
66 | typedef Priority_Control rtems_task_priority; |
---|
67 | |
---|
68 | #define RTEMS_NO_PRIORITY RTEMS_CURRENT_PRIORITY |
---|
69 | |
---|
70 | #define RTEMS_MINIMUM_PRIORITY (PRIORITY_MINIMUM + 1) |
---|
71 | #define RTEMS_MAXIMUM_PRIORITY PRIORITY_MAXIMUM |
---|
72 | |
---|
73 | /* |
---|
74 | * The following constant is passed to rtems_task_set_priority when the |
---|
75 | * caller wants to obtain the current priority. |
---|
76 | */ |
---|
77 | |
---|
78 | #define RTEMS_CURRENT_PRIORITY PRIORITY_MINIMUM |
---|
79 | |
---|
80 | /* |
---|
81 | * Notepads constants (indices into notepad array) |
---|
82 | */ |
---|
83 | |
---|
84 | #define RTEMS_NOTEPAD_FIRST 0 /* lowest numbered notepad */ |
---|
85 | #define RTEMS_NOTEPAD_0 0 /* notepad location 0 */ |
---|
86 | #define RTEMS_NOTEPAD_1 1 /* notepad location 1 */ |
---|
87 | #define RTEMS_NOTEPAD_2 2 /* notepad location 2 */ |
---|
88 | #define RTEMS_NOTEPAD_3 3 /* notepad location 3 */ |
---|
89 | #define RTEMS_NOTEPAD_4 4 /* notepad location 4 */ |
---|
90 | #define RTEMS_NOTEPAD_5 5 /* notepad location 5 */ |
---|
91 | #define RTEMS_NOTEPAD_6 6 /* notepad location 6 */ |
---|
92 | #define RTEMS_NOTEPAD_7 7 /* notepad location 7 */ |
---|
93 | #define RTEMS_NOTEPAD_8 8 /* notepad location 8 */ |
---|
94 | #define RTEMS_NOTEPAD_9 9 /* notepad location 9 */ |
---|
95 | #define RTEMS_NOTEPAD_10 10 /* notepad location 10 */ |
---|
96 | #define RTEMS_NOTEPAD_11 11 /* notepad location 11 */ |
---|
97 | #define RTEMS_NOTEPAD_12 12 /* notepad location 12 */ |
---|
98 | #define RTEMS_NOTEPAD_13 13 /* notepad location 13 */ |
---|
99 | #define RTEMS_NOTEPAD_14 14 /* notepad location 14 */ |
---|
100 | #define RTEMS_NOTEPAD_15 15 /* notepad location 15 */ |
---|
101 | #define RTEMS_NOTEPAD_LAST RTEMS_NOTEPAD_15 /* highest numbered notepad */ |
---|
102 | |
---|
103 | #define RTEMS_NUMBER_NOTEPADS (RTEMS_NOTEPAD_LAST+1) |
---|
104 | |
---|
105 | /* |
---|
106 | * External API name for Thread_Control |
---|
107 | */ |
---|
108 | |
---|
109 | typedef Thread_Control rtems_tcb; |
---|
110 | |
---|
111 | /* |
---|
112 | * The following defines the "return type" of an RTEMS task. |
---|
113 | */ |
---|
114 | |
---|
115 | typedef void rtems_task; |
---|
116 | |
---|
117 | /* |
---|
118 | * The following defines the argument to an RTEMS task. |
---|
119 | */ |
---|
120 | |
---|
121 | typedef unsigned32 rtems_task_argument; |
---|
122 | |
---|
123 | /* |
---|
124 | * The following defines the type for the entry point of an RTEMS task. |
---|
125 | */ |
---|
126 | |
---|
127 | typedef rtems_task ( *rtems_task_entry )( |
---|
128 | rtems_task_argument |
---|
129 | ); |
---|
130 | |
---|
131 | /* |
---|
132 | * The following records define the Initialization Tasks Table. |
---|
133 | * Each entry contains the information required by RTEMS to |
---|
134 | * create and start a user task automatically at executive |
---|
135 | * initialization time. |
---|
136 | */ |
---|
137 | |
---|
138 | typedef struct { |
---|
139 | rtems_name name; /* task name */ |
---|
140 | unsigned32 stack_size; /* task stack size */ |
---|
141 | rtems_task_priority initial_priority; /* task priority */ |
---|
142 | rtems_attribute attribute_set; /* task attributes */ |
---|
143 | rtems_task_entry entry_point; /* task entry point */ |
---|
144 | rtems_mode mode_set; /* task initial mode */ |
---|
145 | unsigned32 argument; /* task argument */ |
---|
146 | } rtems_initialization_tasks_table; |
---|
147 | |
---|
148 | /* |
---|
149 | * This is the API specific information required by each thread for |
---|
150 | * the RTEMS API to function correctly. |
---|
151 | */ |
---|
152 | |
---|
153 | |
---|
154 | typedef struct { |
---|
155 | unsigned32 Notepads[ RTEMS_NUMBER_NOTEPADS ]; |
---|
156 | rtems_event_set pending_events; |
---|
157 | rtems_event_set event_condition; |
---|
158 | ASR_Information Signal; |
---|
159 | } RTEMS_API_Control; |
---|
160 | |
---|
161 | /* |
---|
162 | * The following defines the information control block used to |
---|
163 | * manage this class of objects. |
---|
164 | */ |
---|
165 | |
---|
166 | RTEMS_EXTERN Objects_Information _RTEMS_tasks_Information; |
---|
167 | |
---|
168 | /* |
---|
169 | * These are used to manage the user initialization tasks. |
---|
170 | */ |
---|
171 | |
---|
172 | RTEMS_EXTERN rtems_initialization_tasks_table |
---|
173 | *_RTEMS_tasks_User_initialization_tasks; |
---|
174 | RTEMS_EXTERN unsigned32 _RTEMS_tasks_Number_of_initialization_tasks; |
---|
175 | |
---|
176 | /* |
---|
177 | * _RTEMS_tasks_Manager_initialization |
---|
178 | * |
---|
179 | * DESCRIPTION: |
---|
180 | * |
---|
181 | * This routine initializes all Task Manager related data structures. |
---|
182 | */ |
---|
183 | |
---|
184 | void _RTEMS_tasks_Manager_initialization( |
---|
185 | unsigned32 maximum_tasks, |
---|
186 | unsigned32 number_of_initialization_tasks, |
---|
187 | rtems_initialization_tasks_table *user_tasks |
---|
188 | ); |
---|
189 | |
---|
190 | /* |
---|
191 | * rtems_task_create |
---|
192 | * |
---|
193 | * DESCRIPTION: |
---|
194 | * |
---|
195 | * This routine implements the rtems_task_create directive. The task |
---|
196 | * will have the name name. The attribute_set can be used to indicate |
---|
197 | * that the task will be globally accessible or utilize floating point. |
---|
198 | * The task's stack will be stack_size bytes. The task will begin |
---|
199 | * execution with initial_priority and initial_modes. It returns the |
---|
200 | * id of the created task in ID. |
---|
201 | */ |
---|
202 | |
---|
203 | rtems_status_code rtems_task_create( |
---|
204 | rtems_name name, |
---|
205 | rtems_task_priority initial_priority, |
---|
206 | unsigned32 stack_size, |
---|
207 | rtems_mode initial_modes, |
---|
208 | rtems_attribute attribute_set, |
---|
209 | Objects_Id *id |
---|
210 | ); |
---|
211 | |
---|
212 | /* |
---|
213 | * rtems_task_ident |
---|
214 | * |
---|
215 | * DESCRIPTION: |
---|
216 | * |
---|
217 | * This routine implements the rtems_task_ident directive. |
---|
218 | * This directive returns the task ID associated with name. |
---|
219 | * If more than one task is named name, then the task to |
---|
220 | * which the ID belongs is arbitrary. node indicates the |
---|
221 | * extent of the search for the ID of the task named name. |
---|
222 | * The search can be limited to a particular node or allowed to |
---|
223 | * encompass all nodes. |
---|
224 | */ |
---|
225 | |
---|
226 | rtems_status_code rtems_task_ident( |
---|
227 | rtems_name name, |
---|
228 | unsigned32 node, |
---|
229 | Objects_Id *id |
---|
230 | ); |
---|
231 | |
---|
232 | /* |
---|
233 | * rtems_task_delete |
---|
234 | * |
---|
235 | * DESCRIPTION: |
---|
236 | * |
---|
237 | * This routine implements the rtems_task_delete directive. The |
---|
238 | * task indicated by ID is deleted. |
---|
239 | */ |
---|
240 | |
---|
241 | rtems_status_code rtems_task_delete( |
---|
242 | Objects_Id id |
---|
243 | ); |
---|
244 | |
---|
245 | /* |
---|
246 | * rtems_task_get_note |
---|
247 | * |
---|
248 | * DESCRIPTION: |
---|
249 | * |
---|
250 | * This routine implements the rtems_task_get_note directive. The |
---|
251 | * value of the indicated notepad for the task associated with ID |
---|
252 | * is returned in note. |
---|
253 | */ |
---|
254 | |
---|
255 | rtems_status_code rtems_task_get_note( |
---|
256 | Objects_Id id, |
---|
257 | unsigned32 notepad, |
---|
258 | unsigned32 *note |
---|
259 | ); |
---|
260 | |
---|
261 | /* |
---|
262 | * rtems_task_set_note |
---|
263 | * |
---|
264 | * DESCRIPTION: |
---|
265 | * |
---|
266 | * This routine implements the rtems_task_set_note directive. The |
---|
267 | * value of the indicated notepad for the task associated with ID |
---|
268 | * is returned in note. |
---|
269 | */ |
---|
270 | |
---|
271 | rtems_status_code rtems_task_set_note( |
---|
272 | Objects_Id id, |
---|
273 | unsigned32 notepad, |
---|
274 | unsigned32 note |
---|
275 | ); |
---|
276 | |
---|
277 | /* |
---|
278 | * rtems_task_mode |
---|
279 | * |
---|
280 | * DESCRIPTION: |
---|
281 | * |
---|
282 | * This routine implements the rtems_task_mode directive. The current |
---|
283 | * values of the modes indicated by mask of the calling task are changed |
---|
284 | * to that indicated in mode_set. The former mode of the task is |
---|
285 | * returned in mode_set. |
---|
286 | */ |
---|
287 | |
---|
288 | rtems_status_code rtems_task_mode( |
---|
289 | rtems_mode mode_set, |
---|
290 | rtems_mode mask, |
---|
291 | rtems_mode *previous_mode_set |
---|
292 | ); |
---|
293 | |
---|
294 | /* |
---|
295 | * rtems_task_restart |
---|
296 | * |
---|
297 | * DESCRIPTION: |
---|
298 | * |
---|
299 | * This routine implements the rtems_task_restart directive. The |
---|
300 | * task associated with ID is restarted at its initial entry |
---|
301 | * point with the new argument. |
---|
302 | */ |
---|
303 | |
---|
304 | rtems_status_code rtems_task_restart( |
---|
305 | Objects_Id id, |
---|
306 | unsigned32 arg |
---|
307 | ); |
---|
308 | |
---|
309 | /* |
---|
310 | * rtems_task_suspend |
---|
311 | * |
---|
312 | * DESCRIPTION: |
---|
313 | * |
---|
314 | * This routine implements the rtems_task_suspend directive. The |
---|
315 | * SUSPENDED state is set for task associated with ID. |
---|
316 | */ |
---|
317 | |
---|
318 | rtems_status_code rtems_task_suspend( |
---|
319 | Objects_Id id |
---|
320 | ); |
---|
321 | |
---|
322 | /* |
---|
323 | * rtems_task_resume |
---|
324 | * |
---|
325 | * DESCRIPTION: |
---|
326 | * |
---|
327 | * This routine implements the rtems_task_resume Directive. The |
---|
328 | * SUSPENDED state is cleared for task associated with ID. |
---|
329 | */ |
---|
330 | |
---|
331 | rtems_status_code rtems_task_resume( |
---|
332 | Objects_Id id |
---|
333 | ); |
---|
334 | |
---|
335 | /* |
---|
336 | * rtems_task_set_priority |
---|
337 | * |
---|
338 | * DESCRIPTION: |
---|
339 | * |
---|
340 | * This routine implements the rtems_task_set_priority directive. The |
---|
341 | * current priority of the task associated with ID is set to |
---|
342 | * new_priority. The former priority of that task is returned |
---|
343 | * in old_priority. |
---|
344 | */ |
---|
345 | |
---|
346 | rtems_status_code rtems_task_set_priority( |
---|
347 | Objects_Id id, |
---|
348 | rtems_task_priority new_priority, |
---|
349 | rtems_task_priority *old_priority |
---|
350 | ); |
---|
351 | |
---|
352 | /* |
---|
353 | * rtems_task_start |
---|
354 | * |
---|
355 | * DESCRIPTION: |
---|
356 | * |
---|
357 | * This routine implements the rtems_task_start directive. The |
---|
358 | * starting execution point of the task associated with ID is |
---|
359 | * set to entry_point with the initial argument. |
---|
360 | */ |
---|
361 | |
---|
362 | rtems_status_code rtems_task_start( |
---|
363 | Objects_Id id, |
---|
364 | rtems_task_entry entry_point, |
---|
365 | unsigned32 argument |
---|
366 | ); |
---|
367 | |
---|
368 | /* |
---|
369 | * rtems_task_wake_when |
---|
370 | * |
---|
371 | * DESCRIPTION: |
---|
372 | * |
---|
373 | * This routine implements the rtems_task_wake_when directive. The |
---|
374 | * calling task is blocked until the current time of day is |
---|
375 | * equal to that indicated by time_buffer. |
---|
376 | */ |
---|
377 | |
---|
378 | rtems_status_code rtems_task_wake_when( |
---|
379 | rtems_time_of_day *time_buffer |
---|
380 | ); |
---|
381 | |
---|
382 | /* |
---|
383 | * rtems_task_wake_after |
---|
384 | * |
---|
385 | * DESCRIPTION: |
---|
386 | * |
---|
387 | * This routine implements the rtems_task_wake_after directive. The |
---|
388 | * calling task is blocked until the indicated number of clock |
---|
389 | * ticks have occurred. |
---|
390 | */ |
---|
391 | |
---|
392 | rtems_status_code rtems_task_wake_after( |
---|
393 | rtems_interval ticks |
---|
394 | ); |
---|
395 | |
---|
396 | /* |
---|
397 | * rtems_task_is_suspended |
---|
398 | * |
---|
399 | * This directive returns a status indicating whether or not |
---|
400 | * the specified task is suspended. |
---|
401 | */ |
---|
402 | |
---|
403 | rtems_status_code rtems_task_is_suspended( |
---|
404 | Objects_Id id |
---|
405 | ); |
---|
406 | |
---|
407 | /* |
---|
408 | * rtems_task_variable_add |
---|
409 | * |
---|
410 | * This directive adds a per task variable. |
---|
411 | */ |
---|
412 | |
---|
413 | rtems_status_code rtems_task_variable_add( |
---|
414 | rtems_id tid, |
---|
415 | int *ptr |
---|
416 | ); |
---|
417 | |
---|
418 | /* |
---|
419 | * rtems_task_variable_delete |
---|
420 | * |
---|
421 | * This directive removes a per task variable. |
---|
422 | */ |
---|
423 | |
---|
424 | rtems_status_code rtems_task_variable_delete( |
---|
425 | rtems_id tid, |
---|
426 | int *ptr |
---|
427 | ); |
---|
428 | |
---|
429 | /* |
---|
430 | * _RTEMS_tasks_Initialize_user_tasks |
---|
431 | * |
---|
432 | * This routine creates and starts all configured user |
---|
433 | * initialzation threads. |
---|
434 | * |
---|
435 | * Input parameters: NONE |
---|
436 | * |
---|
437 | * Output parameters: NONE |
---|
438 | */ |
---|
439 | |
---|
440 | void _RTEMS_tasks_Initialize_user_tasks( void ); |
---|
441 | |
---|
442 | #ifndef __RTEMS_APPLICATION__ |
---|
443 | #include <rtems/rtems/tasks.inl> |
---|
444 | #endif |
---|
445 | #if defined(RTEMS_MULTIPROCESSING) |
---|
446 | #include <rtems/rtems/taskmp.h> |
---|
447 | #endif |
---|
448 | |
---|
449 | #ifdef __cplusplus |
---|
450 | } |
---|
451 | #endif |
---|
452 | |
---|
453 | #endif |
---|
454 | /* end of include file */ |
---|