Julian Hall | cfe2f5b | 2022-09-22 11:26:35 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Julian Hall | 93df76a | 2022-09-22 17:30:06 +0100 | [diff] [blame] | 7 | #ifndef MEDIA_VOLUME_INDEX_H |
| 8 | #define MEDIA_VOLUME_INDEX_H |
Julian Hall | cfe2f5b | 2022-09-22 11:26:35 +0100 | [diff] [blame] | 9 | |
| 10 | #include <stdint.h> |
Julian Hall | 4a658ac | 2022-10-20 10:44:49 +0100 | [diff] [blame] | 11 | #include <media/volume/volume.h> |
Julian Hall | cfe2f5b | 2022-09-22 11:26:35 +0100 | [diff] [blame] | 12 | |
| 13 | #ifdef __cplusplus |
| 14 | extern "C" { |
| 15 | #endif |
| 16 | |
| 17 | /** |
Julian Hall | 93df76a | 2022-09-22 17:30:06 +0100 | [diff] [blame] | 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 | /** |
Julian Hall | 9497010 | 2022-09-28 11:02:48 +0100 | [diff] [blame] | 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 | */ |
Julian Hall | 4a658ac | 2022-10-20 10:44:49 +0100 | [diff] [blame] | 29 | #define VOLUME_ID_COMMON_BASE (0x10000000) |
Julian Hall | 9497010 | 2022-09-28 11:02:48 +0100 | [diff] [blame] | 30 | #define VOLUME_ID_SECURE_FLASH (VOLUME_ID_COMMON_BASE + 0) |
| 31 | |
| 32 | /** |
Julian Hall | cfe2f5b | 2022-09-22 11:26:35 +0100 | [diff] [blame] | 33 | * @brief Initialize the volume index |
| 34 | * |
| 35 | * The volume_index is a singleton that holds the mapping of volume IDs |
Julian Hall | 4a658ac | 2022-10-20 10:44:49 +0100 | [diff] [blame] | 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. |
Julian Hall | cfe2f5b | 2022-09-22 11:26:35 +0100 | [diff] [blame] | 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 |
Julian Hall | 4a658ac | 2022-10-20 10:44:49 +0100 | [diff] [blame] | 55 | * @param[in] volume The volume that extends the base io_dev |
Julian Hall | cfe2f5b | 2022-09-22 11:26:35 +0100 | [diff] [blame] | 56 | * |
| 57 | * @return 0 if successful |
| 58 | */ |
| 59 | int volume_index_add( |
| 60 | unsigned int volume_id, |
Julian Hall | 4a658ac | 2022-10-20 10:44:49 +0100 | [diff] [blame] | 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 | |
Julian Hall | cfe2f5b | 2022-09-22 11:26:35 +0100 | [diff] [blame] | 84 | |
| 85 | #ifdef __cplusplus |
| 86 | } |
| 87 | #endif |
| 88 | |
Julian Hall | 93df76a | 2022-09-22 17:30:06 +0100 | [diff] [blame] | 89 | #endif /* MEDIA_VOLUME_INDEX_H */ |