qemu-arm
[Top][All Lists]
Advanced

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

Re: [PATCH 23/44] Add GENET register structs. Part 1


From: Peter Maydell
Subject: Re: [PATCH 23/44] Add GENET register structs. Part 1
Date: Fri, 4 Aug 2023 15:48:26 +0100

On Wed, 26 Jul 2023 at 14:44, Sergey Kambalin <serg.oker@gmail.com> wrote:
>
> Signed-off-by: Sergey Kambalin <sergey.kambalin@auriga.com>
> ---
>  include/hw/net/bcm2838_genet.h | 125 ++++++++++++++++++++++++++++++++-
>  1 file changed, 124 insertions(+), 1 deletion(-)
>
> diff --git a/include/hw/net/bcm2838_genet.h b/include/hw/net/bcm2838_genet.h
> index f62b24fa2f..89b45eb39f 100644
> --- a/include/hw/net/bcm2838_genet.h
> +++ b/include/hw/net/bcm2838_genet.h
> @@ -18,8 +18,131 @@ OBJECT_DECLARE_SIMPLE_TYPE(BCM2838GenetState, 
> BCM2838_GENET)
>  #define BCM2838_GENET_REV_MAJOR         6
>  #define BCM2838_GENET_REV_MINOR         0
>
> +typedef union {
> +    uint32_t value;
> +    struct {
> +        uint32_t gphy_rev:16;
> +        uint32_t minor_rev:4;
> +        uint32_t reserved_20_23:4;
> +        uint32_t major_rev:4;
> +        uint32_t reserved_28_31:4;
> +    } fields;

Don't try to use bitfields to represent guest register layout
or in-memory data, please -- it's not portable or endian safe.

> +} BCM2838GenetSysRevCtrl;

> +typedef struct {
> +    BCM2838GenetSysRevCtrl rev_ctrl;
> +    uint32_t port_ctrl;
> +    uint32_t rbuf_flush_ctrl;
> +    uint32_t tbuf_flush_ctrl;
> +    uint8_t reserved_0x10[0x30];
> +} __attribute__((__packed__)) BCM2838GenetRegsSys;

Better not to use packed structs for that either.

thanks
-- PMM



reply via email to

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