1 /*
2  * Copyright (c) 2019-2020, ARM Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef FCONF_H
8 #define FCONF_H
9 
10 #include <stdint.h>
11 
12 /* Public API */
13 #define FCONF_GET_PROPERTY(a, b, c)	a##__##b##_getter(c)
14 
15 /*
16  * This macro takes three arguments:
17  *   config:	Configuration identifier
18  *   name:	property namespace
19  *   callback:	populate() function
20  */
21 #define FCONF_REGISTER_POPULATOR(config, name, callback)			\
22 	__attribute__((used, section(".fconf_populator")))			\
23 	const struct fconf_populator (name##__populator) = {			\
24 		.config_type = (#config),					\
25 		.info = (#name),						\
26 		.populate = (callback)						\
27 	};
28 
29 /*
30  * Populator callback
31  *
32  * This structure are used by the fconf_populate function and should only be
33  * defined by the FCONF_REGISTER_POPULATOR macro.
34  */
35 struct fconf_populator {
36 	/* Description of the data loaded by the callback */
37 	const char *config_type;
38 	const char *info;
39 
40 	/* Callback used by fconf_populate function with a provided config dtb.
41 	 * Return 0 on success, err_code < 0 otherwise.
42 	 */
43 	int (*populate)(uintptr_t config);
44 };
45 
46 /* This function supports to load tb_fw_config and fw_config dtb */
47 int fconf_load_config(unsigned int image_id);
48 
49 /* Top level populate function
50  *
51  * This function takes a configuration dtb and calls all the registered
52  * populator callback with it.
53  *
54  *  Panic on error.
55  */
56 void fconf_populate(const char *config_type, uintptr_t config);
57 
58 /* FCONF specific getter */
59 #define fconf__dtb_getter(prop)	fconf_dtb_info.prop
60 
61 /* Structure used to locally keep a reference to the config dtb. */
62 struct fconf_dtb_info_t {
63 	uintptr_t base_addr;
64 	size_t size;
65 };
66 
67 extern struct fconf_dtb_info_t fconf_dtb_info;
68 
69 #endif /* FCONF_H */
70