blob: e97ccbee980219d8f001fdeb12af6662d5dd25c7 [file] [log] [blame]
Marc Moreno Berengue51af9512018-06-14 18:28:14 +01001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
8#ifndef __TFM_SST_ASSET_MACROS_H__
9#define __TFM_SST_ASSET_MACROS_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include "tfm_sst_asset_defs.h"
16
17/*!
18 * \def TFM_SST_ASSET_IS_ASSET_CAT(sst_def_cat_type, type)
19 *
20 * \brief Macro to check if the asset category type (type) is equal to the
21 * TF-M SST asset defined category types (sst_def_cat_type).
22 *
23 * \param[in] sst_def_cat_type TF-M SST asset defined category type
24 * \param[in] type Asset type
25 *
26 * \return Returns 1 if the asset type is equal to the TF-M SST asset defined
27 * type. Otherwise, it returns 0.
28 */
29#define TFM_SST_ASSET_IS_ASSET_CAT(sst_def_cat_type, type) \
30 (((type & TFM_SST_ASSET_CAT_VENDOR_DEFINED) != 0) && \
31 ((type & TFM_SST_ASSET_CAT_TYPE_MASK) == sst_def_cat_type))
32
33/*!
34 * \def TFM_SST_ASSET_IS_ASSET_TYPE(sst_def_type, type)
35 *
36 * \brief Macro to check if the asset type (type) is equal to the
37 * TF-M SST asset defined type (sst_def_type).
38 *
39 * \param[in] sst_def_type TF-M SST asset defined type
40 * \param[in] type Asset type
41 *
42 * \return Returns 1 if the asset type is equal to the TF-M SST asset defined
43 * type. Otherwise, it returns 0.
44 */
45#define TFM_SST_ASSET_IS_ASSET_TYPE(sst_def_type, type) \
46 (((type & TFM_SST_ASSET_CAT_VENDOR_DEFINED) != 0) && \
47 (type == sst_def_type))
48
49/*!
50 * \def TFM_SST_ASSET_IS_VENDOR_DEFINED(type)
51 *
52 * \brief Macro to check if the asset type is vendor defined.
53 *
54 * \param[in] type Asset type
55 *
56 * \return Returns 1 if the asset type is equal to TFM_SST_ASSET_VENDOR_DEFINED.
57 * Otherwise, it returns 0.
58 */
59#define TFM_SST_ASSET_IS_VENDOR_DEFINED(type) \
60 ((type & TFM_SST_ASSET_VENDOR_DEFINED) != 0)
61
62/*!
63 * \def TFM_SST_ASSET_IS_KEY_TYPE(type)
64 *
65 * \brief Macro to check if the asset type is a key.
66 *
67 * \param[in] type Asset type
68 *
69 * \return Returns 1 if it is a key. Otherwise, it returns 0.
70 */
71#define TFM_SST_ASSET_IS_KEY_TYPE(type) \
72 ((type & TFM_SST_ASSET_KEY_MASK) != 0)
73
74/*!
75 * \def TFM_SST_ASSET_IS_ASYMMETRIC_KEY_TYPE(type)
76 *
77 * \brief Macro to check if the asset type is a symmetric key.
78 *
79 * \param[in] type Asset type
80 *
81 * \return Returns 1 if it is an asymmetric key. Otherwise, it returns 0.
82 */
83#define TFM_SST_ASSET_IS_ASYMMETRIC_KEY_TYPE(type) \
84 ((type & TFM_SST_ASSET_KEY_ASYMMETRIC_MASK) != 0)
85
86/*!
87 * \def TFM_SST_ASSET_HAS_ATTR(sst_def_asset_attr, attrs)
88 *
89 * \brief Macro to check if the asset attributes (attrs) have a specific TF-M
90 * SST asset defined bit attribute (sst_def_asset_attr).
91 *
92 * \param[in] sst_def_type TF-M SST asset defined bit attribute
93 * \param[in] attrs Asset attributes
94 *
95 * \return Returns 1 if the asset has the TF-M SST asset defined
96 * attribute. Otherwise, it returns 0.
97 */
98#define TFM_SST_ASSET_HAS_ATTR(sst_def_asset_attr, attrs) \
99 (((attrs & sst_def_asset_attr) != 0) && \
100 ((attrs & TFM_SST_ASSET_ATTR_VENDOR_DEFINED) == 0))
101
102/*!
103 * \def TFM_SST_ASSET_HAS_ATTR_VENDOR_DEFINED(attrs)
104 *
105 * \brief Macro to check if the asset attributes are vendor defined.
106 *
107 * \param[in] attrs Asset attributes
108 *
109 * \return Returns 1 if the asset type is equal to TFM_SST_ASSET_VENDOR_DEFINED.
110 * Otherwise, it returns 0.
111 */
112#define TFM_SST_ASSET_HAS_ATTR_VENDOR_DEFINED(attrs) \
113 ((attrs & TFM_SST_ASSET_ATTR_VENDOR_DEFINED) != 0)
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif /* __TFM_SST_ASSET_MACROS_H__ */