From 73a80de4228a498b483c8e10ab317920d978d507 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Thu, 20 Jan 2022 23:22:42 -0700 Subject: Moved globals to file --- src/sys/schedule.c | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) (limited to 'src/sys/schedule.c') diff --git a/src/sys/schedule.c b/src/sys/schedule.c index 1b02476..c300ae0 100644 --- a/src/sys/schedule.c +++ b/src/sys/schedule.c @@ -1,29 +1,10 @@ #include #include +#include #include #include #include -#define SYS_SCHEDULE_C -struct Scheduler scheduler = { - .tlist = { - {.prev = 0, .next = 0, .data = 0}, - {.prev = 0, .next = 0, .data = 0}, - {.prev = 0, .next = 0, .data = 0}, - {.prev = 0, .next = 0, .data = 0}, - {.prev = 0, .next = 0, .data = 0}, - {.prev = 0, .next = 0, .data = 0}, - }, - .rthread_ll = 0, - .ctx = 0, -}; -unsigned long syssp = 0; -struct cpu_context syscpu = { - .r4 = 0, .r5 = 0, .r6 = 0, .r7 = 0, - .r8 = 0, .r9 = 0, .r10 = 0, .r11 = 0, - .r12 = 0, .lr = 0, -}; - void init_scheduler(void) { for(int i = 0; i < PRIORITIES; i++) { @@ -32,11 +13,9 @@ void init_scheduler(void) scheduler.tlist[i].data = 0; } scheduler.rthread_ll = 0; - scheduler.ctx = &syscpu; + scheduler.ctx = &svccpu; } -unsigned char stacks_table[MAX_THREADS] = {0, }; - void* get_stack(void) { for (int i = 0; i < MAX_THREADS; i++) { @@ -48,7 +27,6 @@ void* get_stack(void) return 0; } -static unsigned long nextpid = 3; void add_thread(void (*thread_fxn)(void), unsigned char priority) { struct Thread* thread = (struct Thread*)malloca(sizeof(struct Thread), 4); @@ -119,7 +97,7 @@ void schedule_c(void) } else if (next_thread_ll != 0) { struct Thread* next_thread = next_thread_ll->data; - preserve_sys_stack(&syssp); + preserve_sys_stack(&svcsp); restore_stack(next_thread); scheduler.rthread_ll = next_thread_ll; scheduler.ctx = &next_thread->data.cpu_context; @@ -129,8 +107,8 @@ void schedule_c(void) restore_ctx(scheduler.ctx); asm volatile ("bx %0" :: "r"(rthread->thread)); } else { - scheduler.ctx = &syscpu; - restore_sys_stack(&syssp); + scheduler.ctx = &svccpu; + restore_sys_stack(&svcsp); restore_ctx(scheduler.ctx); } } -- cgit v1.2.1