direct-io.hg

view xenolinux-2.4.21-pre4-sparse/kernel/panic.c @ 286:ced52ac28d16

bitkeeper revision 1.122.2.1 (3e6f4ea8S_O9ScUz62sSCLP3_id_AQ)

acknowledge interupt...
author iap10@labyrinth.cl.cam.ac.uk
date Wed Mar 12 15:13:44 2003 +0000 (2003-03-12)
parents d7d0a23b2e07
children
line source
1 /*
2 * linux/kernel/panic.c
3 *
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.
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>
20 asmlinkage void sys_sync(void); /* it's really int */
22 int panic_timeout;
24 struct notifier_block *panic_notifier_list;
26 static int __init panic_setup(char *str)
27 {
28 panic_timeout = simple_strtoul(str, NULL, 0);
29 return 1;
30 }
32 __setup("panic=", panic_setup);
34 /**
35 * panic - halt the system
36 * @fmt: The text string to print
37 *
38 * Display a message, then perform cleanups. Functions in the panic
39 * notifier list are called after the filesystem cache is flushed (when possible).
40 *
41 * This function never returns.
42 */
44 NORET_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
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);
65 #ifdef CONFIG_SMP
66 smp_send_stop();
67 #endif
69 notifier_call_chain(&panic_notifier_list, 0, NULL);
71 if (panic_timeout > 0)
72 {
73 /*
74 * Delay timeout seconds before rebooting the machine.
75 * We can't use the "normal" timers since we just panicked..
76 */
77 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
78 mdelay(panic_timeout*1000);
79 /*
80 * Should we run the reboot notifier. For the moment Im
81 * choosing not too. It might crash, be corrupt or do
82 * more harm than good for other reasons.
83 */
84 machine_restart(NULL);
85 }
86 #ifdef __sparc__
87 {
88 extern int stop_a_enabled;
89 /* Make sure the user can actually press L1-A */
90 stop_a_enabled = 1;
91 printk("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 sti();
98 for(;;) {
99 #if defined(CONFIG_X86) && defined(CONFIG_VT)
100 extern void panic_blink(void);
101 panic_blink();
102 #endif
103 CHECK_EMERGENCY_SYNC
104 #if defined(CONFIG_XENO)
105 HYPERVISOR_exit();
106 #endif
107 }
108 }
110 /**
111 * print_tainted - return a string to represent the kernel taint state.
112 *
113 * The string is overwritten by the next call to print_taint().
114 */
116 const char *print_tainted()
117 {
118 static char buf[20];
119 if (tainted) {
120 snprintf(buf, sizeof(buf), "Tainted: %c%c",
121 tainted & 1 ? 'P' : 'G',
122 tainted & 2 ? 'F' : ' ');
123 }
124 else
125 snprintf(buf, sizeof(buf), "Not tainted");
126 return(buf);
127 }
129 int tainted = 0;
131 /*
132 * A BUG() call in an inline function in a header should be avoided,
133 * because it can seriously bloat the kernel. So here we have
134 * helper functions.
135 * We lose the BUG()-time file-and-line info this way, but it's
136 * usually not very useful from an inline anyway. The backtrace
137 * tells us what we want to know.
138 */
140 void __out_of_line_bug(int line)
141 {
142 printk("kernel BUG in header file at line %d\n", line);
144 BUG();
146 /* Satisfy __attribute__((noreturn)) */
147 for ( ; ; )
148 ;
149 }