Marc Moreno Berengue | 20dab39 | 2017-11-29 13:18:58 +0000 | [diff] [blame] | 1 | /* |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 2 | * Copyright (c) 2017-2019, Arm Limited. All rights reserved. |
Marc Moreno Berengue | 20dab39 | 2017-11-29 13:18:58 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
Marc Moreno Berengue | ef20272 | 2018-08-10 13:43:43 +0100 | [diff] [blame] | 8 | #ifndef __TFM_PLAT_DEFS_H__ |
| 9 | #define __TFM_PLAT_DEFS_H__ |
Marc Moreno Berengue | 20dab39 | 2017-11-29 13:18:58 +0000 | [diff] [blame] | 10 | /** |
| 11 | * \note The interfaces defined in this file must be implemented for each |
| 12 | * target. |
| 13 | */ |
Marc Moreno Berengue | 20dab39 | 2017-11-29 13:18:58 +0000 | [diff] [blame] | 14 | |
| 15 | #include <stdint.h> |
| 16 | #include <limits.h> |
| 17 | |
Marc Moreno Berengue | 9926df8 | 2018-08-10 13:45:52 +0100 | [diff] [blame] | 18 | enum tfm_plat_err_t { |
| 19 | TFM_PLAT_ERR_SUCCESS = 0, |
| 20 | TFM_PLAT_ERR_SYSTEM_ERR, |
Marc Moreno Berengue | 4cc81fc | 2018-08-10 14:32:01 +0100 | [diff] [blame] | 21 | TFM_PLAT_ERR_MAX_VALUE, |
David Vincze | 2ff8c6a | 2019-05-21 11:53:00 +0200 | [diff] [blame] | 22 | TFM_PLAT_ERR_INVALID_INPUT, |
| 23 | TFM_PLAT_ERR_UNSUPPORTED, |
Marc Moreno Berengue | 20dab39 | 2017-11-29 13:18:58 +0000 | [diff] [blame] | 24 | /* Following entry is only to ensure the error code of int size */ |
Marc Moreno Berengue | 9926df8 | 2018-08-10 13:45:52 +0100 | [diff] [blame] | 25 | TFM_PLAT_ERR_FORCE_INT_SIZE = INT_MAX |
Marc Moreno Berengue | 20dab39 | 2017-11-29 13:18:58 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
Edison Ai | 551cf97 | 2019-08-22 14:07:29 +0800 | [diff] [blame^] | 28 | #if defined(TFM_PSA_API) && defined(TFM_LVL) && (TFM_LVL != 1) |
Edison Ai | 14dd137 | 2019-07-11 18:02:18 +0800 | [diff] [blame] | 29 | |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 30 | /*! |
Mate Toth-Pal | 9aae21d | 2019-02-11 15:39:30 +0100 | [diff] [blame] | 31 | * \def TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME) |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 32 | * |
Mate Toth-Pal | 9aae21d | 2019-02-11 15:39:30 +0100 | [diff] [blame] | 33 | * \brief This macro provides a mechanism to place a function code or a data |
| 34 | * variable in the code section (e.g. RO) of a specific secure partition |
Edison Ai | 14dd137 | 2019-07-11 18:02:18 +0800 | [diff] [blame] | 35 | * at linker time. |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 36 | * |
| 37 | * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest |
Edison Ai | bb614aa | 2018-11-21 15:15:00 +0800 | [diff] [blame] | 38 | * file "name" field. |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 39 | */ |
Mate Toth-Pal | 9aae21d | 2019-02-11 15:39:30 +0100 | [diff] [blame] | 40 | #define TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME) \ |
Marc Moreno Berengue | 8e0fa7a | 2018-10-04 18:25:13 +0100 | [diff] [blame] | 41 | __attribute__((section(TFM_PARTITION_NAME"_ATTR_FN"))) |
| 42 | |
Mate Toth-Pal | 9aae21d | 2019-02-11 15:39:30 +0100 | [diff] [blame] | 43 | /*! |
| 44 | * \def TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME) |
| 45 | * |
| 46 | * \brief This macro provides a mechanism to place data variables in the RW data |
Edison Ai | 14dd137 | 2019-07-11 18:02:18 +0800 | [diff] [blame] | 47 | * section of a specific secure partition at linker time. |
Mate Toth-Pal | 9aae21d | 2019-02-11 15:39:30 +0100 | [diff] [blame] | 48 | * |
| 49 | * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest |
| 50 | * file "name" field. |
| 51 | */ |
| 52 | #define TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME) \ |
| 53 | __attribute__((section(TFM_PARTITION_NAME"_ATTR_RW"))) |
| 54 | |
| 55 | /*! |
| 56 | * \def TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME) |
| 57 | * |
| 58 | * \brief This macro provides a mechanism to place data variables in the ZI data |
Edison Ai | 14dd137 | 2019-07-11 18:02:18 +0800 | [diff] [blame] | 59 | * section of a specific secure partition at linker time. |
Mate Toth-Pal | 9aae21d | 2019-02-11 15:39:30 +0100 | [diff] [blame] | 60 | * |
| 61 | * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest |
| 62 | * file "name" field. |
| 63 | */ |
| 64 | #define TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME) \ |
| 65 | __attribute__((section(TFM_PARTITION_NAME"_ATTR_ZI"))) |
| 66 | #else |
| 67 | #define TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME) |
| 68 | #define TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME) |
| 69 | #define TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME) |
| 70 | #endif |
Marc Moreno Berengue | ef20272 | 2018-08-10 13:43:43 +0100 | [diff] [blame] | 71 | #endif /* __TFM_PLAT_DEFS_H__ */ |