1
2
3
4
5
6
7
8
9
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
20asmlinkage void sys_sync(void);
21
22int panic_timeout;
23
24struct notifier_block *panic_notifier_list;
25
26static int __init panic_setup(char *str)
27{
28 panic_timeout = simple_strtoul(str, NULL, 0);
29 return 1;
30}
31
32__setup("panic=", panic_setup);
33
34
35
36
37
38
39
40
41
42
43
44NORET_TYPE void panic(const char * fmt, ...)
45{
46 static char buf[1024];
47 va_list args;
48#if defined(CONFIG_ARCH_S390)
49 unsigned long caller = (unsigned long) __builtin_return_address(0);
50#endif
51
52 bust_spinlocks(1);
53 va_start(args, fmt);
54 vsprintf(buf, fmt, args);
55 va_end(args);
56 printk(KERN_EMERG "Kernel panic: %s\n",buf);
57 if (in_interrupt())
58 printk(KERN_EMERG "In interrupt handler - not syncing\n");
59 else if (!current->pid)
60 printk(KERN_EMERG "In idle task - not syncing\n");
61 else
62 sys_sync();
63 bust_spinlocks(0);
64
65#ifdef CONFIG_SMP
66 smp_send_stop();
67#endif
68
69 notifier_call_chain(&panic_notifier_list, 0, buf);
70
71 if (panic_timeout > 0)
72 {
73
74
75
76
77 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
78 mdelay(panic_timeout*1000);
79
80
81
82
83
84 machine_restart(NULL);
85 }
86#ifdef __sparc__
87 {
88 extern int stop_a_enabled;
89
90 stop_a_enabled = 1;
91 printk(KERN_EMERG "Press L1-A to return to the boot prom\n");
92 }
93#endif
94#if defined(CONFIG_ARCH_S390)
95 disabled_wait(caller);
96#endif
97 local_irq_enable();
98 for(;;) {
99 CHECK_EMERGENCY_SYNC
100 }
101}
102
103
104
105
106
107
108
109
110
111
112
113const char *print_tainted()
114{
115 static char buf[20];
116 if (tainted) {
117 snprintf(buf, sizeof(buf), "Tainted: %c%c%c",
118 tainted & TAINT_PROPRIETORY_MODULE ? 'P' : 'G',
119 tainted & TAINT_FORCED_MODULE ? 'F' : ' ',
120 tainted & TAINT_UNSAFE_SMP ? 'S' : ' ');
121 }
122 else
123 snprintf(buf, sizeof(buf), "Not tainted");
124 return(buf);
125}
126
127int tainted = 0;
128