[linux-yocto] [PATCH 23/87] arm/boot: Boot loader emulation code for AXM5516.

Paul Butler butler.paul at gmail.com
Mon May 27 09:55:54 PDT 2013


From: John Jacques <john.jacques at lsi.com>

Signed-off-by: John Jacques <john.jacques at lsi.com>
---
 arch/arm/boot/emuboot/Makefile    | 28 +++++++++++++
 arch/arm/boot/emuboot/emuboot.S   | 87 +++++++++++++++++++++++++++++++++++++++
 arch/arm/boot/emuboot/emuboot.lds | 30 ++++++++++++++
 arch/arm/boot/emuboot/pack.py     | 10 +++++
 4 files changed, 155 insertions(+)
 create mode 100644 arch/arm/boot/emuboot/Makefile
 create mode 100644 arch/arm/boot/emuboot/emuboot.S
 create mode 100644 arch/arm/boot/emuboot/emuboot.lds
 create mode 100644 arch/arm/boot/emuboot/pack.py

diff --git a/arch/arm/boot/emuboot/Makefile b/arch/arm/boot/emuboot/Makefile
new file mode 100644
index 0000000..1d8e491
--- /dev/null
+++ b/arch/arm/boot/emuboot/Makefile
@@ -0,0 +1,28 @@
+# Build an image for emulation.
+
+AS		= $(CROSS_COMPILE)gcc -c
+LD		= $(CROSS_COMPILE)ld
+OBJCOPY         = $(CROSS_COMPILE)objcopy
+
+DTC = ../../../../scripts/dtc/dtc
+DTS = ../dts/axm55xx.dts
+ZIMAGE = ../zImage
+
+all: clean linux.img
+
+clean:
+	rm -f linux.img emuboot.o zImage.emu axm55xx.dtb
+
+linux.img: emuboot.o emuboot.lds zImage.emu
+	$(LD) -o linux.tmp --script=emuboot.lds
+	$(OBJCOPY) -O binary -R .note -R .comment -S linux.tmp $@
+	rm -f linux.tmp
+
+zImage.emu: $(ZIMAGE) axm55xx.dtb
+	python pack.py $(ZIMAGE) $< > $@
+
+axm55xx.dtb: $(DTS)
+	$(DTC) -O dtb -o $@ $<
+
+emuboot.o: emuboot.S
+	$(AS) -o $@ $<
diff --git a/arch/arm/boot/emuboot/emuboot.S b/arch/arm/boot/emuboot/emuboot.S
new file mode 100644
index 0000000..a71a412
--- /dev/null
+++ b/arch/arm/boot/emuboot/emuboot.S
@@ -0,0 +1,87 @@
+/*
+ * emuboot.S - simple register setup code for stand-alone Linux booting
+ *
+ * Copyright (C) 2011 ARM Limited. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE.txt file.
+ */
+
+#define SPIN_TABLE_BASE 0x10000000
+
+	.syntax	unified
+	.text
+
+	.globl	_start
+_start:
+	@
+	@ Allow the debugger to gain control...
+	@
+1:	ldr	r0, =0
+	cmp	r0, #0
+	beq	1b
+
+	@
+	@ Program architected timer frequency
+	@
+	mrc	p15, 0, r0, c0, c1, 1		@ CPUID_EXT_PFR1
+	lsr	r0, r0, #16
+	ands	r0, r0, #1			@ Check generic timer support
+	beq	1f
+	ldr	r0, =6250000			@ 6.25 MHz timer frequency
+	mcr	p15, 0, r0, c14, c0, 0		@ CNTFRQ
+1:
+	@
+	@ CPU initialisation
+	@
+	mrc	p15, 0, r0, c0, c0, 5		@ MPIDR (ARMv7 only)
+	and	r0, r0, #15			@ CPU number
+	cmp	r0, #0				@ primary CPU?
+	beq	2f
+
+	@
+	@ Secondary CPUs
+	@
+	ldr	r1, =SPIN_TABLE_BASE
+	adr	r2, 1f
+	ldmia	r2, {r3 - r7}			@ move the code to a location
+	stmia	r1, {r3 - r7}			@ less likely to be overridden
+	add	r0, r1, #0x20			@ Entry point for secondary
+						@ CPUs @ SPIN_TABLE_BASE+0x20
+	mov	r2, #0
+	str	r2, [r0, #0]			@ ensure initially zero
+	mov	pc, r1				@ branch to the relocated code
+1:
+	wfe
+	ldr	r1, [r0]
+	cmp	r1, #0
+	beq	1b
+	mov	pc, r1				@ branch to the given address
+
+	@
+	@ Kernel parameters
+	@
+2:	mov	r0, #0				@ Must be zero
+	mov	r1, #0				@ Machine type (not needed)
+	adr	r2, atags			@ ATAGS pointer
+	mov	r3, #0
+	ldr	lr, =kernel
+	mov     pc, lr				@ jump to the kernel
+
+	.org	0x100
+atags:
+	@ ATAG_CORE
+	.long	2
+	.long	0x54410001
+
+	@ ATAG_CMDLINE
+	.long	(1f - .) >> 2
+	.long	0x54410009
+	.asciz	"root=/dev/mmcblk0 rootwait ip=none mem=1024M console=ttyAMA0"
+
+	.align	2
+1:
+
+	@ ATAG_NONE
+	.long	0
+	.long	0x00000000
diff --git a/arch/arm/boot/emuboot/emuboot.lds b/arch/arm/boot/emuboot/emuboot.lds
new file mode 100644
index 0000000..0a24a17
--- /dev/null
+++ b/arch/arm/boot/emuboot/emuboot.lds
@@ -0,0 +1,30 @@
+/*
+ * emuboot.lds
+ *
+ * Copyright (C) 2011 ARM Limited. All rights reserved.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE.txt file.
+ */
+
+OUTPUT_FORMAT("elf32-littlearm")
+OUTPUT_ARCH(arm)
+TARGET(binary)
+
+INPUT(./emuboot.o)
+INPUT(./zImage.emu)
+
+PHYS_OFFSET = 0x00000000;
+
+SECTIONS
+{
+	. = PHYS_OFFSET;
+	.text : { emuboot.o }
+	. = PHYS_OFFSET + 0x8000 - 0x0;
+	kernel = . + 0x0;
+	.kernel : { ./zImage.emu }
+	. = PHYS_OFFSET + 0x00800000;
+	filesystem = .;
+	.data : { *(.data) }
+	.bss : { *(.bss) }
+}
diff --git a/arch/arm/boot/emuboot/pack.py b/arch/arm/boot/emuboot/pack.py
new file mode 100644
index 0000000..fe2ce70
--- /dev/null
+++ b/arch/arm/boot/emuboot/pack.py
@@ -0,0 +1,10 @@
+import sys
+
+while len(sys.argv) > 1:
+	f = open(sys.argv.pop(1), "rb")
+	f.seek(0, 2)
+	sz = f.tell()
+	f.seek(0,0)
+	pad = ((sz + 3) & ~3) - sz
+	sys.stdout.write(f.read() + '\0'*pad)
+	f.close()
-- 
1.8.3




More information about the linux-yocto mailing list