From: David A. Long dave.long@linaro.org
Add a new "fdt_high" enviroment variable. This can be used to control (or prevent) the relocation of the flattened device tree on boot. It can be used to prevent relocation of the fdt into highmem. The variable behaves similarly to the existing "initrd_high" variable.
Signed-off-by: David A. Long dave.long@linaro.org --- common/image.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 35 insertions(+), 10 deletions(-)
diff --git a/common/image.c b/common/image.c index e542a57..d565f33 100644 --- a/common/image.c +++ b/common/image.c @@ -1234,8 +1234,10 @@ int boot_relocate_fdt (struct lmb *lmb, char **of_flat_tree, ulong *of_size) { void *fdt_blob = *of_flat_tree; void *of_start = 0; + char *fdt_high; ulong of_len = 0; int err; + int disable_relocation=0;
/* nothing to do */ if (*of_size == 0) @@ -1249,7 +1251,24 @@ int boot_relocate_fdt (struct lmb *lmb, char **of_flat_tree, ulong *of_size) /* position on a 4K boundary before the alloc_current */ /* Pad the FDT by a specified amount */ of_len = *of_size + CONFIG_SYS_FDT_PAD; - of_start = (void *)(unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, + + /* If fdt_high is set use it to select the relocation address */ + fdt_high = getenv("fdt_high"); + if(fdt_high) { + void *desired_addr = (void *) simple_strtoul(fdt_high, NULL, 16); + + if(((ulong) desired_addr) == ~0UL || desired_addr == NULL) { + /* Zero or all ones means use fdt in place */ + desired_addr = fdt_blob; + disable_relocation = 1; + } + of_start = (void *)(unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, ((ulong) desired_addr) + of_len); + if(of_start != desired_addr) { + puts("Failed using fdt_high value for Device Tree"); + goto error; + } + } else + of_start = (void *)(unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, getenv_bootm_mapsize() + getenv_bootm_low());
if (of_start == 0) { @@ -1257,18 +1276,24 @@ int boot_relocate_fdt (struct lmb *lmb, char **of_flat_tree, ulong *of_size) goto error; }
- debug ("## device tree at %p ... %p (len=%ld [0x%lX])\n", - fdt_blob, fdt_blob + *of_size - 1, of_len, of_len); + if(disable_relocation) { + /* We assume there is space after the existing fdt to use for padding */ + fdt_set_totalsize(of_start, of_len); + printf(" Using Device Tree in place at %p, end %p\n", of_start, of_start+of_len-1); + } else { + debug ("## device tree at %p ... %p (len=%ld [0x%lX])\n", + fdt_blob, fdt_blob + *of_size - 1, of_len, of_len);
- printf (" Loading Device Tree to %p, end %p ... ", - of_start, of_start + of_len - 1); + printf (" Loading Device Tree to %p, end %p ... ", + of_start, of_start + of_len - 1);
- err = fdt_open_into (fdt_blob, of_start, of_len); - if (err != 0) { - fdt_error ("fdt move failed"); - goto error; + err = fdt_open_into (fdt_blob, of_start, of_len); + if (err != 0) { + fdt_error ("fdt move failed"); + goto error; + } + puts ("OK\n"); } - puts ("OK\n");
*of_flat_tree = of_start; *of_size = of_len;
Dear "David A. Long",
In message 20110708175540.2334.92924.stgit@dave-Dell-System-XPS-L502X you wrote:
From: David A. Long dave.long@linaro.org
Add a new "fdt_high" enviroment variable. This can be used to control (or prevent) the relocation of the flattened device tree on boot. It can be used to prevent relocation of the fdt into highmem. The variable behaves similarly to the existing "initrd_high" variable.
Signed-off-by: David A. Long dave.long@linaro.org
common/image.c | 45 +++++++++++++++++++++++++++++++++++---------- 1 files changed, 35 insertions(+), 10 deletions(-)
Please add appropriate documentation to the README as well.
of_start = (void *)(unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, ((ulong) desired_addr) + of_len);
Line too long. Please fix globally.
if(of_start != desired_addr) {
puts("Failed using fdt_high value for Device Tree");
goto error;
}
- } else
of_start = (void *)(unsigned long)lmb_alloc_base(lmb, of_len, 0x1000, getenv_bootm_mapsize() + getenv_bootm_low());
In U-Boot we require braces around multi-line statements.
The alignment of the second line is not corrrect as well.
And Cc: the U-Boot ML, please.
Best regards,
Wolfgang Denk