提交 62f01848 编写于 作者: P Peter Maydell

nvic: Make nvic_sysreg_ns_ops work with any MemoryRegion

Generalize nvic_sysreg_ns_ops so that we can pass it an
arbitrary MemoryRegion which it will use as the underlying
register implementation to apply the NS-alias behaviour
to. We'll want this so we can do the same with systick.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NPhilippe Mathieu-Daudé <f4bug@amsat.org>
Message-id: 1512154296-5652-2-git-send-email-peter.maydell@linaro.org
上级 1313e2d7
...@@ -1786,10 +1786,12 @@ static MemTxResult nvic_sysreg_ns_write(void *opaque, hwaddr addr, ...@@ -1786,10 +1786,12 @@ static MemTxResult nvic_sysreg_ns_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size, uint64_t value, unsigned size,
MemTxAttrs attrs) MemTxAttrs attrs)
{ {
MemoryRegion *mr = opaque;
if (attrs.secure) { if (attrs.secure) {
/* S accesses to the alias act like NS accesses to the real region */ /* S accesses to the alias act like NS accesses to the real region */
attrs.secure = 0; attrs.secure = 0;
return nvic_sysreg_write(opaque, addr, value, size, attrs); return memory_region_dispatch_write(mr, addr, value, size, attrs);
} else { } else {
/* NS attrs are RAZ/WI for privileged, and BusFault for user */ /* NS attrs are RAZ/WI for privileged, and BusFault for user */
if (attrs.user) { if (attrs.user) {
...@@ -1803,10 +1805,12 @@ static MemTxResult nvic_sysreg_ns_read(void *opaque, hwaddr addr, ...@@ -1803,10 +1805,12 @@ static MemTxResult nvic_sysreg_ns_read(void *opaque, hwaddr addr,
uint64_t *data, unsigned size, uint64_t *data, unsigned size,
MemTxAttrs attrs) MemTxAttrs attrs)
{ {
MemoryRegion *mr = opaque;
if (attrs.secure) { if (attrs.secure) {
/* S accesses to the alias act like NS accesses to the real region */ /* S accesses to the alias act like NS accesses to the real region */
attrs.secure = 0; attrs.secure = 0;
return nvic_sysreg_read(opaque, addr, data, size, attrs); return memory_region_dispatch_read(mr, addr, data, size, attrs);
} else { } else {
/* NS attrs are RAZ/WI for privileged, and BusFault for user */ /* NS attrs are RAZ/WI for privileged, and BusFault for user */
if (attrs.user) { if (attrs.user) {
...@@ -2075,7 +2079,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp) ...@@ -2075,7 +2079,7 @@ static void armv7m_nvic_realize(DeviceState *dev, Error **errp)
if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) { if (arm_feature(&s->cpu->env, ARM_FEATURE_V8)) {
memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s), memory_region_init_io(&s->sysreg_ns_mem, OBJECT(s),
&nvic_sysreg_ns_ops, s, &nvic_sysreg_ns_ops, &s->sysregmem,
"nvic_sysregs_ns", 0x1000); "nvic_sysregs_ns", 0x1000);
memory_region_add_subregion(&s->container, 0x20000, &s->sysreg_ns_mem); memory_region_add_subregion(&s->container, 0x20000, &s->sysreg_ns_mem);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册