ce_int.h revision 26620e3108f6a0f32f5f0a0725e28e5ae66017d6
1/**************************************************************************** 2** 3** File: ce_int.h 4** 5** Description: This file contains the Near Field Communication (NFC) 6** Card Emulation mode related internal function / definitions. 7** 8** Copyright (c) 2009-2010, Broadcom Corp., All Rights Reserved. 9** Broadcom Bluetooth Core. Proprietary and confidential. 10****************************************************************************/ 11 12#ifndef CE_INT_H_ 13#define CE_INT_H_ 14 15#include "ce_api.h" 16 17#if (CE_TEST_INCLUDED == FALSE) 18#define CE_MIN_SUP_PROTO NCI_PROTOCOL_FELICA 19#define CE_MAX_SUP_PROTO NCI_PROTOCOL_ISO4 20#else 21#define CE_MIN_SUP_PROTO NCI_PROTOCOL_TYPE1 22#define CE_MAX_SUP_PROTO NCI_PROTOCOL_MIFARE 23#endif 24 25#define CE_MAX_BYTE_PER_PAGE 7 /* 2^8=256. CB use UINT8 for BytesPerPage, so max is 7 */ 26 27/* CE Type 3 Tag structures */ 28 29/* Type 3 Tag NDEF card-emulation */ 30typedef struct { 31 BOOLEAN initialized; 32 UINT8 version; /* Ver: peer version */ 33 UINT8 nbr; /* NBr: number of blocks that can be read using one Check command */ 34 UINT8 nbw; /* Nbw: number of blocks that can be written using one Update command */ 35 UINT16 nmaxb; /* Nmaxb: maximum number of blocks available for NDEF data */ 36 UINT8 writef; /* WriteFlag: 00h if writing data finished; 0Fh if writing data in progress */ 37 UINT8 rwflag; /* RWFlag: 00h NDEF is read-only; 01h if read/write available */ 38 UINT32 ln; 39 UINT8 *p_buf; /* Current contents for READs */ 40 41 /* Scratch NDEF buffer (for update NDEF commands) */ 42 UINT8 scratch_writef; 43 UINT32 scratch_ln; 44 UINT8 *p_scratch_buf; /* Scratch buffer for WRITE/readback */ 45} tCE_T3T_NDEF_INFO; 46 47/* Type 3 Tag current command processing */ 48typedef struct { 49 UINT16 service_code_list[T3T_MSG_SERVICE_LIST_MAX]; 50 UINT8 *p_block_list_start; 51 UINT8 *p_block_data_start; 52 UINT8 num_services; 53 UINT8 num_blocks; 54} tCE_T3T_CUR_CMD; 55 56/* Type 3 Tag control blcok */ 57typedef struct 58{ 59 UINT8 state; 60 UINT16 system_code; 61 UINT8 local_nfcid2[NCI_RF_F_UID_LEN]; 62 UINT8 local_pmm[NCI_T3T_PMM_LEN]; 63 tCE_T3T_NDEF_INFO ndef_info; 64 tCE_T3T_CUR_CMD cur_cmd; 65} tCE_T3T_MEM; 66 67/* CE Type 4 Tag control blocks */ 68typedef struct 69{ 70 UINT8 aid_len; 71 UINT8 aid[NFC_MAX_AID_LEN]; 72 tCE_CBACK *p_cback; 73} tCE_T4T_REG_AID; /* registered AID table */ 74 75typedef struct 76{ 77 TIMER_LIST_ENT timer; /* timeout for update file */ 78 UINT8 cc_file[T4T_FC_TLV_OFFSET_IN_CC + T4T_FILE_CONTROL_TLV_SIZE]; 79 UINT8 *p_ndef_msg; /* storage of NDEF message */ 80 UINT16 nlen; /* current size of NDEF message */ 81 UINT16 max_file_size; /* size of storage + 2 bytes for NLEN */ 82 UINT8 *p_scratch_buf; /* temp storage of NDEF message for update */ 83 84#define CE_T4T_STATUS_T4T_APP_SELECTED 0x01 /* T4T CE App is selected */ 85#define CE_T4T_STATUS_REG_AID_SELECTED 0x02 /* Registered AID is selected */ 86#define CE_T4T_STATUS_CC_FILE_SELECTED 0x04 /* CC file is selected */ 87#define CE_T4T_STATUS_NDEF_SELECTED 0x08 /* NDEF file is selected */ 88#define CE_T4T_STATUS_NDEF_FILE_READ_ONLY 0x10 /* NDEF is read-only */ 89#define CE_T4T_STATUS_NDEF_FILE_UPDATING 0x20 /* NDEF is updating */ 90#define CE_T4T_STATUS_WILDCARD_AID_SELECTED 0x40 /* Wildcard AID selected */ 91 92 UINT8 status; 93 94 tCE_CBACK *p_wildcard_aid_cback; /* registered wildcard AID callback */ 95 tCE_T4T_REG_AID reg_aid[CE_T4T_MAX_REG_AID]; /* registered AID table */ 96 UINT8 selected_aid_idx; 97} tCE_T4T_MEM; 98 99#define CE_T4T_WILDCARD_AID_HANDLE (CE_T4T_MAX_REG_AID) /* reserved handle for wildcard aid */ 100 101/* CE memory control blocks */ 102typedef struct 103{ 104 tCE_T3T_MEM t3t; 105 tCE_T4T_MEM t4t; 106} tCE_MEM; 107 108/* CE control blocks */ 109typedef struct 110{ 111 tCE_MEM mem; 112 tCE_CBACK *p_cback; 113 UINT8 *p_ndef; /* the memory starting from NDEF */ 114 UINT16 ndef_max; /* max size of p_ndef */ 115 UINT16 ndef_cur; /* current size of p_ndef */ 116 tNFC_RF_TECH tech; 117 UINT8 trace_level; 118 119} tCE_CB; 120 121/* 122** CE Type 4 Tag Definition 123*/ 124 125/* Max data size using a single ReadBinary. 2 bytes are for status bytes */ 126#define CE_T4T_MAX_LE (NFC_CE_POOL_BUF_SIZE - BT_HDR_SIZE - NCI_MSG_OFFSET_SIZE - NCI_DATA_HDR_SIZE - T4T_RSP_STATUS_WORDS_SIZE) 127 128/* Max data size using a single UpdateBinary. 6 bytes are for CLA, INS, P1, P2, Lc */ 129#define CE_T4T_MAX_LC (NFC_CE_POOL_BUF_SIZE - BT_HDR_SIZE - NCI_DATA_HDR_SIZE - T4T_CMD_MAX_HDR_SIZE) 130 131/***************************************************************************** 132** EXTERNAL FUNCTION DECLARATIONS 133*****************************************************************************/ 134#ifdef __cplusplus 135extern "C" { 136#endif 137 138/* Global NFC data */ 139#if NFC_DYNAMIC_MEMORY == FALSE 140NFC_API extern tCE_CB ce_cb; 141#else 142NFC_API extern tCE_CB *ce_cb_ptr; 143#define ce_cb (*ce_cb_ptr) 144#endif 145 146extern void ce_init(void); 147 148/* ce_t3t internal functions */ 149void ce_t3t_init(void); 150tNFC_STATUS ce_select_t3t (UINT16 system_code, UINT8 nfcid2[NCI_RF_F_UID_LEN]); 151 152/* ce_t4t internal functions */ 153extern tNFC_STATUS ce_select_t4t (void); 154extern void ce_t4t_process_timeout (TIMER_LIST_ENT *p_tle); 155 156#ifdef __cplusplus 157} 158#endif 159 160#endif /* CE_INT_H_ */ 161