On 31/12/2014 12:21, Laszlo Ersek wrote:
> Because register emulation in QEMU is integer-preserving, not
> string-preserving (see (2)), we have to jump through a few hoops.
> 
> (3a) We defined the memory mapped fw_cfg data register as
> DEVICE_BIG_ENDIAN.
> 
> The particular choice is not really relevant -- we picked BE only for
> consistency with the control register, which *does* transfer integers --
> but our choice affects how we must host-encode values from fw_cfg strings.
> 
> (3b) Since we want the fw_cfg string "XY" to appear as the [0x58, 0x59]
> array on the data register, *and* we picked DEVICE_BIG_ENDIAN, we must
> compose the host (== C language) value 0x5859 in the read accessor
> function.

I'm not sure this is right.

DEVICE_BIG_ENDIAN means that if we return 0xaabb and the guest is little
endian, it will return 0xbbaa.  But the value returned by the accessor
is always in host endianness.

And it makes sense to swap in the guest if the register is big endian
but the guest is little endian.

So IMHO your old code is right.  Either you are overthinking it, or I'm
underthinking it...  Knowing our respective personalities, either
possibility is just as likely... ;)

Paolo

Reply via email to