Re: [PATCH v2 03/12] hw/arm/raspi: Unify RASPI_MACHINE types

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

 



On Tue, 4 Feb 2025 at 00:23, Philippe Mathieu-Daudé <philmd@xxxxxxxxxx> wrote:
>
> Merge Raspi4bMachineState within RaspiMachineState by
> using an unnamed union.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
> ---
>  hw/arm/raspi.c | 21 +++++++--------------
>  1 file changed, 7 insertions(+), 14 deletions(-)
>
> diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
> index 3fa382d62ce..ef94d57dab5 100644
> --- a/hw/arm/raspi.c
> +++ b/hw/arm/raspi.c
> @@ -38,9 +38,6 @@
>  #define TYPE_RASPI_MACHINE  MACHINE_TYPE_NAME("raspi-common")
>  OBJECT_DECLARE_SIMPLE_TYPE(RaspiMachineState, RASPI_MACHINE)
>
> -#define TYPE_RASPI4B_MACHINE MACHINE_TYPE_NAME("raspi4b")
> -OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
> -
>  #define SMPBOOT_ADDR    0x300 /* this should leave enough space for ATAGS */
>  #define MVBAR_ADDR      0x400 /* secure vectors */
>  #define BOARDSETUP_ADDR (MVBAR_ADDR + 0x20) /* board setup code */
> @@ -49,15 +46,12 @@ OBJECT_DECLARE_SIMPLE_TYPE(Raspi4bMachineState, RASPI4B_MACHINE)
>  #define SPINTABLE_ADDR  0xd8 /* Pi 3 bootloader spintable */
>
>  struct RaspiMachineState {
> -    /*< private >*/
>      RaspiBaseMachineState parent_obj;
> -    /*< public >*/
> -    BCM283XState soc;
> -};
>
> -struct Raspi4bMachineState {
> -    RaspiBaseMachineState parent_obj;
> -    BCM2838State soc;
> +    union {
> +        BCM283XState soc;
> +        BCM2838State soc4;
> +    };

Do we have any other examples of using a union like this?
I think it's exactly because the components are different
for raspi4b that it has its own machine state struct.

thanks
-- PMM




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux