Mistake on this page?
Report an issue in GitHub or email us
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  * \return Returns 1 if the client Id is secure. Otherwise, returns 0.
26  */
27 #define TFM_CLIENT_ID_IS_S(client_id) ((client_id)>0)
28 
29 /**
30  * \brief Checks if the provided client ID is a non-secure client ID.
31  *
32  * \param[in] client_id Client ID to check
33  *
34  * \return Returns 1 if the client Id is non-secure. Otherwise, returns 0.
35  */
36 #define TFM_CLIENT_ID_IS_NS(client_id) ((client_id)<0)
37 
38 /* Maximum number of input and output vectors */
39 #define PSA_MAX_IOVEC (4)
40 
41 /* FixMe: sort out DEBUG compile option and limit return value options
42  * on external interfaces */
43 /* For secure functions using prorietary signatures
44  * TFM will only return values recognized and parsed by TFM core.
45  * Service return codes are not automatically passed on to REE.
46  * Any non-zero return value is interpreted as an error that may trigger
47  * TEE error handling flow.
48  * For secure functions using the veneers in secure_fw/ns_callable/tfm_veneers.c
49  * (iovec API) this limitation does not apply.
50  */
51 enum tfm_status_e
52 {
53  TFM_SUCCESS = 0,
54  TFM_PARTITION_BUSY,
55  TFM_ERROR_SECURE_DOMAIN_LOCKED,
56  TFM_ERROR_INVALID_PARAMETER,
57  TFM_ERROR_PARTITION_NON_REENTRANT,
58  TFM_ERROR_NS_THREAD_MODE_CALL,
59  TFM_ERROR_NOT_INITIALIZED,
60  TFM_ERROR_NO_ACTIVE_PARTITION,
61  TFM_ERROR_INVALID_EXC_MODE,
62  TFM_SECURE_LOCK_FAILED,
63  TFM_SECURE_UNLOCK_FAILED,
64  TFM_ERROR_GENERIC = 0x1F,
65  TFM_PARTITION_SPECIFIC_ERROR_MIN,
66 };
67 
68 //==================== Secure function declarations ==========================//
69 
70 /**
71  * \brief Assign client ID to the current TZ context
72  *
73  * \param[in] ns_client_id The client ID to be assigned to the current
74  * context
75  * \return TFM_SUCCESS if the client ID assigned successfully, an error code
76  * according to \ref tfm_status_e in case of error.
77  *
78  * \note This function have to be called from handler mode.
79  */
80 enum tfm_status_e tfm_register_client_id (int32_t ns_client_id);
81 
82 /**
83  * \brief Retrieve the version of the PSA Framework API that is implemented
84  *
85  * \return The version of the PSA Framework
86  */
87 uint32_t tfm_psa_framework_version_veneer(void);
88 
89 /**
90  * \brief Return version of secure function provided by secure binary
91  *
92  * \param[in] sid ID of secure service
93  *
94  * \return Version number of secure function
95  */
96 uint32_t tfm_psa_version_veneer(uint32_t sid);
97 
98 /**
99  * \brief Connect to secure function
100  *
101  * \param[in] sid ID of secure service
102  * \param[in] minor_version Minor version of SF requested by client
103  *
104  * \return Returns handle to connection
105  */
106 psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t minor_version);
107 
108 /**
109  * \brief Call a secure function referenced by a connection handle
110  *
111  * \param[in] handle Handle to connection
112  * \param[in] in_vecs invec containing pointer/count of input vectors
113  * \param[in] out_vecs outvec containing pointer/count of output vectors
114  *
115  * \return Returns \ref psa_status_t status code
116  */
117 psa_status_t tfm_psa_call_veneer(psa_handle_t handle,
118  const psa_invec *in_vecs,
119  psa_outvec *out_vecs);
120 
121 /**
122  * \brief Close connection to secure function referenced by a connection handle
123  *
124  * \param[in] handle Handle to connection
125  *
126  * \return Returns \ref psa_status_t status code
127  */
128 psa_status_t tfm_psa_close_veneer(psa_handle_t handle);
129 
130 //================ End Secure function declarations ==========================//
131 
132 #ifdef __cplusplus
133 }
134 #endif
135 
136 #endif /* __TFM_API_H__ */
Structure which describes a scatter-gather output buffer.
Definition: client.h:54
Structure that describes a scatter-gather input buffer.
Definition: client.h:48
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.