mirror of
https://github.com/qemu/qemu.git
synced 2025-08-09 10:25:06 +00:00
grlib-apbuart: Add support of various flags
- enable/disable Rx and Tx - Rx and Tx interrupt - Tx FIFO empty and Tx SHIFT empty Signed-off-by: Fabien Chouteau <chouteau@adacore.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
8eda222831
commit
99e448006d
@ -75,7 +75,6 @@ typedef struct UART {
|
|||||||
CharDriverState *chr;
|
CharDriverState *chr;
|
||||||
|
|
||||||
/* registers */
|
/* registers */
|
||||||
uint32_t receive;
|
|
||||||
uint32_t status;
|
uint32_t status;
|
||||||
uint32_t control;
|
uint32_t control;
|
||||||
|
|
||||||
@ -136,6 +135,7 @@ static void grlib_apbuart_receive(void *opaque, const uint8_t *buf, int size)
|
|||||||
{
|
{
|
||||||
UART *uart = opaque;
|
UART *uart = opaque;
|
||||||
|
|
||||||
|
if (uart->control & UART_RECEIVE_ENABLE) {
|
||||||
uart_add_to_fifo(uart, buf, size);
|
uart_add_to_fifo(uart, buf, size);
|
||||||
|
|
||||||
uart->status |= UART_DATA_READY;
|
uart->status |= UART_DATA_READY;
|
||||||
@ -143,6 +143,7 @@ static void grlib_apbuart_receive(void *opaque, const uint8_t *buf, int size)
|
|||||||
if (uart->control & UART_RECEIVE_INTERRUPT) {
|
if (uart->control & UART_RECEIVE_INTERRUPT) {
|
||||||
qemu_irq_pulse(uart->irq);
|
qemu_irq_pulse(uart->irq);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void grlib_apbuart_event(void *opaque, int event)
|
static void grlib_apbuart_event(void *opaque, int event)
|
||||||
@ -193,8 +194,15 @@ static void grlib_apbuart_write(void *opaque, hwaddr addr,
|
|||||||
switch (addr) {
|
switch (addr) {
|
||||||
case DATA_OFFSET:
|
case DATA_OFFSET:
|
||||||
case DATA_OFFSET + 3: /* When only one byte write */
|
case DATA_OFFSET + 3: /* When only one byte write */
|
||||||
|
/* Transmit when character device available and transmitter enabled */
|
||||||
|
if ((uart->chr) && (uart->control & UART_TRANSMIT_ENABLE)) {
|
||||||
c = value & 0xFF;
|
c = value & 0xFF;
|
||||||
qemu_chr_fe_write(uart->chr, &c, 1);
|
qemu_chr_fe_write(uart->chr, &c, 1);
|
||||||
|
/* Generate interrupt */
|
||||||
|
if (uart->control & UART_TRANSMIT_INTERRUPT) {
|
||||||
|
qemu_irq_pulse(uart->irq);
|
||||||
|
}
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case STATUS_OFFSET:
|
case STATUS_OFFSET:
|
||||||
@ -242,6 +250,19 @@ static int grlib_apbuart_init(SysBusDevice *dev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void grlib_apbuart_reset(DeviceState *d)
|
||||||
|
{
|
||||||
|
UART *uart = container_of(d, UART, busdev.qdev);
|
||||||
|
|
||||||
|
/* Transmitter FIFO and shift registers are always empty in QEMU */
|
||||||
|
uart->status = UART_TRANSMIT_FIFO_EMPTY | UART_TRANSMIT_SHIFT_EMPTY;
|
||||||
|
/* Everything is off */
|
||||||
|
uart->control = 0;
|
||||||
|
/* Flush receive FIFO */
|
||||||
|
uart->len = 0;
|
||||||
|
uart->current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static Property grlib_apbuart_properties[] = {
|
static Property grlib_apbuart_properties[] = {
|
||||||
DEFINE_PROP_CHR("chrdev", UART, chr),
|
DEFINE_PROP_CHR("chrdev", UART, chr),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
@ -253,6 +274,7 @@ static void grlib_apbuart_class_init(ObjectClass *klass, void *data)
|
|||||||
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
|
SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
|
||||||
|
|
||||||
k->init = grlib_apbuart_init;
|
k->init = grlib_apbuart_init;
|
||||||
|
dc->reset = grlib_apbuart_reset;
|
||||||
dc->props = grlib_apbuart_properties;
|
dc->props = grlib_apbuart_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user