OSDN Git Service

Remove must-always-be-true BTU_BTA_INCLUDED
[android-x86/system-bt.git] / main / bte_init.c
1 /******************************************************************************
2  *
3  *  Copyright (C) 2000-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 module contains the routines that initialize the stack components.
22  *  It must be called before the BTU task is started.
23  *
24  ******************************************************************************/
25
26 #include "bt_target.h"
27 #include <string.h>
28
29 #ifndef BTA_INCLUDED
30 #define BTA_INCLUDED FALSE
31 #endif
32
33 /* Include initialization functions definitions */
34 #if (defined(RFCOMM_INCLUDED) && RFCOMM_INCLUDED == TRUE)
35 #include "port_api.h"
36 #endif
37
38 #if (defined(TCS_INCLUDED) && TCS_INCLUDED == TRUE)
39 #include "tcs_api.h"
40 #endif
41
42 #if (defined(OBX_INCLUDED) && OBX_INCLUDED == TRUE)
43 #include "obx_api.h"
44 #endif
45
46 #if (defined(BNEP_INCLUDED) && BNEP_INCLUDED == TRUE)
47 #include "bnep_api.h"
48 #endif
49
50 #if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE)
51 #include "gap_api.h"
52 #endif
53
54 #if ((defined(CTP_INCLUDED) && CTP_INCLUDED == TRUE))
55 #include "ctp_api.h"
56 #endif
57
58 #if ((defined(ICP_INCLUDED) && ICP_INCLUDED == TRUE))
59 #include "icp_api.h"
60 #endif
61
62 #if (defined(SPP_INCLUDED) && SPP_INCLUDED == TRUE)
63 #include "spp_api.h"
64 #endif
65
66 #if (defined(DUN_INCLUDED) && DUN_INCLUDED == TRUE)
67 #include "dun_api.h"
68 #endif
69
70 #if (defined(GOEP_INCLUDED) &&  GOEP_INCLUDED == TRUE)
71 #include "goep_util.h"
72 #endif /* GOEP included */
73
74 #if (defined(OPP_INCLUDED) && OPP_INCLUDED == TRUE)
75 #include "opp_api.h"
76 #endif /* OPP */
77
78 #if (defined(BIP_INCLUDED) && BIP_INCLUDED == TRUE)
79 #include "bip_api.h"
80 #endif
81
82 #if (defined(BTA_BI_INCLUDED) && BTA_BI_INCLUDED == TRUE)
83 #include "bta_bi_api.h"
84 #endif
85
86 #if (defined(HFP_INCLUDED) && HFP_INCLUDED == TRUE)
87 #include "hfp_api.h"
88 #endif
89
90 #if ((defined(HSP2_INCLUDED) && HSP2_INCLUDED == TRUE)) || \
91     ((defined(HFP_INCLUDED) && HFP_INCLUDED == TRUE))
92 #include "hsp2_api.h"
93 #endif
94
95 #if (defined(HCRP_INCLUDED) && HCRP_INCLUDED == TRUE)
96 #if (defined(HCRP_CLIENT_INCLUDED) && HCRP_CLIENT_INCLUDED == TRUE)
97 #include "hcrp_api.h"
98 #endif
99 #if (defined(HCRP_SERVER_INCLUDED) && HCRP_SERVER_INCLUDED == TRUE)
100 #include "hcrpm_api.h"
101 #endif
102 #endif
103
104 #if (defined(BPP_INCLUDED) && BPP_INCLUDED == TRUE)
105 #include "bpp_api.h"
106 #endif
107
108 #if (defined(PAN_INCLUDED) && PAN_INCLUDED == TRUE)
109 #include "pan_api.h"
110 #endif
111
112 #if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE)
113 #include "avrc_api.h"
114 #endif
115
116 #if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE)
117 #include "a2d_api.h"
118 #endif
119
120
121 #if (defined(HID_DEV_INCLUDED) && HID_DEV_INCLUDED == TRUE)
122 #include "hidd_api.h"
123 #endif
124
125 #if (defined(HID_HOST_INCLUDED) && HID_HOST_INCLUDED == TRUE)
126 #include "hidh_api.h"
127 #endif
128
129 #if (defined(SAP_SERVER_INCLUDED) && SAP_SERVER_INCLUDED == TRUE)
130 #include "sap_api.h"
131 #endif  /* SAP_SERVER_INCLUDED */
132
133 #if (defined(MCA_INCLUDED) && MCA_INCLUDED == TRUE)
134 #include "mca_api.h"
135 #endif
136
137 #if (defined(BLE_INCLUDED) && BLE_INCLUDED == TRUE)
138 #include "gatt_api.h"
139 #if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE)
140 #include "smp_api.h"
141 #endif
142 #endif
143
144 // btla-specific ++
145 /***** BTA Modules ******/
146 #if BTA_INCLUDED == TRUE && BTA_DYNAMIC_MEMORY == TRUE
147 #include "bta_api.h"
148 #include "bta_sys.h"
149
150 #if BTA_AC_INCLUDED == TRUE
151 #include "bta_acs_int.h"
152 #include "bta_acc_int.h"
153 #endif
154
155 #if BTA_AG_INCLUDED == TRUE
156 #include "bta_ag_int.h"
157 #endif
158
159 #if BTA_HS_INCLUDED == TRUE
160 #include "bta_hs_int.h"
161 #endif
162
163 #include "bta_dm_int.h"
164
165 #if BTA_DG_INCLUDED == TRUE
166 #include "bta_dg_api.h"
167 #include "bta_dg_int.h"
168 #endif
169
170 #if BTA_FT_INCLUDED == TRUE
171 #include "bta_ftc_int.h"
172 #include "bta_fts_int.h"
173 #endif
174
175 #if BTA_PBC_INCLUDED == TRUE
176 #include "bta_pbc_int.h"
177 #endif
178
179 #if BTA_PBS_INCLUDED == TRUE
180 #include "bta_pbs_int.h"
181 #endif
182
183 #if BTA_OP_INCLUDED == TRUE
184 #include "bta_opc_int.h"
185 #include "bta_ops_int.h"
186 #endif
187
188 #if BTA_SS_INCLUDED==TRUE
189 #include "bta_ss_int.h"
190 #endif
191
192 #if BTA_CT_INCLUDED==TRUE
193 #include "bta_ct_int.h"
194 #endif
195
196 #if BTA_CG_INCLUDED==TRUE
197 #include "bta_cg_int.h"
198 #endif
199
200 #if BTA_BI_INCLUDED==TRUE
201 #include "bta_bic_int.h"
202 #include "bta_bis_int.h"
203 #endif
204
205 #if BTA_PR_INCLUDED==TRUE
206 #include "bta_pr_int.h"
207 #endif
208
209 #if BTA_AR_INCLUDED==TRUE
210 #include "bta_ar_int.h"
211 #endif
212 #if BTA_AV_INCLUDED==TRUE
213 #include "bta_av_int.h"
214 #endif
215
216 #if BTA_SC_INCLUDED==TRUE
217 #include "bta_sc_int.h"
218 #endif
219
220 #if BTA_HD_INCLUDED==TRUE
221 #include "bta_hd_int.h"
222 #endif
223
224 #if BTA_HH_INCLUDED==TRUE
225 #include "bta_hh_int.h"
226 #endif
227
228 #if BTA_FM_INCLUDED==TRUE
229 #include "bta_fm_int.h"
230 #endif
231
232 #if BTA_FMTX_INCLUDED==TRUE
233 #include "bta_fmtx_int.h"
234 #endif
235
236 #if BTA_JV_INCLUDED==TRUE
237 #include "bta_jv_int.h"
238 tBTA_JV_CB *bta_jv_cb_ptr = NULL;
239 #endif
240
241 #if BTA_MCE_INCLUDED == TRUE
242 #include "bta_mce_int.h"
243 #endif
244
245 #if BTA_MSE_INCLUDED == TRUE
246 #include "bta_mse_int.h"
247 #endif
248
249 #if BTA_HL_INCLUDED == TRUE
250 #include "bta_hl_int.h"
251 #endif
252
253 #if BTA_GATT_INCLUDED == TRUE
254 #include "bta_gattc_int.h"
255 #include "bta_gatts_int.h"
256 #endif
257
258 #if BTA_PAN_INCLUDED==TRUE
259 #include "bta_pan_int.h"
260 #endif
261
262 #include "bta_sys_int.h"
263
264 /* control block for patch ram downloading */
265 #include "bta_prm_int.h"
266
267 #endif /* BTA_INCLUDED */
268 // btla-specific --
269
270 /*****************************************************************************
271 **                          F U N C T I O N S                                *
272 ******************************************************************************/
273
274 /*****************************************************************************
275 **
276 ** Function         BTE_InitStack
277 **
278 ** Description      Initialize control block memory for each component.
279 **
280 **                  Note: The core stack components must be called
281 **                      before creating the BTU Task.  The rest of the
282 **                      components can be initialized at a later time if desired
283 **                      as long as the component's init function is called
284 **                      before accessing any of its functions.
285 **
286 ** Returns          void
287 **
288 ******************************************************************************/
289 BT_API void BTE_InitStack(void)
290 {
291 /* Initialize the optional stack components */
292
293 /****************************
294 ** RFCOMM and its profiles **
295 *****************************/
296 #if (defined(RFCOMM_INCLUDED) && RFCOMM_INCLUDED == TRUE)
297     RFCOMM_Init();
298
299 #if (defined(SPP_INCLUDED) && SPP_INCLUDED == TRUE)
300     SPP_Init();
301 #endif  /* SPP */
302
303 #if (defined(DUN_INCLUDED) && DUN_INCLUDED == TRUE)
304     DUN_Init();
305 #endif  /* DUN */
306
307 #if (defined(HSP2_INCLUDED) && HSP2_INCLUDED == TRUE)
308     HSP2_Init();
309 #endif  /* HSP2 */
310
311 #if (defined(HFP_INCLUDED) && HFP_INCLUDED == TRUE)
312     HFP_Init();
313 #endif  /* HFP */
314
315 /**************************
316 ** OBEX and its profiles **
317 ***************************/
318 #if (defined(OBX_INCLUDED) && OBX_INCLUDED == TRUE)
319     OBX_Init();
320 #if (defined(BIP_INCLUDED) && BIP_INCLUDED == TRUE)
321     BIP_Init();
322 #if (defined(BTA_BI_INCLUDED) && BTA_BI_INCLUDED == TRUE)
323     BTA_BicInit();
324 #endif  /* BTA BI */
325 #endif  /* BIP */
326
327 #if (defined(GOEP_INCLUDED) && GOEP_INCLUDED == TRUE)
328     GOEP_Init();
329 #endif /* GOEP */
330
331
332 #if (defined(OPP_INCLUDED) && OPP_INCLUDED == TRUE)
333     OPP_Init();
334 #endif
335
336 #if (defined(BPP_INCLUDED) && BPP_INCLUDED == TRUE)
337     BPP_Init();
338 #endif  /* BPP */
339 #endif  /* OBX */
340
341
342 #endif  /* RFCOMM Included */
343
344 /*************************
345 ** TCS and its profiles **
346 **************************/
347 #if (defined(TCS_INCLUDED) && TCS_INCLUDED == TRUE)
348     TCS_Init();
349
350 #if (defined(CTP_INCLUDED) && CTP_INCLUDED == TRUE)
351     CTP_Init();
352 #endif /* CTP_INCLUDED */
353
354 #if (defined(ICP_INCLUDED) && ICP_INCLUDED == TRUE)
355     ICP_Init();
356 #endif /* ICP_INCLUDED */
357
358 #endif /* TCS_INCLUDED */
359
360
361 /**************************
362 ** BNEP and its profiles **
363 ***************************/
364 #if (defined(BNEP_INCLUDED) && BNEP_INCLUDED == TRUE)
365     BNEP_Init();
366
367 #if (defined(PAN_INCLUDED) && PAN_INCLUDED == TRUE)
368     PAN_Init();
369 #endif  /* PAN */
370 #endif  /* BNEP Included */
371
372
373 /**************************
374 ** AVDT and its profiles **
375 ***************************/
376 #if (defined(A2D_INCLUDED) && A2D_INCLUDED == TRUE)
377     A2D_Init();
378 #endif  /* AADP */
379
380
381 #if (defined(AVRC_INCLUDED) && AVRC_INCLUDED == TRUE)
382     AVRC_Init();
383 #endif
384
385
386 /***********
387 ** Others **
388 ************/
389 #if (defined(GAP_INCLUDED) && GAP_INCLUDED == TRUE)
390     GAP_Init();
391 #endif  /* GAP Included */
392
393 #if (defined(HCRP_INCLUDED) && HCRP_INCLUDED == TRUE)
394 #if (defined(HCRP_CLIENT_INCLUDED) && HCRP_CLIENT_INCLUDED == TRUE)
395     HCRP_Init();
396 #endif
397 #if (defined(HCRP_SERVER_INCLUDED) && HCRP_SERVER_INCLUDED == TRUE)
398     HCRPM_Init();
399 #endif
400 #endif  /* HCRP Included */
401
402 #if (defined(SAP_SERVER_INCLUDED) && SAP_SERVER_INCLUDED == TRUE)
403     SAP_Init();
404 #endif  /* SAP_SERVER_INCLUDED */
405
406 #if (defined(HID_DEV_INCLUDED) && HID_DEV_INCLUDED == TRUE)
407     HID_DevInit();
408 #endif
409 #if (defined(HID_HOST_INCLUDED) && HID_HOST_INCLUDED == TRUE)
410     HID_HostInit();
411 #endif
412
413 #if (defined(MCA_INCLUDED) && MCA_INCLUDED == TRUE)
414     MCA_Init();
415 #endif  /* SAP_SERVER_INCLUDED */
416
417 /****************
418 ** BTA Modules **
419 *****************/
420 // btla-specific ++
421 #if (BTA_INCLUDED == TRUE && BTA_DYNAMIC_MEMORY == TRUE)
422     memset((void*)bta_sys_cb_ptr, 0, sizeof(tBTA_SYS_CB));
423     memset((void*)bta_dm_cb_ptr, 0, sizeof(tBTA_DM_CB));
424     memset((void*)bta_dm_search_cb_ptr, 0, sizeof(tBTA_DM_SEARCH_CB));
425     memset((void*)bta_dm_di_cb_ptr, 0, sizeof(tBTA_DM_DI_CB));
426     memset((void*)bta_prm_cb_ptr, 0, sizeof(tBTA_PRM_CB));
427
428 #if BTA_AC_INCLUDED == TRUE
429     memset((void*)bta_acc_cb_ptr, 0, sizeof(tBTA_ACC_CB));
430     memset((void*)bta_acs_cb_ptr, 0, sizeof(tBTA_ACS_CB));
431 #endif
432 #if BTA_AG_INCLUDED == TRUE
433     memset((void*)bta_ag_cb_ptr, 0, sizeof(tBTA_AG_CB));
434 #endif
435 #if BTA_HS_INCLUDED == TRUE
436     memset((void*)bta_hs_cb_ptr, 0, sizeof(tBTA_HS_CB));
437 #endif
438 #if BTA_DG_INCLUDED == TRUE
439     memset((void*)bta_dg_cb_ptr, 0, sizeof(tBTA_DG_CB));
440 #endif
441 #if BTA_FT_INCLUDED==TRUE
442     memset((void*)bta_ftc_cb_ptr, 0, sizeof(tBTA_FTC_CB));
443     memset((void*)bta_fts_cb_ptr, 0, sizeof(tBTA_FTS_CB));
444 #endif
445 #if BTA_PBC_INCLUDED==TRUE
446     memset((void*)bta_pbc_cb_ptr, 0, sizeof(tBTA_PBC_CB));
447 #endif
448 #if BTA_PBS_INCLUDED==TRUE
449     memset((void*)bta_pbs_cb_ptr, 0, sizeof(tBTA_PBS_CB));
450 #endif
451 #if BTA_OP_INCLUDED==TRUE
452     memset((void*)bta_opc_cb_ptr, 0, sizeof(tBTA_OPC_CB));
453     memset((void*)bta_ops_cb_ptr, 0, sizeof(tBTA_OPS_CB));
454 #endif
455 #if BTA_SS_INCLUDED==TRUE
456     memset((void*)bta_ss_cb_ptr, 0, sizeof(tBTA_SS_CB));
457 #endif
458 #if BTA_CT_INCLUDED==TRUE
459     memset((void*)bta_ct_cb_ptr, 0, sizeof(tBTA_CT_CB));
460 #endif
461 #if BTA_CG_INCLUDED==TRUE
462     memset((void*)bta_cg_cb_ptr, 0, sizeof(tBTA_CG_CB));
463 #endif
464 #if BTA_BI_INCLUDED==TRUE
465     memset((void *)bta_bic_cb_ptr, 0, sizeof(tBTA_BIC_CB));
466     memset((void *)bta_bis_cb_ptr, 0, sizeof(tBTA_BIS_CB));
467 #endif
468 #if BTA_AR_INCLUDED==TRUE
469     memset((void *)bta_ar_cb_ptr, 0, sizeof(tBTA_AR_CB));
470 #endif
471 #if BTA_AV_INCLUDED==TRUE
472     memset((void *)bta_av_cb_ptr, 0, sizeof(tBTA_AV_CB));
473 #endif
474 #if BTA_PR_INCLUDED==TRUE
475     memset((void *)bta_pr_cb_ptr, 0, sizeof(tBTA_PR_CB));
476 #endif
477 #if BTA_SC_INCLUDED==TRUE
478     memset((void *)bta_sc_cb_ptr, 0, sizeof(tBTA_SC_CB));
479 #endif
480 #if BTA_HD_INCLUDED==TRUE
481     memset((void *)bta_hd_cb_ptr, 0, sizeof(tBTA_HD_CB));
482 #endif
483 #if BTA_HH_INCLUDED==TRUE
484     memset((void *)bta_hh_cb_ptr, 0, sizeof(tBTA_HH_CB));
485 #endif
486 #if BTA_FM_INCLUDED==TRUE
487     memset((void *)bta_fm_cb_ptr, 0, sizeof(tBTA_FM_CB));
488 #endif
489 #if BTA_FMTX_INCLUDED==TRUE
490     memset((void *)bta_fmtx_cb_ptr, 0, sizeof(tBTA_FMTX_CB));
491 #endif
492 #if 0
493 #if BTA_JV_INCLUDED==TRUE
494     memset((void *)bta_jv_cb_ptr, 0, sizeof(tBTA_JV_CB));
495 #endif
496 #endif
497 #if BTA_HL_INCLUDED==TRUE
498     memset((void *)bta_hl_cb_ptr, 0, sizeof(tBTA_HL_CB));
499 #endif
500 #if BTA_GATT_INCLUDED==TRUE
501     memset((void *)bta_gattc_cb_ptr, 0, sizeof(tBTA_GATTC_CB));
502     memset((void *)bta_gatts_cb_ptr, 0, sizeof(tBTA_GATTS_CB));
503 #endif
504 #if BTA_PAN_INCLUDED==TRUE
505     memset((void *)bta_pan_cb_ptr, 0, sizeof(tBTA_PAN_CB));
506 #endif
507
508 #endif /* BTA_INCLUDED == TRUE */
509 // btla-specific --
510 }