qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: Alistair Francis <alistair.francis@xilinx.com>
Cc: "QEMU Developers" <qemu-devel@nongnu.org>,
	"Peter Crosthwaite" <crosthwaitepeter@gmail.com>,
	"Edgar Iglesias" <edgar.iglesias@xilinx.com>,
	"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
	"Andreas Färber" <afaerber@suse.de>,
	"KONRAD Frédéric" <fred.konrad@greensocs.com>,
	"Alex Bennée" <alex.bennee@linaro.org>
Subject: Re: [Qemu-devel] [PATCH v8 2/8] register: Add Register API
Date: Mon, 27 Jun 2016 15:24:14 +0100	[thread overview]
Message-ID: <CAFEAcA8wAb7k85sGq2Ov+SErQemcm4BcgE24bDDhFLFFi2v8AA@mail.gmail.com> (raw)
In-Reply-To: <12df904913bfddb24a2fc0121aeb879a902f38f7.1466782459.git.alistair.francis@xilinx.com>

On 24 June 2016 at 16:42, Alistair Francis <alistair.francis@xilinx.com> wrote:
> This API provides some encapsulation of registers and factors out some
> common functionality to common code. Bits of device state (usually MMIO
> registers) often have all sorts of access restrictions and semantics
> associated with them. This API allows you to define what those
> restrictions are on a bit-by-bit basis.
>
> Helper functions are then used to access the register which observe the
> semantics defined by the RegisterAccessInfo struct.
>
> Some features:
> Bits can be marked as read_only (ro field)
> Bits can be marked as write-1-clear (w1c field)
> Bits can be marked as reserved (rsvd field)
> Reset values can be defined (reset)
> Bits can be marked clear on read (cor)
> Pre and post action callbacks can be added to read and write ops
> Verbose debugging info can be enabled/disabled

> +uint64_t register_read(RegisterInfo *reg, uint64_t re, const char* prefix,
> +                       bool debug)
> +{
> +    uint64_t ret;
> +    const RegisterAccessInfo *ac;
> +
> +    assert(reg);
> +
> +    ac = reg->access;
> +    if (!ac || !ac->name) {
> +        qemu_log_mask(LOG_GUEST_ERROR, "%s: read from undefined device state\n",
> +                      prefix);
> +        return 0;
> +    }
> +
> +    ret = reg->data ? register_read_val(reg) : ac->reset;
> +
> +    /* Mask based on the read enable size */
> +    ret &= re;
> +    register_write_val(reg, ret & ~ac->cor);

If you do a byte read on a word-size register then the
masking with re will result in our writing back zeroes
to the high bits of the word, won't it?

thanks
-- PMM

  reply	other threads:[~2016-06-27 14:24 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 [this message]
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
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=CAFEAcA8wAb7k85sGq2Ov+SErQemcm4BcgE24bDDhFLFFi2v8AA@mail.gmail.com \
    --to=peter.maydell@linaro.org \
    --cc=afaerber@suse.de \
    --cc=alex.bennee@linaro.org \
    --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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).