blob: d9f15958fde26ca7697401eab3691f485e128cb2 [file] [log] [blame]
Ken Liu2e434892022-02-16 12:10:16 +08001/*
2 * Copyright (c) 2022, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7#include "cmsis.h"
8#include "exception_info.h"
Joakim Andersson7df331f2022-05-30 16:21:13 +02009#include "utilities.h"
Ken Liu2e434892022-02-16 12:10:16 +080010
Joakim Andersson7df331f2022-05-30 16:21:13 +020011void C_HardFault_Handler(void)
Ken Liu2e434892022-02-16 12:10:16 +080012{
Ken Liu2e434892022-02-16 12:10:16 +080013 /* A HardFault may indicate corruption of secure state, so it is essential
14 * that Non-secure code does not regain control after one is raised.
15 * Returning from this exception could allow a pending NS exception to be
16 * taken, so the current solution is not to return.
17 */
Joakim Andersson7df331f2022-05-30 16:21:13 +020018 tfm_core_panic();
19}
20
21__attribute__((naked)) void HardFault_Handler(void)
22{
23 EXCEPTION_INFO(EXCEPTION_TYPE_HARDFAULT);
24
25 __ASM volatile(
26 "bl C_HardFault_Handler \n"
27 "b . \n"
28 );
29}
30
31void C_MemManage_Handler(void)
32{
33 /* A MemManage fault may indicate corruption of secure state, so it is
34 * essential that Non-secure code does not regain control after one is
35 * raised. Returning from this exception could allow a pending NS exception
36 * to be taken, so the current solution is to panic.
37 */
38 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080039}
40
41__attribute__((naked)) void MemManage_Handler(void)
42{
43 EXCEPTION_INFO(EXCEPTION_TYPE_MEMFAULT);
44
Joakim Andersson7df331f2022-05-30 16:21:13 +020045 __ASM volatile(
46 "bl C_MemManage_Handler \n"
47 "b . \n"
48 );
49}
50
51void C_BusFault_Handler(void)
52{
53 /* A BusFault may indicate corruption of secure state, so it is essential
54 * that Non-secure code does not regain control after one is raised.
55 * Returning from this exception could allow a pending NS exception to be
56 * taken, so the current solution is to panic.
Ken Liu2e434892022-02-16 12:10:16 +080057 */
Joakim Andersson7df331f2022-05-30 16:21:13 +020058 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080059}
60
61__attribute__((naked)) void BusFault_Handler(void)
62{
63 EXCEPTION_INFO(EXCEPTION_TYPE_BUSFAULT);
64
Joakim Andersson7df331f2022-05-30 16:21:13 +020065 __ASM volatile(
66 "bl C_BusFault_Handler \n"
67 "b . \n"
68 );
69}
70
71void C_SecureFault_Handler(void)
72{
73 /* A SecureFault may indicate corruption of secure state, so it is essential
Ken Liu2e434892022-02-16 12:10:16 +080074 * that Non-secure code does not regain control after one is raised.
75 * Returning from this exception could allow a pending NS exception to be
Joakim Andersson7df331f2022-05-30 16:21:13 +020076 * taken, so the current solution is to panic.
Ken Liu2e434892022-02-16 12:10:16 +080077 */
Joakim Andersson7df331f2022-05-30 16:21:13 +020078 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080079}
80
81__attribute__((naked)) void SecureFault_Handler(void)
82{
83 EXCEPTION_INFO(EXCEPTION_TYPE_SECUREFAULT);
84
Joakim Andersson7df331f2022-05-30 16:21:13 +020085 __ASM volatile(
86 "bl C_SecureFault_Handler \n"
87 "b . \n"
88 );
89}
90
91void C_UsageFault_Handler(void)
92{
93 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080094}
95
96__attribute__((naked)) void UsageFault_Handler(void)
97{
98 EXCEPTION_INFO(EXCEPTION_TYPE_USAGEFAULT);
Joakim Andersson7df331f2022-05-30 16:21:13 +020099
100 __ASM volatile(
101 "bl C_UsageFault_Handler \n"
102 "b . \n"
103 );
Ken Liu2e434892022-02-16 12:10:16 +0800104}