blob: 14288cf505d8fce5e083b2b14bdb7f8f9066feac [file] [log] [blame]
Kevin O'Connor2d2fa312013-09-14 21:55:26 -04001#ifndef __OUTPUT_H
2#define __OUTPUT_H
3
Kevin O'Connor71036f82014-04-07 20:36:02 -04004#include "config.h" // CONFIG_DEBUG_LEVEL
Kevin O'Connor2d2fa312013-09-14 21:55:26 -04005#include "types.h" // u32
6
7// output.c
Kevin O'Connorbb1fcb42014-01-15 13:52:14 -05008void debug_banner(void);
Kevin O'Connor2d2fa312013-09-14 21:55:26 -04009void panic(const char *fmt, ...)
10 __attribute__ ((format (printf, 1, 2))) __noreturn;
11void printf(const char *fmt, ...)
12 __attribute__ ((format (printf, 1, 2)));
13int snprintf(char *str, size_t size, const char *fmt, ...)
14 __attribute__ ((format (printf, 3, 4)));
15char * znprintf(size_t size, const char *fmt, ...)
16 __attribute__ ((format (printf, 2, 3)));
17void __dprintf(const char *fmt, ...)
18 __attribute__ ((format (printf, 1, 2)));
19struct bregs;
20void __debug_enter(struct bregs *regs, const char *fname);
21void __debug_isr(const char *fname);
22void __debug_stub(struct bregs *regs, int lineno, const char *fname);
23void __warn_invalid(struct bregs *regs, int lineno, const char *fname);
24void __warn_unimplemented(struct bregs *regs, int lineno, const char *fname);
25void __warn_internalerror(int lineno, const char *fname);
26void __warn_noalloc(int lineno, const char *fname);
27void __warn_timeout(int lineno, const char *fname);
28void __set_invalid(struct bregs *regs, int lineno, const char *fname);
29void __set_unimplemented(struct bregs *regs, int lineno, const char *fname);
30void __set_code_invalid(struct bregs *regs, u32 linecode, const char *fname);
31void __set_code_unimplemented(struct bregs *regs, u32 linecode
32 , const char *fname);
33void hexdump(const void *d, int len);
34
35#define dprintf(lvl, fmt, args...) do { \
36 if (CONFIG_DEBUG_LEVEL && (lvl) <= CONFIG_DEBUG_LEVEL) \
37 __dprintf((fmt) , ##args ); \
38 } while (0)
39#define debug_enter(regs, lvl) do { \
40 if ((lvl) && (lvl) <= CONFIG_DEBUG_LEVEL) \
41 __debug_enter((regs), __func__); \
42 } while (0)
43#define debug_isr(lvl) do { \
44 if ((lvl) && (lvl) <= CONFIG_DEBUG_LEVEL) \
45 __debug_isr(__func__); \
46 } while (0)
47#define debug_stub(regs) \
48 __debug_stub((regs), __LINE__, __func__)
49#define warn_invalid(regs) \
50 __warn_invalid((regs), __LINE__, __func__)
51#define warn_unimplemented(regs) \
52 __warn_unimplemented((regs), __LINE__, __func__)
53#define warn_internalerror() \
54 __warn_internalerror(__LINE__, __func__)
55#define warn_noalloc() \
56 __warn_noalloc(__LINE__, __func__)
57#define warn_timeout() \
58 __warn_timeout(__LINE__, __func__)
59#define set_invalid(regs) \
60 __set_invalid((regs), __LINE__, __func__)
61#define set_code_invalid(regs, code) \
62 __set_code_invalid((regs), (code) | (__LINE__ << 8), __func__)
63#define set_unimplemented(regs) \
64 __set_unimplemented((regs), __LINE__, __func__)
65#define set_code_unimplemented(regs, code) \
66 __set_code_unimplemented((regs), (code) | (__LINE__ << 8), __func__)
67
68#endif // output.h