blob: 8a3fec8cc9eabd994b4deb8e2206697738c65c6c [file] [log] [blame]
Ashutosh Singhf4d88672017-11-29 13:35:43 +00001/*
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +01002 * Copyright (c) 2017-2018, Arm Limited. All rights reserved.
Ashutosh Singhf4d88672017-11-29 13:35:43 +00003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 *
6 */
7
Mate Toth-Pal1379e152018-07-30 17:38:29 +02008#include "tfm_sst_veneers.h"
Ashutosh Singhf4d88672017-11-29 13:35:43 +00009#include "tfm_sst_defs.h"
10#include "tfm_ns_lock.h"
Mate Toth-Pal1379e152018-07-30 17:38:29 +020011#include "tfm_id_mngr.h"
Ashutosh Singhf4d88672017-11-29 13:35:43 +000012
Marc Moreno Berenguec304f922018-07-12 11:39:11 +010013enum psa_sst_err_t psa_sst_create(uint32_t asset_uuid, const uint8_t *token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010014 uint32_t token_size)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000015{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010016 struct tfm_sst_token_t s_token;
Mate Toth-Pal1379e152018-07-30 17:38:29 +020017 int32_t client_id;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010018
19 /* Pack the token information in the token structure */
20 s_token.token = token;
21 s_token.token_size = token_size;
22
Mate Toth-Pal1379e152018-07-30 17:38:29 +020023 client_id = tfm_sst_get_cur_id();
24
25 return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_create,
26 client_id,
27 asset_uuid,
28 (uint32_t)&s_token,
29 0);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000030}
31
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010032enum psa_sst_err_t psa_sst_get_info(uint32_t asset_uuid,
Marc Moreno Berenguec304f922018-07-12 11:39:11 +010033 const uint8_t *token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010034 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010035 struct psa_sst_asset_info_t *info)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000036{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010037 struct tfm_sst_token_t s_token;
Mate Toth-Pal1379e152018-07-30 17:38:29 +020038 int32_t client_id;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010039
40 /* Pack the token information in the token structure */
41 s_token.token = token;
42 s_token.token_size = token_size;
43
Mate Toth-Pal1379e152018-07-30 17:38:29 +020044 client_id = tfm_sst_get_cur_id();
45
46 return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_info,
47 client_id,
48 asset_uuid,
49 (uint32_t)&s_token,
50 (uint32_t)info);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000051}
52
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010053enum psa_sst_err_t psa_sst_get_attributes(uint32_t asset_uuid,
Marc Moreno Berenguec304f922018-07-12 11:39:11 +010054 const uint8_t *token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010055 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010056 struct psa_sst_asset_attrs_t *attrs)
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010057{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010058 struct tfm_sst_token_t s_token;
Mate Toth-Pal1379e152018-07-30 17:38:29 +020059 int32_t client_id;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010060
61 /* Pack the token information in the token structure */
62 s_token.token = token;
63 s_token.token_size = token_size;
64
Mate Toth-Pal1379e152018-07-30 17:38:29 +020065 client_id = tfm_sst_get_cur_id();
66
67 return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_get_attributes,
68 client_id,
69 asset_uuid,
70 (uint32_t)&s_token,
71 (uint32_t)attrs);
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010072}
73
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010074enum psa_sst_err_t psa_sst_set_attributes(uint32_t asset_uuid,
Marc Moreno Berenguec304f922018-07-12 11:39:11 +010075 const uint8_t *token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010076 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010077 const struct psa_sst_asset_attrs_t *attrs)
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010078{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010079 struct tfm_sst_token_t s_token;
Mate Toth-Pal1379e152018-07-30 17:38:29 +020080 int32_t client_id;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010081
82 /* Pack the token information in the token structure */
83 s_token.token = token;
84 s_token.token_size = token_size;
85
Mate Toth-Pal1379e152018-07-30 17:38:29 +020086 client_id = tfm_sst_get_cur_id();
87
88 return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_set_attributes,
89 client_id,
90 asset_uuid,
91 (uint32_t)&s_token,
92 (uint32_t)attrs);
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010093}
94
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010095enum psa_sst_err_t psa_sst_read(uint32_t asset_uuid,
Marc Moreno Berenguec304f922018-07-12 11:39:11 +010096 const uint8_t *token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010097 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +010098 uint32_t size,
99 uint32_t offset,
100 uint8_t *data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000101{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100102 struct tfm_sst_token_t s_token;
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100103 struct tfm_sst_buf_t s_data;
Mate Toth-Pal1379e152018-07-30 17:38:29 +0200104 int32_t client_id;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100105
106 /* Pack the token information in the token structure */
107 s_token.token = token;
108 s_token.token_size = token_size;
109
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100110 /* Pack buffer information in the buffer structure */
111 s_data.size = size;
112 s_data.offset = offset;
113 s_data.data = data;
114
Mate Toth-Pal1379e152018-07-30 17:38:29 +0200115 client_id = tfm_sst_get_cur_id();
116
117 return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_read,
118 client_id,
119 asset_uuid,
120 (uint32_t)&s_token,
121 (uint32_t)&s_data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000122}
123
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100124enum psa_sst_err_t psa_sst_write(uint32_t asset_uuid,
Marc Moreno Berenguec304f922018-07-12 11:39:11 +0100125 const uint8_t *token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100126 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100127 uint32_t size,
128 uint32_t offset,
129 const uint8_t *data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000130{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100131 struct tfm_sst_token_t s_token;
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100132 struct tfm_sst_buf_t s_data;
Mate Toth-Pal1379e152018-07-30 17:38:29 +0200133 int32_t client_id;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100134
135 /* Pack the token information in the token structure */
136 s_token.token = token;
137 s_token.token_size = token_size;
138
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100139 /* Pack buffer information in the buffer structure */
140 s_data.size = size;
141 s_data.offset = offset;
142 s_data.data = (uint8_t *)data;
143
Mate Toth-Pal1379e152018-07-30 17:38:29 +0200144 client_id = tfm_sst_get_cur_id();
145
146 return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_write,
147 client_id,
148 asset_uuid,
149 (uint32_t)&s_token,
150 (uint32_t)&s_data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000151}
152
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100153enum psa_sst_err_t psa_sst_delete(uint32_t asset_uuid,
Marc Moreno Berenguec304f922018-07-12 11:39:11 +0100154 const uint8_t *token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100155 uint32_t token_size)
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000156{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100157 struct tfm_sst_token_t s_token;
Mate Toth-Pal1379e152018-07-30 17:38:29 +0200158 int32_t client_id;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100159
160 /* Pack the token information in the token structure */
161 s_token.token = token;
162 s_token.token_size = token_size;
163
Mate Toth-Pal1379e152018-07-30 17:38:29 +0200164 client_id = tfm_sst_get_cur_id();
165
166 return tfm_ns_lock_dispatch((veneer_fn)tfm_sst_veneer_delete,
167 client_id,
168 asset_uuid,
169 (uint32_t)&s_token,
170 0);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000171}