FreeCalypso > hg > fc-tourmaline
view cdg-hybrid/cdginc/p_8010_136_simdrv_sap.val @ 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 | 35f7a1dc9f7d |
| children |
line wrap: on
line source
/* +--------------------------------------------------------------------------+ | PROJECT : PROTOCOL STACK | | FILE : p_8010_136_simdrv_sap.val | | SOURCE : "sap\8010_136_SIMDRV_SAP.pdf" | | LastModified : "2004-06-10" | | IdAndVersion : "8010.136.03.009" | | SrcFileTime : "Thu Nov 29 09:27:56 2007" | | Generated by CCDGEN_2.5.5A on Fri Oct 14 21:41:52 2016 | | !!DO NOT MODIFY!!DO NOT MODIFY!!DO NOT MODIFY!! | +--------------------------------------------------------------------------+ */ /* PRAGMAS * PREFIX : SIMDRV * COMPATIBILITY_DEFINES : NO * ALWAYS_ENUM_IN_VAL_FILE: YES * ENABLE_GROUP: YES * CAPITALIZE_TYPENAME: NO */ #ifndef P_8010_136_SIMDRV_SAP_VAL #define P_8010_136_SIMDRV_SAP_VAL #define CDG_ENTER__P_8010_136_SIMDRV_SAP_VAL #define CDG_ENTER__FILENAME _P_8010_136_SIMDRV_SAP_VAL #define CDG_ENTER__P_8010_136_SIMDRV_SAP_VAL__FILE_TYPE CDGINC #define CDG_ENTER__P_8010_136_SIMDRV_SAP_VAL__LAST_MODIFIED _2004_06_10 #define CDG_ENTER__P_8010_136_SIMDRV_SAP_VAL__ID_AND_VERSION _8010_136_03_009 #define CDG_ENTER__P_8010_136_SIMDRV_SAP_VAL__SRC_FILE_TIME _Thu_Nov_29_09_27_56_2007 #include "CDG_ENTER.h" #undef CDG_ENTER__P_8010_136_SIMDRV_SAP_VAL #undef CDG_ENTER__FILENAME /* * Enum to value table VAL_reset_return_val * CCDGEN:WriteEnum_Count==29 */ #ifndef __T_SIMDRV_VAL_reset_return_val__ #define __T_SIMDRV_VAL_reset_return_val__ typedef enum { SIMDRV_SIM_INSERTED = 0x0, /* A SIM is inserted and ATR/PPS was successful */ SIMDRV_SIM_NOT_INSERTED = 0x1, /* No SIM inserted (hardware detected) */ SIMDRV_INVALID_CARD = 0x2, /* Card is not responding or gives unintelligible answers, communications time out. */ SIMDRV_ME_FAILURE = 0x3, /* Power management related problems, e.g. voltage selection */ SIMDRV_IMPROPER_CALL_BACK = 0x4, /* simdrv_register function called with pointer improperly set, e.g. NULL. */ SIMDRV_ME_READER_NOT_AVAILABLE = 0x5 /* The reader requested is not available */ }T_SIMDRV_VAL_reset_return_val; #endif /* * Enum to value table VAL_len * CCDGEN:WriteEnum_Count==31 */ #ifndef __T_SIMDRV_VAL_len__ #define __T_SIMDRV_VAL_len__ typedef enum { SIMDRV_VAL_LEN__RANGE_MIN = 0x0, /* minimum */ SIMDRV_VAL_LEN__RANGE_MAX = 0x100, /* maximum */ SIMDRV_LENGTH_UNKNOWN = 0xffff /* Indicating that the length expected is unknown. */ }T_SIMDRV_VAL_len; #endif /* * Enum to value table VAL_sw1_2 * CCDGEN:WriteEnum_Count==33 */ #ifndef __T_SIMDRV_VAL_sw1_2__ #define __T_SIMDRV_VAL_sw1_2__ typedef enum { SIMDRV_ERR_NOCARD = 0x1, /* No SIM inserted (hardware detected) */ SIMDRV_ERR_NOT_RESET = 0x2, /* A reset has not been performed on the driver with the requested Id. */ SIMDRV_ERR_ME_FAIL = 0x3, /* Unrecoverable ME failure (for instance interrupt fails to occur) */ SIMDRV_ERR_RETRY_FAIL = 0x4, /* ME/SIM communication failed after certain retries, SIM reset required */ SIMDRV_ERR_PARAM_WRONG = 0x5 /* A driver function is called with invalid parameters */ }T_SIMDRV_VAL_sw1_2; #endif /* * Enum to value table VAL_cla * CCDGEN:WriteEnum_Count==35 */ #ifndef __T_SIMDRV_VAL_cla__ #define __T_SIMDRV_VAL_cla__ typedef enum { SIMDRV_GSM_CLASS_BYTE = 0xa0, /* GSM Class byte according to [GSM 11.11 / 3GPP 51.011] */ SIMDRV_UMTS_CLASS_BYTE = 0x80, /* UMTS Class byte according to [ETSI 102 221 10.1.2] */ SIMDRV_UICC_CLASS_BYTE = 0x0 /* UICC Class byte according to [ISO 7816-4] */ }T_SIMDRV_VAL_cla; #endif /* * Enum to value table VAL_ins * CCDGEN:WriteEnum_Count==37 */ #ifndef __T_SIMDRV_VAL_ins__ #define __T_SIMDRV_VAL_ins__ typedef enum { SIMDRV_INS_SELECT = 0xa4, /* Select Instruction */ SIMDRV_INS_STATUS = 0xf2, /* Status Instruction */ SIMDRV_INS_READ_BINARY = 0xb0, /* Read Binary Instruction */ SIMDRV_INS_UPDATE_BINARY = 0xd6, /* Update Binary Instruction */ SIMDRV_INS_READ_RECORD = 0xb2, /* Read Record Instruction */ SIMDRV_INS_UPDATE_RECORD = 0xdc, /* Update Record Instruction */ SIMDRV_INS_SEEK = 0xa2, /* Seek Instruction */ SIMDRV_INS_INCREASE = 0x32, /* Increase Instruction */ SIMDRV_INS_VERIFY_CHV = 0x20, /* Verify Chv Instruction */ SIMDRV_INS_CHANGE_CHV = 0x24, /* Change Chv Instruction */ SIMDRV_INS_DISABLE_CHV = 0x26, /* Disable Chv Instruction */ SIMDRV_INS_ENABLE_CHV = 0x28, /* Ensable Chv Instruction */ SIMDRV_INS_UNBLOCK_CHV = 0x2c, /* Unblock Chv Instruction */ SIMDRV_INS_INVALIDATE = 0x4, /* Invalidate Instruction */ SIMDRV_INS_REHABILITATE = 0x44, /* Rehabilitate Instruction */ SIMDRV_INS_AUTHENTICATE = 0x88, /* Run GSM Algorithm (2/2.5G) / Authenticate (3G) Instruction */ SIMDRV_INS_TERMINAL_PROFILE = 0x10, /* Terminal Profile Instruction */ SIMDRV_INS_ENVELOPE = 0xc2, /* Envelope Instruction */ SIMDRV_INS_FETCH = 0x12, /* Fetch Instruction */ SIMDRV_INS_TERMINAL_RESPONSE = 0x14, /* Terminal Response Instruction */ SIMDRV_INS_GET_RESPONSE = 0xc0 /* Get Response Instruction */ }T_SIMDRV_VAL_ins; #endif /* * Enum to value table VAL_voltage_select * CCDGEN:WriteEnum_Count==39 */ #ifndef __T_SIMDRV_VAL_voltage_select__ #define __T_SIMDRV_VAL_voltage_select__ typedef enum { SIMDRV_REQ_VOLTAGE_SEL = 0x0, /* The SIM reader driver shall perform voltage selection */ SIMDRV_OMIT_VOLTAGE_SEL = 0x1 /* The SIM reader driver shall restart with the current voltage */ }T_SIMDRV_VAL_voltage_select; #endif /* * Enum to value table VAL_config_requested * CCDGEN:WriteEnum_Count==41 */ #ifndef __T_SIMDRV_VAL_config_requested__ #define __T_SIMDRV_VAL_config_requested__ typedef enum { SIMDRV_OMIT_CONFIG_CHARACTERISTICS = 0x0, /* PS Shall not retrieve Configuration Characteristics */ SIMDRV_REQUEST_CONFIG_CHARACTERISTICS = 0x1 /* PS Shall retrieve Configuration Characteristics */ }T_SIMDRV_VAL_config_requested; #endif /* * Enum to value table VAL_reader_id * CCDGEN:WriteEnum_Count==43 */ #ifndef __T_SIMDRV_VAL_reader_id__ #define __T_SIMDRV_VAL_reader_id__ typedef enum { SIMDRV_VAL_READER_ID__RANGE_MIN = 0x1, /* minimum */ SIMDRV_VAL_READER_ID__RANGE_MAX = 0x2 /* maximum */ }T_SIMDRV_VAL_reader_id; #endif /* * user defined constants */ #define SIMDRV_SIZE_ATR_INFO (0x21) #define SIMDRV_MIN_RESULT (0x1) #define SIMDRV_MAX_RESULT (0x100) #define SIMDRV_MIN_DATA_SIZE (0x1) #define SIMDRV_MAX_DATA_SIZE (0xff) #define SIMDRV_MAX_READERS (0x2) #include "CDG_LEAVE.h" #endif
