exec: add endian specific phys ld/st functions
PATCH v2 1/9 exec: add endian specific phys ld/st functions
Device code some times needs to access physical memory and does that through the ld./st._phys functions. However, these are the exact same functions that the CPU uses to access memory, which means they will be endianness swapped depending on the target CPU.
However, devices don't know about the CPU's endianness, but instead access memory directly using their own interface to the memory bus, so they need some way to read data with their native endianness.
This patch adds _le and _be functions to ld./st._phys.
---
v1 -> v2:
- inline endian detection, so we can use qemu's ld.|st._le|be_p functions
--- cpu-common.h | 12 ++++ exec.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 203 insertions(+), 10 deletions(-)
cpu-common.h +12 -0
@@ -135,14 +135,26 @@ void qemu_flush_coalesced_mmio_buffer(void);uint32_t ldub_phys (target_phys_addr_t addr);uint32_t lduw_phys (target_phys_addr_t addr); +uint32_t lduw_le_phys (target_phys_addr_t addr); +uint32_t lduw_be_phys (target_phys_addr_t addr);uint32_t ldl_phys (target_phys_addr_t addr); +uint32_t ldl_le_phys (target_phys_addr_t addr); +uint32_t ldl_be_phys (target_phys_addr_t addr);uint64_t ldq_phys (target_phys_addr_t addr); +uint64_t ldq_le_phys (target_phys_addr_t addr); +uint64_t ldq_be_phys (target_phys_addr_t addr);void stl_phys_notdirty (target_phys_addr_t addr,uint32_t val);void stq_phys_notdirty (target_phys_addr_t addr,uint64_t val);void stb_phys (target_phys_addr_t addr,uint32_t val);void stw_phys (target_phys_addr_t addr,uint32_t val); +void stw_le_phys (target_phys_addr_t addr,uint32_t val); +void stw_be_phys (target_phys_addr_t addr,uint32_t val);void stl_phys (target_phys_addr_t addr,uint32_t val); +void stl_le_phys (target_phys_addr_t addr,uint32_t val); +void stl_be_phys (target_phys_addr_t addr,uint32_t val);void stq_phys (target_phys_addr_t addr,uint64_t val); +void stq_le_phys (target_phys_addr_t addr,uint64_t val); +void stq_be_phys (target_phys_addr_t addr,uint64_t val);void cpu_physical_memory_write_rom (target_phys_addr_t addr,const uint8_t *buf,int len);
exec.c +191 -10
312 lines not on this page · raw message
Signature · 1 line
1.6.0.2
Am 06.07.2011 um 09:09 schrieb Alexander Graf <[email protected]>:
Quoted 10 lines
Device code some times needs to access physical memory and does that through the ld./st._phys functions. However, these are the exact same functions that the CPU uses to access memory, which means they will be endianness swapped depending on the target CPU.
However, devices don't know about the CPU's endianness, but instead access memory directly using their own interface to the memory bus, so they need some way to read data with their native endianness.
This patch adds
_leand_befunctions to ld./st._phys.
Blue, mind to apply at least this one if there are no concerns? The API it adds makes sense IMHO and I don't want to hold up the megasas patch due to it ;).
Alex
Quoted 1 line
Blue Swirl
AppliedThanks, applied all.
Quoted 20 lines · Alexander Graf
Am 06.07.2011 um 09:09 schrieb Alexander Graf <[email protected]>:
Quoted 10 lines
Device code some times needs to access physical memory and does that through the ld./st._phys functions. However, these are the exact same functions that the CPU uses to access memory, which means they will be endianness swapped depending on the target CPU.
However, devices don't know about the CPU's endianness, but instead access memory directly using their own interface to the memory bus, so they need some way to read data with their native endianness.
This patch adds
_leand_befunctions to ld./st._phys.Blue, mind to apply at least this one if there are no concerns? The API it adds makes sense IMHO and I don't want to hold up the megasas patch due to it ;).
Alex
Quoted 1 line