From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Peng Hao <peng.hao2@zte.com.cn>,
QEMU Developers <qemu-devel@nongnu.org>,
Wen Congyang <wency@cn.fujitsu.com>,
Hu Tao <hutao@cn.fujitsu.com>
Subject: Re: [Qemu-devel] [PATCH v3 3/4] hw/misc/pvpanic: Add the MMIO interface
Date: Thu, 18 Oct 2018 15:19:15 +0200 [thread overview]
Message-ID: <a11adc0b-4737-f270-0cd1-1390239c00a5@redhat.com> (raw)
In-Reply-To: <CAFEAcA-p21K3nbCUL0Hi=cBhqpPmQaHUXrUpEFuWFL+thgJoSg@mail.gmail.com>
On 18/10/2018 15:08, Peter Maydell wrote:
> On 18 October 2018 at 14:04, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>> Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> [PMD: Use TYPE_PVPANIC definition, split in 2 patches]
>> ---
>> Peng: I hope this is now more obvious how you could reuse the pvpanic device.
>>
>> hw/misc/pvpanic.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 51 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/misc/pvpanic.c b/hw/misc/pvpanic.c
>> index 4f552e1533..b81c5fa633 100644
>> --- a/hw/misc/pvpanic.c
>> +++ b/hw/misc/pvpanic.c
>> @@ -2,10 +2,12 @@
>> * QEMU simulated pvpanic device.
>> *
>> * Copyright Fujitsu, Corp. 2013
>> + * Copyright (c) 2018 ZTE Ltd.
>> *
>> * Authors:
>> * Wen Congyang <wency@cn.fujitsu.com>
>> * Hu Tao <hutao@cn.fujitsu.com>
>> + * Peng Hao <peng.hao2@zte.com.cn>
>> *
>> * This work is licensed under the terms of the GNU GPL, version 2 or later.
>> * See the COPYING file in the top-level directory.
>> @@ -47,7 +49,10 @@ static void handle_event(int event)
>>
>> typedef struct PVPanicState {
>> /*< private >*/
>> - ISADevice isadev;
>> + union {
>> + ISADevice isadev;
>> + SysBusDevice busdev;
>> + };
>
> This field is the parent-type for the QOM object, so I don't
> think it makes sense for it to be a union. Any one QOM object
> should have a single distinct parent type. (There are other
> examples of "some more or less similar device has ISA and
> SysBus or PCI and SysBus variations" which should provide
> some models to copy from.
OK, I understand as I can use "Device parent_obj" instead of that union?
But then we want:
pvpanic_isa_info.instance_size =
sizeof(PVPanic_Common_State) + sizeof(ISADevice)
pvpanic_mmio_info.instance_size =
sizeof(PVPanic_Common_State) + sizeof(SysBusDevice)
So to avoid union, I have to use:
typedef struct PVPanicCommonState {
MemoryRegion mr;
uint16_t ioport;
} PVPanicCommonState;
typedef struct PVPanicISAState {
/*< private >*/
ISADevice isadev;
/*< public >*/
PVPanicCommonState common;
} PVPanicISAState;
#define PVPANIC_ISA(obj) \
OBJECT_CHECK(PVPanicISAState, (obj), TYPE_PVPANIC)
typedef struct PVPanicMMIOState {
/*< private >*/
SysBusDevice busdev;
/*< public >*/
PVPanicCommonState common;
} PVPanicMMIOState;
#define PVPANIC_MMIO(obj) \
OBJECT_CHECK(PVPanicMMIOState, (obj), TYPE_PVPANIC)
And later:
-->8--
@@ -92,3 +104,3 @@ static void pvpanic_isa_realizefn(DeviceState *dev,
Error **errp)
ISADevice *d = ISA_DEVICE(dev);
- PVPanicState *s = PVPANIC(dev);
+ PVPanicState *s = PVPANIC_ISA(dev);
FWCfgState *fw_cfg = fw_cfg_find();
@@ -125,3 +137,3 @@ static TypeInfo pvpanic_isa_info = {
.parent = TYPE_ISA_DEVICE,
- .instance_size = sizeof(PVPanicState),
+ .instance_size = sizeof(PVPanicISAState),
.instance_init = pvpanic_isa_initfn,
@@ -151,3 +163,3 @@ static void pvpanic_mmio_initfn(Object *obj)
{
- PVPanicState *s = PVPANIC(obj);
+ PVPanicState *s = PVPANIC_MMIO(obj);
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
@@ -169,3 +181,3 @@ static TypeInfo pvpanic_mmio_info = {
.parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(PVPanicState),
+ .instance_size = sizeof(PVPanicMMIOState),
.instance_init = pvpanic_mmio_initfn,
---
Am I correct?
Thanks,
Phil.
next prev parent reply other threads:[~2018-10-18 13:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-18 13:04 [Qemu-devel] [PATCH v3 0/4] hw/misc: Add a MMIO interface to the pvpanic device Philippe Mathieu-Daudé
2018-10-18 13:04 ` [Qemu-devel] [PATCH v3 1/4] hw/misc/pvpanic: Build the pvpanic device in $(common-obj) Philippe Mathieu-Daudé
2018-10-18 13:04 ` [Qemu-devel] [PATCH v3 2/4] hw/misc/pvpanic: Cosmetic renaming Philippe Mathieu-Daudé
2018-10-18 13:04 ` [Qemu-devel] [PATCH v3 3/4] hw/misc/pvpanic: Add the MMIO interface Philippe Mathieu-Daudé
2018-10-18 13:08 ` Peter Maydell
2018-10-18 13:19 ` Philippe Mathieu-Daudé [this message]
2018-10-18 13:27 ` Peter Maydell
2018-10-18 16:13 ` peng.hao2
2018-10-18 13:04 ` [Qemu-devel] [PATCH v3 4/4] hw/arm/virt: Use the pvpanic device Philippe Mathieu-Daudé
2018-10-18 13:37 ` Peter Maydell
2018-10-18 16:07 ` peng.hao2
2018-10-18 13:09 ` [Qemu-devel] [PATCH v3 0/4] hw/misc: Add a MMIO interface to " Philippe Mathieu-Daudé
2018-10-25 5:47 ` [Qemu-devel] [PATCH v3 0/4] hw/misc: Add a MMIO interface to the pvpanicdevice peng.hao2
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=a11adc0b-4737-f270-0cd1-1390239c00a5@redhat.com \
--to=philmd@redhat.com \
--cc=hutao@cn.fujitsu.com \
--cc=peng.hao2@zte.com.cn \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=wency@cn.fujitsu.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).