mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 08:43:55 -06:00
hw/mips/itu: Pass SAAR using QOM link property
QOM objects shouldn't access each other internals fields except using the QOM API. mips_cps_realize() instantiates a TYPE_MIPS_ITU object, and directly sets the 'saar' pointer: if (saar_present) { s->itu.saar = &env->CP0_SAAR; } In order to avoid that, pass the MIPS_CPU object via a QOM link property, and set the 'saar' pointer in mips_itu_realize(). Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Message-Id: <20230203113650.78146-10-philmd@linaro.org>
This commit is contained in:
parent
10997f2d1d
commit
4c921e3fb2
3 changed files with 26 additions and 28 deletions
|
@ -66,20 +66,17 @@ static bool cpu_mips_itu_supported(CPUMIPSState *env)
|
|||
static void mips_cps_realize(DeviceState *dev, Error **errp)
|
||||
{
|
||||
MIPSCPSState *s = MIPS_CPS(dev);
|
||||
CPUMIPSState *env;
|
||||
MIPSCPU *cpu;
|
||||
int i;
|
||||
target_ulong gcr_base;
|
||||
bool itu_present = false;
|
||||
bool saar_present = false;
|
||||
|
||||
if (!clock_get(s->clock)) {
|
||||
error_setg(errp, "CPS input clock is not connected to an output clock");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < s->num_vp; i++) {
|
||||
cpu = MIPS_CPU(object_new(s->cpu_type));
|
||||
for (int i = 0; i < s->num_vp; i++) {
|
||||
MIPSCPU *cpu = MIPS_CPU(object_new(s->cpu_type));
|
||||
CPUMIPSState *env = &cpu->env;
|
||||
|
||||
/* All VPs are halted on reset. Leave powering up to CPC. */
|
||||
if (!object_property_set_bool(OBJECT(cpu), "start-powered-off", true,
|
||||
|
@ -97,7 +94,6 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
|
|||
cpu_mips_irq_init_cpu(cpu);
|
||||
cpu_mips_clock_init(cpu);
|
||||
|
||||
env = &cpu->env;
|
||||
if (cpu_mips_itu_supported(env)) {
|
||||
itu_present = true;
|
||||
/* Attach ITC Tag to the VP */
|
||||
|
@ -107,22 +103,15 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
|
|||
qemu_register_reset(main_cpu_reset, cpu);
|
||||
}
|
||||
|
||||
cpu = MIPS_CPU(first_cpu);
|
||||
env = &cpu->env;
|
||||
saar_present = (bool)env->saarp;
|
||||
|
||||
/* Inter-Thread Communication Unit */
|
||||
if (itu_present) {
|
||||
object_initialize_child(OBJECT(dev), "itu", &s->itu, TYPE_MIPS_ITU);
|
||||
object_property_set_link(OBJECT(&s->itu), "cpu[0]",
|
||||
OBJECT(first_cpu), &error_abort);
|
||||
object_property_set_uint(OBJECT(&s->itu), "num-fifo", 16,
|
||||
&error_abort);
|
||||
object_property_set_uint(OBJECT(&s->itu), "num-semaphores", 16,
|
||||
&error_abort);
|
||||
object_property_set_bool(OBJECT(&s->itu), "saar-present", saar_present,
|
||||
&error_abort);
|
||||
if (saar_present) {
|
||||
s->itu.saar = &env->CP0_SAAR;
|
||||
}
|
||||
if (!sysbus_realize(SYS_BUS_DEVICE(&s->itu), errp)) {
|
||||
return;
|
||||
}
|
||||
|
@ -158,7 +147,7 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
|
|||
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->gic), 0));
|
||||
|
||||
/* Global Configuration Registers */
|
||||
gcr_base = env->CP0_CMGCRBase << 4;
|
||||
gcr_base = MIPS_CPU(first_cpu)->env.CP0_CMGCRBase << 4;
|
||||
|
||||
object_initialize_child(OBJECT(dev), "gcr", &s->gcr, TYPE_MIPS_GCR);
|
||||
object_property_set_uint(OBJECT(&s->gcr), "num-vp", s->num_vp,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue