diff options
author | Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> | 2024-01-25 07:56:17 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2024-01-25 07:56:17 +0000 |
commit | 12517449e99fd7e46f9c86913b7d95cf501d184e (patch) | |
tree | 103830989989eac6105fae06c0690e825a56887a | |
parent | d4931f70dea845ae9cd474b2a483533d2fbc14b3 (diff) | |
parent | 7925d5f2548272d96db3fd7050546aebd649618e (diff) | |
download | secure_element-12517449e99fd7e46f9c86913b7d95cf501d184e.tar.gz |
Merge "NXP SecureElement HAL update for SNxxx" into main
33 files changed, 402 insertions, 898 deletions
diff --git a/snxxx/1.0/SecureElement.cpp b/snxxx/1.0/SecureElement.cpp index 021f783..f605957 100755..100644 --- a/snxxx/1.0/SecureElement.cpp +++ b/snxxx/1.0/SecureElement.cpp @@ -128,7 +128,7 @@ Return<void> SecureElement::getAtr(getAtr_cb _hidl_cb) { } status = phNxpEse_SetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed"; } status = phNxpEse_getAtr(&atrData); if (status != ESESTATUS_SUCCESS) { @@ -142,7 +142,7 @@ Return<void> SecureElement::getAtr(getAtr_cb _hidl_cb) { status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed"; } if (status != ESESTATUS_SUCCESS) { @@ -202,7 +202,7 @@ Return<void> SecureElement::transmit(const hidl_vec<uint8_t>& data, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(result); @@ -302,7 +302,7 @@ Return<void> SecureElement::openLogicalChannel(const hidl_vec<uint8_t>& aid, send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); return Void(); @@ -390,7 +390,7 @@ Return<void> SecureElement::openLogicalChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); phNxpEse_free(cpdu.pdata); @@ -490,7 +490,7 @@ Return<void> SecureElement::openBasicChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SecureElementStatus::SUCCESS) { SecureElementStatus closeChannelStatus = @@ -553,7 +553,7 @@ SecureElement::internalCloseChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } } if (mOpenedChannels[channelNumber]) { @@ -611,7 +611,7 @@ SecureElement::closeChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } } if (mOpenedChannels[channelNumber]) { @@ -679,7 +679,7 @@ SecureElement::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); diff --git a/snxxx/1.0/VirtualISO.cpp b/snxxx/1.0/VirtualISO.cpp index 3683208..12c2197 100644 --- a/snxxx/1.0/VirtualISO.cpp +++ b/snxxx/1.0/VirtualISO.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2021 NXP + * Copyright 2018-2021, 2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,7 +144,7 @@ Return<void> VirtualISO::transmit(const hidl_vec<uint8_t>& data, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(result); @@ -241,7 +241,7 @@ Return<void> VirtualISO::openLogicalChannel(const hidl_vec<uint8_t>& aid, send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); return Void(); @@ -326,7 +326,7 @@ Return<void> VirtualISO::openLogicalChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); phNxpEse_free(cpdu.pdata); @@ -415,7 +415,7 @@ Return<void> VirtualISO::openBasicChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SecureElementStatus::SUCCESS) { SecureElementStatus closeChannelStatus = @@ -479,7 +479,7 @@ VirtualISO::internalCloseChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } } if (mOpenedChannels[channelNumber]) { @@ -538,7 +538,7 @@ VirtualISO::closeChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } } if (mOpenedChannels[channelNumber]) { @@ -593,7 +593,7 @@ VirtualISO::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); diff --git a/snxxx/1.1/SecureElement.cpp b/snxxx/1.1/SecureElement.cpp index e261910..8b27e77 100755..100644 --- a/snxxx/1.1/SecureElement.cpp +++ b/snxxx/1.1/SecureElement.cpp @@ -220,7 +220,7 @@ Return<void> SecureElement::getAtr(getAtr_cb _hidl_cb) { } status = phNxpEse_SetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed"; } status = phNxpEse_getAtr(&atrData); if (status != ESESTATUS_SUCCESS) { @@ -234,7 +234,7 @@ Return<void> SecureElement::getAtr(getAtr_cb _hidl_cb) { status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed"; } if (status != ESESTATUS_SUCCESS) { @@ -295,7 +295,7 @@ Return<void> SecureElement::transmit(const hidl_vec<uint8_t>& data, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(result); @@ -388,7 +388,7 @@ Return<void> SecureElement::openLogicalChannel(const hidl_vec<uint8_t>& aid, send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); return Void(); @@ -476,7 +476,7 @@ Return<void> SecureElement::openLogicalChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); phNxpEse_free(cpdu.pdata); @@ -576,7 +576,7 @@ Return<void> SecureElement::openBasicChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SecureElementStatus::SUCCESS) { SecureElementStatus closeChannelStatus = @@ -629,7 +629,7 @@ Return<SecureElementStatus> SecureElement::internalCloseChannel( } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } } if (channelNumber < mMaxChannelCount) { @@ -705,7 +705,7 @@ Return<SecureElementStatus> SecureElement::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); diff --git a/snxxx/1.1/VirtualISO.cpp b/snxxx/1.1/VirtualISO.cpp index 6b0748a..ae90211 100755..100644 --- a/snxxx/1.1/VirtualISO.cpp +++ b/snxxx/1.1/VirtualISO.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2021 NXP + * Copyright 2018-2021, 2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -211,7 +211,7 @@ Return<void> VirtualISO::transmit(const hidl_vec<uint8_t>& data, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(result); @@ -308,7 +308,7 @@ Return<void> VirtualISO::openLogicalChannel(const hidl_vec<uint8_t>& aid, send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); return Void(); @@ -393,7 +393,7 @@ Return<void> VirtualISO::openLogicalChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); phNxpEse_free(cpdu.pdata); @@ -482,7 +482,7 @@ Return<void> VirtualISO::openBasicChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SecureElementStatus::SUCCESS) { SecureElementStatus closeChannelStatus = @@ -537,7 +537,7 @@ VirtualISO::internalCloseChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (mOpenedChannels[channelNumber]) { mOpenedChannels[channelNumber] = false; @@ -586,7 +586,7 @@ VirtualISO::closeChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (mOpenedChannels[channelNumber]) { mOpenedChannels[channelNumber] = false; @@ -642,7 +642,7 @@ VirtualISO::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); diff --git a/snxxx/1.2/Android.bp b/snxxx/1.2/Android.bp index 5ca335d..aedd554 100644 --- a/snxxx/1.2/Android.bp +++ b/snxxx/1.2/Android.bp @@ -28,7 +28,7 @@ cc_binary { init_rc: ["android.hardware.secure_element_snxxx@1.2-service.rc"], proprietary: true, defaults: ["hidl_defaults"], - enabled: true, + enabled: false, srcs: [ "NxpEseService.cpp", "SecureElement.cpp", diff --git a/snxxx/1.2/NxpEseService.cpp b/snxxx/1.2/NxpEseService.cpp index b3ff2b9..0da44e7 100755 --- a/snxxx/1.2/NxpEseService.cpp +++ b/snxxx/1.2/NxpEseService.cpp @@ -22,14 +22,14 @@ #include <hidl/LegacySupport.h> #include <log/log.h> #include <string.h> -#include <vendor/nxp/nxpese/1.0/INxpEse.h> #include <regex> -#include "NxpEse.h" #include "SecureElement.h" #include "VirtualISO.h" #ifdef NXP_BOOTTIME_UPDATE +#include <vendor/nxp/nxpese/1.0/INxpEse.h> +#include "NxpEse.h" #include "eSEClient.h" #endif @@ -46,8 +46,10 @@ using android::hardware::registerPassthroughServiceImplementation; using INfc = android::hardware::nfc::V1_2::INfc; using android::hardware::secure_element::V1_2::ISecureElement; using android::hardware::secure_element::V1_2::implementation::SecureElement; +#ifdef NXP_BOOTTIME_UPDATE using vendor::nxp::nxpese::V1_0::INxpEse; using vendor::nxp::nxpese::V1_0::implementation::NxpEse; +#endif using vendor::nxp::virtual_iso::V1_0::implementation::VirtualISO; using INfcAidl = ::aidl::android::hardware::nfc::INfc; @@ -94,7 +96,9 @@ int main() { bool ret = false; android::sp<ISecureElement> se_service = nullptr; +#ifdef NXP_BOOTTIME_UPDATE android::sp<INxpEse> nxp_se_service = nullptr; +#endif android::sp<ISecureElement> virtual_iso_service = nullptr; try { @@ -124,7 +128,7 @@ int main() { goto shutdown; } ALOGI("Secure Element Service is ready"); - +#ifdef NXP_BOOTTIME_UPDATE ALOGI("NXP Secure Element Extn Service 1.0 is starting."); nxp_se_service = new NxpEse(); if (nxp_se_service == nullptr) { @@ -142,6 +146,7 @@ int main() { goto shutdown; } ALOGI("Secure Element Service is ready"); +#endif } #ifdef NXP_VISO_ENABLE diff --git a/snxxx/1.2/SecureElement.cpp b/snxxx/1.2/SecureElement.cpp index 35b84eb..8cdb5c4 100755..100644 --- a/snxxx/1.2/SecureElement.cpp +++ b/snxxx/1.2/SecureElement.cpp @@ -17,8 +17,8 @@ ******************************************************************************/ #include "SecureElement.h" -#include "NxpEse.h" #ifdef NXP_BOOTTIME_UPDATE +#include "NxpEse.h" #include "eSEClient.h" #endif #include <android-base/logging.h> @@ -55,7 +55,9 @@ static sTransceiveBuffer_t gsTxRxBuffer; static hidl_vec<uint8_t> gsRspDataBuff(256); sp<V1_0::ISecureElementHalCallback> SecureElement::mCallbackV1_0 = nullptr; std::vector<bool> SecureElement::mOpenedChannels; +#ifdef NXP_BOOTTIME_UPDATE using vendor::nxp::nxpese::V1_0::implementation::NxpEse; +#endif SecureElement::SecureElement() : mMaxChannelCount(0), mOpenedchannelCount(0), mIsEseInitialized(false) {} @@ -109,8 +111,10 @@ Return<void> SecureElement::init( if (ESESTATUS_SUCCESS == phNxpEse_SetEndPoint_Cntxt(0)) { initStatus = phNxpEse_init(initParams); if (ESESTATUS_SUCCESS == initStatus) { - /*update OS mode during first init*/ - IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) { + /*update OS mode during first init*/ + IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); + } if (ESESTATUS_SUCCESS == phNxpEse_ResetEndPoint_Cntxt(0)) { LOG(INFO) << "ESE SPI init complete!!!"; @@ -125,7 +129,8 @@ Return<void> SecureElement::init( if (status == ESESTATUS_SUCCESS && (initStatus == ESESTATUS_TRANSCEIVE_FAILED || initStatus == ESESTATUS_FAILED)) { - IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) + IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); mIsInitDone = true; } } @@ -220,7 +225,8 @@ Return<void> SecureElement::init_1_1( initStatus = phNxpEse_init(initParams); if (initStatus == ESESTATUS_SUCCESS) { /*update OS mode during first init*/ - IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) + IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); if (ESESTATUS_SUCCESS == phNxpEse_ResetEndPoint_Cntxt(0)) { LOG(INFO) << "ESE SPI init complete!!!"; @@ -235,7 +241,8 @@ Return<void> SecureElement::init_1_1( if (status == ESESTATUS_SUCCESS && (initStatus == ESESTATUS_TRANSCEIVE_FAILED || initStatus == ESESTATUS_FAILED)) { - IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) + IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); mIsInitDone = true; } } @@ -264,7 +271,8 @@ Return<void> SecureElement::getAtr(getAtr_cb _hidl_cb) { bool mIsSeHalInitDone = false; // In dedicated mode getATR not allowed - if (IS_OSU_MODE(OsuHalExtn::getInstance().GETATR)) { + if ((GET_CHIP_OS_VERSION() < OS_VERSION_8_9) && + (IS_OSU_MODE(OsuHalExtn::getInstance().GETATR))) { LOG(ERROR) << "%s: Not allowed in dedicated mode!!!" << __func__; _hidl_cb(response); return Void(); @@ -282,7 +290,7 @@ Return<void> SecureElement::getAtr(getAtr_cb _hidl_cb) { } status = phNxpEse_SetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed"; } status = phNxpEse_getAtr(&atrData); if (status != ESESTATUS_SUCCESS) { @@ -296,7 +304,7 @@ Return<void> SecureElement::getAtr(getAtr_cb _hidl_cb) { status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed"; } if (status != ESESTATUS_SUCCESS) { @@ -337,23 +345,24 @@ Return<void> SecureElement::transmit(const hidl_vec<uint8_t>& data, _hidl_cb(result); return Void(); } - OsuHalExtn::OsuApduMode mode = IS_OSU_MODE( - data, OsuHalExtn::getInstance().TRANSMIT, &gsTxRxBuffer.cmdData); - if (mode == OsuHalExtn::getInstance().OSU_BLOCKED_MODE) { - LOG(ERROR) << "Not allowed in dedicated mode!!!"; - /*Return empty hidl_vec*/ - _hidl_cb(result); - return Void(); - } else if (mode == OsuHalExtn::getInstance().OSU_RST_MODE) { - uint8_t sw[2] = {0x90, 0x00}; - result.resize(sizeof(sw)); - memcpy(&result[0], sw, sizeof(sw)); - _hidl_cb(result); - return Void(); + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) { + OsuHalExtn::OsuApduMode mode = IS_OSU_MODE( + data, OsuHalExtn::getInstance().TRANSMIT, &gsTxRxBuffer.cmdData); + if (mode == OsuHalExtn::getInstance().OSU_BLOCKED_MODE) { + LOG(ERROR) << "Not allowed in dedicated mode!!!"; + /*Return empty hidl_vec*/ + _hidl_cb(result); + return Void(); + } else if (mode == OsuHalExtn::getInstance().OSU_RST_MODE) { + uint8_t sw[2] = {0x90, 0x00}; + result.resize(sizeof(sw)); + memcpy(&result[0], sw, sizeof(sw)); + _hidl_cb(result); + return Void(); + } } else { - // continue with normal processing + memcpy(gsTxRxBuffer.cmdData.p_data, data.data(), gsTxRxBuffer.cmdData.len); } - // memcpy(gsTxRxBuffer.cmdData.p_data, data.data(), gsTxRxBuffer.cmdData.len); LOG(INFO) << "Acquired lock for SPI"; status = phNxpEse_SetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { @@ -373,7 +382,7 @@ Return<void> SecureElement::transmit(const hidl_vec<uint8_t>& data, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(result); @@ -424,7 +433,8 @@ Return<void> SecureElement::openLogicalChannel(const hidl_vec<uint8_t>& aid, LOG(INFO) << "Acquired the lock from SPI openLogicalChannel"; // In dedicated mode openLogical not allowed - if (IS_OSU_MODE(OsuHalExtn::getInstance().OPENLOGICAL)) { + if ((GET_CHIP_OS_VERSION() < OS_VERSION_6_2) && + (IS_OSU_MODE(OsuHalExtn::getInstance().OPENLOGICAL))) { LOG(ERROR) << "%s: Not allowed in dedicated mode!!!" << __func__; _hidl_cb(resApduBuff, SecureElementStatus::IOERROR); return Void(); @@ -494,7 +504,7 @@ Return<void> SecureElement::openLogicalChannel(const hidl_vec<uint8_t>& aid, send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); return Void(); @@ -590,7 +600,7 @@ Return<void> SecureElement::openLogicalChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); phNxpEse_free(cpdu.pdata); @@ -616,9 +626,9 @@ Return<void> SecureElement::openBasicChannel(const hidl_vec<uint8_t>& aid, 0x41, 0x01, 0x43, 0x4F, 0x52, 0x01}; LOG(ERROR) << "Acquired the lock in SPI openBasicChannel"; - OsuHalExtn::OsuApduMode mode = - IS_OSU_MODE(aid, OsuHalExtn::getInstance().OPENBASIC); - if (mode == OsuHalExtn::OSU_PROP_MODE) { + if ((GET_CHIP_OS_VERSION() < OS_VERSION_8_9) && + IS_OSU_MODE(aid, OsuHalExtn::getInstance().OPENBASIC) == + OsuHalExtn::OSU_PROP_MODE) { uint8_t sw[2] = {0x90, 0x00}; result.resize(sizeof(sw)); memcpy(&result[0], sw, 2); @@ -662,22 +672,24 @@ Return<void> SecureElement::openBasicChannel(const hidl_vec<uint8_t>& aid, } } - phNxpEse_data atrData; - if (phNxpEse_getAtr(&atrData) != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_getAtr failed"; - } - if (atrData.p_data != NULL) { - phNxpEse_free(atrData.p_data); - } + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) { + phNxpEse_data atrData; + if (phNxpEse_getAtr(&atrData) != ESESTATUS_SUCCESS) { + LOG(ERROR) << "phNxpEse_getAtr failed"; + } + if (atrData.p_data != NULL) { + phNxpEse_free(atrData.p_data); + } - if (phNxpEse_GetOsMode() == OSU_MODE) { - if (mOpenedchannelCount == 0) { - if (seHalDeInit() != SecureElementStatus::SUCCESS) { - LOG(INFO) << "seDeInit Failed"; + if (phNxpEse_GetOsMode() == OSU_MODE) { + if (mOpenedchannelCount == 0) { + if (seHalDeInit() != SecureElementStatus::SUCCESS) { + LOG(INFO) << "seDeInit Failed"; + } } + _hidl_cb(result, SecureElementStatus::IOERROR); + return Void(); } - _hidl_cb(result, SecureElementStatus::IOERROR); - return Void(); } if (mOpenedChannels.size() == 0x00) { @@ -755,7 +767,7 @@ Return<void> SecureElement::openBasicChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SecureElementStatus::SUCCESS) { SecureElementStatus closeChannelStatus = @@ -808,7 +820,7 @@ Return<SecureElementStatus> SecureElement::internalCloseChannel( } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } } if (channelNumber < mMaxChannelCount) { @@ -829,7 +841,8 @@ Return<SecureElementStatus> SecureElement::internalCloseChannel( Return<SecureElementStatus> SecureElement::closeChannel(uint8_t channelNumber) { AutoMutex guard(seHalLock); // Close internal allowed when not in dedicated Mode - if (!IS_OSU_MODE(OsuHalExtn::getInstance().CLOSE, channelNumber)) { + if ((GET_CHIP_OS_VERSION() >= OS_VERSION_8_9) || + (!IS_OSU_MODE(OsuHalExtn::getInstance().CLOSE, channelNumber))) { return internalCloseChannel(channelNumber); } else { /*Decrement channel count opened to @@ -904,7 +917,7 @@ Return<SecureElementStatus> SecureElement::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); diff --git a/snxxx/1.2/SecureElement.h b/snxxx/1.2/SecureElement.h index 198a039..28e95ff 100755..100644 --- a/snxxx/1.2/SecureElement.h +++ b/snxxx/1.2/SecureElement.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2020,2022-2023 NXP + * Copyright 2020,2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/snxxx/1.2/VirtualISO.cpp b/snxxx/1.2/VirtualISO.cpp index 857a254..445d97d 100755..100644 --- a/snxxx/1.2/VirtualISO.cpp +++ b/snxxx/1.2/VirtualISO.cpp @@ -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. @@ -17,9 +17,9 @@ ******************************************************************************/ #include "VirtualISO.h" -#include "NxpEse.h" #include "SecureElement.h" #ifdef NXP_BOOTTIME_UPDATE +#include "NxpEse.h" #include "eSEClient.h" #endif #include <android-base/logging.h> @@ -42,7 +42,9 @@ namespace implementation { #define DEFAULT_BASIC_CHANNEL 0x00 using ::android::hardware::secure_element::V1_2::ISecureElement; +#ifdef NXP_BOOTTIME_UPDATE using vendor::nxp::nxpese::V1_0::implementation::NxpEse; +#endif typedef struct gsTransceiveBuffer { phNxpEse_data cmdData; @@ -214,7 +216,7 @@ Return<void> VirtualISO::transmit(const hidl_vec<uint8_t>& data, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(result); @@ -328,7 +330,7 @@ Return<void> VirtualISO::openLogicalChannel(const hidl_vec<uint8_t>& aid, send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); return Void(); @@ -413,7 +415,7 @@ Return<void> VirtualISO::openLogicalChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } _hidl_cb(resApduBuff, sestatus); phNxpEse_free(cpdu.pdata); @@ -507,7 +509,7 @@ Return<void> VirtualISO::openBasicChannel(const hidl_vec<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SecureElementStatus::SUCCESS) { SecureElementStatus closeChannelStatus = @@ -562,7 +564,7 @@ VirtualISO::internalCloseChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (mOpenedChannels[channelNumber]) { mOpenedChannels[channelNumber] = false; @@ -611,7 +613,7 @@ VirtualISO::closeChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (mOpenedChannels[channelNumber]) { mOpenedChannels[channelNumber] = false; @@ -667,7 +669,7 @@ VirtualISO::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); diff --git a/snxxx/1.2/VirtualISO.h b/snxxx/1.2/VirtualISO.h index 53419e1..dc4f296 100755..100644 --- a/snxxx/1.2/VirtualISO.h +++ b/snxxx/1.2/VirtualISO.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2020,2022 NXP + * Copyright 2018-2020,2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +21,8 @@ #include <android-base/stringprintf.h> #include <android/hardware/secure_element/1.0/types.h> #include <android/hardware/secure_element/1.2/ISecureElement.h> +#include <android/binder_manager.h> +#include <android/binder_process.h> #include <hardware/hardware.h> #include <hidl/MQDescriptor.h> #include <hidl/Status.h> diff --git a/snxxx/aidl/SecureElement.cpp b/snxxx/aidl/SecureElement.cpp index 7a7a5aa..432a2ef 100644 --- a/snxxx/aidl/SecureElement.cpp +++ b/snxxx/aidl/SecureElement.cpp @@ -50,6 +50,19 @@ static std::vector<uint8_t> gsRspDataBuff(256); std::shared_ptr<ISecureElementCallback> SecureElement::mCb = nullptr; AIBinder_DeathRecipient* clientDeathRecipient = nullptr; std::vector<bool> SecureElement::mOpenedChannels; +static const std::vector<std::vector<uint8_t>> kWeaverAIDs = { + {0xA0, 0x00, 0x00, 0x03, 0x96, 0x10, 0x10}, // Primary AID + {0xA0, 0x00, 0x00, 0x03, 0x96, 0x54, 0x53, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x23, 0x00, 0x00, 0x00}, // Alternate AID +}; + +static bool isWeaverApplet(std::vector<uint8_t> aid) { + if (std::find(kWeaverAIDs.begin(), kWeaverAIDs.end(), aid) != + kWeaverAIDs.end()) { + return true; + } + return false; +} SecureElement::SecureElement() : mMaxChannelCount(0), mOpenedchannelCount(0), mIsEseInitialized(false) {} @@ -119,9 +132,10 @@ ScopedAStatus SecureElement::init( if (ESESTATUS_SUCCESS == phNxpEse_SetEndPoint_Cntxt(0)) { initStatus = phNxpEse_init(initParams); if (initStatus == ESESTATUS_SUCCESS) { - /*update OS mode during first init*/ - IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); - + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) { + /*update OS mode during first init*/ + IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); + } if (ESESTATUS_SUCCESS == phNxpEse_ResetEndPoint_Cntxt(0)) { LOG(INFO) << "ESE SPI init complete!!!"; mIsInitDone = true; @@ -135,7 +149,8 @@ ScopedAStatus SecureElement::init( if (status == ESESTATUS_SUCCESS && (initStatus == ESESTATUS_TRANSCEIVE_FAILED || initStatus == ESESTATUS_FAILED)) { - IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) + IS_OSU_MODE(OsuHalExtn::getInstance().INIT, 0); mIsInitDone = true; } } @@ -163,7 +178,8 @@ ScopedAStatus SecureElement::getAtr(std::vector<uint8_t>* _aidl_return) { bool mIsSeHalInitDone = false; // In dedicated mode getATR not allowed - if (IS_OSU_MODE(OsuHalExtn::getInstance().GETATR)) { + if ((GET_CHIP_OS_VERSION() < OS_VERSION_6_2) && + (IS_OSU_MODE(OsuHalExtn::getInstance().GETATR))) { LOG(ERROR) << "%s: Not allowed in dedicated mode!!!" << __func__; *_aidl_return = response; return ndk::ScopedAStatus::ok(); @@ -181,7 +197,7 @@ ScopedAStatus SecureElement::getAtr(std::vector<uint8_t>* _aidl_return) { } status = phNxpEse_SetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed"; } status = phNxpEse_getAtr(&atrData); if (status != ESESTATUS_SUCCESS) { @@ -195,7 +211,7 @@ ScopedAStatus SecureElement::getAtr(std::vector<uint8_t>* _aidl_return) { status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "Endpoint set failed"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed"; } if (status != ESESTATUS_SUCCESS) { @@ -204,7 +220,7 @@ ScopedAStatus SecureElement::getAtr(std::vector<uint8_t>* _aidl_return) { ALOGI("0x%x\t", *i); } - *_aidl_return = response; + *_aidl_return = std::move(response); if (atrData.p_data != NULL) { phNxpEse_free(atrData.p_data); } @@ -228,6 +244,14 @@ ScopedAStatus SecureElement::transmit(const std::vector<uint8_t>& data, AutoMutex guard(seHalLock); ESESTATUS status = ESESTATUS_FAILED; std::vector<uint8_t> result; + if (!mOpenedchannelCount) { + // 0x69, 0x86 = COMMAND NOT ALLOWED + uint8_t sw[2] = {0x69, 0x86}; + result.resize(sizeof(sw)); + memcpy(&result[0], sw, sizeof(sw)); + return ScopedAStatus::fromServiceSpecificError(CHANNEL_NOT_AVAILABLE); + } + phNxpEse_memset(&gsTxRxBuffer.cmdData, 0x00, sizeof(phNxpEse_data)); phNxpEse_memset(&gsTxRxBuffer.rspData, 0x00, sizeof(phNxpEse_data)); gsTxRxBuffer.cmdData.len = (uint32_t)data.size(); @@ -239,23 +263,24 @@ ScopedAStatus SecureElement::transmit(const std::vector<uint8_t>& data, *_aidl_return = result; return ScopedAStatus::ok(); } - OsuHalExtn::OsuApduMode mode = IS_OSU_MODE( - data, OsuHalExtn::getInstance().TRANSMIT, &gsTxRxBuffer.cmdData); - if (mode == OsuHalExtn::getInstance().OSU_BLOCKED_MODE) { - LOG(ERROR) << "Not allowed in dedicated mode!!!"; - /*Return empty vec*/ - *_aidl_return = result; - return ScopedAStatus::ok(); - } else if (mode == OsuHalExtn::getInstance().OSU_RST_MODE) { - uint8_t sw[2] = {0x90, 0x00}; - result.resize(sizeof(sw)); - memcpy(&result[0], sw, sizeof(sw)); - *_aidl_return = result; - return ScopedAStatus::ok(); + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) { + OsuHalExtn::OsuApduMode mode = IS_OSU_MODE( + data, OsuHalExtn::getInstance().TRANSMIT, &gsTxRxBuffer.cmdData); + if (mode == OsuHalExtn::getInstance().OSU_BLOCKED_MODE) { + LOG(ERROR) << "Not allowed in dedicated mode!!!"; + /*Return empty vec*/ + *_aidl_return = result; + return ScopedAStatus::ok(); + } else if (mode == OsuHalExtn::getInstance().OSU_RST_MODE) { + uint8_t sw[2] = {0x90, 0x00}; + result.resize(sizeof(sw)); + memcpy(&result[0], sw, sizeof(sw)); + *_aidl_return = result; + return ScopedAStatus::ok(); + } } else { - // continue with normal processing + memcpy(gsTxRxBuffer.cmdData.p_data, data.data(), gsTxRxBuffer.cmdData.len); } - // memcpy(gsTxRxBuffer.cmdData.p_data, data.data(), gsTxRxBuffer.cmdData.len); LOG(INFO) << "Acquired lock for SPI"; status = phNxpEse_SetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { @@ -272,19 +297,13 @@ ScopedAStatus SecureElement::transmit(const std::vector<uint8_t>& data, memcpy(&result[0], respBuf, sizeof(respBuf)); } else { LOG(ERROR) << "transmit failed!!!"; - if (!mOpenedchannelCount) { - // 0x69, 0x86 = COMMAND NOT ALLOWED - uint8_t sw[2] = {0x69, 0x86}; - result.resize(sizeof(sw)); - memcpy(&result[0], sw, sizeof(sw)); - } } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } - *_aidl_return = result; + *_aidl_return = std::move(result); if (NULL != gsTxRxBuffer.cmdData.p_data) { phNxpEse_free(gsTxRxBuffer.cmdData.p_data); gsTxRxBuffer.cmdData.p_data = NULL; @@ -333,7 +352,8 @@ ScopedAStatus SecureElement::openLogicalChannel( LOG(INFO) << "Acquired the lock from SPI openLogicalChannel"; // In dedicated mode openLogical not allowed - if (IS_OSU_MODE(OsuHalExtn::getInstance().OPENLOGICAL)) { + if ((GET_CHIP_OS_VERSION() < OS_VERSION_8_9) && + (IS_OSU_MODE(OsuHalExtn::getInstance().OPENLOGICAL))) { LOG(ERROR) << "%s: Not allowed in dedicated mode!!!" << __func__; *_aidl_return = resApduBuff; return ScopedAStatus::fromServiceSpecificError(IOERROR); @@ -403,7 +423,7 @@ ScopedAStatus SecureElement::openLogicalChannel( send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } *_aidl_return = resApduBuff; return ScopedAStatus::fromServiceSpecificError(sestatus); @@ -497,9 +517,9 @@ ScopedAStatus SecureElement::openLogicalChannel( } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } - *_aidl_return = resApduBuff; + *_aidl_return = std::move(resApduBuff); phNxpEse_free(cpdu.pdata); phNxpEse_free(rpdu.pdata); @@ -521,6 +541,8 @@ ScopedAStatus SecureElement::openBasicChannel( ESESTATUS status = ESESTATUS_SUCCESS; phNxpEse_7816_cpdu_t cpdu; phNxpEse_7816_rpdu_t rpdu; + std::vector<uint8_t> ls_aid = {0xA0, 0x00, 0x00, 0x03, 0x96, 0x41, 0x4C, + 0x41, 0x01, 0x43, 0x4F, 0x52, 0x01}; if (mOpenedChannels[0]) { LOG(ERROR) << "openBasicChannel failed, channel already in use"; @@ -529,9 +551,9 @@ ScopedAStatus SecureElement::openBasicChannel( } LOG(ERROR) << "Acquired the lock in SPI openBasicChannel"; - OsuHalExtn::OsuApduMode mode = - IS_OSU_MODE(aid, OsuHalExtn::getInstance().OPENBASIC); - if (mode == OsuHalExtn::OSU_PROP_MODE) { + if ((GET_CHIP_OS_VERSION() < OS_VERSION_8_9) && + IS_OSU_MODE(aid, OsuHalExtn::getInstance().OPENBASIC) == + OsuHalExtn::OSU_PROP_MODE) { uint8_t sw[2] = {0x90, 0x00}; result.resize(sizeof(sw)); memcpy(&result[0], sw, 2); @@ -562,6 +584,8 @@ ScopedAStatus SecureElement::openBasicChannel( *_aidl_return = result; return ScopedAStatus::fromServiceSpecificError(FAILED); } else { + mOpenedChannels[0] = true; + mOpenedchannelCount++; *_aidl_return = result; return ScopedAStatus::ok(); } @@ -576,22 +600,24 @@ ScopedAStatus SecureElement::openBasicChannel( } } - phNxpEse_data atrData; - if (phNxpEse_getAtr(&atrData) != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_getAtr failed"; - } - if (atrData.p_data != NULL) { - phNxpEse_free(atrData.p_data); - } + if (GET_CHIP_OS_VERSION() < OS_VERSION_8_9) { + phNxpEse_data atrData; + if (phNxpEse_getAtr(&atrData) != ESESTATUS_SUCCESS) { + LOG(ERROR) << "phNxpEse_getAtr failed"; + } + if (atrData.p_data != NULL) { + phNxpEse_free(atrData.p_data); + } - if (phNxpEse_GetOsMode() == OSU_MODE) { - if (mOpenedchannelCount == 0) { - if (seHalDeInit() != SESTATUS_SUCCESS) { - LOG(INFO) << "seDeInit Failed"; + if (phNxpEse_GetOsMode() == OSU_MODE) { + if (mOpenedchannelCount == 0) { + if (seHalDeInit() != SESTATUS_SUCCESS) { + LOG(INFO) << "seDeInit Failed"; + } } + *_aidl_return = result; + return ScopedAStatus::fromServiceSpecificError(IOERROR); } - *_aidl_return = result; - return ScopedAStatus::fromServiceSpecificError(IOERROR); } if (mOpenedChannels.size() == 0x00) { @@ -669,7 +695,7 @@ ScopedAStatus SecureElement::openBasicChannel( } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SESTATUS_SUCCESS) { int closeChannelStatus = internalCloseChannel(DEFAULT_BASIC_CHANNEL); @@ -677,7 +703,7 @@ ScopedAStatus SecureElement::openBasicChannel( LOG(ERROR) << "%s: closeChannel Failed" << __func__; } } - *_aidl_return = result; + *_aidl_return = std::move(result); phNxpEse_free(cpdu.pdata); phNxpEse_free(rpdu.pdata); return sestatus == SESTATUS_SUCCESS @@ -723,7 +749,7 @@ int SecureElement::internalCloseChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } } else if (channelNumber == DEFAULT_BASIC_CHANNEL && mOpenedChannels[channelNumber]) { @@ -750,7 +776,8 @@ ScopedAStatus SecureElement::closeChannel(int8_t channelNumber) { AutoMutex guard(seHalLock); int sestatus; // Close internal allowed when not in dedicated Mode - if (!IS_OSU_MODE(OsuHalExtn::getInstance().CLOSE, channelNumber)) { + if ((GET_CHIP_OS_VERSION() >= OS_VERSION_8_9) || + (!IS_OSU_MODE(OsuHalExtn::getInstance().CLOSE, channelNumber))) { sestatus = internalCloseChannel(channelNumber); } else { /*Decrement channel count opened to @@ -814,7 +841,7 @@ int SecureElement::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(0); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); @@ -928,13 +955,11 @@ static int getResponseInternal(uint8_t cla, phNxpEse_7816_rpdu_t& rpdu, } uint8_t SecureElement::getReserveChannelCnt(const std::vector<uint8_t>& aid) { - const std::vector<uint8_t> weaverAid = {0xA0, 0x00, 0x00, 0x03, - 0x96, 0x10, 0x10}; const std::vector<uint8_t> araAid = {0xA0, 0x00, 0x00, 0x01, 0x51, 0x41, 0x43, 0x4C, 0x00}; uint8_t reserveChannel = 0; // Check priority access enabled then only reserve channel - if (mHasPriorityAccess && aid != weaverAid && aid != araAid) { + if (mHasPriorityAccess && !isWeaverApplet(aid) && aid != araAid) { // Exclude basic channel reserveChannel = 1; } diff --git a/snxxx/aidl/VirtualISO.cpp b/snxxx/aidl/VirtualISO.cpp index 571e365..5808238 100644 --- a/snxxx/aidl/VirtualISO.cpp +++ b/snxxx/aidl/VirtualISO.cpp @@ -111,7 +111,7 @@ ScopedAStatus VirtualISO::init( ScopedAStatus VirtualISO::getAtr(std::vector<uint8_t>* _aidl_return) { std::vector<uint8_t> response; - *_aidl_return = response; + *_aidl_return = std::move(response); return ScopedAStatus::ok(); } @@ -152,10 +152,10 @@ ScopedAStatus VirtualISO::transmit(const std::vector<uint8_t>& data, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } - *_aidl_return = result; + *_aidl_return = std::move(result); if (NULL != gsTxRxBuffer.cmdData.p_data) { phNxpEse_free(gsTxRxBuffer.cmdData.p_data); @@ -269,7 +269,7 @@ ScopedAStatus VirtualISO::openLogicalChannel( send the callback and return*/ status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } *_aidl_return = resApduBuff; return ScopedAStatus::fromServiceSpecificError(sestatus); @@ -352,9 +352,9 @@ ScopedAStatus VirtualISO::openLogicalChannel( } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } - *_aidl_return = resApduBuff; + *_aidl_return = std::move(resApduBuff); phNxpEse_free(cpdu.pdata); phNxpEse_free(rpdu.pdata); @@ -448,7 +448,7 @@ ScopedAStatus VirtualISO::openBasicChannel(const std::vector<uint8_t>& aid, } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (sestatus != SESTATUS_SUCCESS) { int closeChannelStatus = internalCloseChannel(DEFAULT_BASIC_CHANNEL); @@ -456,7 +456,7 @@ ScopedAStatus VirtualISO::openBasicChannel(const std::vector<uint8_t>& aid, LOG(ERROR) << "%s: closeChannel Failed" << __func__; } } - *_aidl_return = result; + *_aidl_return = std::move(result); phNxpEse_free(cpdu.pdata); phNxpEse_free(rpdu.pdata); return sestatus == SESTATUS_SUCCESS @@ -503,7 +503,7 @@ int VirtualISO::internalCloseChannel(uint8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (mOpenedChannels[channelNumber]) { mOpenedChannels[channelNumber] = false; @@ -551,7 +551,7 @@ ScopedAStatus VirtualISO::closeChannel(int8_t channelNumber) { } status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; } if (mOpenedChannels[channelNumber]) { mOpenedChannels[channelNumber] = false; @@ -610,7 +610,7 @@ int VirtualISO::seHalDeInit() { if (ESESTATUS_SUCCESS != deInitStatus) mIsDeInitDone = false; status = phNxpEse_ResetEndPoint_Cntxt(1); if (status != ESESTATUS_SUCCESS) { - LOG(ERROR) << "phNxpEse_SetEndPoint_Cntxt failed!!!"; + LOG(ERROR) << "phNxpEse_ResetEndPoint_Cntxt failed!!!"; mIsDeInitDone = false; } status = phNxpEse_close(deInitStatus); diff --git a/snxxx/ese-clients/inc/eSEClient.h b/snxxx/ese-clients/inc/eSEClient.h index a017f60..4122f7e 100644 --- a/snxxx/ese-clients/inc/eSEClient.h +++ b/snxxx/ese-clients/inc/eSEClient.h @@ -16,6 +16,7 @@ * ******************************************************************************/ +#ifdef NXP_BOOTTIME_UPDATE #include "eSEClientIntf.h" #include "phNxpEse_Api.h" @@ -37,3 +38,4 @@ typedef enum { } SEDomainID; #endif /* ESE_UPDATE_2_H_ */ +#endif /* NXP_BOOTTIME_UPDATE */
\ No newline at end of file diff --git a/snxxx/ese-clients/src/eSEClient.cpp b/snxxx/ese-clients/src/eSEClient.cpp index 2498027..566358b 100644 --- a/snxxx/ese-clients/src/eSEClient.cpp +++ b/snxxx/ese-clients/src/eSEClient.cpp @@ -16,6 +16,7 @@ * ******************************************************************************/ +#ifdef NXP_BOOTTIME_UPDATE #include "eSEClient.h" #include <IChannel.h> @@ -501,3 +502,4 @@ SESTATUS eSEUpdate_SeqHandler() { } return SESTATUS_SUCCESS; } +#endif /* NXP_BOOTTIME_UPDATE */
\ No newline at end of file diff --git a/snxxx/extns/impl/NxpEse.cpp b/snxxx/extns/impl/NxpEse.cpp index 9970db6..72390dd 100755..100644 --- a/snxxx/extns/impl/NxpEse.cpp +++ b/snxxx/extns/impl/NxpEse.cpp @@ -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. @@ -15,10 +15,9 @@ * limitations under the License. * ******************************************************************************/ -#include "NxpEse.h" #ifdef NXP_BOOTTIME_UPDATE +#include "NxpEse.h" #include "eSEClient.h" -#endif #include <android-base/logging.h> #include <android-base/stringprintf.h> #include <memunreachable/memunreachable.h> @@ -166,7 +165,6 @@ exit1: virtualISOCallback->onStateChange(false); } } -#ifdef NXP_BOOTTIME_UPDATE Return<void> NxpEse::ioctlHandler(uint64_t ioctlType, ese_nxp_IoctlInOutData_t& inpOutData) { switch (ioctlType) { @@ -183,7 +181,6 @@ Return<void> NxpEse::ioctlHandler(uint64_t ioctlType, } return Void(); } -#endif Return<void> NxpEse::ioctl(uint64_t ioctlType, const hidl_vec<uint8_t>& inOutData, @@ -196,20 +193,16 @@ Return<void> NxpEse::ioctl(uint64_t ioctlType, * underlying HAL implementation since it's an inout argument*/ memcpy(&inpOutData, pInOutData, sizeof(ese_nxp_IoctlInOutData_t)); ESESTATUS status = phNxpEse_spiIoctl(ioctlType, &inpOutData); -#ifdef NXP_BOOTTIME_UPDATE ioctlHandler(ioctlType, inpOutData); -#endif /*copy data and additional fields indicating status of ioctl operation * and context of the caller. Then invoke the corresponding proxy callback*/ inpOutData.out.ioctlType = ioctlType; inpOutData.out.result = status; -#ifdef NXP_BOOTTIME_UPDATE if (ioctlType == HAL_ESE_IOCTL_GET_ESE_UPDATE_STATE) { inpOutData.out.data.status = (getJcopUpdateRequired() | (getLsUpdateRequired() << 8)); } -#endif - hidl_vec<uint8_t> outputData; + EseData outputData; outputData.setToExternal((uint8_t*)&inpOutData.out, sizeof(ese_nxp_ExtnOutputData_t)); LOG(ERROR) << "GET ESE update state2 = " << inpOutData.out.data.status; @@ -230,3 +223,4 @@ Return<void> NxpEse::debug(const hidl_handle& /* fd */, } // namespace nxpese } // namespace nxp } // namespace vendor +#endif //NXP_BOOTTIME_UPDATE
\ No newline at end of file diff --git a/snxxx/extns/impl/NxpEse.h b/snxxx/extns/impl/NxpEse.h index 02e2302..bc2b01c 100755..100644 --- a/snxxx/extns/impl/NxpEse.h +++ b/snxxx/extns/impl/NxpEse.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2019,2022 NXP + * Copyright 2018-2019,2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ * limitations under the License. * ******************************************************************************/ +#ifdef NXP_BOOTTIME_UPDATE #ifndef VENDOR_NXP_NXPNFC_V1_0_NXPNFC_H #define VENDOR_NXP_NXPNFC_V1_0_NXPNFC_H @@ -56,7 +57,6 @@ struct NxpEse : public INxpEse { // Methods from ::android::hidl::base::V1_0::IBase follow. Return<void> debug(const hidl_handle& handle, const hidl_vec<hidl_string>& options) override; - Return<void> ioctl(uint64_t ioctlType, const hidl_vec<uint8_t>& inOutData, ioctl_cb _hidl_cb) override; static Return<void> setSeCallBack( @@ -73,7 +73,6 @@ struct NxpEse : public INxpEse { clientCallback); static void initSEService(); static void initVIrtualISOService(); - private: Return<void> ioctlHandler(uint64_t ioctlType, ese_nxp_IoctlInOutData_t& inpOutData); @@ -86,3 +85,4 @@ struct NxpEse : public INxpEse { } // namespace vendor #endif // VENDOR_NXP_NXPNFC_V1_0_NXPNFC_H +#endif // NXP_BOOTTIME_UPDATE
\ No newline at end of file diff --git a/snxxx/libese-spi/common/include/phNxpEseFeatures.h b/snxxx/libese-spi/common/include/phNxpEseFeatures.h index af8f491..4cc1d0e 100644 --- a/snxxx/libese-spi/common/include/phNxpEseFeatures.h +++ b/snxxx/libese-spi/common/include/phNxpEseFeatures.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2020, 2022 NXP + * Copyright 2018-2020, 2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +39,7 @@ typedef enum OS_VERSION { OS_VERSION_5_2_2 = 4, OS_VERSION_6_2 = 5, OS_VERSION_6_3 = 6, + OS_VERSION_8_9 = 8, INVALID_OS_VERSION = 0xFF, } phNxpEse_OsVersion_t; diff --git a/snxxx/libese-spi/p73/inc/phNxpEse_Api.h b/snxxx/libese-spi/p73/inc/phNxpEse_Api.h index 7d720db..f21c6d2 100755..100644 --- a/snxxx/libese-spi/p73/inc/phNxpEse_Api.h +++ b/snxxx/libese-spi/p73/inc/phNxpEse_Api.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2021,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. @@ -115,16 +115,7 @@ typedef struct phNxpEse_initParams { */ ESESTATUS phNxpEse_init(phNxpEse_initParams initParams); -/** - * \ingroup spi_libese - * - * \brief Check if libese has opened - * - * \retval return false if it is close, otherwise true. - * - */ -bool phNxpEse_isOpen(); - +#ifdef NXP_BOOTTIME_UPDATE /** * \ingroup spi_libese * @@ -138,6 +129,8 @@ bool phNxpEse_isOpen(); * */ ESESTATUS phNxpEse_spiIoctl(uint64_t ioctlType, void* p_data); +#endif + /** * \ingroup spi_libese * @@ -184,21 +177,6 @@ ESESTATUS phNxpEse_open(phNxpEse_initParams initParams); /** * \ingroup spi_libese - * \brief 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 period. - * - * \param[in] initParams - Initialize with init mode ( normal/osu) and media - * type(SPI- legacy/ APDU type). - * - * \retval ESESTATUS_SUCCESS On Success ESESTATUS_SUCCESS else proper error code - * - */ -ESESTATUS phNxpEse_openPrioSession(phNxpEse_initParams initParams); - -/** - * \ingroup spi_libese * \brief This function prepares the C-APDU, send to ESE and then receives the *response from ESE, * decode it and returns data. @@ -291,16 +269,6 @@ ESESTATUS phNxpEse_getAtr(phNxpEse_data* pATR); /** * \ingroup spi_libese - * \brief This function sends the S-frame to indicate END_OF_APDU - * - * - * \retval ESESTATUS_SUCCESS Always return ESESTATUS_SUCCESS (0). - * - */ -ESESTATUS phNxpEse_EndOfApdu(void); - -/** - * \ingroup spi_libese * \brief This function suspends execution of the calling thread for * (at least) usec microseconds * @@ -375,27 +343,6 @@ void phNxpEse_free(void* ptr); /** * \ingroup spi_libese - * \brief This function performs disable/enable power control - * - * - * \retval ESESTATUS_SUCCESS Always return ESESTATUS_SUCCESS (0). - * - */ -ESESTATUS phNxpEse_DisablePwrCntrl(void); - -/** - * \ingroup spi_libese - * \brief This function is used to get the ESE timer status - * - * \param[out] timer_buffer - * - * \retval ESESTATUS_SUCCESS Always return ESESTATUS_SUCCESS (0). - * - */ -ESESTATUS phNxpEse_GetEseStatus(phNxpEse_data* timer_buffer); - -/** - * \ingroup spi_libese * \brief This function power recycles the ESE * (using prop. FW command) by talking to NFC HAL * 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(¤t_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 diff --git a/snxxx/libese-spi/p73/pal/NxpTimer.cpp b/snxxx/libese-spi/p73/pal/NxpTimer.cpp index 17274e7..d3d9023 100644 --- a/snxxx/libese-spi/p73/pal/NxpTimer.cpp +++ b/snxxx/libese-spi/p73/pal/NxpTimer.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2022 NXP + * Copyright 2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ #include <unistd.h> NxpTimer::NxpTimer(std::string tag) { - logtag = tag; + logtag = std::move(tag); is_running = false; start_ts = end_ts = 0; } diff --git a/snxxx/libese-spi/p73/pal/phNxpEsePal.cpp b/snxxx/libese-spi/p73/pal/phNxpEsePal.cpp index 1cf8927..1ff56d0 100755..100644 --- a/snxxx/libese-spi/p73/pal/phNxpEsePal.cpp +++ b/snxxx/libese-spi/p73/pal/phNxpEsePal.cpp @@ -205,7 +205,7 @@ ESESTATUS phPalEse_ioctl(phPalEse_ControlCode_t eControlCode, void* pDevHandle, ** ** Description This function suspends execution of the calling thread for ** total_time usecs(max extra delay 1 usecs) with busy wait. -** Use this only for short delays (less than 500 microseconds) +** Use this only for short delays (less than 500 microsecs) ** ** Returns None ** diff --git a/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.cpp b/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.cpp index 08ddda1..fa29656 100644 --- a/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.cpp +++ b/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.cpp @@ -45,6 +45,7 @@ #define MAX_RETRY_CNT 10 #define HAL_NFC_SPI_DWP_SYNC 21 +#define USE_COLD_RESET 0x00 extern int omapi_status; @@ -76,6 +77,7 @@ void EseSpiTransport::Close(void* pDevHandle) { return; } +#ifdef NXP_BOOTTIME_UPDATE /******************************************************************************* ** ** Function phNxpEse_spiIoctl @@ -117,6 +119,8 @@ ESESTATUS phNxpEse_spiIoctl(uint64_t ioctlType, void* p_data) { #endif return status; } +#endif + #if (NFC_NXP_ESE_VER == JCOP_VER_4_0) /******************************************************************************* ** @@ -190,6 +194,15 @@ ESESTATUS EseSpiTransport::OpenAndConfigure(pphPalEse_Config_t pConfig) { mConfigColdResetIntf = 0x01; /* Default interface is NFC HAL */ NXP_LOG_ESE_D("mConfigColdResetIntf: Default value "); } + /* Read eSE GPIO reset config */ + if (EseConfig::hasKey(NAME_NXP_ESE_GPIO_RESET)) { + mConfigGpioReset = EseConfig::getUnsigned(NAME_NXP_ESE_GPIO_RESET); + NXP_LOG_ESE_D("mConfigGpioReset value from config file = %ld", + mConfigGpioReset); + } else { + mConfigGpioReset = USE_COLD_RESET; + NXP_LOG_ESE_D("mConfigGpioReset: Default value "); + } NXP_LOG_ESE_D("Opening port=%s\n", pConfig->pDevName); /* open port */ retry: @@ -383,20 +396,26 @@ ESESTATUS EseSpiTransport::Ioctl(phPalEse_ControlCode_t eControlCode, case phPalEse_e_ChipRst: if (GET_CHIP_OS_VERSION() != OS_VERSION_4_0) { if (level == 5) { // SPI driver communication part - if (!mConfigColdResetIntf) { /* Call the driver IOCTL */ - retioctl = - ioctl((intptr_t)pDevHandle, ESE_PERFORM_COLD_RESET, level); + if (!mConfigColdResetIntf) { // Call the driver IOCTL + unsigned int cmd = ESE_PERFORM_COLD_RESET; + if ((mConfigGpioReset == 0x01) && + ((GET_CHIP_OS_VERSION() == OS_VERSION_8_9))) { + cmd = P61_SET_PWR; + } + retioctl = ioctl((intptr_t)pDevHandle, cmd, level); if (0x00 <= retioctl) { ret = ESESTATUS_SUCCESS; } } else { -#if (NFC_NXP_ESE_VER == JCOP_VER_5_x) - // Nfc Driver communication part - pNfcAdapt.Initialize(); - ret = pNfcAdapt.resetEse(level); -#else - ret = ESESTATUS_SUCCESS; -#endif + if ((NFC_NXP_ESE_VER == JCOP_VER_5_x) && + (GET_CHIP_OS_VERSION() != OS_VERSION_8_9)) { + // Nfc Driver communication part + pNfcAdapt.Initialize(); + ret = pNfcAdapt.resetEse(level); + } else { + NXP_LOG_ESE_E("%s: Not supported", __func__); + ret = ESESTATUS_SUCCESS; + } } } else { ret = ESESTATUS_SUCCESS; diff --git a/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.h b/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.h index 2d252c2..4dc87ee 100644 --- a/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.h +++ b/snxxx/libese-spi/p73/pal/spi/EseSpiTransport.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2020 NXP + * Copyright 2020, 2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,5 +30,5 @@ class EseSpiTransport : public EseTransport { private: unsigned long int mConfigSofWrite, mConfigSpiWriteTimeout, - mConfigColdResetIntf; + mConfigColdResetIntf, mConfigGpioReset; };
\ No newline at end of file diff --git a/snxxx/libese-spi/p73/spm/phNxpEse_Spm.cpp b/snxxx/libese-spi/p73/spm/phNxpEse_Spm.cpp index b2c5558..ec92bfd 100755..100644 --- a/snxxx/libese-spi/p73/spm/phNxpEse_Spm.cpp +++ b/snxxx/libese-spi/p73/spm/phNxpEse_Spm.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2019,2022 NXP + * Copyright 2018-2019, 2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -201,69 +201,6 @@ ESESTATUS phNxpEse_SPM_ConfigPwr(spm_power_t arg) { } /****************************************************************************** - * Function phNxpEse_SPM_EnablePwr - * - * Description This function request to the nfc i2c driver - * to enable power to ese. This api should be called before - * sending any apdu to ese. - * - * Returns On Success ESESTATUS_SUCCESS else proper error code - * - ******************************************************************************/ -ESESTATUS phNxpEse_SPM_EnablePwr(void) { - int32_t ret = -1; - ESESTATUS wSpmStatus = ESESTATUS_SUCCESS; - spm_state_t current_spm_state = SPM_STATE_INVALID; - NXP_LOG_ESE_D("%s : phNxpEse_SPM_EnablePwr is set to = 0x%d", __FUNCTION__, - 0); - ret = phPalEse_ioctl(phPalEse_e_ChipRst, pEseDeviceHandle, 0); - if (ret < 0) { - NXP_LOG_ESE_E("%s : failed errno = 0x%x", __FUNCTION__, errno); - if (errno == -EBUSY) { - wSpmStatus = phNxpEse_SPM_GetState(¤t_spm_state); - if (wSpmStatus != ESESTATUS_SUCCESS) { - NXP_LOG_ESE_E(" %s : phNxpEse_SPM_GetPwrState Failed", __FUNCTION__); - return wSpmStatus; - } else { - if (current_spm_state == SPM_STATE_DWNLD) { - wSpmStatus = ESESTATUS_DWNLD_BUSY; - } else { - wSpmStatus = ESESTATUS_BUSY; - } - } - - } else { - wSpmStatus = ESESTATUS_FAILED; - } - } - - return wSpmStatus; -} - -/****************************************************************************** - * Function phNxpEse_SPM_DisablePwr - * - * Description This function request to the nfc i2c driver - * to disable power to ese. This api should be called - * once apdu exchange is done. - * - * Returns On Success ESESTATUS_SUCCESS else proper error code - * - ******************************************************************************/ -ESESTATUS phNxpEse_SPM_DisablePwr(void) { - int32_t ret = -1; - ESESTATUS status = ESESTATUS_SUCCESS; - NXP_LOG_ESE_D("%s : phNxpEse_SPM_DisablePwr is set to = 0x%d", __FUNCTION__, - 1); - ret = phPalEse_ioctl(phPalEse_e_ChipRst, pEseDeviceHandle, 1); - if (ret < 0) { - NXP_LOG_ESE_E("%s : failed errno = 0x%x", __FUNCTION__, errno); - status = ESESTATUS_FAILED; - } - - return status; -} -/****************************************************************************** * Function phNxpEse_SPM_SetPwrScheme * * Description This function request to the nfc i2c driver @@ -385,73 +322,6 @@ ESESTATUS phNxpEse_SPM_SetEseClientUpdateState(long arg) { return status; } -/****************************************************************************** - * Function phNxpEse_SPM_ResetPwr - * - * Description This function request to the nfc i2c driver - * to reset ese. - * - * Returns On Success ESESTATUS_SUCCESS else proper error code - * - ******************************************************************************/ -ESESTATUS phNxpEse_SPM_ResetPwr(void) { - int32_t ret = -1; - ESESTATUS wSpmStatus = ESESTATUS_SUCCESS; - spm_state_t current_spm_state = SPM_STATE_INVALID; - - /* reset the ese */ - ret = phPalEse_ioctl(phPalEse_e_ChipRst, pEseDeviceHandle, 2); - if (ret < 0) { - NXP_LOG_ESE_E("%s : failed errno = 0x%x", __FUNCTION__, errno); - if (errno == -EBUSY || errno == EBUSY) { - wSpmStatus = phNxpEse_SPM_GetState(¤t_spm_state); - if (wSpmStatus != ESESTATUS_SUCCESS) { - NXP_LOG_ESE_E(" %s : phNxpEse_SPM_GetPwrState Failed", __FUNCTION__); - return wSpmStatus; - } else { - if (current_spm_state == SPM_STATE_DWNLD) { - wSpmStatus = ESESTATUS_DWNLD_BUSY; - } else { - wSpmStatus = ESESTATUS_BUSY; - } - } - - } else { - wSpmStatus = ESESTATUS_FAILED; - } - } - - return wSpmStatus; -} - -/******************************************************************************* -** -** Function phTmlEse_get_ese_access -** -** Description -** -** Parameters timeout - timeout to wait for ese access -** -** Returns success or failure -** -*******************************************************************************/ -ESESTATUS phNxpEse_SPM_GetAccess(long timeout) { - ESESTATUS status = ESESTATUS_SUCCESS; - NXP_LOG_ESE_D("phTmlEse_get_ese_access(), timeout %ld", timeout); -#if ((NFC_NXP_ESE_VER == JCOP_VER_3_1) || (NFC_NXP_ESE_VER == JCOP_VER_3_2)) - int ret = -1; - - ret = phPalEse_ioctl(phPalEse_e_GetEseAccess, pEseDeviceHandle, timeout); - if (ret < 0) { - if (ret == -EBUSY) - status = ESESTATUS_BUSY; - else - status = ESESTATUS_FAILED; - } - NXP_LOG_ESE_D("phTmlEse_get_ese_access(), exit %d", status); -#endif - return status; -} /******************************************************************************* ** ** Function phNxpEse_SPM_RelAccess diff --git a/snxxx/libese-spi/p73/spm/phNxpEse_Spm.h b/snxxx/libese-spi/p73/spm/phNxpEse_Spm.h index a65d991..1fb15ed 100644 --- a/snxxx/libese-spi/p73/spm/phNxpEse_Spm.h +++ b/snxxx/libese-spi/p73/spm/phNxpEse_Spm.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2019 NXP + * Copyright 2018-2019, 2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -83,28 +83,6 @@ ESESTATUS phNxpEse_SPM_ConfigPwr(spm_power_t arg); /** * \ingroup SPI_Power_Management - * \brief This function request to the nfc i2c driver - * to enable power to ese. This api should be called before - * sending any apdu to ese. - * - * - * \retval -On Success ESESTATUS_SUCCESS else proper error code - */ -ESESTATUS phNxpEse_SPM_EnablePwr(void); - -/** - * \ingroup SPI_Power_Management - * \brief This function request to the nfc i2c driver - * to disable power to ese. This api should be called - * once apdu exchange is done. - * - * - * \retval -On Success ESESTATUS_SUCCESS else proper error code - */ -ESESTATUS phNxpEse_SPM_DisablePwr(void); - -/** - * \ingroup SPI_Power_Management * \brief This function gets the current power state of ESE * \param[in] current_state -input is of type spm_state_t. * @@ -114,25 +92,6 @@ ESESTATUS phNxpEse_SPM_GetState(spm_state_t* current_state); /** * \ingroup SPI_Power_Management - * \brief This function request to the nfc i2c driver - * to reset ese. - * - * \retval -On Success ESESTATUS_SUCCESS else proper error code - */ -ESESTATUS phNxpEse_SPM_ResetPwr(void); - -/** - * \ingroup SPI_Power_Management - * \brief This function request to get access to eSE - * - * \param[in] timeout - timeout to wait for ese access. - * - * \retval -On Success ESESTATUS_SUCCESS else proper error code - */ -ESESTATUS phNxpEse_SPM_GetAccess(long timeout); - -/** - * \ingroup SPI_Power_Management * \brief This function set the SPM power state * * \param[in] arg - state value. diff --git a/snxxx/libese-spi/p73/utils/config.cpp b/snxxx/libese-spi/p73/utils/config.cpp index a470af8..79dc73a 100644 --- a/snxxx/libese-spi/p73/utils/config.cpp +++ b/snxxx/libese-spi/p73/utils/config.cpp @@ -15,9 +15,9 @@ */ /****************************************************************************** * - * The original Work has been changed by NXP Semiconductors. + * The original Work has been changed by NXP. * - * Copyright (C) 2019 NXP Semiconductors + * Copyright 2019,2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -156,9 +156,3 @@ std::string ConfigFile::getString(const std::string& key) { unsigned ConfigFile::getUnsigned(const std::string& key) { return getValue(key).getUnsigned(); } - -std::vector<uint8_t> ConfigFile::getBytes(const std::string& key) { - return getValue(key).getBytes(); -} - -void ConfigFile::clear() { values_.clear(); } diff --git a/snxxx/libese-spi/p73/utils/config.h b/snxxx/libese-spi/p73/utils/config.h index 115c7fa..7b37442 100644 --- a/snxxx/libese-spi/p73/utils/config.h +++ b/snxxx/libese-spi/p73/utils/config.h @@ -15,9 +15,9 @@ */ /****************************************************************************** * - * The original Work has been changed by NXP Semiconductors. + * The original Work has been changed by NXP. * - * Copyright (C) 2019 NXP Semiconductors + * Copyright 2019,2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,9 +65,6 @@ class ConfigFile { bool hasKey(const std::string& key); std::string getString(const std::string& key); unsigned getUnsigned(const std::string& key); - std::vector<uint8_t> getBytes(const std::string& key); - - void clear(); private: ConfigValue& getValue(const std::string& key); diff --git a/snxxx/libese-spi/p73/utils/ese_config.cpp b/snxxx/libese-spi/p73/utils/ese_config.cpp index 4a6b2cc..e90db57 100644 --- a/snxxx/libese-spi/p73/utils/ese_config.cpp +++ b/snxxx/libese-spi/p73/utils/ese_config.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018 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. @@ -79,9 +79,3 @@ unsigned EseConfig::getUnsigned(const std::string& key, if (hasKey(key)) return getUnsigned(key); return default_value; } - -std::vector<uint8_t> EseConfig::getBytes(const std::string& key) { - return getInstance().config_.getBytes(key); -} - -void EseConfig::clear() { getInstance().config_.clear(); } diff --git a/snxxx/libese-spi/p73/utils/ese_config.h b/snxxx/libese-spi/p73/utils/ese_config.h index d5da308..e3d5c77 100755..100644 --- a/snxxx/libese-spi/p73/utils/ese_config.h +++ b/snxxx/libese-spi/p73/utils/ese_config.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2020,2022 NXP + * Copyright 2018-2020,2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,10 +41,10 @@ #define NAME_NXP_VISO_DPD_ENABLED "NXP_VISO_DPD_ENABLED" #define NAME_NXP_NAD_POLL_RETRY_TIME "NXP_NAD_POLL_RETRY_TIME" #define NAME_RNACK_RETRY_DELAY "RNACK_RETRY_DELAY" -#define NAME_NXP_P61_JCOP_DEFAULT_INTERFACE "NXP_P61_JCOP_DEFAULT_INTERFACE" #define NAME_NXP_ESE_IFSD_VALUE "NXP_ESE_IFSD_VALUE" #define NAME_NXP_EUICC_IFSD_VALUE "NXP_EUICC_IFSD_VALUE" #define NAME_NXP_P61_COLD_RESET_INTERFACE "NXP_P61_COLD_RESET_INTERFACE" +#define NAME_NXP_ESE_GPIO_RESET "NXP_ESE_GPIO_RESET" #define NAME_NXP_OS_VERSION "NXP_OS_VERSION" #define NAME_NXP_WTX_NTF_COUNT "NXP_WTX_NTF_COUNT" #define NAME_NXP_OSU_MAX_WTX_COUNT "NXP_OSU_MAX_WTX_COUNT" @@ -60,8 +60,6 @@ class EseConfig { std::string default_value); static unsigned getUnsigned(const std::string& key); static unsigned getUnsigned(const std::string& key, unsigned default_value); - static std::vector<uint8_t> getBytes(const std::string& key); - static void clear(); private: static EseConfig& getInstance(); diff --git a/snxxx/libese-spi/src/adaptation/NfcAdaptation.cpp b/snxxx/libese-spi/src/adaptation/NfcAdaptation.cpp index 474fa10..241ffd6 100644 --- a/snxxx/libese-spi/src/adaptation/NfcAdaptation.cpp +++ b/snxxx/libese-spi/src/adaptation/NfcAdaptation.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2020,2022 NXP + * Copyright 2018-2020,2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -232,6 +232,7 @@ ESESTATUS NfcAdaptation::resetEse(uint64_t level) { return result; } +#ifdef NXP_BOOTTIME_UPDATE /******************************************************************************* ** ** Function: NfcAdaptation::setEseUpdateState @@ -270,7 +271,7 @@ ESESTATUS NfcAdaptation::setEseUpdateState(void* p_data) { return result; } - +#endif /******************************************************************************* ** ** Function: ThreadCondVar::ThreadCondVar() diff --git a/snxxx/libese-spi/src/include/NfcAdaptation.h b/snxxx/libese-spi/src/include/NfcAdaptation.h index a87fa98..e5a49b9 100644 --- a/snxxx/libese-spi/src/include/NfcAdaptation.h +++ b/snxxx/libese-spi/src/include/NfcAdaptation.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2020,2022 NXP + * Copyright 2020,2022-2023 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -69,10 +69,12 @@ class AutoThreadMutex { class NfcAdaptation { public: virtual ~NfcAdaptation(); - void Initialize(); static NfcAdaptation& GetInstance(); static ESESTATUS resetEse(uint64_t level); + void Initialize(); +#ifdef NXP_BOOTTIME_UPDATE static ESESTATUS setEseUpdateState(void* p_data); +#endif ese_nxp_IoctlInOutData_t* mCurrentIoctlData; private: |