Nucleus
Barry Per-CPU Scheduler bb0cb77 (3 years, 2 months ago)
diff --git a/kernel/panic.c b/kernel/panic.c
index 2c07d24..68b68b5 100644
--- a/kernel/panic.c
+++ b/kernel/panic.c
@@ -5,6 +5,8 @@
* be compiled in.
*/
+#include <string.h>
+#include <nucleus/cpu.h>
#include <nucleus/kernel.h>
#include <io.h>
@@ -12,6 +14,15 @@
_Noreturn void
panic(char *fmt, ...)
{
+ if (!fmt)
+ goto halt;
+ Processor *proc;
+ for_each_cpu(proc) {
+ if (proc == cpu->self)
+ continue;
+ send_ipiq(proc->id, (ipiq_func_t) panic, NULL, IPIQ_ASYNC);
+ }
+
outb(0xE9, '\033');
outb(0xE9, '[');
outb(0xE9, '3');
@@ -19,6 +30,13 @@ panic(char *fmt, ...)
outb(0xE9, 'm');
char buf[1024], *p = buf;
+ memset(buf, 0, 1024);
+
+ sprintf(buf, "[CPU#%d] ", cpu->id);
+ while (*p)
+ outb(0xE9, *p++);
+ memset(buf, 0, 1024);
+ p = buf;
/* Print error to serial port */
va_list args;
@@ -29,6 +47,7 @@ panic(char *fmt, ...)
outb(0xE9, *p++);
outb(0xE9, '\n');
+halt:
/* Halt processor */
while (1) asm volatile("cli; hlt");
__builtin_unreachable();