| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2010, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bdbg_app.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/1 $ |
|---|
| 12 | * $brcm_Date: 7/7/10 10:49a $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/basemodules/dbg/bdbg_app.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/1 7/7/10 10:49a vsilyaev |
|---|
| 21 | * SW7420-867: Application interface to the debug module |
|---|
| 22 | * |
|---|
| 23 | ***************************************************************************/ |
|---|
| 24 | |
|---|
| 25 | #ifndef BDBG_APP_H |
|---|
| 26 | #define BDBG_APP_H |
|---|
| 27 | |
|---|
| 28 | #ifdef __cplusplus |
|---|
| 29 | extern "C" { |
|---|
| 30 | #endif |
|---|
| 31 | |
|---|
| 32 | #if BDBG_DEBUG_BUILD |
|---|
| 33 | |
|---|
| 34 | /*************************************************************************** |
|---|
| 35 | Summary: |
|---|
| 36 | Set the instance debug level. |
|---|
| 37 | |
|---|
| 38 | Description: |
|---|
| 39 | Set debug level for the module instance. |
|---|
| 40 | |
|---|
| 41 | Input: |
|---|
| 42 | handle - the module instance |
|---|
| 43 | level - new debug level |
|---|
| 44 | |
|---|
| 45 | Returns: |
|---|
| 46 | BERR_SUCCESS - instance has been registered |
|---|
| 47 | BERR_INVALID_PARAMETER - unknown instance |
|---|
| 48 | ****************************************************************************/ |
|---|
| 49 | BERR_Code BDBG_SetInstanceLevel(BDBG_Instance handle, BDBG_Level level); |
|---|
| 50 | |
|---|
| 51 | /*************************************************************************** |
|---|
| 52 | Summary: |
|---|
| 53 | Get the instance debug level. |
|---|
| 54 | |
|---|
| 55 | Description: |
|---|
| 56 | Get current debug level for the module instance. |
|---|
| 57 | |
|---|
| 58 | Input: |
|---|
| 59 | handle - the module instance |
|---|
| 60 | |
|---|
| 61 | Output: |
|---|
| 62 | level - current debug level |
|---|
| 63 | |
|---|
| 64 | Returns: |
|---|
| 65 | BERR_SUCCESS - instance has been registered |
|---|
| 66 | BERR_INVALID_PARAMETER - unknown instance |
|---|
| 67 | ****************************************************************************/ |
|---|
| 68 | BERR_Code BDBG_GetInstanceLevel(BDBG_Instance handle, BDBG_Level *level); |
|---|
| 69 | |
|---|
| 70 | /*************************************************************************** |
|---|
| 71 | Summary: |
|---|
| 72 | Set the instance name. |
|---|
| 73 | |
|---|
| 74 | Description: |
|---|
| 75 | Set name for the module instance. |
|---|
| 76 | |
|---|
| 77 | Input: |
|---|
| 78 | handle - the module instance |
|---|
| 79 | new - name for the module instance |
|---|
| 80 | |
|---|
| 81 | Returns: |
|---|
| 82 | BERR_SUCCESS - instance has been registered |
|---|
| 83 | BERR_INVALID_PARAMETER - unknown instance |
|---|
| 84 | ****************************************************************************/ |
|---|
| 85 | BERR_Code BDBG_SetInstanceName(BDBG_Instance handle, const char *name); |
|---|
| 86 | |
|---|
| 87 | /*************************************************************************** |
|---|
| 88 | Summary: |
|---|
| 89 | Set the module debug level. |
|---|
| 90 | |
|---|
| 91 | Description: |
|---|
| 92 | Set debug level for the module. |
|---|
| 93 | |
|---|
| 94 | Input: |
|---|
| 95 | name - the module or module:instance name |
|---|
| 96 | level - new debug level |
|---|
| 97 | |
|---|
| 98 | Returns: |
|---|
| 99 | BERR_SUCCESS - the module debug level has been set |
|---|
| 100 | BERR_INVALID_PARAMETER - unknown module |
|---|
| 101 | ****************************************************************************/ |
|---|
| 102 | BERR_Code BDBG_SetModuleLevel(const char *name, BDBG_Level level); |
|---|
| 103 | |
|---|
| 104 | /*************************************************************************** |
|---|
| 105 | Summary: |
|---|
| 106 | Get module debug level. |
|---|
| 107 | |
|---|
| 108 | Description: |
|---|
| 109 | Get current debug level for the module. |
|---|
| 110 | |
|---|
| 111 | Input: |
|---|
| 112 | name - the module or module:instance name |
|---|
| 113 | level - new debug level |
|---|
| 114 | |
|---|
| 115 | Returns: |
|---|
| 116 | BERR_SUCCESS - the module debug level has been returned |
|---|
| 117 | BERR_INVALID_PARAMETER - unknown module |
|---|
| 118 | ****************************************************************************/ |
|---|
| 119 | BERR_Code BDBG_GetModuleLevel(const char *name, BDBG_Level *level); |
|---|
| 120 | |
|---|
| 121 | /*************************************************************************** |
|---|
| 122 | Summary: |
|---|
| 123 | Get the module's instance debug level. |
|---|
| 124 | |
|---|
| 125 | Description: |
|---|
| 126 | Get current debug level for the module's instance. |
|---|
| 127 | |
|---|
| 128 | Input: |
|---|
| 129 | name - the module name |
|---|
| 130 | handle - the module instance |
|---|
| 131 | |
|---|
| 132 | Output: |
|---|
| 133 | level - current debug level |
|---|
| 134 | |
|---|
| 135 | Returns: |
|---|
| 136 | BERR_SUCCESS - instance has been registered |
|---|
| 137 | BERR_INVALID_PARAMETER - unknown instance |
|---|
| 138 | ****************************************************************************/ |
|---|
| 139 | BERR_Code BDBG_GetModuleInstanceLevel(const char *name, BDBG_Instance handle, BDBG_Level *level); |
|---|
| 140 | |
|---|
| 141 | /*************************************************************************** |
|---|
| 142 | Summary: |
|---|
| 143 | Set the module's instance debug level. |
|---|
| 144 | |
|---|
| 145 | Description: |
|---|
| 146 | Set debug level for the module's instance. |
|---|
| 147 | |
|---|
| 148 | Input: |
|---|
| 149 | name - the module name |
|---|
| 150 | handle - the instance |
|---|
| 151 | level - new debug level |
|---|
| 152 | |
|---|
| 153 | Returns: |
|---|
| 154 | BERR_SUCCESS - the module debug level has been set |
|---|
| 155 | BERR_INVALID_PARAMETER - unknown module |
|---|
| 156 | ****************************************************************************/ |
|---|
| 157 | BERR_Code BDBG_SetModuleInstanceLevel(const char *name, BDBG_Instance handle, BDBG_Level level); |
|---|
| 158 | |
|---|
| 159 | /*************************************************************************** |
|---|
| 160 | Summary: |
|---|
| 161 | Set global debug level. |
|---|
| 162 | |
|---|
| 163 | Description: |
|---|
| 164 | Set the global debug level. |
|---|
| 165 | |
|---|
| 166 | Input: |
|---|
| 167 | level - new debug level |
|---|
| 168 | |
|---|
| 169 | Returns: |
|---|
| 170 | BERR_SUCCESS - global debug level has been set |
|---|
| 171 | ****************************************************************************/ |
|---|
| 172 | BERR_Code BDBG_SetLevel(BDBG_Level level); |
|---|
| 173 | |
|---|
| 174 | /*************************************************************************** |
|---|
| 175 | Summary: |
|---|
| 176 | Get the global debug level. |
|---|
| 177 | |
|---|
| 178 | Description: |
|---|
| 179 | Return the global debug level. |
|---|
| 180 | |
|---|
| 181 | Input: |
|---|
| 182 | <none> |
|---|
| 183 | |
|---|
| 184 | Output: |
|---|
| 185 | level - current global debug level |
|---|
| 186 | |
|---|
| 187 | Returns: |
|---|
| 188 | BERR_SUCCESS - current debug level has been retrieved |
|---|
| 189 | ****************************************************************************/ |
|---|
| 190 | BERR_Code BDBG_GetLevel(BDBG_Level *level); |
|---|
| 191 | |
|---|
| 192 | /*************************************************************************** |
|---|
| 193 | Summary: |
|---|
| 194 | Enumerates debug modules |
|---|
| 195 | |
|---|
| 196 | Description: |
|---|
| 197 | This function is used to enumerate all modules that are |
|---|
| 198 | to the debug subsystem. Module becomes known to the debug subsystem |
|---|
| 199 | after it was used any of following primitives: |
|---|
| 200 | BDBG_ENTER, BDBG_LEAVE, BDBG_MSG, BDBG_WRN, BDBG_ERR |
|---|
| 201 | or debug modules was accessed using by BDBG_SetModuleLevel |
|---|
| 202 | BDBG_GetModuleLevel functions. |
|---|
| 203 | |
|---|
| 204 | Input: |
|---|
| 205 | callback - callback function that is called for each module and instance |
|---|
| 206 | cntx - user specified context that would be passed into the callback function |
|---|
| 207 | |
|---|
| 208 | Output: |
|---|
| 209 | None |
|---|
| 210 | |
|---|
| 211 | Returns: |
|---|
| 212 | None |
|---|
| 213 | ****************************************************************************/ |
|---|
| 214 | void BDBG_EnumerateAll(void (*callback)(void *cntx, const char *module, BDBG_Instance instance, const char *inst_name), void *cntx); |
|---|
| 215 | |
|---|
| 216 | |
|---|
| 217 | /*************************************************************************** |
|---|
| 218 | Summary: |
|---|
| 219 | Set function to receive output the module; |
|---|
| 220 | |
|---|
| 221 | Description: |
|---|
| 222 | Set function that would receive all debug output generated by the module. Setting this |
|---|
| 223 | function would not affect debug output that directed to usual output channel. |
|---|
| 224 | If module_print |
|---|
| 225 | |
|---|
| 226 | Input: |
|---|
| 227 | name - the module or module:instance name |
|---|
| 228 | module_print - function that would receive all debug output generated by the module |
|---|
| 229 | |
|---|
| 230 | Returns: |
|---|
| 231 | BERR_SUCCESS - the module debug level has been set |
|---|
| 232 | BERR_INVALID_PARAMETER - unknown module |
|---|
| 233 | ****************************************************************************/ |
|---|
| 234 | BERR_Code BDBG_SetModulePrintFunction(const char *name, BDBG_DebugModule_Print module_print); |
|---|
| 235 | |
|---|
| 236 | #else /* BDBG_DEBUG_BUILD */ |
|---|
| 237 | |
|---|
| 238 | #define BDBG_SetLevel(level) (BERR_SUCCESS) |
|---|
| 239 | #define BDBG_GetLevel(pLevel) (*(pLevel) = BDBG_eMsg, BERR_SUCCESS) |
|---|
| 240 | #define BDBG_SetModuleLevel(module, level) (BERR_SUCCESS) |
|---|
| 241 | #define BDBG_EnumerateAll(callback, cntx) BDBG_NOP() |
|---|
| 242 | #define BDBG_GetModuleLevel(module, pLevel) (*(pLevel) = BDBG_eMsg, BERR_SUCCESS) |
|---|
| 243 | #define BDBG_SetModuleInstanceLevel(module, handle, level) (BERR_SUCCESS) |
|---|
| 244 | #define BDBG_GetModuleInstanceLevel(module, handle, pLevel) (*(pLevel) = BDBG_eMsg, BERR_SUCCESS) |
|---|
| 245 | #define BDBG_SetInstanceLevel(handle, level) (BERR_SUCCESS) |
|---|
| 246 | #define BDBG_GetInstanceLevel(handle, pLevel) (*(pLevel) = BDBG_eMsg, BERR_SUCCESS) |
|---|
| 247 | #define BDBG_SetInstanceName(handle, name) (BERR_SUCCESS) |
|---|
| 248 | #endif /* BDBG_DEBUG_BUILD */ |
|---|
| 249 | |
|---|
| 250 | #ifdef __cplusplus |
|---|
| 251 | } |
|---|
| 252 | #endif |
|---|
| 253 | |
|---|
| 254 | #endif /* BDBG_APP_H */ |
|---|
| 255 | |
|---|