89 lines
2.2 KiB
C
Executable File
89 lines
2.2 KiB
C
Executable File
#ifndef __MODULE_DBG_H_
|
|
#define __MODULE_DBG_H_
|
|
|
|
#if defined __KERNEL__
|
|
#define vk_pr_warn pr_warn
|
|
#define vk_printk printk
|
|
#elif defined(__FREERTOS)
|
|
#include <stdio.h>
|
|
#define vk_pr_warn printf
|
|
#define vk_printk printf
|
|
|
|
#ifndef unlikely
|
|
#define unlikely(x) (x)
|
|
#endif
|
|
|
|
#else
|
|
#error Not supported OS
|
|
#endif
|
|
|
|
#define NVT_DBG_FATAL 0
|
|
#define NVT_DBG_ERR 1
|
|
#define NVT_DBG_WRN 2
|
|
#define NVT_DBG_UNIT 3
|
|
#define NVT_DBG_FUNC 4
|
|
#define NVT_DBG_IND 5
|
|
#define NVT_DBG_MSG 6
|
|
#define NVT_DBG_VALUE 7
|
|
#define NVT_DBG_USER 8
|
|
|
|
#ifdef DEBUG
|
|
extern unsigned int otp_debug_level;
|
|
#define nvt_dbg(level, fmt, args...) \
|
|
do { \
|
|
if (unlikely(NVT_DBG_##level <= otp_debug_level)) \
|
|
vk_pr_warn("%s:" fmt, __func__, ##args); \
|
|
} while (0)
|
|
#else
|
|
#define nvt_dbg(fmt, ...)
|
|
#endif
|
|
|
|
#define DBG_FATAL(fmt, args...) nvt_dbg(FATAL, fmt, ##args)
|
|
#define DBG_ERR(fmt, args...) nvt_dbg(ERR, fmt, ##args)
|
|
#define DBG_WRN(fmt, args...) nvt_dbg(WRN, fmt, ##args)
|
|
#define DBG_UNIT(fmt, args...) nvt_dbg(UNIT, fmt, ##args)
|
|
#define DBG_FUNC(fmt, args...) nvt_dbg(FUNC, fmt, ##args)
|
|
#define DBG_IND(fmt, args...) nvt_dbg(IND, fmt, ##args)
|
|
#define DBG_MSG(fmt, args...) nvt_dbg(MSG, fmt, ##args)
|
|
#define DBG_VALUE(fmt, args...) nvt_dbg(VALUE, fmt, ##args)
|
|
#define DBG_USER(fmt, args...) nvt_dbg(USER, fmt, ##args)
|
|
#define DBG_DUMP(fmt, args...) vk_pr_warn("%s:" fmt, __func__, ##args);
|
|
|
|
#endif
|
|
|
|
/*
|
|
#ifndef CHKPNT
|
|
#define CHKPNT printk("\033[37mCHK: %d, %s\033[0m\r\n", __LINE__, __func__)
|
|
#endif
|
|
|
|
#ifndef DBGD
|
|
#define DBGD(x) printk("\033[0;35m%s=%d\033[0m\r\n", #x, x)
|
|
#endif
|
|
|
|
#ifndef DBGH
|
|
#define DBGH(x) printk("\033[0;35m%s=0x%08X\033[0m\r\n", #x, x)
|
|
#endif
|
|
|
|
#ifndef DBG_DUMP
|
|
#define DBG_DUMP(fmtstr, args...) printk(fmtstr, ##args)
|
|
#endif
|
|
|
|
#ifndef DBG_ERR
|
|
#define DBG_ERR(fmtstr, args...) printk("\033[0;31mERR:%s() \033[0m" fmtstr, __func__, ##args)
|
|
#endif
|
|
|
|
#ifndef DBG_WRN
|
|
#define DBG_WRN(fmtstr, args...) printk("\033[0;33mWRN:%s() \033[0m" fmtstr, __func__, ##args)
|
|
#endif
|
|
|
|
#if 0
|
|
#define DBG_IND(fmtstr, args...) printk("%s(): " fmtstr, __func__, ##args)
|
|
#else
|
|
#ifndef DBG_IND
|
|
#define DBG_IND(fmtstr, args...)
|
|
#endif
|
|
#endif
|
|
*/
|
|
|
|
|