blob: ab2175d717ccbcce7f1e240f131009d444c0b0e9 [file] [log] [blame]
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +00001/*
Jamie Fox5592db02017-12-18 16:48:29 +00002 * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#include <stdio.h>
9#include <string.h>
10#include <stdbool.h>
11
12#include "cmsis.h"
13#include "tfm_api.h"
14#include "cmsis_os2.h"
15#include "tfm_integ_test.h"
16#include "tfm_ns_svc.h"
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000017#include "tfm_ns_lock.h"
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000018#ifdef TEST_FRAMEWORK_NS
19#include "test/framework/integ_test.h"
20#endif
21
22#include "Driver_USART.h"
23
24/* For UART the CMSIS driver is used */
25extern ARM_DRIVER_USART Driver_USART0;
26
27/**
28 * \brief Modified table template for user defined SVC functions
29 *
30 * \details RTX has a weak definition of osRtxUserSVC, which
31 * is overridden here
32 */
33extern void * const osRtxUserSVC[1+USER_SVC_COUNT];
34 void * const osRtxUserSVC[1+USER_SVC_COUNT] = {
35 (void *)USER_SVC_COUNT,
36
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010037#define X(SVC_ENUM, SVC_HANDLER) (void*)SVC_HANDLER,
38 /* SVC API for Services */
39 LIST_SVC_DISPATCHERS
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000040
41#if defined(CORE_TEST_INTERACTIVE)
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010042 LIST_SVC_CORE_TEST_INTERACTIVE
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000043#endif /* CORE_TEST_INTERACTIVE */
44
Mate Toth-Pal349714a2018-02-23 15:30:24 +010045#if defined(TFM_PARTITION_TEST_CORE)
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010046 LIST_SVC_TFM_PARTITION_TEST_CORE
Mate Toth-Pal349714a2018-02-23 15:30:24 +010047#endif /* TFM_PARTITION_TEST_CORE */
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000048
Mate Toth-Pal349714a2018-02-23 15:30:24 +010049#if defined(TFM_PARTITION_TEST_SST)
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010050 LIST_SVC_TFM_PARTITION_TEST_SST
Mate Toth-Pal349714a2018-02-23 15:30:24 +010051#endif /* TFM_PARTITION_TEST_SST */
Jamie Fox5592db02017-12-18 16:48:29 +000052
Antonio de Angelisd9cd66e2018-03-27 11:19:59 +010053#undef X
54
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000055//(void *)user_function1,
56// ...
57};
58
59/* Struct FILE is implemented in stdio.h. Used to redirect printf to UART0 */
60FILE __stdout;
61/* Redirects armclang printf to UART */
62int fputc(int ch, FILE *f) {
63 /* Send byte to UART0 */
64 (void)Driver_USART0.Send((const unsigned char *)&ch, 1);
65 /* Return character written */
66 return ch;
67}
68/* redirects gcc printf to uart */
69int _write(int fd, char * str, int len)
70{
71 (void)Driver_USART0.Send(str, len);
72
73 return len;
74}
75
76/**
77 * \brief List of RTOS thread attributes
78 */
79#ifdef TEST_FRAMEWORK_NS
80static const osThreadAttr_t tserv_test = {
81 .name = "test_app",
82 .stack_size = 1024U
83};
84#endif
85
86/**
87 * \brief Static globals to hold RTOS related quantities,
88 * main thread
89 */
90static osStatus_t status;
91static osThreadId_t thread_id;
92
93/**
94 * \brief main() function
95 */
Mate Toth-Pal31a2d962018-03-09 13:14:44 +010096#ifndef __GNUC__
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000097__attribute__((noreturn))
Mate Toth-Pal31a2d962018-03-09 13:14:44 +010098#endif
Antonio de Angelisa54ed7e2017-11-29 13:37:58 +000099int main(void)
100{
101 (void)Driver_USART0.Initialize(NULL); /* Use UART0 as stdout */
102 Driver_USART0.Control(ARM_USART_MODE_ASYNCHRONOUS, 115200);
103
104 status = osKernelInitialize();
105
106 /* Initialize the TFM NS lock */
107 tfm_ns_lock_init();
108
109#ifdef TEST_FRAMEWORK_NS
110 thread_id = osThreadNew(test_app, NULL, &tserv_test);
111#else
112 UNUSED_VARIABLE(thread_id);
113#endif
114
115 status = osKernelStart();
116
117 /* Reached only in case of error */
118 for (;;) {
119 }
120}