qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] lsi53c895a: fix endianness issues


From: Aurelien Jarno
Subject: Re: [Qemu-devel] [PATCH] lsi53c895a: fix endianness issues
Date: Fri, 7 Jan 2011 17:42:30 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

On Fri, Jan 07, 2011 at 04:21:29PM +0000, Stefan Hajnoczi wrote:
> On Fri, Jan 7, 2011 at 2:43 PM,  <address@hidden> wrote:
> > From: Aurelien Jarno <address@hidden>
> >
> > lsi_ram_read*() and lsi_ram_write*() are not consistent, one uses
> > leXX_to_cpu() the other uses nothing. As the comment above the RAM
> > declaration says: "Script ram is stored as 32-bit words in host
> > byteorder.", remove the leXX_to_cpu() calls.
> >
> > This fixes the boot of an ARM versatile machine on MIPS and PowerPC
> > hosts.
> >
> > Signed-off-by: Aurelien Jarno <address@hidden>
> > ---
> >  hw/lsi53c895a.c |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> script_ram[] is host byteorder for sure.  This patch looks correct.
> 
> Now I'm wondering about read_dword:
> 
> static inline uint32_t read_dword(LSIState *s, uint32_t addr)
> {
>     uint32_t buf;
> 
>     /* Optimize reading from SCRIPTS RAM.  */
>     if ((addr & 0xffffe000) == s->script_ram_base) {
>         return s->script_ram[(addr & 0x1fff) >> 2];
>     }
>     cpu_physical_memory_read(addr, (uint8_t *)&buf, 4);
>     return cpu_to_le32(buf);
> }
> 
> If addr is in script_ram[], then the return value is host byteorder.

Correct, it's what is assumed latter during the script execution.

> If addr is not in script_ram[], then it is converted to little-endian?

It needs to be converted to host byteorder. le32_to_cpu() would probably
more correct here for little endian targets (I doubt anyway that
lsi53c895a works on big endian targets given other parts of the code).

It should probably be only bswapped for cross-endian if we latter add
support for big endian.

>  Will lsi emulation work on big-endian hosts?
> 

With this patch it definitely works on big-endian hosts and
little-endian guests (tested with ARM guest on MIPS and PowerPC hosts).

-- 
Aurelien Jarno                          GPG: 1024D/F1BCDB73
address@hidden                 http://www.aurel32.net



reply via email to

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