bt_types.h revision eb190654c5fbaea2f396bb5523f57062f291879a
1/**************************************************************************** 2** 3** Name bt_types.h 4** 5** Function this file contains definitions that are shared between 6** units in the Bluetooth system such as events. 7** 8** Copyright (c) 1999-2012, Broadcom Corp., All Rights Reserved. 9** Broadcom Bluetooth Core. Proprietary and confidential. 10** 11****************************************************************************/ 12 13#ifndef BT_TYPES_H 14#define BT_TYPES_H 15 16#include "data_types.h" 17 18#ifdef _WIN32 19#ifdef BLUESTACK_TESTER 20 #include "bte_stack_entry.h" 21#endif 22#endif 23 24/* READ WELL !! 25** 26** This section defines global events. These are events that cross layers. 27** Any event that passes between layers MUST be one of these events. Tasks 28** can use their own events internally, but a FUNDAMENTAL design issue is 29** that global events MUST be one of these events defined below. 30** 31** The convention used is the the event name contains the layer that the 32** event is going to. 33*/ 34#define BT_EVT_MASK 0xFF00 35#define BT_SUB_EVT_MASK 0x00FF 36 /* To Bluetooth Upper Layers */ 37 /************************************/ 38#define BT_EVT_TO_BTU_L2C_EVT 0x0900 /* L2CAP event */ 39#define BT_EVT_TO_BTU_HCI_EVT 0x1000 /* HCI Event */ 40#define BT_EVT_TO_BTU_HCI_BR_EDR_EVT (0x0000 | BT_EVT_TO_BTU_HCI_EVT) /* event from BR/EDR controller */ 41#define BT_EVT_TO_BTU_HCI_AMP1_EVT (0x0001 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 1 controller */ 42#define BT_EVT_TO_BTU_HCI_AMP2_EVT (0x0002 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 2 controller */ 43#define BT_EVT_TO_BTU_HCI_AMP3_EVT (0x0003 | BT_EVT_TO_BTU_HCI_EVT) /* event from local AMP 3 controller */ 44 45#define BT_EVT_TO_BTU_HCI_ACL 0x1100 /* ACL Data from HCI */ 46#define BT_EVT_TO_BTU_HCI_SCO 0x1200 /* SCO Data from HCI */ 47#define BT_EVT_TO_BTU_HCIT_ERR 0x1300 /* HCI Transport Error */ 48 49#define BT_EVT_TO_BTU_SP_EVT 0x1400 /* Serial Port Event */ 50#define BT_EVT_TO_BTU_SP_DATA 0x1500 /* Serial Port Data */ 51 52#define BT_EVT_TO_BTU_HCI_CMD 0x1600 /* HCI command from upper layer */ 53 54 55#define BT_EVT_TO_BTU_L2C_SEG_XMIT 0x1900 /* L2CAP segment(s) transmitted */ 56 57#define BT_EVT_PROXY_INCOMING_MSG 0x1A00 /* BlueStackTester event: incoming message from target */ 58 59#define BT_EVT_BTSIM 0x1B00 /* Insight BTSIM event */ 60#define BT_EVT_BTISE 0x1C00 /* Insight Script Engine event */ 61 62 /* To LM */ 63 /************************************/ 64#define BT_EVT_TO_LM_HCI_CMD 0x2000 /* HCI Command */ 65#define BT_EVT_TO_LM_HCI_ACL 0x2100 /* HCI ACL Data */ 66#define BT_EVT_TO_LM_HCI_SCO 0x2200 /* HCI SCO Data */ 67#define BT_EVT_TO_LM_HCIT_ERR 0x2300 /* HCI Transport Error */ 68#define BT_EVT_TO_LM_LC_EVT 0x2400 /* LC event */ 69#define BT_EVT_TO_LM_LC_LMP 0x2500 /* LC Received LMP command frame */ 70#define BT_EVT_TO_LM_LC_ACL 0x2600 /* LC Received ACL data */ 71#define BT_EVT_TO_LM_LC_SCO 0x2700 /* LC Received SCO data (not used) */ 72#define BT_EVT_TO_LM_LC_ACL_TX 0x2800 /* LMP data transmit complete */ 73#define BT_EVT_TO_LM_LC_LMPC_TX 0x2900 /* LMP Command transmit complete */ 74#define BT_EVT_TO_LM_LOCAL_ACL_LB 0x2a00 /* Data to be locally loopbacked */ 75#define BT_EVT_TO_LM_HCI_ACL_ACK 0x2b00 /* HCI ACL Data ack (not used) */ 76#define BT_EVT_TO_LM_DIAG 0x2c00 /* LM Diagnostics commands */ 77 78 79#define BT_EVT_TO_BTM_CMDS 0x2f00 80#define BT_EVT_TO_BTM_PM_MDCHG_EVT (0x0001 | BT_EVT_TO_BTM_CMDS) 81 82#define BT_EVT_TO_TCS_CMDS 0x3000 83 84#define BT_EVT_TO_OBX_CL_MSG 0x3100 85#define BT_EVT_TO_OBX_SR_MSG 0x3200 86 87#define BT_EVT_TO_CTP_CMDS 0x3300 88 89/* Obex Over L2CAP */ 90#define BT_EVT_TO_OBX_CL_L2C_MSG 0x3400 91#define BT_EVT_TO_OBX_SR_L2C_MSG 0x3500 92 93/* ftp events */ 94#define BT_EVT_TO_FTP_SRVR_CMDS 0x3600 95#define BT_EVT_TO_FTP_CLNT_CMDS 0x3700 96 97#define BT_EVT_TO_BTU_SAP 0x3800 /* SIM Access Profile events */ 98 99/* opp events */ 100#define BT_EVT_TO_OPP_SRVR_CMDS 0x3900 101#define BT_EVT_TO_OPP_CLNT_CMDS 0x3a00 102 103/* gap events */ 104#define BT_EVT_TO_GAP_MSG 0x3b00 105 106/* start timer */ 107#define BT_EVT_TO_START_TIMER 0x3c00 108 109/* stop timer */ 110#define BT_EVT_TO_STOP_TIMER 0x3d00 111 112/* start quick timer */ 113#define BT_EVT_TO_START_QUICK_TIMER 0x3e00 114 115 116/* for NFC */ 117 /************************************/ 118#define BT_EVT_TO_NFC_NCI 0x4000 /* NCI Command, Notification or Data*/ 119#define BT_EVT_TO_NFC_NCI_VS 0x4200 /* Vendor specific message */ 120#define BT_EVT_TO_NFC_MSGS 0x4300 /* messages between NFC and NCI task */ 121 122#define BT_EVT_TO_NFCCSIM_NCI 0x4a00 /* events to NFCC simulation (NCI packets) */ 123 124/* HCISU Events */ 125 126#define BT_EVT_HCISU 0x5000 127 128#define BT_EVT_TO_HCISU_LP_APP_SLEEPING_EVT (0x0005 | BT_EVT_HCISU) 129#define BT_EVT_TO_HCISU_LP_ALLOW_BT_SLEEP_EVT (0x0006 | BT_EVT_HCISU) 130#define BT_EVT_TO_HCISU_LP_WAKEUP_HOST_EVT (0x0007 | BT_EVT_HCISU) 131#define BT_EVT_TO_HCISU_LP_RCV_H4IBSS_EVT (0x0008 | BT_EVT_HCISU) 132#define BT_EVT_TO_HCISU_H5_RESET_EVT (0x0009 | BT_EVT_HCISU) 133#define BT_EVT_HCISU_START_QUICK_TIMER (0x000a | BT_EVT_HCISU) 134 135#define BT_EVT_DATA_TO_AMP_1 0x5100 136#define BT_EVT_DATA_TO_AMP_15 0x5f00 137 138/* HSP Events */ 139 140#define BT_EVT_BTU_HSP2 0x6000 141 142#define BT_EVT_TO_BTU_HSP2_EVT (0x0001 | BT_EVT_BTU_HSP2) 143 144/* BPP Events */ 145#define BT_EVT_TO_BPP_PR_CMDS 0x6100 /* Printer Events */ 146#define BT_EVT_TO_BPP_SND_CMDS 0x6200 /* BPP Sender Events */ 147 148/* BIP Events */ 149#define BT_EVT_TO_BIP_CMDS 0x6300 150 151/* HCRP Events */ 152 153#define BT_EVT_BTU_HCRP 0x7000 154 155#define BT_EVT_TO_BTU_HCRP_EVT (0x0001 | BT_EVT_BTU_HCRP) 156#define BT_EVT_TO_BTU_HCRPM_EVT (0x0002 | BT_EVT_BTU_HCRP) 157 158 159#define BT_EVT_BTU_HFP 0x8000 160#define BT_EVT_TO_BTU_HFP_EVT (0x0001 | BT_EVT_BTU_HFP) 161 162#define BT_EVT_BTU_IPC_EVT 0x9000 163#define BT_EVT_BTU_IPC_LOGMSG_EVT (0x0000 | BT_EVT_BTU_IPC_EVT) 164#define BT_EVT_BTU_IPC_ACL_EVT (0x0001 | BT_EVT_BTU_IPC_EVT) 165#define BT_EVT_BTU_IPC_BTU_EVT (0x0002 | BT_EVT_BTU_IPC_EVT) 166#define BT_EVT_BTU_IPC_L2C_EVT (0x0003 | BT_EVT_BTU_IPC_EVT) 167#define BT_EVT_BTU_IPC_L2C_MSG_EVT (0x0004 | BT_EVT_BTU_IPC_EVT) 168#define BT_EVT_BTU_IPC_BTM_EVT (0x0005 | BT_EVT_BTU_IPC_EVT) 169#define BT_EVT_BTU_IPC_AVDT_EVT (0x0006 | BT_EVT_BTU_IPC_EVT) 170#define BT_EVT_BTU_IPC_SLIP_EVT (0x0007 | BT_EVT_BTU_IPC_EVT) 171#define BT_EVT_BTU_IPC_MGMT_EVT (0x0008 | BT_EVT_BTU_IPC_EVT) 172#define BT_EVT_BTU_IPC_BTTRC_EVT (0x0009 | BT_EVT_BTU_IPC_EVT) 173#define BT_EVT_BTU_IPC_BURST_EVT (0x000A | BT_EVT_BTU_IPC_EVT) 174 175/* Define the header of each buffer used in the Bluetooth stack. 176*/ 177typedef struct 178{ 179 UINT16 event; 180 UINT16 len; 181 UINT16 offset; 182 UINT16 layer_specific; 183} BT_HDR; 184 185#define BT_HDR_SIZE (sizeof (BT_HDR)) 186 187#define BT_PSM_SDP 0x0001 188#define BT_PSM_RFCOMM 0x0003 189#define BT_PSM_TCS 0x0005 190#define BT_PSM_CTP 0x0007 191#define BT_PSM_BNEP 0x000F 192#define BT_PSM_HIDC 0x0011 193#define BT_PSM_HIDI 0x0013 194#define BT_PSM_UPNP 0x0015 195#define BT_PSM_AVCTP 0x0017 196#define BT_PSM_AVDTP 0x0019 197#define BT_PSM_AVCTP_13 0x001B /* Advanced Control - Browsing */ 198#define BT_PSM_UDI_CP 0x001D /* Unrestricted Digital Information Profile C-Plane */ 199#define BT_PSM_ATT 0x001F /* Attribute Protocol */ 200 201 202/* These macros extract the HCI opcodes from a buffer 203*/ 204#define HCI_GET_CMD_HDR_OPCODE(p) (UINT16)((*((UINT8 *)((p) + 1) + p->offset) + \ 205 (*((UINT8 *)((p) + 1) + p->offset + 1) << 8))) 206#define HCI_GET_CMD_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 2)) 207 208#define HCI_GET_EVT_HDR_OPCODE(p) (UINT8)(*((UINT8 *)((p) + 1) + p->offset)) 209#define HCI_GET_EVT_HDR_PARAM_LEN(p) (UINT8) (*((UINT8 *)((p) + 1) + p->offset + 1)) 210 211 212/******************************************************************************** 213** Macros to get and put bytes to and from a stream (Little Endian format). 214*/ 215#define UINT32_TO_STREAM(p, u32) {*(p)++ = (UINT8)(u32); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 24);} 216#define UINT24_TO_STREAM(p, u24) {*(p)++ = (UINT8)(u24); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)((u24) >> 16);} 217#define UINT16_TO_STREAM(p, u16) {*(p)++ = (UINT8)(u16); *(p)++ = (UINT8)((u16) >> 8);} 218#define UINT8_TO_STREAM(p, u8) {*(p)++ = (UINT8)(u8);} 219#define INT8_TO_STREAM(p, u8) {*(p)++ = (INT8)(u8);} 220#define ARRAY32_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 32; ijk++) *(p)++ = (UINT8) a[31 - ijk];} 221#define ARRAY16_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 16; ijk++) *(p)++ = (UINT8) a[15 - ijk];} 222#define ARRAY8_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < 8; ijk++) *(p)++ = (UINT8) a[7 - ijk];} 223#define BDADDR_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *(p)++ = (UINT8) a[BD_ADDR_LEN - 1 - ijk];} 224#define LAP_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < LAP_LEN; ijk++) *(p)++ = (UINT8) a[LAP_LEN - 1 - ijk];} 225#define DEVCLASS_TO_STREAM(p, a) {register int ijk; for (ijk = 0; ijk < DEV_CLASS_LEN;ijk++) *(p)++ = (UINT8) a[DEV_CLASS_LEN - 1 - ijk];} 226#define ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];} 227#define REVERSE_ARRAY_TO_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[len - 1 - ijk];} 228 229#define STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;} 230#define STREAM_TO_UINT16(u16, p) {u16 = ((UINT16)(*(p)) + (((UINT16)(*((p) + 1))) << 8)); (p) += 2;} 231#define STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) ); (p) += 3;} 232#define STREAM_TO_UINT32(u32, p) {u32 = (((UINT32)(*(p))) + ((((UINT32)(*((p) + 1)))) << 8) + ((((UINT32)(*((p) + 2)))) << 16) + ((((UINT32)(*((p) + 3)))) << 24)); (p) += 4;} 233#define STREAM_TO_BDADDR(a, p) {register int ijk; register UINT8 *pbda = (UINT8 *)a + BD_ADDR_LEN - 1; for (ijk = 0; ijk < BD_ADDR_LEN; ijk++) *pbda-- = *p++;} 234#define STREAM_TO_ARRAY32(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 31; for (ijk = 0; ijk < 32; ijk++) *_pa-- = *p++;} 235#define STREAM_TO_ARRAY16(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 15; for (ijk = 0; ijk < 16; ijk++) *_pa-- = *p++;} 236#define STREAM_TO_ARRAY8(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + 7; for (ijk = 0; ijk < 8; ijk++) *_pa-- = *p++;} 237#define STREAM_TO_DEVCLASS(a, p) {register int ijk; register UINT8 *_pa = (UINT8 *)a + DEV_CLASS_LEN - 1; for (ijk = 0; ijk < DEV_CLASS_LEN; ijk++) *_pa-- = *p++;} 238#define STREAM_TO_LAP(a, p) {register int ijk; register UINT8 *plap = (UINT8 *)a + LAP_LEN - 1; for (ijk = 0; ijk < LAP_LEN; ijk++) *plap-- = *p++;} 239#define STREAM_TO_ARRAY(a, p, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;} 240#define REVERSE_STREAM_TO_ARRAY(a, p, len) {register int ijk; register UINT8 *_pa = (UINT8 *)a + len - 1; for (ijk = 0; ijk < len; ijk++) *_pa-- = *p++;} 241 242/******************************************************************************** 243** Macros to get and put bytes to and from a field (Little Endian format). 244** These are the same as to stream, except the pointer is not incremented. 245*/ 246#define UINT32_TO_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)(u32); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+3) = (UINT8)((u32) >> 24);} 247#define UINT24_TO_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)(u24); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)((u24) >> 16);} 248#define UINT16_TO_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)(u16); *((UINT8 *)(p)+1) = (UINT8)((u16) >> 8);} 249#define UINT8_TO_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);} 250 251 252/******************************************************************************** 253** Macros to get and put bytes to and from a stream (Big Endian format) 254*/ 255#define UINT32_TO_BE_STREAM(p, u32) {*(p)++ = (UINT8)((u32) >> 24); *(p)++ = (UINT8)((u32) >> 16); *(p)++ = (UINT8)((u32) >> 8); *(p)++ = (UINT8)(u32); } 256#define UINT24_TO_BE_STREAM(p, u24) {*(p)++ = (UINT8)((u24) >> 16); *(p)++ = (UINT8)((u24) >> 8); *(p)++ = (UINT8)(u24);} 257#define UINT16_TO_BE_STREAM(p, u16) {*(p)++ = (UINT8)((u16) >> 8); *(p)++ = (UINT8)(u16);} 258#define UINT8_TO_BE_STREAM(p, u8) {*(p)++ = (UINT8)(u8);} 259#define ARRAY_TO_BE_STREAM(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) *(p)++ = (UINT8) a[ijk];} 260 261#define BE_STREAM_TO_UINT8(u8, p) {u8 = (UINT8)(*(p)); (p) += 1;} 262#define BE_STREAM_TO_UINT16(u16, p) {u16 = (UINT16)(((UINT16)(*(p)) << 8) + (UINT16)(*((p) + 1))); (p) += 2;} 263#define BE_STREAM_TO_UINT24(u32, p) {u32 = (((UINT32)(*((p) + 2))) + ((UINT32)(*((p) + 1)) << 8) + ((UINT32)(*(p)) << 16)); (p) += 3;} 264#define BE_STREAM_TO_UINT32(u32, p) {u32 = ((UINT32)(*((p) + 3)) + ((UINT32)(*((p) + 2)) << 8) + ((UINT32)(*((p) + 1)) << 16) + ((UINT32)(*(p)) << 24)); (p) += 4;} 265#define BE_STREAM_TO_ARRAY(p, a, len) {register int ijk; for (ijk = 0; ijk < len; ijk++) ((UINT8 *) a)[ijk] = *p++;} 266 267 268/******************************************************************************** 269** Macros to get and put bytes to and from a field (Big Endian format). 270** These are the same as to stream, except the pointer is not incremented. 271*/ 272#define UINT32_TO_BE_FIELD(p, u32) {*(UINT8 *)(p) = (UINT8)((u32) >> 24); *((UINT8 *)(p)+1) = (UINT8)((u32) >> 16); *((UINT8 *)(p)+2) = (UINT8)((u32) >> 8); *((UINT8 *)(p)+3) = (UINT8)(u32); } 273#define UINT24_TO_BE_FIELD(p, u24) {*(UINT8 *)(p) = (UINT8)((u24) >> 16); *((UINT8 *)(p)+1) = (UINT8)((u24) >> 8); *((UINT8 *)(p)+2) = (UINT8)(u24);} 274#define UINT16_TO_BE_FIELD(p, u16) {*(UINT8 *)(p) = (UINT8)((u16) >> 8); *((UINT8 *)(p)+1) = (UINT8)(u16);} 275#define UINT8_TO_BE_FIELD(p, u8) {*(UINT8 *)(p) = (UINT8)(u8);} 276 277 278/* Common Bluetooth field definitions */ 279#define BD_ADDR_LEN 6 /* Device address length */ 280typedef UINT8 BD_ADDR[BD_ADDR_LEN]; /* Device address */ 281typedef UINT8 *BD_ADDR_PTR; /* Pointer to Device Address */ 282 283#define AMP_KEY_TYPE_GAMP 0 284#define AMP_KEY_TYPE_WIFI 1 285#define AMP_KEY_TYPE_UWB 2 286typedef UINT8 tAMP_KEY_TYPE; 287 288#define BT_OCTET8_LEN 8 289typedef UINT8 BT_OCTET8[BT_OCTET8_LEN]; /* octet array: size 16 */ 290 291#define LINK_KEY_LEN 16 292typedef UINT8 LINK_KEY[LINK_KEY_LEN]; /* Link Key */ 293 294#define AMP_LINK_KEY_LEN 32 295typedef UINT8 AMP_LINK_KEY[AMP_LINK_KEY_LEN]; /* Dedicated AMP and GAMP Link Keys */ 296 297#define BT_OCTET16_LEN 16 298typedef UINT8 BT_OCTET16[BT_OCTET16_LEN]; /* octet array: size 16 */ 299 300#define PIN_CODE_LEN 16 301typedef UINT8 PIN_CODE[PIN_CODE_LEN]; /* Pin Code (upto 128 bits) MSB is 0 */ 302typedef UINT8 *PIN_CODE_PTR; /* Pointer to Pin Code */ 303 304#define DEV_CLASS_LEN 3 305typedef UINT8 DEV_CLASS[DEV_CLASS_LEN]; /* Device class */ 306typedef UINT8 *DEV_CLASS_PTR; /* Pointer to Device class */ 307 308#define EXT_INQ_RESP_LEN 3 309typedef UINT8 EXT_INQ_RESP[EXT_INQ_RESP_LEN];/* Extended Inquiry Response */ 310typedef UINT8 *EXT_INQ_RESP_PTR; /* Pointer to Extended Inquiry Response */ 311 312#define BD_NAME_LEN 248 313typedef UINT8 BD_NAME[BD_NAME_LEN + 1]; /* Device name */ 314typedef UINT8 *BD_NAME_PTR; /* Pointer to Device name */ 315 316#define BD_FEATURES_LEN 8 317typedef UINT8 BD_FEATURES[BD_FEATURES_LEN]; /* LMP features supported by device */ 318 319#define BT_EVENT_MASK_LEN 8 320typedef UINT8 BT_EVENT_MASK[BT_EVENT_MASK_LEN]; /* Event Mask */ 321 322#define LAP_LEN 3 323typedef UINT8 LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */ 324typedef UINT8 INQ_LAP[LAP_LEN]; /* IAC as passed to Inquiry (LAP) */ 325 326#define RAND_NUM_LEN 16 327typedef UINT8 RAND_NUM[RAND_NUM_LEN]; 328 329#define ACO_LEN 12 330typedef UINT8 ACO[ACO_LEN]; /* Authenticated ciphering offset */ 331 332#define COF_LEN 12 333typedef UINT8 COF[COF_LEN]; /* ciphering offset number */ 334 335typedef struct { 336 UINT8 qos_flags; /* TBD */ 337 UINT8 service_type; /* see below */ 338 UINT32 token_rate; /* bytes/second */ 339 UINT32 token_bucket_size; /* bytes */ 340 UINT32 peak_bandwidth; /* bytes/second */ 341 UINT32 latency; /* microseconds */ 342 UINT32 delay_variation; /* microseconds */ 343} FLOW_SPEC; 344 345/* Values for service_type */ 346#define NO_TRAFFIC 0 347#define BEST_EFFORT 1 348#define GUARANTEED 2 349 350/* Service class of the CoD */ 351#define SERV_CLASS_NETWORKING (1 << 1) 352#define SERV_CLASS_RENDERING (1 << 2) 353#define SERV_CLASS_CAPTURING (1 << 3) 354#define SERV_CLASS_OBJECT_TRANSFER (1 << 4) 355#define SERV_CLASS_OBJECT_AUDIO (1 << 5) 356#define SERV_CLASS_OBJECT_TELEPHONY (1 << 6) 357#define SERV_CLASS_OBJECT_INFORMATION (1 << 7) 358 359/* Second byte */ 360#define SERV_CLASS_LIMITED_DISC_MODE (0x20) 361 362/* Field size definitions. Note that byte lengths are rounded up. */ 363#define ACCESS_CODE_BIT_LEN 72 364#define ACCESS_CODE_BYTE_LEN 9 365#define SHORTENED_ACCESS_CODE_BIT_LEN 68 366 367typedef UINT8 ACCESS_CODE[ACCESS_CODE_BYTE_LEN]; 368 369#define SYNTH_TX 1 /* want synth code to TRANSMIT at this freq */ 370#define SYNTH_RX 2 /* want synth code to RECEIVE at this freq */ 371 372#define SYNC_REPS 1 /* repeats of sync word transmitted to start of burst */ 373 374/* Bluetooth CLK27 */ 375#define BT_CLK27 (2 << 26) 376 377/* Bluetooth CLK12 is 1.28 sec */ 378#define BT_CLK12_TO_MS(x) ((x) * 1280) 379#define BT_MS_TO_CLK12(x) ((x) / 1280) 380#define BT_CLK12_TO_SLOTS(x) ((x) << 11) 381 382/* Bluetooth CLK is 0.625 msec */ 383#define BT_CLK_TO_MS(x) (((x) * 5 + 3) / 8) 384#define BT_MS_TO_CLK(x) (((x) * 8 + 2) / 5) 385 386#define BT_CLK_TO_MICROSECS(x) (((x) * 5000 + 3) / 8) 387#define BT_MICROSECS_TO_CLK(x) (((x) * 8 + 2499) / 5000) 388 389/* Maximum UUID size - 16 bytes, and structure to hold any type of UUID. */ 390#define MAX_UUID_SIZE 16 391typedef struct 392{ 393#define LEN_UUID_16 2 394#define LEN_UUID_32 4 395#define LEN_UUID_128 16 396 397 UINT16 len; 398 399 union 400 { 401 UINT16 uuid16; 402 UINT32 uuid32; 403 UINT8 uuid128[MAX_UUID_SIZE]; 404 } uu; 405 406} tBT_UUID; 407 408#define BT_EIR_FLAGS_TYPE 0x01 409#define BT_EIR_MORE_16BITS_UUID_TYPE 0x02 410#define BT_EIR_COMPLETE_16BITS_UUID_TYPE 0x03 411#define BT_EIR_MORE_32BITS_UUID_TYPE 0x04 412#define BT_EIR_COMPLETE_32BITS_UUID_TYPE 0x05 413#define BT_EIR_MORE_128BITS_UUID_TYPE 0x06 414#define BT_EIR_COMPLETE_128BITS_UUID_TYPE 0x07 415#define BT_EIR_SHORTENED_LOCAL_NAME_TYPE 0x08 416#define BT_EIR_COMPLETE_LOCAL_NAME_TYPE 0x09 417#define BT_EIR_TX_POWER_LEVEL_TYPE 0x0A 418#define BT_EIR_OOB_BD_ADDR_TYPE 0x0C 419#define BT_EIR_OOB_COD_TYPE 0x0D 420#define BT_EIR_OOB_SSP_HASH_C_TYPE 0x0E 421#define BT_EIR_OOB_SSP_RAND_R_TYPE 0x0F 422#define BT_EIR_MANUFACTURER_SPECIFIC_TYPE 0xFF 423 424#define BT_OOB_COD_SIZE 3 425#define BT_OOB_HASH_C_SIZE 16 426#define BT_OOB_RAND_R_SIZE 16 427 428/* Broadcom proprietary UUIDs and reserved PSMs 429** 430** The lowest 4 bytes byte of the UUID or GUID depends on the feature. Typically, 431** the value of those bytes will be the PSM or SCN, but it is up to the features. 432*/ 433#define BRCM_PROPRIETARY_UUID_BASE 0xDA, 0x23, 0x41, 0x02, 0xA3, 0xBB, 0xC1, 0x71, 0xBA, 0x09, 0x6f, 0x21 434#define BRCM_PROPRIETARY_GUID_BASE 0xda23, 0x4102, 0xa3, 0xbb, 0xc1, 0x71, 0xba, 0x09, 0x6f, 0x21 435 436/* We will not allocate a PSM in the reserved range to 3rd party apps 437*/ 438#define BRCM_RESERVED_PSM_START 0x5AE1 439#define BRCM_RESERVED_PSM_END 0x5AFF 440 441#define BRCM_UTILITY_SERVICE_PSM 0x5AE1 442#define BRCM_MATCHER_PSM 0x5AE3 443 444/* Connection statistics 445*/ 446 447/* Structure to hold connection stats */ 448#ifndef BT_CONN_STATS_DEFINED 449#define BT_CONN_STATS_DEFINED 450 451/* These bits are used in the bIsConnected field */ 452#define BT_CONNECTED_USING_BREDR 1 453#define BT_CONNECTED_USING_AMP 2 454 455typedef struct 456{ 457 UINT32 is_connected; 458 INT32 rssi; 459 UINT32 bytes_sent; 460 UINT32 bytes_rcvd; 461 UINT32 duration; 462} tBT_CONN_STATS; 463 464#endif 465 466/* AMP transport selection criteria definitions. 467** NOTE: if underlying L2CAP connection uses basic mode than it can use only BR/EDR. 468** For such L2CAP connections AMP connection the criteria provided by application 469** is reset by AMP manager to AMP_USE_AMP_NEVER. 470*/ 471#define AMP_USE_AMP_NEVER 0 /* Connection only via BR/EDR controller, no AMP allowed */ 472#define AMP_USE_AMP_IF_PEER_TRIES_IT 1 /* Allow AMP to be used if the peer tries to use it */ 473#define AMP_USE_AMP_IF_PHY_CONN_EXISTS 2 /* Use AMP if there is already a physical connection (default) */ 474#define AMP_USE_AMP_IF_LC_POWER_ON 3 /* Only try to use AMP if the Local Controller is powered on */ 475#define AMP_USE_AMP_IF_LC_AND_PEER_POWER_ON 4 /* Only try to use AMP if both LC and peer are powered on */ 476#define AMP_USE_AMP_IF_POSSIBLE 5 /* Try to use AMP if at all possible */ 477#define AMP_USE_AMP_ONLY 6 /* Only use AMP, never use BR/EDR */ 478#define AMP_USE_AMP_MAX_DEF AMP_USE_AMP_ONLY /* Maximum enum defined for AMP Criteria */ 479 480#define AMP_AUTOSWITCH_ALLOWED 0x80000000 /* flag to indicate that this connection is auto-switch ready */ 481#define AMP_USE_CURRENT_CRITERIA 0xFFFFFFFF /* Flag if previous criteria was to be still used */ 482 483typedef UINT32 tAMP_CRITERIA; 484 485 486/***************************************************************************** 487** Low Energy definitions 488** 489** Address types 490*/ 491#define BLE_ADDR_PUBLIC 0x00 492#define BLE_ADDR_RANDOM 0x01 493#define BLE_ADDR_TYPE_MASK (BLE_ADDR_RANDOM | BLE_ADDR_PUBLIC) 494typedef UINT8 tBLE_ADDR_TYPE; 495 496#define BLE_ADDR_IS_STATIC(x) ((x[0] & 0xC0) == 0xC0) 497 498typedef struct 499{ 500 tBLE_ADDR_TYPE type; 501 BD_ADDR bda; 502} tBLE_BD_ADDR; 503 504/* Device Types 505*/ 506#define BT_DEVICE_TYPE_BREDR 0x01 507#define BT_DEVICE_TYPE_BLE 0x02 508#define BT_DEVICE_TYPE_DUMO 0x03 509typedef UINT8 tBT_DEVICE_TYPE; 510/*****************************************************************************/ 511 512 513/* Define trace levels */ 514#define BT_TRACE_LEVEL_NONE 0 /* No trace messages to be generated */ 515#define BT_TRACE_LEVEL_ERROR 1 /* Error condition trace messages */ 516#define BT_TRACE_LEVEL_WARNING 2 /* Warning condition trace messages */ 517#define BT_TRACE_LEVEL_API 3 /* API traces */ 518#define BT_TRACE_LEVEL_EVENT 4 /* Debug messages for events */ 519#define BT_TRACE_LEVEL_DEBUG 5 /* Full debug messages */ 520 521#define MAX_TRACE_LEVEL 5 522 523 524/* Define New Trace Type Definition */ 525/* TRACE_CTRL_TYPE 0x^^000000*/ 526#define TRACE_CTRL_MASK 0xff000000 527#define TRACE_GET_CTRL(x) ((((UINT32)(x)) & TRACE_CTRL_MASK) >> 24) 528 529#define TRACE_CTRL_GENERAL 0x00000000 530#define TRACE_CTRL_STR_RESOURCE 0x01000000 531#define TRACE_CTRL_SEQ_FLOW 0x02000000 532#define TRACE_CTRL_MAX_NUM 3 533 534/* LAYER SPECIFIC 0x00^^0000*/ 535#define TRACE_LAYER_MASK 0x00ff0000 536#define TRACE_GET_LAYER(x) ((((UINT32)(x)) & TRACE_LAYER_MASK) >> 16) 537 538#define TRACE_LAYER_NONE 0x00000000 539#define TRACE_LAYER_USB 0x00010000 540#define TRACE_LAYER_SERIAL 0x00020000 541#define TRACE_LAYER_SOCKET 0x00030000 542#define TRACE_LAYER_RS232 0x00040000 543#define TRACE_LAYER_TRANS_MAX_NUM 5 544#define TRACE_LAYER_TRANS_ALL 0x007f0000 545#define TRACE_LAYER_LC 0x00050000 546#define TRACE_LAYER_LM 0x00060000 547#define TRACE_LAYER_HCI 0x00070000 548#define TRACE_LAYER_L2CAP 0x00080000 549#define TRACE_LAYER_RFCOMM 0x00090000 550#define TRACE_LAYER_SDP 0x000a0000 551#define TRACE_LAYER_TCS 0x000b0000 552#define TRACE_LAYER_OBEX 0x000c0000 553#define TRACE_LAYER_BTM 0x000d0000 554#define TRACE_LAYER_GAP 0x000e0000 555#define TRACE_LAYER_DUN 0x000f0000 556#define TRACE_LAYER_GOEP 0x00100000 557#define TRACE_LAYER_ICP 0x00110000 558#define TRACE_LAYER_HSP2 0x00120000 559#define TRACE_LAYER_SPP 0x00130000 560#define TRACE_LAYER_CTP 0x00140000 561#define TRACE_LAYER_BPP 0x00150000 562#define TRACE_LAYER_HCRP 0x00160000 563#define TRACE_LAYER_FTP 0x00170000 564#define TRACE_LAYER_OPP 0x00180000 565#define TRACE_LAYER_BTU 0x00190000 566#define TRACE_LAYER_GKI 0x001a0000 567#define TRACE_LAYER_BNEP 0x001b0000 568#define TRACE_LAYER_PAN 0x001c0000 569#define TRACE_LAYER_HFP 0x001d0000 570#define TRACE_LAYER_HID 0x001e0000 571#define TRACE_LAYER_BIP 0x001f0000 572#define TRACE_LAYER_AVP 0x00200000 573#define TRACE_LAYER_A2D 0x00210000 574#define TRACE_LAYER_SAP 0x00220000 575#define TRACE_LAYER_AMP 0x00230000 576#define TRACE_LAYER_MCA 0x00240000 577#define TRACE_LAYER_ATT 0x00250000 578#define TRACE_LAYER_SMP 0x00260000 579#define TRACE_LAYER_NFC 0x00270000 580#define TRACE_LAYER_NCI 0x00280000 581#define TRACE_LAYER_LLCP 0x00290000 582#define TRACE_LAYER_NDEF 0x002a0000 583#define TRACE_LAYER_RW 0x002b0000 584#define TRACE_LAYER_CE 0x002c0000 585#define TRACE_LAYER_P2P 0x002d0000 586#define TRACE_LAYER_SNEP 0x002e0000 587#define TRACE_LAYER_CHO 0x002f0000 588#define TRACE_LAYER_NFA 0x00300000 589 590#define TRACE_LAYER_MAX_NUM 0x0031 591 592 593/* TRACE_ORIGINATOR 0x0000^^00*/ 594#define TRACE_ORG_MASK 0x0000ff00 595#define TRACE_GET_ORG(x) ((((UINT32)(x)) & TRACE_ORG_MASK) >> 8) 596 597#define TRACE_ORG_STACK 0x00000000 598#define TRACE_ORG_HCI_TRANS 0x00000100 599#define TRACE_ORG_PROTO_DISP 0x00000200 600#define TRACE_ORG_RPC 0x00000300 601#define TRACE_ORG_GKI 0x00000400 602#define TRACE_ORG_APPL 0x00000500 603#define TRACE_ORG_SCR_WRAPPER 0x00000600 604#define TRACE_ORG_SCR_ENGINE 0x00000700 605#define TRACE_ORG_USER_SCR 0x00000800 606#define TRACE_ORG_TESTER 0x00000900 607#define TRACE_ORG_MAX_NUM 10 /* 32-bit mask; must be < 32 */ 608#define TRACE_LITE_ORG_MAX_NUM 6 609#define TRACE_ORG_ALL 0x03ff 610#define TRACE_ORG_RPC_TRANS 0x04 611 612#define TRACE_ORG_REG 0x00000909 613#define TRACE_ORG_REG_SUCCESS 0x0000090a 614 615/* TRACE_TYPE 0x000000^^*/ 616#define TRACE_TYPE_MASK 0x000000ff 617#define TRACE_GET_TYPE(x) (((UINT32)(x)) & TRACE_TYPE_MASK) 618 619#define TRACE_TYPE_ERROR 0x00000000 620#define TRACE_TYPE_WARNING 0x00000001 621#define TRACE_TYPE_API 0x00000002 622#define TRACE_TYPE_EVENT 0x00000003 623#define TRACE_TYPE_DEBUG 0x00000004 624#define TRACE_TYPE_STACK_ONLY_MAX TRACE_TYPE_DEBUG 625#define TRACE_TYPE_TX 0x00000005 626#define TRACE_TYPE_RX 0x00000006 627#define TRACE_TYPE_DEBUG_ASSERT 0x00000007 628#define TRACE_TYPE_GENERIC 0x00000008 629#define TRACE_TYPE_REG 0x00000009 630#define TRACE_TYPE_REG_SUCCESS 0x0000000a 631#define TRACE_TYPE_CMD_TX 0x0000000b 632#define TRACE_TYPE_EVT_TX 0x0000000c 633#define TRACE_TYPE_ACL_TX 0x0000000d 634#define TRACE_TYPE_CMD_RX 0x0000000e 635#define TRACE_TYPE_EVT_RX 0x0000000f 636#define TRACE_TYPE_ACL_RX 0x00000010 637#define TRACE_TYPE_TARGET_TRACE 0x00000011 638#define TRACE_TYPE_SCO_TX 0x00000012 639#define TRACE_TYPE_SCO_RX 0x00000013 640 641 642#define TRACE_TYPE_MAX_NUM 20 643#define TRACE_TYPE_ALL 0xffff 644 645/* Define color for script type */ 646#define SCR_COLOR_DEFAULT 0 647#define SCR_COLOR_TYPE_COMMENT 1 648#define SCR_COLOR_TYPE_COMMAND 2 649#define SCR_COLOR_TYPE_EVENT 3 650#define SCR_COLOR_TYPE_SELECT 4 651 652/* Define protocol trace flag values */ 653#define SCR_PROTO_TRACE_HCI_SUMMARY 0x00000001 654#define SCR_PROTO_TRACE_HCI_DATA 0x00000002 655#define SCR_PROTO_TRACE_L2CAP 0x00000004 656#define SCR_PROTO_TRACE_RFCOMM 0x00000008 657#define SCR_PROTO_TRACE_SDP 0x00000010 658#define SCR_PROTO_TRACE_TCS 0x00000020 659#define SCR_PROTO_TRACE_OBEX 0x00000040 660#define SCR_PROTO_TRACE_OAPP 0x00000080 /* OBEX Application Profile */ 661#define SCR_PROTO_TRACE_AMP 0x00000100 662#define SCR_PROTO_TRACE_BNEP 0x00000200 663#define SCR_PROTO_TRACE_AVP 0x00000400 664#define SCR_PROTO_TRACE_MCA 0x00000800 665#define SCR_PROTO_TRACE_ATT 0x00001000 666#define SCR_PROTO_TRACE_SMP 0x00002000 667#define SCR_PROTO_TRACE_NCI 0x00004000 668#define SCR_PROTO_TRACE_LLCP 0x00008000 669#define SCR_PROTO_TRACE_NDEF 0x00010000 670#define SCR_PROTO_TRACE_RW 0x00020000 671#define SCR_PROTO_TRACE_CE 0x00040000 672#define SCR_PROTO_TRACE_SNEP 0x00080000 673#define SCR_PROTO_TRACE_CHO 0x00100000 674#define SCR_PROTO_TRACE_ALL 0x001fffff 675#define SCR_PROTO_TRACE_HCI_LOGGING_VSE 0x0800 /* Brcm vs event for logmsg and protocol traces */ 676 677#define MAX_SCRIPT_TYPE 5 678 679#define TCS_PSM_INTERCOM 5 680#define TCS_PSM_CORDLESS 7 681#define BT_PSM_BNEP 0x000F 682/* Define PSMs HID uses */ 683#define HID_PSM_CONTROL 0x0011 684#define HID_PSM_INTERRUPT 0x0013 685 686#if defined(UCD_HID_INCLUDED) && (UCD_HID_INCLUDED == TRUE) 687#define UCD_PSM_MIN 0x8003 688#define UCD_PSM_MAX 0x8003 689#define UCD_PSM_HID 0x8003 690#endif 691 692/* Define a function for logging */ 693typedef void (BT_LOG_FUNC) (int trace_type, const char *fmt_str, ...); 694 695#endif 696 697