Home | History | Annotate | Download | only in src
      1 /*
      2  * Copyright (C) 2010 NXP Semiconductors
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /*!
     18  * \file phLibNfc_SE.c
     19 
     20  * Project: NFC FRI / HALDL
     21  *
     22  * $Date: Thu Apr 22 13:59:50 2010 $
     23  * $Author: ing07385 $
     24  * $Revision: 1.65 $
     25  * $Aliases: NFC_FRI1.1_WK1014_SDK,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1019_SDK,NFC_FRI1.1_WK1024_SDK $
     26  *
     27  */
     28 
     29 /*
     30 ************************* Header Files ***************************************
     31 */
     32 
     33 #include <phNfcStatus.h>
     34 #include <phLibNfc.h>
     35 #include <phHal4Nfc.h>
     36 #include <phOsalNfc.h>
     37 #include <phLibNfc_Internal.h>
     38 #include <phLibNfc_SE.h>
     39 #include <phLibNfc_ndef_raw.h>
     40 #include <phLibNfc_initiator.h>
     41 #include <phLibNfc_discovery.h>
     42 
     43 /*
     44 *************************** Macro's  ****************************************
     45 */
     46 
     47 #ifndef STATIC_DISABLE
     48 #define STATIC static
     49 #else
     50 #define STATIC
     51 #endif
     52 
     53 /*
     54 *************************** Global Variables **********************************
     55 */
     56 
     57 /*This Structure  contains the Secure Element information*/
     58 phLibNfc_SE_List_t sSecuredElementInfo[PHLIBNFC_MAXNO_OF_SE];
     59 
     60 /*
     61 *************************** Static Function Declaration ***********************
     62 */
     63 
     64 /* Response callback for SE Set Mode*/
     65 STATIC
     66 void phLibNfc_SE_SetMode_cb(void  *context, NFCSTATUS status);
     67 
     68 
     69 /* SE register listner response notification */
     70 STATIC
     71 void phLibNfc_SeNotification(void                     *context,
     72                         phHal_eNotificationType_t     type,
     73                         phHal4Nfc_NotificationInfo_t  info,
     74                         NFCSTATUS                     status
     75                         );
     76 /*
     77 *************************** Function Definitions ******************************
     78 */
     79 
     80 /**
     81 * Registers notification handler to handle secure element specific events
     82 */
     83 NFCSTATUS phLibNfc_SE_NtfRegister   (
     84                             pphLibNfc_SE_NotificationCb_t  pSE_NotificationCb,
     85                             void                            *pContext
     86                             )
     87 {
     88      NFCSTATUS         Status = NFCSTATUS_SUCCESS;
     89      pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)gpphLibContext;
     90 
     91      if((NULL == gpphLibContext) ||
     92          (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
     93      {
     94          Status = NFCSTATUS_NOT_INITIALISED;
     95      }
     96      else if((pSE_NotificationCb == NULL)
     97          ||(NULL == pContext))
     98      {
     99          /*parameters sent by upper layer are not valid*/
    100          Status = NFCSTATUS_INVALID_PARAMETER;
    101      }
    102      else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
    103      {
    104          Status = NFCSTATUS_SHUTDOWN;
    105      }
    106      else
    107      {
    108          /*Register SE notification with lower layer.
    109          Any activity on Smx or UICC will be notified */
    110          Status = phHal4Nfc_RegisterNotification(
    111                                             pLibContext->psHwReference,
    112                                             eRegisterSecureElement,
    113                                             phLibNfc_SeNotification,
    114                                             (void*)pLibContext);
    115         if(Status == NFCSTATUS_SUCCESS)
    116         {
    117             pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb = pSE_NotificationCb;
    118             pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt=pContext;
    119         }
    120         else
    121         {
    122             /* Registration failed */
    123             Status = NFCSTATUS_FAILED;
    124         }
    125      }
    126      return Status;
    127 }
    128 /**
    129 * SE Notification events are notified with this callback
    130 */
    131 STATIC void phLibNfc_SeNotification(void  *context,
    132                                     phHal_eNotificationType_t    type,
    133                                     phHal4Nfc_NotificationInfo_t  info,
    134                                     NFCSTATUS                   status)
    135 {
    136     pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)context;
    137     phHal_sEventInfo_t  *pEvtInfo = NULL;
    138     phLibNfc_uSeEvtInfo_t Se_Trans_Info={0};
    139     phLibNfc_SE_List_t  *pSeInfo=NULL;
    140 
    141     if(pLibContext != gpphLibContext)
    142     {
    143         /*wrong context returned*/
    144         phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
    145     }
    146     else
    147     {
    148         if((status == NFCSTATUS_SUCCESS) && (type == NFC_EVENT_NOTIFICATION))
    149         {
    150             pEvtInfo = info.psEventInfo;
    151             status = NFCSTATUS_SUCCESS;
    152             if((pEvtInfo->eventSource == phHal_ePICC_DevType )
    153                 && (pEvtInfo->eventHost == phHal_eHostController) )
    154             {
    155                 sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_Type = phLibNfc_SE_Type_SmartMX;
    156                 /* Smartx Mx is Activated */
    157                 pSeInfo = &sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX];
    158             }
    159             if(pEvtInfo->eventHost == phHal_eUICCHost)
    160             {
    161                 /* UICC is Activate */
    162                 sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type = phLibNfc_SE_Type_UICC;
    163                 pSeInfo = &sSecuredElementInfo[LIBNFC_SE_UICC_INDEX];
    164             }
    165             else
    166             {
    167                 /*presently Smx event source is not supported */
    168             }
    169             if(pSeInfo!=NULL)
    170             {
    171                 switch(pEvtInfo->eventType)
    172                 {
    173                     case NFC_EVT_TRANSACTION:
    174                     {
    175                         if(pEvtInfo->eventInfo.aid.length != 0)
    176                         {
    177                             /*copy the Application id on which transaction happened*/
    178 							Se_Trans_Info.UiccEvtInfo.aid.buffer =pEvtInfo->eventInfo.aid.buffer;
    179 							Se_Trans_Info.UiccEvtInfo.aid.length =pEvtInfo->eventInfo.aid.length;
    180                         }
    181 						if((pEvtInfo->eventHost == phHal_eUICCHost)
    182                            && (info.psEventInfo->eventInfo.uicc_info.param.length
    183                                 != 0))
    184                         {
    185                             /*copy the parameters info on which transaction happened*/
    186 							Se_Trans_Info.UiccEvtInfo.param.buffer =
    187 										info.psEventInfo->eventInfo.uicc_info.param.buffer;
    188 							Se_Trans_Info.UiccEvtInfo.param.length =
    189 										info.psEventInfo->eventInfo.uicc_info.param.length;
    190                         }
    191                             /*Notify to upper layer that transaction had happened on the
    192                             one of the application stored in UICC or Smx*/
    193                         (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
    194                             pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
    195                             phLibNfc_eSE_EvtStartTransaction,
    196                             pSeInfo->hSecureElement,
    197                             &Se_Trans_Info,
    198                             status);
    199                         break;
    200                     }
    201                     case NFC_EVT_END_OF_TRANSACTION:
    202                     {
    203                         (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
    204                             pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
    205                             phLibNfc_eSE_EvtEndTransaction,
    206                             pSeInfo->hSecureElement,
    207                             &Se_Trans_Info,
    208                             status);
    209                         break;
    210                     }
    211 					case NFC_EVT_CONNECTIVITY:
    212                     {
    213                         (*pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb)(
    214                             pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt,
    215                             phLibNfc_eSE_EvtConnectivity,
    216                             pSeInfo->hSecureElement,
    217                             &Se_Trans_Info,
    218                             status);
    219                         break;
    220                     }
    221                     case NFC_EVT_START_OF_TRANSACTION:
    222                     default:
    223                     {
    224                         break;
    225                     }
    226                 }
    227             }
    228             else
    229             {
    230 
    231             }
    232          }
    233     }
    234   return;
    235 }
    236 
    237 /**
    238  * Unregister the Secured Element Notification.
    239  */
    240 NFCSTATUS phLibNfc_SE_NtfUnregister(void)
    241 {
    242     NFCSTATUS Status = NFCSTATUS_SUCCESS;
    243     pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)gpphLibContext;
    244 
    245     if((NULL == gpphLibContext) ||
    246         (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
    247     {
    248         /*Lib Nfc is not initialized*/
    249         Status = NFCSTATUS_NOT_INITIALISED;
    250     }
    251     else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
    252     {
    253         Status = NFCSTATUS_SHUTDOWN;
    254     }
    255     else
    256     {
    257         /*Unregister SE event notification with lower layer.
    258         even some transaction happens on UICC or Smx will not
    259         be notified afterworlds */
    260         Status = phHal4Nfc_UnregisterNotification(
    261                                                 pLibContext->psHwReference,
    262                                                 eRegisterSecureElement,
    263                                                 pLibContext);
    264         if(Status != NFCSTATUS_SUCCESS)
    265         {
    266             /*Unregister failed*/
    267             Status=NFCSTATUS_FAILED;
    268         }
    269         pLibContext->sSeContext.sSeCallabackInfo.pSeListenerNtfCb=NULL;
    270         pLibContext->sSeContext.sSeCallabackInfo.pSeListenerCtxt=NULL;
    271     }
    272     return Status;
    273 }
    274 
    275 /**
    276 * Get list of available Secure Elements
    277 */
    278 NFCSTATUS phLibNfc_SE_GetSecureElementList(
    279                         phLibNfc_SE_List_t*     pSE_List,
    280                         uint8_t*                uSE_count
    281                         )
    282 {
    283     NFCSTATUS Status = NFCSTATUS_SUCCESS;
    284 	uint8_t    uNo_Of_SE = 0;
    285 
    286     if((NULL == gpphLibContext) ||
    287         (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
    288     {
    289         Status = NFCSTATUS_NOT_INITIALISED;
    290     }
    291     else if((NULL ==pSE_List) || (NULL ==uSE_count))
    292     {
    293         Status = NFCSTATUS_INVALID_PARAMETER;
    294     }
    295     else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
    296     {
    297         Status = NFCSTATUS_SHUTDOWN;
    298     }
    299     else
    300     {
    301         /*Check for which type of Secure Element is available*/
    302         if(gpphLibContext->psHwReference->uicc_connected==TRUE)
    303         {
    304             /* Populate the UICC type */
    305             sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type = phLibNfc_SE_Type_UICC;
    306 
    307             /* Populate the UICC handle */
    308             sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement =(phLibNfc_Handle)
    309                             (LIBNFC_SE_UICC_INDEX + LIBNFC_SE_BASE_HANDLE);
    310 
    311 #ifdef NXP_HAL_ENABLE_SMX
    312 
    313             pSE_List[LIBNFC_SE_UICC_INDEX].eSE_Type =
    314 				sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type;
    315             pSE_List[LIBNFC_SE_UICC_INDEX].hSecureElement = (phLibNfc_Handle)
    316                             (LIBNFC_SE_UICC_INDEX + LIBNFC_SE_BASE_HANDLE);
    317             pSE_List[LIBNFC_SE_UICC_INDEX].eSE_CurrentState =
    318 				sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState;
    319 #else
    320 			pSE_List->eSE_Type =
    321 				sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_Type;
    322             pSE_List->hSecureElement = (phLibNfc_Handle)
    323                             (LIBNFC_SE_UICC_INDEX + LIBNFC_SE_BASE_HANDLE);
    324             pSE_List->eSE_CurrentState =
    325 				sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState;
    326 #endif
    327             /* update the No of SE retrieved */
    328 			uNo_Of_SE ++;
    329 
    330         }
    331         if (gpphLibContext->psHwReference->smx_connected ==TRUE)
    332         {
    333             /* if the Smx is also connected to the PN544 */
    334             /* Populate the SMX type */
    335             sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_Type = phLibNfc_SE_Type_SmartMX;
    336 
    337             /* Populate the SMX handle */
    338             sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement =(phLibNfc_Handle)
    339                             (LIBNFC_SE_SMARTMX_INDEX + LIBNFC_SE_BASE_HANDLE);
    340             pSE_List[LIBNFC_SE_SMARTMX_INDEX].eSE_Type =
    341 				sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_Type;
    342             pSE_List[LIBNFC_SE_SMARTMX_INDEX].hSecureElement = (phLibNfc_Handle)
    343                             (LIBNFC_SE_SMARTMX_INDEX + LIBNFC_SE_BASE_HANDLE);
    344             pSE_List[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState =
    345 				sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState;
    346 
    347             /* update the No of SE retrieved */
    348 			uNo_Of_SE ++;
    349 
    350         }
    351 		*uSE_count = uNo_Of_SE;
    352     }
    353     return Status;
    354 }
    355 
    356 /**
    357 * Sets secure element mode.
    358 * This  function configures SE to specific mode based on activation mode type
    359 */
    360 
    361 NFCSTATUS phLibNfc_SE_SetMode ( phLibNfc_Handle             hSE_Handle,
    362                                phLibNfc_eSE_ActivationMode  eActivation_mode,
    363                                pphLibNfc_SE_SetModeRspCb_t  pSE_SetMode_Rsp_cb,
    364                                void *                       pContext
    365                                )
    366 {
    367     NFCSTATUS Status = NFCSTATUS_SUCCESS;
    368     phHal_eEmulationType_t  eEmulationType = NFC_SMARTMX_EMULATION;
    369     pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)gpphLibContext;
    370 
    371     if((NULL == gpphLibContext) ||
    372         (gpphLibContext->LibNfcState.cur_state == eLibNfcHalStateShutdown))
    373     {
    374         Status = NFCSTATUS_NOT_INITIALISED;
    375     }
    376 	else if((pSE_SetMode_Rsp_cb ==NULL)
    377         ||(NULL == pContext)||(NULL==(void *)hSE_Handle))
    378     {
    379         Status=NFCSTATUS_INVALID_PARAMETER;
    380     }
    381 	else if(gpphLibContext->LibNfcState.next_state == eLibNfcHalStateShutdown)
    382     {
    383         Status = NFCSTATUS_SHUTDOWN;
    384     }
    385     else if((pLibContext->status.GenCb_pending_status == TRUE)
    386           ||(NULL!=pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb))
    387     {
    388         /*previous callback is pending still*/
    389         Status =NFCSTATUS_REJECTED;
    390     }
    391     else
    392     {
    393         switch(eActivation_mode)
    394         {
    395             case phLibNfc_SE_ActModeVirtual:
    396             case phLibNfc_SE_ActModeDefault:
    397             {
    398                 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
    399                 {
    400                     eEmulationType = NFC_UICC_EMULATION;
    401                     /*Enable the UICC -External reader can see it*/
    402                     pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc = TRUE;
    403                 }
    404                 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
    405                 {
    406                     eEmulationType = NFC_SMARTMX_EMULATION;
    407                     /*Enable the SMX -External reader can see it*/
    408                     pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation = TRUE;
    409                 }
    410                 else
    411                 {
    412                     Status=NFCSTATUS_INVALID_HANDLE;
    413                 }
    414                 if(Status==NFCSTATUS_SUCCESS)
    415                 {
    416                     pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeVirtual;
    417                     pLibContext->sCardEmulCfg.emuType = eEmulationType;
    418                     Status = phHal4Nfc_ConfigParameters(
    419                                             pLibContext->psHwReference,
    420                                             NFC_EMULATION_CONFIG,
    421                                             (phHal_uConfig_t*)&pLibContext->sCardEmulCfg,
    422                                             phLibNfc_SE_SetMode_cb,
    423                                             pLibContext);
    424                 }
    425             }
    426             break;
    427             case phLibNfc_SE_ActModeWired:
    428             {
    429                 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
    430                 {
    431                     if(pLibContext->CBInfo.pClientNtfRegRespCB!=NULL)
    432                     {
    433                         /*Disable the SMX -External reader can't see it anymore*/
    434                         pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation = FALSE;
    435                         pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeWired;
    436 
    437                         Status = phHal4Nfc_Switch_SMX_Mode(
    438                                             pLibContext->psHwReference,
    439                                             eSmartMx_Wired,
    440                                             phLibNfc_SE_SetMode_cb,
    441                                             pLibContext
    442                                             );
    443                     }
    444                 }
    445                 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
    446                 {
    447                     /*This mode is not applicable to UICC*/
    448                     Status = NFCSTATUS_REJECTED;
    449                 }
    450                 else
    451                 {
    452                     Status = NFCSTATUS_INVALID_HANDLE;
    453                 }
    454             }
    455             break;
    456 
    457             case phLibNfc_SE_ActModeOff:
    458             {
    459                 /*UICC emulation deactivate*/
    460                 if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
    461                 {
    462                     eEmulationType = NFC_UICC_EMULATION;
    463                     /*Disable the UICC -External reader can't see it anymore*/
    464                     pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc = FALSE;
    465 
    466                 }
    467                 else if(hSE_Handle == sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
    468                 {
    469                     eEmulationType = NFC_SMARTMX_EMULATION;
    470                     /*Disable the SMX -External reader can't see it anymore*/
    471                     pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation=FALSE;
    472 
    473                 }
    474                 else
    475                 {
    476                     Status = NFCSTATUS_INVALID_HANDLE;
    477                 }
    478                 if(Status==NFCSTATUS_SUCCESS)
    479                 {
    480                     pLibContext->sCardEmulCfg.emuType = eEmulationType;
    481                     pLibContext->sSeContext.eActivatedMode = phLibNfc_SE_ActModeOff;
    482                     Status = phHal4Nfc_ConfigParameters(pLibContext->psHwReference,
    483                                                             NFC_EMULATION_CONFIG,
    484                                                             (phHal_uConfig_t*)&pLibContext->sCardEmulCfg,
    485                                                             phLibNfc_SE_SetMode_cb,
    486                                                             pLibContext);
    487                 }
    488             }
    489             break;
    490             default:
    491                 Status=NFCSTATUS_INVALID_PARAMETER;
    492                 break;
    493 
    494         }/*End of eActivation_mode switch */
    495         if(Status==NFCSTATUS_PENDING)
    496         {
    497             pLibContext->sSeContext.hSetemp=hSE_Handle;
    498             pLibContext->status.GenCb_pending_status = TRUE;
    499             pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = pSE_SetMode_Rsp_cb;
    500             pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt=pContext;
    501         }
    502         else if(Status == NFCSTATUS_INVALID_HANDLE)
    503         {
    504             Status= Status;
    505         }
    506         else
    507         {
    508             Status = NFCSTATUS_FAILED;
    509         }
    510     }
    511     return Status;
    512 }
    513 /**
    514 * Callback for Se Set mode
    515 */
    516 STATIC void phLibNfc_SE_SetMode_cb(void  *context, NFCSTATUS status)
    517 {
    518     pphLibNfc_LibContext_t pLibContext=(pphLibNfc_LibContext_t)context;
    519     pphLibNfc_SE_SetModeRspCb_t  pUpperLayerCb=NULL;
    520     void                         *pUpperContext=NULL;
    521     phLibNfc_Handle              hSeHandle=0;
    522     uint8_t                      TempState=FALSE;
    523 
    524     if(pLibContext != gpphLibContext)
    525     {
    526         /*wrong context returned*/
    527         phOsalNfc_RaiseException(phOsalNfc_e_InternalErr,1);
    528     }
    529     else
    530     {
    531         if(eLibNfcHalStateShutdown == gpphLibContext->LibNfcState.next_state)
    532         {
    533             /*If shutdown is called in between allow shutdown to happen*/
    534             phLibNfc_Pending_Shutdown();
    535             status = NFCSTATUS_SHUTDOWN;
    536         }
    537         else
    538         {
    539             if(status == NFCSTATUS_SUCCESS)
    540             {
    541                 hSeHandle = pLibContext->sSeContext.hSetemp;
    542 
    543                 if(hSeHandle == sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].hSecureElement)
    544                 {
    545                     if(TRUE==pLibContext->sCardEmulCfg.config.uiccEmuCfg.enableUicc)
    546                     {
    547                         /*If  Activation mode was virtual allow external reader to see it*/
    548                         pLibContext->sSeContext.uUiccActivate = TRUE;
    549                         sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState = phLibNfc_SE_Active;
    550                     }
    551                     else
    552                     {
    553                         /*If  Activation mode was wired don't allow external reader to see it*/
    554                         pLibContext->sSeContext.uUiccActivate = FALSE;
    555                         sSecuredElementInfo[LIBNFC_SE_UICC_INDEX].eSE_CurrentState =
    556                                                                     phLibNfc_SE_Inactive;
    557                     }
    558                     status = NFCSTATUS_SUCCESS;
    559                     TempState = pLibContext->sSeContext.uUiccActivate;
    560                 }
    561                 else if (hSeHandle==sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].hSecureElement)
    562                 {
    563                     if(TRUE==pLibContext->sCardEmulCfg.config.smartMxCfg.enableEmulation)
    564                     {
    565                         /*If  Activation mode was virtual allow external reader to see it*/
    566                         pLibContext->sSeContext.uSmxActivate = TRUE;
    567                         sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState =
    568                                                                         phLibNfc_SE_Active;
    569                     }
    570                     else
    571                     {
    572                         /*If  Activation mode was wired don't allow external reader to see it*/
    573                         pLibContext->sSeContext.uSmxActivate = FALSE;
    574                         sSecuredElementInfo[LIBNFC_SE_SMARTMX_INDEX].eSE_CurrentState=
    575                                                                         phLibNfc_SE_Inactive;
    576                     }
    577                     status = NFCSTATUS_SUCCESS;
    578                     TempState = pLibContext->sSeContext.uSmxActivate;
    579                 }
    580                 else
    581                 {
    582                     status = NFCSTATUS_FAILED;
    583                 }
    584             }
    585             else
    586             {
    587                 status = NFCSTATUS_FAILED;
    588             }
    589             pLibContext->status.GenCb_pending_status = FALSE;
    590         }
    591 
    592     }
    593     pUpperLayerCb = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb;
    594     pUpperContext = pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt;
    595     pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCb = NULL;
    596     pLibContext->sSeContext.sSeCallabackInfo.pSEsetModeCtxt = NULL;
    597 	PHNFC_UNUSED_VARIABLE(TempState);
    598     /* Call the upper layer cb */
    599     if(pUpperLayerCb!= NULL )
    600     {
    601         (*pUpperLayerCb)(pUpperContext,
    602                         hSeHandle,
    603 						status);
    604     }
    605     return;
    606 }
    607 
    608 
    609 
    610