aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2011-10-06 16:44:26 +0200
committerAvi Kivity <avi@redhat.com>2011-11-24 18:31:54 +0200
commit63858cd99244aeb819f92a6f8f9a23a5719c4824 (patch)
treebf488a0978297c63fafe9a728bf9b102d958ee75 /hw
parentc601785091d72dc95b13a40c09e4fd6a3ccc3197 (diff)
parallel: convert to memory API
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/mips_jazz.c3
-rw-r--r--hw/parallel.c27
-rw-r--r--hw/pc.h3
3 files changed, 16 insertions, 17 deletions
diff --git a/hw/mips_jazz.c b/hw/mips_jazz.c
index 6e657ddd4e..f6e331652b 100644
--- a/hw/mips_jazz.c
+++ b/hw/mips_jazz.c
@@ -274,7 +274,8 @@ static void mips_jazz_init(MemoryRegion *address_space,
/* Parallel port */
if (parallel_hds[0])
- parallel_mm_init(0x80008000, 0, rc4030[0], parallel_hds[0]);
+ parallel_mm_init(address_space, 0x80008000, 0, rc4030[0],
+ parallel_hds[0]);
/* Sound card */
/* FIXME: missing Jazz sound at 0x8000c000, rc4030[2] */
diff --git a/hw/parallel.c b/hw/parallel.c
index 8494d94f69..c4c5dbee5b 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -65,6 +65,7 @@
#define PARA_CTR_SIGNAL (PARA_CTR_SELECT|PARA_CTR_INIT|PARA_CTR_AUTOLF|PARA_CTR_STROBE)
typedef struct ParallelState {
+ MemoryRegion iomem;
uint8_t dataw;
uint8_t datar;
uint8_t status;
@@ -555,24 +556,20 @@ static void parallel_mm_writel (void *opaque,
parallel_ioport_write_sw(s, addr >> s->it_shift, value);
}
-static CPUReadMemoryFunc * const parallel_mm_read_sw[] = {
- &parallel_mm_readb,
- &parallel_mm_readw,
- &parallel_mm_readl,
-};
-
-static CPUWriteMemoryFunc * const parallel_mm_write_sw[] = {
- &parallel_mm_writeb,
- &parallel_mm_writew,
- &parallel_mm_writel,
+static const MemoryRegionOps parallel_mm_ops = {
+ .old_mmio = {
+ .read = { parallel_mm_readb, parallel_mm_readw, parallel_mm_readl },
+ .write = { parallel_mm_writeb, parallel_mm_writew, parallel_mm_writel },
+ },
+ .endianness = DEVICE_NATIVE_ENDIAN,
};
/* If fd is zero, it means that the parallel device uses the console */
-bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
+bool parallel_mm_init(MemoryRegion *address_space,
+ target_phys_addr_t base, int it_shift, qemu_irq irq,
CharDriverState *chr)
{
ParallelState *s;
- int io_sw;
s = g_malloc0(sizeof(ParallelState));
s->irq = irq;
@@ -580,9 +577,9 @@ bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
s->it_shift = it_shift;
qemu_register_reset(parallel_reset, s);
- io_sw = cpu_register_io_memory(parallel_mm_read_sw, parallel_mm_write_sw,
- s, DEVICE_NATIVE_ENDIAN);
- cpu_register_physical_memory(base, 8 << it_shift, io_sw);
+ memory_region_init_io(&s->iomem, &parallel_mm_ops, s,
+ "parallel", 8 << it_shift);
+ memory_region_add_subregion(address_space, base, &s->iomem);
return true;
}
diff --git a/hw/pc.h b/hw/pc.h
index 4515006381..b7b7e40ce7 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -55,7 +55,8 @@ static inline bool parallel_init(int index, CharDriverState *chr)
return true;
}
-bool parallel_mm_init(target_phys_addr_t base, int it_shift, qemu_irq irq,
+bool parallel_mm_init(MemoryRegion *address_space,
+ target_phys_addr_t base, int it_shift, qemu_irq irq,
CharDriverState *chr);
/* i8259.c */