1 /* 2 * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #ifndef MEDIA_VOLUME_INDEX_H 8 #define MEDIA_VOLUME_INDEX_H 9 10 #include <stdint.h> 11 #include <media/volume/volume.h> 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** 18 * For tf-a declaration of plat_get_image_source(). Included within C++ extern C 19 * guard to allow for calling from C++. 20 */ 21 #include <plat/common/platform.h> 22 23 /** 24 * @brief Some common volume identifiers 25 * 26 * Volume IDs only need to be unique within a deployment. For convenience, 27 * here are some common volume IDs that may be useful. 28 */ 29 #define VOLUME_ID_COMMON_BASE (0x10000000) 30 #define VOLUME_ID_SECURE_FLASH (VOLUME_ID_COMMON_BASE + 0) 31 32 /** 33 * @brief Initialize the volume index 34 * 35 * The volume_index is a singleton that holds the mapping of volume IDs 36 * to concrete volume objects that associate a storage volume with an 37 * IO device that may be used to access storage. The mappings are setup 38 * during deployment configuration to meet the IO needs of the deployment. 39 * The volume_index realizes the tf-a function plat_get_image_source() to 40 * make the mappings available to tf-a components. 41 */ 42 void volume_index_init(void); 43 44 /** 45 * @brief Clears the volume index 46 * 47 * Clears all mappings. 48 */ 49 void volume_index_clear(void); 50 51 /** 52 * @brief Add an entry to the volume index 53 * 54 * @param[in] volume_id Volume identifier 55 * @param[in] volume The volume that extends the base io_dev 56 * 57 * @return 0 if successful 58 */ 59 int volume_index_add( 60 unsigned int volume_id, 61 struct volume *volume); 62 63 /** 64 * @brief Find an added volume by volume index 65 * 66 * @param[in] volume_id Volume identifier 67 * @param[out] volume The volume that extends the base io_dev 68 * 69 * @return 0 if found 70 */ 71 int volume_index_find( 72 unsigned int volume_id, 73 struct volume **volume); 74 75 /** 76 * @brief Iterator function 77 * 78 * @param[in] index 0..n 79 * 80 * @return Pointer to a concrete volume or NULL if iterated beyond final entry 81 */ 82 struct volume *volume_index_get(unsigned int index); 83 84 85 #ifdef __cplusplus 86 } 87 #endif 88 89 #endif /* MEDIA_VOLUME_INDEX_H */ 90