aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cpu/irq.c23
-rw-r--r--src/graphics/drawer.c39
-rw-r--r--src/graphics/drawer.h4
-rw-r--r--src/graphics/lfb.c4
-rw-r--r--src/sys/core.c117
-rw-r--r--src/sys/core.h1
-rw-r--r--src/sys/timer.c25
7 files changed, 86 insertions, 127 deletions
diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index 1d50c7d..7c7fc45 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -1,7 +1,8 @@
#include "../cpu/irq.h"
+#include "../drivers/uart.h"
+#include "../graphics/drawer.h"
#include "../sys/core.h"
#include "../sys/timer.h"
-#include "../drivers/uart.h"
#include "../util/mutex.h"
#include "../util/time.h"
@@ -22,23 +23,22 @@ void c_irq_handler(void) {
if(data == 0x14) {
unsigned long timer_status;
asm volatile("mrc p15, 0, %0, c14, c3, 1" : "=r"(timer_status));
+ unsigned int x = g_Drawer.x;
+ unsigned int y = g_Drawer.y;
+ g_Drawer.x = 0;
+ g_Drawer.y = 7;
+ write_string(&g_Drawer, "TIMER: ");
if(timer_status == 0) {
cntfrq = read_cntfrq();
write_cntv_tval(cntfrq);
enable_cntv();
-#ifndef NOANSI
- uart_string((char*)"\033[?25l\033[s\033[4;1H\033[0KTimer: \033[92mEnabled\033[0m\033[u\033[?25h");
-#else
- uart_string((char*)"\033[?25l\033[4;1H\033[0KTimer: \033[92mEnabled\033[0m\033[8;1H\033[?25h> ");
-#endif
+ write_cstring(&g_Drawer, "Enabled ", 0x00FF00);
} else {
disable_cntv();
-#ifndef NOANSI
- uart_string((char*)"\033[?25l\033[s\033[4;1H\033[0KTimer: \033[91mDisabled\033[0m\033[u\033[?25h");
-#else
- uart_string((char*)"\033[?25l\033[4;1H\033[0KTimer: \033[91mDisabled\033[0m\033[8;1H\033[?25h> ");
-#endif
+ write_cstring(&g_Drawer, "Disabled", 0xFF0000);
}
+ g_Drawer.x = x;
+ g_Drawer.y = y;
} else {
unsigned long off = cmdidx;
if (off < 2048) {
@@ -46,7 +46,6 @@ void c_irq_handler(void) {
if (data == 0x0D) {
off = 0;
cmd[0] = 0x0;
- //uart_char(0x0a);
uart_char(data);
uart_string("\033[?25l> \033[0K\033[?25h");
// Backspace Case
diff --git a/src/graphics/drawer.c b/src/graphics/drawer.c
index a2c5d8e..742712a 100644
--- a/src/graphics/drawer.c
+++ b/src/graphics/drawer.c
@@ -3,6 +3,26 @@
static struct Drawer g_Drawer = {x: 0, y: 0};
+void write_cchar(struct Drawer* d, char s, unsigned int c) {
+ d->x %= GG_MAX_X;
+ d->y %= GG_MAX_Y;
+ if (s == 0x0A) {
+ d->y += 1;
+ d->x = 0;
+ } else {
+ draw_cletter(d->x++, d->y, s, c);
+ if (d->x > GG_MAX_X) {
+ d->y += 1;
+ d->x = 0;
+ }
+ }
+ // CHECK Y EVENTUALLY
+}
+
+void write_char(struct Drawer* d, char s) {
+ write_cchar(d, s, 0xFFFFFF);
+}
+
void write_cstring(struct Drawer* d, char* s, unsigned int c) {
d->x %= GG_MAX_X;
d->y %= GG_MAX_Y;
@@ -44,3 +64,22 @@ void write_chex32(struct Drawer* d, unsigned long val, unsigned int c) {
void write_hex32(struct Drawer* d, unsigned long val) {
write_chex32(d, val, 0xFFFFFF);
}
+
+void write_c10(struct Drawer* d, unsigned long val, unsigned int c) {
+ static char out[] = "0000000000";
+ char* s = (char*)out+10;
+ unsigned long tmp = val;
+ if(tmp == 0)
+ s--;
+ while (tmp != 0) {
+ s--;
+ unsigned char rem = tmp%10;
+ tmp /= 10;
+ *s = rem + 0x30;
+ }
+ write_cstring(d, s, c);
+}
+
+void write_10(struct Drawer* d, unsigned long val) {
+ write_c10(d, val, 0xFFFFFF);
+}
diff --git a/src/graphics/drawer.h b/src/graphics/drawer.h
index 63b5194..04f8f23 100644
--- a/src/graphics/drawer.h
+++ b/src/graphics/drawer.h
@@ -8,10 +8,14 @@ struct Drawer {
static struct Drawer g_Drawer;
+void write_cchar(struct Drawer* d, char s, unsigned int c);
+void write_char(struct Drawer* d, char s);
void write_cstring(struct Drawer* d, char* s, unsigned int c);
void write_string(struct Drawer* d, char* s);
void write_chex32(struct Drawer* d, unsigned long val, unsigned int c);
void write_hex32(struct Drawer* d, unsigned long val);
+void write_c10(struct Drawer* d, unsigned long val, unsigned int c);
+void write_10(struct Drawer* d, unsigned long val);
void set_drawer(struct Drawer* d, unsigned int x, unsigned int y);
#endif
diff --git a/src/graphics/lfb.c b/src/graphics/lfb.c
index de241d8..5e307f4 100644
--- a/src/graphics/lfb.c
+++ b/src/graphics/lfb.c
@@ -100,7 +100,7 @@ void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsign
for(y=0; y<8; y++) {
for(x=0; x<8; x++) {
if((1 << (7-x)) & glyphs_byte[y+8*(ltr)]) {
- *((unsigned int*)ptr) = isrgb ? c : (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16);;
+ *((unsigned int*)ptr) = isrgb ? (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16) : c;
} else {
*((unsigned int*)ptr) = 0x000000;
}
@@ -118,7 +118,7 @@ void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsi
for(y=0; y<8; y++) {
for(x=0; x<8; x++) {
if((1 << (7-x)) & glyphs[y+8*(ltr)]) {
- *((unsigned int*)ptr) = isrgb ? c : (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16);;
+ *((unsigned int*)ptr) = isrgb ? (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16) : c;
} else {
*((unsigned int*)ptr) = 0x000000;
}
diff --git a/src/sys/core.c b/src/sys/core.c
index f3699d8..f5d7ca1 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -18,9 +18,6 @@ char* os_info_v = "?";
char* os_info_v = VERSION;
#endif
-static char* irq_on = " \033[92mEnabled\033[0m";
-static char* irq_off = " \033[91mDisabled\033[0m";
-
// Initialize IRQs
void sysinit() {
// Mask Overrun of UART0
@@ -31,7 +28,6 @@ void sysinit() {
// Route GPU interrupts to Core 0
store32(0x00, GPU_INTERRUPTS_ROUTING);
- //*(unsigned long*)
// Enable Timer
// As an IRQ
@@ -48,9 +44,6 @@ void sysinit() {
enable_cntv();
// Graphics Initialize
- //init_graphics();
- //draw_box(0x01FE, 0, 0, 640, 480);
- //draw_box(0xFFFF, 2, 2, 10, 10);
lfb_init();
lfb_showpicture();
@@ -59,72 +52,6 @@ void sysinit() {
enablefiq();
}
-// Checks IRQ status
-void chk_irq_stat() {
- uart_string((char*)"Checking Enabled Services...\n");
-
- // Basic IRQ
- unsigned long ib_val = load32(IRQ_BASIC_ENABLE);
- uart_string((char*)"IRQB Status: ");
- uart_hexn(ib_val);
-
- // IRQ 1
- unsigned long i1_val = load32(IRQ_ENABLE1);
- uart_string((char*)"IRQ1 Status: ");
- uart_hexn(i1_val);
-
- // IRQ 2
- unsigned long i2_val = load32(IRQ_ENABLE2);
- uart_string((char*)"IRQ2 Status: ");
- uart_hexn(i2_val);
-
- // Check UART IRQ
- uart_string((char*)" UART:");
- if (i2_val & (1<<25)) {
- uart_string(irq_on);
- } else {
- uart_string(irq_off);
- }
- uart_char(0x0a);
-
- // Check TIMER IRQ
- uart_string((char*)" TIMER:");
- if (ib_val & (1<<0)) {
- uart_string(irq_on);
- // Output the frequency
- uart_string((char*)" Frequency: ");
- cntfrq = read_cntfrq();
- //uart_hexn(cntfrq);
- uart_10(cntfrq);
- uart_string((char*)" Hz\n");
- } else {
- uart_string(irq_off);
- }
- uart_char(0x0a);
-
- // Check FIQ
- unsigned long f_val = load32(FIQ_CONTROL);
- uart_string((char*)"FIQ Status: ");
- uart_hexn(f_val);
- if (f_val & 0x80) {
- uart_string(irq_on);
- } else {
- uart_string(irq_off);
- }
- uart_char(0x0a);
-
- // Check GPU Interrupt Routing
- unsigned long g_val = load32(GPU_INTERRUPTS_ROUTING);
- uart_string((char*)"GPU IRQ Routed to Core ");
- uart_char(0x30 + (g_val & 0x3));
- uart_char(0x0a);
- uart_string((char*)"GPU FIQ Routed to Core ");
- uart_char(0x30 + ((g_val>>2) & 0x3));
- uart_char(0x0a);
-
- uart_char(0x0a);
-}
-
void output_irq_status(void) {
// Basic IRQ
unsigned long ib_val = load32(IRQ_BASIC_ENABLE);
@@ -135,17 +62,12 @@ void output_irq_status(void) {
// FIQ
unsigned long f_val = load32(FIQ_CONTROL);
- uart_string("\033[5;1H");
// Check GPU Interrupt Routing
unsigned long g_val = load32(GPU_INTERRUPTS_ROUTING);
- uart_string((char*)"GPU IRQ: Core ");
- uart_char(0x30 + (g_val & 0x3));
- uart_string((char*)" | GPU FIQ: Core ");
- uart_char(0x30 + ((g_val>>2) & 0x3));
write_string(&g_Drawer, "GPU IRQ: Core ");
- write_hex32(&g_Drawer, g_val & 0b11);
+ write_10(&g_Drawer, g_val & 0b11);
write_string(&g_Drawer, " | GPU FIQ: Core ");
- write_hex32(&g_Drawer, (g_val >> 2) & 0b11);
+ write_10(&g_Drawer, (g_val >> 2) & 0b11);
write_string(&g_Drawer, "\n");
write_hex32(&g_Drawer, ib_val);
@@ -159,46 +81,43 @@ void output_irq_status(void) {
// Check UART IRQ
write_string(&g_Drawer, "\nUART: ");
if (i2_val & (1<<25)) {
- uart_string(irq_on);
write_cstring(&g_Drawer, "Enabled", 0x00FF00);
} else {
- uart_string(irq_off);
write_cstring(&g_Drawer, "Disabled", 0xFF0000);
}
// Check TIMER IRQ
- write_string(&g_Drawer, "\n");
- write_string(&g_Drawer, "TIMER: ");
+ write_string(&g_Drawer, "\nTIMER: ");
if (ib_val & (1<<0)) {
- uart_string(irq_on);
write_cstring(&g_Drawer, "Enabled", 0x00FF00);
// Output the frequency
- uart_string(" @ ");
+ write_string(&g_Drawer, " @ ");
unsigned long frq = read_cntfrq()/1000;
- uart_10(frq);
- uart_string((char*)" kHz");
+ write_10(&g_Drawer, frq);
+ write_string(&g_Drawer, " kHz");
} else {
- uart_string(irq_off);
write_cstring(&g_Drawer, "Disabled", 0xFF0000);
}
-
+ write_string(&g_Drawer, "\nTIMER: ");
+ write_cstring(&g_Drawer, "Enabled", 0x00FF00);
}
void postinit() {
// OS Info
- uart_string("\033[2J\033[1;1H\033[91mDendritOS \033[96mv");
- uart_string(os_info_v);
- uart_string("\033[0m #");
+ write_cstring(&g_Drawer, "DendritOS", 0xFF0000);
+ write_cstring(&g_Drawer, " v", 0x00FF00);
+ write_cstring(&g_Drawer, os_info_v, 0x00FF00);
+ write_string(&g_Drawer, " #");
if (lock_mutex(&exe_cnt_m, SYS_PID) == 0) {
- uart_10(*(exe_cnt_m.addr));
+ write_10(&g_Drawer, *(exe_cnt_m.addr));
release_mutex(&exe_cnt_m, SYS_PID);
}
// Commands
- uart_string("\033[2;1HMonitor: Ctrl-A m\033[2;20HExit: Ctrl-A x");
- uart_string("\033[3;1HTimer: Ctrl-T\033[3;20H");
+ write_string(&g_Drawer, "\nMonitor Ctrl-A m Exit: Ctrl-A x");
+ write_string(&g_Drawer, "\nTimer: Ctrl-T");
// Timer Status
- uart_string("\033[4;1HTimer: \033[92mEnabled\033[0m");
+ //uart_string("Timer: \033[92mEnabled\033[0m");
// GPU IRQ Statuses
+ write_string(&g_Drawer, "\n");
output_irq_status();
- // Input line
- uart_string("\033[8;1H> ");
+ write_string(&g_Drawer, "\n> ");
}
diff --git a/src/sys/core.h b/src/sys/core.h
index d720e17..88d4644 100644
--- a/src/sys/core.h
+++ b/src/sys/core.h
@@ -114,7 +114,6 @@ enum
};
void sysinit();
-void chk_irq_stat();
void postinit();
#endif
diff --git a/src/sys/timer.c b/src/sys/timer.c
index ca3366c..ff55bd4 100644
--- a/src/sys/timer.c
+++ b/src/sys/timer.c
@@ -1,3 +1,4 @@
+#include "../graphics/drawer.h"
#include "../sys/core.h"
#include "../sys/timer.h"
#include "../util/time.h"
@@ -22,21 +23,19 @@ void c_timer() {
//uart_hexn(v);
// Lock the execution counter
+ unsigned int x = g_Drawer.x;
+ unsigned int y = g_Drawer.y;
+ g_Drawer.x = 0;
+ g_Drawer.y = 0;
if (lock_mutex(&exe_cnt_m, SCHED_PID) == 0) {
*(exe_cnt_m.addr) += 1;
-#ifndef NOANSI
- uart_string("\033[?25l\033[s\033[1;1H\033[91mDendritOS \033[96mv");
-#else
- uart_string("\033[?25l\033[1;1H\033[91mDendritOS \033[96mv");
-#endif
- uart_string(os_info_v);
- uart_string("\033[0m #");
- uart_10(*(exe_cnt_m.addr));
-#ifndef NOANSI
- uart_string("\033[u\033[?25h");
-#else
- uart_string("\033[8;1H\033[?25h> ");
-#endif
+ write_cstring(&g_Drawer, "DendritOS", 0xDF0000);
+ write_cstring(&g_Drawer, " v", 0x00DF00);
+ write_cstring(&g_Drawer, os_info_v, 0x00DF00);
+ write_string(&g_Drawer, " #");
+ write_10(&g_Drawer, *(exe_cnt_m.addr));
release_mutex(&exe_cnt_m, SCHED_PID);
}
+ g_Drawer.x = x;
+ g_Drawer.y = y;
}