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 /* The size of the buffers in pool 0. */ 130 #ifndef GKI_BUF0_SIZE 131 #define GKI_BUF0_SIZE 64 132 #endif 133 134 /* The number of buffers in buffer pool 0. */ 135 #ifndef GKI_BUF0_MAX 136 #define GKI_BUF0_MAX 8 137 #endif 138 139 /* The ID of buffer pool 0. */ 140 #ifndef GKI_POOL_ID_0 141 #define GKI_POOL_ID_0 0 142 #endif 143 144 /* The size of the buffers in pool 1. */ 145 #ifndef GKI_BUF1_SIZE 146 #define GKI_BUF1_SIZE 288 147 #endif 148 149 /* The number of buffers in buffer pool 1. */ 150 #ifndef GKI_BUF1_MAX 151 #define GKI_BUF1_MAX 8 152 #endif 153 154 /* The ID of buffer pool 1. */ 155 #ifndef GKI_POOL_ID_1 156 #define GKI_POOL_ID_1 1 157 #endif 158 159 /* The size of the largest PUBLIC fixed buffer in system. */ 160 #ifndef GKI_MAX_BUF_SIZE 161 #define GKI_MAX_BUF_SIZE GKI_BUF1_SIZE 162 #endif 163 164 /* The pool ID of the largest PUBLIC fixed buffer in system. */ 165 #ifndef GKI_MAX_BUF_SIZE_POOL_ID 166 #define GKI_MAX_BUF_SIZE_POOL_ID GKI_POOL_ID_1 167 #endif 168 169 /* buffer size for USERIAL, it must large enough to hold NFC_HDR and max packet 170 * size */ 171 #ifndef USERIAL_POOL_BUF_SIZE 172 #define USERIAL_POOL_BUF_SIZE GKI_BUF1_SIZE 173 #endif 174 175 /* buffer pool ID for USERIAL */ 176 #ifndef USERIAL_POOL_ID 177 #define USERIAL_POOL_ID GKI_POOL_ID_1 178 #endif 179 180 #ifndef GKI_NUM_FIXED_BUF_POOLS 181 #define GKI_NUM_FIXED_BUF_POOLS 2 182 #endif 183 184 /* The number of fixed and dynamic buffer pools */ 185 #ifndef GKI_NUM_TOTAL_BUF_POOLS 186 #define GKI_NUM_TOTAL_BUF_POOLS 2 187 #endif 188 189 /* The buffer pool usage mask. */ 190 #ifndef GKI_DEF_BUFPOOL_PERM_MASK 191 #define GKI_DEF_BUFPOOL_PERM_MASK 0xfff0 192 #endif 193 194 /* The buffer corruption check flag. */ 195 #ifndef GKI_ENABLE_BUF_CORRUPTION_CHECK 196 #define GKI_ENABLE_BUF_CORRUPTION_CHECK TRUE 197 #endif 198 199 /* The GKI severe error macro. */ 200 #ifndef GKI_SEVERE 201 #define GKI_SEVERE(code) 202 #endif 203 204 /* Maximum number of exceptions logged. */ 205 #ifndef GKI_MAX_EXCEPTION 206 #define GKI_MAX_EXCEPTION 8 207 #endif 208 209 /* Maximum number of chars stored for each exception message. */ 210 #ifndef GKI_MAX_EXCEPTION_MSGLEN 211 #define GKI_MAX_EXCEPTION_MSGLEN 64 212 #endif 213 214 #ifndef GKI_SEND_MSG_FROM_ISR 215 #define GKI_SEND_MSG_FROM_ISR FALSE 216 #endif 217 218 #define GKI_TRACE_0(m) 219 #define GKI_TRACE_1(m, p1) 220 #define GKI_TRACE_2(m, p1, p2) 221 #define GKI_TRACE_3(m, p1, p2, p3) 222 #define GKI_TRACE_4(m, p1, p2, p3, p4) 223 #define GKI_TRACE_5(m, p1, p2, p3, p4, p5) 224 #define GKI_TRACE_6(m, p1, p2, p3, p4, p5, p6) 225 226 #define GKI_TRACE_ERROR_0(m) \ 227 LogMsg( \ 228 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 229 m) 230 #define GKI_TRACE_ERROR_1(m, p1) \ 231 LogMsg( \ 232 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 233 m, p1) 234 #define GKI_TRACE_ERROR_2(m, p1, p2) \ 235 LogMsg( \ 236 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 237 m, p1, p2) 238 #define GKI_TRACE_ERROR_3(m, p1, p2, p3) \ 239 LogMsg( \ 240 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 241 m, p1, p2, p3) 242 #define GKI_TRACE_ERROR_4(m, p1, p2, p3, p4) \ 243 LogMsg( \ 244 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 245 m, p1, p2, p3, p4) 246 #define GKI_TRACE_ERROR_5(m, p1, p2, p3, p4, p5) \ 247 LogMsg( \ 248 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 249 m, p1, p2, p3, p4, p5) 250 #define GKI_TRACE_ERROR_6(m, p1, p2, p3, p4, p5, p6) \ 251 LogMsg( \ 252 TRACE_CTRL_GENERAL | TRACE_LAYER_GKI | TRACE_ORG_GKI | TRACE_TYPE_ERROR, \ 253 m, p1, p2, p3, p4, p5, p6) 254 255 #ifdef __cplusplus 256 extern "C" { 257 #endif 258 259 extern void LogMsg(uint32_t trace_set_mask, const char* fmt_str, ...); 260 261 #ifdef __cplusplus 262 } 263 #endif 264 265 #endif /* GKI_TARGET_H */ 266