blob: d9a4b8e6281b0b84659b3170fc2ac00aa9acc70a [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>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00008#include <common/bl_common.h>
9#include <common/debug.h>
10#include <common/runtime_svc.h>
11#include <drivers/arm/gicv2.h>
12#include <lib/mmio.h>
13
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020014#include "rcar_def.h"
15
16#define SWDT_ERROR_ID (1024U)
17#define SWDT_ERROR_TYPE (16U)
18#define SWDT_CHAR_MAX (13U)
19
20extern void rcar_swdt_release(void);
21
22void bl2_interrupt_error_id(uint32_t int_id)
23{
24 ERROR("\n");
25 if (int_id >= SWDT_ERROR_ID) {
26 ERROR("Unhandled exception occurred.\n");
Marek Vasut24b17992018-12-28 20:23:36 +010027 ERROR(" Exception type = FIQ_SP_EL0\n");
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020028 panic();
29 }
30
31 /* Clear the interrupt request */
32 gicv2_end_of_interrupt((uint32_t) int_id);
33 rcar_swdt_release();
34 ERROR("Unhandled exception occurred.\n");
Marek Vasut24b17992018-12-28 20:23:36 +010035 ERROR(" Exception type = FIQ_SP_EL0\n");
36 ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
37 ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
38 ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
39 ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020040 ERROR("\n");
41 panic();
42}
43
44void bl2_interrupt_error_type(uint32_t ex_type)
45{
46 const uint8_t interrupt_ex[SWDT_ERROR_TYPE][SWDT_CHAR_MAX] = {
47 "SYNC SP EL0",
48 "IRQ SP EL0",
49 "FIQ SP EL0",
50 "SERR SP EL0",
51 "SYNC SP ELx",
52 "IRQ SP ELx",
53 "FIQ SP ELx",
54 "SERR SP ELx",
55 "SYNC AARCH64",
56 "IRQ AARCH64",
57 "FIQ AARCH64",
58 "SERR AARCH64",
59 "SYNC AARCH32",
60 "IRQ AARCH32",
61 "FIQ AARCH32",
62 "SERR AARCH32"
63 };
64 char msg[128];
65
66 /* Clear the interrupt request */
67 if (ex_type >= SWDT_ERROR_TYPE) {
68 ERROR("\n");
69 ERROR("Unhandled exception occurred.\n");
70 ERROR(" Exception type = Unknown (%d)\n", ex_type);
71 goto loop;
72 }
73
74 rcar_swdt_release();
75 ERROR("\n");
76 ERROR("Unhandled exception occurred.\n");
77 snprintf(msg, sizeof(msg), " Exception type = %s\n",
78 &interrupt_ex[ex_type][0]);
79 ERROR("%s", msg);
80 switch (ex_type) {
Marek Vasut24b17992018-12-28 20:23:36 +010081 case SYNC_EXCEPTION_SP_EL0:
82 ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
83 ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
84 ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
85 ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020086 break;
Marek Vasut24b17992018-12-28 20:23:36 +010087 case IRQ_SP_EL0:
88 ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
89 ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
90 ERROR(" IAR_EL3 = 0x%x\n", gicv2_acknowledge_interrupt());
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020091 break;
Marek Vasut24b17992018-12-28 20:23:36 +010092 case FIQ_SP_EL0:
93 ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
94 ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
95 ERROR(" IAR_EL3 = 0x%x\n", gicv2_acknowledge_interrupt());
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +020096 break;
Marek Vasut24b17992018-12-28 20:23:36 +010097 case SERROR_SP_EL0:
98 ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
99 ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
100 ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
101 ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +0200102 break;
103 default:
104 break;
105 }
106loop:
107 ERROR("\n");
108 panic();
109}