aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/cpu.h14
-rw-r--r--include/cpu/atomic/swap.h4
2 files changed, 16 insertions, 2 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;
diff --git a/include/cpu/atomic/swap.h b/include/cpu/atomic/swap.h
index cbed62c..32717fb 100644
--- a/include/cpu/atomic/swap.h
+++ b/include/cpu/atomic/swap.h
@@ -22,7 +22,7 @@ static inline void atm_lock(unsigned long pid, unsigned long* addr)
" dmb"
: "=&r" (current_lock_value), "=&r" (tmp)
: "r" (pid), "r" (addr)
- : "cc");
+ : "cc", "memory");
}
static inline void atm_release(unsigned long* addr)
@@ -34,7 +34,7 @@ static inline void atm_release(unsigned long* addr)
" dsb\n"
" sev"
:: "r" (cleared), "r" (addr)
- : "cc");
+ : "cc", "memory");
}
#endif