1 |
27 |
unneback |
//===========================================================================
|
2 |
|
|
//
|
3 |
|
|
// uit_func.cxx
|
4 |
|
|
//
|
5 |
|
|
// uITRON compatibility functions
|
6 |
|
|
//
|
7 |
|
|
//===========================================================================
|
8 |
|
|
//####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//===========================================================================
|
41 |
|
|
//#####DESCRIPTIONBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// Author(s): hmt
|
44 |
|
|
// Contributors: hmt
|
45 |
|
|
// Date: 1998-03-13
|
46 |
|
|
// Purpose: uITRON compatibility functions
|
47 |
|
|
// Description:
|
48 |
|
|
//
|
49 |
|
|
//####DESCRIPTIONEND####
|
50 |
|
|
//
|
51 |
|
|
//===========================================================================
|
52 |
|
|
|
53 |
|
|
#include <pkgconf/uitron.h> // uITRON setup CYGNUM_UITRON_SEMAS
|
54 |
|
|
// CYGPKG_UITRON et al
|
55 |
|
|
|
56 |
|
|
#ifdef CYGPKG_UITRON
|
57 |
|
|
|
58 |
|
|
// invoke the inline function definition to create static C linkage
|
59 |
|
|
// functions here:
|
60 |
|
|
#define CYGPRI_UITRON_FUNCS_HERE_AND_NOW
|
61 |
|
|
#include <cyg/compat/uitron/uit_func.h>
|
62 |
|
|
|
63 |
|
|
cyg_uint32 cyg_uitron_dis_dsp_old_priority = 0;
|
64 |
|
|
|
65 |
|
|
// ------------------------------------------------------------------------
|
66 |
|
|
// STARTUP
|
67 |
|
|
// this routine is outside the uITRON specification; call it from
|
68 |
|
|
// cyg_start(), cyg_package_start(), cyg_prestart() or cyg_user_start()
|
69 |
|
|
// to start the uITRON tasks and scheduler.
|
70 |
|
|
|
71 |
|
|
#if CYGNUM_UITRON_START_TASKS < 0
|
72 |
|
|
#error CYGNUM_UITRON_START_TASKS should be >= 0
|
73 |
|
|
#endif
|
74 |
|
|
|
75 |
|
|
#if CYGNUM_UITRON_START_TASKS == 0
|
76 |
|
|
#define START_TASKS CYGNUM_UITRON_TASKS
|
77 |
|
|
#else
|
78 |
|
|
#define START_TASKS CYGNUM_UITRON_START_TASKS
|
79 |
|
|
#endif
|
80 |
|
|
|
81 |
|
|
#ifdef CYGPKG_UITRON_TASKS_CREATE_DELETE
|
82 |
|
|
#if START_TASKS > CYGNUM_UITRON_TASKS_INITIALLY
|
83 |
|
|
#undef START_TASKS
|
84 |
|
|
#define START_TASKS CYGNUM_UITRON_TASKS_INITIALLY
|
85 |
|
|
#endif
|
86 |
|
|
#endif
|
87 |
|
|
|
88 |
|
|
#if START_TASKS > CYGNUM_UITRON_TASKS
|
89 |
|
|
#undef START_TASKS
|
90 |
|
|
#define START_TASKS CYGNUM_UITRON_TASKS
|
91 |
|
|
#endif
|
92 |
|
|
|
93 |
|
|
#if START_TASKS <= 0
|
94 |
|
|
#error Number of uITRON tasks to start initially must be >= 0
|
95 |
|
|
#endif
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
#define SET_UP_PTRS( _which_ ) CYG_MACRO_START \
|
99 |
|
|
for ( i = 0; \
|
100 |
|
|
(i < CYGNUM_UITRON_ ## _which_ ## _INITIALLY) && \
|
101 |
|
|
(i < CYGNUM_UITRON_ ## _which_ ) ; \
|
102 |
|
|
i++ ) { \
|
103 |
|
|
CYG_UITRON_PTRS( _which_ )[ i ] = CYG_UITRON_OBJS( _which_ ) + i; \
|
104 |
|
|
} \
|
105 |
|
|
if ( (CYGNUM_UITRON_ ## _which_ ## _INITIALLY) \
|
106 |
|
|
< (CYGNUM_UITRON_ ## _which_) ) \
|
107 |
|
|
for ( /* i as is */; i < CYGNUM_UITRON_ ## _which_ ; i++ ) { \
|
108 |
|
|
CYG_UITRON_PTRS( _which_ )[ i ] = NULL; \
|
109 |
|
|
} \
|
110 |
|
|
CYG_MACRO_END
|
111 |
|
|
|
112 |
|
|
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK
|
113 |
|
|
#ifdef CYGSEM_UITRON_TIME_IS_MILLISECONDS
|
114 |
|
|
Cyg_Clock::converter uit_clock_to_system;
|
115 |
|
|
Cyg_Clock::converter uit_clock_from_system;
|
116 |
|
|
#endif
|
117 |
|
|
#endif
|
118 |
|
|
|
119 |
|
|
void cyg_uitron_start( void )
|
120 |
|
|
{
|
121 |
|
|
cyg_int32 i;
|
122 |
|
|
|
123 |
|
|
#ifdef CYGVAR_KERNEL_COUNTERS_CLOCK
|
124 |
|
|
#ifdef CYGSEM_UITRON_TIME_IS_MILLISECONDS
|
125 |
|
|
// initialize the clock converters
|
126 |
|
|
Cyg_Clock::real_time_clock->
|
127 |
|
|
get_other_to_clock_converter( 1000000, &uit_clock_to_system );
|
128 |
|
|
Cyg_Clock::real_time_clock->
|
129 |
|
|
get_clock_to_other_converter( 1000000, &uit_clock_from_system );
|
130 |
|
|
#endif
|
131 |
|
|
#endif
|
132 |
|
|
|
133 |
|
|
for ( i = 0; i < START_TASKS; i++ ) {
|
134 |
|
|
#ifdef CYGIMP_THREAD_PRIORITY
|
135 |
|
|
// save the initial priority in our private array
|
136 |
|
|
cyg_uitron_task_initial_priorities[ i ] =
|
137 |
|
|
cyg_uitron_TASKS[ i ].get_priority();
|
138 |
|
|
#endif
|
139 |
|
|
// and awaken the task:
|
140 |
|
|
cyg_uitron_TASKS[ i ].resume();
|
141 |
|
|
}
|
142 |
|
|
for ( /* i as is */; i < CYGNUM_UITRON_TASKS; i++ ) {
|
143 |
|
|
#ifdef CYGIMP_THREAD_PRIORITY
|
144 |
|
|
// save the initial priority in our private array
|
145 |
|
|
cyg_uitron_task_initial_priorities[ i ] =
|
146 |
|
|
cyg_uitron_TASKS[ i ].get_priority();
|
147 |
|
|
#endif
|
148 |
|
|
// but ensure the task state is dormant.
|
149 |
|
|
cyg_uitron_TASKS[ i ].kill();
|
150 |
|
|
}
|
151 |
|
|
|
152 |
|
|
#ifdef CYGPKG_UITRON_TASKS_CREATE_DELETE
|
153 |
|
|
SET_UP_PTRS( TASKS );
|
154 |
|
|
#endif
|
155 |
|
|
#ifdef CYGPKG_UITRON_SEMAS_CREATE_DELETE
|
156 |
|
|
SET_UP_PTRS( SEMAS );
|
157 |
|
|
#endif
|
158 |
|
|
#ifdef CYGPKG_UITRON_MBOXES_CREATE_DELETE
|
159 |
|
|
SET_UP_PTRS( MBOXES );
|
160 |
|
|
#endif
|
161 |
|
|
#ifdef CYGPKG_UITRON_FLAGS_CREATE_DELETE
|
162 |
|
|
SET_UP_PTRS( FLAGS );
|
163 |
|
|
#endif
|
164 |
|
|
#ifdef CYGPKG_UITRON_MEMPOOLFIXED_CREATE_DELETE
|
165 |
|
|
SET_UP_PTRS( MEMPOOLFIXED );
|
166 |
|
|
#endif
|
167 |
|
|
#ifdef CYGPKG_UITRON_MEMPOOLVAR_CREATE_DELETE
|
168 |
|
|
SET_UP_PTRS( MEMPOOLVAR );
|
169 |
|
|
#endif
|
170 |
|
|
}
|
171 |
|
|
|
172 |
|
|
// These allow programs to link when cyg_uitron_start() is called
|
173 |
|
|
// (often because of CYGSEM_START_UITRON_COMPATIBILITY from infra,
|
174 |
|
|
// though we define these regardless just in case)
|
175 |
|
|
// even when there is no interest in uITRON and so the tasks are
|
176 |
|
|
// not externally defined; the reference to cyg_uitron_start()
|
177 |
|
|
// ensures the tasks array et al are still included...
|
178 |
|
|
extern "C" {
|
179 |
|
|
void task1( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
|
180 |
|
|
void task2( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
|
181 |
|
|
void task3( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
|
182 |
|
|
void task4( unsigned int arg ) CYGBLD_ATTRIB_WEAK;
|
183 |
|
|
}
|
184 |
|
|
|
185 |
|
|
void task1( unsigned int arg ) {}
|
186 |
|
|
void task2( unsigned int arg ) {}
|
187 |
|
|
void task3( unsigned int arg ) {}
|
188 |
|
|
void task4( unsigned int arg ) {}
|
189 |
|
|
|
190 |
|
|
#endif // CYGPKG_UITRON
|
191 |
|
|
|
192 |
|
|
// EOF uit_func.cxx
|