Mistake on this page?
Report an issue in GitHub or email us
TARGET_TFM_V1_0/include/tfm_api.h
1 /*
2  * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __TFM_API_H__
9 #define __TFM_API_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 #include "psa/client.h"
17 
18 #define TFM_INVALID_CLIENT_ID 0
19 
20 /**
21  * \brief Checks if the provided client ID is a secure client ID.
22  *
23  * \param[in] client_id Client ID to check.
24  *
25  * \retval 1 Client ID is secure.
26  * \retval 0 Client ID is non-secure.
27  */
28 #define TFM_CLIENT_ID_IS_S(client_id) ((client_id)>0)
29 
30 /**
31  * \brief Checks if the provided client ID is a non-secure client ID.
32  *
33  * \param[in] client_id Client ID to check.
34  *
35  * \retval 1 Client ID is non-secure.
36  * \retval 0 Client ID is secure.
37  */
38 #define TFM_CLIENT_ID_IS_NS(client_id) ((client_id)<0)
39 
40 /* The mask used for timeout values */
41 #define PSA_TIMEOUT_MASK PSA_BLOCK
42 
43 /* FixMe: sort out DEBUG compile option and limit return value options
44  * on external interfaces */
45 enum tfm_status_e
46 {
47  TFM_SUCCESS = 0,
48  TFM_PARTITION_BUSY,
49  TFM_ERROR_SECURE_DOMAIN_LOCKED,
50  TFM_ERROR_INVALID_PARAMETER,
51  TFM_ERROR_PARTITION_NON_REENTRANT,
52  TFM_ERROR_NS_THREAD_MODE_CALL,
53  TFM_ERROR_NOT_INITIALIZED,
54  TFM_ERROR_NO_ACTIVE_PARTITION,
55  TFM_ERROR_INVALID_EXC_MODE,
56  TFM_SECURE_LOCK_FAILED,
57  TFM_SECURE_UNLOCK_FAILED,
58  TFM_ERROR_GENERIC = 0x1F,
59 };
60 
61 /*
62  * Structure to package type, in_len and out_len, it is mainly used for
63  * psa_call.
64  */
66  int32_t type;
67  size_t in_len;
68  size_t out_len;
69 };
70 
71 /********************* Secure function declarations ***************************/
72 
73 /**
74  * \brief Assign client ID to the current TZ context.
75  *
76  * \param[in] ns_client_id The client ID to be assigned to the current
77  * context.
78  * \retval TFM_SUCCESS The client ID assigned successfully.
79  * \retval error code The client ID assignment failed, an error code
80  * returned according to \ref tfm_status_e.
81  * \note This function have to be called from handler mode.
82  */
83 enum tfm_status_e tfm_register_client_id (int32_t ns_client_id);
84 
85 /**
86  * \brief Retrieve the version of the PSA Framework API that is implemented.
87  *
88  * \return The version of the PSA Framework.
89  */
90 uint32_t tfm_psa_framework_version_veneer(void);
91 
92 /**
93  * \brief Return version of secure function provided by secure binary.
94  *
95  * \param[in] sid ID of secure service.
96  *
97  * \return Version number of secure function.
98  */
99 uint32_t tfm_psa_version_veneer(uint32_t sid);
100 
101 /**
102  * \brief Connect to secure function.
103  *
104  * \param[in] sid ID of secure service.
105  * \param[in] version Version of SF requested by client.
106  *
107  * \return Returns handle to connection.
108  */
109 psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t version);
110 
111 /**
112  * \brief Call a secure function referenced by a connection handle.
113  *
114  * \param[in] handle Handle to connection.
115  * \param[in] ctrl_param Parameter structure, includes reuqest type,
116  * in_num and out_num.
117  * \param[in] in_vec Array of input \ref psa_invec structures.
118  * \param[in/out] out_vec Array of output \ref psa_outvec structures.
119  *
120  * \return Returns \ref psa_status_t status code.
121  */
122 psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
123  const struct tfm_control_parameter_t *ctrl_param,
124  const psa_invec *in_vec,
125  psa_outvec *out_vec);
126 
127 /**
128  * \brief Close connection to secure function referenced by a connection handle.
129  *
130  * \param[in] handle Handle to connection
131  *
132  * \return void
133  */
134 void tfm_psa_close_veneer(psa_handle_t handle);
135 
136 /***************** End Secure function declarations ***************************/
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* __TFM_API_H__ */
A writable output memory region provided to an RoT Service.
A read-only input memory region provided to an RoT Service.
int32_t psa_status_t
Function return status.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.