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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [compat/] [uitron/] [v2_0/] [include/] [uit_ifnc.inl] - Blame information for rev 773

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

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

powered by: WebSVN 2.1.0

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