Mate Toth-Pal | ce61afa | 2018-08-03 13:51:01 +0200 | [diff] [blame] | 1 | /* |
Summer Qin | 9544482 | 2022-01-27 11:22:00 +0800 | [diff] [blame] | 2 | * Copyright (c) 2018-2022, Arm Limited. All rights reserved. |
Chris Brand | cae2026 | 2022-06-23 12:05:33 -0700 | [diff] [blame^] | 3 | * Copyright (c) 2022 Cypress Semiconductor Corporation (an Infineon company) |
| 4 | * or an affiliate of Cypress Semiconductor Corporation. All rights reserved. |
Mate Toth-Pal | ce61afa | 2018-08-03 13:51:01 +0200 | [diff] [blame] | 5 | * |
| 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 Wang | 854a46f | 2021-08-12 16:16:25 +0800 | [diff] [blame] | 15 | #define TFM_NS_CLIENT_INVALID_ID ((int32_t)0) |
| 16 | |
Chris Brand | cae2026 | 2022-06-23 12:05:33 -0700 | [diff] [blame^] | 17 | #ifdef TFM_CONFIG_USE_TRUSTZONE |
David Hu | 1d0c53c | 2019-07-09 18:14:09 +0800 | [diff] [blame] | 18 | /* |
| 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 Hu | 94d424a | 2020-04-29 15:49:24 +0800 | [diff] [blame] | 26 | |
| 27 | /*! |
| 28 | * \def __tfm_nspm_secure_gateway_attributes__ |
| 29 | * |
| 30 | * \brief Attributes for secure gateway functions for NSPM |
| 31 | */ |
TTornblom | 44e6561 | 2020-05-04 19:20:11 +0200 | [diff] [blame] | 32 | #if !defined(__ARMCC_VERSION) && !defined(__ICCARM__) |
David Hu | 94d424a | 2020-04-29 15:49:24 +0800 | [diff] [blame] | 33 | /* |
| 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 Brand | cae2026 | 2022-06-23 12:05:33 -0700 | [diff] [blame^] | 43 | #endif /* TFM_CONFIG_USE_TRUSTZONE */ |
David Hu | 1d0c53c | 2019-07-09 18:14:09 +0800 | [diff] [blame] | 44 | |
Mate Toth-Pal | ce61afa | 2018-08-03 13:51:01 +0200 | [diff] [blame] | 45 | /** |
| 46 | * \brief initialise the NS context database |
| 47 | */ |
Sherry Zhnag | 482b88b | 2021-08-19 17:51:47 +0800 | [diff] [blame] | 48 | void tfm_nspm_ctx_init(void); |
Mate Toth-Pal | ce61afa | 2018-08-03 13:51:01 +0200 | [diff] [blame] | 49 | |
| 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 | */ |
| 56 | int32_t tfm_nspm_get_current_client_id(void); |
| 57 | |
Mate Toth-Pal | ce61afa | 2018-08-03 13:51:01 +0200 | [diff] [blame] | 58 | #endif /* __TFM_NSPM_H__ */ |