Home | History | Annotate | Download | only in btm
      1 /******************************************************************************
      2  *
      3  *  Copyright (C) 2002-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 definition of the btm control block when
     22  *  BTM_DYNAMIC_MEMORY is used.
     23  *
     24  ******************************************************************************/
     25 
     26 #include "bt_types.h"
     27 #include "bt_target.h"
     28 #include <string.h>
     29 #include "btm_int.h"
     30 #include "stack_config.h"
     31 
     32 /* Global BTM control block structure
     33 */
     34 #if BTM_DYNAMIC_MEMORY == FALSE
     35 tBTM_CB  btm_cb;
     36 #endif
     37 
     38 /*******************************************************************************
     39 **
     40 ** Function         btm_init
     41 **
     42 ** Description      This function is called at BTM startup to allocate the
     43 **                  control block (if using dynamic memory), and initializes the
     44 **                  tracing level.  It then initializes the various components of
     45 **                  btm.
     46 **
     47 ** Returns          void
     48 **
     49 *******************************************************************************/
     50 void btm_init (void)
     51 {
     52     /* All fields are cleared; nonzero fields are reinitialized in appropriate function */
     53     memset(&btm_cb, 0, sizeof(tBTM_CB));
     54     btm_cb.page_queue = fixed_queue_new(SIZE_MAX);
     55     btm_cb.sec_pending_q = fixed_queue_new(SIZE_MAX);
     56     btm_cb.sec_collision_timer = alarm_new("btm.sec_collision_timer");
     57     btm_cb.pairing_timer = alarm_new("btm.pairing_timer");
     58 
     59 #if defined(BTM_INITIAL_TRACE_LEVEL)
     60     btm_cb.trace_level = BTM_INITIAL_TRACE_LEVEL;
     61 #else
     62     btm_cb.trace_level = BT_TRACE_LEVEL_NONE;    /* No traces */
     63 #endif
     64     /* Initialize BTM component structures */
     65     btm_inq_db_init();                  /* Inquiry Database and Structures */
     66     btm_acl_init();                     /* ACL Database and Structures */
     67     /* Security Manager Database and Structures */
     68     if (stack_config_get_interface()->get_pts_secure_only_mode())
     69         btm_sec_init(BTM_SEC_MODE_SC);
     70     else
     71         btm_sec_init(BTM_SEC_MODE_SP);
     72 #if BTM_SCO_INCLUDED == TRUE
     73     btm_sco_init();                     /* SCO Database and Structures (If included) */
     74 #endif
     75 
     76     btm_cb.sec_dev_rec = list_new(osi_free);
     77 
     78     btm_dev_init();                     /* Device Manager Structures & HCI_Reset */
     79 }
     80 
     81 
     82