|
25 | 25 | #include <stddef.h>
|
26 | 26 | #include "psa/error.h"
|
27 | 27 |
|
| 28 | +#ifdef __cplusplus |
| 29 | +extern "C" { |
| 30 | +#endif |
| 31 | + |
28 | 32 | #if !defined(UINT32_MAX)
|
29 | 33 | #define UINT32_MAX ((uint32_t)-1)
|
30 | 34 | #endif
|
@@ -53,5 +57,99 @@ typedef struct psa_outvec {
|
53 | 57 | size_t len; /**< Length in bytes of the buffer.*/
|
54 | 58 | } psa_outvec;
|
55 | 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 | + |
56 | 154 | #endif // __MBED_OS_DEFAULT_PSA_CLIENT_API_H__
|
57 | 155 | #endif
|
0 commit comments