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              4
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**
134** Buffer configuration
135**
136******************************************************************************/
137
138/* TRUE if GKI uses dynamic buffers. */
139#ifndef GKI_USE_DYNAMIC_BUFFERS
140#define GKI_USE_DYNAMIC_BUFFERS     FALSE
141#endif
142
143/* The size of the buffers in pool 0. */
144#ifndef GKI_BUF0_SIZE
145#define GKI_BUF0_SIZE               64
146#endif
147
148/* The number of buffers in buffer pool 0. */
149#ifndef GKI_BUF0_MAX
150#define GKI_BUF0_MAX                48
151#endif
152
153/* The ID of buffer pool 0. */
154#ifndef GKI_POOL_ID_0
155#define GKI_POOL_ID_0               0
156#endif
157
158/* The size of the buffers in pool 1. */
159#ifndef GKI_BUF1_SIZE
160#define GKI_BUF1_SIZE               288
161#endif
162
163/* The number of buffers in buffer pool 1. */
164#ifndef GKI_BUF1_MAX
165#define GKI_BUF1_MAX                26
166#endif
167
168/* The ID of buffer pool 1. */
169#ifndef GKI_POOL_ID_1
170#define GKI_POOL_ID_1               1
171#endif
172
173/* The size of the buffers in pool 2. */
174#ifndef GKI_BUF2_SIZE
175#define GKI_BUF2_SIZE               660
176#endif
177
178/* The number of buffers in buffer pool 2. */
179#ifndef GKI_BUF2_MAX
180#define GKI_BUF2_MAX                45
181#endif
182
183/* The ID of buffer pool 2. */
184#ifndef GKI_POOL_ID_2
185#define GKI_POOL_ID_2               2
186#endif
187
188/* The size of the buffers in pool 3. */
189#ifndef GKI_BUF3_SIZE
190#define GKI_BUF3_SIZE               (4096+16)
191#endif
192
193/* The number of buffers in buffer pool 3. */
194#ifndef GKI_BUF3_MAX
195#define GKI_BUF3_MAX                200
196#endif
197
198/* The ID of buffer pool 3. */
199#ifndef GKI_POOL_ID_3
200#define GKI_POOL_ID_3               3
201#endif
202
203/* The size of the largest PUBLIC fixed buffer in system. */
204#ifndef GKI_MAX_BUF_SIZE
205#define GKI_MAX_BUF_SIZE            GKI_BUF3_SIZE
206#endif
207
208/* The pool ID of the largest PUBLIC fixed buffer in system. */
209#ifndef GKI_MAX_BUF_SIZE_POOL_ID
210#define GKI_MAX_BUF_SIZE_POOL_ID    GKI_POOL_ID_3
211#endif
212
213/* RESERVED buffer pool for OBX */
214/* Ideally there should be 1 buffer for each instance for RX data, and some number
215of TX buffers based on active instances. OBX will only use these if packet size
216requires it. In most cases the large packets are used in only one direction so
217the other direction will use smaller buffers.
218Devices with small amount of RAM should limit the number of active obex objects.
219*/
220/* The size of the buffers in pool 4. */
221#ifndef GKI_BUF4_SIZE
222#define GKI_BUF4_SIZE               (8080+26)
223#endif
224
225/* The number of buffers in buffer pool 4. */
226#ifndef GKI_BUF4_MAX
227#define GKI_BUF4_MAX                (OBX_NUM_SERVERS + OBX_NUM_CLIENTS)
228#endif
229
230/* The ID of buffer pool 4. */
231#ifndef GKI_POOL_ID_4
232#define GKI_POOL_ID_4               4
233#endif
234
235/* The number of fixed GKI buffer pools.
236eL2CAP requires Pool ID 5
237If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7
238If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to 7, otherwise set to 8
239If BLE_INCLUDED is FALSE then Pool ID 8 is uncessary and set the following to 8, otherwise set to 9
240POOL_ID 9 is a public pool meant for large buffer needs such as SDP_DB
241*/
242// btla-specific ++
243#ifndef GKI_NUM_FIXED_BUF_POOLS
244#define GKI_NUM_FIXED_BUF_POOLS     10
245#endif
246
247/* The buffer pool usage mask. */
248#ifndef GKI_DEF_BUFPOOL_PERM_MASK
249/* Setting POOL_ID 9 as a public pool meant for large buffers such as SDP_DB */
250#define GKI_DEF_BUFPOOL_PERM_MASK   0xfdf0
251#endif
252// btla-specific --
253
254/* The number of fixed and dynamic buffer pools */
255#ifndef GKI_NUM_TOTAL_BUF_POOLS
256#define GKI_NUM_TOTAL_BUF_POOLS     10
257#endif
258
259/* The following is intended to be a reserved pool for L2CAP
260Flow control and retransmissions and intentionally kept out
261of order */
262
263/* The number of buffers in buffer pool 5. */
264#ifndef GKI_BUF5_MAX
265#define GKI_BUF5_MAX                64
266#endif
267
268/* The ID of buffer pool 5. */
269#ifndef GKI_POOL_ID_5
270#define GKI_POOL_ID_5               5
271#endif
272
273/* The size of the buffers in pool 5
274** Special pool used by l2cap retransmissions only.  This size based on segment
275** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI
276** header.  13 bytes of max headers allows us a 339 payload max. (in btui_app.txt)
277** Note: 748 used for insight scriptwrapper with CAT-2 scripts.
278*/
279#ifndef GKI_BUF5_SIZE
280#define GKI_BUF5_SIZE               748
281#endif
282
283/* The buffer corruption check flag. */
284#ifndef GKI_ENABLE_BUF_CORRUPTION_CHECK
285#define GKI_ENABLE_BUF_CORRUPTION_CHECK TRUE
286#endif
287
288/* The GKI severe error macro. */
289#ifndef GKI_SEVERE
290#define GKI_SEVERE(code)
291#endif
292
293/* TRUE if GKI includes debug functionality. */
294#ifndef GKI_DEBUG
295#define GKI_DEBUG                   FALSE
296#endif
297
298/* Maximum number of exceptions logged. */
299#ifndef GKI_MAX_EXCEPTION
300#define GKI_MAX_EXCEPTION           8
301#endif
302
303/* Maximum number of chars stored for each exception message. */
304#ifndef GKI_MAX_EXCEPTION_MSGLEN
305#define GKI_MAX_EXCEPTION_MSGLEN    64
306#endif
307
308/* The following is intended to be a reserved pool for SCO
309over HCI data and intentionally kept out of order */
310
311/* The ID of buffer pool 6. */
312#ifndef GKI_POOL_ID_6
313#define GKI_POOL_ID_6               6
314#endif
315
316/* The size of the buffers in pool 6,
317  BUF_SIZE = max SCO data 255 + sizeof(BT_HDR) = 8 + SCO packet header 3 + padding 2 = 268 */
318#ifndef GKI_BUF6_SIZE
319#define GKI_BUF6_SIZE               268
320#endif
321
322/* The number of buffers in buffer pool 6. */
323#ifndef GKI_BUF6_MAX
324#define GKI_BUF6_MAX                60
325#endif
326
327
328/* The following pool is a dedicated pool for HDP
329   If a shared pool is more desirable then
330   1. set BTA_HL_LRG_DATA_POOL_ID to the desired Gki Pool ID
331   2. make sure that the shared pool size is larger than 9472
332   3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
333      POOL ID 7 is not needed
334*/
335
336/* The ID of buffer pool 7. */
337#ifndef GKI_POOL_ID_7
338#define GKI_POOL_ID_7               7
339#endif
340
341/* The size of the buffers in pool 7 */
342#ifndef GKI_BUF7_SIZE
343#define GKI_BUF7_SIZE               (10240 + 24)
344#endif
345
346/* The number of buffers in buffer pool 7. */
347#ifndef GKI_BUF7_MAX
348#define GKI_BUF7_MAX                2
349#endif
350
351/* The following pool is a dedicated pool for GATT
352   If a shared pool is more desirable then
353   1. set GATT_DB_POOL_ID to the desired Gki Pool ID
354   2. make sure that the shared pool size fit a common GATT database needs
355   3. adjust GKI_NUM_FIXED_BUF_POOLS accordingly since
356      POOL ID 8 is not needed
357*/
358
359/* The ID of buffer pool 8. */
360#ifndef GKI_POOL_ID_8
361#define GKI_POOL_ID_8               8
362#endif
363
364/* The size of the buffers in pool 8 */
365#ifndef GKI_BUF8_SIZE
366#define GKI_BUF8_SIZE               128
367#endif
368
369/* The number of buffers in buffer pool 8. */
370#ifndef GKI_BUF8_MAX
371#define GKI_BUF8_MAX                30
372#endif
373
374// btla-specific ++
375/* The following pool is  meant for large allocations such as SDP_DB */
376#ifndef GKI_POOL_ID_9
377#define GKI_POOL_ID_9              9
378#endif
379
380#ifndef GKI_BUF9_SIZE
381#define GKI_BUF9_SIZE            8192
382#endif
383
384#ifndef GKI_BUF9_MAX
385#define GKI_BUF9_MAX           5
386#endif
387// btla-specific --
388
389#ifdef __cplusplus
390extern "C"
391{
392#endif
393
394EXPORT_API extern void LogMsg (UINT32 trace_set_mask, const char *fmt_str, ...);
395
396#ifdef __cplusplus
397}
398#endif
399
400#endif  /* GKI_TARGET_H */
401