|
0
|
1 //=========================================================================== |
|
|
2 // |
|
2
|
3 // uit_func.cxx |
|
0
|
4 // |
|
2
|
5 // uITRON compatibility functions |
|
0
|
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 |
|
2
|
25 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
26 // ------------------------------------------- |
|
|
27 // |
|
|
28 //####COPYRIGHTEND#### |
|
|
29 //=========================================================================== |
|
|
30 //#####DESCRIPTIONBEGIN#### |
|
|
31 // |
|
2
|
32 // Author(s): hmt |
|
|
33 // Contributors: hmt |
|
|
34 // Date: 1998-03-13 |
|
|
35 // Purpose: uITRON compatibility functions |
|
|
36 // Description: |
|
0
|
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 |
|
2
|
52 cyg_uint32 cyg_uitron_dis_dsp_old_priority = 0; |
|
|
53 |
|
0
|
54 // ------------------------------------------------------------------------ |
|
|
55 // STARTUP |
|
|
56 // this routine is outside the uITRON specification; call it from |
|
|
57 // cyg_start(), cyg_package_start(), cyg_prestart() or cyg_user_start() |
|
|
58 // to start the uITRON tasks and scheduler. |
|
|
59 |
|
|
60 #if CYGNUM_UITRON_START_TASKS < 0 |
|
|
61 #error CYGNUM_UITRON_START_TASKS should be >= 0 |
|
|
62 #endif |
|
|
63 |
|
|
64 #if CYGNUM_UITRON_START_TASKS == 0 |
|
|
65 #define START_TASKS CYGNUM_UITRON_TASKS |
|
|
66 #else |
|
|
67 #define START_TASKS CYGNUM_UITRON_START_TASKS |
|
|
68 #endif |
|
|
69 |
|
|
70 #ifdef CYGPKG_UITRON_TASKS_CREATE_DELETE |
|
|
71 #if START_TASKS > CYGNUM_UITRON_TASKS_INITIALLY |
|
|
72 #undef START_TASKS |
|
|
73 #define START_TASKS CYGNUM_UITRON_TASKS_INITIALLY |
|
|
74 #endif |
|
|
75 #endif |
|
|
76 |
|
|
77 #if START_TASKS > CYGNUM_UITRON_TASKS |
|
|
78 #undef START_TASKS |
|
|
79 #define START_TASKS CYGNUM_UITRON_TASKS |
|
|
80 #endif |
|
|
81 |
|
|
82 #if START_TASKS <= 0 |
|
|
83 #error Number of uITRON tasks to start initially must be >= 0 |
|
|
84 #endif |
|
|
85 |
|
|
86 |
|
2
|
87 #define SET_UP_PTRS( _which_ ) CYG_MACRO_START \ |
|
0
|
88 for ( i = 0; \ |
|
|
89 (i < CYGNUM_UITRON_ ## _which_ ## _INITIALLY) && \ |
|
|
90 (i < CYGNUM_UITRON_ ## _which_ ) ; \ |
|
|
91 i++ ) { \ |
|
|
92 CYG_UITRON_PTRS( _which_ )[ i ] = CYG_UITRON_OBJS( _which_ ) + i; \ |
|
|
93 } \ |
|
2
|
94 if ( (CYGNUM_UITRON_ ## _which_ ## _INITIALLY) \ |
|
|
95 < (CYGNUM_UITRON_ ## _which_) ) \ |
|
|
96 for ( /* i as is */; i < CYGNUM_UITRON_ ## _which_ ; i++ ) { \ |
|
|
97 CYG_UITRON_PTRS( _which_ )[ i ] = NULL; \ |
|
|
98 } \ |
|
0
|
99 CYG_MACRO_END |
|
|
100 |
|
|
101 void cyg_uitron_start( void ) |
|
|
102 { |
|
|
103 cyg_int32 i; |
|
|
104 for ( i = 0; i < START_TASKS; i++ ) { |
|
|
105 #ifdef CYGIMP_THREAD_PRIORITY |
|
|
106 // save the initial priority in our private array |
|
|
107 cyg_uitron_task_initial_priorities[ i ] = |
|
|
108 cyg_uitron_TASKS[ i ].get_priority(); |
|
|
109 #endif |
|
|
110 // and awaken the task: |
|
|
111 cyg_uitron_TASKS[ i ].resume(); |
|
|
112 } |
|
|
113 for ( /* i as is */; i < CYGNUM_UITRON_TASKS; i++ ) { |
|
|
114 #ifdef CYGIMP_THREAD_PRIORITY |
|
|
115 // save the initial priority in our private array |
|
|
116 cyg_uitron_task_initial_priorities[ i ] = |
|
|
117 cyg_uitron_TASKS[ i ].get_priority(); |
|
|
118 #endif |
|
|
119 // but ensure the task state is dormant. |
|
|
120 cyg_uitron_TASKS[ i ].kill(); |
|
|
121 } |
|
|
122 |
|
|
123 #ifdef CYGPKG_UITRON_TASKS_CREATE_DELETE |
|
|
124 SET_UP_PTRS( TASKS ); |
|
|
125 #endif |
|
|
126 #ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE |
|
|
127 SET_UP_PTRS( SEMAS ); |
|
|
128 #endif |
|
|
129 #ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE |
|
|
130 SET_UP_PTRS( MBOXES ); |
|
|
131 #endif |
|
|
132 #ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE |
|
|
133 SET_UP_PTRS( FLAGS ); |
|
|
134 #endif |
|
|
135 #ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE |
|
|
136 SET_UP_PTRS( MEMPOOLFIXED ); |
|
|
137 #endif |
|
|
138 #ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE |
|
|
139 SET_UP_PTRS( MEMPOOLVAR ); |
|
|
140 #endif |
|
|
141 } |
|
|
142 |
|
|
143 // These allow programs to link when cyg_uitron_start() is called |
|
|
144 // (often because of CYGSEM_START_UITRON_COMPATIBILITY from infra, |
|
|
145 // though we define these regardless just in case) |
|
|
146 // even when there is no interest in uITRON and so the tasks are |
|
|
147 // not externally defined; the reference to cyg_uitron_start() |
|
|
148 // ensures the tasks array et al are still included... |
|
|
149 extern "C" { |
|
|
150 void task1( unsigned int arg ) CYGBLD_ATTRIB_WEAK; |
|
|
151 void task2( unsigned int arg ) CYGBLD_ATTRIB_WEAK; |
|
|
152 void task3( unsigned int arg ) CYGBLD_ATTRIB_WEAK; |
|
|
153 void task4( unsigned int arg ) CYGBLD_ATTRIB_WEAK; |
|
|
154 } |
|
|
155 |
|
|
156 void task1( unsigned int arg ) {} |
|
|
157 void task2( unsigned int arg ) {} |
|
|
158 void task3( unsigned int arg ) {} |
|
|
159 void task4( unsigned int arg ) {} |
|
|
160 |
|
|
161 #endif // CYGPKG_UITRON |
|
|
162 |
|
|
163 // EOF uit_func.cxx |