qemu-discuss
[Top][All Lists]
Advanced

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

Re: [Qemu-discuss] CPU write value passed from application to qemu is st


From: Peter Maydell
Subject: Re: [Qemu-discuss] CPU write value passed from application to qemu is strange
Date: Mon, 29 Sep 2014 12:51:44 +0100

On 29 September 2014 12:37, Chan Kim <address@hidden> wrote:
> So whatever 32bit value I write, it should be seen as such
> at the device's qemu write function. Isn't this the normal
> behavior? (If I write 0x12345678, it is seen 0x12345678 not
> 0x78563412).

This depends on what the MemoryRegionOps struct for
the memory region sets its .endianness field to.
DEVICE_NATIVE_ENDIAN means the device sees values
the same way round as the guest CPU's native endianness[*],
so if the guest does a 32 bit write of 0x12345678
then it appears in the write function's argument
as 0x12345678. DEVICE_BIG_ENDIAN means that if the
CPU is little endian then the word will be byteswapped.
DEVICE_LITTLE_ENDIAN means that if the CPU is big
endian then the word will be byteswapped. The latter
are useful for devices or buses which have a specific
endianness which is not the same as that of the CPU
(eg PCI is always little endian).

[*] For CPUs which are dynamically endianness swappable
like ARM and PPC, the "guest CPU native endianness" is
the standard endianness of the system bus, which is
LE for ARM and BE for PPC, even if the CPU happens
to be running code of the opposite endianness at the
time.

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]