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>
2019-08-08 12:03:26 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019-2020, ARM Limited. All rights reserved.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
#include <common/debug.h>
|
2019-10-17 15:14:25 +01:00
|
|
|
#include <common/fdt_wrappers.h>
|
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>
2019-08-08 12:03:26 +01:00
|
|
|
#include <lib/fconf/fconf.h>
|
|
|
|
#include <libfdt.h>
|
2019-10-17 14:46:51 +01:00
|
|
|
#include <plat/common/platform.h>
|
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>
2019-08-08 12:03:26 +01:00
|
|
|
#include <platform_def.h>
|
|
|
|
|
2019-10-17 15:14:25 +01:00
|
|
|
struct fconf_dtb_info_t fconf_dtb_info;
|
2019-10-17 14:46:51 +01:00
|
|
|
|
|
|
|
void fconf_load_config(void)
|
|
|
|
{
|
|
|
|
int err;
|
2019-12-17 13:17:25 +00:00
|
|
|
/* fconf FW_CONFIG and TB_FW_CONFIG are currently the same DTB */
|
2019-10-17 14:46:51 +01:00
|
|
|
image_info_t arm_tb_fw_info = {
|
|
|
|
.h.type = (uint8_t)PARAM_IMAGE_BINARY,
|
|
|
|
.h.version = (uint8_t)VERSION_2,
|
|
|
|
.h.size = (uint16_t)sizeof(image_info_t),
|
|
|
|
.h.attr = 0,
|
|
|
|
.image_base = ARM_TB_FW_CONFIG_BASE,
|
|
|
|
.image_max_size = (uint32_t)
|
2019-10-17 15:14:25 +01:00
|
|
|
(ARM_TB_FW_CONFIG_LIMIT - ARM_TB_FW_CONFIG_BASE)
|
2019-10-17 14:46:51 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
VERBOSE("FCONF: Loading FW_CONFIG\n");
|
|
|
|
err = load_auth_image(TB_FW_CONFIG_ID, &arm_tb_fw_info);
|
|
|
|
if (err != 0) {
|
|
|
|
/* Return if FW_CONFIG is not loaded */
|
|
|
|
VERBOSE("Failed to load FW_CONFIG\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* At this point we know that a DTB is indeed available */
|
2019-10-17 15:14:25 +01:00
|
|
|
fconf_dtb_info.base_addr = arm_tb_fw_info.image_base;
|
|
|
|
fconf_dtb_info.size = (size_t)arm_tb_fw_info.image_size;
|
|
|
|
|
|
|
|
#if !BL2_AT_EL3
|
|
|
|
image_desc_t *desc;
|
2019-10-17 14:46:51 +01:00
|
|
|
|
|
|
|
/* The BL2 ep_info arg0 is modified to point to FW_CONFIG */
|
|
|
|
desc = bl1_plat_get_image_desc(BL2_IMAGE_ID);
|
|
|
|
assert(desc != NULL);
|
2019-10-17 15:14:25 +01:00
|
|
|
desc->ep_info.args.arg0 = arm_tb_fw_info.image_base;
|
|
|
|
#endif
|
2019-10-17 14:46:51 +01:00
|
|
|
|
2019-10-17 15:14:25 +01:00
|
|
|
INFO("FCONF: FW_CONFIG loaded at address = 0x%lx\n", arm_tb_fw_info.image_base);
|
2019-10-17 14:46:51 +01:00
|
|
|
}
|
|
|
|
|
2019-12-06 21:46:42 +00:00
|
|
|
void fconf_populate(const char *config_type, uintptr_t config)
|
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>
2019-08-08 12:03:26 +01:00
|
|
|
{
|
|
|
|
assert(config != 0UL);
|
|
|
|
|
|
|
|
/* Check if the pointer to DTB is correct */
|
|
|
|
if (fdt_check_header((void *)config) != 0) {
|
2019-12-06 21:46:42 +00:00
|
|
|
ERROR("FCONF: Invalid DTB file passed for %s\n", config_type);
|
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>
2019-08-08 12:03:26 +01:00
|
|
|
panic();
|
|
|
|
}
|
|
|
|
|
2019-12-06 21:46:42 +00:00
|
|
|
INFO("FCONF: Reading %s firmware configuration file from: 0x%lx\n", config_type, config);
|
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>
2019-08-08 12:03:26 +01:00
|
|
|
|
|
|
|
/* 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));
|
|
|
|
|
2019-12-06 21:46:42 +00:00
|
|
|
if (strcmp(populator->config_type, config_type) == 0) {
|
|
|
|
INFO("FCONF: Reading firmware configuration information for: %s\n", populator->info);
|
|
|
|
if (populator->populate(config) != 0) {
|
|
|
|
/* TODO: handle property miss */
|
|
|
|
panic();
|
|
|
|
}
|
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>
2019-08-08 12:03:26 +01:00
|
|
|
}
|
|
|
|
}
|
2019-10-17 15:14:25 +01:00
|
|
|
|
|
|
|
/* save local pointer to the config dtb */
|
|
|
|
fconf_dtb_info.base_addr = config;
|
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>
2019-08-08 12:03:26 +01:00
|
|
|
}
|