fconf.h 1.66 KB
Newer Older
Louis Mayencourt's avatar
Louis Mayencourt committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
/*
 * Copyright (c) 2019-2020, ARM Limited. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef FCONF_H
#define FCONF_H

#include <stdint.h>

/* Public API */
#define FCONF_GET_PROPERTY(a, b, c)	a##__##b##_getter(c)

15
16
17
18
19
20
21
/*
 * This macro takes three arguments:
 *   config:	Configuration identifier
 *   name:	property namespace
 *   callback:	populate() function
 */
#define FCONF_REGISTER_POPULATOR(config, name, callback)			\
Louis Mayencourt's avatar
Louis Mayencourt committed
22
	__attribute__((used, section(".fconf_populator")))			\
Louis Mayencourt's avatar
Louis Mayencourt committed
23
	const struct fconf_populator (name##__populator) = {			\
24
		.config_type = (#config),					\
Louis Mayencourt's avatar
Louis Mayencourt committed
25
26
		.info = (#name),						\
		.populate = (callback)						\
Louis Mayencourt's avatar
Louis Mayencourt committed
27
28
29
30
31
32
33
34
35
36
	};

/*
 * Populator callback
 *
 * This structure are used by the fconf_populate function and should only be
 * defined by the FCONF_REGISTER_POPULATOR macro.
 */
struct fconf_populator {
	/* Description of the data loaded by the callback */
37
	const char *config_type;
Louis Mayencourt's avatar
Louis Mayencourt committed
38
39
40
41
42
43
44
45
	const char *info;

	/* Callback used by fconf_populate function with a provided config dtb.
	 * Return 0 on success, err_code < 0 otherwise.
	 */
	int (*populate)(uintptr_t config);
};

46
47
48
/* Load firmware configuration dtb */
void fconf_load_config(void);

Louis Mayencourt's avatar
Louis Mayencourt committed
49
50
51
52
53
54
55
/* Top level populate function
 *
 * This function takes a configuration dtb and calls all the registered
 * populator callback with it.
 *
 *  Panic on error.
 */
56
void fconf_populate(const char *config_type, uintptr_t config);
Louis Mayencourt's avatar
Louis Mayencourt committed
57

58
59
60
61
62
63
64
65
66
67
68
/* FCONF specific getter */
#define fconf__dtb_getter(prop)	fconf_dtb_info.prop

/* Structure used to locally keep a reference to the config dtb. */
struct fconf_dtb_info_t {
	uintptr_t base_addr;
	size_t size;
};

extern struct fconf_dtb_info_t fconf_dtb_info;

Louis Mayencourt's avatar
Louis Mayencourt committed
69
#endif /* FCONF_H */