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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [compat/] [uitron/] [current/] [include/] [uit_ifnc.inl] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
#ifndef CYGONCE_COMPAT_UITRON_UIT_IFNC_INL
2
#define CYGONCE_COMPAT_UITRON_UIT_IFNC_INL
3
//===========================================================================
4
//
5
//      uit_ifnc.inl
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 Free Software Foundation, 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
18
// version.
19
//
20
// eCos is distributed in the hope that it will be useful, but WITHOUT
21
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
23
// for more details.
24
//
25
// You should have received a copy of the GNU General Public License
26
// along with eCos; if not, write to the Free Software Foundation, Inc.,
27
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
28
//
29
// As a special exception, if other files instantiate templates or use
30
// macros or inline functions from this file, or you compile this file
31
// and link it with other works to produce a work based on this file,
32
// this file does not by itself cause the resulting work to be covered by
33
// the GNU General Public License. However the source code for this file
34
// must still be made available in accordance with section (3) of the GNU
35
// General Public License v2.
36
//
37
// This exception does not invalidate any other reasons why a work based
38
// on this file might be covered by the GNU General Public License.
39
// -------------------------------------------
40
// ####ECOSGPLCOPYRIGHTEND####
41
//===========================================================================
42
//#####DESCRIPTIONBEGIN####
43
//
44
// Author(s):   hmt
45
// Contributors:        hmt
46
// Date:        1999-08-16
47
// Purpose:     uITRON compatibility functions
48
// Description:
49
//
50
//####DESCRIPTIONEND####
51
//
52
//===========================================================================
53
 
54
#ifdef CYGPKG_UITRON
55
 
56
#ifdef CYGPRI_UITRON_FUNCS_HERE_AND_NOW
57
 
58
class Cyg_Uit_Action {
59
public:
60
    typedef enum {
61
        WUP_TSK,
62
        SIG_SEM,
63
        SET_FLG,
64
        SND_MSG
65
    } action;
66
};
67
 
68
extern volatile int cyg_uit_dsr_actions_head;
69
extern volatile int cyg_uit_dsr_actions_tail;
70
 
71
#define CYGNUM_UITRON_ISR_ACTION_QUEUEMASK (CYGNUM_UITRON_ISR_ACTION_QUEUESIZE-1)
72
 
73
#if ((~CYGNUM_UITRON_ISR_ACTION_QUEUEMASK) &            \
74
     ~((~CYGNUM_UITRON_ISR_ACTION_QUEUEMASK)-1))        \
75
    != CYGNUM_UITRON_ISR_ACTION_QUEUESIZE
76
#error CYGNUM_UITRON_ISR_ACTION_QUEUESIZE not a power of 2
77
#endif
78
 
79
extern Cyg_Uit_Action::action
80
cyg_uit_dsr_actions[ CYGNUM_UITRON_ISR_ACTION_QUEUESIZE ];
81
 
82
extern ID
83
cyg_uit_dsr_act_ids[ CYGNUM_UITRON_ISR_ACTION_QUEUESIZE ];
84
 
85
extern CYG_ADDRWORD
86
cyg_uit_dsr_act_a1s[ CYGNUM_UITRON_ISR_ACTION_QUEUESIZE ];
87
 
88
CYG_UIT_FUNC_INLINE
89
ER
90
iwup_tsk ( ID tskid )
91
{
92
#ifdef CYGSEM_UITRON_ISRFUNCS_TRY_IMMEDIATE_EXECUTION
93
    if ( 1 >= Cyg_Scheduler::get_sched_lock() ) {
94
        // then this ISR is the first one, and the sched was locked by the
95
        // interrupt code.  So this is safe.
96
        return wup_tsk( tskid );
97
    }
98
#endif
99
 
100
    register int i, head;
101
    i = cyg_uit_dsr_actions_head;
102
    head = CYGNUM_UITRON_ISR_ACTION_QUEUEMASK & ( 1 + i );
103
    // If interrupts can be recursive, then there is a race here where a
104
    // slot may be overwritten by a recursive interrupt, or actions from
105
    // such lost; better though than having a slot contain *mixed* data
106
    // from two intermingled interrupts.
107
    if ( head != cyg_uit_dsr_actions_tail ) {
108
        cyg_uit_dsr_actions_head = head;
109
        cyg_uit_dsr_actions[ i ] = Cyg_Uit_Action::WUP_TSK;
110
        cyg_uit_dsr_act_ids[ i ] = tskid;
111
    }
112
    return E_OK;
113
}
114
 
