blob: 8b27d6ecbd2f269d9cc4926f2d2af3b7f14cd341 [file] [log] [blame]
Mate Toth-Palce61afa2018-08-03 13:51:01 +02001/*
Sherry Zhnag482b88b2021-08-19 17:51:47 +08002 * Copyright (c) 2018-2021, 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
Mate Toth-Palce61afa2018-08-03 13:51:01 +020043/**
44 * \brief initialise the NS context database
45 */
Sherry Zhnag482b88b2021-08-19 17:51:47 +080046void tfm_nspm_ctx_init(void);
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__ */