1 /****************************************************************************** 2 * 3 * Copyright (C) 2011-2014 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 20 /****************************************************************************** 21 * 22 * This is the private interface file for NFA_CE 23 * 24 ******************************************************************************/ 25 #ifndef NFA_CE_INT_H 26 #define NFA_CE_INT_H 27 28 #include "nfa_sys.h" 29 #include "nfa_api.h" 30 #include "nfa_ce_api.h" 31 #include "nfa_dm_int.h" 32 #include "nfc_api.h" 33 34 /***************************************************************************** 35 ** Constants and data types 36 *****************************************************************************/ 37 38 /* ce status callback */ 39 typedef void tNFA_CE_STATUS_CBACK (tNFA_STATUS status); 40 41 /* CE events */ 42 enum 43 { 44 /* device manager local device API events */ 45 NFA_CE_API_CFG_LOCAL_TAG_EVT = NFA_SYS_EVT_START (NFA_ID_CE), 46 NFA_CE_API_REG_LISTEN_EVT, 47 NFA_CE_API_DEREG_LISTEN_EVT, 48 NFA_CE_API_CFG_ISODEP_TECH_EVT, 49 NFA_CE_ACTIVATE_NTF_EVT, 50 NFA_CE_DEACTIVATE_NTF_EVT, 51 52 NFA_CE_MAX_EVT 53 }; 54 55 /* Listen registration types */ 56 enum 57 { 58 NFA_CE_REG_TYPE_NDEF, 59 NFA_CE_REG_TYPE_ISO_DEP, 60 NFA_CE_REG_TYPE_FELICA, 61 NFA_CE_REG_TYPE_UICC 62 }; 63 typedef UINT8 tNFA_CE_REG_TYPE; 64 65 /* data type for NFA_CE_API_CFG_LOCAL_TAG_EVT */ 66 typedef struct 67 { 68 BT_HDR hdr; 69 tNFA_PROTOCOL_MASK protocol_mask; 70 UINT8 *p_ndef_data; 71 UINT16 ndef_cur_size; 72 UINT16 ndef_max_size; 73 BOOLEAN read_only; 74 UINT8 uid_len; 75 UINT8 uid[NFA_MAX_UID_LEN]; 76 } tNFA_CE_API_CFG_LOCAL_TAG; 77 78 /* data type for NFA_CE_ACTIVATE_NTF_EVT */ 79 typedef struct 80 { 81 BT_HDR hdr; 82 tNFC_ACTIVATE_DEVT *p_activation_params; 83 } tNFA_CE_ACTIVATE_NTF; 84 85 /* data type for NFA_CE_API_REG_LISTEN_EVT */ 86 typedef struct 87 { 88 BT_HDR hdr; 89 tNFA_CONN_CBACK *p_conn_cback; 90 91 tNFA_CE_REG_TYPE listen_type; 92 93 /* For registering Felica */ 94 UINT16 system_code; 95 UINT8 nfcid2[NCI_RF_F_UID_LEN]; 96 97 /* For registering Type-4 */ 98 UINT8 aid[NFC_MAX_AID_LEN]; /* AID to listen for (For type-4 only) */ 99 UINT8 aid_len; /* AID length */ 100 101 /* For registering UICC */ 102 tNFA_HANDLE ee_handle; 103 tNFA_TECHNOLOGY_MASK tech_mask; 104 } tNFA_CE_API_REG_LISTEN; 105 106 /* data type for NFA_CE_API_DEREG_LISTEN_EVT */ 107 typedef struct 108 { 109 BT_HDR hdr; 110 tNFA_HANDLE handle; 111 UINT32 listen_info; 112 } tNFA_CE_API_DEREG_LISTEN; 113 114 /* union of all data types */ 115 typedef union 116 { 117 /* GKI event buffer header */ 118 BT_HDR hdr; 119 tNFA_CE_API_CFG_LOCAL_TAG local_tag; 120 tNFA_CE_API_REG_LISTEN reg_listen; 121 tNFA_CE_API_DEREG_LISTEN dereg_listen; 122 tNFA_CE_ACTIVATE_NTF activate_ntf; 123 } tNFA_CE_MSG; 124 125 /**************************************************************************** 126 ** LISTEN_INFO definitions 127 *****************************************************************************/ 128 #define NFA_CE_LISTEN_INFO_IDX_NDEF 0 /* Entry 0 is reserved for local NDEF tag */ 129 #define NFA_CE_LISTEN_INFO_IDX_INVALID (NFA_CE_LISTEN_INFO_MAX) 130 131 132 /* Flags for listen request */ 133 #define NFA_CE_LISTEN_INFO_IN_USE 0x00000001 /* LISTEN_INFO entry is in use */ 134 #define NFC_CE_LISTEN_INFO_READONLY_NDEF 0x00000010 /* NDEF is read-only */ 135 #define NFA_CE_LISTEN_INFO_T4T_ACTIVATE_PND 0x00000040 /* App has not been notified of ACTIVATE_EVT yet for this T4T AID */ 136 #define NFA_CE_LISTEN_INFO_T4T_AID 0x00000080 /* This is a listen_info for T4T AID */ 137 #define NFA_CE_LISTEN_INFO_START_NTF_PND 0x00000100 /* App has not been notified of LISTEN_START yet */ 138 #define NFA_CE_LISTEN_INFO_FELICA 0x00000200 /* This is a listen_info for non-NDEF Felica */ 139 #define NFA_CE_LISTEN_INFO_UICC 0x00000400 /* This is a listen_info for UICC */ 140 141 142 /* Structure for listen look up table */ 143 typedef struct 144 { 145 UINT32 flags; 146 tNFA_CONN_CBACK *p_conn_cback; /* Callback for this listen request */ 147 tNFA_PROTOCOL_MASK protocol_mask; /* Mask of protocols for this listen request */ 148 tNFA_HANDLE rf_disc_handle; /* RF Discover handle */ 149 150 /* For host tag emulation (NFA_CeRegisterVirtualT4tSE and NFA_CeRegisterT4tAidOnDH) */ 151 UINT8 t3t_nfcid2[NCI_RF_F_UID_LEN]; 152 UINT16 t3t_system_code; /* Type-3 system code */ 153 UINT8 t4t_aid_handle; /* Type-4 aid callback handle (from CE_T4tRegisterAID) */ 154 155 /* For UICC */ 156 tNFA_HANDLE ee_handle; 157 tNFA_TECHNOLOGY_MASK tech_mask; /* listening technologies */ 158 tNFA_DM_DISC_TECH_PROTO_MASK tech_proto_mask; /* listening technologies and protocols */ 159 } tNFA_CE_LISTEN_INFO; 160 161 162 /****************************************************************************/ 163 164 /* Internal flags for nfa_ce */ 165 #define NFA_CE_FLAGS_APP_INIT_DEACTIVATION 0x00000001 /* Deactivation locally initiated by application */ 166 #define NFA_CE_FLAGS_LISTEN_ACTIVE_SLEEP 0x00000002 /* Tag is in listen active or sleep state */ 167 typedef UINT32 tNFA_CE_FLAGS; 168 169 /* NFA_CE control block */ 170 typedef struct 171 { 172 UINT8 *p_scratch_buf; /* Scratch buffer for write requests */ 173 UINT32 scratch_buf_size; 174 175 tNFC_ACTIVATE_DEVT activation_params; /* Activation params */ 176 tNFA_CE_FLAGS flags; /* internal flags */ 177 tNFA_CONN_CBACK *p_active_conn_cback; /* Callback of activated CE */ 178 179 /* listen_info table (table of listen paramters and app callbacks) */ 180 tNFA_CE_LISTEN_INFO listen_info[NFA_CE_LISTEN_INFO_MAX];/* listen info table */ 181 UINT8 idx_cur_active; /* listen_info index for currently activated CE */ 182 UINT8 idx_wild_card; /* listen_info index for T4T wild card CE */ 183 184 tNFA_DM_DISC_TECH_PROTO_MASK isodep_disc_mask; /* the technology/protocol mask for ISO-DEP */ 185 186 /* Local ndef tag info */ 187 UINT8 *p_ndef_data; 188 UINT16 ndef_cur_size; 189 UINT16 ndef_max_size; 190 191 tNFA_SYS_EVT_HDLR *p_vs_evt_hdlr; /* VS event handler */ 192 } tNFA_CE_CB; 193 extern tNFA_CE_CB nfa_ce_cb; 194 195 /* type definition for action functions */ 196 typedef BOOLEAN (*tNFA_CE_ACTION) (tNFA_CE_MSG *p_data); 197 198 /* Action function prototypes */ 199 BOOLEAN nfa_ce_api_cfg_local_tag (tNFA_CE_MSG *p_ce_msg); 200 BOOLEAN nfa_ce_api_reg_listen (tNFA_CE_MSG *p_ce_msg); 201 BOOLEAN nfa_ce_api_dereg_listen (tNFA_CE_MSG *p_ce_msg); 202 BOOLEAN nfa_ce_api_cfg_isodep_tech (tNFA_CE_MSG *p_ce_msg); 203 BOOLEAN nfa_ce_activate_ntf (tNFA_CE_MSG *p_ce_msg); 204 BOOLEAN nfa_ce_deactivate_ntf (tNFA_CE_MSG *p_ce_msg); 205 206 /* Internal function prototypes */ 207 void nfa_ce_t3t_generate_rand_nfcid (UINT8 nfcid2[NCI_RF_F_UID_LEN]); 208 BOOLEAN nfa_ce_hdl_event (BT_HDR *p_msg); 209 tNFC_STATUS nfa_ce_set_content (void); 210 tNFA_STATUS nfa_ce_start_listening (void); 211 void nfa_ce_remove_listen_info_entry (UINT8 listen_info_idx, BOOLEAN notify_app); 212 void nfa_ce_sys_disable (void); 213 void nfa_ce_free_scratch_buf (void); 214 BOOLEAN nfa_ce_restart_listen_check (void); 215 #endif /* NFA_DM_INT_H */ 216 217