diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/sys/core.c | 90 | ||||
-rw-r--r-- | src/sys/core.h | 1 | ||||
-rw-r--r-- | src/sys/kernel.S | 1 | ||||
-rw-r--r-- | src/sys/timer.c | 59 | ||||
-rw-r--r-- | src/util/status.c | 127 | ||||
-rw-r--r-- | src/util/status.h | 6 |
6 files changed, 145 insertions, 139 deletions
diff --git a/src/sys/core.c b/src/sys/core.c index fda4d86..636dd64 100644 --- a/src/sys/core.c +++ b/src/sys/core.c @@ -11,6 +11,7 @@ #include "../sys/schedule.h" #include "../sys/timer.h" #include "../util/mutex.h" +#include "../util/status.h" #include "../util/time.h" #ifndef VERSION @@ -29,7 +30,6 @@ void sysinit(void) store32(1<<4, UART0_IMSC); // Enable UART GPU IRQ store32(1<<25, IRQ_ENABLE2); - // Enable Timer // As an IRQ store32(1<<0, IRQ_BASIC_ENABLE); @@ -50,91 +50,3 @@ void sysinit(void) enableirq(); enablefiq(); } - -void output_irq_status(void) -{ - // Basic IRQ - unsigned long ib_val = load32(IRQ_BASIC_ENABLE); - // IRQ 1 - unsigned long i1_val = load32(IRQ_ENABLE1); - // IRQ 2 - unsigned long i2_val = load32(IRQ_ENABLE2); - // FIQ - unsigned long f_val = load32(FIQ_CONTROL); - - // Check GPU Interrupt Routing - unsigned long g_val = load32(GPU_INTERRUPTS_ROUTING); - write_string(&g_Drawer, "GPU IRQ: Core "); - write_10(&g_Drawer, g_val & 0b11); - write_string(&g_Drawer, " | GPU FIQ: Core "); - write_10(&g_Drawer, (g_val >> 2) & 0b11); - - write_string(&g_Drawer, "\n"); - write_hex32(&g_Drawer, ib_val); - write_string(&g_Drawer, " "); - write_hex32(&g_Drawer, i1_val); - write_string(&g_Drawer, " "); - write_hex32(&g_Drawer, i2_val); - write_string(&g_Drawer, " "); - write_hex32(&g_Drawer, f_val); - - // Check UART IRQ - write_string(&g_Drawer, "\nUART: "); - if (i2_val & (1<<25)) { - write_cstring(&g_Drawer, "Enabled", 0x00FF00); - } else { - write_cstring(&g_Drawer, "Disabled", 0xFF0000); - } - - // Check TIMER IRQ - write_string(&g_Drawer, " TIMER: "); - if (ib_val & (1<<0)) { - write_cstring(&g_Drawer, "Enabled", 0x00FF00); - } else { - write_cstring(&g_Drawer, "Disabled", 0xFF0000); - } -} - -void postinit(void) -{ - // OS Info - write_cstring(&g_Drawer, "DendritOS", 0xFF0000); - write_cstring(&g_Drawer, " v", 0x00FFFF); - write_cstring(&g_Drawer, os_info_v, 0x00FFFF); - write_string(&g_Drawer, " #"); - if (lock_mutex(&exe_cnt_m, SYS_PID) == 0) { - write_10(&g_Drawer, *((unsigned long*)exe_cnt_m.addr)); - release_mutex(&exe_cnt_m, SYS_PID); - } - - // Commands - write_string(&g_Drawer, "\nMonitor: Ctrl-A m Exit: Ctrl-A x Timer: Ctrl-T"); - - // GPU IRQ Statuses - write_string(&g_Drawer, "\n"); - output_irq_status(); - - // Timer Status - write_string(&g_Drawer, "\nTIMER: "); - write_cstring(&g_Drawer, "Enabled ", 0x00FF00); - // Output the frequency - write_string(&g_Drawer, " @ "); - unsigned long frq = read_cntfrq()/1000; - write_10(&g_Drawer, frq); - write_string(&g_Drawer, " kHz"); - - // Video Status - write_string(&g_Drawer, "\nVIDEO: "); - write_cstring(&g_Drawer, "Enabled ", 0x00FF00); - write_10(&g_Drawer, width); - write_string(&g_Drawer, "x"); - write_10(&g_Drawer, height); - if(isrgb) { - write_string(&g_Drawer, " RGB"); - } else { - write_string(&g_Drawer, " BGR"); - } - - // Output Serial Data Recieve Line - write_string(&g_Drawer, "\n> "); -} diff --git a/src/sys/core.h b/src/sys/core.h index d70f406..2ba2f16 100644 --- a/src/sys/core.h +++ b/src/sys/core.h @@ -117,6 +117,5 @@ enum }; void sysinit(void); -void postinit(void); #endif diff --git a/src/sys/kernel.S b/src/sys/kernel.S index cf1dbb2..a691ebf 100644 --- a/src/sys/kernel.S +++ b/src/sys/kernel.S @@ -4,7 +4,6 @@ kernel_main: push {lr} bl sysinit - bl postinit kernel_main.loop: wfe b kernel_main.loop diff --git a/src/sys/timer.c b/src/sys/timer.c index c3ae53b..9419f80 100644 --- a/src/sys/timer.c +++ b/src/sys/timer.c @@ -3,69 +3,32 @@ #include "../sys/core.h" #include "../sys/timer.h" #include "../util/mutex.h" +#include "../util/status.h" #include "../util/time.h" /// Cycles Per Second #define CPS 10 -#define SYS_TIMER_C extern char* os_info_v; -unsigned long exe_cnt = 0; +#define SYS_TIMER_C +static unsigned long exe_cnt = 0; struct Mutex exe_cnt_m = {.addr = &exe_cnt, .pid = NULL_PID}; -void c_timer(void) +void increase_counter(void) { - // Reset the counter - write_cntv_tval(cntfrq/CPS); - - unsigned int x = g_Drawer.x; - unsigned int y = g_Drawer.y; - g_Drawer.x = 0; - g_Drawer.y = 0; - - // Lock the execution counter if (lock_mutex(&exe_cnt_m, SCHED_PID) == 0) { unsigned long* counter = (unsigned long*)exe_cnt_m.addr; *counter += 1; - write_cstring(&g_Drawer, "DendritOS", 0xFF0000); - write_cstring(&g_Drawer, " v", 0x00FFFF); - write_cstring(&g_Drawer, os_info_v, 0x00FFFF); - write_string(&g_Drawer, " #"); - write_10(&g_Drawer, *((unsigned long*)exe_cnt_m.addr)); release_mutex(&exe_cnt_m, SCHED_PID); } +} - g_Drawer.x = 29; - g_Drawer.y = 5; - // Output the value - unsigned long v = read_cntv_tval(); - write_10(&g_Drawer, v); - write_string(&g_Drawer, " | "); - write_hex32(&g_Drawer, v); - - g_Drawer.x = 0; - g_Drawer.y = 9; - for(int i = 0; i < 128; i++) - write_char(&g_Drawer, ' '); - g_Drawer.x = 0; - g_Drawer.y = 9; - write_string(&g_Drawer, "Timer Counter: "); - if (exe_cnt_m.pid == NULL_PID) { - write_cstring(&g_Drawer, "Free!", 0xFF00FF); - } else { - write_cstring(&g_Drawer, "Locked by ", 0xFF00FF); - if (exe_cnt_m.pid == SYS_PID) - write_cstring(&g_Drawer, "System", 0xFF00FF); - else if (exe_cnt_m.pid == SCHED_PID) - write_cstring(&g_Drawer, "Scheduler", 0xFF00FF); - else { - write_cstring(&g_Drawer, "Process ", 0xFF00FF); - write_c10(&g_Drawer, exe_cnt_m.pid, 0xFF00FF); - } - write_cchar(&g_Drawer, '!', 0xFF00FF); - } +void c_timer(void) +{ + // Reset the counter + write_cntv_tval(cntfrq/CPS); - g_Drawer.x = x; - g_Drawer.y = y; + increase_counter(); + status(); } diff --git a/src/util/status.c b/src/util/status.c new file mode 100644 index 0000000..95ea0ff --- /dev/null +++ b/src/util/status.c @@ -0,0 +1,127 @@ +#include "../graphics/drawer.h" +#include "../graphics/lfb.h" +#include "../sys/core.h" +#include "../sys/timer.h" +#include "../util/mutex.h" +#include "../util/status.h" +#include "../util/time.h" + +extern char* os_info_v; + +void output_irq_status(void) +{ + // Basic IRQ + unsigned long ib_val = load32(IRQ_BASIC_ENABLE); + // IRQ 1 + unsigned long i1_val = load32(IRQ_ENABLE1); + // IRQ 2 + unsigned long i2_val = load32(IRQ_ENABLE2); + // FIQ + unsigned long f_val = load32(FIQ_CONTROL); + + // Check GPU Interrupt Routing + unsigned long g_val = load32(GPU_INTERRUPTS_ROUTING); + write_string(&g_Drawer, "GPU IRQ: Core "); + write_10(&g_Drawer, g_val & 0b11); + write_string(&g_Drawer, " | GPU FIQ: Core "); + write_10(&g_Drawer, (g_val >> 2) & 0b11); + + write_string(&g_Drawer, "\n"); + write_hex32(&g_Drawer, ib_val); + write_string(&g_Drawer, " "); + write_hex32(&g_Drawer, i1_val); + write_string(&g_Drawer, " "); + write_hex32(&g_Drawer, i2_val); + write_string(&g_Drawer, " "); + write_hex32(&g_Drawer, f_val); + + // Check UART IRQ + write_string(&g_Drawer, "\nUART: "); + if (i2_val & (1<<25)) { + write_cstring(&g_Drawer, "Enabled", 0x00FF00); + } else { + write_cstring(&g_Drawer, "Disabled", 0xFF0000); + } + + // Check TIMER IRQ + write_string(&g_Drawer, " TIMER: "); + if (ib_val & (1<<0)) { + write_cstring(&g_Drawer, "Enabled", 0x00FF00); + } else { + write_cstring(&g_Drawer, "Disabled", 0xFF0000); + } +} + +void status(void) +{ + unsigned int x = g_Drawer.x; + unsigned int y = g_Drawer.y; + g_Drawer.x = 0; + g_Drawer.y = 0; + // OS Info + write_cstring(&g_Drawer, "DendritOS", 0xFF0000); + write_cstring(&g_Drawer, " v", 0x00FFFF); + write_cstring(&g_Drawer, os_info_v, 0x00FFFF); + write_string(&g_Drawer, " #"); + if (lock_mutex(&exe_cnt_m, SYS_PID) == 0) { + write_10(&g_Drawer, *((unsigned long*)exe_cnt_m.addr)); + release_mutex(&exe_cnt_m, SYS_PID); + } + + // Commands + write_string(&g_Drawer, "\nMonitor: Ctrl-A m Exit: Ctrl-A x Timer: Ctrl-T"); + + // GPU IRQ Statuses + write_string(&g_Drawer, "\n"); + output_irq_status(); + + // Timer Status + write_string(&g_Drawer, "\nTIMER: "); + write_cstring(&g_Drawer, "Enabled ", 0x00FF00); + // Output the frequency + write_string(&g_Drawer, " @ "); + unsigned long frq = read_cntfrq()/1000; + write_10(&g_Drawer, frq); + write_string(&g_Drawer, " kHz "); + // Output the value + unsigned long v = read_cntv_tval(); + write_10(&g_Drawer, v); + write_string(&g_Drawer, " | "); + write_hex32(&g_Drawer, v); + + // Video Status + write_string(&g_Drawer, "\nVIDEO: "); + write_cstring(&g_Drawer, "Enabled ", 0x00FF00); + write_10(&g_Drawer, width); + write_string(&g_Drawer, "x"); + write_10(&g_Drawer, height); + if(isrgb) { + write_string(&g_Drawer, " RGB"); + } else { + write_string(&g_Drawer, " BGR"); + } + + g_Drawer.x = 0; + g_Drawer.y = 8; + for(int i = 0; i < 128; i++) + write_char(&g_Drawer, ' '); + g_Drawer.x = 0; + g_Drawer.y = 8; + write_string(&g_Drawer, "Timer Counter: "); + if (exe_cnt_m.pid == NULL_PID) { + write_cstring(&g_Drawer, "Free!", 0xFF00FF); + } else { + write_cstring(&g_Drawer, "Locked by ", 0xFF00FF); + if (exe_cnt_m.pid == SYS_PID) + write_cstring(&g_Drawer, "System", 0xFF00FF); + else if (exe_cnt_m.pid == SCHED_PID) + write_cstring(&g_Drawer, "Scheduler", 0xFF00FF); + else { + write_cstring(&g_Drawer, "Process ", 0xFF00FF); + write_c10(&g_Drawer, exe_cnt_m.pid, 0xFF00FF); + } + write_cchar(&g_Drawer, '!', 0xFF00FF); + } + g_Drawer.x = x; + g_Drawer.y = y; +} diff --git a/src/util/status.h b/src/util/status.h new file mode 100644 index 0000000..f6966dd --- /dev/null +++ b/src/util/status.h @@ -0,0 +1,6 @@ +#ifndef UTIL_STATUS_H +#define UTIL_STATUS_H + +void status(void); + +#endif |