Skip to contentSkip to conversation

bootwrapper: Add a firmware-independent simpleboot target.

RFC In review Grant Likely 2 participants 4 messages Feb 2, 2008 – Feb 8, 2008 PowerPC

lore
Share & tools
lore
#0 lore raw

RFC 1/1 bootwrapper: Add a firmware-independent simpleboot target.

From: Grant Likely <[email protected]>

This target produces a flat binary rather than an ELF file, fixes the entry point at the beginning of the image, and takes a complete device tree with no fixups needed.

Based on 'raw' target written by Scott Wood.

---

 arch/powerpc/boot/Makefile         |    9 +++-
 arch/powerpc/boot/io.h             |    7 +++
 arch/powerpc/boot/simpleboot.c     |   88 ++++++++++++++++++++++++++++++++++++
 arch/powerpc/boot/virtex405-head.S |   30 ++++++++++++
 arch/powerpc/boot/wrapper          |    4 ++
 5 files changed, 137 insertions(+), 1 deletions(-)
arch/powerpc/boot/Makefile +8 -1
index 836234b..c4156ea 100644
@@ -40,6 +40,7 @@ $(obj)/ebony.o: BOOTCFLAGS += -mcpu=440
 $(obj)/cuboot-taishan.o: BOOTCFLAGS += -mcpu=440
 $(obj)/cuboot-katmai.o: BOOTCFLAGS += -mcpu=440
 $(obj)/treeboot-walnut.o: BOOTCFLAGS += -mcpu=405
+$(obj)/virtex405-head.o: BOOTCFLAGS += -mcpu=405
 
 
 zlib       := inffast.c inflate.c inftrees.c
@@ -64,7 +65,7 @@ src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c
 		cuboot-bamboo.c cuboot-mpc7448hpc2.c cuboot-taishan.c \
 		fixed-head.S ep88xc.c ep405.c \
 		cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
-		cuboot-warp.c cuboot-85xx-cpm2.c
+		cuboot-warp.c cuboot-85xx-cpm2.c simpleboot.c virtex405-head.S
 src-boot := $(src-wlib) $(src-plat) empty.c
 
 src-boot := $(addprefix $(obj)/, $(src-boot))
@@ -306,6 +307,12 @@ $(obj)/uImage: vmlinux $(wrapperbits)
 $(obj)/cuImage.%: vmlinux $(dtstree)/%.dts $(wrapperbits)
 	$(call if_changed,wrap,cuboot-$*,$(dtstree)/$*.dts)
 
+$(obj)/simpleImage.initrd.%: vmlinux $(dtstree)/%.dts $(wrapperbits)
+	$(call if_changed,wrap,simpleboot-$*,$(dtstree)/$*.dts,,$(obj)/ramdisk.image.gz)
+
+$(obj)/simpleImage.%: vmlinux $(dtstree)/%.dts $(wrapperbits)
+	$(call if_changed,wrap,simpleboot-$*,$(dtstree)/$*.dts)
+
 $(obj)/treeImage.initrd.%: vmlinux $(dtstree)/%.dts $(wrapperbits)
 	$(call if_changed,wrap,treeboot-$*,$(dtstree)/$*.dts,,$(obj)/ramdisk.image.gz)
 
arch/powerpc/boot/io.h +7 -0
index ccaedae..ec57ec9 100644
@@ -99,4 +99,11 @@ static inline void barrier(void)
 	asm volatile("" : : : "memory");
 }
 
+static inline void disable_irq(void)
+{
+	int dummy;
+	asm volatile("mfmsr %0; rlwinm %0, %0, 0, ~(1<<15); mtmsr %0" :
+	             "=r" (dummy) : : "memory");
+}
+
 #endif /* _IO_H */
arch/powerpc/boot/simpleboot.c new file +88 -0

88 lines not on this page · raw message

