Ken Liu | 91d44da | 2018-09-20 22:42:31 +0800 | [diff] [blame] | 1 | /* |
David Hu | 9804b6a | 2021-02-15 21:23:06 +0800 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, Arm Limited. All rights reserved. |
Ken Liu | 91d44da | 2018-09-20 22:42:31 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | #include <inttypes.h> |
David Hu | 9804b6a | 2021-02-15 21:23:06 +0800 | [diff] [blame] | 8 | #include "fih.h" |
Summer Qin | 5fdcf63 | 2020-06-22 16:49:24 +0800 | [diff] [blame] | 9 | #include "utilities.h" |
Summer Qin | bce2113 | 2020-08-19 14:28:10 +0800 | [diff] [blame] | 10 | #include "tfm_hal_platform.h" |
Ken Liu | 91d44da | 2018-09-20 22:42:31 +0800 | [diff] [blame] | 11 | |
Edison Ai | 9059ea0 | 2019-11-28 13:46:14 +0800 | [diff] [blame] | 12 | void tfm_core_panic(void) |
Ken Liu | 91d44da | 2018-09-20 22:42:31 +0800 | [diff] [blame] | 13 | { |
David Hu | 9804b6a | 2021-02-15 21:23:06 +0800 | [diff] [blame] | 14 | fih_delay(); |
| 15 | |
Sebastian Bøe | 055d83a | 2022-02-21 12:01:41 +0100 | [diff] [blame] | 16 | #ifdef CONFIG_TFM_HALT_ON_CORE_PANIC |
| 17 | |
| 18 | /* |
| 19 | * Halt instead of reboot to retain the backtrace that triggered |
| 20 | * the fault and thereby make it easier to debug. |
| 21 | */ |
| 22 | tfm_hal_system_halt(); |
| 23 | |
| 24 | #ifdef TFM_FIH_PROFILE_ON |
| 25 | fih_delay(); |
| 26 | |
| 27 | tfm_hal_system_halt(); |
| 28 | #endif |
| 29 | |
| 30 | #else /* CONFIG_TFM_HALT_ON_CORE_PANIC */ |
Edison Ai | 93dabfd | 2019-12-03 13:44:45 +0800 | [diff] [blame] | 31 | /* |
| 32 | * FixMe: In the first stage, the SPM will restart the entire system when a |
| 33 | * programmer error is detected in either the SPE or NSPE. |
| 34 | * In the next stage, the specified error codes are also sent to any NSPE |
| 35 | * management firmware. The NSPE management firmware can then decide to pass |
| 36 | * those error codes back to the calling task or to use its own |
| 37 | * functionality for terminating an execution context. |
| 38 | */ |
Summer Qin | bce2113 | 2020-08-19 14:28:10 +0800 | [diff] [blame] | 39 | tfm_hal_system_reset(); |
David Hu | 9804b6a | 2021-02-15 21:23:06 +0800 | [diff] [blame] | 40 | |
| 41 | #ifdef TFM_FIH_PROFILE_ON |
| 42 | fih_delay(); |
| 43 | |
| 44 | tfm_hal_system_reset(); |
| 45 | #endif |
Sebastian Bøe | 055d83a | 2022-02-21 12:01:41 +0100 | [diff] [blame] | 46 | |
| 47 | #endif /* CONFIG_TFM_HALT_ON_CORE_PANIC */ |
Ken Liu | 91d44da | 2018-09-20 22:42:31 +0800 | [diff] [blame] | 48 | } |