hw/misc/iotkit-secctl.c: Implement SSE-300 PID register values

The versions of the Secure Access Configuration Register Block
and Non-secure Access Configuration Register Block in the SSE-300
are the same as those in the SSE-200, but the CIDR/PIDR ID
register values are different.

Plumb through the sse-version property and use it to select
the correct ID register values.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-id: 20210219144617.4782-8-peter.maydell@linaro.org
This commit is contained in:
Peter Maydell 2021-02-19 14:45:40 +00:00
parent 1cbd6fe4b8
commit 0eb6b0ad16
3 changed files with 52 additions and 2 deletions

View File

@ -654,6 +654,8 @@ static void armsse_realize(DeviceState *dev, Error **errp)
}
/* Security controller */
object_property_set_int(OBJECT(&s->secctl), "sse-version",
info->sse_version, &error_abort);
if (!sysbus_realize(SYS_BUS_DEVICE(&s->secctl), errp)) {
return;
}

View File

@ -19,6 +19,8 @@
#include "hw/registerfields.h"
#include "hw/irq.h"
#include "hw/misc/iotkit-secctl.h"
#include "hw/arm/armsse-version.h"
#include "hw/qdev-properties.h"
/* Registers in the secure privilege control block */
REG32(SECRESPCFG, 0x10)
@ -95,6 +97,19 @@ static const uint8_t iotkit_secctl_ns_idregs[] = {
0x0d, 0xf0, 0x05, 0xb1,
};
static const uint8_t iotkit_secctl_s_sse300_idregs[] = {
0x04, 0x00, 0x00, 0x00,
0x52, 0xb8, 0x2b, 0x00,
0x0d, 0xf0, 0x05, 0xb1,
};
static const uint8_t iotkit_secctl_ns_sse300_idregs[] = {
0x04, 0x00, 0x00, 0x00,
0x53, 0xb8, 0x2b, 0x00,
0x0d, 0xf0, 0x05, 0xb1,
};
/* The register sets for the various PPCs (AHB internal, APB internal,
* AHB expansion, APB expansion) are all set up so that they are
* in 16-aligned blocks so offsets 0xN0, 0xN4, 0xN8, 0xNC are PPCs
@ -213,7 +228,14 @@ static MemTxResult iotkit_secctl_s_read(void *opaque, hwaddr addr,
case A_CID1:
case A_CID2:
case A_CID3:
r = iotkit_secctl_s_idregs[(offset - A_PID4) / 4];
switch (s->sse_version) {
case ARMSSE_SSE300:
r = iotkit_secctl_s_sse300_idregs[(offset - A_PID4) / 4];
break;
default:
r = iotkit_secctl_s_idregs[(offset - A_PID4) / 4];
break;
}
break;
case A_SECPPCINTCLR:
case A_SECMSCINTCLR:
@ -473,7 +495,14 @@ static MemTxResult iotkit_secctl_ns_read(void *opaque, hwaddr addr,
case A_CID1:
case A_CID2:
case A_CID3:
r = iotkit_secctl_ns_idregs[(offset - A_PID4) / 4];
switch (s->sse_version) {
case ARMSSE_SSE300:
r = iotkit_secctl_ns_sse300_idregs[(offset - A_PID4) / 4];
break;
default:
r = iotkit_secctl_ns_idregs[(offset - A_PID4) / 4];
break;
}
break;
default:
qemu_log_mask(LOG_GUEST_ERROR,
@ -710,6 +739,16 @@ static void iotkit_secctl_init(Object *obj)
sysbus_init_mmio(sbd, &s->ns_regs);
}
static void iotkit_secctl_realize(DeviceState *dev, Error **errp)
{
IoTKitSecCtl *s = IOTKIT_SECCTL(dev);
if (!armsse_version_valid(s->sse_version)) {
error_setg(errp, "invalid sse-version value %d", s->sse_version);
return;
}
}
static const VMStateDescription iotkit_secctl_ppc_vmstate = {
.name = "iotkit-secctl-ppc",
.version_id = 1,
@ -775,12 +814,19 @@ static const VMStateDescription iotkit_secctl_vmstate = {
},
};
static Property iotkit_secctl_props[] = {
DEFINE_PROP_UINT32("sse-version", IoTKitSecCtl, sse_version, 0),
DEFINE_PROP_END_OF_LIST()
};
static void iotkit_secctl_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
dc->vmsd = &iotkit_secctl_vmstate;
dc->reset = iotkit_secctl_reset;
dc->realize = iotkit_secctl_realize;
device_class_set_props(dc, iotkit_secctl_props);
}
static const TypeInfo iotkit_secctl_info = {

View File

@ -120,6 +120,8 @@ struct IoTKitSecCtl {
IoTKitSecCtlPPC apb[IOTS_NUM_APB_PPC];
IoTKitSecCtlPPC apbexp[IOTS_NUM_APB_EXP_PPC];
IoTKitSecCtlPPC ahbexp[IOTS_NUM_APB_EXP_PPC];
uint32_t sse_version;
};
#endif