Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 1 | #ifndef __OUTPUT_H |
| 2 | #define __OUTPUT_H |
| 3 | |
Kevin O'Connor | 71036f8 | 2014-04-07 20:36:02 -0400 | [diff] [blame] | 4 | #include "config.h" // CONFIG_DEBUG_LEVEL |
Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 5 | #include "types.h" // u32 |
| 6 | |
| 7 | // output.c |
Kevin O'Connor | bb1fcb4 | 2014-01-15 13:52:14 -0500 | [diff] [blame] | 8 | void debug_banner(void); |
Kevin O'Connor | 2d2fa31 | 2013-09-14 21:55:26 -0400 | [diff] [blame] | 9 | void panic(const char *fmt, ...) |
| 10 | __attribute__ ((format (printf, 1, 2))) __noreturn; |
| 11 | void printf(const char *fmt, ...) |
| 12 | __attribute__ ((format (printf, 1, 2))); |
| 13 | int snprintf(char *str, size_t size, const char *fmt, ...) |
| 14 | __attribute__ ((format (printf, 3, 4))); |
| 15 | char * znprintf(size_t size, const char *fmt, ...) |
| 16 | __attribute__ ((format (printf, 2, 3))); |
| 17 | void __dprintf(const char *fmt, ...) |
| 18 | __attribute__ ((format (printf, 1, 2))); |
| 19 | struct bregs; |
| 20 | void __debug_enter(struct bregs *regs, const char *fname); |
| 21 | void __debug_isr(const char *fname); |
| 22 | void __debug_stub(struct bregs *regs, int lineno, const char *fname); |
| 23 | void __warn_invalid(struct bregs *regs, int lineno, const char *fname); |
| 24 | void __warn_unimplemented(struct bregs *regs, int lineno, const char *fname); |
| 25 | void __warn_internalerror(int lineno, const char *fname); |
| 26 | void __warn_noalloc(int lineno, const char *fname); |
| 27 | void __warn_timeout(int lineno, const char *fname); |
| 28 | void __set_invalid(struct bregs *regs, int lineno, const char *fname); |
| 29 | void __set_unimplemented(struct bregs *regs, int lineno, const char *fname); |
| 30 | void __set_code_invalid(struct bregs *regs, u32 linecode, const char *fname); |
| 31 | void __set_code_unimplemented(struct bregs *regs, u32 linecode |
| 32 | , const char *fname); |
| 33 | void 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 |