|
0
|
1 #ifndef CYGONCE_COMPAT_UITRON_UIT_FUNC_H |
|
|
2 #define CYGONCE_COMPAT_UITRON_UIT_FUNC_H |
|
|
3 //=========================================================================== |
|
|
4 // |
|
2
|
5 // uit_func.h |
|
0
|
6 // |
|
2
|
7 // uITRON compatibility functions |
|
0
|
8 // |
|
|
9 //=========================================================================== |
|
|
10 //####COPYRIGHTBEGIN#### |
|
|
11 // |
|
|
12 // ------------------------------------------- |
|
|
13 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
14 // Version 1.0 (the "License"); you may not use this file except in |
|
|
15 // compliance with the License. You may obtain a copy of the License at |
|
|
16 // http://sourceware.cygnus.com/ecos |
|
|
17 // |
|
|
18 // Software distributed under the License is distributed on an "AS IS" |
|
|
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
20 // License for the specific language governing rights and limitations under |
|
|
21 // the License. |
|
|
22 // |
|
|
23 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
24 // September 30, 1998. |
|
|
25 // |
|
|
26 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
2
|
27 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
28 // ------------------------------------------- |
|
|
29 // |
|
|
30 //####COPYRIGHTEND#### |
|
|
31 //=========================================================================== |
|
|
32 //#####DESCRIPTIONBEGIN#### |
|
|
33 // |
|
2
|
34 // Author(s): hmt |
|
|
35 // Contributors: hmt |
|
|
36 // Date: 1998-03-13 |
|
|
37 // Purpose: uITRON compatibility functions |
|
|
38 // Description: |
|
0
|
39 // |
|
|
40 //####DESCRIPTIONEND#### |
|
|
41 // |
|
|
42 //=========================================================================== |
|
|
43 |
|
|
44 // ------------------------------------------------------------------------ |
|
|
45 // Source Code Organization |
|
|
46 // |
|
|
47 // First, see pkgconf/uitron.h for details of applicable configuration |
|
|
48 // options. |
|
|
49 // |
|
|
50 // This file uit_func.h provides prototypes for the uITRON API. All the |
|
|
51 // uITRON functions are listed here. The prototypes are configurable |
|
|
52 // either to have C or C++ linkage, and if being compiled in a C++ |
|
|
53 // environment, to be inline. |
|
|
54 // |
|
|
55 // The function prototypes are all in terms of uITRON type definitions from |
|
|
56 // uit_type.h, which is included at the head of uit_func.h. |
|
|
57 // |
|
|
58 // The implementations of the uITRON functions are in uit_func.inl, which |
|
|
59 // is either included at the end of uit_func.h (if functions are inline) or |
|
|
60 // in uit_func.cxx (if outline). |
|
|
61 // |
|
|
62 // uit_func.cxx provides some startup functions plus, if the uITRON |
|
|
63 // functions are out of line, uit_func.inl is included to instantiate those |
|
|
64 // functions. |
|
|
65 // |
|
|
66 // uITRON system objects (tasks, semaphores...) are described in |
|
|
67 // uit_obj.hxx. This is a C++ file and is used by the implementation of |
|
|
68 // the uITRON functions. |
|
|
69 // |
|
|
70 // The uITRON system objects are instantiated in uit_obj.cxx, which uses |
|
|
71 // uit_obj.hxx to define the objects, and the configuration file |
|
|
72 // pkgconf/uitron.h to construct them as required. |
|
|
73 // |
|
|
74 // The include graph from an application, which should only include |
|
|
75 // uit_func.h, is similar to the following: |
|
|
76 // |
|
|
77 // |
|
|
78 // [inline uITRON functions:] |
|
|
79 // |
|
|
80 // <your_app.c> |
|
|
81 // . uit_func.h ; prototypes for funcs |
|
|
82 // . . pkgconf/uitron.h ; configuration info |
|
|
83 // . . uit_type.h ; typedefs for func args |
|
|
84 // . (function prototypes) |
|
|
85 // . . uit_func.inl ; full function bodies |
|
|
86 // . . . uit_objs.hxx ; defs of uITRON data |
|
|
87 // . . (function implementations) |
|
|
88 // |
|
|
89 // |
|
|
90 // [out-of-line uITRON functions:] |
|
|
91 // |
|
|
92 // <your_app.c> |
|
|
93 // . uit_func.h ; prototypes for funcs |
|
|
94 // . . pkgconf/uitron.h ; configuration info |
|
|
95 // . . uit_type.h ; typedefs for func args |
|
|
96 // . (function prototypes) |
|
|
97 // |
|
|
98 // |
|
|
99 // [other uITRON compilation units:] |
|
|
100 // |
|
|
101 // uit_func.cxx ; out-of-line functions |
|
|
102 // . pkgconf/uitron.h ; configuration info |
|
|
103 // . uit_func.h ; prototypes for funcs |
|
|
104 // . . uit_type.h ; typedefs for func args |
|
|
105 // . (function prototypes) |
|
|
106 // . . uit_func.inl ; full function bodies |
|
|
107 // . . . uit_objs.hxx ; defs of uITRON data |
|
|
108 // . . (function implementations) |
|
|
109 // |
|
|
110 // |
|
|
111 // uit_objs.cxx ; static uITRON data objects |
|
|
112 // . pkgconf/uitron.h ; configuration info |
|
|
113 // . uit_objs.hxx ; defs of uITRON data |
|
|
114 // (static uITRON system objects) |
|
|
115 // |
|
|
116 // |
|
|
117 // The various include files are protected against multiple inclusion and |
|
|
118 // so may be safely re-included as convenient. |
|
|
119 // |
|
|
120 // ------------------------------------------------------------------------ |
|
|
121 |
|
|
122 #include <pkgconf/uitron.h> // uITRON setup CYGNUM_UITRON_SEMAS |
|
|
123 // CYGPKG_UITRON et al |
|
|
124 |
|
|
125 #ifdef CYGPKG_UITRON |
|
|
126 |
|
|
127 #include <cyg/infra/cyg_type.h> // types; cyg_int32, CYG_ADDRWORD |
|
|
128 |
|
|
129 #include <cyg/compat/uitron/uit_type.h> // uITRON types; ER ID TMO T_MSG |
|
|
130 |
|
|
131 // ------------------------------------------------------------------------ |
|
|
132 // Object operations: |
|
|
133 // |
|
|
134 // The functions can be inlined in C compiled by C++, or C++ of course, |
|
|
135 // and also outlined in extern "C" functions, eg. for taking the address |
|
|
136 // of, or for use by a pure C program, or of course outlined in C++ for |
|
|
137 // Code size reasons. |
|
|
138 // |
|
|
139 // |
|
|
140 // Summary: |
|
|
141 // |
|
|
142 // IF compiling in C |
|
|
143 // THEN functions must be C linkage and out of line: |
|
|
144 // do NOT specify CYGIMP_UITRON_INLINE_FUNCS nor |
|
|
145 // CYGIMP_UITRON_CPP_OUTLINE_FUNCS. |
|
|
146 // IF compiling in C++ |
|
|
147 // THEN functions can be inline: specify CYGIMP_UITRON_INLINE_FUNCS |
|
|
148 // OR by default, functions are out of line: |
|
|
149 // outline functions can have C++ linkage: |
|
|
150 // specify CYGIMP_UITRON_CPP_OUTLINE_FUNCS |
|
|
151 // OR by default, outline functions have C linkage. |
|
|
152 |
|
|
153 |
|
|
154 #ifdef __cplusplus |
|
|
155 // C++ environment; functions can be inline or not as we please. |
|
|
156 // If not inline they might as well be "C" linkage for sharing with |
|
|
157 // any pure "C" code present. |
|
|
158 |
|
|
159 #ifdef CYGIMP_UITRON_INLINE_FUNCS |
|
|
160 |
|
|
161 #define CYG_UIT_FUNC_EXTERN_BEGIN |
|
|
162 #define CYG_UIT_FUNC_EXTERN_END |
|
2
|
163 #define CYG_UIT_FUNC_INLINE inline |
|
0
|
164 #ifndef CYGPRI_UITRON_FUNCS_HERE_AND_NOW |
|
|
165 #define CYGPRI_UITRON_FUNCS_HERE_AND_NOW |
|
|
166 #endif |
|
|
167 |
|
|
168 #else |
|
|
169 |
|
|
170 #ifdef CYGIMP_UITRON_CPP_OUTLINE_FUNCS |
|
2
|
171 #define CYG_UIT_FUNC_EXTERN_BEGIN extern "C++" { |
|
|
172 #define CYG_UIT_FUNC_EXTERN_END } |
|
0
|
173 #else |
|
2
|
174 #define CYG_UIT_FUNC_EXTERN_BEGIN extern "C" { |
|
|
175 #define CYG_UIT_FUNC_EXTERN_END } |
|
0
|
176 #endif |
|
|
177 |
|
|
178 #define CYG_UIT_FUNC_INLINE |
|
|
179 #endif |
|
|
180 |
|
|
181 #else // !__cplusplus |
|
|
182 // Vanilla "C" environment; external "C" linkage, no inline functions |
|
|
183 |
|
|
184 #ifdef CYGIMP_UITRON_INLINE_FUNCS |
|
|
185 #error "Cannot inline uITRON functions in pure C environment" |
|
|
186 #endif |
|
|
187 #ifdef CYGIMP_UITRON_CPP_OUTLINE_FUNCS |
|
|
188 #error "Cannot use C++ linkage of outline fns in pure C environment" |
|
|
189 #endif |
|
|
190 |
|
|
191 #define CYG_UIT_FUNC_EXTERN_BEGIN |
|
|
192 #define CYG_UIT_FUNC_EXTERN_END |
|
2
|
193 #define CYG_UIT_FUNC_INLINE |
|
0
|
194 |
|
|
195 #endif // !__cplusplus |
|
|
196 |
|
|
197 // ======================================================================== |
|
|
198 // u I T R O N F U N C T I O N S |
|
|
199 // The function declarations themselves: |
|
|
200 |
|
|
201 CYG_UIT_FUNC_EXTERN_BEGIN |
|
|
202 |
|
|
203 // this routine is outside the uITRON specification; call it from main() to |
|
|
204 // start the uITRON tasks and scheduler. It does not return. |
|
|
205 |
|
|
206 #ifdef CYGNUM_UITRON_START_TASKS |
|
|
207 void cyg_uitron_start( void ); |
|
|
208 #endif |
|
|
209 |
|
|
210 // ****************************************************** |
|
|
211 // *** 6.5 C Language Interfaces *** |
|
|
212 // ****************************************************** |
|
|
213 |
|
|
214 // - Task Management Functions |
|
|
215 |
|
2
|
216 ER cre_tsk ( ID tskid, T_CTSK *pk_ctsk ); |
|
|
217 ER del_tsk ( ID tskid ); |
|
|
218 ER sta_tsk ( ID tskid, INT stacd ); |
|
|
219 void ext_tsk ( void ); |
|
|
220 void exd_tsk ( void ); |
|
|
221 ER ter_tsk ( ID tskid ); |
|
0
|
222 |
|
2
|
223 ER dis_dsp ( void ); |
|
|
224 ER ena_dsp ( void ); |
|
|
225 ER chg_pri ( ID tskid, PRI tskpri ); |
|
|
226 ER rot_rdq ( PRI tskpri ); |
|
|
227 ER rel_wai ( ID tskid ); |
|
|
228 ER get_tid ( ID *p_tskid ); |
|
|
229 ER ref_tsk ( T_RTSK *pk_rtsk, ID tskid ); |
|
0
|
230 |
|
|
231 // - Task-Dependent Synchronization Functions |
|
|
232 |
|
2
|
233 ER sus_tsk ( ID tskid ); |
|
|
234 ER rsm_tsk ( ID tskid ); |
|
|
235 ER frsm_tsk ( ID tskid ); |
|
|
236 ER slp_tsk ( void ); |
|
|
237 ER tslp_tsk ( TMO tmout ); |
|
|
238 ER wup_tsk ( ID tskid ); |
|
|
239 ER can_wup ( INT *p_wupcnt, ID tskid ); |
|
0
|
240 |
|
|
241 // - Synchronization and Communication Functions |
|
|
242 |
|
2
|
243 ER cre_sem ( ID semid, T_CSEM *pk_csem ); |
|
|
244 ER del_sem ( ID semid ); |
|
|
245 ER sig_sem ( ID semid ); |
|
|
246 ER wai_sem ( ID semid ); |
|
|
247 ER preq_sem ( ID semid ); |
|
|
248 ER twai_sem ( ID semid, TMO tmout ); |
|
|
249 ER ref_sem ( T_RSEM *pk_rsem, ID semid ); |
|
0
|
250 |
|
2
|
251 ER cre_flg ( ID flgid, T_CFLG *pk_cflg ); |
|
|
252 ER del_flg ( ID flgid ); |
|
|
253 ER set_flg ( ID flgid, UINT setptn ); |
|
|
254 ER clr_flg ( ID flgid, UINT clrptn ); |
|
|
255 ER wai_flg ( UINT *p_flgptn, ID flgid, UINT waiptn, UINT wfmode ); |
|
|
256 ER pol_flg ( UINT *p_flgptn, ID flgid, UINT waiptn, UINT wfmode ); |
|
|
257 ER twai_flg ( UINT *p_flgptn, ID flgid, UINT waiptn, UINT wfmode, |
|
0
|
258 TMO tmout ); |
|
2
|
259 ER ref_flg ( T_RFLG *pk_rflg, ID flgid ); |
|
0
|
260 |
|
2
|
261 ER cre_mbx ( ID mbxid, T_CMBX* pk_cmbx ); |
|
|
262 ER del_mbx ( ID mbxid ); |
|
|
263 ER snd_msg ( ID mbxid, T_MSG *pk_msg ); |
|
|
264 ER rcv_msg ( T_MSG **ppk_msg, ID mbxid ); |
|
|
265 ER prcv_msg ( T_MSG **ppk_msg, ID mbxid ); |
|
|
266 ER trcv_msg ( T_MSG **ppk_msg, ID mbxid, TMO tmout ); |
|
|
267 ER ref_mbx ( T_RMBX *pk_rmbx, ID mbxid ); |
|
0
|
268 |
|
|
269 // - Extended Synchronization and Communication Functions |
|
|
270 |
|
|
271 #if 0 // NOT SUPPORTED |
|
2
|
272 ER cre_mbf ( ID mbfid, T_CMBF *pk_cmbf ); |
|
|
273 ER del_mbf ( ID mbfid ); |
|
|
274 ER snd_mbf ( ID mbfid, VP msg, INT msgsz ); |
|
|
275 ER psnd_mbf ( ID mbfid, VP msg, INT msgsz ); |
|
|
276 ER tsnd_mbf ( ID mbfid, VP msg, INT msgsz, TMO tmout ); |
|
|
277 ER rcv_mbf ( VP msg, INT *p_msgsz, ID mbfid ); |
|
|
278 ER prcv_mbf ( VP msg, INT *p_msgsz, ID mbfid ); |
|
|
279 ER trcv_mbf ( VP msg, INT *p_msgsz, ID mbfid, TMO tmout ); |
|
|
280 ER ref_mbf ( T_RMBF *pk_rmbf, ID mbfid ); |
|
|
281 ER cre_por ( ID porid, T_CPOR *pk_cpor ); |
|
|
282 ER del_por ( ID porid ); |
|
|
283 ER cal_por ( VP msg, INT *p_rmsgsz, ID porid, UINT calptn, INT |
|
0
|
284 cmsgsz ); |
|
2
|
285 ER pcal_por ( VP msg, INT *p_rmsgsz, ID porid, UINT calptn, INT |
|
0
|
286 cmsgsz ); |
|
2
|
287 ER tcal_por ( VP msg, INT *p_rmsgsz, ID porid, UINT calptn, INT |
|
0
|
288 cmsgsz, TMO tmout ); |
|
2
|
289 ER acp_por ( RNO *p_rdvno, VP msg, INT *p_cmsgsz, ID porid, UINT |
|
0
|
290 acpptn ); |
|
2
|
291 ER pacp_por ( RNO *p_rdvno, VP msg, INT *p_cmsgsz, ID porid, UINT |
|
0
|
292 acpptn ); |
|
2
|
293 ER tacp_por ( RNO *p_rdvno, VP msg, INT *p_cmsgsz, ID porid, UINT |
|
0
|
294 acpptn, TMO tmout ); |
|
2
|
295 ER fwd_por ( ID porid, UINT calptn, RNO rdvno, VP msg, INT cmsgsz |
|
0
|
296 ); |
|
2
|
297 ER rpl_rdv ( RNO rdvno, VP msg, INT rmsgsz ); |
|
|
298 ER ref_por ( T_RPOR *pk_rpor, ID porid ); |
|
0
|
299 #endif |
|
|
300 |
|
|
301 // - Interrupt Management Functions |
|
|
302 |
|
|
303 #if 0 // NOT SUPPORTED |
|
2
|
304 ER def_int ( UINT dintno, T_DINT *pk_dint ); |
|
|
305 void ret_wup ( ID tskid ); |
|
0
|
306 #endif |
|
|
307 #if 0 |
|
2
|
308 void ret_int ( void ); |
|
0
|
309 #endif |
|
|
310 #define ret_int() return |
|
2
|
311 ER loc_cpu ( void ); |
|
|
312 ER unl_cpu ( void ); |
|
0
|
313 #if 0 // NOT SUPPORTED |
|
2
|
314 ER dis_int ( UINT eintno ); |
|
|
315 ER ena_int ( UINT eintno ); |
|
|
316 ER chg_iXX ( UINT iXXXX ); |
|
|
317 ER ref_iXX ( UINT *p_iXXXX ); |
|
0
|
318 #endif |
|
|
319 |
|
|
320 // - Memorypool Management Functions |
|
|
321 |
|
2
|
322 ER cre_mpl ( ID mplid, T_CMPL *pk_cmpl ); |
|
|
323 ER del_mpl ( ID mplid ); |
|
|
324 ER get_blk ( VP *p_blk, ID mplid, INT blksz ); |
|
|
325 ER pget_blk ( VP *p_blk, ID mplid, INT blksz ); |
|
|
326 ER tget_blk ( VP *p_blk, ID mplid, INT blksz, TMO tmout ); |
|
|
327 ER rel_blk ( ID mplid, VP blk ); |
|
|
328 ER ref_mpl ( T_RMPL *pk_rmpl, ID mplid ); |
|
0
|
329 |
|
2
|
330 ER cre_mpf ( ID mpfid, T_CMPF *pk_cmpf ); |
|
|
331 ER del_mpf ( ID mpfid ); |
|
|
332 ER get_blf ( VP *p_blf, ID mpfid ); |
|
|
333 ER pget_blf ( VP *p_blf, ID mpfid ); |
|
|
334 ER tget_blf ( VP *p_blf, ID mpfid, TMO tmout ); |
|
|
335 ER rel_blf ( ID mpfid, VP blf ); |
|
|
336 ER ref_mpf ( T_RMPF *pk_rmpf, ID mpfid ); |
|
0
|
337 |
|
|
338 // - Time Management Functions |
|
|
339 |
|
2
|
340 ER set_tim ( SYSTIME *pk_tim ); |
|
|
341 ER get_tim ( SYSTIME *pk_tim ); |
|
|
342 ER dly_tsk ( DLYTIME dlytim ); |
|
|
343 ER def_cyc ( HNO cycno, T_DCYC *pk_dcyc ); |
|
|
344 ER act_cyc ( HNO cycno, UINT cycact ); |
|
|
345 ER ref_cyc ( T_RCYC *pk_rcyc, HNO cycno ); |
|
|
346 ER def_alm ( HNO almno, T_DALM *pk_dalm ); |
|
|
347 ER ref_alm ( T_RALM *pk_ralm, HNO almno ); |
|
0
|
348 #if 0 |
|
2
|
349 void ret_tmr ( void ); |
|
0
|
350 #endif |
|
|
351 #define ret_tmr() return |
|
|
352 |
|
|
353 // - System Management Functions |
|
|
354 |
|
2
|
355 ER get_ver ( T_VER *pk_ver ); |
|
|
356 ER ref_sys ( T_RSYS *pk_rsys ); |
|
|
357 ER ref_cfg ( T_RCFG *pk_rcfg ); |
|
0
|
358 #if 0 // NOT SUPPORTED |
|
2
|
359 ER def_svc ( FN s_fncd, T_DSVC *pk_dsvc ); |
|
|
360 ER def_exc ( UINT exckind, T_DEXC *pk_dexc ); |
|
0
|
361 #endif |
|
|
362 |
|
|
363 // - Network Support Functions |
|
|
364 |
|
|
365 #if 0 // NOT SUPPORTED |
|
2
|
366 ER nrea_dat ( INT *p_reasz, VP dstadr, NODE srcnode, VP srcadr, |
|
0
|
367 INT datsz ); |
|
2
|
368 ER nwri_dat ( INT *p_wrisz, NODE dstnode, VP dstadr, VP srcadr, |
|
0
|
369 INT datsz ); |
|
2
|
370 ER nget_nod ( NODE *p_node ); |
|
|
371 ER nget_ver ( T_VER *pk_ver, NODE node ); |
|
0
|
372 #endif |
|
|
373 |
|
|
374 CYG_UIT_FUNC_EXTERN_END |
|
|
375 |
|
|
376 // ======================================================================== |
|
|
377 |
|
|
378 #ifdef CYGPRI_UITRON_FUNCS_HERE_AND_NOW |
|
|
379 // functions are inline OR we are in the outline implementation, so define |
|
|
380 // the functions as inlines or plain functions depending on the value of |
|
|
381 // CYG_UIT_FUNC_INLINE from above. |
|
|
382 #include <cyg/compat/uitron/uit_func.inl> |
|
|
383 #endif // CYGPRI_UITRON_FUNCS_HERE_AND_NOW |
|
|
384 |
|
|
385 // ------------------------------------------------------------------------ |
|
|
386 #endif // CYGPKG_UITRON |
|
|
387 |
|
|
388 #endif // CYGONCE_COMPAT_UITRON_UIT_FUNC_H |
|
|
389 // EOF uit_func.h |