blob: db11d4e780adb8e99acc6347ce0fb12f5ac9f8b2 [file] [log] [blame]
Ashutosh Singhf4d88672017-11-29 13:35:43 +00001/*
Antonio de Angeliseba14e12018-03-27 11:03:20 +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/**
48 * \brief Gets asset's attributes referenced by asset handler.
49 * Uses cached metadata to return the size and write offset of an asset.
50 *
51 * \param[in] app_id Application ID
52 * \param[in] asset_handle Asset handler
53 * \param[out] attrib_struct Pointer to asset attribute struct
54 *
55 * \return Returns error code as specified in \ref tfm_sst_err_t
56 */
Antonio de Angeliseba14e12018-03-27 11:03:20 +010057enum tfm_sst_err_t tfm_sst_veneer_get_attributes(
Ashutosh Singhf4d88672017-11-29 13:35:43 +000058 uint32_t app_id,
59 uint32_t asset_handle,
Antonio de Angeliseba14e12018-03-27 11:03:20 +010060 struct tfm_sst_attribs_t *attrib_struct);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000061/**
62 * \brief Reads asset's data from asset referenced by asset handler.
63 *
64 * \param[in] app_id Application ID
65 * \param[in] asset_handle Asset handler
66 * \param[in/out] data Pointer to data vector \ref tfm_sst_buf_t to
67 * store data, size and offset
68 *
69 * \return Returns the number of bytes written or a castable \ref tfm_sst_err_t
70 * value
71 */
72enum tfm_sst_err_t tfm_sst_veneer_read(uint32_t app_id,
73 uint32_t asset_handle,
Antonio de Angeliseba14e12018-03-27 11:03:20 +010074 struct tfm_sst_buf_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000075/**
76 * \brief Writes data into an asset referenced by asset handler.
77 *
78 * \param[in] app_id Application ID
79 * \param[in] asset_handle Asset handler
80 * \param[in] data Pointer to data vector \ref tfm_sst_buf_t which
81 * contains the data to write
82 *
83 * \return Returns the number of bytes written or a castable \ref tfm_sst_err_t
84 * value
85 */
86enum tfm_sst_err_t tfm_sst_veneer_write(uint32_t app_id,
87 uint32_t asset_handle,
Antonio de Angeliseba14e12018-03-27 11:03:20 +010088 struct tfm_sst_buf_t *data);
Ashutosh Singhf4d88672017-11-29 13:35:43 +000089/**
90 * \brief Deletes the asset referenced by the asset handler.
91 *
92 * \param[in] app_id Application ID
93 * \param[in] asset_handle Asset handler
94 *
95 * \return Returns TFM_SST_ERR_PERMS_NOT_ALLOWED if the asset can't be deleted
96 * to by this app ID. Returns TFM_SST_ERR_ASSET_REF_INVALID, if asset
97 * no longer exists. Otherwise, TFM_SST_ERR_SUCCESS.
98 */
99enum tfm_sst_err_t tfm_sst_veneer_delete(uint32_t app_id,
Antonio de Angeliseba14e12018-03-27 11:03:20 +0100100 uint32_t asset_handle);
Ashutosh Singhf4d88672017-11-29 13:35:43 +0000101#ifdef __cplusplus
102}
103#endif
104
105#endif /* __TFM_SST_VENEERS_H__ */