barebox/include/printk.h
Sascha Hauer a9d7b3d00e Add PBL console support
This adds simple console support to the PBL which makes it
possible to print more complex messages in the PBL than just
strings or hex numbers. For now puts_ll is used to print the
messages, so it depends on CONFIG_DEBUG_LL which makes it
more a debugging option. However, this could be extended later
to get regular output from the PBL if desired.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2015-01-05 11:30:59 +01:00

110 lines
3.4 KiB
C

#ifndef __PRINTK_H
#define __PRINTK_H
#define MSG_EMERG 0 /* system is unusable */
#define MSG_ALERT 1 /* action must be taken immediately */
#define MSG_CRIT 2 /* critical conditions */
#define MSG_ERR 3 /* error conditions */
#define MSG_WARNING 4 /* warning conditions */
#define MSG_NOTICE 5 /* normal but significant condition */
#define MSG_INFO 6 /* informational */
#define MSG_DEBUG 7 /* debug-level messages */
#define MSG_VDEBUG 8 /* verbose debug messages */
#ifdef VERBOSE_DEBUG
#define LOGLEVEL MSG_VDEBUG
#elif defined DEBUG
#define LOGLEVEL MSG_DEBUG
#else
#define LOGLEVEL CONFIG_COMPILE_LOGLEVEL
#endif
/* debugging and troubleshooting/diagnostic helpers. */
#ifndef CONFIG_CONSOLE_NONE
int dev_printf(int level, const struct device_d *dev, const char *format, ...)
__attribute__ ((format(__printf__, 3, 4)));
#else
static inline int dev_printf(int level, const struct device_d *dev, const char *format, ...)
{
return 0;
}
#endif
#if (!defined(__PBL__) && !defined(CONFIG_CONSOLE_NONE)) || \
(defined(__PBL__) && defined(CONFIG_PBL_CONSOLE))
int pr_print(int level, const char *format, ...)
__attribute__ ((format(__printf__, 2, 3)));
#else
static int pr_print(int level, const char *format, ...)
__attribute__ ((format(__printf__, 2, 3)));
static inline int pr_print(int level, const char *format, ...)
{
return 0;
}
#endif
#define __dev_printf(level, dev, format, args...) \
({ \
(level) <= LOGLEVEL ? dev_printf((level), (dev), (format), ##args) : 0; \
})
#define dev_emerg(dev, format, arg...) \
__dev_printf(0, (dev) , format , ## arg)
#define dev_alert(dev, format, arg...) \
__dev_printf(1, (dev) , format , ## arg)
#define dev_crit(dev, format, arg...) \
__dev_printf(2, (dev) , format , ## arg)
#define dev_err(dev, format, arg...) \
__dev_printf(3, (dev) , format , ## arg)
#define dev_warn(dev, format, arg...) \
__dev_printf(4, (dev) , format , ## arg)
#define dev_notice(dev, format, arg...) \
__dev_printf(5, (dev) , format , ## arg)
#define dev_info(dev, format, arg...) \
__dev_printf(6, (dev) , format , ## arg)
#define dev_dbg(dev, format, arg...) \
__dev_printf(7, (dev) , format , ## arg)
#define dev_vdbg(dev, format, arg...) \
__dev_printf(8, (dev) , format , ## arg)
#define __pr_printk(level, format, args...) \
({ \
(level) <= LOGLEVEL ? pr_print((level), (format), ##args) : 0; \
})
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif
#define pr_emerg(fmt, arg...) __pr_printk(0, pr_fmt(fmt), ##arg)
#define pr_alert(fmt, arg...) __pr_printk(1, pr_fmt(fmt), ##arg)
#define pr_crit(fmt, arg...) __pr_printk(2, pr_fmt(fmt), ##arg)
#define pr_err(fmt, arg...) __pr_printk(3, pr_fmt(fmt), ##arg)
#define pr_warning(fmt, arg...) __pr_printk(4, pr_fmt(fmt), ##arg)
#define pr_notice(fmt, arg...) __pr_printk(5, pr_fmt(fmt), ##arg)
#define pr_info(fmt, arg...) __pr_printk(6, pr_fmt(fmt), ##arg)
#define pr_debug(fmt, arg...) __pr_printk(7, pr_fmt(fmt), ##arg)
#define debug(fmt, arg...) __pr_printk(7, pr_fmt(fmt), ##arg)
#define pr_vdebug(fmt, arg...) __pr_printk(8, pr_fmt(fmt), ##arg)
struct log_entry {
struct list_head list;
char *msg;
void *dummy;
uint64_t timestamp;
int level;
};
extern struct list_head barebox_logbuf;
extern void log_clean(unsigned int limit);
#define BAREBOX_LOG_PRINT_TIME (1 << 0)
#define BAREBOX_LOG_DIFF_TIME (1 << 1)
void log_print(unsigned flags);
#endif