1 | /* |
---|
2 | * COPYRIGHT (c) 1989-1999. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.OARcorp.com/rtems/license.html. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #ifndef __ITRON_TASK_h_ |
---|
13 | #define __ITRON_TASK_h_ |
---|
14 | |
---|
15 | #ifdef __cplusplus |
---|
16 | extern "C" { |
---|
17 | #endif |
---|
18 | |
---|
19 | /* |
---|
20 | * Create Task (cre_tsk) Structure |
---|
21 | */ |
---|
22 | |
---|
23 | typedef struct t_ctsk { |
---|
24 | VP exinf; /* extended information */ |
---|
25 | ATR tskatr; /* task attributes */ |
---|
26 | FP task; /* task start address */ |
---|
27 | PRI itskpri; /* initial task priority */ |
---|
28 | INT stksz; /* stack size */ |
---|
29 | /* additional information may be included depending on the implementation */ |
---|
30 | } T_CTSK; |
---|
31 | |
---|
32 | /* |
---|
33 | * Values for the tskatr field |
---|
34 | */ |
---|
35 | |
---|
36 | #define TA_ASM 0x00 /* program written in assembly language */ |
---|
37 | #define TA_HLNG 0x01 /* program written in high-level language */ |
---|
38 | #define TA_COP0 0x8000 /* uses coprocessor having ID = 0 */ |
---|
39 | #define TA_COP1 0x4000 /* uses coprocessor having ID = 1 */ |
---|
40 | #define TA_COP2 0x2000 /* uses coprocessor having ID = 2 */ |
---|
41 | #define TA_COP3 0x1000 /* uses coprocessor having ID = 3 */ |
---|
42 | #define TA_COP4 0x0800 /* uses coprocessor having ID = 4 */ |
---|
43 | #define TA_COP5 0x0400 /* uses coprocessor having ID = 5 */ |
---|
44 | #define TA_COP6 0x0200 /* uses coprocessor having ID = 6 */ |
---|
45 | #define TA_COP7 0x0100 /* uses coprocessor having ID = 7 */ |
---|
46 | |
---|
47 | /* |
---|
48 | * Values for the tskid field |
---|
49 | */ |
---|
50 | |
---|
51 | #define TSK_SELF 0 /* task specifies itself */ |
---|
52 | |
---|
53 | /* XXX is this a mistake in ITRON? FALSE was here and in the types list */ |
---|
54 | #if 0 |
---|
55 | |
---|
56 | #define FALSE 0 /* indicates a task-independent portion (return */ |
---|
57 | /* parameters only) */ |
---|
58 | #endif |
---|
59 | |
---|
60 | /* |
---|
61 | * Values for the tskpri field |
---|
62 | */ |
---|
63 | |
---|
64 | #define TPRI_INI 0 /* specifies the initial priority on */ |
---|
65 | /* task startup (chg_pri) */ |
---|
66 | #define TPRI_RUN 0 /* specifies the highest priority during */ |
---|
67 | /* execution (rot_rdq) */ |
---|
68 | |
---|
69 | |
---|
70 | /* |
---|
71 | * Reference Task (ref_tsk) Structure |
---|
72 | */ |
---|
73 | |
---|
74 | typedef struct t_rtsk { |
---|
75 | VP exinf; /* extended information */ |
---|
76 | PRI tskpri; /* current priority */ |
---|
77 | UINT tskstat; /* task state */ |
---|
78 | /* |
---|
79 | * The following are represent extended features of support |
---|
80 | * [level X] (implementation-dependent). |
---|
81 | */ |
---|
82 | UINT tskwait; /* cause of wait */ |
---|
83 | ID wid; /* ID of object being waited for */ |
---|
84 | INT wupcnt; /* wakeup request count */ |
---|
85 | INT suscnt; /* SUSPEND request count */ |
---|
86 | ATR tskatr; /* task attributes */ |
---|
87 | FP task; /* task start address */ |
---|
88 | PRI itskpri; /* initial task priority */ |
---|
89 | INT stksz; /* stack size */ |
---|
90 | } T_RTSK; |
---|
91 | |
---|
92 | /* |
---|
93 | * Values for the tskstat field |
---|
94 | */ |
---|
95 | |
---|
96 | |
---|
97 | #define TTS_RUN 0x01 /* RUN */ |
---|
98 | #define TTS_RDY 0x02 /* READY */ |
---|
99 | #define TTS_WAI 0x04 /* WAIT */ |
---|
100 | #define TTS_SUS 0x08 /* SUSPEND */ |
---|
101 | #define TTS_WAS 0x0C /* WAIT-SUSPEND */ |
---|
102 | #define TTS_DMT 0x10 /* DORMANT */ |
---|
103 | |
---|
104 | /* |
---|
105 | * Values for the tskwait field |
---|
106 | */ |
---|
107 | |
---|
108 | #define TTW_SLP 0x0001 /* wait due to slp_tsk or tslp_tsk */ |
---|
109 | #define TTW_DLY 0x0002 /* wait due to dly_tsk */ |
---|
110 | #define TTW_NOD 0x0008 /* connection function response wait */ |
---|
111 | #define TTW_FLG 0x0010 /* wait due to wai_flg or twai_flg */ |
---|
112 | #define TTW_SEM 0x0020 /* wait due to wai_sem or twai_sem */ |
---|
113 | #define TTW_MBX 0x0040 /* wait due to rcv_msg or trcv_msg */ |
---|
114 | #define TTW_SMBF 0x0080 /* wait due to snd_mbf or tsnd_mbf */ |
---|
115 | #define TTW_MBF 0x0100 /* wait due to rcv_mbf or trcv_mbf */ |
---|
116 | #define TTW_CAL 0x0200 /* wait for rendezvous call */ |
---|
117 | #define TTW_ACP 0x0400 /* wait for rendezvous accept */ |
---|
118 | #define TTW_RDV 0x0800 /* wait for rendezvous completion */ |
---|
119 | #define TTW_MPL 0x1000 /* wait due to get_blk or tget_blk */ |
---|
120 | #define TTW_MPF 0x2000 /* wait due to get_blf or tget_blf */ |
---|
121 | |
---|
122 | /* |
---|
123 | * Since the task states given by tskstat and tskwait are expressed |
---|
124 | * by bit correspondences, they are convenient when looking for OR |
---|
125 | * conditions (such as whether a task is in WAIT or READY state). |
---|
126 | */ |
---|
127 | |
---|
128 | /* |
---|
129 | * Task Management Functions |
---|
130 | */ |
---|
131 | |
---|
132 | /* |
---|
133 | * cre_tsk - Create Task |
---|
134 | */ |
---|
135 | |
---|
136 | ER cre_tsk( |
---|
137 | ID tskid, |
---|
138 | T_CTSK *pk_ctsk |
---|
139 | ); |
---|
140 | |
---|
141 | /* |
---|
142 | * del_tsk - Delete Task |
---|
143 | */ |
---|
144 | |
---|
145 | ER del_tsk( |
---|
146 | ID tskid |
---|
147 | ); |
---|
148 | |
---|
149 | /* |
---|
150 | * sta_tsk - Start Task |
---|
151 | */ |
---|
152 | |
---|
153 | ER sta_tsk( |
---|
154 | ID tskid, |
---|
155 | INT stacd |
---|
156 | ); |
---|
157 | |
---|
158 | /* |
---|
159 | * ext_tsk - Exit Issuing Task |
---|
160 | */ |
---|
161 | |
---|
162 | void ext_tsk( void ); |
---|
163 | |
---|
164 | /* |
---|
165 | * exd_tsk - Exit and Delete Task |
---|
166 | */ |
---|
167 | |
---|
168 | void exd_tsk( void ); |
---|
169 | |
---|
170 | /* |
---|
171 | * ter_tsk - Terminate Other Task |
---|
172 | */ |
---|
173 | |
---|
174 | ER ter_tsk( |
---|
175 | ID tskid |
---|
176 | ); |
---|
177 | |
---|
178 | /* |
---|
179 | * dis_dsp - Disable Dispatch |
---|
180 | */ |
---|
181 | |
---|
182 | ER dis_dsp( void ); |
---|
183 | |
---|
184 | /* |
---|
185 | * ena_dsp - Enable Dispatch |
---|
186 | */ |
---|
187 | |
---|
188 | ER ena_dsp( void ); |
---|
189 | |
---|
190 | /* |
---|
191 | * chg_pri - Change Task Priority |
---|
192 | */ |
---|
193 | |
---|
194 | ER chg_pri( |
---|
195 | ID tskid, |
---|
196 | PRI tskpri |
---|
197 | ); |
---|
198 | |
---|
199 | /* |
---|
200 | * rot_rdq - Rotate Tasks on the Ready Queue |
---|
201 | */ |
---|
202 | |
---|
203 | ER rot_rdq( |
---|
204 | PRI tskpri |
---|
205 | ); |
---|
206 | |
---|
207 | /* |
---|
208 | * rel_wai - Release Wait of Other Task |
---|
209 | */ |
---|
210 | |
---|
211 | ER rel_wai( |
---|
212 | ID tskid |
---|
213 | ); |
---|
214 | |
---|
215 | /* |
---|
216 | * get_tid - Get Task Identifier |
---|
217 | */ |
---|
218 | |
---|
219 | ER get_tid( |
---|
220 | ID *p_tskid |
---|
221 | ); |
---|
222 | |
---|
223 | /* |
---|
224 | * ref_tsk - Reference Task Status |
---|
225 | */ |
---|
226 | |
---|
227 | ER ref_tsk( |
---|
228 | T_RTSK *pk_rtsk, |
---|
229 | ID tskid |
---|
230 | ); |
---|
231 | |
---|
232 | |
---|
233 | /* |
---|
234 | * Task-Dependent Synchronization Functions |
---|
235 | */ |
---|
236 | |
---|
237 | /* |
---|
238 | * sus_tsk - Suspend Other Task |
---|
239 | */ |
---|
240 | |
---|
241 | ER sus_tsk( |
---|
242 | ID tskid |
---|
243 | ); |
---|
244 | |
---|
245 | /* |
---|
246 | * rsm_tsk - Resume Suspended Task |
---|
247 | */ |
---|
248 | |
---|
249 | ER rsm_tsk( |
---|
250 | ID tskid |
---|
251 | ); |
---|
252 | |
---|
253 | /* |
---|
254 | * frsm_tsk - Forcibly Resume Suspended Task |
---|
255 | */ |
---|
256 | |
---|
257 | ER frsm_tsk( |
---|
258 | ID tskid |
---|
259 | ); |
---|
260 | |
---|
261 | /* |
---|
262 | * slp_tsk - Sleep Task Sleep Task with Timeout |
---|
263 | */ |
---|
264 | |
---|
265 | ER slp_tsk( void ); |
---|
266 | |
---|
267 | /* |
---|
268 | * tslp_tsk - Sleep Task with Timeout |
---|
269 | */ |
---|
270 | |
---|
271 | ER tslp_tsk( |
---|
272 | TMO tmout |
---|
273 | ); |
---|
274 | |
---|
275 | /* |
---|
276 | * wup_tsk - Wakeup Other Task |
---|
277 | */ |
---|
278 | |
---|
279 | ER wup_tsk( |
---|
280 | ID tskid |
---|
281 | ); |
---|
282 | |
---|
283 | /* |
---|
284 | * can_wup - Cancel Wakeup Request |
---|
285 | */ |
---|
286 | |
---|
287 | ER can_wup( |
---|
288 | INT *p_wupcnt, |
---|
289 | ID tskid |
---|
290 | ); |
---|
291 | |
---|
292 | #ifdef __cplusplus |
---|
293 | } |
---|
294 | #endif |
---|
295 | |
---|
296 | #endif |
---|
297 | /* end of include file */ |
---|
298 | |
---|