qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <f4bug@amsat.org>
To: qemu-devel@nongnu.org
Cc: "Yoshinori Sato" <ysato@users.sourceforge.jp>,
	"Alistair Francis" <alistair@alistair23.me>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Alistair Francis" <alistair.francis@wdc.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [PULL 01/13] hw/registerfields.h: Add 8bit and 16bit register macros
Date: Tue, 17 Mar 2020 17:36:04 +0100	[thread overview]
Message-ID: <20200317163616.30027-2-f4bug@amsat.org> (raw)
In-Reply-To: <20200317163616.30027-1-f4bug@amsat.org>

From: Yoshinori Sato <ysato@users.sourceforge.jp>

Some RX peripheral use 8bit and 16bit registers.
Add the 8bit and 16bit APIs.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Tested-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200224141923.82118-4-ysato@users.sourceforge.jp>
Acked-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 include/hw/registerfields.h | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
index 2659a58737..0407edb7ec 100644
--- a/include/hw/registerfields.h
+++ b/include/hw/registerfields.h
@@ -22,6 +22,14 @@
     enum { A_ ## reg = (addr) };                                          \
     enum { R_ ## reg = (addr) / 4 };
 
+#define REG8(reg, addr)                                                   \
+    enum { A_ ## reg = (addr) };                                          \
+    enum { R_ ## reg = (addr) };
+
+#define REG16(reg, addr)                                                  \
+    enum { A_ ## reg = (addr) };                                          \
+    enum { R_ ## reg = (addr) / 2 };
+
 /* 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
@@ -34,6 +42,12 @@
                                         MAKE_64BIT_MASK(shift, length)};
 
 /* Extract a field from a register */
+#define FIELD_EX8(storage, reg, field)                                    \
+    extract8((storage), R_ ## reg ## _ ## field ## _SHIFT,                \
+              R_ ## reg ## _ ## field ## _LENGTH)
+#define FIELD_EX16(storage, reg, field)                                   \
+    extract16((storage), R_ ## reg ## _ ## field ## _SHIFT,               \
+              R_ ## reg ## _ ## field ## _LENGTH)
 #define FIELD_EX32(storage, reg, field)                                   \
     extract32((storage), R_ ## reg ## _ ## field ## _SHIFT,               \
               R_ ## reg ## _ ## field ## _LENGTH)
@@ -49,6 +63,22 @@
  * Assigning values larger then the target field will result in
  * compilation warnings.
  */
+#define FIELD_DP8(storage, reg, field, val) ({                            \
+    struct {                                                              \
+        unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
+    } v = { .v = val };                                                   \
+    uint8_t d;                                                            \
+    d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,           \
+                  R_ ## reg ## _ ## field ## _LENGTH, v.v);               \
+    d; })
+#define FIELD_DP16(storage, reg, field, val) ({                           \
+    struct {                                                              \
+        unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
+    } v = { .v = val };                                                   \
+    uint16_t d;                                                           \
+    d = deposit32((storage), R_ ## reg ## _ ## field ## _SHIFT,           \
+                  R_ ## reg ## _ ## field ## _LENGTH, v.v);               \
+    d; })
 #define FIELD_DP32(storage, reg, field, val) ({                           \
     struct {                                                              \
         unsigned int v:R_ ## reg ## _ ## field ## _LENGTH;                \
-- 
2.21.1



  reply	other threads:[~2020-03-17 16:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-17 16:36 [PULL 00/13] target: Add the Renesas RX architecture Philippe Mathieu-Daudé
2020-03-17 16:36 ` Philippe Mathieu-Daudé [this message]
2020-03-17 16:36 ` [PULL 02/13] MAINTAINERS: Add entry for " Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 03/13] target/rx: TCG translation Philippe Mathieu-Daudé
2020-04-03 16:41   ` Peter Maydell
2020-04-03 16:47     ` Richard Henderson
2020-03-17 16:36 ` [PULL 04/13] target/rx: TCG helpers Philippe Mathieu-Daudé
2021-12-09 16:04   ` Peter Maydell
2021-12-15 12:42     ` Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 05/13] target/rx: CPU definitions Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 06/13] target/rx: RX disassembler Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 07/13] target/rx: Disassemble rx_index_addr into a string Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 08/13] target/rx: Replace operand with prt_ldmi in disassembler Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 09/13] target/rx: Use prt_ldmi for XCHG_mr disassembly Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 10/13] target/rx: Emit all disassembly in one prt() Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 11/13] target/rx: Collect all bytes during disassembly Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 12/13] target/rx: Dump bytes for each insn " Philippe Mathieu-Daudé
2020-03-17 16:36 ` [PULL 13/13] Add rx-softmmu Philippe Mathieu-Daudé
2020-03-17 20:15 ` [PULL 00/13] target: Add the Renesas RX architecture no-reply
2020-03-18  1:10 ` no-reply
2020-03-18  8:20 ` Philippe Mathieu-Daudé

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=20200317163616.30027-2-f4bug@amsat.org \
    --to=f4bug@amsat.org \
    --cc=alistair.francis@wdc.com \
    --cc=alistair@alistair23.me \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    --cc=ysato@users.sourceforge.jp \
    /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).