[PATCH 2/3] ARM: Add assembler function to get runtime offset

Sascha Hauer s.hauer at pengutronix.de
Sun Sep 9 05:47:55 EDT 2012


This function returns the offset between the address barebox is linked at
and the address barebox is currently running at.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 arch/arm/include/asm/barebox-arm.h |    1 +
 arch/arm/lib/Makefile              |    2 ++
 arch/arm/lib/runtime-offset.S      |   16 ++++++++++++++++
 3 files changed, 19 insertions(+)
 create mode 100644 arch/arm/lib/runtime-offset.S

diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index b880dd4..3639365 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -42,5 +42,6 @@ extern char __ll_return[];
 void board_init_lowlevel(void);
 void board_init_lowlevel_return(void);
 void arch_init_lowlevel(void);
+uint32_t get_runtime_offset(void);
 
 #endif	/* _BAREBOX_ARM_H_ */
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 9d0ff7a..2e624cd 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -16,6 +16,8 @@ obj-y	+= lib1funcs.o
 obj-y	+= ashrdi3.o
 obj-y	+= ashldi3.o
 obj-y	+= lshrdi3.o
+obj-y	+= runtime-offset.o
+pbl-y	+= runtime-offset.o
 obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memcpy.o
 obj-$(CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS)	+= memset.o
 obj-$(CONFIG_ARM_UNWIND) += unwind.o
diff --git a/arch/arm/lib/runtime-offset.S b/arch/arm/lib/runtime-offset.S
new file mode 100644
index 0000000..00d756d
--- /dev/null
+++ b/arch/arm/lib/runtime-offset.S
@@ -0,0 +1,16 @@
+#include <linux/linkage.h>
+#include <asm/assembler.h>
+
+/*
+ * Get the offset between the link address and the address
+ * we are currently running at.
+ */
+ENTRY(get_runtime_offset)
+1:	adr r0, 1b
+	ldr r1, linkadr
+	subs r0, r1, r0
+	mov pc, lr
+
+linkadr:
+.word get_runtime_offset
+ENDPROC(get_runtime_offset)
-- 
1.7.10.4




More information about the barebox mailing list