From dd5a720044c41a88e0a09f174fb602289b93fe28 Mon Sep 17 00:00:00 2001 From: Frans Kaashoek Date: Fri, 12 Aug 2022 10:57:16 -0400 Subject: [PATCH] cosmetic changes (thanks Harry Porter) --- kernel/console.c | 16 ++++++++-------- kernel/plic.c | 2 +- kernel/uart.c | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/kernel/console.c b/kernel/console.c index 23a2d35..56a6799 100644 --- a/kernel/console.c +++ b/kernel/console.c @@ -27,7 +27,7 @@ // // send one character to the uart. -// called by printf, and to echo input characters, +// called by printf(), and to echo input characters, // but not from write(). // void @@ -45,8 +45,8 @@ struct { struct spinlock lock; // input -#define INPUT_BUF 128 - char buf[INPUT_BUF]; +#define INPUT_BUF_SIZE 128 + char buf[INPUT_BUF_SIZE]; uint r; // Read index uint w; // Write index uint e; // Edit index @@ -96,7 +96,7 @@ consoleread(int user_dst, uint64 dst, int n) sleep(&cons.r, &cons.lock); } - c = cons.buf[cons.r++ % INPUT_BUF]; + c = cons.buf[cons.r++ % INPUT_BUF_SIZE]; if(c == C('D')){ // end-of-file if(n < target){ @@ -143,7 +143,7 @@ consoleintr(int c) break; case C('U'): // Kill line. while(cons.e != cons.w && - cons.buf[(cons.e-1) % INPUT_BUF] != '\n'){ + cons.buf[(cons.e-1) % INPUT_BUF_SIZE] != '\n'){ cons.e--; consputc(BACKSPACE); } @@ -156,16 +156,16 @@ consoleintr(int c) } break; default: - if(c != 0 && cons.e-cons.r < INPUT_BUF){ + if(c != 0 && cons.e-cons.r < INPUT_BUF_SIZE){ c = (c == '\r') ? '\n' : c; // echo back to the user. consputc(c); // store for consumption by consoleread(). - cons.buf[cons.e++ % INPUT_BUF] = c; + cons.buf[cons.e++ % INPUT_BUF_SIZE] = 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_SIZE){ // wake up consoleread() if a whole line (or end-of-file) // has arrived. cons.w = cons.e; diff --git a/kernel/plic.c b/kernel/plic.c index d4fd122..4175db9 100644 --- a/kernel/plic.c +++ b/kernel/plic.c @@ -23,7 +23,7 @@ plicinithart(void) // set enable bits for this hart's S-mode // for the uart and virtio disk. - *(uint32*)PLIC_SENABLE(hart)= (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ); + *(uint32*)PLIC_SENABLE(hart) = (1 << UART0_IRQ) | (1 << VIRTIO0_IRQ); // set this hart's S-mode priority threshold to 0. *(uint32*)PLIC_SPRIORITY(hart) = 0; diff --git a/kernel/uart.c b/kernel/uart.c index f75fb3c..af571b1 100644 --- a/kernel/uart.c +++ b/kernel/uart.c @@ -175,7 +175,7 @@ uartgetc(void) // handle a uart interrupt, raised because input has // arrived, or the uart is ready for more output, or -// both. called from trap.c. +// both. called from devintr(). void uartintr(void) {