summaryrefslogtreecommitdiff
path: root/src/lib/fit_payload.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2019-05-13 16:34:16 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-06-21 09:21:01 +0000
commitb379f1964ec6b0a59b7d869154a8bc739eb55fc0 (patch)
tree87a7b8b6beb582bbc387a7e31877ce5a9591ca9f /src/lib/fit_payload.c
parent735ddc930f77950e1f292c574067106cf38e2e87 (diff)
downloadcoreboot-b379f1964ec6b0a59b7d869154a8bc739eb55fc0.tar.xz
fit: Refactor config node handling
This patch makes some minor refactoring to the way the FIT parser handles config nodes. A lot of this code was written in the dawn age of depthcharge when its device tree library wasn't as well-stocked yet, so some of it can be rewritten nicer with more high-level primitives. There's no point in storing both the string name and the actual FDT node of a FIT image node separately, since the latter also contains the former, so remove that. Also eliminate code for the case of not having an FDT (which makes no sense), and move some more FDT validity/compat checking into fit_update_compat() (mostly in anticipation of later changes). This patch was adapted from depthcharge's http://crosreview.com/1553456 with a couple of modifications specific to coreboot's custom FIT loading code. Change-Id: Ia79e0fd0e1159c4aca64c453b82a0379b133350d Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://review.coreboot.org/c/coreboot/+/32870 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/lib/fit_payload.c')
-rw-r--r--src/lib/fit_payload.c51
1 files changed, 23 insertions, 28 deletions
diff --git a/src/lib/fit_payload.c b/src/lib/fit_payload.c
index e0158f2129..4bc6622b19 100644
--- a/src/lib/fit_payload.c
+++ b/src/lib/fit_payload.c
@@ -176,37 +176,34 @@ void fit_payload(struct prog *payload)
struct fit_config_node *config = fit_load(data);
- if (!config || !config->kernel_node) {
+ if (!config) {
printk(BIOS_ERR, "ERROR: Could not load FIT\n");
rdev_munmap(prog_rdev(payload), data);
return;
}
- if (config->fdt_node) {
- dt = fdt_unflatten(config->fdt_node->data);
- if (!dt) {
- printk(BIOS_ERR,
- "ERROR: Failed to unflatten the FDT.\n");
- rdev_munmap(prog_rdev(payload), data);
- return;
- }
+ dt = fdt_unflatten(config->fdt->data);
+ if (!dt) {
+ printk(BIOS_ERR, "ERROR: Failed to unflatten the FDT.\n");
+ rdev_munmap(prog_rdev(payload), data);
+ return;
+ }
- dt_apply_fixups(dt);
+ dt_apply_fixups(dt);
- /* Insert coreboot specific information */
- add_cb_fdt_data(dt);
+ /* Insert coreboot specific information */
+ add_cb_fdt_data(dt);
- /* Update device_tree */
+ /* Update device_tree */
#if defined(CONFIG_LINUX_COMMAND_LINE)
- fit_update_chosen(dt, (char *)CONFIG_LINUX_COMMAND_LINE);
+ fit_update_chosen(dt, (char *)CONFIG_LINUX_COMMAND_LINE);
#endif
- fit_update_memory(dt);
- }
+ fit_update_memory(dt);
/* Collect infos for fit_payload_arch */
- kernel.size = config->kernel_node->size;
+ kernel.size = config->kernel->size;
fdt.size = dt ? dt_flat_size(dt) : 0;
- initrd.size = config->ramdisk_node ? config->ramdisk_node->size : 0;
+ initrd.size = config->ramdisk ? config->ramdisk->size : 0;
/* Invoke arch specific payload placement and fixups */
if (!fit_payload_arch(payload, config, &kernel, &fdt, &initrd)) {
@@ -216,17 +213,15 @@ void fit_payload(struct prog *payload)
return;
}
- /* Load the images to given position */
- if (config->fdt_node) {
- /* Update device_tree */
- if (config->ramdisk_node)
- fit_add_ramdisk(dt, (void *)initrd.offset, initrd.size);
+ /* Update ramdisk location in FDT */
+ if (config->ramdisk)
+ fit_add_ramdisk(dt, (void *)initrd.offset, initrd.size);
- pack_fdt(&fdt, dt);
- }
+ /* Repack FDT for handoff to kernel */
+ pack_fdt(&fdt, dt);
- if (config->ramdisk_node &&
- extract(&initrd, config->ramdisk_node)) {
+ if (config->ramdisk &&
+ extract(&initrd, config->ramdisk)) {
printk(BIOS_ERR, "ERROR: Failed to extract initrd\n");
prog_set_entry(payload, NULL, NULL);
rdev_munmap(prog_rdev(payload), data);
@@ -235,7 +230,7 @@ void fit_payload(struct prog *payload)
timestamp_add_now(TS_KERNEL_DECOMPRESSION);
- if (extract(&kernel, config->kernel_node)) {
+ if (extract(&kernel, config->kernel)) {
printk(BIOS_ERR, "ERROR: Failed to extract kernel\n");
prog_set_entry(payload, NULL, NULL);
rdev_munmap(prog_rdev(payload), data);