1 /*
2 * linux/kernel/panic.c
3 *
4 * Copyright (C) 1991, 1992 Linus Torvalds
5 */
6
7 /*
8 * This function is used through-out the kernel (including mm and fs)
9 * to indicate a major problem.
10 */
11 #include <linux/config.h>
12 #include <linux/sched.h>
13 #include <linux/delay.h>
14 #include <linux/reboot.h>
15 #include <linux/notifier.h>
16 #include <linux/init.h>
17 #include <linux/sysrq.h>
18 #include <linux/interrupt.h>
19
20 asmlinkage void sys_sync(void); /* it's really int */
21 extern void unblank_console(void);
22
23 int panic_timeout;
24
25 struct notifier_block *panic_notifier_list;
26
27 static int __init panic_setup(char *str)
28 {
29 panic_timeout = simple_strtoul(str, NULL, 0);
30 return 1;
31 }
32
33 __setup("panic=", panic_setup);
34
35 /**
36 * panic - halt the system
37 * @fmt: The text string to print
38 *
39 * Display a message, then unblank the console and perform
40 * cleanups. Functions in the panic notifier list are called
41 * after the filesystem cache is flushed (when possible).
42 *
43 * This function never returns.
44 */
45
46 NORET_TYPE void panic(const char * fmt, ...)
47 {
48 static char buf[1024];
49 va_list args;
50 #if defined(CONFIG_ARCH_S390)
51 unsigned long caller = (unsigned long) __builtin_return_address(0);
52 #endif
53
54 va_start(args, fmt);
55 vsprintf(buf, fmt, args);
56 va_end(args);
57 printk(KERN_EMERG "Kernel panic: %s\n",buf);
58 if (in_interrupt())
59 printk(KERN_EMERG "In interrupt handler - not syncing\n");
60 else if (!current->pid)
61 printk(KERN_EMERG "In idle task - not syncing\n");
62 else
63 sys_sync();
64
65 unblank_console();
66
67 #ifdef CONFIG_SMP
68 smp_send_stop();
69 #endif
70
71 notifier_call_chain(&panic_notifier_list, 0, NULL);
72
73 if (panic_timeout > 0)
74 {
75 /*
76 * Delay timeout seconds before rebooting the machine.
77 * We can't use the "normal" timers since we just panicked..
78 */
79 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
80 mdelay(panic_timeout*1000);
81 /*
82 * Should we run the reboot notifier. For the moment Im
83 * choosing not too. It might crash, be corrupt or do
84 * more harm than good for other reasons.
85 */
86 machine_restart(NULL);
87 }
88 #ifdef __sparc__
89 {
90 extern int stop_a_enabled;
91 /* Make sure the user can actually press L1-A */
92 stop_a_enabled = 1;
93 printk("Press L1-A to return to the boot prom\n");
94 }
95 #endif
96 #if defined(CONFIG_ARCH_S390)
97 disabled_wait(caller);
98 #endif
99 sti();
100 for(;;) {
101 CHECK_EMERGENCY_SYNC
102 }
103 }
104
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more
information.