• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright (C) 1999-2012 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 file contains the main Bluetooth Upper Layer definitions. The Broadcom
22  *  implementations of L2CAP RFCOMM, SDP and the BTIf run as one GKI task. The
23  *  btu_task switches between them.
24  *
25  ******************************************************************************/
26 
27 #ifndef BTU_H
28 #define BTU_H
29 
30 #include "bt_target.h"
31 #include "gki.h"
32 
33 // HACK(zachoverflow): temporary dark magic
34 #define BTU_POST_TO_TASK_NO_GOOD_HORRIBLE_HACK 0x1700 // didn't look used in bt_types...here goes nothing
35 typedef struct {
36   void (*callback)(BT_HDR *);
37 } post_to_task_hack_t;
38 
39 typedef struct {
40   void (*callback)(BT_HDR *);
41   BT_HDR *response;
42   void *context;
43 } command_complete_hack_t;
44 
45 typedef struct {
46   void (*callback)(BT_HDR *);
47   uint8_t status;
48   BT_HDR *command;
49   void *context;
50 } command_status_hack_t;
51 
52 /* callbacks
53 */
54 typedef void (*tBTU_TIMER_CALLBACK)(TIMER_LIST_ENT *p_tle);
55 typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr);
56 
57 
58 /* Define the timer types maintained by BTU
59 */
60 #define BTU_TTYPE_BTM_DEV_CTL       1
61 #define BTU_TTYPE_L2CAP_LINK        2
62 #define BTU_TTYPE_L2CAP_CHNL        3
63 #define BTU_TTYPE_L2CAP_HOLD        4
64 #define BTU_TTYPE_SDP               5
65 #define BTU_TTYPE_BTM_SCO           6
66 #define BTU_TTYPE_BTM_ACL           9
67 #define BTU_TTYPE_BTM_RMT_NAME      10
68 #define BTU_TTYPE_RFCOMM_MFC        11
69 #define BTU_TTYPE_RFCOMM_PORT       12
70 #define BTU_TTYPE_TCS_L2CAP         13
71 #define BTU_TTYPE_TCS_CALL          14
72 #define BTU_TTYPE_TCS_WUG           15
73 #define BTU_TTYPE_AUTO_SYNC         16
74 #define BTU_TTYPE_CTP_RECON         17
75 #define BTU_TTYPE_CTP_T100          18
76 #define BTU_TTYPE_CTP_GUARD         19
77 #define BTU_TTYPE_CTP_DETACH        20
78 
79 #define BTU_TTYPE_SPP_CONN_RETRY    21
80 #define BTU_TTYPE_USER_FUNC         22
81 
82 #define BTU_TTYPE_FTP_DISC          25
83 #define BTU_TTYPE_OPP_DISC          26
84 
85 #define BTU_TTYPE_CTP_TL_DISCVY     28
86 #define BTU_TTYPE_IPFRAG_TIMER      29
87 #define BTU_TTYPE_HSP2_AT_CMD_TO    30
88 #define BTU_TTYPE_HSP2_REPEAT_RING  31
89 
90 #define BTU_TTYPE_CTP_GW_INIT       32
91 #define BTU_TTYPE_CTP_GW_CONN       33
92 #define BTU_TTYPE_CTP_GW_IDLE       35
93 
94 #define BTU_TTYPE_ICP_L2CAP         36
95 #define BTU_TTYPE_ICP_T100          37
96 
97 #define BTU_TTYPE_HSP2_WAIT_OK      38
98 
99 /* HCRP Timers */
100 #define BTU_TTYPE_HCRP_NOTIF_REG    39
101 #define BTU_TTYPE_HCRP_PROTO_RSP    40
102 #define BTU_TTYPE_HCRP_CR_GRANT     41
103 #define BTU_TTYPE_HCRP_CR_CHECK     42
104 #define BTU_TTYPE_HCRP_W4_CLOSE     43
105 
106 /* HCRPM Timers */
107 #define BTU_TTYPE_HCRPM_NOTIF_REG   44
108 #define BTU_TTYPE_HCRPM_NOTIF_KEEP  45
109 #define BTU_TTYPE_HCRPM_API_RSP     46
110 #define BTU_TTYPE_HCRPM_W4_OPEN     47
111 #define BTU_TTYPE_HCRPM_W4_CLOSE    48
112 
113 /* BNEP Timers */
114 #define BTU_TTYPE_BNEP              50
115 
116 #define BTU_TTYPE_HSP2_SDP_FAIL_TO  55
117 #define BTU_TTYPE_HSP2_SDP_RTRY_TO  56
118 
119 /* BTU internal */
120 /* unused                           60 */
121 
122 #define BTU_TTYPE_AVDT_CCB_RET      61
123 #define BTU_TTYPE_AVDT_CCB_RSP      62
124 #define BTU_TTYPE_AVDT_CCB_IDLE     63
125 #define BTU_TTYPE_AVDT_SCB_TC       64
126 
127 #define BTU_TTYPE_HID_DEV_REPAGE_TO 65
128 #define BTU_TTYPE_HID_HOST_REPAGE_TO 66
129 
130 #define BTU_TTYPE_HSP2_DELAY_CKPD_RCV 67
131 
132 #define BTU_TTYPE_SAP_TO            68
133 
134 /* BPP Timer */
135 #define BTU_TTYPE_BPP_REF_CHNL     72
136 
137 /* LP HC idle Timer */
138 #define BTU_TTYPE_LP_HC_IDLE_TO 74
139 
140 /* Patch RAM Timer */
141 #define BTU_TTYPE_PATCHRAM_TO 75
142 
143 /* eL2CAP Info Request and other proto cmds timer */
144 #define BTU_TTYPE_L2CAP_FCR_ACK     78
145 #define BTU_TTYPE_L2CAP_INFO        79
146 
147 #define BTU_TTYPE_MCA_CCB_RSP                       98
148 
149 /* BTU internal timer for BLE activity */
150 #define BTU_TTYPE_BLE_INQUIRY                       99
151 #define BTU_TTYPE_BLE_GAP_LIM_DISC                  100
152 #define BTU_TTYPE_ATT_WAIT_FOR_RSP                  101
153 #define BTU_TTYPE_SMP_PAIRING_CMD                   102
154 #define BTU_TTYPE_BLE_RANDOM_ADDR                   103
155 #define BTU_TTYPE_ATT_WAIT_FOR_APP_RSP              104
156 #define BTU_TTYPE_ATT_WAIT_FOR_IND_ACK              105
157 
158 #define BTU_TTYPE_BLE_GAP_FAST_ADV                  106
159 #define BTU_TTYPE_BLE_OBSERVE                       107
160 
161 
162 #define BTU_TTYPE_UCD_TO                            108
163 
164 /* This is the inquiry response information held by BTU, and available
165 ** to applications.
166 */
167 typedef struct
168 {
169     BD_ADDR     remote_bd_addr;
170     UINT8       page_scan_rep_mode;
171     UINT8       page_scan_per_mode;
172     UINT8       page_scan_mode;
173     DEV_CLASS   dev_class;
174     UINT16      clock_offset;
175 } tBTU_INQ_INFO;
176 
177 
178 
179 #define BTU_MAX_REG_TIMER     (2)   /* max # timer callbacks which may register */
180 #define BTU_MAX_REG_EVENT     (6)   /* max # event callbacks which may register */
181 #define BTU_DEFAULT_DATA_SIZE (0x2a0)
182 
183 #if (BLE_INCLUDED == TRUE)
184 #define BTU_DEFAULT_BLE_DATA_SIZE   (27)
185 #endif
186 
187 /* structure to hold registered timers */
188 typedef struct
189 {
190     TIMER_LIST_ENT          *p_tle;      /* timer entry */
191     tBTU_TIMER_CALLBACK     timer_cb;    /* callback triggered when timer expires */
192 } tBTU_TIMER_REG;
193 
194 /* structure to hold registered event callbacks */
195 typedef struct
196 {
197     UINT16                  event_range;  /* start of event range */
198     tBTU_EVENT_CALLBACK     event_cb;     /* callback triggered when event is in range */
199 } tBTU_EVENT_REG;
200 
201 #define NFC_MAX_LOCAL_CTRLS     0
202 
203 /* the index to BTU command queue array */
204 #define NFC_CONTROLLER_ID       (1)
205 #define BTU_MAX_LOCAL_CTRLS     (1 + NFC_MAX_LOCAL_CTRLS) /* only BR/EDR */
206 
207 /* Define structure holding BTU variables
208 */
209 typedef struct
210 {
211     tBTU_TIMER_REG   timer_reg[BTU_MAX_REG_TIMER];
212     tBTU_EVENT_REG   event_reg[BTU_MAX_REG_EVENT];
213 
214     BOOLEAN     reset_complete;             /* TRUE after first ack from device received */
215     UINT8       trace_level;                /* Trace level for HCI layer */
216 } tBTU_CB;
217 
218 #ifdef __cplusplus
219 extern "C" {
220 #endif
221 
222 /* Global BTU data */
223 #if BTU_DYNAMIC_MEMORY == FALSE
224 extern tBTU_CB  btu_cb;
225 #else
226 extern tBTU_CB *btu_cb_ptr;
227 #define btu_cb (*btu_cb_ptr)
228 #endif
229 
230 extern const BD_ADDR        BT_BD_ANY;
231 
232 /* Functions provided by btu_task.c
233 ************************************
234 */
235 extern void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
236 extern void btu_stop_timer (TIMER_LIST_ENT *p_tle);
237 extern void btu_start_timer_oneshot(TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
238 extern void btu_stop_timer_oneshot(TIMER_LIST_ENT *p_tle);
239 
240 extern void btu_uipc_rx_cback(BT_HDR *p_msg);
241 
242 /*
243 ** Quick Timer
244 */
245 #if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
246 extern void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
247 extern void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle);
248 extern void btu_process_quick_timer_evt (void);
249 #endif
250 
251 #if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
252 extern void btu_check_bt_sleep (void);
253 #endif
254 
255 /* Functions provided by btu_hcif.c
256 ************************************
257 */
258 extern void  btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
259 extern void  btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
260 extern void  btu_hcif_send_host_rdy_for_data(void);
261 extern void  btu_hcif_cmd_timeout (UINT8 controller_id);
262 
263 /* Functions provided by btu_core.c
264 ************************************
265 */
266 extern void  btu_init_core(void);
267 extern void  btu_free_core(void);
268 
269 void BTU_StartUp(void);
270 void BTU_ShutDown(void);
271 
272 extern UINT16 BTU_BleAclPktSize(void);
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 #endif
279