mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-09 02:24:58 -06:00
hw/misc/tz-ppc: Support having unused ports in the middle of the range
The Peripheral Protection Controller's handling of unused ports is that if there is nothing connected to the port's downstream then it does not create the sysbus MMIO region for the upstream end of the port. This results in odd behaviour when there is an unused port in the middle of the range: since sysbus MMIO regions are implicitly consecutively allocated, any used ports above the unused ones end up with sysbus MMIO region numbers that don't match the port number. Avoid this numbering mismatch by creating dummy MMIO regions for the unused ports. This doesn't change anything for our existing boards, which don't have any gaps in the middle of the port ranges they use; but it will be needed for the Musca board. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
parent
6c1f6f2733
commit
37e571f1e0
2 changed files with 39 additions and 1 deletions
|
@ -181,6 +181,21 @@ static const MemoryRegionOps tz_ppc_ops = {
|
|||
.endianness = DEVICE_LITTLE_ENDIAN,
|
||||
};
|
||||
|
||||
static bool tz_ppc_dummy_accepts(void *opaque, hwaddr addr,
|
||||
unsigned size, bool is_write,
|
||||
MemTxAttrs attrs)
|
||||
{
|
||||
/*
|
||||
* Board code should never map the upstream end of an unused port,
|
||||
* so we should never try to make a memory access to it.
|
||||
*/
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
static const MemoryRegionOps tz_ppc_dummy_ops = {
|
||||
.valid.accepts = tz_ppc_dummy_accepts,
|
||||
};
|
||||
|
||||
static void tz_ppc_reset(DeviceState *dev)
|
||||
{
|
||||
TZPPC *s = TZ_PPC(dev);
|
||||
|
@ -210,16 +225,33 @@ static void tz_ppc_realize(DeviceState *dev, Error **errp)
|
|||
SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
|
||||
TZPPC *s = TZ_PPC(dev);
|
||||
int i;
|
||||
int max_port = 0;
|
||||
|
||||
/* We can't create the upstream end of the port until realize,
|
||||
* as we don't know the size of the MR used as the downstream until then.
|
||||
*/
|
||||
for (i = 0; i < TZ_NUM_PORTS; i++) {
|
||||
if (s->port[i].downstream) {
|
||||
max_port = i;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i <= max_port; i++) {
|
||||
TZPPCPort *port = &s->port[i];
|
||||
char *name;
|
||||
uint64_t size;
|
||||
|
||||
if (!port->downstream) {
|
||||
/*
|
||||
* Create dummy sysbus MMIO region so the sysbus region
|
||||
* numbering doesn't get out of sync with the port numbers.
|
||||
* The size is entirely arbitrary.
|
||||
*/
|
||||
name = g_strdup_printf("tz-ppc-dummy-port[%d]", i);
|
||||
memory_region_init_io(&port->upstream, obj, &tz_ppc_dummy_ops,
|
||||
port, name, 0x10000);
|
||||
sysbus_init_mmio(sbd, &port->upstream);
|
||||
g_free(name);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue