use tabs, or at least tabwidth of 4, but preferably tabs
[rpi-open-firmware.git] / trap.c
1 /*=============================================================================
2 Copyright (C) 2016 Kristina Brooks
3 All rights reserved.
4
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public License
7 as published by the Free Software Foundation; either version 2
8 of the License, or (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 FILE DESCRIPTION
16 VideoCoreIV second level exception handlers.
17
18 =============================================================================*/
19
20 #include <common.h>
21 #include <pcb.h>
22 #include <exception.h>
23 #include <hardware.h>
24 #include <cpu.h>
25
26 static const char* g_ExceptionNames[] = { VC4_EXC_NAMES };
27
28 static const char* exception_name(uint32_t n) {
29 if (n >= (sizeof(g_ExceptionNames)/4))
30 return "unknown";
31 return g_ExceptionNames[n];
32 }
33
34 #define REGISTER_FORMAT_STRING(prefix) \
35 prefix " r0: 0x%08x r1: 0x%08x r2: 0x%08x r3: 0x%08x\n" \
36 prefix " r4: 0x%08x r5: 0x%08x r6: 0x%08x r7: 0x%08x\n" \
37 prefix " r8: 0x%08x r9: 0x%08x r10: 0x%08x r11: 0x%08x\n" \
38 prefix " r12: 0x%08x r13: 0x%08x r14: 0x%08x r15: 0x%08x\n" \
39 prefix " pc: 0x%08x lr: 0x%08x sr: 0x%08x\n"
40
41 void sleh_fatal(vc4_saved_state_t* pcb, uint32_t n) {
42 printf("Fatal VPU Exception: %s\n", exception_name(n));
43
44 printf("VPU registers:\n");
45
46 printf(
47 REGISTER_FORMAT_STRING(" "),
48 pcb->r0,
49 pcb->r1,
50 pcb->r2,
51 pcb->r3,
52 pcb->r4,
53 pcb->r5,
54 pcb->r6,
55 pcb->r7,
56 pcb->r8,
57 pcb->r9,
58 pcb->r10,
59 pcb->r11,
60 pcb->r12,
61 pcb->r13,
62 pcb->r14,
63 pcb->r15,
64 pcb->pc,
65 pcb->lr,
66 pcb->sr
67 );
68
69 printf("Exception info:\n");
70
71 printf(
72 " src0: 0x%08x src1: 0x%08x vaddr: 0x%08x\n"
73 " C: 0x%08x S: 0x%08x\n",
74 IC0_SRC0,
75 IC0_SRC1,
76 IC0_VADDR,
77 IC0_C,
78 IC0_S
79 );
80
81 printf("We are hanging here ...\n");
82 while(1) printf("Ahh!\n");
83
84 hang_cpu();
85 }
86
87 void sleh_irq(vc4_saved_state_t* pcb) {
88 while(1) printf("Interrupt!\n");
89 panic("interrupt at 0x%X!", pcb->pc);
90 }
This page took 0.079165 seconds and 4 git commands to generate.