/******************************************************************************* ** ** Function nfa_hciu_alloc_pipe ** ** Description Allocate a pipe control block ** ** Returns pointer to the pipe control block, or NULL if ** cannot allocate ** *******************************************************************************/ tNFA_HCI_DYN_PIPE *nfa_hciu_alloc_pipe (UINT8 pipe_id) { UINT8 xx; tNFA_HCI_DYN_PIPE *pp; /* If we already have a pipe of the same ID, release it first it */ if ((pp = nfa_hciu_find_pipe_by_pid (pipe_id)) != NULL) { if (pipe_id > NFA_HCI_LAST_DYNAMIC_PIPE) return pp; nfa_hciu_release_pipe (pipe_id); } /* Look for a free pipe control block */ for (xx = 0, pp = nfa_hci_cb.cfg.dyn_pipes ; xx < NFA_HCI_MAX_PIPE_CB; xx++, pp++) { if (pp->pipe_id == 0) { NFA_TRACE_DEBUG2 ("nfa_hciu_alloc_pipe:%d, index:%d", pipe_id, xx); pp->pipe_id = pipe_id; nfa_hci_cb.nv_write_needed = TRUE; return (pp); } } NFA_TRACE_DEBUG1 ("nfa_hciu_alloc_pipe:%d, NO free entries !!", pipe_id); return (NULL); }
/******************************************************************************* ** ** Function nfa_hciu_get_pipe_owner ** ** Description Find the application that owns a pipe ** ** Returns application handle ** *******************************************************************************/ tNFA_HANDLE nfa_hciu_get_pipe_owner (UINT8 pipe_id) { tNFA_HCI_DYN_PIPE *pp; tNFA_HCI_DYN_GATE *pg; if ((pp = nfa_hciu_find_pipe_by_pid (pipe_id)) == NULL) return (NFA_HANDLE_INVALID); if ((pg = nfa_hciu_find_gate_by_gid (pp->local_gate)) == NULL) return (NFA_HANDLE_INVALID); return (pg->gate_owner); }
/******************************************************************************* ** ** Function nfa_hciu_release_pipe ** ** Description remove the specified pipe ** ** Returns NFA_HCI_ANY_OK, if removed ** NFA_HCI_ANY_E_NOK, if otherwise ** *******************************************************************************/ tNFA_HCI_RESPONSE nfa_hciu_release_pipe (UINT8 pipe_id) { tNFA_HCI_DYN_GATE *p_gate; tNFA_HCI_DYN_PIPE *p_pipe; UINT8 pipe_index; NFA_TRACE_EVENT1 ("nfa_hciu_release_pipe: %u", pipe_id); if ((p_pipe = nfa_hciu_find_pipe_by_pid (pipe_id)) == NULL) return (NFA_HCI_ANY_E_NOK); if (pipe_id > NFA_HCI_LAST_DYNAMIC_PIPE) { NFA_TRACE_DEBUG1 ("ignore pipe: %d", pipe_id); return (NFA_HCI_ANY_E_NOK); } pipe_index = (UINT8) (p_pipe - nfa_hci_cb.cfg.dyn_pipes); if (p_pipe->local_gate == NFA_HCI_IDENTITY_MANAGEMENT_GATE) { /* Remove pipe from ID management gate */ nfa_hci_cb.cfg.id_mgmt_gate.pipe_inx_mask &= ~ (UINT32) (1 << pipe_index); } else { if ((p_gate = nfa_hciu_find_gate_by_gid (p_pipe->local_gate)) == NULL) { /* Mark the pipe control block as free */ p_pipe->pipe_id = 0; return (NFA_HCI_ANY_E_NOK); } /* Remove pipe from gate */ p_gate->pipe_inx_mask &= ~ (UINT32) (1 << pipe_index); } /* Reset pipe control block */ memset (p_pipe,0,sizeof (tNFA_HCI_DYN_PIPE)); nfa_hci_cb.nv_write_needed = TRUE; return NFA_HCI_ANY_OK; }
/******************************************************************************* ** ** Function nfa_hciu_instr_2_str ** ** Description This function returns the instruction name. ** ** Returns pointer to the name ** *******************************************************************************/ char *nfa_hciu_evt_2_str (UINT8 pipe_id, UINT8 evt) { static char unknown[40]; tNFA_HCI_DYN_PIPE *p_pipe; if ( (pipe_id != NFA_HCI_ADMIN_PIPE) &&(pipe_id != NFA_HCI_LINK_MANAGEMENT_PIPE) &&((p_pipe = nfa_hciu_find_pipe_by_pid (pipe_id)) != NULL) ) { if (p_pipe->local_gate == NFA_HCI_CONNECTIVITY_GATE) { switch (evt) { case NFA_HCI_EVT_CONNECTIVITY: return ("EVT_CONNECTIVITY"); case NFA_HCI_EVT_TRANSACTION: return ("EVT_TRANSACTION"); case NFA_HCI_EVT_OPERATION_ENDED: return ("EVT_OPERATION_ENDED"); default: break; } } } switch (evt) { case NFA_HCI_EVT_HCI_END_OF_OPERATION: return ("EVT_END_OF_OPERATION"); case NFA_HCI_EVT_POST_DATA: return ("EVT_POST_DATA"); case NFA_HCI_EVT_HOT_PLUG: return ("EVT_HOT_PLUG"); default: sprintf (unknown, "?? Unknown: %u ?? ", evt); return (unknown); } }
/******************************************************************************* ** ** Function nfa_hciu_evt_2_str ** ** Description This function returns the event name. ** ** Returns pointer to the name ** *******************************************************************************/ char *nfa_hciu_evt_2_str (UINT8 pipe_id, UINT8 evt) { tNFA_HCI_DYN_PIPE *p_pipe; if ( (pipe_id != NFA_HCI_ADMIN_PIPE) &&(pipe_id != NFA_HCI_LINK_MANAGEMENT_PIPE) &&((p_pipe = nfa_hciu_find_pipe_by_pid (pipe_id)) != NULL) ) { if (p_pipe->local_gate == NFA_HCI_CONNECTIVITY_GATE) { switch (evt) { case NFA_HCI_EVT_CONNECTIVITY: return ("EVT_CONNECTIVITY"); case NFA_HCI_EVT_TRANSACTION: return ("EVT_TRANSACTION"); case NFA_HCI_EVT_OPERATION_ENDED: return ("EVT_OPERATION_ENDED"); default: return ("UNKNOWN"); } } } switch (evt) { case NFA_HCI_EVT_HCI_END_OF_OPERATION: return ("EVT_END_OF_OPERATION"); case NFA_HCI_EVT_POST_DATA: return ("EVT_POST_DATA"); case NFA_HCI_EVT_HOT_PLUG: return ("EVT_HOT_PLUG"); default: return ("UNKNOWN"); } }