/*******************************************************************************
**
** Function         nci_proc_prop_ntf
**
** Description      Process NCI notifications in the Proprietary group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_prop_ntf (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *p_evt;
    UINT8   *pp, len, op_code;
    int i;

    /* find the start of the NCI message and parse the NCI header */
    p   = p_evt = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    len = *pp++;

#if(NFC_NXP_NOT_OPEN_INCLUDED == TRUE)
    NFC_TRACE_DEBUG1 ("nci_proc_prop_ntf:op_code =0x%x", op_code);
    switch(op_code)
    {
    case NCI_MSG_RF_WTX:
        nfc_ncif_proc_rf_wtx_ntf (p, p_msg->len);
        return;
    default:
        break;
    }
#endif

    for (i = 0; i < NFC_NUM_VS_CBACKS; i++)
    {
        if (nfc_cb.p_vs_cb[i])
        {
            (*nfc_cb.p_vs_cb[i]) ((tNFC_VS_EVT) (NCI_NTF_BIT|op_code), p_msg->len, p_evt);
        }
    }
}
/*******************************************************************************
**
** Function         nci_proc_rf_management_rsp
**
** Description      Process NCI responses in the RF Management group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_rf_management_rsp (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *pp, len, op_code;
    UINT8   *p_old = nfc_cb.last_cmd;

    /* find the start of the NCI message and parse the NCI header */
    p   = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    len = *pp++;

    switch (op_code)
    {
    case NCI_MSG_RF_DISCOVER:
        nfc_ncif_rf_management_status (NFC_START_DEVT, *pp);
        break;

    case NCI_MSG_RF_DISCOVER_SELECT:
        nfc_ncif_rf_management_status (NFC_SELECT_DEVT, *pp);
        break;

    case NCI_MSG_RF_T3T_POLLING:
        break;

    case NCI_MSG_RF_DISCOVER_MAP:
        nfc_ncif_rf_management_status (NFC_MAP_DEVT, *pp);
        break;

    case NCI_MSG_RF_DEACTIVATE:
        nfc_ncif_proc_deactivate (*pp, *p_old, FALSE);
        break;

#if (NFC_NFCEE_INCLUDED == TRUE)
#if (NFC_RW_ONLY == FALSE)

    case NCI_MSG_RF_SET_ROUTING:
        nfc_ncif_event_status (NFC_SET_ROUTING_REVT, *pp);
        break;

    case NCI_MSG_RF_GET_ROUTING:
        if (*pp != NFC_STATUS_OK)
            nfc_ncif_event_status (NFC_GET_ROUTING_REVT, *pp);
        break;
#endif
#endif

    case NCI_MSG_RF_PARAMETER_UPDATE:
        nfc_ncif_event_status (NFC_RF_COMM_PARAMS_UPDATE_REVT, *pp);
        break;

    default:
        NFC_TRACE_ERROR1 ("unknown opcode:0x%x", op_code);
        break;
    }
}
/*******************************************************************************
**
** Function         nci_proc_rf_management_ntf
**
** Description      Process NCI notifications in the RF Management group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_rf_management_ntf (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *pp, len, op_code;

    /* find the start of the NCI message and parse the NCI header */
    p   = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    len = *pp++;

    switch (op_code)
    {
    case NCI_MSG_RF_DISCOVER :
        nfc_ncif_proc_discover_ntf (p, p_msg->len);
        break;

    case NCI_MSG_RF_DEACTIVATE:
        nfc_ncif_proc_deactivate (NFC_STATUS_OK, *pp, TRUE);
        break;

    case NCI_MSG_RF_INTF_ACTIVATED:
        nfc_ncif_proc_activate (pp, len);
        break;

    case NCI_MSG_RF_FIELD:
        nfc_ncif_proc_rf_field_ntf (*pp);
        break;

    case NCI_MSG_RF_T3T_POLLING:
        nfc_ncif_proc_t3t_polling_ntf (pp, len);
        break;

#if (NFC_NFCEE_INCLUDED == TRUE)
#if (NFC_RW_ONLY == FALSE)

    case NCI_MSG_RF_GET_ROUTING:
        nfc_ncif_proc_get_routing (pp, len);
        break;

    case NCI_MSG_RF_EE_ACTION:
        nfc_ncif_proc_ee_action (pp, len);
        break;

    case NCI_MSG_RF_EE_DISCOVERY_REQ:
        nfc_ncif_proc_ee_discover_req (pp, len);
        break;
#endif
#endif

    default:
        NFC_TRACE_ERROR1 ("unknown opcode:0x%x", op_code);
        break;
    }
}
/*******************************************************************************
**
** Function         nci_proc_ee_management_rsp
**
** Description      Process NCI responses in the NFCEE Management group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_ee_management_rsp (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *pp, len, op_code;
    tNFC_RESPONSE_CBACK *p_cback = nfc_cb.p_resp_cback;
    tNFC_NFCEE_DISCOVER_REVT    nfcee_discover;
    tNFC_NFCEE_INFO_REVT        nfcee_info;
    tNFC_NFCEE_MODE_SET_REVT    mode_set;
    tNFC_RESPONSE   *p_evt = (tNFC_RESPONSE *) &nfcee_info;
    tNFC_RESPONSE_EVT event = NFC_NFCEE_INFO_REVT;
    UINT8   *p_old = nfc_cb.last_cmd;

    /* find the start of the NCI message and parse the NCI header */
    p   = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    NFC_TRACE_DEBUG1 ("nci_proc_ee_management_rsp opcode:0x%x", op_code);
    len = *pp++;

    switch (op_code)
    {
    case NCI_MSG_NFCEE_DISCOVER:
        p_evt                       = (tNFC_RESPONSE *) &nfcee_discover;
        nfcee_discover.status       = *pp++;
        nfcee_discover.num_nfcee    = *pp++;

        if (nfcee_discover.status != NFC_STATUS_OK)
            nfcee_discover.num_nfcee    = 0;

        event                       = NFC_NFCEE_DISCOVER_REVT;
        break;

    case NCI_MSG_NFCEE_MODE_SET:
        p_evt                   = (tNFC_RESPONSE *) &mode_set;
        mode_set.status         = *pp;
        mode_set.nfcee_id       = 0;
        event                   = NFC_NFCEE_MODE_SET_REVT;
        mode_set.nfcee_id       = *p_old++;
        mode_set.mode           = *p_old++;
        break;

    default:
        p_cback = NULL;
        NFC_TRACE_ERROR1 ("unknown opcode:0x%x", op_code);
        break;
    }

    if (p_cback)
        (*p_cback) (event, p_evt);
}
/*******************************************************************************
**
** Function         nci_proc_core_rsp
**
** Description      Process NCI responses in the CORE group
**
** Returns          TRUE-caller of this function to free the GKI buffer p_msg
**
*******************************************************************************/
BOOLEAN nci_proc_core_rsp (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *pp, len, op_code;
    BOOLEAN free = TRUE;
    UINT8   *p_old = nfc_cb.last_cmd;

    /* find the start of the NCI message and parse the NCI header */
    p   = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    NFC_TRACE_DEBUG1 ("nci_proc_core_rsp opcode:0x%x", op_code);
    len = *pp++;

    /* process the message based on the opcode and message type */
    switch (op_code)
    {
    case NCI_MSG_CORE_RESET:
        nfc_ncif_proc_reset_rsp (pp, FALSE);
        break;

    case NCI_MSG_CORE_INIT:
        nfc_ncif_proc_init_rsp (p_msg);
        free = FALSE;
        break;

    case NCI_MSG_CORE_GET_CONFIG:
        nfc_ncif_proc_get_config_rsp (p_msg);
        break;

    case NCI_MSG_CORE_SET_CONFIG:
        nfc_ncif_set_config_status (pp, len);
        break;

    case NCI_MSG_CORE_CONN_CREATE:
        nfc_ncif_proc_conn_create_rsp (p, p_msg->len, *p_old);
        break;

    case NCI_MSG_CORE_CONN_CLOSE:
        nfc_ncif_report_conn_close_evt (*p_old, *pp);
        break;

    default:
        NFC_TRACE_ERROR1 ("unknown opcode:0x%x", op_code);
        break;
    }

    return free;
}
/*******************************************************************************
**
** Function         nci_proc_prop_rsp
**
** Description      Process NCI responses in the Proprietary group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_prop_rsp (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *p_evt;
    UINT8   *pp, len, op_code;
    tNFC_VS_CBACK   *p_cback = (tNFC_VS_CBACK *)nfc_cb.p_vsc_cback;

    /* find the start of the NCI message and parse the NCI header */
    p   = p_evt = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    len = *pp++;

    /*If there's a pending/stored command, restore the associated address of the callback function */
    if (p_cback)
        (*p_cback) ((tNFC_VS_EVT) (NCI_RSP_BIT|op_code), p_msg->len, p_evt);
}
/*******************************************************************************
**
** Function         nci_proc_core_ntf
**
** Description      Process NCI notifications in the CORE group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_core_ntf (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *pp, len, op_code;
    UINT8   conn_id;

    /* find the start of the NCI message and parse the NCI header */
    p   = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    NFC_TRACE_DEBUG1 ("nci_proc_core_ntf opcode:0x%x", op_code);
    len = *pp++;

    /* process the message based on the opcode and message type */
    switch (op_code)
    {
    case NCI_MSG_CORE_RESET:
        nfc_ncif_proc_reset_rsp (pp, TRUE);
        break;

    case NCI_MSG_CORE_GEN_ERR_STATUS:
        /* process the error ntf */
        /* in case of timeout: notify the static connection callback */
        nfc_ncif_event_status (NFC_GEN_ERROR_REVT, *pp);
        nfc_ncif_error_status (NFC_RF_CONN_ID, *pp);
        break;

    case NCI_MSG_CORE_INTF_ERR_STATUS:
        conn_id = *(pp+1);
        nfc_ncif_error_status (conn_id, *pp);
        break;

    case NCI_MSG_CORE_CONN_CREDITS:
        nfc_ncif_proc_credits(pp, len);
        break;

    default:
        NFC_TRACE_ERROR1 ("unknown opcode:0x%x", op_code);
        break;
    }
}
/*******************************************************************************
**
** Function         nci_proc_prop_ntf
**
** Description      Process NCI notifications in the Proprietary group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_prop_ntf (BT_HDR *p_msg)
{
    UINT8   *p;
    UINT8   *p_evt;
    UINT8   *pp, len, op_code;
    int i;

    /* find the start of the NCI message and parse the NCI header */
    p   = p_evt = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    len = *pp++;

    for (i = 0; i < NFC_NUM_VS_CBACKS; i++)
    {
        if (nfc_cb.p_vs_cb[i])
        {
            (*nfc_cb.p_vs_cb[i]) ((tNFC_VS_EVT) (NCI_NTF_BIT|op_code), p_msg->len, p_evt);
        }
    }
}
/*******************************************************************************
**
** Function         nci_proc_ee_management_ntf
**
** Description      Process NCI notifications in the NFCEE Management group
**
** Returns          void
**
*******************************************************************************/
void nci_proc_ee_management_ntf (BT_HDR *p_msg)
{
    UINT8                 *p;
    UINT8                 *pp, len, op_code;
    tNFC_RESPONSE_CBACK   *p_cback = nfc_cb.p_resp_cback;
    tNFC_NFCEE_INFO_REVT  nfcee_info;
    tNFC_RESPONSE         *p_evt   = (tNFC_RESPONSE *) &nfcee_info;
    tNFC_RESPONSE_EVT     event    = NFC_NFCEE_INFO_REVT;
    UINT8                 xx;
    UINT8                 yy;
    UINT8                 ee_status;
    tNFC_NFCEE_TLV        *p_tlv;

    /* find the start of the NCI message and parse the NCI header */
    p   = (UINT8 *) (p_msg + 1) + p_msg->offset;
    pp  = p+1;
    NCI_MSG_PRS_HDR1 (pp, op_code);
    NFC_TRACE_DEBUG1 ("nci_proc_ee_management_ntf opcode:0x%x", op_code);
    len = *pp++;

    if (op_code == NCI_MSG_NFCEE_DISCOVER)
    {
        nfcee_info.nfcee_id    = *pp++;
        ee_status                   = *pp++;

        nfcee_info.ee_status        = ee_status;
        yy                          = *pp;
        nfcee_info.num_interface    = *pp++;
        p                           = pp;

        if (nfcee_info.num_interface > NFC_MAX_EE_INTERFACE)
            nfcee_info.num_interface = NFC_MAX_EE_INTERFACE;

        for (xx = 0; xx < nfcee_info.num_interface; xx++)
        {
            nfcee_info.ee_interface[xx] = *pp++;
        }

        pp                              = p + yy;
        nfcee_info.num_tlvs             = *pp++;
        NFC_TRACE_DEBUG4 ("nfcee_id: 0x%x num_interface:0x%x/0x%x, num_tlvs:0x%x",
            nfcee_info.nfcee_id, nfcee_info.num_interface, yy, nfcee_info.num_tlvs);

        if (nfcee_info.num_tlvs > NFC_MAX_EE_TLVS)
            nfcee_info.num_tlvs = NFC_MAX_EE_TLVS;

        p_tlv = &nfcee_info.ee_tlv[0];

        for (xx = 0; xx < nfcee_info.num_tlvs; xx++, p_tlv++)
        {
            p_tlv->tag  = *pp++;
            p_tlv->len  = yy = *pp++;
            NFC_TRACE_DEBUG2 ("tag:0x%x, len:0x%x", p_tlv->tag, p_tlv->len);
            if (p_tlv->len > NFC_MAX_EE_INFO)
                p_tlv->len = NFC_MAX_EE_INFO;
            p   = pp;
            STREAM_TO_ARRAY (p_tlv->info, pp, p_tlv->len);
            pp  = p += yy;
        }
    }
    else
    {
        p_cback = NULL;
        NFC_TRACE_ERROR1 ("unknown opcode:0x%x", op_code);
    }

    if (p_cback)
        (*p_cback) (event, p_evt);
}
/*******************************************************************************
**
** Function         nfc_hal_dm_proc_msg_during_init
**
** Description      Process NCI message while initializing NFCC
**
** Returns          void
**
*******************************************************************************/
void nfc_hal_dm_proc_msg_during_init (NFC_HDR *p_msg)
{
    UINT8 *p;
    UINT8 reset_reason, reset_type;
    UINT8 mt, pbf, gid, op_code;
    UINT8 *p_old, old_gid, old_oid, old_mt;
    UINT8 u8;
    tNFC_HAL_NCI_CBACK *p_cback = NULL;
    UINT8   chipverlen;
    UINT8   chipverstr[NCI_SPD_HEADER_CHIPVER_LEN];
    UINT32  hw_id = 0;

    HAL_TRACE_DEBUG1 ("nfc_hal_dm_proc_msg_during_init(): init state:%d", nfc_hal_cb.dev_cb.initializing_state);

    p = (UINT8 *) (p_msg + 1) + p_msg->offset;

    NCI_MSG_PRS_HDR0 (p, mt, pbf, gid);
    NCI_MSG_PRS_HDR1 (p, op_code);

    /* check if waiting for this response */
    if (  (nfc_hal_cb.ncit_cb.nci_wait_rsp == NFC_HAL_WAIT_RSP_CMD)
        ||(nfc_hal_cb.ncit_cb.nci_wait_rsp == NFC_HAL_WAIT_RSP_VSC)  )
    {
        if (mt == NCI_MT_RSP)
        {
            p_old = nfc_hal_cb.ncit_cb.last_hdr;
            NCI_MSG_PRS_HDR0 (p_old, old_mt, pbf, old_gid);
            old_oid = ((*p_old) & NCI_OID_MASK);
            /* make sure this is the RSP we are waiting for before updating the command window */
            if ((old_gid == gid) && (old_oid == op_code))
            {
                nfc_hal_cb.ncit_cb.nci_wait_rsp = NFC_HAL_WAIT_RSP_NONE;
                p_cback = (tNFC_HAL_NCI_CBACK *)nfc_hal_cb.ncit_cb.p_vsc_cback;
                nfc_hal_cb.ncit_cb.p_vsc_cback  = NULL;
                nfc_hal_main_stop_quick_timer (&nfc_hal_cb.ncit_cb.nci_wait_rsp_timer);
            }
        }
    }

    if (gid == NCI_GID_CORE)
    {
        if (op_code == NCI_MSG_CORE_RESET)
        {
            if (mt == NCI_MT_NTF)
            {
                if (  (nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_NFCC_ENABLE)
                    ||(nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_POST_XTAL_SET)  )
                {
                    /*
                    ** Core reset ntf in the following cases;
                    ** 1) after power up (raising REG_PU)
                    ** 2) after setting xtal index
                    ** Start pre-initializing NFCC
                    */
                    nfc_hal_main_stop_quick_timer (&nfc_hal_cb.timer);
                    nfc_hal_dm_pre_init_nfcc ();
                }
                else
                {
                    /* Core reset ntf after post-patch download, Call reset notification callback */
                    p++;                                /* Skip over param len */
                    STREAM_TO_UINT8 (reset_reason, p);
                    STREAM_TO_UINT8 (reset_type, p);
                    nfc_hal_prm_spd_reset_ntf (reset_reason, reset_type);
                }
            }
        }
        else if (p_cback)
        {
            (*p_cback) ((tNFC_HAL_NCI_EVT) (op_code),
                        p_msg->len,
                        (UINT8 *) (p_msg + 1) + p_msg->offset);
        }
    }
    else if (gid == NCI_GID_PROP) /* this is for download patch */
    {
        if (mt == NCI_MT_NTF)
            op_code |= NCI_NTF_BIT;
        else
            op_code |= NCI_RSP_BIT;

        if (nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_XTAL_SET)
        {
            if (op_code == (NCI_RSP_BIT|NCI_MSG_GET_XTAL_INDEX_FROM_DH))
            {
                /* start timer in case that NFCC doesn't send RESET NTF after loading patch from NVM */
                NFC_HAL_SET_INIT_STATE (NFC_HAL_INIT_STATE_POST_XTAL_SET);

                nfc_hal_main_start_quick_timer (&nfc_hal_cb.timer, NFC_HAL_TTYPE_NFCC_ENABLE,
                                                ((p_nfc_hal_cfg->nfc_hal_post_xtal_timeout)*QUICK_TIMER_TICKS_PER_SEC)/1000);
            }
        }
        else if (  (op_code == NFC_VS_GET_BUILD_INFO_EVT)
                 &&(nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_BUILD_INFO)  )
        {
            p += NCI_BUILD_INFO_OFFSET_HWID;

            STREAM_TO_UINT32 (hw_id, p);
            nfc_hal_cb.dev_cb.brcm_hw_id = nfc_hal_dm_adjust_hw_id (hw_id);
            HAL_TRACE_DEBUG2 ("brcm_hw_id: 0x%x -> 0x%x", hw_id, nfc_hal_cb.dev_cb.brcm_hw_id);

            STREAM_TO_UINT8 (chipverlen, p);
            memset (chipverstr, 0, NCI_SPD_HEADER_CHIPVER_LEN);

            STREAM_TO_ARRAY (chipverstr, p, chipverlen);

            nfc_hal_hci_handle_build_info (chipverlen, chipverstr);
            nfc_hal_cb.pre_set_mem_idx = 0;
            if (!nfc_hal_dm_check_pre_set_mem())
            {
                /* pre-set mem started */
                return;
            }
            nfc_hal_dm_check_xtal();
        }
        else if (  (op_code == NFC_VS_GET_PATCH_VERSION_EVT)
                 &&(nfc_hal_cb.dev_cb.initializing_state == NFC_HAL_INIT_STATE_W4_PATCH_INFO)  )
        {
            /* Store NVM info to control block */

            /* Skip over rsp len */
            p++;

            /* Get project id */
            STREAM_TO_UINT16 (nfc_hal_cb.nvm_cb.project_id, p);

            /* RFU */
            p++;

            /* Get chip version string */
            STREAM_TO_UINT8 (u8, p);
            if (u8 > NFC_HAL_PRM_MAX_CHIP_VER_LEN)
                u8 = NFC_HAL_PRM_MAX_CHIP_VER_LEN;
            memcpy (nfc_hal_cb.nvm_cb.chip_ver, p, u8);
            p += NCI_PATCH_INFO_VERSION_LEN;

            /* Get major/minor version */
            STREAM_TO_UINT16 (nfc_hal_cb.nvm_cb.ver_major, p);
            STREAM_TO_UINT16 (nfc_hal_cb.nvm_cb.ver_minor, p);

            /* Skip over max_size and patch_max_size */
            p += 4;

            /* Get current lpm patch size */
            STREAM_TO_UINT16 (nfc_hal_cb.nvm_cb.lpm_size, p);
            STREAM_TO_UINT16 (nfc_hal_cb.nvm_cb.fpm_size, p);

            /* clear all flags which may be set during previous initialization */
            nfc_hal_cb.nvm_cb.flags = 0;

            /* Set patch present flag */
            if ((nfc_hal_cb.nvm_cb.fpm_size) || (nfc_hal_cb.nvm_cb.lpm_size))
                nfc_hal_cb.nvm_cb.flags |= NFC_HAL_NVM_FLAGS_PATCH_PRESENT;

            /* LPMPatchCodeHasBadCRC (if not bad crc, then indicate LPM patch is present in nvm) */
            STREAM_TO_UINT8 (u8, p);
            if (u8)
            {
                /* LPM patch in NVM fails CRC check */
                nfc_hal_cb.nvm_cb.flags |= NFC_HAL_NVM_FLAGS_LPM_BAD;
            }


            /* FPMPatchCodeHasBadCRC (if not bad crc, then indicate LPM patch is present in nvm) */
            STREAM_TO_UINT8 (u8, p);
            if (u8)
            {
                /* FPM patch in NVM fails CRC check */
                nfc_hal_cb.nvm_cb.flags |= NFC_HAL_NVM_FLAGS_FPM_BAD;
            }

            /* Check if downloading patch to RAM only (no NVM) */
            STREAM_TO_UINT8 (nfc_hal_cb.nvm_cb.nvm_type, p);
            if (nfc_hal_cb.nvm_cb.nvm_type == NCI_SPD_NVM_TYPE_NONE)
            {
                nfc_hal_cb.nvm_cb.flags |= NFC_HAL_NVM_FLAGS_NO_NVM;
            }

            /* let platform update baudrate or download patch */
            NFC_HAL_SET_INIT_STATE (NFC_HAL_INIT_STATE_W4_APP_COMPLETE);
            nfc_hal_post_reset_init (nfc_hal_cb.dev_cb.brcm_hw_id, nfc_hal_cb.nvm_cb.nvm_type);
        }
        else if (p_cback)
        {
            (*p_cback) ((tNFC_HAL_NCI_EVT) (op_code),
                        p_msg->len,
                        (UINT8 *) (p_msg + 1) + p_msg->offset);
        }
        else if (op_code == NFC_VS_SEC_PATCH_AUTH_EVT)
        {
            HAL_TRACE_DEBUG0 ("signature!!");
            nfc_hal_prm_nci_command_complete_cback ((tNFC_HAL_NCI_EVT) (op_code),
                                                    p_msg->len,
                                                    (UINT8 *) (p_msg + 1) + p_msg->offset);
        }
    }
}