diff options
author | Louis Mayencourt <louis.mayencourt@arm.com> | 2019-08-08 12:03:26 +0100 |
---|---|---|
committer | Louis Mayencourt <louis.mayencourt@arm.com> | 2020-02-07 13:29:09 +0000 |
commit | ab1981db9ea793accf1279446b9f7666a3be04ca (patch) | |
tree | 665d7fbb82c1d741bf5ec049b015034f87fab720 /lib/fconf | |
parent | d6b44b10e9e975f4785cfcadf70737efe0b14e4b (diff) | |
download | arm-trusted-firmware-ab1981db9ea793accf1279446b9f7666a3be04ca.tar.gz |
fconf: initial commit
Introduce the Firmware CONfiguration Framework (fconf).
The fconf is an abstraction layer for platform specific data, allowing
a "property" to be queried and a value retrieved without the requesting
entity knowing what backing store is being used to hold the data.
The default backing store used is C structure. If another backing store
has to be used, the platform integrator needs to provide a "populate()"
function to fill the corresponding C structure.
The "populate()" function must be registered to the fconf framework with
the "FCONF_REGISTER_POPULATOR()". This ensures that the function would
be called inside the "fconf_populate()" function.
A two level macro is used as getter:
- the first macro takes 3 parameters and converts it to a function
call: FCONF_GET_PROPERTY(a,b,c) -> a__b_getter(c).
- the second level defines a__b_getter(c) to the matching C structure,
variable, array, function, etc..
Ex: Get a Chain of trust property:
1) FCONF_GET_PROPERY(tbbr, cot, BL2_id) -> tbbr__cot_getter(BL2_id)
2) tbbr__cot_getter(BL2_id) -> cot_desc_ptr[BL2_id]
Change-Id: Id394001353ed295bc680c3f543af0cf8da549469
Signed-off-by: Louis Mayencourt <louis.mayencourt@arm.com>
Diffstat (limited to 'lib/fconf')
-rw-r--r-- | lib/fconf/fconf.c | 40 | ||||
-rw-r--r-- | lib/fconf/fconf.mk | 11 |
2 files changed, 51 insertions, 0 deletions
diff --git a/lib/fconf/fconf.c b/lib/fconf/fconf.c new file mode 100644 index 000000000..387e758d2 --- /dev/null +++ b/lib/fconf/fconf.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2019-2020, ARM Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include <assert.h> + +#include <common/debug.h> +#include <lib/fconf/fconf.h> +#include <libfdt.h> +#include <platform_def.h> + +void fconf_populate(uintptr_t config) +{ + assert(config != 0UL); + + /* Check if the pointer to DTB is correct */ + if (fdt_check_header((void *)config) != 0) { + ERROR("FCONF: Invalid DTB file passed for FW_CONFIG\n"); + panic(); + } + + INFO("FCONF: Reading firmware configuration file from: 0x%lx\n", config); + + /* Go through all registered populate functions */ + IMPORT_SYM(struct fconf_populator *, __FCONF_POPULATOR_START__, start); + IMPORT_SYM(struct fconf_populator *, __FCONF_POPULATOR_END__, end); + const struct fconf_populator *populator; + + for (populator = start; populator != end; populator++) { + assert((populator->info != NULL) && (populator->populate != NULL)); + + INFO("FCONF: Reading firmware configuration information for: %s\n", populator->info); + if (populator->populate(config) != 0) { + /* TODO: handle property miss */ + panic(); + } + } +} diff --git a/lib/fconf/fconf.mk b/lib/fconf/fconf.mk new file mode 100644 index 000000000..0813c73cc --- /dev/null +++ b/lib/fconf/fconf.mk @@ -0,0 +1,11 @@ +# +# Copyright (c) 2019-2020, ARM Limited. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +# Add Firmware Configuration files +FCONF_SOURCES := lib/fconf/fconf.c + +BL1_SOURCES += ${FCONF_SOURCES} +BL2_SOURCES += ${FCONF_SOURCES} |