Added kernel panic routines to output to the screen on kpanic
[tpg/acess2.git] / Kernel / arch / x86 / kpanic.c
1 /*
2  * Acess 2 Kernel
3  * By John Hodge (thePowersGang)
4  * - x86 Kernel Panic Handler
5  */
6
7 #include <acess.h>
8
9 #define FB      ((Uint16 *)(KERNEL_BASE|0xB8000))
10
11  int    giKP_Pos = 0;
12
13 /**
14  * \brief Sets the screen mode for a kernel panic
15  */
16 void KernelPanic_SetMode()
17 {
18          int    i;
19         // Restore VGA 0xB8000 text mode
20         
21         // Clear Screen
22         for( i = 0; i < 80*25; i++ )
23         {
24                 FB[i] = 0x4F00;
25         }
26 }
27
28 void KernelPanic_PutChar(char Ch)
29 {
30         if( giKP_Pos > 80*25 )  return ;
31         switch(Ch)
32         {
33         case '\t':
34                 do {
35                         FB[giKP_Pos] &= 0xFF00;
36                         FB[giKP_Pos++] |= ' ';
37                 } while(giKP_Pos & 7);
38                 break;
39         
40         case '\n':
41                 giKP_Pos += 80;
42         case '\r':
43                 giKP_Pos -= giKP_Pos % 80;
44                 break;
45         
46         default:
47                 if(' ' <= Ch && Ch < 0x7F)
48                 {
49                         FB[giKP_Pos] &= 0xFF00;
50                         FB[giKP_Pos] |= Ch;
51                 }
52                 giKP_Pos ++;
53                 break;
54         }
55 }

UCC git Repository :: git.ucc.asn.au