115
#ifdef CYGPKG_UITRON_SEMAS
116
#if 0 < CYG_UITRON_NUM( SEMAS )
117
CYG_UIT_FUNC_INLINE
118
ER
119
isig_sem ( ID semid )
120
{
121
#ifdef CYGSEM_UITRON_ISRFUNCS_TRY_IMMEDIATE_EXECUTION
122
    if ( 1 >= Cyg_Scheduler::get_sched_lock() ) {
123
        // then this ISR is the first one, and the sched was locked by the
124
        // interrupt code.  So this is safe.
125
        return sig_sem( semid );
126
    }
127
#endif
128
 
129
    register int i, head;
130
    i = cyg_uit_dsr_actions_head;
131
    head = CYGNUM_UITRON_ISR_ACTION_QUEUEMASK & ( 1 + i );
132
    // If interrupts can be recursive, then there is a race here where a
133
    // slot may be overwritten by a recursive interrupt, or actions from
134
    // such lost; better though than having a slot contain *mixed* data
135
    // from two intermingled interrupts.
136
    if ( head != cyg_uit_dsr_actions_tail ) {
137
        cyg_uit_dsr_actions_head = head;
138
        cyg_uit_dsr_actions[ i ] = Cyg_Uit_Action::SIG_SEM;
139
        cyg_uit_dsr_act_ids[ i ] = semid;
140
    }
141
    return E_OK;
142
}
143
#endif // 0 < CYG_UITRON_NUM( SEMAS )
144
#endif // CYGPKG_UITRON_SEMAS
145
 
146
#ifdef CYGPKG_UITRON_FLAGS
147
#if 0 < CYG_UITRON_NUM( FLAGS )
148
CYG_UIT_FUNC_INLINE
149
ER
150
iset_flg ( ID flgid, UINT setptn )
151
{
152
#ifdef CYGSEM_UITRON_ISRFUNCS_TRY_IMMEDIATE_EXECUTION
153
    if ( 1 >= Cyg_Scheduler::get_sched_lock() ) {
154
        // then this ISR is the first one, and the sched was locked by the
155
        // interrupt code.  So this is safe.
156
        return set_flg( flgid, setptn );
157
    }
158
#endif
159
 
160
    register int i, head;
161
    i = cyg_uit_dsr_actions_head;
162
    head = CYGNUM_UITRON_ISR_ACTION_QUEUEMASK & ( 1 + i );
163
    // If interrupts can be recursive, then there is a race here where a
164
    // slot may be overwritten by a recursive interrupt, or actions from
165
    // such lost; better though than having a slot contain *mixed* data
166
    // from two intermingled interrupts.
167
    if ( head != cyg_uit_dsr_actions_tail ) {
168
        cyg_uit_dsr_actions_head = head;
169
        cyg_uit_dsr_actions[ i ] = Cyg_Uit_Action::SET_FLG;
170
        cyg_uit_dsr_act_ids[ i ] = flgid;
171
        cyg_uit_dsr_act_a1s[ i ] = (CYG_ADDRWORD)setptn;
172
    }
173
    return E_OK;
174
}
175
#endif // 0 < CYG_UITRON_NUM( FLAGS )
176
#endif // CYGPKG_UITRON_FLAGS
177
 
178
#ifdef CYGPKG_UITRON_MBOXES
179
#if 0 < CYG_UITRON_NUM( MBOXES )
180
CYG_UIT_FUNC_INLINE
181
ER
182
isnd_msg ( ID mbxid, T_MSG *pk_msg )
183
{
184
#ifdef CYGSEM_UITRON_ISRFUNCS_TRY_IMMEDIATE_EXECUTION
185
    if ( 1 >= Cyg_Scheduler::get_sched_lock() ) {
186
        // then this ISR is the first one, and the sched was locked by the
187
        // interrupt code.  So this is safe.
188
        return snd_msg( mbxid, pk_msg );
189
    }
190
#endif
191
 
192
    register int i, head;
193
    i = cyg_uit_dsr_actions_head;
194
    head = CYGNUM_UITRON_ISR_ACTION_QUEUEMASK & ( 1 + i );
195
    // If interrupts can be recursive, then there is a race here where a
196
    // slot may be overwritten by a recursive interrupt, or actions from
197
    // such lost; better though than having a slot contain *mixed* data
198
    // from two intermingled interrupts.
199
    if ( head != cyg_uit_dsr_actions_tail ) {
200
        cyg_uit_dsr_actions_head = head;
201
        cyg_uit_dsr_actions[ i ] = Cyg_Uit_Action::SND_MSG;
202
        cyg_uit_dsr_act_ids[ i ] = mbxid;
203
        cyg_uit_dsr_act_a1s[ i ] = (CYG_ADDRWORD)pk_msg;
204
    }
205
    return E_OK;
206
}
207
#endif // 0 < CYG_UITRON_NUM( MBOXES )
208
#endif // CYGPKG_UITRON_MBOXES
209
 
210
// ========================================================================
211
 
212
#endif // CYGPKG_UITRON
213
 
214
#endif // CYGPRI_UITRON_FUNCS_HERE_AND_NOW
215
 
216
#endif // CYGONCE_COMPAT_UITRON_UIT_IFNC_INL
217
//EOF uit_ifnc.inl

powered by: WebSVN 2.1.0

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