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