summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorFrans Kaashoek <[email protected]>2022-08-22 19:36:11 -0400
committerFrans Kaashoek <[email protected]>2022-08-22 19:36:11 -0400
commit7086197c27f7c00544ca006561336d8d5791a482 (patch)
tree3ec48fdb0d815eb9423ad5716b39ef64d1c80c97 /kernel
parent63ef3b8c9fd15d5ea5775813cda94a3c64cff0d3 (diff)
downloadxv6-labs-7086197c27f7c00544ca006561336d8d5791a482.tar.gz
xv6-labs-7086197c27f7c00544ca006561336d8d5791a482.tar.bz2
xv6-labs-7086197c27f7c00544ca006561336d8d5791a482.zip
Simplify uartputc slightly (thanks Harry Porter)
Diffstat (limited to 'kernel')
-rw-r--r--kernel/uart.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/kernel/uart.c b/kernel/uart.c
index af571b1..e3b3b8a 100644
--- a/kernel/uart.c
+++ b/kernel/uart.c
@@ -92,22 +92,18 @@ uartputc(int c)
for(;;)
;
}
-
- while(1){
- if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
- // buffer is full.
- // wait for uartstart() to open up space in the buffer.
- sleep(&uart_tx_r, &uart_tx_lock);
- } else {
- uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
- uart_tx_w += 1;
- uartstart();
- release(&uart_tx_lock);
- return;
- }
+ while(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
+ // buffer is full.
+ // wait for uartstart() to open up space in the buffer.
+ sleep(&uart_tx_r, &uart_tx_lock);
}
+ uart_tx_buf[uart_tx_w % UART_TX_BUF_SIZE] = c;
+ uart_tx_w += 1;
+ uartstart();
+ release(&uart_tx_lock);
}
+
// alternate version of uartputc() that doesn't
// use interrupts, for use by kernel printf() and
// to echo characters. it spins waiting for the uart's