head/sys/dev/altera/jtag_uart/altera_jtag_uart_tty.c
/*
 * Send output to the UART until either there's none left to send, or we run
 * out of room and need to await an interrupt so that we can start sending
 * again.
 *
 * XXXRW: It would be nice to query WSPACE at the beginning and write to the
 * FIFO in bugger chunks.
 */
Send output to the UART until either there's none left to send, or we run
out of room and need to await an interrupt so that we can start sending
again.

It would be nice to query WSPACE at the beginning and write to the
FIFO in bugger chunks.
Send output to the UART until either there ' s none left to send or we run out of room and need to await an interrupt so that we can start sending again . It would be nice to query WSPACE at the beginning and write to the FIFO in bugger chunks .
static void
aju_handle_output(struct altera_jtag_uart_softc *sc, struct tty *tp)
{
	uint32_t v;
	uint8_t ch;
	tty_lock_assert(tp, MA_OWNED);
	AJU_LOCK_ASSERT(sc);
	AJU_UNLOCK(sc);
	while (ttydisc_getc_poll(tp) != 0) {
		AJU_LOCK(sc);
		v = aju_control_read(sc);
		if ((v & ALTERA_JTAG_UART_CONTROL_WSPACE) != 0) {
			AJU_UNLOCK(sc);
			if (ttydisc_getc(tp, &ch, sizeof(ch)) != sizeof(ch))
				panic("%s: ttydisc_getc", __func__);
			AJU_LOCK(sc);
			aju_data_write(sc, ch);
		} else {
			if (*sc->ajus_jtag_presentp == 0) {
				if (ttydisc_getc(tp, &ch, sizeof(ch)) !=
				    sizeof(ch))
					panic("%s: ttydisc_getc 2", __func__);
				AJU_UNLOCK(sc);
				continue;
			}
			if (sc->ajus_irq_res != NULL)
				aju_intr_writable_enable(sc);
			return;
		}
		AJU_UNLOCK(sc);
	}
	AJU_LOCK(sc);
	aju_intr_writable_disable(sc);
}
static void aju_handle_output ( struct altera_jtag_uart_softc * sc , struct tty * tp ) { uint32_t v ; uint8_t ch ; tty_lock_assert ( tp , MA_OWNED ) ; AJU_LOCK_ASSERT ( sc ) ; AJU_UNLOCK ( sc ) ; while ( ttydisc_getc_poll ( tp ) != 0 ) { AJU_LOCK ( sc ) ; v = aju_control_read ( sc ) ; if ( ( v & ALTERA_JTAG_UART_CONTROL_WSPACE ) != 0 ) { AJU_UNLOCK ( sc ) ; if ( ttydisc_getc ( tp , & ch , sizeof ( ch ) ) != sizeof ( ch ) ) panic ( " " , __func__ ) ; AJU_LOCK ( sc ) ; aju_data_write ( sc , ch ) ; } else { if ( * sc -> ajus_jtag_presentp == 0 ) { if ( ttydisc_getc ( tp , & ch , sizeof ( ch ) ) != sizeof ( ch ) ) panic ( " " , __func__ ) ; AJU_UNLOCK ( sc ) ; continue ; } if ( sc -> ajus_irq_res != NULL ) aju_intr_writable_enable ( sc ) ; return ; } AJU_UNLOCK ( sc ) ; } AJU_LOCK ( sc ) ; aju_intr_writable_disable ( sc ) ; }
Send output to the UART until either there's none left to send, or we run
 out of room and need to await an interrupt so that we can start sending
 again.
Send output to the UART until either there ' s none left to send or we run out of room and need to await an interrupt so that we can start sending again .
/*
			 * If JTAG is not present, then we will drop this
			 * character instead of perhaps scheduling an
			 * interrupt to let us know when there is buffer
			 * space.  Otherwise we might get a write interrupt
			 * later even though we aren't interested in sending
			 * anymore.  Loop to drain TTY-layer buffer.
			 */