Question about serial console code

Marcel Moolenaar xcllnt at mac.com
Fri Jun 15 16:05:00 UTC 2007


On Jun 15, 2007, at 6:41 AM, Christian Kandeler wrote:

> 	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.

Yes.

> 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?

The loop is formed by the transmit interrupt of the UART.
When UART_TRANSMIT() is called, the FIFO of the UART is
written and transmission starts. Eventually the UART will
raise a "transmission done" interrupt, which will trigger
the next iteration.

> 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?

If the UART has no FIFO (in the 16550-sense), then sc_txfifosz
is still 1. There's obviously always at least 1 8-bit register
in the UART to which data can to be written or read. The use
of FIFO in the uart(4) is not limited to its definition in PC
hardware.

FYI,

-- 
Marcel Moolenaar
xcllnt at mac.com




More information about the freebsd-hackers mailing list