xref: /rk3399_ARM-atf/include/lib/fconf/fconf.h (revision ab1981db9ea793accf1279446b9f7666a3be04ca)
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 #define FCONF_REGISTER_POPULATOR(name, callback)				\
16 	__attribute__((used, section(".fconf_populator")))			\
17 	const struct fconf_populator name##__populator = {			\
18 		.info = #name,							\
19 		.populate = callback						\
20 	};
21 
22 /*
23  * Populator callback
24  *
25  * This structure are used by the fconf_populate function and should only be
26  * defined by the FCONF_REGISTER_POPULATOR macro.
27  */
28 struct fconf_populator {
29 	/* Description of the data loaded by the callback */
30 	const char *info;
31 
32 	/* Callback used by fconf_populate function with a provided config dtb.
33 	 * Return 0 on success, err_code < 0 otherwise.
34 	 */
35 	int (*populate)(uintptr_t config);
36 };
37 
38 /* Top level populate function
39  *
40  * This function takes a configuration dtb and calls all the registered
41  * populator callback with it.
42  *
43  *  Panic on error.
44  */
45 void fconf_populate(uintptr_t config);
46 
47 #endif /* FCONF_H */
48