From: <marcin.krzeminski@nokia.com>
To: qemu-devel@nongnu.org
Cc: qemu-arm@nongnu.org, peter.maydell@linaro.org,
rfsw-patches@mlist.nokia.com
Subject: [Qemu-devel] [RFC 1/3] nvic: Add CPU numebr property
Date: Fri, 16 Dec 2016 14:22:37 +0100 [thread overview]
Message-ID: <1481894559-13974-2-git-send-email-marcin.krzeminski@nokia.com> (raw)
In-Reply-To: <1481894559-13974-1-git-send-email-marcin.krzeminski@nokia.com>
From: Marcin Krzeminski <marcin.krzeminski@nokia.com>
In case of MultiCPU SoC M3 is not always CPU0.
This commit add cpu_id property to allow set CPU
number for NVIC model. Also address space that this used
by NVIC is updated to mach CPU's one.
Signed-off-by: Marcin Krzeminski <marcin.krzeminski@nokia.com>
---
hw/intc/armv7m_nvic.c | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c
index 06d8db6..66f0f70 100644
--- a/hw/intc/armv7m_nvic.c
+++ b/hw/intc/armv7m_nvic.c
@@ -34,6 +34,7 @@ typedef struct {
MemoryRegion container;
uint32_t num_irq;
qemu_irq sysresetreq;
+ uint32_t cpu_id;
} nvic_state;
#define TYPE_NVIC "armv7m_nvic"
@@ -187,11 +188,11 @@ static uint32_t nvic_readl(nvic_state *s, uint32_t offset)
case 0x1c: /* SysTick Calibration Value. */
return 10000;
case 0xd00: /* CPUID Base. */
- cpu = ARM_CPU(qemu_get_cpu(0));
+ cpu = ARM_CPU(qemu_get_cpu(s->cpu_id));
return cpu->midr;
case 0xd04: /* Interrupt Control State. */
/* VECTACTIVE */
- cpu = ARM_CPU(qemu_get_cpu(0));
+ cpu = ARM_CPU(qemu_get_cpu(s->cpu_id));
val = cpu->env.v7m.exception;
if (val == 1023) {
val = 0;
@@ -222,7 +223,7 @@ static uint32_t nvic_readl(nvic_state *s, uint32_t offset)
val |= (1 << 31);
return val;
case 0xd08: /* Vector Table Offset. */
- cpu = ARM_CPU(qemu_get_cpu(0));
+ cpu = ARM_CPU(qemu_get_cpu(s->cpu_id));
return cpu->env.v7m.vecbase;
case 0xd0c: /* Application Interrupt/Reset Control. */
return 0xfa050000;
@@ -349,7 +350,7 @@ static void nvic_writel(nvic_state *s, uint32_t offset, uint32_t value)
}
break;
case 0xd08: /* Vector Table Offset. */
- cpu = ARM_CPU(qemu_get_cpu(0));
+ cpu = ARM_CPU(qemu_get_cpu(s->cpu_id));
cpu->env.v7m.vecbase = value & 0xffffff80;
break;
case 0xd0c: /* Application Interrupt/Reset Control. */
@@ -453,6 +454,11 @@ static void nvic_sysreg_write(void *opaque, hwaddr addr,
"NVIC: Bad write of size %d at offset 0x%x\n", size, offset);
}
+static Property nvic_properties[] = {
+ DEFINE_PROP_UINT32("cpu-id", nvic_state, cpu_id, 0),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
static const MemoryRegionOps nvic_sysreg_ops = {
.read = nvic_sysreg_read,
.write = nvic_sysreg_write,
@@ -461,13 +467,14 @@ static const MemoryRegionOps nvic_sysreg_ops = {
static const VMStateDescription vmstate_nvic = {
.name = "armv7m_nvic",
- .version_id = 1,
+ .version_id = 2,
.minimum_version_id = 1,
.fields = (VMStateField[]) {
VMSTATE_UINT32(systick.control, nvic_state),
VMSTATE_UINT32(systick.reload, nvic_state),
VMSTATE_INT64(systick.tick, nvic_state),
VMSTATE_TIMER_PTR(systick.timer, nvic_state),
+ VMSTATE_UINT32(cpu_id, nvic_state),
VMSTATE_END_OF_LIST()
}
};
@@ -494,6 +501,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
nvic_state *s = NVIC(dev);
NVICClass *nc = NVIC_GET_CLASS(s);
Error *local_err = NULL;
+ CPUState *cpustate;
/* The NVIC always has only one CPU */
s->gic.num_cpu = 1;
@@ -531,7 +539,10 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
/* 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);
+
+ cpustate = qemu_get_cpu(s->cpu_id);
+ memory_region_add_subregion(cpustate->as->root, 0xe000e000, &s->container);
+
s->systick.timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, systick_timer_tick, s);
}
@@ -564,6 +575,7 @@ static void armv7m_nvic_class_init(ObjectClass *klass, void *data)
dc->vmsd = &vmstate_nvic;
dc->reset = armv7m_nvic_reset;
dc->realize = armv7m_nvic_realize;
+ dc->props = nvic_properties;
}
static const TypeInfo armv7m_nvic_info = {
--
2.7.4
next prev parent reply other threads:[~2016-12-16 13:37 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-12-16 13:22 [Qemu-devel] [RFC 0/3] MultiCPU changes marcin.krzeminski
2016-12-16 13:22 ` marcin.krzeminski [this message]
2016-12-16 14:18 ` [Qemu-devel] [RFC 1/3] nvic: Add CPU numebr property Peter Maydell
2016-12-30 10:13 ` [Qemu-devel] Odp.: " Krzeminski, Marcin (Nokia - PL/Wroclaw)
2016-12-16 13:22 ` [Qemu-devel] [RFC 2/3] ARM: boot: Add option to skip FDT memory node update marcin.krzeminski
2016-12-16 13:22 ` [Qemu-devel] [RFC 3/3] exec: Allow to change Address Space from board level marcin.krzeminski
2016-12-16 14:07 ` [Qemu-devel] [RFC 0/3] MultiCPU changes no-reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1481894559-13974-2-git-send-email-marcin.krzeminski@nokia.com \
--to=marcin.krzeminski@nokia.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=rfsw-patches@mlist.nokia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).