ohci0 interrupt will be thrown - hooray++ \o/
[ppcskel.git] / exception.c
1 /*
2         BootMii - a Free Software replacement for the Nintendo/BroadOn bootloader.
3         Requires mini.
4
5 Copyright (C) 2008              Segher Boessenkool <segher@kernel.crashing.org>
6
7 # This code is licensed to you under the terms of the GNU GPL, version 2;
8 # see file COPYING or http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
9 */
10
11 #include "bootmii_ppc.h"
12
13 #include "string.h"
14
15 extern char exception_2200_start, exception_2200_end;
16
17 void exception_handler(int exception)
18 {
19         u32 *x;
20         u32 i;
21
22         printf("\nException %04x occurred!\n", exception);
23
24         x = (u32 *)0x80002000;
25
26         printf("\n R0..R7    R8..R15  R16..R23  R24..R31\n");
27         for (i = 0; i < 8; i++) {
28                 printf("%08x  %08x  %08x  %08x\n", x[0], x[8], x[16], x[24]);
29                 x++;
30         }
31         x = (u32 *)0x80002080;
32
33         printf("\n CR/XER    LR/CTR  SRR0/SRR1 DAR/DSISR\n");
34         for (i = 0; i < 2; i++) {
35                 printf("%08x  %08x  %08x  %08x\n", x[0], x[2], x[4], x[6]);
36                 x++;
37         }
38
39         // Hang.
40         for (;;)
41                 ;
42 }
43
44 void exception_init(void)
45 {
46         u32 vector;
47         u32 len_2200;
48
49         for (vector = 0x100; vector < 0x2000; vector += 0x10) {
50                 u32 *insn = (u32 *)(0x80000000 + vector);
51
52                 insn[0] = 0xbc002000;                   // stmw 0,0x2000(0)
53                 insn[1] = 0x38600000 | (u32)vector;     // li 3,vector
54                 insn[2] = 0x48002202;                   // ba 0x2200
55                 insn[3] = 0;
56         }
57         sync_before_exec((void *)0x80000100, 0x1f00);
58
59         len_2200 = &exception_2200_end - &exception_2200_start;
60         memcpy((void *)0x80002200, &exception_2200_start, len_2200);
61         sync_before_exec((void *)0x80002200, len_2200);
62 }
63