bootm: Pass unflattened devicetree to handlers
This makes it possible to modify the tree in the handlers. This is necessary because the initrd addresses are only known inside the handlers, but not to the generic bootm code. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
0ba9a2347a
commit
6d6edfcf53
|
@ -169,16 +169,12 @@ static int do_bootz_linux_fdt(int fd, struct image_data *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_BUILTIN(CONFIG_OFTREE)) {
|
if (IS_BUILTIN(CONFIG_OFTREE)) {
|
||||||
struct device_node *node;
|
data->of_root_node = of_unflatten_dtb(NULL, oftree);
|
||||||
|
if (!data->of_root_node) {
|
||||||
node = of_unflatten_dtb(NULL, oftree);
|
|
||||||
if (!node) {
|
|
||||||
pr_err("unable to unflatten devicetree\n");
|
pr_err("unable to unflatten devicetree\n");
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto err_free;
|
goto err_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
data->oftree = of_get_fixed_tree(node);
|
|
||||||
} else {
|
} else {
|
||||||
data->oftree = oftree;
|
data->oftree = oftree;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ config PPC
|
||||||
select HAS_KALLSYMS
|
select HAS_KALLSYMS
|
||||||
select HAS_MODULES
|
select HAS_MODULES
|
||||||
select HAVE_CONFIGURABLE_MEMORY_LAYOUT
|
select HAVE_CONFIGURABLE_MEMORY_LAYOUT
|
||||||
|
select OFTREE
|
||||||
default y
|
default y
|
||||||
|
|
||||||
choice
|
choice
|
||||||
|
|
|
@ -18,6 +18,14 @@ static int do_bootm_linux(struct image_data *data)
|
||||||
if (!data->os_res)
|
if (!data->os_res)
|
||||||
return -EINVAL;
|
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);
|
kernel = (void *)(data->os_address + data->os_entry);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -138,9 +138,8 @@ static int bootm_open_initrd_uimage(struct image_data *data)
|
||||||
static int bootm_open_oftree(struct image_data *data, const char *oftree, int num)
|
static int bootm_open_oftree(struct image_data *data, const char *oftree, int num)
|
||||||
{
|
{
|
||||||
enum filetype ft;
|
enum filetype ft;
|
||||||
struct fdt_header *fdt, *fixfdt;
|
struct fdt_header *fdt;
|
||||||
size_t size;
|
size_t size;
|
||||||
struct device_node *node;
|
|
||||||
|
|
||||||
printf("Loading devicetree from '%s'\n", oftree);
|
printf("Loading devicetree from '%s'\n", oftree);
|
||||||
|
|
||||||
|
@ -188,23 +187,14 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
|
||||||
file_type_to_string(ft));
|
file_type_to_string(ft));
|
||||||
}
|
}
|
||||||
|
|
||||||
node = of_unflatten_dtb(NULL, fdt);
|
data->of_root_node = of_unflatten_dtb(NULL, fdt);
|
||||||
if (!node) {
|
if (!data->of_root_node) {
|
||||||
pr_err("unable to unflatten devicetree\n");
|
pr_err("unable to unflatten devicetree\n");
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bootm_verbose(data) > 1)
|
|
||||||
of_print_nodes(node, 0);
|
|
||||||
|
|
||||||
fixfdt = of_get_fixed_tree(node);
|
|
||||||
if (!fixfdt)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
free(fdt);
|
free(fdt);
|
||||||
|
|
||||||
data->oftree = fixfdt;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -408,10 +398,14 @@ static int do_bootm(int argc, char *argv[])
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err_out;
|
goto err_out;
|
||||||
} else {
|
} else {
|
||||||
data.oftree = of_get_fixed_tree(NULL);
|
data.of_root_node = of_get_root_node();
|
||||||
if (bootm_verbose(&data) && data.oftree)
|
if (bootm_verbose(&data) && data.of_root_node)
|
||||||
printf("using internal devicetree\n");
|
printf("using internal devicetree\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (bootm_verbose(&data) > 1 && data.of_root_node)
|
||||||
|
of_print_nodes(data.of_root_node, 0);
|
||||||
#endif
|
#endif
|
||||||
if (data.os_address == UIMAGE_SOME_ADDRESS)
|
if (data.os_address == UIMAGE_SOME_ADDRESS)
|
||||||
data.os_address = UIMAGE_INVALID_ADDRESS;
|
data.os_address = UIMAGE_INVALID_ADDRESS;
|
||||||
|
|
|
@ -41,6 +41,7 @@ struct image_data {
|
||||||
|
|
||||||
unsigned long initrd_address;
|
unsigned long initrd_address;
|
||||||
|
|
||||||
|
struct device_node *of_root_node;
|
||||||
struct fdt_header *oftree;
|
struct fdt_header *oftree;
|
||||||
|
|
||||||
int verify;
|
int verify;
|
||||||
|
|
Loading…
Reference in New Issue