blob: 148b302e9d18c26e20858512d6f4659c171f8fc1 [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"
Joakim Andersson7df331f2022-05-30 16:21:13 +02008#include "utilities.h"
Dávid Házibe7f0de2023-07-19 11:25:38 +02009/* "exception_info.h" must be the last include because of the IAR pragma */
10#include "exception_info.h"
Ken Liu2e434892022-02-16 12:10:16 +080011
Joakim Andersson7df331f2022-05-30 16:21:13 +020012void C_HardFault_Handler(void)
Ken Liu2e434892022-02-16 12:10:16 +080013{
Ken Liu2e434892022-02-16 12:10:16 +080014 /* A HardFault may indicate corruption of secure state, so it is essential
15 * that Non-secure code does not regain control after one is raised.
16 * Returning from this exception could allow a pending NS exception to be
17 * taken, so the current solution is not to return.
18 */
Joakim Andersson7df331f2022-05-30 16:21:13 +020019 tfm_core_panic();
20}
21
22__attribute__((naked)) void HardFault_Handler(void)
23{
24 EXCEPTION_INFO(EXCEPTION_TYPE_HARDFAULT);
25
26 __ASM volatile(
27 "bl C_HardFault_Handler \n"
28 "b . \n"
29 );
30}
31
32void C_MemManage_Handler(void)
33{
34 /* A MemManage fault may indicate corruption of secure state, so it is
35 * essential that Non-secure code does not regain control after one is
36 * raised. Returning from this exception could allow a pending NS exception
37 * to be taken, so the current solution is to panic.
38 */
39 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080040}
41
42__attribute__((naked)) void MemManage_Handler(void)
43{
44 EXCEPTION_INFO(EXCEPTION_TYPE_MEMFAULT);
45
Joakim Andersson7df331f2022-05-30 16:21:13 +020046 __ASM volatile(
47 "bl C_MemManage_Handler \n"
48 "b . \n"
49 );
50}
51
52void C_BusFault_Handler(void)
53{
54 /* A BusFault may indicate corruption of secure state, so it is essential
55 * that Non-secure code does not regain control after one is raised.
56 * Returning from this exception could allow a pending NS exception to be
57 * taken, so the current solution is to panic.
Ken Liu2e434892022-02-16 12:10:16 +080058 */
Joakim Andersson7df331f2022-05-30 16:21:13 +020059 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080060}
61
62__attribute__((naked)) void BusFault_Handler(void)
63{
64 EXCEPTION_INFO(EXCEPTION_TYPE_BUSFAULT);
65
Joakim Andersson7df331f2022-05-30 16:21:13 +020066 __ASM volatile(
67 "bl C_BusFault_Handler \n"
68 "b . \n"
69 );
70}
71
72void C_SecureFault_Handler(void)
73{
74 /* A SecureFault may indicate corruption of secure state, so it is essential
Ken Liu2e434892022-02-16 12:10:16 +080075 * that Non-secure code does not regain control after one is raised.
76 * Returning from this exception could allow a pending NS exception to be
Joakim Andersson7df331f2022-05-30 16:21:13 +020077 * taken, so the current solution is to panic.
Ken Liu2e434892022-02-16 12:10:16 +080078 */
Joakim Andersson7df331f2022-05-30 16:21:13 +020079 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080080}
81
82__attribute__((naked)) void SecureFault_Handler(void)
83{
84 EXCEPTION_INFO(EXCEPTION_TYPE_SECUREFAULT);
85
Joakim Andersson7df331f2022-05-30 16:21:13 +020086 __ASM volatile(
87 "bl C_SecureFault_Handler \n"
88 "b . \n"
89 );
90}
91
92void C_UsageFault_Handler(void)
93{
94 tfm_core_panic();
Ken Liu2e434892022-02-16 12:10:16 +080095}
96
97__attribute__((naked)) void UsageFault_Handler(void)
98{
99 EXCEPTION_INFO(EXCEPTION_TYPE_USAGEFAULT);
Joakim Andersson7df331f2022-05-30 16:21:13 +0200100
101 __ASM volatile(
102 "bl C_UsageFault_Handler \n"
103 "b . \n"
104 );
Ken Liu2e434892022-02-16 12:10:16 +0800105}