aboutsummaryrefslogtreecommitdiff
path: root/src/lib/fit.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-05-16 16:04:19 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-06-21 09:22:07 +0000
commitfec4206299aefba05cae3bb82421635543ca1a2b (patch)
tree0d576cb7e987e4eef936880ebc2785ffa7d2efb9 /src/lib/fit.c
parent2855a0c14dc1e390a13fbaecf14e888d1339a0b9 (diff)
fit: Add device tree compression
This patch adds support for compressing individual device trees in the FIT image. In order to make this efficient, we'll have to pull the compatible property out of the FDT and store it directly in the config node of the FIT image, so that we don't have to scan (and therefore decompress) every single FDT on boot. Device tree compression is only supported for FIT images that have this external compatible property. For older images with no compression, we still support fallback to scanning the FDT for the property. This patch was adapted from depthcharge's http://crosreview.com/1553458 Change-Id: Ifcb6997782c480c8ef6692df17b66ad96264e623 Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32872 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/lib/fit.c')
-rw-r--r--src/lib/fit.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/src/lib/fit.c b/src/lib/fit.c
index 5fbcd77407..befedde9cf 100644
--- a/src/lib/fit.c
+++ b/src/lib/fit.c
@@ -136,6 +136,8 @@ static void config_node(struct device_tree_node *node)
config->fdt = find_image(prop->prop.data);
else if (!strcmp("ramdisk", prop->prop.name))
config->ramdisk = find_image(prop->prop.data);
+ else if (!strcmp("compatible", prop->prop.name))
+ config->compat = prop->prop;
}
list_insert_after(&config->list_node, &config_nodes);
@@ -391,35 +393,45 @@ void fit_update_memory(struct device_tree *tree)
*/
static int fit_update_compat(struct fit_config_node *config)
{
- if (config->fdt->compression != CBFS_COMPRESS_NONE) {
- printk(BIOS_ERR,
- "FDT compression not yet supported, skipping %s.\n",
- config->name);
- return -1;
- }
+ // If there was no "compatible" property in config node, this is a
+ // legacy FIT image. Must extract compat prop from FDT itself.
+ if (!config->compat.name) {
+ void *fdt_blob = config->fdt->data;
+ const struct fdt_header *fdt_header = fdt_blob;
+ uint32_t fdt_offset = be32_to_cpu(fdt_header->structure_offset);
+
+ if (config->fdt->compression != CBFS_COMPRESS_NONE) {
+ printk(BIOS_ERR,
+ "ERROR: config %s has a compressed FDT without "
+ "external compatible property, skipping.\n",
+ config->name);
+ return -1;
+ }
- void *fdt_blob = config->fdt->data;
- struct compat_string_entry *compat_node;
- const struct fdt_header *fdt_header =
- (const struct fdt_header *)fdt_blob;
- uint32_t fdt_offset = be32_to_cpu(fdt_header->structure_offset);
- size_t i = 0;
+ if (fdt_find_compat(fdt_blob, fdt_offset, &config->compat)) {
+ printk(BIOS_ERR,
+ "ERROR: Can't find compat string in FDT %s "
+ "for config %s, skipping.\n",
+ config->fdt->name, config->name);
+ return -1;
+ }
+ }
config->compat_pos = -1;
config->compat_rank = -1;
- if (!fdt_find_compat(fdt_blob, fdt_offset, &config->compat)) {
- list_for_each(compat_node, compat_strings, list_node) {
- int pos = fit_check_compat(&config->compat,
- compat_node->compat_string);
- if (pos >= 0) {
- config->compat_pos = pos;
- config->compat_rank = i;
- config->compat_string =
- compat_node->compat_string;
- break;
- }
- i++;
+ size_t i = 0;
+ struct compat_string_entry *compat_node;
+ list_for_each(compat_node, compat_strings, list_node) {
+ int pos = fit_check_compat(&config->compat,
+ compat_node->compat_string);
+ if (pos >= 0) {
+ config->compat_pos = pos;
+ config->compat_rank = i;
+ config->compat_string =
+ compat_node->compat_string;
+ break;
}
+ i++;
}
return 0;