NFCSTATUS
phHciNfc_Close_Pipe(
                        phHciNfc_sContext_t     *psHciContext,
                        void                    *pHwRef,
                        phHciNfc_Pipe_Info_t    *pPipeHandle
                    )
{
    uint8_t                 pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    NFCSTATUS               cmd_status = NFCSTATUS_SUCCESS;

    if( (NULL == psHciContext)
        || ( NULL == pHwRef )
        || ( NULL == pPipeHandle )
      )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        /* Obtain the pipe_id from the pipe_handle */
        pipe_id = pPipeHandle->pipe.pipe_id;

        if( (uint8_t)HCI_UNKNOWN_PIPE_ID > pipe_id)
        {
            cmd_status = phHciNfc_Send_Generic_Cmd(
                                        psHciContext, pHwRef, pipe_id,
                                        ANY_CLOSE_PIPE );

            status = ((cmd_status == NFCSTATUS_PENDING)?
                                NFCSTATUS_SUCCESS : cmd_status);
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_ReaderB_Set_LayerData(
                        void            *psContext,
                        void            *pHwRef,
                        phNfc_sData_t   *layer_data_info
                        )
{
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t         *psHciContext = 
                                (phHciNfc_sContext_t *)psContext ;

    if( (NULL == psHciContext) || (NULL == pHwRef) || 
        (NULL == layer_data_info) || (NULL == layer_data_info->buffer)
        || (0 == layer_data_info->length))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_reader_b_info) || 
        (HCI_READER_B_ENABLE != 
        ((phHciNfc_ReaderB_Info_t *)(psHciContext->p_reader_b_info))->
        enable_rdr_b_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_ReaderB_Info_t     *ps_rdr_b_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        ps_rdr_b_info = (phHciNfc_ReaderB_Info_t *)
                        psHciContext->p_reader_b_info ;
        p_pipe_info = ps_rdr_b_info->p_pipe_info;
        if(NULL == p_pipe_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                NFCSTATUS_INVALID_HCI_SEQUENCE);
        }
        else
        {
            p_pipe_info->reg_index = RDR_B_HIGHER_LAYER_DATA_INDEX;
            pipeid = ps_rdr_b_info->pipe_id ;
            p_pipe_info->param_info = (void *)layer_data_info->buffer;
            p_pipe_info->param_length = (uint8_t)
                                        layer_data_info->length;
            /* Fill the data buffer and send the command to the 
            device */
            status = phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                                pipeid, (uint8_t)ANY_SET_PARAMETER);
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_ReaderA_Fwi_Sfgt (
    void             *psHciHandle,
    void             *pHwRef
)
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t     *psHciContext = ((phHciNfc_sContext_t *)psHciHandle);
    if( (NULL == psHciContext)
            || (NULL == pHwRef)
      )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_reader_a_info) ||
            (HCI_READER_A_ENABLE !=
             ((phHciNfc_ReaderA_Info_t *)(psHciContext->p_reader_a_info))->
             enable_rdr_a_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_ReaderA_Info_t     *p_rdr_a_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        p_rdr_a_info = (phHciNfc_ReaderA_Info_t *)
                       psHciContext->p_reader_a_info ;
        p_pipe_info = p_rdr_a_info->p_pipe_info;
        if(NULL == p_pipe_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI,
                                NFCSTATUS_INVALID_HCI_SEQUENCE);
        }
        else
        {
            p_pipe_info->reg_index = RDR_A_FWI_SFGT_INDEX;
            pipeid = p_rdr_a_info->pipe_id ;
            /* Fill the data buffer and send the command to the
            device */
            status =
                phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
                                           pipeid, (uint8_t)ANY_GET_PARAMETER);
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_SWP_Protection(
                            void        *psHciHandle,
                            void        *pHwRef,
                            uint8_t     mode
                      )
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    static uint8_t          param = 0 ;
    phHciNfc_sContext_t     *psHciContext = ((phHciNfc_sContext_t *)psHciHandle);

    if((NULL == psHciContext)||(NULL == pHwRef))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if(NULL == psHciContext->p_swp_info)
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_SWP_Info_t         *ps_swp_info=NULL;
        phHciNfc_Pipe_Info_t        *ps_pipe_info=NULL;
        
        ps_swp_info = (phHciNfc_SWP_Info_t*)psHciContext->p_swp_info;       
        ps_pipe_info = ps_swp_info->p_pipe_info;

        if(NULL == ps_pipe_info)
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                                NFCSTATUS_INVALID_HCI_INFORMATION);
        }
        else
        {
            ps_pipe_info->reg_index = NXP_SWP_PROTECTED_INDEX;
            /* Enable/Disable SWP Protection */
            param = (uint8_t)mode;
            ps_pipe_info->param_info =(void*)&param ;
            ps_pipe_info->param_length = sizeof(param) ;
            status = phHciNfc_Send_Generic_Cmd(psHciContext, pHwRef, 
                                        ps_swp_info->pipe_id, 
                                        (uint8_t)ANY_SET_PARAMETER);
        }

    }
    return status;
}
NFCSTATUS
phHciNfc_ReaderA_Auto_Activate(
    void         *psContext,
    void         *pHwRef,
    uint8_t      activate_enable
)
{
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t         *psHciContext =
        (phHciNfc_sContext_t *)psContext ;
    if( (NULL == psHciContext) || (NULL == pHwRef))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_reader_a_info) ||
            (HCI_READER_A_ENABLE !=
             ((phHciNfc_ReaderA_Info_t *)(psHciContext->p_reader_a_info))->
             enable_rdr_a_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_ReaderA_Info_t     *p_rdr_a_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        p_rdr_a_info = (phHciNfc_ReaderA_Info_t *)
                       psHciContext->p_reader_a_info ;
        p_pipe_info = p_rdr_a_info->p_pipe_info;
        p_pipe_info->reg_index = NXP_AUTO_ACTIVATION_INDEX;
        p_pipe_info->param_info = &activate_enable;
        p_pipe_info->param_length = sizeof(activate_enable);
        pipeid = p_rdr_a_info->pipe_id ;
        status = phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
                                            pipeid, (uint8_t)ANY_SET_PARAMETER);
        if(NFCSTATUS_PENDING == status )
        {
            status = NFCSTATUS_SUCCESS;
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_SWP_Get_Status(
                            void        *psHciHandle,
                            void        *pHwRef
                        )
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    /* static uint8_t       param = 0 ; */
    phHciNfc_sContext_t     *psHciContext = ((phHciNfc_sContext_t *)psHciHandle);

    if((NULL == psHciContext)||(NULL == pHwRef))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if(NULL == psHciContext->p_swp_info)
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_SWP_Info_t         *ps_swp_info=NULL;
        phHciNfc_Pipe_Info_t        *ps_pipe_info=NULL;

        ps_swp_info = (phHciNfc_SWP_Info_t*)psHciContext->p_swp_info;
        ps_pipe_info = ps_swp_info->p_pipe_info;

        if(NULL == ps_pipe_info)
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                                NFCSTATUS_INVALID_HCI_INFORMATION);
        }
        else
        {
            ps_pipe_info->reg_index = NXP_SWP_STATUS_INDEX;
            status = phHciNfc_Send_Generic_Cmd(psHciContext, pHwRef,  
                                    ps_swp_info->pipe_id, 
                                    (uint8_t)ANY_GET_PARAMETER);
        }
    }
    return status;
}
NFCSTATUS
phHciNfc_ReaderA_Set_DataRateMax(
    void         *psContext,
    void         *pHwRef,
    uint8_t      data_rate_value
)
{
    NFCSTATUS                   status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t         *psHciContext =
        (phHciNfc_sContext_t *)psContext ;
    if( (NULL == psHciContext) || (NULL == pHwRef))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_reader_a_info) ||
            (HCI_READER_A_ENABLE !=
             ((phHciNfc_ReaderA_Info_t *)(psHciContext->p_reader_a_info))->
             enable_rdr_a_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }
    else
    {
        phHciNfc_ReaderA_Info_t     *p_rdr_a_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        p_rdr_a_info = (phHciNfc_ReaderA_Info_t *)
                       psHciContext->p_reader_a_info ;
        p_pipe_info = p_rdr_a_info->p_pipe_info;
        p_pipe_info->reg_index = RDR_A_DATA_RATE_MAX_INDEX;
        p_pipe_info->param_info = &data_rate_value;
        p_pipe_info->param_length = sizeof(data_rate_value);
        pipeid = p_rdr_a_info->pipe_id ;
        status = phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
                                            pipeid, (uint8_t)ANY_SET_PARAMETER);
    }
    return status;
}
NFCSTATUS
phHciNfc_Felica_Info_Sequence (
                               void             *psHciHandle,
                               void             *pHwRef
                               )
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t     *psHciContext = 
                            ((phHciNfc_sContext_t *)psHciHandle);

    HCI_PRINT ("HCI : phHciNfc_Felica_Info_Sequence called... \n");
    if( (NULL == psHciContext) 
        || (NULL == pHwRef)
        )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_felica_info) || 
        (HCI_FELICA_ENABLE != 
        ((phHciNfc_Felica_Info_t *)(psHciContext->p_felica_info))->
        enable_felica_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }   
    else
    {
        phHciNfc_Felica_Info_t      *p_fel_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        p_fel_info = (phHciNfc_Felica_Info_t *)
                        psHciContext->p_felica_info ;
        p_pipe_info = p_fel_info->p_pipe_info;
        if(NULL == p_pipe_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                NFCSTATUS_INVALID_HCI_SEQUENCE);
        }
        else
        {
            HCI_DEBUG ("HCI : p_fel_info->current_seq : %02X\n", p_fel_info->current_seq);
            switch(p_fel_info->current_seq)
            {
                case FELICA_SYSTEMCODE:
                {
                    p_pipe_info->reg_index = NXP_FEL_SYS_CODE;
                    pipeid = p_fel_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                        device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                        pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_fel_info->next_seq = FELICA_CURRENTIDM;
                    }
                    break;
                }
                case FELICA_CURRENTIDM:
                {
                    p_pipe_info->reg_index = NXP_FEL_CURRENTIDM;
                    pipeid = p_fel_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                        device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                        pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_fel_info->next_seq = FELICA_CURRENTPMM;
                    }
                    break;
                }
                case FELICA_CURRENTPMM:
                {
                    p_pipe_info->reg_index = NXP_FEL_CURRENTPMM;
                    pipeid = p_fel_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                        device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                        pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_fel_info->next_seq = FELICA_END_SEQUENCE;
                    }
                    break;
                }
                case FELICA_END_SEQUENCE:
                {
                    phNfc_sCompletionInfo_t     CompInfo;
                    if (FEL_MULTIPLE_TAGS_FOUND == 
                        p_fel_info->multiple_tgts_found)
                    {
                        CompInfo.status = NFCSTATUS_MULTIPLE_TAGS;
                    }
                    else
                    {
                        CompInfo.status = NFCSTATUS_SUCCESS;
                    }

                    CompInfo.info = &(p_fel_info->felica_info);

                    p_fel_info->felica_info.RemDevType = phHal_eFelica_PICC;
                    p_fel_info->current_seq = FELICA_SYSTEMCODE;
                    p_fel_info->next_seq = FELICA_SYSTEMCODE;
                    status = NFCSTATUS_SUCCESS;
                    HCI_DEBUG ("HCI : p_fel_info->felica_info.RemDevType : %02X\n", p_fel_info->felica_info.RemDevType);
                    HCI_DEBUG ("HCI : status notified: %02X\n", CompInfo.status);
                    /* Notify to the upper layer */
                    phHciNfc_Tag_Notify(psHciContext, 
                                        pHwRef, 
                                        NFC_NOTIFY_TARGET_DISCOVERED, 
                                        &CompInfo);
                    break;
                }
                default:
                {
                    status = PHNFCSTVAL(CID_NFC_HCI, 
                        NFCSTATUS_INVALID_HCI_RESPONSE);
                    break;
                }
            } 
            HCI_DEBUG ("HCI : p_fel_info->current_seq after : %02X\n", p_fel_info->current_seq);
            HCI_DEBUG ("HCI : p_fel_info->next_seq : %02X\n", p_fel_info->next_seq);
        }
    }
    HCI_PRINT ("HCI : phHciNfc_Felica_Info_Sequence end\n");
    return status;
}
Beispiel #9
0
NFCSTATUS
phHciNfc_LinkMgmt_Initialise(
                                phHciNfc_sContext_t     *psHciContext,
                                void                    *pHwRef
                         )
{
    NFCSTATUS                           status = NFCSTATUS_SUCCESS;
    phHciNfc_Pipe_Info_t                *p_pipe_info = NULL;
    phHciNfc_LinkMgmt_Info_t            *p_link_mgmt_info=NULL;
    uint8_t                             link_pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;

    if( ( NULL == psHciContext )
        || (NULL == pHwRef )
        )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        if( ( NULL == psHciContext->p_link_mgmt_info )
            && (phHciNfc_Allocate_Resource((void **)(&p_link_mgmt_info),
                    sizeof(phHciNfc_LinkMgmt_Info_t))== NFCSTATUS_SUCCESS)
          )
        {
            psHciContext->p_link_mgmt_info = p_link_mgmt_info;
            p_link_mgmt_info->link_cur_seq = LINK_MGMT_PIPE_OPEN;
            p_link_mgmt_info->link_next_seq = LINK_MGMT_PIPE_OPEN;
            p_link_mgmt_info->p_pipe_info = NULL;
        }
        else
        {
            p_link_mgmt_info = (phHciNfc_LinkMgmt_Info_t *)
                                psHciContext->p_link_mgmt_info ;
        }

        if( NULL == p_link_mgmt_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI,
                        NFCSTATUS_INVALID_HCI_INFORMATION);
        }
