diff options
author | Michael Walle <michael@walle.cc> | 2011-08-31 16:48:45 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-10-02 16:14:03 +0200 |
commit | 5adb30d38babd733923004c57c57fef84533a039 (patch) | |
tree | a11353e59aeb5fbe2313c802e53008b09db5512f /hw/milkymist-uart.c | |
parent | 7100453f2ecb2b1593e9559258fda4a11493d2b5 (diff) |
milkymist-uart: convert to memory API
Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/milkymist-uart.c')
-rw-r--r-- | hw/milkymist-uart.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/hw/milkymist-uart.c b/hw/milkymist-uart.c index e8e309de7c..128cd8cc38 100644 --- a/hw/milkymist-uart.c +++ b/hw/milkymist-uart.c @@ -35,7 +35,9 @@ enum { struct MilkymistUartState { SysBusDevice busdev; + MemoryRegion regs_region; CharDriverState *chr; + qemu_irq rx_irq; qemu_irq tx_irq; @@ -43,7 +45,8 @@ struct MilkymistUartState { }; typedef struct MilkymistUartState MilkymistUartState; -static uint32_t uart_read(void *opaque, target_phys_addr_t addr) +static uint64_t uart_read(void *opaque, target_phys_addr_t addr, + unsigned size) { MilkymistUartState *s = opaque; uint32_t r = 0; @@ -66,7 +69,8 @@ static uint32_t uart_read(void *opaque, target_phys_addr_t addr) return r; } -static void uart_write(void *opaque, target_phys_addr_t addr, uint32_t value) +static void uart_write(void *opaque, target_phys_addr_t addr, uint64_t value, + unsigned size) { MilkymistUartState *s = opaque; unsigned char ch = value; @@ -93,16 +97,14 @@ static void uart_write(void *opaque, target_phys_addr_t addr, uint32_t value) } } -static CPUReadMemoryFunc * const uart_read_fn[] = { - NULL, - NULL, - &uart_read, -}; - -static CPUWriteMemoryFunc * const uart_write_fn[] = { - NULL, - NULL, - &uart_write, +static const MemoryRegionOps uart_mmio_ops = { + .read = uart_read, + .write = uart_write, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void uart_rx(void *opaque, const uint8_t *buf, int size) @@ -136,14 +138,13 @@ static void milkymist_uart_reset(DeviceState *d) static int milkymist_uart_init(SysBusDevice *dev) { MilkymistUartState *s = FROM_SYSBUS(typeof(*s), dev); - int uart_regs; sysbus_init_irq(dev, &s->rx_irq); sysbus_init_irq(dev, &s->tx_irq); - uart_regs = cpu_register_io_memory(uart_read_fn, uart_write_fn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, R_MAX * 4, uart_regs); + memory_region_init_io(&s->regs_region, &uart_mmio_ops, s, + "milkymist-uart", R_MAX * 4); + sysbus_init_mmio_region(dev, &s->regs_region); s->chr = qdev_init_chardev(&dev->qdev); if (s->chr) { |