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@linaro.org>
---
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@linaro.org>
+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,
};