Halt-And-Catch-Fire macro

This commit is contained in:
2018-03-06 10:59:23 +01:00
parent 2da088f031
commit 9e2483d78e
3 changed files with 34 additions and 0 deletions

View File

@@ -22,3 +22,17 @@ void debug_printf(char *fmt, ...);
void debug_puts(char *s);
void debug_putsn(char *s, size_t n);
void debug_putch(char c);
#define S(x) #x
#define S_(x) S(x)
#define S__LINE__ S_(__LINE__)
#define PANIC(...) \
do{ \
debug("\n\nKernel panic!\n%s:%d\n", __FILE__, __LINE__); \
debug(__VA_ARGS__); \
volatile int _override = 0; \
while(1){ \
asm("panic_breakpoint_" S__LINE__ ":"); \
if(_override) break; \
} \
}while(0)