vscode-riscv-venus
vscode-riscv-venus copied to clipboard
Console input semantics
Hello there,
First of all: Console input currently is a bit broken. If you output a few chars (like the $PS1
/ user@machine ~ $
prefix usually output by sh
) and then try to read console input, and the user just presses enter
, the chars already output are again read. You can also edit it using backspace, once you type a few chars.
A solution (which I have implemented along with some of the things suggested below, and can PR if wanted) would be to keep track of the "last output char", and only allow editing until that point in the line, while removing things before that when sending the line to the process.
This leads to a general question: What is the motivation behind the current console semantics? It seems unnecessarily convoluted. Specifically, why don't you make it so that every line you enter into the terminal is send to the program, including terminating newline?
"Enabling" the terminal (ecall 0x130
) could then be removed, too -- what was the point of it? All it does is potentially drop input when you invoke it too often, since it resets the input buffer? Simply buffering all input for the user to consume seems like the more sensible option, especially since it also better approximates normal console input (i.e. reading from stdin
), as well as the semantics of MARS.
I'm aware that the suggested changes break backwards compatibility. If that is an issue, they could be delegated to new syscalls (perhaps those orignally intended for console input, i.e. 5-8 (see https://www.doc.ic.ac.uk/lab/secondyear/spim/node8.html))?
I'm happy to learn about what motivated the current design, in case there's something I missed.
Thanks!