From 8c85d15b3f5feee80b81499290afba564cf9eb9d Mon Sep 17 00:00:00 2001 From: Michael Walle Date: Wed, 31 Aug 2011 16:48:41 +0200 Subject: milkymist-memcard: convert to memory API Signed-off-by: Michael Walle Signed-off-by: Avi Kivity --- hw/milkymist-memcard.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'hw/milkymist-memcard.c') diff --git a/hw/milkymist-memcard.c b/hw/milkymist-memcard.c index 22dc377d79..fb6e558755 100644 --- a/hw/milkymist-memcard.c +++ b/hw/milkymist-memcard.c @@ -60,6 +60,7 @@ enum { struct MilkymistMemcardState { SysBusDevice busdev; + MemoryRegion regs_region; SDState *card; int command_write_ptr; @@ -116,7 +117,8 @@ static void memcard_sd_command(MilkymistMemcardState *s) } } -static uint32_t memcard_read(void *opaque, target_phys_addr_t addr) +static uint64_t memcard_read(void *opaque, target_phys_addr_t addr, + unsigned size) { MilkymistMemcardState *s = opaque; uint32_t r = 0; @@ -164,7 +166,8 @@ static uint32_t memcard_read(void *opaque, target_phys_addr_t addr) return r; } -static void memcard_write(void *opaque, target_phys_addr_t addr, uint32_t value) +static void memcard_write(void *opaque, target_phys_addr_t addr, uint64_t value, + unsigned size) { MilkymistMemcardState *s = opaque; @@ -216,16 +219,14 @@ static void memcard_write(void *opaque, target_phys_addr_t addr, uint32_t value) } } -static CPUReadMemoryFunc * const memcard_read_fn[] = { - NULL, - NULL, - &memcard_read, -}; - -static CPUWriteMemoryFunc * const memcard_write_fn[] = { - NULL, - NULL, - &memcard_write, +static const MemoryRegionOps memcard_mmio_ops = { + .read = memcard_read, + .write = memcard_write, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, + .endianness = DEVICE_NATIVE_ENDIAN, }; static void milkymist_memcard_reset(DeviceState *d) @@ -247,15 +248,14 @@ static int milkymist_memcard_init(SysBusDevice *dev) { MilkymistMemcardState *s = FROM_SYSBUS(typeof(*s), dev); DriveInfo *dinfo; - int memcard_regs; dinfo = drive_get_next(IF_SD); s->card = sd_init(dinfo ? dinfo->bdrv : NULL, 0); s->enabled = dinfo ? bdrv_is_inserted(dinfo->bdrv) : 0; - memcard_regs = cpu_register_io_memory(memcard_read_fn, memcard_write_fn, s, - DEVICE_NATIVE_ENDIAN); - sysbus_init_mmio(dev, R_MAX * 4, memcard_regs); + memory_region_init_io(&s->regs_region, &memcard_mmio_ops, s, + "milkymist-memcard", R_MAX * 4); + sysbus_init_mmio_region(dev, &s->regs_region); return 0; } -- cgit v1.2.3