All of lore.kernel.org
 help / color / mirror / Atom feed
From: Tony Nguyen <tony.nguyen@bt.com>
To: qemu-devel@nongnu.org
Cc: "Tony Nguyen" <tony.nguyen@bt.com>,
	"Michael S. Tsirkin" <mst@redhat.com>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>,
	"Richard Henderson" <rth@twiddle.net>
Subject: [Qemu-devel]  [PATCH 1/9] exec: Map device_endian onto MemOp
Date: Sat, 24 Aug 2019 05:42:40 +1000	[thread overview]
Message-ID: <8f687bc199a1f6245ae977141a777a8fd7aa7477.1566588034.git.tony.nguyen@bt.com> (raw)
In-Reply-To: <cover.1566588033.git.tony.nguyen@bt.com>

Preparation to replace device_endian with MemOp.

Mapping device_endian onto MemOp limits behaviour changes to this
relatively smaller patch.

The next patch will replace all device_endian usages with the
equivalent MemOp. That patch will be large but have no behaviour
changes.

A subsequent patch will then delete unused device_endian.

Signed-off-by: Tony Nguyen <tony.nguyen@bt.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
---
 hw/char/serial.c          | 18 ++++++------------
 include/exec/cpu-common.h | 10 +++++++---
 memory.c                  |  1 -
 3 files changed, 13 insertions(+), 16 deletions(-)

diff --git a/hw/char/serial.c b/hw/char/serial.c
index b4aa250950..6328476f52 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -1016,22 +1016,15 @@ static void serial_mm_write(void *opaque, hwaddr addr,
     serial_ioport_write(s, addr >> s->it_shift, value, 1);
 }
 
-static const MemoryRegionOps serial_mm_ops[3] = {
-    [DEVICE_NATIVE_ENDIAN] = {
-        .read = serial_mm_read,
-        .write = serial_mm_write,
-        .endianness = DEVICE_NATIVE_ENDIAN,
-        .valid.max_access_size = 8,
-        .impl.max_access_size = 8,
-    },
-    [DEVICE_LITTLE_ENDIAN] = {
+static const MemoryRegionOps serial_mm_ops[2] = {
+    [0] = {
         .read = serial_mm_read,
         .write = serial_mm_write,
         .endianness = DEVICE_LITTLE_ENDIAN,
         .valid.max_access_size = 8,
         .impl.max_access_size = 8,
     },
-    [DEVICE_BIG_ENDIAN] = {
+    [1] = {
         .read = serial_mm_read,
         .write = serial_mm_write,
         .endianness = DEVICE_BIG_ENDIAN,
@@ -1057,8 +1050,9 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
     serial_realize_core(s, &error_fatal);
     vmstate_register(NULL, base, &vmstate_serial, s);
 
-    memory_region_init_io(&s->io, NULL, &serial_mm_ops[end], s,
-                          "serial", 8 << it_shift);
+    memory_region_init_io(&s->io, NULL,
+                          &serial_mm_ops[end == DEVICE_BIG_ENDIAN],
+                          s, "serial", 8 << it_shift);
     memory_region_add_subregion(address_space, base, &s->io);
     return s;
 }
diff --git a/include/exec/cpu-common.h b/include/exec/cpu-common.h
index f7dbe75fbc..c388453ed7 100644
--- a/include/exec/cpu-common.h
+++ b/include/exec/cpu-common.h
@@ -16,10 +16,14 @@ void tcg_flush_softmmu_tlb(CPUState *cs);
 
 #if !defined(CONFIG_USER_ONLY)
 
+#include "exec/memop.h"
+
 enum device_endian {
-    DEVICE_NATIVE_ENDIAN,
-    DEVICE_BIG_ENDIAN,
-    DEVICE_LITTLE_ENDIAN,
+#ifdef NEED_CPU_H
+    DEVICE_NATIVE_ENDIAN = MO_TE,
+#endif
+    DEVICE_BIG_ENDIAN = MO_BE,
+    DEVICE_LITTLE_ENDIAN = MO_LE,
 };
 
 #if defined(HOST_WORDS_BIGENDIAN)
diff --git a/memory.c b/memory.c
index 11a9b08060..f30ce520c9 100644
--- a/memory.c
+++ b/memory.c
@@ -3283,7 +3283,6 @@ MemOp devend_memop(enum device_endian end)
     switch (end) {
     case DEVICE_LITTLE_ENDIAN:
     case DEVICE_BIG_ENDIAN:
-    case DEVICE_NATIVE_ENDIAN:
         return conv[end];
     default:
         g_assert_not_reached();
-- 
2.23.0



  reply	other threads:[~2019-08-23 19:40 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-23 19:42 [Qemu-devel] [PATCH 0/9] Delete enum device_endian Tony Nguyen
2019-08-23 19:42 ` Tony Nguyen [this message]
2019-08-23 19:42 ` [Qemu-devel] [PATCH 2/9] exec: Replace DEVICE_NATIVE_ENDIAN with MO_TE Tony Nguyen
2019-08-23 19:42   ` [Qemu-riscv] " Tony Nguyen
2019-08-23 19:42   ` [Xen-devel] " Tony Nguyen
2019-08-23 19:42 ` [Qemu-devel] [PATCH 3/9] exec: Replace DEVICE_LITTLE_ENDIAN with MO_LE Tony Nguyen
2019-08-23 19:42   ` [Qemu-riscv] " Tony Nguyen
2019-08-23 19:42   ` [Xen-devel] " Tony Nguyen
2019-08-23 19:42 ` [Qemu-devel] [PATCH 4/9] exec: Replace DEVICE_BIG_ENDIAN with MO_BE Tony Nguyen
2019-08-23 19:42 ` [Qemu-devel] [PATCH 5/9] exec: Replace enum device_endian with MemOp Tony Nguyen
2019-08-23 19:42 ` [Qemu-devel] [PATCH 6/9] memory: Delete devend_memop Tony Nguyen
2019-08-24 22:30   ` Richard Henderson
2019-08-23 19:42 ` [Qemu-devel] [PATCH 7/9] exec: Delete device_endian Tony Nguyen
2019-08-23 19:42 ` [Qemu-devel] [PATCH 8/9] exec: Delete DEVICE_HOST_ENDIAN Tony Nguyen
2019-08-24 22:31   ` Richard Henderson
2019-08-23 19:42 ` [Qemu-devel] [PATCH 9/9] memory: Delete memory_region_big_endian Tony Nguyen
2019-08-24 22:32   ` Richard Henderson

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=8f687bc199a1f6245ae977141a777a8fd7aa7477.1566588034.git.tony.nguyen@bt.com \
    --to=tony.nguyen@bt.com \
    --cc=marcandre.lureau@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    /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.