view src/cs/layer1/p_include/l1p_sign.h @ 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 4e78acac3d88
children
line wrap: on
line source

/************* Revision Controle System Header *************
 *                  GSM Layer 1 software 
 * L1P_SIGN.H
 *
 *        Filename l1p_sign.h
 *  Copyright 2003 (C) Texas Instruments  
 *
 ************* Revision Controle System Header *************/

#define P_GPRS  ( P_L1C + 2 )

// Messages Packet Transfer <-> L1A
#define MPHP_SINGLE_BLOCK_REQ             ( ( P_GPRS << 8 ) | 1  )
#define MPHP_SINGLE_BLOCK_CON             ( ( P_GPRS << 8 ) | 2  )
#define MPHP_STOP_SINGLE_BLOCK_REQ        ( ( P_GPRS << 8 ) | 3  )
#define MPHP_STOP_SINGLE_BLOCK_CON        ( ( P_GPRS << 8 ) | 4  )
#define L1P_SINGLE_BLOCK_CON              ( ( P_GPRS << 8 ) | 5  )

#define MPHP_ASSIGNMENT_REQ               ( ( P_GPRS << 8 ) | 6  )
#define MPHP_ASSIGNMENT_CON               ( ( P_GPRS << 8 ) | 7  )

#define MPHP_TBF_RELEASE_REQ              ( ( P_GPRS << 8 ) | 8  )
#define MPHP_TBF_RELEASE_CON              ( ( P_GPRS << 8 ) | 9  )

#define MPHP_REPEAT_UL_FIXED_ALLOC_REQ    ( ( P_GPRS << 8 ) | 10 )
#define MPHP_REPEAT_UL_FIXED_ALLOC_CON    ( ( P_GPRS << 8 ) | 11 )

#define MPHP_PDCH_RELEASE_REQ             ( ( P_GPRS << 8 ) | 12 )
#define MPHP_PDCH_RELEASE_CON             ( ( P_GPRS << 8 ) | 13 )

#define MPHP_TIMING_ADVANCE_REQ           ( ( P_GPRS << 8 ) | 14 )
#define MPHP_TIMING_ADVANCE_CON           ( ( P_GPRS << 8 ) | 15 )

#define MPHP_UPDATE_PSI_PARAM_REQ         ( ( P_GPRS << 8 ) | 16 )
#define MPHP_UPDATE_PSI_PARAM_CON         ( ( P_GPRS << 8 ) | 17 )


#define MPHP_RA_REQ                       ( ( P_GPRS << 8 ) | 18 )
#define MPHP_RA_CON                       ( ( P_GPRS << 8 ) | 19 )
#define MPHP_RA_STOP_REQ                  ( ( P_GPRS << 8 ) | 20 )
#define MPHP_RA_STOP_CON                  ( ( P_GPRS << 8 ) | 21 )

#define MPHP_POLLING_RESPONSE_REQ         ( ( P_GPRS << 8 ) | 22 )
#define MPHP_POLLING_IND                  ( ( P_GPRS << 8 ) | 23 )

#define L1P_RA_DONE                       ( ( P_GPRS << 8 ) | 24 )

// Messages Packet Idle <-> L1A
#define MPHP_START_PCCCH_REQ              ( ( P_GPRS << 8 ) | 25 )
#define MPHP_STOP_PCCCH_REQ               ( ( P_GPRS << 8 ) | 26 )
#define MPHP_STOP_PCCCH_CON               ( ( P_GPRS << 8 ) | 27 )
#define MPHP_SCELL_PBCCH_REQ              ( ( P_GPRS << 8 ) | 28 )
#define MPHP_SCELL_PBCCH_STOP_REQ         ( ( P_GPRS << 8 ) | 29 )
#define MPHP_SCELL_PBCCH_STOP_CON         ( ( P_GPRS << 8 ) | 30 )
#define MPHP_CR_MEAS_REQ                  ( ( P_GPRS << 8 ) | 31 )
#define MPHP_CR_MEAS_STOP_REQ             ( ( P_GPRS << 8 ) | 32 )
#define MPHP_CR_MEAS_STOP_CON             ( ( P_GPRS << 8 ) | 33 )
#define MPHP_INT_MEAS_REQ                 ( ( P_GPRS << 8 ) | 34 )
#define MPHP_INT_MEAS_STOP_REQ            ( ( P_GPRS << 8 ) | 35 )
#define MPHP_INT_MEAS_STOP_CON            ( ( P_GPRS << 8 ) | 36 )
#define MPHP_NCELL_PBCCH_REQ              ( ( P_GPRS << 8 ) | 37 )
#define MPHP_NCELL_PBCCH_STOP_REQ         ( ( P_GPRS << 8 ) | 38 )
#define MPHP_NCELL_PBCCH_STOP_CON         ( ( P_GPRS << 8 ) | 39 )

#define MPHP_DATA_IND                     ( ( P_GPRS << 8 ) | 40 )
#define MPHP_CR_MEAS_IND                  ( ( P_GPRS << 8 ) | 41 )
#define MPHP_INT_MEAS_IND                 ( ( P_GPRS << 8 ) | 42 )
#define MPHP_TINT_MEAS_IND                ( ( P_GPRS << 8 ) | 43 )
#define MPHP_NCELL_PBCCH_IND              ( ( P_GPRS << 8 ) | 44 )
#define MPHP_TCR_MEAS_REQ                 ( ( P_GPRS << 8 ) | 45 )
#define MPHP_TCR_MEAS_IND                 ( ( P_GPRS << 8 ) | 46 )
#define MPHP_TCR_MEAS_STOP_REQ            ( ( P_GPRS << 8 ) | 47 )
#define MPHP_TCR_MEAS_STOP_CON            ( ( P_GPRS << 8 ) | 48 )

/*** L1S -> L1A communication ***/
#define L1P_PALLC_INFO                    ( ( P_GPRS << 8)  | 49)
#define L1P_PNP_INFO                      ( ( P_GPRS << 8)  | 50)
#define L1P_PEP_INFO                      ( ( P_GPRS << 8)  | 51)
#define L1P_PBCCHS_INFO                   ( ( P_GPRS << 8)  | 52)
#define L1P_PACCH_INFO                    ( ( P_GPRS << 8)  | 53)
#define L1P_CR_MEAS_DONE                  ( ( P_GPRS << 8)  | 54)
#define L1P_TRANSFER_DONE                 ( ( P_GPRS << 8)  | 55)
#define L1P_TCR_MEAS_DONE                 ( ( P_GPRS << 8)  | 56)
#define L1P_TBF_RELEASED                  ( ( P_GPRS << 8)  | 57)
#define L1P_ITMEAS_IND                    ( ( P_GPRS << 8)  | 58)
#define L1P_POLL_DONE                     ( ( P_GPRS << 8)  | 59)
#define L1P_PDCH_RELEASED                 ( ( P_GPRS << 8)  | 60)
#define L1P_TA_CONFIG_DONE                ( ( P_GPRS << 8)  | 61)
#define L1P_PBCCHN_INFO                   ( ( P_GPRS << 8)  | 62)
#define L1P_REPEAT_ALLOC_DONE             ( ( P_GPRS << 8)  | 63)
#define L1P_ALLOC_EXHAUST_DONE            ( ( P_GPRS << 8)  | 64)