diff options
author | Tapas Dey <tdey@codeaurora.org> | 2020-05-01 16:32:16 +0530 |
---|---|---|
committer | Tapas Dey <tdey@codeaurora.org> | 2020-05-08 16:13:49 +0530 |
commit | 8b2f27a98facd199c2f39aff526a3544a4b2cc45 (patch) | |
tree | a5eb785ddd615e7e325ad0b6da82bc4e4edb312c | |
parent | dc689a37c4e5a96605b7cd4ac35f3bc0fa22fb2c (diff) | |
parent | f8ca22078c945ece40dc262be09b5b14bf6cb64c (diff) |
Merge branch 'caf/nxp-libnfc-nci/github-libnfc-nci/br_android_ncihalx_row_11' into nfc.vendor.lnx.2.1
* caf/nxp-libnfc-nci/github-libnfc-nci/br_android_ncihalx_row_11: (42 commits)
Code cleanup on HAL 2.0 implementation
HAL 2.0 implementation
N*pNfcLegacy HAL implementation added following api to replace the IOCTL's and there wrapper function a) HAL_NFC_IOCTL_NCI_TRANSCEIVE -> nciTransceive().
N*pNfcLegacy HAL implementation added following api to replace the IOCTL's and there warapper functions HAL_NFC_GET_N*P_CONFIG -> getN*pConfig().
N*pNfcLegacy HAL implementation added following api to replace the IOCTL's and there warapper functions a) HAL_NFC_IOCTL_GET_CONFIG_INFO -> getCachedNfccConfig().
HciInitUpdateState null pointer access fixed.
N*pNfcLegacy HAL implementation added following api to replace the IOCTL's and there warapper functions a) HAL_NFC_IOCTL_REL_SVDD_WAIT -> spiDwpSync() b) HAL_NFC_IOCTL_REL_DWP_WAIT -> RelForceDwpOnOffWait() c) HAL_NFC_GET_SPM_STATUS -> getSPMStatus() d) HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE -> hciInitUpdateState() e) HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE_COMPLETE -> hciInitUpdateStateComplete()
{R-DP1} Move N*P MIFARE entern to HAL
N*pNfcLegacy HAL implementation API added : getEseState -> Replacement of HAL_NFC_IOCTL_P61_PWR_MODE. This API is called for to get ese state getEseState() generates (uint16_t status);
N*pNfcLegacy HAL implementation API added : setNfcServicePid -> Replacement of HAL_NFC_IOCTL_SET_NFC_SERVICE_PID. Introducing new app in NfcN*pHalLeagcy.and phN*pNciHal_setNfcServicePid to call Tml
N*pNfcLegacy HAL implementation API added : getchipType -> Replacement of HAL_NFC_IOCTL_GET_FEATURE_LIST. getChipType is the api which will take chiptype info at init type and update to update to upper layer after invoking it.
unused N*P NFC HAL IOCTL cleanup for HAL_NFC_IOCTL_SPI_DWP_SYNC. There is not caller for this ioctl. So, cleaning this ioctl.
{R-DP2} Revert "Phase tirm offset sign bit update"
{R-DP2} Do not enable factoryota mode by default
N*pNfcLegacy HAL implementation API added : setEseState -> Replacement of HAL_NFC_IOCTL_P61_IDLE_MODE & HAL_NFC_IOCTL_P61_WIRED_MODE.
{R-DP2} Update cfg files search rule
{R-DP1} Remove libhwbinder/libhidltransport deps
{R-DP1} Disable -Wimplicit-fallthrough unless src is fixed.
IOCTL call sequence clean up for HAL_NFC_IOCTL_RF_ACTION_NTF and HAL_NFC_IOCTL_RF_STATUS_UPDATE
IOCTL call sequence clean up for HAL_ESE_IOCTL_OMAPI_TRY_GET_ESE_SESSION & HAL_ESE_IOCTL_OMAPI_RELEASE_ESE_SESSION] [artf728185][PN8xt]:IOCTL call sequence clean up for HAL_NFC_IOCTL_SET_JCP_DWNLD_ENABLE & HAL_NFC_IOCTL_SET_JCP_DWNLD_DISABLE [artf728187][PN8xt]:IOCTL call sequence clean up for HAL_NFC_IOCTL_NFCEE_SESSION_RESET
...
Change-Id: I1da3816ca9e0e8c676cdd82900857dc6a43f9957
54 files changed, 2345 insertions, 2332 deletions
diff --git a/1.1/NxpNfcService.cpp b/1.1/NxpNfcService.cpp index f435767..71c5a39 100755 --- a/1.1/NxpNfcService.cpp +++ b/1.1/NxpNfcService.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2019 NXP + * Copyright 2018-2020 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ #define LOG_TAG "nxpnfc@1.0-service" #include <android/hardware/nfc/1.1/INfc.h> -#include <vendor/nxp/nxpnfc/1.0/INxpNfc.h> +#include <vendor/nxp/nxpnfc/2.0/INxpNfc.h> #include <hidl/LegacySupport.h> #include "Nfc.h" @@ -35,8 +35,8 @@ using android::hardware::joinRpcThreadpool; using android::sp; using android::status_t; using android::OK; -using vendor::nxp::nxpnfc::V1_0::INxpNfc; -using vendor::nxp::nxpnfc::V1_0::implementation::NxpNfc; +using vendor::nxp::nxpnfc::V2_0::INxpNfc; +using vendor::nxp::nxpnfc::V2_0::implementation::NxpNfc; int main() { ALOGD("Registering NFC HALIMPL Service v1.1..."); diff --git a/1.2/NxpNfcService.cpp b/1.2/NxpNfcService.cpp index 5a151b1..b42b882 100755 --- a/1.2/NxpNfcService.cpp +++ b/1.2/NxpNfcService.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018-2019 NXP + * Copyright 2018-2020 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,13 +18,15 @@ #define LOG_TAG "nxpnfc@1.2-service" #include <android/hardware/nfc/1.2/INfc.h> -#include <vendor/nxp/nxpnfc/1.0/INxpNfc.h> +#include <vendor/nxp/nxpnfc/2.0/INxpNfc.h> +#include <vendor/nxp/nxpnfclegacy/1.0/INxpNfcLegacy.h> #include "DwpEseUpdater.h" #include "DwpSeChannelCallback.h" #include "DwpSeEvtCallback.h" #include "Nfc.h" #include "NxpNfc.h" +#include "nxpnfclegacy/1.0/NxpNfcLegacy.h" #include <hidl/LegacySupport.h> // Generated HIDL files @@ -35,8 +37,10 @@ using android::hardware::configureRpcThreadpool; using android::hardware::joinRpcThreadpool; using android::hardware::nfc::V1_2::INfc; using android::hardware::nfc::V1_2::implementation::Nfc; -using vendor::nxp::nxpnfc::V1_0::INxpNfc; -using vendor::nxp::nxpnfc::V1_0::implementation::NxpNfc; +using vendor::nxp::nxpnfc::V2_0::INxpNfc; +using vendor::nxp::nxpnfc::V2_0::implementation::NxpNfc; +using vendor::nxp::nxpnfclegacy::V1_0::INxpNfcLegacy; +using vendor::nxp::nxpnfclegacy::V1_0::implementation::NxpNfcLegacy; int main() { ALOGD("Registering NFC HALIMPL Service v1.2..."); @@ -57,6 +61,13 @@ int main() { if (status != OK) { ALOGD("Could not register service for NXP NFC Extn Iface (%d).", status); } + + ALOGD("Registering NFC HAL Legacy Service v1.0..."); + sp<INxpNfcLegacy> nxp_nfc_legacy_service = new NxpNfcLegacy(); + status = nxp_nfc_legacy_service->registerAsService(); + if (status != OK) { + ALOGD("Could not register service for NXP NFC Legacy Extn Iface (%d).", status); + } ALOGE("Before calling JCOP JCOS_doDownload"); eseClient.doEseUpdateIfReqd(); ALOGE("After calling JCOS_doDownload"); @@ -115,6 +115,11 @@ cc_library_shared { "halimpl/utils/*.cc", "halimpl/utils/*.cpp", "halimpl/configs/*.cpp", + "halimpl/mifare/*.cc", + "halimpl/ese-clients/src/DwpEseUpdater.cc", + "halimpl/ese-clients/src/DwpSeChannelCallback.cc", + "halimpl/ese-clients/src/DwpSeEvtCallback.cc", + "halimpl/ese-clients/src/HalLibnfcInteface.cc", ], shared_libs: [ "libbase", @@ -130,6 +135,7 @@ cc_library_shared { "vendor.nxp.hardware.nfc@1.0", "vendor.nxp.hardware.nfc@1.1", "android.hardware.secure_element@1.0", + "vendor.nxp.nxpnfclegacy@1.0", "hal_libnfc" ], local_include_dirs: [ @@ -147,12 +153,14 @@ cc_library_shared { "halimpl/inc", "halimpl/common", "halimpl/utils", + "halimpl/mifare", "halimpl/ese-clients/inc", ], cflags: [ "-DBUILDCFG=1", "-Wall", "-Werror", + "-Wno-implicit-fallthrough", "-DNFC_HAL_TARGET=TRUE", "-DNFC_RW_ONLY=TRUE", "-DNXP_EXTNS=TRUE", @@ -34,8 +34,8 @@ This Repo contains any additional information/files required to support the rele | :-------------: |:---------------------:| :-----:| | aosp-master | 10.01.00 (PN80T/PN81T/PN553/PN557) | NFC_AR_00_18C0_10.01.00_OpnSrc | | aosp-master | 10.02.00 (PN80T/PN81T/PN553/PN557) | NFC_AR_00_18C0_10.02.00_OpnSrc | - - +| android-10.0.0_r2 | 10.03.00 (PN80T/PN81T/PN553/PN557) | NFC_AR_00_18C0_10.03.00_OpnSrc | +| android-10.0.0_r2 | 10.04.00 (PN80T/PN81T/PN553/PN557) | NFC_AR_00_18C0_10.04.00_OpnSrc | diff --git a/extns/impl/NxpNfc.cpp b/extns/impl/NxpNfc.cpp deleted file mode 100755 index 736cb43..0000000 --- a/extns/impl/NxpNfc.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (C) 2011, 2012 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -/****************************************************************************** - * - * Copyright 2018-2019 NXP - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -#define LOG_TAG "vendor.nxp.nxpnfc@1.0-impl" -#include "NxpNfc.h" -#include "DwpEseUpdater.h" -#include "hal_nxpnfc.h" -#include "phNxpNciHal_Adaptation.h" -#include <log/log.h> - -namespace vendor { -namespace nxp { -namespace nxpnfc { -namespace V1_0 { -namespace implementation { - -// Methods from ::vendor::nxp::nxpnfc::V1_0::INxpNfc follow. -Return<void> NxpNfc::ioctl(uint64_t ioctlType, - const hidl_vec<uint8_t>& inOutData, - ioctl_cb _hidl_cb) { - ALOGD_IF(true, "%s: enter", __FUNCTION__); - uint32_t status; - nfc_nci_IoctlInOutData_t inpOutData; - NfcData outputData; - nfc_nci_IoctlInOutData_t* pInOutData = - (nfc_nci_IoctlInOutData_t*)&inOutData[0]; - - /*data from proxy->stub is copied to local data which can be updated by - * underlying HAL implementation since its an inout argument*/ - memcpy(&inpOutData, pInOutData, sizeof(nfc_nci_IoctlInOutData_t)); - if (ioctlType == HAL_NFC_IOCTL_SET_TRANSIT_CONFIG) { - /* As transit configurations are appended at the end of - * nfc_nci_IoctlInOutData_t, Assign appropriate pointer to TransitConfig. - * if default configuration(string length is 0), assign null to tansit - * configuration pointer instead of appending configuration, - * and remove partition vendor transit conf file. */ - if (inpOutData.inp.data.transitConfig.len == 0) { - inpOutData.inp.data.transitConfig.val = NULL; - } else { - inpOutData.inp.data.transitConfig.val = - ((char *)pInOutData) + sizeof(nfc_nci_IoctlInOutData_t); - } - } - status = phNxpNciHal_ioctl(ioctlType, &inpOutData); - if(HAL_NFC_IOCTL_ESE_JCOP_DWNLD == ioctlType) { - ALOGD("NxpNfc::ioctl == HAL_NFC_IOCTL_ESE_JCOP_DWNLD"); - if(pInOutData->inp.data.nciCmd.p_cmd[0] == ESE_JCOP_UPDATE_COMPLETED - || pInOutData->inp.data.nciCmd.p_cmd[0] == ESE_LS_UPDATE_COMPLETED) { - ALOGD("NxpNfc::ioctl state == ESE_UPDATE_COMPLETED"); - DwpEseUpdater::setSpiEseClientState(pInOutData->inp.data.nciCmd.p_cmd[0]); - DwpEseUpdater::eSEClientUpdate_NFC_Thread(); - } - } - /*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.context = pInOutData->inp.context; - inpOutData.out.result = status; - outputData.setToExternal((uint8_t*)&inpOutData.out, - sizeof(nfc_nci_ExtnOutputData_t)); - ALOGD_IF(true, "%s: exit", __FUNCTION__); - _hidl_cb(outputData); - return Void(); -} - -} // namespace implementation -} // namespace V1_0 -} // namespace nxpnfc -} // namespace nxp -} // namespace vendor diff --git a/extns/impl/hal_nxpnfc.h b/extns/impl/hal_nxpnfc.h deleted file mode 100644 index 3b690c6..0000000 --- a/extns/impl/hal_nxpnfc.h +++ /dev/null @@ -1,249 +0,0 @@ -/****************************************************************************** - * - * Copyright 2018-2019 NXP - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -#ifndef ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H -#define ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H -#include <vector> -#include <string> - -#define NFC_NCI_NXP_PN54X_HARDWARE_MODULE_ID "nfc_nci.nqx" -#define MAX_IOCTL_TRANSCEIVE_CMD_LEN 256 -#define MAX_IOCTL_TRANSCEIVE_RESP_LEN 256 -#define MAX_ATR_INFO_LEN 128 - -enum { - HAL_NFC_ENABLE_I2C_FRAGMENTATION_EVT = 0x08, - HAL_NFC_POST_MIN_INIT_CPLT_EVT = 0x09, - HAL_NFC_WRITE_COMPLETE = 0x0A -}; - -enum { - HAL_NFC_IOCTL_P61_IDLE_MODE = 0, - HAL_NFC_IOCTL_P61_WIRED_MODE, - HAL_NFC_IOCTL_P61_PWR_MODE, - HAL_NFC_IOCTL_P61_DISABLE_MODE, - HAL_NFC_IOCTL_P61_ENABLE_MODE, - HAL_NFC_IOCTL_SET_BOOT_MODE, - HAL_NFC_IOCTL_GET_CONFIG_INFO, - HAL_NFC_IOCTL_CHECK_FLASH_REQ, - HAL_NFC_IOCTL_FW_DWNLD, - HAL_NFC_IOCTL_FW_MW_VER_CHECK, - HAL_NFC_IOCTL_DISABLE_HAL_LOG, /* 10 */ - HAL_NFC_IOCTL_NCI_TRANSCEIVE, - HAL_NFC_IOCTL_P61_GET_ACCESS, - HAL_NFC_IOCTL_P61_REL_ACCESS, - HAL_NFC_IOCTL_P61_REL_ESE_PWR, - HAL_NFC_IOCTL_P61_SET_ESE_PWR, - HAL_NFC_IOCTL_ESE_CHIP_RST, - HAL_NFC_SET_SPM_PWR, - HAL_NFC_INHIBIT_PWR_CNTRL, - HAL_NFC_IOCTL_REL_SVDD_WAIT, - HAL_NFC_IOCTL_SET_JCP_DWNLD_ENABLE, /* 20 */ - HAL_NFC_IOCTL_SPI_DWP_SYNC, - HAL_NFC_IOCTL_RF_STATUS_UPDATE, - HAL_NFC_IOCTL_SET_JCP_DWNLD_DISABLE, - HAL_NFC_IOCTL_SET_NFC_SERVICE_PID, - HAL_NFC_IOCTL_REL_DWP_WAIT, - HAL_NFC_IOCTL_GET_FEATURE_LIST, - HAL_NFC_SET_POWER_SCHEME, - HAL_NFC_GET_SPM_STATUS, - HAL_NFC_GET_ESE_ACCESS, - HAL_NFC_SET_DWNLD_STATUS, /* 30 */ - HAL_NFC_GET_NXP_CONFIG, - HAL_NFC_IOCTL_RF_ACTION_NTF, - HAL_NFC_IOCTL_SET_TRANSIT_CONFIG, - HAL_NFC_IOCTL_NFCEE_SESSION_RESET, - HAL_ESE_IOCTL_OMAPI_TRY_GET_ESE_SESSION, - HAL_ESE_IOCTL_OMAPI_RELEASE_ESE_SESSION, - HAL_NFC_IOCTL_ESE_JCOP_DWNLD, - HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE, - HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE, - HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE_COMPLETE /* 40 */ -}; - -/* - * Data structures provided below are used of Hal Ioctl calls - */ -/* - * nfc_nci_ExtnCmd_t shall contain data for commands used for transceive command - * in ioctl - */ -typedef struct { - uint16_t cmd_len; - uint8_t p_cmd[MAX_IOCTL_TRANSCEIVE_CMD_LEN]; -} nfc_nci_ExtnCmd_t; - -/* - * nxp_nfc_scrResetEmvcoCmd_t shall contain core set conf command to reset EMVCO - * mode and the length of the command - */ -typedef struct { - long len; - uint8_t cmd[10]; -} nxp_nfc_scrResetEmvcoCmd_t; - -/* - * nfc_nci_ExtnRsp_t shall contain response for command sent in transceive - * command - */ -typedef struct { - uint8_t ese_listen_tech_mask; - uint8_t default_nfcee_disc_timeout; - uint8_t default_nfcee_timeout; - uint8_t ese_wired_prt_mask; - uint8_t uicc_wired_prt_mask; - uint8_t wired_mode_rf_field_enable; - uint8_t aid_block_route; - - uint8_t esePowerDhControl; - uint8_t tagOpTimeout; - uint8_t loaderServiceVersion; - uint8_t defaultNfceeDiscTimeout; - uint8_t dualUiccEnable; - uint8_t ceRouteStrictDisable; - uint32_t osDownloadTimeoutValue; - uint8_t defaultAidRoute; - uint8_t defaultAidPwrState; - uint8_t defaultRoutePwrState; - uint8_t defaultOffHostPwrState; - uint8_t jcopDlAtBootEnable; - uint8_t defaultNfceeTimeout; - uint8_t nxpNfcChip; - uint8_t coreScrnOffAutonomousEnable; - uint8_t p61LsDefaultInterface; - uint8_t p61JcopDefaultInterface; - uint8_t agcDebugEnable; - uint8_t felicaCltPowerState; - uint32_t cmdRspTimeoutValue; - uint8_t checkDefaultProtoSeId; - uint8_t nfccPassiveListenTimeout; - uint32_t nfccStandbyTimeout; - uint32_t wmMaxWtxCount; - uint32_t nfccRfFieldEventTimeout; - uint8_t allowWiredInMifareDesfireClt; - uint8_t dwpIntfResetEnable; - uint8_t nxpLogHalLoglevel; - uint8_t nxpLogExtnsLogLevel; - uint8_t nxpLogTmlLogLevel; - uint8_t nxpLogFwDnldLogLevel; - uint8_t nxpLogNcixLogLevel; - uint8_t nxpLogNcirLogLevel; - uint8_t scrCfgFormat; - uint8_t etsiReaderEnable; - nxp_nfc_scrResetEmvcoCmd_t scrResetEmvco; -} nxp_nfc_config_t; -/* - * nfc_nci_ExtnRsp_t shall contain response for command sent in transceive - * command - */ -typedef struct { - uint16_t rsp_len; - uint8_t p_rsp[MAX_IOCTL_TRANSCEIVE_RESP_LEN]; -} nfc_nci_ExtnRsp_t; -/* - * TransitConfig_t shall contain transit config value and transit - * Configuration length - */ -typedef struct { - long len; - char *val; -} TransitConfig_t; -/* - * InputData_t :ioctl has multiple subcommands - * Each command has corresponding input data which needs to be populated in this - */ -typedef union { - uint16_t bootMode; - uint8_t halType; - nfc_nci_ExtnCmd_t nciCmd; - uint32_t timeoutMilliSec; - long nfcServicePid; - TransitConfig_t transitConfig; -} InputData_t; -/* - * nfc_nci_ExtnInputData_t :Apart from InputData_t, there are context data - * which is required during callback from stub to proxy. - * To avoid additional copy of data while propagating from libnfc to Adaptation - * and Nfcstub to ncihal, common structure is used. As a sideeffect, context - * data - * is exposed to libnfc (Not encapsulated). - */ -typedef struct { - /*context to be used/updated only by users of proxy & stub of Nfc.hal - * i.e, NfcAdaptation & hardware/interface/Nfc. - */ - void* context; - InputData_t data; - uint8_t data_source; - long level; -} nfc_nci_ExtnInputData_t; - -/* - * outputData_t :ioctl has multiple commands/responses - * This contains the output types for each ioctl. - */ -typedef union { - uint32_t status; - nfc_nci_ExtnRsp_t nciRsp; - uint8_t nxpNciAtrInfo[MAX_ATR_INFO_LEN]; - uint32_t p61CurrentState; - uint16_t fwUpdateInf; - uint16_t fwDwnldStatus; - uint16_t fwMwVerStatus; - uint8_t chipType; - nxp_nfc_config_t nxpConfigs; -} outputData_t; - -/* - * nfc_nci_ExtnOutputData_t :Apart from outputData_t, there are other - * information - * which is required during callback from stub to proxy. - * For ex (context, result of the operation , type of ioctl which was - * completed). - * To avoid additional copy of data while propagating from libnfc to Adaptation - * and Nfcstub to ncihal, common structure is used. As a sideeffect, these data - * is exposed(Not encapsulated). - */ -typedef struct { - /*ioctlType, result & context to be used/updated only by users of - * proxy & stub of Nfc.hal. - * i.e, NfcAdaptation & hardware/interface/Nfc - * These fields shall not be used by libnfc or halimplementation*/ - uint64_t ioctlType; - uint32_t result; - void* context; - outputData_t data; -} nfc_nci_ExtnOutputData_t; - -/* - * nfc_nci_IoctlInOutData_t :data structure for input & output - * to be sent for ioctl command. input is populated by client/proxy side - * output is provided from server/stub to client/proxy - */ -typedef struct { - nfc_nci_ExtnInputData_t inp; - nfc_nci_ExtnOutputData_t out; -} nfc_nci_IoctlInOutData_t; - -enum NxpNfcHalStatus { - /** In case of an error, HCI network needs to be re-initialized */ - HAL_NFC_STATUS_RESTART = 0x30, - HAL_NFC_HCI_NV_RESET = 0x40, - HAL_NFC_CONFIG_ESE_LINK_COMPLETE = 0x50 -}; - -#endif // ANDROID_HARDWARE_HAL_NXPNFC_V1_0_H diff --git a/extns/impl/nxpnfc/2.0/NxpNfc.cpp b/extns/impl/nxpnfc/2.0/NxpNfc.cpp new file mode 100644 index 0000000..57df606 --- /dev/null +++ b/extns/impl/nxpnfc/2.0/NxpNfc.cpp @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * Copyright 2018-2020 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +#include <log/log.h> + +#include "NxpNfc.h" +#include "phNxpNciHal.h" +#include "phNxpNciHal_Adaptation.h" + +extern bool nfc_debug_enabled; + +namespace vendor { +namespace nxp { +namespace nxpnfc { +namespace V2_0 { +namespace implementation { + +Return<void> +NxpNfc::getVendorParam(const ::android::hardware::hidl_string &key, + getVendorParam_cb _hidl_cb) { + string val = phNxpNciHal_getSystemProperty(key); + _hidl_cb(val); + return Void(); +} + +Return<bool> +NxpNfc::setVendorParam(const ::android::hardware::hidl_string &key, + const ::android::hardware::hidl_string &value) { + return phNxpNciHal_setSystemProperty(key, value); +} + +Return<bool> +NxpNfc::resetEse(uint64_t resetType) { + NFCSTATUS status = NFCSTATUS_FAILED; + bool ret = false; + ALOGD("NxpNfc::resetEse Entry"); + if((uint64_t)Constants::HAL_NFC_ESE_HARD_RESET == resetType) { + status = phNxpNciHal_resetEse(); + if(NFCSTATUS_SUCCESS == status) { + ret = true; + status = NFCSTATUS_SUCCESS; + ALOGD("HAL_NFC_ESE_HARD_RESET completed"); + } else { + ALOGD("HAL_NFC_ESE_HARD_RESET failed"); + } + } else { + ALOGD("reset called with %lu type",resetType); + } + ALOGD("NxpNfc::resetEse Exit"); + return ret; +} + +Return<bool> +NxpNfc::setEseUpdateState(NxpNfcHalEseState eSEState) { + bool status = false; + + ALOGD("NxpNfc::setEseUpdateState Entry"); + + if(eSEState == NxpNfcHalEseState::HAL_NFC_ESE_JCOP_UPDATE_COMPLETED + || eSEState == NxpNfcHalEseState::HAL_NFC_ESE_LS_UPDATE_COMPLETED) + { + ALOGD("NxpNfc::setEseUpdateState state == HAL_NFC_ESE_JCOP_UPDATE_COMPLETED"); + seteSEClientState((uint8_t)eSEState); + eSEClientUpdate_NFC_Thread(); + } + if (eSEState == NxpNfcHalEseState::HAL_NFC_ESE_UPDATE_COMPLETED) { + status = phNxpNciHal_Abort(); + } + + ALOGD("NxpNfc::setEseUpdateState Exit"); + return status; +} + +Return<bool> +NxpNfc::setNxpTransitConfig(const ::android::hardware::hidl_string &strval) +{ + bool status = true; + ALOGD("NxpNfc::setNxpTransitConfig Entry"); + + status = phNxpNciHal_setNxpTransitConfig((char *)strval.c_str()); + + ALOGD("NxpNfc::setNxpTransitConfig Exit"); + return status; +} + +Return<bool> +NxpNfc::isJcopUpdateRequired() +{ + bool status = 0; + ALOGD("NxpNfc::isJcopUpdateRequired Entry"); + + status = getJcopUpdateRequired(); + + ALOGD("NxpNfc::isJcopUpdateRequired Exit"); + return status; + +} + +Return<bool> +NxpNfc::isLsUpdateRequired() +{ + bool status = 0; + ALOGD("NxpNfc::isLsUpdateRequired Entry"); + + status = getLsUpdateRequired(); + + ALOGD("NxpNfc::isLsUpdateRequired Exit"); + return status; +} + +} // namespace implementation +} // namespace V2_0 +} // namespace nxpnfc +} // namespace nxp +} // namespace vendor diff --git a/extns/impl/NxpNfc.h b/extns/impl/nxpnfc/2.0/NxpNfc.h index 5b0446d..2f09058 100755..100644 --- a/extns/impl/NxpNfc.h +++ b/extns/impl/nxpnfc/2.0/NxpNfc.h @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018 NXP + * Copyright 2018-2020 NXP * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,35 +16,47 @@ * ******************************************************************************/ -#ifndef VENDOR_NXP_NXPNFC_V1_0_NXPNFC_H -#define VENDOR_NXP_NXPNFC_V1_0_NXPNFC_H +#ifndef VENDOR_NXP_NXPNFC_V2_0_NXPNFC_H +#define VENDOR_NXP_NXPNFC_V2_0_NXPNFC_H -#include <vendor/nxp/nxpnfc/1.0/INxpNfc.h> +#include <vendor/nxp/nxpnfc/2.0/INxpNfc.h> #include <hidl/MQDescriptor.h> #include <hidl/Status.h> -#include "hal_nxpnfc.h" + +enum Constants : uint16_t { + HAL_NFC_ESE_HARD_RESET = 5, +}; + namespace vendor { namespace nxp { namespace nxpnfc { -namespace V1_0 { +namespace V2_0 { namespace implementation { using ::android::hidl::base::V1_0::IBase; -using ::vendor::nxp::nxpnfc::V1_0::INxpNfc; +using ::vendor::nxp::nxpnfc::V2_0::INxpNfc; using ::android::hardware::hidl_vec; using ::android::hardware::Return; using ::android::hardware::Void; -struct NxpNfc : public INxpNfc { - Return<void> ioctl(uint64_t ioctlType, const hidl_vec<uint8_t>& inOutData, - ioctl_cb _hidl_cb) override; +struct NxpNfc : public INxpNfc{ + Return<void> getVendorParam(const ::android::hardware::hidl_string &key, + getVendorParam_cb _hidl_cb) override; + Return<bool> + setVendorParam(const ::android::hardware::hidl_string &key, + const ::android::hardware::hidl_string &value) override; + Return<bool> resetEse(uint64_t resetType) override; + Return<bool> setEseUpdateState(NxpNfcHalEseState state) override; + Return<bool> setNxpTransitConfig(const ::android::hardware::hidl_string &strval) override; + Return<bool> isJcopUpdateRequired() override; + Return<bool> isLsUpdateRequired() override; }; } // namespace implementation -} // namespace V1_0 +} // namespace V2_0 } // namespace nxpnfc } // namespace nxp } // namespace vendor -#endif // VENDOR_NXP_NXPNFC_V1_0_NXPNFC_H +#endif // VENDOR_NXP_NXPNFC_V2_0_NXPNFC_H diff --git a/extns/impl/Nxp_Features.h b/extns/impl/nxpnfc/2.0/Nxp_Features.h index 8a276d9..8a276d9 100644 --- a/extns/impl/Nxp_Features.h +++ b/extns/impl/nxpnfc/2.0/Nxp_Features.h diff --git a/extns/impl/nxpnfclegacy/1.0/NxpNfcLegacy.cpp b/extns/impl/nxpnfclegacy/1.0/NxpNfcLegacy.cpp new file mode 100644 index 0000000..1ac5da4 --- /dev/null +++ b/extns/impl/nxpnfclegacy/1.0/NxpNfcLegacy.cpp @@ -0,0 +1,195 @@ +/****************************************************************************** + * + * Copyright 2020 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +#include <log/log.h> + +#include "NxpNfcLegacy.h" +#include "phNxpNciHal.h" +#include <phTmlNfc.h> + +extern bool nfc_debug_enabled; + +namespace vendor { +namespace nxp { +namespace nxpnfclegacy { +namespace V1_0 { +namespace implementation { + + +Return<uint8_t> +NxpNfcLegacy::setEseState(NxpNfcHalEseState EseState) { + NFCSTATUS status = NFCSTATUS_FAILED; + ALOGD("NxpNfcLegacy::setEseState Entry"); + + if(EseState == NxpNfcHalEseState::HAL_NFC_ESE_IDLE_MODE) + { + ALOGD("NxpNfcLegacy::setEseState state == HAL_NFC_ESE_IDLE_MODE"); + status = phNxpNciHal_setEseState(phNxpNciHalNfc_e_SetIdleMode); + } + if (EseState == NxpNfcHalEseState::HAL_NFC_ESE_WIRED_MODE) { + ALOGD("NxpNfcLegacy::setEseState state == HAL_NFC_ESE_WIRED_MODE"); + status = phNxpNciHal_setEseState(phNxpNciHalNfc_e_SetWiredMode); + } + + ALOGD("NxpNfcLegacy::setEseState Exit"); + return status; +} + +Return<uint8_t> +NxpNfcLegacy::getchipType() { + uint8_t chiptype; + ALOGD("NxpNfcLegacy::getchipType Entry"); + chiptype = phNxpHal_getchipType(); + ALOGD("NxpNfcLegacy::getchipType Exit"); + return chiptype; +} + +Return<uint16_t> +NxpNfcLegacy::setNfcServicePid(uint64_t pid) { + NFCSTATUS status = NFCSTATUS_FAILED; + ALOGD("NxpNfcLegacy::setNfcServicePid Entry"); + status = phNxpNciHal_setNfcServicePid(pid); + ALOGD("NxpNfcLegacy::setNfcServicePid Exit"); + return status; +} + +Return<uint16_t> +NxpNfcLegacy::getEseState() { + NFCSTATUS status = NFCSTATUS_FAILED; + ALOGD("NxpNfcLegacy::getEseState Entry"); + status = phNxpNciHal_getEseState(); + ALOGD("NxpNfcLegacy::getEseState Exit"); + return status; +} + +Return<uint16_t> +NxpNfcLegacy::spiDwpSync(uint32_t level) { + uint16_t status = 0; + + ALOGD("NxpNfcLegacy::spiDwpSync Entry"); + status = phNxpNciHal_ReleaseSVDDWait(level); + + ALOGD("NxpNfcLegacy::spiDwpSync Exit"); + return status; +} + +Return<uint16_t> +NxpNfcLegacy::RelForceDwpOnOffWait(uint32_t level) { + uint16_t status = 0; + + ALOGD("NxpNfcLegacy::RelForceDwpOnOffWait Entry"); + status = phNxpNciHal_ReleaseDWPOnOffWait(level); + + ALOGD("NxpNfcLegacy::RelForceDwpOnOffWait Exit"); + return status; +} + +Return<int8_t> +NxpNfcLegacy::getSPMStatus(uint32_t level) { + int8_t status = -1; + + ALOGD("NxpNfcLegacy::getSPMStatus Entry"); + status = phNxpNciHal_getSPMStatus(level); + + ALOGD("NxpNfcLegacy::getSPMStatus Exit"); + return status; +} + +Return<int32_t> +NxpNfcLegacy::hciInitUpdateState(NfcHciInitStatus HciStatus) { + int32_t status = 0; + + ALOGD("NxpNfcLegacy::hciInitUpdateState Entry"); + if (HciStatus == NfcHciInitStatus::NFC_HCI_INIT_START) + { + ALOGD("NxpNfcLegacy::hciInitUpdateState state == NFC_HCI_INIT_START"); + phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus_e_Start); + } + else if (HciStatus == NfcHciInitStatus::NFC_HCI_INIT_COMPLETE) + { + ALOGD("NxpNfcLegacy::hciInitUpdateState state == NFC_HCI_INIT_COMPLETE"); + phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus_e_Complete); + } + ALOGD("NxpNfcLegacy::hciInitUpdateState Exit"); + return status; +} + +Return<int32_t> +NxpNfcLegacy::hciInitUpdateStateComplete() { + int32_t status = 0; + + ALOGD("NxpNfcLegacy::hciInitUpdateStateComplete Entry"); + + status = phNxpNciHal_hciInitUpdateStateComplete(); + + ALOGD("NxpNfcLegacy::hciInitUpdateStateComplete Exit"); + + return status; +} + +Return<void> NxpNfcLegacy::getCachedNfccConfig(getCachedNfccConfig_cb _hidl_cb){ + phNxpNci_getCfg_info_t GetCfg_info; + NxpNciCfgInfo ConfigData; + + ALOGD("NxpNfcLegacy::GetCachedNfccConfig Entry" ); + + phNxpNciHal_GetCachedNfccConfig(&GetCfg_info); + memcpy(&ConfigData,&GetCfg_info,sizeof(NxpNciCfgInfo)); + _hidl_cb(ConfigData); + + ALOGD("NxpNfcLegacy::GetCachedNfccConfig Exit"); + return Void(); +} + +Return<void> NxpNfcLegacy::getNxpConfig(getNxpConfig_cb _hidl_cb) +{ + phNxpNfcHalConfig localConfigData; + NxpNfcHalConfig config; + ALOGD("NxpNfcLegacy::getNxpConfig Entry" ); + phNxpNciHal_getNxpConfig(&localConfigData); + memcpy(&config, &localConfigData, sizeof(NxpNfcHalConfig)); + _hidl_cb(config); + ALOGD("NxpNfcLegacy::getNxpConfig Exit"); + return Void(); +} + +Return<void> NxpNfcLegacy::nciTransceive( const NxpNciExtnCmd &NciCmd,nciTransceive_cb _hidl_cb){ + phNxpNci_Extn_Cmd_t in; + phNxpNci_Extn_Resp_t out; + + NxpNciExtnResp nciResp; + + ALOGD("NxpNfcLegacy::NciTransceive Entry" ); + + memcpy(&in,&NciCmd,sizeof(NxpNciExtnCmd)); + + phNxpNciHal_nciTransceive(&in,&out); + + memcpy(&nciResp,&out,sizeof(NxpNciExtnResp)); + + _hidl_cb(nciResp); + + ALOGD("NxpNfcLegacy::NciTransceive Exit"); + return Void(); +} + + +} // namespace implementation +} // namespace V1_0 +} // namespace nxpnfclegacy +} // namespace nxp +} // namespace vendor diff --git a/extns/impl/nxpnfclegacy/1.0/NxpNfcLegacy.h b/extns/impl/nxpnfclegacy/1.0/NxpNfcLegacy.h new file mode 100644 index 0000000..5978bd2 --- /dev/null +++ b/extns/impl/nxpnfclegacy/1.0/NxpNfcLegacy.h @@ -0,0 +1,61 @@ +/****************************************************************************** + * + * Copyright 2020 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ + +#ifndef VENDOR_NXP_NXPNFCLEGACY_V1_0_NXPNFCLEGACY_H +#define VENDOR_NXP_NXPNFCLEGACY_V1_0_NXPNFCLEGACY_H + +#include <vendor/nxp/nxpnfclegacy/1.0/INxpNfcLegacy.h> +#include <hidl/MQDescriptor.h> +#include <hidl/Status.h> + + + +namespace vendor { +namespace nxp { +namespace nxpnfclegacy { +namespace V1_0 { +namespace implementation { + +using ::android::hidl::base::V1_0::IBase; +using ::vendor::nxp::nxpnfclegacy::V1_0::INxpNfcLegacy; +using ::android::hardware::hidl_vec; +using ::android::hardware::Return; +using ::android::hardware::Void; + +struct NxpNfcLegacy : public INxpNfcLegacy{ + Return<uint8_t> setEseState(NxpNfcHalEseState EseState) override; + Return<uint8_t> getchipType() override; + Return<uint16_t> setNfcServicePid(uint64_t pid) override; + Return<uint16_t> getEseState() override; + Return<uint16_t> spiDwpSync(uint32_t level) override; + Return<uint16_t> RelForceDwpOnOffWait(uint32_t level) override; + Return<int8_t> getSPMStatus(uint32_t level) override; + Return<int32_t> hciInitUpdateState(NfcHciInitStatus HciStatus) override; + Return<int32_t> hciInitUpdateStateComplete() override; + Return<void> getCachedNfccConfig(getCachedNfccConfig_cb _hidl_cb) override; + Return<void> getNxpConfig(getNxpConfig_cb _hidl_cb) override; + Return<void> nciTransceive(const NxpNciExtnCmd &in,nciTransceive_cb _hidl_cb); +}; + +} // namespace implementation +} // namespace V1_0 +} // namespace nxpnfclegacy +} // namespace nxp +} // namespace vendor + +#endif // VENDOR_NXP_NXPNFCLEGACY_V1_0_NXPNFCLEGACY_H diff --git a/extns/intf/nxpnfc/1.0/INxpNfc.hal b/extns/intf/nxpnfc/1.0/INxpNfc.hal deleted file mode 100755 index d5f3569..0000000 --- a/extns/intf/nxpnfc/1.0/INxpNfc.hal +++ /dev/null @@ -1,33 +0,0 @@ -/****************************************************************************** - * - * Copyright 2018 NXP - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - ******************************************************************************/ -package vendor.nxp.nxpnfc@1.0; - -interface INxpNfc { - /* - * Performs an General Input Output operations. - * - * Based on the ioctlType, input data bytes are processed and - * Output data bytes are generated. - * @param ioctlType contains type of functionality as below - * HAL_NFC_IOCTL_SPI_DWP_SYNC to synchronize access to eSE - * HAL_NFC_INHIBIT_PWR_CNTRL to disable eSE power - * HAL_NFC_SET_SPM_PWR to toggle eSE power - * @return output data as stream of bytes - */ - ioctl(uint64_t ioctlType,NfcData inputData) generates(NfcData outputData); -}; diff --git a/extns/intf/nxpnfc/2.0/Android.bp b/extns/intf/nxpnfc/2.0/Android.bp new file mode 100644 index 0000000..59ab821 --- /dev/null +++ b/extns/intf/nxpnfc/2.0/Android.bp @@ -0,0 +1,16 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "vendor.nxp.nxpnfc@2.0", + root: "vendor.nxp.nxpnfc", + srcs: [ + "types.hal", + "INxpNfc.hal", + ], + interfaces: [ + "android.hidl.base@1.0", + ], + types: [ + ], + gen_java: true, +} diff --git a/extns/intf/nxpnfc/2.0/INxpNfc.hal b/extns/intf/nxpnfc/2.0/INxpNfc.hal new file mode 100644 index 0000000..6191631 --- /dev/null +++ b/extns/intf/nxpnfc/2.0/INxpNfc.hal @@ -0,0 +1,76 @@ +/****************************************************************************** + * + * Copyright 2020 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +package vendor.nxp.nxpnfc@2.0; + +interface INxpNfc { + /* + * Gets vendor params values whose Key has been provided. + * + * @param string + * @return output data as string + */ + getVendorParam(string key) generates (string value); + + /* + * Saves the vendor params provided as key-value pair + * + * @param string key string value + * @return status as a boolean, true if success, false if failed + */ + setVendorParam(string key, string value) generates (bool status); + + /* + * reset the ese based on resettype + * + * @param uint64_t to specify resetType + * @return status as a boolean, true if success, false if failed + */ + resetEse(uint64_t resetType) generates (bool status); + + /* + * updates ese with current state and notifies upper layer + * + * @param input current ese state to set + * @return status as a boolean, true if success, false if failed + */ + setEseUpdateState(NxpNfcHalEseState eSEState) generates (bool status); + + /* + * Sets Transit config value + * + * @param string transit config value + * @return status as a boolean, true if success, false if failed + */ + setNxpTransitConfig(string transitConfValue) generates (bool status); + + /* + * api to check jcop update is required or not + * + * @param none + * @return status as a boolean, true if JCOP update required, false if not required. + */ + isJcopUpdateRequired() generates (bool status); + + /* + * api to check LS update is required or not + * + * @param none + * @return status as a boolean, true if LS update required, false if not required. + */ + isLsUpdateRequired() generates (bool status); +}; diff --git a/extns/intf/nxpnfc/2.0/manifest.xml b/extns/intf/nxpnfc/2.0/manifest.xml new file mode 100644 index 0000000..2efc4d9 --- /dev/null +++ b/extns/intf/nxpnfc/2.0/manifest.xml @@ -0,0 +1,14 @@ +<manifest version="1.0"> + <hal format="hidl"> + <name>android.hardware.nfc</name> + <transport>hwbinder</transport> + <impl level="generic"></impl> + <version>1.2</version> + </hal> + <hal format="hidl"> + <name>vendor.nxp.nxpnfc</name> + <transport>hwbinder</transport> + <impl level="generic"></impl> + <version>2.0</version> + </hal> +</manifest> diff --git a/extns/intf/nxpnfc/1.0/types.hal b/extns/intf/nxpnfc/2.0/types.hal index e89d3da..070707e 100755..100644 --- a/extns/intf/nxpnfc/1.0/types.hal +++ b/extns/intf/nxpnfc/2.0/types.hal @@ -1,6 +1,6 @@ /****************************************************************************** * - * Copyright 2018 NXP + * Copyright 2020 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,13 @@ * limitations under the License. * ******************************************************************************/ -package vendor.nxp.nxpnfc@1.0; +package vendor.nxp.nxpnfc@2.0; -typedef vec<uint8_t> NfcData; +enum NxpNfcHalEseState : uint64_t { + HAL_NFC_ESE_UPDATE_COMPLETED = 0, + HAL_NFC_ESE_UPDATE_STARTED, + HAL_NFC_ESE_JCOP_UPDATE_REQUIRED, + HAL_NFC_ESE_JCOP_UPDATE_COMPLETED, + HAL_NFC_ESE_LS_UPDATE_REQUIRED, + HAL_NFC_ESE_LS_UPDATE_COMPLETED +}; diff --git a/extns/intf/nxpnfclegacy/1.0/Android.bp b/extns/intf/nxpnfclegacy/1.0/Android.bp new file mode 100644 index 0000000..bb89272 --- /dev/null +++ b/extns/intf/nxpnfclegacy/1.0/Android.bp @@ -0,0 +1,16 @@ +// This file is autogenerated by hidl-gen -Landroidbp. + +hidl_interface { + name: "vendor.nxp.nxpnfclegacy@1.0", + root: "vendor.nxp.nxpnfclegacy", + srcs: [ + "types.hal", + "INxpNfcLegacy.hal", + ], + interfaces: [ + "android.hidl.base@1.0", + ], + types: [ + ], + gen_java: true, +} diff --git a/extns/intf/nxpnfclegacy/1.0/INxpNfcLegacy.hal b/extns/intf/nxpnfclegacy/1.0/INxpNfcLegacy.hal new file mode 100644 index 0000000..9e8e76f --- /dev/null +++ b/extns/intf/nxpnfclegacy/1.0/INxpNfcLegacy.hal @@ -0,0 +1,105 @@ +/****************************************************************************** + * + * Copyright 2020 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +package vendor.nxp.nxpnfclegacy@1.0; + +interface INxpNfcLegacy { + /* + * Setting state of eSE for DWP/SPI sync + * @param eSE state + * @return status as uint8_t + */ + setEseState(NxpNfcHalEseState EseState) generates (uint8_t status); + + /* + * Gets the chipType which is configured during bootup + * @return chipType as uint8_t + */ + getchipType() generates (uint8_t chipType); + + /* + * Set/Reset PID in driver for signalling during SPI / DWP open/close + * @param process Id as uint64_t + * @return status as uint16_t + */ + setNfcServicePid(uint64_t pid) generates (uint16_t status); + + /* + * Getting state of eSE for Wired Mode/SPI mode (For DWP/SPI sync) + * @Return status as uint16_t + */ + getEseState() generates (uint16_t status); + + /* + * This function release wait for svdd change + * of P61. output returned as Status + * @param svdd level as inputdata + * @return status as uint8_t + */ + spiDwpSync(uint32_t level) generates (uint16_t status); + + /* + * This function release wait for DWP On/Off + * of P73. output returned as Status + * @param eSE vsc as inputdata + * @return status as uint8_t + */ + RelForceDwpOnOffWait(uint32_t level) generates (uint16_t status); + + /* + * This function gets the SPM state before FW download + * @param eSE power GPIO value as input level + * @return status as uint8_t + */ + getSPMStatus(uint32_t level) generates (int8_t status); + + /* + * This function Sends HCI Events to nfc HAL + * @param HCI events as input + * @return status as uint8_t + */ + hciInitUpdateState(NfcHciInitStatus HciStatus) generates(int32_t status); + + /* + * This function posts event HAL_NFC_CONFIG_ESE_LINK_COMPLETE + * @param none + * @return status as uint8_t + */ + hciInitUpdateStateComplete() generates(int32_t status); + + /* + * This function gets the cached configinfo. + * @param none + * @return cached config structure NxpNciCfgInfo + */ + getCachedNfccConfig() generates(NxpNciCfgInfo ConfigData); + + /* + * This function gets vendor Config + * @param none + * @return vendor config structure NxpNfcHalConfig + */ + getNxpConfig() generates(NxpNfcHalConfig ConfigData); + + /* + * This function tarnsceive the nci command response + * @param Nci command as input + * @return nci response + */ + nciTransceive(NxpNciExtnCmd NciCmd) generates(NxpNciExtnResp NciResp); + +}; diff --git a/extns/intf/nxpnfc/1.0/manifest.xml b/extns/intf/nxpnfclegacy/1.0/manifest.xml index 98b69a5..cb4a123 100755..100644 --- a/extns/intf/nxpnfc/1.0/manifest.xml +++ b/extns/intf/nxpnfclegacy/1.0/manifest.xml @@ -2,18 +2,18 @@ <hal format="hidl"> <name>android.hardware.nfc</name> <transport>hwbinder</transport> - <version>1.1</version> + <version>1.2</version> <interface> <name>INfc</name> <instance>default</instance> </interface> </hal> <hal format="hidl"> - <name>vendor.nxp.nxpnfc</name> + <name>vendor.nxp.nxpnfclegacy</name> <transport>hwbinder</transport> <version>1.0</version> <interface> - <name>INxpNfc</name> + <name>INxpNfcLegacy</name> <instance>default</instance> </interface> </hal> diff --git a/extns/intf/nxpnfclegacy/1.0/types.hal b/extns/intf/nxpnfclegacy/1.0/types.hal new file mode 100644 index 0000000..42d1085 --- /dev/null +++ b/extns/intf/nxpnfclegacy/1.0/types.hal @@ -0,0 +1,106 @@ +/****************************************************************************** + * + * Copyright 2020 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +package vendor.nxp.nxpnfclegacy@1.0; + +enum NxpNfcHalEseState : uint64_t { + HAL_NFC_ESE_IDLE_MODE = 0, + HAL_NFC_ESE_WIRED_MODE +}; + +enum NfcHciInitStatus : uint8_t { + NFC_HCI_INIT_COMPLETE = 0x00, + NFC_HCI_INIT_START = 0x01 +}; + +struct NxpNciCfgInfo { + bool isGetcfg; + uint8_t[4] total_duration; + uint8_t total_duration_len; + uint8_t[48] atr_req_gen_bytes; + uint8_t atr_req_gen_bytes_len; + uint8_t[48] atr_res_gen_bytes; + uint8_t atr_res_gen_bytes_len; + uint8_t[3] pmid_wt; + uint8_t pmid_wt_len; +}; + +struct NxpNfcScrResetEmvcoCmd{ + uint64_t len; + uint8_t[10] cmd; +}; + +struct NxpNfcHalConfig { + uint8_t ese_listen_tech_mask; + uint8_t default_nfcee_disc_timeout; + uint8_t default_nfcee_timeout; + uint8_t ese_wired_prt_mask; + uint8_t uicc_wired_prt_mask; + uint8_t wired_mode_rf_field_enable; + uint8_t aid_block_route; + uint8_t esePowerDhControl; + uint8_t tagOpTimeout; + uint8_t loaderServiceVersion; + uint8_t defaultNfceeDiscTimeout; + uint8_t dualUiccEnable; + uint8_t ceRouteStrictDisable; + uint32_t osDownloadTimeoutValue; + uint8_t defaultAidRoute; + uint8_t defaultAidPwrState; + uint8_t defaultRoutePwrState; + uint8_t defaultOffHostPwrState; + uint8_t jcopDlAtBootEnable; + uint8_t defaultNfceeTimeout; + uint8_t nxpNfcChip; + uint8_t coreScrnOffAutonomousEnable; + uint8_t p61LsDefaultInterface; + uint8_t p61JcopDefaultInterface; + uint8_t agcDebugEnable; + uint8_t felicaCltPowerState; + uint32_t cmdRspTimeoutValue; + uint8_t checkDefaultProtoSeId; + uint8_t nfccPassiveListenTimeout; + uint32_t nfccStandbyTimeout; + uint32_t wmMaxWtxCount; + uint32_t nfccRfFieldEventTimeout; + uint8_t allowWiredInMifareDesfireClt; + uint8_t dwpIntfResetEnable; + uint8_t nxpLogHalLoglevel; + uint8_t nxpLogExtnsLogLevel; + uint8_t nxpLogTmlLogLevel; + uint8_t nxpLogFwDnldLogLevel; + uint8_t nxpLogNcixLogLevel; + uint8_t nxpLogNcirLogLevel; + uint8_t scrCfgFormat; + uint8_t etsiReaderEnable; + uint8_t techAbfRoute; + uint8_t techAbfPwrState; + uint8_t wTagSupport; + uint8_t t4tNfceePwrState; + NxpNfcScrResetEmvcoCmd scrResetEmvco; + }; + + struct NxpNciExtnCmd{ + uint16_t cmd_len; + uint8_t[256] p_cmd; +}; + +struct NxpNciExtnResp{ + uint32_t status; + uint16_t rsp_len; + uint8_t[256] p_rsp; +};
\ No newline at end of file diff --git a/extns/intf/nxpnfclegacy/Android.bp b/extns/intf/nxpnfclegacy/Android.bp new file mode 100644 index 0000000..9e452d3 --- /dev/null +++ b/extns/intf/nxpnfclegacy/Android.bp @@ -0,0 +1,4 @@ +hidl_package_root { + name: "vendor.nxp.nxpnfclegacy", + path: "hardware/nxp/nfc/extns/intf/nxpnfclegacy", +} diff --git a/halimpl/common/phNfcTypes.h b/halimpl/common/phNfcTypes.h index 9b0f6a6..ada0a9d 100644 --- a/halimpl/common/phNfcTypes.h +++ b/halimpl/common/phNfcTypes.h @@ -50,14 +50,6 @@ typedef uint16_t NFCSTATUS; /* Return values */ #define PHNFC_ATQA_LENGTH 0x02U /* ATQA length */ /* - * NFC Data structure - */ -typedef struct phNfc_sData { - uint8_t* buffer; /* Buffer to store data */ - uint32_t length; /* Buffer length */ -} phNfc_sData_t; - -/* * Possible Hardware Configuration exposed to upper layer. * Typically this should be port name (Ex:"COM1","COM2") to which PN54X is * connected. @@ -134,177 +126,6 @@ typedef struct phLibNfc_DeferredCall { pphLibNfc_DeferredParameter_t pParameter; /* pointer to Deferred parameter */ } phLibNfc_DeferredCall_t; -/* - * Definitions for supported protocol - */ -typedef struct phNfc_sSupProtocol { - unsigned int MifareUL : 1; /* Protocol Mifare Ultra Light or any NFC Forum - Type-2 tags */ - unsigned int MifareStd : 1; /* Protocol Mifare Standard. */ - unsigned int ISO14443_4A : 1; /* Protocol ISO14443-4 Type A. */ - unsigned int ISO14443_4B : 1; /* Protocol ISO14443-4 Type B. */ - unsigned int ISO15693 : 1; /* Protocol ISO15693 HiTag. */ - unsigned int Felica : 1; /* Protocol Felica. */ - unsigned int NFC : 1; /* Protocol NFC. */ - unsigned int Jewel : 1; /* Protocol Innovision Jewel Tag. or Any T1T*/ - unsigned int - Desfire : 1; /*true indicates specified feature (mapping - or formatting)for DESFire tag supported else not supported.*/ - unsigned int Kovio : 1; /* Protocol Kovio Tag*/ - unsigned int HID : 1; /* Protocol HID(Picopass) Tag*/ - unsigned int Bprime : 1; /* Protocol BPrime Tag*/ - unsigned int EPCGEN2 : 1; /* Protocol EPCGEN2 Tag*/ -} phNfc_sSupProtocol_t; - -/* - * Enumerated MIFARE Commands - */ - -typedef enum phNfc_eMifareCmdList { - phNfc_eMifareRaw = 0x00U, /* This command performs raw transcations */ - phNfc_eMifareAuthentA = 0x60U, /* This command performs an authentication with - KEY A for a sector. */ - phNfc_eMifareAuthentB = 0x61U, /* This command performs an authentication with - KEY B for a sector. */ - phNfc_eMifareRead16 = 0x30U, /* Read 16 Bytes from a Mifare Standard block */ - phNfc_eMifareRead = 0x30U, /* Read Mifare Standard */ - phNfc_eMifareWrite16 = 0xA0U, /* Write 16 Bytes to a Mifare Standard block */ - phNfc_eMifareWrite4 = 0xA2U, /* Write 4 bytes. */ - phNfc_eMifareInc = 0xC1U, /* Increment */ - phNfc_eMifareDec = 0xC0U, /* Decrement */ - phNfc_eMifareTransfer = 0xB0U, /* Transfer */ - phNfc_eMifareRestore = 0xC2U, /* Restore. */ - phNfc_eMifareReadSector = 0x38U, /* Read Sector. */ - phNfc_eMifareWriteSector = 0xA8U, /* Write Sector. */ - /* Above commands could be used for preparing raw command but below one can - not be */ - phNfc_eMifareReadN = 0x01, /* Proprietary Command */ - phNfc_eMifareWriteN = 0x02, /* Proprietary Command */ - phNfc_eMifareSectorSel = 0x03, /* Proprietary Command */ - phNfc_eMifareAuth = 0x04, /* Proprietary Command */ - phNfc_eMifareProxCheck = 0x05, /* Proprietary Command */ - phNfc_eMifareInvalidCmd = 0xFFU /* Invalid Command */ -} phNfc_eMifareCmdList_t; - -/* - * Information about ISO14443A - */ -typedef struct phNfc_sIso14443AInfo { - uint8_t Uid[PHNFC_MAX_UID_LENGTH]; /* UID information of the TYPE A - * Tag Discovered */ - uint8_t UidLength; /* UID information length */ - uint8_t - AppData[PHNFC_MAX_ATR_LENGTH]; /* Application data information of the - 1 * tag discovered (= Historical bytes for - * type A) */ - uint8_t AppDataLength; /* Application data length */ - uint8_t Sak; /* SAK information of the TYPE A - * Tag Discovered */ - uint8_t AtqA[PHNFC_ATQA_LENGTH]; /* ATQA informationof the TYPE A - * Tag Discovered */ - uint8_t MaxDataRate; /* Maximum data rate supported - * by the tag Discovered */ - uint8_t Fwi_Sfgt; /* Frame waiting time and start up - * frame guard */ -} phNfc_sIso14443AInfo_t; - -/* Remote device information structure */ -typedef union phNfc_uRemoteDevInfo { - phNfc_sIso14443AInfo_t Iso14443A_Info; /* ISO1443A Remote device info */ -} phNfc_uRemoteDevInfo_t; - -/* -* -* The RF Device Type List is used to identify the type of -* remote device that is discovered and connected. -* -*/ - -typedef enum phNfc_eRFDevType { - phNfc_eUnknown_DevType = 0x00U, - - phNfc_eISO14443_A_PCD, - phNfc_eISO14443_B_PCD, - phNfc_eISO14443_BPrime_PCD, - phNfc_eFelica_PCD, - phNfc_eJewel_PCD, - phNfc_eISO15693_PCD, - phNfc_eEpcGen2_PCD, - phNfc_ePCD_DevType, - - phNfc_ePICC_DevType, - phNfc_eISO14443_A_PICC, - phNfc_eISO14443_4A_PICC, - phNfc_eISO14443_3A_PICC, - phNfc_eMifare_PICC, - phNfc_eISO14443_B_PICC, - phNfc_eISO14443_4B_PICC, - phNfc_eISO14443_BPrime_PICC, - phNfc_eFelica_PICC, - phNfc_eJewel_PICC, - phNfc_eISO15693_PICC, - phNfc_eEpcGen2_PICC, - - phNfc_eNfcIP1_Target, - phNfc_eNfcIP1_Initiator, - - phNfc_eInvalid_DevType - -} phNfc_eRFDevType_t; - -/* - * The Remote Device Type List is used to identify the type of - * remote device that is discovered/connected - */ -typedef phNfc_eRFDevType_t phNfc_eRemDevType_t; -typedef phNfc_eRemDevType_t phHal_eRemDevType_t; - -/* - * Union for each available type of Commands. - */ - -typedef union phNfc_uCommand { - phNfc_eMifareCmdList_t MfCmd; /* Mifare command structure. */ -} phNfc_uCmdList_t; - -/* - * The Remote Device Information Structure holds information about one single - * Remote - * Device detected. - */ -typedef struct phNfc_sRemoteDevInformation { - uint8_t SessionOpened; /* Flag indicating the validity of - * the handle of the remote device. - * 1 = Device is not activer (Only discovered), 2 = - * Device is active and ready for use*/ - phNfc_eRemDevType_t RemDevType; /* Remote device type */ - phNfc_uRemoteDevInfo_t RemoteDevInfo; /* Union of available Remote Device */ -} phNfc_sRemoteDevInformation_t; - -/* - * Transceive Information Data Structure for sending commands/response to the - * remote device - */ - -typedef struct phNfc_sTransceiveInfo { - phNfc_uCmdList_t cmd; /* Command for transceive */ - uint8_t addr; /* Start Block Number */ - uint8_t NumBlock; /* Number of Blocks to perform operation */ - /* For Felica only*/ - uint16_t* ServiceCodeList; /* 2 Byte service Code List */ - uint16_t* Blocklist; /* 2 Byte Block list */ - phNfc_sData_t sSendData; /* Send data */ - phNfc_sData_t sRecvData; /* Recv data */ - /* For EPC-GEN */ - uint32_t dwWordPtr; /* Word address for the memory write */ - uint8_t bWordPtrLen; /* Specifies the length of word pointer - 00: 8 bits - 01: 16 bits - 10: 24 bits - 11: 32 bits - */ - uint8_t bWordCount; /* Number of words to be read or written */ -} phNfc_sTransceiveInfo_t; #if (NXP_EXTNS == TRUE) typedef enum p61_access_state { P61_STATE_INVALID = 0x0000, diff --git a/halimpl/ese-clients/src/DwpEseUpdater.cc b/halimpl/ese-clients/src/DwpEseUpdater.cc index b629b01..2a8d130 100755 --- a/halimpl/ese-clients/src/DwpEseUpdater.cc +++ b/halimpl/ese-clients/src/DwpEseUpdater.cc @@ -21,7 +21,6 @@ #include "DwpSeEvtCallback.h" #include "EseAdaptation.h" #include "EseUpdateChecker.h" -#include "hal_nxpnfc.h" #include <JcDnld.h> #include <cutils/log.h> #include <dirent.h> @@ -35,6 +34,7 @@ #include <unistd.h> #include <vendor/nxp/nxpese/1.0/INxpEse.h> +extern bool phNxpNciHal_Abort(); #define HAL_ESE_IOCTL_NFC_JCOP_DWNLD 176 using vendor::nxp::nxpese::V1_0::INxpEse; @@ -75,15 +75,15 @@ void DwpEseUpdater::checkIfEseClientUpdateReqd() void IoctlCallback_DwpClient(hidl_vec<uint8_t> outputData) { const char* func = "IoctlCallback_DwpClient"; - nfc_nci_ExtnOutputData_t *pOutData = - (nfc_nci_ExtnOutputData_t *)&outputData[0]; + ese_nxp_ExtnOutputData_t *pOutData = + (ese_nxp_ExtnOutputData_t *)&outputData[0]; ALOGD_IF(nfc_debug_enabled, "%s Ioctl Type=%lu", func, (unsigned long)pOutData->ioctlType); EseAdaptation* pAdaptation = (EseAdaptation*)pOutData->context; /*Output Data from stub->Proxy is copied back to output data * This data will be sent back to libese*/ memcpy(&pAdaptation->mCurrentIoctlData->out, &outputData[0], - sizeof(nfc_nci_ExtnOutputData_t)); + sizeof(ese_nxp_ExtnOutputData_t)); } SESTATUS DwpEseUpdater::doEseUpdateIfReqd() { @@ -168,13 +168,13 @@ void DwpEseUpdater::setDwpEseClientState(uint8_t state) } void DwpEseUpdater::sendeSEUpdateState(uint8_t state) { - nfc_nci_IoctlInOutData_t inpOutData; + ese_nxp_IoctlInOutData_t inpOutData; gpEseAdapt = &EseAdaptation::GetInstance(); gpEseAdapt->Initialize(); ALOGE("%s: State = %d", __FUNCTION__, state); - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = sizeof(state); - memcpy(inpOutData.inp.data.nciCmd.p_cmd, &state, sizeof(state)); + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); + inpOutData.inp.data.nxpCmd.cmd_len = sizeof(state); + memcpy(inpOutData.inp.data.nxpCmd.p_cmd, &state, sizeof(state)); inpOutData.inp.data_source = 2; phNxpNciHal_ioctl(HAL_ESE_IOCTL_NFC_JCOP_DWNLD, &inpOutData); } @@ -203,13 +203,13 @@ SESTATUS DwpEseUpdater::eSEUpdate_SeqHandler() { case ESE_LS_UPDATE_COMPLETED: case ESE_UPDATE_COMPLETED: { - nfc_nci_IoctlInOutData_t inpOutData; + ese_nxp_IoctlInOutData_t inpOutData; DwpEseUpdater::setDwpEseClientState(ESE_UPDATE_COMPLETED); ALOGD("LSUpdate Thread not required inform NFC to restart"); - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); inpOutData.inp.data_source = 2; usleep(50 * 1000); - phNxpNciHal_ioctl(HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE, &inpOutData); + phNxpNciHal_Abort(); } break; } diff --git a/halimpl/hal/phNxpNciHal.cc b/halimpl/hal/phNxpNciHal.cc index 35b0df4..b7e9be6 100644 --- a/halimpl/hal/phNxpNciHal.cc +++ b/halimpl/hal/phNxpNciHal.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2018 NXP Semiconductors + * Copyright (C) 2015-2019 NXP Semiconductors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,12 +30,10 @@ #include <phTmlNfc_i2c.h> #include "phNxpNciHal_nciParser.h" #include <EseAdaptation.h> -#ifdef ENABLE_ESE_CLIENT -#include "hal_nxpese.h" -#endif -#include "hal_nxpnfc.h" #include "spi_spm.h" -#include <vendor/nxp/hardware/nfc/1.0/types.h> +#include <vendor/nxp/hardware/nfc/2.0/types.h> +#include "Nxp_Features.h" +#include "NxpNfc.h" using namespace android::hardware::nfc::V1_1; using namespace android::hardware::nfc::V1_2; @@ -75,6 +73,10 @@ do\ goto recoveryLabel;\ }while(0) +bool bEnableMfcExtns = false; +bool bEnableMfcReader = false; +bool bDisableLegacyMfcExtns = false; + /* Processing of ISO 15693 EOF */ extern uint8_t icode_send_eof; extern uint8_t icode_detected; @@ -101,7 +103,6 @@ extern int phNxpNciHal_CheckFwRegFlashRequired(uint8_t* fw_update_req, extern int phPalEse_spi_ioctl(phPalEse_ControlCode_t eControlCode, void* pDevHandle, long level); extern void phNxpNciHal_conf_nfc_forum_mode(); -static void phNxpNciHal_MinCloseForOmapiClose(nfc_nci_IoctlInOutData_t *pInpOutData); static int phNxpNciHal_fw_mw_ver_check(); phNxpNci_getCfg_info_t* mGetCfg_info = NULL; uint32_t gSvddSyncOff_Delay = 10; @@ -129,6 +130,10 @@ static uint8_t gRecFwRetryCount; // variable to hold dummy FW recovery count static uint8_t write_unlocked_status = NFCSTATUS_SUCCESS; static uint8_t Rx_data[NCI_MAX_DATA_LEN]; uint32_t timeoutTimerId = 0; +/* Used to send Callback Transceive data during Mifare Write. + * If this flag is enabled, no need to send response to Upper layer */ +bool sendRspToUpperLayer = true; + phNxpNciHal_Sem_t config_data; phNxpNciClock_t phNxpNciClock = {0, {0}}; @@ -159,10 +164,10 @@ static void phNxpNciHal_print_res_status(uint8_t* p_rx_data, uint16_t* p_len); static NFCSTATUS phNxpNciHal_CheckValidFwVersion(void); static void phNxpNciHal_enable_i2c_fragmentation(); static void phNxpNciHal_core_MinInitialized_complete(NFCSTATUS status); -static NFCSTATUS phNxpNciHal_set_Boot_Mode(uint8_t mode); NFCSTATUS phNxpNciHal_set_china_region_configs(void); static void phNxpNciHal_configNciParser(void); static void phNxpNciHal_initialize_debug_enabled_flag(); +static void phNxpNciHal_initialize_mifare_flag(); static NFCSTATUS phNxpNciHalRFConfigCmdRecSequence(); static NFCSTATUS phNxpNciHal_CheckRFCmdRespStatus(); static NFCSTATUS phNxpNciHal_uicc_baud_rate(); @@ -170,9 +175,10 @@ static void phNxpNciHal_gpio_restore(phNxpNciHal_GpioInfoState state); NFCSTATUS phNxpNciHal_nfcc_core_reset_init(); NFCSTATUS phNxpNciHal_getChipInfoInFwDnldMode(void); static void phNxpNciHal_notifyHciEvtProcessComplete(); -void phNxpNciHal_phase_tirm_offset_sign_update(); +#ifdef FactoryOTA void phNxpNciHal_isFactoryOTAModeActive(); static NFCSTATUS phNxpNciHal_disableFactoryOTAMode(void); +#endif /****************************************************************************** * Function phNxpNciHal_initialize_debug_enabled_flag @@ -471,6 +477,16 @@ static NFCSTATUS phNxpNciHal_fw_download(void) { return NFCSTATUS_REJECTED; } + if (nfcFL.nfcNxpEse == true) { + uint32_t level = 0x03; + int spi_current_state = phNxpNciHal_getSPMStatus(level); + NXPLOG_NCIHAL_D("spi_current_state = %4x ", spi_current_state); + if (spi_current_state != P61_STATE_IDLE) { + NXPLOG_NCIHAL_E("FW download denied while SPI in use, Continue NFC init"); + return NFCSTATUS_REJECTED; + } + } + nxpncihal_ctrl.phNxpNciGpioInfo.state = GPIO_UNKNOWN; phNxpNciHal_gpio_restore(GPIO_STORE); @@ -524,7 +540,7 @@ static NFCSTATUS phNxpNciHal_fw_download(void) { } else { status = NFCSTATUS_SUCCESS; fw_download_success = 1; - property_set("persist.nfc.hci_network_reset_req", "true"); + property_set("persist.vendor.nfc.hci_network_reset_req", "true"); } /*Keep Read Pending on I2C*/ @@ -745,6 +761,9 @@ int phNxpNciHal_MinInit(nfc_stack_callback_t* p_cback, phNxpNciHal_initialize_debug_enabled_flag(); phNxpLog_InitializeLogLevel(); + /* initialize Mifare flags*/ + phNxpNciHal_initialize_mifare_flag(); + /*Create the timer for extns write response*/ timeoutTimerId = phOsalNfc_Timer_Create(); if (timeoutTimerId == PH_OSALNFC_TIMER_ID_INVALID) { @@ -1260,6 +1279,25 @@ static void phNxpNciHal_open_complete(NFCSTATUS status) { * ******************************************************************************/ int phNxpNciHal_write(uint16_t data_len, const uint8_t* p_data) { + if (bDisableLegacyMfcExtns && bEnableMfcExtns && p_data[0] == 0x00) { + return NxpMfcReaderInstance.Write(data_len, p_data); + } + return phNxpNciHal_write_internal(data_len, p_data); +} + +/****************************************************************************** + * Function phNxpNciHal_write_internal + * + * Description This function write the data to NFCC through physical + * interface (e.g. I2C) using the PN54X driver interface. + * Before sending the data to NFCC, phNxpNciHal_write_ext + * is called to check if there is any extension processing + * is required for the NCI packet being sent out. + * + * Returns It returns number of bytes successfully written to NFCC. + * + ******************************************************************************/ +int phNxpNciHal_write_internal(uint16_t data_len, const uint8_t* p_data) { NFCSTATUS status = NFCSTATUS_FAILED; static phLibNfc_Message_t msg; @@ -1538,6 +1576,13 @@ static void phNxpNciHal_read_complete(void* pContext, /* Unlock semaphore waiting for only ntf*/ SEM_POST(&(nxpncihal_ctrl.ext_cb_data)); nxpncihal_ctrl.nci_info.wait_for_ntf = FALSE; + } else if (bDisableLegacyMfcExtns && !sendRspToUpperLayer && + (nxpncihal_ctrl.p_rx_data[0x00] == 0x00)) { + sendRspToUpperLayer = true; + NFCSTATUS mfcRspStatus = NxpMfcReaderInstance.CheckMfcResponse( + nxpncihal_ctrl.p_rx_data, nxpncihal_ctrl.rx_data_len); + NXPLOG_NCIHAL_D("Mfc Response Status = 0x%x", mfcRspStatus); + SEM_POST(&(nxpncihal_ctrl.ext_cb_data)); } /* Read successful send the event to higher layer */ else if ((nxpncihal_ctrl.p_nfc_stack_data_cback != NULL) && @@ -1629,11 +1674,11 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { static uint8_t android_l_aid_matching_mode_on_cmd[] = { 0x20, 0x02, 0x05, 0x01, 0xA0, 0x91, 0x01, 0x01}; - int len = property_get("persist.nfc.hci_network_reset_req", valueStr, "false"); + int len = property_get("persist.vendor.nfc.hci_network_reset_req", valueStr, "false"); if (len > 0) { persist_hci_network_reset_req = (len == 4 && (memcmp(valueStr, "true", len) == 0)) ? true : false; } - len = property_get("persist.nfc.core_reset_debug_info", valueStr, "false"); + len = property_get("persist.vendor.nfc.core_reset_debug_info", valueStr, "false"); if (len > 0) { persist_core_reset_debug_info_req = (len == 4 && (memcmp(valueStr, "true", len) == 0)) ? true : false; } @@ -1807,6 +1852,10 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { mEEPROM_info.request_type = EEPROM_PROP_ROUTING; mEEPROM_info.request_mode = SET_EEPROM_DATA; status = request_EEPROM(&mEEPROM_info); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E( + "request EEPROM settings for EEPROM_PROP_ROUTING Failed"); + } } } } @@ -1851,6 +1900,10 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { mEEPROM_info.request_type = EEPROM_ESE_SVDD_POWER; mEEPROM_info.request_mode = SET_EEPROM_DATA; status = request_EEPROM(&mEEPROM_info); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E( + "request EEPROM settings for EEPROM_ESE_SVDD_POWER Failed"); + } } if (retlen == 0x01) { retlen = 0; @@ -1861,6 +1914,9 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { mEEPROM_info.request_mode = SET_EEPROM_DATA; phTmlNfc_IoCtl(phTmlNfc_e_SetLegacyPowerScheme); status = request_EEPROM(&mEEPROM_info); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E("request EEPROM settings for ESE_POWER_EXT_PMU Failed"); + } } else if (retlen == 0x02) { retlen = 0; value = 0; @@ -1879,10 +1935,30 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { mEEPROM_info.request_type = EEPROM_ESE_POWER_EXT_PMU; mEEPROM_info.request_mode = SET_EEPROM_DATA; status = request_EEPROM(&mEEPROM_info); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E("request EEPROM settings for ESE_POWER_EXT_PMU Failed"); + } } } } } + retlen = 0; + value = (uint8_t)retlen; + mEEPROM_info.bufflen = sizeof(value); + mEEPROM_info.request_type = EEPROM_NDEF_INTF_CFG; + mEEPROM_info.request_mode = SET_EEPROM_DATA; + if(GetNxpNumValue(NAME_WTAG_SUPPORT, (void*)&retlen, sizeof(retlen))) { + if(retlen == 0x01) { + value = 0x03; //Set T4T from NFCC for W_TAG + mEEPROM_info.buffer = &value; + } + } else { + mEEPROM_info.buffer = &value; + } + status = request_EEPROM(&mEEPROM_info); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E("request EEPROM settings for NDEF_INTF_CFG Failed"); + } } #endif if(persist_core_reset_debug_info_req){ @@ -1891,7 +1967,7 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { NXPLOG_NCIHAL_E("NFCC texted reset ntf failed"); } NXPLOG_NCIHAL_D("NFCC txed reset ntf with reason code 0xA3"); - property_set("persist.nfc.core_reset_debug_info", "false"); + property_set("persist.vendor.nfc.core_reset_debug_info", "false"); } setConfigAlways = false; isfound = GetNxpNumValue(NAME_NXP_SET_CONFIG_ALWAYS, &num, sizeof(num)); @@ -1951,10 +2027,6 @@ int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params) { } } - if(GetNxpNumValue(NAME_NXP_PHASE_TIRM_OFFSET_SIGN_UPDATE, &num, sizeof(num))) { - if(num != 0) phNxpNciHal_phase_tirm_offset_sign_update(); - } - retlen = 0; if (nfcFL.chipType != pn547C2) { NXPLOG_NCIHAL_D("Performing TVDD Settings"); @@ -2744,7 +2816,7 @@ static NFCSTATUS phNxpNciHal_uicc_baud_rate() { return status; } - +#ifdef FactoryOTA void phNxpNciHal_isFactoryOTAModeActive() { uint8_t check_factoryOTA[] = {0x20, 0x03, 0x05, 0x02, 0xA0, 0x08, 0xA0, 0x88}; NFCSTATUS status = NFCSTATUS_FAILED; @@ -2782,34 +2854,7 @@ NFCSTATUS phNxpNciHal_disableFactoryOTAMode() { } return status; } - -void phNxpNciHal_phase_tirm_offset_sign_update() { - uint8_t phase_tirm_offset_read[] = {0x20, 0x03, 0x03, 0x01, 0xA0, 0x17}; - uint8_t phase_tirm_offset_write[] = {0x20, 0x02, 0x05, 0x01, 0xA0, 0x17, 0x01, 0x80}; - NFCSTATUS status = NFCSTATUS_FAILED; - - NXPLOG_NCIHAL_D("check A017 mode status"); - - status = phNxpNciHal_send_ext_cmd(sizeof(phase_tirm_offset_read), phase_tirm_offset_read); - - if (status == NFCSTATUS_SUCCESS) { - if((nxpncihal_ctrl.p_rx_data[8] & 0x40) == 0x40) { - NXPLOG_NCIHAL_D("Set new tirm offset sing update"); - phase_tirm_offset_write[7] |= nxpncihal_ctrl.p_rx_data[8] & 0x3F; - status = phNxpNciHal_send_ext_cmd(sizeof(phase_tirm_offset_write), phase_tirm_offset_write); - if (status == NFCSTATUS_SUCCESS) { - NXPLOG_NCIHAL_D("Phase tirm offset updated"); - } else { - NXPLOG_NCIHAL_E("Phase tirm offset update error"); - } - } else { - NXPLOG_NCIHAL_D("Phase tirm offset OK"); - } - } else { - NXPLOG_NCIHAL_E("Fail to get phase tirm offset status"); - } - return; -} +#endif /****************************************************************************** * Function phNxpNciHal_core_initialized_complete @@ -2913,9 +2958,7 @@ int phNxpNciHal_close(bool bShutdown) { unsigned long uiccListenMask = 0x00; unsigned long eseListenMask = 0x00; - char valueStr[PROPERTY_VALUE_MAX] = {0}; - bool factoryOTA_terminate = false; - int len; + unsigned long num = 0; if (!(GetNxpNumValue(NAME_NXP_UICC_LISTEN_TECH_MASK, &uiccListenMask, sizeof(uiccListenMask)))) { @@ -2967,7 +3010,10 @@ int phNxpNciHal_close(bool bShutdown) { } } - len = property_get("persist.factoryota.reboot", valueStr, "normal"); +#ifdef FactoryOTA + char valueStr[PROPERTY_VALUE_MAX] = {0}; + bool factoryOTA_terminate = false; + int len = property_get("persist.factoryota.reboot", valueStr, "normal"); if (len > 0) { factoryOTA_terminate = (len == 9 && (memcmp(valueStr, "terminate", len) == 0)) ? true : false; } @@ -2976,15 +3022,29 @@ int phNxpNciHal_close(bool bShutdown) { phNxpNciHal_disableFactoryOTAMode(); phNxpNciHal_isFactoryOTAModeActive(); } +#endif + if (GetNxpNumValue(NAME_NXP_CORE_PWR_OFF_AUTONOMOUS_ENABLE, &num, sizeof(num))) { + NXPLOG_NCIHAL_D("Power shutdown with autonomous mode status: %lu", num); + } nxpncihal_ctrl.halStatus = HAL_STATUS_CLOSE; - status = - phNxpNciHal_send_ext_cmd(sizeof(cmd_core_reset_nci), cmd_core_reset_nci); + if (bShutdown && (num == 0x01) ) { + NXPLOG_NCIHAL_D("Power shutdown with autonomous mode enable"); + static uint8_t coreStandBy[] = {0x2F, 0x00, 0x01, 0x02}; + status = phNxpNciHal_send_ext_cmd(sizeof(coreStandBy), coreStandBy); - if (status != NFCSTATUS_SUCCESS) { - NXPLOG_NCIHAL_E("NCI_CORE_RESET: Failed"); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E("NXP Standby Proprietary Ext failed"); + } + } else { + status = + phNxpNciHal_send_ext_cmd(sizeof(cmd_core_reset_nci), cmd_core_reset_nci); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E("NCI_CORE_RESET: Failed"); + } } + sem_destroy(&nxpncihal_ctrl.syncSpiNfc); if (gParserCreated) { @@ -3136,152 +3196,167 @@ int phNxpNciHal_configDiscShutdown(void) { * Returns void. * ******************************************************************************/ -void phNxpNciHal_getNxpConfig(nfc_nci_IoctlInOutData_t *pInpOutData) { - unsigned long num = 0; - long retlen = 0; - uint8_t *buffer = NULL; - long bufflen = 260; - - buffer = (uint8_t *)malloc(bufflen * sizeof(uint8_t)); - memset(&pInpOutData->out.data.nxpConfigs, 0x00, sizeof(pInpOutData->out.data.nxpConfigs)); - if (GetNxpNumValue(NAME_NXP_ESE_LISTEN_TECH_MASK, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.ese_listen_tech_mask = num; - }else { - pInpOutData->out.data.nxpConfigs.ese_listen_tech_mask = 0x07; - } - if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_DISC_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.default_nfcee_disc_timeout = num; - } - if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.default_nfcee_timeout = num; - } - if (GetNxpNumValue(NAME_NXP_ESE_WIRED_PRT_MASK, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.ese_wired_prt_mask = num; - } - if (GetNxpNumValue(NAME_NXP_UICC_WIRED_PRT_MASK, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.uicc_wired_prt_mask = num; - } - if (GetNxpNumValue(NAME_NXP_WIRED_MODE_RF_FIELD_ENABLE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.wired_mode_rf_field_enable = num; - } - if (GetNxpNumValue(NAME_AID_BLOCK_ROUTE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.aid_block_route = num; - } - if (GetNxpNumValue(NAME_NXP_ESE_POWER_DH_CONTROL, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.esePowerDhControl = num; - } - if (GetNxpNumValue(NAME_NXP_SWP_RD_TAG_OP_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.tagOpTimeout = num; - } - if (GetNxpNumValue(NAME_NXP_LOADER_SERICE_VERSION, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.loaderServiceVersion = num; - } - if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_DISC_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.defaultNfceeDiscTimeout = num; - } - if (GetNxpNumValue(NAME_NXP_DUAL_UICC_ENABLE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.dualUiccEnable = num; - } - if (GetNxpNumValue(NAME_NXP_CE_ROUTE_STRICT_DISABLE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.ceRouteStrictDisable = num; - } - if (GetNxpNumValue(NAME_OS_DOWNLOAD_TIMEOUT_VALUE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.osDownloadTimeoutValue = num; - } - if (GetNxpNumValue(NAME_DEFAULT_AID_ROUTE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.defaultAidRoute = num; - } - if (GetNxpNumValue(NAME_DEFAULT_AID_PWR_STATE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.defaultAidPwrState = num; - } - if (GetNxpNumValue(NAME_DEFAULT_ISODEP_PWR_STATE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.defaultRoutePwrState = num; - } - if (GetNxpNumValue(NAME_DEFAULT_OFFHOST_PWR_STATE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.defaultOffHostPwrState = num; - } - if (GetNxpNumValue(NAME_NXP_JCOPDL_AT_BOOT_ENABLE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.jcopDlAtBootEnable = num; - } - if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.defaultNfceeTimeout = num; - } - if (GetNxpNumValue(NAME_NXP_NFC_CHIP, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nxpNfcChip = num; - } - if (GetNxpNumValue(NAME_NXP_CORE_SCRN_OFF_AUTONOMOUS_ENABLE, &num, - sizeof(num))) { - pInpOutData->out.data.nxpConfigs.coreScrnOffAutonomousEnable = num; - } - if (GetNxpNumValue(NAME_NXP_ESE_LS_DEFAULT_INTERFACE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.p61LsDefaultInterface = num; - } - if (GetNxpNumValue(NAME_NXP_ESE_JCOP_DEFAULT_INTERFACE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.p61JcopDefaultInterface = num; - } - if (GetNxpNumValue(NAME_NXP_AGC_DEBUG_ENABLE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.agcDebugEnable = num; - } - if (GetNxpNumValue(NAME_DEFAULT_NFCF_PWR_STATE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.felicaCltPowerState = num; - } else { - pInpOutData->out.data.nxpConfigs.felicaCltPowerState = 0x3F; - } - if (GetNxpNumValue(NAME_NXP_HCEF_CMD_RSP_TIMEOUT_VALUE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.cmdRspTimeoutValue = num; - } - if (GetNxpNumValue(NAME_CHECK_DEFAULT_PROTO_SE_ID, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.checkDefaultProtoSeId = num; - } - if (GetNxpNumValue(NAME_NXP_NFCC_PASSIVE_LISTEN_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nfccPassiveListenTimeout = num; - } - if (GetNxpNumValue(NAME_NXP_NFCC_STANDBY_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nfccStandbyTimeout = num; - } - if (GetNxpNumValue(NAME_NXP_WM_MAX_WTX_COUNT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.wmMaxWtxCount = num; - } - if (GetNxpNumValue(NAME_NXP_NFCC_RF_FIELD_EVENT_TIMEOUT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nfccRfFieldEventTimeout = num; - } - if (GetNxpNumValue(NAME_NXP_ALLOW_WIRED_IN_MIFARE_DESFIRE_CLT, &num, - sizeof(num))) { - pInpOutData->out.data.nxpConfigs.allowWiredInMifareDesfireClt = num; - } - if (GetNxpNumValue(NAME_NXP_DWP_INTF_RESET_ENABLE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.dwpIntfResetEnable = num; - } - if (GetNxpNumValue(NAME_NXPLOG_HAL_LOGLEVEL, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nxpLogHalLoglevel = num; - } - if (GetNxpNumValue(NAME_NXPLOG_EXTNS_LOGLEVEL, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nxpLogExtnsLogLevel = num; - } - if (GetNxpNumValue(NAME_NXPLOG_TML_LOGLEVEL, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nxpLogTmlLogLevel = num; - } - if (GetNxpNumValue(NAME_NXPLOG_FWDNLD_LOGLEVEL, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nxpLogFwDnldLogLevel = num; - } - if (GetNxpNumValue(NAME_NXPLOG_NCIX_LOGLEVEL, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nxpLogNcixLogLevel = num; - } - if (GetNxpNumValue(NAME_NXPLOG_NCIR_LOGLEVEL, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.nxpLogNcirLogLevel = num; - } - if (GetNxpNumValue(NAME_NFA_CONFIG_FORMAT, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.scrCfgFormat = num; - } - if (GetNxpNumValue(NAME_ETSI_READER_ENABLE, &num, sizeof(num))) { - pInpOutData->out.data.nxpConfigs.etsiReaderEnable = num; - } - if (buffer) { - if (GetNxpByteArrayValue(NAME_NXP_PROP_RESET_EMVCO_CMD, (char *)buffer, - bufflen, &retlen)) { - memcpy(pInpOutData->out.data.nxpConfigs.scrResetEmvco.cmd, (char *)buffer, - retlen); - pInpOutData->out.data.nxpConfigs.scrResetEmvco.len = retlen; + void phNxpNciHal_getNxpConfig(phNxpNfcHalConfig *pNxpNfcHalConfig) { + unsigned long num = 0; + long retlen = 0; + uint8_t *buffer = NULL; + long bufflen = 260; + + buffer = (uint8_t *)malloc(bufflen * sizeof(uint8_t)); + memset(pNxpNfcHalConfig, 0x00, sizeof(phNxpNfcHalConfig)); + if (GetNxpNumValue(NAME_NXP_ESE_LISTEN_TECH_MASK, &num, sizeof(num))) { + pNxpNfcHalConfig->ese_listen_tech_mask = num; + }else { + pNxpNfcHalConfig->ese_listen_tech_mask = 0x07; + } + if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_DISC_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->default_nfcee_disc_timeout = num; + } + if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->default_nfcee_timeout = num; + } + if (GetNxpNumValue(NAME_NXP_ESE_WIRED_PRT_MASK, &num, sizeof(num))) { + pNxpNfcHalConfig->ese_wired_prt_mask = num; + } + if (GetNxpNumValue(NAME_NXP_UICC_WIRED_PRT_MASK, &num, sizeof(num))) { + pNxpNfcHalConfig->uicc_wired_prt_mask = num; + } + if (GetNxpNumValue(NAME_NXP_WIRED_MODE_RF_FIELD_ENABLE, &num, sizeof(num))) { + pNxpNfcHalConfig->wired_mode_rf_field_enable = num; + } + if (GetNxpNumValue(NAME_AID_BLOCK_ROUTE, &num, sizeof(num))) { + pNxpNfcHalConfig->aid_block_route = num; + } + if (GetNxpNumValue(NAME_NXP_ESE_POWER_DH_CONTROL, &num, sizeof(num))) { + pNxpNfcHalConfig->esePowerDhControl = num; + } + if (GetNxpNumValue(NAME_NXP_SWP_RD_TAG_OP_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->tagOpTimeout = num; + } + if (GetNxpNumValue(NAME_NXP_LOADER_SERICE_VERSION, &num, sizeof(num))) { + pNxpNfcHalConfig->loaderServiceVersion = num; + } + if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_DISC_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->defaultNfceeDiscTimeout = num; + } + if (GetNxpNumValue(NAME_NXP_DUAL_UICC_ENABLE, &num, sizeof(num))) { + pNxpNfcHalConfig->dualUiccEnable = num; + } + if (GetNxpNumValue(NAME_NXP_CE_ROUTE_STRICT_DISABLE, &num, sizeof(num))) { + pNxpNfcHalConfig->ceRouteStrictDisable = num; + } + if (GetNxpNumValue(NAME_OS_DOWNLOAD_TIMEOUT_VALUE, &num, sizeof(num))) { + pNxpNfcHalConfig->osDownloadTimeoutValue = num; + } + if (GetNxpNumValue(NAME_DEFAULT_AID_ROUTE, &num, sizeof(num))) { + pNxpNfcHalConfig->defaultAidRoute = num; + } + if (GetNxpNumValue(NAME_DEFAULT_AID_PWR_STATE, &num, sizeof(num))) { + pNxpNfcHalConfig->defaultAidPwrState = num; + } + if (GetNxpNumValue(NAME_DEFAULT_ISODEP_PWR_STATE, &num, sizeof(num))) { + pNxpNfcHalConfig->defaultRoutePwrState = num; + } + if (GetNxpNumValue(NAME_DEFAULT_OFFHOST_PWR_STATE, &num, sizeof(num))) { + pNxpNfcHalConfig->defaultOffHostPwrState = num; + } + if (GetNxpNumValue(NAME_NXP_JCOPDL_AT_BOOT_ENABLE, &num, sizeof(num))) { + pNxpNfcHalConfig->jcopDlAtBootEnable = num; + } + if (GetNxpNumValue(NAME_NXP_DEFAULT_NFCEE_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->defaultNfceeTimeout = num; + } + if (GetNxpNumValue(NAME_NXP_NFC_CHIP, &num, sizeof(num))) { + pNxpNfcHalConfig->nxpNfcChip = num; + } + if (GetNxpNumValue(NAME_NXP_CORE_SCRN_OFF_AUTONOMOUS_ENABLE, &num, + sizeof(num))) { + pNxpNfcHalConfig->coreScrnOffAutonomousEnable = num; + } + if (GetNxpNumValue(NAME_NXP_ESE_LS_DEFAULT_INTERFACE, &num, sizeof(num))) { + pNxpNfcHalConfig->p61LsDefaultInterface = num; + } + if (GetNxpNumValue(NAME_NXP_ESE_JCOP_DEFAULT_INTERFACE, &num, sizeof(num))) { + pNxpNfcHalConfig->p61JcopDefaultInterface = num; + } + if (GetNxpNumValue(NAME_NXP_AGC_DEBUG_ENABLE, &num, sizeof(num))) { + pNxpNfcHalConfig->agcDebugEnable = num; + } + if (GetNxpNumValue(NAME_DEFAULT_NFCF_PWR_STATE, &num, sizeof(num))) { + pNxpNfcHalConfig->felicaCltPowerState = num; + } else { + pNxpNfcHalConfig->felicaCltPowerState = 0x3F; + } + if (GetNxpNumValue(NAME_NXP_HCEF_CMD_RSP_TIMEOUT_VALUE, &num, sizeof(num))) { + pNxpNfcHalConfig->cmdRspTimeoutValue = num; + } + if (GetNxpNumValue(NAME_CHECK_DEFAULT_PROTO_SE_ID, &num, sizeof(num))) { + pNxpNfcHalConfig->checkDefaultProtoSeId = num; + } + if (GetNxpNumValue(NAME_NXP_NFCC_PASSIVE_LISTEN_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->nfccPassiveListenTimeout = num; + } + if (GetNxpNumValue(NAME_NXP_NFCC_STANDBY_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->nfccStandbyTimeout = num; + } + if (GetNxpNumValue(NAME_NXP_WM_MAX_WTX_COUNT, &num, sizeof(num))) { + pNxpNfcHalConfig->wmMaxWtxCount = num; + } + if (GetNxpNumValue(NAME_NXP_NFCC_RF_FIELD_EVENT_TIMEOUT, &num, sizeof(num))) { + pNxpNfcHalConfig->nfccRfFieldEventTimeout = num; + } + if (GetNxpNumValue(NAME_NXP_ALLOW_WIRED_IN_MIFARE_DESFIRE_CLT, &num, + sizeof(num))) { + pNxpNfcHalConfig->allowWiredInMifareDesfireClt = num; + } + if (GetNxpNumValue(NAME_NXP_DWP_INTF_RESET_ENABLE, &num, sizeof(num))) { + pNxpNfcHalConfig->dwpIntfResetEnable = num; + } + if (GetNxpNumValue(NAME_NXPLOG_HAL_LOGLEVEL, &num, sizeof(num))) { + pNxpNfcHalConfig->nxpLogHalLoglevel = num; + } + if (GetNxpNumValue(NAME_NXPLOG_EXTNS_LOGLEVEL, &num, sizeof(num))) { + pNxpNfcHalConfig->nxpLogExtnsLogLevel = num; + } + if (GetNxpNumValue(NAME_NXPLOG_TML_LOGLEVEL, &num, sizeof(num))) { + pNxpNfcHalConfig->nxpLogTmlLogLevel = num; + } + if (GetNxpNumValue(NAME_NXPLOG_FWDNLD_LOGLEVEL, &num, sizeof(num))) { + pNxpNfcHalConfig->nxpLogFwDnldLogLevel = num; + } + if (GetNxpNumValue(NAME_NXPLOG_NCIX_LOGLEVEL, &num, sizeof(num))) { + pNxpNfcHalConfig->nxpLogNcixLogLevel = num; + } + if (GetNxpNumValue(NAME_NXPLOG_NCIR_LOGLEVEL, &num, sizeof(num))) { + pNxpNfcHalConfig->nxpLogNcirLogLevel = num; + } + if (GetNxpNumValue(NAME_NFA_CONFIG_FORMAT, &num, sizeof(num))) { + pNxpNfcHalConfig->scrCfgFormat = num; + } + if (GetNxpNumValue(NAME_ETSI_READER_ENABLE, &num, sizeof(num))) { + pNxpNfcHalConfig->etsiReaderEnable = num; + } + if (GetNxpNumValue(NAME_DEFAULT_TECH_ABF_ROUTE, &num, sizeof(num))) { + pNxpNfcHalConfig->techAbfRoute = num; + } + if (GetNxpNumValue(NAME_DEFAULT_TECH_ABF_PWR_STATE, &num, sizeof(num))) { + pNxpNfcHalConfig->techAbfPwrState = num; + } + if (GetNxpNumValue(NAME_WTAG_SUPPORT, &num, sizeof(num))) { + pNxpNfcHalConfig->wTagSupport = num; + } + if (GetNxpNumValue(NAME_DEFAULT_T4TNFCEE_AID_POWER_STATE, &num, sizeof(num))) { + pNxpNfcHalConfig->t4tNfceePwrState = num; + } else { + //sete Default power state as Phone off (Low power mode) + pNxpNfcHalConfig->t4tNfceePwrState = 0x02; + } + if (buffer) { + if (GetNxpByteArrayValue(NAME_NXP_PROP_RESET_EMVCO_CMD, (char *)buffer, + bufflen, &retlen)) { + memcpy(pNxpNfcHalConfig->scrResetEmvco.cmd, (char *)buffer, + retlen); + pNxpNfcHalConfig->scrResetEmvco.len = retlen; } free(buffer); buffer = NULL; @@ -3297,19 +3372,23 @@ void phNxpNciHal_getNxpConfig(nfc_nci_IoctlInOutData_t *pInpOutData) { * Returns void. * ******************************************************************************/ -void phNxpNciHal_setNxpTransitConfig(char *transitConfValue) { +bool phNxpNciHal_setNxpTransitConfig(char *transitConfValue) { + bool status = true; NXPLOG_NCIHAL_D("%s : Enter", __func__); std::string transitConfFileName = "/data/vendor/nfc/libnfc-nxpTransit.conf"; if (transitConfValue != NULL) { if (!WriteStringToFile(transitConfValue, transitConfFileName)) { + status = false; NXPLOG_NCIHAL_D("Failed to write transit values in the config values"); } } else { if (remove(transitConfFileName.c_str())) { + status = false; NXPLOG_NCIHAL_D("File deletion failed"); } } NXPLOG_NCIHAL_D("%s : Exit", __func__); + return status; } /****************************************************************************** * Function phNxpNciHal_getVendorConfig @@ -3592,14 +3671,6 @@ int phNxpNciHal_check_ncicmd_write_window(uint16_t cmd_len, uint8_t* p_cmd) { return status; } -void phNxpNciHal_MinCloseForOmapiClose(nfc_nci_IoctlInOutData_t *pInpOutData) { - if ((nxpncihal_ctrl.halStatus == HAL_STATUS_MIN_OPEN) && - (pInpOutData->inp.data.nciCmd.p_cmd[0] == 0x2F) && - (pInpOutData->inp.data.nciCmd.p_cmd[1] == 0x01) && - (pInpOutData->inp.data.nciCmd.p_cmd[3] == 0x00)) { - phNxpNciHal_Minclose(); - } -} /****************************************************************************** * Function phNxpNciHal_getNfcChipId * @@ -3667,404 +3738,22 @@ std::string phNxpNciHal_getNfcFirmwareVersion() { ******************************************************************************/ int phNxpNciHal_ioctl(long arg, void* p_data) { NXPLOG_NCIHAL_D("%s : enter - arg = %ld", __func__, arg); - nfc_nci_IoctlInOutData_t* pInpOutData = (nfc_nci_IoctlInOutData_t*)p_data; + ese_nxp_IoctlInOutData_t* pInpOutData = (ese_nxp_IoctlInOutData_t*)p_data; int ret = -1; - NFCSTATUS status = NFCSTATUS_FAILED; - phNxpNciHal_FwRfupdateInfo_t* FwRfInfo; - NFCSTATUS fm_mw_ver_check = NFCSTATUS_FAILED; - long level; if (nxpncihal_ctrl.halStatus == HAL_STATUS_CLOSE && - (arg != HAL_NFC_IOCTL_ESE_JCOP_DWNLD && arg - != HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE && arg != HAL_ESE_IOCTL_NFC_JCOP_DWNLD)) { + (arg != HAL_ESE_IOCTL_NFC_JCOP_DWNLD)) { NFCSTATUS status = NFCSTATUS_FAILED; status = phNxpNciHal_MinOpen(); if (status != NFCSTATUS_SUCCESS) { - if (arg == HAL_NFC_IOCTL_SPI_DWP_SYNC) { - /* p_rsp[3] is the status for DWP sync response. value 0x00 equals - Success and 0x01 for Fail. */ - pInpOutData->out.data.nciRsp.p_rsp[3] = 0x01; - } return -1; } } switch (arg) { - case HAL_NFC_IOCTL_P61_IDLE_MODE: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_SetP61IdleMode); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_WIRED_MODE: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_SetP61WiredMode); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_PWR_MODE: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_GetP61PwrMode); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) - pInpOutData->out.data.p61CurrentState = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_ENABLE_MODE: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_SetP61EnableMode); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_DISABLE_MODE: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_SetP61DisableMode); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_REL_ESE_PWR: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_ReleaseEsePower); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_SET_ESE_PWR: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_RaiseEsePower); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_GET_ACCESS: - if(nfcFL.nfcNxpEse) { - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_P61_GET_ACCESS timeoutInMillisec = %d", - pInpOutData->inp.data.timeoutMilliSec); - status = phTmlNfc_get_ese_access(gpphTmlNfc_Context->pDevHandle, - pInpOutData->inp.data.timeoutMilliSec); - if (NFCSTATUS_SUCCESS == status) { - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_P61_REL_ACCESS: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_RelP61Access); - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_P61_REL_ACCESS retval = %d\n", status); - pInpOutData->out.data.status = status; - if (NFCSTATUS_SUCCESS == status) { - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_ESE_CHIP_RST: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_IoCtl(phTmlNfc_e_eSEChipRstMode); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_REL_SVDD_WAIT: - if(nfcFL.nfcNxpEse && nfcFL.eseFL._ESE_SVDD_SYNC) { - status = phTmlNfc_rel_svdd_wait(gpphTmlNfc_Context->pDevHandle, - pInpOutData->inp.level); - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_P61_REL_SVDD_WAIT retval = %d\n", - status); - pInpOutData->out.data.status = status; - if (NFCSTATUS_SUCCESS == status) { - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_REL_DWP_WAIT: - if(nfcFL.nfcNxpEse) { - status = phTmlNfc_rel_dwpOnOff_wait(gpphTmlNfc_Context->pDevHandle, - pInpOutData->inp.level); - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_REL_DWP_ON_OFF_WAIT retval = %d\n", - status); - if (NFCSTATUS_SUCCESS == status) { - ret = 0; - } - } - break; - - case HAL_NFC_IOCTL_SET_BOOT_MODE: - if (NULL != p_data) { - status = phNxpNciHal_set_Boot_Mode(pInpOutData->inp.data.bootMode); - if (NFCSTATUS_FAILED != status) { - pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_SET_JCP_DWNLD_ENABLE: - if(nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) { - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_SET_JCP_DWNLD_ENABLE: \n"); - status = phTmlNfc_IoCtl(phTmlNfc_e_SetJcopDwnldEnable); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - case HAL_NFC_IOCTL_SET_JCP_DWNLD_DISABLE: - if(nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) { - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_SET_JCP_DWNLD_DISABLE: \n"); - status = phTmlNfc_IoCtl(phTmlNfc_e_SetJcopDwnldDisable); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - } - break; - - case HAL_NFC_IOCTL_GET_CONFIG_INFO: - if (mGetCfg_info) { - memcpy(pInpOutData->out.data.nxpNciAtrInfo, mGetCfg_info, - sizeof(phNxpNci_getCfg_info_t)); - } else { - NXPLOG_NCIHAL_E("%s : Error! mgetCfg_info is Empty ", __func__); - } - ret = 0; - break; - case HAL_NFC_IOCTL_CHECK_FLASH_REQ: - FwRfInfo = - (phNxpNciHal_FwRfupdateInfo_t*)&pInpOutData->out.data.fwUpdateInf; - status = phNxpNciHal_CheckFwRegFlashRequired(&FwRfInfo->fw_update_reqd, - &FwRfInfo->rf_update_reqd); - if (NFCSTATUS_SUCCESS == status) { - ret = 0; - } - break; - case HAL_NFC_IOCTL_FW_DWNLD: - status = phNxpNciHal_FwDwnld(*(uint16_t*)p_data); - pInpOutData->out.data.fwDwnldStatus = (uint16_t)status; - if (NFCSTATUS_SUCCESS == status) { - ret = 0; - } - if(nfcFL.nfccFL._NFCC_FORCE_FW_DOWNLOAD) { - force_fw_download_req = false; - } - break; - case HAL_NFC_IOCTL_FW_MW_VER_CHECK: - fm_mw_ver_check = phNxpNciHal_fw_mw_ver_check(); - pInpOutData->out.data.fwMwVerStatus = fm_mw_ver_check; - ret = 0; - break; - case HAL_NFC_IOCTL_NCI_TRANSCEIVE: - if (p_data == NULL) { - ret = -1; - break; - } - - if (pInpOutData->inp.data.nciCmd.cmd_len <= 0) { - ret = -1; - break; - } - - ret = phNxpNciHal_send_ext_cmd(pInpOutData->inp.data.nciCmd.cmd_len, - pInpOutData->inp.data.nciCmd.p_cmd); - pInpOutData->out.data.nciRsp.rsp_len = nxpncihal_ctrl.rx_data_len; - if ((nxpncihal_ctrl.rx_data_len > 0) && - (nxpncihal_ctrl.rx_data_len <= MAX_IOCTL_TRANSCEIVE_RESP_LEN) && - (nxpncihal_ctrl.p_rx_data != NULL)) { - memcpy(pInpOutData->out.data.nciRsp.p_rsp, nxpncihal_ctrl.p_rx_data, - nxpncihal_ctrl.rx_data_len); - } - break; - case HAL_NFC_IOCTL_DISABLE_HAL_LOG: - status = phNxpLog_EnableDisableLogLevel(pInpOutData->inp.data.halType); - break; - case HAL_NFC_IOCTL_SET_NFC_SERVICE_PID: - gpphTmlNfc_Context->nfc_service_pid = pInpOutData->inp.data.nfcServicePid; - status = phTmlNfc_IoCtl(phTmlNfc_e_SetNfcServicePid); - if (NFCSTATUS_FAILED != status) { - if (NULL != p_data) pInpOutData->out.data.status = (uint16_t)status; - ret = 0; - } - break; - case HAL_NFC_IOCTL_GET_FEATURE_LIST: - pInpOutData->out.data.chipType = (uint8_t)phNxpNciHal_getChipType(); - ret = 0; - break; -#ifdef ENABLE_ESE_CLIENT case HAL_ESE_IOCTL_NFC_JCOP_DWNLD : - NXPLOG_NCIHAL_D("HAL_ESE_IOCTL_NFC_JCOP_DWNLD Enter value is %d: \n",pInpOutData->inp.data.nciCmd.p_cmd[0]); + NXPLOG_NCIHAL_D("HAL_ESE_IOCTL_NFC_JCOP_DWNLD Enter value is %d: \n",pInpOutData->inp.data.nxpCmd.p_cmd[0]); if(gpEseAdapt != NULL) ret = gpEseAdapt->HalIoctl(HAL_ESE_IOCTL_NFC_JCOP_DWNLD,pInpOutData); [[fallthrough]]; - case HAL_NFC_IOCTL_ESE_JCOP_DWNLD : - eseUpdateSpi = ESE_UPDATE_COMPLETED; - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_ESE_JCOP_DWNLD Enter value is %d: \n",pInpOutData->inp.data.nciCmd.p_cmd[0]); - if(p_nfc_stack_cback_backup != NULL) - { - (*p_nfc_stack_cback_backup)( - (uint32_t)HAL_NFC_HCI_NV_RESET, HAL_NFC_STATUS_OK); - } - ret = 0; - break; - case HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE : - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_ESE_UPDATE_COMPLETE \n"); - if(p_nfc_stack_cback_backup != NULL) - { - (*p_nfc_stack_cback_backup)((uint32_t)HAL_NFC_STATUS_RESTART, - HAL_NFC_STATUS_OK); - } - else - { - NXPLOG_NCIHAL_D("p_nfc_stack_cback_backup cback NULL \n"); - } - ret = 0; - break; -#endif - case HAL_NFC_IOCTL_SPI_DWP_SYNC: { - ALOGD_IF( - nfc_debug_enabled, - "phNxpNciHal_ioctl HAL_NFC_IOCTL_SPI_DWP_SYNC:enter................"); - - if (!nfcFL.eseFL._NXP_SPI_DWP_SYNC) { - ALOGD_IF(nfc_debug_enabled, - "phNxpNciHal_ioctl HAL_NFC_IOCTL_SPI_DWP_SYNC not supported. " - "Returning.."); - ret = 0; - phNxpNciHal_MinCloseForOmapiClose(pInpOutData); - break; - } - ret = phNxpNciHal_send_ese_hal_cmd(pInpOutData->inp.data.nciCmd.cmd_len, - pInpOutData->inp.data.nciCmd.p_cmd); - pInpOutData->out.data.nciRsp.rsp_len = nxpncihal_ctrl.rx_ese_data_len; - if ((nxpncihal_ctrl.rx_ese_data_len > 0) && - (nxpncihal_ctrl.rx_ese_data_len <= MAX_IOCTL_TRANSCEIVE_RESP_LEN) && - (nxpncihal_ctrl.p_rx_ese_data != NULL)) { - memcpy(pInpOutData->out.data.nciRsp.p_rsp, nxpncihal_ctrl.p_rx_ese_data, - nxpncihal_ctrl.rx_ese_data_len); - } - - if (pInpOutData->out.data.nciRsp.p_rsp[0] == 0x4F && - pInpOutData->out.data.nciRsp.p_rsp[1] == 0x01 && - pInpOutData->out.data.nciRsp.p_rsp[2] == 0x01 && - pInpOutData->out.data.nciRsp.p_rsp[3] == 0x00 && - pInpOutData->inp.data.nciCmd.p_cmd[3] == 0x01) { - NXPLOG_NCIHAL_D("OMAPI COMMAND for Open SUCCESS : 0x%x", - pInpOutData->out.data.nciRsp.p_rsp[3]); - ret = pInpOutData->out.data.nciRsp.p_rsp[3]; - } else if (pInpOutData->out.data.nciRsp.p_rsp[0] == 0x4F && - pInpOutData->out.data.nciRsp.p_rsp[1] == 0x01 && - pInpOutData->out.data.nciRsp.p_rsp[2] == 0x01 && - pInpOutData->out.data.nciRsp.p_rsp[3] == 0x00 && - pInpOutData->inp.data.nciCmd.p_cmd[3] == 0x00) - { - NXPLOG_NCIHAL_D("OMAPI COMMAND for Close SUCCESS : 0x%x", - pInpOutData->out.data.nciRsp.p_rsp[3]); - ret = pInpOutData->out.data.nciRsp.p_rsp[3]; - } else if (pInpOutData->out.data.nciRsp.p_rsp[0] == 0x4F && - pInpOutData->out.data.nciRsp.p_rsp[1] == 0x01 && - pInpOutData->out.data.nciRsp.p_rsp[2] == 0x01 && - pInpOutData->out.data.nciRsp.p_rsp[3] == 0x00 && - pInpOutData->inp.data.nciCmd.p_cmd[3] == 0x02) { - NXPLOG_NCIHAL_D("OMAPI COMMAND for Switch Allowed SUCCESS : 0x%x", - pInpOutData->out.data.nciRsp.p_rsp[3]); - ret = pInpOutData->out.data.nciRsp.p_rsp[3]; - phNxpNciHal_notifyHciEvtProcessComplete(); - } else { - NXPLOG_NCIHAL_D("OMAPI COMMAND FAILURE : 0x%x", - pInpOutData->out.data.nciRsp.p_rsp[3]); - ret = pInpOutData->out.data.nciRsp.p_rsp[3] = - 3; // magic number for omapi failure - } - phNxpNciHal_MinCloseForOmapiClose(pInpOutData); - } break; - case HAL_NFC_SET_SPM_PWR: - level = pInpOutData->inp.level; - if (nfcFL.chipType == pn557) { - /*set a bit to indicate signal trigger from driver is not required for PN557*/ - level |= SIGNAL_TRIGGER_NOT_REQD; - ret = phPalEse_spi_ioctl(phPalEse_e_ChipRst, - gpphTmlNfc_Context->pDevHandle, level); - } else { - ret = NFCSTATUS_FEATURE_NOT_SUPPORTED; - } - break; - case HAL_NFC_SET_POWER_SCHEME: - level = pInpOutData->inp.level; - ret = phPalEse_spi_ioctl(phPalEse_e_SetPowerScheme, - gpphTmlNfc_Context->pDevHandle, level); - break; - case HAL_NFC_GET_SPM_STATUS: - level = pInpOutData->inp.level; - ret = phPalEse_spi_ioctl(phPalEse_e_GetSPMStatus, - gpphTmlNfc_Context->pDevHandle, level); - break; - case HAL_NFC_GET_ESE_ACCESS: - level = pInpOutData->inp.level; - ret = phPalEse_spi_ioctl(phPalEse_e_GetEseAccess, - gpphTmlNfc_Context->pDevHandle, level); - break; - case HAL_NFC_SET_DWNLD_STATUS: - level = pInpOutData->inp.level; - ret = 0; - break; - case HAL_NFC_IOCTL_RF_STATUS_UPDATE: - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_RF_STATUS_UPDATE Enter value is %d: \n", - pInpOutData->inp.data.nciCmd.p_cmd[0]); -#ifdef ENABLE_ESE_CLIENT - if (gpEseAdapt != NULL) - gpEseAdapt->HalNfccNtf(HAL_NFC_IOCTL_RF_STATUS_UPDATE, pInpOutData); -#endif - ret = 0; - break; - case HAL_NFC_IOCTL_RF_ACTION_NTF: - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_RF_ACTION_NTF"); -#ifdef ENABLE_ESE_CLIENT - if (gpEseAdapt != NULL) - gpEseAdapt->HalNfccNtf(HAL_NFC_IOCTL_RF_ACTION_NTF, pInpOutData); -#endif - ret = 0; - break; - case HAL_NFC_GET_NXP_CONFIG: - phNxpNciHal_getNxpConfig(pInpOutData); - ret = 0; - break; - case HAL_NFC_IOCTL_SET_TRANSIT_CONFIG: - phNxpNciHal_setNxpTransitConfig( - pInpOutData->inp.data.transitConfig.val); - ret = 0; - break; - case HAL_NFC_IOCTL_NFCEE_SESSION_RESET: - phNxpNciHal_reset_nfcee_session(true); - ret = 0; - break; - case HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE: - nxpncihal_ctrl.isHciCfgEvtRequested = true; - NXPLOG_NCIHAL_D("HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE value is %d: \n", - pInpOutData->inp.data.nciCmd.p_cmd[0]); -#ifdef ENABLE_ESE_CLIENT - if (gpEseAdapt != NULL) - gpEseAdapt->HalNfccNtf(HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE, pInpOutData); -#endif - ret = 0; - break; - case HAL_NFC_IOCTL_HCI_INIT_STATUS_UPDATE_COMPLETE: - phNxpNciHal_notifyHciEvtProcessComplete(); - break; default: NXPLOG_NCIHAL_E("%s : Wrong arg = %ld", __func__, arg); break; @@ -4781,23 +4470,6 @@ static void phNxpNciHal_print_res_status(uint8_t* p_rx_data, uint16_t* p_len) { } } } -/****************************************************************************** - * Function phNxpNciHal_set_Boot_Mode - * - * Description This function is called to set hal - * boot mode. This can be normal nfc boot - * or fast boot.The param mode can take the - * following values. - * NORAML_NFC_MODE = 0 FAST_BOOT_MODE = 1 - * - * - * Returns void. - * - ******************************************************************************/ -NFCSTATUS phNxpNciHal_set_Boot_Mode(uint8_t mode) { - nxpncihal_ctrl.hal_boot_mode = mode; - return NFCSTATUS_SUCCESS; -} /***************************************************************************** * Function phNxpNciHal_send_get_cfgs @@ -5017,3 +4689,338 @@ static void phNxpNciHal_notifyHciEvtProcessComplete() { (uint32_t)HAL_NFC_CONFIG_ESE_LINK_COMPLETE, HAL_NFC_STATUS_OK); } } + +/****************************************************************************** + * Function phNxpNciHal_setEseState + * + * Description This function is called for to update ese state + * + * Returns void. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_setEseState(phNxpNfcHalEseState eSEstate){ + NXPLOG_NCIHAL_D("%s Enter ", __func__); + NFCSTATUS status = NFCSTATUS_FAILED; + + if(eSEstate == phNxpNciHalNfc_e_SetIdleMode) + status = phTmlNfc_IoCtl(phTmlNfc_e_SetP61IdleMode); + + if(eSEstate == phNxpNciHalNfc_e_SetWiredMode) + status = phTmlNfc_IoCtl(phTmlNfc_e_SetP61WiredMode); + + return status; +} + + +/******************************************************************************* + ** + ** Function phNxpHal_getchipType + ** + ** Description Gets the chipType from hal which is already configured + ** during init time. + ** + ** Returns chipType + *******************************************************************************/ +uint8_t phNxpHal_getchipType() +{ + uint8_t phNxpNciHal_chiptype; + NXPLOG_NCIHAL_D("%s Enter ", __func__); + phNxpNciHal_chiptype = (uint8_t)phNxpNciHal_getChipType(); + + return phNxpNciHal_chiptype; +} + +/******************************************************************************* +** +** Function phNxpNciHal_setNfcServicePid +** +** Description This function request to pn54x driver to +** update NFC service process ID for signalling. +** +** Returns 0 if api call success, else -1 +** +*******************************************************************************/ +uint16_t phNxpNciHal_setNfcServicePid(uint64_t phNxpNfcHalpid) +{ + NXPLOG_NCIHAL_D("%s Enter ", __func__); + NFCSTATUS status = NFCSTATUS_FAILED; + gpphTmlNfc_Context->nfc_service_pid = phNxpNfcHalpid; + status = phTmlNfc_IoCtl(phTmlNfc_e_SetNfcServicePid); + + return status; +} + +/****************************************************************************** + * Function phNxpNciHal_getEseState + * + * Description This function is called for to get ese state + * + * Returns void. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_getEseState(){ + NXPLOG_NCIHAL_D("%s Enter ", __func__); + NFCSTATUS status = NFCSTATUS_FAILED; + status = phTmlNfc_IoCtl(phTmlNfc_e_GetP61PwrMode); + return status; +} + +/****************************************************************************** + * Function phNxpNciHal_initialize_mifare_flag + * + * Description This function gets the value for Mfc flags. + * + * Returns void + * + ******************************************************************************/ +static void phNxpNciHal_initialize_mifare_flag() { + unsigned long num = 0; + bEnableMfcReader = false; + bDisableLegacyMfcExtns = false; + //1: Enable Mifare Classic protocol in RF Discovery. + //0: Remove Mifare Classic protocol in RF Discovery. + if(GetNxpNumValue(NAME_MIFARE_READER_ENABLE, &num, sizeof(num))) { + bEnableMfcReader = (num == 0) ? false : true; + } + //1: Use legacy JNI MFC extns. + //0: Disable legacy JNI MFC extns, use hal MFC Extns instead. + if(GetNxpNumValue(NAME_LEGACY_MIFARE_READER, &num, sizeof(num))) { + bDisableLegacyMfcExtns = (num == 0) ? true : false; + } +} + +/****************************************************************************** + * Function phNxpNciHal_ReleaseSVDDWait + * + * Description This function release wait for svdd change + * of P61. + * + * Returns NFCSTATUS. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_ReleaseSVDDWait(uint32_t level){ + NFCSTATUS status = NFCSTATUS_FAILED; + NXPLOG_NCIHAL_D("%s Enter ", __func__); + + if(nfcFL.nfcNxpEse && nfcFL.eseFL._ESE_SVDD_SYNC) { + status = phTmlNfc_rel_svdd_wait(gpphTmlNfc_Context->pDevHandle, + level); + NXPLOG_NCIHAL_D("phTmlNfc_rel_svdd_wait retval = %d\n", + status); + } + NXPLOG_NCIHAL_D("%s Exit ", __func__); + + return status; +} + +/****************************************************************************** + * Function phNxpNciHal_ReleaseDWPOnOffWait + * + * Description This function release wait for DWP On/Off + * of P73. output returned as Status + * Returns NFCSTATUS. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_ReleaseDWPOnOffWait(uint32_t level){ + NFCSTATUS status = NFCSTATUS_FAILED; + NXPLOG_NCIHAL_D("%s Enter ", __func__); + + if(nfcFL.nfcNxpEse) { + status = phTmlNfc_rel_dwpOnOff_wait(gpphTmlNfc_Context->pDevHandle, + level); + NXPLOG_NCIHAL_D("phNxpNciHal_ReleaseDWPWait retval = %d\n", + status); + } + + NXPLOG_NCIHAL_D("%s Exit ", __func__); + return status; +} + +/****************************************************************************** + * Function phNxpNciHal_getSPMStatus + * + * Description This function gets the SPM state before FW download + * + * Returns 0 as success -1 as failed. + * + *******************************************************************************/ +int phNxpNciHal_getSPMStatus(uint32_t level){ + int ret = -1; + NXPLOG_NCIHAL_D("%s Enter ", __func__); + + ret = phPalEse_spi_ioctl(phPalEse_e_GetSPMStatus, + gpphTmlNfc_Context->pDevHandle, level); + + NXPLOG_NCIHAL_D("%s Exit ", __func__); + return ret; +} + +/****************************************************************************** + * Function phNxpNciHal_hciInitUpdateState + * + * Description This function Sends HCI Events to nfc HAL + * + * Returns 0 as success -1 as failed. + * + *******************************************************************************/ +int32_t phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus HciStatus){ + int ret = -1; + ese_nxp_IoctlInOutData_t InpOutData; + NXPLOG_NCIHAL_D("%s Enter ", __func__); + + nxpncihal_ctrl.isHciCfgEvtRequested = true; + InpOutData.inp.data.nxpCmd.p_cmd[0] = HciStatus; + NXPLOG_NCIHAL_D("phNxpNciHal_hciInitUpdateState value is %d: \n", + InpOutData.inp.data.nxpCmd.p_cmd[0]); + if (gpEseAdapt != NULL) + gpEseAdapt->HalNfccNtf(HAL_ESE_IOCTL_HCI_INIT_STATUS_UPDATE, &InpOutData); + + NXPLOG_NCIHAL_D("%s Exit ", __func__); + return ret; +} + +/****************************************************************************** + * Function phNxpNciHal_hciInitUpdateStateComplete + * + * Description This function posts event HAL_NFC_CONFIG_ESE_LINK_COMPLETE + * + * Returns void. + * + *******************************************************************************/ +int32_t phNxpNciHal_hciInitUpdateStateComplete(){ + int32_t ret = 0; + NXPLOG_NCIHAL_D("%s Enter ", __func__); + + phNxpNciHal_notifyHciEvtProcessComplete(); + + NXPLOG_NCIHAL_D("%s Exit ", __func__); + return ret; +} + +/****************************************************************************** + * Function phNxpNciHal_GetCachedNfccConfig + * + * Description This function receives the cached configinfo. + * + * Returns void. + * + *******************************************************************************/ +void phNxpNciHal_GetCachedNfccConfig(phNxpNci_getCfg_info_t *pGetCfg_info){ + + NXPLOG_NCIHAL_D("%s Enter ", __func__); + + if (mGetCfg_info && pGetCfg_info != NULL) { + memcpy(pGetCfg_info, mGetCfg_info, + sizeof(phNxpNci_getCfg_info_t)); + } else { + NXPLOG_NCIHAL_E("%s : Error! mgetCfg_info is Empty ", __func__); + } + + NXPLOG_NCIHAL_D("%s Exit ", __func__); +} + +/******************************************************************************* +** +** Function phNxpNciHal_resetEse +** +** Description It shall be used to reset eSE by proprietary command. +** +** Parameters +** +** Returns status of eSE reset response +*******************************************************************************/ +NFCSTATUS phNxpNciHal_resetEse() { + NFCSTATUS status = NFCSTATUS_FAILED; + int level = 0; + NXPLOG_NCIHAL_D("%s Entry ", __func__); + if (nfcFL.chipType == pn557) { + /*set a bit to indicate signal trigger from driver is not required for PN557*/ + level = (uint64_t)Constants::HAL_NFC_ESE_HARD_RESET | SIGNAL_TRIGGER_NOT_REQD; + status = phPalEse_spi_ioctl(phPalEse_e_ChipRst, + gpphTmlNfc_Context->pDevHandle, level); + if(status == NFCSTATUS_SUCCESS) { + ALOGD("HAL_NFC_ESE_HARD_RESET completed"); + } else { + ALOGD("HAL_NFC_ESE_HARD_RESET failed"); + } + } else { + ALOGD("ESE Reset Feature not supported"); + } + + return status; +} + +void seteSEClientState(uint8_t state) { + DwpEseUpdater::setSpiEseClientState(state); +} + +/****************************************************************************** +** Function phNxpNciHal_Abort +** +** Description This function shall be used to trigger the abort +** +** Parameters None +** +** Returns bool. +** +*******************************************************************************/ +bool phNxpNciHal_Abort() { + bool ret = true; + + NXPLOG_NCIHAL_D("phNxpNciHal_Abort aborting. \n"); + /* When JCOP download is triggered phNxpNciHal_open is blocked, in this case only + we need to abort the libnfc , this can be done only by check the p_nfc_stack_cback_backup + pointer which is assigned before the JCOP download.*/ + if (p_nfc_stack_cback_backup != NULL){ + abort(); + } + else { + ret = false; + NXPLOG_NCIHAL_D("phNxpNciHal_Abort not triggered\n"); + } + return ret; +} + +bool getJcopUpdateRequired() { return false; } + +bool getLsUpdateRequired() { return false; } + +string phNxpNciHal_getSystemProperty(string key) { key = ""; return key; } + +bool phNxpNciHal_setSystemProperty(string key, string value) { key = value = ""; return false; } + +void eSEClientUpdate_NFC_Thread() { + DwpEseUpdater::eSEClientUpdate_NFC_Thread(); +} + +/****************************************************************************** + * Function phNxpNciHal_nciTransceive + * + * Description This function does tarnsceive of nci command + * + * Returns void. + * + *******************************************************************************/ +void phNxpNciHal_nciTransceive(phNxpNci_Extn_Cmd_t *in, phNxpNci_Extn_Resp_t *out){ + uint32_t status = 0; + NXPLOG_NCIHAL_D("%s Enter ", __func__); + + if (in == NULL ||(in->cmd_len <= 0) || out == NULL) { + return; + } + + status = phNxpNciHal_send_ext_cmd(in->cmd_len, + in->p_cmd); + out->rsp_len = nxpncihal_ctrl.rx_data_len; + if ((nxpncihal_ctrl.rx_data_len > 0) && + (nxpncihal_ctrl.rx_data_len <= MAX_IOCTL_TRANSCEIVE_RESP_LEN) && + (nxpncihal_ctrl.p_rx_data != NULL)) { + memcpy(out->p_rsp, nxpncihal_ctrl.p_rx_data, + nxpncihal_ctrl.rx_data_len); + } + + out->status = status; + + NXPLOG_NCIHAL_D("%s Exit ", __func__); + return; +} diff --git a/halimpl/hal/phNxpNciHal.h b/halimpl/hal/phNxpNciHal.h index 87acaaa..1cea407 100644 --- a/halimpl/hal/phNxpNciHal.h +++ b/halimpl/hal/phNxpNciHal.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2019 NXP Semiconductors + * Copyright (C) 2015-2020 NXP Semiconductors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,19 +16,22 @@ #ifndef _PHNXPNCIHAL_H_ #define _PHNXPNCIHAL_H_ +#include "NxpMfcReader.h" #include <hardware/nfc.h> #include <phNxpNciHal_utils.h> #include "NxpNfcCapability.h" -#include "hal_nxpnfc.h" -#ifdef ENABLE_ESE_CLIENT +#include <vendor/nxp/hardware/nfc/2.0/types.h> +#include "DwpEseUpdater.h" #include "EseUpdateChecker.h" -#endif + +using namespace std; /********************* Definitions and structures *****************************/ #define MAX_RETRY_COUNT 5 #define NCI_MAX_DATA_LEN 300 #define NCI_POLL_DURATION 500 #define HAL_NFC_ENABLE_I2C_FRAGMENTATION_EVT 0x07 +#define HAL_NFC_POST_MIN_INIT_CPLT_EVT 0x09 #define NXP_STAG_TIMEOUT_BUF_LEN 0x04 /*FIXME:TODO:remove*/ #define NXP_WIREDMODE_RESUME_TIMEOUT_LEN 0x04 #define NFCC_DECIDES 00 @@ -75,6 +78,10 @@ typedef void(phNxpNciHal_control_granted_callback_t)(); #define NCI_OID_MASK 0x3F #define NXP_MAX_CONFIG_STRING_LEN 260 +#define NCI_HEADER_SIZE 3 + +#define MAX_IOCTL_TRANSCEIVE_CMD_LEN 256 +#define MAX_IOCTL_TRANSCEIVE_RESP_LEN 256 typedef struct nci_data { uint16_t len; @@ -95,6 +102,13 @@ typedef enum { GPIO_CLEAR = 0xFF } phNxpNciHal_GpioInfoState; +enum NxpNfcHalStatus { + /** In case of an error, HCI network needs to be re-initialized */ + HAL_NFC_STATUS_RESTART = 0x30, + HAL_NFC_HCI_NV_RESET = 0x40, + HAL_NFC_CONFIG_ESE_LINK_COMPLETE = 0x50 +}; + typedef struct phNxpNciGpioInfo { phNxpNciHal_GpioInfoState state; uint8_t values[2]; @@ -200,9 +214,31 @@ typedef enum { EEPROM_ESE_SESSION_ID, EEPROM_SWP1_INTF, EEPROM_SWP1A_INTF, - EEPROM_SWP2_INTF + EEPROM_SWP2_INTF, + EEPROM_NDEF_INTF_CFG } phNxpNci_EEPROM_request_type_t; +typedef enum { + phNxpNciHalNfc_e_SetIdleMode, /* Set the current mode of operation to Idle*/ + phNxpNciHalNfc_e_SetWiredMode, /* Set the current mode of operation to Wired*/ +} phNxpNfcHalEseState; + +typedef enum { + phNxpNfcHciInitStatus_e_Complete = 0x00, + phNxpNfcHciInitStatus_e_Start = 0x01 +} phNxpNfcHciInitStatus; + +typedef struct phNxpNci_Extn_Cmd{ + uint16_t cmd_len; + uint8_t p_cmd[MAX_IOCTL_TRANSCEIVE_CMD_LEN]; +}phNxpNci_Extn_Cmd_t; + +typedef struct phNxpNci_Extn_Resp{ + uint32_t status; + uint16_t rsp_len; + uint8_t p_rsp[MAX_IOCTL_TRANSCEIVE_RESP_LEN]; +}phNxpNci_Extn_Resp_t; + typedef struct phNxpNci_EEPROM_info { uint8_t request_mode; phNxpNci_EEPROM_request_type_t request_type; @@ -243,6 +279,60 @@ typedef struct phNxpNciProfile_Control { uint8_t bTimeout; /* Holds the Timeout Value */ } phNxpNciProfile_Control_t; +struct phNxpNfcScrResetEmvcoCmd{ + uint64_t len; + uint8_t cmd[10]; +}; + +struct phNxpNfcHalConfig { + uint8_t ese_listen_tech_mask; + uint8_t default_nfcee_disc_timeout; + uint8_t default_nfcee_timeout; + uint8_t ese_wired_prt_mask; + uint8_t uicc_wired_prt_mask; + uint8_t wired_mode_rf_field_enable; + uint8_t aid_block_route; + uint8_t esePowerDhControl; + uint8_t tagOpTimeout; + uint8_t loaderServiceVersion; + uint8_t defaultNfceeDiscTimeout; + uint8_t dualUiccEnable; + uint8_t ceRouteStrictDisable; + uint32_t osDownloadTimeoutValue; + uint8_t defaultAidRoute; + uint8_t defaultAidPwrState; + uint8_t defaultRoutePwrState; + uint8_t defaultOffHostPwrState; + uint8_t jcopDlAtBootEnable; + uint8_t defaultNfceeTimeout; + uint8_t nxpNfcChip; + uint8_t coreScrnOffAutonomousEnable; + uint8_t p61LsDefaultInterface; + uint8_t p61JcopDefaultInterface; + uint8_t agcDebugEnable; + uint8_t felicaCltPowerState; + uint32_t cmdRspTimeoutValue; + uint8_t checkDefaultProtoSeId; + uint8_t nfccPassiveListenTimeout; + uint32_t nfccStandbyTimeout; + uint32_t wmMaxWtxCount; + uint32_t nfccRfFieldEventTimeout; + uint8_t allowWiredInMifareDesfireClt; + uint8_t dwpIntfResetEnable; + uint8_t nxpLogHalLoglevel; + uint8_t nxpLogExtnsLogLevel; + uint8_t nxpLogTmlLogLevel; + uint8_t nxpLogFwDnldLogLevel; + uint8_t nxpLogNcixLogLevel; + uint8_t nxpLogNcirLogLevel; + uint8_t scrCfgFormat; + uint8_t etsiReaderEnable; + uint8_t techAbfRoute; + uint8_t techAbfPwrState; + uint8_t wTagSupport; + uint8_t t4tNfceePwrState; + phNxpNfcScrResetEmvcoCmd scrResetEmvco; +}; /* Internal messages to handle callbacks */ #define NCI_HAL_OPEN_CPLT_MSG 0x411 #define NCI_HAL_CLOSE_CPLT_MSG 0x412 @@ -264,6 +354,13 @@ NFCSTATUS phNxpNciHal_send_get_cfgs(); int phNxpNciHal_write_unlocked(uint16_t data_len, const uint8_t* p_data); NFCSTATUS request_EEPROM(phNxpNci_EEPROM_info_t* mEEPROM_info); NFCSTATUS phNxpNciHal_send_nfcee_pwr_cntl_cmd(uint8_t type); +string phNxpNciHal_getSystemProperty(string key); +bool phNxpNciHal_setSystemProperty(string key, string value); +void seteSEClientState(uint8_t state); +void eSEClientUpdate_NFC_Thread(); +bool phNxpNciHal_Abort(); +bool getJcopUpdateRequired(); +bool getLsUpdateRequired(); /******************************************************************************* ** @@ -302,15 +399,141 @@ tNFC_chipType phNxpNciHal_getChipType(); ** ** Returns none *******************************************************************************/ -void phNxpNciHal_getNxpConfig(nfc_nci_IoctlInOutData_t *pInpOutData); +void phNxpNciHal_getNxpConfig(phNxpNfcHalConfig *pNxpNfcHalConfig); /****************************************************************************** * Function phNxpNciHal_getNxpTransitConfig * * Description This function overwrite libnfc-nxpTransit.conf file * with transitConfValue. * - * Returns void. + * Returns status. * ******************************************************************************/ -void phNxpNciHal_setNxpTransitConfig(char *transitConfValue); +bool phNxpNciHal_setNxpTransitConfig(char *transitConfValue); #endif /* _PHNXPNCIHAL_H_ */ + +/****************************************************************************** + * Function phNxpNciHal_setEseState + * + * Description This function is called for to update ese state + * + * Returns void. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_setEseState(phNxpNfcHalEseState eSEstate); + +/******************************************************************************* + ** + ** Function phNxpNciHal_getchipType + ** + ** Description Gets the chipType from hal which is already configured + ** during init time. + ** + ** Returns chipType + *******************************************************************************/ +uint8_t phNxpHal_getchipType(); + +/******************************************************************************* +** +** Function phNxpNciHal_setNfcServicePid +** +** Description This function request to pn54x driver to +** update NFC service process ID for signalling. +** +** Returns 0 if api call success, else -1 +** +*******************************************************************************/ +uint16_t phNxpNciHal_setNfcServicePid(uint64_t pid); + +/****************************************************************************** + * Function phNxpNciHal_getEseState + * + * Description This function is called for to get ese state + * + * Returns void. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_getEseState(); + +/****************************************************************************** + * Function phNxpNciHal_ReleaseSVDDWait + * + * Description This function release wait for svdd change + * of P61. + * + * Returns NFCSTATUS. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_ReleaseSVDDWait(uint32_t level); + +/****************************************************************************** + * Function phNxpNciHal_ReleaseDWPOnOffWait + * + * Description This function release wait for DWP On/Off + * of P73. output returned as Status + * Returns NFCSTATUS. + * + ******************************************************************************/ +NFCSTATUS phNxpNciHal_ReleaseDWPOnOffWait(uint32_t level); + +/****************************************************************************** + * Function phNxpNciHal_getSPMStatus + * + * Description This function gets the SPM state before FW download + * + * Returns 0 as success -1 as failed. + * + *******************************************************************************/ +int phNxpNciHal_getSPMStatus(uint32_t level); + +/****************************************************************************** + * Function phNxpNciHal_hciInitUpdateState + * + * Description This function Sends HCI Events to nfc HAL + * + * Returns 0 as success -1 as failed. + * + *******************************************************************************/ +int32_t phNxpNciHal_hciInitUpdateState(phNxpNfcHciInitStatus HciStatus); + +/****************************************************************************** + * Function phNxpNciHal_hciInitUpdateStateComplete + * + * Description This function posts event HAL_NFC_CONFIG_ESE_LINK_COMPLETE + * + * Returns 0 as success -1 as failed.. + * + *******************************************************************************/ +int32_t phNxpNciHal_hciInitUpdateStateComplete(); + +/****************************************************************************** + * Function phNxpNciHal_GetCachedNfccConfig + * + * Description This function receives the cached configinfo. + * + * Returns void. + * + *******************************************************************************/ +void phNxpNciHal_GetCachedNfccConfig(phNxpNci_getCfg_info_t *pGetCfg_info); + +/******************************************************************************* +** +** Function phNxpNciHal_resetEse +** +** Description It shall be used to to reset eSE by proprietary command. +** +** Parameters None +** +** Returns status of eSE reset response +*******************************************************************************/ +NFCSTATUS phNxpNciHal_resetEse(); + +/****************************************************************************** + * Function phNxpNciHal_nciTransceive + * + * Description This function does tarnsceive of nci command + * + * Returns void. + * + *******************************************************************************/ +void phNxpNciHal_nciTransceive(phNxpNci_Extn_Cmd_t *in, phNxpNci_Extn_Resp_t *out); diff --git a/halimpl/hal/phNxpNciHal_ext.cc b/halimpl/hal/phNxpNciHal_ext.cc index 89dc5ab..92cfa65 100644 --- a/halimpl/hal/phNxpNciHal_ext.cc +++ b/halimpl/hal/phNxpNciHal_ext.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015-2018 NXP Semiconductors + * Copyright (C) 2015-2019 NXP Semiconductors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,22 +13,19 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include "hal_nxpnfc.h" -#include <phNxpNciHal_ext.h> -#include <phNxpNciHal.h> +#include "phNxpNciHal_nciParser.h" +#include <cutils/properties.h> #include <log/log.h> -#include <phTmlNfc.h> #include <phDal4Nfc_messageQueueLib.h> -#include <phNxpNciHal_NfcDepSWPrio.h> -#include <phNxpLog.h> -#include <phNxpConfig.h> #include <phDnldNfc.h> -#include "phNxpNciHal_nciParser.h" -#include <cutils/properties.h> -#ifdef ENABLE_ESE_CLIENT -#include "hal_nxpese.h" -#endif +#include <phNxpConfig.h> +#include <phNxpLog.h> +#include <phNxpNciHal.h> #include <phNxpNciHal_Adaptation.h> +#include <phNxpNciHal_NfcDepSWPrio.h> +#include <phNxpNciHal_ext.h> +#include <phTmlNfc.h> +#include <EseAdaptation.h> /* Timeout value to wait for response from PN548AD */ #define HAL_EXTNS_WRITE_RSP_TIMEOUT (2500) @@ -39,12 +36,15 @@ extern phNxpNciHal_Control_t nxpncihal_ctrl; extern phNxpNciProfile_Control_t nxpprofile_ctrl; extern phNxpNci_getCfg_info_t* mGetCfg_info; - +extern EseAdaptation *gpEseAdapt; extern uint32_t cleanup_timer; uint8_t icode_detected = 0x00; uint8_t icode_send_eof = 0x00; static uint8_t ee_disc_done = 0x00; uint8_t EnableP2P_PrioLogic = false; +extern bool bEnableMfcExtns; +extern bool bEnableMfcReader; +extern bool bDisableLegacyMfcExtns; static uint32_t RfDiscID = 1; static uint32_t RfProtocolType = 4; /* NFCEE Set mode */ @@ -108,15 +108,18 @@ void phNxpNciHal_ext_init(void) { ** *******************************************************************************/ void phNxpNciHal_sendRfEvtToEseHal(uint8_t rfEvtType) { - nfc_nci_IoctlInOutData_t inpOutData; + ese_nxp_IoctlInOutData_t inpOutData; + gpEseAdapt = &EseAdaptation::GetInstance(); + gpEseAdapt->Initialize(); uint8_t rf_state_update[] = {0x00}; - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = sizeof(rf_state_update); + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); + inpOutData.inp.data.nxpCmd.cmd_len = sizeof(rf_state_update); rf_state_update[0] = rfEvtType; - memcpy(inpOutData.inp.data.nciCmd.p_cmd, rf_state_update, + memcpy(inpOutData.inp.data.nxpCmd.p_cmd, rf_state_update, sizeof(rf_state_update)); inpOutData.inp.data_source = 2; - phNxpNciHal_ioctl(HAL_NFC_IOCTL_RF_STATUS_UPDATE, &inpOutData); + if (gpEseAdapt != NULL) + gpEseAdapt->HalNfccNtf(HAL_ESE_IOCTL_RF_STATUS_UPDATE, &inpOutData); } /******************************************************************************* @@ -131,7 +134,8 @@ void phNxpNciHal_sendRfEvtToEseHal(uint8_t rfEvtType) { NFCSTATUS phNxpNciHal_process_ext_rsp(uint8_t* p_ntf, uint16_t* p_len) { NFCSTATUS status = NFCSTATUS_SUCCESS; uint16_t rf_technology_length_param = 0; - + gpEseAdapt = &EseAdaptation::GetInstance(); + gpEseAdapt->Initialize(); /*parse and decode LxDebug Notifications*/ if(p_ntf[0] == 0x6F && (p_ntf[1] == 0x35 || p_ntf[1] == 0x36)) { @@ -185,7 +189,20 @@ NFCSTATUS phNxpNciHal_process_ext_rsp(uint8_t* p_ntf, uint16_t* p_len) { status = NFCSTATUS_SUCCESS; + if (bDisableLegacyMfcExtns && bEnableMfcExtns && p_ntf[0] == 0) { + uint16_t extlen; + extlen = *p_len - NCI_HEADER_SIZE; + NxpMfcReaderInstance.AnalyzeMfcResp(&p_ntf[3], &extlen); + p_ntf[2] = extlen; + *p_len = extlen + NCI_HEADER_SIZE; + } + if (p_ntf[0] == 0x61 && p_ntf[1] == 0x05) { + bEnableMfcExtns = false; + if (bDisableLegacyMfcExtns && p_ntf[4] == 0x80 && p_ntf[5] == 0x80) { + bEnableMfcExtns = true; + NXPLOG_NCIHAL_D("NxpNci: RF Interface = Mifare Enable MifareExtns"); + } switch (p_ntf[4]) { case 0x00: NXPLOG_NCIHAL_D("NxpNci: RF Interface = NFCEE Direct RF"); @@ -346,12 +363,13 @@ NFCSTATUS phNxpNciHal_process_ext_rsp(uint8_t* p_ntf, uint16_t* p_len) { NXPLOG_NCIHAL_D("RF_STATUS_UPDATE_ENABLE : %lu", rf_update_enable); } if (rf_update_enable == 0x01) { - nfc_nci_IoctlInOutData_t inpOutData; - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = p_ntf[2]; - memcpy(inpOutData.inp.data.nciCmd.p_cmd, p_ntf + 3, p_ntf[2]); + ese_nxp_IoctlInOutData_t inpOutData; + memset(&inpOutData, 0x00, sizeof(ese_nxp_IoctlInOutData_t)); + inpOutData.inp.data.nxpCmd.cmd_len = p_ntf[2]; + memcpy(inpOutData.inp.data.nxpCmd.p_cmd, p_ntf + 3, p_ntf[2]); inpOutData.inp.data_source = 2; - phNxpNciHal_ioctl(HAL_NFC_IOCTL_RF_ACTION_NTF, &inpOutData); + if (gpEseAdapt != NULL) + gpEseAdapt->HalNfccNtf(HAL_ESE_IOCTL_RF_ACTION_NTF, &inpOutData); } } @@ -380,6 +398,11 @@ if(nfcFL.nfccFL._NFCC_FORCE_NCI1_0_INIT == true) { p_ntf[3] == 0x02 && nxpncihal_ctrl.is_wait_for_ce_ntf) { NXPLOG_NCIHAL_D("CORE_RESET_NTF 2 reason Command received !"); int len = p_ntf[2] + 2; /*include 2 byte header*/ + if(len != *p_len - 1) { + NXPLOG_NCIHAL_E("phNxpNciHal_ext_process_nfc_init_rsp invalid NTF length"); + android_errorWriteLog(0x534e4554, "121263487"); + return NFCSTATUS_FAILED; + } wFwVerRsp = (((uint32_t)p_ntf[len - 2]) << 16U) | (((uint32_t)p_ntf[len - 1]) << 8U) | p_ntf[len]; iCoreRstNtfLen = *p_len; @@ -402,7 +425,7 @@ if(nfcFL.nfccFL._NFCC_FORCE_NCI1_0_INIT == true) { /*Retreive reset ntf reason code irrespective of NCI 1.0 or 2.0*/ if (p_ntf[0] == 0x60 && p_ntf[1] == 0x00 ){ if ( p_ntf[3] == FW_DBG_REASON_AVAILABLE) - property_set("persist.nfc.core_reset_debug_info", "true"); + property_set("persist.vendor.nfc.core_reset_debug_info", "true"); } } @@ -421,6 +444,11 @@ if (((nfcFL.nfccFL._NFCC_FORCE_NCI1_0_INIT) && phNxpNciHal_configFeatureList(p_ntf,*p_len); } int len = p_ntf[2] + 2; /*include 2 byte header*/ + if(len != *p_len - 1) { + NXPLOG_NCIHAL_E("phNxpNciHal_ext_process_nfc_init_rsp invalid NTF length"); + android_errorWriteLog(0x534e4554, "121263487"); + return NFCSTATUS_FAILED; + } wFwVerRsp = (((uint32_t)p_ntf[len - 2]) << 16U) | (((uint32_t)p_ntf[len - 1]) << 8U) | p_ntf[len]; if (wFwVerRsp == 0) status = NFCSTATUS_FAILED; @@ -515,8 +543,7 @@ static NFCSTATUS phNxpNciHal_ext_process_nfc_init_rsp(uint8_t* p_ntf, uint16_t* nxpncihal_ctrl.nci_info.nci_version = p_ntf[4]; } } else if (p_ntf[0] == NCI_MT_NTF && ((p_ntf[1] & NCI_OID_MASK) == NCI_MSG_CORE_RESET)) { - if(p_ntf[3] == CORE_RESET_TRIGGER_TYPE_CORE_RESET_CMD_RECEIVED || - p_ntf[3] == CORE_RESET_TRIGGER_TYPE_POWERED_ON) { + if(p_ntf[3] == CORE_RESET_TRIGGER_TYPE_CORE_RESET_CMD_RECEIVED ) { NXPLOG_NCIHAL_D("CORE_RESET_NTF NCI2.0 reason CORE_RESET_CMD received !"); nxpncihal_ctrl.nci_info.nci_version = p_ntf[5]; phNxpNciHal_configFeatureList(p_ntf,*p_len); @@ -526,7 +553,7 @@ static NFCSTATUS phNxpNciHal_ext_process_nfc_init_rsp(uint8_t* p_ntf, uint16_t* fw_maj_ver = p_ntf[len - 1]; rom_version = p_ntf[len - 2]; NXPLOG_NCIHAL_D ("NxpNci> FW Version: %x.%x.%x", p_ntf[len-2], p_ntf[len-1], p_ntf[len]); - }else { + } else { uint32_t i; char print_buffer[*p_len * 3 + 1]; @@ -539,7 +566,7 @@ static NFCSTATUS phNxpNciHal_ext_process_nfc_init_rsp(uint8_t* p_ntf, uint16_t* /*Retreive reset ntf reason code irrespective of NCI 1.0 or 2.0*/ if (p_ntf[3] == FW_DBG_REASON_AVAILABLE) - property_set("persist.nfc.core_reset_debug_info", "true"); + property_set("persist.vendor.nfc.core_reset_debug_info", "true"); phNxpNciHal_emergency_recovery(); status = NFCSTATUS_FAILED; } /* Parsing CORE_INIT_RSP*/ @@ -742,11 +769,6 @@ NFCSTATUS phNxpNciHal_write_ext(uint16_t* cmd_len, uint8_t* p_cmd_data, uint16_t* rsp_len, uint8_t* p_rsp_data) { NFCSTATUS status = NFCSTATUS_SUCCESS; - unsigned long retval = 0; - if (GetNxpNumValue(NAME_MIFARE_READER_ENABLE, &retval, - sizeof(unsigned long))) { - NXPLOG_NCIHAL_D("NAME_MIFARE_READER_ENABLE : %lu", retval); - } phNxpNciHal_NfcDep_cmd_ext(p_cmd_data, cmd_len); if (phNxpDta_IsEnable() == true) { @@ -815,7 +837,7 @@ NFCSTATUS phNxpNciHal_write_ext(uint16_t* cmd_len, uint8_t* p_cmd_data, } } - if (retval == 0x01 && p_cmd_data[0] == 0x21 && p_cmd_data[1] == 0x00 && + if (bEnableMfcReader && p_cmd_data[0] == 0x21 && p_cmd_data[1] == 0x00 && p_cmd_data[2] != 0x04 && p_cmd_data[6] != 0x83) { NXPLOG_NCIHAL_D("Going through extns - Adding Mifare in RF Discovery"); p_cmd_data[2] += 3; @@ -825,6 +847,7 @@ NFCSTATUS phNxpNciHal_write_ext(uint16_t* cmd_len, uint8_t* p_cmd_data, p_cmd_data[*cmd_len + 2] = 0x80; *cmd_len += 3; status = NFCSTATUS_SUCCESS; + bEnableMfcExtns = false; NXPLOG_NCIHAL_D( "Going through extns - Adding Mifare in RF Discovery - END"); } else if (p_cmd_data[3] == 0x81 && p_cmd_data[4] == 0x01 && @@ -1282,6 +1305,12 @@ NFCSTATUS request_EEPROM(phNxpNci_EEPROM_info_t* mEEPROM_info) { addr[0] = 0xA0; addr[1] = 0xED; break; + case EEPROM_NDEF_INTF_CFG: + b_position = 0x00; + memIndex = 0x00; + addr[0] = 0xA0; + addr[1] = 0x95; + break; default: ALOGE("No valid request information found"); break; diff --git a/halimpl/inc/phNxpNciHal_Adaptation.h b/halimpl/inc/phNxpNciHal_Adaptation.h index 9b5fca2..913787b 100644 --- a/halimpl/inc/phNxpNciHal_Adaptation.h +++ b/halimpl/inc/phNxpNciHal_Adaptation.h @@ -49,6 +49,7 @@ extern ESE_UPDATE_STATE eseUpdateDwp; int phNxpNciHal_open(nfc_stack_callback_t* p_cback, nfc_stack_data_callback_t* p_data_cback); int phNxpNciHal_write(uint16_t data_len, const uint8_t* p_data); +int phNxpNciHal_write_internal(uint16_t data_len, const uint8_t* p_data); int phNxpNciHal_ioctl(long arg, void* p_data); int phNxpNciHal_core_initialized(uint8_t* p_core_init_rsp_params); int phNxpNciHal_pre_discover(void); diff --git a/halimpl/libnfc-nci_NCI2_0.conf b/halimpl/libnfc-nci_NCI2_0.conf index 942f7ce..f3b9dc1 100644 --- a/halimpl/libnfc-nci_NCI2_0.conf +++ b/halimpl/libnfc-nci_NCI2_0.conf @@ -53,7 +53,7 @@ SCREEN_OFF_POWER_STATE=1 ############################################################################### # Default poll duration (in ms) # The defualt is 500ms if not set (see nfc_target.h) -#NFA_DM_DISC_DURATION_POLL=333 +NFA_DM_DISC_DURATION_POLL=300 ############################################################################### # Force tag polling for the following technology(s). diff --git a/halimpl/libnfc-nxp-PN553_example.conf b/halimpl/libnfc-nxp-PN553_example.conf index 53c4d44..b07e5e9 100644 --- a/halimpl/libnfc-nxp-PN553_example.conf +++ b/halimpl/libnfc-nxp-PN553_example.conf @@ -300,7 +300,7 @@ DEFAULT_OFFHOST_ROUTE=0x02 # host 0x00 # eSE 0x01 # UICC 0x02 -DEFAULT_NFCF_ROUTE=0x02 +DEFAULT_TECH_ABF_ROUTE=0x01 ############################################################################### #Set the default Felica T3T System Code OffHost route Location : @@ -340,14 +340,14 @@ DEFAULT_ISODEP_PWR_STATE=0x1B DEFAULT_OFFHOST_PWR_STATE=0x1B ############################################################################### -#Set the Felica CLT Power state : +#Set Tech A,B,F Power state : #This settings will be used when application does not set this parameter # bit pos 0 = Switch On # bit pos 1 = Switch Off # bit pos 2 = Battery Off # bit pos 3 = Screen Off # bit pos 4 = Screen Lock -DEFAULT_NFCF_PWR_STATE=0x1B +DEFAULT_TECH_ABF_PWR_STATE=0x1B ############################################################################### #Set the SYS_CODE Power state : diff --git a/halimpl/libnfc-nxp-PN557_example.conf b/halimpl/libnfc-nxp-PN557_example.conf index 1fb6e2a..1319612 100644 --- a/halimpl/libnfc-nxp-PN557_example.conf +++ b/halimpl/libnfc-nxp-PN557_example.conf @@ -285,7 +285,7 @@ DEFAULT_OFFHOST_ROUTE=0x02 # host 0x00 # eSE 0x01 # UICC 0x02 -DEFAULT_NFCF_ROUTE=0x02 +DEFAULT_TECH_ABF_ROUTE=0x01 ############################################################################### #Set the default Felica T3T System Code OffHost route Location : @@ -328,7 +328,7 @@ DEFAULT_ISODEP_PWR_STATE=0x3B DEFAULT_OFFHOST_PWR_STATE=0x3B ############################################################################### -#Set the Felica CLT Power state : +#Set Tech A,B,F Power state : #This settings will be used when application does not set this parameter # bit pos 0 = Switch On # bit pos 1 = Switch Off @@ -336,7 +336,7 @@ DEFAULT_OFFHOST_PWR_STATE=0x3B # bit pos 3 = Switched On Sub-State 1 : Screen is off and device is unlocked # bit pos 4 = Switched On Sub-State 2 : Screen is on and device is locked # bit pos 5 = Switched On Sub-State 3 : Screen is off and device is locked -DEFAULT_NFCF_PWR_STATE=0x3B +DEFAULT_TECH_ABF_PWR_STATE=0x3B ############################################################################### #Set the SYS_CODE Power state : diff --git a/halimpl/libnfc-nxp-PN80T_example.conf b/halimpl/libnfc-nxp-PN80T_example.conf index ae42030..725183a 100644 --- a/halimpl/libnfc-nxp-PN80T_example.conf +++ b/halimpl/libnfc-nxp-PN80T_example.conf @@ -25,6 +25,12 @@ NXP_NFC_DEV_NODE="/dev/nq-nci" MIFARE_READER_ENABLE=0x01 ############################################################################### +# Mifare Reader implementation +# 0: General implementation +# 1: Legacy implementation +LEGACY_MIFARE_READER=0 + +############################################################################### # Vzw Feature enable VZW_FEATURE_ENABLE=0x01 @@ -303,7 +309,7 @@ DEFAULT_OFFHOST_ROUTE=0x01 # host 0x00 # eSE 0x01 # UICC 0x02 -DEFAULT_NFCF_ROUTE=0x01 +DEFAULT_TECH_ABF_ROUTE=0x01 ############################################################################### #Set the default Felica T3T System Code OffHost route Location : @@ -343,14 +349,14 @@ DEFAULT_ISODEP_PWR_STATE=0x1B DEFAULT_OFFHOST_PWR_STATE=0x1B ############################################################################### -#Set the Felica CLT Power state : +#Set Tech A,B,F Power state : #This settings will be used when application does not set this parameter # bit pos 0 = Switch On # bit pos 1 = Switch Off # bit pos 2 = Battery Off # bit pos 3 = Screen Off # bit pos 4 = Screen Lock -DEFAULT_NFCF_PWR_STATE=0x1B +DEFAULT_TECH_ABF_PWR_STATE=0x1B ############################################################################### #Set the SYS_CODE Power state : diff --git a/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf b/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf index bd643f2..c38f00d 100755 --- a/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf +++ b/halimpl/libnfc-nxp-PN80T_example_NCI2_0.conf @@ -24,6 +24,12 @@ NXP_NFC_DEV_NODE="/dev/pn553" MIFARE_READER_ENABLE=0x01 ############################################################################### +# Mifare Reader implementation +# 0: General implementation +# 1: Legacy implementation +LEGACY_MIFARE_READER=0 + +############################################################################### # Vzw Feature enable VZW_FEATURE_ENABLE=0x01 diff --git a/halimpl/libnfc-nxp-PN81T_example.conf b/halimpl/libnfc-nxp-PN81T_example.conf index 21e763c..826d94f 100644 --- a/halimpl/libnfc-nxp-PN81T_example.conf +++ b/halimpl/libnfc-nxp-PN81T_example.conf @@ -25,6 +25,12 @@ NXP_NFC_DEV_NODE="/dev/pn553" MIFARE_READER_ENABLE=0x01 ############################################################################### +# Mifare Reader implementation +# 0: General implementation +# 1: Legacy implementation +LEGACY_MIFARE_READER=0 + +############################################################################### # Vzw Feature enable VZW_FEATURE_ENABLE=0x01 @@ -175,7 +181,7 @@ DEFAULT_OFFHOST_ROUTE=0x01 # host 0x00 # eSE 0x01 # UICC 0x02 -DEFAULT_NFCF_ROUTE=0x01 +DEFAULT_TECH_ABF_ROUTE=0x01 ############################################################################### #Set the default Felica T3T System Code OffHost route Location : @@ -218,7 +224,7 @@ DEFAULT_ISODEP_PWR_STATE=0x3B DEFAULT_OFFHOST_PWR_STATE=0x3B ############################################################################### -#Set the Felica CLT Power state : +#Set Tech A,B,F Power state : #This settings will be used when application does not set this parameter # bit pos 0 = Switch On # bit pos 1 = Switch Off @@ -226,7 +232,7 @@ DEFAULT_OFFHOST_PWR_STATE=0x3B # bit pos 3 = Switched On Sub-State 1 : Screen is off and device is unlocked # bit pos 4 = Switched On Sub-State 2 : Screen is on and device is locked # bit pos 5 = Switched On Sub-State 3 : Screen is off and device is locked -DEFAULT_NFCF_PWR_STATE=0x3B +DEFAULT_TECH_ABF_PWR_STATE=0x3B ############################################################################### #Set the SYS_CODE Power state : diff --git a/halimpl/libnfc-nxp_RF-PN553_example.conf b/halimpl/libnfc-nxp_RF-PN553_example.conf index c4d96c4..a6f7b24 100644 --- a/halimpl/libnfc-nxp_RF-PN553_example.conf +++ b/halimpl/libnfc-nxp_RF-PN553_example.conf @@ -48,7 +48,8 @@ # UICC bit rate A0D1 # SWP1A interface A0D4 # DWP intf behavior config, SVDD Load activated by default if set to 0x31 - A037 -NXP_CORE_CONF_EXTN={20, 02, 25, 09, +# For Symmetric baud rate UICC's set A086 to 77 +NXP_CORE_CONF_EXTN={20, 02, 29, 0A, A0, EC, 01, 01, A0, ED, 01, 00, A0, 5E, 01, 01, @@ -57,7 +58,8 @@ NXP_CORE_CONF_EXTN={20, 02, 25, 09, A0, DD, 01, 2D, A0, D1, 01, 06, A0, D4, 01, 01, - A0, 37, 01, 35 + A0, 37, 01, 35, + A0, 86, 01, 77 } # A0, F2, 01, 01, # A0, 40, 01, 01, diff --git a/halimpl/libnfc-nxp_RF-PN557_example.conf b/halimpl/libnfc-nxp_RF-PN557_example.conf index d32c5a4..65b5638 100644 --- a/halimpl/libnfc-nxp_RF-PN557_example.conf +++ b/halimpl/libnfc-nxp_RF-PN557_example.conf @@ -48,14 +48,16 @@ # UICC bit rate A0D1 # SWP1A interface A0D4 # DWP intf behavior config, SVDD Load activated by default if set to 0x31 - A037 -NXP_CORE_CONF_EXTN={20, 02, 1D, 07, +# For Symmetric baud rate UICC's set A086 to 77 +NXP_CORE_CONF_EXTN={20, 02, 21, 08, A0, EC, 01, 01, A0, ED, 01, 00, A0, 5E, 01, 01, A0, 40, 01, 01, A0, DD, 01, 2D, A0, D1, 01, 06, - A0, D4, 01, 01 + A0, D4, 01, 01, + A0, 86, 01, 77 } # A0, F2, 01, 01, # A0, 40, 01, 01, diff --git a/halimpl/libnfc-nxp_RF-PN80T_example.conf b/halimpl/libnfc-nxp_RF-PN80T_example.conf index 7e6c89d..643c67d 100644 --- a/halimpl/libnfc-nxp_RF-PN80T_example.conf +++ b/halimpl/libnfc-nxp_RF-PN80T_example.conf @@ -49,9 +49,11 @@ # How eSE connected to PN553 A012 # UICC bit rate A0D1 # SWP1A interface A0D4 +# SWP_RETRY_FP_INT2 A0DD +# SWP_RETRY_LP_INT2 A0DE # DWP intf behavior config, SVDD Load activated by default if set to 0x31 A037 # For Symmetric baud rate UICC's set A086 to 77 -NXP_CORE_CONF_EXTN={20, 02, 3A, 0E, +NXP_CORE_CONF_EXTN={20, 02, 42, 10, A0, EC, 01, 01, A0, ED, 01, 01, A0, 5E, 01, 01, @@ -62,6 +64,8 @@ NXP_CORE_CONF_EXTN={20, 02, 3A, 0E, A0, 37, 01, 35, A0, D8, 01, 02, A0, D5, 01, 0A, + A0, DD, 01, 00, + A0, DE, 01, 00, A0, B2, 01, 1E, A0, B3, 01, 01, A0, 9F, 02, 08, 08, diff --git a/halimpl/log/phNxpLog.cc b/halimpl/log/phNxpLog.cc index 3a9b3f7..b91d974 100755 --- a/halimpl/log/phNxpLog.cc +++ b/halimpl/log/phNxpLog.cc @@ -253,43 +253,4 @@ void phNxpLog_InitializeLogLevel(void) { gLog_level.extns_log_level, gLog_level.hal_log_level, gLog_level.tml_log_level, gLog_level.ncir_log_level, gLog_level.ncix_log_level); -} - -/****************************************************************************** - * Function phNxpLog_EnableDisableLogLevel - * - * Description This function can be called to enable/disable the log levels - * - * - * Log Level values: - * NXPLOG_LOG_SILENT_LOGLEVEL 0 * No trace to show - * NXPLOG_LOG_ERROR_LOGLEVEL 1 * Show Error trace - *only - * NXPLOG_LOG_WARN_LOGLEVEL 2 * Show Warning - *trace and Error trace - * NXPLOG_LOG_DEBUG_LOGLEVEL 3 * Show all traces - * - * Returns void - * - ******************************************************************************/ -NFCSTATUS phNxpLog_EnableDisableLogLevel(uint8_t enable) { - static nci_log_level_t prevTraceLevel = {0, 0, 0, 0, 0, 0, 0}; - static uint8_t currState = 0x01; - NFCSTATUS status = NFCSTATUS_FAILED; - if (0x01 == enable && currState != 0x01) { - memcpy(&gLog_level, &prevTraceLevel, sizeof(nci_log_level_t)); - currState = 0x01; - status = NFCSTATUS_SUCCESS; - } else if (0x00 == enable && currState != 0x00) { - memcpy(&prevTraceLevel, &gLog_level, sizeof(nci_log_level_t)); - gLog_level.hal_log_level = 0; - gLog_level.extns_log_level = 0; - gLog_level.tml_log_level = 0; - gLog_level.ncix_log_level = 0; - gLog_level.ncir_log_level = 0; - currState = 0x00; - status = NFCSTATUS_SUCCESS; - } - - return status; -} +}
\ No newline at end of file diff --git a/halimpl/log/phNxpLog.h b/halimpl/log/phNxpLog.h index 14cf350..75432b5 100644 --- a/halimpl/log/phNxpLog.h +++ b/halimpl/log/phNxpLog.h @@ -363,5 +363,4 @@ extern const char* NXPLOG_ITEM_HCPR; /* Android logging tag for NxpHcpR */ #endif /* NXP_VRBS_REQ */ void phNxpLog_InitializeLogLevel(void); -NFCSTATUS phNxpLog_EnableDisableLogLevel(uint8_t enable); #endif /* NXPLOG__H_INCLUDED */ diff --git a/halimpl/mifare/NxpMfcReader.cc b/halimpl/mifare/NxpMfcReader.cc new file mode 100644 index 0000000..315a803 --- /dev/null +++ b/halimpl/mifare/NxpMfcReader.cc @@ -0,0 +1,402 @@ +/****************************************************************************** + * + * Copyright 2019 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +#include "NxpMfcReader.h" +#include "phNxpNciHal.h" +#include <phNfcCompId.h> +#include <phNxpLog.h> +#include <phNxpNciHal_Adaptation.h> +#include <phNxpNciHal_ext.h> + +extern bool sendRspToUpperLayer; + +NxpMfcReader &NxpMfcReader::getInstance() { + static NxpMfcReader msNxpMfcReader; + return msNxpMfcReader; +} + +/******************************************************************************* +** +** Function Write +** +** Description Wrapper API to handle Mifare Transceive to TAG_CMD interface +** RAW read write. +** +** Returns It returns number of bytes successfully written to NFCC. +** +*******************************************************************************/ +int NxpMfcReader::Write(uint16_t mfcDataLen, const uint8_t *pMfcData) { + uint16_t mfcTagCmdBuffLen = 0; + uint8_t mfcTagCmdBuff[MAX_MFC_BUFF_SIZE] = {0}; + + memcpy(mfcTagCmdBuff, pMfcData, mfcDataLen); + if (mfcDataLen >= 3) + mfcTagCmdBuffLen = mfcDataLen - NCI_HEADER_SIZE; + BuildMfcCmd(&mfcTagCmdBuff[3], &mfcTagCmdBuffLen); + + mfcTagCmdBuff[2] = mfcTagCmdBuffLen; + mfcDataLen = mfcTagCmdBuffLen + NCI_HEADER_SIZE; + int writtenDataLen = phNxpNciHal_write_internal(mfcDataLen, mfcTagCmdBuff); + + /* send TAG_CMD part 2 for Mifare increment ,decrement and restore commands */ + if (mfcTagCmdBuff[4] == eMifareDec || mfcTagCmdBuff[4] == eMifareInc || + mfcTagCmdBuff[4] == eMifareRestore) { + SendIncDecRestoreCmdPart2(pMfcData); + } + return writtenDataLen; +} + +/******************************************************************************* +** +** Function BuildMfcCmd +** +** Description builds the TAG CMD for Mifare Classic Tag. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::BuildMfcCmd(uint8_t *pData, uint16_t *pLength) { + uint16_t cmdBuffLen = *pLength; + memcpy(mMfcTagCmdIntfData.sendBuf, pData, cmdBuffLen); + mMfcTagCmdIntfData.sendBufLen = cmdBuffLen; + + switch (pData[0]) { + case eMifareAuthentA: + case eMifareAuthentB: + BuildAuthCmd(); + break; + case eMifareRead16: + BuildReadCmd(); + break; + case eMifareWrite16: + AuthForWrite(); + BuildWrite16Cmd(); + break; + case eMifareInc: + case eMifareDec: + BuildIncDecCmd(); + break; + default: + BuildRawCmd(); + break; + } + + memcpy(pData, mMfcTagCmdIntfData.sendBuf, (mMfcTagCmdIntfData.sendBufLen)); + *pLength = (mMfcTagCmdIntfData.sendBufLen); + return; +} + +/******************************************************************************* +** +** Function BuildAuthCmd +** +** Description builds the TAG CMD for Mifare Auth. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::BuildAuthCmd() { + uint8_t byKey = 0x00, noOfKeys = 0x00; + bool isPreloadedKey = false; + + if (mMfcTagCmdIntfData.sendBuf[0] == eMifareAuthentB) { + byKey |= MFC_ENABLE_KEY_B; + } + uint8_t aMfckeys[MFC_NUM_OF_KEYS][MFC_KEY_SIZE] = MFC_KEYS; + noOfKeys = sizeof(aMfckeys) / MFC_KEY_SIZE; + for (uint8_t byIndex = 0; byIndex < noOfKeys; byIndex++) { + if ((memcmp(aMfckeys[byIndex], &mMfcTagCmdIntfData.sendBuf[6], + MFC_AUTHKEYLEN) == 0x00)) { + byKey = byKey | byIndex; + isPreloadedKey = true; + break; + } + } + CalcSectorAddress(); + mMfcTagCmdIntfData.sendBufLen = 0x03; + if (!isPreloadedKey) { + byKey |= MFC_EMBEDDED_KEY; + memcpy(&mMfcTagCmdIntfData.sendBuf[3], &mMfcTagCmdIntfData.sendBuf[6], + MFC_AUTHKEYLEN); + mMfcTagCmdIntfData.sendBufLen += MFC_AUTHKEYLEN; + } + + mMfcTagCmdIntfData.sendBuf[0] = eMfcAuthReq; + mMfcTagCmdIntfData.sendBuf[1] = mMfcTagCmdIntfData.byAddr; + mMfcTagCmdIntfData.sendBuf[2] = byKey; + return; +} + +/******************************************************************************* +** +** Function CalcSectorAddress +** +** Description This function update the sector address for Mifare classic +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::CalcSectorAddress() { + uint8_t BlockNumber = mMfcTagCmdIntfData.sendBuf[1]; + if (BlockNumber >= MFC_4K_BLK128) { + mMfcTagCmdIntfData.byAddr = + (uint8_t)(MFC_SECTOR_NO32 + + ((BlockNumber - MFC_4K_BLK128) / MFC_BYTES_PER_BLOCK)); + } else { + mMfcTagCmdIntfData.byAddr = BlockNumber / MFC_BLKS_PER_SECTOR; + } + + return; +} + +/******************************************************************************* +** +** Function BuildReadCmd +** +** Description builds the TAG CMD for Mifare Read. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::BuildReadCmd() { BuildRawCmd(); } + +/******************************************************************************* +** +** Function BuildWrite16Cmd +** +** Description builds the TAG CMD for Mifare write part 2. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::BuildWrite16Cmd() { + mMfcTagCmdIntfData.sendBuf[0] = eMfRawDataXchgHdr; + mMfcTagCmdIntfData.sendBufLen = mMfcTagCmdIntfData.sendBufLen - 1; + memmove(mMfcTagCmdIntfData.sendBuf + 1, mMfcTagCmdIntfData.sendBuf + 2, + mMfcTagCmdIntfData.sendBufLen); +} + +/******************************************************************************* +** +** Function BuildRawCmd +** +** Description builds the TAG CMD for Raw transceive. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::BuildRawCmd() { + mMfcTagCmdIntfData.sendBufLen = mMfcTagCmdIntfData.sendBufLen + 1; + memmove(mMfcTagCmdIntfData.sendBuf + 1, mMfcTagCmdIntfData.sendBuf, + mMfcTagCmdIntfData.sendBufLen); + mMfcTagCmdIntfData.sendBuf[0] = eMfRawDataXchgHdr; +} + +/******************************************************************************* +** +** Function BuildIncDecCmd +** +** Description builds the TAG CMD for Mifare Inc/Dec. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::BuildIncDecCmd() { + mMfcTagCmdIntfData.sendBufLen = 0x03; // eMfRawDataXchgHdr + cmd + + // blockaddress + memmove(mMfcTagCmdIntfData.sendBuf + 1, mMfcTagCmdIntfData.sendBuf, + mMfcTagCmdIntfData.sendBufLen); + mMfcTagCmdIntfData.sendBuf[0] = eMfRawDataXchgHdr; +} + +/******************************************************************************* +** +** Function AuthForWrite +** +** Description send Mifare write Part 1. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::AuthForWrite() { + sendRspToUpperLayer = false; + NFCSTATUS status = NFCSTATUS_FAILED; + uint8_t authForWriteBuff[] = {0x00, + 0x00, + 0x03, + (uint8_t)eMfRawDataXchgHdr, + (uint8_t)mMfcTagCmdIntfData.sendBuf[0], + (uint8_t)mMfcTagCmdIntfData.sendBuf[1]}; + + status = phNxpNciHal_send_ext_cmd( + sizeof(authForWriteBuff) / sizeof(authForWriteBuff[0]), authForWriteBuff); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E("Mifare Auth for Transceive failed"); + } + return; +} + +/******************************************************************************* +** +** Function SendIncDecRestoreCmdPart2 +** +** Description send Mifare Inc/Dec/Restore Command Part 2. +** +** Returns None +** +*******************************************************************************/ +void NxpMfcReader::SendIncDecRestoreCmdPart2(const uint8_t *mfcData) { + NFCSTATUS status = NFCSTATUS_SUCCESS; + /* Build TAG_CMD part 2 for Mifare increment ,decrement and restore commands*/ + uint8_t incDecRestorePart2[] = {0x00, 0x00, 0x05, (uint8_t)eMfRawDataXchgHdr, + 0x00, 0x00, 0x00, 0x00}; + uint8_t incDecRestorePart2Size = + (sizeof(incDecRestorePart2) / sizeof(incDecRestorePart2[0])); + if (mfcData[3] == eMifareInc || mfcData[3] == eMifareDec) { + for (int i = 4; i < incDecRestorePart2Size; i++) { + incDecRestorePart2[i] = mfcData[i + 1]; + } + } + sendRspToUpperLayer = false; + status = phNxpNciHal_send_ext_cmd(incDecRestorePart2Size, incDecRestorePart2); + if (status != NFCSTATUS_SUCCESS) { + NXPLOG_NCIHAL_E("Mifare Cmd for inc/dec/Restore part 2 failed"); + } + return; +} + +/******************************************************************************* +** +** Function AnalyzeMfcResp +** +** Description Analyze type of MFC response and build MFC response from +** Tag cmd Intf response? +** +** Returns NFCSTATUS_SUCCESS - Data Reception is successful +** NFCSTATUS_FAILED - Data Reception failed +** +*******************************************************************************/ +NFCSTATUS NxpMfcReader::AnalyzeMfcResp(uint8_t *pBuff, uint16_t *pBufflen) { + NFCSTATUS status = NFCSTATUS_SUCCESS; + uint16_t wPldDataSize = 0; + MfcRespId_t RecvdExtnRspId = eInvalidRsp; + + if (0 == (*pBufflen)) { + status = NFCSTATUS_FAILED; + } else { + RecvdExtnRspId = (MfcRespId_t)pBuff[0]; + NXPLOG_NCIHAL_E("%s: RecvdExtnRspId=%d", __func__, RecvdExtnRspId); + switch (RecvdExtnRspId) { + case eMfXchgDataRsp: { + NFCSTATUS writeRespStatus = NFCSTATUS_SUCCESS; + /* check the status byte */ + if (*pBufflen == 3) { + if ((pBuff[0] == 0x10) && (pBuff[1] != 0x0A)) { + NXPLOG_NCIHAL_E("Mifare Error in payload response"); + *pBufflen = 0x1; + pBuff[0] = NFCSTATUS_FAILED; + return NFCSTATUS_FAILED; + } else { + pBuff[0] = NFCSTATUS_SUCCESS; + return NFCSTATUS_SUCCESS; + } + } + writeRespStatus = pBuff[*pBufflen - 1]; + + if (NFCSTATUS_SUCCESS == writeRespStatus) { + status = NFCSTATUS_SUCCESS; + uint16_t wRecvDataSz = 0; + + wPldDataSize = + ((*pBufflen) - (MFC_EXTN_ID_SIZE + MFC_EXTN_STATUS_SIZE)); + wRecvDataSz = MAX_MFC_BUFF_SIZE; + if ((wPldDataSize) <= wRecvDataSz) { + /* Extract the data part from pBuff[2] & fill it to be sent to + * upper layer */ + memmove(&(pBuff[0]), &(pBuff[1]), wPldDataSize); + /* update the number of bytes received from lower layer,excluding + * the status byte */ + *pBufflen = wPldDataSize; + } else { + status = NFCSTATUS_FAILED; + } + } else { + status = NFCSTATUS_FAILED; + } + } break; + + case eMfcAuthRsp: { + /* check the status byte */ + if (NFCSTATUS_SUCCESS == pBuff[1]) { + status = NFCSTATUS_SUCCESS; + /* DataLen = TotalRecvdLen - (sizeof(RspId) + sizeof(Status)) */ + wPldDataSize = + ((*pBufflen) - (MFC_EXTN_ID_SIZE + MFC_EXTN_STATUS_SIZE)); + /* Extract the data part from pBuff[2] & fill it to be sent to upper + * layer */ + pBuff[0] = pBuff[1]; + /* update the number of bytes received from lower layer,excluding + * the status byte */ + *pBufflen = wPldDataSize + 1; + } else { + pBuff[0] = pBuff[1]; + *pBufflen = 1; + status = NFCSTATUS_FAILED; + } + } break; + default: { status = NFCSTATUS_FAILED; } break; + } + } + return status; +} + +/******************************************************************************* +** +** Function CheckMfcResponse +** +** Description This function is called to check if it's a valid Mfc +** response data +** +** Returns NFCSTATUS_SUCCESS +** NFCSTATUS_FAILED +** +*******************************************************************************/ +NFCSTATUS NxpMfcReader::CheckMfcResponse(uint8_t *pTransceiveData, + uint16_t transceiveDataLen) { + NFCSTATUS status = NFCSTATUS_SUCCESS; + + if (transceiveDataLen == 3) { + if ((pTransceiveData)[0] == 0x10 && (pTransceiveData)[1] != 0x0A) { + NXPLOG_NCIHAL_E("Mifare Error in payload response"); + transceiveDataLen = 0x1; + pTransceiveData += 1; + return NFCSTATUS_FAILED; + } + } + if ((pTransceiveData)[0] == 0x40) { + pTransceiveData += 1; + transceiveDataLen = 0x01; + if ((pTransceiveData)[0] == 0x03) { + transceiveDataLen = 0x00; + status = NFCSTATUS_FAILED; + } + } else if ((pTransceiveData)[0] == 0x10) { + pTransceiveData += 1; + transceiveDataLen = 0x10; + } + return status; +} diff --git a/halimpl/mifare/NxpMfcReader.h b/halimpl/mifare/NxpMfcReader.h new file mode 100644 index 0000000..da216e1 --- /dev/null +++ b/halimpl/mifare/NxpMfcReader.h @@ -0,0 +1,120 @@ +/****************************************************************************** + * + * Copyright 2019 NXP + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ******************************************************************************/ +#pragma once + +/*include files*/ +#include <phNfcStatus.h> +#include <phNfcTypes.h> + +#define NxpMfcReaderInstance (NxpMfcReader::getInstance()) + +#define MAX_MFC_BUFF_SIZE 32 + +#define MFC_4K_BLK128 128 /*Block number 128 for Mifare 4k */ +#define MFC_SECTOR_NO32 32 /* Sector 32 for Mifare 4K*/ +#define MFC_BYTES_PER_BLOCK 16 +#define MFC_BLKS_PER_SECTOR (0x04) + +#define MFC_EXTN_ID_SIZE (0x01U) /* Size of Mfc Req/Rsp Id */ +#define MFC_EXTN_STATUS_SIZE (0x01U) /* Size of Mfc Resp Status Byte */ + +#define MFC_AUTHKEYLEN 0x06 /* Authentication key length */ +#define MFC_AUTHENTICATION_KEY \ + (0x00U) /* Authentication key passed in extension \ + command header of authentication command */ +#define MFC_ENABLE_KEY_B (0x80U) +#define MFC_EMBEDDED_KEY (0x10) +#define MFC_NUM_OF_KEYS (0x03U) +#define MFC_KEY_SIZE (0x06U) +#define MFC_KEYS \ + { \ + {0xA0, 0XA1, 0xA2, 0XA3, 0xA4, 0XA5}, \ + {0xD3, 0XF7, 0xD3, 0XF7, 0xD3, 0XF7}, \ + {0xFF, 0XFF, 0xFF, 0XFF, 0xFF, 0XFF}, \ + } /* Key used during NDEF format */ + +typedef enum MifareCmdList { + eMifareRaw = 0x00U, /* This command performs raw transcations */ + eMifareAuthentA = 0x60U, /* This command performs an authentication with + KEY A for a sector. */ + eMifareAuthentB = 0x61U, /* This command performs an authentication with + KEY B for a sector. */ + eMifareRead16 = 0x30U, /* Read 16 Bytes from a Mifare Standard block */ + eMifareRead = 0x30U, /* Read Mifare Standard */ + eMifareWrite16 = 0xA0U, /* Write 16 Bytes to a Mifare Standard block */ + eMifareWrite4 = 0xA2U, /* Write 4 bytes. */ + eMifareInc = 0xC1U, /* Increment */ + eMifareDec = 0xC0U, /* Decrement */ + eMifareTransfer = 0xB0U, /* Transfer */ + eMifareRestore = 0xC2U, /* Restore. */ + eMifareReadSector = 0x38U, /* Read Sector. */ + eMifareWriteSector = 0xA8U, /* Write Sector. */ +} MifareCmdList_t; + +/* + * Request Id for different commands + */ +typedef enum MfcCmdReqId { + eMfRawDataXchgHdr = 0x10, /* MF Raw Data Request from DH */ + eMfWriteNReq = 0x31, /* MF N bytes write request from DH */ + eMfReadNReq = 0x32, /* MF N bytes read request from DH */ + eMfSectorSelReq = 0x33, /* MF Block select request from DH */ + eMfPlusProxCheckReq = 0x28, /* MF + Prox check request for NFCC from DH */ + eMfcAuthReq = 0x40, /* MFC Authentication request for NFCC from DH */ + eInvalidReq /* Invalid ReqId */ +} MfcCmdReqId_t; + +/* + * Response Ids for different command response + */ +typedef enum MfcRespId { + eMfXchgDataRsp = 0x10, /* DH gets Raw data from MF on successful req */ + eMfWriteNRsp = 0x31, /* DH gets write status */ + eMfReadNRsp = 0x32, /* DH gets N Bytes read from MF, if successful */ + eMfSectorSelRsp = 0x33, /* DH gets the Sector Select cmd status */ + eMfPlusProxCheckRsp = 0x29, /* DH gets the MF+ Prox Check cmd status */ + eMfcAuthRsp = 0x40, /* DH gets the authenticate cmd status */ + eInvalidRsp /* Invalid RspId */ +} MfcRespId_t; + +typedef struct MfcTagCmdIntfData { + uint8_t byAddr; /* Start address to perform operation*/ + uint16_t sendBufLen; /* Holds the length of the received data. */ + uint8_t sendBuf[MAX_MFC_BUFF_SIZE]; /*Holds the ack of some initial commands*/ +} MfcTagCmdIntfData_t; + +class NxpMfcReader { +private: + MfcTagCmdIntfData_t mMfcTagCmdIntfData; + void BuildMfcCmd(uint8_t *pData, uint16_t *pLength); + void BuildAuthCmd(); + void BuildReadCmd(); + void BuildWrite16Cmd(); + void BuildRawCmd(); + void BuildIncDecCmd(); + void CalcSectorAddress(); + void AuthForWrite(); + void SendIncDecRestoreCmdPart2(const uint8_t *mfcData); + +public: + int Write(uint16_t mfcDataLen, const uint8_t *pMfcData); + NFCSTATUS AnalyzeMfcResp(uint8_t *pBuff, uint16_t *pBufflen); + NFCSTATUS CheckMfcResponse(uint8_t *pTransceiveData, + uint16_t transceiveDataLen); + static NxpMfcReader &getInstance(); +};
\ No newline at end of file diff --git a/halimpl/src/halLibnfc/src/Android.bp b/halimpl/src/halLibnfc/src/Android.bp index 469379f..590e0f6 100755 --- a/halimpl/src/halLibnfc/src/Android.bp +++ b/halimpl/src/halLibnfc/src/Android.bp @@ -20,8 +20,8 @@ cc_library_shared { "android.hardware.nfc@1.0", "android.hardware.nfc@1.1", "android.hardware.nfc@1.2", - "vendor.nxp.hardware.nfc@1.0", - "vendor.nxp.hardware.nfc@1.1", + "vendor.nxp.hardware.nfc@2.0", + "vendor.nxp.nxpnfclegacy@1.0" ], cflags: [ "-DBUILDCFG=1", diff --git a/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc b/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc index 3e06e82..e730d1c 100755 --- a/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc +++ b/halimpl/src/halLibnfc/src/adaptation/HalNfcAdaptation.cc @@ -35,7 +35,6 @@ * ******************************************************************************/ #include "HalNfcAdaptation.h" -#include "hal_nxpnfc.h" #include "nfa_api.h" #include "nfc_int.h" #include "nfc_target.h" @@ -67,7 +66,8 @@ using ::android::hardware::hidl_death_recipient; using android::hardware::hidl_vec; using android::hardware::nfc::V1_1::INfcClientCallback; using ::android::hidl::base::V1_0::IBase; -using vendor::nxp::hardware::nfc::V1_0::INqNfc; +using vendor::nxp::hardware::nfc::V2_0::INqNfc; +using vendor::nxp::nxpnfclegacy::V1_0::INxpNfcLegacy; extern bool nfc_debug_enabled; @@ -77,6 +77,7 @@ HalNfcAdaptation *HalNfcAdaptation::mpInstance = NULL; HalAdaptationThreadMutex HalNfcAdaptation::sLock; HalAdaptationThreadMutex HalNfcAdaptation::sIoctlLock; sp<INqNfc> HalNfcAdaptation::mNqHal; +sp<INxpNfcLegacy> HalNfcAdaptation::mHalNxpNfcLegacy; sp<INfc> HalNfcAdaptation::mHal; sp<INfcV1_1> HalNfcAdaptation::mHal_1_1; INfcClientCallback *HalNfcAdaptation::mCallback; @@ -173,7 +174,6 @@ public: ** *******************************************************************************/ HalNfcAdaptation::HalNfcAdaptation() { - mCurrentIoctlData = NULL; mNfcHalDeathRecipient = new NfcDeathRecipient(mHal); memset(&mHalEntryFuncs, 0, sizeof(mHalEntryFuncs)); } @@ -385,6 +385,21 @@ uint32_t HalNfcAdaptation::Thread(__attribute__((unused)) uint32_t arg) { tHAL_NFC_ENTRY *HalNfcAdaptation::GetHalEntryFuncs() { return &mHalEntryFuncs; } /******************************************************************************* + ** + ** Function phNxpNciHal_getchipType + ** + ** Description Gets the chipType from hal which is already configured + ** during init time. + ** + ** Returns chipType + *******************************************************************************/ +uint8_t HalNfcAdaptation::HalgetchipType() { + const char* func = "NfcAdaptation::HalgetchipType"; + DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s : Enter", func); + return mHalNxpNfcLegacy->getchipType(); +} + +/******************************************************************************* ** ** Function: HalNfcAdaptation::InitializeHalDeviceContext ** @@ -402,9 +417,7 @@ void HalNfcAdaptation::InitializeHalDeviceContext() { mHalEntryFuncs.close = HalClose; mHalEntryFuncs.core_initialized = HalCoreInitialized; mHalEntryFuncs.write = HalWrite; -#if (NXP_EXTNS == TRUE) - mHalEntryFuncs.ioctl = HalIoctl; -#endif + mHalEntryFuncs.getchipType = HalgetchipType; mHalEntryFuncs.prediscover = HalPrediscover; mHalEntryFuncs.control_granted = HalControlGranted; LOG(INFO) << StringPrintf("%s: Try INfcV1_1::getService()", func); @@ -431,6 +444,15 @@ void HalNfcAdaptation::InitializeHalDeviceContext() { func, mNqHal.get(), (mNqHal->isRemote() ? "remote" : "local")); } + + LOG(INFO) << StringPrintf("%s: INxpNfcLegacy::getService()", func); + mHalNxpNfcLegacy = INxpNfcLegacy::tryGetService(); + if(mHalNxpNfcLegacy == nullptr) { + LOG(INFO) << StringPrintf ( "Failed to retrieve the NXPNFC Legacy HAL!"); + } else { + LOG(INFO) << StringPrintf("%s: INxpNfcLegacy::getService() returned %p (%s)", func, mHalNxpNfcLegacy.get(), + (mHalNxpNfcLegacy->isRemote() ? "remote" : "local")); + } } /******************************************************************************* @@ -556,70 +578,6 @@ void HalNfcAdaptation::HalWrite(uint16_t data_len, uint8_t *p_data) { #if (NXP_EXTNS == TRUE) /******************************************************************************* ** -** Function: IoctlCallback -** -** Description: Callback from HAL stub for IOCTL api invoked. -** Output data for IOCTL is sent as argument -** -** Returns: None. -** -*******************************************************************************/ -void IoctlCallback(::android::hardware::nfc::V1_0::NfcData outputData) { - const char *func = "IoctlCallback"; - nfc_nci_ExtnOutputData_t *pOutData = - (nfc_nci_ExtnOutputData_t *)&outputData[0]; - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "%s Ioctl Type=%llu", func, (unsigned long long)pOutData->ioctlType); - HalNfcAdaptation *pAdaptation = (HalNfcAdaptation *)pOutData->context; - /*Output Data from stub->Proxy is copied back to output data - * This data will be sent back to libnfc*/ - memcpy(&pAdaptation->mCurrentIoctlData->out, &outputData[0], - sizeof(nfc_nci_ExtnOutputData_t)); -} -/******************************************************************************* -** -** Function: HalNfcAdaptation::HalIoctl -** -** Description: Calls ioctl to the Nfc driver. -** If called with a arg value of 0x01 than wired access requested, -** status of the requst would be updated to p_data. -** If called with a arg value of 0x00 than wired access will be -** released, status of the requst would be updated to p_data. -** If called with a arg value of 0x02 than current p61 state would -*be -** updated to p_data. -** -** Returns: -1 or 0. -** -*******************************************************************************/ -int HalNfcAdaptation::HalIoctl(long arg, void *p_data) { - const char *func = "HalNfcAdaptation::HalIoctl"; - ::android::hardware::nfc::V1_0::NfcData data; - HalAdaptationAutoThreadMutex a(sIoctlLock); - nfc_nci_IoctlInOutData_t *pInpOutData = (nfc_nci_IoctlInOutData_t *)p_data; - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s arg=%ld", func, arg); - pInpOutData->inp.context = &HalNfcAdaptation::GetInstance(); - HalNfcAdaptation::GetInstance().mCurrentIoctlData = pInpOutData; - data.setToExternal((uint8_t *)pInpOutData, sizeof(nfc_nci_IoctlInOutData_t)); - if (arg == HAL_NFC_IOCTL_SET_TRANSIT_CONFIG) { - /*Insert Transit config at the end of IOCTL data as transit buffer also - needs to be part of NfcData(hidl_vec)*/ - std::vector<uint8_t> tempStdVec(data); - tempStdVec.insert(tempStdVec.end(), pInpOutData->inp.data.transitConfig.val, - pInpOutData->inp.data.transitConfig.val + - (pInpOutData->inp.data.transitConfig.len)); - data = tempStdVec; - } - if (mNqHal != nullptr) - mNqHal->ioctl(arg, data, IoctlCallback); - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("%s Ioctl Completed for Type=%llu", func, - (unsigned long long)pInpOutData->out.ioctlType); - return (pInpOutData->out.result); -} - -/******************************************************************************* -** ** Function: HalNfcAdaptation::HalGetFwDwnldFlag ** ** Description: Get FW Download Flag. diff --git a/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h b/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h index b8aecd7..e1d1771 100755 --- a/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h +++ b/halimpl/src/halLibnfc/src/include/HalNfcAdaptation.h @@ -44,10 +44,12 @@ #include <android/hardware/nfc/1.0/types.h> #include <hardware/nfc.h> #include <utils/RefBase.h> -#include <vendor/nxp/hardware/nfc/1.0/INqNfc.h> +#include <vendor/nxp/nxpnfclegacy/1.0/INxpNfcLegacy.h> +#include <vendor/nxp/nxpnfclegacy/1.0/types.h> +#include <vendor/nxp/hardware/nfc/2.0/INqNfc.h> using ::android::sp; -using vendor::nxp::hardware::nfc::V1_0::INqNfc; +using vendor::nxp::hardware::nfc::V2_0::INqNfc; namespace android { namespace hardware { @@ -111,6 +113,7 @@ public: void Finalize(); void FactoryReset(); void DeviceShutdown(); + static uint8_t HalgetchipType(); static HalNfcAdaptation &GetInstance(); tHAL_NFC_ENTRY *GetHalEntryFuncs(); void DownloadFirmware(); @@ -118,7 +121,6 @@ public: #if (NXP_EXTNS == TRUE) void MinInitialize(); int HalGetFwDwnldFlag(uint8_t *fwDnldRequest); - nfc_nci_IoctlInOutData_t *mCurrentIoctlData; #endif private: @@ -136,8 +138,9 @@ private: static HalAdaptationThreadCondVar mHalIoctlEvent; static android::sp<android::hardware::nfc::V1_0::INfc> mHal; static android::sp<android::hardware::nfc::V1_1::INfc> mHal_1_1; - static android::sp<vendor::nxp::hardware::nfc::V1_0::INqNfc> mNqHal; + static android::sp<vendor::nxp::hardware::nfc::V2_0::INqNfc> mNqHal; static android::hardware::nfc::V1_1::INfcClientCallback *mCallback; + static android::sp<vendor::nxp::nxpnfclegacy::V1_0::INxpNfcLegacy> mHalNxpNfcLegacy; sp<NfcDeathRecipient> mNfcHalDeathRecipient; #if (NXP_EXTNS == TRUE) static HalAdaptationThreadCondVar mHalCoreResetCompletedEvent; @@ -159,9 +162,6 @@ private: static void HalCoreInitialized(uint16_t data_len, uint8_t *p_core_init_rsp_params); static void HalWrite(uint16_t data_len, uint8_t *p_data); -#if (NXP_EXTNS == TRUE) - static int HalIoctl(long arg, void *p_data); -#endif static bool HalPrediscover(); static void HalControlGranted(); }; diff --git a/halimpl/src/halLibnfc/src/include/nfc_hal_api.h b/halimpl/src/halLibnfc/src/include/nfc_hal_api.h index 140f93b..508417f 100755 --- a/halimpl/src/halLibnfc/src/include/nfc_hal_api.h +++ b/halimpl/src/halLibnfc/src/include/nfc_hal_api.h @@ -43,7 +43,6 @@ #ifndef NFC_HAL_API_H #define NFC_HAL_API_H #include "data_types.h" -#include "hal_nxpnfc.h" #include "nfc_hal_target.h" #include <hardware/nfc.h> @@ -71,6 +70,7 @@ typedef uint8_t(tHAL_API_GET_MAX_NFCEE)(void); #if (NXP_EXTNS == TRUE) typedef int(tHAL_API_IOCTL)(long arg, void *p_data); typedef int(tHAL_API_GET_FW_DWNLD_FLAG)(uint8_t *fwDnldRequest); +typedef uint8_t(tHAL_API_getchipType)(void); #endif typedef struct { @@ -87,6 +87,7 @@ typedef struct { #if (NXP_EXTNS == TRUE) tHAL_API_IOCTL *ioctl; tHAL_API_GET_FW_DWNLD_FLAG *check_fw_dwnld_flag; + tHAL_API_getchipType* getchipType; #endif } tHAL_NFC_ENTRY; diff --git a/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc b/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc index 0c8671d..cbd1e49 100755 --- a/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc +++ b/halimpl/src/halLibnfc/src/nfa/dm/nfa_dm_act.cc @@ -50,7 +50,6 @@ #include "nfc_api.h" #include "nfa_ee_int.h" #if (NFC_NFCEE_INCLUDED == true) -#include "hal_nxpnfc.h" #include "nfc_int.h" #endif diff --git a/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h b/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h index 4a8c46f..ea068a5 100755 --- a/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h +++ b/halimpl/src/halLibnfc/src/nfc/include/nfc_api.h @@ -363,6 +363,12 @@ enum { }; typedef uint16_t tNFC_CONN_EVT; +enum { + HAL_NFC_ENABLE_I2C_FRAGMENTATION_EVT = 0x08, + HAL_NFC_POST_MIN_INIT_CPLT_EVT = 0x09, + HAL_NFC_WRITE_COMPLETE = 0x0A +}; + #define NFC_NFCC_INFO_LEN 4 #ifndef NFC_NFCC_MAX_NUM_VS_INTERFACE #define NFC_NFCC_MAX_NUM_VS_INTERFACE 5 @@ -1469,20 +1475,6 @@ extern tNFC_STATUS NFC_SendVsCommand(uint8_t oid, NFC_HDR *p_data, extern tNFC_STATUS NFC_SendRawVsCommand(NFC_HDR *p_data, tNFC_VS_CBACK *p_cback); -#if (NXP_EXTNS == TRUE) -/******************************************************************************* -** -** Function NFC_SetP61Status -** -** Description This function set the JCOP download -** state to pn544 driver. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -extern int32_t NFC_SetP61Status(void *pdata, libnfc_jcop_dwnld_state_t isJcopState); -#endif - /******************************************************************************* ** ** Function NFC_GetStatusName @@ -1511,15 +1503,6 @@ extern uint8_t nfc_hal_nfcc_reset(void); extern uint8_t nfc_hal_nfcc_init(uint8_t **pinit_rsp); /******************************************************************************* ** -** Function NFC_EnableDisableHalLog -** -** Description This function is used to enable/disable -** HAL log level. -** -*******************************************************************************/ -void NFC_EnableDisableHalLog(uint8_t type); -/******************************************************************************* -** ** Function nfc_ncif_getMaxRoutingTableSize ** ** Description This function is called to get the Max supported routing @@ -1560,107 +1543,6 @@ extern tNFC_STATUS NFC_Nfcee_PwrLinkCtrl(uint8_t nfcee_id, uint8_t cfg_value); ** *******************************************************************************/ int32_t NFC_ReqWiredAccess(void *pdata); -/******************************************************************************* -** -** Function NFC_RelWiredAccess -** -** Description This function release access -** of P61. Status would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelWiredAccess(void *pdata); -/******************************************************************************* -** -** Function NFC_GetWiredAccess -** -** Description This function gets the current access state -** of P61. Current state would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_GetP61Status(void *pdata); -/******************************************************************************* -** -** Function NFC_DisableWired -** -** Description This function request to pn54x driver to -** disable ese vdd gpio -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_DisableWired(void *pdata); - -/******************************************************************************* -** -** Function NFC_ReleaseEsePwr -** -** Description This function request to pn553 driver to -** turn ese vdd gpio low -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_ReleaseEsePwr(void *pdata); - -/******************************************************************************* -** -** Function NFC_AcquireEsePwr -** -** Description This function request to pn553 driver to -** turn ese vdd gpio high -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_AcquireEsePwr(void *pdata); - -/******************************************************************************* -** -** Function NFC_eSEChipReset -** -** Description This function request to reset ESE using ISO_RST feature. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_eSEChipReset(void *pdata); -/******************************************************************************* -** -** Function NFC_EnableWired -** -** Description This function request to pn54x driver to -** enable ese vdd gpio -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_EnableWired(void *pdata); -/******************************************************************************* -** -** Function NFC_SetNfcServicePid -** -** Description This function request to pn54x driver to -** update NFC service process ID for signalling. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_SetNfcServicePid(); -/******************************************************************************* -** -** Function NFC_ResetNfcServicePid -** -** Description This function request to pn54x driver to -** reset NFC service process ID for signalling. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_ResetNfcServicePid(); /******************************************************************************* ** @@ -1675,43 +1557,6 @@ bool NFC_IsLowRamDevice(); /******************************************************************************* ** -** Function NFC_GetEseAccess -** -** Description This function request to pn54x driver to get access -** of P61. it returns 0 on success. This api waits maximum -** defined timeout -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_GetEseAccess(void *pdata); - -/******************************************************************************* -** -** Function NFC_RelEseAccess -** -** Description This function release access of P61. -** it returns 0 on success. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelEseAccess(void *pdata); - -/******************************************************************************* -** -** Function NFC_RelSvddWait -** -** Description This function release wait for svdd change -** of P61. Status would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelSvddWait(void *pdata); - -/******************************************************************************* -** ** Function NFC_GetChipType ** ** Description Returns currently selected chip type @@ -1723,18 +1568,6 @@ tNFC_chipType NFC_GetChipType(); /******************************************************************************* ** -** Function NFC_RelForceDwpOnOffWait -** -** Description This function release wait for DWP On/Off -** of P73. Status would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelForceDwpOnOffWait(void *pdata); - -/******************************************************************************* -** ** Function NFC_Queue_Is_empty ** ** Description This function to get NFCEE connection ID queue information diff --git a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc index 1266d1a..4d12d6c 100755 --- a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc +++ b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_main.cc @@ -52,7 +52,6 @@ #include "bt_types.h" #include "gki.h" -#include "hal_nxpnfc.h" #include "nci_hmsgs.h" #include "nfa_sys.h" #include "nfc_int.h" @@ -498,19 +497,6 @@ void nfc_main_handle_hal_evt(tNFC_HAL_EVT_MSG *p_msg) { 0xA0, 0xD4, 0x01, 0x00}; NFC_SetConfig(disableUiccCmd[2], disableUiccCmd); nfc_enabled(NCI_STATUS_OK, nfc_cb.p_nci_init_rsp); -#if (NXP_EXTNS == TRUE) - /* - * reading requred EEPROM config vlaues from HAL - * and updating libnfc structure. - * During Setconfig request these stored values are compared - * If found same setconfigs will not be sent - * */ - { - nfc_nci_IoctlInOutData_t inpOutData; - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_GET_CONFIG_INFO, - (void *)&inpOutData); - } -#endif } else /* if post initailization failed */ { nfc_enabled(NCI_STATUS_FAILED, NULL); @@ -858,13 +844,6 @@ void NFC_Disable(void) { return; } -#if (NXP_EXTNS == TRUE) - if (nfc_cb.boot_mode != NFC_NORMAL_BOOT_MODE) { - nfc_nci_IoctlInOutData_t inpOutData; - inpOutData.inp.data.bootMode = NFC_NORMAL_BOOT_MODE; - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_BOOT_MODE, (void *)&inpOutData); - } -#endif /* Close transport and clean up */ nfc_task_shutdown_nfcc(); } @@ -1535,31 +1514,6 @@ int get_i2c_fragmentation_enabled() { return i2c_fragmentation_enabled; } #if (NXP_EXTNS == TRUE) /******************************************************************************* ** -** Function NFC_ReqWiredAccess -** -** Description This function request to pn54x driver to get access -** of P61. Status would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_ReqWiredAccess(void *pdata) { - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("NFC_ReqWiredAccess"); - - if (!nfcFL.nfcNxpEse) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("nfcNxpEse is not available.. Returning"); - return -1; - } - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_WIRED_MODE, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} - -/******************************************************************************* -** ** Function NFC_GetNCIVersion ** ** Description Called by higher layer to get the current nci @@ -1570,111 +1524,6 @@ int32_t NFC_ReqWiredAccess(void *pdata) { *******************************************************************************/ uint8_t NFC_GetNCIVersion() { return nfc_cb.nci_version; } -/******************************************************************************* -** -** Function NFC_RelWiredAccess -** -** Description This function release access -** of P61. Status would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelWiredAccess(void *pdata) { - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_IDLE_MODE, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} -/******************************************************************************* -** -** Function NFC_GetP61Status -** -** Description This function gets the current access state -** of P61. Current state would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_GetP61Status(void *pdata) { - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_PWR_MODE, &inpOutData); - *(uint32_t *)pdata = inpOutData.out.data.p61CurrentState; - return status; -} -/******************************************************************************* - * - ** Function NFC_DisableWired - ** - ** Description This function request to pn54x driver to - ** disable ese vdd gpio - ** - ** Returns 0 if api call success, else -1 - ** - *******************************************************************************/ -int32_t NFC_DisableWired(void *pdata) { - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_DISABLE_MODE, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} -/******************************************************************************* -** -** Function NFC_EnableWired -** -** Description This function request to pn54x driver to -** enable ese vdd gpio -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_EnableWired(void *pdata) { - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_ENABLE_MODE, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} - -/******************************************************************************* -** -** Function NFC_ReleaseEsePwr -** -** Description This function request to pn553 driver to -** turn ese vdd gpio low -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_ReleaseEsePwr(void *pdata) { - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_REL_ESE_PWR, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} - -/******************************************************************************* -** -** Function NFC_AcquireEsePwr -** -** Description This function request to pn553 driver to -** turn ese vdd gpio high -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_AcquireEsePwr(void *pdata) { - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_SET_ESE_PWR, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} - #if (NXP_EXTNS == TRUE) /******************************************************************************* ** @@ -1698,220 +1547,10 @@ void check_nfcee_session_and_reset() NFC_SetConfig(resetEseSessionCmd[2], resetEseSessionCmd); } -/******************************************************************************* -** -** Function NFC_SetP61Status -** -** Description This function set the JCOP download -** state to pn544 driver. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_SetP61Status(void *pdata, libnfc_jcop_dwnld_state_t isJcopState) { - if (!nfcFL.eseFL._ESE_JCOP_DWNLD_PROTECTION) { - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "NFC_SetP61Status :" - "ESE_JCOP_DWNLD_PROTECTION is not available.. Returning"); - return -1; - } - nfc_nci_IoctlInOutData_t inpOutData; - if (isJcopState == LIBNFC_JCP_DWNLD_START) - isJcopState = (libnfc_jcop_dwnld_state_t)nfc_cb.p_hal->ioctl( - HAL_NFC_IOCTL_SET_JCP_DWNLD_ENABLE, &inpOutData); - else if (isJcopState == LIBNFC_JCP_DWP_DWNLD_COMPLETE) - isJcopState = (libnfc_jcop_dwnld_state_t)( - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_JCP_DWNLD_DISABLE, &inpOutData)); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return isJcopState; -} #endif - -/******************************************************************************* -** -** Function NFC_eSEChipReset -** -** Description This function request to pn54x driver to -** chip reset the ESE using ISO_RST pin configuration. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_eSEChipReset(void *pdata) { - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_ESE_CHIP_RST, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} - -/******************************************************************************* -** -** Function NFC_GetEseAccess -** -** Description This function request to pn54x driver to get access -** of P61. it returns 0 on success. This api waits maximum -** defined timeout -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_GetEseAccess(void *pdata) { - int32_t status = NFC_STATUS_EPERM; - if ((nfcFL.eseFL._NXP_ESE_VER != JCOP_VER_3_1) && - (nfcFL.eseFL._NXP_ESE_VER != JCOP_VER_3_2)) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFC_GetEseAccess NXP_ESE_VER !=" - "JCOP_VER_3_1 or JCOP_VER_3_2 . Returning"); - return status; - } - nfc_nci_IoctlInOutData_t inpOutData; - - inpOutData.inp.data.timeoutMilliSec = *(uint32_t *)pdata; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_GET_ACCESS, &inpOutData); - return status; -} -/******************************************************************************* -** -** Function NFC_RelEseAccess -** -** Description This function release access of P61. -** it returns 0 on success. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelEseAccess(void *pdata) { - int32_t status = NFC_STATUS_EPERM; - if ((nfcFL.eseFL._NXP_ESE_VER != JCOP_VER_3_1) && - (nfcFL.eseFL._NXP_ESE_VER != JCOP_VER_3_2)) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFC_RelEseAccess NXP_ESE_VER !=" - "JCOP_VER_3_1 or JCOP_VER_3_2 . Returning"); - return status; - } - nfc_nci_IoctlInOutData_t inpOutData; - - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_P61_REL_ACCESS, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} - -/******************************************************************************* -** -** Function NFC_RelSvddWait -** -** Description This function release wait for svdd change -** of P61. Status would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelSvddWait(void *pdata) { - if (!nfcFL.eseFL._ESE_SVDD_SYNC) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFC_RelSvddWait :" - "ESE_SVDD_SYNC is not available.. Returning"); - return NFC_STATUS_EPERM; - } - nfc_nci_IoctlInOutData_t inpOutData; - int32_t status; - status = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_REL_SVDD_WAIT, &inpOutData); - *(tNFC_STATUS *)pdata = inpOutData.out.data.status; - return status; -} -/******************************************************************************* -** -** Function NFC_RelForceDwpOnOffWait -** -** Description This function release wait for DWP On/Off -** of P73. Status would be updated to pdata -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_RelForceDwpOnOffWait(void *pdata) { - return (nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_REL_DWP_WAIT, pdata)); -} #endif #if (NXP_EXTNS == TRUE) -/******************************************************************************* -** -** Function NFC_EnableDisableHalLog -** -** Description This function is used to enable/disable -** HAL log level. -** -*******************************************************************************/ -void NFC_EnableDisableHalLog(uint8_t type) { - if (0x01 == type || 0x00 == type) { - nfc_nci_IoctlInOutData_t inpOutData; - inpOutData.inp.data.halType = type; - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_DISABLE_HAL_LOG, &inpOutData); - } -} - -/******************************************************************************* -** -** Function NFC_SetNfcServicePid -** -** Description This function request to pn54x driver to -** update NFC service process ID for signalling. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_SetNfcServicePid() { - tNFC_STATUS setPidStatus = NFC_STATUS_OK; - nfc_nci_IoctlInOutData_t inpOutData; - if (NFC_IsLowRamDevice()) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFC_SetNfcServicePid: Not valid for low RAM device"); - return setPidStatus; - } - inpOutData.inp.data.nfcServicePid = getpid(); - setPidStatus = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_NFC_SERVICE_PID, - (void *)&inpOutData); - if (setPidStatus == NFC_STATUS_OK) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("nfc service set pid done"); - } else { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("nfc service set pid failed"); - } - return setPidStatus; -} -/******************************************************************************* -** -** Function NFC_ResetNfcServicePid -** -** Description This function request to pn54x driver to -** update NFC service process ID for signalling. -** -** Returns 0 if api call success, else -1 -** -*******************************************************************************/ -int32_t NFC_ResetNfcServicePid() { - tNFC_STATUS setPidStatus = NFC_STATUS_OK; - nfc_nci_IoctlInOutData_t inpOutData; - inpOutData.inp.data.nfcServicePid = 0; - if (NFC_IsLowRamDevice()) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFC_ResetNfcServicePid: Not valid for low RAM device"); - return setPidStatus; - } - setPidStatus = nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_SET_NFC_SERVICE_PID, - (void *)&inpOutData); - if (setPidStatus == NFC_STATUS_OK) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("nfc service set pid done"); - } else { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("nfc service set pid failed"); - } - return setPidStatus; -} /******************************************************************************* ** @@ -1974,16 +1613,10 @@ void NFC_SetStaticHciCback(tNFC_CONN_CBACK *p_cback) { void NFC_GetFeatureList() { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("NFC_GetFeatureList() Enter"); - tNFC_STATUS status = NFC_STATUS_FAILED; - nfc_nci_IoctlInOutData_t inpOutData; - status = - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_GET_FEATURE_LIST, (void *)&inpOutData); - if (status == NFC_STATUS_OK) { - chipType = (tNFC_chipType)inpOutData.out.data.chipType; - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFC_GetFeatureList ()chipType = %d", chipType); - - } else { + chipType = (tNFC_chipType)nfc_cb.p_hal->getchipType(); + if(chipType != 0x00) { + DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("NFC_GetFeatureList ()chipType = %d", chipType); + } else{ chipType = pn553; } CONFIGURE_FEATURELIST(chipType); diff --git a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc index 40f8cd9..2ac5695 100755 --- a/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc +++ b/halimpl/src/halLibnfc/src/nfc/nfc/nfc_ncif.cc @@ -47,7 +47,6 @@ #include "nfc_target.h" -#include "hal_nxpnfc.h" #include "nci_defs.h" #include "nci_hmsgs.h" #include "nfc_api.h" @@ -88,63 +87,6 @@ void disc_deact_ntf_timeout_handler(tNFC_RESPONSE_EVT event); /******************************************************************************* ** -** Function nfc_hal_nfcc_get_reset_info -** -** Description Register dump when CORE_RESET_NTF happens -** -** Returns status of command transceive -** -*******************************************************************************/ -uint8_t nfc_hal_nfcc_get_reset_info(void) { - nfc_nci_IoctlInOutData_t inpOutData; - /*NCI_RESET_CMD*/ - uint8_t nfc_hal_nfcc_get_reset_info[6][6] = { - { - 0x20, - 0x00, - 0x01, - 0x00, - }, - { - 0x20, - 0x01, - 0x00, - }, - {0x20, 0x03, 0x03, 0x01, 0xA0, 0x1A}, - {0x20, 0x03, 0x03, 0x01, 0xA0, 0x1B}, - {0x20, 0x03, 0x03, 0x01, 0xA0, 0x1C}, - {0x20, 0x03, 0x03, 0x01, 0xA0, 0x27}}; - uint8_t core_status = NCI_STATUS_FAILED; - uint8_t retry_count = 0; - uint8_t i = 0, j = 0; - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("%s Enter", __func__); - - for (i = 0; i < 6; i++) { - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = nfc_hal_nfcc_get_reset_info[i][2] + 3; - memcpy(inpOutData.inp.data.nciCmd.p_cmd, - (uint8_t *)&nfc_hal_nfcc_get_reset_info[i], - nfc_hal_nfcc_get_reset_info[i][2] + 3); - do { - core_status = - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_NCI_TRANSCEIVE, &inpOutData); - retry_count++; - } while (NCI_STATUS_OK != core_status && - retry_count < (NFC_NFCC_INIT_MAX_RETRY + 1)); - if (core_status == NCI_STATUS_OK) { - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "%s No.%d response for nfc_hal_nfcc_get_reset_info", __func__, i); - for (j = 0; j < inpOutData.out.data.nciRsp.rsp_len; j++) { - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - " %s 0x%02x", __func__, inpOutData.out.data.nciRsp.p_rsp[j]); - } - } - } - return core_status; -} - -/******************************************************************************* -** ** Function nfc_ncif_update_window ** ** Description Update tx cmd window to indicate that NFCC can received @@ -199,219 +141,8 @@ void nfc_ncif_cmd_timeout(void) { DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("nfc_ncif_cmd_timeout(): enter"); -#if (NXP_EXTNS == TRUE) - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("Start Middleware Recovery Procedure"); - { - // TO DO: - // Sending command which are core_reset,init,discovery as raw packet (Hard - // coding) - // and we have to match the RF state between before entering recovery and - // after recovery. - // finally, executing the last command which is before entering recovery, - // and invoking the callback. - - // step 1. Sending core reset/init command - // step 2. deciding to send command whether discovery or not. - // step 3. invoking the callback function which is registered at last time - // before entering recovery. - - /* - consist of buffer(p_core_init_rsp_params) - buffer[0] = Indicators 0:Normal mode 1:Recovery mode 2:core reset was last - command 3:core init was last command - buffer[1] = Last NFCC NCI RF State, 0:IDLE 1:DISCOVERY - buffer[2] = Length of discovery command to be sent as a part of recovery. - buffer[3~34] = Last Discovery command(including phase data).(32 byte) - buffer[35] = Indicator 0: No command to be sent after Recovery 1: Command - available to be sent after recovery buffer[36~294] = Last Command /or Last - Command including Data. buffer[295] = Last screen state - */ - uint8_t *buffer = NULL; - tNFC_CONN_CB *p_cb = NULL; - uint16_t bufflen = - 36 + 258 + - 2; // Initial data + max command size + 1 extra buffer + 1 screenState - uint16_t fw_dwnld_status = NFC_STATUS_FAILED; - tNFC_STATUS status = NFC_STATUS_FAILED; - tNFC_FWUpdate_Info_t fw_update_inf; - nfc_nci_IoctlInOutData_t inpOutData; - - /*Stop the command timeout timer*/ - nfc_stop_timer(&nfc_cb.nci_wait_rsp_timer); - - buffer = (uint8_t *)malloc(bufflen * sizeof(uint8_t)); - - if (NULL == buffer) { - LOG(ERROR) << StringPrintf("Recovery MEM Allocation is failed!!"); - return; - } - memset(buffer, 0x00, (bufflen * sizeof(uint8_t))); - - /*We need to send Core Reset and Core Init as a part of recovery*/ - buffer[0] = 0x01; - - /*Set the last screen state*/ - buffer[295] = gScreenState; - - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "MW last RF discovery flags 0x%x", nfa_dm_cb.disc_cb.disc_flags); - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "MW last RF discovery state 0x%x", nfa_dm_cb.disc_cb.disc_state); - - if (nfc_cb.nfc_state == NFC_STATE_CORE_INIT) { -#if (NXP_EXTNS == TRUE) - if (nfcFL.nfccFL._NFCC_MW_RCVRY_BLK_FW_DNLD) { - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "MW recovery should abort FW download checking at time of " - "cmd_timeout"); - } else { - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("Force FW Download !"); - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_CHECK_FLASH_REQ, &inpOutData); - fw_update_inf = - *(tNFC_FWUpdate_Info_t *)&inpOutData.out.data.fwUpdateInf; - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_FW_DWNLD, &inpOutData); - fw_dwnld_status = inpOutData.out.data.fwDwnldStatus; - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("FW Download 0x%x", fw_dwnld_status); - if (fw_dwnld_status != NFC_STATUS_OK) - nfc_enabled(NFC_STATUS_FAILED, NULL); - } -#else - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("Force FW Download !"); - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_CHECK_FLASH_REQ, &fw_update_inf); - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_FW_DWNLD, &fw_dwnld_status); - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("FW Download 0x%x", fw_dwnld_status); - if (fw_dwnld_status != NFC_STATUS_OK) - nfc_enabled(NFC_STATUS_FAILED, NULL); -#endif - } - - /*For debug purpose,register dump when CORE_RESET_NTF happens*/ - if (core_reset_init_num_buff) { - uint8_t stat = 0; - stat = nfc_hal_nfcc_get_reset_info(); - if (stat != NCI_STATUS_OK) - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("Failed to get reset info"); - } - - /*Prepare the DISCOVERY command*/ - if (!(nfa_dm_cb.disc_cb.disc_state > NFA_DM_RFST_IDLE)) { - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFCC last NCI RF state is IDLE"); - /*NCI stack RF state set to IDLE*/ - buffer[1] = 0x00; - } else { - uint8_t *ps = (uint8_t *)nfc_cb.p_last_disc; - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("NFCC last NCI RF state is DISCOVERY"); - /*Last NFCC state set to DISCOVERY*/ - buffer[1] = 0x01; - /*NCI stack RF state set to DISCOVERY*/ - nfa_dm_cb.disc_cb.disc_state = 0x01; - if (ps[0]) { - /*Set the length of last DISCOVERY packet including header*/ - buffer[2] = - 2 + 1 + 1 + - (ps[0] * - 2); /*HDR(2) + Length(1) + Configs(1) + Data(TechnMode(2) * 2)*/ - /*Copy the DISCOVERY command header*/ - memcpy((uint8_t *)&buffer[3], "\x21\x03", 2); - /*Set the length of content of the last DISCOVERY command*/ - buffer[5] = 1 + (ps[0] * 2); /*Configs(1) + Data(TechnMode(2) * 2)*/ - /*Copy the content of DISCOVERY command*/ - memcpy((uint8_t *)&buffer[6], ps, buffer[5]); - } else { - buffer[2] = 0x1A; /*Length of hard coded recovery discovery command*/ - memcpy((uint8_t *)&buffer[3], - "\x21\x03\x17\x0B\x00\x01\x01\x01\x02\x01\x03\x01\x80\x01\x81" - "\x01\x82\x01\x83\x01\x85\x01\x06\x01\x77\x01", - 24); - } - } - /*Prepare the last command sent just before CORE_RESET_NTF*/ - if (((nfc_cb.last_hdr[0] == 0x21 && nfc_cb.last_hdr[1] == 0x06) && - (nfc_cb.last_cmd_buf[0] == 0x01 && - nfc_cb.last_cmd_buf[1] == 0x01)) || /*DEACTIVATE TO SLEEP*/ - (nfc_cb.last_hdr[0] == 0x21 && nfc_cb.last_hdr[1] == 0x04) || /**/ - (nfc_cb.last_hdr[0] == 0x21 && nfc_cb.last_hdr[1] == 0x08) || /**/ - ((nfc_cb.last_hdr[0] == 0x21 && - nfc_cb.last_hdr[1] == 0x06) && /*DEACTIVATE TO DISCOVERY*/ - (nfc_cb.last_cmd_buf[0] == 0x01 && nfc_cb.last_cmd_buf[1] == 0x03))) { - buffer[35] = 0x00; /*No need to send last command*/ - } else if ((nfc_cb.last_hdr[0] == 0x20 && - (nfc_cb.last_hdr[1] == 0x02 || - nfc_cb.last_hdr[1] == 0x03)) || /*SET CONFIG COMMAND*/ - (nfc_cb.last_hdr[0] == 0x2F && - nfc_cb.last_hdr[1] == 0x15) || /*PROPRIETARY COMMAND*/ - (nfc_cb.last_hdr[0] == 0x21 && - nfc_cb.last_hdr[1] == 0x01) || /*LISTEN ROUTING COMMAND*/ - ((nfc_cb.last_hdr[0] == 0x21 && nfc_cb.last_hdr[1] == 0x06) && - (nfc_cb.last_cmd_buf[0] == 0x01 && - nfc_cb.last_cmd_buf[1] == 0x00)) /*DEACTIVATE TO IDLE*/ - ) { - /*Set indicating last command is available to be sent after recovery*/ - buffer[35] = 0x01; - - /*Copy the last HEADER*/ - memcpy(&buffer[36], nfc_cb.last_hdr, NFC_SAVED_HDR_SIZE); - /*Copy the last command*/ - memcpy(&buffer[38], nfc_cb.last_cmd_buf, nfc_cb.cmd_size + 1); - } else /*either CORE_RESET or CORE_INIT was the last command*/ - { - /*Set indicating last command is available to be sent after recovery*/ - buffer[35] = 0x01; - memcpy(&buffer[36], nfc_cb.last_hdr, NFC_SAVED_HDR_SIZE); - - buffer[38] = nfc_cb.cmd_size; /*Length of last command*/ - - if (nfc_cb.cmd_size > 0) /*last command was CORE_RESET*/ - memcpy(&buffer[39], nfc_cb.last_cmd, NFC_SAVED_CMD_SIZE); - else - buffer[35] = 0x00; /*last command was CORE_INIT*/ - if (nfc_cb.last_hdr[0] == 0x20 && nfc_cb.last_hdr[1] == 0x00) - buffer[0] = 2; /*indicate last command was CORE_RESET*/ - else if (nfc_cb.last_hdr[0] == 0x20 && nfc_cb.last_hdr[1] == 0x01) - buffer[0] = 3; /*indicate last command was CORE_INIT*/ - } - if (0xFF != nfcc_dh_conn_id) { - /* Flush the data if any before proceeding further with the recovery */ - p_cb = nfc_find_conn_cb_by_conn_id(nfcc_dh_conn_id); - if (NULL != p_cb) { - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "nfc_ncif_cmd_timeout(): connection id %d", nfcc_dh_conn_id); - status = NFC_FlushData(p_cb->conn_id); - if (status != NFC_STATUS_OK) { - LOG(ERROR) << StringPrintf( - "nfc_ncif_cmd_timeout(): NFC data flush failed"); - } - } - } - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf( - "nfc_ncif_cmd_timeout(): Indicator:0x%02X disc cmd len:0x%02X last cmd " - "len:0x%02X", - buffer[0], buffer[2], buffer[38]); - - nfc_cb.p_hal->core_initialized(bufflen, buffer); - if (buffer != NULL) - free(buffer); - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("nfc_ncif_cmd_timeout(): exit"); - } -#else - /* report an error */ - nfc_ncif_event_status(NFC_GEN_ERROR_REVT, NFC_STATUS_HW_TIMEOUT); - nfc_ncif_event_status(NFC_NFCC_TIMEOUT_REVT, NFC_STATUS_HW_TIMEOUT); - - /* if enabling NFC, notify upper layer of failure */ - if (nfc_cb.nfc_state == NFC_STATE_CORE_INIT) { - nfc_enabled(NFC_STATUS_FAILED, NULL); - } /* XXX maco since this failure is unrecoverable, abort the process */ abort(); -#endif } /******************************************************************************* @@ -2132,68 +1863,6 @@ void nfc_ncif_proc_reset_rsp(uint8_t *p, bool is_ntf) { } } -#if (NXP_EXTNS == TRUE) -uint8_t nfc_hal_nfcc_reset(void) { - nfc_nci_IoctlInOutData_t inpOutData; - /*NCI_RESET_CMD*/ - uint8_t cmd_reset_nci[] = {0x20, 0x00, 0x01, 0x00}; - uint8_t core_status = NCI_STATUS_FAILED; - uint8_t retry_count = 0; - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("Inside nfc_hal_nfcc_reset"); - - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - inpOutData.inp.data.nciCmd.cmd_len = sizeof(cmd_reset_nci); - memcpy(inpOutData.inp.data.nciCmd.p_cmd, cmd_reset_nci, - sizeof(cmd_reset_nci)); - do { - core_status = - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_NCI_TRANSCEIVE, &inpOutData); - retry_count++; - } while (NCI_STATUS_OK != core_status && - retry_count < (NFC_NFCC_INIT_MAX_RETRY + 1)); - return core_status; -} -uint8_t nfc_hal_nfcc_init(uint8_t **pinit_rsp) { - nfc_nci_IoctlInOutData_t inpOutData; - /*NCI_INIT_CMD*/ - uint8_t cmd_init_nci[] = {0x20, 0x01, 0x00}; - uint8_t cmd_init_nci2_0[] = {0x20, 0x01, 0x02, 0x00, 0x00}; - uint8_t init_status = NCI_STATUS_FAILED; - uint8_t retry_count = 0; - DLOG_IF(INFO, nfc_debug_enabled) << StringPrintf("Inside nfc_hal_nfcc_init"); - if (pinit_rsp == NULL) - return init_status; - - memset(&inpOutData, 0x00, sizeof(nfc_nci_IoctlInOutData_t)); - if (nfc_cb.nci_version == NCI_VERSION_1_0) { - inpOutData.inp.data.nciCmd.cmd_len = sizeof(cmd_init_nci); - memcpy(inpOutData.inp.data.nciCmd.p_cmd, cmd_init_nci, - sizeof(cmd_init_nci)); - } else { - inpOutData.inp.data.nciCmd.cmd_len = sizeof(cmd_init_nci2_0); - memcpy(inpOutData.inp.data.nciCmd.p_cmd, cmd_init_nci2_0, - sizeof(cmd_init_nci2_0)); - } - do { - init_status = - nfc_cb.p_hal->ioctl(HAL_NFC_IOCTL_NCI_TRANSCEIVE, &inpOutData); - retry_count++; - } while (NCI_STATUS_OK != init_status && - retry_count < (NFC_NFCC_INIT_MAX_RETRY + 1)); - if (init_status == NCI_STATUS_OK && inpOutData.out.data.nciRsp.rsp_len > 0) { - *pinit_rsp = (uint8_t *)GKI_getbuf(inpOutData.out.data.nciRsp.rsp_len); - if (NULL != *pinit_rsp) - memcpy(*pinit_rsp, inpOutData.out.data.nciRsp.p_rsp, - inpOutData.out.data.nciRsp.rsp_len); - else { - init_status = NCI_STATUS_FAILED; - DLOG_IF(INFO, nfc_debug_enabled) - << StringPrintf("nfc_hal_nfcc_init: Memory alocation failed"); - } - } - return init_status; -} -#endif /******************************************************************************* ** ** Function nfc_ncif_proc_init_rsp @@ -2615,4 +2284,4 @@ bool nfc_ncif_proc_proprietary_rsp(uint8_t mt, uint8_t gid, uint8_t oid) { return stat; } -#endif
\ No newline at end of file +#endif diff --git a/halimpl/tml/phTmlNfc.cc b/halimpl/tml/phTmlNfc.cc index fe8c8aa..9d15561 100755 --- a/halimpl/tml/phTmlNfc.cc +++ b/halimpl/tml/phTmlNfc.cc @@ -955,13 +955,6 @@ NFCSTATUS phTmlNfc_IoCtl(phTmlNfc_ControlCode_t eControlCode) { sem_post(&gpphTmlNfc_Context->rxSemaphore); break; } - case phTmlNfc_e_SetJcopDwnldEnable: { - if(nfcFL.nfcNxpEse) { - wStatus = phTmlNfc_i2c_set_Jcop_dwnld_state( - gpphTmlNfc_Context->pDevHandle, JCP_DWNLD_START); - } - break; - } case phTmlNfc_e_SetJcopDwnldDisable: { if(nfcFL.nfcNxpEse) { wStatus = phTmlNfc_i2c_set_Jcop_dwnld_state( @@ -997,44 +990,6 @@ NFCSTATUS phTmlNfc_IoCtl(phTmlNfc_ControlCode_t eControlCode) { } break; } - case phTmlNfc_e_SetP61DisableMode: { - if(nfcFL.nfcNxpEse) { - wStatus = phTmlNfc_i2c_set_p61_power_state( - gpphTmlNfc_Context->pDevHandle, 2); - } - break; - } - case phTmlNfc_e_SetP61EnableMode: { - { - wStatus = phTmlNfc_i2c_set_p61_power_state( - gpphTmlNfc_Context->pDevHandle, 3); - } - break; - } - case phTmlNfc_e_RelP61Access: { - if(nfcFL.nfcNxpEse) { - wStatus = phTmlNfc_i2c_set_p61_power_state( - gpphTmlNfc_Context->pDevHandle, 4); - } - break; - } - case phTmlNfc_e_RaiseEsePower: { - wStatus = phTmlNfc_i2c_set_p61_power_state( - gpphTmlNfc_Context->pDevHandle, 5); - break; - } - case phTmlNfc_e_ReleaseEsePower: { - wStatus = phTmlNfc_i2c_set_p61_power_state( - gpphTmlNfc_Context->pDevHandle, 6); - break; - } - case phTmlNfc_e_eSEChipRstMode: { - if(nfcFL.nfcNxpEse) { - wStatus = phTmlNfc_i2c_reset( - gpphTmlNfc_Context->pDevHandle, 3); - } - break; - } case phTmlNfc_e_SetLegacyPowerScheme: { if(nfcFL.nfcNxpEse) { wStatus = phTmlNfc_set_power_scheme( diff --git a/halimpl/tml/phTmlNfc.h b/halimpl/tml/phTmlNfc.h index 8162d35..ddbdeb9 100644 --- a/halimpl/tml/phTmlNfc.h +++ b/halimpl/tml/phTmlNfc.h @@ -112,17 +112,10 @@ typedef enum { phTmlNfc_e_SetP61WiredMode, /* Set the current P61 mode of operation to Wired*/ phTmlNfc_e_SetP61IdleMode, /* Set the current P61 mode of operation to Idle*/ - phTmlNfc_e_SetP61DisableMode, /* Set the ese vdd gpio to low*/ - phTmlNfc_e_SetP61EnableMode, /* Set the ese vdd gpio to high*/ - phTmlNfc_e_RaiseEsePower, /* Set the ese pwr gpio to high*/ - phTmlNfc_e_ReleaseEsePower, /* Set the ese pwr gpio to high*/ - phTmlNfc_e_eSEChipRstMode, /* ISO RST of P73*/ - phTmlNfc_e_RelP61Access, /*Release the P61 lock*/ phTmlNfc_e_SetLegacyPowerScheme, phTmlNfc_e_SetExtPMUPowerScheme, phTmlNfc_e_SetPN67TPowerScheme, phTmlNfc_e_RelP61SvddWait, - phTmlNfc_e_SetJcopDwnldEnable, phTmlNfc_e_SetJcopDwnldDisable } phTmlNfc_ControlCode_t; /* Control code for IOCTL call */ diff --git a/halimpl/tml/spi_spm.cc b/halimpl/tml/spi_spm.cc index 6b6a38f..d0f1de6 100755 --- a/halimpl/tml/spi_spm.cc +++ b/halimpl/tml/spi_spm.cc @@ -66,9 +66,6 @@ int phPalEse_spi_ioctl(phPalEse_ControlCode_t eControlCode, void *pDevHandle, case phPalEse_e_SetPowerScheme: ret = 0; break; - case phPalEse_e_GetEseAccess: - ret = 0; - break; case phPalEse_e_DisablePwrCntrl: ret = ioctl((intptr_t)pDevHandle, P61_SET_SPI_PWR, 1); break; diff --git a/halimpl/tml/spi_spm.h b/halimpl/tml/spi_spm.h index 0162c1d..f10af71 100755 --- a/halimpl/tml/spi_spm.h +++ b/halimpl/tml/spi_spm.h @@ -30,7 +30,6 @@ typedef enum { phPalEse_e_ResetDevice = PH_PALESE_RESETDEVICE, /*!< Reset the device */ phPalEse_e_EnableLog, /*!< Enable the spi driver logs */ phPalEse_e_EnablePollMode, /*!< Enable the polling for SPI */ - phPalEse_e_GetEseAccess, /*!< get the bus access in specified timeout */ phPalEse_e_ChipRst, /*!< eSE Chip reset using ISO RST pin*/ phPalEse_e_EnableThroughputMeasurement, /*!< Enable throughput measurement */ phPalEse_e_SetPowerScheme, /*!< Set power scheme */ diff --git a/halimpl/utils/phNxpConfig.cpp b/halimpl/utils/phNxpConfig.cpp index 6f36560..8c57313 100644 --- a/halimpl/utils/phNxpConfig.cpp +++ b/halimpl/utils/phNxpConfig.cpp @@ -54,11 +54,11 @@ #include <vector> #include <list> #include <sys/stat.h> -#include <stdlib.h> #include <phNxpLog.h> -#include <cutils/properties.h> +#include <android-base/properties.h> #include "sparse_crc32.h" +#include <cutils/properties.h> #if GENERIC_TARGET const char alternative_config_path[] = "/data/vendor/nfc/"; @@ -579,18 +579,20 @@ inline int getDigitValue(char c, int base) { ** Returns: none ** *******************************************************************************/ -void findConfigFilePathFromTransportConfigPaths(const string& configName, +bool findConfigFilePathFromTransportConfigPaths(const string& configName, string& filePath) { for (int i = 0; i < transport_config_path_size; i++) { + if (configName.empty()) break; filePath.assign(transport_config_paths[i]); filePath += configName; struct stat file_stat; if (stat(filePath.c_str(), &file_stat) == 0 && S_ISREG(file_stat.st_mode)) { - return; + return true; } } // Config file didnt exist in any of the transport config_paths. - filePath.assign(""); + filePath = ""; + return false; } /******************************************************************************* diff --git a/halimpl/utils/phNxpConfig.h b/halimpl/utils/phNxpConfig.h index 4e8a735..b078f1a 100644 --- a/halimpl/utils/phNxpConfig.h +++ b/halimpl/utils/phNxpConfig.h @@ -56,6 +56,7 @@ int updateNxpConfigTimestamp(); #define NAME_NXPLOG_TML_LOGLEVEL "NXPLOG_TML_LOGLEVEL" #define NAME_NFC_DEBUG_ENABLED "NFC_DEBUG_ENABLED" #define NAME_MIFARE_READER_ENABLE "MIFARE_READER_ENABLE" +#define NAME_LEGACY_MIFARE_READER "LEGACY_MIFARE_READER" #define NAME_FW_STORAGE "FW_STORAGE" #define NAME_NXP_NFC_DEV_NODE "NXP_NFC_DEV_NODE" #define NAME_NXP_NFC_CHIP "NXP_NFC_CHIP" @@ -96,6 +97,7 @@ int updateNxpConfigTimestamp(); #define NAME_NFA_POLL_BAIL_OUT_MODE "NFA_POLL_BAIL_OUT_MODE" #define NAME_DEFAULT_OFFHOST_ROUTE "DEFAULT_OFFHOST_ROUTE" #define NAME_DEFAULT_NFCF_ROUTE "DEFAULT_NFCF_ROUTE" +#define NAME_DEFAULT_TECH_ABF_ROUTE "DEFAULT_TECH_ABF_ROUTE" #define NAME_DEFAULT_SYS_CODE_ROUTE "DEFAULT_SYS_CODE_ROUTE" #define NAME_DEFAULT_SYS_CODE_PWR_STATE "DEFAULT_SYS_CODE_PWR_STATE" #define NAME_OFFHOST_ROUTE_ESE "OFFHOST_ROUTE_ESE" @@ -107,7 +109,6 @@ int updateNxpConfigTimestamp(); #define NAME_OFF_HOST_SIM_PIPE_ID "OFF_HOST_SIM_PIPE_ID" #define NAME_NFA_PROPRIETARY_CFG "NFA_PROPRIETARY_CFG" #define NAME_PRESENCE_CHECK_ALGORITHM "PRESENCE_CHECK_ALGORITHM" -#define NAME_NXP_PHASE_TIRM_OFFSET_SIGN_UPDATE "NXP_PHASE_TIRM_OFFSET_SIGN_UPDATE" #define NAME_AID_MATCHING_PLATFORM "AID_MATCHING_PLATFORM" #define NAME_DEFAULT_SYS_CODE "DEFAULT_SYS_CODE" #define NAME_NXP_TYPEA_UICC_BAUD_RATE "NXP_TYPEA_UICC_BAUD_RATE" @@ -141,8 +142,10 @@ int updateNxpConfigTimestamp(); "NXP_CORE_SCRN_OFF_AUTONOMOUS_ENABLE" #define NAME_NXP_ESE_LS_DEFAULT_INTERFACE "NXP_ESE_LS_DEFAULT_INTERFACE" #define NAME_NXP_ESE_JCOP_DEFAULT_INTERFACE "NXP_ESE_JCOP_DEFAULT_INTERFACE" +#define NAME_NXP_CORE_PWR_OFF_AUTONOMOUS_ENABLE "NXP_CORE_PWR_OFF_AUTONOMOUS_ENABLE" #define NAME_NXP_AGC_DEBUG_ENABLE "NXP_AGC_DEBUG_ENABLE" #define NAME_DEFAULT_NFCF_PWR_STATE "DEFAULT_NFCF_PWR_STATE" +#define NAME_DEFAULT_TECH_ABF_PWR_STATE "DEFAULT_TECH_ABF_PWR_STATE" #define NAME_NXP_HCEF_CMD_RSP_TIMEOUT_VALUE "NXP_HCEF_CMD_RSP_TIMEOUT_VALUE" #define NAME_CHECK_DEFAULT_PROTO_SE_ID "NXP_CHECK_DEFAULT_PROTO_SE_ID" #define NAME_NXP_NFCC_PASSIVE_LISTEN_TIMEOUT "NXP_NFCC_PASSIVE_LISTEN_TIMEOUT" @@ -156,6 +159,8 @@ int updateNxpConfigTimestamp(); #define NAME_NXP_PROP_RESET_EMVCO_CMD "NXP_PROP_RESET_EMVCO_CMD" #define NAME_NFA_CONFIG_FORMAT "NFA_CONFIG_FORMAT" #define NAME_ETSI_READER_ENABLE "ETSI_READER_ENABLE" +#define NAME_WTAG_SUPPORT "WTAG_SUPPORT" +#define NAME_DEFAULT_T4TNFCEE_AID_POWER_STATE "DEFAULT_T4TNFCEE_AID_POWER_STATE" /** * @brief defines the different config files used. */ |