port-work; won't compile or even work
[ppcskel.git] / exception.c
index 095de44507780d28a82b3aed68c741d17f825036..f42b78be2da341bf1f7eeef5aa477967bc82394b 100644 (file)
@@ -3,6 +3,8 @@
        Requires mini.
 
 Copyright (C) 2008             Segher Boessenkool <segher@kernel.crashing.org>
+Copyright (C) 2009             Bernhard Urban <lewurm@gmx.net>
+Copyright (C) 2009             Sebastian Falbesoner <sebastian.falbesoner@gmail.com>
 
 # This code is licensed to you under the terms of the GNU GPL, version 2;
 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
@@ -11,34 +13,51 @@ Copyright (C) 2008          Segher Boessenkool <segher@kernel.crashing.org>
 #include "bootmii_ppc.h"
 
 #include "string.h"
+#include "irq.h"
+#include "hollywood.h"
 
 extern char exception_2200_start, exception_2200_end;
 
 void exception_handler(int exception)
 {
-       u32 *x;
-       u32 i;
+       u32 cookie = irq_kill();
+       // check if the exception was actually an external interrupt
+       if (exception == 0x500) {
+               irq_handler();
+       }
 
-       printf("\nException %04x occurred!\n", exception);
+       // check if exception happened due to the decrementer
+       else if (exception == 0x900) {
+               //printf("\nDecrementer exception occured - who cares?\n");
+       }
 
-       x = (u32 *)0x80002000;
+       else {
+               u32 *x;
+               u32 i;
 
-       printf("\n R0..R7    R8..R15  R16..R23  R24..R31\n");
-       for (i = 0; i < 8; i++) {
-               printf("%08x  %08x  %08x  %08x\n", x[0], x[8], x[16], x[24]);
-               x++;
-       }
-       x = (u32 *)0x80002080;
+               printf("\nException %04X occurred!\n", exception);
+
+               x = (u32 *)0x80002000;
+
+               printf("\n R0..R7    R8..R15  R16..R23  R24..R31\n");
+               for (i = 0; i < 8; i++) {
+                       printf("%08x  %08x  %08x  %08x\n", x[0], x[8], x[16], x[24]);
+                       x++;
+               }
+               x = (u32 *)0x80002080;
+
+               printf("\n CR/XER    LR/CTR  SRR0/SRR1 DAR/DSISR\n");
+               for (i = 0; i < 2; i++) {
+                       printf("%08x  %08x  %08x  %08x\n", x[0], x[2], x[4], x[6]);
+                       x++;
+               }
 
-       printf("\n CR/XER    LR/CTR  SRR0/SRR1 DAR/DSISR\n");
-       for (i = 0; i < 2; i++) {
-               printf("%08x  %08x  %08x  %08x\n", x[0], x[2], x[4], x[6]);
-               x++;
+               // Hang.
+               for (;;)
+                       ;
        }
 
-       // Hang.
-       for (;;)
-               ;
+       irq_restore(cookie);
 }
 
 void exception_init(void)