1 /*
2  * Arm SCP/MCP Software
3  * Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.
4  *
5  * SPDX-License-Identifier: BSD-3-Clause
6  *
7  * Description:
8  *      ARM-M exception handlers.
9  */
10 
11 #include <cmsis_compiler.h>
12 
13 #include <fwk_attributes.h>
14 #include <fwk_noreturn.h>
15 
16 #include <stdbool.h>
17 
arch_exception_reset(void)18 noreturn void arch_exception_reset(void)
19 {
20     /*
21      * When entering the firmware, before the framework is entered the following
22      * things happen:
23      *  1. The toolchain-specific C runtime is initialized
24      *     For Arm Compiler:
25      *       1. Zero-initialized data is zeroed
26      *       2. Initialized data is decompressed and copied
27      *     For GCC/Newlib:
28      *       1. Zero-initialized data is zeroed
29      *       2. Initialized data is copied by software_init_hook()
30      * 2. The main() function is called by the C runtime
31      */
32 
33 #ifdef __ARMCC_VERSION
34     extern noreturn void __main(void);
35 
36     __main();
37 #else
38     extern noreturn void _start(void);
39 
40     _start();
41 #endif
42 }
43 
arch_exception_invalid(void)44 noreturn FWK_WEAK void arch_exception_invalid(void)
45 {
46     while (true) {
47         __WFI();
48     }
49 }
50