2 * Copyright (c) 2013-2016 ARM Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * ----------------------------------------------------------------------
20 * $Date: 15. October 2016
23 * Project: TrustZone for ARMv8-M
24 * Title: Code template for secure main function
26 *---------------------------------------------------------------------------*/
31 /* Use CMSE intrinsics */
34 #include "RTE_Components.h"
35 #include CMSIS_device_header
37 /* TZ_START_NS: Start address of non-secure application */
39 #define TZ_START_NS (0x200000U)
42 /* typedef for non-secure callback functions */
43 typedef void (*funcptr_void) (void) __attribute__((cmse_nonsecure_call));
47 funcptr_void NonSecure_ResetHandler;
49 /* Add user setup code for secure part here*/
51 /* Set non-secure main stack (MSP_NS) */
52 __TZ_set_MSP_NS(*((uint32_t *)(TZ_START_NS)));
54 /* Get non-secure reset handler */
55 NonSecure_ResetHandler = (funcptr_void)(*((uint32_t *)((TZ_START_NS) + 4U)));
57 /* Start non-secure state software application */
58 NonSecure_ResetHandler();
60 /* Non-secure software does not return, this code is not executed */
66 #if defined(__CORTEX_M)
68 extern void HardFault_Handler(void);
69 void HardFault_Handler(void) {
70 printf("Bootloader HardFault!\n");