summaryrefslogtreecommitdiff
path: root/hw/milkymist-hpdmc.c
diff options
context:
space:
mode:
authorMichael Walle <michael@walle.cc>2011-08-31 16:48:40 +0200
committerAvi Kivity <avi@redhat.com>2011-10-02 16:14:02 +0200
commit321c17ae97de0e69d1dc2d7609734adca0aa5c05 (patch)
tree986253b6551d441eae33173593050ba2ef81f0c5 /hw/milkymist-hpdmc.c
parent9496e1c335993eca3901d94f19c86fd501715a49 (diff)
milkymist-hpdmc: 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-hpdmc.c')
-rw-r--r--hw/milkymist-hpdmc.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/hw/milkymist-hpdmc.c b/hw/milkymist-hpdmc.c
index c0962fb528..17c840ff08 100644
--- a/hw/milkymist-hpdmc.c
+++ b/hw/milkymist-hpdmc.c
@@ -42,12 +42,14 @@ enum {
struct MilkymistHpdmcState {
SysBusDevice busdev;
+ MemoryRegion regs_region;
uint32_t regs[R_MAX];
};
typedef struct MilkymistHpdmcState MilkymistHpdmcState;
-static uint32_t hpdmc_read(void *opaque, target_phys_addr_t addr)
+static uint64_t hpdmc_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
{
MilkymistHpdmcState *s = opaque;
uint32_t r = 0;
@@ -72,7 +74,8 @@ static uint32_t hpdmc_read(void *opaque, target_phys_addr_t addr)
return r;
}
-static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint32_t value)
+static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint64_t value,
+ unsigned size)
{
MilkymistHpdmcState *s = opaque;
@@ -96,16 +99,14 @@ static void hpdmc_write(void *opaque, target_phys_addr_t addr, uint32_t value)
}
}
-static CPUReadMemoryFunc * const hpdmc_read_fn[] = {
- NULL,
- NULL,
- &hpdmc_read,
-};
-
-static CPUWriteMemoryFunc * const hpdmc_write_fn[] = {
- NULL,
- NULL,
- &hpdmc_write,
+static const MemoryRegionOps hpdmc_mmio_ops = {
+ .read = hpdmc_read,
+ .write = hpdmc_write,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ },
+ .endianness = DEVICE_NATIVE_ENDIAN,
};
static void milkymist_hpdmc_reset(DeviceState *d)
@@ -125,11 +126,10 @@ static void milkymist_hpdmc_reset(DeviceState *d)
static int milkymist_hpdmc_init(SysBusDevice *dev)
{
MilkymistHpdmcState *s = FROM_SYSBUS(typeof(*s), dev);
- int hpdmc_regs;
- hpdmc_regs = cpu_register_io_memory(hpdmc_read_fn, hpdmc_write_fn, s,
- DEVICE_NATIVE_ENDIAN);
- sysbus_init_mmio(dev, R_MAX * 4, hpdmc_regs);
+ memory_region_init_io(&s->regs_region, &hpdmc_mmio_ops, s,
+ "milkymist-hpdmc", R_MAX * 4);
+ sysbus_init_mmio_region(dev, &s->regs_region);
return 0;
}