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