From: "Alex Bennée" <alex.bennee@linaro.org>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: edgar.iglesias@xilinx.com, peter.maydell@linaro.org,
qemu-devel@nongnu.org, crosthwaitepeter@gmail.com,
edgar.iglesias@gmail.com, afaerber@suse.de,
fred.konrad@greensocs.com
Subject: Re: [Qemu-devel] [PATCH v3 07/16] register: Add block initialise helper
Date: Tue, 09 Feb 2016 16:12:30 +0000 [thread overview]
Message-ID: <87a8n9x3pt.fsf@linaro.org> (raw)
In-Reply-To: <31e7c7dfd48ae5221f9459c16324a0bcd5660a04.1454115217.git.alistair.francis@xilinx.com>
Alistair Francis <alistair.francis@xilinx.com> writes:
> From: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>
> Add a helper that will scan a static RegisterAccessInfo Array
> and populate a container MemoryRegion with registers as defined.
>
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> Signed-off-by: Alistair Francis <alistair.francis@xilinx.com>
> ---
> V3:
> - Fix typo
> V2:
> - Use memory_region_add_subregion_no_print()
>
> hw/core/register.c | 29 +++++++++++++++++++++++++++++
> include/hw/register.h | 20 ++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
> diff --git a/hw/core/register.c b/hw/core/register.c
> index 939f398..4d7dd95 100644
> --- a/hw/core/register.c
> +++ b/hw/core/register.c
> @@ -258,6 +258,35 @@ uint64_t register_read_memory_le(void *opaque, hwaddr addr, unsigned size)
> return register_read_memory(opaque, addr, size, false);
> }
>
> +void register_init_block32(DeviceState *owner, const RegisterAccessInfo *rae,
> + int num, RegisterInfo *ri, uint32_t *data,
> + MemoryRegion *container, const MemoryRegionOps *ops,
> + bool debug_enabled)
Are there going to be register_init_block8, 16 and 64 variants? Perhaps
this should be a generic register_block function that takes the size and
skip of the registers?
> +{
> + const char *debug_prefix = object_get_typename(OBJECT(owner));
> + int i;
> +
> + for (i = 0; i < num; i++) {
> + int index = rae[i].decode.addr / 4;
> + RegisterInfo *r = &ri[index];
> +
> + *r = (RegisterInfo) {
> + .data = &data[index],
> + .data_size = sizeof(uint32_t),
> + .access = &rae[i],
> + .debug = debug_enabled,
> + .prefix = debug_prefix,
> + .opaque = owner,
> + };
> + register_init(r);
> +
> + memory_region_init_io(&r->mem, OBJECT(owner), ops, r, r->access->name,
> + sizeof(uint32_t));
> + memory_region_add_subregion_no_print(container,
> + r->access->decode.addr,
> &r->mem);
Why a memory region for every register? Couldn't we have a shared region
for the whole block and handle dispatching in the register code?
> + }
> +}
> +
> static const TypeInfo register_info = {
> .name = TYPE_REGISTER,
> .parent = TYPE_DEVICE,
> diff --git a/include/hw/register.h b/include/hw/register.h
> index 3316458..30dedbf 100644
> --- a/include/hw/register.h
> +++ b/include/hw/register.h
> @@ -182,6 +182,26 @@ void register_write_memory_le(void *opaque, hwaddr addr, uint64_t value,
> uint64_t register_read_memory_be(void *opaque, hwaddr addr, unsigned size);
> uint64_t register_read_memory_le(void *opaque, hwaddr addr, unsigned size);
>
> +/**
> + * Init a block of consecutive registers into a container MemoryRegion. A
> + * number of constant register definitions are parsed to create a corresponding
> + * array of RegisterInfo's.
> + *
> + * @owner: device owning the registers
> + * @rae: Register definitions to init
> + * @num: number of registers to init (length of @rae)
> + * @ri: Register array to init
> + * @data: Array to use for register data
> + * @container: Memory region to contain new registers
> + * @ops: Memory region ops to access registers.
> + * @debug enabled: turn on/off verbose debug information
> + */
> +
> +void register_init_block32(DeviceState *owner, const RegisterAccessInfo *rae,
> + int num, RegisterInfo *ri, uint32_t *data,
> + MemoryRegion *container, const MemoryRegionOps *ops,
> + bool debug_enabled);
> +
> /* Define constants for a 32 bit register */
> #define REG32(reg, addr) \
> enum { A_ ## reg = (addr) }; \
--
Alex Bennée
next prev parent reply other threads:[~2016-02-09 16:12 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-01-30 1:00 [Qemu-devel] [PATCH v3 00/16] data-driven device registers Alistair Francis
2016-01-30 1:00 ` [Qemu-devel] [PATCH v3 01/16] memory: Allow subregions to not be printed by info mtree Alistair Francis
2016-01-30 1:00 ` [Qemu-devel] [PATCH v3 02/16] register: Add Register API Alistair Francis
2016-02-09 16:06 ` Alex Bennée
2016-02-09 19:35 ` Alistair Francis
2016-02-09 22:29 ` Peter Crosthwaite
2016-01-30 1:00 ` [Qemu-devel] [PATCH v3 03/16] register: Add Memory API glue Alistair Francis
2016-01-30 1:00 ` [Qemu-devel] [PATCH v3 04/16] register: Add support for decoding information Alistair Francis
2016-01-30 1:00 ` [Qemu-devel] [PATCH v3 05/16] register: Define REG and FIELD macros Alistair Francis
2016-01-30 1:00 ` [Qemu-devel] [PATCH v3 06/16] register: QOMify Alistair Francis
2016-02-09 11:49 ` Alex Bennée
2016-02-09 18:09 ` Alistair Francis
2016-01-30 1:00 ` [Qemu-devel] [PATCH v3 07/16] register: Add block initialise helper Alistair Francis
2016-02-09 16:12 ` Alex Bennée [this message]
2016-02-09 19:50 ` Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 08/16] bitops: Add ONES macro Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 09/16] dma: Add Xilinx Zynq devcfg device model Alistair Francis
2016-02-09 17:08 ` Alex Bennée
2016-02-09 21:47 ` Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 10/16] xilinx_zynq: add devcfg to machine model Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 11/16] qdev: Define qdev_get_gpio_out Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 12/16] qdev: Add qdev_pass_all_gpios API Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 13/16] irq: Add opaque setter routine Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 14/16] register: Add GPIO API Alistair Francis
2016-01-30 1:01 ` [Qemu-devel] [PATCH v3 15/16] misc: Introduce ZynqMP IOU SLCR Alistair Francis
2016-02-09 17:22 ` [Qemu-devel] [PATCH v3 00/16] data-driven device registers Alex Bennée
2016-02-09 21:56 ` Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a8n9x3pt.fsf@linaro.org \
--to=alex.bennee@linaro.org \
--cc=afaerber@suse.de \
--cc=alistair.francis@xilinx.com \
--cc=crosthwaitepeter@gmail.com \
--cc=edgar.iglesias@gmail.com \
--cc=edgar.iglesias@xilinx.com \
--cc=fred.konrad@greensocs.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.