From: Philippe Mathieu-Daudé <[email protected]> Mark the AddressSpace structure const when it is only accessed read-only.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Pierrick Bouvier <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Reviewed-by: Richard Henderson <[email protected]> Message-Id: <[email protected]> --- include/system/memory.h | 13 +++++++------ system/physmem.c | 14 ++++++++------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/system/memory.h b/include/system/memory.h index 7ecad33130c..e143c9c3f39 100644 --- a/include/system/memory.h +++ b/include/system/memory.h @@ -2719,7 +2719,7 @@ void address_space_remove_listeners(const AddressSpace *as); * @len: the number of bytes to read or write * @is_write: indicates the transfer direction */ -MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, +MemTxResult address_space_rw(const AddressSpace *as, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len, bool is_write); @@ -2736,7 +2736,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, * @buf: buffer with the data transferred * @len: the number of bytes to write */ -MemTxResult address_space_write(AddressSpace *as, hwaddr addr, +MemTxResult address_space_write(const AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const void *buf, hwaddr len); @@ -2799,7 +2799,8 @@ MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr, #include "system/memory_ldst_phys.h.inc" #endif -void address_space_flush_icache_range(AddressSpace *as, hwaddr addr, hwaddr len); +void address_space_flush_icache_range(AddressSpace *as, + hwaddr addr, hwaddr len); /* address_space_get_iotlb_entry: translate an address into an IOTLB * entry. Should be called from an RCU critical section. @@ -2919,7 +2920,7 @@ void address_space_register_map_client(AddressSpace *as, QEMUBH *bh); void address_space_unregister_map_client(AddressSpace *as, QEMUBH *bh); /* Internal functions, part of the implementation of address_space_read. */ -MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, +MemTxResult address_space_read_full(const AddressSpace *as, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len); MemTxResult flatview_read_continue(FlatView *fv, hwaddr addr, MemTxAttrs attrs, void *buf, @@ -2974,7 +2975,7 @@ static inline bool memory_access_is_direct(const MemoryRegion *mr, * @len: length of the data transferred */ static inline __attribute__((__always_inline__)) -MemTxResult address_space_read(AddressSpace *as, hwaddr addr, +MemTxResult address_space_read(const AddressSpace *as, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len) { @@ -3017,7 +3018,7 @@ MemTxResult address_space_read(AddressSpace *as, hwaddr addr, * @len: the number of bytes to fill with the constant byte * @attrs: memory transaction attributes */ -MemTxResult address_space_set(AddressSpace *as, hwaddr addr, +MemTxResult address_space_set(const AddressSpace *as, hwaddr addr, uint8_t c, hwaddr len, MemTxAttrs attrs); /* Coalesced MMIO regions are areas where write operations can be reordered. diff --git a/system/physmem.c b/system/physmem.c index b33aa14ab64..7ea65395863 100644 --- a/system/physmem.c +++ b/system/physmem.c @@ -3416,7 +3416,7 @@ static MemTxResult flatview_read(FlatView *fv, hwaddr addr, mr_addr, l, mr); } -MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, +MemTxResult address_space_read_full(const AddressSpace *as, hwaddr addr, MemTxAttrs attrs, void *buf, hwaddr len) { MemTxResult result = MEMTX_OK; @@ -3431,7 +3431,7 @@ MemTxResult address_space_read_full(AddressSpace *as, hwaddr addr, return result; } -MemTxResult address_space_write(AddressSpace *as, hwaddr addr, +MemTxResult address_space_write(const AddressSpace *as, hwaddr addr, MemTxAttrs attrs, const void *buf, hwaddr len) { @@ -3447,8 +3447,9 @@ MemTxResult address_space_write(AddressSpace *as, hwaddr addr, return result; } -MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, - void *buf, hwaddr len, bool is_write) +MemTxResult address_space_rw(const AddressSpace *as, hwaddr addr, + MemTxAttrs attrs, void *buf, + hwaddr len, bool is_write) { if (is_write) { return address_space_write(as, addr, attrs, buf, len); @@ -3457,7 +3458,7 @@ MemTxResult address_space_rw(AddressSpace *as, hwaddr addr, MemTxAttrs attrs, } } -MemTxResult address_space_set(AddressSpace *as, hwaddr addr, +MemTxResult address_space_set(const AddressSpace *as, hwaddr addr, uint8_t c, hwaddr len, MemTxAttrs attrs) { #define FILLBUF_SIZE 512 @@ -3514,7 +3515,8 @@ MemTxResult address_space_write_rom(AddressSpace *as, hwaddr addr, return MEMTX_OK; } -void address_space_flush_icache_range(AddressSpace *as, hwaddr addr, hwaddr len) +void address_space_flush_icache_range(AddressSpace *as, + hwaddr addr, hwaddr len) { /* * This function should do the same thing as an icache flush that was -- 2.53.0
