From patchwork Fri Jun 14 07:30:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Leon Alrae X-Patchwork-Id: 251249 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 634CB2C00A8 for ; Fri, 14 Jun 2013 17:32:31 +1000 (EST) Received: from localhost ([::1]:40245 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnOUm-0007RF-JO for incoming@patchwork.ozlabs.org; Fri, 14 Jun 2013 03:32:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37561) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnOUN-0007Qn-Sl for qemu-devel@nongnu.org; Fri, 14 Jun 2013 03:32:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UnOUJ-0005gU-Dg for qemu-devel@nongnu.org; Fri, 14 Jun 2013 03:32:03 -0400 Received: from multi.imgtec.com ([194.200.65.239]:8161) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UnOUJ-0005NA-7G for qemu-devel@nongnu.org; Fri, 14 Jun 2013 03:31:59 -0400 From: Leon Alrae To: Date: Fri, 14 Jun 2013 08:30:43 +0100 Message-ID: <1371195048-19618-2-git-send-email-leon.alrae@imgtec.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1371195048-19618-1-git-send-email-leon.alrae@imgtec.com> References: <1371195048-19618-1-git-send-email-leon.alrae@imgtec.com> MIME-Version: 1.0 X-Originating-IP: [192.168.14.85] X-SEF-Processed: 7_3_0_01192__2013_06_14_08_31_25 X-detected-operating-system: by eggs.gnu.org: Windows XP X-Received-From: 194.200.65.239 Cc: yongbok.kim@imgtec.com, cristian.cuna@imgtec.com, leon.alrae@imgtec.com, paul.burton@imgtec.com, aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 1/6] mips_malta: fix BIOS endianness swapping X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Paul Burton 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 --- hw/mips/mips_malta.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/mips/mips_malta.c b/hw/mips/mips_malta.c index 5033d51..4def898 100644 --- a/hw/mips/mips_malta.c +++ b/hw/mips/mips_malta.c @@ -916,8 +916,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++;