aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-02-13 01:54:51 -0700
committerChristian Cunningham <cc@localhost>2022-02-13 01:54:51 -0700
commit958696be616aaaa4fe18fc2b886216f191bb6f9b (patch)
tree1bdef3ca97744487cfaad680665adce83dc60d47 /include
parentfcf70bcd6a2b2d3bbf76280041438fb1abf33d52 (diff)
Mutex Waiting Implemented
Svc 4 and 5
Diffstat (limited to 'include')
-rw-r--r--include/cpu.h6
-rw-r--r--include/sys/schedule.h8
2 files changed, 10 insertions, 4 deletions
diff --git a/include/cpu.h b/include/cpu.h
index 19f0e56..c200016 100644
--- a/include/cpu.h
+++ b/include/cpu.h
@@ -81,7 +81,11 @@ static inline void* getirqstack(void)
#define sys0(sys_n) asm volatile("svc #" syscall_h_expand_and_quote(sys_n) ::: "r0", "r1", "r2", "r3");
#define sys0_64(sys_n,addr) asm volatile("svc #" syscall_h_expand_and_quote(sys_n) "\nmov r2, %0\nstr r1, [r2]\nstr r0, [r2, #4]" ::"r"(addr): "r0", "r1", "r2", "r3", "memory");
-#define sys1(sys_n,arg0) asm volatile("svc #" syscall_h_expand_and_quote(sys_n) ::[r0]"r"(arg0): "r0", "r1", "r2", "r3");
+//#define sys1(sys_n,arg0) asm volatile("svc #" syscall_h_expand_and_quote(sys_n) ::[r0]"r"(arg0): "r0", "r1", "r2", "r3");
+#define sys1(sys_n,arg0) {\
+ register long r0 asm ("r0") = (long) (arg0); \
+ asm volatile("svc #" syscall_h_expand_and_quote(sys_n) ::"r"(r0): "memory"); \
+ }
#define SYS_YIELD 0
#define SYS_TIME 1
diff --git a/include/sys/schedule.h b/include/sys/schedule.h
index cb784c5..336ab4a 100644
--- a/include/sys/schedule.h
+++ b/include/sys/schedule.h
@@ -27,12 +27,12 @@ struct Thread {
void* pc;
void* sp; // Store r0-r12,lr on stack
unsigned long sp_base;
- void* mptr;
+ unsigned long cpsr;
unsigned long pid;
unsigned char priority;
unsigned char preempt;
unsigned short status;
- unsigned long cpsr;
+ void* mptr;
};
struct ThreadRotBuffer {
@@ -60,10 +60,12 @@ void add_thread(void* pc, void* arg, unsigned char priority);
void draw_stacks(void);
void uart_scheduler(void);
struct Thread* next_thread(void);
-/// TODO: ENSURE IRQ/ FIQ entry switches
+/// TODO: ENSURE IRQ/ FIQ entry switches
/// to user mode then calls the SVC call
extern void schedule(void);
extern void cleanup(void);
void yield(void);
+void sched_mutex_yield(void* m);
+void sched_mutex_resurrect(void* m);
#endif