Fix: lab3 on-board problems
This commit is contained in:
@@ -159,20 +159,41 @@ void _reboot(void)
|
||||
_reset(1 << 16);
|
||||
}
|
||||
|
||||
char *_shell_buf = (char *)0x0;
|
||||
int _shell_sz = 0;
|
||||
|
||||
static inline
|
||||
int _shell_operations(char ch)
|
||||
{
|
||||
switch (ch) {
|
||||
case 0x7f:
|
||||
if (_shell_sz > 0) {
|
||||
--_shell_sz;
|
||||
uart_puts("\b \b");
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int shell(file_node_t *initrd_root)
|
||||
{
|
||||
uart_puts("# ");
|
||||
char *buf = kmalloc(INPUT_BUFLEN * sizeof(char)), ch;
|
||||
int sz = 0;
|
||||
char ch;
|
||||
_shell_buf = kmalloc(INPUT_BUFLEN * sizeof(char));
|
||||
_shell_sz = 0;
|
||||
while ((ch = uart_getc()) != '\n') {
|
||||
buf[sz++] = ch;
|
||||
if (_shell_operations(ch))
|
||||
continue;
|
||||
_shell_buf[_shell_sz++] = ch;
|
||||
uart_putb((const uint8_t *)&ch, 1);
|
||||
}
|
||||
uart_puts(ENDL);
|
||||
buf[sz] = ' ';
|
||||
_shell_buf[_shell_sz] = ' ';
|
||||
|
||||
vector_t *args = make_vector(0);
|
||||
for (char *saveptr = 0x0, *tok = strtok_r(buf, " ", &saveptr);
|
||||
for (char *saveptr = 0x0, *tok = strtok_r(_shell_buf, " ", &saveptr);
|
||||
tok; tok = strtok_r((char *)0x0, " ", &saveptr)) {
|
||||
VEC_PUSH(args, tok);
|
||||
LOG(tok);
|
||||
|
||||
Reference in New Issue
Block a user