From 5bb02975ac5f541245af9b4f6c0be4ffaa2d8463 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Sun, 23 Jan 2022 12:59:27 -0700 Subject: Draw Exception info to screen --- src/sys/core.c | 11 +---------- src/sys/schedule.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) (limited to 'src/sys') diff --git a/src/sys/core.c b/src/sys/core.c index 4a44e96..d84770d 100644 --- a/src/sys/core.c +++ b/src/sys/core.c @@ -71,26 +71,17 @@ void sysinit(void) add_thread(testlocal, 0, 3); add_thread(testlocal, 0, 5); add_thread(testnew, 0, 4); - uart_scheduler(); } void testlocal(void) { - uart_string("Ran thread!\n"); - if (scheduler.rthread->pid == 4) { - add_thread(testlocal, 0, 0); - //uart_scheduler(); - } - uart_hexn((unsigned long)getsp()); - uart_string("Exiting thread!\n"); + draw_stacks(); } void testnew(void) { - uart_string("Ran special\n"); add_thread(testlocal, 0, 0); usr_schedule(); - uart_string("Finish special!\n"); } void __attribute__((naked)) usr_schedule(void) diff --git a/src/sys/schedule.c b/src/sys/schedule.c index ea5b465..ebf60bc 100644 --- a/src/sys/schedule.c +++ b/src/sys/schedule.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -48,6 +49,25 @@ struct RStack get_stack(void) return r; } +void draw_stacks(void) +{ + unsigned long ioff = 0; + unsigned long yoff = 320; +#define STACK_DRAW_WIDTH 32 +#define STACK_DRAW_SIZE 3 + for(int i = 0; i < MAX_THREADS; i++) { + if(stacks_table[i]) + draw_cbox(ioff, yoff, STACK_DRAW_SIZE, STACK_DRAW_SIZE, 0xFFFFFF); + else + draw_cbox(ioff, yoff, STACK_DRAW_SIZE, STACK_DRAW_SIZE, 0x000000); + ioff += STACK_DRAW_SIZE; + if(ioff % STACK_DRAW_WIDTH == 0) { + yoff += STACK_DRAW_SIZE; + ioff = 0; + } + } +} + void add_thread(void* pc, void* arg, unsigned char priority) { //void* sp = get_stack(); -- cgit v1.2.1