summaryrefslogtreecommitdiff
path: root/snxxx/libese-spi/p73/lib
diff options
context:
space:
mode:
Diffstat (limited to 'snxxx/libese-spi/p73/lib')
-rw-r--r--snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.cpp204
-rw-r--r--[-rwxr-xr-x]snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.h9
-rw-r--r--snxxx/libese-spi/p73/lib/phNxpEse_Api.cpp354
3 files changed, 122 insertions, 445 deletions
diff --git a/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.cpp b/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.cpp
index 5a3d01d..4dea1c4 100644
--- a/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.cpp
+++ b/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.cpp
@@ -191,15 +191,6 @@ static ESESTATUS TransceiveProcess(void);
/**
* \ingroup ISO7816-3_protocol_lib
- * \brief This internal function is used to
- * 1. Send proprietary S-Frame command for re-sync
- *T=1 sequence at worker
- *
- */
-static ESESTATUS phNxpEseProto7816_RSync(void);
-
-/**
- * \ingroup ISO7816-3_protocol_lib
* \brief This function is used to send the spi hard reset command
*
*/
@@ -889,13 +880,15 @@ static void phNxpEseProto7816_DecodeSFrameATRData(uint8_t* p_data) {
(phNxpEseProto7816_3_Var.atrInfo.bgt[1]));
NXP_LOG_ESE_D("BWT = %d ms", phNxpEseProto7816_3_Var.atrInfo.bwt[0] << 8 |
phNxpEseProto7816_3_Var.atrInfo.bwt[1]);
- NXP_LOG_ESE_D("Max supported frequency = %d Hz",
+ NXP_LOG_ESE_D("Max supported frequency = %d KHz",
phNxpEseProto7816_3_Var.atrInfo.maxFreq[0] << 8 |
phNxpEseProto7816_3_Var.atrInfo.maxFreq[1]);
NXP_LOG_ESE_D("Checksum LRC(0)/CRC(1) supports = 0x%x",
phNxpEseProto7816_3_Var.atrInfo.checksum);
NXP_LOG_ESE_D("DefaultIFSC = %d bytes",
phNxpEseProto7816_3_Var.atrInfo.defaultIFSC);
+ NXP_LOG_ESE_D("Number of logical connections supported = %d",
+ phNxpEseProto7816_3_Var.atrInfo.numChannels);
NXP_LOG_ESE_D("Max IFSC = %d bytes",
phNxpEseProto7816_3_Var.atrInfo.maxIFSC[0] << 8 |
phNxpEseProto7816_3_Var.atrInfo.maxIFSC[1]);
@@ -916,7 +909,11 @@ static void phNxpEseProto7816_DecodeSFrameATRData(uint8_t* p_data) {
: "OSU Mode"));
}
if (phNxpEseProto7816_3_Var.atrInfo.vendorID[PH_PROTO_ATR_RSP_VENDOR_ID_LEN -
- 1] >= PH_SE_OS_VERSION_21) {
+ 1] >= PH_SE_OS_VERSION_30) {
+ phNxpEse_setOsVersion(OS_VERSION_8_9);
+ } else if (phNxpEseProto7816_3_Var.atrInfo
+ .vendorID[PH_PROTO_ATR_RSP_VENDOR_ID_LEN - 1] >=
+ PH_SE_OS_VERSION_21) {
phNxpEse_setOsVersion(OS_VERSION_6_3);
} else if (phNxpEseProto7816_3_Var.atrInfo
.vendorID[PH_PROTO_ATR_RSP_VENDOR_ID_LEN - 1] >=
@@ -990,20 +987,86 @@ static void phNxpEseProto7816_DecodeSFrameSecureTimerData(uint8_t* p_data) {
}
/******************************************************************************
+ * Function phNxpEseProto7816_SetTxstate
+ *
+ * Description This internal function is used to set the Tranceive state
+ * of T=1 Proto stack. Accordingly, it will set the params
+ * for next transceive.
+ * Returns void.
+ *
+ ******************************************************************************/
+static void phNxpEseProto7816_SetTxstate(
+ phNxpEseProto7816_TransceiveStates_t state) {
+ phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = SFRAME;
+ phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState = state;
+ switch (state) {
+ case SEND_S_IFS_ADJ:
+ phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.SframeInfo.sFrameType =
+ IFS_REQ;
+ break;
+ case SEND_S_ATR_REQ:
+ phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.SframeInfo.sFrameType =
+ ATR_REQ;
+ break;
+ default:
+ NXP_LOG_ESE_E("%s: Wrong transceive state received ", __FUNCTION__);
+ break;
+ }
+}
+/******************************************************************************
+ * Function phNxpEseProto7816_DecodeAtrRsp
+ *
+ * Description The function phNxpEseProto7816_DecodeFrame() shall call
+ * this function up on receiving the ATR RSP
+ * 1. If Last sent frame is S-Frame then send back the correct
+ * S-frame response.
+ * 2. If Last sent frame is I-Frame then trigger the recovery
+ * RESET_TYPE_OS_RESET.
+ * Returns On success returns ESESTATUS_SUCCESS else ESESTATUS_FAILED.
+ *
+ ******************************************************************************/
+static ESESTATUS phNxpEseProto7816_DecodeAtrRsp(uint8_t* p_data) {
+ ESESTATUS status = ESESTATUS_SUCCESS;
+ // This is 4ms delay and delay of 1ms in also there in line 1401 before
+ // next Tx
+ phNxpEse_Sleep(HARD_RESET_RES_DELAY);
+ if (phNxpEseProto7816_3_Var.phNxpEseLastTx_Cntx.FrameType == IFRAME) {
+ // Applicable only for SN300
+ phNxpEseProto7816_SetTxstate(SEND_S_ATR_REQ);
+ phNxpEseProto7816_3_Var.reset_type = RESET_TYPE_OS_RESET;
+ } else {
+ if (p_data[PH_PROPTO_7816_FRAME_LENGTH_OFFSET] > 0) {
+ /*Response status either success/fail*/
+ if (!p_data[PH_PROPTO_7816_FRAME_LENGTH_OFFSET + 1])
+ status = ESESTATUS_FAILED;
+ else
+ status = ESESTATUS_SUCCESS;
+ }
+ phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = UNKNOWN;
+ phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState = IDLE_STATE;
+ }
+ phNxpEseProto7816_3_Var.phNxpEseRx_Cntx.lastRcvdSframeInfo.sFrameType =
+ HARD_RESET_RSP;
+ return status;
+}
+/******************************************************************************
* Function phNxpEseProto7816_DecodeFrame
*
* Description This internal function is used to
* 1. Identify the received frame
* 2. If the received frame is I-frame with expected sequence
- number, store it or else send R-NACK
- 3. If the received frame is R-frame,
- 3.1 R-ACK with expected seq. number: Send the next
- chained I-frame
- 3.2 R-ACK with different sequence number: Send the R-Nack
- 3.3 R-NACK: Re-send the last frame
- 4. If the received frame is S-frame, send back the correct
- S-frame response.
- * Returns On success return true or else false.
+ * number, store it or else send R-NACK
+ * 3. If the received frame is R-frame,
+ * 3.1 R-ACK with expected seq. number: Send the next
+ * chained I-frame
+ * 3.2 R-ACK with different sequence number: Send the R-Nack
+ * 3.3 R-NACK: Re-send the last frame
+ * 4. If the received frame is S-frame,
+ * 4.1 Last sent frame is S-Frame then send back the
+ * correct S-frame response.
+ * 4.2 Last sent frame is I-Frame then trigger the recovery
+ * RESET_TYPE_OS_RESET.
+ * Returns On success returns true else false.
*
******************************************************************************/
static ESESTATUS phNxpEseProto7816_DecodeFrame(uint8_t* p_data,
@@ -1289,6 +1352,8 @@ static ESESTATUS phNxpEseProto7816_DecodeFrame(uint8_t* p_data,
phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = UNKNOWN;
phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState =
IDLE_STATE;
+ if (phNxpEseProto7816_3_Var.reset_type == RESET_TYPE_OS_RESET)
+ status = ESESTATUS_FAILED;
break;
case ABORT_REQ:
phNxpEseProto7816_3_Var.phNxpEseRx_Cntx.lastRcvdSframeInfo.sFrameType =
@@ -1377,11 +1442,7 @@ static ESESTATUS phNxpEseProto7816_DecodeFrame(uint8_t* p_data,
phNxpEseProto7816_3_Var.currentIFSDSize = tmpcurrentIFSDSize;
phNxpEseProto7816_3_Var.phNxpEseProto7816_CurrentState =
PH_NXP_ESE_PROTO_7816_TRANSCEIVE;
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = SFRAME;
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.SframeInfo.sFrameType =
- IFS_REQ;
- phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState =
- SEND_S_IFS_ADJ;
+ phNxpEseProto7816_SetTxstate(SEND_S_IFS_ADJ);
} else {
phNxpEseProto7816_ResetProtoParams();
phNxpEseProto7816_3_Var.phNxpEseRx_Cntx.lastRcvdSframeInfo
@@ -1414,21 +1475,7 @@ static ESESTATUS phNxpEseProto7816_DecodeFrame(uint8_t* p_data,
HARD_RESET_REQ;
break;
case HARD_RESET_RSP:
- // This is 4ms delay and delay of 1ms in also there in line 1401 before
- // next Tx
- phNxpEse_Sleep(HARD_RESET_RES_DELAY);
- phNxpEseProto7816_3_Var.phNxpEseRx_Cntx.lastRcvdSframeInfo.sFrameType =
- HARD_RESET_RSP;
- if (p_data[PH_PROPTO_7816_FRAME_LENGTH_OFFSET] > 0) {
- /*Response status either success/fail*/
- if (!p_data[PH_PROPTO_7816_FRAME_LENGTH_OFFSET + 1])
- status = ESESTATUS_FAILED;
- else
- status = ESESTATUS_SUCCESS;
- }
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = UNKNOWN;
- phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState =
- IDLE_STATE;
+ status = phNxpEseProto7816_DecodeAtrRsp(p_data);
break;
case ATR_RSP:
phNxpEseProto7816_3_Var.phNxpEseRx_Cntx.lastRcvdSframeInfo.sFrameType =
@@ -1441,9 +1488,13 @@ static ESESTATUS phNxpEseProto7816_DecodeFrame(uint8_t* p_data,
} else {
phNxpEse_setOsVersion(OS_VERSION_4_0);
}
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = UNKNOWN;
- phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState =
- IDLE_STATE;
+ if (phNxpEseProto7816_3_Var.reset_type == RESET_TYPE_OS_RESET) {
+ phNxpEseProto7816_SetTxstate(SEND_S_IFS_ADJ);
+ } else {
+ phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = UNKNOWN;
+ phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState =
+ IDLE_STATE;
+ }
break;
default:
NXP_LOG_ESE_E("%s Wrong S-Frame Received", __FUNCTION__);
@@ -1806,29 +1857,6 @@ static void printCmdRspTimeDuration(ESESTATUS status, uint32_t cmdLen,
}
/******************************************************************************
- * Function phNxpEseProto7816_RSync
- *
- * Description This function is used to send the RSync command
- *
- * Returns On success return true or else false.
- *
- ******************************************************************************/
-static ESESTATUS phNxpEseProto7816_RSync(void) {
- ESESTATUS status = ESESTATUS_FAILED;
- phNxpEseProto7816_3_Var.phNxpEseProto7816_CurrentState =
- PH_NXP_ESE_PROTO_7816_TRANSCEIVE;
- /* send the end of session s-frame */
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = SFRAME;
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.SframeInfo.sFrameType =
- RESYNCH_REQ;
- phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState = SEND_S_RSYNC;
- status = TransceiveProcess();
- phNxpEseProto7816_3_Var.phNxpEseProto7816_CurrentState =
- PH_NXP_ESE_PROTO_7816_IDLE;
- return status;
-}
-
-/******************************************************************************
* Function phNxpEseProto7816_HardReset
*
* Description This function is used to send the spi hard reset command
@@ -1925,17 +1953,12 @@ ESESTATUS phNxpEseProto7816_Reset(void) {
ESESTATUS status = ESESTATUS_FAILED;
/* Resetting host protocol instance */
phNxpEseProto7816_ResetProtoParams();
- if (GET_CHIP_OS_VERSION() != OS_VERSION_4_0) {
- status = phNxpEseProto7816_HardReset();
- if (status == ESESTATUS_SUCCESS) {
- /* Updating the ATR information(IFS,..) to 7816 stack */
- phNxpEse_data atrRsp;
- phNxpEseProto7816_getAtr(&atrRsp);
- phNxpEse_free(atrRsp.p_data);
- }
- } else {
- /* Resynchronising ESE protocol instance */
- status = phNxpEseProto7816_RSync();
+ status = phNxpEseProto7816_HardReset();
+ if (status == ESESTATUS_SUCCESS) {
+ /* Updating the ATR information(IFS,..) to 7816 stack */
+ phNxpEse_data atrRsp;
+ phNxpEseProto7816_getAtr(&atrRsp);
+ phNxpEse_free(atrRsp.p_data);
}
return status;
}
@@ -1967,16 +1990,12 @@ ESESTATUS phNxpEseProto7816_Open(phNxpEseProto7816InitParam_t initParam) {
}
} else /* Initialisation condition to achieve usecases like JCOP download */
{
- if (GET_CHIP_OS_VERSION() != OS_VERSION_4_0) {
- status = phNxpEseProto7816_HardReset();
- /* Updating the ATR information (Eg: IFS,..) to 7816 stack */
- if (status == ESESTATUS_SUCCESS) {
- phNxpEse_data atrRsp;
- phNxpEseProto7816_getAtr(&atrRsp);
- phNxpEse_free(atrRsp.p_data);
- }
- } else {
- status = phNxpEseProto7816_RSync();
+ status = phNxpEseProto7816_HardReset();
+ /* Updating the ATR information (Eg: IFS,..) to 7816 stack */
+ if (status == ESESTATUS_SUCCESS) {
+ phNxpEse_data atrRsp;
+ phNxpEseProto7816_getAtr(&atrRsp);
+ phNxpEse_free(atrRsp.p_data);
}
}
return status;
@@ -2134,10 +2153,7 @@ ESESTATUS phNxpEseProto7816_SetIfs(uint16_t IFS_Size) {
}
phNxpEseProto7816_3_Var.phNxpEseProto7816_CurrentState =
PH_NXP_ESE_PROTO_7816_TRANSCEIVE;
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = SFRAME;
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.SframeInfo.sFrameType = IFS_REQ;
- phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState =
- SEND_S_IFS_ADJ;
+ phNxpEseProto7816_SetTxstate(SEND_S_IFS_ADJ);
status = TransceiveProcess();
if (ESESTATUS_FAILED == status) {
/* reset all the structures */
@@ -2208,11 +2224,7 @@ ESESTATUS phNxpEseProto7816_getAtr(phNxpEse_data* pATRRsp) {
NXP_LOG_ESE_D("Enter %s ", __FUNCTION__);
phNxpEseProto7816_3_Var.phNxpEseProto7816_CurrentState =
PH_NXP_ESE_PROTO_7816_TRANSCEIVE;
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.FrameType = SFRAME;
-
- phNxpEseProto7816_3_Var.phNxpEseNextTx_Cntx.SframeInfo.sFrameType = ATR_REQ;
- phNxpEseProto7816_3_Var.phNxpEseProto7816_nextTransceiveState =
- SEND_S_ATR_REQ;
+ phNxpEseProto7816_SetTxstate(SEND_S_ATR_REQ);
status = TransceiveProcess();
if (ESESTATUS_FAILED == status) {
/* reset all the structures */
diff --git a/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.h b/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.h
index f71d8fc..d6e4758 100755..100644
--- a/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.h
+++ b/snxxx/libese-spi/p73/lib/phNxpEseProto7816_3.h
@@ -1,6 +1,6 @@
/******************************************************************************
*
- * Copyright 2018-2022 NXP
+ * Copyright 2018-2023 NXP
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -122,7 +122,8 @@ typedef enum phNxpEseProto7816_TransceiveStates {
*/
typedef enum phNxpEseProto7816_ResetType {
RESET_TYPE_NONE,
- RESET_TYPE_RECOVERY
+ RESET_TYPE_RECOVERY,
+ RESET_TYPE_OS_RESET
} phNxpEseProto7816_ResetType_t;
/*!
@@ -503,6 +504,10 @@ typedef struct phNxpEseProto7816_PCB_bits {
*/
#define PH_SE_OS_VERSION_21 0x21
/*!
+ * \brief OS version on SE for SN300
+ */
+#define PH_SE_OS_VERSION_30 0x30
+/*!
* \brief Default wait extension notification interval
*/
#define PH_DEFAULT_WTX_NTF_LIMIT 0x03
diff --git a/snxxx/libese-spi/p73/lib/phNxpEse_Api.cpp b/snxxx/libese-spi/p73/lib/phNxpEse_Api.cpp
index 09d9df9..7c0e254 100644
--- a/snxxx/libese-spi/p73/lib/phNxpEse_Api.cpp
+++ b/snxxx/libese-spi/p73/lib/phNxpEse_Api.cpp
@@ -45,8 +45,6 @@ static ESESTATUS phNxpEse_checkJcopDwnldState(void);
static ESESTATUS phNxpEse_setJcopDwnldState(phNxpEse_JcopDwnldState state);
static ESESTATUS phNxpEse_checkFWDwnldStatus(void);
static void phNxpEse_GetMaxTimer(unsigned long* pMaxTimer);
-static unsigned char* phNxpEse_GgetTimerTlvBuffer(unsigned char* timer_buffer,
- unsigned int value);
static __inline bool phNxpEse_isColdResetRequired(phNxpEse_initMode mode,
ESESTATUS status);
static int poll_sof_chained_delay = 0;
@@ -481,205 +479,6 @@ clean_and_return_2:
}
/******************************************************************************
- * \ingroup spi_libese
- *
- * \brief Check if libese has opened
- *
- * \retval return false if it is close, otherwise true.
- **
- ******************************************************************************/
-bool phNxpEse_isOpen() { return nxpese_ctxt.EseLibStatus != ESE_STATUS_CLOSE; }
-
-/******************************************************************************
- * Function phNxpEse_openPrioSession
- *
- * Description This function is called by Jni during the
- * initialization of the ESE. It opens the physical connection
- * with ESE () and creates required client thread for
- * operation. This will get priority access to ESE for timeout
- duration.
-
- * Returns This function return ESESTATUS_SUCCESS (0) in case of
- success
- * In case of failure returns other failure value.
- *
- ******************************************************************************/
-ESESTATUS phNxpEse_openPrioSession(phNxpEse_initParams initParams) {
- phPalEse_Config_t tPalConfig;
- ESESTATUS wConfigStatus = ESESTATUS_SUCCESS;
- unsigned long int num = 0, tpm_enable = 0;
-
- /* initialize trace level */
- phNxpLog_InitializeLogLevel();
- NXP_LOG_ESE_D("phNxpEse_openPrioSession Enter");
-#ifdef SPM_INTEGRATED
- ESESTATUS wSpmStatus = ESESTATUS_SUCCESS;
- spm_state_t current_spm_state = SPM_STATE_INVALID;
-#endif
- phNxpEse_memset(&nxpese_ctxt, 0x00, sizeof(nxpese_ctxt));
- phNxpEse_memset(&tPalConfig, 0x00, sizeof(tPalConfig));
-
- NXP_LOG_ESE_D("MW SEAccessKit Version");
- NXP_LOG_ESE_D("Android Version:0x%x", NXP_ANDROID_VER);
- NXP_LOG_ESE_D("Major Version:0x%x", ESELIB_MW_VERSION_MAJ);
- NXP_LOG_ESE_D("Minor Version:0x%x", ESELIB_MW_VERSION_MIN);
-
-#if (NXP_POWER_SCHEME_SUPPORT == true)
- if (EseConfig::hasKey(NAME_NXP_POWER_SCHEME)) {
- num = EseConfig::getUnsigned(NAME_NXP_POWER_SCHEME);
- nxpese_ctxt.pwr_scheme = num;
- NXP_LOG_ESE_D("Power scheme read from config file - %lu", num);
- } else
-#endif
- {
- nxpese_ctxt.pwr_scheme = PN67T_POWER_SCHEME;
- NXP_LOG_ESE_D("Power scheme not defined in config file - %lu", num);
- }
- if (EseConfig::hasKey(NAME_NXP_TP_MEASUREMENT)) {
- tpm_enable = EseConfig::getUnsigned(NAME_NXP_TP_MEASUREMENT);
- NXP_LOG_ESE_D(
- "SPI Throughput measurement enable/disable read from config file - %lu",
- tpm_enable);
- } else {
- NXP_LOG_ESE_D("SPI Throughput not defined in config file - %lu", num);
- }
-
- tPalConfig.pDevName = (int8_t*)"/dev/p73";
-
- /* Initialize PAL layer */
- wConfigStatus = phPalEse_open_and_configure(&tPalConfig);
- if (wConfigStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phPalEse_Init Failed");
- goto clean_and_return;
- }
- /* Copying device handle to hal context*/
- nxpese_ctxt.pDevHandle = tPalConfig.pDevHandle;
-
-#ifdef SPM_INTEGRATED
- /* Get the Access of ESE*/
- wSpmStatus = phNxpEse_SPM_Init(nxpese_ctxt.pDevHandle);
- if (wSpmStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phNxpEse_SPM_Init Failed");
- wConfigStatus = ESESTATUS_FAILED;
- goto clean_and_return_2;
- }
- wSpmStatus = phNxpEse_SPM_SetPwrScheme(nxpese_ctxt.pwr_scheme);
- if (wSpmStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E(" %s : phNxpEse_SPM_SetPwrScheme Failed", __FUNCTION__);
- wConfigStatus = ESESTATUS_FAILED;
- goto clean_and_return_1;
- }
- wSpmStatus = phNxpEse_SPM_GetState(&current_spm_state);
- if (wSpmStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E(" %s : phNxpEse_SPM_GetPwrState Failed", __FUNCTION__);
- wConfigStatus = ESESTATUS_FAILED;
- goto clean_and_return_1;
- } else {
- if ((current_spm_state & SPM_STATE_SPI) |
- (current_spm_state & SPM_STATE_SPI_PRIO)) {
- NXP_LOG_ESE_E(" %s : SPI is already opened...second instance not allowed",
- __FUNCTION__);
- wConfigStatus = ESESTATUS_FAILED;
- goto clean_and_return_1;
- }
- if (current_spm_state & SPM_STATE_JCOP_DWNLD) {
- NXP_LOG_ESE_E(" %s : Denying to open JCOP Download in progress",
- __FUNCTION__);
- wConfigStatus = ESESTATUS_FAILED;
- goto clean_and_return_1;
- }
- if (GET_CHIP_OS_VERSION() == OS_VERSION_4_0) {
- wConfigStatus = phNxpEse_checkFWDwnldStatus();
- if (wConfigStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_D(
- "Failed to open SPI due to VEN pin used by FW download \n");
- wConfigStatus = ESESTATUS_FAILED;
- goto clean_and_return_1;
- }
- }
- }
- phNxpEse_memcpy(&nxpese_ctxt.initParams, &initParams.initMode,
- sizeof(phNxpEse_initParams));
- if (GET_CHIP_OS_VERSION() == OS_VERSION_4_0) {
- /* Updating ESE power state based on the init mode */
- if (ESE_MODE_OSU == nxpese_ctxt.initParams.initMode) {
- wConfigStatus = phNxpEse_checkJcopDwnldState();
- if (wConfigStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phNxpEse_checkJcopDwnldState failed");
- goto clean_and_return_1;
- }
- }
- }
- wSpmStatus = phNxpEse_SPM_ConfigPwr(SPM_POWER_PRIO_ENABLE);
- if (wSpmStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phNxpEse_SPM_ConfigPwr: enabling power for spi prio Failed");
- if (wSpmStatus == ESESTATUS_BUSY) {
- wConfigStatus = ESESTATUS_BUSY;
- } else if (wSpmStatus == ESESTATUS_DWNLD_BUSY) {
- wConfigStatus = ESESTATUS_DWNLD_BUSY;
- } else {
- wConfigStatus = ESESTATUS_FAILED;
- }
- goto clean_and_return;
- } else {
- NXP_LOG_ESE_E("nxpese_ctxt.spm_power_state true");
- nxpese_ctxt.spm_power_state = true;
- }
-#endif
-
-#ifndef SPM_INTEGRATED
- wConfigStatus =
- phPalEse_ioctl(phPalEse_e_ResetDevice, nxpese_ctxt.pDevHandle, 2);
- if (wConfigStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phPalEse_IoCtl Failed");
- goto clean_and_return;
- }
-#endif
- wConfigStatus =
- phPalEse_ioctl(phPalEse_e_EnableLog, nxpese_ctxt.pDevHandle, 0);
- if (wConfigStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phPalEse_IoCtl Failed");
- goto clean_and_return;
- }
- wConfigStatus =
- phPalEse_ioctl(phPalEse_e_EnablePollMode, nxpese_ctxt.pDevHandle, 1);
- if (wConfigStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phPalEse_IoCtl Failed");
- goto clean_and_return;
- }
- NXP_LOG_ESE_D("wConfigStatus %x", wConfigStatus);
- if (GET_CHIP_OS_VERSION() == OS_VERSION_4_0) {
- if (tpm_enable) {
- wConfigStatus = phPalEse_ioctl(phPalEse_e_EnableThroughputMeasurement,
- nxpese_ctxt.pDevHandle, 0);
- if (wConfigStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phPalEse_IoCtl Failed");
- goto clean_and_return;
- }
- }
- }
- return wConfigStatus;
-
-clean_and_return:
-#ifdef SPM_INTEGRATED
- wSpmStatus = phNxpEse_SPM_ConfigPwr(SPM_POWER_DISABLE);
- if (wSpmStatus != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("phNxpEse_SPM_ConfigPwr: disabling power Failed");
- }
-clean_and_return_1:
- phNxpEse_SPM_DeInit();
-clean_and_return_2:
-#endif
- if (NULL != nxpese_ctxt.pDevHandle) {
- phPalEse_close(nxpese_ctxt.pDevHandle);
- phNxpEse_memset(&nxpese_ctxt, 0x00, sizeof(nxpese_ctxt));
- }
- nxpese_ctxt.EseLibStatus = ESE_STATUS_CLOSE;
- nxpese_ctxt.spm_power_state = false;
- return ESESTATUS_FAILED;
-}
-
-/******************************************************************************
* Function phNxpEse_setJcopDwnldState
*
* Description This function is used to check whether JCOP OS
@@ -969,25 +768,6 @@ ESESTATUS phNxpEse_resetJcopUpdate(void) {
NXP_LOG_ESE_D(" %s Exit \n", __FUNCTION__);
return status;
}
-/******************************************************************************
- * Function phNxpEse_EndOfApdu
- *
- * Description This function is used to send S-frame to indicate
- *END_OF_APDU
- *
- * Returns It returns ESESTATUS_SUCCESS (0) if the operation is
- *successful else
- * ESESTATUS_FAILED(1)
- *
- ******************************************************************************/
-ESESTATUS phNxpEse_EndOfApdu(void) {
- ESESTATUS status = ESESTATUS_SUCCESS;
-#if (NXP_ESE_END_OF_SESSION == true)
- status = phNxpEseProto7816_Close(
- (phNxpEseProto7816SecureTimer_t*)&nxpese_ctxt.secureTimerParams);
-#endif
- return status;
-}
/******************************************************************************
* Function phNxpEse_chipReset
@@ -1584,11 +1364,13 @@ ESESTATUS phNxpEse_WriteFrame(uint32_t data_len, uint8_t* p_data) {
phNxpEse_memcpy(nxpese_ctxt.p_cmd_data, p_data, data_len);
nxpese_ctxt.cmd_len = data_len;
- // eSE requires around 200 usec to switch from tx to rx mode
- // As per the observation, debug logs when enabled introduces around
- // same amount of delay, therefore below explicit delay is required
- // only if debug logs are disabled
- if (ese_log_level < NXPESE_LOGLEVEL_DEBUG) phPalEse_BusyWait(200 /*usecs*/);
+ if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) {
+ // eSE requires around 200 usec to switch from tx to rx mode
+ // As per the observation, debug logs when enabled introduces around
+ // same amount of delay, therefore below explicit delay is required
+ // only if debug logs are disabled
+ if (ese_log_level < NXPESE_LOGLEVEL_DEBUG) phPalEse_BusyWait(200 /*usecs*/);
+ }
dwNoBytesWrRd = phPalEse_write(nxpese_ctxt.pDevHandle, nxpese_ctxt.p_cmd_data,
nxpese_ctxt.cmd_len);
@@ -1740,33 +1522,6 @@ static void phNxpEse_GetMaxTimer(unsigned long* pMaxTimer) {
}
/******************************************************************************
- * Function phNxpEseP61_DisablePwrCntrl
- *
- * Description This function disables eSE GPIO power off/on control
- * when enabled
- *
- * Returns SUCCESS/FAIL.
- *
- ******************************************************************************/
-ESESTATUS phNxpEse_DisablePwrCntrl(void) {
- ESESTATUS status = ESESTATUS_SUCCESS;
- unsigned long maxTimer = 0;
- NXP_LOG_ESE_E("%s Enter", __FUNCTION__);
- phNxpEse_GetMaxTimer(&maxTimer);
- if (GET_CHIP_OS_VERSION() == OS_VERSION_4_0) {
- status = phNxpEse_SPM_DisablePwrControl(maxTimer);
- if (status != ESESTATUS_SUCCESS) {
- NXP_LOG_ESE_E("%s phNxpEseP61_DisablePwrCntrl: failed", __FUNCTION__);
- }
- } else {
- NXP_LOG_ESE_E("%s phNxpEseP61_DisablePwrCntrl: not supported",
- __FUNCTION__);
- status = ESESTATUS_FAILED;
- }
- return status;
-}
-
-/******************************************************************************
* Function phNxpEse_getOsVersion
*
* Description This function returns OS version from config file &
@@ -1833,101 +1588,6 @@ static ESESTATUS phNxpEse_checkFWDwnldStatus(void) {
}
/******************************************************************************
- * Function phNxpEse_GetEseStatus(unsigned char *timer_buffer)
- *
- * Description This function returns the all three timer
- * Timeout buffer length should be minimum 18 bytes. Response will be in below
- format:
- * <0xF1><Len><Timer Value><0xF2><Len><Timer Value><0xF3><Len><Timer Value>
- *
- * Returns SUCCESS/FAIL.
- * ESESTATUS_SUCCESS if 0xF1 or 0xF2 tag timeout >= 0 & 0xF3 == 0
- * ESESTATUS_BUSY if 0xF3 tag timeout > 0
- * ESESTATUS_FAILED if any other error
-
- ******************************************************************************/
-ESESTATUS phNxpEse_GetEseStatus(phNxpEse_data* timer_buffer) {
- ESESTATUS status = ESESTATUS_FAILED;
-
- phNxpEse_SecureTimer_t secureTimerParams;
- uint8_t* temp_timer_buffer = NULL;
- NXP_LOG_ESE_D("%s Enter", __FUNCTION__);
- if (GET_CHIP_OS_VERSION() != OS_VERSION_4_0) {
- NXP_LOG_ESE_E("%s function not supported", __FUNCTION__);
- return status;
- }
- if (timer_buffer != NULL) {
- timer_buffer->len =
- (sizeof(secureTimerParams.secureTimer1) +
- sizeof(secureTimerParams.secureTimer2) +
- sizeof(secureTimerParams.secureTimer3)) +
- PH_PROPTO_7816_FRAME_LENGTH_OFFSET * PH_PROPTO_7816_FRAME_LENGTH_OFFSET;
- temp_timer_buffer = (uint8_t*)phNxpEse_memalloc(timer_buffer->len);
- timer_buffer->p_data = temp_timer_buffer;
-
- phNxpEse_memcpy(&secureTimerParams, &nxpese_ctxt.secureTimerParams,
- sizeof(phNxpEse_SecureTimer_t));
-
- NXP_LOG_ESE_D(
- "%s secureTimer1 0x%x secureTimer2 0x%x secureTimer3 0x%x len = %d",
- __FUNCTION__, secureTimerParams.secureTimer1,
- secureTimerParams.secureTimer2, secureTimerParams.secureTimer3,
- timer_buffer->len);
-
- *temp_timer_buffer++ = PH_PROPTO_7816_SFRAME_TIMER1;
- *temp_timer_buffer++ = sizeof(secureTimerParams.secureTimer1);
- temp_timer_buffer = phNxpEse_GgetTimerTlvBuffer(
- temp_timer_buffer, secureTimerParams.secureTimer1);
- if (temp_timer_buffer != NULL) {
- *temp_timer_buffer++ = PH_PROPTO_7816_SFRAME_TIMER2;
- *temp_timer_buffer++ = sizeof(secureTimerParams.secureTimer2);
- temp_timer_buffer = phNxpEse_GgetTimerTlvBuffer(
- temp_timer_buffer, secureTimerParams.secureTimer2);
- if (temp_timer_buffer != NULL) {
- *temp_timer_buffer++ = PH_PROPTO_7816_SFRAME_TIMER3;
- *temp_timer_buffer++ = sizeof(secureTimerParams.secureTimer3);
- temp_timer_buffer = phNxpEse_GgetTimerTlvBuffer(
- temp_timer_buffer, secureTimerParams.secureTimer3);
- if (temp_timer_buffer != NULL) {
- if (secureTimerParams.secureTimer3 > 0) {
- status = ESESTATUS_BUSY;
- } else {
- status = ESESTATUS_SUCCESS;
- }
- }
- }
- }
- } else {
- NXP_LOG_ESE_E("%s Invalid timer buffer ", __FUNCTION__);
- }
-
- NXP_LOG_ESE_D("%s Exit status = 0x%x", __FUNCTION__, status);
- return status;
-}
-
-static unsigned char* phNxpEse_GgetTimerTlvBuffer(uint8_t* timer_buffer,
- unsigned int value) {
- short int count = 0, shift = 3;
- unsigned int mask = 0x000000FF;
- if (GET_CHIP_OS_VERSION() != OS_VERSION_4_0) {
- NXP_LOG_ESE_E("%s function not supported", __FUNCTION__);
- } else {
- NXP_LOG_ESE_D("value = %x \n", value);
- for (count = 0; count < 4; count++) {
- if (timer_buffer != NULL) {
- *timer_buffer = (value >> (shift * 8) & mask);
- NXP_LOG_ESE_D("*timer_buffer=0x%x shift=0x%x", *timer_buffer, shift);
- timer_buffer++;
- shift--;
- } else {
- break;
- }
- }
- }
- return timer_buffer;
-}
-
-/******************************************************************************
* Function phNxpEse_NotifySEWtxRequest
*
* Description This function notifies SE hal service if it registers