blob: 842ccb8a905b2ff2614b8a6ce6df71b330d67810 [file] [log] [blame]
Mate Toth-Palce61afa2018-08-03 13:51:01 +02001/*
Summer Qinc0711612020-02-17 17:48:32 +08002 * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
Mate Toth-Palce61afa2018-08-03 13:51:01 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_NSPM_H__
9#define __TFM_NSPM_H__
10
11#include <stdint.h>
12
TTornblom44e65612020-05-04 19:20:11 +020013#if !defined(TFM_MULTI_CORE_TOPOLOGY)
David Hu1d0c53c2019-07-09 18:14:09 +080014/*
15 * The macro cmse_nsfptr_create defined in the gcc library uses the non-standard
16 * gcc C lanuage extension 'typeof'. TF-M is built with '-std=c99' so typeof
17 * cannot be used in the code. As a workaround cmse_nsfptr_create is redefined
18 * here to use only standard language elements.
19 */
20#undef cmse_nsfptr_create
21#define cmse_nsfptr_create(p) ((intptr_t) (p) & ~1)
David Hu94d424a2020-04-29 15:49:24 +080022
23/*!
24 * \def __tfm_nspm_secure_gateway_attributes__
25 *
26 * \brief Attributes for secure gateway functions for NSPM
27 */
TTornblom44e65612020-05-04 19:20:11 +020028#if !defined(__ARMCC_VERSION) && !defined(__ICCARM__)
David Hu94d424a2020-04-29 15:49:24 +080029/*
30 * GNUARM requires noclone attribute to protect gateway function symbol from
31 * being renamed and cloned
32 */
33#define __tfm_nspm_secure_gateway_attributes__ \
34 __attribute__((cmse_nonsecure_entry, noclone))
35#else
36#define __tfm_nspm_secure_gateway_attributes__ \
37 __attribute__((cmse_nonsecure_entry))
38#endif /* !__ARMCC_VERSION */
39#endif /* __GNUC__ && !TFM_MULTI_CORE_TOPOLOGY */
David Hu1d0c53c2019-07-09 18:14:09 +080040
Summer Qinc0711612020-02-17 17:48:32 +080041#ifndef TFM_PSA_API
Mate Toth-Palce61afa2018-08-03 13:51:01 +020042/**
43 * \brief initialise the NS context database
44 */
45void tfm_nspm_configure_clients(void);
Summer Qinc0711612020-02-17 17:48:32 +080046#endif
Mate Toth-Palce61afa2018-08-03 13:51:01 +020047
48/**
49 * \brief Get the client ID of the current NS client
50 *
51 * \return The client id of the current NS client. 0 (invalid client id) is
52 * returned in case of error.
53 */
54int32_t tfm_nspm_get_current_client_id(void);
55
Edison Ai4dcae6f2019-03-18 10:13:47 +080056#ifdef TFM_PSA_API
57/**
58 * \brief NSPM thread main entry function
59 *
Edison Ai4dcae6f2019-03-18 10:13:47 +080060 * Note: This function should not return back.
61 */
Edison Ai9c48d202019-10-12 16:57:21 +080062void tfm_nspm_thread_entry(void);
Edison Ai4dcae6f2019-03-18 10:13:47 +080063#endif
64
David Hu1d0c53c2019-07-09 18:14:09 +080065#ifdef TFM_MULTI_CORE_TOPOLOGY
66/* Unnecessary to configure Non-secure side code */
67#define configure_ns_code() do {} while (0)
68#else
69/*
70 * \brief Configure Non-secure code, such as vector table, MSP and entry point.
71 */
72void configure_ns_code(void);
73#endif
74
Mate Toth-Palce61afa2018-08-03 13:51:01 +020075#endif /* __TFM_NSPM_H__ */