qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v3 3/4] hw/misc/pvpanic: Add the MMIO interface


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v3 3/4] hw/misc/pvpanic: Add the MMIO interface
Date: Thu, 18 Oct 2018 14:27:33 +0100

On 18 October 2018 at 14:19, Philippe Mathieu-Daudé <address@hidden> wrote:
> On 18/10/2018 15:08, Peter Maydell wrote:
>> 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.

> 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)
>

Something like that, I think. Basically you have two
distinct types, an ISA PVPanic and a SysBus PVPanic,
which have straightforward inheritance (the ISA PVPanic
is-a ISADevice, the SysBus PVPanic is-a SysBusdevice).
Both have-a PVPanic common state.

See eg hw/display/sm501.c, or hw/net/ne2000{,-isa}.c.

thanks
-- PMM



reply via email to

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