blob: 790435fc4961815f2a70b4a2513615ba98fce81b [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
8#include "tfm_sst_defs.h"
9#include "tfm_ns_lock.h"
10
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010011enum psa_sst_err_t psa_sst_create(uint32_t asset_uuid, const uint8_t* token,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010012 uint32_t token_size)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000013{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010014 struct tfm_sst_token_t s_token;
15
16 /* Pack the token information in the token structure */
17 s_token.token = token;
18 s_token.token_size = token_size;
19
Ashutosh Singhf4d88672017-11-29 13:35:43 +000020 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_CREATE,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010021 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010022 (uint32_t)&s_token,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000023 0,
24 0);
25}
26
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010027enum psa_sst_err_t psa_sst_get_info(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010028 const uint8_t* token,
29 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010030 struct psa_sst_asset_info_t *info)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000031{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010032 struct tfm_sst_token_t s_token;
33
34 /* Pack the token information in the token structure */
35 s_token.token = token;
36 s_token.token_size = token_size;
37
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +010038 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_GET_INFO,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010039 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010040 (uint32_t)&s_token,
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +010041 (uint32_t)info,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000042 0);
43}
44
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010045enum psa_sst_err_t psa_sst_get_attributes(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010046 const uint8_t* token,
47 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010048 struct psa_sst_asset_attrs_t *attrs)
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010049{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010050 struct tfm_sst_token_t s_token;
51
52 /* Pack the token information in the token structure */
53 s_token.token = token;
54 s_token.token_size = token_size;
55
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010056 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_GET_ATTRIBUTES,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010057 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010058 (uint32_t)&s_token,
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010059 (uint32_t)attrs,
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010060 0);
61}
62
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010063enum psa_sst_err_t psa_sst_set_attributes(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010064 const uint8_t* token,
65 uint32_t token_size,
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010066 const struct psa_sst_asset_attrs_t *attrs)
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010067{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010068 struct tfm_sst_token_t s_token;
69
70 /* Pack the token information in the token structure */
71 s_token.token = token;
72 s_token.token_size = token_size;
73
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010074 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_SET_ATTRIBUTES,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010075 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010076 (uint32_t)&s_token,
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010077 (uint32_t)attrs,
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010078 0);
79}
80
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +010081enum psa_sst_err_t psa_sst_read(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010082 const uint8_t* token,
83 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +010084 uint32_t size,
85 uint32_t offset,
86 uint8_t *data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000087{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010088 struct tfm_sst_token_t s_token;
Marc Moreno Berengue79032942018-06-26 15:34:05 +010089 struct tfm_sst_buf_t s_data;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010090
91 /* Pack the token information in the token structure */
92 s_token.token = token;
93 s_token.token_size = token_size;
94
Marc Moreno Berengue79032942018-06-26 15:34:05 +010095 /* Pack buffer information in the buffer structure */
96 s_data.size = size;
97 s_data.offset = offset;
98 s_data.data = data;
99
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000100 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_READ,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100101 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100102 (uint32_t)&s_token,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100103 (uint32_t)&s_data,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000104 0);
105}
106
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100107enum psa_sst_err_t psa_sst_write(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100108 const uint8_t* token,
109 uint32_t token_size,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100110 uint32_t size,
111 uint32_t offset,
112 const uint8_t *data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000113{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100114 struct tfm_sst_token_t s_token;
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100115 struct tfm_sst_buf_t s_data;
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100116
117 /* Pack the token information in the token structure */
118 s_token.token = token;
119 s_token.token_size = token_size;
120
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100121 /* Pack buffer information in the buffer structure */
122 s_data.size = size;
123 s_data.offset = offset;
124 s_data.data = (uint8_t *)data;
125
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000126 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_WRITE,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100127 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100128 (uint32_t)&s_token,
Marc Moreno Berengue79032942018-06-26 15:34:05 +0100129 (uint32_t)&s_data,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000130 0);
131}
132
Marc Moreno Berengue7d053a32018-06-27 18:22:14 +0100133enum psa_sst_err_t psa_sst_delete(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100134 const uint8_t* token,
135 uint32_t token_size)
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000136{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100137 struct tfm_sst_token_t s_token;
138
139 /* Pack the token information in the token structure */
140 s_token.token = token;
141 s_token.token_size = token_size;
142
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000143 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_DELETE,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100144 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100145 (uint32_t)&s_token,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000146 0,
147 0);
148}