OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [uitron/] [current/] [src/] [uit_func.cxx] - Blame information for rev 810

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.