aboutsummaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-01-03 21:35:01 -0800
committerChristian Cunningham <cc@localhost>2022-01-03 21:35:01 -0800
commitf3ea4cd0c22f351d8dfffb0e937194c4b526b665 (patch)
treebc0dcb168ba06417a765c588420bdc20068a553c /src/sys
parent01af43f3bad5deb061237ebddc577511336de7d5 (diff)
Added Stack ASM Functions
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/core.h22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/sys/core.h b/src/sys/core.h
index 2ba2f16..fa9e1b5 100644
--- a/src/sys/core.h
+++ b/src/sys/core.h
@@ -19,6 +19,28 @@ static inline void delay(unsigned long cycles)
: "=r"(cycles): [cycles]"0"(cycles) : "cc");
}
+static inline void preserveregs(void)
+{
+ asm volatile("push {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11}");
+}
+
+static inline void restoreregs(void)
+{
+ asm volatile("pop {r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11}");
+}
+
+static inline void* getsp(void)
+{
+ void* out;
+ asm volatile ("mov %0, sp" : "=r"(out));
+ return out;
+}
+
+static inline void setsp(void* in)
+{
+ asm volatile ("mov sp, %0" :: "r"(in));
+}
+
enum
{
// The offset for the MMIO area