#ifdef ESTABLISH_SESSION
        else if( hciMode_Session == psHciContext->hci_mode )
        {
            status = NFCSTATUS_SUCCESS;
        }
#endif
        else
        {
            switch(p_link_mgmt_info->link_cur_seq )
            {
                /* Link Mgmt pipe open sequence */
                case LINK_MGMT_PIPE_OPEN:
                {
                    if(phHciNfc_Allocate_Resource((void **)(&p_pipe_info),
                        sizeof(phHciNfc_Pipe_Info_t))!= NFCSTATUS_SUCCESS)
                    {
                        status = PHNFCSTVAL(CID_NFC_HCI,
                                NFCSTATUS_INSUFFICIENT_RESOURCES);
                    }
                    else
                    {
                        /* Populate the pipe information in the pipe handle */
                        ((phHciNfc_Pipe_Info_t *)p_pipe_info)->pipe.pipe_id = 
                                        PIPETYPE_STATIC_LINK;
                        ((phHciNfc_Pipe_Info_t *)p_pipe_info)->recv_resp = 
                                        &phHciNfc_Recv_LinkMgmt_Response;
                        psHciContext->p_pipe_list[PIPETYPE_STATIC_LINK] =
                                                                    p_pipe_info ;
                        status = phHciNfc_Open_Pipe( psHciContext,
                                                            pHwRef,p_pipe_info );
                        if(status == NFCSTATUS_SUCCESS)
                        {
                            p_link_mgmt_info->p_pipe_info = p_pipe_info ;
                            p_link_mgmt_info->link_next_seq = 
                                                    LINK_MGMT_GET_REC_ERROR;
                            status = NFCSTATUS_PENDING;
                        }
                    }
                    break;
                }
                case LINK_MGMT_GET_REC_ERROR:
                {
                    p_pipe_info = p_link_mgmt_info->p_pipe_info;
                    if(NULL == p_pipe_info )
                    {
                        status = PHNFCSTVAL(CID_NFC_HCI, 
                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
                    }
                    else
                    {
                        p_pipe_info->reg_index = REC_ERROR_INDEX;
                        link_pipe_id = PIPETYPE_STATIC_LINK ;
                        status = 
                            phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                                link_pipe_id,   (uint8_t)ANY_GET_PARAMETER );
                        if(NFCSTATUS_PENDING == status )
                        {
                            p_link_mgmt_info->link_next_seq =
                                                        LINK_MGMT_PIPE_CLOSE;
                            status = NFCSTATUS_SUCCESS;
                        }
                    }
                    break;
                }
                case LINK_MGMT_SET_REC_ERROR:
                {
                    p_pipe_info = p_link_mgmt_info->p_pipe_info;
                    if(NULL == p_pipe_info )
                    {
                        status = PHNFCSTVAL(CID_NFC_HCI, 
                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
                    }
                    else
                    {
                        p_pipe_info->reg_index = REC_ERROR_INDEX;
                        link_pipe_id = PIPETYPE_STATIC_LINK ;
                        status = 
                            phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                                link_pipe_id,   (uint8_t)ANY_GET_PARAMETER );
                        if(NFCSTATUS_PENDING == status )
                        {
                            p_link_mgmt_info->link_next_seq =
                                                        LINK_MGMT_PIPE_CLOSE;
                            status = NFCSTATUS_SUCCESS;
                        }
                    }
                    break;
                }
                default:
                {
                    status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
                    break;
                }

            }/* End of the Sequence Switch */

        }/* End of the Link Info Memory Check */
    } /* End of Null Context Check */

    return status;
}
NFCSTATUS
phHciNfc_Admin_Initialise(
                                phHciNfc_sContext_t     *psHciContext,
                                void                    *pHwRef
                         )
{
    NFCSTATUS                           status = NFCSTATUS_SUCCESS;
    phHciNfc_Pipe_Info_t                *p_pipe_info = NULL;
    phHciNfc_AdminGate_Info_t           *p_admin_info=NULL;
    uint8_t                             length = 0;

    if( (NULL == psHciContext)
        || (NULL == pHwRef )
        )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else
    {
        if( ( NULL == psHciContext->p_admin_info )
            && (phHciNfc_Allocate_Resource((void **)(&p_admin_info),
                    sizeof(phHciNfc_AdminGate_Info_t))== NFCSTATUS_SUCCESS)
          )
        {
            psHciContext->p_admin_info = (void *) p_admin_info;
            p_admin_info->current_seq = ADMIN_PIPE_OPEN;
            p_admin_info->next_seq = ADMIN_END_SEQUENCE;
            p_admin_info->admin_pipe_info = NULL;
        }
        else
        {
            p_admin_info = (phHciNfc_AdminGate_Info_t * )
                                psHciContext->p_admin_info ;
        }

        if( NULL == p_admin_info)
        {
            status = PHNFCSTVAL(CID_NFC_HCI,
                        NFCSTATUS_INSUFFICIENT_RESOURCES);
        }
        else
        {
            switch(p_admin_info->current_seq)
            {
                /* Admin pipe open sequence , Initially open the Admin Pipe */
                case ADMIN_PIPE_OPEN:
                {
                    if(phHciNfc_Allocate_Resource((void **)(&p_pipe_info),
                        sizeof(phHciNfc_Pipe_Info_t))!= NFCSTATUS_SUCCESS)
                    {
                        status = PHNFCSTVAL(CID_NFC_HCI,
                                NFCSTATUS_INSUFFICIENT_RESOURCES);
                    }
                    else
                    {
                        /* Populate the pipe information in the pipe handle */
                        ((phHciNfc_Pipe_Info_t *)p_pipe_info)->pipe.pipe_id = 
                                        PIPETYPE_STATIC_ADMIN;
                        ((phHciNfc_Pipe_Info_t *)p_pipe_info)->recv_resp = 
                                        &phHciNfc_Recv_Admin_Response;
                        ((phHciNfc_Pipe_Info_t *)p_pipe_info)->recv_cmd = 
                                        &phHciNfc_Recv_Admin_Cmd;
                        ((phHciNfc_Pipe_Info_t *)p_pipe_info)->recv_event = 
                                        &phHciNfc_Recv_Admin_Event;
                        psHciContext->p_pipe_list[PIPETYPE_STATIC_ADMIN] =
                                                                    p_pipe_info ;
                        status = phHciNfc_Open_Pipe( psHciContext,
                                                            pHwRef,p_pipe_info );
                        if(status == NFCSTATUS_SUCCESS)
                        {
                            p_admin_info->admin_pipe_info = p_pipe_info ;
                            p_admin_info->next_seq = ADMIN_GET_SESSION;
                            status = NFCSTATUS_PENDING;
                        }
                    }
                    break;
                }
                case ADMIN_GET_SESSION:
                {
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    p_pipe_info->reg_index = SESSION_INDEX;
                    p_pipe_info->prev_status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                            (uint8_t)HCI_ADMIN_PIPE_ID,
                                (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == p_pipe_info->prev_status )
                    {
#ifdef UICC_SESSION_RESET
                        p_admin_info->next_seq = ADMIN_CLEAR_UICC_PIPES;
#elif defined (ESTABLISH_SESSION)
                        p_admin_info->next_seq = ADMIN_VERIFY_SESSION;
#else
                        p_admin_info->next_seq = ADMIN_CLEAR_PIPES;
#endif
                        status = NFCSTATUS_PENDING;
                    }
                    break;
                }
#ifdef UICC_SESSION_RESET
                case ADMIN_CLEAR_UICC_PIPES:
                {
                    uint8_t config = 0x00;
                    p_pipe_info = p_admin_info->admin_pipe_info;
                     /* TODO: Implement the Clear UICC PIPES Using
                      * Memory configuration.
                      */
                    status = phHciNfc_DevMgmt_Configure( psHciContext, pHwRef,
                            NFC_ADDRESS_UICC_SESSION , config );
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_admin_info->next_seq = ADMIN_CLEAR_PIPES;
                        status = NFCSTATUS_PENDING;
                    }
                    break;
                }
#endif
                case ADMIN_VERIFY_SESSION:
                {
                    phHal_sHwConfig_t *p_hw_config = 
                             (phHal_sHwConfig_t *) psHciContext->p_config_params;
                    phHal_sHwReference_t *p_hw_ref = 
                             (phHal_sHwReference_t *) pHwRef;
                    int             cmp_val = 0;
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    cmp_val = phOsalNfc_MemCompare(p_hw_config->session_id , 
                                 p_hw_ref->session_id , 
                                         sizeof(p_hw_ref->session_id));
                    if((cmp_val == 0) 
                        && ( HCI_SESSION == psHciContext->init_mode)
                        )
                    {
                        psHciContext->hci_mode = hciMode_Session;
                        status = phHciNfc_Update_Pipe( psHciContext, pHwRef,
                                                &p_admin_info->pipe_seq );
                        if((status == NFCSTATUS_SUCCESS) 
                            && (NULL != p_pipe_info))
                        {
                            
                            p_pipe_info->reg_index = MAX_PIPE_INDEX;
                            status = phHciNfc_Send_Generic_Cmd( psHciContext,  
                                    pHwRef, (uint8_t)HCI_ADMIN_PIPE_ID,
                                                    (uint8_t)ANY_GET_PARAMETER );
                            p_pipe_info->prev_status = status;
                            if(NFCSTATUS_PENDING == status )
                            {
                                p_admin_info->next_seq = ADMIN_PIPE_CLOSE;
                                status = NFCSTATUS_SUCCESS;
                            }
                        }
                        else
                        {
                            status = PHNFCSTVAL(CID_NFC_HCI, 
                                            NFCSTATUS_INVALID_HCI_SEQUENCE);
                        }
                        break;
                    }
                    else
                    {
                        /* To clear the pipe information*/
                        psHciContext->hci_mode = hciMode_Override;
                        p_admin_info->current_seq = ADMIN_CLEAR_PIPES;
                    }
                }
                /* fall through */
                case ADMIN_CLEAR_PIPES:
                {
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    p_pipe_info->prev_status = 
                                    phHciNfc_Send_Admin_Cmd( psHciContext,
                                        pHwRef, ADM_CLEAR_ALL_PIPE,
                                            length, p_pipe_info);
                    status = ((p_pipe_info->prev_status == NFCSTATUS_PENDING)?
                                            NFCSTATUS_SUCCESS : 
                                                p_pipe_info->prev_status);
                    if(status == NFCSTATUS_SUCCESS) 
                    {
                        p_admin_info->next_seq = ADMIN_PIPE_REOPEN;
                        status = NFCSTATUS_PENDING;
                    }
                    break;
                }
                /* Admin pipe Re-Open sequence , Re-Open the Admin Pipe */
                case ADMIN_PIPE_REOPEN:
                {
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    status = phHciNfc_Open_Pipe( psHciContext,
                                                        pHwRef,p_pipe_info );
                    if(status == NFCSTATUS_SUCCESS)
                    {
                        p_admin_info->next_seq = ADMIN_CREATE_PIPES;
                        status = NFCSTATUS_PENDING;
                    }
                    break;
                }
                case ADMIN_CREATE_PIPES:
                {
                    status = phHciNfc_Create_All_Pipes( psHciContext, pHwRef,
                                                        &p_admin_info->pipe_seq );
                    if(status == NFCSTATUS_SUCCESS) 
                    {
                        p_admin_info->next_seq = ADMIN_GET_WHITE_LIST;
                        status = NFCSTATUS_PENDING;
                    }
                    break;
                }
                case ADMIN_GET_WHITE_LIST:
                {
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    if(NULL == p_pipe_info )
                    {
                        status = PHNFCSTVAL(CID_NFC_HCI, 
                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
                    }
                    else
                    {
                        p_pipe_info->reg_index = WHITELIST_INDEX;
                        status = phHciNfc_Send_Generic_Cmd( psHciContext,  
                                pHwRef, (uint8_t)HCI_ADMIN_PIPE_ID,
                                                (uint8_t)ANY_GET_PARAMETER );
                        p_pipe_info->prev_status = status;
                        if(HCI_SELF_TEST == psHciContext->init_mode)
                        {
                            status = ((NFCSTATUS_PENDING == status )?
                                            NFCSTATUS_SUCCESS : status);
                        }
                        else 
                        {
                            if(NFCSTATUS_PENDING == status )
                            {
                                p_admin_info->next_seq = ADMIN_GET_HOST_LIST;
                                /* status = NFCSTATUS_SUCCESS; */
                            }
                        }
                    }
                    break;
                }
                case ADMIN_GET_HOST_LIST:
                {
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    if(NULL == p_pipe_info )
                    {
                        status = PHNFCSTVAL(CID_NFC_HCI, 
                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
                    }
                    else
                    {
                        p_pipe_info->reg_index = HOST_LIST_INDEX;
                        status = phHciNfc_Send_Generic_Cmd( psHciContext,  
                                pHwRef, (uint8_t)HCI_ADMIN_PIPE_ID,
                                                (uint8_t)ANY_GET_PARAMETER );
                        p_pipe_info->prev_status = status;
                        if(NFCSTATUS_PENDING == status )
                        {

#if defined(HOST_WHITELIST)
                            p_admin_info->next_seq = ADMIN_SET_WHITE_LIST;
#else
                            p_admin_info->next_seq = ADMIN_SET_SESSION;
                            status = NFCSTATUS_SUCCESS;
#endif
                        }
                    }
                    break;
                }
                case ADMIN_SET_WHITE_LIST:
                {
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    if(NULL == p_pipe_info )
                    {
                        status = PHNFCSTVAL(CID_NFC_HCI, 
                                        NFCSTATUS_INVALID_HCI_SEQUENCE);
                    }
                    else
                    {
                        uint8_t             i = 0;

                        for (i = 0; i < WHITELIST_MAX_LEN - 2; i++ )
                        {
                            p_admin_info->whitelist[i] = i + 2;
                        }
                        status = phHciNfc_Set_Param(psHciContext, pHwRef,
                                      p_pipe_info, WHITELIST_INDEX, 
                                        (uint8_t *)p_admin_info->whitelist, i );
                        if(NFCSTATUS_PENDING == status )
                        {
                            p_admin_info->next_seq = ADMIN_SET_SESSION;
                            status = NFCSTATUS_SUCCESS;
                        }
                    }
                    break;
                }
                case ADMIN_SET_SESSION:
                {
                    phHal_sHwConfig_t *p_hw_config = 
                             (phHal_sHwConfig_t *) psHciContext->p_config_params;
                    p_pipe_info = p_admin_info->admin_pipe_info;
                    status = phHciNfc_Set_Param(psHciContext, pHwRef, p_pipe_info,
                        SESSION_INDEX, (uint8_t *)(p_hw_config->session_id),
                            sizeof(p_hw_config->session_id));
                    if(NFCSTATUS_PENDING == p_pipe_info->prev_status )
                    {
                        p_admin_info->next_seq = ADMIN_PIPE_CLOSE;
                        status = NFCSTATUS_SUCCESS;
                    }
                    break;
                }
                default:
                {
                    status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
                    break;
                }

            }/* End of the Sequence Switch */

        }/* End of the Admin Info Memory Check */

    }/* End of Null context Check */

    return status;
}
NFCSTATUS
phHciNfc_ReaderB_Info_Sequence (
                                void             *psHciHandle,
                                void             *pHwRef
                                )
{
    NFCSTATUS               status = NFCSTATUS_SUCCESS;
    phHciNfc_sContext_t     *psHciContext = ((phHciNfc_sContext_t *)psHciHandle);
    if( (NULL == psHciContext) 
        || (NULL == pHwRef)
        )
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
    }
    else if((NULL == psHciContext->p_reader_b_info) || 
        (HCI_READER_B_ENABLE != 
        ((phHciNfc_ReaderB_Info_t *)(psHciContext->p_reader_b_info))->
        enable_rdr_b_gate))
    {
        status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
    }   
    else
    {
        phHciNfc_ReaderB_Info_t     *p_rdr_b_info=NULL;
        phHciNfc_Pipe_Info_t        *p_pipe_info=NULL;
        uint8_t                     pipeid = 0;

        p_rdr_b_info = (phHciNfc_ReaderB_Info_t *)
                            psHciContext->p_reader_b_info ;
        p_pipe_info = p_rdr_b_info->p_pipe_info;
        if(NULL == p_pipe_info )
        {
            status = PHNFCSTVAL(CID_NFC_HCI, 
                NFCSTATUS_INVALID_HCI_SEQUENCE);
        }
        else
        {
            switch(p_rdr_b_info->current_seq)
            {
                case RDR_B_PUPI:
                {
                    p_pipe_info->reg_index = RDR_B_PUPI_INDEX;
                    pipeid = p_rdr_b_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                    device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                        pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_rdr_b_info->next_seq = RDR_B_APP_DATA;
                    }
                    break;
                }
                case RDR_B_APP_DATA:
                {
                    p_pipe_info->reg_index = RDR_B_APP_DATA_INDEX;
                    pipeid = p_rdr_b_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                    device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                        pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_rdr_b_info->next_seq = RDR_B_AFI;
                    }
                    break;
                }
                case RDR_B_AFI:
                {
                    /* RW to the registry */
                    p_pipe_info->reg_index = RDR_B_AFI_INDEX;
                    pipeid = p_rdr_b_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                    device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                        pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_rdr_b_info->next_seq = RDR_B_HIGHER_LAYER_RESP;
                    }
                    break;
                }

                case RDR_B_HIGHER_LAYER_RESP:
                {
                    p_pipe_info->reg_index = RDR_B_HIGHER_LAYER_RESP_INDEX;
                    pipeid = p_rdr_b_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                        device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                                    pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_rdr_b_info->next_seq = RDR_B_HIGHER_LAYER_DATA;
                    }
                    break;
                }

                case RDR_B_HIGHER_LAYER_DATA:
                {
                    /* RW to the registry */
                    p_pipe_info->reg_index = RDR_B_HIGHER_LAYER_DATA_INDEX;
                    pipeid = p_rdr_b_info->pipe_id ;
                    /* Fill the data buffer and send the command to the 
                    device */
                    status = 
                        phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef, 
                        pipeid, (uint8_t)ANY_GET_PARAMETER);
                    if(NFCSTATUS_PENDING == status )
                    {
                        p_rdr_b_info->next_seq = RDR_B_END_SEQUENCE;
                    }
                    break;
                }
                case RDR_B_END_SEQUENCE:
                {
                    phNfc_sCompletionInfo_t     CompInfo;
                    if (RDR_B_MULTIPLE_TAGS_FOUND == 
                        p_rdr_b_info->multiple_tgts_found)
                    {
                        CompInfo.status = NFCSTATUS_MULTIPLE_TAGS;
                    }
                    else
                    {
                        CompInfo.status = NFCSTATUS_SUCCESS;
                    }

                    CompInfo.info = &(p_rdr_b_info->reader_b_info);

                    p_rdr_b_info->reader_b_info.RemDevType = phHal_eISO14443_B_PICC;
                    p_rdr_b_info->current_seq = RDR_B_PUPI;
                    p_rdr_b_info->next_seq = RDR_B_PUPI;
                    status = NFCSTATUS_SUCCESS;
                    /* Notify to the upper layer */
                    phHciNfc_Tag_Notify(psHciContext, 
                                        pHwRef, 
                                        NFC_NOTIFY_TARGET_DISCOVERED, 
                                        &CompInfo);
                    break;
                }
                default:
                {
                    status = PHNFCSTVAL(CID_NFC_HCI, 
                        NFCSTATUS_INVALID_HCI_RESPONSE);
                    break;
                }
            }           
        }
    }
    return status;
}