1 /* 2 * Copyright (c) 2023 Cypress Semiconductor Corporation (an Infineon company) 3 * or an affiliate of Cypress Semiconductor Corporation. All rights reserved. 4 * 5 * SPDX-License-Identifier: BSD-3-Clause 6 * 7 */ 8 9 #ifndef __AGENT_API_H__ 10 #define __AGENT_API_H__ 11 12 #include <stdint.h> 13 14 #include "config_impl.h" 15 #include "psa/client.h" 16 #include "psa/service.h" 17 18 struct client_params_t { 19 int32_t ns_client_id_stateless; 20 psa_invec *p_invecs; 21 psa_outvec *p_outvecs; 22 }; 23 24 /** 25 * \brief Specific psa_call() variants for agents 26 * 27 * \param[in] handle Handle to the service being accessed. 28 * \param[in] control A composited uint32_t value for controlling purpose, 29 * containing call types, numbers of in/out vectors and 30 * attributes of vectors. 31 * \param[in] params Combines the psa_invec and psa_outvec params 32 * for the psa_call() to be made, as well as 33 * NS agent's client identifier, which is ignored 34 * for connection-based services. 35 * \param[in] client_data_stateless Client data, treated as opaque by SPM. 36 * 37 * \retval PSA_SUCCESS Success. 38 * \retval "Does not return" The call is invalid, one or more of the 39 * following are true: 40 * \arg An invalid handle was passed. 41 * \arg The connection is already handling a request. 42 * \arg An invalid memory reference was provided. 43 * \arg in_num + out_num > PSA_MAX_IOVEC. 44 * \arg The message is unrecognized by the RoT 45 * Service or incorrectly formatted. 46 */ 47 psa_status_t agent_psa_call(psa_handle_t handle, uint32_t control, 48 const struct client_params_t *params, 49 const void *client_data_stateless); 50 51 #if CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1 52 53 /** 54 * \brief psa_connect() interface for NS agents 55 * 56 * \param[in] sid RoT Service identity. 57 * \param[in] version The version of the RoT Service. 58 * \param[in] ns_client_id Agent representing NS client's identifier. 59 * \param[in] client_data Client data, treated as opaque by SPM. 60 * 61 * \retval PSA_SUCCESS Success. 62 * \retval PSA_ERROR_CONNECTION_REFUSED The SPM or RoT Service has refused the 63 * connection. 64 * \retval PSA_ERROR_CONNECTION_BUSY The SPM or RoT Service cannot make the 65 * connection at the moment. 66 * \retval "Does not return" The RoT Service ID and version are not 67 * supported, or the caller is not 68 * permitted to access the service. 69 */ 70 psa_handle_t agent_psa_connect(uint32_t sid, uint32_t version, 71 int32_t ns_client_id, const void *client_data); 72 73 #else /* CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1 */ 74 #define agent_psa_connect NULL 75 #endif /* CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1 */ 76 77 #endif /* __AGENT_API_H__ */ 78