milkymist-hpdmc: convert to memory API

Signed-off-by: Michael Walle <michael@walle.cc>
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Michael Walle 2011-08-31 16:48:40 +02:00 committed by Avi Kivity
parent 9496e1c335
commit 321c17ae97

View File

@ -42,12 +42,14 @@ enum {
struct MilkymistHpdmcState { struct MilkymistHpdmcState {
SysBusDevice busdev; SysBusDevice busdev;
MemoryRegion regs_region;
uint32_t regs[R_MAX]; uint32_t regs[R_MAX];
}; };
typedef struct MilkymistHpdmcState MilkymistHpdmcState; 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; MilkymistHpdmcState *s = opaque;
uint32_t r = 0; uint32_t r = 0;
@ -72,7 +74,8 @@ static uint32_t hpdmc_read(void *opaque, target_phys_addr_t addr)
return r; 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; 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[] = { static const MemoryRegionOps hpdmc_mmio_ops = {
NULL, .read = hpdmc_read,
NULL, .write = hpdmc_write,
&hpdmc_read, .valid = {
}; .min_access_size = 4,
.max_access_size = 4,
static CPUWriteMemoryFunc * const hpdmc_write_fn[] = { },
NULL, .endianness = DEVICE_NATIVE_ENDIAN,
NULL,
&hpdmc_write,
}; };
static void milkymist_hpdmc_reset(DeviceState *d) 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) static int milkymist_hpdmc_init(SysBusDevice *dev)
{ {
MilkymistHpdmcState *s = FROM_SYSBUS(typeof(*s), dev); MilkymistHpdmcState *s = FROM_SYSBUS(typeof(*s), dev);
int hpdmc_regs;
hpdmc_regs = cpu_register_io_memory(hpdmc_read_fn, hpdmc_write_fn, s, memory_region_init_io(&s->regs_region, &hpdmc_mmio_ops, s,
DEVICE_NATIVE_ENDIAN); "milkymist-hpdmc", R_MAX * 4);
sysbus_init_mmio(dev, R_MAX * 4, hpdmc_regs); sysbus_init_mmio_region(dev, &s->regs_region);
return 0; return 0;
} }