diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 2a7d0f5..00c4908 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -169,16 +169,12 @@ } if (IS_BUILTIN(CONFIG_OFTREE)) { - struct device_node *node; - - node = of_unflatten_dtb(NULL, oftree); - if (!node) { + data->of_root_node = of_unflatten_dtb(NULL, oftree); + if (!data->of_root_node) { pr_err("unable to unflatten devicetree\n"); ret = -EINVAL; goto err_free; } - - data->oftree = of_get_fixed_tree(node); } else { data->oftree = oftree; } diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig index d124065..db269dd 100644 --- a/arch/ppc/Kconfig +++ b/arch/ppc/Kconfig @@ -4,6 +4,7 @@ select HAS_KALLSYMS select HAS_MODULES select HAVE_CONFIGURABLE_MEMORY_LAYOUT + select OFTREE default y choice diff --git a/arch/ppc/lib/ppclinux.c b/arch/ppc/lib/ppclinux.c index 95dc83b..ef69ead 100644 --- a/arch/ppc/lib/ppclinux.c +++ b/arch/ppc/lib/ppclinux.c @@ -18,6 +18,14 @@ if (!data->os_res) return -EINVAL; + data->oftree = of_get_fixed_tree(data->of_root_node); + if (!data->oftree) { + pr_err("bootm: No devicetree given.\n"); + return -EINVAL; + } + + fdt_add_reserve_map(data->oftree); + kernel = (void *)(data->os_address + data->os_entry); /* diff --git a/commands/bootm.c b/commands/bootm.c index 65a75e2..ea5a35b 100644 --- a/commands/bootm.c +++ b/commands/bootm.c @@ -138,9 +138,8 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int num) { enum filetype ft; - struct fdt_header *fdt, *fixfdt; + struct fdt_header *fdt; size_t size; - struct device_node *node; printf("Loading devicetree from '%s'\n", oftree); @@ -188,23 +187,14 @@ file_type_to_string(ft)); } - node = of_unflatten_dtb(NULL, fdt); - if (!node) { + data->of_root_node = of_unflatten_dtb(NULL, fdt); + if (!data->of_root_node) { pr_err("unable to unflatten devicetree\n"); return -EINVAL; } - if (bootm_verbose(data) > 1) - of_print_nodes(node, 0); - - fixfdt = of_get_fixed_tree(node); - if (!fixfdt) - return -EINVAL; - free(fdt); - data->oftree = fixfdt; - return 0; } #endif @@ -408,10 +398,14 @@ if (ret) goto err_out; } else { - data.oftree = of_get_fixed_tree(NULL); - if (bootm_verbose(&data) && data.oftree) + data.of_root_node = of_get_root_node(); + if (bootm_verbose(&data) && data.of_root_node) printf("using internal devicetree\n"); } + + + if (bootm_verbose(&data) > 1 && data.of_root_node) + of_print_nodes(data.of_root_node, 0); #endif if (data.os_address == UIMAGE_SOME_ADDRESS) data.os_address = UIMAGE_INVALID_ADDRESS; diff --git a/include/boot.h b/include/boot.h index 3ce0de1..971a403 100644 --- a/include/boot.h +++ b/include/boot.h @@ -41,6 +41,7 @@ unsigned long initrd_address; + struct device_node *of_root_node; struct fdt_header *oftree; int verify;