fix indentation some more
[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 static void print_vpu_state(vc4_saved_state_t* pcb) {
42 printf("VPU registers:\n");
43
44 printf(
45 REGISTER_FORMAT_STRING(" "),
46 pcb->r0,
47 pcb->r1,
48 pcb->r2,
49 pcb->r3,
50 pcb->r4,
51 pcb->r5,
52 pcb->r6,
53 pcb->r7,
54 pcb->r8,
55 pcb->r9,
56 pcb->r10,
57 pcb->r11,
58 pcb->r12,
59 pcb->r13,
60 pcb->r14,
61 pcb->r15,
62 pcb->pc,
63 pcb->lr,
64 pcb->sr
65 );
66
67 printf("Exception info (IC0):\n");
68
69 printf(
70 " src0: 0x%08x src1: 0x%08x vaddr: 0x%08x\n"
71 " C: 0x%08x S: 0x%08x\n",
72 IC0_SRC0,
73 IC0_SRC1,
74 IC0_VADDR,
75 IC0_C,
76 IC0_S
77 );
78
79 printf("Exception info (IC1):\n");
80
81 printf(
82 " src0: 0x%08x src1: 0x%08x vaddr: 0x%08x\n"
83 " C: 0x%08x S: 0x%08x\n",
84 IC1_SRC0,
85 IC1_SRC1,
86 IC1_VADDR,
87 IC1_C,
88 IC1_S
89 );
90 }
91
92 void sleh_fatal(vc4_saved_state_t* pcb, uint32_t n) {
93 printf("Fatal VPU Exception: %s\n", exception_name(n));
94
95 print_vpu_state(pcb);
96
97 printf("We are hanging here ...\n");
98
99 hang_cpu();
100 }
101
102 extern void arm_monitor_interrupt();
103
104 void sleh_irq(vc4_saved_state_t* pcb, uint32_t tp) {
105 uint32_t status = IC0_S;
106 uint32_t source = status & 0xFF;
107
108 printf("VPU Received interrupt from source %d\n", source);
109
110 if (source == INTERRUPT_ARM) {
111 arm_monitor_interrupt();
112 }
113 else {
114 print_vpu_state(pcb);
115 panic("unknown interrupt source!");
116 }
117 }
This page took 0.074969 seconds and 4 git commands to generate.