From 0160f834928a7b7c518c69bb4feb8750796caebc Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 8 Dec 2014 12:15:06 +0100 Subject: [PATCH] ARM: Add get_sp() and get_lr() functions In case it's needed for some early code. Signed-off-by: Sascha Hauer --- arch/arm/include/asm/common.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/arch/arm/include/asm/common.h b/arch/arm/include/asm/common.h index 133bb8e1f..9ff3b19c7 100644 --- a/arch/arm/include/asm/common.h +++ b/arch/arm/include/asm/common.h @@ -16,6 +16,32 @@ static inline unsigned long get_pc(void) return pc; } +static inline unsigned long get_lr(void) +{ + unsigned long lr; + + __asm__ __volatile__( + "mov %0, lr\n" + : "=r" (lr) + : + : "memory"); + + return lr; +} + +static inline unsigned long get_sp(void) +{ + unsigned long sp; + + __asm__ __volatile__( + "mov %0, sp\n" + : "=r" (sp) + : + : "memory"); + + return sp; +} + static inline void arm_setup_stack(unsigned long top) { __asm__ __volatile__("mov sp, %0" : : "r"(top));