* [PATCH RFC v2] MIPS: add support for vmlinux.bin appended DTB
@ 2014-07-12 10:49 Jonas Gorski
2014-08-08 18:39 ` Jonas Gorski
0 siblings, 1 reply; 3+ messages in thread
From: Jonas Gorski @ 2014-07-12 10:49 UTC (permalink / raw)
To: linux-mips; +Cc: Ralf Baechle, John Crispin, James Hogan, Markos Chandras
Add support for populating initial_boot_params through a dtb
blob appended to raw vmlinux.bin.
Signed-off-by: Jonas Gorski <jogo@openwrt.org>
---
Changes RFC v1 -> v2
* changed all occurences of vmlinux to vmlinux.bin
* clarified this applies to the raw vmlinux.bin without decompressor
* s/initial_device_params/initial_boot_params/
Initial comments by me still valid:
Mostly adapted from how ARM is doing it.
Sent as an RFC PATCH because I am not sure if this is the right way to
it, and whether storing the pointer in initial_boot_params is a good
idea, or a new variable should be introduced.
The reasoning for initial_boot_params is that there is no common
MIPS interface yet, so the next best thing was using that. This also
has the advantage of keeping the original fw_args intact.
This patch works for me on bcm63xx, where the bootloader expects
an lzma compressed kernel, so I didn't want to double compress using
the in-kernel compressed kernel support.
Completely untested on anything except MIPS32 / big endian.
arch/mips/Kconfig | 18 ++++++++++++++++++
arch/mips/kernel/head.S | 19 +++++++++++++++++++
arch/mips/kernel/vmlinux.lds.S | 6 ++++++
3 files changed, 43 insertions(+)
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 3f05b56..21c6d51 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -2476,6 +2476,24 @@ config USE_OF
select OF_EARLY_FLATTREE
select IRQ_DOMAIN
+config MIPS_APPENDED_DTB
+ bool "Use appended device tree blob to vmlinux.bin (EXPERIMENTAL)"
+ depends on OF
+ help
+ With this option, the boot code will look for a device tree binary
+ DTB) appended to raw vmlinux.bin (without decompressor).
+ (e.g. cat vmlinux.bin <filename>.dtb > vmlinux_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 vmlinux.bin. Do not leave this option active in a production kernel
+ if you don't intend to always append a DTB.
+
endmenu
config LOCKDEP_SUPPORT
diff --git a/arch/mips/kernel/head.S b/arch/mips/kernel/head.S
index 95afd66..72c1049 100644
--- a/arch/mips/kernel/head.S
+++ b/arch/mips/kernel/head.S
@@ -93,7 +93,22 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
PTR_LA t0, 0f
jr t0
0:
+#ifdef CONFIG_MIPS_APPENDED_DTB
+ PTR_LA t0, __appended_dtb
+ PTR_LI t3, 0
+#ifdef CONFIG_CPU_BIG_ENDIAN
+ PTR_LI t1, 0xd00dfeed
+#else
+ PTR_LI t1, 0xedfe0dd0
+#endif
+ LONG_L t2, (t0)
+ bne t1, t2, not_found
+
+ PTR_LA t3, __appended_dtb
+
+not_found:
+#endif
PTR_LA t0, __bss_start # clear .bss
LONG_S zero, (t0)
PTR_LA t1, __bss_stop - LONGSIZE
@@ -107,6 +122,10 @@ NESTED(kernel_entry, 16, sp) # kernel entry point
LONG_S a2, fw_arg2
LONG_S a3, fw_arg3
+#ifdef CONFIG_MIPS_APPENDED_DTB
+ LONG_S t3, initial_boot_params
+#endif
+
MTC0 zero, CP0_CONTEXT # clear context register
PTR_LA $28, init_thread_union
/* Set the SP after an empty pt_regs. */
diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 3b46f7c..8009530 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -127,6 +127,12 @@ SECTIONS
}
PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
+
+#ifdef CONFIG_MIPS_APPENDED_DTB
+ __appended_dtb = .;
+ /* leave space for appended DTB */
+ . = . + 0x100000;
+#endif
/*
* Align to 64K in attempt to eliminate holes before the
* .bss..swapper_pg_dir section at the start of .bss. This
--
2.0.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH RFC v2] MIPS: add support for vmlinux.bin appended DTB
2014-07-12 10:49 [PATCH RFC v2] MIPS: add support for vmlinux.bin appended DTB Jonas Gorski
@ 2014-08-08 18:39 ` Jonas Gorski
2015-04-10 18:17 ` Aaro Koskinen
0 siblings, 1 reply; 3+ messages in thread
From: Jonas Gorski @ 2014-08-08 18:39 UTC (permalink / raw)
To: MIPS Mailing List
Cc: Ralf Baechle, John Crispin, James Hogan, Markos Chandras
On Sat, Jul 12, 2014 at 12:49 PM, Jonas Gorski <jogo@openwrt.org> wrote:
> (snip)
> diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
> index 3b46f7c..8009530 100644
> --- a/arch/mips/kernel/vmlinux.lds.S
> +++ b/arch/mips/kernel/vmlinux.lds.S
> @@ -127,6 +127,12 @@ SECTIONS
> }
>
> PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
> +
> +#ifdef CONFIG_MIPS_APPENDED_DTB
> + __appended_dtb = .;
> + /* leave space for appended DTB */
> + . = . + 0x100000;
> +#endif
Okay, this won't work for non SMP kernels - PERCPU is empty there, so
the actual binary end is then __mips_machine_end, not __per_cpu_end
(unless mips_machine_end happens to satisfty the per_cpu alignment
requirements).
So back to the drawing board.
Jonas
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RFC v2] MIPS: add support for vmlinux.bin appended DTB
2014-08-08 18:39 ` Jonas Gorski
@ 2015-04-10 18:17 ` Aaro Koskinen
0 siblings, 0 replies; 3+ messages in thread
From: Aaro Koskinen @ 2015-04-10 18:17 UTC (permalink / raw)
To: Jonas Gorski
Cc: MIPS Mailing List, Ralf Baechle, John Crispin, James Hogan,
Markos Chandras
Hi,
On Fri, Aug 08, 2014 at 08:39:48PM +0200, Jonas Gorski wrote:
> On Sat, Jul 12, 2014 at 12:49 PM, Jonas Gorski <jogo@openwrt.org> wrote:
> > (snip)
> > diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
> > index 3b46f7c..8009530 100644
> > --- a/arch/mips/kernel/vmlinux.lds.S
> > +++ b/arch/mips/kernel/vmlinux.lds.S
> > @@ -127,6 +127,12 @@ SECTIONS
> > }
> >
> > PERCPU_SECTION(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
> > +
> > +#ifdef CONFIG_MIPS_APPENDED_DTB
> > + __appended_dtb = .;
> > + /* leave space for appended DTB */
> > + . = . + 0x100000;
> > +#endif
>
> Okay, this won't work for non SMP kernels - PERCPU is empty there, so
> the actual binary end is then __mips_machine_end, not __per_cpu_end
> (unless mips_machine_end happens to satisfty the per_cpu alignment
> requirements).
>
> So back to the drawing board.
Any news? Would it work just by not defining PERCPU on non-SMP builds?
A.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-04-10 18:17 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-07-12 10:49 [PATCH RFC v2] MIPS: add support for vmlinux.bin appended DTB Jonas Gorski
2014-08-08 18:39 ` Jonas Gorski
2015-04-10 18:17 ` Aaro Koskinen
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.