blob: ab47fd87416b08cd4304a66ea2db081f2a3921e0 [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 Berengue10d0d362018-06-18 14:15:56 +010011enum tfm_sst_err_t tfm_sst_create(uint32_t asset_uuid, const uint8_t* token,
12 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 Berengue4258e542018-06-18 13:55:59 +010027enum tfm_sst_err_t tfm_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 Berengue675b6e92018-06-14 17:31:01 +010030 struct tfm_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 Berengue4258e542018-06-18 13:55:59 +010045enum tfm_sst_err_t tfm_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 Berengue51af9512018-06-14 18:28:14 +010048 struct tfm_sst_asset_attrs_t *attrs)
49{
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 Berengue4258e542018-06-18 13:55:59 +010063enum tfm_sst_err_t tfm_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 Berengue51af9512018-06-14 18:28:14 +010066 const struct tfm_sst_asset_attrs_t *attrs)
67{
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 Berengue4258e542018-06-18 13:55:59 +010081enum tfm_sst_err_t tfm_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 Berengue4258e542018-06-18 13:55:59 +010084 struct tfm_sst_buf_t* data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +000085{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010086 struct tfm_sst_token_t s_token;
87
88 /* Pack the token information in the token structure */
89 s_token.token = token;
90 s_token.token_size = token_size;
91
Ashutosh Singhf4d88672017-11-29 13:35:43 +000092 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_READ,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010093 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +010094 (uint32_t)&s_token,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000095 (uint32_t)data,
Ashutosh Singhf4d88672017-11-29 13:35:43 +000096 0);
97}
98
Marc Moreno Berengue4258e542018-06-18 13:55:59 +010099enum tfm_sst_err_t tfm_sst_write(uint32_t asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100100 const uint8_t* token,
101 uint32_t token_size,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100102 struct tfm_sst_buf_t* data)
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000103{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100104 struct tfm_sst_token_t s_token;
105
106 /* Pack the token information in the token structure */
107 s_token.token = token;
108 s_token.token_size = token_size;
109
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000110 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_WRITE,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100111 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100112 (uint32_t)&s_token,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000113 (uint32_t)data,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000114 0);
115}
116
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100117enum tfm_sst_err_t tfm_sst_delete(uint32_t asset_uuid,
118 const uint8_t* token,
119 uint32_t token_size)
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000120{
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100121 struct tfm_sst_token_t s_token;
122
123 /* Pack the token information in the token structure */
124 s_token.token = token;
125 s_token.token_size = token_size;
126
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000127 return tfm_ns_lock_svc_dispatch(SVC_TFM_SST_DELETE,
Marc Moreno Berengue4258e542018-06-18 13:55:59 +0100128 asset_uuid,
Marc Moreno Berengue10d0d362018-06-18 14:15:56 +0100129 (uint32_t)&s_token,
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000130 0,
131 0);
132}