FreeCalypso > hg > fc-tourmaline
view src/cs/layer1/audio_include/l1audio_signa.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 * L1AUDIO_SIGNA.H * * Filename l1audio_signa.h * Copyright 2003 (C) Texas Instruments * ************* Revision Controle System Header *************/ #if (AUDIO_TASK == 1) #define P_AUDIO ( 0x18 ) // Messages MMI <-> L1A #if (KEYBEEP) #define MMI_KEYBEEP_START_REQ ( ( P_AUDIO << 8 ) | 0 ) #define MMI_KEYBEEP_STOP_REQ ( ( P_AUDIO << 8 ) | 1 ) #define MMI_KEYBEEP_START_CON ( ( P_AUDIO << 8 ) | 2 ) #define MMI_KEYBEEP_STOP_CON ( ( P_AUDIO << 8 ) | 3 ) #endif #if (TONE) #define MMI_TONE_START_REQ ( ( P_AUDIO << 8 ) | 4 ) #define MMI_TONE_STOP_REQ ( ( P_AUDIO << 8 ) | 5 ) #define MMI_TONE_START_CON ( ( P_AUDIO << 8 ) | 6 ) #define MMI_TONE_STOP_CON ( ( P_AUDIO << 8 ) | 7 ) #endif #if (MELODY_E1) #define MMI_MELODY0_START_REQ ( ( P_AUDIO << 8 ) | 8 ) #define MMI_MELODY0_STOP_REQ ( ( P_AUDIO << 8 ) | 9 ) #define MMI_MELODY0_START_CON ( ( P_AUDIO << 8 ) | 10 ) #define MMI_MELODY0_STOP_CON ( ( P_AUDIO << 8 ) | 11 ) #define MMI_MELODY1_START_REQ ( ( P_AUDIO << 8 ) | 12 ) #define MMI_MELODY1_STOP_REQ ( ( P_AUDIO << 8 ) | 13 ) #define MMI_MELODY1_START_CON ( ( P_AUDIO << 8 ) | 14 ) #define MMI_MELODY1_STOP_CON ( ( P_AUDIO << 8 ) | 15 ) #endif #if (VOICE_MEMO) #define MMI_VM_PLAY_START_REQ ( ( P_AUDIO << 8 ) | 16 ) #define MMI_VM_PLAY_STOP_REQ ( ( P_AUDIO << 8 ) | 17 ) #define MMI_VM_PLAY_START_CON ( ( P_AUDIO << 8 ) | 18 ) #define MMI_VM_PLAY_STOP_CON ( ( P_AUDIO << 8 ) | 19 ) #define MMI_VM_RECORD_START_REQ ( ( P_AUDIO << 8 ) | 20 ) #define MMI_VM_RECORD_STOP_REQ ( ( P_AUDIO << 8 ) | 21 ) #define MMI_VM_RECORD_START_CON ( ( P_AUDIO << 8 ) | 22 ) #define MMI_VM_RECORD_STOP_CON ( ( P_AUDIO << 8 ) | 23 ) #endif #if (SPEECH_RECO) #define MMI_SR_ENROLL_START_REQ ( ( P_AUDIO << 8 ) | 24 ) #define MMI_SR_ENROLL_STOP_REQ ( ( P_AUDIO << 8 ) | 25 ) #define MMI_SR_ENROLL_START_CON ( ( P_AUDIO << 8 ) | 26 ) #define MMI_SR_ENROLL_STOP_CON ( ( P_AUDIO << 8 ) | 27 ) #define MMI_SR_UPDATE_START_REQ ( ( P_AUDIO << 8 ) | 28 ) #define MMI_SR_UPDATE_STOP_REQ ( ( P_AUDIO << 8 ) | 29 ) #define MMI_SR_UPDATE_START_CON ( ( P_AUDIO << 8 ) | 30 ) #define MMI_SR_UPDATE_STOP_CON ( ( P_AUDIO << 8 ) | 31 ) #define MMI_SR_RECO_START_REQ ( ( P_AUDIO << 8 ) | 32 ) #define MMI_SR_RECO_STOP_REQ ( ( P_AUDIO << 8 ) | 33 ) #define MMI_SR_RECO_START_CON ( ( P_AUDIO << 8 ) | 34 ) #define MMI_SR_RECO_STOP_CON ( ( P_AUDIO << 8 ) | 35 ) #define MMI_SR_UPDATE_CHECK_START_REQ ( ( P_AUDIO << 8 ) | 36 ) #define MMI_SR_UPDATE_CHECK_STOP_REQ ( ( P_AUDIO << 8 ) | 37 ) #define MMI_SR_UPDATE_CHECK_START_CON ( ( P_AUDIO << 8 ) | 38 ) #define MMI_SR_UPDATE_CHECK_STOP_CON ( ( P_AUDIO << 8 ) | 39 ) #endif #if (AEC) #define MMI_AEC_REQ ( ( P_AUDIO << 8 ) | 40 ) #define MMI_AEC_CON ( ( P_AUDIO << 8 ) | 41 ) #endif #if (FIR) #define MMI_AUDIO_FIR_REQ ( ( P_AUDIO << 8 ) | 42 ) #define MMI_AUDIO_FIR_CON ( ( P_AUDIO << 8 ) | 43 ) #endif #if (AUDIO_MODE) #define MMI_AUDIO_MODE_REQ ( ( P_AUDIO << 8 ) | 44 ) #define MMI_AUDIO_MODE_CON ( ( P_AUDIO << 8 ) | 45 ) #endif #if (MELODY_E2) #define MMI_MELODY0_E2_START_REQ ( ( P_AUDIO << 8 ) | 46 ) #define MMI_MELODY0_E2_STOP_REQ ( ( P_AUDIO << 8 ) | 47 ) #define MMI_MELODY0_E2_START_CON ( ( P_AUDIO << 8 ) | 48 ) #define MMI_MELODY0_E2_STOP_CON ( ( P_AUDIO << 8 ) | 49 ) #define MMI_MELODY1_E2_START_REQ ( ( P_AUDIO << 8 ) | 50 ) #define MMI_MELODY1_E2_STOP_REQ ( ( P_AUDIO << 8 ) | 51 ) #define MMI_MELODY1_E2_START_CON ( ( P_AUDIO << 8 ) | 52 ) #define MMI_MELODY1_E2_STOP_CON ( ( P_AUDIO << 8 ) | 53 ) #endif #if (L1_VOICE_MEMO_AMR) #define MMI_VM_AMR_PLAY_START_REQ ( ( P_AUDIO << 8 ) | 54 ) #define MMI_VM_AMR_PLAY_STOP_REQ ( ( P_AUDIO << 8 ) | 55 ) #define MMI_VM_AMR_PLAY_START_CON ( ( P_AUDIO << 8 ) | 56 ) #define MMI_VM_AMR_PLAY_STOP_CON ( ( P_AUDIO << 8 ) | 57 ) #define MMI_VM_AMR_RECORD_START_REQ ( ( P_AUDIO << 8 ) | 58 ) #define MMI_VM_AMR_RECORD_STOP_REQ ( ( P_AUDIO << 8 ) | 59 ) #define MMI_VM_AMR_RECORD_START_CON ( ( P_AUDIO << 8 ) | 60 ) #define MMI_VM_AMR_RECORD_STOP_CON ( ( P_AUDIO << 8 ) | 61 ) #endif #if (L1_CPORT == 1) #define MMI_CPORT_CONFIGURE_REQ ( ( P_AUDIO << 8 ) | 62 ) #define MMI_CPORT_CONFIGURE_CON ( ( P_AUDIO << 8 ) | 63 ) #endif // Messages L1S -> L1A #if (KEYBEEP) #define L1_KEYBEEP_START_CON ( ( P_AUDIO << 8 ) | 64 ) #define L1_KEYBEEP_STOP_CON ( ( P_AUDIO << 8 ) | 65 ) #endif #if (TONE) #define L1_TONE_START_CON ( ( P_AUDIO << 8 ) | 66 ) #define L1_TONE_STOP_CON ( ( P_AUDIO << 8 ) | 67 ) #endif #if (MELODY_E1) #define L1_MELODY0_START_CON ( ( P_AUDIO << 8 ) | 68 ) #define L1_MELODY0_STOP_CON ( ( P_AUDIO << 8 ) | 69 ) #define L1_MELODY1_START_CON ( ( P_AUDIO << 8 ) | 70 ) #define L1_MELODY1_STOP_CON ( ( P_AUDIO << 8 ) | 71 ) #endif #if (VOICE_MEMO) #define L1_VM_PLAY_START_CON ( ( P_AUDIO << 8 ) | 72 ) #define L1_VM_PLAY_STOP_CON ( ( P_AUDIO << 8 ) | 73 ) #define L1_VM_RECORD_START_CON ( ( P_AUDIO << 8 ) | 74 ) #define L1_VM_RECORD_STOP_CON ( ( P_AUDIO << 8 ) | 75 ) #endif #if (SPEECH_RECO) #define L1_SR_ENROLL_START_CON ( ( P_AUDIO << 8 ) | 76 ) #define L1_SR_ENROLL_STOP_CON ( ( P_AUDIO << 8 ) | 77 ) #define L1_SR_UPDATE_START_CON ( ( P_AUDIO << 8 ) | 78 ) #define L1_SR_UPDATE_STOP_CON ( ( P_AUDIO << 8 ) | 79 ) #define L1_SR_RECO_START_CON ( ( P_AUDIO << 8 ) | 80 ) #define L1_SR_RECO_STOP_CON ( ( P_AUDIO << 8 ) | 81 ) #define L1_SR_RECO_STOP_IND ( ( P_AUDIO << 8 ) | 82 ) #define L1_SR_PROCESSING_STOP_CON ( ( P_AUDIO << 8 ) | 83 ) #endif #if (AEC) #define L1_AEC_CON ( ( P_AUDIO << 8 ) | 84 ) #define L1_AEC_IND ( ( P_AUDIO << 8 ) | 85 ) #endif #if (FIR) #define L1_AUDIO_FIR_CON ( ( P_AUDIO << 8 ) | 86 ) #endif #if (AUDIO_MODE) #define L1_AUDIO_MODE_CON ( ( P_AUDIO << 8 ) | 87 ) #endif #if (L1_VOICE_MEMO_AMR) #define L1_VM_AMR_PLAY_START_CON ( ( P_AUDIO << 8 ) | 88 ) #define L1_VM_AMR_PLAY_STOP_CON ( ( P_AUDIO << 8 ) | 89 ) #define L1_VM_AMR_RECORD_START_CON ( ( P_AUDIO << 8 ) | 90 ) #define L1_VM_AMR_RECORD_STOP_CON ( ( P_AUDIO << 8 ) | 91 ) #endif #if (L1_CPORT == 1) #define L1_CPORT_CONFIGURE_CON ( ( P_AUDIO << 8 ) | 92 ) #endif // Messages L1A <-> Audio background #if (SPEECH_RECO) #define L1_SRBACK_SAVE_DATA_REQ ( ( P_AUDIO << 8 ) | 93 ) #define L1_SRBACK_SAVE_DATA_CON ( ( P_AUDIO << 8 ) | 94 ) #define L1_SRBACK_LOAD_MODEL_REQ ( ( P_AUDIO << 8 ) | 95 ) #define L1_SRBACK_LOAD_MODEL_CON ( ( P_AUDIO << 8 ) | 96 ) #define L1_SRBACK_TEMP_SAVE_DATA_REQ ( ( P_AUDIO << 8 ) | 97 ) #define L1_SRBACK_TEMP_SAVE_DATA_CON ( ( P_AUDIO << 8 ) | 98 ) #endif #if (MELODY_E2) #define L1_BACK_MELODY_E2_LOAD_INSTRUMENT_REQ ( ( P_AUDIO << 8 ) | 99 ) #define L1_BACK_MELODY_E2_LOAD_INSTRUMENT_CON ( ( P_AUDIO << 8 ) | 100 ) #define L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_REQ ( ( P_AUDIO << 8 ) | 101 ) #define L1_BACK_MELODY_E2_UNLOAD_INSTRUMENT_CON ( ( P_AUDIO << 8 ) | 102 ) #define L1_MELODY0_E2_STOP_CON ( ( P_AUDIO << 8 ) | 103 ) #define L1_MELODY1_E2_STOP_CON ( ( P_AUDIO << 8 ) | 104 ) #endif #if (OP_RIV_AUDIO == 1) #if (L1_AUDIO_DRIVER == 1) #define L1_AUDIO_DRIVER_IND ( ( P_AUDIO << 8 ) | 105 ) #endif #endif #endif // AUDIO_TASK == 1