blob: d113cd3b845fc88bc952027059d7ae44a1c91707 [file] [log] [blame]
nxpandroidc7611652015-09-23 16:42:05 +05301/******************************************************************************
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 ******************************************************************************/
nxpandroidc7611652015-09-23 16:42:05 +053018
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
nxpandroidc7611652015-09-23 16:42:05 +053027#include "nfa_api.h"
28#include "nfa_ce_api.h"
29#include "nfa_dm_int.h"
nxf24591c1cbeab2018-02-21 17:32:26 +053030#include "nfa_sys.h"
nxpandroidc7611652015-09-23 16:42:05 +053031#include "nfc_api.h"
32
33/*****************************************************************************
34** Constants and data types
35*****************************************************************************/
36
nxpandroidc7611652015-09-23 16:42:05 +053037/* CE events */
nxpandroid8f6d0532017-07-12 18:25:30 +053038enum {
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,
nxf24591c1cbeab2018-02-21 17:32:26 +053045 NFA_CE_DEACTIVATE_NTF_EVT
nxpandroidc7611652015-09-23 16:42:05 +053046
nxpandroidc7611652015-09-23 16:42:05 +053047};
48
49/* Listen registration types */
nxf24591c1cbeab2018-02-21 17:32:26 +053050enum { NFA_CE_REG_TYPE_ISO_DEP, NFA_CE_REG_TYPE_FELICA, NFA_CE_REG_TYPE_UICC };
nxpandroid8f6d0532017-07-12 18:25:30 +053051typedef uint8_t tNFA_CE_REG_TYPE;
nxpandroidc7611652015-09-23 16:42:05 +053052
53/* data type for NFA_CE_API_CFG_LOCAL_TAG_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053054typedef 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];
nxpandroidc7611652015-09-23 16:42:05 +053063} tNFA_CE_API_CFG_LOCAL_TAG;
64
65/* data type for NFA_CE_ACTIVATE_NTF_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053066typedef struct {
67 NFC_HDR hdr;
68 tNFC_ACTIVATE_DEVT* p_activation_params;
nxpandroidc7611652015-09-23 16:42:05 +053069} tNFA_CE_ACTIVATE_NTF;
70
71/* data type for NFA_CE_API_REG_LISTEN_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053072typedef struct {
73 NFC_HDR hdr;
74 tNFA_CONN_CBACK* p_conn_cback;
nxpandroidc7611652015-09-23 16:42:05 +053075
nxpandroid8f6d0532017-07-12 18:25:30 +053076 tNFA_CE_REG_TYPE listen_type;
nxpandroidc7611652015-09-23 16:42:05 +053077
nxpandroid8f6d0532017-07-12 18:25:30 +053078 /* 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];
nxpandroidc7611652015-09-23 16:42:05 +053082
nxpandroid8f6d0532017-07-12 18:25:30 +053083 /* 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 */
nxpandroidc7611652015-09-23 16:42:05 +053086
nxpandroid8f6d0532017-07-12 18:25:30 +053087 /* For registering UICC */
88 tNFA_HANDLE ee_handle;
89 tNFA_TECHNOLOGY_MASK tech_mask;
nxpandroidc7611652015-09-23 16:42:05 +053090} tNFA_CE_API_REG_LISTEN;
91
92/* data type for NFA_CE_API_DEREG_LISTEN_EVT */
nxpandroid8f6d0532017-07-12 18:25:30 +053093typedef struct {
94 NFC_HDR hdr;
95 tNFA_HANDLE handle;
96 uint32_t listen_info;
nxpandroidc7611652015-09-23 16:42:05 +053097} tNFA_CE_API_DEREG_LISTEN;
98
99/* union of all data types */
nxpandroid8f6d0532017-07-12 18:25:30 +0530100typedef 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;
nxpandroidc7611652015-09-23 16:42:05 +0530107} tNFA_CE_MSG;
108
109/****************************************************************************
110** LISTEN_INFO definitions
111*****************************************************************************/
nxpandroid8f6d0532017-07-12 18:25:30 +0530112/* 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)
nxpandroidc7611652015-09-23 16:42:05 +0530115
116/* Flags for listen request */
nxpandroid8f6d0532017-07-12 18:25:30 +0530117/* 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 Kotharkardf5d02e2018-05-10 14:54:54 +0530131/* App has not been notified of ACTIVATE_EVT yet for this HCEF NFCID2 */
132#define NFA_CE_LISTEN_INFO_T3T_ACTIVATE_PND 0x00010000
nxpandroidc7611652015-09-23 16:42:05 +0530133
134/* Structure for listen look up table */
nxpandroid8f6d0532017-07-12 18:25:30 +0530135typedef 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 */
nxpandroidc7611652015-09-23 16:42:05 +0530141
nxpandroid8f6d0532017-07-12 18:25:30 +0530142 /* 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) */
nxpandroidc7611652015-09-23 16:42:05 +0530149
nxpandroid8f6d0532017-07-12 18:25:30 +0530150 /* 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 */
nxpandroidc7611652015-09-23 16:42:05 +0530155} tNFA_CE_LISTEN_INFO;
156
nxpandroidc7611652015-09-23 16:42:05 +0530157/****************************************************************************/
158
159/* Internal flags for nfa_ce */
nxpandroid8f6d0532017-07-12 18:25:30 +0530160/* 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
164typedef uint32_t tNFA_CE_FLAGS;
nxpandroidc7611652015-09-23 16:42:05 +0530165
166/* NFA_CE control block */
nxpandroid8f6d0532017-07-12 18:25:30 +0530167typedef struct {
168 uint8_t* p_scratch_buf; /* Scratch buffer for write requests */
169 uint32_t scratch_buf_size;
nxpandroidc7611652015-09-23 16:42:05 +0530170
nxpandroid8f6d0532017-07-12 18:25:30 +0530171 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 */
nxpandroidc7611652015-09-23 16:42:05 +0530174
nxpandroid8f6d0532017-07-12 18:25:30 +0530175 /* 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 */
nxpandroidc7611652015-09-23 16:42:05 +0530180
nxpandroid8f6d0532017-07-12 18:25:30 +0530181 tNFA_DM_DISC_TECH_PROTO_MASK
182 isodep_disc_mask; /* the technology/protocol mask for ISO-DEP */
nxpandroidc7611652015-09-23 16:42:05 +0530183
nxpandroid8f6d0532017-07-12 18:25:30 +0530184 /* Local ndef tag info */
185 uint8_t* p_ndef_data;
186 uint16_t ndef_cur_size;
187 uint16_t ndef_max_size;
nxpandroidc7611652015-09-23 16:42:05 +0530188
nxpandroid8f6d0532017-07-12 18:25:30 +0530189 tNFA_SYS_EVT_HDLR* p_vs_evt_hdlr; /* VS event handler */
nxpandroidc7611652015-09-23 16:42:05 +0530190} tNFA_CE_CB;
191extern tNFA_CE_CB nfa_ce_cb;
192
193/* type definition for action functions */
nxpandroid8f6d0532017-07-12 18:25:30 +0530194typedef bool (*tNFA_CE_ACTION)(tNFA_CE_MSG* p_data);
195
196extern uint8_t NFC_GetNCIVersion();
nxpandroidc7611652015-09-23 16:42:05 +0530197
198/* Action function prototypes */
nxpandroid8f6d0532017-07-12 18:25:30 +0530199bool nfa_ce_api_cfg_local_tag(tNFA_CE_MSG* p_ce_msg);
200bool nfa_ce_api_reg_listen(tNFA_CE_MSG* p_ce_msg);
201bool nfa_ce_api_dereg_listen(tNFA_CE_MSG* p_ce_msg);
202bool nfa_ce_api_cfg_isodep_tech(tNFA_CE_MSG* p_ce_msg);
203bool nfa_ce_activate_ntf(tNFA_CE_MSG* p_ce_msg);
204bool nfa_ce_deactivate_ntf(tNFA_CE_MSG* p_ce_msg);
nxpandroidc7611652015-09-23 16:42:05 +0530205
206/* Internal function prototypes */
nxpandroid8f6d0532017-07-12 18:25:30 +0530207void nfa_ce_t3t_generate_rand_nfcid(uint8_t nfcid2[NCI_RF_F_UID_LEN]);
208bool nfa_ce_hdl_event(NFC_HDR* p_msg);
209tNFC_STATUS nfa_ce_set_content(void);
210tNFA_STATUS nfa_ce_start_listening(void);
211void nfa_ce_remove_listen_info_entry(uint8_t listen_info_idx, bool notify_app);
212void nfa_ce_sys_disable(void);
213void nfa_ce_free_scratch_buf(void);
214bool nfa_ce_restart_listen_check(void);
nxpandroidc7611652015-09-23 16:42:05 +0530215#endif /* NFA_DM_INT_H */