blob: 7906f80bd8171b27ec045fa50e717d597814432e [file] [log] [blame]
Mate Toth-Palce61afa2018-08-03 13:51:01 +02001/*
Summer Qin95444822022-01-27 11:22:00 +08002 * Copyright (c) 2018-2022, 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
Mate Toth-Palce61afa2018-08-03 13:51:01 +020056#endif /* __TFM_NSPM_H__ */