• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2003-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  *  This is the private interface file for the NFA DTA
22  *
23  ******************************************************************************/
24 #ifndef NFA_DTA_INT_H
25 #define NFA_DTA_INT_H
26 
27 #include "ce_api.h"
28 #include "nfa_dta_api.h"
29 #include "nfa_sys.h"
30 #include "nfa_sys_int.h"
31 #include "nfc_api.h"
32 #include "rw_api.h"
33 
34 #if (NFA_DTA_INCLUDED == TRUE)
35 
36 /*****************************************************************************
37 **  DTA definitions
38 *****************************************************************************/
39 
40 #define NFA_DTA_DISCOVER_PARAMS_MAX 6
41 
42 #define NFA_DTA_SCRATCH_BUF_SIZE T3T_MSG_BLOCKSIZE
43 
44 #ifndef NFA_DTA_DEFAULT_CO_OUT_DSAP
45 /* Default SAP[LT,CO-OUT-DEST] if SDP was not performed to get SAP from the LT
46  */
47 #define NFA_DTA_DEFAULT_CO_OUT_DSAP 0x12
48 #endif
49 
50 /*****************************************************************************
51 * DTA state machine definitions
52 *****************************************************************************/
53 
54 typedef struct {
55   bool tp_continue;                       /* NFA_DTA_CFG_TP_CONTINUE    */
56   tNFA_DTA_FL_POLL_LISTEN poll_listen;    /* NFA_DTA_CFG_POLL_LISTEN    */
57   bool t4at_nfcdep_priority;              /* NFA_DTA_CFG_T4AT_NFCDEP_PRIORITY */
58   bool reactivation;                      /* NFA_DTA_CFG_REACTIVATION   */
59   uint16_t total_duration;                /* NFA_DTA_CFG_TOTAL_DURATION */
60   tNFA_DTA_EMVCO_PCD_MODE emvco_pcd_mode; /* NFA_DTA_CFG_EMVCO_PCD */
61 } tNFA_DTA_CONFIG;
62 
63 /*****************************************************************************
64 * DTA state machine definitions
65 *****************************************************************************/
66 /* DTA events */
67 enum {
68   /* device manager local device API events */
69   NFA_DTA_API_ENABLE_EVT = NFA_SYS_EVT_START(NFA_ID_DTA),
70   NFA_DTA_API_START_EVT,
71   NFA_DTA_DATA_CBACK_EVT,
72 
73   NFA_DTA_MAX_EVT
74 };
75 
76 /* data type for NFA_DTA_API_ENABLE_EVT */
77 typedef struct {
78   NFC_HDR hdr;
79   bool auto_start;
80   tNFA_DTA_CBACK* p_cback;
81 } tNFA_DTA_API_ENABLE;
82 
83 /* data type for NFA_DTA_API_START_EVT  */
84 typedef struct {
85   NFC_HDR hdr;
86   uint16_t pattern_number;
87   uint8_t tlv_len;
88   uint8_t* p_tlv_params;
89 } tNFA_DTA_API_START;
90 
91 /* data type for NFA_DTA_API_CONFIG  */
92 typedef struct {
93   NFC_HDR hdr;
94   tNFA_DTA_CFG_ITEM item;
95   tNFA_DTA_CFG cfg_data;
96 } tNFA_DTA_API_CONFIG;
97 
98 /* data type for NFA_DTA_DATA_CBACK_EVT */
99 typedef struct {
100   uint8_t event;
101   tRW_DATA data;
102 } tNFA_DTA_RW_DATA;
103 
104 typedef struct {
105   uint8_t event;
106   tCE_DATA data;
107 } tNFA_DTA_CE_DATA;
108 
109 typedef struct {
110   tNFC_CONN_EVT event;
111   tNFC_CONN data;
112 } tNFA_DTA_NFCDEP_DATA;
113 
114 typedef uint8_t tNFA_DTA_LLCP_EVT;
115 
116 typedef uint8_t tNFA_DTA_DATA_TYPE;
117 
118 typedef struct {
119   NFC_HDR hdr;
120   tNFA_DTA_DATA_TYPE type;
121   union {
122     tNFA_DTA_RW_DATA rw;
123     tNFA_DTA_CE_DATA ce;
124     tNFA_DTA_NFCDEP_DATA nfcdep;
125     tNFA_DTA_LLCP_EVT llcp_evt;
126   } data;
127 } tNFA_DTA_DATA_CBACK;
128 
129 /* All API message type */
130 typedef union {
131   NFC_HDR hdr;
132   tNFA_DTA_API_ENABLE enable;
133   tNFA_DTA_API_CONFIG cfg;
134   tNFA_DTA_API_START start;
135   tNFA_DTA_DATA_CBACK data_cback;
136 } tNFA_DTA_MSG;
137 
138 typedef uint8_t tNFA_DTA_STATE;
139 
140 typedef uint8_t tNFA_DTA_SUBSTATE;
141 
142 /*****************************************************************************
143 * DTA control block definitions
144 *****************************************************************************/
145 
146 /* NDEF buffer definitions */
147 enum {
148   NFA_DTA_BUF_MAX
149 };
150 
151 typedef struct {
152   uint8_t* p_data;
153   uint32_t max_size;
154   uint32_t cur_size;
155   uint32_t offset; /* current read/write offset */
156 } tNFA_DTA_BUF_CB;
157 
158 /* DTA test step command */
159 typedef tNFC_STATUS (*tNFA_DTA_CMD_FCN)(void*);
160 
161 /* DTA control block */
162 typedef struct {
163   uint32_t dta_flags; /* dta_flags must be first item in structure (statically
164                          intialized to 0 on startup) */
165 
166   /* Configuration */
167   tNFA_DTA_CONFIG cfg;
168 
169   /* DTA State Machine */
170   tNFA_DTA_STATE state;
171   tNFA_DTA_SUBSTATE substate; /* Current protocol-specific sub-state */
172   tNFA_DTA_CBACK* p_cback;    /* Applicatation for DTA event notification */
173 
174   /* DTA test parameters */
175   uint16_t pattern_number;
176   uint16_t pattern_number_old;
177 
178   /* Discovery Parameters */
179   uint8_t disc_state;
180   uint8_t disc_params_num;
181   tNFC_DISCOVER_PARAMS disc_params[NFA_DTA_DISCOVER_PARAMS_MAX];
182 
183   /* Activation parameters */
184   tNFC_ACTIVATE_DEVT activate_params;
185   uint8_t cur_protocol_rank; /* perference ranking of currently discovered
186                                 protocol */
187 
188   tRW_CBACK* p_rw_cback;
189   tCE_CBACK* p_ce_cback;
190 
191   TIMER_LIST_ENT
192   protocol_timer; /* timer for the activated protocol if needed */
193 
194   uint8_t t4t_ce_app; /* T4T listen mode test application */
195   tCE_T4T_AID_HANDLE
196       t4t_dta_aid_hdl; /* T4T registration handle for proprietary dta aid */
197   tCE_T4T_AID_HANDLE
198       t4t_prop_aid_hdl; /* T4T registration handle for proprietary aid */
199   uint8_t nfc_dep_wt;
200 
201   bool llcp_cl_more_to_read; /* TRUE if there is more to read in llcp cl link*/
202   bool llcp_co_more_to_read; /* TRUE if there is more to read in llcp recieve
203                                 window*/
204   bool llcp_is_initiator;    /* TURE if IUT is LLCP initiator */
205   uint16_t llcp_local_link_miu;  /* link MIU of IUT               */
206   uint16_t llcp_remote_link_miu; /* link MIU of LT                */
207 
208   uint8_t llcp_pattern_num_sap; /* SAP of pattern number exchange */
209 
210   uint8_t llcp_cl_in_local_sap;   /* SAP of IUT-CL-IN-DEST */
211   uint8_t llcp_cl_out_local_sap;  /* SAP of IUT-CL-OUT-SRC */
212   uint8_t llcp_cl_out_remote_sap; /* SAP of LT-CL-OUT-DEST */
213 
214   uint8_t llcp_co_in_local_sap;   /* SAP of IUT-CO-IN-DEST */
215   uint8_t llcp_co_in_remote_sap;  /* SAP of LT-CO-IN-SRC   */
216   uint8_t llcp_co_out_local_sap;  /* SAP of IUT-CO-OUT-SRC */
217   uint8_t llcp_co_out_remote_sap; /* SAP of LT-CO-OUT-DEST */
218 
219   uint16_t llcp_co_out_remote_miu; /* MIU of LT-CO-OUT-DEST */
220   uint8_t llcp_co_out_remote_rw;   /* RW of LT-CO-OUT-DEST  */
221 
222   uint8_t llcp_flags;      /* internal flags for LLCP echo test */
223   uint8_t llcp_sdp_tid_cl; /* SDP transaction ID for outbound connectionless */
224   uint8_t
225       llcp_sdp_tid_co; /* SDP transaction ID for outbound connection-oriented */
226 
227   TIMER_LIST_ENT llcp_cl_echo_timer; /* timer for the connectionless echo test
228                                         application      */
229   TIMER_LIST_ENT llcp_co_echo_timer; /* timer for the connection-oriented echo
230                                         test application */
231   BUFFER_Q
232   llcp_cl_buffer; /* buffer for the connectionless echo test application */
233   BUFFER_Q llcp_co_buffer; /* buffer for the connection-oriented echo test
234                               application*/
235 
236   tNFA_HANDLE snep_server_handle;
237   tNFA_HANDLE snep_server_conn_handle;
238   tNFA_HANDLE snep_client_handle;
239 
240   uint8_t* p_snep_short_ndef;
241   uint32_t snep_short_ndef_size;
242   uint8_t* p_snep_long_ndef;
243   uint32_t snep_long_ndef_size;
244 
245   /* DTA buffer for NDEF read/write */
246   tNFA_DTA_BUF_CB buf_cb[NFA_DTA_BUF_MAX];
247   uint32_t ndef_size; /* Size of NDEF message from NDEF detection */
248 
249   /* Scratch buffer for miscelaneous use */
250   uint8_t scratch_buf[NFA_DTA_SCRATCH_BUF_SIZE];
251 
252   /* DTA Test command table */
253   tNFA_DTA_CMD_FCN*
254       p_cur_cmd_tbl; /* Current table of commands for current test */
255   uint8_t cur_cmd_idx;
256 } tNFA_DTA_CB;
257 extern tNFA_DTA_CB nfa_dta_cb;
258 
259 /* NFA_SYS info for DTA */
260 extern const tNFA_SYS_REG nfa_dta_sys_reg;
261 
262 /* DTA startup setconfig parameters */
263 extern uint8_t* p_nfa_dta_start_up_cfg;
264 extern uint8_t nfa_dta_start_up_cfg_len;
265 
266 /*****************************************************************************
267 * DTA internal funciton protoytpes
268 *****************************************************************************/
269 
270 extern uint8_t* p_nfa_dta_brcm_start_up_cfg;
271 extern uint8_t nfa_dta_brcm_start_up_cfg_len;
272 extern uint8_t* p_nfa_dta_start_up_vsc_cfg;
273 
274 #endif /* (NFA_DTA_INCLUDED == TRUE) */
275 #endif /* NFA_DTA_INT_H */
276