From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Daniel P . Berrange" <berrange@redhat.com>,
"Cédric Le Goater" <clg@kaod.org>,
"Taylor Simpson" <ltaylorsimpson@gmail.com>,
"Edgar E . Iglesias" <edgar.iglesias@gmail.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Jim Shu" <jim.shu@sifive.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Markus Armbruster" <armbru@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Richard Henderson" <richard.henderson@linaro.org>,
"LIU Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Alessandro Di Federico" <ale@rev.ng>,
"Dr . David Alan Gilbert" <dave@treblig.org>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Bernhard Beschow" <shentey@gmail.com>,
"Luc Michel" <luc@lmichel.fr>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Mark Burton" <mburton@qti.qualcomm.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Anton Johansson" <anjo@rev.ng>
Subject: [PATCH] hw/misc/mips_itu: Make MIPSITUState target agnostic
Date: Mon, 18 Sep 2023 09:30:23 +0200 [thread overview]
Message-ID: <20230918073023.3846-1-philmd@linaro.org> (raw)
When prototyping a heterogenous machine including the ITU,
we get:
include/hw/misc/mips_itu.h:76:5: error: unknown type name 'MIPSCPU'
MIPSCPU *cpu0;
^
MIPSCPU is declared in the target specific "cpu.h" header,
but we don't want to include it, because "cpu.h" is target
specific and its inclusion taints all files including
"mips_itu.h", which become target specific too.
Avoid that by using the common CPUState structure. Add an
extra QOM check to ensure the CPU is of type MIPS.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
RFC:
ITU isn't relevant for the heterogeneous machines we are
interested to model, but I wanted something relatively easy
to start the discussion.
I'm not really happy about this because we lose the QOM type
check on the linked ArchCPU (thus I had to add it manually in
the device realize() handler). But I guess this is the compromise
we have to accept to include headers declaring target-specific
devices in a heterogeneous container.
---
include/hw/misc/mips_itu.h | 2 +-
hw/misc/mips_itu.c | 7 +++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/include/hw/misc/mips_itu.h b/include/hw/misc/mips_itu.h
index 35218b2d14..7917524987 100644
--- a/include/hw/misc/mips_itu.h
+++ b/include/hw/misc/mips_itu.h
@@ -73,7 +73,7 @@ struct MIPSITUState {
/* SAAR */
uint64_t *saar;
- MIPSCPU *cpu0;
+ CPUState *cpu0;
};
/* Get ITC Configuration Tag memory region. */
diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c
index 0eda302db4..2b46b132fb 100644
--- a/hw/misc/mips_itu.c
+++ b/hw/misc/mips_itu.c
@@ -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(),
};
--
2.41.0
next reply other threads:[~2023-09-18 7:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-18 7:30 Philippe Mathieu-Daudé [this message]
2023-09-19 6:41 ` [PATCH] hw/misc/mips_itu: Make MIPSITUState target agnostic Richard Henderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230918073023.3846-1-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=ale@rev.ng \
--cc=alex.bennee@linaro.org \
--cc=alistair@alistair23.me \
--cc=anjo@rev.ng \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@kaod.org \
--cc=dave@treblig.org \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=jiaxun.yang@flygoat.com \
--cc=jim.shu@sifive.com \
--cc=ltaylorsimpson@gmail.com \
--cc=luc@lmichel.fr \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mburton@qti.qualcomm.com \
--cc=paul.walmsley@sifive.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=shentey@gmail.com \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).