blob: 5146e76fc662cdc119a602e9733ba77c1f30f34b [file] [log] [blame]
David Hu733d8f92019-09-23 15:32:40 +08001/*
Mingyang Sund44522a2020-01-16 16:48:37 +08002 * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
David Hu733d8f92019-09-23 15:32:40 +08003 *
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 Sund44522a2020-01-16 16:48:37 +080022uint32_t tfm_spm_client_psa_framework_version(void);
David Hu733d8f92019-09-23 15:32:40 +080023
24/**
25 * \brief handler for \ref psa_version.
26 *
27 * \param[in] sid RoT Service identity.
Summer Qin43c185d2019-10-10 15:44:42 +080028 * \param[in] ns_caller If 'true', call from non-secure client.
David Hu733d8f92019-09-23 15:32:40 +080029 * 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 Patel3a986022019-10-08 17:37:15 +053033 * \retval > 0 The version of the implemented RoT Service.
David Hu733d8f92019-09-23 15:32:40 +080034 */
Mingyang Sund44522a2020-01-16 16:48:37 +080035uint32_t tfm_spm_client_psa_version(uint32_t sid, bool ns_caller);
David Hu733d8f92019-09-23 15:32:40 +080036
37/**
38 * \brief handler for \ref psa_connect.
39 *
40 * \param[in] sid RoT Service identity.
Jaykumar Pitambarbhai Patel3a986022019-10-08 17:37:15 +053041 * \param[in] version The version of the RoT Service.
Summer Qin43c185d2019-10-10 15:44:42 +080042 * \param[in] ns_caller If 'true', call from non-secure client.
David Hu733d8f92019-09-23 15:32:40 +080043 * 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 Sund44522a2020-01-16 16:48:37 +080054psa_status_t tfm_spm_client_psa_connect(uint32_t sid, uint32_t version,
55 bool ns_caller);
David Hu733d8f92019-09-23 15:32:40 +080056
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 Qin43c185d2019-10-10 15:44:42 +080072 * \param[in] ns_caller If 'true', call from non-secure client.
David Hu733d8f92019-09-23 15:32:40 +080073 * 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 Sund44522a2020-01-16 16:48:37 +080088psa_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 Hu733d8f92019-09-23 15:32:40 +080092
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 Qin43c185d2019-10-10 15:44:42 +080098 * \param[in] ns_caller If 'true', call from non-secure client.
David Hu733d8f92019-09-23 15:32:40 +080099 * 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 Sund44522a2020-01-16 16:48:37 +0800108void tfm_spm_client_psa_close(psa_handle_t handle, bool ns_caller);
David Hu733d8f92019-09-23 15:32:40 +0800109
Jaykumar Pitambarbhai Patel3a986022019-10-08 17:37:15 +0530110#endif