blob: 612d0e9583165f476bf55a05d94a461d3a1ad9d7 [file] [log] [blame]
Julian Hallcfe2f5b2022-09-22 11:26:35 +01001/*
2 * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Julian Hall93df76a2022-09-22 17:30:06 +01007#ifndef MEDIA_VOLUME_INDEX_H
8#define MEDIA_VOLUME_INDEX_H
Julian Hallcfe2f5b2022-09-22 11:26:35 +01009
10#include <stdint.h>
Julian Hall4a658ac2022-10-20 10:44:49 +010011#include <media/volume/volume.h>
Julian Hallcfe2f5b2022-09-22 11:26:35 +010012
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/**
Julian Hall93df76a2022-09-22 17:30:06 +010018 * 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 Hall94970102022-09-28 11:02:48 +010024 * @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 Hall4a658ac2022-10-20 10:44:49 +010029#define VOLUME_ID_COMMON_BASE (0x10000000)
Julian Hall94970102022-09-28 11:02:48 +010030#define VOLUME_ID_SECURE_FLASH (VOLUME_ID_COMMON_BASE + 0)
31
32/**
Julian Hallcfe2f5b2022-09-22 11:26:35 +010033 * @brief Initialize the volume index
34 *
35 * The volume_index is a singleton that holds the mapping of volume IDs
Julian Hall4a658ac2022-10-20 10:44:49 +010036 * 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 Hallcfe2f5b2022-09-22 11:26:35 +010041 */
42void volume_index_init(void);
43
44/**
45 * @brief Clears the volume index
46 *
47 * Clears all mappings.
48 */
49void volume_index_clear(void);
50
51/**
52 * @brief Add an entry to the volume index
53 *
54 * @param[in] volume_id Volume identifier
Julian Hall4a658ac2022-10-20 10:44:49 +010055 * @param[in] volume The volume that extends the base io_dev
Julian Hallcfe2f5b2022-09-22 11:26:35 +010056 *
57 * @return 0 if successful
58 */
59int volume_index_add(
60 unsigned int volume_id,
Julian Hall4a658ac2022-10-20 10:44:49 +010061 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 */
71int 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 */
82struct volume *volume_index_get(unsigned int index);
83
Julian Hallcfe2f5b2022-09-22 11:26:35 +010084
85#ifdef __cplusplus
86}
87#endif
88
Julian Hall93df76a2022-09-22 17:30:06 +010089#endif /* MEDIA_VOLUME_INDEX_H */