aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2011-08-31 16:48:41 +0200
committerAvi Kivity <avi@redhat.com>2011-10-02 16:14:03 +0200
commit8c85d15b3f5feee80b81499290afba564cf9eb9d (patch)
treec7f81220ab892c8ae33999b8e249f96432dd844e
parent321c17ae97de0e69d1dc2d7609734adca0aa5c05 (diff)
milkymist-memcard: convert to memory API
Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: Avi Kivity <avi@redhat.com>
-rw-r--r--hw/milkymist-memcard.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/hw/milkymist-memcard.c b/hw/milkymist-memcard.c
index 22dc377d7..fb6e55875 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;
}