qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Yoshinori Sato <ysato@users.sourceforge.jp>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, richard.henderson@linaro.org,
	Yoshinori Sato <ysato@users.sourceforge.jp>,
	philmd@redhat.com
Subject: [Qemu-devel] [PATCH v15 02/12] hw/registerfields.h: Add 8bit and 16bit register macros.
Date: Wed, 22 May 2019 23:29:46 +0900	[thread overview]
Message-ID: <20190522142956.41916-3-ysato@users.sourceforge.jp> (raw)
In-Reply-To: <20190522142956.41916-1-ysato@users.sourceforge.jp>

Some RX peripheral using 8bit and 16bit registers.
Added 8bit and 16bit APIs.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 include/hw/registerfields.h | 30 +++++++++++++++++++++++++++++-
 1 file changed, 29 insertions(+), 1 deletion(-)

diff --git a/include/hw/registerfields.h b/include/hw/registerfields.h
index 2659a58737..8573bdd7db 100644
--- a/include/hw/registerfields.h
+++ b/include/hw/registerfields.h
@@ -13,11 +13,17 @@
 
 #include "qemu/bitops.h"
 
-/* Define constants for a 32 bit register */
+/* Define constants for a 8, 16 and 32 bit register */
 
 /* This macro will define A_FOO, for the byte address of a register
  * as well as R_FOO for the uint32_t[] register number (A_FOO / 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 REG32(reg, addr)                                                  \
     enum { A_ ## reg = (addr) };                                          \
     enum { R_ ## reg = (addr) / 4 };
@@ -34,6 +40,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 +61,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.11.0



  parent reply	other threads:[~2019-05-22 14:50 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-22 14:29 [Qemu-devel] [PATCH v15 00/12] Add RX archtecture support Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 01/12] qemu/bitops.h: Add extract8 and extract16 Yoshinori Sato
2019-05-22 14:29 ` Yoshinori Sato [this message]
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 03/12] target/rx: TCG translation Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 04/12] target/rx: TCG helper Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 05/12] target/rx: CPU definition Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 06/12] target/rx: RX disassembler Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 07/12] hw/intc: RX62N interrupt controller (ICUa) Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 08/12] hw/timer: RX62N internal timer modules Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 09/12] hw/char: RX62N serial communication interface (SCI) Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 10/12] hw/rx: RX Target hardware definition Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 11/12] Add rx-softmmu Yoshinori Sato
2019-05-22 14:29 ` [Qemu-devel] [PATCH v15 12/12] MAINTAINERS: Add RX Yoshinori Sato
2019-05-22 14:50 ` [Qemu-devel] [PATCH v15 00/12] Add RX archtecture support Philippe Mathieu-Daudé
2019-05-23  8:19   ` Yoshinori Sato
2019-05-22 15:15 ` no-reply

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=20190522142956.41916-3-ysato@users.sourceforge.jp \
    --to=ysato@users.sourceforge.jp \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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).