Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 1 | /* |
Marc Moreno Berengue | 675b6e9 | 2018-06-14 17:31:01 +0100 | [diff] [blame^] | 2 | * Copyright (c) 2017-2018, Arm Limited. All rights reserved. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 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 |
| 12 | extern "C" { |
| 13 | #endif |
| 14 | |
| 15 | #include "tfm_sst_defs.h" |
| 16 | |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 17 | /** |
| 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 | */ |
| 30 | enum tfm_sst_err_t tfm_sst_veneer_get_handle(uint32_t app_id, |
| 31 | uint16_t asset_uuid, |
Antonio de Angelis | eba14e1 | 2018-03-27 11:03:20 +0100 | [diff] [blame] | 32 | uint32_t *hdl); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 33 | /** |
| 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 Angelis | eba14e1 | 2018-03-27 11:03:20 +0100 | [diff] [blame] | 45 | enum tfm_sst_err_t tfm_sst_veneer_create(uint32_t app_id, uint16_t asset_uuid); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 46 | |
| 47 | /** |
Marc Moreno Berengue | 675b6e9 | 2018-06-14 17:31:01 +0100 | [diff] [blame^] | 48 | * \brief Gets asset's information referenced by asset handler. |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 49 | * |
Marc Moreno Berengue | 675b6e9 | 2018-06-14 17:31:01 +0100 | [diff] [blame^] | 50 | * \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 Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 54 | * |
| 55 | * \return Returns error code as specified in \ref tfm_sst_err_t |
| 56 | */ |
Marc Moreno Berengue | 675b6e9 | 2018-06-14 17:31:01 +0100 | [diff] [blame^] | 57 | enum 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 Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 61 | /** |
| 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 | */ |
| 72 | enum tfm_sst_err_t tfm_sst_veneer_read(uint32_t app_id, |
| 73 | uint32_t asset_handle, |
Antonio de Angelis | eba14e1 | 2018-03-27 11:03:20 +0100 | [diff] [blame] | 74 | struct tfm_sst_buf_t *data); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 75 | /** |
| 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 | */ |
| 86 | enum tfm_sst_err_t tfm_sst_veneer_write(uint32_t app_id, |
| 87 | uint32_t asset_handle, |
Antonio de Angelis | eba14e1 | 2018-03-27 11:03:20 +0100 | [diff] [blame] | 88 | struct tfm_sst_buf_t *data); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 89 | /** |
| 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 | */ |
| 99 | enum tfm_sst_err_t tfm_sst_veneer_delete(uint32_t app_id, |
Antonio de Angelis | eba14e1 | 2018-03-27 11:03:20 +0100 | [diff] [blame] | 100 | uint32_t asset_handle); |
Ashutosh Singh | f4d8867 | 2017-11-29 13:35:43 +0000 | [diff] [blame] | 101 | #ifdef __cplusplus |
| 102 | } |
| 103 | #endif |
| 104 | |
| 105 | #endif /* __TFM_SST_VENEERS_H__ */ |