SyterKit 0.4.0.x
SyterKit is a bare-metal framework
Loading...
Searching...
No Matches
log.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: GPL-2.0+ */
2
3#ifndef __DEBUG_H__
4#define __DEBUG_H__
5
6#include <stdbool.h>
7#include <stddef.h>
8#include <stdint.h>
9#include <types.h>
10
11#include <timer.h>
12
13#include <sys-uart.h>
14
15#include "xformat.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif// __cplusplus
20
21#define LOG_LEVEL_MUTE 0
22#define LOG_LEVEL_ERROR 1
23#define LOG_LEVEL_WARNING 2
24#define LOG_LEVEL_INFO 3
25#define LOG_LEVEL_DEBUG 4
26#define LOG_LEVEL_TRACE 5
27#define LOG_LEVEL_BACKTRACE 6
28
29#ifndef LOG_LEVEL_DEFAULT
30
31#ifdef DEBUG_MODE
32#define LOG_LEVEL_DEFAULT LOG_LEVEL_DEBUG
33#elif defined TRACE_MODE
34#define LOG_LEVEL_DEFAULT LOG_LEVEL_TRACE
35#else
36#define LOG_LEVEL_DEFAULT LOG_LEVEL_INFO
37#endif// DEBUG_MODE
38
39#endif// LOG_LEVEL_DEFAULT
40
41#if LOG_LEVEL_DEFAULT >= LOG_LEVEL_TRACE
42#define printk_trace(fmt, ...) printk(LOG_LEVEL_TRACE, fmt, ##__VA_ARGS__)
43#else
44#define printk_trace(fmt, ...) ((void) 0)
45#endif
46
47#if LOG_LEVEL_DEFAULT >= LOG_LEVEL_DEBUG
48#define printk_debug(fmt, ...) printk(LOG_LEVEL_DEBUG, fmt, ##__VA_ARGS__)
49#else
50#define printk_debug(fmt, ...) ((void) 0)
51#endif
52
53#if LOG_LEVEL_DEFAULT >= LOG_LEVEL_INFO
54#define printk_info(fmt, ...) printk(LOG_LEVEL_INFO, fmt, ##__VA_ARGS__)
55#else
56#define printk_info(fmt, ...) ((void) 0)
57#endif
58
59#if LOG_LEVEL_DEFAULT >= LOG_LEVEL_WARNING
60#define printk_warning(fmt, ...) printk(LOG_LEVEL_WARNING, fmt, ##__VA_ARGS__)
61#else
62#define printk_warning(fmt, ...) ((void) 0)
63#endif
64
65#if LOG_LEVEL_DEFAULT >= LOG_LEVEL_ERROR
66#define printk_error(fmt, ...) printk(LOG_LEVEL_ERROR, fmt, ##__VA_ARGS__)
67#else
68#define printk_error(fmt, ...) ((void) 0)
69#endif
70
78void set_timer_count();
79
91void printk(int level, const char *fmt, ...);
92
103void uart_printf(const char *fmt, ...);
104
115int printf(const char *fmt, ...);
116
127void dump_hex(uint32_t start_addr, uint32_t count);
128
129#ifdef __cplusplus
130}
131#endif// __cplusplus
132
133#endif
u32_t uint32_t
Definition stdint.h:13
void set_timer_count()
Set timer count.
Definition timer.c:16
void printk(int level, const char *fmt,...)
Print message to kernel log.
Definition log.c:13
int printf(const char *fmt,...)
Print message via UART.
Definition log.c:84
void dump_hex(uint32_t start_addr, uint32_t count)
Dumps memory content in hexadecimal format.
Definition log.c:114
void uart_printf(const char *fmt,...)
Print message via UART.
Definition log.c:74