Re: [PATCH v2 07/16] hw/char/xilinx_uartlite: Make device endianness configurable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/11/24 10:27, Richard Henderson wrote:
On 11/7/24 01:22, Philippe Mathieu-Daudé wrote:
Replace the DEVICE_NATIVE_ENDIAN MemoryRegionOps by a pair
of DEVICE_LITTLE_ENDIAN / DEVICE_BIG_ENDIAN.
Add the "little-endian" property to select the device
endianness, defaulting to little endian.
Set the proper endianness on the single machine using the
device.

Signed-off-by: Philippe Mathieu-Daudé <philmd@xxxxxxxxxx>
---
  hw/char/xilinx_uartlite.c                | 44 ++++++++++++++++--------
  hw/microblaze/petalogix_s3adsp1800_mmu.c |  1 +
  2 files changed, 31 insertions(+), 14 deletions(-)

Reviewed-by: Richard Henderson <richard.henderson@xxxxxxxxxx>

+static const MemoryRegionOps uart_ops[2] = {
+    {
+        .read = uart_read,
+        .write = uart_write,
+        .endianness = DEVICE_BIG_ENDIAN,
+        .impl = {
+            .min_access_size = 4,
+            .max_access_size = 4,
+        },
+        .valid = {
+            .min_access_size = 1,
+            .max_access_size = 4,
+        },
+    }, {
+        .read = uart_read,
+        .write = uart_write,
+        .endianness = DEVICE_LITTLE_ENDIAN,
+        .impl = {
+            .min_access_size = 4,
+            .max_access_size = 4,
+        },
+        .valid = {
+            .min_access_size = 1,
+            .max_access_size = 4,
+        },
      }
  };

Having looked at several of these now, it occurs to me that you can avoid repetition:

static const MemoryRegionOps uart_ops[2] = {
     [0 ... 1] = {
         .read = uart_read,
         etc,
     },
     [0].endianness = DEVICE_BIG_ENDIAN,
     [1].endianness = DEVICE_LITTLE_ENDIAN,
};

Thank you :) I had the idea it was possible then forgot about it.




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux