nfa_ce_int.h revision f8a4ca325ef137a94869b34d36095ba7d08816a3
1/*****************************************************************************
2**
3**  Name:           nfa_ce_int.h
4**
5**  Description:    This is the private interface file for NFA_CE
6**
7**  Copyright (c) 2011, Broadcom Corp., All Rights Reserved.
8**  Broadcom Bluetooth Core. Proprietary and confidential.
9**
10*****************************************************************************/
11#ifndef NFA_CE_INT_H
12#define NFA_CE_INT_H
13
14#include "nfa_sys.h"
15#include "nfa_api.h"
16#include "nfa_ce_api.h"
17#include "nfa_dm_int.h"
18#include "nfc_api.h"
19
20/*****************************************************************************
21**  Constants and data types
22*****************************************************************************/
23
24/* ce status callback */
25typedef void tNFA_CE_STATUS_CBACK (tNFA_STATUS status);
26
27/* CE events */
28enum
29{
30    /* device manager local device API events */
31    NFA_CE_API_CFG_LOCAL_TAG_EVT    = NFA_SYS_EVT_START (NFA_ID_CE),
32    NFA_CE_API_REG_LISTEN_EVT,
33    NFA_CE_API_DEREG_LISTEN_EVT,
34    NFA_CE_API_CFG_ISODEP_TECH_EVT,
35    NFA_CE_ACTIVATE_NTF_EVT,
36    NFA_CE_DEACTIVATE_NTF_EVT,
37
38    NFA_CE_MAX_EVT
39};
40
41/* Listen registration types */
42enum
43{
44    NFA_CE_REG_TYPE_NDEF,
45    NFA_CE_REG_TYPE_ISO_DEP,
46    NFA_CE_REG_TYPE_FELICA,
47    NFA_CE_REG_TYPE_UICC
48};
49typedef UINT8 tNFA_CE_REG_TYPE;
50
51/* data type for NFA_CE_API_CFG_LOCAL_TAG_EVT */
52typedef struct
53{
54    BT_HDR              hdr;
55    tNFA_PROTOCOL_MASK  protocol_mask;
56    UINT8               *p_ndef_data;
57    UINT16              ndef_cur_size;
58    UINT16              ndef_max_size;
59    BOOLEAN             read_only;
60    UINT8               uid_len;
61    UINT8               uid[NFA_MAX_UID_LEN];
62} tNFA_CE_API_CFG_LOCAL_TAG;
63
64/* data type for NFA_CE_ACTIVATE_NTF_EVT */
65typedef struct
66{
67    BT_HDR              hdr;
68    tNFC_ACTIVATE_DEVT *p_activation_params;
69} tNFA_CE_ACTIVATE_NTF;
70
71/* data type for NFA_CE_API_REG_LISTEN_EVT */
72typedef struct
73{
74    BT_HDR              hdr;
75    tNFA_CONN_CBACK     *p_conn_cback;
76
77    tNFA_CE_REG_TYPE   listen_type;
78
79    /* For registering Felica */
80    UINT16              system_code;
81    UINT8               nfcid2[NCI_RF_F_UID_LEN];
82
83    /* For registering Type-4 */
84    UINT8               aid[NFC_MAX_AID_LEN];   /* AID to listen for (For type-4 only)  */
85    UINT8               aid_len;                /* AID length                           */
86
87    /* For registering UICC */
88    tNFA_HANDLE             ee_handle;
89    tNFA_TECHNOLOGY_MASK    tech_mask;
90} tNFA_CE_API_REG_LISTEN;
91
92/* data type for NFA_CE_API_DEREG_LISTEN_EVT */
93typedef struct
94{
95    BT_HDR          hdr;
96    tNFA_HANDLE     handle;
97    UINT32          listen_info;
98} tNFA_CE_API_DEREG_LISTEN;
99
100/* union of all data types */
101typedef union
102{
103    /* GKI event buffer header */
104    BT_HDR                      hdr;
105    tNFA_CE_API_CFG_LOCAL_TAG   local_tag;
106    tNFA_CE_API_REG_LISTEN      reg_listen;
107    tNFA_CE_API_DEREG_LISTEN    dereg_listen;
108    tNFA_CE_ACTIVATE_NTF        activate_ntf;
109} tNFA_CE_MSG;
110
111/****************************************************************************
112** LISTEN_INFO definitions
113*****************************************************************************/
114#define NFA_CE_LISTEN_INFO_IDX_NDEF     0                           /* Entry 0 is reserved for local NDEF tag */
115#define NFA_CE_LISTEN_INFO_IDX_INVALID  (NFA_CE_LISTEN_INFO_MAX)
116
117
118/* Flags for listen request */
119#define NFA_CE_LISTEN_INFO_IN_USE           0x00000001  /* LISTEN_INFO entry is in use                                      */
120#define NFC_CE_LISTEN_INFO_READONLY_NDEF    0x00000010  /* NDEF is read-only                                                */
121#define NFA_CE_LISTEN_INFO_T4T_ACTIVATE_PND 0x00000040  /* App has not been notified of ACTIVATE_EVT yet for this T4T AID   */
122#define NFA_CE_LISTEN_INFO_T4T_AID          0x00000080  /* This is a listen_info for T4T AID                                */
123#define NFA_CE_LISTEN_INFO_START_NTF_PND    0x00000100  /* App has not been notified of LISTEN_START yet                    */
124#define NFA_CE_LISTEN_INFO_FELICA           0x00000200  /* This is a listen_info for non-NDEF Felica                        */
125#define NFA_CE_LISTEN_INFO_UICC             0x00000400  /* This is a listen_info for UICC                                   */
126
127
128/* Structure for listen look up table */
129typedef struct
130{
131    UINT32              flags;
132    tNFA_CONN_CBACK     *p_conn_cback;                  /* Callback for this listen request             */
133    tNFA_PROTOCOL_MASK  protocol_mask;                  /* Mask of protocols for this listen request    */
134    tNFA_HANDLE         rf_disc_handle;                 /* RF Discover handle */
135
136    /* For host tag emulation (NFA_CeRegisterVirtualT4tSE and NFA_CeRegisterT4tAidOnDH) */
137    UINT8               t3t_nfcid2[NCI_RF_F_UID_LEN];
138    UINT16              t3t_system_code;                /* Type-3 system code */
139    UINT8               t4t_aid_handle;                 /* Type-4 aid callback handle (from CE_T4tRegisterAID) */
140
141    /* For UICC */
142    tNFA_HANDLE                     ee_handle;
143    tNFA_TECHNOLOGY_MASK            tech_mask;          /* listening technologies               */
144    tNFA_DM_DISC_TECH_PROTO_MASK    tech_proto_mask;    /* listening technologies and protocols */
145} tNFA_CE_LISTEN_INFO;
146
147
148/****************************************************************************/
149
150/* Internal flags for nfa_ce */
151#define NFA_CE_FLAGS_APP_INIT_DEACTIVATION  0x00000001  /* Deactivation locally initiated by application */
152#define NFA_CE_FLAGS_LISTEN_ACTIVE_SLEEP    0x00000002  /* Tag is in listen active or sleep state        */
153typedef UINT32 tNFA_CE_FLAGS;
154
155/* NFA_CE control block */
156typedef struct
157{
158    UINT8   *p_scratch_buf;                                 /* Scratch buffer for write requests    */
159    UINT32  scratch_buf_size;
160
161    tNFC_ACTIVATE_DEVT  activation_params;                  /* Activation params        */
162    tNFA_CE_FLAGS       flags;                              /* internal flags           */
163    tNFA_CONN_CBACK     *p_active_conn_cback;               /* Callback of activated CE */
164
165    /* listen_info table (table of listen paramters and app callbacks) */
166    tNFA_CE_LISTEN_INFO listen_info[NFA_CE_LISTEN_INFO_MAX];/* listen info table                            */
167    UINT8               idx_cur_active;                     /* listen_info index for currently activated CE */
168
169    tNFA_DM_DISC_TECH_PROTO_MASK isodep_disc_mask;          /* the technology/protocol mask for ISO-DEP */
170
171    /* Local ndef tag info */
172    UINT8               *p_ndef_data;
173    UINT16              ndef_cur_size;
174    UINT16              ndef_max_size;
175
176    tNFA_SYS_EVT_HDLR   *p_vs_evt_hdlr;                     /* VS event handler */
177} tNFA_CE_CB;
178extern tNFA_CE_CB nfa_ce_cb;
179
180/* type definition for action functions */
181typedef BOOLEAN (*tNFA_CE_ACTION) (tNFA_CE_MSG *p_data);
182
183/* Action function prototypes */
184BOOLEAN nfa_ce_api_cfg_local_tag (tNFA_CE_MSG *p_ce_msg);
185BOOLEAN nfa_ce_api_reg_listen (tNFA_CE_MSG *p_ce_msg);
186BOOLEAN nfa_ce_api_dereg_listen (tNFA_CE_MSG *p_ce_msg);
187BOOLEAN nfa_ce_api_cfg_isodep_tech (tNFA_CE_MSG *p_ce_msg);
188BOOLEAN nfa_ce_activate_ntf (tNFA_CE_MSG *p_ce_msg);
189BOOLEAN nfa_ce_deactivate_ntf (tNFA_CE_MSG *p_ce_msg);
190
191/* Internal function prototypes */
192void nfa_ce_t3t_generate_rand_nfcid (UINT8 nfcid2[NCI_RF_F_UID_LEN]);
193BOOLEAN nfa_ce_hdl_event (BT_HDR *p_msg);
194tNFC_STATUS nfa_ce_set_content (void);
195tNFA_STATUS nfa_ce_start_listening (void);
196void nfa_ce_remove_listen_info_entry (UINT8 listen_info_idx, BOOLEAN notify_app);
197void nfa_ce_sys_disable (void);
198void nfa_ce_free_scratch_buf (void);
199
200#endif /* NFA_DM_INT_H */
201
202