• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 2010-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 EE.
22  *
23  ******************************************************************************/
24 #ifndef NFA_EE_INT_H
25 #define NFA_EE_INT_H
26 #include "nfa_ee_api.h"
27 #include "nfa_sys.h"
28 #include "nfc_api.h"
29 
30 /*****************************************************************************
31 **  Constants and data types
32 *****************************************************************************/
33 /* the number of tNFA_EE_ECBs (for NFCEEs and DH) */
34 #define NFA_EE_NUM_ECBS (NFA_EE_MAX_EE_SUPPORTED + 1)
35 /* The index for DH in nfa_ee_cb.ee_cb[] */
36 #define NFA_EE_CB_4_DH NFA_EE_MAX_EE_SUPPORTED
37 #define NFA_EE_INVALID 0xFF
38 /* only A, B, F, Bprime are supported by UICC now */
39 #define NFA_EE_MAX_TECH_ROUTE 4
40 
41 #ifndef NFA_EE_AID_CFG_TAG_NAME
42 /* AID                             */
43 #define NFA_EE_AID_CFG_TAG_NAME 0x4F
44 #endif
45 
46 /* NFA EE events */
47 enum {
48   NFA_EE_API_DISCOVER_EVT = NFA_SYS_EVT_START(NFA_ID_EE),
49   NFA_EE_API_REGISTER_EVT,
50   NFA_EE_API_DEREGISTER_EVT,
51   NFA_EE_API_MODE_SET_EVT,
52   NFA_EE_API_SET_TECH_CFG_EVT,
53   NFA_EE_API_CLEAR_TECH_CFG_EVT,
54   NFA_EE_API_SET_PROTO_CFG_EVT,
55   NFA_EE_API_CLEAR_PROTO_CFG_EVT,
56   NFA_EE_API_ADD_AID_EVT,
57   NFA_EE_API_REMOVE_AID_EVT,
58   NFA_EE_API_ADD_SYSCODE_EVT,
59   NFA_EE_API_REMOVE_SYSCODE_EVT,
60   NFA_EE_API_LMRT_SIZE_EVT,
61   NFA_EE_API_UPDATE_NOW_EVT,
62   NFA_EE_API_CONNECT_EVT,
63   NFA_EE_API_SEND_DATA_EVT,
64   NFA_EE_API_DISCONNECT_EVT,
65   NFA_EE_API_CLEAR_ROUTING_TABLE_EVT,
66   NFA_EE_API_PWR_AND_LINK_CTRL_EVT,
67 
68   NFA_EE_NCI_DISC_RSP_EVT,
69   NFA_EE_NCI_DISC_NTF_EVT,
70   NFA_EE_NCI_MODE_SET_RSP_EVT,
71   NFA_EE_NCI_CONN_EVT,
72   NFA_EE_NCI_DATA_EVT,
73   NFA_EE_NCI_ACTION_NTF_EVT,
74   NFA_EE_NCI_DISC_REQ_NTF_EVT,
75   NFA_EE_NCI_WAIT_RSP_EVT,
76 
77   NFA_EE_ROUT_TIMEOUT_EVT,
78   NFA_EE_DISCV_TIMEOUT_EVT,
79   NFA_EE_CFG_TO_NFCC_EVT,
80   NFA_EE_NCI_NFCEE_STATUS_NTF_EVT,
81   NFA_EE_PWR_CONTROL_EVT,
82   NFA_EE_MAX_EVT
83 };
84 
85 typedef uint16_t tNFA_EE_INT_EVT;
86 /* for listen mode routing table*/
87 #define NFA_EE_AE_ROUTE 0x80
88 #define NFA_EE_AE_VS 0x40
89 
90 /* NFA EE Management state */
91 enum {
92   NFA_EE_EM_STATE_INIT = 0,
93   NFA_EE_EM_STATE_INIT_DONE,
94   NFA_EE_EM_STATE_RESTORING,
95   NFA_EE_EM_STATE_DISABLING,
96   NFA_EE_EM_STATE_DISABLED,
97 
98   NFA_EE_EM_STATE_MAX
99 };
100 typedef uint8_t tNFA_EE_EM_STATE;
101 
102 /* NFA EE connection status */
103 enum {
104   NFA_EE_CONN_ST_NONE, /* not connected */
105   NFA_EE_CONN_ST_WAIT, /* connection is initiated; waiting for ack */
106   NFA_EE_CONN_ST_CONN, /* connected; can send/receive data */
107   NFA_EE_CONN_ST_DISC  /* disconnecting; waiting for ack */
108 };
109 typedef uint8_t tNFA_EE_CONN_ST;
110 
111 #define NFA_EE_MAX_AID_CFG_LEN (510)
112 // Technology A/B/F reserved: 5*3 = 15
113 // Protocol ISODEP/NFCDEP/T3T reserved: 5*3 = 15
114 // Extends (APDU pattern/SC)reserved: 30
115 #define NFA_EE_MAX_PROTO_TECH_EXT_ROUTE_LEN 60
116 
117 #define NFA_EE_SYSTEM_CODE_LEN 02
118 #define NFA_EE_SYSTEM_CODE_TLV_SIZE 06
119 #define NFA_EE_MAX_SYSTEM_CODE_ENTRIES 10
120 #define NFA_EE_MAX_SYSTEM_CODE_CFG_LEN \
121   (NFA_EE_MAX_SYSTEM_CODE_ENTRIES * NFA_EE_SYSTEM_CODE_TLV_SIZE)
122 
123 /* NFA EE control block flags:
124  * use to indicate an API function has changed the configuration of the
125  * associated NFCEE
126  * The flags are cleared when the routing table/VS is updated */
127 /* technology routing changed         */
128 #define NFA_EE_ECB_FLAGS_TECH 0x02
129 /* protocol routing changed           */
130 #define NFA_EE_ECB_FLAGS_PROTO 0x04
131 /* AID routing changed                */
132 #define NFA_EE_ECB_FLAGS_AID 0x08
133 /* System Code routing changed        */
134 #define NFA_EE_ECB_FLAGS_SYSCODE 0x01
135 /* VS changed                         */
136 #define NFA_EE_ECB_FLAGS_VS 0x10
137 /* Restore related                    */
138 #define NFA_EE_ECB_FLAGS_RESTORE 0x20
139 /* routing flags changed              */
140 #define NFA_EE_ECB_FLAGS_ROUTING 0x0E
141 /* NFCEE Discover Request NTF is set  */
142 #define NFA_EE_ECB_FLAGS_DISC_REQ 0x40
143 /* DISC_REQ N reported before DISC N  */
144 #define NFA_EE_ECB_FLAGS_ORDER 0x80
145 typedef uint8_t tNFA_EE_ECB_FLAGS;
146 
147 /* part of tNFA_EE_STATUS; for internal use only  */
148 /* waiting for restore to full power mode to complete */
149 #define NFA_EE_STATUS_RESTORING 0x20
150 /* this bit is in ee_status for internal use only */
151 #define NFA_EE_STATUS_INT_MASK 0x20
152 #define NFA_EE_STATUS_MEP_MASK 0x40
153 
154 #define NFA_EMPTY_AID_TLV_LEN 0x02
155 
156 /* NFA-EE information for a particular NFCEE Entity (including DH) */
157 typedef struct {
158   tNFA_TECHNOLOGY_MASK
159       tech_switch_on; /* default routing - technologies switch_on  */
160   tNFA_TECHNOLOGY_MASK
161       tech_switch_off; /* default routing - technologies switch_off */
162   tNFA_TECHNOLOGY_MASK
163       tech_battery_off; /* default routing - technologies battery_off*/
164   tNFA_TECHNOLOGY_MASK
165       tech_screen_lock; /* default routing - technologies screen_lock*/
166   tNFA_TECHNOLOGY_MASK
167       tech_screen_off; /* default routing - technologies screen_off*/
168   tNFA_TECHNOLOGY_MASK
169       tech_screen_off_lock; /* default routing - technologies screen_off_lock*/
170   tNFA_PROTOCOL_MASK
171       proto_switch_on; /* default routing - protocols switch_on     */
172   tNFA_PROTOCOL_MASK
173       proto_switch_off; /* default routing - protocols switch_off    */
174   tNFA_PROTOCOL_MASK
175       proto_battery_off;     /* default routing - protocols battery_off   */
176   tNFA_PROTOCOL_MASK
177       proto_screen_lock; /* default routing - protocols screen_lock    */
178   tNFA_PROTOCOL_MASK
179       proto_screen_off; /* default routing - protocols screen_off  */
180   tNFA_PROTOCOL_MASK
181       proto_screen_off_lock; /* default routing - protocols screen_off_lock  */
182   tNFA_EE_CONN_ST conn_st;   /* connection status */
183   uint8_t conn_id;           /* connection id */
184   tNFA_EE_CBACK* p_ee_cback; /* the callback function */
185 
186   /* Each AID entry has an ssociated aid_len, aid_pwr_cfg, aid_rt_info.
187    * aid_cfg[] contains AID and maybe some other VS information in TLV format
188    * The first T is always NFA_EE_AID_CFG_TAG_NAME, the L is the actual AID
189    * length
190    * the aid_len is the total length of all the TLVs associated with this AID
191    * entry
192    */
193   uint8_t* aid_len;     /* the actual lengths in aid_cfg */
194   uint8_t* aid_pwr_cfg; /* power configuration of this
195                                                   AID entry */
196   uint8_t* aid_rt_info; /* route/vs info for this AID
197                                                   entry */
198   uint8_t* aid_cfg;     /* routing entries based on AID */
199   uint8_t* aid_info;    /* Aid Info Prefix/Suffix/Exact */
200 
201   uint8_t aid_entries;   /* The number of AID entries in aid_cfg */
202   uint8_t nfcee_id;      /* ID for this NFCEE */
203   uint8_t ee_status;     /* The NFCEE status */
204   uint8_t ee_old_status; /* The NFCEE status before going to low power mode */
205   tNFA_EE_INTERFACE
206       ee_interface[NFC_MAX_EE_INTERFACE]; /* NFCEE supported interface */
207   tNFA_EE_TLV ee_tlv[NFC_MAX_EE_TLVS];    /* the TLV */
208   uint8_t num_interface;                  /* number of Target interface */
209   uint8_t num_tlvs;                       /* number of TLVs */
210   uint8_t ee_power_supply_status;         /* power supply of NFCEE*/
211   tNFA_EE_ECB_FLAGS ecb_flags;            /* the flags of this control block */
212   tNFA_EE_INTERFACE use_interface; /* NFCEE interface used for the connection */
213   tNFA_NFC_PROTOCOL la_protocol;   /* Listen A protocol    */
214   tNFA_NFC_PROTOCOL lb_protocol;   /* Listen B protocol    */
215   tNFA_NFC_PROTOCOL lf_protocol;   /* Listen F protocol    */
216   tNFA_NFC_PROTOCOL lbp_protocol;  /* Listen B' protocol   */
217   uint8_t size_mask_proto;         /* the size for protocol routing */
218   uint8_t size_mask_tech;          /* the size for technology routing */
219   uint16_t size_aid; /* the size for aid routing */
220   /*System Code Based Routing Variables*/
221   uint8_t sys_code_cfg[NFA_EE_MAX_SYSTEM_CODE_ENTRIES * NFA_EE_SYSTEM_CODE_LEN];
222   uint8_t sys_code_pwr_cfg[NFA_EE_MAX_SYSTEM_CODE_ENTRIES];
223   uint8_t sys_code_rt_loc[NFA_EE_MAX_SYSTEM_CODE_ENTRIES];
224   uint8_t sys_code_rt_loc_vs_info[NFA_EE_MAX_SYSTEM_CODE_ENTRIES];
225   /* The number of SC entries in sys_code_cfg buffer*/
226   uint8_t sys_code_cfg_entries;
227   uint16_t size_sys_code; /* The size for system code routing */
228 } tNFA_EE_ECB;
229 
230 /* data type for Empty AID Index and ECB */
231 typedef struct {
232   tNFA_EE_ECB* p_cb;
233   uint16_t index;
234   bool addEmptyAidRoute;
235   int offset;
236 } tNFA_EE_EMPTY_AID_ECB;
237 
238 /* data type for NFA_EE_API_DISCOVER_EVT */
239 typedef struct {
240   NFC_HDR hdr;
241   tNFA_EE_CBACK* p_cback;
242 } tNFA_EE_API_DISCOVER;
243 
244 /* data type for NFA_EE_API_REGISTER_EVT */
245 typedef struct {
246   NFC_HDR hdr;
247   tNFA_EE_CBACK* p_cback;
248 } tNFA_EE_API_REGISTER;
249 
250 /* data type for NFA_EE_API_DEREGISTER_EVT */
251 typedef struct {
252   NFC_HDR hdr;
253   int index;
254 } tNFA_EE_API_DEREGISTER;
255 
256 /* data type for NFA_EE_API_MODE_SET_EVT */
257 typedef struct {
258   NFC_HDR hdr;
259   tNFA_EE_ECB* p_cb;
260   uint8_t nfcee_id;
261   uint8_t mode;
262 } tNFA_EE_API_MODE_SET;
263 
264 /* data type for NFA_EE_API_SET_TECH_CFG_EVT */
265 typedef struct {
266   NFC_HDR hdr;
267   tNFA_EE_ECB* p_cb;
268   uint8_t nfcee_id;
269   tNFA_TECHNOLOGY_MASK technologies_switch_on;
270   tNFA_TECHNOLOGY_MASK technologies_switch_off;
271   tNFA_TECHNOLOGY_MASK technologies_battery_off;
272   tNFA_TECHNOLOGY_MASK technologies_screen_lock;
273   tNFA_TECHNOLOGY_MASK technologies_screen_off;
274   tNFA_TECHNOLOGY_MASK technologies_screen_off_lock;
275 } tNFA_EE_API_SET_TECH_CFG, tNFA_EE_API_CLEAR_TECH_CFG;
276 
277 /* data type for NFA_EE_API_SET_PROTO_CFG_EVT */
278 typedef struct {
279   NFC_HDR hdr;
280   tNFA_EE_ECB* p_cb;
281   uint8_t nfcee_id;
282   tNFA_PROTOCOL_MASK protocols_switch_on;
283   tNFA_PROTOCOL_MASK protocols_switch_off;
284   tNFA_PROTOCOL_MASK protocols_battery_off;
285   tNFA_PROTOCOL_MASK protocols_screen_lock;
286   tNFA_PROTOCOL_MASK protocols_screen_off;
287   tNFA_PROTOCOL_MASK protocols_screen_off_lock;
288 } tNFA_EE_API_SET_PROTO_CFG, tNFA_EE_API_CLEAR_PROTO_CFG;
289 
290 /* data type for NFA_EE_API_ADD_AID_EVT */
291 typedef struct {
292   NFC_HDR hdr;
293   tNFA_EE_ECB* p_cb;
294   uint8_t nfcee_id;
295   uint8_t aid_len;
296   uint8_t* p_aid;
297   tNFA_EE_PWR_STATE power_state;
298   uint8_t aidInfo;
299 } tNFA_EE_API_ADD_AID;
300 
301 /* data type for NFA_EE_API_REMOVE_AID_EVT */
302 typedef struct {
303   NFC_HDR hdr;
304   uint8_t aid_len;
305   uint8_t* p_aid;
306 } tNFA_EE_API_REMOVE_AID;
307 
308 /* data type for NFA_EE_API_ADD_SYSCODE_EVT */
309 typedef struct {
310   NFC_HDR hdr;
311   tNFA_EE_ECB* p_cb;
312   uint8_t nfcee_id;
313   uint16_t syscode;
314   tNFA_EE_PWR_STATE power_state;
315 } tNFA_EE_API_ADD_SYSCODE;
316 
317 /* data type for NFA_EE_API_REMOVE_SYSCODE_EVT */
318 typedef struct {
319   NFC_HDR hdr;
320   uint16_t syscode;
321 } tNFA_EE_API_REMOVE_SYSCODE;
322 
323 /* data type for NFA_EE_API_LMRT_SIZE_EVT */
324 typedef NFC_HDR tNFA_EE_API_LMRT_SIZE;
325 
326 /* data type for NFA_EE_API_CONNECT_EVT */
327 typedef struct {
328   NFC_HDR hdr;
329   tNFA_EE_ECB* p_cb;
330   uint8_t nfcee_id;
331   uint8_t ee_interface;
332   tNFA_EE_CBACK* p_cback;
333 } tNFA_EE_API_CONNECT;
334 
335 /* data type for NFA_EE_API_SEND_DATA_EVT */
336 typedef struct {
337   NFC_HDR hdr;
338   tNFA_EE_ECB* p_cb;
339   uint8_t nfcee_id;
340   uint16_t data_len;
341   uint8_t* p_data;
342 } tNFA_EE_API_SEND_DATA;
343 
344 /* data type for NFA_EE_API_DISCONNECT_EVT */
345 typedef struct {
346   NFC_HDR hdr;
347   tNFA_EE_ECB* p_cb;
348   uint8_t nfcee_id;
349 } tNFA_EE_API_DISCONNECT;
350 
351 /* data type for NFA_EE_API_PWR_AND_LINK_CTRL_EVT */
352 typedef struct {
353   NFC_HDR hdr;
354   tNFA_EE_ECB* p_cb;
355   uint8_t nfcee_id;
356   uint8_t config;
357 } tNFA_EE_API_PWR_AND_LINK_CTRL;
358 
359 typedef struct {
360   NFC_HDR hdr;
361   tNFA_EE_ECB* p_cb;
362   bool clear_tech;
363   bool clear_proto;
364   bool clear_sc;
365 } tNFA_EE_API_CLEAR_ROUTING_TABLE;
366 
367 /* common data type for internal events with nfa_ee_use_cfg_cb[] as TRUE */
368 typedef struct {
369   NFC_HDR hdr;
370   tNFA_EE_ECB* p_cb;
371   uint8_t nfcee_id;
372 } tNFA_EE_CFG_HDR;
373 
374 /* data type for NFA_EE_NCI_DISC_RSP_EVT */
375 typedef struct {
376   NFC_HDR hdr;
377   tNFC_NFCEE_DISCOVER_REVT* p_data;
378 } tNFA_EE_NCI_DISC_RSP;
379 
380 /* data type for NFA_EE_NCI_DISC_NTF_EVT */
381 typedef struct {
382   NFC_HDR hdr;
383   tNFC_NFCEE_INFO_REVT* p_data;
384 } tNFA_EE_NCI_DISC_NTF;
385 
386 /* data type for NFA_EE_NCI_MODE_SET_RSP_EVT */
387 typedef struct {
388   NFC_HDR hdr;
389   tNFC_NFCEE_MODE_SET_REVT* p_data;
390 } tNFA_EE_NCI_MODE_SET;
391 
392 /* data type for NFA_EE_NCI_WAIT_RSP_EVT */
393 typedef struct {
394   NFC_HDR hdr;
395   void* p_data;
396   uint8_t opcode;
397 } tNFA_EE_NCI_WAIT_RSP;
398 
399 /* data type for NFA_EE_NCI_CONN_EVT and NFA_EE_NCI_DATA_EVT */
400 typedef struct {
401   NFC_HDR hdr;
402   uint8_t conn_id;
403   tNFC_CONN_EVT event;
404   tNFC_CONN* p_data;
405 } tNFA_EE_NCI_CONN;
406 
407 /* data type for NFA_EE_NCI_ACTION_NTF_EVT */
408 typedef struct {
409   NFC_HDR hdr;
410   tNFC_EE_ACTION_REVT* p_data;
411 } tNFA_EE_NCI_ACTION;
412 
413 /* data type for NFA_EE_NCI_DISC_REQ_NTF_EVT */
414 typedef struct {
415   NFC_HDR hdr;
416   tNFC_EE_DISCOVER_REQ_REVT* p_data;
417 } tNFA_EE_NCI_DISC_REQ;
418 
419 /* data type for NFA_EE_NCI_NFCEE_STATUS_EVT */
420 typedef struct {
421   NFC_HDR hdr;
422   tNFC_NFCEE_STATUS_REVT* p_data;
423 } tNFA_EE_NCI_NFCEE_STATUS_NTF;
424 
425 /* data type for NFA_EE_NCI_NFCEE_STATUS_EVT */
426 typedef struct {
427   NFC_HDR hdr;
428   tNFC_NFCEE_PL_CONTROL_REVT* p_data;
429 } tNFA_EE_NCI_PWR_AND_LINK_CTRL_RSP;
430 
431 /* union of all event data types */
432 typedef union {
433   NFC_HDR hdr;
434   tNFA_EE_CFG_HDR cfg_hdr;
435   tNFA_EE_API_DISCOVER ee_discover;
436   tNFA_EE_API_REGISTER ee_register;
437   tNFA_EE_API_DEREGISTER deregister;
438   tNFA_EE_API_MODE_SET mode_set;
439   tNFA_EE_API_SET_TECH_CFG set_tech;
440   tNFA_EE_API_CLEAR_TECH_CFG clear_tech;
441   tNFA_EE_API_SET_PROTO_CFG set_proto;
442   tNFA_EE_API_CLEAR_PROTO_CFG clear_proto;
443   tNFA_EE_API_ADD_AID add_aid;
444   tNFA_EE_API_REMOVE_AID rm_aid;
445   tNFA_EE_API_ADD_SYSCODE add_syscode;
446   tNFA_EE_API_REMOVE_SYSCODE rm_syscode;
447   tNFA_EE_API_LMRT_SIZE lmrt_size;
448   tNFA_EE_API_CONNECT connect;
449   tNFA_EE_API_SEND_DATA send_data;
450   tNFA_EE_API_DISCONNECT disconnect;
451   tNFA_EE_API_CLEAR_ROUTING_TABLE clear_routing_table;
452   tNFA_EE_API_PWR_AND_LINK_CTRL pwr_and_link_ctrl;
453   tNFA_EE_NCI_DISC_RSP disc_rsp;
454   tNFA_EE_NCI_DISC_NTF disc_ntf;
455   tNFA_EE_NCI_MODE_SET mode_set_rsp;
456   tNFA_EE_NCI_WAIT_RSP wait_rsp;
457   tNFA_EE_NCI_CONN conn;
458   tNFA_EE_NCI_ACTION act;
459   tNFA_EE_NCI_DISC_REQ disc_req;
460   tNFA_EE_NCI_NFCEE_STATUS_NTF nfcee_status_ntf;
461   tNFA_EE_NCI_PWR_AND_LINK_CTRL_RSP ncfee_pwr_and_link_ctrl_rsp;
462 } tNFA_EE_MSG;
463 
464 /* type for State Machine (SM) action functions */
465 typedef void (*tNFA_EE_SM_ACT)(tNFA_EE_MSG* p_data);
466 
467 /*****************************************************************************
468 **  control block
469 *****************************************************************************/
470 #define NFA_EE_CFGED_UPDATE_NOW 0x80
471 /* either switch off or battery off is configured */
472 #define NFA_EE_CFGED_OFF_ROUTING 0x40
473 
474 /* the following status are the definition used in ee_cfg_sts */
475 #define NFA_EE_STS_CHANGED_ROUTING 0x01
476 #define NFA_EE_STS_CHANGED 0x0f
477 #define NFA_EE_STS_PREV_ROUTING 0x10
478 #define NFA_EE_STS_PREV 0xf0
479 
480 /* need to report NFA_EE_UPDATED_EVT */
481 #define NFA_EE_WAIT_UPDATE 0x10
482 /* waiting for the rsp of set routing commands */
483 #define NFA_EE_WAIT_UPDATE_RSP 0x20
484 #define NFA_EE_WAIT_UPDATE_ALL 0xF0
485 
486 typedef uint8_t tNFA_EE_WAIT;
487 
488 /* set this bit when waiting for HCI to finish the initialization process in
489  * NFA_EE_EM_STATE_RESTORING */
490 #define NFA_EE_FLAG_WAIT_HCI 0x01
491 /* set this bit when EE needs to notify the p_enable_cback at the end of NFCEE
492  * discover process in NFA_EE_EM_STATE_RESTORING */
493 #define NFA_EE_FLAG_NOTIFY_HCI 0x02
494 /* set this bit when gracefully disable with outstanding NCI connections */
495 #define NFA_EE_FLAG_WAIT_DISCONN 0x04
496 typedef uint8_t tNFA_EE_FLAGS;
497 
498 /* NFCEE DISCOVER in progress       */
499 #define NFA_EE_DISC_STS_ON 0x00
500 /* disable NFCEE DISCOVER           */
501 #define NFA_EE_DISC_STS_OFF 0x01
502 /* received NFCEE DISCOVER REQ NTF  */
503 #define NFA_EE_DISC_STS_REQ 0x02
504 /* received NFA_EE_MODE_SET_COMPLETE  */
505 #define NFA_EE_MODE_SET_COMPLETE 0x03
506 /* initialize EE_RECOVERY             */
507 #define NFA_EE_RECOVERY_INIT 0x04
508 /* update ee config during EE_RECOVERY */
509 #define NFA_EE_RECOVERY_REDISCOVERED 0x05
510 typedef uint8_t tNFA_EE_DISC_STS;
511 
512 typedef void(tNFA_EE_ENABLE_DONE_CBACK)(tNFA_EE_DISC_STS status);
513 
514 /* NFA EE Management control block */
515 typedef struct {
516   tNFA_EE_ECB ecb[NFA_EE_NUM_ECBS]; /* control block for DH and NFCEEs  */
517   TIMER_LIST_ENT timer;             /* timer to send info to NFCC       */
518   TIMER_LIST_ENT discv_timer;       /* timer to end NFCEE discovery     */
519   tNFA_EE_CBACK* p_ee_cback[NFA_EE_MAX_CBACKS]; /* to report EE events       */
520   tNFA_EE_CBACK* p_ee_disc_cback; /* to report EE discovery result    */
521   tNFA_EE_ENABLE_DONE_CBACK*
522       p_enable_cback;          /* callback to notify on enable done*/
523   tNFA_EE_EM_STATE em_state;   /* NFA-EE state initialized or not  */
524   uint8_t wait_rsp;            /* num of NCI rsp expected (update) */
525   uint8_t num_ee_expecting;    /* number of ee_info still expecting*/
526   uint8_t cur_ee;              /* the number of ee_info in cb      */
527   uint8_t ee_cfged;            /* the bit mask of configured ECBs  */
528   uint8_t ee_cfg_sts;          /* configuration status             */
529   tNFA_EE_WAIT ee_wait_evt;    /* Pending event(s) to be reported  */
530   tNFA_EE_FLAGS ee_flags;      /* flags                            */
531   uint8_t route_block_control; /* controls route block feature   */
532   bool isDiscoveryStopped;     /* discovery status                  */
533   uint8_t nfcee_id;            /* NFCEE ID */
534   uint8_t mode;                /* Mode */
535 } tNFA_EE_CB;
536 
537 /* Order of Routing entries in Routing Table */
538 #define NCI_ROUTE_ORDER_AID 0x01        /* AID routing order */
539 #define NCI_ROUTE_ORDER_SYS_CODE 0x03   /* System Code routing order*/
540 #define NCI_ROUTE_ORDER_PROTOCOL 0x04   /* Protocol routing order*/
541 #define NCI_ROUTE_ORDER_TECHNOLOGY 0x05 /* Technology routing order*/
542 
543 /*****************************************************************************
544 **  External variables
545 *****************************************************************************/
546 
547 /* NFA EE control block */
548 extern tNFA_EE_CB nfa_ee_cb;
549 
550 /*****************************************************************************
551 **  External functions
552 *****************************************************************************/
553 /* function prototypes - exported from nfa_ee_main.c */
554 void nfa_ee_sys_enable(void);
555 void nfa_ee_sys_disable(void);
556 
557 /* event handler function type */
558 bool nfa_ee_evt_hdlr(NFC_HDR* p_msg);
559 void nfa_ee_proc_nfcc_power_mode(uint8_t nfcc_power_mode);
560 #if (NFC_NFCEE_INCLUDED == TRUE)
561 void nfa_ee_get_tech_route(uint8_t power_state, uint8_t* p_handles);
562 #endif
563 void nfa_ee_proc_evt(tNFC_RESPONSE_EVT event, void* p_data);
564 tNFA_EE_ECB* nfa_ee_find_ecb(uint8_t nfcee_id);
565 tNFA_EE_ECB* nfa_ee_add_mep_ecb(uint8_t nfcee_id);
566 tNFA_EE_ECB* nfa_ee_find_ecb_by_conn_id(uint8_t conn_id);
567 uint8_t nfa_ee_ecb_to_mask(tNFA_EE_ECB* p_cb);
568 void nfa_ee_restore_one_ecb(tNFA_EE_ECB* p_cb);
569 bool nfa_ee_is_active(tNFA_HANDLE nfcee_id);
570 
571 /* Action function prototypes - nfa_ee_act.c */
572 void nfa_ee_api_discover(tNFA_EE_MSG* p_data);
573 void nfa_ee_api_register(tNFA_EE_MSG* p_data);
574 void nfa_ee_api_deregister(tNFA_EE_MSG* p_data);
575 void nfa_ee_api_mode_set(tNFA_EE_MSG* p_data);
576 void nfa_ee_api_set_tech_cfg(tNFA_EE_MSG* p_data);
577 void nfa_ee_api_clear_tech_cfg(tNFA_EE_MSG* p_data);
578 void nfa_ee_api_set_proto_cfg(tNFA_EE_MSG* p_data);
579 void nfa_ee_api_clear_proto_cfg(tNFA_EE_MSG* p_data);
580 void nfa_ee_api_add_aid(tNFA_EE_MSG* p_data);
581 void nfa_ee_api_remove_aid(tNFA_EE_MSG* p_data);
582 void nfa_ee_api_add_sys_code(tNFA_EE_MSG* p_data);
583 void nfa_ee_api_remove_sys_code(tNFA_EE_MSG* p_data);
584 void nfa_ee_api_lmrt_size(tNFA_EE_MSG* p_data);
585 void nfa_ee_api_update_now(tNFA_EE_MSG* p_data);
586 void nfa_ee_api_connect(tNFA_EE_MSG* p_data);
587 void nfa_ee_api_send_data(tNFA_EE_MSG* p_data);
588 void nfa_ee_api_disconnect(tNFA_EE_MSG* p_data);
589 void nfa_ee_api_clear_routing_table(tNFA_EE_MSG* p_data);
590 void nfa_ee_api_pwr_and_link_ctrl(tNFA_EE_MSG* p_data);
591 void nfa_ee_report_disc_done(bool notify_sys);
592 void nfa_ee_nci_disc_rsp(tNFA_EE_MSG* p_data);
593 void nfa_ee_nci_disc_ntf(tNFA_EE_MSG* p_data);
594 void nfa_ee_nci_mode_set_rsp(tNFA_EE_MSG* p_data);
595 void nfa_ee_nci_nfcee_status_ntf(tNFA_EE_MSG* p_data);
596 void nfa_ee_pwr_and_link_ctrl_rsp(tNFA_EE_MSG* p_data);
597 void nfa_ee_nci_wait_rsp(tNFA_EE_MSG* p_data);
598 void nfa_ee_nci_conn(tNFA_EE_MSG* p_data);
599 void nfa_ee_nci_action_ntf(tNFA_EE_MSG* p_data);
600 void nfa_ee_nci_disc_req_ntf(tNFA_EE_MSG* p_data);
601 void nfa_ee_rout_timeout(tNFA_EE_MSG* p_data);
602 void nfa_ee_discv_timeout(tNFA_EE_MSG* p_data);
603 void nfa_ee_lmrt_to_nfcc(tNFA_EE_MSG* p_data);
604 void nfa_ee_update_rout(void);
605 void nfa_ee_report_event(tNFA_EE_CBACK* p_cback, tNFA_EE_EVT event,
606                          tNFA_EE_CBACK_DATA* p_data);
607 tNFA_EE_ECB* nfa_ee_find_aid_offset(uint8_t aid_len, uint8_t* p_aid,
608                                     int* p_offset, int* p_entry);
609 tNFA_EE_ECB* nfa_ee_find_sys_code_offset(uint16_t sys_code, int* p_offset,
610                                          int* p_entry);
611 int nfa_ee_find_total_aid_len(tNFA_EE_ECB* p_cb, int start_entry);
612 void nfa_ee_start_timer(void);
613 void nfa_ee_reg_cback_enable_done(tNFA_EE_ENABLE_DONE_CBACK* p_cback);
614 void nfa_ee_report_update_evt(void);
615 
616 extern void nfa_ee_proc_hci_info_cback(void);
617 void nfa_ee_check_disable(void);
618 bool nfa_ee_restore_ntf_done(void);
619 void nfa_ee_check_restore_complete(void);
620 int nfa_ee_find_max_aid_cfg_len(void);
621 #endif /* NFA_P2P_INT_H */
622