Import 2.1.118
[davej-history.git] / kernel / panic.c
bloba102a9598f664414c90c458e3c88564f4ba9851f
1 /*
2 * linux/kernel/panic.c
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
7 /*
8 * This function is used through-out the kernel (including mm and fs)
9 * to indicate a major problem.
11 #include <stdarg.h>
13 #include <linux/kernel.h>
14 #include <linux/sched.h>
15 #include <linux/delay.h>
16 #include <linux/smp.h>
17 #include <linux/reboot.h>
18 #include <linux/init.h>
19 #include <linux/sysrq.h>
20 #include <linux/interrupt.h>
22 asmlinkage void sys_sync(void); /* it's really int */
23 extern void unblank_console(void);
24 extern int C_A_D;
26 int panic_timeout = 0;
28 void __init panic_setup(char *str, int *ints)
30 if (ints[0] == 1)
31 panic_timeout = ints[1];
34 NORET_TYPE void panic(const char * fmt, ...)
36 static char buf[1024];
37 va_list args;
39 va_start(args, fmt);
40 vsprintf(buf, fmt, args);
41 va_end(args);
42 printk(KERN_EMERG "Kernel panic: %s\n",buf);
43 if (current == task[0])
44 printk(KERN_EMERG "In swapper task - not syncing\n");
45 else if (in_interrupt())
46 printk(KERN_EMERG "In interrupt handler - not syncing\n");
47 else
48 sys_sync();
50 unblank_console();
52 #ifdef __SMP__
53 smp_message_pass(MSG_ALL_BUT_SELF, MSG_STOP_CPU, 0, 0);
54 #endif
55 if (panic_timeout > 0)
58 * Delay timeout seconds before rebooting the machine.
59 * We can't use the "normal" timers since we just panicked..
61 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
62 mdelay(panic_timeout*1000);
64 * Should we run the reboot notifier. For the moment Im
65 * choosing not too. It might crash, be corrupt or do
66 * more harm than good for other reasons.
68 machine_restart(NULL);
70 #ifdef __sparc__
71 printk("Press L1-A to return to the boot prom\n");
72 #endif
73 sti();
74 for(;;) {
75 CHECK_EMERGENCY_SYNC