OSDN Git Service

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