• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /******************************************************************************
2  *
3  *  Copyright 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 <base/callback.h>
31 #include <base/location.h>
32 #include <base/threading/thread.h>
33 
34 #include <cstdint>
35 
36 #include "bt_target.h"
37 #include "common/message_loop_thread.h"
38 #include "include/hardware/bluetooth.h"
39 #include "osi/include/alarm.h"
40 #include "osi/include/osi.h"  // UNUSED_ATTR
41 #include "stack/include/bt_hdr.h"
42 
43 /* Global BTU data */
44 extern uint8_t btu_trace_level;
45 
46 /* Functions provided by btu_hcif.cc
47  ***********************************
48 */
49 void btu_hcif_process_event(UNUSED_ATTR uint8_t controller_id,
50                             const BT_HDR* p_buf);
51 void btu_hcif_send_cmd(UNUSED_ATTR uint8_t controller_id, const BT_HDR* p_msg);
52 void btu_hcif_send_cmd_with_cb(const base::Location& posted_from,
53                                uint16_t opcode, uint8_t* params,
54                                uint8_t params_len,
55                                base::OnceCallback<void(uint8_t*, uint16_t)> cb);
56 namespace bluetooth::legacy::testing {
57 void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
58                                  const uint8_t* p_cmd,
59                                  void* p_vsc_status_cback);
60 }  // namespace bluetooth::legacy::testing
61 
62 /* Functions provided by btu_task.cc
63  ***********************************
64 */
65 bluetooth::common::MessageLoopThread* get_main_thread();
66 bt_status_t do_in_main_thread(const base::Location& from_here,
67                               base::OnceClosure task);
68 bt_status_t do_in_main_thread_delayed(const base::Location& from_here,
69                                       base::OnceClosure task,
70                                       const base::TimeDelta& delay);
71 
72 bool is_on_main_thread();
73 using BtMainClosure = std::function<void()>;
74 void post_on_bt_main(BtMainClosure closure);
75 
76 #endif
77