comparison packages/compat/uitron/current/src/uit_func.cxx @ 0:3111d98ba7b3 ecos-v1_1-release

Initial commit of eCos version 1.1
author jlarmour
date Tue, 11 May 1999 11:16:07 +0000
parents
children 443894e2e912
comparison
equal deleted inserted replaced
-1:000000000000 0:3111d98ba7b3
1 //===========================================================================
2 //
3 // uit_func.cxx
4 //
5 // uITRON compatibility functions
6 //
7 //===========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Cygnus eCos Public License
12 // Version 1.0 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://sourceware.cygnus.com/ecos
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Cygnus Operating System, released
22 // September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Cygnus. Portions created
25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved.
26 // -------------------------------------------
27 //
28 //####COPYRIGHTEND####
29 //===========================================================================
30 //#####DESCRIPTIONBEGIN####
31 //
32 // Author(s): hmt
33 // Contributors: hmt
34 // Date: 1998-03-13
35 // Purpose: uITRON compatibility functions
36 // Description:
37 //
38 //####DESCRIPTIONEND####
39 //
40 //===========================================================================
41
42 #include <pkgconf/uitron.h> // uITRON setup CYGNUM_UITRON_SEMAS
43 // CYGPKG_UITRON et al
44
45 #ifdef CYGPKG_UITRON
46
47 // invoke the inline function definition to create static C linkage
48 // functions here:
49 #define CYGPRI_UITRON_FUNCS_HERE_AND_NOW
50 #include <cyg/compat/uitron/uit_func.h>
51
52 // ------------------------------------------------------------------------
53 // STARTUP
54 // this routine is outside the uITRON specification; call it from
55 // cyg_start(), cyg_package_start(), cyg_prestart() or cyg_user_start()
56 // to start the uITRON tasks and scheduler.
57
58 #if CYGNUM_UITRON_START_TASKS < 0
59 #error CYGNUM_UITRON_START_TASKS should be >= 0
60 #endif
61
62 #if CYGNUM_UITRON_START_TASKS == 0
63 #define START_TASKS CYGNUM_UITRON_TASKS
64 #else
65 #define START_TASKS CYGNUM_UITRON_START_TASKS
66 #endif
67
68 #ifdef CYGPKG_UITRON_TASKS_CREATE_DELETE
69 #if START_TASKS > CYGNUM_UITRON_TASKS_INITIALLY
70 #undef START_TASKS
71 #define START_TASKS CYGNUM_UITRON_TASKS_INITIALLY
72 #endif
73 #endif
74
75 #if START_TASKS > CYGNUM_UITRON_TASKS
76 #undef START_TASKS
77 #define START_TASKS CYGNUM_UITRON_TASKS
78 #endif
79
80 #if START_TASKS <= 0
81 #error Number of uITRON tasks to start initially must be >= 0
82 #endif
83
84
85 #define SET_UP_PTRS( _which_ ) CYG_MACRO_START \
86 for ( i = 0; \
87 (i < CYGNUM_UITRON_ ## _which_ ## _INITIALLY) && \
88 (i < CYGNUM_UITRON_ ## _which_ ) ; \
89 i++ ) { \
90 CYG_UITRON_PTRS( _which_ )[ i ] = CYG_UITRON_OBJS( _which_ ) + i; \
91 } \
92 for ( /* i as is */; i < CYGNUM_UITRON_ ## _which_ ; i++ ) { \
93 CYG_UITRON_PTRS( _which_ )[ i ] = NULL; \
94 } \
95 CYG_MACRO_END
96
97 void cyg_uitron_start( void )
98 {
99 cyg_int32 i;
100 for ( i = 0; i < START_TASKS; i++ ) {
101 #ifdef CYGIMP_THREAD_PRIORITY
102 // save the initial priority in our private array
103 cyg_uitron_task_initial_priorities[ i ] =
104 cyg_uitron_TASKS[ i ].get_priority();
105 #endif
106 // and awaken the task:
107 cyg_uitron_TASKS[ i ].resume();
108 }
109 for ( /* i as is */; i < CYGNUM_UITRON_TASKS; i++ ) {
110 #ifdef CYGIMP_THREAD_PRIORITY
111 // save the initial priority in our private array
112 cyg_uitron_task_initial_priorities[ i ] =
113 cyg_uitron_TASKS[ i ].get_priority();
114 #endif
115 // but ensure the task state is dormant.
116 cyg_uitron_TASKS[ i ].kill();
117 }
118
119 #ifdef CYGPKG_UITRON_TASKS_CREATE_DELETE
120 SET_UP_PTRS( TASKS );
121 #endif
122 #ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
123 SET_UP_PTRS( SEMAS );
124 #endif
125 #ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
126 SET_UP_PTRS( MBOXES );
127 #endif
128 #ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
129 SET_UP_PTRS( FLAGS );
130 #endif
131 #ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
132 SET_UP_PTRS( MEMPOOLFIXED );
133 #endif
134 #ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
135 SET_UP_PTRS( MEMPOOLVAR );
136 #endif
137 }
138
139 // These allow programs to link when cyg_uitron_start() is called
140 // (often because of CYGSEM_START_UITRON_COMPATIBILITY from infra,
141 // though we define these regardless just in case)
142 // even when there is no interest in uITRON and so the tasks are
143 // not externally defined; the reference to cyg_uitron_start()
144 // ensures the tasks array et al are still included...
145 extern "C" {
146 void task1( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
147 void task2( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
148 void task3( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
149 void task4( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
150 }
151
152 void task1( unsigned int arg ) {}
153 void task2( unsigned int arg ) {}
154 void task3( unsigned int arg ) {}
155 void task4( unsigned int arg ) {}
156
157 #endif // CYGPKG_UITRON
158
159 // EOF uit_func.cxx