Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
csr_log_text.h
Go to the documentation of this file.
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 
13 #include "csr_log_configure.h"
14 
15 #ifdef __cplusplus
16 extern "C" {
17 #endif
18 
19 typedef struct CsrLogSubOrigin
20 {
21  u16 subOriginNumber; /* Id of the given SubOrigin */
22  const char *subOriginName; /* Prefix Text for this SubOrigin */
24 
25 /* Register a task which is going to use the CSR_LOG_TEXT_XXX interface */
26 #ifdef CSR_LOG_ENABLE
27 void CsrLogTextRegister(CsrLogTextTaskId taskId, const char *taskName, u16 subOriginsLength, const CsrLogSubOrigin *subOrigins);
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)
35 void CsrLogTextCritical(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
36 void CsrLogTextBufferCritical(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
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)
51 void CsrLogTextError(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
52 void CsrLogTextBufferError(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
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)
68 void CsrLogTextWarning(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
69 void CsrLogTextBufferWarning(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
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)
84 void CsrLogTextInfo(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
85 void CsrLogTextBufferInfo(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
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)
99 void CsrLogTextDebug(CsrLogTextTaskId taskId, u16 subOrigin, const char *formatString, ...);
100 void CsrLogTextBufferDebug(CsrLogTextTaskId taskId, u16 subOrigin, size_t bufferLength, const void *buffer, const char *formatString, ...);
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