4 * Copyright (C) 1991, 1992 Linus Torvalds
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/notifier.h>
15 #include <linux/init.h>
16 #include <linux/sysrq.h>
17 #include <linux/interrupt.h>
20 #include <asm/machvec.h>
23 asmlinkage
void sys_sync(void); /* it's really int */
24 extern void unblank_console(void);
27 int panic_timeout
= 0;
29 struct notifier_block
*panic_notifier_list
= NULL
;
31 static int __init
panic_setup(char *str
)
33 panic_timeout
= simple_strtoul(str
, NULL
, 0);
37 __setup("panic=", panic_setup
);
39 NORET_TYPE
void panic(const char * fmt
, ...)
41 static char buf
[1024];
45 vsprintf(buf
, fmt
, args
);
47 printk(KERN_EMERG
"Kernel panic: %s\n",buf
);
48 if (current
== init_tasks
[0])
49 printk(KERN_EMERG
"In swapper task - not syncing\n");
50 else if (in_interrupt())
51 printk(KERN_EMERG
"In interrupt handler - not syncing\n");
61 notifier_call_chain(&panic_notifier_list
, 0, NULL
);
63 if (panic_timeout
> 0)
66 * Delay timeout seconds before rebooting the machine.
67 * We can't use the "normal" timers since we just panicked..
69 printk(KERN_EMERG
"Rebooting in %d seconds..",panic_timeout
);
70 mdelay(panic_timeout
*1000);
72 * Should we run the reboot notifier. For the moment Im
73 * choosing not too. It might crash, be corrupt or do
74 * more harm than good for other reasons.
76 machine_restart(NULL
);
79 printk("Press L1-A to return to the boot prom\n");