aboutsummaryrefslogtreecommitdiff
path: root/hw/cadence_uart.c
diff options
context:
space:
mode:
Diffstat (limited to 'hw/cadence_uart.c')
-rw-r--r--hw/cadence_uart.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/hw/cadence_uart.c b/hw/cadence_uart.c
index d98e531..686e617 100644
--- a/hw/cadence_uart.c
+++ b/hw/cadence_uart.c
@@ -354,12 +354,12 @@ static void uart_read_rx_fifo(UartState *s, uint32_t *c)
uart_update_status(s);
}
-static void uart_write(void *opaque, target_phys_addr_t offset,
+static void uart_write(void *opaque, hwaddr offset,
uint64_t value, unsigned size)
{
UartState *s = (UartState *)opaque;
- DB_PRINT(" offset:%x data:%08x\n", offset, (unsigned)value);
+ DB_PRINT(" offset:%x data:%08x\n", (unsigned)offset, (unsigned)value);
offset >>= 2;
switch (offset) {
case R_IER: /* ier (wts imr) */
@@ -397,20 +397,23 @@ static void uart_write(void *opaque, target_phys_addr_t offset,
}
}
-static uint64_t uart_read(void *opaque, target_phys_addr_t offset,
+static uint64_t uart_read(void *opaque, hwaddr offset,
unsigned size)
{
UartState *s = (UartState *)opaque;
uint32_t c = 0;
offset >>= 2;
- if (offset > R_MAX) {
- return 0;
+ if (offset >= R_MAX) {
+ c = 0;
} else if (offset == R_TX_RX) {
uart_read_rx_fifo(s, &c);
- return c;
+ } else {
+ c = s->r[offset];
}
- return s->r[offset];
+
+ DB_PRINT(" offset:%x data:%08x\n", (unsigned)(offset << 2), (unsigned)c);
+ return c;
}
static const MemoryRegionOps uart_ops = {