1 | /** |
---|
2 | * @file rtems/itron/task.inl |
---|
3 | */ |
---|
4 | |
---|
5 | /* |
---|
6 | * COPYRIGHT (c) 1989-1999. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.rtems.com/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef _RTEMS_ITRON_TASK_H |
---|
17 | # error "Never use <rtems/itron/task.inl> directly; include <rtems/itron/task.h> instead." |
---|
18 | #endif |
---|
19 | |
---|
20 | #ifndef _RTEMS_ITRON_TASK_INL |
---|
21 | #define _RTEMS_ITRON_TASK_INL |
---|
22 | |
---|
23 | #ifdef __cplusplus |
---|
24 | extern "C" { |
---|
25 | #endif |
---|
26 | |
---|
27 | /* |
---|
28 | * _ITRON_Task_Allocate |
---|
29 | * |
---|
30 | * DESCRIPTION: |
---|
31 | * |
---|
32 | * This routine allocates the task associated with the specified |
---|
33 | * task ID from the pool of inactive tasks. |
---|
34 | * |
---|
35 | * Input parameters: |
---|
36 | * tskid - id of task to allocate |
---|
37 | * status - pointer to status variable |
---|
38 | * |
---|
39 | * Output parameters: |
---|
40 | * returns - pointer to the task control block |
---|
41 | * *status - status |
---|
42 | */ |
---|
43 | |
---|
44 | RTEMS_INLINE_ROUTINE Thread_Control *_ITRON_Task_Allocate( |
---|
45 | ID tskid |
---|
46 | ) |
---|
47 | { |
---|
48 | return (Thread_Control *)_ITRON_Objects_Allocate_by_index( |
---|
49 | &_ITRON_Task_Information, |
---|
50 | tskid, |
---|
51 | sizeof(Thread_Control) |
---|
52 | ); |
---|
53 | } |
---|
54 | |
---|
55 | /* |
---|
56 | * _ITRON_Task_Clarify_allocation_id_error |
---|
57 | * |
---|
58 | * This function is invoked when an object allocation ID error |
---|
59 | * occurs to determine the specific ITRON error code to return. |
---|
60 | */ |
---|
61 | |
---|
62 | #define _ITRON_Task_Clarify_allocation_id_error( _id ) \ |
---|
63 | _ITRON_Objects_Clarify_allocation_id_error( \ |
---|
64 | &_ITRON_Task_Information, (_id) ) |
---|
65 | |
---|
66 | /* |
---|
67 | * _ITRON_Task_Clarify_get_id_error |
---|
68 | * |
---|
69 | * This function is invoked when an object get ID error |
---|
70 | * occurs to determine the specific ITRON error code to return. |
---|
71 | */ |
---|
72 | |
---|
73 | #define _ITRON_Task_Clarify_get_id_error( _id ) \ |
---|
74 | _ITRON_Objects_Clarify_get_id_error( &_ITRON_Task_Information, (_id) ) |
---|
75 | |
---|
76 | /* |
---|
77 | * _ITRON_Task_Free |
---|
78 | * |
---|
79 | * DESCRIPTION: |
---|
80 | * |
---|
81 | * This routine frees a task control block to the |
---|
82 | * inactive chain of free task control blocks. |
---|
83 | * |
---|
84 | * Input parameters: |
---|
85 | * the_task - pointer to task control block |
---|
86 | * |
---|
87 | * Output parameters: NONE |
---|
88 | */ |
---|
89 | |
---|
90 | RTEMS_INLINE_ROUTINE void _ITRON_Task_Free ( |
---|
91 | Thread_Control *the_task |
---|
92 | ) |
---|
93 | { |
---|
94 | _ITRON_Objects_Free( &_ITRON_Task_Information, &the_task->Object ); |
---|
95 | } |
---|
96 | |
---|
97 | /*PAGE |
---|
98 | * |
---|
99 | * _ITRON_Task_Get |
---|
100 | * |
---|
101 | * DESCRIPTION: |
---|
102 | * |
---|
103 | * This function maps task IDs to task control blocks. |
---|
104 | * If ID corresponds to a local task, then it returns |
---|
105 | * the_task control pointer which maps to ID and location |
---|
106 | * is set to OBJECTS_LOCAL. if the task ID is global and |
---|
107 | * resides on a remote node, then location is set to OBJECTS_REMOTE, |
---|
108 | * and the_task is undefined. Otherwise, location is set |
---|
109 | * to OBJECTS_ERROR and the_task is undefined. |
---|
110 | * |
---|
111 | * Input parameters: |
---|
112 | * id - ITRON task ID. |
---|
113 | * the_location - pointer to a location variable |
---|
114 | * |
---|
115 | * Output parameters: |
---|
116 | * *the_location - location of the object |
---|
117 | */ |
---|
118 | |
---|
119 | RTEMS_INLINE_ROUTINE Thread_Control *_ITRON_Task_Get ( |
---|
120 | ID id, |
---|
121 | Objects_Locations *location |
---|
122 | ) |
---|
123 | { |
---|
124 | if ( id == 0 ) { |
---|
125 | _Thread_Disable_dispatch(); |
---|
126 | *location = OBJECTS_LOCAL; |
---|
127 | return _Thread_Executing; |
---|
128 | } |
---|
129 | |
---|
130 | return (Thread_Control *) |
---|
131 | _ITRON_Objects_Get( &_ITRON_Task_Information, id, location ); |
---|
132 | } |
---|
133 | |
---|
134 | /*PAGE |
---|
135 | * |
---|
136 | * _ITRON_Task_Is_null |
---|
137 | * |
---|
138 | * This function returns TRUE if the_task is NULL and FALSE otherwise. |
---|
139 | * |
---|
140 | * Input parameters: |
---|
141 | * the_task - pointer to task control block |
---|
142 | * |
---|
143 | * Output parameters: |
---|
144 | * TRUE - if the_task is NULL |
---|
145 | * FALSE - otherwise |
---|
146 | */ |
---|
147 | |
---|
148 | RTEMS_INLINE_ROUTINE boolean _ITRON_Task_Is_null ( |
---|
149 | Thread_Control *the_task |
---|
150 | ) |
---|
151 | { |
---|
152 | return ( the_task == NULL ); |
---|
153 | } |
---|
154 | |
---|
155 | /* |
---|
156 | * XXX insert inline routines here |
---|
157 | */ |
---|
158 | |
---|
159 | /*PAGE |
---|
160 | * |
---|
161 | * _ITRON_tasks_Priority_to_Core |
---|
162 | */ |
---|
163 | |
---|
164 | RTEMS_INLINE_ROUTINE Priority_Control _ITRON_Task_Priority_to_Core( |
---|
165 | PRI ITRON_priority |
---|
166 | ) |
---|
167 | { |
---|
168 | return (Priority_Control) ITRON_priority; |
---|
169 | } |
---|
170 | |
---|
171 | /*PAGE |
---|
172 | * |
---|
173 | * _ITRON_tasks_Core_to_Priority |
---|
174 | */ |
---|
175 | |
---|
176 | RTEMS_INLINE_ROUTINE PRI _ITRON_Task_Core_to_Priority( |
---|
177 | Priority_Control core_priority |
---|
178 | ) |
---|
179 | { |
---|
180 | return (PRI) core_priority; |
---|
181 | } |
---|
182 | |
---|
183 | |
---|
184 | #ifdef __cplusplus |
---|
185 | } |
---|
186 | #endif |
---|
187 | |
---|
188 | #endif |
---|
189 | /* end of include file */ |
---|