Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2023, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | #include <stddef.h> |
| 9 | #include "psa/client.h" |
Kevin Peng | 0eca5ea | 2023-07-21 17:32:31 +0800 | [diff] [blame] | 10 | #include "tfm_erpc.h" |
Summer Qin | 153f3df | 2022-11-17 15:51:02 +0800 | [diff] [blame] | 11 | |
| 12 | psa_status_t erpc_psa_call(psa_handle_t handle, int32_t t, |
| 13 | const list_binary_1_t *erpc_in_vec, |
| 14 | list_binary_1_t *erpc_out_vec) |
| 15 | { |
| 16 | psa_status_t status; |
| 17 | psa_invec in_vec[PSA_MAX_IOVEC]; |
| 18 | psa_outvec out_vec[PSA_MAX_IOVEC]; |
| 19 | size_t i; |
| 20 | size_t in_len = erpc_in_vec->elementsCount; |
| 21 | size_t out_len = erpc_out_vec->elementsCount; |
| 22 | |
| 23 | /* Copy RPC iovecs into PSA iovecs */ |
| 24 | for (i = 0; i < in_len; ++i) { |
| 25 | in_vec[i] = (psa_invec){erpc_in_vec->elements[i].data, |
| 26 | erpc_in_vec->elements[i].dataLength}; |
| 27 | } |
| 28 | |
| 29 | for (i = 0; i < out_len; ++i) { |
| 30 | out_vec[i] = (psa_outvec){erpc_out_vec->elements[i].data, |
| 31 | erpc_out_vec->elements[i].dataLength}; |
| 32 | } |
| 33 | |
| 34 | status = psa_call(handle, t, in_vec, in_len, out_vec, out_len); |
| 35 | |
| 36 | /* Copy updated PSA outvec lens into RPC outvecs */ |
| 37 | for (i = 0; i < out_len; ++i) { |
| 38 | erpc_out_vec->elements[i].dataLength = out_vec[i].len; |
| 39 | } |
| 40 | |
| 41 | return status; |
| 42 | } |