提交 538ddf65 编写于 作者: P Peter Maydell

hw/mpcore: Clean up mpcore_priv_read/write as they are now SCU only

The only code left in mpcore_priv_read and mpcore_priv_write is now
the implementation of the SCU registers. Clean up by renaming functions
and removing some unnecessary conditionals to make this clearer.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
上级 c3ffa595
...@@ -36,59 +36,49 @@ typedef struct mpcore_priv_state { ...@@ -36,59 +36,49 @@ typedef struct mpcore_priv_state {
/* Per-CPU private memory mapped IO. */ /* Per-CPU private memory mapped IO. */
static uint64_t mpcore_priv_read(void *opaque, target_phys_addr_t offset, static uint64_t mpcore_scu_read(void *opaque, target_phys_addr_t offset,
unsigned size) unsigned size)
{ {
mpcore_priv_state *s = (mpcore_priv_state *)opaque; mpcore_priv_state *s = (mpcore_priv_state *)opaque;
int id; int id;
offset &= 0xff; offset &= 0xff;
if (offset < 0x100) { /* SCU */
/* SCU */ switch (offset) {
switch (offset) { case 0x00: /* Control. */
case 0x00: /* Control. */ return s->scu_control;
return s->scu_control; case 0x04: /* Configuration. */
case 0x04: /* Configuration. */ id = ((1 << s->num_cpu) - 1) << 4;
id = ((1 << s->num_cpu) - 1) << 4; return id | (s->num_cpu - 1);
return id | (s->num_cpu - 1); case 0x08: /* CPU status. */
case 0x08: /* CPU status. */ return 0;
return 0; case 0x0c: /* Invalidate all. */
case 0x0c: /* Invalidate all. */ return 0;
return 0; default:
default: hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset);
goto bad_reg;
}
} }
bad_reg:
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset);
return 0;
} }
static void mpcore_priv_write(void *opaque, target_phys_addr_t offset, static void mpcore_scu_write(void *opaque, target_phys_addr_t offset,
uint64_t value, unsigned size) uint64_t value, unsigned size)
{ {
mpcore_priv_state *s = (mpcore_priv_state *)opaque; mpcore_priv_state *s = (mpcore_priv_state *)opaque;
offset &= 0xff; offset &= 0xff;
if (offset < 0x100) { /* SCU */
/* SCU */ switch (offset) {
switch (offset) { case 0: /* Control register. */
case 0: /* Control register. */ s->scu_control = value & 1;
s->scu_control = value & 1; break;
break; case 0x0c: /* Invalidate all. */
case 0x0c: /* Invalidate all. */ /* This is a no-op as cache is not emulated. */
/* This is a no-op as cache is not emulated. */ break;
break; default:
default: hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset);
goto bad_reg;
}
} }
return;
bad_reg:
hw_error("mpcore_priv_read: Bad offset %x\n", (int)offset);
} }
static const MemoryRegionOps mpcore_priv_ops = { static const MemoryRegionOps mpcore_scu_ops = {
.read = mpcore_priv_read, .read = mpcore_scu_read,
.write = mpcore_priv_write, .write = mpcore_scu_write,
.endianness = DEVICE_NATIVE_ENDIAN, .endianness = DEVICE_NATIVE_ENDIAN,
}; };
...@@ -106,8 +96,7 @@ static void mpcore_priv_map_setup(mpcore_priv_state *s) ...@@ -106,8 +96,7 @@ static void mpcore_priv_map_setup(mpcore_priv_state *s)
int i; int i;
SysBusDevice *busdev = sysbus_from_qdev(s->mptimer); SysBusDevice *busdev = sysbus_from_qdev(s->mptimer);
memory_region_init(&s->container, "mpcode-priv-container", 0x2000); memory_region_init(&s->container, "mpcode-priv-container", 0x2000);
memory_region_init_io(&s->iomem, &mpcore_priv_ops, s, "mpcode-priv", memory_region_init_io(&s->iomem, &mpcore_scu_ops, s, "mpcore-scu", 0x100);
0x100);
memory_region_add_subregion(&s->container, 0, &s->iomem); memory_region_add_subregion(&s->container, 0, &s->iomem);
/* GIC CPU interfaces: "current CPU" at 0x100, then specific CPUs /* GIC CPU interfaces: "current CPU" at 0x100, then specific CPUs
* at 0x200, 0x300... * at 0x200, 0x300...
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册