From bf96ad9f52d39222cd7c3003e42566937efed224 Mon Sep 17 00:00:00 2001 From: Jan Vesely Date: Tue, 3 Apr 2012 17:53:24 -0400 Subject: [PATCH 2/2] serial, omap_uart: Add support for fifo level regs Signed-off-by: Jan Vesely --- hw/omap_uart.c | 10 ++++++++++ hw/pc.h | 3 +++ hw/serial.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 0 deletions(-) diff --git a/hw/omap_uart.c b/hw/omap_uart.c index 644fa04..912133d 100644 --- a/hw/omap_uart.c +++ b/hw/omap_uart.c @@ -175,6 +175,16 @@ static uint64_t omap_uart_read(void *opaque, target_phys_addr_t addr, return s->wkup; case 0x60: /* CFPS (OMAP2) */ return s->cfps; + case 0x64: /* RXFIFO_LVL_REG (OMAP3) */ + if (s->revision >= 0x52) { + return serial_rx_fifo_count(s->serial) & 0xff; + } + break; + case 0x68: /* TXFIFO_LVL_REG (OMAP3) */ + if (s->revision >= 0x52) { + return serial_tx_fifo_count(s->serial) & 0xff; + } + break; } OMAP_BAD_REG(addr); diff --git a/hw/pc.h b/hw/pc.h index af48bcf..9acd814 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -37,6 +37,9 @@ static inline bool serial_isa_init(ISABus *bus, int index, return true; } +unsigned serial_rx_fifo_count(SerialState *s); +unsigned serial_tx_fifo_count(SerialState *s); + void serial_set_frequency(SerialState *s, uint32_t frequency); void serial_change_char_driver(SerialState *s, CharDriverState *chr); const MemoryRegionOps *serial_get_memops(enum device_endian end); diff --git a/hw/serial.c b/hw/serial.c index 2e065ce..f1f3eb1 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -758,6 +758,18 @@ static void serial_init_core(SerialState *s) serial_event, s); } +/* Get number of stored bytes in receive fifo. */ +unsigned serial_rx_fifo_count(SerialState *s) +{ + return s->recv_fifo.count; +} + +/* Get number of stored bytes in transmit fifo. */ +unsigned serial_tx_fifo_count(SerialState *s) +{ + return s->xmit_fifo.count; +} + /* Change the main reference oscillator frequency. */ void serial_set_frequency(SerialState *s, uint32_t frequency) { -- 1.7.3.4