blob: 5b54c049a8bfc98561d75ba6c5f1be5dfebb7daa [file] [log] [blame]
Louis Mayencourt944ade82019-08-08 12:03:26 +01001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
Louis Mayencourt944ade82019-08-08 12:03:26 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef FCONF_H
8#define FCONF_H
9
Claus Pedersen785e66c2022-09-12 22:42:58 +000010#include <stddef.h>
Louis Mayencourt944ade82019-08-08 12:03:26 +010011#include <stdint.h>
12
13/* Public API */
14#define FCONF_GET_PROPERTY(a, b, c) a##__##b##_getter(c)
15
Madhukar Pappireddy81519692019-12-06 15:46:42 -060016/*
17 * This macro takes three arguments:
18 * config: Configuration identifier
19 * name: property namespace
20 * callback: populate() function
21 */
22#define FCONF_REGISTER_POPULATOR(config, name, callback) \
Louis Mayencourt944ade82019-08-08 12:03:26 +010023 __attribute__((used, section(".fconf_populator"))) \
Yann Gautier39531c62022-11-18 14:04:03 +010024 static const struct fconf_populator (name##__populator) = { \
Madhukar Pappireddy81519692019-12-06 15:46:42 -060025 .config_type = (#config), \
Louis Mayencourt2711cc82020-02-24 14:37:25 +000026 .info = (#name), \
27 .populate = (callback) \
Louis Mayencourt944ade82019-08-08 12:03:26 +010028 };
29
30/*
31 * Populator callback
32 *
33 * This structure are used by the fconf_populate function and should only be
34 * defined by the FCONF_REGISTER_POPULATOR macro.
35 */
36struct fconf_populator {
37 /* Description of the data loaded by the callback */
Madhukar Pappireddy81519692019-12-06 15:46:42 -060038 const char *config_type;
Louis Mayencourt944ade82019-08-08 12:03:26 +010039 const char *info;
40
41 /* Callback used by fconf_populate function with a provided config dtb.
42 * Return 0 on success, err_code < 0 otherwise.
43 */
44 int (*populate)(uintptr_t config);
45};
46
Manish V Badarkhebb533c72020-06-11 22:17:30 +010047/* This function supports to load tb_fw_config and fw_config dtb */
Manish V Badarkhee069f8a2020-06-11 22:25:53 +010048int fconf_load_config(unsigned int image_id);
Louis Mayencourt5a15b2d2019-10-17 14:46:51 +010049
Louis Mayencourt944ade82019-08-08 12:03:26 +010050/* Top level populate function
51 *
52 * This function takes a configuration dtb and calls all the registered
53 * populator callback with it.
54 *
55 * Panic on error.
56 */
Madhukar Pappireddy81519692019-12-06 15:46:42 -060057void fconf_populate(const char *config_type, uintptr_t config);
Louis Mayencourt944ade82019-08-08 12:03:26 +010058
Louis Mayencourt81bd9162019-10-17 15:14:25 +010059/* FCONF specific getter */
60#define fconf__dtb_getter(prop) fconf_dtb_info.prop
61
62/* Structure used to locally keep a reference to the config dtb. */
63struct fconf_dtb_info_t {
64 uintptr_t base_addr;
65 size_t size;
66};
67
68extern struct fconf_dtb_info_t fconf_dtb_info;
69
Louis Mayencourt944ade82019-08-08 12:03:26 +010070#endif /* FCONF_H */