STATIC void phLibNfc_Switch_Swp_Mode_CB( void *context, NFCSTATUS status ) { if(PHNFCSTATUS(status)!=NFCSTATUS_SUCCESS) { status = NFCSTATUS_FAILED; } if(gpphLibContext!= NULL) { if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state) { /*If shutdown called in between allow shutdown to happen*/ phLibNfc_Pending_Shutdown(); status = NFCSTATUS_SHUTDOWN; } } if((NULL != context)&&(context == (void *)&phLibNfc_Ioctl_Cntx)) { if(NULL != phLibNfc_Ioctl_Cntx.CliRspCb) { (*phLibNfc_Ioctl_Cntx.CliRspCb)( phLibNfc_Ioctl_Cntx.pCliCntx, phLibNfc_Ioctl_Cntx.pOutParam, status ); } } return; }
/* *************************** Function Definitions ****************************** */ void phLibNfc_config_discovery_cb(void *context, NFCSTATUS status) { if((phLibNfc_LibContext_t *)context == gpphLibContext) { /*check for same context*/ if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state) { /*If shutdown called in between allow shutdown to happen*/ phLibNfc_Pending_Shutdown(); status = NFCSTATUS_SHUTDOWN; } else { gpphLibContext->status.GenCb_pending_status = FALSE; gpphLibContext->status.DiscEnbl_status = FALSE; phLibNfc_UpdateCurState(status,gpphLibContext); #ifdef RESTART_CFG if(gpphLibContext->status.Discovery_pending_status == TRUE) { NFCSTATUS RetStatus = NFCSTATUS_FAILED; /* Application has called discovery before receiving this callback, so NO notification to the upper layer, instead lower layer discovery is called */ gpphLibContext->status.Discovery_pending_status = FALSE; RetStatus = phHal4Nfc_ConfigureDiscovery( gpphLibContext->psHwReference, gpphLibContext->eLibNfcCfgMode, &gpphLibContext->sADDconfig, (pphLibNfc_RspCb_t) phLibNfc_config_discovery_cb, (void *)gpphLibContext); if (NFCSTATUS_PENDING == RetStatus) { (void)phLibNfc_UpdateNextState(gpphLibContext, eLibNfcHalStateConfigReady); gpphLibContext->status.GenCb_pending_status = TRUE; gpphLibContext->status.DiscEnbl_status = TRUE; } else { status = NFCSTATUS_FAILED; } } #endif /* #ifdef RESTART_CFG */ } } /*End of if-context check*/ else { /*exception: wrong context pointer returned*/ phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); status = NFCSTATUS_FAILED; } if(gpphLibContext->CBInfo.pClientDisConfigCb!=NULL) { gpphLibContext->CBInfo.pClientDisConfigCb(gpphLibContext->CBInfo.pClientDisCfgCntx,status); gpphLibContext->CBInfo.pClientDisConfigCb=NULL; } return; }
static void phFriNfc_LlcpMac_Nfcip_Receive_Cb(void *pContext, NFCSTATUS Status) { phFriNfc_LlcpMac_t *LlcpMac = (phFriNfc_LlcpMac_t *)pContext; #ifdef LLCP_CHANGES phFriNfc_LlcpMac_Send_CB_t pfSendCB; void *pSendContext; if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown) { phLibNfc_Pending_Shutdown(); Status = NFCSTATUS_SHUTDOWN; } if (NFCSTATUS_SHUTDOWN == Status) { /* Save context in local variables */ pfSendCB = LlcpMac->MacSend_Cb; pSendContext = LlcpMac->MacSend_Context; /* Reset the pointer to the Send Callback */ LlcpMac->MacSend_Cb = NULL; LlcpMac->MacSend_Context = NULL; /* Reset Send and Receive Flag */ LlcpMac->SendPending = FALSE; LlcpMac->RecvPending = FALSE; } #endif /* #ifdef LLCP_CHANGES */ phFriNfc_LlcpMac_Nfcip_TriggerRecvCb(LlcpMac, Status); #ifdef LLCP_CHANGES if (NFCSTATUS_SHUTDOWN == Status) { if ((LlcpMac->SendPending) && (NULL != pfSendCB)) { pfSendCB(pSendContext, Status); } } else #endif /* #ifdef LLCP_CHANGES */ { /* Test if a send is pending */ if(LlcpMac->SendPending) { Status = phFriNfc_LlcpMac_Nfcip_Send(LlcpMac,LlcpMac->psSendBuffer,LlcpMac->MacSend_Cb,LlcpMac->MacSend_Context); } } }
/** * Response Callback for Remote device Presence Check. */ STATIC void phLibNfc_RemoteDev_CheckPresence_Cb(void *context, NFCSTATUS status) { void *pUpperLayerContext=NULL; pphLibNfc_RspCb_t pClientCb=NULL; /*check valid context is returned or not*/ if((phLibNfc_LibContext_t *)context != gpphLibContext) { /*exception: wrong context pointer returned*/ phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); } /* Mark general callback pending status as FALSE*/ gpphLibContext->status.GenCb_pending_status = FALSE; pClientCb =gpphLibContext->CBInfo.pClientPresChkCb ; pUpperLayerContext = gpphLibContext->CBInfo.pClientPresChkCntx; gpphLibContext->CBInfo.pClientPresChkCntx = NULL; gpphLibContext->CBInfo.pClientPresChkCb =NULL; /* Check DeInit call is called, if yes call pending shutdown and return NFCSTATUS_SHUTDOWN */ if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state) { phLibNfc_Pending_Shutdown(); status = NFCSTATUS_SHUTDOWN; } else { if (status != NFCSTATUS_SUCCESS) { /*If status is other than SUCCESS (Internal error) return NFCSTATUS_TARGET_LOST */ status= NFCSTATUS_TARGET_LOST; } else { status = NFCSTATUS_SUCCESS; } } /* Update the current state */ phLibNfc_UpdateCurState(status,gpphLibContext); if(NULL != pClientCb) { /* call the upper layer callback */ pClientCb(pUpperLayerContext,status); } return; }
static void phFriNfc_LlcpMac_Nfcip_Send_Cb(void *pContext, NFCSTATUS Status) { phFriNfc_LlcpMac_t *LlcpMac = (phFriNfc_LlcpMac_t *)pContext; #ifdef LLCP_CHANGES if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown) { phLibNfc_Pending_Shutdown(); Status = NFCSTATUS_SHUTDOWN; } #endif /* #ifdef LLCP_CHANGES */ /* Reset Send and Receive Flag */ LlcpMac->SendPending = FALSE; LlcpMac->RecvPending = FALSE; phFriNfc_LlcpMac_Nfcip_TriggerSendCb(LlcpMac, Status); }
STATIC void phLibNfc_Ioctl_Mgmt_CB(void *context, phNfc_sData_t *pOutData, NFCSTATUS status ) { phLibNfc_Ioctl_Cntx_t *pIoctlCntx=NULL; if(PHNFCSTATUS(status)!=NFCSTATUS_SUCCESS) { status = NFCSTATUS_FAILED; } if(gpphLibContext!= NULL) { if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state) { /*If shutdown called in between allow shutdown to happen*/ phLibNfc_Pending_Shutdown(); status = NFCSTATUS_SHUTDOWN; } } pIoctlCntx= (phLibNfc_Ioctl_Cntx_t*)context; if( pIoctlCntx !=NULL) { switch(pIoctlCntx->IoctlCode) { case NFC_FW_DOWNLOAD: { /*Release the hardware reference memory*/ phOsalNfc_FreeMemory(pIoctlCntx->psHwReference); }break; case NFC_MEM_READ: { }break; case NFC_MEM_WRITE: { }break; case PHLIBNFC_ANTENNA_TEST: { }break; case PHLIBNFC_SWP_TEST: { }break; case PHLIBNFC_PRBS_TEST: { }break; default: { } } pIoctlCntx->CliRspCb(pIoctlCntx->pCliCntx,pOutData,status); if(gpphLibContext!= NULL) { gpphLibContext->status.GenCb_pending_status=FALSE; } } }
/** * Callback for Se Set mode */ STATIC void phLibNfc_SE_SetMode_cb(void *context, NFCSTATUS status) { pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)context; pphLibNfc_SE_SetModeRspCb_t pUpperLayerCb=NULL; void *pUpperContext=NULL; phLibNfc_Handle hSeHandle=0; uint8_t TempState=FALSE; if(pLibContext != gpphLibContext) { /*wrong context returned*/ phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1); } else { if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state) { /*If shutdown is called in between allow shutdown to happen*/ phLibNfc_Pending_Shutdown(); status = NFCSTATUS_SHUTDOWN; } else { if(status == NFCSTATUS_SUCCESS) { hSeHandle = pLibContext->sSeContext.hSetemp; if(hSeHandle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement) { if(TRUE==pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc) { /*If Activation mode was virtual allow external reader to see it*/ pLibContext->sSeContext.uUiccActivate = TRUE; sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState = phLibNfc_SE_Active; } else { /*If Activation mode was wired don't allow external reader to see it*/ pLibContext->sSeContext.uUiccActivate = FALSE; sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState = phLibNfc_SE_Inactive; } status = NFCSTATUS_SUCCESS; TempState = pLibContext->sSeContext.uUiccActivate; } else if (hSeHandle==sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement) { if(TRUE==pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation) { /*If Activation mode was virtual allow external reader to see it*/ pLibContext->sSeContext.uSmxActivate = TRUE; sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState = phLibNfc_SE_Active; } else { /*If Activation mode was wired don't allow external reader to see it*/ pLibContext->sSeContext.uSmxActivate = FALSE; sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState= phLibNfc_SE_Inactive; } status = NFCSTATUS_SUCCESS; TempState = pLibContext->sSeContext.uSmxActivate; } else { status = NFCSTATUS_FAILED; } } else { status = NFCSTATUS_FAILED; } pLibContext->status.GenCb_pending_status = FALSE; } } pUpperLayerCb = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb; pUpperContext = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt; pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = NULL; pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt = NULL; PHNFC_UNUSED_VARIABLE(TempState); /* Call the upper layer cb */ if(pUpperLayerCb!= NULL ) { (*pUpperLayerCb)(pUpperContext, hSeHandle, status); } return; }