summaryrefslogtreecommitdiff
path: root/console.c
diff options
context:
space:
mode:
authorRobert Morris <[email protected]>2019-06-03 17:59:17 -0400
committerRobert Morris <[email protected]>2019-06-03 17:59:17 -0400
commitcefe223bf5e4b68e5c1202f2f089a164ad656621 (patch)
treeb2bf9fdb2c94e3159ce595c6b4a88daf5c35e878 /console.c
parentefecbee7c0c265b0b2fe956f308e1a73cc63eda6 (diff)
downloadxv6-labs-cefe223bf5e4b68e5c1202f2f089a164ad656621.tar.gz
xv6-labs-cefe223bf5e4b68e5c1202f2f089a164ad656621.tar.bz2
xv6-labs-cefe223bf5e4b68e5c1202f2f089a164ad656621.zip
console input and sbrk
Diffstat (limited to 'console.c')
-rw-r--r--console.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/console.c b/console.c
index 41f53e9..56817d8 100644
--- a/console.c
+++ b/console.c
@@ -208,6 +208,41 @@ consolewrite(struct inode *ip, char *buf, int n)
}
void
+consoleintr(int c)
+{
+ acquire(&cons.lock);
+
+ switch(c){
+ case C('U'): // Kill line.
+ while(input.e != input.w &&
+ input.buf[(input.e-1) % INPUT_BUF] != '\n'){
+ input.e--;
+ consputc(BACKSPACE);
+ }
+ break;
+ case C('H'): case '\x7f': // Backspace
+ if(input.e != input.w){
+ input.e--;
+ consputc(BACKSPACE);
+ }
+ break;
+ default:
+ if(c != 0 && input.e-input.r < INPUT_BUF){
+ c = (c == '\r') ? '\n' : c;
+ input.buf[input.e++ % INPUT_BUF] = c;
+ consputc(c);
+ if(c == '\n' || c == C('D') || input.e == input.r+INPUT_BUF){
+ input.w = input.e;
+ wakeup(&input.r);
+ }
+ }
+ break;
+ }
+
+ release(&cons.lock);
+}
+
+void
consoleinit(void)
{
initlock(&cons.lock, "console");