FreeCalypso > hg > fc-tourmaline
view src/g23m-aci/aci/cmh_raf.c @ 220:0ed36de51973
ABB semaphore protection overhaul
The ABB semaphone protection logic that came with TCS211 from TI
was broken in several ways:
* Some semaphore-protected functions were called from Application_Initialize()
context. NU_Obtain_Semaphore() called with NU_SUSPEND fails with
NU_INVALID_SUSPEND in this context, but the return value wasn't checked,
and NU_Release_Semaphore() would be called unconditionally at the end.
The latter call would increment the semaphore count past 1, making the
semaphore no longer binary and thus no longer effective for resource
protection. The fix is to check the return value from NU_Obtain_Semaphore()
and skip the NU_Release_Semaphore() call if the semaphore wasn't properly
obtained.
* Some SPI hardware manipulation was being done before entering the semaphore-
protected critical section. The fix is to reorder the code: first obtain
the semaphore, then do everything else.
* In the corner case of L1/DSP recovery, l1_abb_power_on() would call some
non-semaphore-protected ABB & SPI init functions. The fix is to skip those
calls in the case of recovery.
* A few additional corner cases existed, all of which are fixed by making
ABB semaphore protection 100% consistent for all ABB functions and code paths.
There is still one remaining problem of priority inversion: suppose a low-
priority task calls an ABB function, and some medium-priority task just happens
to preempt right in the middle of that semaphore-protected ABB operation. Then
the high-priority SPI task is locked out for a non-deterministic time until
that medium-priority task finishes its work and goes back to sleep. This
priority inversion problem remains outstanding for now.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 26 Apr 2021 20:55:25 +0000 |
parents | fa8dc04885d8 |
children |
line wrap: on
line source
/* +----------------------------------------------------------------------------- | Project : GSM-PS (6147) | Modul : CMH_RAF +----------------------------------------------------------------------------- | Copyright 2002 Texas Instruments Berlin, AG | All rights reserved. | | This file is confidential and a trade secret of Texas | Instruments Berlin, AG | The receipt of or possession of this file does not convey | any rights to reproduce or disclose its contents or to | manufacture, use, or sell anything it may describe, in | whole, or in part, without the specific written consent of | Texas Instruments Berlin, AG. +----------------------------------------------------------------------------- | Purpose : This module defines the functions used by the command | handler for RA. +----------------------------------------------------------------------------- */ #ifdef DTI #ifndef CMH_RAF_C #define CMH_RAF_C #endif #include "aci_all.h" /*==== INCLUDES ===================================================*/ #include "aci_cmh.h" #include "ati_cmd.h" #include "aci_cmd.h" #ifdef FAX_AND_DATA #include "aci_fd.h" #endif /* of #ifdef FAX_AND_DATA */ #include "aci.h" #include "psa.h" #include "aci_io.h" #include "psa_ra.h" #include "psa_cc.h" #include "cmh.h" #include "cmh_ra.h" #include "cmh_cc.h" /*==== CONSTANTS ==================================================*/ /*==== TYPES ======================================================*/ /*==== EXPORT =====================================================*/ /*==== VARIABLES ==================================================*/ /*==== FUNCTIONS ==================================================*/ /* +-------------------------------------------------------------------+ | PROJECT : GSM-PS (6147) MODULE : CMH_RA | | ROUTINE : cmhRA_SelTrfProt | +-------------------------------------------------------------------+ PURPOSE : select transfer protocol */ GLOBAL UBYTE cmhRA_SelTrfProt( SHORT cId ) { switch( cmhCC_getcalltype(cId) ) { case( TRANS_CALL ): return( RA_MODEL_TRANS ); case( NON_TRANS_CALL ): return( RA_MODEL_RLP ); case( FAX_CALL ): return( RA_MODEL_FAX ); #ifdef CO_UDP_IP /* a WAP call should be a non-transparent call for RA */ case( UDPIP_CALL ): return( RA_MODEL_RLP ); #endif #ifdef FF_PPP case( PPP_CALL ): return( RA_MODEL_RLP ); #endif /* FF_PPP */ #if defined(FF_GPF_TCPIP) case TCPIP_CALL: return RA_MODEL_RLP ; #endif /* FF_GPF_TCPIP */ default: TRACE_EVENT( "UNEXP TYPE OF CALL IN CTB" ); return( NOT_PRESENT_8BIT ); } } /* +-------------------------------------------------------------------+ | PROJECT : GSM-PS (6147) MODULE : CMH_RA | | ROUTINE : cmhRA_SelChnRate | +-------------------------------------------------------------------+ PURPOSE : select channel rate */ GLOBAL UBYTE cmhRA_SelChnRate ( void ) { switch( ccShrdPrm.chType ) { case( MNCC_CH_TCH_F ): switch( ccShrdPrm.chMod ) { case( MNCC_CHM_DATA_14_4 ): return( TRA_FULLRATE_14400 ); case( MNCC_CHM_DATA_9_6 ): return( TRA_FULLRATE_9600 ); case( MNCC_CHM_DATA_4_8 ): return( TRA_FULLRATE_4800 ); case( MNCC_CHM_DATA_2_4 ): return( TRA_FULLRATE_2400 ); default: TRACE_EVENT( "UNEXP CHN MODE IN CTB" ); return((UBYTE)-1); /* return type is UBYTE,so return type is typecasted with UBYTE */ } case( MNCC_CH_TCH_H ): switch( ccShrdPrm.chMod ) { case( MNCC_CHM_DATA_2_4 ): return( TRA_HALFRATE_2400 ); case( MNCC_CHM_DATA_4_8 ): return( TRA_HALFRATE_4800 ); case( MNCC_CHM_DATA_14_4 ): case( MNCC_CHM_DATA_9_6 ): default: TRACE_EVENT( "UNEXP CHN MODE IN CTB" ); return((UBYTE)-1); /* return type is UBYTE,so return type is typecasted with UBYTE */ } default: TRACE_EVENT( "UNEXP CHN TYPE IN CTB" ); return((UBYTE)-1); /* return type is UBYTE,so return type is typecasted with UBYTE */ } } /* +-------------------------------------------------------------------+ | PROJECT : GSM-PS (6147) MODULE : CMH_RA | | ROUTINE : cmhRA_SelChnRate | +-------------------------------------------------------------------+ PURPOSE : select channel rate */ GLOBAL UBYTE cmhRA_SelUsrRate( SHORT cId ) { if (ccShrdPrm.ctb[cId] EQ NULL) return NOT_PRESENT_8BIT; switch (psaCC_ctb(cId)->BC[psaCC_ctb(cId)->curBC].rate) { case( MNCC_UR_0_3_KBIT ): return( URA_300 ); case( MNCC_UR_1_2_KBIT ): return( URA_1200 ); case( MNCC_UR_2_4_KBIT ): return( URA_2400 ); case( MNCC_UR_4_8_KBIT ): return( URA_4800 ); case( MNCC_UR_9_6_KBIT ): return( URA_9600 ); case( MNCC_UR_1_2_KBIT_V23 ): return( URA_1200_75 ); case( MNCC_UR_12_0_KBIT_TRANS): return( URA_14400 ); case( 8 ): return( URA_14400 ); /* !!! change if SAP is updated */ default: TRACE_EVENT( "UNEXP USER RATE IN CTB" ); return( NOT_PRESENT_8BIT ); } } /* +-------------------------------------------------------------------+ | PROJECT : GSM-PS (6147) MODULE : CMH_RA | | ROUTINE : cmhRA_SelDataBits | +-------------------------------------------------------------------+ PURPOSE : select number of data bits */ GLOBAL UBYTE cmhRA_SelDataBits( SHORT cId ) { if (ccShrdPrm.ctb[cId] EQ NULL) return NOT_PRESENT_8BIT; switch (psaCC_ctb(cId)->BC[psaCC_ctb(cId)->curBC].data_bits) { case( MNCC_DATA_7_BIT ): return( 7 ); case( MNCC_DATA_8_BIT ): return( 8 ); default: TRACE_EVENT( "UNEXP NR OF DATA BITS IN CTB" ); return( NOT_PRESENT_8BIT ); } } /* +-------------------------------------------------------------------+ | PROJECT : GSM-PS (6147) MODULE : CMH_RA | | ROUTINE : cmhRA_SelStopBits | +-------------------------------------------------------------------+ PURPOSE : select number of stop bits */ GLOBAL UBYTE cmhRA_SelStopBits( SHORT cId ) { if (ccShrdPrm.ctb[cId] EQ NULL) return NOT_PRESENT_8BIT; switch (psaCC_ctb(cId)->BC[psaCC_ctb(cId)->curBC].stop_bits) { case( MNCC_STOP_1_BIT ): return( 1 ); case( MNCC_STOP_2_BIT ): return( 2 ); default: TRACE_EVENT( "UNEXP NR OF STOP BITS IN CTB" ); return( NOT_PRESENT_8BIT ); } } #ifdef FF_FAX /* +-------------------------------------------------------------------+ | PROJECT : GSM-PS (6147) MODULE : CMH_RA | | ROUTINE : cmhRA_SelBitOrder | +-------------------------------------------------------------------+ PURPOSE : select bit order */ GLOBAL UBYTE cmhRA_SelBitOrder( T_ACI_CMD_SRC srcId ) { switch( fnd_cmhPrm[srcId].t30CmdPrm.FBOval ) { case( FBO_VAL_DirCDirBD ): return( FBO_NRM_STATUS + FBO_NRM_DATA ); case( FBO_VAL_RvrCDirBD ): return( FBO_NRM_STATUS + FBO_REV_DATA ); case( FBO_VAL_DirCRvrBD ): return( FBO_REV_STATUS + FBO_NRM_DATA ); case( FBO_VAL_RvrCRvrBD ): return( FBO_REV_STATUS + FBO_REV_DATA ); default: TRACE_EVENT( "UNEXP FBO VALUE" ); return( NOT_PRESENT_8BIT ); } } #endif /* FF_FAX */ #endif /* DTI */ /*==== EOF ========================================================*/