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