David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 1 | /* |
Mingyang Sun | d44522a | 2020-01-16 16:48:37 +0800 | [diff] [blame^] | 2 | * Copyright (c) 2019-2020, Arm Limited. All rights reserved. |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #ifndef __TFM_PSA_CLIENT_CALL_H__ |
| 9 | #define __TFM_PSA_CLIENT_CALL_H__ |
| 10 | |
| 11 | #include <stdint.h> |
| 12 | #include "psa/client.h" |
| 13 | |
| 14 | /* Common handlers for PSA client calls */ |
| 15 | |
| 16 | /** |
| 17 | * \brief handler for \ref psa_framework_version. |
| 18 | * |
| 19 | * \return version The version of the PSA Framework implementation |
| 20 | * that is providing the runtime services. |
| 21 | */ |
Mingyang Sun | d44522a | 2020-01-16 16:48:37 +0800 | [diff] [blame^] | 22 | uint32_t tfm_spm_client_psa_framework_version(void); |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 23 | |
| 24 | /** |
| 25 | * \brief handler for \ref psa_version. |
| 26 | * |
| 27 | * \param[in] sid RoT Service identity. |
Summer Qin | 43c185d | 2019-10-10 15:44:42 +0800 | [diff] [blame] | 28 | * \param[in] ns_caller If 'true', call from non-secure client. |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 29 | * Otherwise from secure client. |
| 30 | * |
| 31 | * \retval PSA_VERSION_NONE The RoT Service is not implemented, or the |
| 32 | * caller is not permitted to access the service. |
Jaykumar Pitambarbhai Patel | 3a98602 | 2019-10-08 17:37:15 +0530 | [diff] [blame] | 33 | * \retval > 0 The version of the implemented RoT Service. |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 34 | */ |
Mingyang Sun | d44522a | 2020-01-16 16:48:37 +0800 | [diff] [blame^] | 35 | uint32_t tfm_spm_client_psa_version(uint32_t sid, bool ns_caller); |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 36 | |
| 37 | /** |
| 38 | * \brief handler for \ref psa_connect. |
| 39 | * |
| 40 | * \param[in] sid RoT Service identity. |
Jaykumar Pitambarbhai Patel | 3a98602 | 2019-10-08 17:37:15 +0530 | [diff] [blame] | 41 | * \param[in] version The version of the RoT Service. |
Summer Qin | 43c185d | 2019-10-10 15:44:42 +0800 | [diff] [blame] | 42 | * \param[in] ns_caller If 'true', call from non-secure client. |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 43 | * Otherwise from secure client. |
| 44 | * |
| 45 | * \retval PSA_SUCCESS Success. |
| 46 | * \retval PSA_ERROR_CONNECTION_REFUSED The SPM or RoT Service has refused the |
| 47 | * connection. |
| 48 | * \retval PSA_ERROR_CONNECTION_BUSY The SPM or RoT Service cannot make the |
| 49 | * connection at the moment. |
| 50 | * \retval "Does not return" The RoT Service ID and version are not |
| 51 | * supported, or the caller is not permitted to |
| 52 | * access the service. |
| 53 | */ |
Mingyang Sun | d44522a | 2020-01-16 16:48:37 +0800 | [diff] [blame^] | 54 | psa_status_t tfm_spm_client_psa_connect(uint32_t sid, uint32_t version, |
| 55 | bool ns_caller); |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * \brief handler for \ref psa_call. |
| 59 | * |
| 60 | * \param[in] handle Service handle to the established connection, |
| 61 | * \ref psa_handle_t |
| 62 | * \param[in] type The request type. |
| 63 | * Must be zero( \ref PSA_IPC_CALL) or positive. |
| 64 | * \param[in] inptr Array of input psa_invec structures. |
| 65 | * \ref psa_invec |
| 66 | * \param[in] in_num Number of input psa_invec structures. |
| 67 | * \ref psa_invec |
| 68 | * \param[in] outptr Array of output psa_outvec structures. |
| 69 | * \ref psa_outvec |
| 70 | * \param[in] out_num Number of outut psa_outvec structures. |
| 71 | * \ref psa_outvec |
Summer Qin | 43c185d | 2019-10-10 15:44:42 +0800 | [diff] [blame] | 72 | * \param[in] ns_caller If 'true', call from non-secure client. |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 73 | * Otherwise from secure client. |
| 74 | * \param[in] privileged Privileged mode or unprivileged mode: |
| 75 | * \ref TFM_PARTITION_UNPRIVILEGED_MODE |
| 76 | * \ref TFM_PARTITION_PRIVILEGED_MODE |
| 77 | * |
| 78 | * \retval PSA_SUCCESS Success. |
| 79 | * \retval "Does not return" The call is invalid, one or more of the |
| 80 | * following are true: |
| 81 | * \arg An invalid handle was passed. |
| 82 | * \arg The connection is already handling a request. |
| 83 | * \arg An invalid memory reference was provided. |
| 84 | * \arg in_num + out_num > PSA_MAX_IOVEC. |
| 85 | * \arg The message is unrecognized by the RoT |
| 86 | * Service or incorrectly formatted. |
| 87 | */ |
Mingyang Sun | d44522a | 2020-01-16 16:48:37 +0800 | [diff] [blame^] | 88 | psa_status_t tfm_spm_client_psa_call(psa_handle_t handle, int32_t type, |
| 89 | const psa_invec *inptr, size_t in_num, |
| 90 | psa_outvec *outptr, size_t out_num, |
| 91 | bool ns_caller, uint32_t privileged); |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 92 | |
| 93 | /** |
| 94 | * \brief handler for \ref psa_close. |
| 95 | * |
| 96 | * \param[in] handle Service handle to the connection to be closed, |
| 97 | * \ref psa_handle_t |
Summer Qin | 43c185d | 2019-10-10 15:44:42 +0800 | [diff] [blame] | 98 | * \param[in] ns_caller If 'true', call from non-secure client. |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 99 | * Otherwise from secure client. |
| 100 | * |
| 101 | * \retval void Success. |
| 102 | * \retval "Does not return" The call is invalid, one or more of the |
| 103 | * following are true: |
| 104 | * \arg An invalid handle was provided that is not |
| 105 | * the null handle. |
| 106 | * \arg The connection is handling a request. |
| 107 | */ |
Mingyang Sun | d44522a | 2020-01-16 16:48:37 +0800 | [diff] [blame^] | 108 | void tfm_spm_client_psa_close(psa_handle_t handle, bool ns_caller); |
David Hu | 733d8f9 | 2019-09-23 15:32:40 +0800 | [diff] [blame] | 109 | |
Jaykumar Pitambarbhai Patel | 3a98602 | 2019-10-08 17:37:15 +0530 | [diff] [blame] | 110 | #endif |