qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v8 6/8] register: Add block initialise helper


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH v8 6/8] register: Add block initialise helper
Date: Mon, 27 Jun 2016 15:31:15 +0100

On 24 June 2016 at 16:42, Alistair Francis <address@hidden> wrote:
> From: Peter Crosthwaite <address@hidden>
>
> Add a helper that will scan a static RegisterAccessInfo Array
> and populate a container MemoryRegion with registers as defined.
>
> Signed-off-by: Peter Crosthwaite <address@hidden>
> Signed-off-by: Alistair Francis <address@hidden>
> ---

> --- a/hw/core/register.c
> +++ b/hw/core/register.c
> @@ -228,6 +228,50 @@ uint64_t register_read_memory(void *opaque, hwaddr addr,
>      return extract64(read_val, 0, size * 8);
>  }
>
> +RegisterInfoArray *register_init_block32(DeviceState *owner,
> +                                         const RegisterAccessInfo *rae,
> +                                         int num, RegisterInfo *ri,
> +                                         uint32_t *data,
> +                                         const MemoryRegionOps *ops,
> +                                         bool debug_enabled,
> +                                         uint64_t memory_size)
> +{
> +    const char *device_prefix = object_get_typename(OBJECT(owner));
> +    RegisterInfoArray *r_array = g_new0(RegisterInfoArray, 1);
> +    int i;
> +
> +    r_array->r = g_new0(RegisterInfo *, num);
> +    r_array->num_elements = num;
> +    r_array->debug = debug_enabled;
> +    r_array->prefix = device_prefix;
> +
> +    for (i = 0; i < num; i++) {
> +        int index = rae[i].addr / 4;
> +        RegisterInfo *r = &ri[index];
> +
> +        *r = (RegisterInfo) {
> +            .data = &data[index],
> +            .data_size = sizeof(uint32_t),
> +            .access = &rae[i],
> +            .opaque = owner,
> +        };
> +        register_init(r);
> +
> +        r_array->r[i] = r;
> +    }
> +
> +    memory_region_init_io(&r_array->mem, OBJECT(owner), ops, r_array,
> +                          device_prefix, memory_size);
> +
> +    return r_array;
> +}
> +
> +void register_finlise_block(RegisterInfoArray *r_array)

"finalize" (typo, and we prefer the -z- spelling in APIs.)

> +/**
> + * This function should be called to cleanup the registers that were 
> initialized
> + * when calling register_init_block32()
> + *
> + * @r_array: An structure containing all of the registers. The caller is in
> + *           charge of cleaning up the memory region (r_array->mem).

What cleanup does the memory region require?

> + */
> +
> +void register_finlise_block(RegisterInfoArray *r_array);
> +
>  /* Define constants for a 32 bit register */
>
>  /* This macro will define A_FOO, for the byte address of a register

thanks
-- PMM



reply via email to

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