1 /* 2 * Copyright (c) 2017-2020, Arm Limited. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef __PS_OBJECT_SYSTEM_H__ 9 #define __PS_OBJECT_SYSTEM_H__ 10 11 #include <stdint.h> 12 13 #include "psa/protected_storage.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 /** 20 * \brief Prepares the protected storage system for usage, populating internal 21 * structures. 22 * It identifies and validates the system metadata. 23 * 24 * \return Returns error code specified in \ref psa_status_t 25 */ 26 psa_status_t ps_system_prepare(void); 27 28 /** 29 * \brief Creates a new object with the provided UID and client ID. 30 * 31 * \param[in] uid Unique identifier for the data 32 * \param[in] client_id Identifier of the asset's owner (client) 33 * \param[in] create_flags Flags indicating the properties of the data 34 * \param[in] size Size of the contents of `data` in bytes 35 * 36 * \return Returns error code specified in \ref psa_status_t 37 */ 38 psa_status_t ps_object_create(psa_storage_uid_t uid, int32_t client_id, 39 psa_storage_create_flags_t create_flags, 40 uint32_t size); 41 42 /** 43 * \brief Gets the data of the object with the provided UID and client ID. 44 * 45 * \param[in] uid Unique identifier for the data 46 * \param[in] client_id Identifier of the asset's owner (client) 47 * \param[in] offset Offset in the object at which to begin the read 48 * \param[in] size Size of the contents of `data` in bytes 49 * \param[out] p_data_length On success, this will contain size of the data 50 * written to asset 51 * 52 * \return Returns error code specified in \ref psa_status_t 53 */ 54 psa_status_t ps_object_read(psa_storage_uid_t uid, int32_t client_id, 55 uint32_t offset, uint32_t size, 56 size_t *p_data_length); 57 58 /** 59 * \brief Writes data into the object with the provided UID and client ID. 60 * 61 * \param[in] uid Unique identifier for the data 62 * \param[in] client_id Identifier of the asset's owner (client) 63 * \param[in] offset Offset in the object at which to begin the write 64 * \param[in] size Size of the contents of `data` in bytes 65 * 66 * \return Returns error code specified in \ref psa_status_t 67 */ 68 psa_status_t ps_object_write(psa_storage_uid_t uid, int32_t client_id, 69 uint32_t offset, uint32_t size); 70 71 /** 72 * \brief Deletes the object with the provided UID and client ID. 73 * 74 * \param[in] uid Unique identifier for the data 75 * \param[in] client_id Identifier of the asset's owner (client) 76 * 77 * \return Returns error code specified in \ref psa_status_t 78 */ 79 psa_status_t ps_object_delete(psa_storage_uid_t uid, int32_t client_id); 80 81 /** 82 * \brief Gets the asset information for the object with the provided UID and 83 * client ID. 84 * 85 * \param[in] uid Unique identifier for the data 86 * \param[in] client_id Identifier of the asset's owner (client) 87 * \param[out] info Pointer to the `psa_storage_info_t` struct that will 88 * be populated with the metadata 89 * 90 * \return Returns error code specified in \ref psa_status_t 91 */ 92 psa_status_t ps_object_get_info(psa_storage_uid_t uid, int32_t client_id, 93 struct psa_storage_info_t *info); 94 95 /** 96 * \brief Wipes the protected storage system and all object data. 97 * 98 * \return Returns error code specified in \ref psa_status_t 99 */ 100 psa_status_t ps_system_wipe_all(void); 101 102 #ifdef __cplusplus 103 } 104 #endif 105 106 #endif /* __PS_OBJECT_SYSTEM_H__ */ 107