blob: 2a20e28decc0e46854aa2c0df079991122eca4e1 [file] [log] [blame]
Ashutosh Singhf4d88672017-11-29 13:35:43 +00001/*
Jamie Foxb93da8b2018-12-13 18:27:30 +00002 * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
Ashutosh Singhf4d88672017-11-29 13:35:43 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Jamie Foxb93da8b2018-12-13 18:27:30 +00008#include "psa_protected_storage.h"
9
Ashutosh Singhf4d88672017-11-29 13:35:43 +000010#include "tfm_ns_lock.h"
Jamie Foxb93da8b2018-12-13 18:27:30 +000011#include "tfm_sst_defs.h"
12#include "tfm_sst_veneers.h"
Mate Toth-Pal261df462018-08-07 12:02:42 +020013
Jamie Foxb93da8b2018-12-13 18:27:30 +000014psa_ps_status_t psa_ps_set(psa_ps_uid_t uid,
15 uint32_t data_length,
16 const void *p_data,
17 psa_ps_create_flags_t create_flags)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000018{
Jamie Foxb93da8b2018-12-13 18:27:30 +000019 enum tfm_sst_err_t err;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010020
Jamie Foxb93da8b2018-12-13 18:27:30 +000021 err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_set,
22 (uint32_t)&uid,
23 (uint32_t)data_length,
24 (uint32_t)p_data,
25 (uint32_t)create_flags);
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010026
Jamie Foxb93da8b2018-12-13 18:27:30 +000027 return TFM_SST_PSA_RETURN(err);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000028}
29
Jamie Foxb93da8b2018-12-13 18:27:30 +000030psa_ps_status_t psa_ps_get(psa_ps_uid_t uid,
31 uint32_t data_offset,
32 uint32_t data_length,
33 void *p_data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000034{
Jamie Foxb93da8b2018-12-13 18:27:30 +000035 enum tfm_sst_err_t err;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010036
Jamie Foxb93da8b2018-12-13 18:27:30 +000037 err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get,
38 (uint32_t)&uid,
39 (uint32_t)data_offset,
40 (uint32_t)data_length,
41 (uint32_t)p_data);
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010042
Jamie Foxb93da8b2018-12-13 18:27:30 +000043 return TFM_SST_PSA_RETURN(err);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000044}
45
Jamie Foxb93da8b2018-12-13 18:27:30 +000046psa_ps_status_t psa_ps_get_info(psa_ps_uid_t uid, struct psa_ps_info_t *p_info)
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010047{
Jamie Foxb93da8b2018-12-13 18:27:30 +000048 enum tfm_sst_err_t err;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010049
Jamie Foxb93da8b2018-12-13 18:27:30 +000050 err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_info,
51 (uint32_t)&uid,
52 (uint32_t)p_info,
53 (uint32_t)0,
54 (uint32_t)0);
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010055
Jamie Foxb93da8b2018-12-13 18:27:30 +000056 return TFM_SST_PSA_RETURN(err);
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010057}
58
Jamie Foxb93da8b2018-12-13 18:27:30 +000059psa_ps_status_t psa_ps_remove(psa_ps_uid_t uid)
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010060{
Jamie Foxb93da8b2018-12-13 18:27:30 +000061 enum tfm_sst_err_t err;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010062
Jamie Foxb93da8b2018-12-13 18:27:30 +000063 err = tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_remove,
64 (uint32_t)&uid,
65 (uint32_t)0,
66 (uint32_t)0,
67 (uint32_t)0);
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010068
Jamie Foxb93da8b2018-12-13 18:27:30 +000069 return TFM_SST_PSA_RETURN(err);
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010070}
71
Jamie Foxb93da8b2018-12-13 18:27:30 +000072psa_ps_status_t psa_ps_create(psa_ps_uid_t uid, uint32_t size,
73 psa_ps_create_flags_t create_flags)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000074{
Jamie Foxb93da8b2018-12-13 18:27:30 +000075 (void)uid, (void)size, (void)create_flags;
76 return PSA_PS_ERROR_NOT_SUPPORTED;
Ashutosh Singhf4d88672017-11-29 13:35:43 +000077}
78
Jamie Foxb93da8b2018-12-13 18:27:30 +000079psa_ps_status_t psa_ps_set_extended(psa_ps_uid_t uid, uint32_t data_offset,
80 uint32_t data_length, const void *p_data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000081{
Jamie Foxb93da8b2018-12-13 18:27:30 +000082 (void)uid, (void)data_offset, (void)data_length, (void)p_data;
83 return PSA_PS_ERROR_NOT_SUPPORTED;
Ashutosh Singhf4d88672017-11-29 13:35:43 +000084}
85
Jamie Foxb93da8b2018-12-13 18:27:30 +000086uint32_t psa_ps_get_support(void)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000087{
Jamie Foxb93da8b2018-12-13 18:27:30 +000088 uint32_t support_flags;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010089
Jamie Foxb93da8b2018-12-13 18:27:30 +000090 /* Initialise support_flags to a sensible default, to avoid returning an
91 * uninitialised value in case the secure function fails.
92 */
93 support_flags = 0;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010094
Jamie Foxb93da8b2018-12-13 18:27:30 +000095 /* The PSA API does not return an error, so any error from TF-M is
96 * ignored.
97 */
98 (void)tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_support,
99 (uint32_t)&support_flags,
100 (uint32_t)0,
101 (uint32_t)0,
102 (uint32_t)0);
103
104 return support_flags;
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000105}