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