memory: Access MemoryRegion with endianness

Preparation for collapsing the two byte swaps adjust_endianness and
handle_bswap into the former.

Call memory_region_dispatch_{read|write} with endianness encoded into
the "MemOp op" operand.

This patch does not change any behaviour as
memory_region_dispatch_{read|write} is yet to handle the endianness.

Once it does handle endianness, callers with byte swaps can collapse
them into adjust_endianness.

Backports commit d5d680cacc66ef7e3c02c81dc8f3a34eabce6dfe from qemu
This commit is contained in:
Tony Nguyen 2020-01-07 18:52:02 -05:00 committed by Lioncash
parent b335c4756a
commit da98d0da4e
21 changed files with 71 additions and 10 deletions

View file

@ -1960,8 +1960,13 @@ static MemTxResult flatview_write_continue(FlatView *fv, hwaddr addr,
/* XXX: could force current_cpu to NULL to avoid
potential bugs */
val = ldn_p(buf, l);
/*
* TODO: Merge bswap from ldn_p into memory_region_dispatch_write
* by using ldn_he_p and dropping MO_TE to get a host-endian value.
*/
result |= memory_region_dispatch_write(mr, addr1, val,
size_memop(l), attrs);
size_memop(l) | MO_TE,
attrs);
} else {
/* RAM case */
ptr = qemu_map_ram_ptr(mr->uc, mr->ram_block, addr1);
@ -2037,8 +2042,12 @@ MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr,
// Unicorn: commented out
//release_lock |= prepare_mmio_access(mr);
l = memory_access_size(mr, l, addr1);
/*
* TODO: Merge bswap from stn_p into memory_region_dispatch_read
* by using stn_he_p and dropping MO_TE to get a host-endian value.
*/
result |= memory_region_dispatch_read(mr, addr1, &val,
size_memop(l), attrs);
size_memop(l) | MO_TE, attrs);
stn_p(buf, l, val);
} else {
/* RAM case */