xref: /rk3399_ARM-atf/plat/renesas/common/bl2_interrupt_error.c (revision 65d227c3a20c80bb70f796e5839dc96014f0f9cf)
1*499c2713SBiju Das /*
2*499c2713SBiju Das  * Copyright (c) 2015-2017, Renesas Electronics Corporation. All rights reserved.
3*499c2713SBiju Das  *
4*499c2713SBiju Das  * SPDX-License-Identifier: BSD-3-Clause
5*499c2713SBiju Das  */
6*499c2713SBiju Das 
7*499c2713SBiju Das #include <arch_helpers.h>
8*499c2713SBiju Das #include <common/bl_common.h>
9*499c2713SBiju Das #include <common/debug.h>
10*499c2713SBiju Das #include <common/runtime_svc.h>
11*499c2713SBiju Das #include <drivers/arm/gicv2.h>
12*499c2713SBiju Das #include <lib/mmio.h>
13*499c2713SBiju Das 
14*499c2713SBiju Das #include "rcar_def.h"
15*499c2713SBiju Das 
16*499c2713SBiju Das #define SWDT_ERROR_ID	(1024U)
17*499c2713SBiju Das #define SWDT_ERROR_TYPE	(16U)
18*499c2713SBiju Das #define SWDT_CHAR_MAX	(13U)
19*499c2713SBiju Das 
20*499c2713SBiju Das extern void rcar_swdt_release(void);
21*499c2713SBiju Das 
bl2_interrupt_error_id(uint32_t int_id)22*499c2713SBiju Das void bl2_interrupt_error_id(uint32_t int_id)
23*499c2713SBiju Das {
24*499c2713SBiju Das 	ERROR("\n");
25*499c2713SBiju Das 	if (int_id >= SWDT_ERROR_ID) {
26*499c2713SBiju Das 		ERROR("Unhandled exception occurred.\n");
27*499c2713SBiju Das 		ERROR("     Exception type = FIQ_SP_EL0\n");
28*499c2713SBiju Das 		panic();
29*499c2713SBiju Das 	}
30*499c2713SBiju Das 
31*499c2713SBiju Das 	/* Clear the interrupt request */
32*499c2713SBiju Das 	gicv2_end_of_interrupt((uint32_t) int_id);
33*499c2713SBiju Das 	rcar_swdt_release();
34*499c2713SBiju Das 	ERROR("Unhandled exception occurred.\n");
35*499c2713SBiju Das 	ERROR("     Exception type = FIQ_SP_EL0\n");
36*499c2713SBiju Das 	ERROR("     SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
37*499c2713SBiju Das 	ERROR("     ELR_EL3  = 0x%x\n", (uint32_t) read_elr_el3());
38*499c2713SBiju Das 	ERROR("     ESR_EL3  = 0x%x\n", (uint32_t) read_esr_el3());
39*499c2713SBiju Das 	ERROR("     FAR_EL3  = 0x%x\n", (uint32_t) read_far_el3());
40*499c2713SBiju Das 	ERROR("\n");
41*499c2713SBiju Das 	panic();
42*499c2713SBiju Das }
43*499c2713SBiju Das 
bl2_interrupt_error_type(uint32_t ex_type)44*499c2713SBiju Das void bl2_interrupt_error_type(uint32_t ex_type)
45*499c2713SBiju Das {
46*499c2713SBiju Das 	const uint8_t interrupt_ex[SWDT_ERROR_TYPE][SWDT_CHAR_MAX] = {
47*499c2713SBiju Das 		"SYNC SP EL0",
48*499c2713SBiju Das 		"IRQ SP EL0",
49*499c2713SBiju Das 		"FIQ SP EL0",
50*499c2713SBiju Das 		"SERR SP EL0",
51*499c2713SBiju Das 		"SYNC SP ELx",
52*499c2713SBiju Das 		"IRQ SP ELx",
53*499c2713SBiju Das 		"FIQ SP ELx",
54*499c2713SBiju Das 		"SERR SP ELx",
55*499c2713SBiju Das 		"SYNC AARCH64",
56*499c2713SBiju Das 		"IRQ AARCH64",
57*499c2713SBiju Das 		"FIQ AARCH64",
58*499c2713SBiju Das 		"SERR AARCH64",
59*499c2713SBiju Das 		"SYNC AARCH32",
60*499c2713SBiju Das 		"IRQ AARCH32",
61*499c2713SBiju Das 		"FIQ AARCH32",
62*499c2713SBiju Das 		"SERR AARCH32"
63*499c2713SBiju Das 	};
64*499c2713SBiju Das 	char msg[128];
65*499c2713SBiju Das 
66*499c2713SBiju Das 	/* Clear the interrupt request  */
67*499c2713SBiju Das 	if (ex_type >= SWDT_ERROR_TYPE) {
68*499c2713SBiju Das 		ERROR("\n");
69*499c2713SBiju Das 		ERROR("Unhandled exception occurred.\n");
70*499c2713SBiju Das 		ERROR("     Exception type = Unknown (%d)\n", ex_type);
71*499c2713SBiju Das 		goto loop;
72*499c2713SBiju Das 	}
73*499c2713SBiju Das 
74*499c2713SBiju Das 	rcar_swdt_release();
75*499c2713SBiju Das 	ERROR("\n");
76*499c2713SBiju Das 	ERROR("Unhandled exception occurred.\n");
77*499c2713SBiju Das 	snprintf(msg, sizeof(msg), "     Exception type = %s\n",
78*499c2713SBiju Das 		 &interrupt_ex[ex_type][0]);
79*499c2713SBiju Das 	ERROR("%s", msg);
80*499c2713SBiju Das 	switch (ex_type) {
81*499c2713SBiju Das 	case SYNC_EXCEPTION_SP_EL0:
82*499c2713SBiju Das 		ERROR("     SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
83*499c2713SBiju Das 		ERROR("     ELR_EL3  = 0x%x\n", (uint32_t) read_elr_el3());
84*499c2713SBiju Das 		ERROR("     ESR_EL3  = 0x%x\n", (uint32_t) read_esr_el3());
85*499c2713SBiju Das 		ERROR("     FAR_EL3  = 0x%x\n", (uint32_t) read_far_el3());
86*499c2713SBiju Das 		break;
87*499c2713SBiju Das 	case IRQ_SP_EL0:
88*499c2713SBiju Das 		ERROR("     SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
89*499c2713SBiju Das 		ERROR("     ELR_EL3  = 0x%x\n", (uint32_t) read_elr_el3());
90*499c2713SBiju Das 		ERROR("     IAR_EL3  = 0x%x\n", gicv2_acknowledge_interrupt());
91*499c2713SBiju Das 		break;
92*499c2713SBiju Das 	case FIQ_SP_EL0:
93*499c2713SBiju Das 		ERROR("     SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
94*499c2713SBiju Das 		ERROR("     ELR_EL3  = 0x%x\n", (uint32_t) read_elr_el3());
95*499c2713SBiju Das 		ERROR("     IAR_EL3  = 0x%x\n", gicv2_acknowledge_interrupt());
96*499c2713SBiju Das 		break;
97*499c2713SBiju Das 	case SERROR_SP_EL0:
98*499c2713SBiju Das 		ERROR("     SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
99*499c2713SBiju Das 		ERROR("     ELR_EL3  = 0x%x\n", (uint32_t) read_elr_el3());
100*499c2713SBiju Das 		ERROR("     ESR_EL3  = 0x%x\n", (uint32_t) read_esr_el3());
101*499c2713SBiju Das 		ERROR("     FAR_EL3  = 0x%x\n", (uint32_t) read_far_el3());
102*499c2713SBiju Das 		break;
103*499c2713SBiju Das 	default:
104*499c2713SBiju Das 		break;
105*499c2713SBiju Das 	}
106*499c2713SBiju Das loop:
107*499c2713SBiju Das 	ERROR("\n");
108*499c2713SBiju Das 	panic();
109*499c2713SBiju Das }
110