root/kernel/panic.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. panic_setup
  2. panic
  3. bad_user_access_length

   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 
  17 asmlinkage void sys_sync(void); /* it's really int */
  18 extern void hard_reset_now(void);
  19 extern void do_unblank_screen(void);
  20 extern int C_A_D;
  21 
  22 int panic_timeout = 0;
  23 
  24 void panic_setup(char *str, int *ints)
     /* [previous][next][first][last][top][bottom][index][help] */
  25 {
  26         if (ints[0] == 1)
  27                 panic_timeout = ints[1];
  28 }
  29 
  30 NORET_TYPE void panic(const char * fmt, ...)
     /* [previous][next][first][last][top][bottom][index][help] */
  31 {
  32         static char buf[1024];
  33         va_list args;
  34         int i;
  35 
  36         va_start(args, fmt);
  37         vsprintf(buf, fmt, args);
  38         va_end(args);
  39         printk(KERN_EMERG "Kernel panic: %s\n",buf);
  40         if (current == task[0])
  41                 printk(KERN_EMERG "In swapper task - not syncing\n");
  42         else
  43                 sys_sync();
  44 
  45         do_unblank_screen();
  46 
  47         if (panic_timeout > 0)
  48         {
  49                 /*
  50                  * Delay timeout seconds before rebooting the machine. 
  51                  * We can't use the "normal" timers since we just panicked..
  52                  */
  53                 printk(KERN_EMERG "Rebooting in %d seconds..",panic_timeout);
  54                 for(i = 0; i < (panic_timeout*1000); i++)
  55                         udelay(1000);
  56                 hard_reset_now();
  57         }
  58         for(;;);
  59 }
  60 
  61 /*
  62  * GCC 2.5.8 doesn't always optimize correctly; see include/asm/segment.h
  63  */
  64 
  65 int bad_user_access_length(void)
     /* [previous][next][first][last][top][bottom][index][help] */
  66 {
  67         panic("bad_user_access_length executed (not cool, dude)");
  68 }

/* [previous][next][first][last][top][bottom][index][help] */