1
2
3
4
5
6
7
8
9
10
11#include <stdarg.h>
12
13#include <linux/kernel.h>
14#include <linux/sched.h>
15#include <linux/delay.h>
16#include <linux/smp.h>
17#include <linux/reboot.h>
18#include <linux/init.h>
19#include <linux/sysrq.h>
20
21asmlinkage void sys_sync(void);
22extern void unblank_console(void);
23extern int C_A_D;
24
25int panic_timeout = 0;
26
27__initfunc(void panic_setup(char *str, int *ints))
28{
29 if (ints[0] == 1)
30 panic_timeout = ints[1];
31}
32
33NORET_TYPE void panic(const char * fmt, ...)
34{
35 static char buf[1024];
36 va_list args;
37 int i;
38
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
46 sys_sync();
47
48 unblank_console();
49
50#ifdef __SMP__
51 smp_message_pass(MSG_ALL_BUT_SELF, MSG_STOP_CPU, 0, 0);
52#endif
53 if (panic_timeout > 0)
54 {
55
56
57
58
59 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
60 for(i = 0; i < (panic_timeout*1000); i++)
61 udelay(1000);
62
63
64
65
66
67 machine_restart(NULL);
68 }
69#ifdef __sparc__
70 printk("Press L1-A to return to the boot prom\n");
71#endif
72 sti();
73 for(;;) {
74 CHECK_EMERGENCY_SYNC
75 }
76}
77
78