blob: 108ea97f4d1a9d2fa903ca9d516a70366f2e4751 [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#ifndef __TFM_SST_VENEERS_H__
9#define __TFM_SST_VENEERS_H__
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15#include "tfm_sst_defs.h"
16
Ashutosh Singhf4d88672017-11-29 13:35:43 +000017/**
18 * \brief Gets handler for the given asset uuid. If an asset is deleted, the
19 * linked asset handle reference is no longer valid and will give
20 * TFM_SST_ERR_ASSET_REF_INVALID if used.
21 *
22 * \param[in] app_id Application ID
23 * \param[in] asset_uuid Asset UUID
24 * \param[out] hdl Handle to be returned
25 *
26 * \return Returns asset handle. If asset is not found, it returns
27 * TFM_SST_ERR_ASSET_NOT_FOUND. If SST area is not prepared, it returns
28 * TFM_SST_ERR_ASSET_NOT_PREPARED.
29 */
30enum tfm_sst_err_t tfm_sst_veneer_get_handle(uint32_t app_id,
31 uint16_t asset_uuid,
Antonio de Angeliseba14e12018-03-27 11:03:20 +010032 uint32_t *hdl);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000033/**
34 * \brief Allocates space for the asset, referenced by asset handler,
35 * without setting any data in the asset.
36 *
37 * \param[in] app_id Application ID
38 * \param[in] asset_uuid Asset UUID
39 *
40 * \return Returns an asset handle. If SST area is not prepared, it returns
41 * TFM_SST_ERR_ASSET_NOT_PREPARED. If SST area is full, it returns
42 * TFM_SST_ERR_STORAGE_SYSTEM_FULL. If application id doesn't have the
43 * write rights, it returns TFM_SST_ERR_PERMS_NOT_ALLOWED.
44 */
Antonio de Angeliseba14e12018-03-27 11:03:20 +010045enum tfm_sst_err_t tfm_sst_veneer_create(uint32_t app_id, uint16_t asset_uuid);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000046
47/**
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +010048 * \brief Gets asset's information referenced by asset handler.
Ashutosh Singhf4d88672017-11-29 13:35:43 +000049 *
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +010050 * \param[in] app_id Application ID
51 * \param[in] asset_handle Asset handler
52 * \param[out] info Pointer to store the asset's information
53 * \ref tfm_sst_asset_info_t
Ashutosh Singhf4d88672017-11-29 13:35:43 +000054 *
55 * \return Returns error code as specified in \ref tfm_sst_err_t
56 */
Marc Moreno Berengue675b6e92018-06-14 17:31:01 +010057enum tfm_sst_err_t tfm_sst_veneer_get_info(uint32_t app_id,
58 uint32_t asset_handle,
59 struct tfm_sst_asset_info_t *info);
60
Ashutosh Singhf4d88672017-11-29 13:35:43 +000061/**
Marc Moreno Berengue51af9512018-06-14 18:28:14 +010062 * \brief Gets asset's attributes referenced by asset handler.
63 *
64 * \param[in] app_id Application ID
65 * \param[in] asset_handle Asset handler
66 * \param[out] attrs Pointer to store the asset's attributes
67 *
68 * \return Returns error code as specified in \ref tfm_sst_err_t
69 */
70enum tfm_sst_err_t tfm_sst_veneer_get_attributes(
71 uint32_t app_id,
72 uint32_t asset_handle,
73 struct tfm_sst_asset_attrs_t *attrs);
74
75/**
76 * \brief Sets asset's attributes referenced by asset handler.
77 *
78 * \param[in] app_id Application ID
79 * \param[in] asset_handle Asset handler
80 * \param[in] attrs Pointer to new the asset's attributes
81 * \ref tfm_sst_asset_attrs_t
82 *
83 * \return Returns error code as specified in \ref tfm_sst_err_t
84 */
85enum tfm_sst_err_t tfm_sst_veneer_set_attributes(
86 uint32_t app_id,
87 uint32_t asset_handle,
88 const struct tfm_sst_asset_attrs_t *attrs);
89
90/**
Ashutosh Singhf4d88672017-11-29 13:35:43 +000091 * \brief Reads asset's data from asset referenced by asset handler.
92 *
93 * \param[in] app_id Application ID
94 * \param[in] asset_handle Asset handler
95 * \param[in/out] data Pointer to data vector \ref tfm_sst_buf_t to
96 * store data, size and offset
97 *
98 * \return Returns the number of bytes written or a castable \ref tfm_sst_err_t
99 * value
100 */
101enum tfm_sst_err_t tfm_sst_veneer_read(uint32_t app_id,
102 uint32_t asset_handle,
Antonio de Angeliseba14e12018-03-27 11:03:20 +0100103 struct tfm_sst_buf_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000104/**
105 * \brief Writes data into an asset referenced by asset handler.
106 *
107 * \param[in] app_id Application ID
108 * \param[in] asset_handle Asset handler
109 * \param[in] data Pointer to data vector \ref tfm_sst_buf_t which
110 * contains the data to write
111 *
112 * \return Returns the number of bytes written or a castable \ref tfm_sst_err_t
113 * value
114 */
115enum tfm_sst_err_t tfm_sst_veneer_write(uint32_t app_id,
116 uint32_t asset_handle,
Antonio de Angeliseba14e12018-03-27 11:03:20 +0100117 struct tfm_sst_buf_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000118/**
119 * \brief Deletes the asset referenced by the asset handler.
120 *
121 * \param[in] app_id Application ID
122 * \param[in] asset_handle Asset handler
123 *
124 * \return Returns TFM_SST_ERR_PERMS_NOT_ALLOWED if the asset can't be deleted
125 * to by this app ID. Returns TFM_SST_ERR_ASSET_REF_INVALID, if asset
126 * no longer exists. Otherwise, TFM_SST_ERR_SUCCESS.
127 */
128enum tfm_sst_err_t tfm_sst_veneer_delete(uint32_t app_id,
Antonio de Angeliseba14e12018-03-27 11:03:20 +0100129 uint32_t asset_handle);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000130#ifdef __cplusplus
131}
132#endif
133
134#endif /* __TFM_SST_VENEERS_H__ */