blob: a458fba65959943f65226d066c8e31b3c82ede05 [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
David Wang854a46f2021-08-12 16:16:25 +080013#define TFM_NS_CLIENT_INVALID_ID ((int32_t)0)
14
TTornblom44e65612020-05-04 19:20:11 +020015#if !defined(TFM_MULTI_CORE_TOPOLOGY)
David Hu1d0c53c2019-07-09 18:14:09 +080016/*
17 * The macro cmse_nsfptr_create defined in the gcc library uses the non-standard
18 * gcc C lanuage extension 'typeof'. TF-M is built with '-std=c99' so typeof
19 * cannot be used in the code. As a workaround cmse_nsfptr_create is redefined
20 * here to use only standard language elements.
21 */
22#undef cmse_nsfptr_create
23#define cmse_nsfptr_create(p) ((intptr_t) (p) & ~1)
David Hu94d424a2020-04-29 15:49:24 +080024
25/*!
26 * \def __tfm_nspm_secure_gateway_attributes__
27 *
28 * \brief Attributes for secure gateway functions for NSPM
29 */
TTornblom44e65612020-05-04 19:20:11 +020030#if !defined(__ARMCC_VERSION) && !defined(__ICCARM__)
David Hu94d424a2020-04-29 15:49:24 +080031/*
32 * GNUARM requires noclone attribute to protect gateway function symbol from
33 * being renamed and cloned
34 */
35#define __tfm_nspm_secure_gateway_attributes__ \
36 __attribute__((cmse_nonsecure_entry, noclone))
37#else
38#define __tfm_nspm_secure_gateway_attributes__ \
39 __attribute__((cmse_nonsecure_entry))
40#endif /* !__ARMCC_VERSION */
41#endif /* __GNUC__ && !TFM_MULTI_CORE_TOPOLOGY */
David Hu1d0c53c2019-07-09 18:14:09 +080042
Summer Qinc0711612020-02-17 17:48:32 +080043#ifndef TFM_PSA_API
Mate Toth-Palce61afa2018-08-03 13:51:01 +020044/**
45 * \brief initialise the NS context database
46 */
47void tfm_nspm_configure_clients(void);
Summer Qinc0711612020-02-17 17:48:32 +080048#endif
Mate Toth-Palce61afa2018-08-03 13:51:01 +020049
50/**
51 * \brief Get the client ID of the current NS client
52 *
53 * \return The client id of the current NS client. 0 (invalid client id) is
54 * returned in case of error.
55 */
56int32_t tfm_nspm_get_current_client_id(void);
57
Edison Ai4dcae6f2019-03-18 10:13:47 +080058#ifdef TFM_PSA_API
59/**
60 * \brief NSPM thread main entry function
61 *
Edison Ai4dcae6f2019-03-18 10:13:47 +080062 * Note: This function should not return back.
63 */
Edison Ai9c48d202019-10-12 16:57:21 +080064void tfm_nspm_thread_entry(void);
Edison Ai4dcae6f2019-03-18 10:13:47 +080065#endif
66
David Hu1d0c53c2019-07-09 18:14:09 +080067#ifdef TFM_MULTI_CORE_TOPOLOGY
68/* Unnecessary to configure Non-secure side code */
69#define configure_ns_code() do {} while (0)
70#else
71/*
72 * \brief Configure Non-secure code, such as vector table, MSP and entry point.
73 */
74void configure_ns_code(void);
75#endif
76
Mate Toth-Palce61afa2018-08-03 13:51:01 +020077#endif /* __TFM_NSPM_H__ */