All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alistair Francis <alistair.francis@xilinx.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: "Alistair Francis" <alistair.francis@xilinx.com>,
	"Edgar Iglesias" <edgar.iglesias@xilinx.com>,
	"QEMU Developers" <qemu-devel@nongnu.org>,
	"Peter Crosthwaite" <crosthwaitepeter@gmail.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Andreas Färber" <afaerber@suse.de>,
	"KONRAD Frédéric" <fred.konrad@greensocs.com>
Subject: Re: [Qemu-devel] [PATCH v8 6/8] register: Add block initialise helper
Date: Mon, 27 Jun 2016 09:16:56 -0700	[thread overview]
Message-ID: <CAKmqyKOTA_pNej_E3KSkTpMxmM9JLH2YorqvKcVZO+8Bs6NWmA@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA8zch+Hh2nW1BZUvUfNLPW+98Z1YJ3+7Gv-yMDQALLZ7Q@mail.gmail.com>

On Mon, Jun 27, 2016 at 7:31 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 24 June 2016 at 16:42, Alistair Francis <alistair.francis@xilinx.com> wrote:
>> 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>
>> ---
>
>> --- 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.)

Sorry it's just a habit.

>
>> +/**
>> + * 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?

The device init function that calls the register init function will
also call memory_region_add_subregion(). Doesn't it need to call
memory_region_del_subregion() afterwards?

Thanks,

Alistair

>
>> + */
>> +
>> +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	other threads:[~2016-06-27 16:17 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-24 15:42 [Qemu-devel] [PATCH v8 0/8] data-driven device registers Alistair Francis
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 1/8] bitops: Add MAKE_64BIT_MASK macro Alistair Francis
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 2/8] register: Add Register API Alistair Francis
2016-06-27 14:24   ` Peter Maydell
2016-06-27 15:51     ` Alistair Francis
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 3/8] register: Add Memory API glue Alistair Francis
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 4/8] register: Define REG and FIELD macros Alistair Francis
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 5/8] register: QOMify Alistair Francis
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 6/8] register: Add block initialise helper Alistair Francis
2016-06-27 14:31   ` Peter Maydell
2016-06-27 16:16     ` Alistair Francis [this message]
2016-06-27 16:44       ` Peter Maydell
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 7/8] dma: Add Xilinx Zynq devcfg device model Alistair Francis
2016-06-27 14:34   ` Peter Maydell
2016-06-27 16:12     ` Alistair Francis
2016-06-24 15:42 ` [Qemu-devel] [PATCH v8 8/8] xilinx_zynq: Connect devcfg to the Zynq machine model 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=CAKmqyKOTA_pNej_E3KSkTpMxmM9JLH2YorqvKcVZO+8Bs6NWmA@mail.gmail.com \
    --to=alistair.francis@xilinx.com \
    --cc=afaerber@suse.de \
    --cc=alex.bennee@linaro.org \
    --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.