15d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 25d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Copyright (C) 2010 NXP Semiconductors 35d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 45d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Licensed under the Apache License, Version 2.0 (the "License"); 55d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * you may not use this file except in compliance with the License. 65d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * You may obtain a copy of the License at 75d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 85d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * http://www.apache.org/licenses/LICENSE-2.0 95d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Unless required by applicable law or agreed to in writing, software 115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * distributed under the License is distributed on an "AS IS" BASIS, 125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * See the License for the specific language governing permissions and 145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * limitations under the License. 155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== * 195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \file phHciNfc_Emulation.c * 225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief HCI Emulation management routines. * 235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* Project: NFC-FRI-1.1 * 265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Date: Tue Jun 8 09:30:37 2010 $ * 285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Author: ing04880 $ * 295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Revision: 1.52 $ * 305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* * 325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* =========================================================================== * 335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly***************************** Header File Inclusion **************************** 375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcConfig.h> 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcCompId.h> 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phNfcHalTypes.h> 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Pipe.h> 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_Emulation.h> 435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_WI.h> 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_SWP.h> 455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_NfcIPMgmt.h> 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef HOST_EMULATION 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_CE_A.h> 505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc_CE_B.h> 515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h> 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly****************************** Macro Definitions ******************************* 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Structure and Enumeration *************************** 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** \defgroup grp_hci_nfc HCI Emulation Management Component 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellytypedef enum phHciNfc_EmulationMgmt_Seq{ 695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCIP_TARGET_PIPE_OPEN = 0x00U, 705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCIP_TARGET_MODE_CONFIG, 715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCIP_TARGET_MERGE_SAK, 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCIP_TARGET_PIPE_CLOSE, 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HOST_CE_A_INIT, 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HOST_CE_A_RELEASE, 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HOST_CE_B_INIT, 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HOST_CE_B_RELEASE, 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_PIPE_OPEN, 815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_ENABLE_EMULATION, 825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_DEFAULT_EMULATION, 835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_DISABLE_EMULATION, 845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_ENABLE_NOTIFICATION, 865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_DISABLE_NOTIFICATION, 875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_SWITCH_WIRED_MODE, 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_SWITCH_DEFAULT_MODE, 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_PIPE_CLOSE, 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_PIPE_OPEN, 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_ENABLE_EMULATION, 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DEFAULT_EMULATION, 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DETECTION, 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DISABLE_EMULATION, 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_GET_BIT_RATE, 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_PIPE_CLOSE, 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly CONFIG_DEFAULT_EMULATION, 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly END_EMULATION_SEQ 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} phHciNfc_EmulationMgmt_Seq_t; 1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellytypedef struct phHciNfc_EmulationMgmt_Info{ 1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_eEmulationType_t se_default; 1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t smx_powerless; 1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_enable; 1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_powerless; 1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_id; 1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Application ID of the UICC Transaction performed */ 1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_aid[MAX_AID_LEN]; 1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_param[MAX_UICC_PARAM_LEN]; 1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_param_len; 1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_uicc_pipe_info; 1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Seq_t emulation_cur_seq; 1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Seq_t emulation_next_seq; 1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} phHciNfc_EmulationMgmt_Info_t; 1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Static Function Declaration ************************** 1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_Uicc_Cmd ( 1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pCmd, 1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_Uicc_Event ( 1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pEvent, 1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*************************** Function Definitions *************************** 1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid 1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Uicc_Connectivity( 1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *pPipeInfo = NULL; 1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info = NULL; 1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL != psHciContext->p_emulation_mgmt_info ) 1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = (phHciNfc_EmulationMgmt_Info_t *) 1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo = psHciContext->p_pipe_list[NXP_PIPE_CONNECTIVITY]; 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (TRUE == ((phHal_sHwReference_t *)pHwRef)->uicc_connected) 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL == pPipeInfo)) 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Allocate_Resource((void **)&pPipeInfo, 1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHciNfc_Pipe_Info_t)); 1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL != pPipeInfo) 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NFCSTATUS_SUCCESS == status)) 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* The Source Host is the UICC Host */ 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->pipe.source.host_id = 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) phHciNfc_UICCHostID; 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* The Source Gate is same as the Destination Gate */ 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->pipe.source.gate_id = 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) phHciNfc_ConnectivityGate; 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* The Destination Host is the Terminal Host */ 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->pipe.dest.host_id = 1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) phHciNfc_TerminalHostID; 1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* The Source Gate is same as the Destination Gate */ 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->pipe.dest.gate_id = 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t) phHciNfc_ConnectivityGate; 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* The Pipe ID is Hardcoded to Connectivity */ 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->pipe.pipe_id = (uint8_t) NXP_PIPE_CONNECTIVITY; 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Uicc_Update_PipeInfo(psHciContext, 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NXP_PIPE_CONNECTIVITY, pPipeInfo); 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_SUCCESS == status) 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_pipe_list[NXP_PIPE_CONNECTIVITY] = pPipeInfo; 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_enable = TRUE; 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)phOsalNfc_FreeMemory(pPipeInfo); 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Get the pipe_id of Connectivity Managment Gate. 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * This function Get the pipe_id of Connectivity Managment Gate. 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Uicc_Get_PipeID( 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *ppipe_id 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info = NULL; 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL != psHciContext) 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( NULL != ppipe_id ) 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && ( NULL != psHciContext->p_emulation_mgmt_info ) 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = (phHciNfc_EmulationMgmt_Info_t *) 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *ppipe_id = p_emulation_mgmt_info->uicc_id ; 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* Function to Update the Pipe Information */ 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Uicc_Update_PipeInfo( 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id, 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *pPipeInfo 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info=NULL; 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext ) 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if ( NULL == psHciContext->p_emulation_mgmt_info ) 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION); 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = (phHciNfc_EmulationMgmt_Info_t *) 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update the pipe_id of the Connectivity Gate 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * obtained from the HCI Response */ 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_id = pipe_id; 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->p_uicc_pipe_info = pPipeInfo; 2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( NULL != pPipeInfo) 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Update the Response Receive routine of the Connectivity Gate */ 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* pPipeInfo->recv_resp = phHciNfc_Recv_Uicc_Response; */ 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->recv_cmd = &phHciNfc_Recv_Uicc_Cmd; 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pPipeInfo->recv_event = &phHciNfc_Recv_Uicc_Event; 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Updates the Sequence of Emulation Managment Gate. 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function Resets/Updates the sequence of the Emulation Management 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* gate. 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_EmuMgmt_Update_Seq( 2995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 3005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eSeqType_t seq_type 3015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info=NULL; 3045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 3055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext ) 3065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 3085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext->p_emulation_mgmt_info ) 3125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 3145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 3155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = (phHciNfc_EmulationMgmt_Info_t *) 3195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 3205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(seq_type) 3215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case RESET_SEQ: 3235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case INIT_SEQ: 3245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P 3265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_cur_seq = NFCIP_TARGET_PIPE_OPEN; 3275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 3285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_cur_seq = WI_PIPE_OPEN; 3295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 3305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = END_EMULATION_SEQ ; 3315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UPDATE_SEQ: 3345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_cur_seq = 3365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq; 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case INFO_SEQ: 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_cur_seq = SWP_ENABLE_EMULATION; 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = END_EMULATION_SEQ ; 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case REL_SEQ: 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_cur_seq = WI_DISABLE_EMULATION; 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = END_EMULATION_SEQ ; 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Initialisation of RF Emulation Gates. 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function initialses the RF Emulation Management and 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* populates the Reader Management Information Structure 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 3735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_EmuMgmt_Initialise( 3745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info = NULL; 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info=NULL; 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext ) 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( ( NULL == psHciContext->p_emulation_mgmt_info ) 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (phHciNfc_Allocate_Resource((void **)(&p_emulation_mgmt_info), 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHciNfc_EmulationMgmt_Info_t))== NFCSTATUS_SUCCESS) 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info = p_emulation_mgmt_info; 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_cur_seq = NFCIP_TARGET_PIPE_OPEN; 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_cur_seq = WI_PIPE_OPEN; 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = END_EMULATION_SEQ; 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_id = (uint8_t)HCI_UNKNOWN_PIPE_ID; 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = (phHciNfc_EmulationMgmt_Info_t *) 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext->p_emulation_mgmt_info ) 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INSUFFICIENT_RESOURCES); 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ESTABLISH_SESSION 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(( hciMode_Session == psHciContext->hci_mode ) 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NFCIP_TARGET_PIPE_OPEN == p_emulation_mgmt_info->emulation_cur_seq ) 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(p_emulation_mgmt_info->emulation_cur_seq ) 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ENABLE_P2P 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* NFCIP Target Open sequence */ 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFCIP_TARGET_PIPE_OPEN: 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_NfcIP_Info_t *) 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_nfcip_info)->p_tgt_pipe_info; 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Open_Pipe( psHciContext, 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, p_pipe_info ); 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCIP_TARGET_MODE_CONFIG; 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* NFCIP Target Mode Config sequence */ 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFCIP_TARGET_MODE_CONFIG: 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NFCIP_ACTIVE_SHIFT 0x03U 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define NFCIP_PASSIVE_MASK 0x07U 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t mode = ( NXP_NFCIP_ACTIVE_DEFAULT << NFCIP_ACTIVE_SHIFT ) | 45600c98d516cac9dcdad6c22400267a2fd2bea3adfNick Pelly ( DEFAULT_NFCIP_TARGET_MODE_SUPPORT & NFCIP_PASSIVE_MASK ); 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_NfcIP_SetMode( psHciContext, pHwRef, 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCIP_TARGET, mode); 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING ) 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TGT_MERGE_SAK 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCIP_TARGET_MERGE_SAK; 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_PIPE_OPEN; 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TGT_MERGE_SAK */ 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = NFCSTATUS_SUCCESS; */ 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TGT_MERGE_SAK 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* NFCIP Target SAK Merge sequence */ 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFCIP_TARGET_MERGE_SAK: 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_NfcIP_SetMergeSak( psHciContext, pHwRef, 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly TRUE ); 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING ) 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_PIPE_OPEN; 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = NFCSTATUS_SUCCESS; */ 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef TGT_MERGE_SAK */ 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /* #ifdef ENABLE_P2P */ 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Secure Element WI pipe open sequence */ 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case WI_PIPE_OPEN: 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_WI_Info_t *) 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_wi_info)->p_pipe_info; 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Open_Pipe( psHciContext, 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, p_pipe_info ); 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef DISABLE_WI_NOTIFICATION 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_PIPE_OPEN; 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_ENABLE_NOTIFICATION; 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Enable the SmartMx Notifications through WI */ 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case WI_ENABLE_NOTIFICATION: 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_WI_Info_t *) 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_wi_info)->p_pipe_info; 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_WI_Configure_Notifications( 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef, eEnableEvents ); 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_PIPE_OPEN; 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Enable the SmartMx Emulation by Default through WI */ 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case WI_ENABLE_EMULATION: 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_WI_Info_t *) 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_wi_info)->p_pipe_info; 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_WI_Configure_Default( psHciContext, 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, TRUE ); 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_PIPE_OPEN; 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* SWP pipe open sequence */ 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_PIPE_OPEN: 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_SWP_Info_t *) 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->p_pipe_info; 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Open_Pipe( psHciContext, 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, p_pipe_info ); 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_ENABLE_EMULATION; 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifndef ESTABLISH_SESSION 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Enable the UICC Emulation through SWP */ 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_ENABLE_EMULATION: 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_SWP_Info_t *) 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->p_pipe_info; 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef SWP_EVENT_USAGE 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Mode( psHciContext, pHwRef, 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UICC_SWITCH_MODE_ON ); 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* UICC_SWITCH_MODE_DEFAULT */ 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Default( psHciContext, 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, TRUE ); 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DETECTION; 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = NFCSTATUS_SUCCESS; */ 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disable the UICC Emulation through SWP */ 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_DETECTION: 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_SWP_Info_t *) 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->p_pipe_info; 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Uicc_Connect_Status( 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t uicc_connect = ((phHciNfc_SWP_Info_t *) 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->uicc_status; 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(UICC_CONNECTED == uicc_connect) 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef SWP_EVENT_USAGE 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DISABLE_EMULATION; 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_DISABLE_EMULATION; 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHal_sHwReference_t *) 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef)->uicc_connected = TRUE; 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_PENDING; 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Mode( psHciContext, 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, UICC_SWITCH_MODE_DEFAULT ); 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (NFCSTATUS_PENDING == status)? 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (p_emulation_mgmt_info->emulation_next_seq = 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_DISABLE_EMULATION): 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (p_emulation_mgmt_info->emulation_next_seq = 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DETECTION); 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disable the SmartMx Emulation through WI */ 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case WI_DISABLE_EMULATION: 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_WI_Info_t *) 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_wi_info)->p_pipe_info; 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_WI_Configure_Mode( psHciContext, 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, eSmartMx_Default ); 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DISABLE_EMULATION; 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifndef SWP_EVENT_USAGE 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the UICC Baud Rate Status */ 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_GET_BIT_RATE: 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_SWP_Info_t *) 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->p_pipe_info; 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Get_Bitrate( 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DISABLE_EMULATION; 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* fall through */ 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disable the UICC Emulation through SWP */ 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_DISABLE_EMULATION: 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_SWP_Info_t *) 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->p_pipe_info; 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Mode( psHciContext, 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, UICC_SWITCH_MODE_DEFAULT ); 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_DISABLE_EMULATION; 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disable WI Emulation for Previous Wired 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Mode Set */ 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = NFCSTATUS_SUCCESS; */ 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE); 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Sequence Switch */ 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Reader Info Memory Check */ 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Null Context Check */ 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Connection Routine for the Uicc. 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function tries to enable and initialise the UICC connected 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* through SWP. 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Uicc_Connect_Status( 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* phHciNfc_Pipe_Info_t *p_pipe_info = NULL; */ 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info=NULL; */ 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static uint32_t uicc_connection_retry = 0; 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext ) 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_SWP_Status_t uicc_status = 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHciNfc_SWP_Info_t *) 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->uicc_status; 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(uicc_connection_retry == 0) 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef UICC_STATUS_DELAY 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for( ;uicc_connection_retry < UICC_STATUS_DELAY_COUNT; 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_connection_retry ++ ); 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_connection_retry = 0; 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Get_Status( 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_PENDING == status) 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_connection_retry++; 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(uicc_status) 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_CONNECTION_ONGOING: 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_DISCONNECTION_ONGOING: 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_NOT_CONNECTED: 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(uicc_connection_retry < 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UICC_MAX_CONNECT_RETRY) 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Get_Status( 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext, pHwRef ); 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NFCSTATUS_PENDING == status) 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_connection_retry++; 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_CONNECTED: 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_CONNECTION_LOST: 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_CONNECTION_FAILED: 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_connection_retry = 0; 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of the Status Switch */ 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NFCSTATUS_PENDING != status ) 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_connection_retry = 0; 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Error Scenario due to SWP Disable Config */ 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Null Context Check */ 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*! 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* \brief Release of RF Emulation Gate Configuration. 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* This function initialses the RF Emulation Management and 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* populates the Reader Management Information Structure 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_EmuMgmt_Release( 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info = NULL; 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info=NULL; 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext ) 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = (phHciNfc_EmulationMgmt_Info_t *) 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == psHciContext->p_emulation_mgmt_info ) 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INSUFFICIENT_RESOURCES); 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(p_emulation_mgmt_info->emulation_cur_seq ) 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Enable/Disable the SmartMx Emulation through WI 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * After the power down 8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Enable the SmartMx Emulation by Default through WI */ 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case WI_DEFAULT_EMULATION: 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_WI_Info_t *) 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_wi_info)->p_pipe_info; 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_WI_Configure_Default( psHciContext, 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, p_emulation_mgmt_info->smx_powerless ); 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly WI_DISABLE_EMULATION; 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* SmartMx In Default Mode */ 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case WI_DISABLE_EMULATION: 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_WI_Info_t *) 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_wi_info)->p_pipe_info; 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_WI_Configure_Mode( psHciContext, 9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, eSmartMx_Default ); 9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS ) 9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DISABLE_EMULATION; 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_EmuMgmt_Update_Seq(psHciContext, 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = NFCSTATUS_PENDING; */ 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Enable/Disable the UICC Emulation through SWP 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * After the power down 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Enable the UICC Emulation by Default through SWP */ 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_DEFAULT_EMULATION: 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_SWP_Info_t *) 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->p_pipe_info; 9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Default( psHciContext, 9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, p_emulation_mgmt_info->uicc_powerless ); 9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SWP_DISABLE_EMULATION; 9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = NFCSTATUS_SUCCESS; */ 9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Disable the UICC Emulation through SWP */ 9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_DISABLE_EMULATION: 9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = ((phHciNfc_SWP_Info_t *) 9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_swp_info)->p_pipe_info; 9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Mode( psHciContext, 9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, UICC_SWITCH_MODE_DEFAULT ); 9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly CONFIG_DEFAULT_EMULATION; 9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_EmuMgmt_Update_Seq(psHciContext, 9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configure the Default Secure Element Emulation */ 9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case CONFIG_DEFAULT_EMULATION: 9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0 9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == p_pipe_info ) 9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, 9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_HCI_INFORMATION); 9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = phHciNfc_DevMgmt_Configure( psHciContext, 9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, , ); */ 9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_PENDING) 9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->emulation_next_seq = 9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly END_EMULATION_SEQ; 9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_EmuMgmt_Update_Seq(psHciContext, 10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UPDATE_SEQ); 10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE); 10105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Sequence Switch */ 10145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* End of the Reader Info Memory Check */ 10165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Null Context Check */ 10185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 10205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 10215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#if 0 10235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 10245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Emulation_Start ( 10255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 10265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef 10275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 10285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 10295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 10305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 10325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 10335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 10345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 10365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Emulation_Cfg ( 10375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext, 10385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 10395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_eConfigType_t cfg_type 10405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 10415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 10425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 10435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info=NULL; 10445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sEmulationCfg_t *p_emulation_cfg = NULL; 10455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == psHciContext) || (NULL == pHwRef) ) 10475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 10495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if ( ( NULL == psHciContext->p_emulation_mgmt_info ) 10515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( NULL == psHciContext->p_config_params ) ) 10525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION); 10545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = (phHciNfc_EmulationMgmt_Info_t *) 10585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 10595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_cfg = psHciContext->p_config_params; 10605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(cfg_type) 10615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SMX_WI_CFG: 10635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sSmartMX_Cfg_t *smx_config = 10655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &p_emulation_cfg->config.smartMxCfg; 10665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->smx_powerless = 10675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)(FALSE != smx_config->lowPowerMode ); 10685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_WI_Configure_Default( psHciContext, pHwRef, 10695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly smx_config->enableEmulation ); 10705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case UICC_SWP_CFG: 10735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef SWP_CFG_SEQ 10755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sUiccEmuCfg_t *uicc_config = 10765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &p_emulation_cfg->config.uiccEmuCfg; 10775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_powerless = 10785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)(FALSE != uicc_config->lowPowerMode ); 10795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef SWP_EVENT_USAGE 10815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Mode( psHciContext, pHwRef, 10825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((TRUE == uicc_config->enableUicc)? /* UICC_SWITCH_MODE_DEFAULT */ 10835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UICC_SWITCH_MODE_ON :UICC_SWITCH_MODE_OFF)); 10845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 10855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Default( psHciContext, pHwRef, 10865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uicc_config->enableUicc ); 10875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 10885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 10905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Config_Sequence( psHciContext, 10915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, p_emulation_cfg); 10925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 10935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case SWP_EVT_CFG: 10965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sUiccEmuCfg_t *uicc_config = 10985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &p_emulation_cfg->config.uiccEmuCfg; 10995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_powerless = 11005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (uint8_t)(FALSE != uicc_config->lowPowerMode ); 11015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_SWP_Configure_Mode( psHciContext, pHwRef, 11035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((TRUE == uicc_config->enableUicc)? /* UICC_SWITCH_MODE_DEFAULT */ 11045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly UICC_SWITCH_MODE_ON :UICC_SWITCH_MODE_DEFAULT)); 11055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef HOST_EMULATION 11095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_CE_A_CFG: 11105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHostEmuCfg_A_t *host_ce_a_cfg = 11125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &p_emulation_cfg->config.hostEmuCfg_A; 11135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(host_ce_a_cfg->enableEmulation == TRUE ) 11145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_CE_A_Initialise( psHciContext, pHwRef); 11165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_CE_A_Release( psHciContext, pHwRef); 11205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_CE_B_CFG: 11245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHostEmuCfg_B_t *host_ce_b_cfg = 11265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &p_emulation_cfg->config.hostEmuCfg_B; 11275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(host_ce_b_cfg->enableEmulation == TRUE ) 11285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_CE_B_Initialise( psHciContext, pHwRef); 11305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_CE_B_Release( psHciContext, pHwRef); 11345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 11385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* case INVALID_CFG: 11395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case POLL_LOOP_CFG: */ 11405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 11415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION); 11435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of the Configuration Switch */ 11475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 11505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 11515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 11545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 11555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_Uicc_Cmd ( 11565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 11575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 11585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pCmd, 11595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 11605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 11615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 11625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 11635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 11645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 11655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 11665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID; 11675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t cmd = (uint8_t) HCP_MSG_INSTRUCTION_INVALID; 11685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t response = (uint8_t) ANY_OK; 11695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 11705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = 11715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHciNfc_sContext_t *)psContext ; 11725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet = NULL; 11735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *hcp_message = NULL; 11745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Pipe_Info_t *p_pipe_info = NULL; 11755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info=NULL; 11765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == psHciContext) 11785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == pHwRef) 11795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (HCP_HEADER_LEN > length ) 11805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 11815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER); 11835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 11855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet = (phHciNfc_HCP_Packet_t *)pCmd; 11875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message = &hcp_packet->msg.message; 11885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info = psHciContext->p_emulation_mgmt_info; 11895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Command instruction bits from the Message Header */ 11915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly cmd = (uint8_t) GET_BITS8( hcp_message->msg_header, 11925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN); 11935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id = p_emulation_mgmt_info->uicc_id; 11945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info = psHciContext->p_pipe_list[pipe_id]; 11955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 11965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch( cmd ) 11975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* These are Commands are sent from the UICC Controller */ 11995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_OPEN_PIPE: 12005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_enable = TRUE ; 12025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_CLOSE_PIPE: 12055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(TRUE != p_emulation_mgmt_info->uicc_enable) 12075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly response = ANY_E_PIPE_NOT_OPENED; 12095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FAILED); */ 12105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_enable = FALSE; 12145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_SET_PARAMETER: 12185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case ANY_GET_PARAMETER: 12195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case PRO_HOST_REQUEST: 12205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly response = ANY_E_CMD_NOT_SUPPORTED; 12225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_COMMAND_NOT_SUPPORTED);*/ 12235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 12265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly response = ANY_E_NOK; 12285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_COMMAND); */ 12295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet = (phHciNfc_HCP_Packet_t *) psHciContext->send_buffer; 12335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Build_HCPFrame(hcp_packet,HCP_CHAINBIT_DEFAULT, 12345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pipe_id, HCP_MSG_TYPE_RESPONSE, response ); 12355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->tx_total = HCP_HEADER_LEN; 12365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_Send_HCP( (void *)psHciContext, (void *)pHwRef ); 12375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->recv_msg_type = HCP_MSG_TYPE_COMMAND; 12395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->sent_msg_type = HCP_MSG_TYPE_RESPONSE; 12405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->prev_msg = response ; 12415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_pipe_info->prev_status = status; 12425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 12435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 12465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 12475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 12495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 12505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHciNfc_Recv_Uicc_Event ( 12515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *psContext, 12525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 12535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t *pEvent, 12545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef ONE_BYTE_LEN 12555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t length 12565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 12575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint16_t length 12585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif 12595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 12605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 12615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t event = (uint8_t) HCP_MSG_INSTRUCTION_INVALID; 12625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint32_t i = 0; 12635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS; 12645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_sContext_t *psHciContext = 12655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (phHciNfc_sContext_t *)psContext ; 12665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Packet_t *hcp_packet = NULL; 12675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_HCP_Message_t *hcp_message = NULL; 12685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sEventInfo_t event_info; 12695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_EmulationMgmt_Info_t *p_emulation_mgmt_info = 12705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHciContext->p_emulation_mgmt_info ; 12715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (NULL == p_emulation_mgmt_info) 12745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || ( TRUE != p_emulation_mgmt_info->uicc_enable) 12755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 12765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED); 12785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 12805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_packet = (phHciNfc_HCP_Packet_t *)pEvent; 12825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message = &hcp_packet->msg.message; 12835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Get the Event instruction bits from the Message Header */ 12855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event = (uint8_t) GET_BITS8( hcp_message->msg_header, 12865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCP_MSG_INSTRUCTION_OFFSET, HCP_MSG_INSTRUCTION_LEN); 12875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventHost = phHal_eUICCHost ; 12885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventSource = phHal_ePICC_DevType ; 12895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch( event ) 12915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EVT_END_OF_TRANSACTION: 12935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventType = NFC_EVT_END_OF_TRANSACTION; 12955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EVT_TRANSACTION: 12985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(length > HCP_HEADER_LEN + TRANSACTION_MIN_LEN) 13005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventType = NFC_EVT_TRANSACTION; 13025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(;i<(length-HCP_HEADER_LEN);) 13045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch (hcp_message->payload[i]) 13065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case TRANSACTION_AID: 13085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* AID LENGTH INDEX */ 13105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly i++; 13115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the event_info.eventInfo.aid 13125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Structure with the Received Transaction AID. 13135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 13145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventInfo.aid.length = 13155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message->payload[i++]; 13165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memcpy((void *)p_emulation_mgmt_info->uicc_aid, 13175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(hcp_message->payload[i]), 13185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventInfo.aid.length ); 13195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventInfo.aid.buffer = (uint8_t *) 13205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_aid; 13215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly i = i + event_info.eventInfo.aid.length; 13225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case TRANSACTION_PARAM: 13255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Parameter Length Index */ 13275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly i++; 13285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Fill the event_info.eventInfo.param 13295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Structure with the Received Parameter. 13305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 13315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_param_len = 13325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly hcp_message->payload[i++]; 13335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void) memcpy((void *)p_emulation_mgmt_info->uicc_param, 13345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(hcp_message->payload[i]), 13355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_param_len ); 13365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventInfo.uicc_info.param.length = 13375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_param_len; 13385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventInfo.uicc_info.param.buffer = (uint8_t *) 13395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly p_emulation_mgmt_info->uicc_param; 13405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly i = i + event_info.eventInfo.uicc_info.param.length; 13415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 13445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL( CID_NFC_HCI, 13475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_FEATURE_NOT_SUPPORTED ); 13485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly i = length; 13495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("%s: Statement Should Not Occur \n", 13505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly "phHciNfc_Recv_Uicc_Event"); 13515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Transaction Switch */ 13545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EVT_CONNECTIVITY: 13595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventType = NFC_EVT_CONNECTIVITY; 13615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case EVT_OPERATION_ENDED: 13645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly event_info.eventType = NFC_EVT_OPERATION_ENDED; 13665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 13695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL( CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED ); 13715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly HCI_DEBUG("%s: Statement Should Not Occur \n","phHciNfc_Recv_Uicc_Event"); 13725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 13735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ( NFCSTATUS_SUCCESS == status ) 13765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Notify_Event( psHciContext, pHwRef, 13785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_NOTIFY_EVENT, (void *)&event_info ); 13795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status; 13825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 13835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1385