blob: a6b79a4cd2d51a257e16f56ad7e30afdcad89a1d [file] [log] [blame]
Miklos Balint87da2512018-04-19 13:45:50 +02001/*
Nicola Mazzucato6414e292025-05-09 22:05:05 +01002 * SPDX-FileCopyrightText: Copyright The TrustedFirmware-M Contributors
Miklos Balint87da2512018-04-19 13:45:50 +02003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Nicola Mazzucato6414e292025-05-09 22:05:05 +01008#ifdef TFM_HYBRID_PLATFORM_API_BROKER
9#include "psa/api_broker.h"
10#endif
Jamie Foxcc31d402019-01-28 17:13:52 +000011#include "psa/client.h"
Antonio de Angelis05b24192019-07-04 15:28:46 +010012#include "tfm_ns_interface.h"
Ken Liu82e3eac2021-10-14 16:19:13 +080013#include "tfm_psa_call_pack.h"
Miklos Balint87da2512018-04-19 13:45:50 +020014
Nicola Mazzucato6414e292025-05-09 22:05:05 +010015/*
16 **** API functions for TrustZone Interface ****
17 *
18 * Thir names are resolved in the api_broker header file.
19 *
20 * The client always calls the APIs with the standard names.
21 */
Miklos Balint87da2512018-04-19 13:45:50 +020022
Nicola Mazzucato6414e292025-05-09 22:05:05 +010023uint32_t PSA_FRAMEWORK_VERSION_TZ(void)
Edison Aib3e56962018-09-04 19:12:31 +080024{
Antonio de Angelis05b24192019-07-04 15:28:46 +010025 return tfm_ns_interface_dispatch(
26 (veneer_fn)tfm_psa_framework_version_veneer,
Edison Aib3e56962018-09-04 19:12:31 +080027 0,
28 0,
29 0,
30 0);
31}
32
Nicola Mazzucato6414e292025-05-09 22:05:05 +010033uint32_t PSA_VERSION_TZ(uint32_t sid)
Miklos Balint87da2512018-04-19 13:45:50 +020034{
Antonio de Angelis05b24192019-07-04 15:28:46 +010035 return tfm_ns_interface_dispatch(
36 (veneer_fn)tfm_psa_version_veneer,
Miklos Balint87da2512018-04-19 13:45:50 +020037 sid,
38 0,
39 0,
40 0);
41}
42
Nicola Mazzucato6414e292025-05-09 22:05:05 +010043psa_status_t PSA_CALL_TZ(psa_handle_t handle, int32_t type,
Edison Aib3e56962018-09-04 19:12:31 +080044 const psa_invec *in_vec,
45 size_t in_len,
46 psa_outvec *out_vec,
47 size_t out_len)
Miklos Balint87da2512018-04-19 13:45:50 +020048{
Ken Liu40b09ba2023-08-10 10:01:40 +080049 if ((type > PSA_CALL_TYPE_MAX) ||
50 (type < PSA_CALL_TYPE_MIN) ||
51 (in_len > PSA_MAX_IOVEC) ||
52 (out_len > PSA_MAX_IOVEC)) {
Shawn Shan9c7b9be2021-05-17 15:28:02 +080053 return PSA_ERROR_PROGRAMMER_ERROR;
Xinyu Zhang99b069f2021-04-09 14:36:42 +080054 }
Edison Aib3e56962018-09-04 19:12:31 +080055
Antonio de Angelis05b24192019-07-04 15:28:46 +010056 return tfm_ns_interface_dispatch(
57 (veneer_fn)tfm_psa_call_veneer,
Miklos Balint87da2512018-04-19 13:45:50 +020058 (uint32_t)handle,
Xinyu Zhang99b069f2021-04-09 14:36:42 +080059 PARAM_PACK(type, in_len, out_len),
Summer Qin83ac1ca2019-09-29 18:33:28 +080060 (uint32_t)in_vec,
61 (uint32_t)out_vec);
Miklos Balint87da2512018-04-19 13:45:50 +020062}
David Hu1439fdc2023-02-15 14:16:58 +080063
Nicola Mazzucato6414e292025-05-09 22:05:05 +010064psa_handle_t PSA_CONNECT_TZ(uint32_t sid, uint32_t version)
David Hu1439fdc2023-02-15 14:16:58 +080065{
66 return tfm_ns_interface_dispatch((veneer_fn)tfm_psa_connect_veneer, sid, version, 0, 0);
67}
68
Nicola Mazzucato6414e292025-05-09 22:05:05 +010069void PSA_CLOSE_TZ(psa_handle_t handle)
David Hu1439fdc2023-02-15 14:16:58 +080070{
71 (void)tfm_ns_interface_dispatch((veneer_fn)tfm_psa_close_veneer, (uint32_t)handle, 0, 0, 0);
72}