blob: c50c603767e63980e4a74ef45374fc53afef11c5 [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001/*
2 * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch_helpers.h>
8#include <bl_common.h>
9#include <debug.h>
10#include <gicv2.h>
11#include <mmio.h>
12#include <runtime_svc.h>
13#include "rcar_def.h"
14
15#define SWDT_ERROR_ID (1024U)
16#define SWDT_ERROR_TYPE (16U)
17#define SWDT_CHAR_MAX (13U)
18
19extern void rcar_swdt_release(void);
20
21void bl2_interrupt_error_id(uint32_t int_id)
22{
23 ERROR("\n");
24 if (int_id >= SWDT_ERROR_ID) {
25 ERROR("Unhandled exception occurred.\n");
26 ERROR(" Exception type = FIQ_SP_ELX\n");
27 panic();
28 }
29
30 /* Clear the interrupt request */
31 gicv2_end_of_interrupt((uint32_t) int_id);
32 rcar_swdt_release();
33 ERROR("Unhandled exception occurred.\n");
34 ERROR(" Exception type = FIQ_SP_ELX\n");
35 ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
36 ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
37 ERROR(" ESR_EL1 = 0x%x\n", (uint32_t) read_esr_el1());
38 ERROR(" FAR_EL1 = 0x%x\n", (uint32_t) read_far_el1());
39 ERROR("\n");
40 panic();
41}
42
43void bl2_interrupt_error_type(uint32_t ex_type)
44{
45 const uint8_t interrupt_ex[SWDT_ERROR_TYPE][SWDT_CHAR_MAX] = {
46 "SYNC SP EL0",
47 "IRQ SP EL0",
48 "FIQ SP EL0",
49 "SERR SP EL0",
50 "SYNC SP ELx",
51 "IRQ SP ELx",
52 "FIQ SP ELx",
53 "SERR SP ELx",
54 "SYNC AARCH64",
55 "IRQ AARCH64",
56 "FIQ AARCH64",
57 "SERR AARCH64",
58 "SYNC AARCH32",
59 "IRQ AARCH32",
60 "FIQ AARCH32",
61 "SERR AARCH32"
62 };
63 char msg[128];
64
65 /* Clear the interrupt request */
66 if (ex_type >= SWDT_ERROR_TYPE) {
67 ERROR("\n");
68 ERROR("Unhandled exception occurred.\n");
69 ERROR(" Exception type = Unknown (%d)\n", ex_type);
70 goto loop;
71 }
72
73 rcar_swdt_release();
74 ERROR("\n");
75 ERROR("Unhandled exception occurred.\n");
76 snprintf(msg, sizeof(msg), " Exception type = %s\n",
77 &interrupt_ex[ex_type][0]);
78 ERROR("%s", msg);
79 switch (ex_type) {
80 case SYNC_EXCEPTION_SP_ELX:
81 ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
82 ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
83 ERROR(" ESR_EL1 = 0x%x\n", (uint32_t) read_esr_el1());
84 ERROR(" FAR_EL1 = 0x%x\n", (uint32_t) read_far_el1());
85 break;
86 case IRQ_SP_ELX:
87 ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
88 ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
89 ERROR(" IAR_EL1 = 0x%x\n", gicv2_acknowledge_interrupt());
90 break;
91 case FIQ_SP_ELX:
92 ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
93 ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
94 ERROR(" IAR_EL1 = 0x%x\n", gicv2_acknowledge_interrupt());
95 break;
96 case SERROR_SP_ELX:
97 ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
98 ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
99 ERROR(" ESR_EL1 = 0x%x\n", (uint32_t) read_esr_el1());
100 ERROR(" FAR_EL1 = 0x%x\n", (uint32_t) read_far_el1());
101 break;
102 default:
103 break;
104 }
105loop:
106 ERROR("\n");
107 panic();
108}