AM64x MCU+ SDK  08.06.00
cdn_log.h
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * Copyright (C) 2012-2021 Cadence Design Systems, Inc.
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  * 3. Neither the name of the copyright holder nor the names of its
14  * contributors may be used to endorse or promote products derived from
15  * this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
21  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  ******************************************************************************
30  * cdn_log.h
31  * System wide debug log messaging framework
32  *****************************************************************************/
33 
34 #ifndef INCLUDE_CDN_LOG_H
35 #define INCLUDE_CDN_LOG_H
36 
37 #ifdef __cplusplus
38 extern "C"
39 {
40 #endif
41 
42 #include "cdn_assert.h"
43 #include "cdn_inttypes.h"
44 #include <kernel/dpl/DebugP.h>
45 #include <kernel/nortos/dpl/common/printf.h>
46 
47 /* parasoft-begin-suppress MISRA2012-RULE-8_6-2 "An identifier with external linkage shall have exactly one external definition, DRV-4757" */
48 /* parasoft-begin-suppress MISRA2012-DIR-4_9-4 "A function should be used in preference to a function-like macro where they are interchangeable, DRV-4759" */
49 
50 #ifdef CFG_CUSB_DEBUG
51  #define DEBUG
52  #define CFP_DBG_MSG 1
53 #endif
54 
58 #define CLIENT_MSG 0x01000000
59 
60 #define DBG_GEN_MSG 0xFFFFFFFF
61 
70 #define DBG_CRIT 0
71 #define DBG_WARN 5
72 #define DBG_FYI 10
73 #define DBG_HIVERB 100
74 #define DBG_INFLOOP 200
75 
76 /* module mask: */
77 #ifdef _HAVE_DBG_LOG_INT_
78 uint32_t g_dbg_enable_log = 0;
79 #else
80 extern uint32_t g_dbg_enable_log;
81 #endif
82 
83 /* level, counter, state: */
84 #ifdef _HAVE_DBG_LOG_INT_
85 uint32_t g_dbg_log_lvl = DBG_CRIT;
86 uint32_t g_dbg_log_cnt = 0;
87 uint32_t g_dbg_state = 0;
88 #else
89 extern uint32_t g_dbg_log_lvl;
90 extern uint32_t g_dbg_log_cnt;
91 extern uint32_t g_dbg_state;
92 #endif
93 
94 /* There is possibility to provide custom logging functions instead of default
95  * - DbgMsg
96  * by defining macros:
97  * - DEBUG for DbgMsg with custom print implementation
98  *
99  * There is also possibility to provide own implementation of printf() routine by
100  * defining function:
101  * DbgPrint
102  * that provides name of functions that replace printf().
103  * Their prototype:
104  * void DbgPrint(const char *fmt, ...)
105  *
106  * If DEBUG symbol is defined, then appropriate prototype is declared within this header file.
107  *
108  * If DEBUG is not defined, print is not used. Existing macros will not print any data.
109  */
110 
111 /* For DEBUG build, use custom logging with own implementation of DbgPrint */
112 #ifdef DEBUG
113 extern void DbgPrint(uint32_t module_id,uint32_t log_lvl ,const char *fmt, ...);
114 #define cDbgMsg( _t, _x, ...) DbgPrint(_t,_x,__VA_ARGS__)
115 #else
116 #define cDbgMsg( _t, _x, ...)
117 #endif /* DEBUG */
118 
119 #ifdef CFP_DBG_MSG
120 #define DbgMsg( t, x, ...) cDbgMsg( (t), (x), __VA_ARGS__ )
121 #else
122 #define DbgMsg( t, x, ...)
123 #endif
124 
125 #define DEBUG_PREFIX "[ %s : %d ] "
126 
127 /* ******** Default vDbgMsg ******** */
128 # define vDbgMsg(log_lvl, module, msg, ...) DbgMsg( (log_lvl), (module), (DEBUG_PREFIX msg),__func__, \
129  __LINE__,__VA_ARGS__)
130 
131 /* ******** Default cvDbgMsg ******** */
132 # define cvDbgMsg(log_lvl, module, msg, ...) cDbgMsg( (log_lvl), (module), (DEBUG_PREFIX msg), __func__, \
133  __LINE__, g_dbg_log_cnt++, __VA_ARGS__)
134 
135 /* ******** Default cvDbgMsg ******** */
136 # define evDbgMsg(log_lvl, module, msg, ...) { cDbgMsg( (log_lvl), (module), (DEBUG_PREFIX msg), __func__, \
137  __LINE__, g_dbg_log_cnt++, __VA_ARGS__); \
138  assert(0); }
139 
140 /* parasoft-end-suppress MISRA2012-RULE-8_6-2 */
141 /* parasoft-end-suppress MISRA2012-DIR-4_4-4 */
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 
147 #endif /* INCLUDE_CDN_LOG_H */
DBG_CRIT
#define DBG_CRIT
Definition: cdn_log.h:70
g_dbg_log_lvl
uint32_t g_dbg_log_lvl
g_dbg_enable_log
uint32_t g_dbg_enable_log
g_dbg_log_cnt
uint32_t g_dbg_log_cnt
DebugP.h
DbgPrint
void DbgPrint(uint32_t module_id, uint32_t log_lvl, const char *str,...)
Printf function hook for cadence usb device driver.
g_dbg_state
uint32_t g_dbg_state