1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
/*
* Copyright (c) 2018-2021, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
*/
#include <inttypes.h>
#include "psa/client.h"
#include "svc_num.h"
#include "tfm_api.h"
#include "tfm_hal_device_header.h"
#include "tfm_psa_call_param.h"
__attribute__((naked))
uint32_t psa_framework_version(void)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_FRAMEWORK_VERSION));
}
__attribute__((naked))
uint32_t psa_version(uint32_t sid)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_VERSION));
}
__attribute__((naked))
psa_handle_t psa_connect(uint32_t sid, uint32_t version)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_CONNECT));
}
__attribute__((naked))
static psa_status_t psa_call_param_pack(psa_handle_t handle,
uint32_t ctrl_param,
const psa_invec *in_vec,
psa_outvec *out_vec)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_CALL));
}
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)
{
if ((type > INT16_MAX) ||
(type < INT16_MIN) ||
(in_len > PSA_MAX_IOVEC) ||
(out_len > PSA_MAX_IOVEC) ||
((in_len + out_len) > PSA_MAX_IOVEC)) {
return PSA_ERROR_INVALID_ARGUMENT;
}
return psa_call_param_pack(handle,
PARAM_PACK(type, in_len, out_len),
in_vec,
out_vec);
}
__attribute__((naked))
void psa_close(psa_handle_t handle)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_CLOSE));
}
|