NSMBW-Decomp
A decompilation of New Super Mario Bros. Wii
Loading...
Searching...
No Matches
btu.h
1/******************************************************************************
2 *
3 * Copyright (C) 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 "bt_target.h"
31#include "gki.h"
32
33/* Define the BTU mailbox usage
34*/
35#define BTU_HCI_RCV_MBOX TASK_MBOX_0 /* Messages from HCI */
36#define BTU_BTIF_MBOX TASK_MBOX_1 /* Messages to BTIF */
37
38/* callbacks
39*/
40typedef void (*tBTU_TIMER_CALLBACK)(TIMER_LIST_ENT *p_tle);
41typedef void (*tBTU_EVENT_CALLBACK)(BT_HDR *p_hdr);
42
43
44/* Define the timer types maintained by BTU
45*/
46#define BTU_TTYPE_BTM_DEV_CTL 1
47#define BTU_TTYPE_L2CAP_LINK 2
48#define BTU_TTYPE_L2CAP_CHNL 3
49#define BTU_TTYPE_L2CAP_HOLD 4
50#define BTU_TTYPE_SDP 5
51#define BTU_TTYPE_BTM_SCO 6
52#define BTU_TTYPE_BTM_ACL 9
53#define BTU_TTYPE_BTM_RMT_NAME 10
54#define BTU_TTYPE_RFCOMM_MFC 11
55#define BTU_TTYPE_RFCOMM_PORT 12
56#define BTU_TTYPE_TCS_L2CAP 13
57#define BTU_TTYPE_TCS_CALL 14
58#define BTU_TTYPE_TCS_WUG 15
59#define BTU_TTYPE_AUTO_SYNC 16
60#define BTU_TTYPE_CTP_RECON 17
61#define BTU_TTYPE_CTP_T100 18
62#define BTU_TTYPE_CTP_GUARD 19
63#define BTU_TTYPE_CTP_DETACH 20
64
65#define BTU_TTYPE_SPP_CONN_RETRY 21
66#define BTU_TTYPE_USER_FUNC 22
67
68#define BTU_TTYPE_FTP_DISC 25
69#define BTU_TTYPE_OPP_DISC 26
70
71#define BTU_TTYPE_CTP_TL_DISCVY 28
72#define BTU_TTYPE_IPFRAG_TIMER 29
73#define BTU_TTYPE_HSP2_AT_CMD_TO 30
74#define BTU_TTYPE_HSP2_REPEAT_RING 31
75
76#define BTU_TTYPE_CTP_GW_INIT 32
77#define BTU_TTYPE_CTP_GW_CONN 33
78#define BTU_TTYPE_CTP_GW_IDLE 35
79
80#define BTU_TTYPE_ICP_L2CAP 36
81#define BTU_TTYPE_ICP_T100 37
82
83#define BTU_TTYPE_HSP2_WAIT_OK 38
84
85/* HCRP Timers */
86#define BTU_TTYPE_HCRP_NOTIF_REG 39
87#define BTU_TTYPE_HCRP_PROTO_RSP 40
88#define BTU_TTYPE_HCRP_CR_GRANT 41
89#define BTU_TTYPE_HCRP_CR_CHECK 42
90#define BTU_TTYPE_HCRP_W4_CLOSE 43
91
92/* HCRPM Timers */
93#define BTU_TTYPE_HCRPM_NOTIF_REG 44
94#define BTU_TTYPE_HCRPM_NOTIF_KEEP 45
95#define BTU_TTYPE_HCRPM_API_RSP 46
96#define BTU_TTYPE_HCRPM_W4_OPEN 47
97#define BTU_TTYPE_HCRPM_W4_CLOSE 48
98
99/* BNEP Timers */
100#define BTU_TTYPE_BNEP 50
101
102/* OBX */
103#define BTU_TTYPE_OBX_CLIENT_TO 51
104#define BTU_TTYPE_OBX_SERVER_TO 52
105#define BTU_TTYPE_OBX_SVR_SESS_TO 53
106
107
108#define BTU_TTYPE_HSP2_SDP_FAIL_TO 55
109#define BTU_TTYPE_HSP2_SDP_RTRY_TO 56
110
111/* BTU internal */
112/* unused 60 */
113
114#define BTU_TTYPE_AVDT_CCB_RET 61
115#define BTU_TTYPE_AVDT_CCB_RSP 62
116#define BTU_TTYPE_AVDT_CCB_IDLE 63
117#define BTU_TTYPE_AVDT_SCB_TC 64
118
119#define BTU_TTYPE_HID_DEV_REPAGE_TO 65
120#define BTU_TTYPE_HID_HOST_REPAGE_TO 66
121
122#define BTU_TTYPE_HSP2_DELAY_CKPD_RCV 67
123
124#define BTU_TTYPE_SAP_TO 68
125
126/* BPP Timer */
127#define BTU_TTYPE_BPP_REF_CHNL 72
128
129/* LP HC idle Timer */
130#define BTU_TTYPE_LP_HC_IDLE_TO 74
131
132/* Patch RAM Timer */
133#define BTU_TTYPE_PATCHRAM_TO 75
134
135/* eL2CAP Info Request and other proto cmds timer */
136#define BTU_TTYPE_L2CAP_FCR_ACK 78
137#define BTU_TTYPE_L2CAP_INFO 79
138
139/* BTU internal for BR/EDR and AMP HCI command timeout (reserve up to 3 AMP controller) */
140#define BTU_TTYPE_BTU_CMD_CMPL 80
141#define BTU_TTYPE_BTU_AMP1_CMD_CMPL 81
142#define BTU_TTYPE_BTU_AMP2_CMD_CMPL 82
143#define BTU_TTYPE_BTU_AMP3_CMD_CMPL 83
144
145#define BTU_TTYPE_MCA_CCB_RSP 98
146
147/* BTU internal timer for BLE activity */
148#define BTU_TTYPE_BLE_INQUIRY 99
149#define BTU_TTYPE_BLE_GAP_LIM_DISC 100
150#define BTU_TTYPE_ATT_WAIT_FOR_RSP 101
151#define BTU_TTYPE_SMP_PAIRING_CMD 102
152#define BTU_TTYPE_BLE_RANDOM_ADDR 103
153#define BTU_TTYPE_ATT_WAIT_FOR_APP_RSP 104
154#define BTU_TTYPE_ATT_WAIT_FOR_IND_ACK 105
155#define BTU_TTYPE_BLE_SCAN_PARAM_IDLE 106
156
157/* Define the BTU_TASK APPL events
158*/
159#if (defined(NFC_SHARED_TRANSPORT_ENABLED) && (NFC_SHARED_TRANSPORT_ENABLED==TRUE))
160#define BTU_NFC_AVAILABLE_EVT EVENT_MASK(APPL_EVT_0) /* Notifies BTU task that NFC is available (used for shared NFC+BT transport) */
161#endif
162
163/* This is the inquiry response information held by BTU, and available
164** to applications.
165*/
166typedef struct
167{
168 BD_ADDR remote_bd_addr;
169 UINT8 page_scan_rep_mode;
170 UINT8 page_scan_per_mode;
171 UINT8 page_scan_mode;
172 DEV_CLASS dev_class;
173 UINT16 clock_offset;
175
176
177
178#define BTU_MAX_REG_TIMER (2) /* max # timer callbacks which may register */
179#define BTU_MAX_REG_EVENT (6) /* max # event callbacks which may register */
180#define BTU_DEFAULT_DATA_SIZE (0x2a0)
181
182#if (BLE_INCLUDED == TRUE)
183#define BTU_DEFAULT_BLE_DATA_SIZE (27)
184#endif
185
186/* structure to hold registered timers */
187typedef struct
188{
189 TIMER_LIST_ENT *p_tle; /* timer entry */
190 tBTU_TIMER_CALLBACK timer_cb; /* callback triggered when timer expires */
192
193/* structure to hold registered event callbacks */
194typedef struct
195{
196 UINT16 event_range; /* start of event range */
197 tBTU_EVENT_CALLBACK event_cb; /* callback triggered when event is in range */
199
200#define NFC_MAX_LOCAL_CTRLS 0
201
202/* the index to BTU command queue array */
203#define NFC_CONTROLLER_ID (1)
204#define BTU_MAX_LOCAL_CTRLS (1 + NFC_MAX_LOCAL_CTRLS) /* only BR/EDR */
205
206/* AMP HCI control block */
207typedef struct
208{
209 BUFFER_Q cmd_xmit_q;
210 BUFFER_Q cmd_cmpl_q;
211 UINT16 cmd_window;
212 TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */
213#if (defined(BTU_CMD_CMPL_TOUT_DOUBLE_CHECK) && BTU_CMD_CMPL_TOUT_DOUBLE_CHECK == TRUE)
214 BOOLEAN checked_hcisu;
215#endif
217
218/* Define structure holding BTU variables
219*/
220typedef struct
221{
222 tBTU_TIMER_REG timer_reg[BTU_MAX_REG_TIMER];
223 tBTU_EVENT_REG event_reg[BTU_MAX_REG_EVENT];
224
225 TIMER_LIST_Q quick_timer_queue; /* Timer queue for transport level (100/10 msec)*/
226 TIMER_LIST_Q timer_queue; /* Timer queue for normal BTU task (1 second) */
227
228 TIMER_LIST_ENT cmd_cmpl_timer; /* Command complete timer */
229
230 UINT16 hcit_acl_data_size; /* Max ACL data size across HCI transport */
231 UINT16 hcit_acl_pkt_size; /* Max ACL packet size across HCI transport */
232 /* (this is data size plus 4 bytes overhead) */
233
234#if BLE_INCLUDED == TRUE
235 UINT16 hcit_ble_acl_data_size; /* Max BLE ACL data size across HCI transport */
236 UINT16 hcit_ble_acl_pkt_size; /* Max BLE ACL packet size across HCI transport */
237 /* (this is data size plus 4 bytes overhead) */
238#endif
239
240 BOOLEAN reset_complete; /* TRUE after first ack from device received */
241 UINT8 trace_level; /* Trace level for HCI layer */
242
243 tHCI_CMD_CB hci_cmd_cb[BTU_MAX_LOCAL_CTRLS]; /* including BR/EDR */
244} tBTU_CB;
245
246#ifdef __cplusplus
247extern "C" {
248#endif
249
250/* Global BTU data */
251#if BTU_DYNAMIC_MEMORY == FALSE
252BTU_API extern tBTU_CB btu_cb;
253#else
254BTU_API extern tBTU_CB *btu_cb_ptr;
255#define btu_cb (*btu_cb_ptr)
256#endif
257
258BTU_API extern const BD_ADDR BT_BD_ANY;
259
260/* Functions provided by btu_task.c
261************************************
262*/
263BTU_API extern void btu_start_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
264BTU_API extern void btu_stop_timer (TIMER_LIST_ENT *p_tle);
265BTU_API extern void btu_register_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout, tBTU_TIMER_CALLBACK timer_cb);
266BTU_API extern void btu_deregister_timer(TIMER_LIST_ENT *p_tle);
267BTU_API extern UINT32 btu_remaining_time (TIMER_LIST_ENT *p_tle);
268
269
270BTU_API extern void btu_register_event_range (UINT16 range, tBTU_EVENT_CALLBACK event_cb);
271BTU_API extern void btu_deregister_event_range (UINT16 range);
272BTU_API extern void btu_uipc_rx_cback(BT_HDR *p_msg);
273
274BTU_API extern void btu_hcif_flush_cmd_queue(void);
275/*
276** Quick Timer
277*/
278#if defined(QUICK_TIMER_TICKS_PER_SEC) && (QUICK_TIMER_TICKS_PER_SEC > 0)
279#define QUICK_TIMER_TICKS (GKI_SECS_TO_TICKS (1)/QUICK_TIMER_TICKS_PER_SEC)
280BTU_API extern void btu_start_quick_timer (TIMER_LIST_ENT *p_tle, UINT16 type, UINT32 timeout);
281BTU_API extern void btu_stop_quick_timer (TIMER_LIST_ENT *p_tle);
282BTU_API extern void btu_process_quick_timer_evt (void);
283BTU_API extern void process_quick_timer_evt (TIMER_LIST_Q *p_tlq);
284#endif
285
286#if (defined(HCILP_INCLUDED) && HCILP_INCLUDED == TRUE)
287BTU_API extern void btu_check_bt_sleep (void);
288#endif
289
290/* Functions provided by btu_hcif.c
291************************************
292*/
293BTU_API extern void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_buf);
294BTU_API extern void btu_hcif_send_cmd (UINT8 controller_id, BT_HDR *p_msg);
295BTU_API extern void btu_hcif_send_host_rdy_for_data(void);
296BTU_API extern void btu_hcif_cmd_timeout (UINT8 controller_id);
297
298/* Functions provided by btu_core.c
299************************************
300*/
301BTU_API extern void btu_init_core(void);
302BTU_API extern void BTE_Init(void);
303BTU_API extern UINT16 BTU_AclPktSize(void);
304BTU_API extern UINT16 BTU_BleAclPktSize(void);
305
306#ifdef __cplusplus
307}
308#endif
309
310#endif
Definition btu.h:221