[PATCH] Fix up 'linux-dvb' maintainers entry
[linux-2.6/history.git] / kernel / panic.c
blobf5863a571e9b722fd80d9d0253d62c77cbac9987
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/config.h>
12 #include <linux/module.h>
13 #include <linux/sched.h>
14 #include <linux/delay.h>
15 #include <linux/reboot.h>
16 #include <linux/notifier.h>
17 #include <linux/init.h>
18 #include <linux/sysrq.h>
19 #include <linux/interrupt.h>
20 #include <linux/nmi.h>
22 asmlinkage void sys_sync(void); /* it's really int */
24 int panic_timeout;
25 int panic_on_oops;
26 int tainted;
28 EXPORT_SYMBOL(panic_timeout);
30 struct notifier_block *panic_notifier_list;
32 EXPORT_SYMBOL(panic_notifier_list);
34 static int __init panic_setup(char *str)
36 panic_timeout = simple_strtoul(str, NULL, 0);
37 return 1;
39 __setup("panic=", panic_setup);
41 /**
42 * panic - halt the system
43 * @fmt: The text string to print
45 * Display a message, then perform cleanups. Functions in the panic
46 * notifier list are called after the filesystem cache is flushed (when possible).
48 * This function never returns.
51 NORET_TYPE void panic(const char * fmt, ...)
53 static char buf[1024];
54 va_list args;
55 #if defined(CONFIG_ARCH_S390)
56 unsigned long caller = (unsigned long) __builtin_return_address(0);
57 #endif
59 bust_spinlocks(1);
60 va_start(args, fmt);
61 vsnprintf(buf, sizeof(buf), fmt, args);
62 va_end(args);
63 printk(KERN_EMERG "Kernel panic: %s\n",buf);
64 if (in_interrupt())
65 printk(KERN_EMERG "In interrupt handler - not syncing\n");
66 else if (!current->pid)
67 printk(KERN_EMERG "In idle task - not syncing\n");
68 else
69 sys_sync();
70 bust_spinlocks(0);
72 #ifdef CONFIG_SMP
73 smp_send_stop();
74 #endif
76 notifier_call_chain(&panic_notifier_list, 0, buf);
78 if (panic_timeout > 0)
80 int i;
82 * Delay timeout seconds before rebooting the machine.
83 * We can't use the "normal" timers since we just panicked..
85 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
86 for (i = 0; i < panic_timeout; i++) {
87 touch_nmi_watchdog();
88 mdelay(1000);
91 * Should we run the reboot notifier. For the moment Im
92 * choosing not too. It might crash, be corrupt or do
93 * more harm than good for other reasons.
95 machine_restart(NULL);
97 #ifdef __sparc__
99 extern int stop_a_enabled;
100 /* Make sure the user can actually press L1-A */
101 stop_a_enabled = 1;
102 printk(KERN_EMERG "Press L1-A to return to the boot prom\n");
104 #endif
105 #if defined(CONFIG_ARCH_S390)
106 disabled_wait(caller);
107 #endif
108 local_irq_enable();
109 for (;;)
113 EXPORT_SYMBOL(panic);
116 * print_tainted - return a string to represent the kernel taint state.
118 * 'P' - Proprietary module has been loaded.
119 * 'F' - Module has been forcibly loaded.
120 * 'S' - SMP with CPUs not designed for SMP.
122 * The string is overwritten by the next call to print_taint().
125 const char *print_tainted(void)
127 static char buf[20];
128 if (tainted) {
129 snprintf(buf, sizeof(buf), "Tainted: %c%c%c",
130 tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G',
131 tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
132 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ');
134 else
135 snprintf(buf, sizeof(buf), "Not tainted");
136 return(buf);