Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 1 | #ifndef CSR_LOG_TEXT_H__ |
| 2 | #define CSR_LOG_TEXT_H__ |
| 3 | /***************************************************************************** |
| 4 | |
| 5 | (c) Cambridge Silicon Radio Limited 2010 |
| 6 | All rights reserved and confidential information of CSR |
| 7 | |
| 8 | Refer to LICENSE.txt included with this source for details |
| 9 | on the license terms. |
| 10 | |
| 11 | *****************************************************************************/ |
| 12 | |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 13 | #include "csr_log_configure.h" |
| 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | typedef struct CsrLogSubOrigin |
| 20 | { |
Greg Kroah-Hartman | 8c87f69 | 2012-07-20 12:00:10 -0700 | [diff] [blame] | 21 | u16 subOriginNumber; /* Id of the given SubOrigin */ |
Greg Kroah-Hartman | c781b96 | 2012-07-20 12:22:32 -0700 | [diff] [blame] | 22 | const char *subOriginName; /* Prefix Text for this SubOrigin */ |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 23 | } CsrLogSubOrigin; |
| 24 | |
| 25 | /* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */ |
| 26 | #ifdef CSR_LOG_ENABLE |
Greg Kroah-Hartman | c781b96 | 2012-07-20 12:22:32 -0700 | [diff] [blame] | 27 | void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins); |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 28 | #else |
| 29 | #define CsrLogTextRegister(taskId, taskName, subOriginsLength, subOrigins) |
| 30 | #endif |
| 31 | |
| 32 | /* CRITICAL: Conditions that are threatening to the integrity/stability of the |
| 33 | system as a whole. */ |
| 34 | #if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_CRITICAL_DISABLE) |
Greg Kroah-Hartman | c781b96 | 2012-07-20 12:22:32 -0700 | [diff] [blame] | 35 | void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); |
Greg Kroah-Hartman | d4fda8d | 2012-07-20 12:27:19 -0700 | [diff] [blame] | 36 | void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 37 | #define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) CsrLogTextCritical taskId_subOrigin_formatString_varargs |
| 38 | #define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_CRITICAL(logtextargs);}} |
| 39 | #define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferCritical taskId_subOrigin_length_buffer_formatString_varargs |
| 40 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_CRITICAL(logtextbufferargs);}} |
| 41 | #else |
| 42 | #define CSR_LOG_TEXT_CRITICAL(taskId_subOrigin_formatString_varargs) |
| 43 | #define CSR_LOG_TEXT_CONDITIONAL_CRITICAL(condition, logtextargs) |
| 44 | #define CSR_LOG_TEXT_BUFFER_CRITICAL(taskId_subOrigin_length_buffer_formatString_varargs) |
| 45 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_CRITICAL(condition, logtextbufferargs) |
| 46 | #endif |
| 47 | |
| 48 | /* ERROR: Malfunction of a component rendering it unable to operate correctly, |
| 49 | causing lack of functionality but not loss of system integrity/stability. */ |
| 50 | #if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_ERROR_DISABLE) |
Greg Kroah-Hartman | c781b96 | 2012-07-20 12:22:32 -0700 | [diff] [blame] | 51 | void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); |
Greg Kroah-Hartman | d4fda8d | 2012-07-20 12:27:19 -0700 | [diff] [blame] | 52 | void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 53 | #define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) CsrLogTextError taskId_subOrigin_formatString_varargs |
| 54 | #define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_ERROR(logtextargs);}} |
| 55 | #define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferError taskId_subOrigin_length_buffer_formatString_varargs |
| 56 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_ERROR(logtextbufferargs);}} |
| 57 | #else |
| 58 | #define CSR_LOG_TEXT_ERROR(taskId_subOrigin_formatString_varargs) |
| 59 | #define CSR_LOG_TEXT_CONDITIONAL_ERROR(condition, logtextargs) |
| 60 | #define CSR_LOG_TEXT_BUFFER_ERROR(taskId_subOrigin_length_buffer_formatString_varargs) |
| 61 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_ERROR(condition, logtextbufferargs) |
| 62 | #endif |
| 63 | |
| 64 | /* WARNING: Conditions that are unexpected and indicative of possible problems |
| 65 | or violations of specifications, where the result of such deviations does not |
| 66 | lead to malfunction of the component. */ |
| 67 | #if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_WARNING_DISABLE) |
Greg Kroah-Hartman | c781b96 | 2012-07-20 12:22:32 -0700 | [diff] [blame] | 68 | void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); |
Greg Kroah-Hartman | d4fda8d | 2012-07-20 12:27:19 -0700 | [diff] [blame] | 69 | void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 70 | #define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) CsrLogTextWarning taskId_subOrigin_formatString_varargs |
| 71 | #define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_WARNING(logtextargs);}} |
| 72 | #define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferWarning taskId_subOrigin_length_buffer_formatString_varargs |
| 73 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_WARNING(logtextbufferargs);}} |
| 74 | #else |
| 75 | #define CSR_LOG_TEXT_WARNING(taskId_subOrigin_formatString_varargs) |
| 76 | #define CSR_LOG_TEXT_CONDITIONAL_WARNING(condition, logtextargs) |
| 77 | #define CSR_LOG_TEXT_BUFFER_WARNING(taskId_subOrigin_length_buffer_formatString_varargs) |
| 78 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_WARNING(condition, logtextbufferargs) |
| 79 | #endif |
| 80 | |
| 81 | /* INFO: Important events that may aid in determining the conditions under which |
| 82 | the more severe conditions are encountered. */ |
| 83 | #if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_INFO_DISABLE) |
Greg Kroah-Hartman | c781b96 | 2012-07-20 12:22:32 -0700 | [diff] [blame] | 84 | void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); |
Greg Kroah-Hartman | d4fda8d | 2012-07-20 12:27:19 -0700 | [diff] [blame] | 85 | void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 86 | #define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) CsrLogTextInfo taskId_subOrigin_formatString_varargs |
| 87 | #define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_INFO(logtextargs);}} |
| 88 | #define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferInfo taskId_subOrigin_length_buffer_formatString_varargs |
| 89 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_INFO(logtextbufferargs);}} |
| 90 | #else |
| 91 | #define CSR_LOG_TEXT_INFO(taskId_subOrigin_formatString_varargs) |
| 92 | #define CSR_LOG_TEXT_CONDITIONAL_INFO(condition, logtextargs) |
| 93 | #define CSR_LOG_TEXT_BUFFER_INFO(taskId_subOrigin_length_buffer_formatString_varargs) |
| 94 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_INFO(condition, logtextbufferargs) |
| 95 | #endif |
| 96 | |
| 97 | /* DEBUG: Similar to INFO, but dedicated to events that occur more frequently. */ |
| 98 | #if defined(CSR_LOG_ENABLE) && !defined(CSR_LOG_LEVEL_TEXT_DEBUG_DISABLE) |
Greg Kroah-Hartman | c781b96 | 2012-07-20 12:22:32 -0700 | [diff] [blame] | 99 | void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...); |
Greg Kroah-Hartman | d4fda8d | 2012-07-20 12:27:19 -0700 | [diff] [blame] | 100 | void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...); |
Greg Kroah-Hartman | 635d2b0 | 2012-06-19 16:15:42 -0700 | [diff] [blame] | 101 | #define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) CsrLogTextDebug taskId_subOrigin_formatString_varargs |
| 102 | #define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) {if (condition) {CSR_LOG_TEXT_DEBUG(logtextargs);}} |
| 103 | #define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) CsrLogTextBufferDebug taskId_subOrigin_length_buffer_formatString_varargs |
| 104 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) {if (condition) {CSR_LOG_TEXT_BUFFER_DEBUG(logtextbufferargs);}} |
| 105 | #else |
| 106 | #define CSR_LOG_TEXT_DEBUG(taskId_subOrigin_formatString_varargs) |
| 107 | #define CSR_LOG_TEXT_CONDITIONAL_DEBUG(condition, logtextargs) |
| 108 | #define CSR_LOG_TEXT_BUFFER_DEBUG(taskId_subOrigin_length_buffer_formatString_varargs) |
| 109 | #define CSR_LOG_TEXT_BUFFER_CONDITIONAL_DEBUG(condition, logtextbufferargs) |
| 110 | #endif |
| 111 | |
| 112 | /* CSR_LOG_TEXT_ASSERT (CRITICAL) */ |
| 113 | #ifdef CSR_LOG_ENABLE |
| 114 | #define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) \ |
| 115 | {if (!(condition)) {CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Assertion \"%s\" failed at %s:%u", #condition, __FILE__, __LINE__));}} |
| 116 | #else |
| 117 | #define CSR_LOG_TEXT_ASSERT(origin, suborigin, condition) |
| 118 | #endif |
| 119 | |
| 120 | /* CSR_LOG_TEXT_UNHANDLED_PRIM (CRITICAL) */ |
| 121 | #ifdef CSR_LOG_ENABLE |
| 122 | #define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) \ |
| 123 | CSR_LOG_TEXT_CRITICAL((origin, suborigin, "Unhandled primitive 0x%04X:0x%04X at %s:%u", primClass, primType, __FILE__, __LINE__)) |
| 124 | #else |
| 125 | #define CSR_LOG_TEXT_UNHANDLED_PRIMITIVE(origin, suborigin, primClass, primType) |
| 126 | #endif |
| 127 | |
| 128 | #ifdef __cplusplus |
| 129 | } |
| 130 | #endif |
| 131 | |
| 132 | #endif |