Mistake on this page?
Report an issue in GitHub or email us
TARGET_MBED_PSA_SRV/inc/psa/client.h
1 /* Copyright (c) 2017-2020 ARM Limited
2  *
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #if defined(FEATURE_TFM)
19 #include "interface/include/psa_client.h"
20 #else
21 
22 #ifndef __MBED_OS_DEFAULT_PSA_CLIENT_API_H__
23 #define __MBED_OS_DEFAULT_PSA_CLIENT_API_H__
24 
25 #include <stddef.h>
26 #include "psa/error.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #if !defined(UINT32_MAX)
33 #define UINT32_MAX ((uint32_t)-1)
34 #endif
35 
36 #if !defined(INT32_MIN)
37 #define INT32_MIN (-0x7fffffff - 1)
38 #endif
39 
40 #define PSA_FRAMEWORK_VERSION (0x0100) /**< Version of the PSA Framework API. */
41 #define PSA_VERSION_NONE (0L) /**< Identifier for an unimplemented Root of Trust (RoT) Service. */
42 #define PSA_CONNECTION_REFUSED (INT32_MIN + 1) /**< The return value from psa_connect() if the RoT Service or SPM was unable to establish a connection.*/
43 #define PSA_CONNECTION_BUSY (INT32_MIN + 2) /**< The return value from psa_connect() if the RoT Service rejects the connection for a transient reason.*/
44 #define PSA_DROP_CONNECTION (INT32_MIN) /**< The result code in a call to psa_reply() to indicate a nonrecoverable error in the client.*/
45 #define PSA_NULL_HANDLE ((psa_handle_t)0) /**< Denotes an invalid handle.*/
46 
47 typedef int32_t psa_handle_t;
48 
49 typedef struct psa_invec {
50  const void *base; /**< Starting address of the buffer.*/
51  size_t len; /**< Length in bytes of the buffer.*/
52 } psa_invec;
53 
54 
55 typedef struct psa_outvec {
56  void *base; /**< Starting address of the buffer.*/
57  size_t len; /**< Length in bytes of the buffer.*/
58 } psa_outvec;
59 
60 /**
61  * \brief Retrieve the version of the PSA Framework API that is implemented.
62  *
63  * \return version The version of the PSA Framework implementation
64  * that is providing the runtime services to the
65  * caller. The major and minor version are encoded
66  * as follows:
67  * \arg version[15:8] -- major version number.
68  * \arg version[7:0] -- minor version number.
69  */
70 uint32_t psa_framework_version(void);
71 
72 /**
73  * \brief Retrieve the version of an RoT Service or indicate that it is not
74  * present on this system.
75  *
76  * \param[in] sid ID of the RoT Service to query.
77  *
78  * \retval PSA_VERSION_NONE The RoT Service is not implemented, or the
79  * caller is not permitted to access the service.
80  * \retval > 0 The version of the implemented RoT Service.
81  */
82 uint32_t psa_version(uint32_t sid);
83 
84 /**
85  * \brief Connect to an RoT Service by its SID.
86  *
87  * \param[in] sid ID of the RoT Service to connect to.
88  * \param[in] version Requested version of the RoT Service.
89  *
90  * \retval > 0 A handle for the connection.
91  * \retval PSA_ERROR_CONNECTION_REFUSED The SPM or RoT Service has refused the
92  * connection.
93  * \retval PSA_ERROR_CONNECTION_BUSY The SPM or RoT Service cannot make the
94  * connection at the moment.
95  * \retval "PROGRAMMER ERROR" The call is a PROGRAMMER ERROR if one or more
96  * of the following are true:
97  * \arg The RoT Service ID is not present.
98  * \arg The RoT Service version is not supported.
99  * \arg The caller is not allowed to access the RoT
100  * service.
101  */
102 psa_handle_t psa_connect(uint32_t sid, uint32_t version);
103 
104 /**
105  * \brief Call an RoT Service on an established connection.
106  *
107  * \param[in] handle A handle to an established connection.
108  * \param[in] type The reuqest type.
109  * Must be zero( \ref PSA_IPC_CALL) or positive.
110  * \param[in] in_vec Array of input \ref psa_invec structures.
111  * \param[in] in_len Number of input \ref psa_invec structures.
112  * \param[in/out] out_vec Array of output \ref psa_outvec structures.
113  * \param[in] out_len Number of output \ref psa_outvec structures.
114  *
115  * \retval >=0 RoT Service-specific status value.
116  * \retval <0 RoT Service-specific error code.
117  * \retval PSA_ERROR_PROGRAMMER_ERROR The connection has been terminated by the
118  * RoT Service. The call is a PROGRAMMER ERROR if
119  * one or more of the following are true:
120  * \arg An invalid handle was passed.
121  * \arg The connection is already handling a request.
122  * \arg type < 0.
123  * \arg An invalid memory reference was provided.
124  * \arg in_len + out_len > PSA_MAX_IOVEC.
125  * \arg The message is unrecognized by the RoT
126  * Service or incorrectly formatted.
127  */
128 psa_status_t psa_call(psa_handle_t handle, int32_t type,
129  const psa_invec *in_vec,
130  size_t in_len,
131  psa_outvec *out_vec,
132  size_t out_len);
133 
134 /**
135  * \brief Close a connection to an RoT Service.
136  *
137  * \param[in] handle A handle to an established connection, or the
138  * null handle.
139  *
140  * \retval void Success.
141  * \retval "PROGRAMMER ERROR" The call is a PROGRAMMER ERROR if one or more
142  * of the following are true:
143  * \arg An invalid handle was provided that is not
144  * the null handle.
145  * \arg The connection is currently handling a
146  * request.
147  */
148 void psa_close(psa_handle_t handle);
149 
150 #ifdef __cplusplus
151 }
152 #endif
153 
154 #endif // __MBED_OS_DEFAULT_PSA_CLIENT_API_H__
155 #endif
size_t len
Length in bytes of the buffer.
void * base
Starting address of the buffer.
const void * base
Starting address of the buffer.
A writable output memory region provided to an RoT Service.
A read-only input memory region provided to an RoT Service.
size_t len
Length in bytes of the buffer.
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.