aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2017-02-20 15:36:00 +0000
committerPeter Maydell <peter.maydell@linaro.org>2017-02-28 15:02:29 +0000
commit5bca4de93753b24e89ad0b1bad597d6de5e2e1d3 (patch)
tree326f5db0b4ae9f99f5683a33aac3174ca68fbfa4
parent10545eeff8554697153ee0d90d19e1db1d503521 (diff)
armv7m: Make NVIC expose a memory region rather than mapping itself
Make the NVIC device expose a memory region for its users to map, rather than mapping itself into the system memory space on realize, and get the one user (the ARMv7M object) to do this. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 1487604965-23220-7-git-send-email-peter.maydell@linaro.org
-rw-r--r--hw/arm/armv7m.c7
-rw-r--r--hw/intc/armv7m_nvic.c7
2 files changed, 8 insertions, 6 deletions
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c
index 3332f34617..de9746665d 100644
--- a/hw/arm/armv7m.c
+++ b/hw/arm/armv7m.c
@@ -171,6 +171,7 @@ static void armv7m_instance_init(Object *obj)
static void armv7m_realize(DeviceState *dev, Error **errp)
{
ARMv7MState *s = ARMV7M(dev);
+ SysBusDevice *sbd;
Error *err = NULL;
int i;
char **cpustr;
@@ -232,10 +233,14 @@ static void armv7m_realize(DeviceState *dev, Error **errp)
qdev_pass_gpios(DEVICE(&s->nvic), dev, "SYSRESETREQ");
/* Wire the NVIC up to the CPU */
- sysbus_connect_irq(SYS_BUS_DEVICE(&s->nvic), 0,
+ sbd = SYS_BUS_DEVICE(&s->nvic);
+ sysbus_connect_irq(sbd, 0,
qdev_get_gpio_in(DEVICE(s->cpu), ARM_CPU_IRQ));
s->cpu->env.nvic = &s->nvic;
+ memory_region_add_subregion(&s->container, 0xe000e000,
+ sysbus_mmio_get_region(sbd, 0));
+
for (i = 0; i < ARRAY_SIZE(s->bitband); i++) {
Object *obj = OBJECT(&s->bitband[i]);
SysBusDevice *sbd = SYS_BUS_DEVICE(&s->bitband[i]);
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index f2ada39996..c814e16e49 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -19,7 +19,6 @@
#include "hw/arm/arm.h"
#include "hw/arm/armv7m_nvic.h"
#include "target/arm/cpu.h"
-#include "exec/address-spaces.h"
#include "qemu/log.h"
#include "trace.h"
@@ -1043,10 +1042,8 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
"nvic_sysregs", 0x1000);
memory_region_add_subregion(&s->container, 0, &s->sysregmem);
- /* Map the whole thing into system memory at the location required
- * by the v7M architecture.
- */
- memory_region_add_subregion(get_system_memory(), 0xe000e000, &s->container);
+ sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->container);
+
s->systick.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, systick_timer_tick, s);
}