From nobody Wed Nov 27 02:33:45 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.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=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1700930150497229.11456702746773; Sat, 25 Nov 2023 08:35:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r6vcG-00031e-RQ; Sat, 25 Nov 2023 11:34:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6vcE-00031B-V4; Sat, 25 Nov 2023 11:34:46 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r6vbx-00034V-Gs; Sat, 25 Nov 2023 11:34:45 -0500 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 44B47756094; Sat, 25 Nov 2023 17:34:25 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 3B3BC756078; Sat, 25 Nov 2023 17:34:25 +0100 (CET) From: BALATON Zoltan Subject: [PATCH v2 for-8.2] ppc/amigaone: Allow running AmigaOS without firmware image To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Daniel Henrique Barboza , clg@kaod.org, philmd@linaro.org Message-Id: <20231125163425.3B3BC756078@zero.eik.bme.hu> Date: Sat, 25 Nov 2023 17:34:25 +0100 (CET) X-Virus-Scanned: ClamAV using ClamSMTP Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1700930153467100003 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The machine uses a modified U-Boot under GPL license but the sources of it are lost with only a binary available so it cannot be included in QEMU. Allow running without the firmware image with -bios none which can be used when calling a boot loader directly and thus simplifying booting guests. We need a small routine that AmigaOS calls from ROM which is added in this case to allow booting AmigaOS without external firmware image. Signed-off-by: BALATON Zoltan --- v2: Unfortunately AmigaOS needs some additional ROM part which is added Please merge for 8.2 as it allows booting AmigaOS simpler without having to download separate firmware. hw/ppc/amigaone.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/hw/ppc/amigaone.c b/hw/ppc/amigaone.c index 992a55e632..a11d2d5556 100644 --- a/hw/ppc/amigaone.c +++ b/hw/ppc/amigaone.c @@ -40,6 +40,16 @@ #define PROM_ADDR 0xfff00000 #define PROM_SIZE (512 * KiB) =20 +/* AmigaOS calls this routine from ROM, use this if -bios none */ +static const char dummy_fw[] =3D { + 0x38, 0x00, 0x00, 0x08, /* li r0,8 */ + 0x7c, 0x09, 0x03, 0xa6, /* mtctr r0 */ + 0x54, 0x63, 0xf8, 0x7e, /* srwi r3,r3,1 */ + 0x42, 0x00, 0xff, 0xfc, /* bdnz 0x8 */ + 0x7c, 0x63, 0x18, 0xf8, /* not r3,r3 */ + 0x4e, 0x80, 0x00, 0x20, /* blr */ +}; + static void amigaone_cpu_reset(void *opaque) { PowerPCCPU *cpu =3D opaque; @@ -94,17 +104,21 @@ static void amigaone_init(MachineState *machine) } =20 /* allocate and load firmware */ + rom =3D g_new(MemoryRegion, 1); + memory_region_init_rom(rom, NULL, "rom", PROM_SIZE, &error_fatal); + memory_region_add_subregion(get_system_memory(), PROM_ADDR, rom); filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, fwname); if (filename) { - rom =3D g_new(MemoryRegion, 1); - memory_region_init_rom(rom, NULL, "rom", PROM_SIZE, &error_fatal); - memory_region_add_subregion(get_system_memory(), PROM_ADDR, rom); sz =3D load_image_targphys(filename, PROM_ADDR, PROM_SIZE); if (sz <=3D 0 || sz > PROM_SIZE) { error_report("Could not load firmware '%s'", filename); exit(1); } g_free(filename); + } else if (!strcmp(fwname, "none")) { + address_space_write_rom(&address_space_memory, 0xfff7ff80, + MEMTXATTRS_UNSPECIFIED, dummy_fw, + ARRAY_SIZE(dummy_fw)); } else if (!qtest_enabled()) { error_report("Could not find firmware '%s'", fwname); exit(1); --=20 2.30.9