aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/boot.S2
-rw-r--r--src/cpu/atomic/swap.h6
-rw-r--r--src/cpu/irq.c9
-rw-r--r--src/cpu/irq.h12
-rw-r--r--src/drivers/uart.c8
-rw-r--r--src/drivers/uart.h5
-rw-r--r--src/graphics/drawer.c37
-rw-r--r--src/graphics/drawer.h4
-rw-r--r--src/graphics/font.bin.h (renamed from src/graphics/font.h.bin)0
-rw-r--r--src/graphics/glyphs.h3
-rw-r--r--src/graphics/glyphs.old2
-rw-r--r--src/graphics/homer.h1
-rw-r--r--src/graphics/lfb.c59
-rw-r--r--src/graphics/lfb.h16
-rw-r--r--src/lib/mem.c15
-rw-r--r--src/lib/strings.c9
-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
-rw-r--r--src/util/mutex.c10
-rw-r--r--src/util/time.c1
23 files changed, 174 insertions, 100 deletions
diff --git a/src/boot.S b/src/boot.S
index 2a9b459..9128ba0 100644
--- a/src/boot.S
+++ b/src/boot.S
@@ -88,4 +88,4 @@ prefetch_handler: .word io_halt
data_handler: .word io_halt
unused_handler: .word io_halt
irq_handler: .word irq
-fiq_handler: .word fiq
+fiq_handler: .word io_halt // fiq
diff --git a/src/cpu/atomic/swap.h b/src/cpu/atomic/swap.h
index 374dd97..3584d4e 100644
--- a/src/cpu/atomic/swap.h
+++ b/src/cpu/atomic/swap.h
@@ -8,7 +8,8 @@
/// https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/3_Processes.html
/// https://developer.arm.com/documentation/dht0008/a/arm-synchronization-primitives/practical-uses/implementing-a-semaphore?lang=en
-static inline void atm_lock(unsigned long pid, unsigned long* addr) {
+static inline void atm_lock(unsigned long pid, unsigned long* addr)
+{
unsigned long tmp, current_lock_value;
asm volatile(
"1: ldrex %0, [%3]\n"
@@ -23,7 +24,8 @@ static inline void atm_lock(unsigned long pid, unsigned long* addr) {
: "cc");
}
-static inline void atm_release(unsigned long* addr) {
+static inline void atm_release(unsigned long* addr)
+{
unsigned long cleared = NULL_PID;
asm volatile(
" dmb\n"
diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index f2b326e..1654828 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -8,10 +8,9 @@
extern unsigned long cmdidx;
extern char cmd[2048];
-extern void disable_irq(void);
-extern void enable_irq(void);
-void c_irq_handler(void) {
+void c_irq_handler(void)
+{
disableirq();
unsigned long source = load32(CORE0_IRQ_SOURCE);
if (source & (1 << 8)) {
@@ -56,12 +55,12 @@ void c_irq_handler(void) {
} else if (data == 0x6C) {
cmd[off] = (char) data;
off += 1;
- lock_mutex(&exe_cnt_m, SCHED_PID);
+ lock_mutex(&exe_cnt_m, SYS_PID);
// Release Case
} else if (data == 0x72) {
cmd[off] = (char) data;
off += 1;
- release_mutex(&exe_cnt_m, SCHED_PID);
+ release_mutex(&exe_cnt_m, SYS_PID);
// Else output
} else {
cmd[off] = (char) data;
diff --git a/src/cpu/irq.h b/src/cpu/irq.h
index 971d0b9..3b8f085 100644
--- a/src/cpu/irq.h
+++ b/src/cpu/irq.h
@@ -1,16 +1,20 @@
#ifndef CPU_IRQ_H
#define CPU_IRQ_H
-static inline void enableirq() {
+static inline void enableirq(void)
+{
asm volatile("cpsie i");
}
-static inline void disableirq() {
+static inline void disableirq(void)
+{
asm volatile("cpsid i");
}
-static inline void enablefiq() {
+static inline void enablefiq(void)
+{
asm volatile("cpsie f");
}
-static inline void disablefiq() {
+static inline void disablefiq(void)
+{
asm volatile("cpsid f");
}
diff --git a/src/drivers/uart.c b/src/drivers/uart.c
index 64bd73a..a45f86d 100644
--- a/src/drivers/uart.c
+++ b/src/drivers/uart.c
@@ -1,11 +1,13 @@
#include "../drivers/uart.h"
-void uart_hexn(unsigned long c_val) {
+void uart_hexn(unsigned long c_val)
+{
uart_hex(c_val);
- uart_char(0x0a);
+ uart_char('\n');
}
-void uart_10(unsigned long val) {
+void uart_10(unsigned long val)
+{
unsigned long t = val;
unsigned long c;
char buffer[11] = "0000000000\0";
diff --git a/src/drivers/uart.h b/src/drivers/uart.h
index c3f8e86..21e8795 100644
--- a/src/drivers/uart.h
+++ b/src/drivers/uart.h
@@ -1,8 +1,9 @@
#ifndef DRIVERS_UART_H
#define DRIVERS_UART_H
-#define PRINTS_DBG(X) uart_char('[');uart_string(__FILE__);uart_char(':');uart_10(__LINE__);uart_string("] ");uart_string(X);
-#define PRINTI_DBG(X) uart_char('[');uart_string(__FILE__);uart_char(':');uart_10(__LINE__);uart_string("] ");uart_10(X);
+#define PRINTS_DBG(X) uart_char('[');uart_string(__FILE__);uart_char(':');uart_10(__LINE__);uart_string("] ");uart_string(X);uart_char('\n');
+#define PRINTX_DBG(X) uart_char('[');uart_string(__FILE__);uart_char(':');uart_10(__LINE__);uart_string("] ");uart_hex((unsigned long)X);uart_char('\n');
+#define PRINTI_DBG(X) uart_char('[');uart_string(__FILE__);uart_char(':');uart_10(__LINE__);uart_string("] ");uart_10((unsigned long)X);uart_char('\n');
extern void uart_char(unsigned char c);
extern void uart_hex(unsigned long data);
diff --git a/src/graphics/drawer.c b/src/graphics/drawer.c
index be7b0ac..35a16a6 100644
--- a/src/graphics/drawer.c
+++ b/src/graphics/drawer.c
@@ -1,10 +1,11 @@
-#include "../graphics/lfb.h"
#include "../graphics/drawer.h"
+#include "../graphics/lfb.h"
#define GRAPHICS_DRAWER_C
struct Drawer g_Drawer = {.x = 0, .y = 0};
-void write_cchar(struct Drawer* d, char s, unsigned int c) {
+void write_cchar(struct Drawer* d, char s, unsigned int c)
+{
d->x %= GG_MAX_X;
d->y %= GG_MAX_Y;
if (s == 0x0A) {
@@ -20,11 +21,13 @@ void write_cchar(struct Drawer* d, char s, unsigned int c) {
// CHECK Y EVENTUALLY
}
-void write_char(struct Drawer* d, char s) {
+void write_char(struct Drawer* d, char s)
+{
write_cchar(d, s, 0xFFFFFF);
}
-void write_cstring(struct Drawer* d, char* s, unsigned int c) {
+void write_cstring(struct Drawer* d, char* s, unsigned int c)
+{
d->x %= GG_MAX_X;
d->y %= GG_MAX_Y;
unsigned int idx = 0;
@@ -44,16 +47,13 @@ void write_cstring(struct Drawer* d, char* s, unsigned int c) {
}
}
-void write_string(struct Drawer* d, char* s) {
+void write_string(struct Drawer* d, char* s)
+{
write_cstring(d, s, 0xFFFFFF);
}
-void set_drawer(struct Drawer* d, unsigned int x, unsigned int y) {
- d->x = x % GG_MAX_X;
- d->y = y % GG_MAX_Y;
-}
-
-void write_chex32(struct Drawer* d, unsigned long val, unsigned int c) {
+void write_chex32(struct Drawer* d, unsigned long val, unsigned int c)
+{
draw_chex32(d->x, d->y, val, c);
d->x += 8;
if (d->x >= GG_MAX_X) {
@@ -62,11 +62,13 @@ void write_chex32(struct Drawer* d, unsigned long val, unsigned int c) {
}
}
-void write_hex32(struct Drawer* d, unsigned long val) {
+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) {
+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;
@@ -81,6 +83,13 @@ void write_c10(struct Drawer* d, unsigned long val, unsigned int c) {
write_cstring(d, s, c);
}
-void write_10(struct Drawer* d, unsigned long val) {
+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)
+{
+ d->x = x % GG_MAX_X;
+ d->y = y % GG_MAX_Y;
+}
diff --git a/src/graphics/drawer.h b/src/graphics/drawer.h
index 1ad89c5..6d97163 100644
--- a/src/graphics/drawer.h
+++ b/src/graphics/drawer.h
@@ -12,12 +12,16 @@ extern 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/font.h.bin b/src/graphics/font.bin.h
index f883cda..f883cda 100644
--- a/src/graphics/font.h.bin
+++ b/src/graphics/font.bin.h
diff --git a/src/graphics/glyphs.h b/src/graphics/glyphs.h
index 668508e..1a9319d 100644
--- a/src/graphics/glyphs.h
+++ b/src/graphics/glyphs.h
@@ -1,7 +1,6 @@
#ifndef GRAPHICS_GLYPHS_H
#define GRAPHICS_GLYPHS_H
-//extern char* glyphs;
-#include "font.h.bin"
+#include "font.bin.h"
#endif
diff --git a/src/graphics/glyphs.old b/src/graphics/glyphs.old
index 6377747..0a831f9 100644
--- a/src/graphics/glyphs.old
+++ b/src/graphics/glyphs.old
@@ -1,4 +1,3 @@
-
const char glyphs[] = {
0b10000001,
0b00111000,
@@ -1298,4 +1297,3 @@ const char glyphs_byte[] = {
0b01000000,
0b00000000,
};
-
diff --git a/src/graphics/homer.h b/src/graphics/homer.h
index 97b4edb..459bc3d 100644
--- a/src/graphics/homer.h
+++ b/src/graphics/homer.h
@@ -11,6 +11,7 @@ pixel[1] = ((((data[1] - 33) & 0xF) << 4) | ((data[2] - 33) >> 2)); \
pixel[2] = ((((data[2] - 33) & 0x3) << 6) | ((data[3] - 33))); \
data += 4; \
}
+
static char *homer_data =
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
diff --git a/src/graphics/lfb.c b/src/graphics/lfb.c
index 6aa6012..54bc71c 100644
--- a/src/graphics/lfb.c
+++ b/src/graphics/lfb.c
@@ -1,8 +1,8 @@
#include "../drivers/uart.h"
+#include "../graphics/glyphs.h"
+#include "../graphics/homer.h"
#include "../graphics/lfb.h"
#include "../graphics/mbox.h"
-#include "../graphics/homer.h"
-#include "../graphics/glyphs.h"
#define GRAPHICS_LFB_C
unsigned int width, height, pitch, isrgb; /* dimensions and channel order */
@@ -11,7 +11,7 @@ unsigned char *lfb; /* raw frame buffer address */
/**
* Set screen resolution to 1024x768
*/
-void lfb_init()
+void lfb_init(void)
{
mbox[0] = 35*4;
mbox[1] = MBOX_REQUEST;
@@ -71,11 +71,23 @@ void lfb_init()
}
}
+void clear_screen(void)
+{
+ unsigned char *ptr=lfb;
+ for(unsigned int y = 0; y < height; y++) {
+ for(unsigned int x = 0; x < width; x++) {
+ *(unsigned int*)ptr = 0x000000;
+ ptr += 4;
+ }
+ }
+}
+
/**
* Show a picture
*/
-void lfb_showpicture()
+void lfb_showpicture(void)
{
+ clear_screen();
unsigned int x,y;
unsigned char *ptr=lfb;
char *data=homer_data, pixel[4];
@@ -93,7 +105,8 @@ void lfb_showpicture()
}
}
-void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c) {
+void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c)
+{
unsigned int x, y;
unsigned char* ptr = lfb;
ptr += (pitch*ly*GLYPH_Y+lx*4*GLYPH_X);
@@ -114,7 +127,13 @@ void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsign
}
}
-void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c) {
+void draw_byte(unsigned char lx, unsigned char ly, unsigned char letter)
+{
+ draw_cbyte(lx, ly, letter, 0xFFFFFF);
+}
+
+void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c)
+{
unsigned int x, y;
unsigned char* ptr = lfb;
ptr += (pitch*ly*GLYPH_Y+lx*4*GLYPH_X);
@@ -132,7 +151,13 @@ void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsi
}
}
-void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c) {
+void draw_letter(unsigned char lx, unsigned char ly, unsigned char letter)
+{
+ draw_cletter(lx, ly, letter, 0xFFFFFF);
+}
+
+void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c)
+{
unsigned int x = lx % GG_MAX_X, y = ly % GG_MAX_Y;
unsigned int idx = 0;
while(s[idx] != 0) {
@@ -145,7 +170,13 @@ void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c) {
}
}
-void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c) {
+void draw_string(unsigned int lx, unsigned int ly, char* s)
+{
+ draw_cstring(lx, ly, s, 0xFFFFFF);
+}
+
+void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c)
+{
unsigned int x = lx % GG_MAX_X, y = ly % GG_MAX_Y;
for(unsigned int i = 0; i < GLYPH_X; i++) {
draw_cbyte(x++, y, 0xF & (val >> ((GLYPH_X-1)-i)*4), c);
@@ -157,15 +188,7 @@ void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned i
}
}
-void draw_byte(unsigned char lx, unsigned char ly, unsigned char letter) {
- draw_cbyte(lx, ly, letter, 0xFFFFFF);
-}
-void draw_letter(unsigned char lx, unsigned char ly, unsigned char letter) {
- draw_cletter(lx, ly, letter, 0xFFFFFF);
-}
-void draw_string(unsigned int lx, unsigned int ly, char* s){
- draw_cstring(lx, ly, s, 0xFFFFFF);
-}
-void draw_hex32(unsigned int lx, unsigned int ly, unsigned long val) {
+void draw_hex32(unsigned int lx, unsigned int ly, unsigned long val)
+{
draw_chex32(lx, ly, val, 0xFFFFFF);
}
diff --git a/src/graphics/lfb.h b/src/graphics/lfb.h
index 37914ac..a4eef2e 100644
--- a/src/graphics/lfb.h
+++ b/src/graphics/lfb.h
@@ -8,17 +8,21 @@
extern unsigned int width, height, pitch, isrgb; /* dimensions and channel order */
#endif
-void lfb_init();
-void lfb_showpicture();
+void lfb_init(void);
+void lfb_showpicture(void);
-void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
-void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
-void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c);
-void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c);
+void clear_screen(void);
+void draw_cbyte(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
void draw_byte(unsigned char lx, unsigned char ly, unsigned char letter);
+
+void draw_cletter(unsigned char lx, unsigned char ly, unsigned char letter, unsigned int c);
void draw_letter(unsigned char lx, unsigned char ly, unsigned char letter);
+
+void draw_cstring(unsigned int lx, unsigned int ly, char* s, unsigned int c);
void draw_string(unsigned int lx, unsigned int ly, char* s);
+
+void draw_chex32(unsigned int lx, unsigned int ly, unsigned long val, unsigned int c);
void draw_hex32(unsigned int lx, unsigned int ly, unsigned long val);
#endif
diff --git a/src/lib/mem.c b/src/lib/mem.c
index 3313c07..3683ae7 100644
--- a/src/lib/mem.c
+++ b/src/lib/mem.c
@@ -1,6 +1,7 @@
#include "../drivers/uart.h"
-void memshow32(unsigned long* addr, unsigned int n) {
+void memshow32(unsigned long* addr, unsigned int n)
+{
for(unsigned int i = 0; i < n; i++) {
uart_hex(addr[i]);
if (i+1 != n)
@@ -9,13 +10,15 @@ void memshow32(unsigned long* addr, unsigned int n) {
uart_char(0x0a);
}
-void memcpy(unsigned char* src, unsigned char* dest, unsigned int n) {
+void memcpy(unsigned char* src, unsigned char* dest, unsigned int n)
+{
for(unsigned int i = 0; i < n; i++) {
dest[i] = src[i];
}
}
-unsigned char memcmp(unsigned char* a, unsigned char* b, unsigned int n) {
+unsigned char memcmp(unsigned char* a, unsigned char* b, unsigned int n)
+{
for(unsigned int i = 0; i < n; i++) {
if (a[i] != b[i])
return 0;
@@ -23,13 +26,15 @@ unsigned char memcmp(unsigned char* a, unsigned char* b, unsigned int n) {
return 1;
}
-void memcpy32(unsigned long* src, unsigned long* dest, unsigned int n) {
+void memcpy32(unsigned long* src, unsigned long* dest, unsigned int n)
+{
for(unsigned int i = 0; i < n; i++) {
dest[i] = src[i];
}
}
-unsigned char memcmp32(unsigned long* a, unsigned long* b, unsigned int n) {
+unsigned char memcmp32(unsigned long* a, unsigned long* b, unsigned int n)
+{
for(unsigned int i = 0; i < n; i++) {
if (a[i] != b[i])
return 0;
diff --git a/src/lib/strings.c b/src/lib/strings.c
index 795caa2..94b315f 100644
--- a/src/lib/strings.c
+++ b/src/lib/strings.c
@@ -1,6 +1,7 @@
#include "../lib/strings.h"
-unsigned long strlen(string_t s) {
+unsigned long strlen(string_t s)
+{
unsigned long len = 0;
while (s[len] != 0) {
len += 1;
@@ -8,7 +9,8 @@ unsigned long strlen(string_t s) {
return len;
}
-unsigned char strcmp(string_t a, string_t b) {
+unsigned char strcmp(string_t a, string_t b)
+{
unsigned long idx = 0;
while (a[idx] != 0 && b[idx] != 0) {
if (a[idx] != b[idx]) {
@@ -19,7 +21,8 @@ unsigned char strcmp(string_t a, string_t b) {
return a[idx] == b[idx];
}
-unsigned char strcmpn(string_t a, string_t b, unsigned int n) {
+unsigned char strcmpn(string_t a, string_t b, unsigned int n)
+{
unsigned long idx = 0;
while (a[idx] != 0 && b[idx] != 0 && idx+1 < n) {
if (a[idx] != b[idx]) {
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
diff --git a/src/util/mutex.c b/src/util/mutex.c
index 9cfdf6c..2637a6c 100644
--- a/src/util/mutex.c
+++ b/src/util/mutex.c
@@ -1,9 +1,9 @@
-#include "../util/mutex.h"
#include "../cpu/atomic/swap.h"
+#include "../util/mutex.h"
-unsigned char lock_mutex(struct Mutex* m, unsigned long pid) {
+unsigned char lock_mutex(struct Mutex* m, unsigned long pid)
+{
if (m->pid == NULL_PID) {
- //m->pid = pid;
atm_lock(pid, &m->pid);
return 0;
}
@@ -13,9 +13,9 @@ unsigned char lock_mutex(struct Mutex* m, unsigned long pid) {
// Eventually, there will need to be a hook into the scheduling mechanism
// that checks the currently running process and check that against the
// mutex's pid lock
-unsigned char release_mutex(struct Mutex* m, unsigned long pid) {
+unsigned char release_mutex(struct Mutex* m, unsigned long pid)
+{
if (m->pid == pid) {
- //m->pid = NULL_PID;
atm_release(&m->pid);
return 0;
}
diff --git a/src/util/time.c b/src/util/time.c
index 3db2cad..f6d8f04 100644
--- a/src/util/time.c
+++ b/src/util/time.c
@@ -2,7 +2,6 @@
void routing_core0cntv_to_core0irq(void)
{
- // IRQ
store32(0x08, CORE0_TIMER_IRQCNTL);
}