On 23.12.2009, at 11:06, Aurelien Jarno wrote: > On Wed, Dec 23, 2009 at 10:29:53AM +0100, Alexander Graf wrote: >> >> On 23.12.2009, at 07:12, Aurelien Jarno wrote: >> >>> On Tue, Dec 22, 2009 at 02:45:17PM +0100, Alexander Graf wrote: >>>> When we get an MMIO request, we always get variables in host endianness. >>>> The >>>> only time we need to actually reverse byte order is when we read bytes from >>>> guest memory. >>>> >>>> Apparently the DBDMA implementation is different there. A lot of the logic >>>> in there depends on values being big endian. Now, qemu does all the >>>> conversion >>>> in the MMIO handlers for us already though, so it turns out that we're in >>>> the same byte order from a C point of view, but cpu_to_be32 and be32_to_cpu >>>> end up being nops. >>>> >>>> This makes the code work differently on x86 (little endian) than on ppc >>>> (big >>>> endian). On x86 it works, on ppc it doesn't. >>>> >>>> This patch (while being seriously hacky and ugly) makes dbdma emulation >>>> work >>>> on ppc hosts. I'll leave the real fixing to someone else. >>> >>> I have to say I found it too hacky to be included in QEMU. I would >>> prefer if someone can provide a real fix. >> >> Looking at hw/pci_host_template.h I'm actually more confident now that this >> is actually the correct solution. We don't want big endian or little endian, >> we want reversed endian variables. >> > > I guess it's the same problem, that is the bswap is there to emulate the > fact that the bus is connected backward. Then I guess that the bswap > should also depends on TARGET_WORDS_BIGENDIAN, even if this file is > currently only compiled for big endian targets. Also a comment might be > a good idea.
Yeah, I was thinking of a helper function to convert that, so we don't have #ifdef's cluttered all over the code :-) Alex