Julian Hall | 56387ba | 2022-11-18 11:47:44 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2022-2023, Arm Limited and Contributors. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #ifndef INSTALLER_INDEX_H |
| 8 | #define INSTALLER_INDEX_H |
| 9 | |
| 10 | #include <stddef.h> |
| 11 | #include <stdint.h> |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 12 | |
| 13 | #include "service/fwu/agent/install_type.h" |
Julian Hall | 56387ba | 2022-11-18 11:47:44 +0000 | [diff] [blame] | 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | /** |
| 20 | * Interface dependencies |
| 21 | */ |
| 22 | struct installer; |
Gyorgy Szing | 9f298cc | 2023-03-31 12:43:33 +0000 | [diff] [blame] | 23 | struct uuid_octets; |
Julian Hall | 56387ba | 2022-11-18 11:47:44 +0000 | [diff] [blame] | 24 | |
| 25 | /** |
| 26 | * @brief Initialize the installer index |
| 27 | * |
| 28 | * The installer_index is a singleton that holds the set of installers that are suitable |
| 29 | * for the deployment. The mix of installers will depend on factors such as the image |
| 30 | * container used by firmware or whether images are encrypted etc. |
| 31 | */ |
| 32 | void installer_index_init(void); |
| 33 | |
| 34 | /** |
| 35 | * @brief Clears the installer index |
| 36 | * |
| 37 | * Clears all mappings. |
| 38 | */ |
| 39 | void installer_index_clear(void); |
| 40 | |
| 41 | /** |
| 42 | * @brief Register an installer |
| 43 | * |
| 44 | * Registers an installer to handle image installation for a particular install_type |
| 45 | * and location. |
| 46 | * |
| 47 | * @param[in] installer The installer to use |
| 48 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 49 | void installer_index_register(struct installer *installer); |
Julian Hall | 56387ba | 2022-11-18 11:47:44 +0000 | [diff] [blame] | 50 | |
| 51 | /** |
| 52 | * @brief Find an installer for the specified type and location |
| 53 | * |
| 54 | * @param[in] install_type The type of installer |
| 55 | * @param[in] location_id The location it serves |
| 56 | * |
| 57 | * @return Pointer to a concrete installer or NULL if none found |
| 58 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 59 | struct installer *installer_index_find(enum install_type install_type, uint32_t location_id); |
Julian Hall | 56387ba | 2022-11-18 11:47:44 +0000 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * @brief Find a registered installer associated with the specified location UUID |
| 63 | * |
| 64 | * @param[in] location_uuid The associated location UUID |
| 65 | * |
| 66 | * @return Pointer to a concrete installer or NULL if none found |
| 67 | */ |
Gyorgy Szing | 3c44624 | 2023-03-31 01:53:15 +0200 | [diff] [blame] | 68 | struct installer *installer_index_find_by_location_uuid(const struct uuid_octets *location_uuid); |
Julian Hall | 56387ba | 2022-11-18 11:47:44 +0000 | [diff] [blame] | 69 | |
| 70 | /** |
| 71 | * @brief Iterator function |
| 72 | * |
| 73 | * @param[in] index 0..n |
| 74 | * |
| 75 | * @return Pointer to a concrete installer or NULL if iterated beyond final entry |
| 76 | */ |
| 77 | struct installer *installer_index_get(unsigned int index); |
| 78 | |
| 79 | /** |
| 80 | * @brief Get an array of location_ids |
| 81 | * |
| 82 | * Updatable firmware may be distributed over multiple locations. Each location is |
| 83 | * assigned a location_id when the set of installers are registered for the platform. |
| 84 | * This function returns a variable length array of locations_ids for the platform. |
| 85 | * This is useful for checking if an incoming update has included components that |
| 86 | * update all locations or not. |
| 87 | * |
| 88 | * @param[out] num_ids 0..n |
| 89 | * |
| 90 | * @return Pointer to a static array of location ids |
| 91 | */ |
| 92 | const uint32_t *installer_index_get_location_ids(size_t *num_ids); |
| 93 | |
| 94 | #ifdef __cplusplus |
| 95 | } |
| 96 | #endif |
| 97 | |
| 98 | #endif /* INSTALLER_INDEX_H */ |