kernel/sys/panic.c

35 lines
787 B
C
Raw Normal View History

2020-01-27 21:42:49 +02:00
#if defined(AMD64_SMP)
2020-02-04 12:45:15 +02:00
#include "arch/amd64/smp/ipi.h"
#include "arch/amd64/smp/smp.h"
#include "arch/amd64/cpu.h"
#endif
2019-10-12 13:40:48 +03:00
#include "sys/panic.h"
#include "sys/debug.h"
void panicf(const char *fmt, ...) {
asm volatile ("cli");
va_list args;
kfatal("--- Panic ---\n");
va_start(args, fmt);
2020-01-14 11:32:06 +02:00
debugs(DEBUG_FATAL, "\033[41m");
2019-10-12 13:40:48 +03:00
debugfv(DEBUG_FATAL, fmt, args);
2020-01-14 11:32:06 +02:00
debugs(DEBUG_FATAL, "\033[0m");
2019-10-12 13:40:48 +03:00
va_end(args);
kfatal("--- Panic ---\n");
2020-01-27 21:42:49 +02:00
#if defined(AMD64_SMP)
// Send PANIC IPIs to all other CPUs
size_t cpu = get_cpu()->processor_id;
kfatal("cpu%u initiates panic sequence\n", cpu);
for (size_t i = 0; i < smp_ncpus; ++i) {
if (i != cpu) {
amd64_ipi_send(i, IPI_VECTOR_PANIC);
}
}
#endif
2019-10-12 13:40:48 +03:00
panic_hlt();
}