nfa_dm_int.h revision c95c79ccb65d82a65b960919077d5c359cf28ced
1/******************************************************************************
2 *
3 *  Copyright (C) 2003-2013 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 *
22 *  This is the private interface file for the NFA device manager.
23 *
24 ******************************************************************************/
25#ifndef NFA_DM_INT_H
26#define NFA_DM_INT_H
27
28#include "nfc_api.h"
29#include "nfa_api.h"
30
31
32/*****************************************************************************
33**  Constants and data types
34*****************************************************************************/
35
36/* DM events */
37enum
38{
39    /* device manager local device API events */
40    NFA_DM_API_ENABLE_EVT           = NFA_SYS_EVT_START (NFA_ID_DM),
41    NFA_DM_API_DISABLE_EVT,
42    NFA_DM_API_SET_CONFIG_EVT,
43    NFA_DM_API_GET_CONFIG_EVT,
44    NFA_DM_API_REQUEST_EXCL_RF_CTRL_EVT,
45    NFA_DM_API_RELEASE_EXCL_RF_CTRL_EVT,
46    NFA_DM_API_ENABLE_POLLING_EVT,
47    NFA_DM_API_DISABLE_POLLING_EVT,
48    NFA_DM_API_RAW_FRAME_EVT,
49    NFA_DM_API_SET_P2P_LISTEN_TECH_EVT,
50    NFA_DM_API_START_RF_DISCOVERY_EVT,
51    NFA_DM_API_STOP_RF_DISCOVERY_EVT,
52    NFA_DM_API_SET_RF_DISC_DURATION_EVT,
53    NFA_DM_API_SELECT_EVT,
54    NFA_DM_API_UPDATE_RF_PARAMS_EVT,
55    NFA_DM_API_DEACTIVATE_EVT,
56    NFA_DM_API_POWER_OFF_SLEEP_EVT,
57    NFA_DM_API_REG_NDEF_HDLR_EVT,
58    NFA_DM_API_DEREG_NDEF_HDLR_EVT,
59    NFA_DM_API_REG_VSC_EVT,
60    NFA_DM_API_SEND_VSC_EVT,
61    NFA_DM_TIMEOUT_DISABLE_EVT,
62    NFA_DM_MAX_EVT
63};
64
65
66/* data type for NFA_DM_API_ENABLE_EVT */
67typedef struct
68{
69    BT_HDR                  hdr;
70    tNFA_DM_CBACK           *p_dm_cback;
71    tNFA_CONN_CBACK         *p_conn_cback;
72} tNFA_DM_API_ENABLE;
73
74/* data type for NFA_DM_API_DISABLE_EVT */
75typedef struct
76{
77    BT_HDR              hdr;
78    BOOLEAN             graceful;
79} tNFA_DM_API_DISABLE;
80
81/* data type for NFA_DM_API_SET_CONFIG_EVT */
82typedef struct
83{
84    BT_HDR              hdr;
85    tNFA_PMID           param_id;
86    UINT8               length;
87    UINT8              *p_data;
88} tNFA_DM_API_SET_CONFIG;
89
90/* data type for NFA_DM_API_GET_CONFIG_EVT */
91typedef struct
92{
93    BT_HDR              hdr;
94    UINT8               num_ids;
95    tNFA_PMID          *p_pmids;
96} tNFA_DM_API_GET_CONFIG;
97
98/* data type for NFA_DM_API_REQ_EXCL_RF_CTRL_EVT */
99typedef struct
100{
101    BT_HDR               hdr;
102    tNFA_TECHNOLOGY_MASK poll_mask;
103    tNFA_LISTEN_CFG      listen_cfg;
104    tNFA_CONN_CBACK     *p_conn_cback;
105    tNFA_NDEF_CBACK     *p_ndef_cback;
106} tNFA_DM_API_REQ_EXCL_RF_CTRL;
107
108/* data type for NFA_DM_API_ENABLE_POLLING_EVT */
109typedef struct
110{
111    BT_HDR               hdr;
112    tNFA_TECHNOLOGY_MASK poll_mask;
113} tNFA_DM_API_ENABLE_POLL;
114
115/* data type for NFA_DM_API_SET_P2P_LISTEN_TECH_EVT */
116typedef struct
117{
118    BT_HDR                  hdr;
119    tNFA_TECHNOLOGY_MASK    tech_mask;
120} tNFA_DM_API_SET_P2P_LISTEN_TECH;
121
122/* data type for NFA_DM_API_SELECT_EVT */
123typedef struct
124{
125    BT_HDR              hdr;
126    UINT8               rf_disc_id;
127    tNFA_NFC_PROTOCOL   protocol;
128    tNFA_INTF_TYPE      rf_interface;
129} tNFA_DM_API_SELECT;
130
131/* data type for NFA_DM_API_UPDATE_RF_PARAMS_EVT */
132typedef struct
133{
134    BT_HDR              hdr;
135    tNFA_RF_COMM_PARAMS params;
136} tNFA_DM_API_UPDATE_RF_PARAMS;
137
138/* data type for NFA_DM_API_DEACTIVATE_EVT */
139typedef struct
140{
141    BT_HDR              hdr;
142    BOOLEAN             sleep_mode;
143} tNFA_DM_API_DEACTIVATE;
144
145/* data type for NFA_DM_API_SET_RF_DISC_DURATION_EVT */
146typedef struct
147{
148    BT_HDR              hdr;
149    UINT16              rf_disc_dur_ms;
150} tNFA_DM_API_SET_RF_DISC_DUR;
151#define NFA_RF_DISC_DURATION_MAX                0xFFFF
152
153/* data type for NFA_DM_API_REG_NDEF_HDLR_EVT */
154#define NFA_NDEF_FLAGS_HANDLE_WHOLE_MESSAGE     0x01
155#define NFA_NDEF_FLAGS_WKT_URI                  0x02
156#define NFA_NDEF_FLAGS_WHOLE_MESSAGE_NOTIFIED   0x04
157
158typedef struct
159{
160    BT_HDR              hdr;
161    tNFA_HANDLE         ndef_type_handle;
162    UINT8               flags;
163    tNFA_NDEF_CBACK    *p_ndef_cback;
164    tNFA_TNF            tnf;                /* Type-name field of record-type that was registered.                  */
165    tNFA_NDEF_URI_ID    uri_id;             /* URI prefix abrieviation (for NFA_RegisterNDefUriHandler)             */
166    UINT8               name_len;           /* Length of type name or absolute URI                                  */
167    UINT8               name[1];            /* Type name or absolute URI of record-type that got was registered.    */
168} tNFA_DM_API_REG_NDEF_HDLR;
169
170/* data type for NFA_DM_API_DEREG_NDEF_HDLR_EVT */
171typedef struct
172{
173    BT_HDR      hdr;
174    tNFA_HANDLE ndef_type_handle;
175} tNFA_DM_API_DEREG_NDEF_HDLR;
176
177/* data type for NFA_DM_API_REG_VSC_EVT */
178typedef struct
179{
180    BT_HDR          hdr;
181    tNFA_VSC_CBACK  *p_cback;
182    BOOLEAN         is_register;
183} tNFA_DM_API_REG_VSC;
184
185/* data type for NFA_DM_API_SEND_VSC_EVT */
186typedef struct
187{
188    BT_HDR          hdr;
189    tNFA_VSC_CBACK  *p_cback;
190    UINT8           oid;
191    UINT8           cmd_params_len;
192    UINT16          pad;    /* add padding to ensure the size is big enough for offset=NCI_VSC_MSG_HDR_SIZE */
193    UINT8           *p_cmd_params;
194} tNFA_DM_API_SEND_VSC;
195
196
197/* union of all data types */
198typedef union
199{
200    /* GKI event buffer header */
201    BT_HDR                          hdr;                /* NFA_DM_API_RAW_FRAME_EVT             */
202                                                        /* NFA_DM_API_MULTI_TECH_RSP_EVT        */
203                                                        /* NFA_DM_API_RELEASE_EXCL_RF_CTRL      */
204                                                        /* NFA_DM_API_DISABLE_POLLING_EVT       */
205                                                        /* NFA_DM_API_START_RF_DISCOVERY_EVT    */
206                                                        /* NFA_DM_API_STOP_RF_DISCOVERY_EVT     */
207    tNFA_DM_API_ENABLE              enable;             /* NFA_DM_API_ENABLE_EVT                */
208    tNFA_DM_API_DISABLE             disable;            /* NFA_DM_API_DISABLE_EVT               */
209    tNFA_DM_API_SET_CONFIG          setconfig;          /* NFA_DM_API_SET_CONFIG_EVT            */
210    tNFA_DM_API_GET_CONFIG          getconfig;          /* NFA_DM_API_GET_CONFIG_EVT            */
211    tNFA_DM_API_SET_RF_DISC_DUR     disc_duration;      /* NFA_DM_API_SET_RF_DISC_DURATION_EVT  */
212    tNFA_DM_API_REG_NDEF_HDLR       reg_ndef_hdlr;      /* NFA_DM_API_REG_NDEF_HDLR_EVT         */
213    tNFA_DM_API_DEREG_NDEF_HDLR     dereg_ndef_hdlr;    /* NFA_DM_API_DEREG_NDEF_HDLR_EVT       */
214    tNFA_DM_API_REQ_EXCL_RF_CTRL    req_excl_rf_ctrl;   /* NFA_DM_API_REQUEST_EXCL_RF_CTRL      */
215    tNFA_DM_API_ENABLE_POLL         enable_poll;        /* NFA_DM_API_ENABLE_POLLING_EVT        */
216    tNFA_DM_API_SET_P2P_LISTEN_TECH set_p2p_listen_tech;/* NFA_DM_API_SET_P2P_LISTEN_TECH_EVT   */
217    tNFA_DM_API_SELECT              select;             /* NFA_DM_API_SELECT_EVT                */
218    tNFA_DM_API_UPDATE_RF_PARAMS    update_rf_params;   /* NFA_DM_API_UPDATE_RF_PARAMS_EVT      */
219    tNFA_DM_API_DEACTIVATE          deactivate;         /* NFA_DM_API_DEACTIVATE_EVT            */
220    tNFA_DM_API_SEND_VSC            send_vsc;           /* NFA_DM_API_SEND_VSC_EVT              */
221    tNFA_DM_API_REG_VSC             reg_vsc;            /* NFA_DM_API_REG_VSC_EVT               */
222} tNFA_DM_MSG;
223
224/* DM RF discovery state */
225enum
226{
227    NFA_DM_RFST_IDLE,               /* idle state                     */
228    NFA_DM_RFST_DISCOVERY,          /* discovery state                */
229    NFA_DM_RFST_W4_ALL_DISCOVERIES, /* wait for all discoveries state */
230    NFA_DM_RFST_W4_HOST_SELECT,     /* wait for host selection state  */
231    NFA_DM_RFST_POLL_ACTIVE,        /* poll mode activated state      */
232    NFA_DM_RFST_LISTEN_ACTIVE,      /* listen mode activated state    */
233    NFA_DM_RFST_LISTEN_SLEEP,       /* listen mode sleep state        */
234    NFA_DM_RFST_LP_LISTEN,          /* Listening in Low Power mode    */
235    NFA_DM_RFST_LP_ACTIVE           /* Activated in Low Power mode    */
236};
237typedef UINT8 tNFA_DM_RF_DISC_STATE;
238
239/* DM RF discovery state machine event */
240enum
241{
242    NFA_DM_RF_DISCOVER_CMD,         /* start RF discovery                    */
243    NFA_DM_RF_DISCOVER_RSP,         /* discover response from NFCC           */
244    NFA_DM_RF_DISCOVER_NTF,         /* RF discovery NTF from NFCC            */
245    NFA_DM_RF_DISCOVER_SELECT_CMD,  /* select discovered target              */
246    NFA_DM_RF_DISCOVER_SELECT_RSP,  /* select response from NFCC             */
247    NFA_DM_RF_INTF_ACTIVATED_NTF,   /* RF interface activation NTF from NFCC */
248    NFA_DM_RF_DEACTIVATE_CMD,       /* deactivate RF interface               */
249    NFA_DM_RF_DEACTIVATE_RSP,       /* deactivate response from NFCC         */
250    NFA_DM_RF_DEACTIVATE_NTF,       /* deactivate RF interface NTF from NFCC */
251    NFA_DM_LP_LISTEN_CMD,           /* NFCC is listening in low power mode   */
252    NFA_DM_CORE_INTF_ERROR_NTF,     /* RF interface error NTF from NFCC      */
253    NFA_DM_DISC_SM_MAX_EVENT
254};
255typedef UINT8 tNFA_DM_RF_DISC_SM_EVENT;
256
257/* DM RF discovery state machine data */
258typedef struct
259{
260    UINT8               rf_disc_id;
261    tNFA_NFC_PROTOCOL   protocol;
262    tNFA_INTF_TYPE      rf_interface;
263} tNFA_DM_DISC_SELECT_PARAMS;
264
265typedef union
266{
267    tNFC_DISCOVER               nfc_discover;       /* discovery data from NFCC    */
268    tNFC_DEACT_TYPE             deactivate_type;    /* deactivation type           */
269    tNFA_DM_DISC_SELECT_PARAMS  select;             /* selected target information */
270} tNFA_DM_RF_DISC_DATA;
271
272/* Callback event from NFA DM RF Discovery to other NFA sub-modules */
273enum
274{
275    NFA_DM_RF_DISC_START_EVT,           /* discovery started with protocol, technology and mode       */
276    NFA_DM_RF_DISC_ACTIVATED_EVT,       /* activated with configured protocol, technology and mode    */
277    NFA_DM_RF_DISC_DEACTIVATED_EVT      /* deactivated sleep or idle                                  */
278};
279typedef UINT8 tNFA_DM_RF_DISC_EVT;
280
281/* Combined NFC Technology and protocol bit mask */
282#define NFA_DM_DISC_MASK_PA_T1T                 0x00000001
283#define NFA_DM_DISC_MASK_PA_T2T                 0x00000002
284#define NFA_DM_DISC_MASK_PA_ISO_DEP             0x00000004
285#define NFA_DM_DISC_MASK_PA_NFC_DEP             0x00000008
286#define NFA_DM_DISC_MASK_PB_ISO_DEP             0x00000010
287#define NFA_DM_DISC_MASK_PF_T3T                 0x00000020
288#define NFA_DM_DISC_MASK_PF_NFC_DEP             0x00000040
289#define NFA_DM_DISC_MASK_P_ISO15693             0x00000100
290#define NFA_DM_DISC_MASK_P_B_PRIME              0x00000200
291#define NFA_DM_DISC_MASK_P_KOVIO                0x00000400
292#define NFA_DM_DISC_MASK_PAA_NFC_DEP            0x00000800
293#define NFA_DM_DISC_MASK_PFA_NFC_DEP            0x00001000
294#define NFA_DM_DISC_MASK_P_LEGACY               0x00002000  /* Legacy/proprietary/non-NFC Forum protocol (e.g Shanghai transit card) */
295#define NFA_DM_DISC_MASK_POLL                   0x0000FFFF
296
297#define NFA_DM_DISC_MASK_LA_T1T                 0x00010000
298#define NFA_DM_DISC_MASK_LA_T2T                 0x00020000
299#define NFA_DM_DISC_MASK_LA_ISO_DEP             0x00040000
300#define NFA_DM_DISC_MASK_LA_NFC_DEP             0x00080000
301#define NFA_DM_DISC_MASK_LB_ISO_DEP             0x00100000
302#define NFA_DM_DISC_MASK_LF_T3T                 0x00200000
303#define NFA_DM_DISC_MASK_LF_NFC_DEP             0x00400000
304#define NFA_DM_DISC_MASK_L_ISO15693             0x01000000
305#define NFA_DM_DISC_MASK_L_B_PRIME              0x02000000
306#define NFA_DM_DISC_MASK_LAA_NFC_DEP            0x04000000
307#define NFA_DM_DISC_MASK_LFA_NFC_DEP            0x08000000
308#define NFA_DM_DISC_MASK_L_LEGACY               0x10000000
309#define NFA_DM_DISC_MASK_LISTEN                 0xFFFF0000
310
311typedef UINT32  tNFA_DM_DISC_TECH_PROTO_MASK;
312
313
314/* DM RF discovery host ID */
315#define NFA_DM_DISC_HOST_ID_DH          NFC_DH_ID
316typedef UINT8 tNFA_DM_DISC_HOST_ID;
317
318/* DM deactivation callback type */
319typedef void (tNFA_DISCOVER_CBACK) (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data);
320
321/* DM RF discovery action flags */
322#define NFA_DM_DISC_FLAGS_ENABLED        0x0001    /* RF discovery process has been started        */
323#define NFA_DM_DISC_FLAGS_STOPPING       0x0002    /* Stop RF discovery is pending                 */
324#define NFA_DM_DISC_FLAGS_DISABLING      0x0004    /* Disable NFA is pending                       */
325#define NFA_DM_DISC_FLAGS_CHECKING       0x0008    /* Sleep wakeup in progress                     */
326#define NFA_DM_DISC_FLAGS_NOTIFY         0x0010    /* Notify sub-module that discovery is starting */
327#define NFA_DM_DISC_FLAGS_W4_RSP         0x0020    /* command has been sent to NFCC in the state   */
328#define NFA_DM_DISC_FLAGS_W4_NTF         0x0040    /* wait for NTF before changing discovery state */
329
330typedef UINT16 tNFA_DM_DISC_FLAGS;
331
332/* DM Discovery control block */
333typedef struct
334{
335    BOOLEAN                         in_use;             /* TRUE if used          */
336    tNFA_DISCOVER_CBACK            *p_disc_cback;       /* discovery callback    */
337
338    tNFA_DM_DISC_FLAGS              disc_flags;         /* specific action flags */
339    tNFA_DM_DISC_HOST_ID            host_id;            /* DH or UICC1/UICC2     */
340    tNFA_DM_DISC_TECH_PROTO_MASK    requested_disc_mask;/* technology and protocol requested              */
341    tNFA_DM_DISC_TECH_PROTO_MASK    selected_disc_mask; /* technology and protocol waiting for activation */
342} tNFA_DM_DISC_ENTRY;
343
344#define NFA_DM_DISC_NUM_ENTRIES  8              /* polling, raw listen, P2P listen, NDEF CE, 2xVSE, 2xUICC */
345
346#define NFA_DM_MAX_DISC_PARAMS   16             /* max discovery technology parameters */
347
348/* index of listen mode routing table for technologies */
349enum {
350    NFA_DM_DISC_LRT_NFC_A,
351    NFA_DM_DISC_LRT_NFC_B,
352    NFA_DM_DISC_LRT_NFC_F,
353    NFA_DM_DISC_LRT_NFC_BP
354};
355
356/* SLP_REQ (HLTA) command */
357#define SLP_REQ_CMD     0x5000
358#define NFA_DM_MAX_TECH_ROUTE   4 /* NFA_EE_MAX_TECH_ROUTE. only A, B, F, Bprime are supported by UICC now */
359
360/* timeout for waiting deactivation NTF,
361** possible delay to send deactivate CMD if all credit wasn't returned
362** transport delay (1sec) and max RWT (5sec)
363*/
364#define NFA_DM_DISC_TIMEOUT_W4_DEACT_NTF            (NFC_DEACTIVATE_TIMEOUT*1000 + 6000)
365
366typedef struct
367{
368    UINT16                  disc_duration;          /* Disc duration                                    */
369    tNFA_DM_DISC_FLAGS      disc_flags;             /* specific action flags                            */
370    tNFA_DM_RF_DISC_STATE   disc_state;             /* RF discovery state                               */
371
372    tNFC_RF_TECH_N_MODE     activated_tech_mode;    /* activated technology and mode                    */
373    UINT8                   activated_rf_disc_id;   /* activated RF discovery ID                        */
374    tNFA_INTF_TYPE          activated_rf_interface; /* activated RF interface                           */
375    tNFA_NFC_PROTOCOL       activated_protocol;     /* activated protocol                               */
376    tNFA_HANDLE             activated_handle;       /* handle of activated sub-module                   */
377    UINT8                   activated_sel_res;      /* activated tag's SEL_RES response                 */
378
379    tNFA_DM_DISC_ENTRY      entry[NFA_DM_DISC_NUM_ENTRIES];
380
381    tNFA_DM_DISC_ENTRY      excl_disc_entry;        /* exclusive RF discovery                           */
382    tNFA_LISTEN_CFG         excl_listen_config;     /* listen cfg for exclusive-rf mode                 */
383
384    UINT8                   listen_RT[NFA_DM_MAX_TECH_ROUTE];/* Host ID for A, B, F, B' technology routing*/
385    tNFA_DM_DISC_TECH_PROTO_MASK    dm_disc_mask;   /* technology and protocol waiting for activation   */
386
387    TIMER_LIST_ENT          tle;                    /* timer for waiting deactivation NTF               */
388
389} tNFA_DM_DISC_CB;
390
391/* NDEF Type Handler Definitions */
392#define NFA_NDEF_DEFAULT_HANDLER_IDX    0           /* Default handler entry in ndef_handler table      */
393
394#define NFA_PARAM_ID_INVALID            0xFF
395
396/* Maximum number of pending SetConfigs */
397#define NFA_DM_SETCONFIG_PENDING_MAX            32
398
399/* NFA_DM flags */
400#define NFA_DM_FLAGS_DM_IS_ACTIVE               0x00000001  /* DM is enabled                                                        */
401#define NFA_DM_FLAGS_EXCL_RF_ACTIVE             0x00000002  /* Exclusive RF mode is active                                          */
402#define NFA_DM_FLAGS_POLLING_ENABLED            0x00000004  /* Polling is enabled (while not in exclusive RF mode                   */
403#define NFA_DM_FLAGS_SEND_POLL_STOP_EVT         0x00000008  /* send poll stop event                                                 */
404#define NFA_DM_FLAGS_AUTO_READING_NDEF          0x00000010  /* auto reading of NDEF in progress                                     */
405#define NFA_DM_FLAGS_ENABLE_EVT_PEND            0x00000020  /* NFA_DM_ENABLE_EVT is not reported yet                                */
406#define NFA_DM_FLAGS_SEND_DEACTIVATED_EVT       0x00000040  /* Send NFA_DEACTIVATED_EVT when deactivated                            */
407#define NFA_DM_FLAGS_NFCC_IS_RESTORING          0x00000100  /* NFCC is restoring after back to full power mode                      */
408#define NFA_DM_FLAGS_SETTING_PWR_MODE           0x00000200  /* NFCC power mode is updating                                          */
409#define NFA_DM_FLAGS_DM_DISABLING_NFC           0x00000400  /* NFA DM is disabling NFC                                              */
410/* stored parameters */
411typedef struct
412{
413    UINT8 total_duration[NCI_PARAM_LEN_TOTAL_DURATION];
414
415    UINT8 la_bit_frame_sdd[NCI_PARAM_LEN_LA_BIT_FRAME_SDD];
416    UINT8 la_bit_frame_sdd_len;
417    UINT8 la_platform_config[NCI_PARAM_LEN_LA_PLATFORM_CONFIG];
418    UINT8 la_platform_config_len;
419    UINT8 la_sel_info[NCI_PARAM_LEN_LA_SEL_INFO];
420    UINT8 la_sel_info_len;
421    UINT8 la_nfcid1[NCI_NFCID1_MAX_LEN];
422    UINT8 la_nfcid1_len;
423    UINT8 la_hist_by[NCI_MAX_HIS_BYTES_LEN];
424    UINT8 la_hist_by_len;
425
426    UINT8 lb_sensb_info[NCI_PARAM_LEN_LB_SENSB_INFO];
427    UINT8 lb_sensb_info_len;
428    UINT8 lb_nfcid0[NCI_PARAM_LEN_LB_NFCID0];
429    UINT8 lb_nfcid0_len;
430    UINT8 lb_appdata[NCI_PARAM_LEN_LB_APPDATA];
431    UINT8 lb_appdata_len;
432    UINT8 lb_adc_fo[NCI_PARAM_LEN_LB_ADC_FO];
433    UINT8 lb_adc_fo_len;
434    UINT8 lb_h_info[NCI_MAX_ATTRIB_LEN];
435    UINT8 lb_h_info_len;
436
437    UINT8 lf_protocol[NCI_PARAM_LEN_LF_PROTOCOL];
438    UINT8 lf_protocol_len;
439    UINT8 lf_t3t_flags2[NCI_PARAM_LEN_LF_T3T_FLAGS2];
440    UINT8 lf_t3t_flags2_len;
441    UINT8 lf_t3t_pmm[NCI_PARAM_LEN_LF_T3T_PMM];
442    UINT8 lf_t3t_id[NFA_CE_LISTEN_INFO_MAX][NCI_PARAM_LEN_LF_T3T_ID];
443
444    UINT8 fwi[NCI_PARAM_LEN_FWI];
445    UINT8 wt[NCI_PARAM_LEN_WT];
446    UINT8 atr_req_gen_bytes[NCI_MAX_GEN_BYTES_LEN];
447    UINT8 atr_req_gen_bytes_len;
448    UINT8 atr_res_gen_bytes[NCI_MAX_GEN_BYTES_LEN];
449    UINT8 atr_res_gen_bytes_len;
450} tNFA_DM_PARAMS;
451
452/* DM control block */
453typedef struct
454{
455    UINT32                      flags;              /* NFA_DM flags (see definitions for NFA_DM_FLAGS_*)    */
456    tNFA_DM_CBACK              *p_dm_cback;         /* NFA DM callback                                      */
457    TIMER_LIST_ENT              tle;
458
459    BOOLEAN                     sleep_wakeup_deact_pending; /* TRUE if deactivate while checking presence */
460    tNFA_DEACTIVATE_TYPE        sleep_wakeup_deact_type;    /* deactivate type                            */
461
462    /* NFC link connection management */
463    tNFA_CONN_CBACK            *p_conn_cback;       /* callback for connection events       */
464    tNFA_TECHNOLOGY_MASK        poll_mask;          /* technologies being polled            */
465
466    tNFA_CONN_CBACK            *p_excl_conn_cback;  /* exclusive RF mode callback           */
467    tNFA_NDEF_CBACK            *p_excl_ndef_cback;  /* ndef callback for exclusive RF mdoe  */
468
469    tNFA_HANDLE                 poll_disc_handle;   /* discovery handle for polling         */
470
471    UINT8                      *p_activate_ntf;     /* temp holding activation notfication  */
472
473    UINT8                       activated_nfcid[NCI_NFCID1_MAX_LEN];
474                                                    /* NFCID 0/1/2 or UID of ISO15694       */
475    UINT8                       activated_nfcid_len;/* length of NFCID ot UID               */
476
477    /* NFC link discovery management */
478    tNFA_DM_DISC_CB             disc_cb;
479
480    /* NDEF Type handler */
481    tNFA_DM_API_REG_NDEF_HDLR   *p_ndef_handler[NFA_NDEF_MAX_HANDLERS];    /* ndef handler table */
482
483    /* stored parameters */
484    tNFA_DM_PARAMS              params;
485
486    /* SetConfig management */
487    UINT32                      setcfg_pending_mask;    /* Mask of to indicate whether pending SET_CONFIGs require NFA_DM_SET_CONFIG_EVT. LSB=oldest pending */
488    UINT8                       setcfg_pending_num;     /* Number of setconfigs pending */
489
490    /* NFCC power mode */
491    UINT8                       nfcc_pwr_mode;          /* NFA_DM_PWR_MODE_FULL or NFA_DM_PWR_MODE_OFF_SLEEP */
492} tNFA_DM_CB;
493
494/* Internal function prototypes */
495void nfa_dm_ndef_handle_message (tNFA_STATUS status, UINT8 *p_msg_buf, UINT32 len);
496void nfa_dm_ndef_dereg_all (void);
497void nfa_dm_act_conn_cback_notify (UINT8 event, tNFA_CONN_EVT_DATA *p_data);
498void nfa_dm_notify_activation_status (tNFA_STATUS status, tNFA_TAG_PARAMS *p_params);
499void nfa_dm_disable_complete (void);
500
501/* Internal functions from nfa_rw */
502void nfa_rw_init (void);
503void nfa_rw_proc_disc_evt (tNFA_DM_RF_DISC_EVT event, tNFC_DISCOVER *p_data, BOOLEAN excl_rf_not_active);
504tNFA_STATUS nfa_rw_send_raw_frame (BT_HDR *p_data);
505
506/* Internal functions from nfa_ce */
507void nfa_ce_init (void);
508
509/* Pointer to compile-time configuration structure */
510extern tNFA_HCI_CFG *p_nfa_hci_cfg;
511extern tNFA_DM_CFG *p_nfa_dm_cfg;
512extern UINT8 *p_nfa_dm_ce_cfg;
513extern UINT8 *p_nfa_dm_gen_cfg;
514extern UINT8 nfa_ee_max_ee_cfg;
515extern tNCI_DISCOVER_MAPS *p_nfa_dm_interface_mapping;
516extern UINT8 nfa_dm_num_dm_interface_mapping;
517
518/* NFA device manager control block */
519#if NFA_DYNAMIC_MEMORY == FALSE
520extern tNFA_DM_CB nfa_dm_cb;
521#else
522extern tNFA_DM_CB *nfa_dm_cb_ptr;
523#define nfa_dm_cb (*nfa_dm_cb_ptr)
524#endif
525
526void nfa_dm_init (void);
527void nfa_p2p_init (void);
528#if (defined (NFA_CHO_INCLUDED) && (NFA_CHO_INCLUDED==TRUE))
529void nfa_cho_init (void);
530#else
531#define nfa_cho_init()
532#endif /* (defined (NFA_CHO_INCLUDED) && (NFA_CHO_INCLUDED==TRUE)) */
533#if (defined (NFA_SNEP_INCLUDED) && (NFA_SNEP_INCLUDED==TRUE))
534void nfa_snep_init (BOOLEAN is_dta_mode);
535#else
536#define nfa_snep_init(is_dta_mode)
537#endif
538
539void nfa_dta_init (void);
540#if (NFC_NFCEE_INCLUDED == TRUE)
541void nfa_ee_init (void);
542void nfa_hci_init (void);
543#else
544#define nfa_ee_init()
545#define nfa_hci_init()
546#endif
547
548/* Action function prototypes */
549BOOLEAN nfa_dm_enable (tNFA_DM_MSG *p_data);
550BOOLEAN nfa_dm_disable (tNFA_DM_MSG *p_data);
551BOOLEAN nfa_dm_set_config (tNFA_DM_MSG *p_data);
552BOOLEAN nfa_dm_get_config (tNFA_DM_MSG *p_data);
553BOOLEAN nfa_dm_act_request_excl_rf_ctrl (tNFA_DM_MSG *p_data);
554BOOLEAN nfa_dm_act_release_excl_rf_ctrl (tNFA_DM_MSG *p_data);
555BOOLEAN nfa_dm_act_enable_polling (tNFA_DM_MSG *p_data);
556BOOLEAN nfa_dm_act_disable_polling (tNFA_DM_MSG *p_data);
557BOOLEAN nfa_dm_act_send_raw_frame (tNFA_DM_MSG *p_data);
558BOOLEAN nfa_dm_set_p2p_listen_tech (tNFA_DM_MSG *p_data);
559BOOLEAN nfa_dm_act_start_rf_discovery (tNFA_DM_MSG *p_data);
560BOOLEAN nfa_dm_act_stop_rf_discovery (tNFA_DM_MSG *p_data);
561BOOLEAN nfa_dm_act_set_rf_disc_duration (tNFA_DM_MSG *p_data);
562BOOLEAN nfa_dm_act_select (tNFA_DM_MSG *p_data);
563BOOLEAN nfa_dm_act_update_rf_params (tNFA_DM_MSG *p_data);
564BOOLEAN nfa_dm_act_deactivate (tNFA_DM_MSG *p_data);
565BOOLEAN nfa_dm_act_power_off_sleep (tNFA_DM_MSG *p_data);
566BOOLEAN nfa_dm_ndef_reg_hdlr (tNFA_DM_MSG *p_data);
567BOOLEAN nfa_dm_ndef_dereg_hdlr (tNFA_DM_MSG *p_data);
568BOOLEAN nfa_dm_tout (tNFA_DM_MSG *p_data);
569BOOLEAN nfa_dm_act_reg_vsc (tNFA_DM_MSG *p_data);
570BOOLEAN nfa_dm_act_send_vsc (tNFA_DM_MSG *p_data);
571BOOLEAN nfa_dm_act_disable_timeout (tNFA_DM_MSG *p_data);
572BOOLEAN nfa_dm_act_nfc_cback_data (tNFA_DM_MSG *p_data);
573
574void nfa_dm_proc_nfcc_power_mode (UINT8 nfcc_power_mode);
575
576/* Main function prototypes */
577BOOLEAN nfa_dm_evt_hdlr (BT_HDR *p_msg);
578void nfa_dm_sys_enable (void);
579void nfa_dm_sys_disable (void);
580tNFA_STATUS nfa_dm_check_set_config (UINT8 tlv_list_len, UINT8 *p_tlv_list, BOOLEAN app_init);
581
582void nfa_dm_conn_cback_event_notify (UINT8 event, tNFA_CONN_EVT_DATA *p_data);
583
584/* Discovery function prototypes */
585void nfa_dm_disc_sm_execute (tNFA_DM_RF_DISC_SM_EVENT event, tNFA_DM_RF_DISC_DATA *p_data);
586tNFA_HANDLE nfa_dm_add_rf_discover (tNFA_DM_DISC_TECH_PROTO_MASK disc_mask, tNFA_DM_DISC_HOST_ID host_id, tNFA_DISCOVER_CBACK *p_disc_cback);
587void nfa_dm_delete_rf_discover (tNFA_HANDLE handle);
588void nfa_dm_start_excl_discovery (tNFA_TECHNOLOGY_MASK poll_tech_mask,
589                                  tNFA_LISTEN_CFG *p_listen_cfg,
590                                  tNFA_DISCOVER_CBACK  *p_disc_cback);
591void nfa_dm_rel_excl_rf_control_and_notify (void);
592void nfa_dm_stop_excl_discovery (void);
593void nfa_dm_disc_new_state (tNFA_DM_RF_DISC_STATE new_state);
594
595void nfa_dm_start_rf_discover (void);
596void nfa_dm_rf_discover_select (UINT8 rf_disc_id, tNFA_NFC_PROTOCOL protocol, tNFA_INTF_TYPE rf_interface);
597tNFA_STATUS nfa_dm_rf_deactivate (tNFA_DEACTIVATE_TYPE deactivate_type);
598BOOLEAN nfa_dm_is_protocol_supported (tNFA_NFC_PROTOCOL protocol, UINT8 sel_res);
599BOOLEAN nfa_dm_is_active (void);
600tNFC_STATUS nfa_dm_disc_sleep_wakeup (void);
601
602
603
604#if (NFC_NFCEE_INCLUDED == FALSE)
605#define nfa_ee_get_tech_route(ps, ha) memset(ha, NFC_DH_ID, NFA_DM_MAX_TECH_ROUTE);
606#endif
607
608#if (BT_TRACE_VERBOSE == TRUE)
609char *nfa_dm_nfc_revt_2_str (tNFC_RESPONSE_EVT event);
610#endif
611
612
613#endif /* NFA_DM_INT_H */
614
615