]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - arch/x86/lib/relocate.c
x86: Support relocation of FDT on start-up
[karo-tx-uboot.git] / arch / x86 / lib / relocate.c
index 200baaba6a2707c28fabc82cb93054158cdff5c0..3a38e52ac9d8f6960dbf87dc601d833277416d8c 100644 (file)
@@ -32,6 +32,7 @@
  */
 
 #include <common.h>
+#include <libfdt.h>
 #include <malloc.h>
 #include <asm/u-boot-x86.h>
 #include <asm/relocate.h>
@@ -46,6 +47,22 @@ int copy_uboot_to_ram(void)
        return 0;
 }
 
+int copy_fdt_to_ram(void)
+{
+       if (gd->arch.new_fdt) {
+               ulong fdt_size;
+
+               fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32);
+
+               memcpy(gd->arch.new_fdt, gd->fdt_blob, fdt_size);
+               debug("Relocated fdt from %p to %p, size %lx\n",
+                      gd->fdt_blob, gd->arch.new_fdt, fdt_size);
+               gd->fdt_blob = gd->arch.new_fdt;
+       }
+
+       return 0;
+}
+
 int clear_bss(void)
 {
        ulong dst_addr = (ulong)&__bss_start + gd->reloc_off;
@@ -80,12 +97,12 @@ int do_elf_reloc_fixups(void)
 
                        /* Check that the target points into .text */
                        if (*offset_ptr_ram >= CONFIG_SYS_TEXT_BASE &&
-                                       *offset_ptr_ram <
+                                       *offset_ptr_ram <=
                                        (CONFIG_SYS_TEXT_BASE + size)) {
                                *offset_ptr_ram += gd->reloc_off;
                        }
                }
-       } while (re_src++ < re_end);
+       } while (++re_src < re_end);
 
        return 0;
 }