etrax-timer: Convert to MemoryRegion

Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
Edgar E. Iglesias 2011-08-11 13:47:46 +02:00 committed by Avi Kivity
parent dbfb57f3b1
commit b8e5da2c59

View File

@ -43,6 +43,7 @@
struct etrax_timer { struct etrax_timer {
SysBusDevice busdev; SysBusDevice busdev;
MemoryRegion mmio;
qemu_irq irq; qemu_irq irq;
qemu_irq nmi; qemu_irq nmi;
@ -72,7 +73,8 @@ struct etrax_timer {
uint32_t r_masked_intr; uint32_t r_masked_intr;
}; };
static uint32_t timer_readl (void *opaque, target_phys_addr_t addr) static uint64_t
timer_read(void *opaque, target_phys_addr_t addr, unsigned int size)
{ {
struct etrax_timer *t = opaque; struct etrax_timer *t = opaque;
uint32_t r = 0; uint32_t r = 0;
@ -239,9 +241,11 @@ static inline void timer_watchdog_update(struct etrax_timer *t, uint32_t value)
} }
static void static void
timer_writel (void *opaque, target_phys_addr_t addr, uint32_t value) timer_write(void *opaque, target_phys_addr_t addr,
uint64_t val64, unsigned int size)
{ {
struct etrax_timer *t = opaque; struct etrax_timer *t = opaque;
uint32_t value = val64;
switch (addr) switch (addr)
{ {
@ -281,14 +285,14 @@ timer_writel (void *opaque, target_phys_addr_t addr, uint32_t value)
} }
} }
static CPUReadMemoryFunc * const timer_read[] = { static const MemoryRegionOps timer_ops = {
NULL, NULL, .read = timer_read,
&timer_readl, .write = timer_write,
}; .endianness = DEVICE_LITTLE_ENDIAN,
.valid = {
static CPUWriteMemoryFunc * const timer_write[] = { .min_access_size = 4,
NULL, NULL, .max_access_size = 4
&timer_writel, }
}; };
static void etraxfs_timer_reset(void *opaque) static void etraxfs_timer_reset(void *opaque)
@ -307,7 +311,6 @@ static void etraxfs_timer_reset(void *opaque)
static int etraxfs_timer_init(SysBusDevice *dev) static int etraxfs_timer_init(SysBusDevice *dev)
{ {
struct etrax_timer *t = FROM_SYSBUS(typeof (*t), dev); struct etrax_timer *t = FROM_SYSBUS(typeof (*t), dev);
int timer_regs;
t->bh_t0 = qemu_bh_new(timer0_hit, t); t->bh_t0 = qemu_bh_new(timer0_hit, t);
t->bh_t1 = qemu_bh_new(timer1_hit, t); t->bh_t1 = qemu_bh_new(timer1_hit, t);
@ -319,10 +322,8 @@ static int etraxfs_timer_init(SysBusDevice *dev)
sysbus_init_irq(dev, &t->irq); sysbus_init_irq(dev, &t->irq);
sysbus_init_irq(dev, &t->nmi); sysbus_init_irq(dev, &t->nmi);
timer_regs = cpu_register_io_memory(timer_read, timer_write, t, memory_region_init_io(&t->mmio, &timer_ops, t, "etraxfs-timer", 0x5c);
DEVICE_NATIVE_ENDIAN); sysbus_init_mmio_region(dev, &t->mmio);
sysbus_init_mmio(dev, 0x5c, timer_regs);
qemu_register_reset(etraxfs_timer_reset, t); qemu_register_reset(etraxfs_timer_reset, t);
return 0; return 0;
} }