2 * Copyright (C) 2010 NXP Semiconductors
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * =========================================================================== *
21 * \file hHciNfc_PipeMgmt.c *
22 * \brief HCI Pipe Management Routines. *
25 * Project: NFC-FRI-1.1 *
27 * $Date: Tue Aug 18 10:12:39 2009 $ *
28 * $Author: ing04880 $ *
30 * $Aliases: NFC_FRI1.1_WK934_R31_1,NFC_FRI1.1_WK941_PREP1,NFC_FRI1.1_WK941_PREP2,NFC_FRI1.1_WK941_1,NFC_FRI1.1_WK943_R32_1,NFC_FRI1.1_WK949_PREP1,NFC_FRI1.1_WK943_R32_10,NFC_FRI1.1_WK943_R32_13,NFC_FRI1.1_WK943_R32_14,NFC_FRI1.1_WK1007_R33_1,NFC_FRI1.1_WK1007_R33_4,NFC_FRI1.1_WK1017_PREP1,NFC_FRI1.1_WK1017_R34_1,NFC_FRI1.1_WK1017_R34_2,NFC_FRI1.1_WK1023_R35_1 $
32 * =========================================================================== *
37 ***************************** Header File Inclusion ****************************
40 #include <phNfcConfig.h>
41 #include <phNfcCompId.h>
42 #include <phHciNfc_Pipe.h>
43 #include <phOsalNfc.h>
44 #include <phHciNfc_AdminMgmt.h>
45 #include <phHciNfc_LinkMgmt.h>
46 #include <phHciNfc_IDMgmt.h>
47 #include <phHciNfc_DevMgmt.h>
48 #include <phHciNfc_PollingLoop.h>
49 #include <phHciNfc_RFReader.h>
50 #include <phHciNfc_RFReaderA.h>
52 #include <phHciNfc_RFReaderB.h>
55 #include <phHciNfc_Felica.h>
58 #include <phHciNfc_Jewel.h>
61 #include <phHciNfc_ISO15693.h>
64 #include <phHciNfc_NfcIPMgmt.h>
67 #include <phHciNfc_CE_A.h>
68 #include <phHciNfc_CE_B.h>
70 #include <phHciNfc_WI.h>
71 #include <phHciNfc_SWP.h>
74 ****************************** Macro Definitions *******************************
78 *************************** Structure and Enumeration ***************************
80 static phHciNfc_GateID_t host_gate_list[] = {
81 phHciNfc_IdentityMgmtGate,
82 phHciNfc_PN544MgmtGate,
83 phHciNfc_PollingLoopGate,
84 phHciNfc_RFReaderAGate,
86 phHciNfc_RFReaderBGate,
90 phHciNfc_RFReaderFGate,
94 phHciNfc_JewelReaderGate,
98 phHciNfc_ISO15693Gate,
102 phHciNfc_NFCIP1InitRFGate,
103 phHciNfc_NFCIP1TargetRFGate,
105 phHciNfc_NfcWIMgmtGate,
106 phHciNfc_SwpMgmtGate,
107 #if defined(HOST_EMULATION) && ( NXP_UICC_CE_RIGHTS < 0x01 )
108 phHciNfc_CETypeAGate,
109 phHciNfc_CETypeBGate,
115 *************************** Static Function Declaration **************************
120 phHciNfc_Create_Pipe(
121 phHciNfc_sContext_t *psHciContext,
123 phHciNfc_Gate_Info_t *destination,
124 phHciNfc_Pipe_Info_t **ppPipeHandle
129 *************************** Function Definitions ***************************
134 * \brief Creation of the Pipe
136 * This function creates the pipe between a source host's gate and destination
143 phHciNfc_Create_Pipe(
144 phHciNfc_sContext_t *psHciContext,
146 phHciNfc_Gate_Info_t *destination,
147 phHciNfc_Pipe_Info_t **ppPipeHandle
150 NFCSTATUS status = NFCSTATUS_SUCCESS;
152 *ppPipeHandle = (phHciNfc_Pipe_Info_t *)
153 phOsalNfc_GetMemory( sizeof(phHciNfc_Pipe_Info_t) );
155 if(NULL != *ppPipeHandle)
157 /* The Source Host is the Terminal Host */
158 (*ppPipeHandle)->pipe.source.host_id = (uint8_t) phHciNfc_TerminalHostID;
160 /* The Source Gate is same as the Destination Gate */
161 (*ppPipeHandle)->pipe.source.gate_id =
162 ((phHciNfc_Gate_Info_t *)destination)->gate_id;
163 (*ppPipeHandle)->pipe.dest.host_id =
164 ((phHciNfc_Gate_Info_t *)destination)->host_id;
165 (*ppPipeHandle)->pipe.dest.gate_id =
166 ((phHciNfc_Gate_Info_t *)destination)->gate_id;
168 /* if( hciMode_Override == psHciContext->hci_mode ) */
170 /* The Pipe ID is unknown until it is assigned */
171 (*ppPipeHandle)->pipe.pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
173 status = phHciNfc_Send_Admin_Cmd( psHciContext, pHwRef,
174 ADM_CREATE_PIPE, (PIPEINFO_SIZE-1)
180 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INSUFFICIENT_RESOURCES);
187 phHciNfc_Update_Pipe(
188 phHciNfc_sContext_t *psHciContext,
190 phHciNfc_PipeMgmt_Seq_t *p_pipe_seq
193 static uint8_t pipe_index = HCI_DYNAMIC_PIPE_ID;
194 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
195 NFCSTATUS status = NFCSTATUS_SUCCESS;
199 (pipe_index + HCI_DYNAMIC_PIPE_ID) <=
200 (uint8_t)(sizeof(host_gate_list)/sizeof(phHciNfc_GateID_t) );
203 status = phHciNfc_Allocate_Resource((void **)&p_pipe_info,
204 sizeof(phHciNfc_Pipe_Info_t));
206 if( (NFCSTATUS_SUCCESS == status)
207 && (NULL != p_pipe_info))
209 /* The Source Host is the Terminal Host */
210 p_pipe_info->pipe.source.host_id = (uint8_t) phHciNfc_TerminalHostID;
212 /* The Source Gate is same as the Destination Gate */
213 p_pipe_info->pipe.source.gate_id =
214 host_gate_list[pipe_index];
215 p_pipe_info->pipe.dest.host_id =
216 phHciNfc_HostControllerID;
217 p_pipe_info->pipe.dest.gate_id =
218 host_gate_list[pipe_index];
219 /* The Pipe ID is unknown until it is assigned */
220 p_pipe_info->pipe.pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
222 /* Initialise the Resources for the particular Gate */
224 status = phHciNfc_Create_All_Pipes(psHciContext,
225 pHwRef, p_pipe_seq );
227 if( NFCSTATUS_SUCCESS == status )
229 uint8_t pipe_id = (uint8_t)(pipe_index + HCI_DYNAMIC_PIPE_ID);
230 status = phHciNfc_Update_PipeInfo( psHciContext, p_pipe_seq ,
231 pipe_id, p_pipe_info );
232 if( NFCSTATUS_SUCCESS == status )
234 p_pipe_info->pipe.pipe_id = pipe_id;
235 psHciContext->p_pipe_list[pipe_id] = p_pipe_info;
239 phOsalNfc_FreeMemory(p_pipe_info);
245 phOsalNfc_FreeMemory(p_pipe_info);
251 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INSUFFICIENT_RESOURCES);
255 if( NFCSTATUS_SUCCESS == status )
257 status = phHciNfc_LinkMgmt_Initialise( psHciContext,pHwRef );
258 if(NFCSTATUS_SUCCESS == status)
260 status = phHciNfc_ReaderMgmt_Initialise( psHciContext,pHwRef );
262 if(NFCSTATUS_SUCCESS == status)
264 status = phHciNfc_EmuMgmt_Initialise( psHciContext,pHwRef );
273 * \brief Deletion of the Pipe
275 * This function Deletes a pipe created between a terminal host's gate and
276 * destination host's gate
281 phHciNfc_Delete_Pipe(
282 phHciNfc_sContext_t *psHciContext,
284 phHciNfc_Pipe_Info_t *pPipeHandle
287 NFCSTATUS status=NFCSTATUS_SUCCESS;
288 NFCSTATUS cmd_status = NFCSTATUS_SUCCESS;
290 if( (NULL == psHciContext)
292 || (NULL == pPipeHandle)
295 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
299 cmd_status = phHciNfc_Send_Admin_Cmd( psHciContext, pHwRef,
300 ADM_DELETE_PIPE, PIPEID_LEN, pPipeHandle );
301 status = ( (cmd_status == NFCSTATUS_PENDING)?
302 NFCSTATUS_SUCCESS : cmd_status);
308 #ifdef HOST_EMULATION
311 phHciNfc_CE_Pipes_OP(
312 phHciNfc_sContext_t *psHciContext,
314 phHciNfc_PipeMgmt_Seq_t *p_pipe_seq
317 NFCSTATUS status = NFCSTATUS_SUCCESS;
318 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
319 /* uint8_t pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID; */
321 if( (NULL == psHciContext) || (NULL == pHwRef) )
323 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
327 switch( *p_pipe_seq )
329 case PIPE_CARD_A_CREATE:
331 phHciNfc_Gate_Info_t id_dest;
333 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
334 id_dest.gate_id = (uint8_t)phHciNfc_CETypeAGate;
336 status = phHciNfc_CE_A_Init_Resources ( psHciContext );
337 if(status == NFCSTATUS_SUCCESS)
339 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
340 &id_dest, &p_pipe_info);
341 status = ((NFCSTATUS_PENDING == status )?
342 NFCSTATUS_SUCCESS : status);
346 case PIPE_CARD_B_CREATE:
348 phHciNfc_Gate_Info_t id_dest;
350 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
351 id_dest.gate_id = (uint8_t)phHciNfc_CETypeBGate;
353 status = phHciNfc_CE_B_Init_Resources ( psHciContext );
354 if(status == NFCSTATUS_SUCCESS)
356 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
357 &id_dest, &p_pipe_info);
358 status = ((NFCSTATUS_PENDING == status )?
359 NFCSTATUS_SUCCESS : status);
364 case PIPE_CARD_F_CREATE:
366 phHciNfc_Gate_Info_t id_dest;
368 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
369 id_dest.gate_id = (uint8_t)phHciNfc_CETypeFGate;
371 /* status = phHciNfc_Card_Emulation_Init (psHciContext , TYPE_F); */
372 if(status == NFCSTATUS_SUCCESS)
374 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
375 &id_dest, &p_pipe_info);
376 /* status = ((NFCSTATUS_PENDING == status )?
377 NFCSTATUS_SUCCESS : status); */
381 case PIPE_CARD_A_DELETE:
383 status = phHciNfc_CE_A_Get_PipeID( psHciContext, &pipe_id );
384 p_pipe_info = psHciContext->p_pipe_list[pipe_id];
385 if(status == NFCSTATUS_SUCCESS)
387 status = phHciNfc_Delete_Pipe( psHciContext, pHwRef,
389 status = ((NFCSTATUS_PENDING == status )?
390 NFCSTATUS_SUCCESS : status);
394 case PIPE_CARD_B_DELETE:
396 status = phHciNfc_CE_B_Get_PipeID( psHciContext, &pipe_id );
397 p_pipe_info = psHciContext->p_pipe_list[pipe_id];
398 if(status == NFCSTATUS_SUCCESS)
400 status = phHciNfc_Delete_Pipe( psHciContext, pHwRef,
402 status = ((NFCSTATUS_PENDING == status )?
403 NFCSTATUS_SUCCESS : status);
408 /* case PIPE_MGMT_END : */
411 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
423 * \brief Creates the Pipes of all the Supported Gates .
425 * This function Creates the pipes for all the supported gates
429 phHciNfc_Create_All_Pipes(
430 phHciNfc_sContext_t *psHciContext,
432 phHciNfc_PipeMgmt_Seq_t *p_pipe_seq
435 NFCSTATUS status = NFCSTATUS_SUCCESS;
436 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
438 if( (NULL == psHciContext) || (NULL == pHwRef)
439 || (NULL == p_pipe_seq) )
441 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
446 switch( *p_pipe_seq )
448 /* Admin pipe close sequence */
449 case PIPE_IDMGMT_CREATE:
451 phHciNfc_Gate_Info_t id_dest;
453 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
454 id_dest.gate_id = (uint8_t)phHciNfc_IdentityMgmtGate;
456 status = phHciNfc_IDMgmt_Init_Resources (psHciContext);
457 if((status == NFCSTATUS_SUCCESS)
458 #ifdef ESTABLISH_SESSION
459 && (hciMode_Session != psHciContext->hci_mode)
463 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
464 &id_dest, &p_pipe_info);
465 /* status = ((NFCSTATUS_PENDING == status )?
466 NFCSTATUS_SUCCESS : status); */
470 case PIPE_PN544MGMT_CREATE:
472 phHciNfc_Gate_Info_t id_dest;
474 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
475 id_dest.gate_id = (uint8_t)phHciNfc_PN544MgmtGate;
477 status = phHciNfc_DevMgmt_Init_Resources (psHciContext);
478 if((status == NFCSTATUS_SUCCESS)
479 #ifdef ESTABLISH_SESSION
480 && (hciMode_Session != psHciContext->hci_mode)
484 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
485 &id_dest, &p_pipe_info);
486 if(HCI_SELF_TEST == psHciContext->init_mode)
488 status = ((NFCSTATUS_PENDING == status )?
489 NFCSTATUS_SUCCESS : status);
494 case PIPE_POLLINGLOOP_CREATE:
496 phHciNfc_Gate_Info_t id_dest;
498 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
499 id_dest.gate_id = (uint8_t)phHciNfc_PollingLoopGate;
501 status = phHciNfc_PollLoop_Init_Resources (psHciContext);
502 if((status == NFCSTATUS_SUCCESS)
503 #ifdef ESTABLISH_SESSION
504 && (hciMode_Session != psHciContext->hci_mode)
508 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
509 &id_dest, &p_pipe_info);
510 /* status = ((NFCSTATUS_PENDING == status )?
511 NFCSTATUS_SUCCESS : status); */
515 case PIPE_READER_A_CREATE:
517 phHciNfc_Gate_Info_t id_dest;
519 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
520 id_dest.gate_id = (uint8_t)phHciNfc_RFReaderAGate;
522 status = phHciNfc_ReaderA_Init_Resources (psHciContext);
523 if((status == NFCSTATUS_SUCCESS)
524 #ifdef ESTABLISH_SESSION
525 && (hciMode_Session != psHciContext->hci_mode)
529 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
530 &id_dest, &p_pipe_info);
531 /* status = ((NFCSTATUS_PENDING == status )?
532 NFCSTATUS_SUCCESS : status); */
537 case PIPE_READER_B_CREATE:
539 phHciNfc_Gate_Info_t id_dest;
541 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
542 id_dest.gate_id = (uint8_t)phHciNfc_RFReaderBGate;
544 status = phHciNfc_ReaderB_Init_Resources (psHciContext);
545 if((status == NFCSTATUS_SUCCESS)
546 #ifdef ESTABLISH_SESSION
547 && (hciMode_Session != psHciContext->hci_mode)
551 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
552 &id_dest, &p_pipe_info);
553 /* status = ((NFCSTATUS_PENDING == status )?
554 NFCSTATUS_SUCCESS : status); */
561 case PIPE_READER_F_CREATE:
563 phHciNfc_Gate_Info_t id_dest;
565 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
566 id_dest.gate_id = (uint8_t)phHciNfc_RFReaderFGate;
568 status = phHciNfc_Felica_Init_Resources (psHciContext);
569 if((status == NFCSTATUS_SUCCESS)
570 #ifdef ESTABLISH_SESSION
571 && (hciMode_Session != psHciContext->hci_mode)
575 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
576 &id_dest, &p_pipe_info);
577 /* status = ((NFCSTATUS_PENDING == status )?
578 NFCSTATUS_SUCCESS : status); */
584 case PIPE_READER_JWL_CREATE:
586 phHciNfc_Gate_Info_t id_dest;
588 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
589 id_dest.gate_id = (uint8_t)phHciNfc_JewelReaderGate;
591 status = phHciNfc_Jewel_Init_Resources (psHciContext);
592 if((status == NFCSTATUS_SUCCESS)
593 #ifdef ESTABLISH_SESSION
594 && (hciMode_Session != psHciContext->hci_mode)
598 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
599 &id_dest, &p_pipe_info);
600 /* status = ((NFCSTATUS_PENDING == status )?
601 NFCSTATUS_SUCCESS : status); */
605 #endif /* #ifdef TYPE_JEWEL */
607 case PIPE_READER_ISO15693_CREATE:
609 phHciNfc_Gate_Info_t id_dest;
611 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
612 id_dest.gate_id = (uint8_t)phHciNfc_ISO15693Gate;
614 status = phHciNfc_ISO15693_Init_Resources (psHciContext);
615 if((status == NFCSTATUS_SUCCESS)
616 #ifdef ESTABLISH_SESSION
617 && (hciMode_Session != psHciContext->hci_mode)
621 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
622 &id_dest, &p_pipe_info);
623 /* status = ((NFCSTATUS_PENDING == status )?
624 NFCSTATUS_SUCCESS : status); */
628 #endif /* #ifdef TYPE_ISO15693 */
629 case PIPE_NFC_INITIATOR_CREATE:
631 phHciNfc_Gate_Info_t id_dest;
633 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
634 id_dest.gate_id = (uint8_t)phHciNfc_NFCIP1InitRFGate;
636 status = phHciNfc_Initiator_Init_Resources (psHciContext);
637 if((status == NFCSTATUS_SUCCESS)
638 #ifdef ESTABLISH_SESSION
639 && (hciMode_Session != psHciContext->hci_mode)
643 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
644 &id_dest, &p_pipe_info);
645 /* status = ((NFCSTATUS_PENDING == status )?
646 NFCSTATUS_SUCCESS : status); */
651 case PIPE_NFC_TARGET_CREATE:
653 phHciNfc_Gate_Info_t id_dest;
655 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
656 id_dest.gate_id = (uint8_t)phHciNfc_NFCIP1TargetRFGate;
659 status = phHciNfc_Target_Init_Resources (psHciContext);
660 if((status == NFCSTATUS_SUCCESS)
661 #ifdef ESTABLISH_SESSION
662 && (hciMode_Session != psHciContext->hci_mode)
666 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
667 &id_dest, &p_pipe_info);
668 /* status = ((NFCSTATUS_PENDING == status )?
669 NFCSTATUS_SUCCESS : status); */
676 phHciNfc_Gate_Info_t id_dest;
678 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
679 id_dest.gate_id = (uint8_t)phHciNfc_NfcWIMgmtGate;
681 status = phHciNfc_WI_Init_Resources ( psHciContext );
682 if((status == NFCSTATUS_SUCCESS)
683 #ifdef ESTABLISH_SESSION
684 && (hciMode_Session != psHciContext->hci_mode)
688 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
689 &id_dest, &p_pipe_info);
690 /* status = ((NFCSTATUS_PENDING == status )?
691 NFCSTATUS_SUCCESS : status); */
695 case PIPE_SWP_CREATE:
697 phHciNfc_Gate_Info_t id_dest;
699 id_dest.host_id = (uint8_t)phHciNfc_HostControllerID;
700 id_dest.gate_id = (uint8_t)phHciNfc_SwpMgmtGate;
702 status = phHciNfc_SWP_Init_Resources ( psHciContext );
704 if((status == NFCSTATUS_SUCCESS)
705 #ifdef ESTABLISH_SESSION
706 && (hciMode_Session != psHciContext->hci_mode)
710 status = phHciNfc_Create_Pipe( psHciContext, pHwRef,
711 &id_dest, &p_pipe_info);
712 status = ((NFCSTATUS_PENDING == status )?
713 NFCSTATUS_SUCCESS : status);
717 /* case PIPE_MGMT_END : */
720 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
724 } /* End of Pipe Seq Switch */
726 } /* End of Null Check for the Context */
732 * \brief Deletes the Pipes of all the Supported Gates .
734 * This function Deletes the pipes for all the supported gates
738 phHciNfc_Delete_All_Pipes(
739 phHciNfc_sContext_t *psHciContext,
741 phHciNfc_PipeMgmt_Seq_t pipeSeq
744 NFCSTATUS status = NFCSTATUS_SUCCESS;
745 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
748 if( (NULL == psHciContext) || (NULL == pHwRef) )
750 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
754 /* pipeSeq = PIPE_DELETE_ALL; */
756 if ( PIPE_DELETE_ALL == pipeSeq )
758 /* Admin pipe close sequence */
759 p_pipe_info = psHciContext->p_pipe_list[PIPETYPE_STATIC_ADMIN];
760 status = phHciNfc_Send_Admin_Cmd( psHciContext,
761 pHwRef, ADM_CLEAR_ALL_PIPE,
762 length, p_pipe_info);
763 status = ((NFCSTATUS_PENDING == status)?
764 NFCSTATUS_SUCCESS : status);
768 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
772 } /* End of Null Check for the Context */
780 phHciNfc_Update_PipeInfo(
781 phHciNfc_sContext_t *psHciContext,
782 phHciNfc_PipeMgmt_Seq_t *pPipeSeq,
784 phHciNfc_Pipe_Info_t *pPipeInfo
787 phHciNfc_GateID_t gate_id = phHciNfc_UnknownGate;
788 NFCSTATUS status = NFCSTATUS_SUCCESS;
791 (NULL == psHciContext) || (NULL == pPipeSeq)
792 || ( NULL == pPipeInfo )
795 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
799 gate_id = (phHciNfc_GateID_t )pPipeInfo->pipe.dest.gate_id ;
802 /* Identity Management Pipe Creation */
803 case phHciNfc_IdentityMgmtGate:
805 status = phHciNfc_IDMgmt_Update_PipeInfo(psHciContext,
807 if(NFCSTATUS_SUCCESS == status)
809 *pPipeSeq = PIPE_PN544MGMT_CREATE;
813 case phHciNfc_PN544MgmtGate:
815 status = phHciNfc_DevMgmt_Update_PipeInfo(psHciContext,
817 if(NFCSTATUS_SUCCESS == status)
819 *pPipeSeq = ( HCI_SELF_TEST != psHciContext->init_mode )?
820 PIPE_POLLINGLOOP_CREATE:PIPE_DELETE_ALL;
824 case phHciNfc_PollingLoopGate:
826 status = phHciNfc_PollLoop_Update_PipeInfo(psHciContext,
828 if(NFCSTATUS_SUCCESS == status)
830 *pPipeSeq = PIPE_READER_A_CREATE;
834 case phHciNfc_RFReaderAGate:
836 status = phHciNfc_ReaderA_Update_PipeInfo(psHciContext,
838 if(NFCSTATUS_SUCCESS == status)
842 *pPipeSeq = PIPE_READER_B_CREATE;
843 /* #if defined (TYPE_B) */
844 #elif defined (TYPE_FELICA)
845 *pPipeSeq = PIPE_READER_F_CREATE;
846 /* #if defined (TYPE_FELICA) */
847 #elif defined (TYPE_JEWEL)
848 *pPipeSeq = PIPE_READER_JWL_CREATE;
849 /* #if defined (TYPE_JEWEL) */
850 #elif defined (TYPE_ISO15693)
851 *pPipeSeq = PIPE_READER_ISO15693_CREATE;
852 /* #if defined (TYPE_ISO15693) */
853 #elif defined(ENABLE_P2P)
854 *pPipeSeq = PIPE_NFC_INITIATOR_CREATE;
855 /* #if defined(ENABLE_P2P) */
856 /*lint -e{91} suppress "Line exceeds"*/
857 #elif !defined(TYPE_B) && !defined(TYPE_FELICA) && !defined(TYPE_JEWEL) && !defined(TYPE_ISO15693) && !defined(ENABLE_P2P)
858 *pPipeSeq = PIPE_WI_CREATE;
864 case phHciNfc_RFReaderBGate:
866 status = phHciNfc_ReaderB_Update_PipeInfo(psHciContext,
868 if(NFCSTATUS_SUCCESS == status)
870 #if defined (TYPE_FELICA)
871 *pPipeSeq = PIPE_READER_F_CREATE;
872 /* #if defined (TYPE_FELICA) */
873 #elif defined (TYPE_JEWEL)
874 *pPipeSeq = PIPE_READER_JWL_CREATE;
875 /* #if defined (TYPE_JEWEL) */
876 #elif defined (TYPE_ISO15693)
877 *pPipeSeq = PIPE_READER_ISO15693_CREATE;
878 /* #if defined (TYPE_ISO15693) */
879 #elif defined(ENABLE_P2P)
880 *pPipeSeq = PIPE_NFC_INITIATOR_CREATE;
881 /* #if defined(ENABLE_P2P) */
882 /*lint -e{91} suppress "Line exceeds"*/
883 #elif !defined(TYPE_FELICA) && !defined(TYPE_JEWEL) && !defined(TYPE_ISO15693) && !defined(ENABLE_P2P)
884 *pPipeSeq = PIPE_WI_CREATE;
891 case phHciNfc_RFReaderFGate:
893 status = phHciNfc_Felica_Update_PipeInfo(psHciContext,
895 if(NFCSTATUS_SUCCESS == status)
897 #if defined (TYPE_JEWEL)
898 *pPipeSeq = PIPE_READER_JWL_CREATE;
899 /* #if defined (TYPE_JEWEL) */
900 #elif defined (TYPE_ISO15693)
901 *pPipeSeq = PIPE_READER_ISO15693_CREATE;
902 /* #if defined (TYPE_ISO15693) */
903 #elif defined(ENABLE_P2P)
904 *pPipeSeq = PIPE_NFC_INITIATOR_CREATE;
905 /* #if defined(ENABLE_P2P) */
906 #elif !defined(TYPE_JEWEL) && !defined(TYPE_ISO15693) && !defined(ENABLE_P2P)
907 *pPipeSeq = PIPE_WI_CREATE;
914 case phHciNfc_JewelReaderGate:
916 status = phHciNfc_Jewel_Update_PipeInfo(psHciContext,
918 if(NFCSTATUS_SUCCESS == status)
920 #if defined (TYPE_ISO15693)
921 *pPipeSeq = PIPE_READER_ISO15693_CREATE;
922 /* #if defined (TYPE_ISO15693) */
923 #elif defined(ENABLE_P2P)
924 *pPipeSeq = PIPE_NFC_INITIATOR_CREATE;
925 /* #if defined(ENABLE_P2P) */
926 #elif !defined(TYPE_ISO15693) && !defined(ENABLE_P2P)
927 *pPipeSeq = PIPE_WI_CREATE;
932 #endif /* #ifdef TYPE_JEWEL */
933 #if defined (TYPE_ISO15693)
934 case phHciNfc_ISO15693Gate:
936 status = phHciNfc_ISO15693_Update_PipeInfo(psHciContext,
938 if(NFCSTATUS_SUCCESS == status)
942 *pPipeSeq = PIPE_NFC_INITIATOR_CREATE;
944 *pPipeSeq = PIPE_WI_CREATE;
945 #endif /* #ifdef ENABLE_P2P */
949 #endif /* #if defined (TYPE_ISO15693) */
950 case phHciNfc_NFCIP1InitRFGate:
953 status = phHciNfc_Initiator_Update_PipeInfo(psHciContext,
955 if(NFCSTATUS_SUCCESS == status)
957 *pPipeSeq = PIPE_NFC_TARGET_CREATE;
962 case phHciNfc_NFCIP1TargetRFGate:
965 status = phHciNfc_Target_Update_PipeInfo(psHciContext,
967 if(NFCSTATUS_SUCCESS == status)
969 *pPipeSeq = PIPE_WI_CREATE;
974 case phHciNfc_NfcWIMgmtGate:
976 status = phHciNfc_WI_Update_PipeInfo(psHciContext,
978 if(NFCSTATUS_SUCCESS == status)
980 *pPipeSeq = PIPE_SWP_CREATE;
984 case phHciNfc_SwpMgmtGate:
986 status = phHciNfc_SWP_Update_PipeInfo(psHciContext,
988 if(NFCSTATUS_SUCCESS == status)
990 *pPipeSeq = PIPE_DELETE_ALL;
994 case phHciNfc_ConnectivityGate:
996 status = phHciNfc_Uicc_Update_PipeInfo(psHciContext,
1000 #ifdef HOST_EMULATION
1001 case phHciNfc_CETypeAGate:
1003 status = phHciNfc_CE_A_Update_PipeInfo(psHciContext,
1004 pipe_id, pPipeInfo);
1005 if(NFCSTATUS_SUCCESS == status)
1007 *pPipeSeq = PIPE_CARD_B_CREATE;
1011 case phHciNfc_CETypeBGate:
1013 status = phHciNfc_CE_B_Update_PipeInfo(psHciContext,
1014 pipe_id, pPipeInfo);
1015 if(NFCSTATUS_SUCCESS == status)
1017 *pPipeSeq = PIPE_DELETE_ALL;
1022 case phHciNfc_UnknownGate:
1025 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_HCI_GATE_NOT_SUPPORTED );
1028 /*End of the default Switch Case */
1030 } /*End of the Index Switch */
1031 } /* End of Context and the Identity information validity check */
1038 * \brief Opening the Pipe
1040 * This function opens the the pipe created between a terminal host's gate and
1041 * destination host's gate
1047 phHciNfc_sContext_t *psHciContext,
1049 phHciNfc_Pipe_Info_t *pPipeHandle
1052 uint8_t pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
1053 NFCSTATUS status = NFCSTATUS_SUCCESS;
1054 NFCSTATUS cmd_status = NFCSTATUS_SUCCESS;
1056 if( (NULL == psHciContext)
1057 || ( NULL == pHwRef )
1058 || ( NULL == pPipeHandle )
1061 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1065 /* Obtain the pipe_id from the pipe_handle */
1066 pipe_id = pPipeHandle->pipe.pipe_id;
1068 if ( pipe_id <= PHHCINFC_MAX_PIPE)
1070 cmd_status = phHciNfc_Send_Generic_Cmd( psHciContext,pHwRef,
1071 pipe_id, ANY_OPEN_PIPE);
1072 status = ( (cmd_status == NFCSTATUS_PENDING)?
1073 NFCSTATUS_SUCCESS : cmd_status);
1081 * \brief Closing the Pipe
1083 * This function Closes the the pipe created between a terminal host's gate and
1084 * destination host's gate
1089 phHciNfc_Close_Pipe(
1090 phHciNfc_sContext_t *psHciContext,
1092 phHciNfc_Pipe_Info_t *pPipeHandle
1095 uint8_t pipe_id = (uint8_t) HCI_UNKNOWN_PIPE_ID;
1096 NFCSTATUS status = NFCSTATUS_SUCCESS;
1097 NFCSTATUS cmd_status = NFCSTATUS_SUCCESS;
1099 if( (NULL == psHciContext)
1100 || ( NULL == pHwRef )
1101 || ( NULL == pPipeHandle )
1104 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
1108 /* Obtain the pipe_id from the pipe_handle */
1109 pipe_id = pPipeHandle->pipe.pipe_id;
1111 if( (uint8_t)HCI_UNKNOWN_PIPE_ID > pipe_id)
1113 cmd_status = phHciNfc_Send_Generic_Cmd(
1114 psHciContext, pHwRef, pipe_id,
1117 status = ((cmd_status == NFCSTATUS_PENDING)?
1118 NFCSTATUS_SUCCESS : cmd_status);