console/uart tweaks
This commit is contained in:
parent
cf48b24c03
commit
a33f60fea3
|
@ -39,7 +39,7 @@ consputc(int c)
|
||||||
}
|
}
|
||||||
|
|
||||||
if(c == BACKSPACE){
|
if(c == BACKSPACE){
|
||||||
// if the user typed backspace, erase the character.
|
// if the user typed backspace, overwrite with a space.
|
||||||
uartputc('\b'); uartputc(' '); uartputc('\b');
|
uartputc('\b'); uartputc(' '); uartputc('\b');
|
||||||
} else {
|
} else {
|
||||||
uartputc(c);
|
uartputc(c);
|
||||||
|
@ -134,10 +134,10 @@ consoleread(int user_dst, uint64 dst, int n)
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// the uart interrupt handler, uartintr(), calls this
|
// the console input interrupt handler.
|
||||||
// for each input character. do erase/kill processing,
|
// uartintr() calls this for input character.
|
||||||
// append to cons.buf, wake up reader if a whole
|
// do erase/kill processing, append to cons.buf,
|
||||||
// line has arrived.
|
// wake up consoleread() if a whole line has arrived.
|
||||||
//
|
//
|
||||||
void
|
void
|
||||||
consoleintr(int c)
|
consoleintr(int c)
|
||||||
|
@ -165,9 +165,16 @@ consoleintr(int c)
|
||||||
default:
|
default:
|
||||||
if(c != 0 && cons.e-cons.r < INPUT_BUF){
|
if(c != 0 && cons.e-cons.r < INPUT_BUF){
|
||||||
c = (c == '\r') ? '\n' : c;
|
c = (c == '\r') ? '\n' : c;
|
||||||
cons.buf[cons.e++ % INPUT_BUF] = c;
|
|
||||||
|
// echo back to the user.
|
||||||
consputc(c);
|
consputc(c);
|
||||||
|
|
||||||
|
// store for consumption by consoleread().
|
||||||
|
cons.buf[cons.e++ % INPUT_BUF] = c;
|
||||||
|
|
||||||
if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
|
if(c == '\n' || c == C('D') || cons.e == cons.r+INPUT_BUF){
|
||||||
|
// wake up consoleread() if a whole line (or end-of-file)
|
||||||
|
// has arrived.
|
||||||
cons.w = cons.e;
|
cons.w = cons.e;
|
||||||
wakeup(&cons.r);
|
wakeup(&cons.r);
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,9 @@ devintr()
|
||||||
|
|
||||||
if((scause & 0x8000000000000000L) &&
|
if((scause & 0x8000000000000000L) &&
|
||||||
(scause & 0xff) == 9){
|
(scause & 0xff) == 9){
|
||||||
// supervisor external interrupt, via PLIC.
|
// this is a supervisor external interrupt, via PLIC.
|
||||||
|
|
||||||
|
// irq indicates which device interrupted.
|
||||||
int irq = plic_claim();
|
int irq = plic_claim();
|
||||||
|
|
||||||
if(irq == UART0_IRQ){
|
if(irq == UART0_IRQ){
|
||||||
|
|
|
@ -43,6 +43,7 @@ uartinit(void)
|
||||||
*R(1) = 0x01;
|
*R(1) = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// write one output character to the UART.
|
||||||
void
|
void
|
||||||
uartputc(int c)
|
uartputc(int c)
|
||||||
{
|
{
|
||||||
|
@ -52,6 +53,8 @@ uartputc(int c)
|
||||||
*R(0) = c;
|
*R(0) = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// read one input character from the UART.
|
||||||
|
// return -1 if none is waiting.
|
||||||
int
|
int
|
||||||
uartgetc(void)
|
uartgetc(void)
|
||||||
{
|
{
|
||||||
|
@ -63,6 +66,7 @@ uartgetc(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// trap.c calls here when the uart interrupts.
|
||||||
void
|
void
|
||||||
uartintr(void)
|
uartintr(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue