blob: fe1069d695862c7eb09af600b495ba618bb49e61 [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.
Chris Brandcae20262022-06-23 12:05:33 -07003 * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company)
4 * or an affiliate of Cypress Semiconductor Corporation. All rights reserved.
Mate Toth-Palce61afa2018-08-03 13:51:01 +02005 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 *
8 */
9
10#ifndef __TFM_NSPM_H__
11#define __TFM_NSPM_H__
12
13#include <stdint.h>
14
David Wang854a46f2021-08-12 16:16:25 +080015#define TFM_NS_CLIENT_INVALID_ID ((int32_t)0)
16
Chris Brandcae20262022-06-23 12:05:33 -070017#ifdef TFM_CONFIG_USE_TRUSTZONE
David Hu1d0c53c2019-07-09 18:14:09 +080018/*
19 * The macro cmse_nsfptr_create defined in the gcc library uses the non-standard
20 * gcc C lanuage extension 'typeof'. TF-M is built with '-std=c99' so typeof
21 * cannot be used in the code. As a workaround cmse_nsfptr_create is redefined
22 * here to use only standard language elements.
23 */
24#undef cmse_nsfptr_create
25#define cmse_nsfptr_create(p) ((intptr_t) (p) & ~1)
David Hu94d424a2020-04-29 15:49:24 +080026
27/*!
28 * \def __tfm_nspm_secure_gateway_attributes__
29 *
30 * \brief Attributes for secure gateway functions for NSPM
31 */
TTornblom44e65612020-05-04 19:20:11 +020032#if !defined(__ARMCC_VERSION) && !defined(__ICCARM__)
David Hu94d424a2020-04-29 15:49:24 +080033/*
34 * GNUARM requires noclone attribute to protect gateway function symbol from
35 * being renamed and cloned
36 */
37#define __tfm_nspm_secure_gateway_attributes__ \
38 __attribute__((cmse_nonsecure_entry, noclone))
39#else
40#define __tfm_nspm_secure_gateway_attributes__ \
41 __attribute__((cmse_nonsecure_entry))
42#endif /* !__ARMCC_VERSION */
Chris Brandcae20262022-06-23 12:05:33 -070043#endif /* TFM_CONFIG_USE_TRUSTZONE */
David Hu1d0c53c2019-07-09 18:14:09 +080044
Mate Toth-Palce61afa2018-08-03 13:51:01 +020045/**
46 * \brief initialise the NS context database
47 */
Sherry Zhnag482b88b2021-08-19 17:51:47 +080048void tfm_nspm_ctx_init(void);
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
Mate Toth-Palce61afa2018-08-03 13:51:01 +020058#endif /* __TFM_NSPM_H__ */