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