Lines Matching refs:uart
99 static int uart_data_to_read(UART *uart) in uart_data_to_read() argument
101 return uart->current < uart->len; in uart_data_to_read()
104 static char uart_pop(UART *uart) in uart_pop() argument
108 if (uart->len == 0) { in uart_pop()
109 uart->status &= ~UART_DATA_READY; in uart_pop()
113 ret = uart->buffer[uart->current++]; in uart_pop()
115 if (uart->current >= uart->len) { in uart_pop()
117 uart->len = 0; in uart_pop()
118 uart->current = 0; in uart_pop()
121 if (!uart_data_to_read(uart)) { in uart_pop()
122 uart->status &= ~UART_DATA_READY; in uart_pop()
128 static void uart_add_to_fifo(UART *uart, in uart_add_to_fifo() argument
132 if (uart->len + length > FIFO_LENGTH) { in uart_add_to_fifo()
135 memcpy(uart->buffer + uart->len, buffer, length); in uart_add_to_fifo()
136 uart->len += length; in uart_add_to_fifo()
141 UART *uart = opaque; in grlib_apbuart_can_receive() local
143 return FIFO_LENGTH - uart->len; in grlib_apbuart_can_receive()
148 UART *uart = opaque; in grlib_apbuart_receive() local
150 if (uart->control & UART_RECEIVE_ENABLE) { in grlib_apbuart_receive()
151 uart_add_to_fifo(uart, buf, size); in grlib_apbuart_receive()
153 uart->status |= UART_DATA_READY; in grlib_apbuart_receive()
155 if (uart->control & UART_RECEIVE_INTERRUPT) { in grlib_apbuart_receive()
156 qemu_irq_pulse(uart->irq); in grlib_apbuart_receive()
170 UART *uart = opaque; in grlib_apbuart_read() local
178 return uart_pop(uart); in grlib_apbuart_read()
182 return uart->status; in grlib_apbuart_read()
185 return uart->control; in grlib_apbuart_read()
200 UART *uart = opaque; in grlib_apbuart_write() local
210 if (qemu_chr_fe_backend_connected(&uart->chr) && in grlib_apbuart_write()
211 (uart->control & UART_TRANSMIT_ENABLE)) { in grlib_apbuart_write()
215 qemu_chr_fe_write_all(&uart->chr, &c, 1); in grlib_apbuart_write()
217 if (uart->control & UART_TRANSMIT_INTERRUPT) { in grlib_apbuart_write()
218 qemu_irq_pulse(uart->irq); in grlib_apbuart_write()
228 uart->control = value; in grlib_apbuart_write()
250 UART *uart = GRLIB_APB_UART(dev); in grlib_apbuart_realize() local
253 qemu_chr_fe_set_handlers(&uart->chr, in grlib_apbuart_realize()
257 NULL, uart, NULL, true); in grlib_apbuart_realize()
259 sysbus_init_irq(sbd, &uart->irq); in grlib_apbuart_realize()
261 memory_region_init_io(&uart->iomem, OBJECT(uart), &grlib_apbuart_ops, uart, in grlib_apbuart_realize()
264 sysbus_init_mmio(sbd, &uart->iomem); in grlib_apbuart_realize()
269 UART *uart = GRLIB_APB_UART(d); in grlib_apbuart_reset() local
272 uart->status = UART_TRANSMIT_FIFO_EMPTY | UART_TRANSMIT_SHIFT_EMPTY; in grlib_apbuart_reset()
274 uart->control = 0; in grlib_apbuart_reset()
276 uart->len = 0; in grlib_apbuart_reset()
277 uart->current = 0; in grlib_apbuart_reset()