[U-Boot] [PATCH 08/11] mx6: add plugin file for use with imximage.cfg

Troy Kisky troy.kisky at boundarydevices.com
Wed Sep 19 02:03:06 CEST 2012


The "plugin" command of mkimage can take this
file as an argument.

Signed-off-by: Troy Kisky <troy.kisky at boundarydevices.com>
---
 arch/arm/cpu/armv7/mx6/Makefile |    5 +-
 arch/arm/cpu/armv7/mx6/plugin.S |  141 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 145 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/armv7/mx6/plugin.S

diff --git a/arch/arm/cpu/armv7/mx6/Makefile b/arch/arm/cpu/armv7/mx6/Makefile
index cbce411..b1fce4e 100644
--- a/arch/arm/cpu/armv7/mx6/Makefile
+++ b/arch/arm/cpu/armv7/mx6/Makefile
@@ -33,11 +33,14 @@ SOBJS   = lowlevel_init.o
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
 OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS))
 
-all:	$(obj).depend $(LIB)
+all:	$(obj).depend $(LIB) plugin.bin
 
 $(LIB):	$(OBJS)
 	$(call cmd_link_o_target, $(OBJS))
 
+plugin.bin: plugin.o
+	$(OBJCOPY) -O binary --gap-fill 0xff $< $@
+
 #########################################################################
 
 # defines $(obj).depend target
diff --git a/arch/arm/cpu/armv7/mx6/plugin.S b/arch/arm/cpu/armv7/mx6/plugin.S
new file mode 100644
index 0000000..e2a45d7
--- /dev/null
+++ b/arch/arm/cpu/armv7/mx6/plugin.S
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) 2012 Boundary Devices Inc.
+ *
+ * Licensed under the GPL-2 or later.
+ */
+#include <config.h>
+#include <asm/arch/imx-regs.h>
+
+#define HAB_RVT_ENTRY		0x98
+#define HAB_RVT_FAIL_SAFE_VECT	0xbc
+#define HAB_RVT_LOAD_DATA	0xc8
+
+#define HDR_SELF_PTR	0x14
+#define HDR_BOOT_DATA	0x20
+#define HDR_IMAGE_LEN	0x24
+
+/*
+ * plugin_start(void **start, size_t *bytes, UINT32 *ivt_offset)
+ */
+plugin_start:
+/* Save the return address and the function arguments */
+	push	{r0-r8, lr}
+
+/* r0-r2 must not be 0 and must be 4 byte aligned */
+	tst	r0, r0
+	tstne	r1, r1
+	tstne	r2, r2
+	mov	r3, r0
+	orreq	r3, r3, #1
+	orr	r3, r3, r1
+	orr	r3, r3, r2
+#if 0
+	ldr	r0, plugin
+	tst	r0, r0
+	orreq	r3, r3, #1
+#endif
+
+#define rCPU	r2	/* 22 - mx6q, 12 - mx6dl, 2 sololite */
+#define rFlag	r3
+#define	rIomux	r4
+#define rVal0	r5
+#define rVal1	r6
+#define rVal2	r7
+#define rTable	r8
+	mov	rCPU, #2
+
+	ldr	r1, =ANATOP_BASE_ADDR
+	ldr	r0, [r1, #0x280]
+	mov	r0, r0, LSR #16
+	cmp	r0, #0x60
+	movne	rCPU, #12
+	ldrne	r0, [r1, #0x260]
+	movne	r0, r0, LSR #16
+	cmpne	r0, #0x61
+	movne	rCPU, #22
+
+	mov	rVal0, #0
+	mov	rVal1, #0
+	mov	rVal2, #0
+	ldr	rIomux, =IOMUXC_BASE_ADDR
+	adr	rTable, mx6_table
+	b	3f
+
+1:	movs	r0, r1, LSR #30
+	beq	2f
+	mov	r1, r1, LSL rCPU
+	movs	r1, r1, LSR #32-10
+	addne	r1, rIomux, r1, LSL #2
+	cmp	r0, #3
+	subne	r0, r0, #1
+	orr	r1, r1, r0
+
+2:	ands	r0, r1, #3
+	bic	r1, r1, #3
+	ldrne	rVal0, [rTable], #4
+	movne	rVal1, rVal0
+	movne	rVal2, rVal0
+	subnes	r0, r0, #1
+	ldrne	rVal1, [rTable], #4
+	movne	rVal2, rVal1
+	subnes	r0, r0, #1
+	ldrne	rVal2, [rTable], #4
+
+	mov	r0, rVal0
+	cmp	rCPU, #12
+	moveq	r0, rVal1
+	cmp	rCPU, #2
+	moveq	r0, rVal2
+	cmp	r1, #0
+	strne	r0, [r1]
+3:	ldr	r1, [rTable], #4
+	cmp	r1, #0
+	bne	1b
+
+	ands	rFlag, rFlag, #3
+	bne	4f		/* Branch if not called as plugin */
+/* Align end of table to 64 byte boundary */
+	sub	rTable, rTable, #1
+	orr	rTable, rTable, #0x3f
+	add	rTable, rTable, #1
+	ldr	r2, [rTable, #HDR_SELF_PTR]
+	ldr	r0, [rTable, #HDR_BOOT_DATA]
+	ldr	r1, [rTable, #HDR_IMAGE_LEN]
+	sub	rTable, r2, r0
+	mov	r2, r0
+	mov	r3, r1
+	mov	r4, #0
+	push	{r0-r4}
+	mov	r0, #HAB_RVT_LOAD_DATA
+	ldr	r4, [r0]
+	mov	r0, sp
+	add	r1, sp, #4
+	add	r2, sp, #8
+	blx	r4
+
+	pop	{r4, r5}
+	add	sp, sp, #12
+	pop	{r0-r3}
+/*
+ * Before returning to ROM, we need to fill the return values arguments
+ * to our function.
+ * plugin_start(void **start, size_t *bytes, UINT32 *ivt_offset)
+ */
+
+	str	r4, [r0]
+	str	r5, [r1]
+	str	rTable, [r2]
+	mov	r0, #1
+	pop	{r4-r8, pc}
+
+/* Not called as plugin */
+4:	popne	{r0-r8, lr}
+	mov	r0, #HAB_RVT_ENTRY
+	ldr	lr, [r0]
+	blx	lr
+	mov	r0, #HAB_RVT_FAIL_SAFE_VECT
+	ldr	lr, [r0]
+	blx	lr
+
+	.ltorg
+mx6_table:
-- 
1.7.9.5



More information about the U-Boot mailing list