qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] hw/misc/mips_itu: Make MIPSITUState target agnostic


From: Richard Henderson
Subject: Re: [PATCH] hw/misc/mips_itu: Make MIPSITUState target agnostic
Date: Tue, 19 Sep 2023 08:41:54 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1

On 9/18/23 09:30, Philippe Mathieu-Daudé wrote:
@@ -530,9 +530,12 @@ static void mips_itu_realize(DeviceState *dev, Error 
**errp)
      if (!s->cpu0) {
          error_setg(errp, "Missing 'cpu[0]' property");
          return;
+    } else if (!object_dynamic_cast(OBJECT(s->cpu0), TYPE_MIPS_CPU)) {
+        error_setg(errp, "MIPS ITU expects a MIPS CPU");
+        return;
      }
- env = &s->cpu0->env;
+    env = &MIPS_CPU(s->cpu0)->env;
      if (env->saarp) {
          s->saar = env->CP0_SAAR;
      }...
@@ -563,7 +566,7 @@ static Property mips_itu_properties[] = {
                       ITC_FIFO_NUM_MAX),
     DEFINE_PROP_UINT32("num-semaphores", MIPSITUState, num_semaphores,
                       ITC_SEMAPH_NUM_MAX),
-    DEFINE_PROP_LINK("cpu[0]", MIPSITUState, cpu0, TYPE_MIPS_CPU, MIPSCPU *),
+    DEFINE_PROP_LINK("cpu[0]", MIPSITUState, cpu0, TYPE_CPU, CPUState *),
     DEFINE_PROP_END_OF_LIST(),

I think you want to keep TYPE_MIPS_CPU here. If you do that, I believe you could remove the dynamic_cast check above and let the MIPS_CPU macro assert, because the link cannot be set with an incorrect type.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]