Question about serial console code

Christian Kandeler christian.kandeler at hob.de
Fri Jun 15 14:01:06 UTC 2007


Hi,

I've spent some time figuring out the code path for user space output to a 
serial console, and there is one thing I don't understand. The code flow goes 
via write() and tty_write() to uart_tty_oproc(), which contains the following 
line:
	sc->sc_txdatasz = q_to_b(&tp->t_outq, sc->sc_txbuf, sc->sc_txfifosz);
This copies at most sc->sc_txfifosz (the size of the UART's FIFO) bytes from 
tp->outq to sc->sc_txbuf. After that, UART_TRANSMIT is called and outputs the 
characters just copied to the serial device. Now obviously, the number of 
characters in tp->t_outq can be greater than the UART's FIFO size, but I 
can't for the life of me find a loop anywhere in the call tree. So what 
happens to the rest of the outq buffer? And what if the UART has no FIFO at 
all (e.g. 8250)? sc->sc_txfifosz is zero in that case, so how does anything 
ever get printed then?


Regards,
Christian Kandeler


More information about the freebsd-hackers mailing list