qemu-devel
[Top][All Lists]
Advanced

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

Re: [PATCH v3 1/2] hw/core/register: Add more 64-bit utilities


From: Alistair Francis
Subject: Re: [PATCH v3 1/2] hw/core/register: Add more 64-bit utilities
Date: Fri, 23 Jul 2021 15:12:14 +1000

On Wed, Jul 21, 2021 at 4:31 AM Joe Komlodi <joe.komlodi@xilinx.com> wrote:
>
> We already have some utilities to handle 64-bit wide registers, so this just
> adds some more for:
> - Initializing 64-bit registers
> - Extracting and depositing to an array of 64-bit registers
>
> Signed-off-by: Joe Komlodi <joe.komlodi@xilinx.com>

Reviewed-by: Alistair Francis <alistair.francis@wdc.com>

Alistair

> ---
>  hw/core/register.c          | 12 ++++++++++++
>  include/hw/register.h       |  8 ++++++++
>  include/hw/registerfields.h |  8 ++++++++
>  3 files changed, 28 insertions(+)
>
> diff --git a/hw/core/register.c b/hw/core/register.c
> index d6f8c20..95b0150 100644
> --- a/hw/core/register.c
> +++ b/hw/core/register.c
> @@ -300,6 +300,18 @@ RegisterInfoArray *register_init_block32(DeviceState 
> *owner,
>                                 data, ops, debug_enabled, memory_size, 32);
>  }
>
> +RegisterInfoArray *register_init_block64(DeviceState *owner,
> +                                         const RegisterAccessInfo *rae,
> +                                         int num, RegisterInfo *ri,
> +                                         uint64_t *data,
> +                                         const MemoryRegionOps *ops,
> +                                         bool debug_enabled,
> +                                         uint64_t memory_size)
> +{
> +    return register_init_block(owner, rae, num, ri, (void *)
> +                               data, ops, debug_enabled, memory_size, 64);
> +}
> +
>  void register_finalize_block(RegisterInfoArray *r_array)
>  {
>      object_unparent(OBJECT(&r_array->mem));
> diff --git a/include/hw/register.h b/include/hw/register.h
> index b480e38..6a076cf 100644
> --- a/include/hw/register.h
> +++ b/include/hw/register.h
> @@ -204,6 +204,14 @@ RegisterInfoArray *register_init_block32(DeviceState 
> *owner,
>                                           bool debug_enabled,
>                                           uint64_t memory_size);
>
> +RegisterInfoArray *register_init_block64(DeviceState *owner,
> +                                         const RegisterAccessInfo *rae,
> +                                         int num, RegisterInfo *ri,
> +                                         uint64_t *data,
> +                                         const MemoryRegionOps *ops,
> +                                         bool debug_enabled,
> +                                         uint64_t memory_size);
> +
>  /**
>   * This function should be called to cleanup the registers that were 
> initialized
>   * when calling register_init_block32(). This function should only be called
> diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
> index 93fa4a8..9a03ac5 100644
> --- a/include/hw/registerfields.h
> +++ b/include/hw/registerfields.h
> @@ -30,6 +30,10 @@
>      enum { A_ ## reg = (addr) };                                          \
>      enum { R_ ## reg = (addr) / 2 };
>
> +#define REG64(reg, addr)                                                  \
> +    enum { A_ ## reg = (addr) };                                          \
> +    enum { R_ ## reg = (addr) / 8 };
> +
>  /* Define SHIFT, LENGTH and MASK constants for a field within a register */
>
>  /* This macro will define R_FOO_BAR_MASK, R_FOO_BAR_SHIFT and 
> R_FOO_BAR_LENGTH
> @@ -58,6 +62,8 @@
>  /* Extract a field from an array of registers */
>  #define ARRAY_FIELD_EX32(regs, reg, field)                                \
>      FIELD_EX32((regs)[R_ ## reg], reg, field)
> +#define ARRAY_FIELD_EX64(regs, reg, field)                                \
> +    FIELD_EX64((regs)[R_ ## reg], reg, field)
>
>  /* Deposit a register field.
>   * Assigning values larger then the target field will result in
> @@ -99,5 +105,7 @@
>  /* Deposit a field to array of registers.  */
>  #define ARRAY_FIELD_DP32(regs, reg, field, val)                           \
>      (regs)[R_ ## reg] = FIELD_DP32((regs)[R_ ## reg], reg, field, val);
> +#define ARRAY_FIELD_DP64(regs, reg, field, val)                           \
> +    (regs)[R_ ## reg] = FIELD_DP64((regs)[R_ ## reg], reg, field, val);
>
>  #endif
> --
> 2.7.4
>



reply via email to

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