TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
tfm_psa_api_veneers.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 <stdbool.h>
9 #include <stdio.h>
10 #include "psa/client.h"
11 #include "psa/service.h"
12 #include "tfm_arch.h"
13 #include "tfm_secure_api.h"
14 #include "tfm_api.h"
15 #include "tfm_svcalls.h"
16 
17 /* Veneer implementation */
18 
19 /*
20  * SVC to core directly before touch stack due to:
21  * - Re-entrant detection bases on stack information.
22  * - SVC here stores the current xPSR into stack and recover it back while
23  * exception returns, no leakage of secure state information and no
24  * interference between two sides.
25  */
26 
27 __tfm_psa_secure_gateway_attributes__
29 {
30  __ASM volatile("SVC %0 \n"
31  "BXNS LR \n"
32  : : "I" (TFM_SVC_PSA_FRAMEWORK_VERSION));
33 }
34 
35 __tfm_psa_secure_gateway_attributes__
36 uint32_t tfm_psa_version_veneer(uint32_t sid)
37 {
38  __ASM volatile("SVC %0 \n"
39  "BXNS LR \n"
40  : : "I" (TFM_SVC_PSA_VERSION));
41 }
42 
43 __tfm_psa_secure_gateway_attributes__
44 psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t version)
45 {
46  __ASM volatile("SVC %0 \n"
47  "BXNS LR \n"
48  : : "I" (TFM_SVC_PSA_CONNECT));
49 }
50 
51 __tfm_psa_secure_gateway_attributes__
53  const struct tfm_control_parameter_t *ctrl_param,
54  const psa_invec *in_vec,
55  psa_outvec *out_vec)
56 {
57  __ASM volatile("SVC %0 \n"
58  "BXNS LR \n"
59  : : "I" (TFM_SVC_PSA_CALL));
60 }
61 
62 __tfm_psa_secure_gateway_attributes__
64 {
65  __ASM volatile("SVC %0 \n"
66  "BXNS LR \n"
67  : : "I" (TFM_SVC_PSA_CLOSE));
68 }
__tfm_psa_secure_gateway_attributes__ uint32_t tfm_psa_version_veneer(uint32_t sid)
Return version of secure function provided by secure binary.
__tfm_psa_secure_gateway_attributes__ psa_status_t tfm_psa_call_veneer(psa_handle_t handle, const struct tfm_control_parameter_t *ctrl_param, const psa_invec *in_vec, psa_outvec *out_vec)
Call a secure function referenced by a connection handle.
__tfm_psa_secure_gateway_attributes__ void tfm_psa_close_veneer(psa_handle_t handle)
Close connection to secure function referenced by a connection handle.
__tfm_psa_secure_gateway_attributes__ psa_handle_t tfm_psa_connect_veneer(uint32_t sid, uint32_t version)
Connect to secure function.
int32_t psa_handle_t
Definition: client.h:61
__tfm_psa_secure_gateway_attributes__ uint32_t tfm_psa_framework_version_veneer(void)
Retrieve the version of the PSA Framework API that is implemented.
int32_t psa_status_t
Function return status.
Definition: crypto_types.h:43