blob: 81ad05d10d44c7fa56351fefa32dcef116673b91 [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>
Gyorgy Szing3c446242023-03-31 01:53:15 +020012
13#include "service/fwu/agent/install_type.h"
Julian Hall56387ba2022-11-18 11:47:44 +000014
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**
20 * Interface dependencies
21 */
22struct installer;
Gyorgy Szing9f298cc2023-03-31 12:43:33 +000023struct uuid_octets;
Julian Hall56387ba2022-11-18 11:47:44 +000024
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 */
32void installer_index_init(void);
33
34/**
35 * @brief Clears the installer index
36 *
37 * Clears all mappings.
38 */
39void 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 Szing3c446242023-03-31 01:53:15 +020049void installer_index_register(struct installer *installer);
Julian Hall56387ba2022-11-18 11:47:44 +000050
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 Szing3c446242023-03-31 01:53:15 +020059struct installer *installer_index_find(enum install_type install_type, uint32_t location_id);
Julian Hall56387ba2022-11-18 11:47:44 +000060
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 Szing3c446242023-03-31 01:53:15 +020068struct installer *installer_index_find_by_location_uuid(const struct uuid_octets *location_uuid);
Julian Hall56387ba2022-11-18 11:47:44 +000069
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 */
77struct 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 */
92const uint32_t *installer_index_get_location_ids(size_t *num_ids);
93
94#ifdef __cplusplus
95}
96#endif
97
98#endif /* INSTALLER_INDEX_H */