36 lines
No EOL
895 B
C
36 lines
No EOL
895 B
C
#include "uart.h"
|
|
#include "task.h"
|
|
#include "shell.h"
|
|
#include <string.h>
|
|
|
|
void shell_run() {
|
|
char input[64];
|
|
int pos = 0;
|
|
|
|
uart_write("MiniOS Shell> ");
|
|
|
|
while (1) {
|
|
char c = uart_getchar();
|
|
uart_putchar(c); // Echo
|
|
if (c == '\r' || c == '\n') {
|
|
input[pos] = '\0';
|
|
uart_write("\n");
|
|
|
|
if (strcmp(input, "echo") == 0) {
|
|
uart_write("Echo test\n");
|
|
} else if (strcmp(input, "ps") == 0) {
|
|
uart_write("Task list: [0] task1, [1] task2\n");
|
|
} else if (strcmp(input, "halt") == 0) {
|
|
uart_write("System halted.\n");
|
|
while (1);
|
|
} else {
|
|
uart_write("Unknown command\n");
|
|
}
|
|
|
|
pos = 0;
|
|
uart_write("MiniOS Shell> ");
|
|
} else {
|
|
input[pos++] = c;
|
|
}
|
|
}
|
|
} |