1 /*
2  * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "psa/client.h"
9 #include "tfm_ns_interface.h"
10 #include "tfm_api.h"
11 #include "tfm_psa_call_pack.h"
12 
13 /**** API functions ****/
14 
psa_framework_version(void)15 uint32_t psa_framework_version(void)
16 {
17     return tfm_ns_interface_dispatch(
18                                 (veneer_fn)tfm_psa_framework_version_veneer,
19                                 0,
20                                 0,
21                                 0,
22                                 0);
23 }
24 
psa_version(uint32_t sid)25 uint32_t psa_version(uint32_t sid)
26 {
27     return tfm_ns_interface_dispatch(
28                                 (veneer_fn)tfm_psa_version_veneer,
29                                 sid,
30                                 0,
31                                 0,
32                                 0);
33 }
34 
psa_call(psa_handle_t handle,int32_t type,const psa_invec * in_vec,size_t in_len,psa_outvec * out_vec,size_t out_len)35 psa_status_t psa_call(psa_handle_t handle, int32_t type,
36                       const psa_invec *in_vec,
37                       size_t in_len,
38                       psa_outvec *out_vec,
39                       size_t out_len)
40 {
41     if ((type > INT16_MAX) ||
42         (type < INT16_MIN) ||
43         (in_len > UINT8_MAX) ||
44         (out_len > UINT8_MAX)) {
45         return PSA_ERROR_PROGRAMMER_ERROR;
46     }
47 
48     return tfm_ns_interface_dispatch(
49                                 (veneer_fn)tfm_psa_call_veneer,
50                                 (uint32_t)handle,
51                                 PARAM_PACK(type, in_len, out_len),
52                                 (uint32_t)in_vec,
53                                 (uint32_t)out_vec);
54 }
55