aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/uart.c12
-rw-r--r--src/sys/core.h22
-rw-r--r--src/util/status.c3
3 files changed, 29 insertions, 8 deletions
diff --git a/src/drivers/uart.c b/src/drivers/uart.c
index cc1933e..142a5c3 100644
--- a/src/drivers/uart.c
+++ b/src/drivers/uart.c
@@ -1,11 +1,5 @@
#include "../drivers/uart.h"
-void uart_hexn(unsigned long c_val)
-{
- uart_hex(c_val);
- uart_char('\n');
-}
-
void uart_10(unsigned long val)
{
unsigned long t = val;
@@ -22,3 +16,9 @@ void uart_10(unsigned long val)
}
uart_string(dptr);
}
+
+void uart_hexn(unsigned long c_val)
+{
+ uart_hex(c_val);
+ uart_char('\n');
+}
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
diff --git a/src/util/status.c b/src/util/status.c
index 1ac08e8..bd529da 100644
--- a/src/util/status.c
+++ b/src/util/status.c
@@ -141,8 +141,7 @@ void status(void)
write_char(&g_Drawer, '\n');
*/
- unsigned long sp;
- asm volatile ("mov %0, sp": "=r"(sp));
+ unsigned long sp = (unsigned long)getsp();
write_hex32(&g_Drawer, sp);
g_Drawer.x = x;