From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54525 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PMHex-00012a-TG for qemu-devel@nongnu.org; Sat, 27 Nov 2010 05:05:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PMHes-0004Lg-Jh for qemu-devel@nongnu.org; Sat, 27 Nov 2010 05:05:35 -0500 Received: from mail-px0-f173.google.com ([209.85.212.173]:46059) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PMHes-0004LZ-EY for qemu-devel@nongnu.org; Sat, 27 Nov 2010 05:05:30 -0500 Received: by pxi16 with SMTP id 16so545998pxi.4 for ; Sat, 27 Nov 2010 02:05:29 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <201011262347.46536.paul@codesourcery.com> References: <1290670555-12575-1-git-send-email-agraf@suse.de> <1290670555-12575-2-git-send-email-agraf@suse.de> <201011262347.46536.paul@codesourcery.com> From: Blue Swirl Date: Sat, 27 Nov 2010 10:05:09 +0000 Message-ID: Subject: Re: [Qemu-devel] [PATCH 01/15] exec: introduce endianness swapped mmio Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paul Brook Cc: =?UTF-8?Q?Andreas_F=C3=A4rber?= , Alexander Graf , QEMU-devel Developers On Fri, Nov 26, 2010 at 11:47 PM, Paul Brook wrote: >> > diff --git a/exec.c b/exec.c >> > index db9ff55..f54a360 100644 >> > --- a/exec.c >> > +++ b/exec.c >> > >> > @@ -3370,6 +3474,22 @@ static int cpu_register_io_memory_fixed(int >> > io_index, >> > >> > =C2=A0 =C2=A0 } >> > =C2=A0 =C2=A0 io_mem_opaque[io_index] =3D opaque; >> > >> > + =C2=A0 =C2=A0switch (endian) { >> > + =C2=A0 =C2=A0case DEVICE_BIG_ENDIAN: >> > +#ifndef TARGET_WORDS_BIGENDIAN >> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0swapendian_init(io_index); >> > +#endif >> > + =C2=A0 =C2=A0 =C2=A0 =C2=A0break; >> >> So basically, you just moved the #ifdefs to another place. :) > > Many #ifdefs inconsistently scattered through all the device code have be= en > replaced by a single #ifdef. > >> Shouldn't this be dependent on the CPU state and determined at >> runtime? Thinking of MSR LE bit on ppc. I guess QEMU doesn't support >> bi-endian ppc today, as does the 970, but it would be nice to keep it >> in mind. > > Switching endianness of a CPU generally does not effect the endianness of= the > CPU/peripheral busses. =C2=A0It makes the CPU byteswap accesses before th= ey are > seen by either memory or devices. > > In theory it might be possible to avoid redundant byteswaps if you're rea= lly > clever. =C2=A0In practice you still have to handle the fact that your dev= ices are a > different endianness to RAM, so it probably doesn't gain you a whole lot. Sparc64 MMU can also perform byte swapping, there is also a byte swapping CPU mode and byte swapping access instructions. I think only the instructions are used (for PCI).