aboutsummaryrefslogtreecommitdiff
path: root/hw/syborg_rtc.c
diff options
context:
space:
mode:
authorBenoƮt Canet <benoit.canet@gmail.com>2011-10-24 22:38:25 +0200
committerAvi Kivity <avi@redhat.com>2011-11-24 18:31:57 +0200
commit43b8c30da260d6f37eb9c580ad9b7e0b33df5a0e (patch)
tree921eee0cea639c53884695a2eeff68d1a7d1ae32 /hw/syborg_rtc.c
parent9ca9e358e2279acd579bd8c91119db3fd6ee2eea (diff)
syborg_rtc: convert to memory API
Signed-off-by: Benoit Canet <benoit.canet@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/syborg_rtc.c')
-rw-r--r--hw/syborg_rtc.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/hw/syborg_rtc.c b/hw/syborg_rtc.c
index 69f6ccf29c..375664f863 100644
--- a/hw/syborg_rtc.c
+++ b/hw/syborg_rtc.c
@@ -35,12 +35,14 @@ enum {
typedef struct {
SysBusDevice busdev;
+ MemoryRegion iomem;
int64_t offset;
int64_t data;
qemu_irq irq;
} SyborgRTCState;
-static uint32_t syborg_rtc_read(void *opaque, target_phys_addr_t offset)
+static uint64_t syborg_rtc_read(void *opaque, target_phys_addr_t offset,
+ unsigned size)
{
SyborgRTCState *s = (SyborgRTCState *)opaque;
offset &= 0xfff;
@@ -58,7 +60,8 @@ static uint32_t syborg_rtc_read(void *opaque, target_phys_addr_t offset)
}
}
-static void syborg_rtc_write(void *opaque, target_phys_addr_t offset, uint32_t value)
+static void syborg_rtc_write(void *opaque, target_phys_addr_t offset,
+ uint64_t value, unsigned size)
{
SyborgRTCState *s = (SyborgRTCState *)opaque;
uint64_t now;
@@ -90,16 +93,10 @@ static void syborg_rtc_write(void *opaque, target_phys_addr_t offset, uint32_t v
}
}
-static CPUReadMemoryFunc * const syborg_rtc_readfn[] = {
- syborg_rtc_read,
- syborg_rtc_read,
- syborg_rtc_read
-};
-
-static CPUWriteMemoryFunc * const syborg_rtc_writefn[] = {
- syborg_rtc_write,
- syborg_rtc_write,
- syborg_rtc_write
+static const MemoryRegionOps syborg_rtc_ops = {
+ .read = syborg_rtc_read,
+ .write = syborg_rtc_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
};
static const VMStateDescription vmstate_syborg_rtc = {
@@ -118,12 +115,9 @@ static int syborg_rtc_init(SysBusDevice *dev)
{
SyborgRTCState *s = FROM_SYSBUS(SyborgRTCState, dev);
struct tm tm;
- int iomemtype;
- iomemtype = cpu_register_io_memory(syborg_rtc_readfn,
- syborg_rtc_writefn, s,
- DEVICE_NATIVE_ENDIAN);
- sysbus_init_mmio(dev, 0x1000, iomemtype);
+ memory_region_init_io(&s->iomem, &syborg_rtc_ops, s, "rtc", 0x1000);
+ sysbus_init_mmio_region(dev, &s->iomem);
qemu_get_timedate(&tm, 0);
s->offset = (uint64_t)mktime(&tm) * 1000000000;