TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
psa_client.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include <inttypes.h>
9 #include "tfm/tfm_core_svc.h"
10 #include "psa/client.h"
11 #include "tfm_api.h"
12 
13 __attribute__((naked))
14 uint32_t psa_framework_version(void)
15 {
16  __ASM volatile("SVC %0 \n"
17  "BX LR \n"
18  : : "I" (TFM_SVC_PSA_FRAMEWORK_VERSION));
19 }
20 
21 __attribute__((naked))
22 uint32_t psa_version(uint32_t sid)
23 {
24  __ASM volatile("SVC %0 \n"
25  "BX LR \n"
26  : : "I" (TFM_SVC_PSA_VERSION));
27 }
28 
29 __attribute__((naked))
30 psa_handle_t psa_connect(uint32_t sid, uint32_t version)
31 {
32  __ASM volatile("SVC %0 \n"
33  "BX LR \n"
34  : : "I" (TFM_SVC_PSA_CONNECT));
35 }
36 
37 __attribute__((naked))
38 static psa_status_t psa_call_param_pack(psa_handle_t handle,
39  struct tfm_control_parameter_t *ctrl_param,
40  const psa_invec *in_vec, psa_outvec *out_vec)
41 {
42  __ASM volatile("SVC %0 \n"
43  "BX LR \n"
44  : : "I" (TFM_SVC_PSA_CALL));
45 }
46 
48  int32_t type,
49  const psa_invec *in_vec,
50  size_t in_len,
51  psa_outvec *out_vec,
52  size_t out_len)
53 {
54  struct tfm_control_parameter_t ctrl_param;
55  ctrl_param.type = type;
56  ctrl_param.in_len = in_len;
57  ctrl_param.out_len = out_len;
58 
59  return psa_call_param_pack(handle, &ctrl_param, in_vec, out_vec);
60 }
61 
62 __attribute__((naked))
63 void psa_close(psa_handle_t handle)
64 {
65  __ASM volatile("SVC %0 \n"
66  "BX LR \n"
67  : : "I" (TFM_SVC_PSA_CLOSE));
68 }
psa_status_t 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)
Call an RoT Service on an established connection.
Definition: psa_client.c:47
void psa_close(psa_handle_t handle)
Close a connection to an RoT Service.
Definition: psa_client.c:63
uint32_t psa_version(uint32_t sid)
Retrieve the version of an RoT Service or indicate that it is not present on this system...
Definition: psa_client.c:22
psa_handle_t psa_connect(uint32_t sid, uint32_t version)
Connect to an RoT Service by its SID.
Definition: psa_client.c:30
uint32_t psa_framework_version(void)
Retrieve the version of the PSA Framework API that is implemented.
Definition: psa_client.c:14
int32_t psa_handle_t
Definition: client.h:61
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43