Subversion Repositories AFRtranscoder

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/******************************************************************************
2
 * @file     main_s.c
3
 * @brief    Code template for secure main function
4
 * @version  V1.1.1
5
 * @date     10. January 2018
6
 ******************************************************************************/
7
/*
8
 * Copyright (c) 2013-2018 Arm Limited. All rights reserved.
9
 *
10
 * SPDX-License-Identifier: Apache-2.0
11
 *
12
 * Licensed under the Apache License, Version 2.0 (the License); you may
13
 * not use this file except in compliance with the License.
14
 * You may obtain a copy of the License at
15
 *
16
 * www.apache.org/licenses/LICENSE-2.0
17
 *
18
 * Unless required by applicable law or agreed to in writing, software
19
 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
20
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
 * See the License for the specific language governing permissions and
22
 * limitations under the License.
23
 */
24
 
25
/* Use CMSE intrinsics */
26
#include <arm_cmse.h>
27
 
28
#include "RTE_Components.h"
29
#include CMSIS_device_header
30
 
31
/* TZ_START_NS: Start address of non-secure application */
32
#ifndef TZ_START_NS
33
#define TZ_START_NS (0x200000U)
34
#endif
35
 
36
/* typedef for non-secure callback functions */
37
typedef void (*funcptr_void) (void) __attribute__((cmse_nonsecure_call));
38
 
39
/* Secure main() */
40
int main(void) {
41
  funcptr_void NonSecure_ResetHandler;
42
 
43
  /* Add user setup code for secure part here*/
44
 
45
  /* Set non-secure main stack (MSP_NS) */
46
  __TZ_set_MSP_NS(*((uint32_t *)(TZ_START_NS)));
47
 
48
  /* Get non-secure reset handler */
49
  NonSecure_ResetHandler = (funcptr_void)(*((uint32_t *)((TZ_START_NS) + 4U)));
50
 
51
  /* Start non-secure state software application */
52
  NonSecure_ResetHandler();
53
 
54
  /* Non-secure software does not return, this code is not executed */
55
  while (1) {
56
    __NOP();
57
  }
58
}