blob: 791bbb06404c2ce40029ebe47967497ee95a165e [file] [log] [blame]
Ashutosh Singhf4d88672017-11-29 13:35:43 +00001/*
2 * Copyright (c) 2017, Arm Limited. All rights reserved.
3 *
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
17#define __cmse_secure_gateway \
18 __attribute__((cmse_nonsecure_entry, noinline, section("SFN")))
19
20/**
21 * \brief Gets handler for the given asset uuid. If an asset is deleted, the
22 * linked asset handle reference is no longer valid and will give
23 * TFM_SST_ERR_ASSET_REF_INVALID if used.
24 *
25 * \param[in] app_id Application ID
26 * \param[in] asset_uuid Asset UUID
27 * \param[out] hdl Handle to be returned
28 *
29 * \return Returns asset handle. If asset is not found, it returns
30 * TFM_SST_ERR_ASSET_NOT_FOUND. If SST area is not prepared, it returns
31 * TFM_SST_ERR_ASSET_NOT_PREPARED.
32 */
33enum tfm_sst_err_t tfm_sst_veneer_get_handle(uint32_t app_id,
34 uint16_t asset_uuid,
35 uint32_t *hdl)
36__cmse_secure_gateway;
37
38/**
39 * \brief Allocates space for the asset, referenced by asset handler,
40 * without setting any data in the asset.
41 *
42 * \param[in] app_id Application ID
43 * \param[in] asset_uuid Asset UUID
44 *
45 * \return Returns an asset handle. If SST area is not prepared, it returns
46 * TFM_SST_ERR_ASSET_NOT_PREPARED. If SST area is full, it returns
47 * TFM_SST_ERR_STORAGE_SYSTEM_FULL. If application id doesn't have the
48 * write rights, it returns TFM_SST_ERR_PERMS_NOT_ALLOWED.
49 */
50enum tfm_sst_err_t tfm_sst_veneer_create(uint32_t app_id, uint16_t asset_uuid)
51__cmse_secure_gateway;
52
53/**
54 * \brief Gets asset's attributes referenced by asset handler.
55 * Uses cached metadata to return the size and write offset of an asset.
56 *
57 * \param[in] app_id Application ID
58 * \param[in] asset_handle Asset handler
59 * \param[out] attrib_struct Pointer to asset attribute struct
60 *
61 * \return Returns error code as specified in \ref tfm_sst_err_t
62 */
63extern enum tfm_sst_err_t tfm_sst_veneer_get_attributes(
64 uint32_t app_id,
65 uint32_t asset_handle,
66 struct tfm_sst_attribs_t *attrib_struct)
67__cmse_secure_gateway;
68
69/**
70 * \brief Reads asset's data from asset referenced by asset handler.
71 *
72 * \param[in] app_id Application ID
73 * \param[in] asset_handle Asset handler
74 * \param[in/out] data Pointer to data vector \ref tfm_sst_buf_t to
75 * store data, size and offset
76 *
77 * \return Returns the number of bytes written or a castable \ref tfm_sst_err_t
78 * value
79 */
80enum tfm_sst_err_t tfm_sst_veneer_read(uint32_t app_id,
81 uint32_t asset_handle,
82 struct tfm_sst_buf_t *data)
83__cmse_secure_gateway;
84
85/**
86 * \brief Writes data into an asset referenced by asset handler.
87 *
88 * \param[in] app_id Application ID
89 * \param[in] asset_handle Asset handler
90 * \param[in] data Pointer to data vector \ref tfm_sst_buf_t which
91 * contains the data to write
92 *
93 * \return Returns the number of bytes written or a castable \ref tfm_sst_err_t
94 * value
95 */
96enum tfm_sst_err_t tfm_sst_veneer_write(uint32_t app_id,
97 uint32_t asset_handle,
98 struct tfm_sst_buf_t *data)
99__cmse_secure_gateway;
100
101/**
102 * \brief Deletes the asset referenced by the asset handler.
103 *
104 * \param[in] app_id Application ID
105 * \param[in] asset_handle Asset handler
106 *
107 * \return Returns TFM_SST_ERR_PERMS_NOT_ALLOWED if the asset can't be deleted
108 * to by this app ID. Returns TFM_SST_ERR_ASSET_REF_INVALID, if asset
109 * no longer exists. Otherwise, TFM_SST_ERR_SUCCESS.
110 */
111enum tfm_sst_err_t tfm_sst_veneer_delete(uint32_t app_id,
112 uint32_t asset_handle)
113__cmse_secure_gateway;
114
115#ifdef __cplusplus
116}
117#endif
118
119#endif /* __TFM_SST_VENEERS_H__ */