From: Paul Burton Date: Fri, 14 Jun 2013 07:30:43 +0000 (+0100) Subject: mips_malta: fix BIOS endianness swapping X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=a2b8813d62fa5a35adc1a7bf58de5b2ffb754f5d;p=qemu.git mips_malta: fix BIOS endianness swapping If the target is little endian (mipsel) then the BIOS image endianness is swapped so that the big endian BIOS binaries commonly produced can be loaded correctly. When using the -bios argument the BIOS is loaded using load_image_targphys, however this doesn't perform the load to target memory immediately. Instead it loads the BIOS file into a struct Rom which will later be written to target memory upon reset. However the endianness conversion was being performed before this, on init, and operating on the target memory which at this point is blank & will later be overwritten by the (big endian) BIOS image. Correct this by operating on the data referenced by struct Rom rather than the target memory when the -bios argument is used. Signed-off-by: Paul Burton Signed-off-by: Leon Alrae Signed-off-by: Aurelien Jarno --- diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index e932fdc77d..05d9bf512f 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -920,8 +920,11 @@ void mips_malta_init(QEMUMachineInitArgs *args) a neat trick which allows bi-endian firmware. */ #ifndef TARGET_WORDS_BIGENDIAN { - uint32_t *addr = memory_region_get_ram_ptr(bios); - uint32_t *end = addr + bios_size; + uint32_t *end, *addr = rom_ptr(FLASH_ADDRESS); + if (!addr) { + addr = memory_region_get_ram_ptr(bios); + } + end = (void *)addr + bios_size; while (addr < end) { bswap32s(addr); addr++;