MIPS: Add support for vmlinuz.bin appended dtb
authorJonas Gorski <jogo@openwrt.org>
Sun, 12 Apr 2015 10:24:59 +0000 (12:24 +0200)
committerRalf Baechle <ralf@linux-mips.org>
Sun, 21 Jun 2015 19:54:15 +0000 (21:54 +0200)
Add support for detecting a vmlinuz.bin appended dtb and overriding
the boot arguments to match the UHI interface.

To ensure _edata / __apendend_dtb points to the actual end of the
binary, align the data section to 16 bytes instead of the address
cursor.

Due to ld.script not going through the preprocessor, we can't check
for MIPS_ZBOOT_APPENDED_DTB being enabled, so always reserve space
for it. It should have no consequences for booting without it enabled
except 1 MiB more ram usage during the uncompressing stage.

Signed-off-by: Jonas Gorski <jogo@openwrt.org>
Cc: linux-mips@linux-mips.org
Cc: devicetree@vger.kernel.org
Cc: John Crispin <blogic@openwrt.org>
Cc: Kevin Cernekee <cernekee@gmail.com>
Cc: Florian Fainelli <f.fainelli@gmail.com>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: Andrew Bresticker <abrestic@chromium.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>
Cc: Paul Burton <paul.burton@imgtec.com>
Cc: James Hartley <James.Hartley@imgtec.com>
Patchwork: https://patchwork.linux-mips.org/patch/9741/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/Kconfig
arch/mips/boot/compressed/head.S
arch/mips/boot/compressed/ld.script

index 7cb5f6dbaeeeb55fbc4c221ae889a3f213e7f2f1..a2ee09c8056f1ff55f32dcfd4421ee904d8140a8 100644 (file)
@@ -2702,6 +2702,24 @@ choice
                  look like a DTB header after a reboot if no actual DTB is appended
                  to vmlinux.bin.  Do not leave this option active in a production kernel
                  if you don't intend to always append a DTB.
+
+       config MIPS_ZBOOT_APPENDED_DTB
+               bool "vmlinuz.bin"
+               depends on SYS_SUPPORTS_ZBOOT
+               help
+                 With this option, the boot code will look for a device tree binary
+                 DTB) appended to raw vmlinuz.bin (with decompressor).
+                 (e.g. cat vmlinuz.bin <filename>.dtb > vmlinuz_w_dtb).
+
+                 This is meant as a backward compatibility convenience for those
+                 systems with a bootloader that can't be upgraded to accommodate
+                 the documented boot protocol using a device tree.
+
+                 Beware that there is very little in terms of protection against
+                 this option being confused by leftover garbage in memory that might
+                 look like a DTB header after a reboot if no actual DTB is appended
+                 to vmlinuz.bin.  Do not leave this option active in a production kernel
+                 if you don't intend to always append a DTB.
 endchoice
 
 endmenu
index 409cb483a9ffc5bf1045a0a928b44c9a78904f28..c580e853b9fbe3904456857ab4eb76cfb04aba98 100644 (file)
@@ -25,6 +25,22 @@ start:
        move    s2, a2
        move    s3, a3
 
+#ifdef CONFIG_MIPS_ZBOOT_APPENDED_DTB
+       PTR_LA  t0, __appended_dtb
+#ifdef CONFIG_CPU_BIG_ENDIAN
+       li      t1, 0xd00dfeed
+#else
+       li      t1, 0xedfe0dd0
+#endif
+       lw      t2, (t0)
+       bne     t1, t2, not_found
+        nop
+
+       move    s1, t0
+       PTR_LI  s0, -2
+not_found:
+#endif
+
        /* Clear BSS */
        PTR_LA  a0, _edata
        PTR_LA  a2, _end
index 5a33409c7f63b09bf7599ed77a4dd762c99f8ead..2ed08fbef8e7505a022629a0e183a0c004a44ec6 100644 (file)
@@ -29,8 +29,12 @@ SECTIONS
                *(.image)
                __image_end = .;
                CONSTRUCTORS
+               . = ALIGN(16);
        }
-       . = ALIGN(16);
+       __appended_dtb = .;
+       /* leave space for appended DTB */
+       . += 0x100000;
+
        _edata = .;
        /* End of data section */