diff options
author | BenoƮt Canet <benoit.canet@gmail.com> | 2011-10-24 22:38:26 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-11-24 18:31:57 +0200 |
commit | a8a008223cd8e194cd98c049dfaeaaec2ca9f68c (patch) | |
tree | 7bb2e80f2e6f7de927fe8bec8238865338602ed9 | |
parent | 43b8c30da260d6f37eb9c580ad9b7e0b33df5a0e (diff) |
syborg_serial: convert to memory API
Signed-off-by: Benoit Canet <benoit.canet@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r-- | hw/syborg_serial.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/hw/syborg_serial.c b/hw/syborg_serial.c index c83f82c36e..b73a009ede 100644 --- a/hw/syborg_serial.c +++ b/hw/syborg_serial.c @@ -58,6 +58,7 @@ enum { typedef struct { SysBusDevice busdev; + MemoryRegion iomem; uint32_t int_enable; uint32_t fifo_size; uint32_t *read_fifo; @@ -152,7 +153,8 @@ static void dma_rx_start(SyborgSerialState *s, uint32_t len) syborg_serial_update(s); } -static uint32_t syborg_serial_read(void *opaque, target_phys_addr_t offset) +static uint64_t syborg_serial_read(void *opaque, target_phys_addr_t offset, + unsigned size) { SyborgSerialState *s = (SyborgSerialState *)opaque; uint32_t c; @@ -192,7 +194,7 @@ static uint32_t syborg_serial_read(void *opaque, target_phys_addr_t offset) } static void syborg_serial_write(void *opaque, target_phys_addr_t offset, - uint32_t value) + uint64_t value, unsigned size) { SyborgSerialState *s = (SyborgSerialState *)opaque; unsigned char ch; @@ -261,16 +263,10 @@ static void syborg_serial_event(void *opaque, int event) /* TODO: Report BREAK events? */ } -static CPUReadMemoryFunc * const syborg_serial_readfn[] = { - syborg_serial_read, - syborg_serial_read, - syborg_serial_read -}; - -static CPUWriteMemoryFunc * const syborg_serial_writefn[] = { - syborg_serial_write, - syborg_serial_write, - syborg_serial_write +static const MemoryRegionOps syborg_serial_ops = { + .read = syborg_serial_read, + .write = syborg_serial_write, + .endianness = DEVICE_NATIVE_ENDIAN, }; static const VMStateDescription vmstate_syborg_serial = { @@ -295,13 +291,11 @@ static const VMStateDescription vmstate_syborg_serial = { static int syborg_serial_init(SysBusDevice *dev) { SyborgSerialState *s = FROM_SYSBUS(SyborgSerialState, dev); - int iomemtype; sysbus_init_irq(dev, &s->irq); - iomemtype = cpu_register_io_memory(syborg_serial_readfn, - syborg_serial_writefn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, 0x1000, iomemtype); + memory_region_init_io(&s->iomem, &syborg_serial_ops, s, + "serial", 0x1000); + sysbus_init_mmio_region(dev, &s->iomem); s->chr = qdev_init_chardev(&dev->qdev); if (s->chr) { qemu_chr_add_handlers(s->chr, syborg_serial_can_receive, |