aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Cunningham <cc@localhost>2021-12-18 23:24:10 -0800
committerChristian Cunningham <cc@localhost>2021-12-18 23:24:10 -0800
commit456580be4408869962cf28bb39d909fb5fcb6176 (patch)
tree3b65f4546946cc3b2d395f4829a024a165497808
parent033def321866592caa3278af3e067f05addbbc93 (diff)
Added serial input storing
Added NOANSI option
-rw-r--r--src/cpu/irq.c73
1 files changed, 60 insertions, 13 deletions
diff --git a/src/cpu/irq.c b/src/cpu/irq.c
index c00ce8c..0a1e080 100644
--- a/src/cpu/irq.c
+++ b/src/cpu/irq.c
@@ -5,11 +5,14 @@
#include "../drivers/uart.h"
#include "../util/time.h"
+extern unsigned long cmdidx;
+extern char cmd[2048];
extern void disable_irq(void);
extern void enable_irq(void);
void c_irq_handler(void) {
- disable_irq();
+ //disable_irq();
+ disableirq();
unsigned long source = load32(CORE0_IRQ_SOURCE);
if (source & (1 << 8)) {
if(load32(IRQ_PENDING2) & (1 << 25)) {
@@ -23,31 +26,75 @@ void c_irq_handler(void) {
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
} 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
}
} else {
- if (data == 0x0D) {
- //uart_char(0x0a);
- uart_char(data);
- uart_string("\033[?25l> \033[0K\033[?25h");
- } else if (data == 0x08) {
- uart_char((unsigned char)data);
- uart_char(0x20);
- uart_char((unsigned char)data);
- } else {
- uart_char((unsigned char)data);
+ unsigned long off = cmdidx;
+ if (off < 2048) {
+ if (data == 0x0D) {
+ off = 0;
+ cmd[0] = 0x0;
+ //uart_char(0x0a);
+ uart_char(data);
+ uart_string("\033[?25l> \033[0K\033[?25h");
+ } else if (data == 0x08 || data == 0x7F) {
+ if (off > 0) {
+ off -= 1;
+ }
+ cmd[off] = 0x0;
+ uart_char((unsigned char)data);
+ uart_char(0x20);
+ uart_char((unsigned char)data);
+ } else {
+ uart_char((unsigned char)data);
+ cmd[off] = (char) data;
+ off += 1;
+ }
+ } else if (off == 2048) {
+ if (data == 0x0D) {
+ off = 0;
+ cmd[0] = 0x0;
+ //uart_char(0x0a);
+ uart_char(data);
+ uart_string("\033[?25l> \033[0K\033[?25h");
+ } else if (data == 0x08 || data == 0x7F) {
+ if (off > 0) {
+ off -= 1;
+ }
+ cmd[off] = 0x0;
+ uart_char((unsigned char)data);
+ uart_char(0x20);
+ uart_char((unsigned char)data);
+ }
}
+ cmdidx = off;
+ //store32(off, (unsigned long*) cmdidx);
+ uart_string("\033[?25l\033[9;1H\033[0K");
+ uart_10(off);
+ uart_string("\n\033[0K");
+ uart_string(cmd);
+ uart_string("\033[?25h\033[8;1H> ");
}
- enable_irq();
+ //enable_irq();
+ enableirq();
return;
}
}
} else if (source & (1 << 3)) {
c_timer();
- enable_irq();
+ //enable_irq();
+ enableirq();
}
return;
}