aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-02-01 18:25:51 -0700
committerChristian Cunningham <cc@localhost>2022-02-01 18:25:51 -0700
commite71ca9d94c38d61096e587e1fa17a8b79cd89397 (patch)
tree866edbd5b74a2b02f6c8c599ce0175a81c4f2ecf
parent36f2d87ee57e841be5fe60f6430bdd167f9f03af (diff)
Started syscalling
-rw-r--r--include/cpu.h7
-rw-r--r--src/sys/core.c9
2 files changed, 9 insertions, 7 deletions
diff --git a/include/cpu.h b/include/cpu.h
index 68638a5..52d016b 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -76,4 +76,11 @@ static inline void* getirqstack(void)
return sp;
}
+#define syscall_h_quote(text) #text
+#define syscall_h_expand_and_quote(text) syscall_h_quote(text)
+
+#define sys0(sys_n) asm volatile("svc #" syscall_h_expand_and_quote(sys_n) ::: "r0", "r1", "r2", "r3", "lr");
+
+#define SYS_SCHED 2
+
#endif
diff --git a/src/sys/core.c b/src/sys/core.c
index 1b71d3d..83cd563 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -1,4 +1,5 @@
#include <cpu/irq.h>
+#include <cpu.h>
#include <drivers/uart.h>
#include <globals.h>
#include <graphics/drawer.h>
@@ -16,7 +17,6 @@
void testlocal(void);
void testnew(void);
-void __attribute__((naked)) usr_schedule(void);
// Initialize IRQs
void sysinit(void)
@@ -80,10 +80,5 @@ void testlocal(void)
void testnew(void)
{
add_thread(testlocal, 0, 0);
- usr_schedule();
-}
-
-void __attribute__((naked)) usr_schedule(void)
-{
- asm volatile ("svc #2");
+ sys0(SYS_SCHED);
}