blob: 6a2a14d797bace2a2515b792f84b2e3d51beacbf [file] [log] [blame]
Marc Moreno Berengue20dab392017-11-29 13:18:58 +00001/*
Raef Coles79d82082021-01-07 15:42:38 +00002 * Copyright (c) 2017-2021, 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,
Marc Moreno Berengue20dab392017-11-29 13:18:58 +000024 /* Following entry is only to ensure the error code of int size */
Marc Moreno Berengue9926df82018-08-10 13:45:52 +010025 TFM_PLAT_ERR_FORCE_INT_SIZE = INT_MAX
Marc Moreno Berengue20dab392017-11-29 13:18:58 +000026};
27
Edison Ai551cf972019-08-22 14:07:29 +080028#if defined(TFM_PSA_API) && defined(TFM_LVL) && (TFM_LVL != 1)
Edison Ai14dd1372019-07-11 18:02:18 +080029
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010030/*!
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010031 * \def TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME)
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010032 *
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010033 * \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 Ai14dd1372019-07-11 18:02:18 +080035 * at linker time.
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010036 *
37 * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest
Edison Aibb614aa2018-11-21 15:15:00 +080038 * file "name" field.
Raef Coles79d82082021-01-07 15:42:38 +000039 * \param[in] TFM_PARTITION_TYPE TF-M partition type assigned in the manifest
40 * file "type" field.
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010041 */
Raef Coles79d82082021-01-07 15:42:38 +000042#define TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME, \
43 TFM_PARTITION_TYPE) \
44 __attribute__((section(TFM_PARTITION_NAME "_" TFM_PARTITION_TYPE "_ATTR_FN")))
Marc Moreno Berengue8e0fa7a2018-10-04 18:25:13 +010045
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010046/*!
47 * \def TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME)
48 *
49 * \brief This macro provides a mechanism to place data variables in the RW data
Edison Ai14dd1372019-07-11 18:02:18 +080050 * section of a specific secure partition at linker time.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010051 *
52 * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest
53 * file "name" field.
Raef Coles79d82082021-01-07 15:42:38 +000054 * \param[in] TFM_PARTITION_TYPE TF-M partition type assigned in the manifest
55 * file "type" field.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010056 */
Raef Coles79d82082021-01-07 15:42:38 +000057#define TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME, \
58 TFM_PARTITION_TYPE) \
59 __attribute__((section(TFM_PARTITION_NAME "_" TFM_PARTITION_TYPE "_ATTR_RW")))
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010060
61/*!
62 * \def TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME)
63 *
64 * \brief This macro provides a mechanism to place data variables in the ZI data
Edison Ai14dd1372019-07-11 18:02:18 +080065 * section of a specific secure partition at linker time.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010066 *
67 * \param[in] TFM_PARTITION_NAME TF-M partition name assigned in the manifest
68 * file "name" field.
Raef Coles79d82082021-01-07 15:42:38 +000069 * \param[in] TFM_PARTITION_TYPE TF-M partition type assigned in the manifest
70 * file "type" field.
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010071 */
Raef Coles79d82082021-01-07 15:42:38 +000072#define TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME, \
73 TFM_PARTITION_TYPE) \
74 __attribute__((section(TFM_PARTITION_NAME "_" TFM_PARTITION_TYPE "_ATTR_ZI")))
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010075#else
Raef Coles79d82082021-01-07 15:42:38 +000076#define TFM_LINK_SET_RO_IN_PARTITION_SECTION(TFM_PARTITION_NAME, TFM_PARTITION_TYPE)
77#define TFM_LINK_SET_RW_IN_PARTITION_SECTION(TFM_PARTITION_NAME, TFM_PARTITION_TYPE)
78#define TFM_LINK_SET_ZI_IN_PARTITION_SECTION(TFM_PARTITION_NAME, TFM_PARTITION_TYPE)
Mate Toth-Pal9aae21d2019-02-11 15:39:30 +010079#endif
Marc Moreno Berengueef202722018-08-10 13:43:43 +010080#endif /* __TFM_PLAT_DEFS_H__ */