aboutsummaryrefslogtreecommitdiff
path: root/hw/milkymist-softusb.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2013-03-15 14:34:22 +0000
committerAnthony Liguori <aliguori@us.ibm.com>2013-04-01 09:08:33 -0500
commitc34e120554c31d45bdfbac08a5c1d9ef92a62020 (patch)
tree243b66a6e204426fcc5e39b8b462080a64b4fbdf /hw/milkymist-softusb.c
parent20cf850c6ac5bf1ef13de1da93a5c8b5ea28b304 (diff)
milkymist-softusb: Don't map RAM memory regions in the device itself
Don't map the pmem and dmem RAM memory regions in the milkymist-softusb device itself. Instead just expose them as sysbus mmio regions which the device creator can map appropriately. This allows us to drop the pmem_base and dmem_base properties. Instead of going via cpu_physical_memory_read/_write when the device wants to access the RAMs, we just keep a host pointer to the memory and use that. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de> Acked-by: Michael Walle <michael@walle.cc> Message-id: 1363358063-23973-5-git-send-email-peter.maydell@linaro.org Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/milkymist-softusb.c')
-rw-r--r--hw/milkymist-softusb.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/hw/milkymist-softusb.c b/hw/milkymist-softusb.c
index d911686de7..b279d4e908 100644
--- a/hw/milkymist-softusb.c
+++ b/hw/milkymist-softusb.c
@@ -54,10 +54,11 @@ struct MilkymistSoftUsbState {
MemoryRegion dmem;
qemu_irq irq;
+ void *pmem_ptr;
+ void *dmem_ptr;
+
/* device properties */
- uint32_t pmem_base;
uint32_t pmem_size;
- uint32_t dmem_base;
uint32_t dmem_size;
/* device registers */
@@ -134,7 +135,7 @@ static inline void softusb_read_dmem(MilkymistSoftUsbState *s,
return;
}
- cpu_physical_memory_read(s->dmem_base + offset, buf, len);
+ memcpy(buf, s->dmem_ptr + offset, len);
}
static inline void softusb_write_dmem(MilkymistSoftUsbState *s,
@@ -146,7 +147,7 @@ static inline void softusb_write_dmem(MilkymistSoftUsbState *s,
return;
}
- cpu_physical_memory_write(s->dmem_base + offset, buf, len);
+ memcpy(s->dmem_ptr + offset, buf, len);
}
static inline void softusb_read_pmem(MilkymistSoftUsbState *s,
@@ -158,7 +159,7 @@ static inline void softusb_read_pmem(MilkymistSoftUsbState *s,
return;
}
- cpu_physical_memory_read(s->pmem_base + offset, buf, len);
+ memcpy(buf, s->pmem_ptr + offset, len);
}
static inline void softusb_write_pmem(MilkymistSoftUsbState *s,
@@ -170,7 +171,7 @@ static inline void softusb_write_pmem(MilkymistSoftUsbState *s,
return;
}
- cpu_physical_memory_write(s->pmem_base + offset, buf, len);
+ memcpy(s->pmem_ptr + offset, buf, len);
}
static void softusb_mouse_changed(MilkymistSoftUsbState *s)
@@ -270,11 +271,13 @@ static int milkymist_softusb_init(SysBusDevice *dev)
memory_region_init_ram(&s->pmem, "milkymist-softusb.pmem",
s->pmem_size);
vmstate_register_ram_global(&s->pmem);
- sysbus_add_memory(dev, s->pmem_base, &s->pmem);
+ s->pmem_ptr = memory_region_get_ram_ptr(&s->pmem);
+ sysbus_init_mmio(dev, &s->pmem);
memory_region_init_ram(&s->dmem, "milkymist-softusb.dmem",
s->dmem_size);
vmstate_register_ram_global(&s->dmem);
- sysbus_add_memory(dev, s->dmem_base, &s->dmem);
+ s->dmem_ptr = memory_region_get_ram_ptr(&s->dmem);
+ sysbus_init_mmio(dev, &s->dmem);
hid_init(&s->hid_kbd, HID_KEYBOARD, softusb_kbd_hid_datain);
hid_init(&s->hid_mouse, HID_MOUSE, softusb_mouse_hid_datain);
@@ -298,9 +301,7 @@ static const VMStateDescription vmstate_milkymist_softusb = {
};
static Property milkymist_softusb_properties[] = {
- DEFINE_PROP_UINT32("pmem_base", MilkymistSoftUsbState, pmem_base, 0xa0000000),
DEFINE_PROP_UINT32("pmem_size", MilkymistSoftUsbState, pmem_size, 0x00001000),
- DEFINE_PROP_UINT32("dmem_base", MilkymistSoftUsbState, dmem_base, 0xa0020000),
DEFINE_PROP_UINT32("dmem_size", MilkymistSoftUsbState, dmem_size, 0x00002000),
DEFINE_PROP_END_OF_LIST(),
};