linux-old/kernel/panic.c
<<
>>
Prefs
   1/*
   2 *  linux/kernel/panic.c
   3 *
   4 *  Copyright (C) 1991, 1992  Linus Torvalds
   5 */
   6
   7/*
   8 * This function is used through-out the kernel (including mm and fs)
   9 * to indicate a major problem.
  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); /* it's really int */
  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                 * Delay timeout seconds before rebooting the machine. 
  57                 * We can't use the "normal" timers since we just panicked..
  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                 *      Should we run the reboot notifier. For the moment Im
  64                 *      choosing not too. It might crash, be corrupt or do
  65                 *      more harm than good for other reasons.
  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
lxr.linux.no kindly hosted by Redpill Linpro AS, provider of Linux consulting and operations services since 1995.