1 /****************************************************************************** 2 * 3 * 4 * Copyright 2015-2019, 2021-2023 NXP 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 ******************************************************************************/ 19 #pragma once 20 #include <utils/RefBase.h> 21 #include <vendor/nxp/nxpese/1.0/INxpEse.h> 22 23 #include "NxpNfcThreadMutex.h" 24 #include "ese_hal_api.h" 25 #include "hal_nxpese.h" 26 using vendor::nxp::nxpese::V1_0::INxpEse; 27 28 class EseAdaptation { 29 public: 30 void Initialize(); 31 void InitializeHalDeviceContext(); 32 virtual ~EseAdaptation(); 33 static EseAdaptation& GetInstance(); 34 static int HalIoctl(long arg, void* p_data); 35 tHAL_ESE_ENTRY* GetHalEntryFuncs(); 36 ese_nxp_IoctlInOutData_t* mCurrentIoctlData; 37 tHAL_ESE_ENTRY mSpiHalEntryFuncs; // function pointers for HAL entry points 38 39 private: 40 EseAdaptation(); 41 void signal(); 42 static EseAdaptation* mpInstance; 43 static NfcHalThreadMutex sLock; 44 static NfcHalThreadMutex sIoctlLock; 45 NfcHalThreadCondVar mCondVar; 46 static tHAL_ESE_CBACK* mHalCallback; 47 static tHAL_ESE_DATA_CBACK* mHalDataCallback; 48 static NfcHalThreadCondVar mHalOpenCompletedEvent; 49 static NfcHalThreadCondVar mHalCloseCompletedEvent; 50 static NfcHalThreadCondVar mHalIoctlEvent; 51 static android::sp<vendor::nxp::nxpese::V1_0::INxpEse> mHalNxpEse; 52 static NfcHalThreadCondVar mHalCoreResetCompletedEvent; 53 static NfcHalThreadCondVar mHalCoreInitCompletedEvent; 54 static NfcHalThreadCondVar mHalInitCompletedEvent; 55 static uint32_t Thread(); 56 static void HalDeviceContextDataCallback(uint16_t data_len, uint8_t* p_data); 57 58 static void HalOpen(tHAL_ESE_CBACK* p_hal_cback, 59 tHAL_ESE_DATA_CBACK* p_data_cback); 60 static void HalClose(); 61 static void HalWrite(uint16_t data_len, uint8_t* p_data); 62 static void HalRead(uint16_t data_len, uint8_t* p_data); 63 }; 64 tHAL_ESE_ENTRY* getInstance(); 65