aboutsummaryrefslogtreecommitdiff
path: root/include/cpu.h
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-19 12:01:18 -0700
committerChristian Cunningham <cc@localhost>2022-01-19 12:01:18 -0700
commit49672787286b44c07561355b290946f80f334e58 (patch)
treeb6f79cc8228737eb76f5fe6f174bec54e74ec1f9 /include/cpu.h
parentd22b1c3cde432ea96408c329fe78fbf0a9da9a8e (diff)
Added clobbers
Diffstat (limited to 'include/cpu.h')
-rw-r--r--include/cpu.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/cpu.h b/include/cpu.h
index c93b3b5..eb2cdc0 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -24,6 +24,20 @@ static inline void setmode(unsigned long mode)
asm volatile ("msr cpsr_c, %0" :: "r"(mode));
}
+static inline void* getsysstack(void)
+{
+ void* sp;
+ asm volatile (
+ "mrs r0, cpsr\n"
+ "bic r1, r0, #0x1F\n"
+ "orr r1, r1, #0x1F\n"
+ "msr cpsr_c, r1\n"
+ "mov %0, sp\n"
+ "msr cpsr_c, r0"
+ : "=r"(sp));
+ return sp;
+}
+
static inline void* getsvcstack(void)
{
void* sp;