| 1 | #include <console/crash.h> |
| 2 | #include <console/panic.h> |
| 3 | #include <console/printf.h> |
| 4 | #include <console/report.h> |
| 5 | #include <dbg.h> |
| 6 | #include <stdarg.h> |
| 7 | #include <string.h> |
| 8 | #include <sync/raw_spinlock.h> |
| 9 | |
| 10 | static char msg[REPORT_LINE_MAX]; |
| 11 | static struct raw_spinlock panic_msg_lock = RAW_SPINLOCK_INIT; |
| 12 | __noreturn void panic_impl_default(struct crash_payload pluh, const char *file, |
| 13 | int line, const char *func, const char *fmt, |
| 14 | ...) { |
| 15 | unused(pluh); |
| 16 | raw_spin_lock(lock: &panic_msg_lock); |
| 17 | va_list args; |
| 18 | va_start(args, fmt); |
| 19 | vsnprintf(buffer: msg, buffer_len: (int) sizeof(msg), format: fmt, args); |
| 20 | va_end(args); |
| 21 | |
| 22 | crash_full(ctx: &(struct crash_context){ |
| 23 | .payload = pluh, |
| 24 | .source = CRASH_SOURCE_PANIC, |
| 25 | .formats = CRASH_FMT_DEFAULT, |
| 26 | .file = file, |
| 27 | .line = line, |
| 28 | .func = func, |
| 29 | .msg = msg, |
| 30 | .regs = NULL, |
| 31 | }); |
| 32 | } |
| 33 | |