Arunachalam Ganapathy | 5f0afde | 2023-11-20 12:05:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <arch_helpers.h> |
| 8 | #include <debug.h> |
| 9 | |
| 10 | /* We save x0-x30. */ |
| 11 | #define GPRS_CNT 31U |
| 12 | |
| 13 | /* Set of registers saved by the crash_dump() assembly function in stack. */ |
| 14 | struct rec_regs { |
| 15 | unsigned long gprs[GPRS_CNT]; |
| 16 | unsigned long sp; |
| 17 | }; |
| 18 | |
| 19 | void __dead2 realm_print_exception(const struct rec_regs *ctx) |
| 20 | { |
| 21 | u_register_t mpid; |
| 22 | |
| 23 | /* |
| 24 | * The instruction barrier ensures we don't read stale values of system |
| 25 | * registers. |
| 26 | */ |
| 27 | isb(); |
| 28 | |
| 29 | mpid = read_mpidr_el1(); |
| 30 | realm_printf("Unhandled exception on REC%u.\n", mpid & MPID_MASK); |
| 31 | |
| 32 | /* Dump some interesting system registers. */ |
| 33 | realm_printf("System registers:\n"); |
| 34 | realm_printf(" MPIDR=0x%lx\n", mpid); |
| 35 | realm_printf(" ESR=0x%lx ELR=0x%lx FAR=0x%lx\n", read_esr_el1(), |
| 36 | read_elr_el1(), read_far_el1()); |
| 37 | realm_printf(" SCTLR=0x%lx SPSR=0x%lx DAIF=0x%lx\n", |
| 38 | read_sctlr_el1(), read_spsr_el1(), read_daif()); |
| 39 | |
| 40 | /* Dump general-purpose registers. */ |
| 41 | realm_printf("General-purpose registers:\n"); |
| 42 | for (unsigned int i = 0U; i < GPRS_CNT; i++) { |
| 43 | realm_printf(" x%u=0x%lx\n", i, ctx->gprs[i]); |
| 44 | } |
| 45 | realm_printf(" SP=0x%lx\n", ctx->sp); |
| 46 | |
| 47 | while (1) { |
| 48 | wfi(); |
| 49 | } |
| 50 | } |