1 #ifndef CYGONCE_COMPAT_UITRON_UIT_IFNC_INL
2 #define CYGONCE_COMPAT_UITRON_UIT_IFNC_INL
3 //===========================================================================
7 // uITRON compatibility functions
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.
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.
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
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.
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.
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.
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####
48 // Purpose: uITRON compatibility functions
51 //####DESCRIPTIONEND####
53 //===========================================================================
57 #ifdef CYGPRI_UITRON_FUNCS_HERE_AND_NOW
59 class Cyg_Uit_Action {
69 extern volatile int cyg_uit_dsr_actions_head;
70 extern volatile int cyg_uit_dsr_actions_tail;
72 #define CYGNUM_UITRON_ISR_ACTION_QUEUEMASK (CYGNUM_UITRON_ISR_ACTION_QUEUESIZE-1)
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
80 extern Cyg_Uit_Action::action
81 cyg_uit_dsr_actions[ CYGNUM_UITRON_ISR_ACTION_QUEUESIZE ];
84 cyg_uit_dsr_act_ids[ CYGNUM_UITRON_ISR_ACTION_QUEUESIZE ];
87 cyg_uit_dsr_act_a1s[ CYGNUM_UITRON_ISR_ACTION_QUEUESIZE ];
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 );
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;
116 #ifdef CYGPKG_UITRON_SEMAS
117 #if 0 < CYG_UITRON_NUM( SEMAS )
120 isig_sem ( ID semid )
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 );
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;
144 #endif // 0 < CYG_UITRON_NUM( SEMAS )
145 #endif // CYGPKG_UITRON_SEMAS
147 #ifdef CYGPKG_UITRON_FLAGS
148 #if 0 < CYG_UITRON_NUM( FLAGS )
151 iset_flg ( ID flgid, UINT setptn )
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 );
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;
176 #endif // 0 < CYG_UITRON_NUM( FLAGS )
177 #endif // CYGPKG_UITRON_FLAGS
179 #ifdef CYGPKG_UITRON_MBOXES
180 #if 0 < CYG_UITRON_NUM( MBOXES )
183 isnd_msg ( ID mbxid, T_MSG *pk_msg )
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 );
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;
208 #endif // 0 < CYG_UITRON_NUM( MBOXES )
209 #endif // CYGPKG_UITRON_MBOXES
211 // ========================================================================
213 #endif // CYGPKG_UITRON
215 #endif // CYGPRI_UITRON_FUNCS_HERE_AND_NOW
217 #endif // CYGONCE_COMPAT_UITRON_UIT_IFNC_INL