1 /*
2  * Copyright (c) 2018-2024, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "tfm_hal_device_header.h"
9 #include "target_cfg.h"
10 #include "Driver_MPC.h"
11 #include "utilities.h"
12 #include "tfm_hal_platform.h"
13 /* "exception_info.h" must be the last include because of the IAR pragma */
14 #include "exception_info.h"
15 
16 /* Import MPC driver */
17 extern ARM_DRIVER_MPC Driver_EFLASH0_MPC;
18 extern ARM_DRIVER_MPC Driver_CODE_SRAM_MPC;
19 
C_MPC_Handler(void)20 void C_MPC_Handler(void)
21 {
22     /* Clear MPC interrupt flags and pending MPC IRQ */
23     Driver_EFLASH0_MPC.ClearInterrupt();
24     Driver_CODE_SRAM_MPC.ClearInterrupt();
25     NVIC_ClearPendingIRQ(S_MPC_COMBINED_IRQn);
26 
27     /* Print fault message and block execution */
28     ERROR_MSG("Platform Exception: MPC fault!!!");
29 
30     tfm_core_panic();
31 }
32 
MPC_Handler(void)33 __attribute__((naked)) void MPC_Handler(void)
34 {
35     EXCEPTION_INFO();
36 
37     __ASM volatile(
38         "BL        C_MPC_Handler           \n"
39         "B         .                       \n"
40     );
41 }
42 
C_PPC_Handler(void)43 void C_PPC_Handler(void)
44 {
45     /*
46      * Due to an issue on the FVP, the PPC fault doesn't trigger a
47      * PPC IRQ which is handled by the PPC_handler.
48      * In the FVP execution, this code is not execute.
49      */
50 
51     /* Clear PPC interrupt flag and pending PPC IRQ */
52     ppc_clear_irq();
53     NVIC_ClearPendingIRQ(S_PPC_COMBINED_IRQn);
54 
55     /* Print fault message*/
56     ERROR_MSG("Platform Exception: PPC fault!!!");
57 
58     tfm_core_panic();
59 }
60 
PPC_Handler(void)61 __attribute__((naked)) void PPC_Handler(void)
62 {
63     EXCEPTION_INFO();
64 
65     __ASM volatile(
66         "BL        C_PPC_Handler           \n"
67         "B         .                       \n"
68     );
69 }
70 
C_NMI_Handler(void)71 void C_NMI_Handler(void)
72 {
73     /*
74      * FixMe: Due to the issue on the MUSCA_B1 board: secure watchdog is not
75      * able to reset the system on the second timeout. Hence performing the
76      * warm reset as part of watchdog interrupt (Take place in NMI).
77      */
78     /* Print fault message*/
79     ERROR_MSG("Platform Exception: NMI fault!!!");
80 
81     /* Trigger warm-reset */
82     tfm_hal_system_reset();
83 }
84 
NMI_Handler(void)85 __attribute__((naked)) void NMI_Handler(void)
86 {
87     EXCEPTION_INFO();
88 
89     __ASM volatile(
90         "BL        C_NMI_Handler           \n"
91         "B         .                       \n"
92     );
93 }
94