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