From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593459142; cv=none; d=zohomail.com; s=zohoarc; b=KxBbEkglCBNhb8cJTcYLPhIkMAgu0v+H6vUc2fYCanezwAmUlODdUmhUue0RxYW5dgDsyLtRiLp5b3UdzkUunZ0FpduY6tJobcY/NU3fgwTuhck0xulPbRxP2sAFNqBLcM+sgPoucLPhc2tqxjlX3GjM50Hu4DaWnmHUugFqtBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593459142; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HY1utQGsCNJUlJj0r5TlpSGq5sfXIGYjsyki0x4np50=; b=avULmI9if6xEiEp2lmcHaPVZA9i3959Pyq13P6QF+BzGrcqVlgRVfY3vg9ES0N1iuUYgiW9ur62jr0KIBUyevkkxq4I4YsDsag7pB/taofqEaRDpoFlD7vpEraxZt0GwV0/R8SsI3V/mIwhT0w+XSqnkVhrE5+zYa3jcPW9oB/o= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593459142033740.1623913930341; Mon, 29 Jun 2020 12:32:22 -0700 (PDT) Received: from localhost ([::1]:47904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzVs-0006dO-Ry for importer@patchew.org; Mon, 29 Jun 2020 15:32:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRF-00081F-SB; Mon, 29 Jun 2020 15:27:33 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:42893) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRC-0002GZ-Df; Mon, 29 Jun 2020 15:27:33 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 83581748DD9; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 062FD746331; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v7 1/8] mac_oldworld: Allow loading binary ROM image Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/29 15:27:18 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The beige G3 Power Macintosh has a 4MB firmware ROM. Fix the size of the rom region and fall back to loading a binary image with -bios if loading ELF image failed. This allows testing emulation with a ROM image from real hardware as well as using an ELF OpenBIOS image. Signed-off-by: BALATON Zoltan --- v4: use load address from ELF to check if ROM is too big hw/ppc/mac_oldworld.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index f8c204ead7..baf3da6f90 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -59,6 +59,8 @@ #define NDRV_VGA_FILENAME "qemu_vga.ndrv" =20 #define GRACKLE_BASE 0xfec00000 +#define PROM_BASE 0xffc00000 +#define PROM_SIZE (4 * MiB) =20 static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) @@ -99,6 +101,7 @@ static void ppc_heathrow_init(MachineState *machine) SysBusDevice *s; DeviceState *dev, *pic_dev; BusState *adb_bus; + uint64_t bios_addr; int bios_size; unsigned int smp_cpus =3D machine->smp.cpus; uint16_t ppc_boot_device; @@ -127,24 +130,32 @@ static void ppc_heathrow_init(MachineState *machine) =20 memory_region_add_subregion(sysmem, 0, machine->ram); =20 - /* allocate and load BIOS */ - memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE, + /* allocate and load firmware ROM */ + memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", PROM_SIZE, &error_fatal); + memory_region_add_subregion(sysmem, PROM_BASE, bios); =20 - if (bios_name =3D=3D NULL) + if (!bios_name) { bios_name =3D PROM_FILENAME; + } filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); - memory_region_add_subregion(sysmem, PROM_ADDR, bios); - - /* Load OpenBIOS (ELF) */ if (filename) { - bios_size =3D load_elf(filename, NULL, 0, NULL, NULL, NULL, NULL, = NULL, - 1, PPC_ELF_MACHINE, 0, 0); + /* Load OpenBIOS (ELF) */ + bios_size =3D load_elf(filename, NULL, NULL, NULL, NULL, &bios_add= r, + NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); + if (bios_size <=3D 0) { + /* or load binary ROM image */ + bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE); + bios_addr =3D PROM_BASE; + } else { + /* load_elf sets high 32 bits for some reason, strip those */ + bios_addr &=3D 0xffffffffULL; + } g_free(filename); } else { bios_size =3D -1; } - if (bios_size < 0 || bios_size > BIOS_SIZE) { + if (bios_size < 0 || bios_addr - PROM_BASE + bios_size > PROM_SIZE) { error_report("could not load PowerPC bios '%s'", bios_name); exit(1); } --=20 2.21.3 From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593459040; cv=none; d=zohomail.com; s=zohoarc; b=SXE5EIXcAfle00eX9D1hr58G+XtF+EJtIymWliQQe6nUgLVxO5GuDOz4VkXaaw5eIdWz/HovPbuLQB68ENyDO3U22rOX63QRQqCzU73H1Lgp6UReO3n8DpkDpgVM26a5VXFoGOjEj2VFmuRFQbvJbzUZ3AWmDojrQTPx92rkigo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593459040; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zfZ0U5arl20U1jYtGTwSxPg25Lql8sWjQ4MAAEokS1M=; b=Qmy9jpYIskEVDGbqHF/cXLV7vjQ+vzXpOfSMeqsPMuW+0TImxK2aOY90xy0e3GSiubIoCDf/SmgSby0BTh6nKWTvYhlhBjhDFgBsmiinMVUyDZkdF1ZjJDrOtULsyeqYkyIN2sZv+sgohLZgrexGqXGSC16HOSRo4zMM85npKn0= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593459040266923.0304342114663; Mon, 29 Jun 2020 12:30:40 -0700 (PDT) Received: from localhost ([::1]:41680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzUF-0003yW-3M for importer@patchew.org; Mon, 29 Jun 2020 15:30:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRH-00082c-O1; Mon, 29 Jun 2020 15:27:35 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:42918) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRF-0002IM-Ns; Mon, 29 Jun 2020 15:27:35 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 87FD7748DDA; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 0B6A47475F9; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v7 2/8] mac_newworld: Allow loading binary ROM image Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Fall back to load binary ROM image if loading ELF fails. This also moves PROM_BASE and PROM_SIZE defines to board as these are matching the ROM size and address on this board and removes the now unused PROM_ADDR and BIOS_SIZE defines from common mac.h. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- Unlike mac_oldworld where the openbios-ppc image loads at end of ROM region here we only check size and assume ELF image is loaded from PROM_BASE, Checking the load addr here is tricky because this board is also be compiled both 64 and 32 bit and load_elf seems to always return 64 bit value so handling that could become a mess. If this is a problem then it's a preexisting one so should be fixed in a separate patch. This one just allows loading ROM binary too otherwise preserving previous behaviour. hw/ppc/mac.h | 2 -- hw/ppc/mac_newworld.c | 22 ++++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h index 04e498bc57..195967facd 100644 --- a/hw/ppc/mac.h +++ b/hw/ppc/mac.h @@ -40,10 +40,8 @@ /* SMP is not enabled, for now */ #define MAX_CPUS 1 =20 -#define BIOS_SIZE (1 * MiB) #define NVRAM_SIZE 0x2000 #define PROM_FILENAME "openbios-ppc" -#define PROM_ADDR 0xfff00000 =20 #define KERNEL_LOAD_ADDR 0x01000000 #define KERNEL_GAP 0x00100000 diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 828c5992ae..c88142af57 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -82,6 +82,8 @@ =20 #define NDRV_VGA_FILENAME "qemu_vga.ndrv" =20 +#define PROM_BASE 0xfff00000 +#define PROM_SIZE (1 * MiB) =20 static void fw_cfg_boot_set(void *opaque, const char *boot_device, Error **errp) @@ -100,7 +102,7 @@ static void ppc_core99_reset(void *opaque) =20 cpu_reset(CPU(cpu)); /* 970 CPUs want to get their initial IP as part of their boot protoco= l */ - cpu->env.nip =3D PROM_ADDR + 0x100; + cpu->env.nip =3D PROM_BASE + 0x100; } =20 /* PowerPC Mac99 hardware initialisation */ @@ -153,25 +155,29 @@ static void ppc_core99_init(MachineState *machine) /* allocate RAM */ memory_region_add_subregion(get_system_memory(), 0, machine->ram); =20 - /* allocate and load BIOS */ - memory_region_init_rom(bios, NULL, "ppc_core99.bios", BIOS_SIZE, + /* allocate and load firmware ROM */ + memory_region_init_rom(bios, NULL, "ppc_core99.bios", PROM_SIZE, &error_fatal); + memory_region_add_subregion(get_system_memory(), PROM_BASE, bios); =20 - if (bios_name =3D=3D NULL) + if (!bios_name) { bios_name =3D PROM_FILENAME; + } filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name); - memory_region_add_subregion(get_system_memory(), PROM_ADDR, bios); - - /* Load OpenBIOS (ELF) */ if (filename) { + /* Load OpenBIOS (ELF) */ bios_size =3D load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0); =20 + if (bios_size <=3D 0) { + /* or load binary ROM image */ + bios_size =3D load_image_targphys(filename, PROM_BASE, PROM_SI= ZE); + } g_free(filename); } else { bios_size =3D -1; } - if (bios_size < 0 || bios_size > BIOS_SIZE) { + if (bios_size < 0 || bios_size > PROM_SIZE) { error_report("could not load PowerPC bios '%s'", bios_name); exit(1); } --=20 2.21.3 From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593458924; cv=none; d=zohomail.com; s=zohoarc; b=hupuqLK3JAkF5Oi7CpHrb7MUZpXD9z/jPYFFXzjdppj0ptNvika6pEfgL+WtanaARmaeS9t9MK0uNWmVbxwnv9AP5bFKusHLK718kbpVqatC3TJcyJdoTX4iVJH/K3Ibl4UcVwIx7zpXxpojVEGHfkm7zpfXqiIAE9/uKaZfMJg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593458924; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7TFk/WkeULCoJZfZgVi0eHUqdMXTEM2mjF2/Knb+5pk=; b=abnm0xaA1juwDwy7kSCOey0QKl5VGir6qOh23IyJ6S5cVgUG1elc6PVD2J3rPSYKJw36kxNy1pRCLsYMJi0jqNxqZME4VtXF9r9a6VL5p/K+GnaA1BMxOeCQ/zt8HG3gGycZy+OVLrb7msH7ehjk1/htuRjSsyvJvJBTNthmK6U= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593458924440210.4299204901714; Mon, 29 Jun 2020 12:28:44 -0700 (PDT) Received: from localhost ([::1]:35238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzSM-0001Bc-C8 for importer@patchew.org; Mon, 29 Jun 2020 15:28:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRE-00080u-TA; Mon, 29 Jun 2020 15:27:32 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:42896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRC-0002Ga-Cs; Mon, 29 Jun 2020 15:27:32 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 866A2748DCD; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 1004E7482CD; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: <8ece4381702aa5d5f004616e1818dd9b33dab620.1593456926.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v7 3/8] mac_oldworld: Drop a variable, use get_system_memory() directly Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/29 15:27:18 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Half of the occurances already use get_system_memory() directly instead of sysmem variable, convert the two other uses to get_system_memory() too which seems to be more common and drop the variable. Signed-off-by: BALATON Zoltan Reviewed-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/mac_oldworld.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index baf3da6f90..d1c4244b1e 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -87,7 +87,6 @@ static void ppc_heathrow_init(MachineState *machine) const char *kernel_cmdline =3D machine->kernel_cmdline; const char *initrd_filename =3D machine->initrd_filename; const char *boot_device =3D machine->boot_order; - MemoryRegion *sysmem =3D get_system_memory(); PowerPCCPU *cpu =3D NULL; CPUPPCState *env =3D NULL; char *filename; @@ -128,12 +127,12 @@ static void ppc_heathrow_init(MachineState *machine) exit(1); } =20 - memory_region_add_subregion(sysmem, 0, machine->ram); + memory_region_add_subregion(get_system_memory(), 0, machine->ram); =20 /* allocate and load firmware ROM */ memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", PROM_SIZE, &error_fatal); - memory_region_add_subregion(sysmem, PROM_BASE, bios); + memory_region_add_subregion(get_system_memory(), PROM_BASE, bios); =20 if (!bios_name) { bios_name =3D PROM_FILENAME; --=20 2.21.3 From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593459039; cv=none; d=zohomail.com; s=zohoarc; b=US4BVonpBwhcBBnXnbItcEoCzjWe5MGMNlgXcjfEZwdsmtVbFKtKYU0qbWTYaVgSGEI/n+e2rr4dmzXOEQB6/MJeFJSx5GzwCU3eyPvEZRcA3mMNFCNRyGhTtwy86JOcWflDE47fatFQ6TxZsOn9wjnOKKZ3+csrjYzDaBiWLt8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593459039; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r19Lk8P7TTDCI713fw+nQq610hvi5gL0AWaH5yUAPiI=; b=JeTW2sUOpcm2b1D2aJTnTQRN2NgfJwWlqzK2VbYHyc+yi+aq/d5WT9sd5J1N7z9Td1H0ywEBGrOjlTsnu7hO+B8I0om3YwZ9pByy2bxseaioxpj1PV6fMwMbSxYvjNenBj25ujIH8kWQpwCdEVOq0MkWVky5BAJxAWLNyoB8oiU= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593459039164560.0049763015134; Mon, 29 Jun 2020 12:30:39 -0700 (PDT) Received: from localhost ([::1]:41570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzUD-0003vu-Tb for importer@patchew.org; Mon, 29 Jun 2020 15:30:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51540) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRF-00080w-2p; Mon, 29 Jun 2020 15:27:33 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:42885) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRC-0002GW-Co; Mon, 29 Jun 2020 15:27:32 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 4CCA2748DD1; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 14B577482D3; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: <5e9db897c3b48bce89891599c55752acfae1b892.1593456926.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v7 4/8] mac_oldworld: Drop some variables Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Values not used frequently enough may not worth putting in a local variable, especially with names almost as long as the original value because that does not improve readability, to the contrary it makes it harder to see what value is used. Drop a few such variables. Signed-off-by: BALATON Zoltan Reviewed-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/mac_oldworld.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index d1c4244b1e..4200008851 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -83,14 +83,11 @@ static void ppc_heathrow_reset(void *opaque) static void ppc_heathrow_init(MachineState *machine) { ram_addr_t ram_size =3D machine->ram_size; - const char *kernel_filename =3D machine->kernel_filename; - const char *kernel_cmdline =3D machine->kernel_cmdline; - const char *initrd_filename =3D machine->initrd_filename; const char *boot_device =3D machine->boot_order; PowerPCCPU *cpu =3D NULL; CPUPPCState *env =3D NULL; char *filename; - int linux_boot, i; + int i; MemoryRegion *bios =3D g_new(MemoryRegion, 1); uint32_t kernel_base, initrd_base, cmdline_base =3D 0; int32_t kernel_size, initrd_size; @@ -108,8 +105,6 @@ static void ppc_heathrow_init(MachineState *machine) void *fw_cfg; uint64_t tbfreq; =20 - linux_boot =3D (kernel_filename !=3D NULL); - /* init CPUs */ for (i =3D 0; i < smp_cpus; i++) { cpu =3D POWERPC_CPU(cpu_create(machine->cpu_type)); @@ -159,7 +154,7 @@ static void ppc_heathrow_init(MachineState *machine) exit(1); } =20 - if (linux_boot) { + if (machine->kernel_filename) { uint64_t lowaddr =3D 0; int bswap_needed; =20 @@ -169,30 +164,33 @@ static void ppc_heathrow_init(MachineState *machine) bswap_needed =3D 0; #endif kernel_base =3D KERNEL_LOAD_ADDR; - kernel_size =3D load_elf(kernel_filename, NULL, + kernel_size =3D load_elf(machine->kernel_filename, NULL, translate_kernel_address, NULL, NULL, &lowaddr, NULL, NULL, 1, PPC_ELF_MACH= INE, 0, 0); if (kernel_size < 0) - kernel_size =3D load_aout(kernel_filename, kernel_base, + kernel_size =3D load_aout(machine->kernel_filename, kernel_bas= e, ram_size - kernel_base, bswap_needed, TARGET_PAGE_SIZE); if (kernel_size < 0) - kernel_size =3D load_image_targphys(kernel_filename, + kernel_size =3D load_image_targphys(machine->kernel_filename, kernel_base, ram_size - kernel_base); if (kernel_size < 0) { - error_report("could not load kernel '%s'", kernel_filename); + error_report("could not load kernel '%s'", + machine->kernel_filename); exit(1); } /* load initrd */ - if (initrd_filename) { - initrd_base =3D TARGET_PAGE_ALIGN(kernel_base + kernel_size + = KERNEL_GAP); - initrd_size =3D load_image_targphys(initrd_filename, initrd_ba= se, + if (machine->initrd_filename) { + initrd_base =3D TARGET_PAGE_ALIGN(kernel_base + kernel_size + + KERNEL_GAP); + initrd_size =3D load_image_targphys(machine->initrd_filename, + initrd_base, ram_size - initrd_base); if (initrd_size < 0) { error_report("could not load initial ram disk '%s'", - initrd_filename); + machine->initrd_filename); exit(1); } cmdline_base =3D TARGET_PAGE_ALIGN(initrd_base + initrd_size); @@ -336,9 +334,10 @@ static void ppc_heathrow_init(MachineState *machine) fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base); fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size); - if (kernel_cmdline) { + if (machine->kernel_cmdline) { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base); - pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel= _cmdline); + pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, + machine->kernel_cmdline); } else { fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0); } --=20 2.21.3 From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593458924; cv=none; d=zohomail.com; s=zohoarc; b=UGpXGsBCw4A/BoYG6acXQaGD97KB4iv8FGElhJ8FBu5mBkc3vhoQ2mhrEPTFySy+Mjh3ljyk3Lk3tLRDD1mnKcItX6Me/uBSiBVxZtvIJNhfNkSB1JlowFQ5HlSMjwn+XOGwqiXziMlgg9k3dpKJxdE1f1Bd+gH4ElMe/F3ttxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593458924; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZFi7irsaS7VLW6FTCjcos6fHo/KPbBnuMKnIV4DzJfE=; b=HuPBQ+YB7QurtvKCVgpxOp9MxngNMtlwaKNcOqE006QA51fQvZWXo2jwT7QaRt6e/6faSTNcDzlC4uDz26GzancJ5HINSyqAUFbCIIvdefXKOLdrN38TdSR//CiYOmYxUKhdCycg8sWQMWIdW0Iae3Gl+Roo+4ixkG5+KEtDGE4= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593458924312619.4852293617616; Mon, 29 Jun 2020 12:28:44 -0700 (PDT) Received: from localhost ([::1]:35270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzSM-0001CE-HD for importer@patchew.org; Mon, 29 Jun 2020 15:28:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51594) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRH-00082A-Aw; Mon, 29 Jun 2020 15:27:35 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:42890) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRC-0002GY-NQ; Mon, 29 Jun 2020 15:27:35 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 686BC748DD8; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 19782748DCA; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v7 5/8] mac_oldworld: Change PCI address of macio to match real hardware Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/29 15:27:18 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The board firmware expect these to be at fixed addresses and programs them without probing, this patch puts the macio device at the expected PCI address. Signed-off-by: BALATON Zoltan Reviewed-by: Mark Cave-Ayland --- hw/ppc/mac_oldworld.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 4200008851..6276973c95 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -286,7 +286,7 @@ static void ppc_heathrow_init(MachineState *machine) ide_drive_get(hd, ARRAY_SIZE(hd)); =20 /* MacIO */ - macio =3D pci_new(-1, TYPE_OLDWORLD_MACIO); + macio =3D pci_new(PCI_DEVFN(16, 0), TYPE_OLDWORLD_MACIO); dev =3D DEVICE(macio); qdev_prop_set_uint64(dev, "frequency", tbfreq); object_property_set_link(OBJECT(macio), OBJECT(pic_dev), "pic", --=20 2.21.3 From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593459066; cv=none; d=zohomail.com; s=zohoarc; b=Ikva2xYdBpflESoSvR3iteIDKIUQH88fB/yFJ+BOOEVPy/mSEK5LoRr3qe9Vk1o7s5R4NLHOhBNfzPsrVtpf9lfmh5gti9dNiVlsd/ySO+1QYDy9w5IIg/2Oy48gEoZbZHn/CcWjCuJCC8ERX5aWWFo+eDXnJadtlEz6AhC4zrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593459066; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HiInLphKbK+mHVO1BW111T2YD+iH9MRHX+bo+0caezE=; b=e+cLI5nLJOmi5BK+Zyghg+oV8jfVwtuC7vdMf69BVNuc+Fh0LubpfRcrvdgYsGyVubnbakZnJBrSX+Ab9u8OmVx69B0LgKSdMlAVUYkEiRZPIsnztlonop7EZOMFkN3jHxCbaUnuF7naPcRLmwN6AxQd/LGIro7kkwUB20QlHKI= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593459066004352.7234786969043; Mon, 29 Jun 2020 12:31:06 -0700 (PDT) Received: from localhost ([::1]:43568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzUe-0004ox-N5 for importer@patchew.org; Mon, 29 Jun 2020 15:31:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRJ-00086n-LR; Mon, 29 Jun 2020 15:27:37 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:42921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRG-0002IU-D4; Mon, 29 Jun 2020 15:27:37 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id C5608748DCA; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 1E4B4748DCC; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: <015adea83c4708c5ed32e561bc8d0691ef839764.1593456926.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v7 6/8] i2c: Match parameters of i2c_start_transfer and i2c_send_recv Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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=2001:738:2001:2001::2001; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" These functions have a parameter that decides the direction of transfer but totally confusingly they don't match but inverted sense. To avoid frequent mistakes when using these functions change i2c_send_recv to match i2c_start_transfer. Also use bool in i2c_start_transfer instead of int to match i2c_send_recv. Signed-off-by: BALATON Zoltan --- This probably won't be the solution accepted as Philippe has an alternative series fixing this problem here: https://lists.nongnu.org/archive/html/qemu-devel/2020-06/msg07022.html but until that or something else is merged this will do for the next patch. When this gets sorted out I'll send a rebased version. hw/display/sm501.c | 2 +- hw/i2c/core.c | 34 +++++++++++++++++----------------- hw/i2c/ppc4xx_i2c.c | 2 +- include/hw/i2c/i2c.h | 4 ++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/hw/display/sm501.c b/hw/display/sm501.c index a7fc08c52b..e714674681 100644 --- a/hw/display/sm501.c +++ b/hw/display/sm501.c @@ -1041,7 +1041,7 @@ static void sm501_i2c_write(void *opaque, hwaddr addr= , uint64_t value, s->i2c_byte_count + 1, s->i2c_addr >> 1); for (i =3D 0; i <=3D s->i2c_byte_count; i++) { res =3D i2c_send_recv(s->i2c_bus, &s->i2c_data[i], - !(s->i2c_addr & 1)); + s->i2c_addr & 1); if (res) { SM501_DPRINTF("sm501 i2c : transfer failed" " i=3D%d, res=3D%d\n", i, res); diff --git a/hw/i2c/core.c b/hw/i2c/core.c index acf34a12d6..0303fefeaf 100644 --- a/hw/i2c/core.c +++ b/hw/i2c/core.c @@ -91,7 +91,7 @@ int i2c_bus_busy(I2CBus *bus) * without releasing the bus. If that fails, the bus is still * in a transaction. */ -int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv) +int i2c_start_transfer(I2CBus *bus, uint8_t address, bool recv) { BusChild *kid; I2CSlaveClass *sc; @@ -175,26 +175,14 @@ void i2c_end_transfer(I2CBus *bus) bus->broadcast =3D false; } =20 -int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send) +int i2c_send_recv(I2CBus *bus, uint8_t *data, bool recv) { I2CSlaveClass *sc; I2CSlave *s; I2CNode *node; int ret =3D 0; =20 - if (send) { - QLIST_FOREACH(node, &bus->current_devs, next) { - s =3D node->elt; - sc =3D I2C_SLAVE_GET_CLASS(s); - if (sc->send) { - trace_i2c_send(s->address, *data); - ret =3D ret || sc->send(s, *data); - } else { - ret =3D -1; - } - } - return ret ? -1 : 0; - } else { + if (recv) { ret =3D 0xff; if (!QLIST_EMPTY(&bus->current_devs) && !bus->broadcast) { sc =3D I2C_SLAVE_GET_CLASS(QLIST_FIRST(&bus->current_devs)->el= t); @@ -206,19 +194,31 @@ int i2c_send_recv(I2CBus *bus, uint8_t *data, bool se= nd) } *data =3D ret; return 0; + } else { + QLIST_FOREACH(node, &bus->current_devs, next) { + s =3D node->elt; + sc =3D I2C_SLAVE_GET_CLASS(s); + if (sc->send) { + trace_i2c_send(s->address, *data); + ret =3D ret || sc->send(s, *data); + } else { + ret =3D -1; + } + } + return ret ? -1 : 0; } } =20 int i2c_send(I2CBus *bus, uint8_t data) { - return i2c_send_recv(bus, &data, true); + return i2c_send_recv(bus, &data, false); } =20 uint8_t i2c_recv(I2CBus *bus) { uint8_t data =3D 0xff; =20 - i2c_send_recv(bus, &data, false); + i2c_send_recv(bus, &data, true); return data; } =20 diff --git a/hw/i2c/ppc4xx_i2c.c b/hw/i2c/ppc4xx_i2c.c index c0a8e04567..d3899203a4 100644 --- a/hw/i2c/ppc4xx_i2c.c +++ b/hw/i2c/ppc4xx_i2c.c @@ -239,7 +239,7 @@ static void ppc4xx_i2c_writeb(void *opaque, hwaddr addr= , uint64_t value, } } if (!(i2c->sts & IIC_STS_ERR) && - i2c_send_recv(i2c->bus, &i2c->mdata[i], !recv)) { + i2c_send_recv(i2c->bus, &i2c->mdata[i], recv)) { i2c->sts |=3D IIC_STS_ERR; i2c->extsts |=3D IIC_EXTSTS_XFRA; break; diff --git a/include/hw/i2c/i2c.h b/include/hw/i2c/i2c.h index d6e3d85faf..ad2475d6a2 100644 --- a/include/hw/i2c/i2c.h +++ b/include/hw/i2c/i2c.h @@ -72,10 +72,10 @@ struct I2CBus { I2CBus *i2c_init_bus(DeviceState *parent, const char *name); void i2c_set_slave_address(I2CSlave *dev, uint8_t address); int i2c_bus_busy(I2CBus *bus); -int i2c_start_transfer(I2CBus *bus, uint8_t address, int recv); +int i2c_start_transfer(I2CBus *bus, uint8_t address, bool recv); void i2c_end_transfer(I2CBus *bus); void i2c_nack(I2CBus *bus); -int i2c_send_recv(I2CBus *bus, uint8_t *data, bool send); +int i2c_send_recv(I2CBus *bus, uint8_t *data, bool recv); int i2c_send(I2CBus *bus, uint8_t data); uint8_t i2c_recv(I2CBus *bus); =20 --=20 2.21.3 From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593459274; cv=none; d=zohomail.com; s=zohoarc; b=XXfhwwBaou94HOLsct+c4T6396DCw1Jb4qWKKY4o5mQRRxaZFk6AOEeWc0g1cMN27YxqQDyRpJcitjXaEtWnsDWoQlskcFz2FsqUcVlR1wrBmnADIUsFfpiFSkKPbMscZQ8DWTwHDW0RsEkOKfzZT9mt6RMPK8op8514m9z7YLo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593459274; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3mzcplCAc7uxEGgApxHdblQOnVuW4oZ+Tx++/MRxKq4=; b=k/8U7+ei+AmYk/cf0b2FYbw2EYrGBezf+7f34REBwDFahbXkVe8MtkWmMX4AwSmdKo9aOkowFcA/cjdMwNcNDD0CPpUE6v/O4ZR6rp/FUWEbmNnP4xXiEYb6GciuaagmgxTd3P4WSKhgG6AnprXCk2vcR2Yz7W2Fv4v0yIPSjZg= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593459274523793.3681359679404; Mon, 29 Jun 2020 12:34:34 -0700 (PDT) Received: from localhost ([::1]:54154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzY1-0000zt-AP for importer@patchew.org; Mon, 29 Jun 2020 15:34:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRI-00084g-P0; Mon, 29 Jun 2020 15:27:36 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:42919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRF-0002IL-OR; Mon, 29 Jun 2020 15:27:36 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id B60B2748DDB; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 2289E748DC8; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: <93758f65ef21d977fe835364bb1386fb4c03a6ce.1593456926.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [RFC PATCH v7 7/8] WIP macio/cuda: Attempt to add i2c support Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/29 15:27:18 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" This is not a final, RFC patch attempt to implement i2c bus in CUDA needed for firmware to access SPD data of installed RAM. The skeleton is there but actual implementation of I2C commands need to be refined because I don't know how this is supposed to work. In my understanding after an I2C command (at least for combined transfer) CUDA should enter a mode where reading subsequent values from VIA[SR] should return bytes received from the i2C device but not sure what ends this mode or how to model it correctly. So this patch just returns fixed amount of bytes expected by reading SPD eeproms just to make testing the firmware ROM possible. Help fixing and finishing this is welcome, I don't plan to spend more time with this so just submitted it for whoever picks this up. Signed-off-by: BALATON Zoltan --- hw/misc/macio/cuda.c | 76 +++++++++++++++++++++++++++++++++++- include/hw/misc/macio/cuda.h | 1 + 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c index 5bbc7770fa..3fc9773717 100644 --- a/hw/misc/macio/cuda.c +++ b/hw/misc/macio/cuda.c @@ -28,6 +28,7 @@ #include "hw/ppc/mac.h" #include "hw/qdev-properties.h" #include "migration/vmstate.h" +#include "hw/i2c/i2c.h" #include "hw/input/adb.h" #include "hw/misc/mos6522.h" #include "hw/misc/macio/cuda.h" @@ -370,6 +371,75 @@ static bool cuda_cmd_set_time(CUDAState *s, return true; } =20 +static bool cuda_cmd_get_set_iic(CUDAState *s, + const uint8_t *in_data, int in_len, + uint8_t *out_data, int *out_len) +{ + int i; + + qemu_log_mask(LOG_UNIMP, "CUDA: unimplemented GET_SET_IIC %s 0x%x %d\n= ", + (in_data[0] & 1 ? "read" : "write"), in_data[0] >> 1, + in_len); + if (i2c_start_transfer(s->i2c_bus, in_data[0] >> 1, in_data[0] & 1)) { + return false; + } + for (i =3D 0; i < in_len - 3; i++) { + if (i2c_send(s->i2c_bus, in_data[i])) { + i2c_end_transfer(s->i2c_bus); + return false; + } + } + return true; +} + +static bool cuda_cmd_combined_iic(CUDAState *s, + const uint8_t *in_data, int in_len, + uint8_t *out_data, int *out_len) +{ + int i; + + if (in_len < 3) { + qemu_log_mask(LOG_GUEST_ERROR, + "CUDA: COMBINED_FORMAT_IIC too few input bytes\n"); + return false; + } + if ((in_data[0] & 0xfe) !=3D (in_data[2] & 0xfe)) { + qemu_log_mask(LOG_GUEST_ERROR, + "CUDA: COMBINED_FORMAT_IIC address mismatch\n"); + return false; + } + + uint8_t data =3D in_data[1]; + if (i2c_start_transfer(s->i2c_bus, in_data[0] >> 1, in_data[0] & 1) || + i2c_send_recv(s->i2c_bus, &data, in_data[0] & 1)) { + return false; + } + i2c_end_transfer(s->i2c_bus); + if (in_data[2] & 1) { + if (i2c_start_transfer(s->i2c_bus, in_data[2] >> 1, in_data[2] & 1= )) { + i2c_end_transfer(s->i2c_bus); + return false; + } + for (i =3D 0; i < 5; i++) { + if (i2c_send_recv(s->i2c_bus, &out_data[i], in_data[2] & 1)) { + i2c_end_transfer(s->i2c_bus); + return false; + } + } + *out_len =3D i; + i2c_end_transfer(s->i2c_bus); + } else { + for (i =3D 0; i < in_len - 3; i++) { + data =3D in_data[3 + i]; + if (i2c_send_recv(s->i2c_bus, &data, in_data[2] & 1)) { + i2c_end_transfer(s->i2c_bus); + return false; + } + } + } + return true; +} + static const CudaCommand handlers[] =3D { { CUDA_AUTOPOLL, "AUTOPOLL", cuda_cmd_autopoll }, { CUDA_SET_AUTO_RATE, "SET_AUTO_RATE", cuda_cmd_set_autorate }, @@ -382,6 +452,8 @@ static const CudaCommand handlers[] =3D { cuda_cmd_set_power_message }, { CUDA_GET_TIME, "GET_TIME", cuda_cmd_get_time }, { CUDA_SET_TIME, "SET_TIME", cuda_cmd_set_time }, + { CUDA_GET_SET_IIC, "GET_SET_IIC", cuda_cmd_get_set_iic }, + { CUDA_COMBINED_FORMAT_IIC, "COMBINED_FORMAT_IIC", cuda_cmd_combined_i= ic }, }; =20 static void cuda_receive_packet(CUDAState *s, @@ -549,6 +621,7 @@ static void cuda_init(Object *obj) { CUDAState *s =3D CUDA(obj); SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + DeviceState *dev =3D DEVICE(obj); =20 object_initialize_child(obj, "mos6522-cuda", &s->mos6522_cuda, TYPE_MOS6522_CUDA); @@ -557,7 +630,8 @@ static void cuda_init(Object *obj) sysbus_init_mmio(sbd, &s->mem); =20 qbus_create_inplace(&s->adb_bus, sizeof(s->adb_bus), TYPE_ADB_BUS, - DEVICE(obj), "adb.0"); + dev, "adb.0"); + s->i2c_bus =3D i2c_init_bus(dev, "i2c"); } =20 static Property cuda_properties[] =3D { diff --git a/include/hw/misc/macio/cuda.h b/include/hw/misc/macio/cuda.h index a8cf0be1ec..6856ed7704 100644 --- a/include/hw/misc/macio/cuda.h +++ b/include/hw/misc/macio/cuda.h @@ -79,6 +79,7 @@ typedef struct CUDAState { =20 ADBBusState adb_bus; MOS6522CUDAState mos6522_cuda; + I2CBus *i2c_bus; =20 uint32_t tick_offset; uint64_t tb_frequency; --=20 2.21.3 From nobody Sat Apr 20 12:28:32 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 ARC-Seal: i=1; a=rsa-sha256; t=1593459168; cv=none; d=zohomail.com; s=zohoarc; b=OFgSjkKmckUKCoXMao7i9ZpHG+iVHUONFlOoKirrRpyWOHD/Lrlp0HgsLxLcjTEZrPW4/3fAvQ5mHSW9Rxq9w+EWcJtFkl0zi0+lyny/bmSfJfdwI8XtriKF9VCUReCx00ATV8Y57RxlvQBIO7+0T6H5WtrWOoYGZcNgIj9OUoU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593459168; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LN4Q5RWNFGGWI4XW5fcd/qctFmRc19y9xocp9lLEJr0=; b=iJTTD4WX+2Aw9lEuMONR0TMhe4SVFAcoEjZQLthKLjusRlu9QzF5b3j1xohGq8+lvCcGL7hOfFBrE4z/wB75vdU2ffvYIkeoU0Brh9+VDnbXOwZR0yJv9RK50IKtk6K1ydQvhChU8tto0EJmb40w7FpvJaQqUJwH9GKsmIHLryk= ARC-Authentication-Results: i=1; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1593459168342628.9179898841057; Mon, 29 Jun 2020 12:32:48 -0700 (PDT) Received: from localhost ([::1]:49180 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpzWF-0007A1-4h for importer@patchew.org; Mon, 29 Jun 2020 15:32:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRI-00083T-8A; Mon, 29 Jun 2020 15:27:36 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:42920) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpzRG-0002IV-3I; Mon, 29 Jun 2020 15:27:35 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id B86E5748DDC; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 27F9D748DCB; Mon, 29 Jun 2020 21:27:18 +0200 (CEST) Message-Id: <9f5f44878dc0f60b073201e657d6e4dcc940f68c.1593456926.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v7 8/8] mac_oldworld: Add SPD data to cover RAM Date: Mon, 29 Jun 2020 20:55:26 +0200 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org X-Spam-Probability: 8% 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-detected-operating-system: by eggs.gnu.org: First seen = 2020/06/29 15:27:18 X-ACL-Warn: Detected OS = FreeBSD 9.x or newer [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Howard Spoelstra , Mark Cave-Ayland , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" OpenBIOS gets RAM size via fw_cfg but rhe original board firmware detects RAM using SPD data so generate and add SDP eeproms to cover as much RAM as possible to describe with SPD (this may be less than the actual ram_size due to SDRAM size constraints). This patch is more complex as it should be which I intend to fix once agreement can be made on how to get back the necessary functionality removed by previous patches. See in this thread: https://lists.nongnu.org/archive/html/qemu-devel/2020-06/msg08710.html Signed-off-by: BALATON Zoltan --- hw/ppc/mac_oldworld.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 6276973c95..6a27287c9f 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -34,6 +34,7 @@ #include "hw/input/adb.h" #include "sysemu/sysemu.h" #include "net/net.h" +#include "hw/i2c/smbus_eeprom.h" #include "hw/isa/isa.h" #include "hw/pci/pci.h" #include "hw/pci/pci_host.h" @@ -104,6 +105,8 @@ static void ppc_heathrow_init(MachineState *machine) DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS]; void *fw_cfg; uint64_t tbfreq; + uint8_t *spd_data[3] =3D {}; + I2CBus *i2c_bus; =20 /* init CPUs */ for (i =3D 0; i < smp_cpus; i++) { @@ -121,8 +124,16 @@ static void ppc_heathrow_init(MachineState *machine) "maximum 2047 MB", ram_size / MiB); exit(1); } - memory_region_add_subregion(get_system_memory(), 0, machine->ram); + for (i =3D 0; i < 3; i++) { + int size_left =3D ram_size - i * 512 * MiB; + if (size_left > 0) { + uint32_t s =3D size_left / MiB; + s =3D (s > 512 ? 512 : s); + s =3D 1U << (31 - clz32(s)); + spd_data[i] =3D spd_data_generate(SDR, s * MiB); + } + } =20 /* allocate and load firmware ROM */ memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", PROM_SIZE, @@ -302,6 +313,12 @@ static void ppc_heathrow_init(MachineState *machine) macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); =20 dev =3D DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); + i2c_bus =3D I2C_BUS(qdev_get_child_bus(dev, "i2c")); + for (i =3D 0; i < 3; i++) { + if (spd_data[i]) { + smbus_eeprom_init_one(i2c_bus, 0x50 + i, spd_data[i]); + } + } adb_bus =3D qdev_get_child_bus(dev, "adb.0"); dev =3D qdev_new(TYPE_ADB_KEYBOARD); qdev_realize_and_unref(dev, adb_bus, &error_fatal); --=20 2.21.3