Mistake on this page?
Report an issue in GitHub or email us
psa_client.h
1 /*
2  * Copyright (c) 2018-2019, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef __PSA_CLIENT_H__
9 #define __PSA_CLIENT_H__
10 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 #include <stdint.h>
16 #include <stddef.h>
17 
18 /*********************** PSA Client Macros and Types *************************/
19 
20 #define PSA_FRAMEWORK_VERSION (0x0100)
21 
22 #define PSA_VERSION_NONE (0)
23 
24 /* PSA response types */
25 #define PSA_SUCCESS (0)
26 #define PSA_CONNECTION_REFUSED (INT32_MIN + 1)
27 #define PSA_CONNECTION_BUSY (INT32_MIN + 2)
28 #define PSA_DROP_CONNECTION (INT32_MIN)
29 
30 /* PSA message handles */
31 #define PSA_NULL_HANDLE ((psa_handle_t)0)
32 
33 typedef int32_t psa_status_t;
34 typedef int32_t psa_handle_t;
35 
36 /**
37  * A read-only input memory region provided to an RoT Service.
38  */
39 typedef struct psa_invec {
40  const void *base; /*!< the start address of the memory buffer */
41  size_t len; /*!< the size in bytes */
42 } psa_invec;
43 
44 /**
45  * A writable output memory region provided to an RoT Service.
46  */
47 typedef struct psa_outvec {
48  void *base; /*!< the start address of the memory buffer */
49  size_t len; /*!< the size in bytes */
50 } psa_outvec;
51 
52 /*************************** PSA Client API **********************************/
53 
54 /**
55  * \brief Retrieve the version of the PSA Framework API that is implemented.
56  *
57  * \return version The version of the PSA Framework implementation
58  * that is providing the runtime services to the
59  * caller. The major and minor version are encoded
60  * as follows:
61  * \arg version[15:8] -- major version number.
62  * \arg version[7:0] -- minor version number.
63  */
64 uint32_t psa_framework_version(void);
65 
66 /**
67  * \brief Retrieve the minor version of an RoT Service or indicate that it is
68  * not present on this system.
69  *
70  * \param[in] sid ID of the RoT Service to query.
71  *
72  * \retval PSA_VERSION_NONE The RoT Service is not implemented, or the
73  * caller is not permitted to access the service.
74  * \retval > 0 The minor version of the implemented RoT
75  * Service.
76  */
77 uint32_t psa_version(uint32_t sid);
78 
79 /**
80  * \brief Connect to an RoT Service by its SID.
81  *
82  * \param[in] sid ID of the RoT Service to connect to.
83  * \param[in] minor_version Requested version of the RoT Service.
84  *
85  * \retval > 0 A handle for the connection.
86  * \retval PSA_CONNECTION_REFUSED The SPM or RoT Service has refused the
87  * connection.
88  * \retval PSA_CONNECTION_BUSY The SPM or RoT Service cannot make the
89  * connection at the moment.
90  * \retval "Does not return" The RoT Service ID and version are not
91  * supported, or the caller is not permitted to
92  * access the service.
93  */
94 psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version);
95 
96 /**
97  * \brief Call an RoT Service on an established connection.
98  *
99  * \param[in] handle A handle to an established connection.
100  * \param[in] in_vec Array of input \ref psa_invec structures.
101  * \param[in] in_len Number of input \ref psa_invec structures.
102  * \param[in/out] out_vec Array of output \ref psa_outvec structures.
103  * \param[in] out_len Number of output \ref psa_outvec structures.
104  *
105  * \retval >=0 RoT Service-specific status value.
106  * \retval <0 RoT Service-specific error code.
107  * \retval PSA_DROP_CONNECTION The connection has been dropped by the RoT
108  * Service. This indicates that either this or
109  * a previous message was invalid.
110  * \retval "Does not return" The call is invalid, one or more of the
111  * following are true:
112  * \arg An invalid handle was passed.
113  * \arg The connection is already handling a request.
114  * \arg An invalid memory reference was provided.
115  * \arg in_len + out_len > PSA_MAX_IOVEC.
116  * \arg The message is unrecognized by the RoT
117  * Service or incorrectly formatted.
118  */
119 psa_status_t psa_call(psa_handle_t handle,
120  const psa_invec *in_vec,
121  size_t in_len,
122  psa_outvec *out_vec,
123  size_t out_len);
124 
125 /**
126  * \brief Close a connection to an RoT Service.
127  *
128  * \param[in] handle A handle to an established connection, or the
129  * null handle.
130  *
131  * \retval void Success.
132  * \retval "Does not return" The call is invalid, one or more of the
133  * following are true:
134  * \arg An invalid handle was provided that is not
135  * the null handle.
136  * \arg The connection is handling a request.
137  */
138 void psa_close(psa_handle_t handle);
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* __PSA_CLIENT_H__ */
uint32_t psa_framework_version(void)
Retrieve the version of the PSA Framework API that is implemented.
psa_status_t psa_call(psa_handle_t handle, const psa_invec *in_vec, size_t in_len, const psa_outvec *out_vec, size_t out_len)
Call a connected Root of Trust Service.
size_t len
Length in bytes of the buffer.
Definition: client.h:50
struct psa_outvec psa_outvec
Structure which describes a scatter-gather output buffer.
const void * base
Starting address of the buffer.
Definition: client.h:49
psa_handle_t psa_connect(uint32_t sid, uint32_t minor_version)
Connect to a Root of Trust Service by its SID.
Structure which describes a scatter-gather output buffer.
Definition: client.h:54
Structure that describes a scatter-gather input buffer.
Definition: client.h:48
void psa_close(psa_handle_t handle)
Close a connection to a Root of Trust Service.
struct psa_invec psa_invec
Structure that describes a scatter-gather input buffer.
uint32_t psa_version(uint32_t sid)
Retrieve the minor version of a Root of Trust Service by its SID.
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.