Home | History | Annotate | Download | only in btu
      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 load and shutdown the core stack
     22  *  components.
     23  *
     24  ******************************************************************************/
     25 
     26 #include "bt_target.h"
     27 #include <string.h>
     28 #include "dyn_mem.h"
     29 
     30 #include "btu.h"
     31 #include "btm_int.h"
     32 #include "sdpint.h"
     33 #include "l2c_int.h"
     34 
     35 #if (BLE_INCLUDED == TRUE)
     36 #include "gatt_api.h"
     37 #include "gatt_int.h"
     38 #if SMP_INCLUDED == TRUE
     39 #include "smp_int.h"
     40 #endif
     41 #endif
     42 
     43 extern void PLATFORM_DisableHciTransport(UINT8 bDisable);
     44 /*****************************************************************************
     45 **                          V A R I A B L E S                                *
     46 ******************************************************************************/
     47 const BD_ADDR   BT_BD_ANY = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
     48 
     49 /*****************************************************************************
     50 **                          F U N C T I O N S                                *
     51 ******************************************************************************/
     52 /*****************************************************************************
     53 **
     54 ** Function         btu_init_core
     55 **
     56 ** Description      Initialize control block memory for each core component.
     57 **
     58 **
     59 ** Returns          void
     60 **
     61 ******************************************************************************/
     62 void btu_init_core(void)
     63 {
     64     /* Initialize the mandatory core stack components */
     65     btm_init();
     66 
     67     l2c_init();
     68 
     69     sdp_init();
     70 
     71 #if BLE_INCLUDED == TRUE
     72     gatt_init();
     73 #if (defined(SMP_INCLUDED) && SMP_INCLUDED == TRUE)
     74     SMP_Init();
     75 #endif
     76     btm_ble_init();
     77 #endif
     78 }
     79 
     80 
     81 /*****************************************************************************
     82 **
     83 ** Function         BTE_Init
     84 **
     85 ** Description      Initializes the BTU control block.
     86 **
     87 **                  NOTE: Must be called before creating any tasks
     88 **                      (RPC, BTU, HCIT, APPL, etc.)
     89 **
     90 ** Returns          void
     91 **
     92 ******************************************************************************/
     93 void BTE_Init(void)
     94 {
     95     int i = 0;
     96 
     97     memset (&btu_cb, 0, sizeof (tBTU_CB));
     98     btu_cb.hcit_acl_pkt_size = BTU_DEFAULT_DATA_SIZE + HCI_DATA_PREAMBLE_SIZE;
     99 #if (BLE_INCLUDED == TRUE)
    100     btu_cb.hcit_ble_acl_pkt_size = BTU_DEFAULT_BLE_DATA_SIZE + HCI_DATA_PREAMBLE_SIZE;
    101 #endif
    102     btu_cb.trace_level = HCI_INITIAL_TRACE_LEVEL;
    103 
    104     for ( i = 0; i < BTU_MAX_LOCAL_CTRLS; i++ ) /* include BR/EDR */
    105         btu_cb.hci_cmd_cb[i].cmd_window = 1;
    106 }
    107 
    108 
    109 /*****************************************************************************
    110 **
    111 ** Function         BTU_AclPktSize
    112 **
    113 ** Description      export the ACL packet size.
    114 **
    115 ** Returns          UINT16
    116 **
    117 ******************************************************************************/
    118 UINT16 BTU_AclPktSize(void)
    119 {
    120     return btu_cb.hcit_acl_pkt_size;
    121 }
    122 /*****************************************************************************
    123 **
    124 ** Function         BTU_BleAclPktSize
    125 **
    126 ** Description      export the BLE ACL packet size.
    127 **
    128 ** Returns          UINT16
    129 **
    130 ******************************************************************************/
    131 UINT16 BTU_BleAclPktSize(void)
    132 {
    133 #if BLE_INCLUDED == TRUE
    134     return btu_cb.hcit_ble_acl_pkt_size;
    135 #else
    136     return 0;
    137 #endif
    138 }
    139 
    140 /*******************************************************************************
    141 **
    142 ** Function         btu_uipc_rx_cback
    143 **
    144 ** Description
    145 **
    146 **
    147 ** Returns          void
    148 **
    149 *******************************************************************************/
    150 void btu_uipc_rx_cback(BT_HDR *p_msg)
    151 {
    152     BT_TRACE_3 (TRACE_LAYER_BTM, TRACE_TYPE_DEBUG, "btu_uipc_rx_cback event 0x%x, len %d, offset %d",
    153 		p_msg->event, p_msg->len, p_msg->offset);
    154     GKI_send_msg(BTU_TASK, BTU_HCI_RCV_MBOX, p_msg);
    155 
    156 }
    157 
    158