diff options
author | Avi Kivity <avi@redhat.com> | 2011-11-14 14:23:17 +0200 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-11-24 18:32:01 +0200 |
commit | cde844fa76b2e3f35b814a73d8d43688283ce8b4 (patch) | |
tree | 466d1f844c76c123ab00f21cb547080418ba1704 /hw/grlib_gptimer.c | |
parent | 6281f7d11fa6bfb6da3926359fbe70684e582cb1 (diff) |
grlib_gptimer: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/grlib_gptimer.c')
-rw-r--r-- | hw/grlib_gptimer.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/hw/grlib_gptimer.c b/hw/grlib_gptimer.c index 85869b95eb..c142a5b89b 100644 --- a/hw/grlib_gptimer.c +++ b/hw/grlib_gptimer.c @@ -68,6 +68,7 @@ struct GPTimer { struct GPTimerUnit { SysBusDevice busdev; + MemoryRegion iomem; uint32_t nr_timers; /* Number of timers available */ uint32_t freq_hz; /* System frequency */ @@ -153,7 +154,8 @@ static void grlib_gptimer_hit(void *opaque) } } -static uint32_t grlib_gptimer_readl(void *opaque, target_phys_addr_t addr) +static uint64_t grlib_gptimer_read(void *opaque, target_phys_addr_t addr, + unsigned size) { GPTimerUnit *unit = opaque; target_phys_addr_t timer_addr; @@ -211,8 +213,8 @@ static uint32_t grlib_gptimer_readl(void *opaque, target_phys_addr_t addr) return 0; } -static void -grlib_gptimer_writel(void *opaque, target_phys_addr_t addr, uint32_t value) +static void grlib_gptimer_write(void *opaque, target_phys_addr_t addr, + uint64_t value, unsigned size) { GPTimerUnit *unit = opaque; target_phys_addr_t timer_addr; @@ -299,12 +301,14 @@ grlib_gptimer_writel(void *opaque, target_phys_addr_t addr, uint32_t value) trace_grlib_gptimer_writel(-1, addr, value); } -static CPUReadMemoryFunc * const grlib_gptimer_read[] = { - NULL, NULL, grlib_gptimer_readl, -}; - -static CPUWriteMemoryFunc * const grlib_gptimer_write[] = { - NULL, NULL, grlib_gptimer_writel, +static const MemoryRegionOps grlib_gptimer_ops = { + .read = grlib_gptimer_read, + .write = grlib_gptimer_write, + .endianness = DEVICE_NATIVE_ENDIAN, + .valid = { + .min_access_size = 4, + .max_access_size = 4, + }, }; static void grlib_gptimer_reset(DeviceState *d) @@ -340,7 +344,6 @@ static int grlib_gptimer_init(SysBusDevice *dev) { GPTimerUnit *unit = FROM_SYSBUS(typeof(*unit), dev); unsigned int i; - int timer_regs; assert(unit->nr_timers > 0); assert(unit->nr_timers <= GPTIMER_MAX_TIMERS); @@ -361,15 +364,10 @@ static int grlib_gptimer_init(SysBusDevice *dev) ptimer_set_freq(timer->ptimer, unit->freq_hz); } - timer_regs = cpu_register_io_memory(grlib_gptimer_read, - grlib_gptimer_write, - unit, DEVICE_NATIVE_ENDIAN); - if (timer_regs < 0) { - return -1; - } + memory_region_init_io(&unit->iomem, &grlib_gptimer_ops, unit, "gptimer", + UNIT_REG_SIZE + GPTIMER_REG_SIZE * unit->nr_timers); - sysbus_init_mmio(dev, UNIT_REG_SIZE + GPTIMER_REG_SIZE * unit->nr_timers, - timer_regs); + sysbus_init_mmio_region(dev, &unit->iomem); return 0; } |