blob: 16262579b6b31722963892dc45b22826df156e64 [file] [log] [blame]
Julian Hall56387ba2022-11-18 11:47:44 +00001/*
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>
12#include <service/fwu/agent/install_type.h>
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18/**
19 * Interface dependencies
20 */
21struct installer;
22
23/**
24 * @brief Initialize the installer index
25 *
26 * The installer_index is a singleton that holds the set of installers that are suitable
27 * for the deployment. The mix of installers will depend on factors such as the image
28 * container used by firmware or whether images are encrypted etc.
29 */
30void installer_index_init(void);
31
32/**
33 * @brief Clears the installer index
34 *
35 * Clears all mappings.
36 */
37void installer_index_clear(void);
38
39/**
40 * @brief Register an installer
41 *
42 * Registers an installer to handle image installation for a particular install_type
43 * and location.
44 *
45 * @param[in] installer The installer to use
46 */
47void installer_index_register(
48 struct installer *installer);
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 */
58struct installer *installer_index_find(
59 enum install_type install_type,
60 uint32_t location_id);
61
62/**
63 * @brief Find a registered installer associated with the specified location UUID
64 *
65 * @param[in] location_uuid The associated location UUID
66 *
67 * @return Pointer to a concrete installer or NULL if none found
68 */
69struct installer *installer_index_find_by_location_uuid(
70 const struct uuid_octets *location_uuid);
71
72/**
73 * @brief Iterator function
74 *
75 * @param[in] index 0..n
76 *
77 * @return Pointer to a concrete installer or NULL if iterated beyond final entry
78 */
79struct installer *installer_index_get(unsigned int index);
80
81/**
82 * @brief Get an array of location_ids
83 *
84 * Updatable firmware may be distributed over multiple locations. Each location is
85 * assigned a location_id when the set of installers are registered for the platform.
86 * This function returns a variable length array of locations_ids for the platform.
87 * This is useful for checking if an incoming update has included components that
88 * update all locations or not.
89 *
90 * @param[out] num_ids 0..n
91 *
92 * @return Pointer to a static array of location ids
93 */
94const uint32_t *installer_index_get_location_ids(size_t *num_ids);
95
96#ifdef __cplusplus
97}
98#endif
99
100#endif /* INSTALLER_INDEX_H */