• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifdef BUILDCFG
22 #include "buildcfg.h"
23 #endif
24 
25 #include "data_types.h"
26 
27 /* Operating System Selection */
28 #ifndef BTE_SIM_APP
29 #define _GKI_ARM
30 #define _GKI_STANDALONE
31 #else
32 #define _BT_WIN32
33 #endif
34 
35 /******************************************************************************
36 **
37 ** Task configuration
38 **
39 ******************************************************************************/
40 
41 /* Definitions of task IDs for inter-task messaging */
42 #ifndef MMI_TASK
43 #define MMI_TASK 0
44 #endif
45 
46 #ifndef HCISU_TASK
47 #define HCISU_TASK 1
48 #endif
49 
50 #ifndef NCIT_TASK
51 #define NCIT_TASK 2
52 #endif
53 
54 #ifndef NFC_TASK
55 #define NFC_TASK 3
56 #endif
57 
58 #ifndef BTU_TASK
59 #define BTU_TASK 4
60 #endif
61 
62 /* BTE Application, Sample Apps, or Serial port Demo based on JP3 and JP4
63  * setting) */
64 #ifndef BTE_APPL_TASK
65 #define BTE_APPL_TASK 5
66 #endif
67 
68 #ifndef DEV_MGR_TASK
69 #define DEV_MGR_TASK 6
70 #endif
71 
72 #ifndef ISE_SCR_TASK
73 #define ISE_SCR_TASK 7
74 #endif
75 
76 #ifndef UCODEC_TASK
77 #define UCODEC_TASK 8
78 #endif
79 
80 #ifndef RPCT_TASK
81 #define RPCT_TASK 9
82 #endif
83 
84 #ifndef UNV_TASK
85 #define UNV_TASK 10
86 #endif
87 
88 #ifndef BTE_IDLE_TASK
89 #define BTE_IDLE_TASK 11
90 #endif
91 
92 #ifndef UIPC_TASK
93 #define UIPC_TASK 12
94 #endif
95 
96 #ifndef HCISU_AMP_TASK
97 #define HCISU_AMP_TASK 13
98 #endif
99 
100 /* The number of GKI tasks in the software system. */
101 #ifndef GKI_MAX_TASKS
102 #define GKI_MAX_TASKS 14
103 #endif
104 
105 /******************************************************************************
106 **
107 ** Timer configuration
108 **
109 ******************************************************************************/
110 
111 /* The number of GKI timers in the software system. */
112 #ifndef GKI_NUM_TIMERS
113 #define GKI_NUM_TIMERS 3
114 #endif
115 
116 /* A conversion value for translating ticks to calculate GKI timer.  */
117 #ifndef TICKS_PER_SEC
118 #define TICKS_PER_SEC 100
119 #endif
120 
121 /* delay in ticks before stopping system tick. */
122 #ifndef GKI_DELAY_STOP_SYS_TICK
123 #define GKI_DELAY_STOP_SYS_TICK 10
124 #endif
125 
126 /******************************************************************************
127 **
128 ** Buffer configuration
129 **
130 ******************************************************************************/
131 
132 /* TRUE if GKI uses dynamic buffers. */
133 #ifndef GKI_USE_DYNAMIC_BUFFERS
134 #define GKI_USE_DYNAMIC_BUFFERS FALSE
135 #endif
136 
137 /* The size of the buffers in pool 0. */
138 #ifndef GKI_BUF0_SIZE
139 #define GKI_BUF0_SIZE 64
140 #endif
141 
142 /* The number of buffers in buffer pool 0. */
143 #ifndef GKI_BUF0_MAX
144 #define GKI_BUF0_MAX 48
145 #endif
146 
147 /* The ID of buffer pool 0. */
148 #ifndef GKI_POOL_ID_0
149 #define GKI_POOL_ID_0 0
150 #endif
151 
152 /* The size of the buffers in pool 1. */
153 #ifndef GKI_BUF1_SIZE
154 #define GKI_BUF1_SIZE 128
155 #endif
156 
157 /* The number of buffers in buffer pool 1. */
158 #ifndef GKI_BUF1_MAX
159 #define GKI_BUF1_MAX 26
160 #endif
161 
162 /* The ID of buffer pool 1. */
163 #ifndef GKI_POOL_ID_1
164 #define GKI_POOL_ID_1 1
165 #endif
166 
167 /* The size of the buffers in pool 2. */
168 #ifndef GKI_BUF2_SIZE
169 #define GKI_BUF2_SIZE 660
170 #endif
171 
172 /* The number of buffers in buffer pool 2. */
173 #ifndef GKI_BUF2_MAX
174 #define GKI_BUF2_MAX 45
175 #endif
176 
177 /* The ID of buffer pool 2. */
178 #ifndef GKI_POOL_ID_2
179 #define GKI_POOL_ID_2 2
180 #endif
181 
182 /* The size of the buffers in pool 3. */
183 #ifndef GKI_BUF3_SIZE
184 #define GKI_BUF3_SIZE 2500
185 #endif
186 
187 /* The number of buffers in buffer pool 3. */
188 #ifndef GKI_BUF3_MAX
189 #define GKI_BUF3_MAX 30
190 #endif
191 
192 /* The ID of buffer pool 3. */
193 #ifndef GKI_POOL_ID_3
194 #define GKI_POOL_ID_3 3
195 #endif
196 
197 /* The size of the largest PUBLIC fixed buffer in system. */
198 #ifndef GKI_MAX_BUF_SIZE
199 #define GKI_MAX_BUF_SIZE GKI_BUF3_SIZE
200 #endif
201 
202 /* The pool ID of the largest PUBLIC fixed buffer in system. */
203 #ifndef GKI_MAX_BUF_SIZE_POOL_ID
204 #define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_3
205 #endif
206 
207 /* RESERVED buffer pool for OBX */
208 /* Ideally there should be 1 buffer for each instance for RX data, and some
209 number
210 of TX buffers based on active instances. OBX will only use these if packet size
211 requires it. In most cases the large packets are used in only one direction so
212 the other direction will use smaller buffers.
213 Devices with small amount of RAM should limit the number of active obex objects.
214 */
215 /* The size of the buffers in pool 4. */
216 #ifndef GKI_BUF4_SIZE
217 #define GKI_BUF4_SIZE 0x2000
218 #endif
219 
220 /* The number of buffers in buffer pool 4. */
221 #ifndef GKI_BUF4_MAX
222 /* (OBX_NUM_SERVERS + OBX_NUM_CLIENTS) */
223 #define GKI_BUF4_MAX 96
224 #endif
225 
226 /* The ID of buffer pool 4. */
227 #ifndef GKI_POOL_ID_4
228 #define GKI_POOL_ID_4 4
229 #endif
230 
231 /* The number of fixed GKI buffer pools.
232 If L2CAP_FCR_INCLUDED is FALSE, Pool ID 5 is unnecessary
233 If BTM_SCO_HCI_INCLUDED is FALSE, Pool ID 6 is unnecessary, otherwise set to 7
234 If BTA_HL_INCLUDED is FALSE then Pool ID 7 is uncessary and set the following to
235 7, otherwise set to 8
236 If GATT_SERVER_ENABLED is FALSE then Pool ID 8 is uncessary and set the
237 following to 8, otherwise set to 9
238 */
239 #ifndef GKI_NUM_FIXED_BUF_POOLS
240 #define GKI_NUM_FIXED_BUF_POOLS 9
241 #endif
242 
243 /* The buffer pool usage mask. */
244 #ifndef GKI_DEF_BUFPOOL_PERM_MASK
245 #define GKI_DEF_BUFPOOL_PERM_MASK 0xfff0
246 #endif
247 
248 /* The number of fixed and dynamic buffer pools.
249 If L2CAP_FCR_INCLUDED is FALSE, Pool ID 4 is unnecessary */
250 #ifndef GKI_NUM_TOTAL_BUF_POOLS
251 #define GKI_NUM_TOTAL_BUF_POOLS 10
252 #endif
253 
254 /* The following is intended to be a reserved pool for L2CAP
255 Flow control and retransmissions and intentionally kept out
256 of order */
257 
258 /* The number of buffers in buffer pool 5. */
259 #ifndef GKI_BUF5_MAX
260 #define GKI_BUF5_MAX 64
261 #endif
262 
263 /* The ID of buffer pool 5. */
264 #ifndef GKI_POOL_ID_5
265 #define GKI_POOL_ID_5 5
266 #endif
267 
268 /* The size of the buffers in pool 5
269 ** Special pool used by l2cap retransmissions only. This size based on segment
270 ** that will fit into both DH5 and 2-DH3 packet types after accounting for GKI
271 ** header. 13 bytes of max headers allows us a 339 payload max.
272 ** (in btui_app.txt)
273 ** Note: 748 used for insight scriptwrapper with CAT-2 scripts.
274 */
275 #ifndef GKI_BUF5_SIZE
276 #define GKI_BUF5_SIZE 748
277 #endif
278 
279 /* The buffer corruption check flag. */
280 #ifndef GKI_ENABLE_BUF_CORRUPTION_CHECK
281 #define GKI_ENABLE_BUF_CORRUPTION_CHECK TRUE
282 #endif
283 
284 /* The GKI severe error macro. */
285 #ifndef GKI_SEVERE
286 #define GKI_SEVERE(code)
287 #endif
288 
289 /* TRUE if GKI includes debug functionality. */
290 #ifndef GKI_DEBUG
291 #define GKI_DEBUG FALSE
292 #endif
293 
294 /* Maximum number of exceptions logged. */
295 #ifndef GKI_MAX_EXCEPTION
296 #define GKI_MAX_EXCEPTION 8
297 #endif
298 
299 /* Maximum number of chars stored for each exception message. */
300 #ifndef GKI_MAX_EXCEPTION_MSGLEN
301 #define GKI_MAX_EXCEPTION_MSGLEN 64
302 #endif
303 
304 #ifndef GKI_SEND_MSG_FROM_ISR
305 #define GKI_SEND_MSG_FROM_ISR FALSE
306 #endif
307 
308 /* The following is intended to be a reserved pool for SCO
309 over 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(NFC_HDR) = 8 + SCO packet header 3 +
318   padding 2 = 268 */
319 #ifndef GKI_BUF6_SIZE
320 #define GKI_BUF6_SIZE 268
321 #endif
322 
323 /* The number of buffers in buffer pool 6. */
324 #ifndef GKI_BUF6_MAX
325 #define GKI_BUF6_MAX 60
326 #endif
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 9472
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 #if (GKI_DEBUG == TRUE)
375 #ifdef LOG_TAG
376 #undef LOG_TAG
377 #endif
378 #define LOG_TAG "GKI_LINUX"
379 /* GKI Trace Macros */
380 #define GKI_TRACE_0(m)                                          \
381   LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \
382              TRACE_TYPE_GENERIC,                                \
383          m)
384 #define GKI_TRACE_1(m, p1)                                      \
385   LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \
386              TRACE_TYPE_GENERIC,                                \
387          m, p1)
388 #define GKI_TRACE_2(m, p1, p2)                                  \
389   LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \
390              TRACE_TYPE_GENERIC,                                \
391          m, p1, p2)
392 #define GKI_TRACE_3(m, p1, p2, p3)                              \
393   LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \
394              TRACE_TYPE_GENERIC,                                \
395          m, p1, p2, p3)
396 #define GKI_TRACE_4(m, p1, p2, p3, p4)                          \
397   LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \
398              TRACE_TYPE_GENERIC,                                \
399          m, p1, p2, p3, p4)
400 #define GKI_TRACE_5(m, p1, p2, p3, p4, p5)                      \
401   LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \
402              TRACE_TYPE_GENERIC,                                \
403          m, p1, p2, p3, p4, p5)
404 #define GKI_TRACE_6(m, p1, p2, p3, p4, p5, p6)                  \
405   LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \
406              TRACE_TYPE_GENERIC,                                \
407          m, p1, p2, p3, p4, p5, p6)
408 #else
409 #define GKI_TRACE_0(m)
410 #define GKI_TRACE_1(m, p1)
411 #define GKI_TRACE_2(m, p1, p2)
412 #define GKI_TRACE_3(m, p1, p2, p3)
413 #define GKI_TRACE_4(m, p1, p2, p3, p4)
414 #define GKI_TRACE_5(m, p1, p2, p3, p4, p5)
415 #define GKI_TRACE_6(m, p1, p2, p3, p4, p5, p6)
416 
417 #endif
418 
419 #define GKI_TRACE_ERROR_0(m)                                                   \
420   LogMsg(                                                                      \
421       TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
422       m)
423 #define GKI_TRACE_ERROR_1(m, p1)                                               \
424   LogMsg(                                                                      \
425       TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
426       m, p1)
427 #define GKI_TRACE_ERROR_2(m, p1, p2)                                           \
428   LogMsg(                                                                      \
429       TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
430       m, p1, p2)
431 #define GKI_TRACE_ERROR_3(m, p1, p2, p3)                                       \
432   LogMsg(                                                                      \
433       TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
434       m, p1, p2, p3)
435 #define GKI_TRACE_ERROR_4(m, p1, p2, p3, p4)                                   \
436   LogMsg(                                                                      \
437       TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
438       m, p1, p2, p3, p4)
439 #define GKI_TRACE_ERROR_5(m, p1, p2, p3, p4, p5)                               \
440   LogMsg(                                                                      \
441       TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
442       m, p1, p2, p3, p4, p5)
443 #define GKI_TRACE_ERROR_6(m, p1, p2, p3, p4, p5, p6)                           \
444   LogMsg(                                                                      \
445       TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \
446       m, p1, p2, p3, p4, p5, p6)
447 
448 #ifdef __cplusplus
449 extern "C" {
450 #endif
451 
452 extern void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...);
453 
454 #ifdef __cplusplus
455 }
456 #endif
457 
458 #endif /* GKI_TARGET_H */
459