Import 2.2.8pre2
[davej-history.git] / kernel / panic.c
bloba7dbe450341c4370541b535493d1bc53cc65abbc
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/init.h>
15 #include <linux/sysrq.h>
16 #include <linux/interrupt.h>
18 #ifdef __alpha__
19 #include <asm/machvec.h>
20 #endif
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_send_stop();
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 #ifdef __alpha__
74 if (alpha_using_srm)
75 halt();
76 #endif
77 sti();
78 for(;;) {
79 CHECK_EMERGENCY_SYNC