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

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