misc cleanup
[rpi-open-firmware.git] / trap.c
diff --git a/trap.c b/trap.c
index 5d233df..c311008 100644 (file)
--- a/trap.c
+++ b/trap.c
@@ -1,5 +1,5 @@
 /*=============================================================================\r
-Copyright (C) 2016 Kristina Brooks\r
+Copyright (C) 2016-2017 Authors of rpi-open-firmware\r
 All rights reserved.\r
 \r
 This program is free software; you can redistribute it and/or\r
@@ -17,7 +17,7 @@ VideoCoreIV second level exception handlers.
 \r
 =============================================================================*/\r
 \r
-#include <common.h>\r
+#include <lib/runtime.h>\r
 #include <pcb.h>\r
 #include <exception.h>\r
 #include <hardware.h>\r
@@ -38,53 +38,79 @@ static const char* exception_name(uint32_t n) {
        prefix " r12: 0x%08x r13: 0x%08x r14: 0x%08x r15: 0x%08x\n" \\r
        prefix "  pc: 0x%08x  lr: 0x%08x  sr: 0x%08x\n"\r
 \r
-void sleh_fatal(vc4_saved_state_t* pcb, uint32_t n) {\r
-       printf("Fatal VPU Exception: %s\n", exception_name(n));\r
-\r
+static void print_vpu_state(vc4_saved_state_t* pcb) {\r
        printf("VPU registers:\n");\r
 \r
        printf(\r
-               REGISTER_FORMAT_STRING("   "),\r
-               pcb->r0,\r
-               pcb->r1,\r
-               pcb->r2,\r
-               pcb->r3,\r
-               pcb->r4,\r
-               pcb->r5,\r
-               pcb->r6,\r
-               pcb->r7,\r
-               pcb->r8,\r
-               pcb->r9, \r
-               pcb->r10,\r
-               pcb->r11,\r
-               pcb->r12,\r
-               pcb->r13,\r
-               pcb->r14,\r
-               pcb->r15,\r
-               pcb->pc,\r
-               pcb->lr,\r
-               pcb->sr\r
+           REGISTER_FORMAT_STRING("   "),\r
+           pcb->r0,\r
+           pcb->r1,\r
+           pcb->r2,\r
+           pcb->r3,\r
+           pcb->r4,\r
+           pcb->r5,\r
+           pcb->r6,\r
+           pcb->r7,\r
+           pcb->r8,\r
+           pcb->r9,\r
+           pcb->r10,\r
+           pcb->r11,\r
+           pcb->r12,\r
+           pcb->r13,\r
+           pcb->r14,\r
+           pcb->r15,\r
+           pcb->pc,\r
+           pcb->lr,\r
+           pcb->sr\r
+       );\r
+\r
+       printf("Exception info (IC0):\n");\r
+\r
+       printf(\r
+           "   src0: 0x%08x src1: 0x%08x vaddr: 0x%08x\n"\r
+           "      C: 0x%08x    S: 0x%08x\n",\r
+           IC0_SRC0,\r
+           IC0_SRC1,\r
+           IC0_VADDR,\r
+           IC0_C,\r
+           IC0_S\r
        );\r
 \r
-       printf("Exception info:\n");\r
+       printf("Exception info (IC1):\n");\r
 \r
        printf(\r
-               "   src0: 0x%08x src1: 0x%08x vaddr: 0x%08x\n"\r
-               "      C: 0x%08x    S: 0x%08x\n",\r
-               IC0_SRC0,\r
-               IC0_SRC1,\r
-               IC0_VADDR,\r
-               IC0_C,\r
-               IC0_S\r
+           "   src0: 0x%08x src1: 0x%08x vaddr: 0x%08x\n"\r
+           "      C: 0x%08x    S: 0x%08x\n",\r
+           IC1_SRC0,\r
+           IC1_SRC1,\r
+           IC1_VADDR,\r
+           IC1_C,\r
+           IC1_S\r
        );\r
+}\r
+\r
+void sleh_fatal(vc4_saved_state_t* pcb, uint32_t n) {\r
+       printf("Fatal VPU Exception: %s\n", exception_name(n));\r
+\r
+       print_vpu_state(pcb);\r
 \r
        printf("We are hanging here ...\n");\r
-        while(1) printf("Ahh!\n");\r
-       \r
+\r
        hang_cpu();\r
 }\r
 \r
-void sleh_irq(vc4_saved_state_t* pcb) {\r
-        while(1) printf("Interrupt!\n");\r
-       panic("interrupt at 0x%X!", pcb->pc);\r
+extern void arm_monitor_interrupt();\r
+\r
+void sleh_irq(vc4_saved_state_t* pcb, uint32_t tp) {\r
+       uint32_t status = IC0_S;\r
+       uint32_t source = status & 0xFF;\r
+\r
+       printf("VPU Received interrupt from source %d\n", source);\r
+\r
+       if (source == INTERRUPT_ARM) {\r
+               arm_monitor_interrupt();\r
+       } else {\r
+               print_vpu_state(pcb);\r
+               panic("unknown interrupt source!");\r
+       }\r
 }\r
This page took 0.028454 seconds and 4 git commands to generate.