aboutsummaryrefslogtreecommitdiff
path: root/src/sys
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2021-12-24 15:21:54 -0800
committerChristian Cunningham <cc@localhost>2021-12-24 15:21:54 -0800
commit3a366988a0077474075d8f33ad76514d2fa0c5d6 (patch)
tree7aa293e59bee8308825e029069d395c628d230cd /src/sys
parentd44bf5acb015edaeacc022f423bae4743b868f53 (diff)
Standardized Formatting
Diffstat (limited to 'src/sys')
-rw-r--r--src/sys/core.c38
-rw-r--r--src/sys/core.h13
-rw-r--r--src/sys/power.c3
-rw-r--r--src/sys/timer.c19
-rw-r--r--src/sys/timer.h2
5 files changed, 48 insertions, 27 deletions
diff --git a/src/sys/core.c b/src/sys/core.c
index 178b5f8..8e54f49 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -1,14 +1,14 @@
#include "../cpu/irq.h"
#include "../drivers/uart.h"
-#include "../graphics/lfb.h"
#include "../graphics/drawer.h"
+#include "../graphics/lfb.h"
#include "../lib/mem.h"
#include "../lib/strings.h"
-#include "../util/time.h"
-#include "../util/mutex.h"
#include "../sys/core.h"
-#include "../sys/timer.h"
#include "../sys/power.h"
+#include "../sys/timer.h"
+#include "../util/mutex.h"
+#include "../util/time.h"
#ifndef VERSION
char* os_info_v = "?";
@@ -17,13 +17,13 @@ char* os_info_v = VERSION;
#endif
// Initialize IRQs
-void sysinit() {
+void sysinit(void)
+{
// Route GPU interrupts to Core 0
store32(0x00, GPU_INTERRUPTS_ROUTING);
// Mask Overrun of UART0
store32(1<<4, UART0_IMSC);
-
// Enable UART GPU IRQ
store32(1<<25, IRQ_ENABLE2);
@@ -50,7 +50,8 @@ void sysinit() {
enablefiq();
}
-void output_irq_status(void) {
+void output_irq_status(void)
+{
// Basic IRQ
unsigned long ib_val = load32(IRQ_BASIC_ENABLE);
// IRQ 1
@@ -91,16 +92,10 @@ void output_irq_status(void) {
} else {
write_cstring(&g_Drawer, "Disabled", 0xFF0000);
}
- 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");
}
-void postinit() {
+void postinit(void)
+{
// OS Info
write_cstring(&g_Drawer, "DendritOS", 0xFF0000);
write_cstring(&g_Drawer, " v", 0x00FFFF);
@@ -110,12 +105,24 @@ void postinit() {
write_10(&g_Drawer, *(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);
@@ -127,5 +134,6 @@ void postinit() {
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 74bac74..d70f406 100644
--- a/src/sys/core.h
+++ b/src/sys/core.h
@@ -3,15 +3,18 @@
extern unsigned long cntfrq;
-static inline unsigned long load32(unsigned long addr) {
+static inline unsigned long load32(unsigned long addr)
+{
return *(volatile unsigned long*)addr;
}
-static inline void store32(unsigned long value, unsigned long addr) {
+static inline void store32(unsigned long value, unsigned long addr)
+{
*(volatile unsigned long*)addr = value;
}
-static inline void delay(unsigned long cycles) {
+static inline void delay(unsigned long cycles)
+{
asm volatile("__delay_%=: subs %[cycles], %[cycles], #1;bne __delay_%=\n"
: "=r"(cycles): [cycles]"0"(cycles) : "cc");
}
@@ -113,7 +116,7 @@ enum
PM_RSTC_RESET = 0x00000102,
};
-void sysinit();
-void postinit();
+void sysinit(void);
+void postinit(void);
#endif
diff --git a/src/sys/power.c b/src/sys/power.c
index 4abee01..6b04404 100644
--- a/src/sys/power.c
+++ b/src/sys/power.c
@@ -1,7 +1,8 @@
#include "../sys/core.h"
#include "../sys/power.h"
-void reboot(void) {
+void reboot(void)
+{
store32(PM_WDOG, PM_PASSWORD | 1);
store32(PM_RSTC, PM_PASSWORD | PM_RSTC_WRCFG_FULL_RESET);
}
diff --git a/src/sys/timer.c b/src/sys/timer.c
index aa50bd3..d282789 100644
--- a/src/sys/timer.c
+++ b/src/sys/timer.c
@@ -1,9 +1,9 @@
+#include "../drivers/uart.h"
#include "../graphics/drawer.h"
#include "../sys/core.h"
#include "../sys/timer.h"
-#include "../util/time.h"
#include "../util/mutex.h"
-#include "../drivers/uart.h"
+#include "../util/time.h"
#define SYS_TIMER_C
extern char* os_info_v;
@@ -11,7 +11,8 @@ extern char* os_info_v;
unsigned long exe_cnt = 0;
struct Mutex exe_cnt_m = {.addr = &exe_cnt, .pid = NULL_PID};
-void c_timer() {
+void c_timer(void)
+{
// Reset the counter
write_cntv_tval(cntfrq/100);
@@ -46,11 +47,19 @@ void c_timer() {
g_Drawer.x = 0;
g_Drawer.y = 9;
write_string(&g_Drawer, "Timer Counter: ");
- if (exe_cnt_m.pid == 0) {
+ if (exe_cnt_m.pid == NULL_PID) {
write_cstring(&g_Drawer, "Free!", 0xFF00FF);
} else {
write_cstring(&g_Drawer, "Locked by ", 0xFF00FF);
- write_c10(&g_Drawer, exe_cnt_m.pid, 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;
diff --git a/src/sys/timer.h b/src/sys/timer.h
index 76fc015..29dc2dd 100644
--- a/src/sys/timer.h
+++ b/src/sys/timer.h
@@ -5,6 +5,6 @@
extern struct Mutex exe_cnt_m;
#endif
-void c_timer();
+void c_timer(void);
#endif