From nobody Sun Nov 9 17:50:07 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551357054244229.7855374523807; Thu, 28 Feb 2019 04:30:54 -0800 (PST) Received: from localhost ([127.0.0.1]:37281 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzKpu-000397-6K for importer@patchew.org; Thu, 28 Feb 2019 07:30:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gzKnw-0001qC-HZ for qemu-devel@nongnu.org; Thu, 28 Feb 2019 07:28:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gzKnv-0007pX-Cs for qemu-devel@nongnu.org; Thu, 28 Feb 2019 07:28:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:40646) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gzKnu-0007iE-T4 for qemu-devel@nongnu.org; Thu, 28 Feb 2019 07:28:47 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 50294C0B773B; Thu, 28 Feb 2019 12:28:42 +0000 (UTC) Received: from thuth.com (ovpn-116-149.ams2.redhat.com [10.36.116.149]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4D58168D87; Thu, 28 Feb 2019 12:28:41 +0000 (UTC) From: Thomas Huth To: Peter Maydell , qemu-devel@nongnu.org Date: Thu, 28 Feb 2019 13:27:55 +0100 Message-Id: <1551356875-30676-14-git-send-email-thuth@redhat.com> In-Reply-To: <1551356875-30676-1-git-send-email-thuth@redhat.com> References: <1551356875-30676-1-git-send-email-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 28 Feb 2019 12:28:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 13/13] hw/m68k/mcf5208: Support loading of bios images X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Thomas Huth Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Thomas Huth The MCF5208EVB supports 2 MiB of flash at address 0. Add support for this memory region and some code to load the file that can be specified with the "-bios" command line option. This can be used for example to load U-Boot images for the MCF5208EVB (we still lack some features in the CPU emulation for this firmware, though, so it can not be run successfully yet). Reviewed-by: Stefano Garzarella Signed-off-by: Thomas Huth --- hw/m68k/mcf5208.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/hw/m68k/mcf5208.c b/hw/m68k/mcf5208.c index 8531e07..6f6efae 100644 --- a/hw/m68k/mcf5208.c +++ b/hw/m68k/mcf5208.c @@ -27,6 +27,8 @@ =20 #define SYS_FREQ 166666666 =20 +#define ROM_SIZE 0x200000 + #define PCSR_EN 0x0001 #define PCSR_RLD 0x0002 #define PCSR_PIF 0x0004 @@ -227,6 +229,7 @@ static void mcf5208evb_init(MachineState *machine) hwaddr entry; qemu_irq *pic; MemoryRegion *address_space_mem =3D get_system_memory(); + MemoryRegion *rom =3D g_new(MemoryRegion, 1); MemoryRegion *ram =3D g_new(MemoryRegion, 1); MemoryRegion *sram =3D g_new(MemoryRegion, 1); =20 @@ -237,6 +240,10 @@ static void mcf5208evb_init(MachineState *machine) env->vbr =3D 0; /* TODO: Configure BARs. */ =20 + /* ROM at 0x00000000 */ + memory_region_init_rom(rom, NULL, "mcf5208.rom", ROM_SIZE, &error_fata= l); + memory_region_add_subregion(address_space_mem, 0x00000000, rom); + /* DRAM at 0x40000000 */ memory_region_allocate_system_memory(ram, NULL, "mcf5208.ram", ram_siz= e); memory_region_add_subregion(address_space_mem, 0x40000000, ram); @@ -285,9 +292,30 @@ static void mcf5208evb_init(MachineState *machine) /* 0xfc0a4000 GPIO. */ /* 0xfc0a8000 SDRAM controller. */ =20 + /* Load firmware */ + if (bios_name) { + char *fn; + uint8_t *ptr; + + fn =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); + if (!fn) { + error_report("Could not find ROM image '%s'", bios_name); + exit(1); + } + if (load_image_targphys(fn, 0x0, ROM_SIZE) < 8) { + error_report("Could not load ROM image '%s'", bios_name); + exit(1); + } + g_free(fn); + /* Initial PC is always at offset 4 in firmware binaries */ + ptr =3D rom_ptr(0x4, 4); + assert(ptr !=3D NULL); + env->pc =3D ldl_p(ptr); + } + /* Load kernel. */ if (!kernel_filename) { - if (qtest_enabled()) { + if (qtest_enabled() || bios_name) { return; } error_report("Kernel image must be specified"); --=20 1.8.3.1