Simplify uartputc slightly (thanks Harry Porter)
This commit is contained in:
parent
63ef3b8c9f
commit
7086197c27
|
@ -92,22 +92,18 @@ uartputc(int c)
|
||||||
for(;;)
|
for(;;)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
while(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
|
||||||
while(1){
|
// buffer is full.
|
||||||
if(uart_tx_w == uart_tx_r + UART_TX_BUF_SIZE){
|
// wait for uartstart() to open up space in the buffer.
|
||||||
// buffer is full.
|
sleep(&uart_tx_r, &uart_tx_lock);
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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
|
// alternate version of uartputc() that doesn't
|
||||||
// use interrupts, for use by kernel printf() and
|
// use interrupts, for use by kernel printf() and
|
||||||
// to echo characters. it spins waiting for the uart's
|
// to echo characters. it spins waiting for the uart's
|
||||||
|
|
Loading…
Reference in a new issue