phHal4Nfc.c revision 8d4d6a13c4c3bf4e966d12297cc9a9f6cf9d42a8
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 * \file phHal4Nfc.c 185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \brief Hal4Nfc source. 195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Project: NFC-FRI 1.1 215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Date: Fri Jun 11 09:32:23 2010 $ 235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Author: ing07385 $ 245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Revision: 1.192 $ 255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * $Aliases: NFC_FRI1.1_WK1023_R35_1 $ 265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* ---------------------------Include files ---------------------------------*/ 305e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHal4Nfc.h> 325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHal4Nfc_Internal.h> 335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc.h> 345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phHciNfc.h> 355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phLlcNfc.h> 365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phDal4Nfc.h> 375e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#include <phDnldNfc.h> 385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#include <phOsalNfc_Timer.h> 395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* ------------------------------- Macros -----------------------------------*/ 415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifndef HAL_UNIT_TEST 425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC static 435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#else 445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define STATIC 455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*#ifndef UNIT_TEST*/ 465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define HAL4_LAYERS 3 475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define LAYER_HCI 2 485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define LAYER_LLC 1 495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#define LAYER_DAL 0 505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* --------------------Structures and enumerations --------------------------*/ 525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHal_sHwReference_t *gpphHal4Nfc_Hwref; 545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_IoctlComplete( 565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_LowerNotificationHandler( 615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext, 625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_HandleEvent( 675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_OpenComplete( 725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_CloseComplete( 775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 815e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomasstatic void phHal4Nfc_DownloadComplete( 825e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas void *pContext, 835e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas void *pHwRef, 845e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas uint8_t type, 855e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas void *pInfo 865e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas ); 875e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic NFCSTATUS phHal4Nfc_Configure_Layers( 895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfcLayer_sCfg_t **pphLayer 905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*Callback for Self tests*/ 945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_SelfTestComplete( 955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 1005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The open callback function to be called by the HCI when open (initializaion) 1015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * sequence is completed or if there is an error in initialization. 1025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * It is passed as a parameter to HCI when calling HCI Init. 1035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 1045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_OpenComplete( 1065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 1075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 1085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = ((phNfc_sCompletionInfo_t *)pInfo)->status; 1115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_GenCallback_t pUpper_OpenCb 1125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = Hal4Ctxt->sUpperLayerInfo.pUpperOpenCb; 1135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpper_Context 1145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt; 1155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(status == NFCSTATUS_SUCCESS) 1165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Open Successful"); 1185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef MERGE_SAK_SW1 /*Software Workaround*/ 1195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eHal4StateOpenAndReady == Hal4Ctxt->Hal4NextState) 1205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = phHciNfc_System_Configure ( 1225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle, 1235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)gpphHal4Nfc_Hwref, 1245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_TGT_MERGE_ADDRESS, 1255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PH_HAL4NFC_TGT_MERGE_SAK /*config value*/ 1265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING != status) 1295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*#ifdef MERGE_SAK_SW1*/ 1305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Update State*/ 1325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4CurrentState = Hal4Ctxt->Hal4NextState; 1335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateInvalid; 1345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pUpperOpenCb = NULL; 1355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pUpper_OpenCb) 1365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Upper layer's Open Cb*/ 1385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pUpper_OpenCb)(Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt, 1395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_SUCCESS 1405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 1415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else/*Open did not succeed.Go back to reset state*/ 1455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4CurrentState = eHal4StateClosed; 1475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateInvalid; 1485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle = NULL; 1495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((void *)Hal4Ctxt->pHal4Nfc_LayerCfg); 1505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->pHal4Nfc_LayerCfg = NULL; 1515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((void *)Hal4Ctxt); 1525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref->hal_context = NULL; 1535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref = NULL; 1545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Open Failed"); 1555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call upper layer's Open Cb with error status*/ 1565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pUpper_OpenCb)(pUpper_Context,status); 1575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 1595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 1605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 1625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The close callback function called by the HCI when close sequence is 1635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * completed or if there is an error in closing. 1645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * It is passed as a parameter to HCI when calling HCI Release. 1655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 1665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_CloseComplete( 1675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 1685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 1695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 1705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 1715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status= ((phNfc_sCompletionInfo_t *)pInfo)->status; 1725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_GenCallback_t pUpper_CloseCb; 1735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpper_Context; 1745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t RemoteDevNumber = 0; 1755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpper_CloseCb = Hal4Ctxt->sUpperLayerInfo.pUpperCloseCb; 1765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpper_Context = Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt; 1775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Update state*/ 1785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4CurrentState = Hal4Ctxt->Hal4NextState; 1795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateInvalid; 1805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*If Closed successfully*/ 1815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == status) 1825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle = NULL; 1845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free all heap allocations*/ 1855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((void *)Hal4Ctxt->pHal4Nfc_LayerCfg); 1865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->pHal4Nfc_LayerCfg = NULL; 1875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free ADD context info*/ 1885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psADDCtxtInfo) 1895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly while(RemoteDevNumber < MAX_REMOTE_DEVICES) 1915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->rem_dev_list[RemoteDevNumber]) 1935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 1945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((void *) 1955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (Hal4Ctxt->rem_dev_list[RemoteDevNumber])); 1965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->rem_dev_list[RemoteDevNumber] = NULL; 1975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 1985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RemoteDevNumber++; 1995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psADDCtxtInfo->nbr_of_devices = 0; 2015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->psADDCtxtInfo); 2025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*if(NULL != Hal4Ctxt->psADDCtxtInfo)*/ 2035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free Trcv context info*/ 2045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psTrcvCtxtInfo) 2055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psTrcvCtxtInfo->sLowerRecvData.buffer) 2075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory( 2095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psTrcvCtxtInfo->sLowerRecvData.buffer 2105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 2115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == Hal4Ctxt->sTgtConnectInfo.psConnectedDevice) 2135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != Hal4Ctxt->psTrcvCtxtInfo->psUpperSendData)) 2145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->psTrcvCtxtInfo->psUpperSendData); 2165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->psTrcvCtxtInfo); 2185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*if(NULL != Hal4Ctxt->psTrcvCtxtInfo)*/ 2195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free Hal context and Hardware reference*/ 2205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref->hal_context = NULL; 2215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref = NULL; 2225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((void *)Hal4Ctxt); 2235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/* if(NFCSTATUS_SUCCESS == status)*/ 2245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call Upper layer's Close Cb with status*/ 2255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pUpper_CloseCb)(pUpper_Context,status); 2265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 2275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 2315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* For configuring the various layers during the Initialization call 2325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* 2345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly*/ 2355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic 2365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS 2375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyphHal4Nfc_Configure_Layers( 2385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfcLayer_sCfg_t **pphLayer 2395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 2405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 2415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t index = HAL4_LAYERS - 1; 2425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t i = 0; 2435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_SUCCESS ; 2445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Configuring layers"); 2455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly *pphLayer = (phNfcLayer_sCfg_t *) phOsalNfc_GetMemory( 2465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phNfcLayer_sCfg_t) * HAL4_LAYERS); 2475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == *pphLayer) 2495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = PHNFCSTVAL(CID_NFC_HAL, 2515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INSUFFICIENT_RESOURCES);/*Memory allocation error*/ 2525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 2545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)*pphLayer,0,( 2575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phNfcLayer_sCfg_t) * HAL4_LAYERS)); 2585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for(i=0 ; i < HAL4_LAYERS ;i++, index-- ) 2605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer + i)->layer_index = index; 2625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(index) 2635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case LAYER_HCI: /*Configure Hci*/ 2655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_name =(uint8_t *) "Hci"; 2675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_registry = NULL; 2685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_next = 2695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (((phNfcLayer_sCfg_t *)*pphLayer) + i + 1); 2705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case LAYER_LLC:/*Configure LLC*/ 2735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_registry = phLlcNfc_Register; 2755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_name = (uint8_t *)"Llc"; 2765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_next = 2775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (((phNfcLayer_sCfg_t *)*pphLayer) + i + 1); 2785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case LAYER_DAL: /*Configure the DAL*/ 2815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 2825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_registry = phDal4Nfc_Register; 2835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_name = (uint8_t *)"Dal"; 2845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pphLayer+i)->layer_next = NULL ; 2855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 2875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 2885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 2895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of Switch */ 2905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of For Loop */ 2915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } /* End of NULL Check */ 2925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return status ; 2945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 2955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 2975e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 2985e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#ifdef ANDROID 2995e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3005e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#define LOG_TAG "NFC-HCI" 3015e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3025e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#include <utils/Log.h> 3035e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#include <dlfcn.h> 3045e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3058d4d6a13c4c3bf4e966d12297cc9a9f6cf9d42a8Nick Pelly#define FW_PATH "/system/vendor/firmware/libpn544_fw.so" 3068d4d6a13c4c3bf4e966d12297cc9a9f6cf9d42a8Nick Pelly 307ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenenconst unsigned char *nxp_nfc_full_version = NULL; 308ac9c8c89d16e2c458c9c43e1def75d4e1f8f5b9bMartijn Coenenconst unsigned char *nxp_nfc_fw = NULL; 3095e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3105e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomasint dlopen_firmware() { 3115e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas void *p; 3125e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3138d4d6a13c4c3bf4e966d12297cc9a9f6cf9d42a8Nick Pelly void *handle = dlopen(FW_PATH, RTLD_NOW); 3145e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas if (handle == NULL) { 3158d4d6a13c4c3bf4e966d12297cc9a9f6cf9d42a8Nick Pelly LOGE("Could not open %s", FW_PATH); 3165e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return -1; 3175e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas } 3185e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3195e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas p = dlsym(handle, "nxp_nfc_full_version"); 3205e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas if (p == NULL) { 3215e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas LOGE("Could not link nxp_nfc_full_version"); 3225e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return -1; 3235e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas } 3245e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas nxp_nfc_full_version = (unsigned char *)p; 3255e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3265e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas p = dlsym(handle, "nxp_nfc_fw"); 3275e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas if (p == NULL) { 3285e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas LOGE("Could not link nxp_nfc_fw"); 3295e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return -1; 3305e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas } 3315e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas nxp_nfc_fw = (unsigned char *)p; 3325e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3335e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas return 0; 3345e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas} 3355e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#endif 3365e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 3385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The open function called by the upper HAL when HAL4 is to be opened 3395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * (initialized). 3405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 3415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 3425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phHal4Nfc_Open( 3435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHwReference_t *psHwReference, 3445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_InitType_t InitType, 3455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_GenCallback_t pOpenCallback, 3465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext 3475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 3485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 3495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS openRetVal = NFCSTATUS_SUCCESS; 3505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt = NULL; 3515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHciNfc_Init_t eHciInitType = (phHciNfc_Init_t)InitType; 3525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Set Default Clock settings once*/ 3535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static phHal_sHwConfig_t sHwConfig = { 3545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly {0}, 3555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NXP_DEFAULT_CLK_REQUEST, 3565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NXP_DEFAULT_INPUT_CLK 3575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }; 3585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*NULL checks*/ 3595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == psHwReference || NULL == pOpenCallback) 3605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_PrecondFailed,1); 3625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly openRetVal = PHNFCSTVAL(CID_NFC_HAL ,NFCSTATUS_INVALID_PARAMETER); 3635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL != gpphHal4Nfc_Hwref) 3655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Hal4 context is open or open in progress ,return Ctxt already open*/ 3675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly openRetVal = PHNFCSTVAL(CID_NFC_HAL ,NFCSTATUS_ALREADY_INITIALISED); 3685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else/*Do an initialization*/ 3705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3715e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#ifdef ANDROID 372d4cb91ee6f74f187cc0e7ba9dc073b0a77c27dfaNick Pelly dlopen_firmware(); 3735e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas#endif 3745e97605ca8d83414b122bae72e65ea388b66718adaniel_Tomas 3755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*If hal4 ctxt in Hwreference is NULL create a new context*/ 3765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == ((phHal_sHwReference_t *)psHwReference)->hal_context) 3775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *) 3795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof( 3805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t) 3815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 3825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHal_sHwReference_t *)psHwReference)->hal_context = Hal4Ctxt; 3835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else/*Take context from Hw reference*/ 3855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = ((phHal_sHwReference_t *)psHwReference)->hal_context; 3875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == Hal4Ctxt) 3895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly openRetVal = PHNFCSTVAL(CID_NFC_HAL, 3915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INSUFFICIENT_RESOURCES); 3925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 3935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 3945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 3955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)Hal4Ctxt, 3965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 0, 3975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal4Nfc_Hal4Ctxt_t))); 3985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* Configure layers if not configured */ 3995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( NULL == Hal4Ctxt->pHal4Nfc_LayerCfg ) 4005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly openRetVal = phHal4Nfc_Configure_Layers( 4025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(Hal4Ctxt->pHal4Nfc_LayerCfg) 4035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 4045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( openRetVal == NFCSTATUS_SUCCESS ) 4075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*update Next state*/ 4095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = (HCI_SELF_TEST == eHciInitType? 4105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eHal4StateSelfTestMode:eHal4StateOpenAndReady); 4115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Store callback and context ,and set Default settings in Context*/ 4125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pUpperOpenCb = pOpenCallback; 4135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt = pContext; 4145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sTgtConnectInfo.EmulationState = NFC_EVT_DEACTIVATED; 4155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref = psHwReference; 4165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Calling Hci-Init"); 4175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly openRetVal = phHciNfc_Initialise ( 4185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)&Hal4Ctxt->psHciHandle, 4195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference, 4205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eHciInitType, 4215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &sHwConfig, 4225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (pphNfcIF_Notification_CB_t) 4235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_LowerNotificationHandler, 4245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)Hal4Ctxt, 4255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->pHal4Nfc_LayerCfg 4265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 4275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Hci Init did not succeed.free Resources and return*/ 4285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( (openRetVal != NFCSTATUS_SUCCESS) 4295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (PHNFCSTATUS (openRetVal) != NFCSTATUS_PENDING) ) 4305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->pHal4Nfc_LayerCfg); 4325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt); 4335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = NULL; 4345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*if( openRetVal == NFCSTATUS_SUCCESS )*/ 4365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else/*Free the context*/ 4375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt); 4395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*else*/ 4405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return openRetVal; 4435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 4445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 4455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** The I/O Control function allows the caller to use (vendor-) specific 4465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly* functionality provided by the lower layer or by the hardware. */ 4475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phHal4Nfc_Ioctl( 4485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHwReference_t *psHwReference, 4495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint32_t IoctlCode, 4505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *pInParam, 4515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *pOutParam, 4525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_IoctlCallback_t pIoctlCallback, 4535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext 4545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 4555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 4565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetStatus = NFCSTATUS_FAILED; 4575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt = NULL; 4585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint32_t config_type = 0; 4595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t ind = 0; 4605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*NULL checks*/ 4615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == psHwReference) 4625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == pIoctlCallback) 4635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 4645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_PrecondFailed,1); 4665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = PHNFCSTVAL(CID_NFC_HAL ,NFCSTATUS_INVALID_PARAMETER); 4675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Only the Ioctls NFC_FW_DOWNLOAD_CHECK and NFC_FW_DOWNLOAD are allowed in 4695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly the uninitialized state of HAL*/ 4705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(NULL == psHwReference->hal_context) 4715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef FW_DOWNLOAD 4735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFC_FW_DOWNLOAD_CHECK == IoctlCode) 4745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phDnldNfc_Run_Check( 4765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference 4775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 4785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NFC_FW_DOWNLOAD == IoctlCode) 4805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &&(NULL == gpphHal4Nfc_Hwref))/*Indicates current state is shutdown*/ 4815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *) 4835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t)sizeof( 4845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t) 4855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 4865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == Hal4Ctxt) 4875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = PHNFCSTVAL(CID_NFC_HAL, 4895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INSUFFICIENT_RESOURCES); 4905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 4915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 4925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 4935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHal_sHwReference_t *)psHwReference)->hal_context 4945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = Hal4Ctxt; 4955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset((void *)Hal4Ctxt, 4965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 0, 4975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((uint32_t)sizeof(phHal4Nfc_Hal4Ctxt_t))); 4985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt = pContext; 4995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb 5005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = pIoctlCallback;/*Register upper layer callback*/ 5015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam = pOutParam; 5025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Upgrade the firmware*/ 5035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phDnldNfc_Upgrade ( 5045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference, 5055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_DownloadComplete, 5065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt 5075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 5085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_SUCCESS == RetStatus) 5095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt); 5115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ((phHal_sHwReference_t *)psHwReference)->hal_context = NULL; 5125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 5165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*NFC_FW_DOWNLOAD*/ 5175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = PHNFCSTVAL(CID_NFC_HAL ,NFCSTATUS_NOT_INITIALISED); 5195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else/*Status is Initialised*/ 5225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Register upper layer context*/ 5245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = psHwReference->hal_context; 5255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam = pOutParam; 5265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(IoctlCode) 5275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Self test Ioctls*/ 5295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case DEVMGMT_ANTENNA_TEST: 5305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case DEVMGMT_SWP_TEST: 5315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case DEVMGMT_NFCWI_TEST: 5325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eHal4StateSelfTestMode ==Hal4Ctxt->Hal4CurrentState) 5335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHciNfc_System_Test( 5355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle, 5365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)psHwReference, 5375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly IoctlCode , 5385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInParam 5395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 5405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*PRBS Test*/ 5435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case DEVMGMT_PRBS_TEST: 5445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHciNfc_PRBS_Test( 5455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle, 5465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)psHwReference, 5475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly IoctlCode , 5485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInParam 5495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 5505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*To Set Antenna Power Level*/ 5525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_ANTENNA_CWG: 5535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eHal4StateSelfTestMode ==Hal4Ctxt->Hal4CurrentState) 5545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHciNfc_System_Configure ( 5565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle, 5575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)psHwReference, 5585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_ANTENNA_CWG, 5595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInParam->buffer[0] /**Set Power Level*/ 5605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 5615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 5625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Not allowed when Init is complete*/ 5655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_FW_DOWNLOAD_CHECK: 5665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_FW_DOWNLOAD: 5675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = PHNFCSTVAL(CID_NFC_HAL, 5685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_BUSY); 5695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Gpio read*/ 5715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_GPIO_READ: 5725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /* if(eHal4StateSelfTestMode == Hal4Ctxt->Hal4CurrentState) */ 5735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHciNfc_System_Get_Info( 5755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle, 5765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)psHwReference, 5775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly IoctlCode , 5785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pOutParam->buffer 5795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 5805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 5825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Used to Read Memory/Registers .3 bytes of Array passed form the 5835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly address to read from in MSB first format.*/ 5845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_MEM_READ: 5855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL != pInParam) 5875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (pInParam->length == 3)) 5885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for( ind = 0; ind < 3; ind++ ) 5905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 5915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly config_type = ((config_type << BYTE_SIZE ) 5925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly | (pInParam->buffer[ind] )); 5935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 5945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHciNfc_System_Get_Info( 5955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle, 5965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)psHwReference, 5975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly config_type , 5985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pOutParam->buffer 5995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 6005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = PHNFCSTVAL(CID_NFC_HAL, 6045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_PARAMETER); 6055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Used to Write Memory/Registers .First 3 bytes of Array passed in MSB 6095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly first format form the address to write to.The 4th Byte is the 8 bit 6105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly value to be written to the address*/ 6115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_MEM_WRITE: 6125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL != pInParam) 6145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (pInParam->length == 4)) 6155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly for( ind = 0; ind < 3; ind++ ) 6175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly config_type = ((config_type << BYTE_SIZE ) 6195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly | (pInParam->buffer[ind] )); 6205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHciNfc_System_Configure ( 6225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psHciHandle, 6235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)psHwReference, 6245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly config_type, 6255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInParam->buffer[3] /*config value*/ 6265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 6275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 6295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = PHNFCSTVAL(CID_NFC_HAL , 6315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_INVALID_PARAMETER); 6325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 6365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 6375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFCSTATUS_PENDING == RetStatus)/*Callback Pending*/ 6395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Register upper layer callback and context*/ 6415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt = pContext; 6425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb= pIoctlCallback; 6435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Store the Ioctl code*/ 6445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Ioctl_Type = IoctlCode; 6455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return RetStatus; 6485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 6495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 6515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 6525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The close function called by the upper layer when HAL4 is to be closed 6535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * (shutdown). 6545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 6555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phHal4Nfc_Close( 6565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHwReference_t *psHwReference, 6575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_GenCallback_t pCloseCallback, 6585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext 6595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 6605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 6615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS closeRetVal = NFCSTATUS_SUCCESS; 6625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt = NULL; 6635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*NULL checks*/ 6645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == psHwReference || NULL == pCloseCallback) 6655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_PrecondFailed,1); 6675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly closeRetVal = PHNFCSTVAL(CID_NFC_HAL , NFCSTATUS_INVALID_PARAMETER); 6685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == psHwReference->hal_context) 6705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (((phHal4Nfc_Hal4Ctxt_t *) 6715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference->hal_context)->Hal4CurrentState 6725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly < eHal4StateSelfTestMode) 6735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (((phHal4Nfc_Hal4Ctxt_t *) 6745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference->hal_context)->Hal4NextState 6755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eHal4StateClosed)) 6765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*return already closed*/ 6785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly closeRetVal= PHNFCSTVAL(CID_NFC_HAL , NFCSTATUS_NOT_INITIALISED); 6795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else /*Close the HAL*/ 6815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Get Hal4 context from Hw reference*/ 6835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *)((phHal_sHwReference_t *) 6845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference)->hal_context; 6855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Unregister Tag Listener*/ 6865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psADDCtxtInfo) 6875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 6885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pTagDiscoveryNotification = NULL; 6895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 6905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*store Callback and Context*/ 6915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pUpperCloseCb = pCloseCallback; 6925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt = pContext; 6935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call Hci Release*/ 6945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Calling Hci Release"); 6955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly closeRetVal =(NFCSTATUS)phHciNfc_Release( 6965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)Hal4Ctxt->psHciHandle, 6975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference, 6985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (pphNfcIF_Notification_CB_t) 6995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_LowerNotificationHandler, 7005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)Hal4Ctxt 7015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 7025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Update Next state and exit*/ 7035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if( PHNFCSTATUS (closeRetVal) == NFCSTATUS_PENDING ) 7045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateClosed; 7065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pTagDiscoveryNotification = NULL; 7075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return closeRetVal; 7145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*Forcibly shutdown the HAl4.Frees all Resources in use by Hal4 before shutting 7175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly down*/ 7185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellyvoid phHal4Nfc_Hal4Reset( 7195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHwReference_t *pHwRef, 7205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext 7215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 7225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 7235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt = NULL; 7245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS closeRetVal = NFCSTATUS_SUCCESS; 7255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t RemoteDevNumber = 0; 7265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(pHwRef ==NULL) 7275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly closeRetVal = PHNFCSTVAL(CID_NFC_HAL , NFCSTATUS_INVALID_PARAMETER); 7295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if(pHwRef->hal_context != NULL) 7315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Get the Hal context*/ 7335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *)pHwRef->hal_context; 7345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*store the upper layer context*/ 7355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt = pContext; 7365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateClosed; 7375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pTagDiscoveryNotification = NULL; 7385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call Hci Release*/ 7395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Calling Hci Release"); 7405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly closeRetVal =(NFCSTATUS)phHciNfc_Release( 7415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)Hal4Ctxt->psHciHandle, 7425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef, 7435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (pphNfcIF_Notification_CB_t)NULL, 7445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)Hal4Ctxt 7455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly );/*Clean up Hci*/ 7465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4CurrentState = eHal4StateClosed; 7475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((void *)Hal4Ctxt->pHal4Nfc_LayerCfg); 7485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->pHal4Nfc_LayerCfg = NULL; 7495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free ADD context*/ 7505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psADDCtxtInfo) 7515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pTagDiscoveryNotification = NULL; 7535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly while(RemoteDevNumber < MAX_REMOTE_DEVICES) 7545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->rem_dev_list[RemoteDevNumber]) 7565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory((void *) 7585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (Hal4Ctxt->rem_dev_list[RemoteDevNumber])); 7595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->rem_dev_list[RemoteDevNumber] = NULL; 7605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RemoteDevNumber++; 7625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psADDCtxtInfo->nbr_of_devices = 0; 7645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->psADDCtxtInfo); 7655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free Trcv context*/ 7675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psTrcvCtxtInfo) 7685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psTrcvCtxtInfo->sLowerRecvData.buffer) 7705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->psTrcvCtxtInfo 7725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ->sLowerRecvData.buffer); 7735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == Hal4Ctxt->sTgtConnectInfo.psConnectedDevice) 7755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly && (NULL != Hal4Ctxt->psTrcvCtxtInfo->psUpperSendData)) 7765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->psTrcvCtxtInfo->psUpperSendData); 7785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt->psTrcvCtxtInfo); 7805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(Hal4Ctxt);/*Free the context*/ 7825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pHwRef->hal_context = NULL; 7835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref = NULL; 7845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 7865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Hal4 Context is already closed.Return Success*/ 7885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Reset Should always return Success*/ 7905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(closeRetVal != NFCSTATUS_SUCCESS) 7915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 7925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_PrecondFailed,1); 7935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 7945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 7955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 7965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 7975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/** 7985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \if hal 7995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \ingroup grp_hal_common 8005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \else 8015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \ingroup grp_mw_external_hal_funcs 8025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * \endif 8035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 8045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Retrieves the capabilities of the device represented by the Hardware 8055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Reference parameter. 8065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * The HW, SW versions, the MTU and other mandatory information are located 8075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * inside the pDevCapabilities parameter. 8085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 8095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellyNFCSTATUS phHal4Nfc_GetDeviceCapabilities( 8105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHwReference_t *psHwReference, 8115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sDeviceCapabilities_t *psDevCapabilities, 8125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext 8135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 8145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS retstatus = NFCSTATUS_SUCCESS; 8165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*NULL checks*/ 8175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(psDevCapabilities == NULL || psHwReference == NULL || pContext == NULL) 8185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly retstatus = PHNFCSTVAL(CID_NFC_HAL ,NFCSTATUS_INVALID_PARAMETER); 8205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check for Initialized state*/ 8225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((NULL == psHwReference->hal_context) 8235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (((phHal4Nfc_Hal4Ctxt_t *) 8245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference->hal_context)->Hal4CurrentState 8255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly < eHal4StateOpenAndReady) 8265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (((phHal4Nfc_Hal4Ctxt_t *) 8275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwReference->hal_context)->Hal4NextState 8285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly == eHal4StateClosed)) 8295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly retstatus = PHNFCSTVAL(CID_NFC_HAL ,NFCSTATUS_NOT_INITIALISED); 8315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else/*Provide Device capabilities and Version Info to the caller*/ 8335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy((void *)psDevCapabilities, 8355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)&(psHwReference->device_info), 8365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHal_sDeviceCapabilities_t)); 8375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.Felica = TRUE; 8385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.ISO14443_4A = TRUE; 8395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.ISO14443_4B = TRUE; 8405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.ISO15693 = TRUE; 8415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.Jewel = TRUE; 8425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.MifareStd = TRUE; 8435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.MifareUL = TRUE; 8445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->ReaderSupProtocol.NFC = TRUE; 8455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.Felica = FALSE; 8465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.ISO14443_4A = FALSE; 8475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.ISO14443_4B = FALSE; 8485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.ISO15693 = FALSE; 8495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.Jewel = FALSE; 8505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.MifareStd = FALSE; 8515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.MifareUL = FALSE; 8525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->EmulationSupProtocol.NFC = TRUE; 8535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psDevCapabilities->hal_version = ( 8545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (((PH_HAL4NFC_INTERFACE_VERSION << BYTE_SIZE) 8555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly |(PH_HAL4NFC_INTERFACE_REVISION)<<BYTE_SIZE) 8565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly |(PH_HAL4NFC_INTERFACE_PATCH)<<BYTE_SIZE) 8575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly |PH_HAL4NFC_INTERAFECE_BUILD 8585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 8595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return retstatus; 8615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 8625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 8635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/* 8645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * Handles all notifications received from HCI layer. 8655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly * 8665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly */ 8675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_LowerNotificationHandler( 8685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext, 8695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 8705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 8715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 8725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 8735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 8745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt = NULL; 8755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pInfo) || (NULL == pHwRef) 8765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NULL == pContext)) 8775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_PrecondFailed,1); 8795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 8815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*A copy of hardware reference is maintained in HAL for comparing passed 8835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly and returned context.Set to NULL after a Shutdown*/ 8845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphHal4Nfc_Hwref)/*Get context from Hw ref*/ 8855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *)gpphHal4Nfc_Hwref->hal_context; 8875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NFC_INVALID_RELEASE_TYPE == Hal4Ctxt->sTgtConnectInfo.ReleaseType) 8885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *)pContext; 8905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref = (phHal_sHwReference_t *)pHwRef; 8915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else/*No Copy of Hw ref in HAL.Copy both Hwref and Hal context passed 8945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly by Hci*/ 8955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 8965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *)pContext; 8975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref = (phHal_sHwReference_t *)pHwRef; 8985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 8995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check the type of notification received from Hci and handle it 9005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly accordingly*/ 9015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(type) 9025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_INIT_COMPLETED: 9045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_INIT_FAILED: 9055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_OpenComplete(Hal4Ctxt,pInfo); 9065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_IO_SUCCESS: 9085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_IO_ERROR: 9095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_IoctlComplete(Hal4Ctxt,pInfo); 9105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_RESULT: 9125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_SelfTestComplete(Hal4Ctxt,pInfo); 9135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DEINIT_COMPLETED: 9155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DEINIT_FAILED: 9165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_CloseComplete(Hal4Ctxt,pInfo); 9175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_POLL_ENABLED: 9195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_POLL_DISABLED: 9205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_POLL_RESTARTED: 9215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_CONFIG_ERROR: 9225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_CONFIG_SUCCESS: 9235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_ConfigureComplete(Hal4Ctxt,pInfo,type); 9245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TARGET_DISCOVERED: 9265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DISCOVERY_ERROR: 9275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_TargetDiscoveryComplete(Hal4Ctxt,pInfo); 9285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TARGET_REACTIVATED: 9305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_ReactivationComplete(Hal4Ctxt,pInfo); 9315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_EVENT: 9335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Calling Event callback"); 9345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEvent(Hal4Ctxt,pInfo); 9355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TARGET_CONNECTED: 9375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Calling Hal4 Connect complete"); 9385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_ConnectComplete(Hal4Ctxt,pInfo); 9395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 9415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TARGET_DISCONNECTED: 9425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Target Disconnected"); 9445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Hal4Ctxt->Hal4NextState == eHal4StatePresenceCheck) 9455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_PresenceChkComplete(Hal4Ctxt,pInfo); 9475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 9495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_DisconnectComplete(Hal4Ctxt,pInfo); 9515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TRANSCEIVE_COMPLETED: 9555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TRANSCEIVE_ERROR : 9565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Transceive Callback"); 9575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psTrcvCtxtInfo) 9585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef TRANSACTION_TIMER 9605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 9615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly != PH_OSALNFC_INVALID_TIMER_ID) 9625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Stop( 9645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 9655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 9665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Delete( 9675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 9685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 9695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 9705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = PH_OSALNFC_INVALID_TIMER_ID; 9715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /*TRANSACTION_TIMER*/ 9735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_TransceiveComplete(Hal4Ctxt,pInfo); 9745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_SEND_COMPLETED : 9775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:NfcIp1 Send Callback"); 9785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psTrcvCtxtInfo) 9795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_SendCompleteHandler(Hal4Ctxt,pInfo); 9815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 9825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TRANSACTION : 9845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEmulationEvent(Hal4Ctxt,pInfo); 9855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 9865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_RECV_ERROR : 9875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_RECV_EVENT : 9885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Receive Event"); 9895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psTrcvCtxtInfo) 9905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 9925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly != PH_OSALNFC_INVALID_TIMER_ID) 9935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 9945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Stop( 9955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 9965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 9975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_Timer_Delete( 9985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 9995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 10005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psTrcvCtxtInfo->TransactionTimerId 10015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = PH_OSALNFC_INVALID_TIMER_ID; 10025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_RecvCompleteHandler(Hal4Ctxt,pInfo); 10055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_TARGET_PRESENT: 10075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_PresenceChkComplete(Hal4Ctxt,pInfo); 10085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DEVICE_ERROR: 10105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static phHal4Nfc_NotificationInfo_t uNotificationInfo; 10125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateInvalid; 10135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->sUpperLayerInfo.pDefaultEventHandler) 10145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pDefaultEventHandler( 10165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.DefaultListenerCtxt, 10175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFC_EVENT_NOTIFICATION, 10185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uNotificationInfo, 10195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_BOARD_COMMUNICATION_ERROR 10205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 10215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_UnrecovFirmwareErr,1); 10255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_CONNECT_FAILED: 10295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_DISCONNECT_FAILED: 10305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Generic Error type received from Hci.Handle the error based on 10315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4 next state and which past callback was Pending*/ 10325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_NOTIFY_ERROR: 10335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_WARNING("Hal4:Error Notification from HCI"); 10355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(Hal4Ctxt->Hal4NextState) 10365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StateClosed: 10385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_CloseComplete(Hal4Ctxt,pInfo); 10395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StateSelfTestMode: 10415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_SelfTestComplete(Hal4Ctxt,pInfo); 10425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StateConfiguring: 10445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_ConfigureComplete(Hal4Ctxt,pInfo,type); 10455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StateTargetDiscovered: 10475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StateTargetActivate: 10485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->sTgtConnectInfo.pUpperConnectCb) 10505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL == Hal4Ctxt->sTgtConnectInfo.psConnectedDevice) 10525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_ConfigureComplete(Hal4Ctxt,pInfo,type); 10545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_ConnectComplete(Hal4Ctxt,pInfo); 10585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 10615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 10625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_TargetDiscoveryComplete(Hal4Ctxt,pInfo); 10635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StateTargetConnected: 10675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_ConnectComplete(Hal4Ctxt,pInfo); 10685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StateOpenAndReady: 10705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_DisconnectComplete(Hal4Ctxt,pInfo); 10715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case eHal4StatePresenceCheck: 10735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_PresenceChkComplete(Hal4Ctxt,pInfo); 10745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 10765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_WARNING("Unknown Error notification"); 10775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*End of switch(Hal4Ctxt->Hal4State)*/ 10815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 10825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_PrecondFailed,1); 10835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 10845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*End of switch(type)*/ 10855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 10865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 10875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 10885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 10905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*Event handler for HAL-HCI interface*/ 10915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_HandleEvent( 10925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 10935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 10945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 10955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 10965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sEventInfo_t *psEventInfo = (phHal_sEventInfo_t *)pInfo; 10975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly static phNfc_sNotificationInfo_t sNotificationInfo; 10985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_NotificationInfo_t uNotificationInfo = {NULL}; 10995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS RetStatus = NFCSTATUS_FAILED; 11005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Check if Hal4 Close has already been called*/ 11015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eHal4StateClosed != Hal4Ctxt->Hal4NextState) 11025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psEventInfo->eventType) 11045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_ACTIVATED:/*Target Activated*/ 11065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(psEventInfo->eventHost == phHal_eHostController) 11085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psEventInfo->eventSource) 11105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Target: 11125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_P2PActivateComplete(Hal4Ctxt,pInfo); 11135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_A_PICC: 11155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_B_PICC: 11165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.info = psEventInfo; 11175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.status = NFCSTATUS_SUCCESS; 11185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type = NFC_EVENT_NOTIFICATION; 11195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInfo = &sNotificationInfo; 11205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEmulationEvent(Hal4Ctxt,pInfo); 11215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 11235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_DEACTIVATED:/*Target Deactivated*/ 11295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(psEventInfo->eventHost == phHal_eHostController) 11315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly switch(psEventInfo->eventSource) 11335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eNfcIP1_Target: 11355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleP2PDeActivate(Hal4Ctxt,pInfo); 11365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_A_PICC: 11385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case phHal_eISO14443_B_PICC: 11395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.info = psEventInfo; 11405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.status = NFCSTATUS_SUCCESS; 11415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type = NFC_EVENT_NOTIFICATION; 11425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInfo = &sNotificationInfo; 11435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEmulationEvent(Hal4Ctxt,pInfo); 11445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 11465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Set Protection Event*/ 11525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_PROTECTED: 11535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef IGNORE_EVT_PROTECTED 11555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Ignore_Event_Protected is set to false during Field Off event and 11565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Set protection Configuration.After a NFC_EVT_PROTECTED is received 11575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly once all subsequent NFC_EVT_PROTECTED events are ignored*/ 11585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(FALSE == Hal4Ctxt->Ignore_Event_Protected) 11595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Ignore_Event_Protected = TRUE; 11615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*#ifdef IGNORE_EVT_PROTECTED*/ 11625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.info = psEventInfo; 11635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.status = NFCSTATUS_SUCCESS; 11645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type = NFC_EVENT_NOTIFICATION; 11655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInfo = &sNotificationInfo; 11665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEmulationEvent(Hal4Ctxt,pInfo); 11675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef IGNORE_EVT_PROTECTED 11685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*#ifdef IGNORE_EVT_PROTECTED*/ 11705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*NFC_UICC_RDPHASES_DEACTIVATE_REQ*/ 11735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_UICC_RDPHASES_DEACTIVATE_REQ: 11745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphHal4Nfc_Hwref) 11765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref->uicc_rdr_active = FALSE; 11785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 11805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_UICC_RDPHASES_ACTIVATE_REQ: 11825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != gpphHal4Nfc_Hwref) 11845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref->uicc_rdr_active = TRUE; 11865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 11875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*If a NFC_UICC_RDPHASES_ACTIVATE_REQ is received before a configure 11885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly discovery,then create a ADD context info*/ 11895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if (NULL == Hal4Ctxt->psADDCtxtInfo) 11905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psADDCtxtInfo= (pphHal4Nfc_ADDCtxtInfo_t) 11925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_GetMemory((uint32_t) 11935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (sizeof(phHal4Nfc_ADDCtxtInfo_t))); 11945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psADDCtxtInfo) 11955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 11965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memset(Hal4Ctxt->psADDCtxtInfo,0, 11975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sizeof(phHal4Nfc_ADDCtxtInfo_t) 11985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 11995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->psADDCtxtInfo) 12025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psADDCtxtInfo->sADDCfg.PollDevInfo.PollEnabled 12045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly |= psEventInfo->eventInfo.rd_phases; 12055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Configure HCI Discovery*/ 12065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly RetStatus = phHciNfc_Config_Discovery( 12075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void *)Hal4Ctxt->psHciHandle, 12085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly gpphHal4Nfc_Hwref, 12095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &(Hal4Ctxt->psADDCtxtInfo->sADDCfg) 12105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 12115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = (NFCSTATUS_PENDING == RetStatus? 12125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly eHal4StateConfiguring: 12135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState); 12145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call Default Event handler for these Events*/ 12185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_INFO_TXLDO_OVERCUR: 12195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_INFO_MEM_VIOLATION: 12205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_INFO_TEMP_OVERHEAT: 12215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.info = psEventInfo; 12235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.status = NFCSTATUS_SUCCESS; 12245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type = NFC_EVENT_NOTIFICATION; 12255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInfo = &sNotificationInfo; 12265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Exception events"); 12275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != Hal4Ctxt->sUpperLayerInfo.pDefaultEventHandler) 12285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Pass on Event notification info from Hci to Upper layer*/ 12305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uNotificationInfo.psEventInfo = psEventInfo; 12315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pDefaultEventHandler( 12325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.DefaultListenerCtxt, 12335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type, 12345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uNotificationInfo, 12355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_SUCCESS 12365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 12375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call emulation Event handler fto handle these Events*/ 12415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_TRANSACTION: 12425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_START_OF_TRANSACTION: 12435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_END_OF_TRANSACTION: 12445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_CONNECTIVITY: 12455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_OPERATION_ENDED: 12465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.info = psEventInfo; 12475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.status = NFCSTATUS_SUCCESS; 12485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type = NFC_EVENT_NOTIFICATION; 12495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInfo = &sNotificationInfo; 12505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Event transaction\n"); 12515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEmulationEvent(Hal4Ctxt,pInfo); 12525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_FIELD_ON: 12545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psEventInfo = sNotificationInfo.info = psEventInfo; 12555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.status = NFCSTATUS_SUCCESS; 12565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type = NFC_EVENT_NOTIFICATION; 12575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInfo = &sNotificationInfo; 12585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Event Field ON\n"); 12595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEmulationEvent(Hal4Ctxt,pInfo); 12605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly case NFC_EVT_FIELD_OFF: 12625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly #ifdef IGNORE_EVT_PROTECTED 12635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Ignore_Event_Protected = FALSE; 12645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly #endif/*#ifdef IGNORE_EVT_PROTECTED*/ 12655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->psEventInfo = sNotificationInfo.info = psEventInfo; 12665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.status = NFCSTATUS_SUCCESS; 12675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly sNotificationInfo.type = NFC_EVENT_NOTIFICATION; 12685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pInfo = &sNotificationInfo; 12695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_INFO("Hal4:Event Field OFF\n"); 12705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_HandleEmulationEvent(Hal4Ctxt,pInfo); 12715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly default: 12735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly PHDBG_WARNING("Hal4:Unhandled Event type received"); 12745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly break; 12755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*End of switch*/ 12765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly }/*if(eHal4StateClosed != Hal4Ctxt->Hal4NextState)*/ 12775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 12785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 12795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 12815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/*Callback handler for Self Test Ioctl completion*/ 12825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_SelfTestComplete( 12835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 12845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 12855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 12865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 12875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_FAILED; 12885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *SelfTestResults 12895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = (phNfc_sData_t *)(((phNfc_sCompletionInfo_t *)pInfo)->info); 12905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_IoctlCallback_t pUpper_IoctlCb 12915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb; 12925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpper_Context = Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt; 12935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*check for Success*/ 12945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((SelfTestResults->length > 0) && (0 == SelfTestResults->buffer[0])) 12955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 12965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = NFCSTATUS_SUCCESS; 12975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 12985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Copy response buffer and length*/ 12995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (void)memcpy(Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam->buffer, 13005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SelfTestResults->buffer, 13015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly SelfTestResults->length); 13025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam->length 13035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = SelfTestResults->length; 13045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call registered Ioctl callback*/ 13055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pUpper_IoctlCb)( 13065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpper_Context, 13075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam, 13085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status 13095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 13105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 13115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 13125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pellystatic void phHal4Nfc_IoctlComplete( 13155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt, 13165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 13175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 13195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Copy status*/ 13205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = (((phNfc_sCompletionInfo_t *)pInfo)->status); 13215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_IoctlCallback_t pUpper_IoctlCb 13225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb; 13235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef MERGE_SAK_SW2 13245d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_GenCallback_t pConfigCallback = 13255d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pConfigCallback; 13265d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*#ifdef MERGE_SAK_SW2*/ 13275d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpper_Context = Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt; 13285d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb = NULL; 13295d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef MERGE_SAK_SW1 /*Software workaround 1*/ 13305d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(eHal4StateOpenAndReady == Hal4Ctxt->Hal4NextState) 13315d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13325d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4CurrentState = Hal4Ctxt->Hal4NextState; 13335d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateInvalid; 13345d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Upper layer's Open Cb*/ 13355d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*Hal4Ctxt->sUpperLayerInfo.pUpperOpenCb)( 13365d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt, 13375d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS_SUCCESS 13385d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 13395d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13405d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*#ifdef MERGE_SAK_SW1*/ 13415d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef MERGE_SAK_SW2 /*Software workaround 2*/ 13425d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else if((eHal4StateConfiguring == Hal4Ctxt->Hal4NextState) 13435d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly &&(NULL != pConfigCallback)) 13445d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13455d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pConfigCallback = NULL; 13465d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->Hal4NextState = eHal4StateInvalid; 13475d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pConfigCallback)( 13485d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt,status 13495d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 13505d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13515d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 13525d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif/*#ifdef MERGE_SAK_SW2*/ 13535d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13545d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*for NFC_MEM_READ and NFC_GPIO_READ ,provide one Byte Response*/ 13555d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if ((NFC_MEM_READ == Hal4Ctxt->Ioctl_Type) 13565d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly || (NFC_GPIO_READ == Hal4Ctxt->Ioctl_Type)) 13575d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13585d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam->length 13595d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly = sizeof (uint8_t); 13605d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13615d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call registered Ioctl callback*/ 13625d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pUpper_IoctlCb) 13635d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13645d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pUpper_IoctlCb)( 13655d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpper_Context, 13665d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam, 13675d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status 13685d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 13695d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13705d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13715d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 13725d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 13735d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 13745d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#ifdef FW_DOWNLOAD 13755d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly/**Callback handler for Download completion*/ 13765d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick PellySTATIC void phHal4Nfc_DownloadComplete( 13775d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pContext, 13785d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pHwRef, 13795d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly uint8_t type, 13805d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pInfo 13815d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ) 13825d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly{ 13835d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal4Nfc_Hal4Ctxt_t *Hal4Ctxt = NULL; 13845d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly NFCSTATUS status = NFCSTATUS_FAILED; 13855d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pphHal4Nfc_IoctlCallback_t pUpper_DnldCb = NULL; 13865d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phNfc_sData_t *pIoctlOutParam = NULL; 13875d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phHal_sHwReference_t *psHwRef = NULL; 13885d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly void *pUpper_Context = NULL; 13895d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*NULL checks*/ 13905d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if((NULL == pInfo) || (NULL == pHwRef) || (NULL == pContext)) 13915d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13925d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_RaiseException(phOsalNfc_e_PrecondFailed,1); 13935d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 13945d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly else 13955d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 13965d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly type = type; 13975d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt = (phHal4Nfc_Hal4Ctxt_t *)pContext; 13985d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Copy back stored context/callback for the upper layer*/ 13995d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpper_Context = Hal4Ctxt->sUpperLayerInfo.psUpperLayerCtxt; 14005d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pIoctlOutParam = Hal4Ctxt->sUpperLayerInfo.pIoctlOutParam; 14015d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpper_DnldCb = Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb; 14025d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly Hal4Ctxt->sUpperLayerInfo.pUpperIoctlCb = NULL; 14035d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Copy download status*/ 14045d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status = (((phNfc_sCompletionInfo_t *)pInfo)->status); 14055d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*copy hw reference*/ 14065d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwRef = (phHal_sHwReference_t *)pHwRef; 14075d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Free the temporary hal context used only for the sake of download*/ 14085d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly phOsalNfc_FreeMemory(psHwRef->hal_context); 14095d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly psHwRef->hal_context = NULL; 14105d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly /*Call upper layer callback*/ 14115d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly if(NULL != pUpper_DnldCb) 14125d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly { 14135d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly (*pUpper_DnldCb)( 14145d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pUpper_Context, 14155d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly pIoctlOutParam, 14165d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly status 14175d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly ); 14185d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14195d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly } 14205d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly return; 14215d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly} 14225d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly#endif /*FW_DOWNLOAD*/ 14235d9927ba30ba449badb9f6df0fbeb4d6aedc6e2aNick Pelly 1424