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