aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2022-02-13 13:01:59 -0700
committerChristian Cunningham <cc@localhost>2022-02-13 13:01:59 -0700
commit91f828411617247abde3f0ace64389bb2050f794 (patch)
tree1206eb445ccae6157eecb5c9db3164ca263ade66
parenta3b9723b28d24faffab2d0c770cd355939746e63 (diff)
Unhook old mutex handles
-rw-r--r--include/globals.h2
-rw-r--r--include/util/mutex.h9
-rw-r--r--src/cpu/irq.c8
-rw-r--r--src/exceptions/svc.S1
-rw-r--r--src/globals.c2
-rw-r--r--src/sys/core.c2
-rw-r--r--src/sys/schedule.c2
-rw-r--r--src/sys/timer.c10
-rw-r--r--src/util/status.c29
9 files changed, 7 insertions, 58 deletions
diff --git a/include/globals.h b/include/globals.h
index 8aa337c..4304a15 100644
--- a/include/globals.h
+++ b/include/globals.h
@@ -10,8 +10,6 @@ extern char* os_name;
extern char* os_info_v;
extern unsigned char kmem_begin[0x2000000];
extern unsigned char kmem_lookup[0xD000];
-extern unsigned long exe_cnt;
-extern struct Mutex exe_cnt_m;
extern unsigned long nextpid;
extern unsigned long stimel;
extern unsigned long stimeh;
diff --git a/include/util/mutex.h b/include/util/mutex.h
index 524a461..907fe5b 100644
--- a/include/util/mutex.h
+++ b/include/util/mutex.h
@@ -2,16 +2,17 @@
#define UTIL_MUTEX_H
#define NULL_PID 0
-#define SYS_PID 1
-#define SCHED_PID 2
+#define CORE0_PID 1
+#define CORE1_PID 2
+#define CORE2_PID 3
+#define CORE3_PID 4
+#define FIRST_AVAIL_PID CORE3_PID+1
struct Mutex {
void* addr;
unsigned long pid;
} __attribute__((packed, aligned(4)));;
-unsigned char lock_mutex(struct Mutex*, unsigned long);
-unsigned char release_mutex(struct Mutex*, unsigned long);
struct Mutex* create_mutex(void* addr);
#endif
diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index 6d9a02a..0488231 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -80,7 +80,7 @@ unsigned long c_fiq_handler(void)
}
if (counter % 0x30 == 0) {
return 1;
- }
+ }
return 0;
}
return 0;
@@ -92,12 +92,6 @@ void handle_data(unsigned char data)
if (data == 0x0D) {
// Backspace Case
} else if (data == 0x08 || data == 0x7F) {
- // Lock Case
- } else if (data == 0x6C) {
- lock_mutex(&exe_cnt_m, SYS_PID);
- // Release Case
- } else if (data == 0x72) {
- release_mutex(&exe_cnt_m, SYS_PID);
} else if (data == 0x61) {
add_thread(uart_scheduler, 0, 2);
} else if (data == 0x62) {
diff --git a/src/exceptions/svc.S b/src/exceptions/svc.S
index fc4653a..bebc417 100644
--- a/src/exceptions/svc.S
+++ b/src/exceptions/svc.S
@@ -75,7 +75,6 @@ svc_000005: // Release Mutex
str r1, [r0, #0]
dsb
sev
- // TODO: Branch to scheduler to awake threads awaiting mutex
sub r0, #4
bl sched_mutex_resurrect
ldmfd sp!, {r0-r12,lr}
diff --git a/src/globals.c b/src/globals.c
index 8334a60..1510f36 100644
--- a/src/globals.c
+++ b/src/globals.c
@@ -12,8 +12,6 @@ char* os_info_v = VERSION;
__attribute__((section(".bss.kmem"))) unsigned char kmem_begin[0x2000000];
__attribute__((section(".bss"))) unsigned char kmem_lookup[0xD000];
-__attribute__((section(".bss"))) unsigned long exe_cnt;
-__attribute__((section(".bss"))) struct Mutex exe_cnt_m;
__attribute__((section(".bss"))) unsigned long nextpid;
__attribute__((section(".bss"))) unsigned long stimel;
__attribute__((section(".bss"))) unsigned long stimeh;
diff --git a/src/sys/core.c b/src/sys/core.c
index e987e8c..9803488 100644
--- a/src/sys/core.c
+++ b/src/sys/core.c
@@ -18,8 +18,6 @@
void sysinit(void)
{
// Initialize System Globals
- exe_cnt_m.addr = &exe_cnt;
- exe_cnt_m.pid = NULL_PID;
stimeh = *(unsigned long*)SYS_TIMER_CHI;
stimel = *(unsigned long*)SYS_TIMER_CLO;
*(unsigned long*) SYS_TIMER_C0 = 60000000 + stimeh; // 60 second trigger
diff --git a/src/sys/schedule.c b/src/sys/schedule.c
index 5a45b53..5c7a546 100644
--- a/src/sys/schedule.c
+++ b/src/sys/schedule.c
@@ -34,7 +34,7 @@ void init_scheduler(void)
}
}
// Initialize nextpid
- nextpid = SCHED_PID + 1;
+ nextpid = FIRST_AVAIL_PID;
}
struct RStack get_stack(void)
diff --git a/src/sys/timer.c b/src/sys/timer.c
index 548bf1a..c8f9922 100644
--- a/src/sys/timer.c
+++ b/src/sys/timer.c
@@ -8,20 +8,10 @@
#include <util/time.h>
#include <symbols.h>
-void increase_counter(void)
-{
- if (lock_mutex(&exe_cnt_m, SCHED_PID) == 0) {
- unsigned long* counter = (unsigned long*)exe_cnt_m.addr;
- *counter += 1;
- release_mutex(&exe_cnt_m, SCHED_PID);
- }
-}
-
void c_timer(void)
{
// Reset the counter
write_cntv_tval(cntfrq/CPS);
- increase_counter();
status();
}
diff --git a/src/util/status.c b/src/util/status.c
index 5e8a355..5672a8c 100644
--- a/src/util/status.c
+++ b/src/util/status.c
@@ -64,12 +64,6 @@ void status(void)
write_cstring(&g_Drawer, os_name, 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));
- /* 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");
@@ -105,29 +99,6 @@ void status(void)
}
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 = 0;
g_Drawer.y = 9;
write_string(&g_Drawer, "SVC IRQ FIQ User/SYS\n");
for(int i = 0; i < 128; i++)