1 /*
2 * Copyright (C) 2010 NXP Semiconductors
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 /*!
18 * =========================================================================== *
19 * *
20 * *
21 * \file phHciNfc_IDMgmt.c *
22 * \brief HCI Identity Management Gate Routines. *
23 * *
24 * *
25 * Project: NFC-FRI-1.1 *
26 * *
27 * $Date: Fri Jun 11 11:19:25 2010 $ *
28 * $Author: ing04880 $ *
29 * $Revision: 1.23 $ *
30 * $Aliases: NFC_FRI1.1_WK1023_R35_1 $
31 * *
32 * =========================================================================== *
33 */
34
35 /*
36 ***************************** Header File Inclusion ****************************
37 */
38 #include <phNfcCompId.h>
39 #include <phHciNfc_Pipe.h>
40 #include <phHciNfc_IDMgmt.h>
41 #include <phOsalNfc.h>
42
43 /*
44 ****************************** Macro Definitions *******************************
45 */
46
47 #define FW_VERSION_INDEX 0x01U
48 #define HCI_VERSION_INDEX 0x02U
49 #define HW_VERSION_INDEX 0x03U
50 #define VENDOR_NAME_INDEX 0x04U
51 #define MODEL_ID_INDEX 0x05U
52 #define GATES_LIST_INDEX 0x06U
53 #define FULL_VERSION_INDEX 0x10U
54
55 #define VERSION_LEN 0x03U
56 #define GATES_LIST_LEN 0x20U
57
58 /*
59 *************************** Structure and Enumeration ***************************
60 */
61
62
63 /** \defgroup grp_hci_nfc HCI Identity Management Component
64 *
65 *
66 */
67
68 typedef enum phHciNfc_IDMgmt_Seq{
69 IDMGMT_PIPE_OPEN = 0x00U,
70 IDMGMT_GET_FULL_VERSION,
71 IDMGMT_GET_FW_VERSION,
72 IDMGMT_GET_HW_VERSION,
73 IDMGMT_GET_HCI_VERSION,
74 IDMGMT_GET_VENDOR_NAME,
75 IDMGMT_GET_MODEL_ID,
76 IDMGMT_GET_GATES_LIST,
77 IDMGMT_PIPE_CLOSE
78 } phHciNfc_IDMgmt_Seq_t;
79
80 typedef struct phHciNfc_IDMgmt_Info{
81 phHciNfc_IDMgmt_Seq_t id_cur_seq;
82 phHciNfc_IDMgmt_Seq_t id_next_seq;
83 phHciNfc_Pipe_Info_t *p_pipe_info;
84 uint8_t pipe_id;
85 uint32_t fw_version;
86 uint32_t hw_version;
87 utf8_t vendor_name[VENDOR_NAME_LEN];
88 uint8_t model_id;
89 uint8_t hci_version;
90 uint8_t gates_list[GATES_LIST_LEN];
91 uint8_t full_version[NXP_FULL_VERSION_LEN];
92 } phHciNfc_IDMgmt_Info_t;
93
94 /*
95 *************************** Static Function Declaration **************************
96 */
97
98 static
99 NFCSTATUS
100 phHciNfc_IDMgmt_InfoUpdate(
101 phHciNfc_sContext_t *psHciContext,
102 phHal_sHwReference_t *pHwRef,
103 uint8_t index,
104 uint8_t *reg_value,
105 uint8_t reg_length
106 );
107
108 static
109 NFCSTATUS
110 phHciNfc_Recv_IDMgmt_Response(
111 void *psHciContext,
112 void *pHwRef,
113 uint8_t *pResponse,
114 #ifdef ONE_BYTE_LEN
115 uint8_t length
116 #else
117 uint16_t length
118 #endif
119 );
120
121
122 /*
123 *************************** Function Definitions ***************************
124 */
125
126 /*!
127 * \brief Allocates the resources of Identity Managment Gate.
128 *
129 * This function Allocates the resources of the Identity Management
130 * gate Information Structure.
131 *
132 */
133
134 NFCSTATUS
phHciNfc_IDMgmt_Init_Resources(phHciNfc_sContext_t * psHciContext)135 phHciNfc_IDMgmt_Init_Resources(
136 phHciNfc_sContext_t *psHciContext
137 )
138 {
139 NFCSTATUS status = NFCSTATUS_SUCCESS;
140 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
141 if( NULL == psHciContext )
142 {
143 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
144 }
145 else
146 {
147 if( ( NULL == psHciContext->p_identity_info )
148 && (phHciNfc_Allocate_Resource((void **)(&p_identity_info),
149 sizeof(phHciNfc_IDMgmt_Info_t))== NFCSTATUS_SUCCESS)
150 )
151 {
152 psHciContext->p_identity_info = p_identity_info;
153 p_identity_info->id_cur_seq = IDMGMT_PIPE_OPEN;
154 p_identity_info->id_next_seq = IDMGMT_PIPE_OPEN;
155 p_identity_info->pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
156 }
157 else
158 {
159 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INSUFFICIENT_RESOURCES);
160 }
161 }
162 return status;
163 }
164
165 /*!
166 * \brief Get the pipe_id of Identity Managment Gate.
167 *
168 * This function Get the pipe_id of Identity Managment Gate.
169 *
170 */
171
172
173 NFCSTATUS
phHciNfc_IDMgmt_Get_PipeID(phHciNfc_sContext_t * psHciContext,uint8_t * ppipe_id)174 phHciNfc_IDMgmt_Get_PipeID(
175 phHciNfc_sContext_t *psHciContext,
176 uint8_t *ppipe_id
177 )
178 {
179 NFCSTATUS status = NFCSTATUS_SUCCESS;
180 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
181 if( (NULL != psHciContext)
182 && ( NULL != ppipe_id )
183 && ( NULL != psHciContext->p_identity_info )
184 )
185 {
186 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
187 psHciContext->p_identity_info ;
188 *ppipe_id = p_identity_info->pipe_id ;
189 }
190 else
191 {
192 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
193 }
194 return status;
195 }
196
197 NFCSTATUS
phHciNfc_IDMgmt_Update_Sequence(phHciNfc_sContext_t * psHciContext,phHciNfc_eSeqType_t reader_seq)198 phHciNfc_IDMgmt_Update_Sequence(
199 phHciNfc_sContext_t *psHciContext,
200 phHciNfc_eSeqType_t reader_seq
201 )
202 {
203 NFCSTATUS status = NFCSTATUS_SUCCESS;
204 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
205 if( NULL == psHciContext )
206 {
207 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
208 }
209 else
210 {
211 if( NULL == psHciContext->p_identity_info )
212 {
213 status = PHNFCSTVAL(CID_NFC_HCI,
214 NFCSTATUS_INVALID_HCI_INFORMATION);
215 }
216 else
217 {
218 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
219 psHciContext->p_identity_info ;
220 switch(reader_seq)
221 {
222 case RESET_SEQ:
223 case INIT_SEQ:
224 {
225 p_identity_info->id_cur_seq = IDMGMT_PIPE_OPEN;
226 p_identity_info->id_next_seq = IDMGMT_PIPE_OPEN;
227 break;
228 }
229 case UPDATE_SEQ:
230 {
231 p_identity_info->id_cur_seq =
232 p_identity_info->id_next_seq;
233 break;
234 }
235 case INFO_SEQ:
236 {
237 p_identity_info->id_cur_seq = IDMGMT_GET_FW_VERSION;
238 p_identity_info->id_next_seq = IDMGMT_GET_FW_VERSION;
239 break;
240 }
241 case REL_SEQ:
242 {
243 p_identity_info->id_cur_seq = IDMGMT_PIPE_CLOSE;
244 p_identity_info->id_next_seq = IDMGMT_PIPE_CLOSE;
245 break;
246 }
247 default:
248 {
249 break;
250 }
251 }
252 }
253 }
254
255 return status;
256
257 }
258
259
260
261 /*!
262 * \brief Initialisation of Identity Managment Gate.
263 *
264 * This function initialses the Identity Management gate and
265 * populates the Identity Management Information Structure
266 *
267 */
268
269 NFCSTATUS
phHciNfc_IDMgmt_Initialise(phHciNfc_sContext_t * psHciContext,void * pHwRef)270 phHciNfc_IDMgmt_Initialise(
271 phHciNfc_sContext_t *psHciContext,
272 void *pHwRef
273 )
274 {
275 NFCSTATUS status = NFCSTATUS_SUCCESS;
276 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
277 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
278 #ifndef ESTABLISH_SESSION
279 uint8_t id_pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
280 #endif
281
282 if( NULL == psHciContext )
283 {
284 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
285 }
286 else
287 {
288
289 if( NULL == psHciContext->p_identity_info )
290 {
291 status = PHNFCSTVAL(CID_NFC_HCI,
292 NFCSTATUS_INVALID_HCI_INFORMATION);
293 }
294 else
295 {
296 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
297 psHciContext->p_identity_info ;
298 p_pipe_info = p_identity_info->p_pipe_info;
299 if(NULL == p_pipe_info )
300 {
301 status = PHNFCSTVAL(CID_NFC_HCI,
302 NFCSTATUS_NOT_ALLOWED);
303 }
304 else
305 {
306 switch(p_identity_info->id_cur_seq )
307 {
308 /* Identity Mgmt pipe open sequence */
309 case IDMGMT_PIPE_OPEN:
310 {
311 status = phHciNfc_Open_Pipe( psHciContext,
312 pHwRef, p_pipe_info );
313 if(status == NFCSTATUS_SUCCESS)
314 {
315 p_identity_info->id_next_seq = IDMGMT_GET_FW_VERSION;
316 #ifndef ESTABLISH_SESSION
317 status = NFCSTATUS_PENDING;
318 #endif
319 }
320 break;
321 }
322 #ifndef ESTABLISH_SESSION
323 case IDMGMT_GET_FW_VERSION:
324 {
325 p_pipe_info->reg_index = FW_VERSION_INDEX;
326 id_pipe_id = p_identity_info->pipe_id ;
327 status =
328 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
329 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
330 if(NFCSTATUS_PENDING == status )
331 {
332 p_identity_info->id_next_seq = IDMGMT_GET_HW_VERSION;
333 /* status = NFCSTATUS_SUCCESS; */
334 }
335 break;
336 }
337 case IDMGMT_GET_HW_VERSION:
338 {
339 p_pipe_info->reg_index = HW_VERSION_INDEX;
340 id_pipe_id = p_identity_info->pipe_id ;
341 status =
342 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
343 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
344 if(NFCSTATUS_PENDING == status )
345 {
346 p_identity_info->id_next_seq = IDMGMT_GET_HCI_VERSION;
347 /* status = NFCSTATUS_SUCCESS; */
348 }
349 break;
350 }
351 case IDMGMT_GET_HCI_VERSION:
352 {
353 p_pipe_info->reg_index = HCI_VERSION_INDEX;
354 id_pipe_id = p_identity_info->pipe_id ;
355 status =
356 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
357 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
358 if(NFCSTATUS_PENDING == status )
359 {
360 p_identity_info->id_next_seq = IDMGMT_GET_VENDOR_NAME;
361 /* status = NFCSTATUS_SUCCESS; */
362 }
363 break;
364 }
365 case IDMGMT_GET_VENDOR_NAME:
366 {
367 p_pipe_info->reg_index = VENDOR_NAME_INDEX;
368 id_pipe_id = p_identity_info->pipe_id ;
369 status =
370 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
371 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
372 if(NFCSTATUS_PENDING == status )
373 {
374 p_identity_info->id_next_seq = IDMGMT_GET_MODEL_ID;
375 /* status = NFCSTATUS_SUCCESS; */
376 }
377 break;
378 }
379 case IDMGMT_GET_MODEL_ID:
380 {
381 p_pipe_info->reg_index = MODEL_ID_INDEX;
382 id_pipe_id = p_identity_info->pipe_id ;
383 status =
384 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
385 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
386 if(NFCSTATUS_PENDING == status )
387 {
388 p_identity_info->id_next_seq = IDMGMT_GET_GATES_LIST;
389 /* status = NFCSTATUS_SUCCESS; */
390 }
391 break;
392 }
393 case IDMGMT_GET_GATES_LIST:
394 {
395 p_pipe_info->reg_index = GATES_LIST_INDEX;
396 id_pipe_id = p_identity_info->pipe_id ;
397 status =
398 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
399 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
400 if(NFCSTATUS_PENDING == status )
401 {
402 p_identity_info->id_next_seq = IDMGMT_GET_FULL_VERSION;
403 /* status = NFCSTATUS_SUCCESS; */
404 }
405 break;
406 }
407 case IDMGMT_GET_FULL_VERSION:
408 {
409 p_pipe_info->reg_index = FULL_VERSION_INDEX;
410 id_pipe_id = p_identity_info->pipe_id ;
411 status =
412 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
413 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
414 if(NFCSTATUS_PENDING == status )
415 {
416 p_identity_info->id_next_seq = IDMGMT_PIPE_CLOSE;
417 status = NFCSTATUS_SUCCESS;
418 }
419 break;
420 }
421 #endif
422 default:
423 {
424 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
425 break;
426 }
427
428 }/* End of the Sequence Switch */
429 }/* End of Pipe Info Memory Check */
430
431 }/* End of the Identity Info Memory Check */
432
433 } /* End of Null Context Check */
434
435 return status;
436 }
437
438
439
440 /*!
441 * \brief Initialisation of Identity Managment Gate.
442 *
443 * This function initialses the Identity Management gate and
444 * populates the Identity Management Information Structure
445 *
446 */
447
448 NFCSTATUS
phHciNfc_IDMgmt_Info_Sequence(phHciNfc_sContext_t * psHciContext,void * pHwRef)449 phHciNfc_IDMgmt_Info_Sequence(
450 phHciNfc_sContext_t *psHciContext,
451 void *pHwRef
452 )
453 {
454 NFCSTATUS status = NFCSTATUS_SUCCESS;
455 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
456 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
457 uint8_t id_pipe_id = (uint8_t)HCI_UNKNOWN_PIPE_ID;
458
459 if( NULL == psHciContext )
460 {
461 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
462 }
463 else
464 {
465
466 if( NULL == psHciContext->p_identity_info )
467 {
468 status = PHNFCSTVAL(CID_NFC_HCI,
469 NFCSTATUS_INVALID_HCI_INFORMATION);
470 }
471 else
472 {
473 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
474 psHciContext->p_identity_info ;
475 p_pipe_info = p_identity_info->p_pipe_info;
476 if(NULL == p_pipe_info )
477 {
478 status = PHNFCSTVAL(CID_NFC_HCI,
479 NFCSTATUS_NOT_ALLOWED);
480 }
481 else
482 {
483 switch(p_identity_info->id_cur_seq )
484 {
485 case IDMGMT_GET_FW_VERSION:
486 {
487 p_pipe_info->reg_index = FW_VERSION_INDEX;
488 id_pipe_id = p_identity_info->pipe_id ;
489 status =
490 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
491 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
492 if(NFCSTATUS_PENDING == status )
493 {
494 p_identity_info->id_next_seq = IDMGMT_GET_HW_VERSION;
495 /* status = NFCSTATUS_SUCCESS; */
496 }
497 break;
498 }
499 case IDMGMT_GET_HW_VERSION:
500 {
501 p_pipe_info->reg_index = HW_VERSION_INDEX;
502 id_pipe_id = p_identity_info->pipe_id ;
503 status =
504 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
505 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
506 if(NFCSTATUS_PENDING == status )
507 {
508 p_identity_info->id_next_seq = IDMGMT_GET_HCI_VERSION;
509 /* status = NFCSTATUS_SUCCESS; */
510 }
511 break;
512 }
513 case IDMGMT_GET_HCI_VERSION:
514 {
515 p_pipe_info->reg_index = HCI_VERSION_INDEX;
516 id_pipe_id = p_identity_info->pipe_id ;
517 status =
518 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
519 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
520 if(NFCSTATUS_PENDING == status )
521 {
522 p_identity_info->id_next_seq = IDMGMT_GET_VENDOR_NAME;
523 /* status = NFCSTATUS_SUCCESS; */
524 }
525 break;
526 }
527 case IDMGMT_GET_VENDOR_NAME:
528 {
529 p_pipe_info->reg_index = VENDOR_NAME_INDEX;
530 id_pipe_id = p_identity_info->pipe_id ;
531 status =
532 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
533 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
534 if(NFCSTATUS_PENDING == status )
535 {
536 p_identity_info->id_next_seq = IDMGMT_GET_MODEL_ID;
537 /* status = NFCSTATUS_SUCCESS; */
538 }
539 break;
540 }
541 case IDMGMT_GET_MODEL_ID:
542 {
543 p_pipe_info->reg_index = MODEL_ID_INDEX;
544 id_pipe_id = p_identity_info->pipe_id ;
545 status =
546 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
547 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
548 if(NFCSTATUS_PENDING == status )
549 {
550 p_identity_info->id_next_seq = IDMGMT_GET_GATES_LIST;
551 /* status = NFCSTATUS_SUCCESS; */
552 }
553 break;
554 }
555 case IDMGMT_GET_GATES_LIST:
556 {
557 p_pipe_info->reg_index = GATES_LIST_INDEX;
558 id_pipe_id = p_identity_info->pipe_id ;
559 status =
560 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
561 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
562 if(NFCSTATUS_PENDING == status )
563 {
564 p_identity_info->id_next_seq = IDMGMT_GET_FULL_VERSION;
565 /* status = NFCSTATUS_SUCCESS; */
566 }
567 break;
568 }
569 case IDMGMT_GET_FULL_VERSION:
570 {
571 p_pipe_info->reg_index = FULL_VERSION_INDEX;
572 id_pipe_id = p_identity_info->pipe_id ;
573 status =
574 phHciNfc_Send_Generic_Cmd( psHciContext, pHwRef,
575 id_pipe_id, (uint8_t)ANY_GET_PARAMETER );
576 if(NFCSTATUS_PENDING == status )
577 {
578 p_identity_info->id_next_seq = IDMGMT_PIPE_CLOSE;
579 status = NFCSTATUS_SUCCESS;
580 }
581 break;
582 }
583 default:
584 {
585 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_SEQUENCE);
586 break;
587 }
588
589 }/* End of the Sequence Switch */
590 }/* End of Pipe Info Memory Check */
591
592 }/* End of the Identity Info Memory Check */
593
594 } /* End of Null Context Check */
595
596 return status;
597 }
598
599 /*!
600 * \brief Releases the resources allocated the Identity Management.
601 *
602 * This function Releases the resources allocated the Identity Management.
603 */
604
605 NFCSTATUS
phHciNfc_IDMgmt_Release(phHciNfc_sContext_t * psHciContext,void * pHwRef)606 phHciNfc_IDMgmt_Release(
607 phHciNfc_sContext_t *psHciContext,
608 void *pHwRef
609 )
610 {
611 NFCSTATUS status = NFCSTATUS_SUCCESS;
612 phHciNfc_Pipe_Info_t *p_pipe_info = NULL;
613 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
614 /* static phHciNfc_IDMgmt_Seq_t identity_init_seq = IDMGMT_PIPE_CREATE; */
615
616 if( (NULL == psHciContext) || (NULL == pHwRef) )
617 {
618 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
619 }
620 else
621 {
622 if( NULL != psHciContext->p_identity_info )
623 {
624 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
625 psHciContext->p_identity_info ;
626 p_pipe_info = p_identity_info->p_pipe_info;
627
628 status = phHciNfc_Close_Pipe( psHciContext,
629 pHwRef, p_pipe_info );
630 }
631 else
632 {
633 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_NOT_ALLOWED);
634
635 }/* End of the Identity Info Memory Check */
636
637 } /* End of Null Context Check */
638
639 return status;
640 }
641
642
643 /*!
644 * \brief Receives the HCI Response from the corresponding peripheral device.
645 *
646 * This function receives the HCI Command Response from the connected NFC
647 * Pheripheral device.
648 */
649 static
650 NFCSTATUS
phHciNfc_Recv_IDMgmt_Response(void * psContext,void * pHwRef,uint8_t * pResponse,uint8_t length)651 phHciNfc_Recv_IDMgmt_Response(
652 void *psContext,
653 void *pHwRef,
654 uint8_t *pResponse,
655 #ifdef ONE_BYTE_LEN
656 uint8_t length
657 #else
658 uint16_t length
659 #endif
660 )
661 {
662 phHciNfc_sContext_t *psHciContext =
663 (phHciNfc_sContext_t *)psContext ;
664 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
665 NFCSTATUS status = NFCSTATUS_SUCCESS;
666 uint8_t prev_cmd = ANY_GET_PARAMETER;
667
668 if( (NULL == psHciContext) || (NULL == pHwRef) )
669 {
670 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
671 }
672 else if( NULL == psHciContext->p_identity_info )
673 {
674 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
675 }
676 else
677 {
678 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
679 psHciContext->p_identity_info ;
680 if( NULL != p_identity_info->p_pipe_info)
681 {
682 prev_cmd = p_identity_info->p_pipe_info->prev_msg ;
683 switch(prev_cmd)
684 {
685 case ANY_GET_PARAMETER:
686 {
687 status = phHciNfc_IDMgmt_InfoUpdate(psHciContext,
688 (phHal_sHwReference_t *)pHwRef,
689 p_identity_info->p_pipe_info->reg_index,
690 &pResponse[HCP_HEADER_LEN],
691 (uint8_t)(length - HCP_HEADER_LEN));
692 break;
693 }
694 case ANY_SET_PARAMETER:
695 {
696 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_FEATURE_NOT_SUPPORTED);
697 break;
698 }
699 case ANY_OPEN_PIPE:
700 {
701 break;
702 }
703 case ANY_CLOSE_PIPE:
704 {
705 break;
706 }
707 default:
708 {
709 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_RESPONSE);
710 break;
711 }
712 }
713 if( NFCSTATUS_SUCCESS == status )
714 {
715 p_identity_info->p_pipe_info->prev_status = NFCSTATUS_SUCCESS;
716 p_identity_info->id_cur_seq = p_identity_info->id_next_seq;
717 }
718 }
719 }
720 return status;
721 }
722
723 /* Function to Update the Pipe Information */
724 NFCSTATUS
phHciNfc_IDMgmt_Update_PipeInfo(phHciNfc_sContext_t * psHciContext,uint8_t pipe_id,phHciNfc_Pipe_Info_t * pPipeInfo)725 phHciNfc_IDMgmt_Update_PipeInfo(
726 phHciNfc_sContext_t *psHciContext,
727 uint8_t pipe_id,
728 phHciNfc_Pipe_Info_t *pPipeInfo
729 )
730 {
731 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
732 NFCSTATUS status = NFCSTATUS_SUCCESS;
733
734 if( NULL == psHciContext )
735 {
736 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
737 }
738 else if ( NULL == psHciContext->p_identity_info )
739 {
740 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
741 }
742 else
743 {
744 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
745 psHciContext->p_identity_info ;
746 /* Update the pipe_id of the ID Mgmt Gate obtained from the HCI Response */
747 p_identity_info->pipe_id = pipe_id;
748 p_identity_info->p_pipe_info = pPipeInfo;
749 if ( NULL != pPipeInfo)
750 {
751 /* Update the Response Receive routine of the IDMgmt Gate */
752 pPipeInfo->recv_resp = &phHciNfc_Recv_IDMgmt_Response;
753 }
754 }
755
756 return status;
757 }
758
759 static
760 NFCSTATUS
phHciNfc_IDMgmt_InfoUpdate(phHciNfc_sContext_t * psHciContext,phHal_sHwReference_t * pHwRef,uint8_t index,uint8_t * reg_value,uint8_t reg_length)761 phHciNfc_IDMgmt_InfoUpdate(
762 phHciNfc_sContext_t *psHciContext,
763 phHal_sHwReference_t *pHwRef,
764 uint8_t index,
765 uint8_t *reg_value,
766 uint8_t reg_length
767 )
768 {
769 phHciNfc_IDMgmt_Info_t *p_identity_info=NULL;
770 NFCSTATUS status = NFCSTATUS_SUCCESS;
771 uint8_t i=0;
772 if( (NULL == psHciContext)
773 || (NULL == reg_value)
774 || (reg_length == 0)
775 )
776 {
777 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_PARAMETER);
778 }
779 else if ( NULL == psHciContext->p_identity_info )
780 {
781 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
782 }
783 else
784 {
785 p_identity_info = (phHciNfc_IDMgmt_Info_t *)
786 psHciContext->p_identity_info ;
787
788 switch(index)
789 {
790 case FW_VERSION_INDEX :
791 {
792 HCI_PRINT_BUFFER("\tFW Version:",reg_value,reg_length);
793 for(i=0 ;(reg_length == VERSION_LEN)&&(i < reg_length); i++)
794 {
795 p_identity_info->fw_version |=
796 (uint32_t)(reg_value[VERSION_LEN - i - 1] << (BYTE_SIZE * i));
797 }
798 pHwRef->device_info.fw_version = p_identity_info->fw_version ;
799 break;
800 }
801 case HW_VERSION_INDEX :
802 {
803 HCI_PRINT_BUFFER("\tHW Version:",reg_value,reg_length);
804 for(i=0 ;(reg_length == VERSION_LEN)&&(i < reg_length); i++)
805 {
806 p_identity_info->hw_version |=
807 (uint32_t)(reg_value[VERSION_LEN - i - 1] << (BYTE_SIZE * i));
808 }
809 pHwRef->device_info.hw_version = p_identity_info->hw_version ;
810 break;
811 }
812 case VENDOR_NAME_INDEX :
813 {
814 for(i=0 ;(reg_length <= VENDOR_NAME_LEN)&&(i < reg_length); i++)
815 {
816 p_identity_info->vendor_name[i] = reg_value[i];
817 pHwRef->device_info.vendor_name[i]= reg_value[i];
818 }
819 HCI_DEBUG("\tVendor Name:%s",p_identity_info->vendor_name);
820 break;
821 }
822 case MODEL_ID_INDEX :
823 {
824 HCI_PRINT_BUFFER("\tModel ID:",reg_value,reg_length);
825 p_identity_info->model_id = reg_value[i] ;
826 pHwRef->device_info.model_id = p_identity_info->model_id ;
827 #ifndef NXP_HAL_ENABLE_SMX
828 if( NFC_HW_PN65N == pHwRef->device_info.model_id)
829 #endif
830 {
831 pHwRef->smx_connected = TRUE;
832 }
833 break;
834 }
835 case HCI_VERSION_INDEX :
836 {
837 HCI_PRINT_BUFFER("\tHCI Version:",reg_value,reg_length);
838 p_identity_info->hci_version = reg_value[i] ;
839 pHwRef->device_info.hci_version = p_identity_info->hci_version ;
840 break;
841 }
842 case GATES_LIST_INDEX :
843 {
844 HCI_PRINT_BUFFER("\tGates List:",reg_value,reg_length);
845 for(i=0 ;(reg_length <= GATES_LIST_LEN)&&(i < reg_length); i++)
846 {
847 p_identity_info->gates_list[i] = reg_value[i];
848 }
849 break;
850 }
851 case FULL_VERSION_INDEX :
852 {
853 HCI_PRINT_BUFFER("\tVERSION INFO:",reg_value,reg_length);
854 for(i=0 ;(reg_length <= NXP_FULL_VERSION_LEN)&&(i < reg_length); i++)
855 {
856 p_identity_info->full_version[i] = reg_value[i];
857 pHwRef->device_info.full_version[i]= reg_value[i];
858 }
859 break;
860 }
861 default:
862 {
863 status = PHNFCSTVAL(CID_NFC_HCI, NFCSTATUS_INVALID_HCI_INFORMATION);
864 break;
865 } /*End of the default Switch Case */
866
867 } /*End of the Index Switch */
868
869 } /* End of Context and the Identity information validity check */
870
871 return status;
872 }
873