Import 2.3.30pre1
[davej-history.git] / kernel / panic.c
blob48168d8646b8da8c029697da60395020aea5a92d
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 <linux/sched.h>
12 #include <linux/delay.h>
13 #include <linux/reboot.h>
14 #include <linux/notifier.h>
15 #include <linux/init.h>
16 #include <linux/sysrq.h>
17 #include <linux/interrupt.h>
19 #ifdef __alpha__
20 #include <asm/machvec.h>
21 #endif
23 asmlinkage void sys_sync(void); /* it's really int */
24 extern void unblank_console(void);
25 extern int C_A_D;
27 int panic_timeout = 0;
29 struct notifier_block *panic_notifier_list = NULL;
31 static int __init panic_setup(char *str)
33 panic_timeout = simple_strtoul(str, NULL, 0);
34 return 1;
37 __setup("panic=", panic_setup);
39 NORET_TYPE void panic(const char * fmt, ...)
41 static char buf[1024];
42 va_list args;
44 va_start(args, fmt);
45 vsprintf(buf, fmt, args);
46 va_end(args);
47 printk(KERN_EMERG "Kernel panic: %s\n",buf);
48 if (current == init_tasks[0])
49 printk(KERN_EMERG "In swapper task - not syncing\n");
50 else if (in_interrupt())
51 printk(KERN_EMERG "In interrupt handler - not syncing\n");
52 else
53 sys_sync();
55 unblank_console();
57 #ifdef __SMP__
58 smp_send_stop();
59 #endif
61 notifier_call_chain(&panic_notifier_list, 0, NULL);
63 if (panic_timeout > 0)
66 * Delay timeout seconds before rebooting the machine.
67 * We can't use the "normal" timers since we just panicked..
69 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
70 mdelay(panic_timeout*1000);
72 * Should we run the reboot notifier. For the moment Im
73 * choosing not too. It might crash, be corrupt or do
74 * more harm than good for other reasons.
76 machine_restart(NULL);
78 #ifdef __sparc__
79 printk("Press L1-A to return to the boot prom\n");
80 #endif
81 #ifdef __alpha__
82 if (alpha_using_srm)
83 halt();
84 #endif
85 sti();
86 for(;;) {
87 CHECK_EMERGENCY_SYNC