1 From 318c1fce4aeef298cbb6153416c499c94ad7cda0 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Tue, 24 Jun 2014 10:53:15 +0200
4 Subject: [PATCH RFC v3] MIPS: add support for vmlinux.bin appended DTB
6 Add support for populating initial_boot_params through a dtb
7 blob appended to raw vmlinux.bin.
9 Signed-off-by: Jonas Gorski <jogo@openwrt.org>
13 * fixed !smp kernels (TODO: move it to its own patch
17 * changed all occurences of vmlinux to vmlinux.bin
18 * clarified this applies to the raw vmlinux.bin without decompressor
19 * s/initial_device_params/initial_boot_params/
21 Initial comments by me still valid:
23 Mostly adapted from how ARM is doing it.
25 Sent as an RFC PATCH because I am not sure if this is the right way to
26 it, and whether storing the pointer in initial_boot_params is a good
27 idea, or a new variable should be introduced.
29 The reasoning for initial_boot_params is that there is no common
30 MIPS interface yet, so the next best thing was using that. This also
31 has the advantage of keeping the original fw_args intact.
33 This patch works for me on bcm63xx, where the bootloader expects
34 an lzma compressed kernel, so I didn't want to double compress using
35 the in-kernel compressed kernel support.
37 Completely untested on anything except MIPS32 / big endian.
39 arch/mips/Kconfig | 18 ++++++++++++++++++
40 arch/mips/kernel/head.S | 19 +++++++++++++++++++
41 arch/mips/kernel/vmlinux.lds.S | 7 +++++++
42 3 files changed, 43 insertions(+)
44 --- a/arch/mips/Kconfig
45 +++ b/arch/mips/Kconfig
46 @@ -2519,6 +2519,24 @@ config RAPIDIO
48 source "drivers/rapidio/Kconfig"
50 +config MIPS_APPENDED_DTB
51 + bool "Use appended device tree blob to vmlinux.bin (EXPERIMENTAL)"
54 + With this option, the boot code will look for a device tree binary
55 + DTB) appended to raw vmlinux.bin (without decompressor).
56 + (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_w_dtb).
58 + This is meant as a backward compatibility convenience for those
59 + systems with a bootloader that can't be upgraded to accommodate
60 + the documented boot protocol using a device tree.
62 + Beware that there is very little in terms of protection against
63 + this option being confused by leftover garbage in memory that might
64 + look like a DTB header after a reboot if no actual DTB is appended
65 + to vmlinux.bin. Do not leave this option active in a production kernel
66 + if you don't intend to always append a DTB.
70 menu "Executable file formats"
71 --- a/arch/mips/kernel/head.S
72 +++ b/arch/mips/kernel/head.S
73 @@ -139,6 +139,22 @@ NESTED(kernel_entry, 16, sp) # kernel
75 #endif /* CONFIG_MIPS_MT_SMTC */
77 +#ifdef CONFIG_MIPS_APPENDED_DTB
78 + PTR_LA t0, __appended_dtb
81 +#ifdef CONFIG_CPU_BIG_ENDIAN
82 + PTR_LI t1, 0xd00dfeed
84 + PTR_LI t1, 0xedfe0dd0
87 + bne t1, t2, not_found
89 + PTR_LA t3, __appended_dtb
93 PTR_LA t0, __bss_start # clear .bss
95 PTR_LA t1, __bss_stop - LONGSIZE
96 @@ -152,6 +168,10 @@ NESTED(kernel_entry, 16, sp) # kernel
100 +#ifdef CONFIG_MIPS_APPENDED_DTB
101 + LONG_S t3, initial_boot_params
104 MTC0 zero, CP0_CONTEXT # clear context register
105 PTR_LA $28, init_thread_union
106 /* Set the SP after an empty pt_regs. */
107 --- a/arch/mips/kernel/vmlinux.lds.S
108 +++ b/arch/mips/kernel/vmlinux.lds.S
109 @@ -125,8 +125,14 @@ SECTIONS
115 PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
117 +#ifdef CONFIG_MIPS_APPENDED_DTB
118 + __appended_dtb = .;
119 + /* leave space for appended DTB */
123 * Align to 64K in attempt to eliminate holes before the
124 * .bss..swapper_pg_dir section at the start of .bss. This