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