aboutsummaryrefslogtreecommitdiff
path: root/include/apos/debug.h
blob: ec591ef3c21e3ae01821d9777a7de5503aecbd2e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef APOS_DEBUG_H
#define APOS_DEBUG_H

#include <apos/attrs.h>
#include <apos/pmem.h>
#include <arch/vmem.h>

#if defined(DEBUG)
enum serial_dev {
	/* only the NS16550A and compatible at the moment */
	NS16550A,
};

void __fmt(1, 2) dbg(const char *fmt, ...);

void init_dbg(const void *fdt);

void setup_dmap_dbg();
void setup_io_dbg(struct vm_branch *b);
void setup_dbg(pm_t pt, enum serial_dev dev);

struct dbg_info dbg_from_fdt(const void *fdt);

#define COMMON_FORMAT "[%s] %s:%d\n\t"
#define COMMON_ARGS(s) s, __FILE__, __LINE__
#define bug(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("BUG"), __VA_ARGS__)
#define warn(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("WARN"), __VA_ARGS__)
#define info(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("INFO"), __VA_ARGS__)
#define error(fmt, ...) dbg(COMMON_FORMAT fmt, COMMON_ARGS("ERROR"), __VA_ARGS__)

#else

#define dbg(...)
#define dbg_init(...)
#define dbg_from_fdt(...)

#define init_dbg(...)
#define setup_dmap_dbg(...)
#define setup_io_dbg(...)

#define bug(...)
#define warn(...)
#define info(...)
#define error(...)

#endif /* DEBUG */

#endif /* APOS_DEBUG_H */