aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cpu/irq.c24
-rw-r--r--src/globals.c2
-rw-r--r--src/graphics/drawer.c100
-rw-r--r--src/graphics/lfb.c6
-rw-r--r--src/sys/core.c1
-rw-r--r--src/util/status.c143
6 files changed, 80 insertions, 196 deletions
diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index cfa9d7d..9e44009 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -1,7 +1,7 @@
#include <cpu.h>
#include <cpu/irq.h>
#include <globals.h>
-#include <graphics/drawer.h>
+#include <graphics/lfb.h>
#include <symbols.h>
#include <sys/core.h>
#include <sys/schedule.h>
@@ -27,13 +27,7 @@ void c_irq_handler(void)
unsigned long data = load32(UART0_DR);
// Draw it on the screen
{
- unsigned int x = g_Drawer.x;
- unsigned int y = g_Drawer.y;
- g_Drawer.x = 0;
- g_Drawer.y = 9;
- write_chex32(&g_Drawer, data, 0xAA00FF);
- g_Drawer.x = x;
- g_Drawer.y = y;
+ draw_chex32(0, 9, data, 0xAA00FF);
}
// Handle the recieved data
@@ -41,23 +35,17 @@ 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 = 3;
if(timer_status == 0) {
cntfrq = read_cntfrq();
write_cntv_tval(cntfrq/CPS);
enablecntv();
- write_cstring(&g_Drawer, "TIMER", 0x00FF00);
- write_string(&g_Drawer, ": ");
+ draw_cstring(0, 3, "TIMER", 0x00FF00);
+ draw_string(0, 3, ": ");
} else {
disablecntv();
- write_cstring(&g_Drawer, "TIMER", 0xFF0000);
- write_string(&g_Drawer, ": ");
+ draw_cstring(0, 3, "TIMER", 0xFF0000);
+ draw_string(0, 3, ": ");
}
- g_Drawer.x = x;
- g_Drawer.y = y;
}
// Add task to handle the data
else {
diff --git a/src/globals.c b/src/globals.c
index c596309..e94580c 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -1,7 +1,6 @@
#define GLOBALS_C
#include <lib/kmem.h>
#include <util/mutex.h>
-#include <graphics/drawer.h>
#include <sys/schedule.h>
char* os_name = "Jobbed";
#ifndef VERSION
@@ -16,7 +15,6 @@ __attribute__((section(".bss"))) unsigned long nextpid;
__attribute__((section(".bss"))) unsigned long sched_stack_count;
__attribute__((section(".bss"))) unsigned long stimel;
__attribute__((section(".bss"))) unsigned long stimeh;
-__attribute__((section(".bss"))) struct Drawer g_Drawer;
__attribute__((section(".bss"))) struct Scheduler scheduler;
__attribute__((section(".bss"))) struct Thread usrloopthread;
__attribute__((section(".bss"))) unsigned int gwidth;
diff --git a/src/graphics/drawer.c b/src/graphics/drawer.c
deleted file mode 100644
index dc0ffe1..0000000
--- a/src/graphics/drawer.c
+++ /dev/null
@@ -1,100 +0,0 @@
-#include <graphics/drawer.h>
-#include <graphics/lfb.h>
-
-void write_cchar(struct Drawer* d, char s, unsigned int c)
-{
- lock(&d->l);
- 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;
- }
- }
- unlock(&d->l);
- // 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)
-{
- lock(&d->l);
- d->x %= GG_MAX_X;
- d->y %= GG_MAX_Y;
- unsigned int idx = 0;
- while(s[idx] != 0) {
- if (s[idx] == 0x0A) {
- d->y += 1;
- d->x = 0;
- idx++;
- } else {
- draw_cletter(d->x++, d->y, s[idx++], c);
- if (d->x >= GG_MAX_X) {
- d->y += 1;
- d->x = 0;
- }
- }
- // CHECK Y EVENTUALLY
- }
- unlock(&d->l);
-}
-
-void write_string(struct Drawer* d, char* s)
-{
- write_cstring(d, s, 0xFFFFFF);
-}
-
-void write_chex32(struct Drawer* d, unsigned long val, unsigned int c)
-{
- lock(&d->l);
- draw_chex32(d->x, d->y, val, c);
- d->x += 8;
- if (d->x >= GG_MAX_X) {
- d->y += 1;
- d->x %= GG_MAX_X;
- }
- unlock(&d->l);
-}
-
-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\0";
- char* s = (char*)out+9;
- unsigned long tmp = val;
- for(int i = 0; i < 10; i++) {
- unsigned char rem = tmp%10;
- tmp /= 10;
- *s = rem + 0x30;
- if (tmp==0)
- break;
- s--;
- }
- write_cstring(d, s, c);
-}
-
-void write_10(struct Drawer* d, unsigned long val)
-{
- write_c10(d, val, 0xFFFFFF);
-}
-
-void set_drawer(struct Drawer* d, unsigned int x, unsigned int y)
-{
- lock(&d->l);
- d->x = x % GG_MAX_X;
- d->y = y % GG_MAX_Y;
- unlock(&d->l);
-}
diff --git a/src/graphics/lfb.c b/src/graphics/lfb.c
index ee31514..8f7ad06 100644
--- a/src/graphics/lfb.c
+++ b/src/graphics/lfb.c
@@ -116,12 +116,12 @@ void draw_cpixel(unsigned long lx, unsigned long ly, unsigned int c)
*((unsigned int*)ptr) = gisrgb ? (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16) : c;
}
-void draw_cbox(unsigned long lx, unsigned long ly, unsigned char dx, unsigned char dy, unsigned int c)
+void draw_cbox(unsigned long lx, unsigned long ly, unsigned int dx, unsigned int dy, unsigned int c)
{
unsigned char* ptr = lfb;
ptr += (gpitch*ly+lx*4);
- for(int y = 0; y < dy; y++) {
- for(int x = 0; x < dx; x++) {
+ for(unsigned int y = 0; y < dy; y++) {
+ for(unsigned int x = 0; x < dx; x++) {
*((unsigned int*)ptr) = gisrgb ? (unsigned int)((c&0xFF)<<16 | (c&0xFF00) | (c&0xFF0000)>>16) : c;
ptr += 4;
}
diff --git a/src/sys/core.c b/src/sys/core.c
index 99c08ae..4816d50 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -2,7 +2,6 @@
#include <cpu.h>
#include <drivers/uart.h>
#include <globals.h>
-#include <graphics/drawer.h>
#include <graphics/lfb.h>
#include <lib/kmem.h>
#include <lib/mmu.h>
diff --git a/src/util/status.c b/src/util/status.c
index a54e7c0..7e173b8 100644
--- a/src/util/status.c
+++ b/src/util/status.c
@@ -1,8 +1,9 @@
#include <cpu.h>
#include <globals.h>
-#include <graphics/drawer.h>
#include <graphics/lfb.h>
#include <symbols.h>
+#include <lib/strings.h>
+#include <lib/kmem.h>
#include <sys/core.h>
#include <sys/schedule.h>
#include <util/mutex.h>
@@ -22,125 +23,123 @@ void output_irq_status(void)
// Check GPU Interrupt Routing
unsigned long g_val = load32(GPU_INTERRUPTS_ROUTING);
- write_c10(&g_Drawer, g_val & 0b11, 0x1EA1A1);
- write_c10(&g_Drawer, (g_val >> 2) & 0b11, 0x1EA1A1);
+ draw_cletter(0, 1, (g_val & 0b11) + 0x30, 0x1EA1A1);
+ draw_cletter(1, 1, ((g_val >> 2) & 0b11) + 0x30, 0x1EA1A1);
- write_string(&g_Drawer, " ");
- write_chex32(&g_Drawer, ib_val, 0x1EA1A1);
- write_chex32(&g_Drawer, i1_val, 0x1EA1A1);
- write_chex32(&g_Drawer, i2_val, 0x1EA1A1);
- write_chex32(&g_Drawer, f_val, 0x1EA1A1);
- write_char(&g_Drawer, '\n');
+ draw_chex32(4, 1, ib_val, 0x1EA1A1);
+ draw_chex32(4+9, 1, i1_val, 0x1EA1A1);
+ draw_chex32(4+9*2, 1, i2_val, 0x1EA1A1);
+ draw_chex32(4+9*3, 1, f_val, 0x1EA1A1);
// Check UART IRQ
if (i2_val & (1<<25)) {
- write_cstring(&g_Drawer, "UART ", 0x00FF00);
+ draw_cstring(0, 2, "UART", 0x00FF00);
} else if (f_val == 57) {
- write_cstring(&g_Drawer, "UART ", 0xFFA500);
+ draw_cstring(0, 2, "UART", 0xFFA500);
} else {
- write_cstring(&g_Drawer, "UART ", 0xFF0000);
+ draw_cstring(0, 2, "UART", 0xFF0000);
}
// Check UART IRQ
if (i1_val & (1<<0)) {
- write_cstring(&g_Drawer, "STIMERCMP ", 0x00FF00);
+ draw_cstring(5, 2, "STIMERCMP", 0x00FF00);
} else {
- write_cstring(&g_Drawer, "STIMERCMP ", 0xFF0000);
+ draw_cstring(5, 2, "STIMERCMP", 0xFF0000);
}
if (load32(CORE0_TIMER_IRQCNTL) & 0xF) {
- write_cstring(&g_Drawer, "LTIMER ", 0x00FF00);
+ draw_cstring(4+9+2, 2, "LTIMER", 0x00FF00);
} else if (load32(CORE0_TIMER_IRQCNTL) & 0xF0) {
- write_cstring(&g_Drawer, "LTIMER ", 0xFFA500);
+ draw_cstring(4+9+2, 2, "LTIMER", 0xFFA500);
} else {
- write_cstring(&g_Drawer, "LTIMER ", 0xFF0000);
+ draw_cstring(4+9+2, 2, "LTIMER", 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, os_name, 0xFF0000);
- write_cstring(&g_Drawer, " v", 0x00FFFF);
- write_cstring(&g_Drawer, os_info_v, 0x00FFFF);
- write_cstring(&g_Drawer, " # TStacks: ", 0xFFDF00);
- draw_string(g_Drawer.x, g_Drawer.y, " ");
- write_c10(&g_Drawer, sched_stack_count, 0xFFDF00);
+ draw_cstring(0, 0, " v ", 0x00FFFF);
+ draw_cstring(0, 0, os_name, 0xFF0000);
+ draw_cstring(10, 0, os_info_v, 0x00FFFF);
+ draw_cstring(16, 0, "# TStacks:", 0xFFDF00);
+ draw_string(27, 0, " ");
+ char* st_str = u32_to_str(sched_stack_count);
+ draw_cstring(27, 0, st_str, 0xFFDF00);
+ kfree(st_str);
// GPU IRQ Statuses
- write_string(&g_Drawer, "\n");
output_irq_status();
// Timer Status
- write_cstring(&g_Drawer, "\nTIMER", 0x00FF00);
+ draw_cstring(0, 3, "TIMER", 0x00FF00);
// Output the frequency
- write_string(&g_Drawer, " @ ");
+ draw_string(6, 3, "@");
unsigned long frq = read_cntfrq()/1000;
- write_10(&g_Drawer, frq);
- write_string(&g_Drawer, " kHz ");
+ char* frq_str = u32_to_str(frq);
+ unsigned long fs_len = strlen(frq_str)+1;
+ draw_string(8, 3, frq_str);
+ kfree(frq_str);
+ draw_string(8+fs_len, 3, "kHz");
// Output the value
unsigned long v = read_cntv_tval();
- write_10(&g_Drawer, v);
- write_string(&g_Drawer, " | ");
- write_hex32(&g_Drawer, v);
+ char* v_str = u32_to_str(v);
+ unsigned long vs_len = strlen(v_str) + 1;
+ draw_string(8+fs_len+4, 3, v_str);
+ draw_string(8+fs_len+4 +vs_len, 3, " ");
+ kfree(v_str);
+ draw_letter(8+fs_len+4 +vs_len+1, 3, '|');
+ draw_hex32(8+fs_len+7+vs_len, 3, v);
// Video Status
- write_cstring(&g_Drawer, "\nVIDEO ", 0x00FF00);
- write_10(&g_Drawer, gwidth);
- write_string(&g_Drawer, "x");
- write_10(&g_Drawer, gheight);
- if(gisrgb) {
- write_string(&g_Drawer, " RGB");
- } else {
- write_string(&g_Drawer, " BGR");
- }
+ draw_cstring(0, 4, "VIDEO", 0x00FF00);
+ char* gwidth_str;
+ gwidth_str = u32_to_str(gwidth);
+ unsigned long gs_len = strlen(gwidth_str) + 1;
+ draw_string(6, 4, gwidth_str);
+ kfree(gwidth_str);
+ draw_letter(6+gs_len-1, 4, 'x');
+ gwidth_str = u32_to_str(gheight);
+ unsigned long gs_len1 = strlen(gwidth_str) + 1;
+ draw_string(6+gs_len, 4, gwidth_str);
+ kfree(gwidth_str);
+ if(gisrgb)
+ draw_string(6+gs_len+gs_len1, 4, "RGB");
+ else
+ draw_string(6+gs_len+gs_len1, 4, "BGR");
// Core Stacks
- g_Drawer.x = 0;
- g_Drawer.y = 5;
- write_string(&g_Drawer, "SVC IRQ FIQ User/SYS\n");
- g_Drawer.x = 0;
- g_Drawer.y = 6;
+ draw_string(0, 5, "SVC IRQ FIQ User/SYS\n");
unsigned long sp = (unsigned long)getsvcstack();
- write_hex32(&g_Drawer, sp);
- write_char(&g_Drawer, ' ');
+ draw_hex32(0, 6, sp);
sp = (unsigned long)getirqstack();
- write_hex32(&g_Drawer, sp);
- write_char(&g_Drawer, ' ');
+ draw_hex32(9, 6, sp);
sp = (unsigned long)getfiqstack();
- write_hex32(&g_Drawer, sp);
- write_char(&g_Drawer, ' ');
+ draw_hex32(9*2, 6, sp);
sp = (unsigned long)getsysstack();
- write_hex32(&g_Drawer, sp);
- write_char(&g_Drawer, '\n');
+ draw_hex32(9*3, 6, sp);
// Report Core that updated status
unsigned long coren;
asm volatile (
"mrc p15, #0, %0, c0, c0, #5\n"
"and %0, %0, #3" : "=r"(coren) :: "cc");
- write_string(&g_Drawer, "Status Updated by Core #");
- write_10(&g_Drawer, coren);
+ draw_string(0, 7, "Status Updated by Core #");
+ draw_hex32(24, 7, coren);
// Report Sys Timer Stataus
- write_string(&g_Drawer, "\nSys Timer Status ");
+ draw_string(0, 8, "Sys Timer Status");
coren = *(volatile unsigned long*)SYS_TIMER_CS;
- write_10(&g_Drawer, coren);
- write_string(&g_Drawer, ":");
+ draw_hex32(17, 8, coren);
+ draw_string(17+8, 8, ":");
unsigned long long tval = get_time();
- write_hex32(&g_Drawer, (tval >> 32));
- write_hex32(&g_Drawer, tval);
- write_string(&g_Drawer, ":");
+ draw_hex32(17+8, 8, (tval >> 32));
+ draw_hex32(17+8+8, 8, tval);
coren = *(volatile unsigned long*)SYS_TIMER_C0;
- write_10(&g_Drawer, coren);
- write_string(&g_Drawer, " | ");
- draw_string(g_Drawer.x, g_Drawer.y, " ");
- write_10(&g_Drawer, ((unsigned long)tval)/1000000);
-
- g_Drawer.x = x;
- g_Drawer.y = y;
+ draw_hex32(19+14+8+1, 8, coren);
+ draw_string(19+14+9+8, 8, "|");
+ draw_string(19+14+18, 8, " ");
+ char* t_str = u32_to_str(((unsigned long)tval)/1000000);
+ draw_string(19+14+18, 8, t_str);
+ kfree(t_str);
}