1 /****************************************************************************** 2 * 3 * Copyright (C) 2012-2014 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 #ifndef GKI_HAL_TARGET_H 20 #define GKI_HAL_TARGET_H 21 22 #ifdef BUILDCFG 23 #include "buildcfg_hal.h" 24 #endif 25 26 #include "data_types.h" 27 28 /****************************************************************************** 29 ** 30 ** Task configuration 31 ** 32 ******************************************************************************/ 33 34 /* Definitions of task IDs for inter-task messaging */ 35 #ifndef NFC_HAL_TASK 36 #define NFC_HAL_TASK 0 37 #endif 38 39 /* The number of GKI tasks in the software system. */ 40 #ifndef GKI_MAX_TASKS 41 #define GKI_MAX_TASKS 1 42 #endif 43 44 /****************************************************************************** 45 ** 46 ** Buffer pool assignment 47 ** 48 ******************************************************************************/ 49 50 /* GKI pool for NCI messages */ 51 #ifndef NFC_HAL_NCI_POOL_ID 52 #define NFC_HAL_NCI_POOL_ID GKI_POOL_ID_1 53 #endif 54 55 #ifndef NFC_HAL_NCI_POOL_BUF_SIZE 56 #define NFC_HAL_NCI_POOL_BUF_SIZE GKI_BUF1_SIZE 57 #endif 58 59 /****************************************************************************** 60 ** 61 ** Timer configuration 62 ** 63 ******************************************************************************/ 64 65 /* The number of GKI timers in the software system. */ 66 #ifndef GKI_NUM_TIMERS 67 #define GKI_NUM_TIMERS 2 68 #endif 69 70 /* A conversion value for translating ticks to calculate GKI timer. */ 71 #ifndef TICKS_PER_SEC 72 #define TICKS_PER_SEC 100 73 #endif 74 75 /************************************************************************ 76 ** Utility macros converting ticks to time with user define OS ticks per sec 77 **/ 78 #ifndef GKI_MS_TO_TICKS 79 #define GKI_MS_TO_TICKS(x) ((x) / (1000 / TICKS_PER_SEC)) 80 #endif 81 82 #ifndef GKI_SECS_TO_TICKS 83 #define GKI_SECS_TO_TICKS(x) ((x) * (TICKS_PER_SEC)) 84 #endif 85 86 #ifndef GKI_TICKS_TO_MS 87 #define GKI_TICKS_TO_MS(x) ((x)*1000 / TICKS_PER_SEC) 88 #endif 89 90 #ifndef GKI_TICKS_TO_SECS 91 #define GKI_TICKS_TO_SECS(x) ((x) / TICKS_PER_SEC) 92 #endif 93 94 /* TICK per second from OS (OS dependent change this macro accordingly to 95 * various OS) */ 96 #ifndef OS_TICKS_PER_SEC 97 #define OS_TICKS_PER_SEC 1000 98 #endif 99 100 /************************************************************************ 101 ** Utility macros converting ticks to time with user define OS ticks per sec 102 **/ 103 104 #ifndef GKI_OS_TICKS_TO_MS 105 #define GKI_OS_TICKS_TO_MS(x) ((x)*1000 / OS_TICKS_PER_SEC) 106 #endif 107 108 #ifndef GKI_OS_TICKS_TO_SECS 109 #define GKI_OS_TICKS_TO_SECS(x) ((x) / OS_TICKS_PER_SEC)) 110 #endif 111 112 /* delay in ticks before stopping system tick. */ 113 #ifndef GKI_DELAY_STOP_SYS_TICK 114 #define GKI_DELAY_STOP_SYS_TICK 10 115 #endif 116 117 /* Option to guarantee no preemption during timer expiration (most system don't 118 * need this) */ 119 #ifndef GKI_TIMER_LIST_NOPREEMPT 120 #define GKI_TIMER_LIST_NOPREEMPT FALSE 121 #endif 122 123 /****************************************************************************** 124 ** 125 ** Buffer configuration 126 ** 127 ******************************************************************************/ 128 129 /* TRUE if GKI uses dynamic buffers. */ 130 #ifndef GKI_USE_DYNAMIC_BUFFERS 131 #define GKI_USE_DYNAMIC_BUFFERS FALSE 132 #endif 133 134 /* The size of the buffers in pool 0. */ 135 #ifndef GKI_BUF0_SIZE 136 #define GKI_BUF0_SIZE 64 137 #endif 138 139 /* The number of buffers in buffer pool 0. */ 140 #ifndef GKI_BUF0_MAX 141 #define GKI_BUF0_MAX 8 142 #endif 143 144 /* The ID of buffer pool 0. */ 145 #ifndef GKI_POOL_ID_0 146 #define GKI_POOL_ID_0 0 147 #endif 148 149 /* The size of the buffers in pool 1. */ 150 #ifndef GKI_BUF1_SIZE 151 #define GKI_BUF1_SIZE 288 152 #endif 153 154 /* The number of buffers in buffer pool 1. */ 155 #ifndef GKI_BUF1_MAX 156 #define GKI_BUF1_MAX 8 157 #endif 158 159 /* The ID of buffer pool 1. */ 160 #ifndef GKI_POOL_ID_1 161 #define GKI_POOL_ID_1 1 162 #endif 163 164 /* The size of the largest PUBLIC fixed buffer in system. */ 165 #ifndef GKI_MAX_BUF_SIZE 166 #define GKI_MAX_BUF_SIZE GKI_BUF1_SIZE 167 #endif 168 169 /* The pool ID of the largest PUBLIC fixed buffer in system. */ 170 #ifndef GKI_MAX_BUF_SIZE_POOL_ID 171 #define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_1 172 #endif 173 174 /* buffer size for USERIAL, it must large enough to hold NFC_HDR and max packet 175 * size */ 176 #ifndef USERIAL_POOL_BUF_SIZE 177 #define USERIAL_POOL_BUF_SIZE GKI_BUF1_SIZE 178 #endif 179 180 /* buffer pool ID for USERIAL */ 181 #ifndef USERIAL_POOL_ID 182 #define USERIAL_POOL_ID GKI_POOL_ID_1 183 #endif 184 185 #ifndef GKI_NUM_FIXED_BUF_POOLS 186 #define GKI_NUM_FIXED_BUF_POOLS 2 187 #endif 188 189 /* The number of fixed and dynamic buffer pools */ 190 #ifndef GKI_NUM_TOTAL_BUF_POOLS 191 #define GKI_NUM_TOTAL_BUF_POOLS 2 192 #endif 193 194 /* The buffer pool usage mask. */ 195 #ifndef GKI_DEF_BUFPOOL_PERM_MASK 196 #define GKI_DEF_BUFPOOL_PERM_MASK 0xfff0 197 #endif 198 199 /* The buffer corruption check flag. */ 200 #ifndef GKI_ENABLE_BUF_CORRUPTION_CHECK 201 #define GKI_ENABLE_BUF_CORRUPTION_CHECK TRUE 202 #endif 203 204 /* The GKI severe error macro. */ 205 #ifndef GKI_SEVERE 206 #define GKI_SEVERE(code) 207 #endif 208 209 /* TRUE if GKI includes debug functionality. */ 210 #ifndef GKI_DEBUG 211 #define GKI_DEBUG FALSE 212 #endif 213 214 /* Maximum number of exceptions logged. */ 215 #ifndef GKI_MAX_EXCEPTION 216 #define GKI_MAX_EXCEPTION 8 217 #endif 218 219 /* Maximum number of chars stored for each exception message. */ 220 #ifndef GKI_MAX_EXCEPTION_MSGLEN 221 #define GKI_MAX_EXCEPTION_MSGLEN 64 222 #endif 223 224 #ifndef GKI_SEND_MSG_FROM_ISR 225 #define GKI_SEND_MSG_FROM_ISR FALSE 226 #endif 227 228 #if (GKI_DEBUG == TRUE) 229 #ifdef LOG_TAG 230 #undef LOG_TAG 231 #endif 232 #define LOG_TAG "GKI_LINUX" 233 /* GKI Trace Macros */ 234 #define GKI_TRACE_0(m) \ 235 LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \ 236 TRACE_TYPE_GENERIC, \ 237 m) 238 #define GKI_TRACE_1(m, p1) \ 239 LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \ 240 TRACE_TYPE_GENERIC, \ 241 m, p1) 242 #define GKI_TRACE_2(m, p1, p2) \ 243 LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \ 244 TRACE_TYPE_GENERIC, \ 245 m, p1, p2) 246 #define GKI_TRACE_3(m, p1, p2, p3) \ 247 LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \ 248 TRACE_TYPE_GENERIC, \ 249 m, p1, p2, p3) 250 #define GKI_TRACE_4(m, p1, p2, p3, p4) \ 251 LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \ 252 TRACE_TYPE_GENERIC, \ 253 m, p1, p2, p3, p4) 254 #define GKI_TRACE_5(m, p1, p2, p3, p4, p5) \ 255 LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \ 256 TRACE_TYPE_GENERIC, \ 257 m, p1, p2, p3, p4, p5) 258 #define GKI_TRACE_6(m, p1, p2, p3, p4, p5, p6) \ 259 LogMsg(TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | \ 260 TRACE_TYPE_GENERIC, \ 261 m, p1, p2, p3, p4, p5, p6) 262 #else 263 #define GKI_TRACE_0(m) 264 #define GKI_TRACE_1(m, p1) 265 #define GKI_TRACE_2(m, p1, p2) 266 #define GKI_TRACE_3(m, p1, p2, p3) 267 #define GKI_TRACE_4(m, p1, p2, p3, p4) 268 #define GKI_TRACE_5(m, p1, p2, p3, p4, p5) 269 #define GKI_TRACE_6(m, p1, p2, p3, p4, p5, p6) 270 271 #endif 272 273 #define GKI_TRACE_ERROR_0(m) \ 274 LogMsg( \ 275 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 276 m) 277 #define GKI_TRACE_ERROR_1(m, p1) \ 278 LogMsg( \ 279 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 280 m, p1) 281 #define GKI_TRACE_ERROR_2(m, p1, p2) \ 282 LogMsg( \ 283 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 284 m, p1, p2) 285 #define GKI_TRACE_ERROR_3(m, p1, p2, p3) \ 286 LogMsg( \ 287 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 288 m, p1, p2, p3) 289 #define GKI_TRACE_ERROR_4(m, p1, p2, p3, p4) \ 290 LogMsg( \ 291 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 292 m, p1, p2, p3, p4) 293 #define GKI_TRACE_ERROR_5(m, p1, p2, p3, p4, p5) \ 294 LogMsg( \ 295 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 296 m, p1, p2, p3, p4, p5) 297 #define GKI_TRACE_ERROR_6(m, p1, p2, p3, p4, p5, p6) \ 298 LogMsg( \ 299 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 300 m, p1, p2, p3, p4, p5, p6) 301 302 #ifdef __cplusplus 303 extern "C" { 304 #endif 305 306 extern void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...); 307 308 #ifdef __cplusplus 309 } 310 #endif 311 312 #endif /* GKI_TARGET_H */ 313