aboutsummaryrefslogtreecommitdiff
path: root/hw/grlib_irqmp.c
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-11-14 14:23:17 +0200
committerAvi Kivity <avi@redhat.com>2011-11-24 18:32:01 +0200
commit847b52c107b7f426e9224b6dda41b1ab72bec1bc (patch)
treeffa4aa695b10964a6cde441fe39e3d6b523f70e1 /hw/grlib_irqmp.c
parentcde844fa76b2e3f35b814a73d8d43688283ce8b4 (diff)
grlib_irqmp: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw/grlib_irqmp.c')
-rw-r--r--hw/grlib_irqmp.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/hw/grlib_irqmp.c b/hw/grlib_irqmp.c
index 9490a7830d..dce0bbb9f4 100644
--- a/hw/grlib_irqmp.c
+++ b/hw/grlib_irqmp.c
@@ -49,6 +49,7 @@ typedef struct IRQMPState IRQMPState;
typedef struct IRQMP {
SysBusDevice busdev;
+ MemoryRegion iomem;
void *set_pil_in;
void *set_pil_in_opaque;
@@ -161,7 +162,8 @@ void grlib_irqmp_set_irq(void *opaque, int irq, int level)
}
}
-static uint32_t grlib_irqmp_readl(void *opaque, target_phys_addr_t addr)
+static uint64_t grlib_irqmp_read(void *opaque, target_phys_addr_t addr,
+ unsigned size)
{
IRQMP *irqmp = opaque;
IRQMPState *state;
@@ -224,8 +226,8 @@ static uint32_t grlib_irqmp_readl(void *opaque, target_phys_addr_t addr)
return 0;
}
-static void
-grlib_irqmp_writel(void *opaque, target_phys_addr_t addr, uint32_t value)
+static void grlib_irqmp_write(void *opaque, target_phys_addr_t addr,
+ uint64_t value, unsigned size)
{
IRQMP *irqmp = opaque;
IRQMPState *state;
@@ -311,12 +313,14 @@ grlib_irqmp_writel(void *opaque, target_phys_addr_t addr, uint32_t value)
trace_grlib_irqmp_writel_unknown(addr, value);
}
-static CPUReadMemoryFunc * const grlib_irqmp_read[] = {
- NULL, NULL, &grlib_irqmp_readl,
-};
-
-static CPUWriteMemoryFunc * const grlib_irqmp_write[] = {
- NULL, NULL, &grlib_irqmp_writel,
+static const MemoryRegionOps grlib_irqmp_ops = {
+ .read = grlib_irqmp_read,
+ .write = grlib_irqmp_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+ .valid = {
+ .min_access_size = 4,
+ .max_access_size = 4,
+ },
};
static void grlib_irqmp_reset(DeviceState *d)
@@ -332,7 +336,6 @@ static void grlib_irqmp_reset(DeviceState *d)
static int grlib_irqmp_init(SysBusDevice *dev)
{
IRQMP *irqmp = FROM_SYSBUS(typeof(*irqmp), dev);
- int irqmp_regs;
assert(irqmp != NULL);
@@ -341,17 +344,12 @@ static int grlib_irqmp_init(SysBusDevice *dev)
return -1;
}
- irqmp_regs = cpu_register_io_memory(grlib_irqmp_read,
- grlib_irqmp_write,
- irqmp, DEVICE_NATIVE_ENDIAN);
+ memory_region_init_io(&irqmp->iomem, &grlib_irqmp_ops, irqmp,
+ "irqmp", IRQMP_REG_SIZE);
irqmp->state = g_malloc0(sizeof *irqmp->state);
- if (irqmp_regs < 0) {
- return -1;
- }
-
- sysbus_init_mmio(dev, IRQMP_REG_SIZE, irqmp_regs);
+ sysbus_init_mmio_region(dev, &irqmp->iomem);
return 0;
}