arch/powerpc/boot/virtex405-head.S new file +30 -0
new file mode 100644
index 0000000..3edb13f
@@ -0,0 +1,30 @@
+#include "ppc_asm.h"
+
+	.text
+	.global _zimage_start
+_zimage_start:
+
+	/* PPC errata 213: needed by Virtex-4 FX */
+	mfccr0  0
+	oris    0,0,0x50000000@h
+	mtccr0  0
+
+	/*
+	 * Invalidate the data cache if the data cache is turned off.
+	 * - The 405 core does not invalidate the data cache on power-up
+	 *   or reset but does turn off the data cache. We cannot assume
+	 *   that the cache contents are valid.
+	 * - If the data cache is turned on this must have been done by
+	 *   a bootloader and we assume that the cache contents are
+	 *   valid.
+	 */
+	mfdccr	r9
+	cmplwi	r9,0
+	bne	2f
+	lis	r9,0
+	li	r8,256
+	mtctr	r8
+1:	dccci	r0,r9
+	addi	r9,r9,0x20
+	bdnz	1b
+2:	b	_zimage_start_lib
arch/powerpc/boot/wrapper +4 -0
index c317815..1f41ff4 100755
@@ -195,6 +195,10 @@ ep88xc|ep405|redboot*|ep8248e)
     platformo="$object/fixed-head.o $object/$platform.o"
     binary=y
     ;;
+simpleboot-virtex405-*)
+    platformo="$object/virtex405-head.o $object/simpleboot.o"
+    binary=y
+    ;;
 esac
 
 vmz="$tmpdir/`basename \"$kernel\"`.$ext"
#1 lore raw
Quoted 16 lines · Grant Likely

From: Grant Likely <[email protected]>

This target produces a flat binary rather than an ELF file, fixes the entry point at the beginning of the image, and takes a complete device tree with no fixups needed.

Based on 'raw' target written by Scott Wood.

---

arch/powerpc/boot/io.h +0 -0
index ccaedae..ec57ec9 100644
@@ -99,4 +99,11 @@ static inline void barrier(void)
        asm volatile("" : : : "memory");

arch/powerpc/boot/io.h static inline void barrier(void) · line 109

Quoted 10 lines
arch/powerpc/boot/io.h +7 -0
 }
 
+static inline void disable_irq(void)
+{
+       int dummy;
+       asm volatile("mfmsr %0; rlwinm %0, %0, 0, ~(1<<15); mtmsr %0" :
+                    "=r" (dummy) : : "memory");
+}
+
 #endif /* _IO_H */

Oops, ignore this bit. This is leftover cruft from the original patch. I've now removed it.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.
#2 lore raw
In reply to Grant Likely
Quoted 1 line · Grant Likely

From: Grant Likely <[email protected]>

[snip]

arch/powerpc/boot/simpleboot.c line 39

Quoted 13 lines
arch/powerpc/boot/simpleboot.c new file +13 -0
+void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
+		   unsigned long r6, unsigned long r7)
+{
+	const u32 *na, *ns, *reg, *timebase;
+	u64 memsize64;
+	int node, size, i;
+
+	/* Allocate initial heap for probing the tree */
+	simple_alloc_init(initial_heap, sizeof(initial_heap), 32, 64);
+
+	/* Make sure FDT blob is sane */
+	if (fdt_check_header(_dtb_start) != 0)
+		fatal("Invalid device tree blob\n");

I think most of these fatal()s are pretty pointless. This is platform_init(), so the console won't even have been initialized to actually print any of the messages. Precisely because this is simpleboot, in which every bit of information the wrapper has comes from teh device tree, if the provided blob is so bad as to fail these basic tests, we're totally stuffed anyway. It'll take a hardware debugger to track down, and I don't think the fatal()s will actually help much at that point.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#3 lore raw
Quoted 6 lines · David Gibson

arch/powerpc/boot/simpleboot.c line 39

Quoted 4 lines · Grant Likely

From: Grant Likely <[email protected]>

arch/powerpc/boot/simpleboot.c new file +3 -0
+     /* Make sure FDT blob is sane */
+     if (fdt_check_header(_dtb_start) != 0)
+             fatal("Invalid device tree blob\n");
Quoted 8 lines

I think most of these fatal()s are pretty pointless. This is platform_init(), so the console won't even have been initialized to actually print any of the messages. Precisely because this is simpleboot, in which every bit of information the wrapper has comes from teh device tree, if the provided blob is so bad as to fail these basic tests, we're totally stuffed anyway. It'll take a hardware debugger to track down, and I don't think the fatal()s will actually help much at that point.

heh; very true. I'll kill them.

g.

Signature · 2 lines
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.