The Android Open Source Project | 5738f83 | 2012-12-12 16:00:35 -0800 | [diff] [blame^] | 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 | #ifndef GKI_TARGET_H |
| 19 | #define GKI_TARGET_H |
| 20 | |
| 21 | /* Operating System Selection */ |
| 22 | #ifndef BTE_SIM_APP |
| 23 | #define _GKI_ARM |
| 24 | #define _GKI_STANDALONE |
| 25 | #else |
| 26 | #define _BT_WIN32 |
| 27 | #endif |
| 28 | |
| 29 | /* define prefix for exporting APIs from libraries */ |
| 30 | #define EXPORT_API |
| 31 | |
| 32 | #ifndef BTE_BSE_WRAPPER |
| 33 | #ifdef BTE_SIM_APP |
| 34 | #undef EXPORT_API |
| 35 | #define EXPORT_API __declspec(dllexport) |
| 36 | #endif |
| 37 | #endif |
| 38 | |
| 39 | #define GKI_API EXPORT_API |
| 40 | #define UDRV_API EXPORT_API |
| 41 | |
| 42 | #ifndef GKI_DEBUG |
| 43 | #define GKI_DEBUG FALSE |
| 44 | #endif |
| 45 | |
| 46 | |
| 47 | #if defined (GKI_DEBUG) && (GKI_DEBUG == TRUE) |
| 48 | #define GKI_TRACE(fmt, ...) ALOGI ("%s: " fmt, __FUNCTION__, ## __VA_ARGS__) |
| 49 | #else |
| 50 | #define GKI_TRACE(fmt, ...) |
| 51 | #endif |
| 52 | |
| 53 | /****************************************************************************** |
| 54 | ** |
| 55 | ** Task configuration |
| 56 | ** |
| 57 | ******************************************************************************/ |
| 58 | |
| 59 | /* Definitions of task IDs for inter-task messaging */ |
| 60 | #ifndef BTU_TASK |
| 61 | #define BTU_TASK 0 |
| 62 | #endif |
| 63 | |
| 64 | #ifndef BTIF_TASK |
| 65 | #define BTIF_TASK 1 |
| 66 | #endif |
| 67 | |
| 68 | #ifndef A2DP_MEDIA_TASK |
| 69 | #define A2DP_MEDIA_TASK 2 |
| 70 | #endif |
| 71 | |
| 72 | /* The number of GKI tasks in the software system. */ |
| 73 | #ifndef GKI_MAX_TASKS |
| 74 | #define GKI_MAX_TASKS 3 |
| 75 | #endif |
| 76 | |
| 77 | /****************************************************************************** |
| 78 | ** |
| 79 | ** Timer configuration |
| 80 | ** |
| 81 | ******************************************************************************/ |
| 82 | |
| 83 | /* The number of GKI timers in the software system. */ |
| 84 | #ifndef GKI_NUM_TIMERS |
| 85 | #define GKI_NUM_TIMERS 3 |
| 86 | #endif |
| 87 | |
| 88 | /* A conversion value for translating ticks to calculate GKI timer. */ |
| 89 | #ifndef TICKS_PER_SEC |
| 90 | #define TICKS_PER_SEC 100 |
| 91 | #endif |
| 92 | |
| 93 | /************************************************************************ |
| 94 | ** Utility macros converting ticks to time with user define OS ticks per sec |
| 95 | **/ |
| 96 | #ifndef GKI_MS_TO_TICKS |
| 97 | #define GKI_MS_TO_TICKS(x) ((x) / (1000 / TICKS_PER_SEC)) |
| 98 | #endif |
| 99 | |
| 100 | #ifndef GKI_SECS_TO_TICKS |
| 101 | #define GKI_SECS_TO_TICKS(x) ((x) * (TICKS_PER_SEC)) |
| 102 | #endif |
| 103 | |
| 104 | #ifndef GKI_TICKS_TO_MS |
| 105 | #define GKI_TICKS_TO_MS(x) ((x) * 1000 / TICKS_PER_SEC) |
| 106 | #endif |
| 107 | |
| 108 | #ifndef GKI_TICKS_TO_SECS |
| 109 | #define GKI_TICKS_TO_SECS(x) ((x) / TICKS_PER_SEC) |
| 110 | #endif |
| 111 | |
| 112 | |
| 113 | |
| 114 | /* TICK per second from OS (OS dependent change this macro accordingly to various OS) */ |
| 115 | #ifndef OS_TICKS_PER_SEC |
| 116 | #define OS_TICKS_PER_SEC 1000 |
| 117 | #endif |
| 118 | |
| 119 | /************************************************************************ |
| 120 | ** Utility macros converting ticks to time with user define OS ticks per sec |
| 121 | **/ |
| 122 | |
| 123 | #ifndef GKI_OS_TICKS_TO_MS |
| 124 | #define GKI_OS_TICKS_TO_MS(x) ((x) * 1000 / OS_TICKS_PER_SEC) |
| 125 | #endif |
| 126 | |
| 127 | |
| 128 | #ifndef GKI_OS_TICKS_TO_SECS |
| 129 | #define GKI_OS_TICKS_TO_SECS(x) ((x) / OS_TICKS_PER_SEC)) |
| 130 | #endif |
| 131 | |
| 132 | |
| 133 | /* delay in ticks before stopping system tick. */ |
| 134 | #ifndef GKI_DELAY_STOP_SYS_TICK |
| 135 | #define GKI_DELAY_STOP_SYS_TICK 10 |
| 136 | #endif |
| 137 | |
| 138 | /* Option to guarantee no preemption during timer expiration (most system don't need this) */ |
| 139 | #ifndef GKI_TIMER_LIST_NOPREEMPT |
| 140 | #define GKI_TIMER_LIST_NOPREEMPT FALSE |
| 141 | #endif |
| 142 | |
| 143 | /****************************************************************************** |
| 144 | ** |
| 145 | ** Buffer configuration |
| 146 | ** |
| 147 | ******************************************************************************/ |
| 148 | |
| 149 | /* TRUE if GKI uses dynamic buffers. */ |
| 150 | #ifndef GKI_USE_DYNAMIC_BUFFERS |
| 151 | #define GKI_USE_DYNAMIC_BUFFERS FALSE |
| 152 | #endif |
| 153 | |
| 154 | /* The size of the buffers in pool 0. */ |
| 155 | #ifndef GKI_BUF0_SIZE |
| 156 | #define GKI_BUF0_SIZE 64 |
| 157 | #endif |
| 158 | |
| 159 | /* The number of buffers in buffer pool 0. */ |
| 160 | #ifndef GKI_BUF0_MAX |
| 161 | #define GKI_BUF0_MAX 48 |
| 162 | #endif |
| 163 | |
| 164 | /* The ID of buffer pool 0. */ |
| 165 | #ifndef GKI_POOL_ID_0 |
| 166 | #define GKI_POOL_ID_0 0 |
| 167 | #endif |
| 168 | |
| 169 | /* The size of the buffers in pool 1. */ |
| 170 | #ifndef GKI_BUF1_SIZE |
| 171 | #define GKI_BUF1_SIZE 288 |
| 172 | #endif |
| 173 | |
| 174 | /* The number of buffers in buffer pool 1. */ |
| 175 | #ifndef GKI_BUF1_MAX |
| 176 | #define GKI_BUF1_MAX 26 |
| 177 | #endif |
| 178 | |
| 179 | /* The ID of buffer pool 1. */ |
| 180 | #ifndef GKI_POOL_ID_1 |
| 181 | #define GKI_POOL_ID_1 1 |
| 182 | #endif |
| 183 | |
| 184 | /* The size of the buffers in pool 2. */ |
| 185 | #ifndef GKI_BUF2_SIZE |
| 186 | #define GKI_BUF2_SIZE 660 |
| 187 | #endif |
| 188 | |
| 189 | /* The number of buffers in buffer pool 2. */ |
| 190 | #ifndef GKI_BUF2_MAX |
| 191 | #define GKI_BUF2_MAX 45 |
| 192 | #endif |
| 193 | |
| 194 | /* The ID of buffer pool 2. */ |
| 195 | #ifndef GKI_POOL_ID_2 |
| 196 | #define GKI_POOL_ID_2 2 |
| 197 | #endif |
| 198 | |
| 199 | /* The size of the buffers in pool 3. */ |
| 200 | #ifndef GKI_BUF3_SIZE |
| 201 | #define GKI_BUF3_SIZE (4096+16) |
| 202 | #endif |
| 203 | |
| 204 | /* The number of buffers in buffer pool 3. */ |
| 205 | #ifndef GKI_BUF3_MAX |
| 206 | #define GKI_BUF3_MAX 200 |
| 207 | #endif |
| 208 | |
| 209 | /* The ID of buffer pool 3. */ |
| 210 | #ifndef GKI_POOL_ID_3 |
| 211 | #define GKI_POOL_ID_3 3 |
| 212 | #endif |
| 213 | |
| 214 | /* The size of the largest PUBLIC fixed buffer in system. */ |
| 215 | #ifndef GKI_MAX_BUF_SIZE |
| 216 | #define GKI_MAX_BUF_SIZE GKI_BUF3_SIZE |
| 217 | #endif |
| 218 | |
| 219 | /* The pool ID of the largest PUBLIC fixed buffer in system. */ |
| 220 | #ifndef GKI_MAX_BUF_SIZE_POOL_ID |
| 221 | #define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_3 |
| 222 | #endif |
| 223 | |
| 224 | /* RESERVED buffer pool for OBX */ |
| 225 | /* Ideally there should be 1 buffer for each instance for RX data, and some number |
| 226 | of TX buffers based on active instances. OBX will only use these if packet size |
| 227 | requires it. In most cases the large packets are used in only one direction so |
| 228 | the other direction will use smaller buffers. |
| 229 | Devices with small amount of RAM should limit the number of active obex objects. |
| 230 | */ |
| 231 | /* The size of the buffers in pool 4. */ |
| 232 | #ifndef GKI_BUF4_SIZE |
| 233 | #define GKI_BUF4_SIZE (8080+26) |
| 234 | #endif |
| 235 | |
| 236 | /* The number of buffers in buffer pool 4. */ |
| 237 | #ifndef GKI_BUF4_MAX |
| 238 | #define GKI_BUF4_MAX (OBX_NUM_SERVERS + OBX_NUM_CLIENTS) |
| 239 | #endif |
| 240 | |
| 241 | /* The ID of buffer pool 4. */ |
| 242 | #ifndef GKI_POOL_ID_4 |
| 243 | #define GKI_POOL_ID_4 4 |
| 244 | #endif |
| 245 | |
| 246 | /* The number of fixed GKI buffer pools. |
| 247 | eL2CAP requires Pool ID 5 |
| 248 | If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7 |
| 249 | If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to 7, otherwise set to 8 |
| 250 | If BLE_INCLUDED is FALSE then Pool ID 8 is uncessary and set the following to 8, otherwise set to 9 |
| 251 | POOL_ID 9 is a public pool meant for large buffer needs such as SDP_DB |
| 252 | */ |
| 253 | // btla-specific ++ |
| 254 | #ifndef GKI_NUM_FIXED_BUF_POOLS |
| 255 | #define GKI_NUM_FIXED_BUF_POOLS 10 |
| 256 | #endif |
| 257 | |
| 258 | /* The buffer pool usage mask. */ |
| 259 | #ifndef GKI_DEF_BUFPOOL_PERM_MASK |
| 260 | /* Setting POOL_ID 9 as a public pool meant for large buffers such as SDP_DB */ |
| 261 | #define GKI_DEF_BUFPOOL_PERM_MASK 0xfdf0 |
| 262 | #endif |
| 263 | // btla-specific -- |
| 264 | |
| 265 | /* The number of fixed and dynamic buffer pools */ |
| 266 | #ifndef GKI_NUM_TOTAL_BUF_POOLS |
| 267 | #define GKI_NUM_TOTAL_BUF_POOLS 10 |
| 268 | #endif |
| 269 | |
| 270 | /* The following is intended to be a reserved pool for L2CAP |
| 271 | Flow control and retransmissions and intentionally kept out |
| 272 | of order */ |
| 273 | |
| 274 | /* The number of buffers in buffer pool 5. */ |
| 275 | #ifndef GKI_BUF5_MAX |
| 276 | #define GKI_BUF5_MAX 64 |
| 277 | #endif |
| 278 | |
| 279 | /* The ID of buffer pool 5. */ |
| 280 | #ifndef GKI_POOL_ID_5 |
| 281 | #define GKI_POOL_ID_5 5 |
| 282 | #endif |
| 283 | |
| 284 | /* The size of the buffers in pool 5 |
| 285 | ** Special pool used by l2cap retransmissions only. This size based on segment |
| 286 | ** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI |
| 287 | ** header. 13 bytes of max headers allows us a 339 payload max. (in btui_app.txt) |
| 288 | ** Note: 748 used for insight scriptwrapper with CAT-2 scripts. |
| 289 | */ |
| 290 | #ifndef GKI_BUF5_SIZE |
| 291 | #define GKI_BUF5_SIZE 748 |
| 292 | #endif |
| 293 | |
| 294 | /* The buffer corruption check flag. */ |
| 295 | #ifndef GKI_ENABLE_BUF_CORRUPTION_CHECK |
| 296 | #define GKI_ENABLE_BUF_CORRUPTION_CHECK TRUE |
| 297 | #endif |
| 298 | |
| 299 | /* The GKI severe error macro. */ |
| 300 | #ifndef GKI_SEVERE |
| 301 | #define GKI_SEVERE(code) |
| 302 | #endif |
| 303 | |
| 304 | /* TRUE if GKI includes debug functionality. */ |
| 305 | #ifndef GKI_DEBUG |
| 306 | #define GKI_DEBUG FALSE |
| 307 | #endif |
| 308 | |
| 309 | /* Maximum number of exceptions logged. */ |
| 310 | #ifndef GKI_MAX_EXCEPTION |
| 311 | #define GKI_MAX_EXCEPTION 8 |
| 312 | #endif |
| 313 | |
| 314 | /* Maximum number of chars stored for each exception message. */ |
| 315 | #ifndef GKI_MAX_EXCEPTION_MSGLEN |
| 316 | #define GKI_MAX_EXCEPTION_MSGLEN 64 |
| 317 | #endif |
| 318 | |
| 319 | #ifndef GKI_SEND_MSG_FROM_ISR |
| 320 | #define GKI_SEND_MSG_FROM_ISR FALSE |
| 321 | #endif |
| 322 | |
| 323 | |
| 324 | /* The following is intended to be a reserved pool for SCO |
| 325 | over HCI data and intentionally kept out of order */ |
| 326 | |
| 327 | /* The ID of buffer pool 6. */ |
| 328 | #ifndef GKI_POOL_ID_6 |
| 329 | #define GKI_POOL_ID_6 6 |
| 330 | #endif |
| 331 | |
| 332 | /* The size of the buffers in pool 6, |
| 333 | BUF_SIZE = max SCO data 255 + sizeof(BT_HDR) = 8 + SCO packet header 3 + padding 2 = 268 */ |
| 334 | #ifndef GKI_BUF6_SIZE |
| 335 | #define GKI_BUF6_SIZE 268 |
| 336 | #endif |
| 337 | |
| 338 | /* The number of buffers in buffer pool 6. */ |
| 339 | #ifndef GKI_BUF6_MAX |
| 340 | #define GKI_BUF6_MAX 60 |
| 341 | #endif |
| 342 | |
| 343 | |
| 344 | /* The following pool is a dedicated pool for HDP |
| 345 | If a shared pool is more desirable then |
| 346 | 1. set BTA_HL_LRG_DATA_POOL_ID to the desired Gki Pool ID |
| 347 | 2. make sure that the shared pool size is larger than 9472 |
| 348 | 3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since |
| 349 | POOL ID 7 is not needed |
| 350 | */ |
| 351 | |
| 352 | /* The ID of buffer pool 7. */ |
| 353 | #ifndef GKI_POOL_ID_7 |
| 354 | #define GKI_POOL_ID_7 7 |
| 355 | #endif |
| 356 | |
| 357 | /* The size of the buffers in pool 7 */ |
| 358 | #ifndef GKI_BUF7_SIZE |
| 359 | #define GKI_BUF7_SIZE 9472 |
| 360 | #endif |
| 361 | |
| 362 | /* The number of buffers in buffer pool 7. */ |
| 363 | #ifndef GKI_BUF7_MAX |
| 364 | #define GKI_BUF7_MAX 2 |
| 365 | #endif |
| 366 | |
| 367 | /* The following pool is a dedicated pool for GATT |
| 368 | If a shared pool is more desirable then |
| 369 | 1. set GATT_DB_POOL_ID to the desired Gki Pool ID |
| 370 | 2. make sure that the shared pool size fit a common GATT database needs |
| 371 | 3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since |
| 372 | POOL ID 8 is not needed |
| 373 | */ |
| 374 | |
| 375 | /* The ID of buffer pool 8. */ |
| 376 | #ifndef GKI_POOL_ID_8 |
| 377 | #define GKI_POOL_ID_8 8 |
| 378 | #endif |
| 379 | |
| 380 | /* The size of the buffers in pool 8 */ |
| 381 | #ifndef GKI_BUF8_SIZE |
| 382 | #define GKI_BUF8_SIZE 128 |
| 383 | #endif |
| 384 | |
| 385 | /* The number of buffers in buffer pool 8. */ |
| 386 | #ifndef GKI_BUF8_MAX |
| 387 | #define GKI_BUF8_MAX 30 |
| 388 | #endif |
| 389 | |
| 390 | // btla-specific ++ |
| 391 | /* The following pool is meant for large allocations such as SDP_DB */ |
| 392 | #ifndef GKI_POOL_ID_9 |
| 393 | #define GKI_POOL_ID_9 9 |
| 394 | #endif |
| 395 | |
| 396 | #ifndef GKI_BUF9_SIZE |
| 397 | #define GKI_BUF9_SIZE 8192 |
| 398 | #endif |
| 399 | |
| 400 | #ifndef GKI_BUF9_MAX |
| 401 | #define GKI_BUF9_MAX 5 |
| 402 | #endif |
| 403 | // btla-specific -- |
| 404 | |
| 405 | /* GKI Trace Macros */ |
| 406 | #define GKI_TRACE_0(m) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_GENERIC,m) |
| 407 | #define GKI_TRACE_1(m,p1) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_GENERIC,m,p1) |
| 408 | #define GKI_TRACE_2(m,p1,p2) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_GENERIC,m,p1,p2) |
| 409 | #define GKI_TRACE_3(m,p1,p2,p3) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_GENERIC,m,p1,p2,p3) |
| 410 | #define GKI_TRACE_4(m,p1,p2,p3,p4) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_GENERIC,m,p1,p2,p3,p4) |
| 411 | #define GKI_TRACE_5(m,p1,p2,p3,p4,p5) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_GENERIC,m,p1,p2,p3,p4,p5) |
| 412 | #define GKI_TRACE_6(m,p1,p2,p3,p4,p5,p6) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_GENERIC,m,p1,p2,p3,p4,p5,p6) |
| 413 | |
| 414 | #define GKI_TRACE_ERROR_0(m) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR,m) |
| 415 | #define GKI_TRACE_ERROR_1(m,p1) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR,m,p1) |
| 416 | #define GKI_TRACE_ERROR_2(m,p1,p2) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR,m,p1,p2) |
| 417 | #define GKI_TRACE_ERROR_3(m,p1,p2,p3) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR,m,p1,p2,p3) |
| 418 | #define GKI_TRACE_ERROR_4(m,p1,p2,p3,p4) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR,m,p1,p2,p3,p4) |
| 419 | #define GKI_TRACE_ERROR_5(m,p1,p2,p3,p4,p5) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5) |
| 420 | #define GKI_TRACE_ERROR_6(m,p1,p2,p3,p4,p5,p6) LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR,m,p1,p2,p3,p4,p5,p6) |
| 421 | |
| 422 | #ifdef __cplusplus |
| 423 | extern "C" |
| 424 | { |
| 425 | #endif |
| 426 | |
| 427 | EXPORT_API extern void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...); |
| 428 | |
| 429 | #ifdef __cplusplus |
| 430 | } |
| 431 | #endif |
| 432 | |
| 433 | #endif /* GKI_TARGET_H */ |