blob: 3c7ae6cadc29e8bcd260745f4762edfe5a9097ee [file] [log] [blame]
Marc Moreno Berengue20dab392017-11-29 13:18:58 +00001/*
Raef Coles79809c72022-03-02 13:48:20 +00002 * Copyright (c) 2017-2022, Arm Limited. All rights reserved.
Marc Moreno Berengue20dab392017-11-29 13:18:58 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Marc Moreno Berengueef202722018-08-10 13:43:43 +01008#ifndef __TFM_PLAT_DEFS_H__
9#define __TFM_PLAT_DEFS_H__
Marc Moreno Berengue20dab392017-11-29 13:18:58 +000010/**
11 * \note The interfaces defined in this file must be implemented for each
12 * target.
13 */
Marc Moreno Berengue20dab392017-11-29 13:18:58 +000014
15#include <stdint.h>
16#include <limits.h>
17
Marc Moreno Berengue9926df82018-08-10 13:45:52 +010018enum tfm_plat_err_t {
19 TFM_PLAT_ERR_SUCCESS = 0,
Tamas Band28286e2020-11-27 12:58:39 +000020 TFM_PLAT_ERR_SYSTEM_ERR = 0x3A5C,
21 TFM_PLAT_ERR_MAX_VALUE = 0x55A3,
22 TFM_PLAT_ERR_INVALID_INPUT = 0xA3C5,
23 TFM_PLAT_ERR_UNSUPPORTED = 0xC35A,
Raef Coles79809c72022-03-02 13:48:20 +000024 TFM_PLAT_ERR_NOT_PERMITTED = 0xC5A3,
Marc Moreno Berengue20dab392017-11-29 13:18:58 +000025 /* Following entry is only to ensure the error code of int size */
Marc Moreno Berengue9926df82018-08-10 13:45:52 +010026 TFM_PLAT_ERR_FORCE_INT_SIZE = INT_MAX
Marc Moreno Berengue20dab392017-11-29 13:18:58 +000027};
28
Xinyu Zhangae99e2d2023-07-28 14:03:29 +080029#if defined(TFM_ISOLATION_LEVEL) && (TFM_ISOLATION_LEVEL != 1)
Edison Ai14dd1372019-07-11 18:02:18 +080030
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010031/*!
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010032 * \def TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME)
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010033 *
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010034 * \brief This macro provides a mechanism to place a function code or a data
35 * variable in the code section (e.g. RO) of a specific secure partition
Edison Ai14dd1372019-07-11 18:02:18 +080036 * at linker time.
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010037 *
38 * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest
Edison Aibb614aa2018-11-21 15:15:00 +080039 * file "name" field.
Raef Coles79d82082021-01-07 15:42:38 +000040 * \param[in] TFM_PARTITION_TYPE TF-M partition type assigned in the manifest
41 * file "type" field.
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010042 */
Raef Coles79d82082021-01-07 15:42:38 +000043#define TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME, \
44 TFM_PARTITION_TYPE) \
45 __attribute__((section(TFM_PARTITION_NAME "_" TFM_PARTITION_TYPE "_ATTR_FN")))
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010046
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010047/*!
48 * \def TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME)
49 *
50 * \brief This macro provides a mechanism to place data variables in the RW data
Edison Ai14dd1372019-07-11 18:02:18 +080051 * section of a specific secure partition at linker time.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010052 *
53 * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest
54 * file "name" field.
Raef Coles79d82082021-01-07 15:42:38 +000055 * \param[in] TFM_PARTITION_TYPE TF-M partition type assigned in the manifest
56 * file "type" field.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010057 */
Raef Coles79d82082021-01-07 15:42:38 +000058#define TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME, \
59 TFM_PARTITION_TYPE) \
60 __attribute__((section(TFM_PARTITION_NAME "_" TFM_PARTITION_TYPE "_ATTR_RW")))
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010061
62/*!
63 * \def TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME)
64 *
65 * \brief This macro provides a mechanism to place data variables in the ZI data
Edison Ai14dd1372019-07-11 18:02:18 +080066 * section of a specific secure partition at linker time.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010067 *
68 * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest
69 * file "name" field.
Raef Coles79d82082021-01-07 15:42:38 +000070 * \param[in] TFM_PARTITION_TYPE TF-M partition type assigned in the manifest
71 * file "type" field.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010072 */
Raef Coles79d82082021-01-07 15:42:38 +000073#define TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME, \
74 TFM_PARTITION_TYPE) \
75 __attribute__((section(TFM_PARTITION_NAME "_" TFM_PARTITION_TYPE "_ATTR_ZI")))
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010076#else
Raef Coles79d82082021-01-07 15:42:38 +000077#define TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME, TFM_PARTITION_TYPE)
78#define TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME, TFM_PARTITION_TYPE)
79#define TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME, TFM_PARTITION_TYPE)
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010080#endif
Marc Moreno Berengueef202722018-08-10 13:43:43 +010081#endif /* __TFM_PLAT_DEFS_H__ */