From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HA1vp-0007vo-VD for qemu-devel@nongnu.org; Thu, 25 Jan 2007 05:34:14 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HA1vo-0007vc-EH for qemu-devel@nongnu.org; Thu, 25 Jan 2007 05:34:12 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HA1vo-0007vZ-9n for qemu-devel@nongnu.org; Thu, 25 Jan 2007 05:34:12 -0500 Received: from farad.aurel32.net ([82.232.2.251] helo=mail.aurel32.net) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1HA1vn-0000ym-Iy for qemu-devel@nongnu.org; Thu, 25 Jan 2007 05:34:12 -0500 Received: from amd64.aurel32.net ([2001:618:400:fc13:216:3eff:fe00:1009]) by mail.aurel32.net with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1HA1vi-0007B8-8A for qemu-devel@nongnu.org; Thu, 25 Jan 2007 11:34:06 +0100 Received: from aurel32 by amd64.aurel32.net with local (Exim 4.63) (envelope-from ) id 1HA1vh-0005Ye-RZ for qemu-devel@nongnu.org; Thu, 25 Jan 2007 11:34:06 +0100 Date: Thu, 25 Jan 2007 11:34:05 +0100 From: Aurelien Jarno Subject: Re: [Qemu-devel] qemu/hw mips_malta.c mips_r4k.c Message-ID: <20070125103405.GA21338@amd64.aurel32.net> References: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org On Wed, Jan 24, 2007 at 10:00:13PM +0000, Thiemo Seufer wrote: > CVSROOT: /sources/qemu > Module name: qemu > Changes by: Thiemo Seufer 07/01/24 22:00:13 > > Modified files: > hw : mips_malta.c mips_r4k.c > > Log message: > Fix malta emulation for 64bit qemu. > > CVSWeb URLs: > http://cvs.savannah.gnu.org/viewcvs/qemu/hw/mips_malta.c?cvsroot=qemu&r1=1.5&r2=1.6 > http://cvs.savannah.gnu.org/viewcvs/qemu/hw/mips_r4k.c?cvsroot=qemu&r1=1.32&r2=1.33 > This changes breaks malta emulation on 64-bit hosts. Please find a patch below to fix that. The changes to the bootloader part may looks huge, but it's actually just to keep the comments aligned. Also we don't need sign extent for the bootloader code, as it is done by the lui instruction when executed. Index: mips_malta.c =================================================================== RCS file: /sources/qemu/qemu/hw/mips_malta.c,v retrieving revision 1.6 diff -u -d -p -r1.6 mips_malta.c --- mips_malta.c 24 Jan 2007 22:00:12 -0000 1.6 +++ mips_malta.c 25 Jan 2007 10:28:48 -0000 @@ -32,12 +32,11 @@ #ifdef MIPS_HAS_MIPS64 #define INITRD_LOAD_ADDR (int64_t)0x80800000 -#define ENVP_ADDR (int64_t)0x80002000 #else #define INITRD_LOAD_ADDR (int32_t)0x80800000 -#define ENVP_ADDR (int32_t)0x80002000 #endif +#define ENVP_ADDR (int32_t)0x80002000 #define VIRT_TO_PHYS_ADDEND (-((int64_t)(int32_t)0x80000000)) #define ENVP_NB_ENTRIES 16 @@ -390,36 +389,36 @@ static void write_bootloader (CPUState * /* Small bootloader */ p = (uint32_t *) (phys_ram_base + bios_offset); - stl_raw(p++, 0x0bf00010); /* j 0x1fc00040 */ - stl_raw(p++, 0x00000000); /* nop */ + stl_raw(p++, 0x0bf00010); /* j 0x1fc00040 */ + stl_raw(p++, 0x00000000); /* nop */ /* Second part of the bootloader */ p = (uint32_t *) (phys_ram_base + bios_offset + 0x040); - stl_raw(p++, 0x3c040000); /* lui a0, 0 */ - stl_raw(p++, 0x34840002); /* ori a0, a0, 2 */ - stl_raw(p++, 0x3c050000 | ((ENVP_ADDR) >> 16)); /* lui a1, high(ENVP_ADDR) */ - stl_raw(p++, 0x34a50000 | ((ENVP_ADDR) & 0xffff)); /* ori a1, a0, low(ENVP_ADDR) */ - stl_raw(p++, 0x3c060000 | ((ENVP_ADDR + 8) >> 16)); /* lui a2, high(ENVP_ADDR + 8) */ - stl_raw(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); /* ori a2, a2, low(ENVP_ADDR + 8) */ - stl_raw(p++, 0x3c070000 | ((env->ram_size) >> 16)); /* lui a3, high(env->ram_size) */ - stl_raw(p++, 0x34e70000 | ((env->ram_size) & 0xffff)); /* ori a3, a3, low(env->ram_size) */ - stl_raw(p++, 0x3c1f0000 | ((kernel_addr) >> 16)); /* lui ra, high(kernel_addr) */; - stl_raw(p++, 0x37ff0000 | ((kernel_addr) & 0xffff)); /* ori ra, ra, low(kernel_addr) */ - stl_raw(p++, 0x03e00008); /* jr ra */ - stl_raw(p++, 0x00000000); /* nop */ + stl_raw(p++, 0x3c040000); /* lui a0, 0 */ + stl_raw(p++, 0x34840002); /* ori a0, a0, 2 */ + stl_raw(p++, 0x3c050000 | ((ENVP_ADDR >> 16) & 0xffff)); /* lui a1, high(ENVP_ADDR) */ + stl_raw(p++, 0x34a50000 | (ENVP_ADDR & 0xffff)); /* ori a1, a0, low(ENVP_ADDR) */ + stl_raw(p++, 0x3c060000 | (((ENVP_ADDR + 8) >> 16) & 0xffff)); /* lui a2, high(ENVP_ADDR + 8) */ + stl_raw(p++, 0x34c60000 | ((ENVP_ADDR + 8) & 0xffff)); /* ori a2, a2, low(ENVP_ADDR + 8) */ + stl_raw(p++, 0x3c070000 | (env->ram_size >> 16)); /* lui a3, high(env->ram_size) */ + stl_raw(p++, 0x34e70000 | (env->ram_size & 0xffff)); /* ori a3, a3, low(env->ram_size) */ + stl_raw(p++, 0x3c1f0000 | ((kernel_addr >> 16) & 0xffff)); /* lui ra, high(kernel_addr) */; + stl_raw(p++, 0x37ff0000 | (kernel_addr & 0xffff)); /* ori ra, ra, low(kernel_addr) */ + stl_raw(p++, 0x03e00008); /* jr ra */ + stl_raw(p++, 0x00000000); /* nop */ } static void prom_set(int index, const char *string, ...) { va_list ap; - uint32_t *p; - uint32_t table_addr; + int32_t *p; + int32_t table_addr; char *s; if (index >= ENVP_NB_ENTRIES) return; - p = (uint32_t *) (phys_ram_base + ENVP_ADDR + VIRT_TO_PHYS_ADDEND); + p = (int32_t *) (phys_ram_base + ENVP_ADDR + VIRT_TO_PHYS_ADDEND); p += index; if (string == NULL) { @@ -427,7 +426,7 @@ static void prom_set(int index, const ch return; } - table_addr = ENVP_ADDR + sizeof(uint32_t) * ENVP_NB_ENTRIES + index * ENVP_ENTRY_SIZE; + table_addr = ENVP_ADDR + sizeof(int32_t) * ENVP_NB_ENTRIES + index * ENVP_ENTRY_SIZE; s = (char *) (phys_ram_base + VIRT_TO_PHYS_ADDEND + table_addr); stl_raw(p, table_addr); -- .''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' aurel32@debian.org | aurelien@aurel32.net `- people.debian.org/~aurel32 | www.aurel32.net