summaryrefslogtreecommitdiffstats
path: root/commands/bootm.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-01-10 14:37:17 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-01-11 14:08:30 +0100
commitf30b191e36ddc086c3f58a572096d650fd5a6dfa (patch)
treef2d39d637cdaaf14151095b75d7993b6cade693f /commands/bootm.c
parent46dae550cdccfee407f8ced183f9102296cb79b7 (diff)
downloadbarebox-f30b191e36ddc086c3f58a572096d650fd5a6dfa.tar.gz
barebox-f30b191e36ddc086c3f58a572096d650fd5a6dfa.tar.xz
of: make of_get_fixed_tree more universally usable
Currently the bootm code uses of_fix_tree to apply the fixups to the devicetree given on the command line. This function assumes that there is enough space for the fixups available. Also on ARM we have to make sure the tree does not cross 1Mib boundaries. This patch moves the space allocation and alignment ensurance to of_get_fixed_tree and uses it in bootm. This is the first step for making of_get_fixed_tree the single point of devicetree handling in barebox. of_get_fixed_tree now takes an argument of the input fdt. If it is given, this one is used, otherwise an internal oftree is used which will be created in subsequent patches. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/bootm.c')
-rw-r--r--commands/bootm.c32
1 files changed, 8 insertions, 24 deletions
diff --git a/commands/bootm.c b/commands/bootm.c
index 483e6a1933..d8b846910f 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -139,9 +139,7 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
{
enum filetype ft;
struct fdt_header *fdt, *fixfdt;
- int ret;
size_t size;
- unsigned int align;
if (bootm_verbose(data))
printf("Loading oftree from '%s'\n", oftree);
@@ -190,36 +188,18 @@ static int bootm_open_oftree(struct image_data *data, const char *oftree, int nu
file_type_to_string(ft));
}
- /*
- * ARM Linux uses a single 1MiB section (with 1MiB alignment)
- * for mapping the devicetree, so we are not allowed to cross
- * 1MiB boundaries.
- */
- align = 1 << fls(size + OFTREE_SIZE_INCREASE - 1);
-
- fixfdt = xmemalign(align, size + OFTREE_SIZE_INCREASE);
- memcpy(fixfdt, fdt, size);
-
-
- ret = fdt_open_into(fdt, fixfdt, size + OFTREE_SIZE_INCREASE);
+ fixfdt = of_get_fixed_tree(fdt);
+ if (!fixfdt)
+ return -EINVAL;
free(fdt);
- if (ret) {
- printf("unable to parse %s\n", oftree);
- return -ENODEV;
- }
-
- ret = of_fix_tree(fixfdt);
- if (ret)
- return ret;
-
if (bootm_verbose(data) > 1)
fdt_print(fixfdt, "/");
data->oftree = fixfdt;
- return ret;
+ return 0;
}
#endif
@@ -420,6 +400,10 @@ static int do_bootm(int argc, char *argv[])
ret = bootm_open_oftree(&data, oftree, oftree_num);
if (ret)
goto err_out;
+ } else {
+ data.oftree = of_get_fixed_tree(NULL);
+ if (bootm_verbose(&data) && data.oftree)
+ printf("using internal devicetree\n");
}
#endif
if (data.os_address == UIMAGE_SOME_ADDRESS)