syborg_timer: convert to memory API
Signed-off-by: Benoit Canet <benoit.canet@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:
parent
a8a008223c
commit
7d5ebaf002
@ -53,6 +53,7 @@ enum {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SysBusDevice busdev;
|
SysBusDevice busdev;
|
||||||
|
MemoryRegion iomem;
|
||||||
ptimer_state *timer;
|
ptimer_state *timer;
|
||||||
int running;
|
int running;
|
||||||
int oneshot;
|
int oneshot;
|
||||||
@ -83,7 +84,8 @@ static void syborg_timer_tick(void *opaque)
|
|||||||
syborg_timer_update(s);
|
syborg_timer_update(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t syborg_timer_read(void *opaque, target_phys_addr_t offset)
|
static uint64_t syborg_timer_read(void *opaque, target_phys_addr_t offset,
|
||||||
|
unsigned size)
|
||||||
{
|
{
|
||||||
SyborgTimerState *s = (SyborgTimerState *)opaque;
|
SyborgTimerState *s = (SyborgTimerState *)opaque;
|
||||||
|
|
||||||
@ -114,7 +116,7 @@ static uint32_t syborg_timer_read(void *opaque, target_phys_addr_t offset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void syborg_timer_write(void *opaque, target_phys_addr_t offset,
|
static void syborg_timer_write(void *opaque, target_phys_addr_t offset,
|
||||||
uint32_t value)
|
uint64_t value, unsigned size)
|
||||||
{
|
{
|
||||||
SyborgTimerState *s = (SyborgTimerState *)opaque;
|
SyborgTimerState *s = (SyborgTimerState *)opaque;
|
||||||
|
|
||||||
@ -162,16 +164,10 @@ static void syborg_timer_write(void *opaque, target_phys_addr_t offset,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static CPUReadMemoryFunc * const syborg_timer_readfn[] = {
|
static const MemoryRegionOps syborg_timer_ops = {
|
||||||
syborg_timer_read,
|
.read = syborg_timer_read,
|
||||||
syborg_timer_read,
|
.write = syborg_timer_write,
|
||||||
syborg_timer_read
|
.endianness = DEVICE_NATIVE_ENDIAN,
|
||||||
};
|
|
||||||
|
|
||||||
static CPUWriteMemoryFunc * const syborg_timer_writefn[] = {
|
|
||||||
syborg_timer_write,
|
|
||||||
syborg_timer_write,
|
|
||||||
syborg_timer_write
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const VMStateDescription vmstate_syborg_timer = {
|
static const VMStateDescription vmstate_syborg_timer = {
|
||||||
@ -194,17 +190,14 @@ static int syborg_timer_init(SysBusDevice *dev)
|
|||||||
{
|
{
|
||||||
SyborgTimerState *s = FROM_SYSBUS(SyborgTimerState, dev);
|
SyborgTimerState *s = FROM_SYSBUS(SyborgTimerState, dev);
|
||||||
QEMUBH *bh;
|
QEMUBH *bh;
|
||||||
int iomemtype;
|
|
||||||
|
|
||||||
if (s->freq == 0) {
|
if (s->freq == 0) {
|
||||||
fprintf(stderr, "syborg_timer: Zero/unset frequency\n");
|
fprintf(stderr, "syborg_timer: Zero/unset frequency\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
sysbus_init_irq(dev, &s->irq);
|
sysbus_init_irq(dev, &s->irq);
|
||||||
iomemtype = cpu_register_io_memory(syborg_timer_readfn,
|
memory_region_init_io(&s->iomem, &syborg_timer_ops, s, "timer", 0x1000);
|
||||||
syborg_timer_writefn, s,
|
sysbus_init_mmio_region(dev, &s->iomem);
|
||||||
DEVICE_NATIVE_ENDIAN);
|
|
||||||
sysbus_init_mmio(dev, 0x1000, iomemtype);
|
|
||||||
|
|
||||||
bh = qemu_bh_new(syborg_timer_tick, s);
|
bh = qemu_bh_new(syborg_timer_tick, s);
|
||||||
s->timer = ptimer_init(bh);
|
s->timer = ptimer_init(bh);
|
||||||
|
Loading…
Reference in New Issue
Block a user