From nobody Mon Apr 29 14:04:23 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=1593368507; cv=none; d=zohomail.com; s=zohoarc; b=Q7wsJwqMs1ncdkVVmn+BGbjzG3TyaUD+v3iKpDZamu1UE04BS9V979Rh4H9LIMOva3sI9JT2psFEOulOUh5cMLZdLz4d2Bqt/4ZUA6reHTLB81Z6mdBvWjuOXTPwF+JTNzC3DNEHaM9GPvyNnBy6W9r6wqgr0/EzSYGTf9o1sKY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368507; 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=lhpdhSO6/I/iEPsXGeq512+RL7fPWp82Q1GBjfiNwbVnfHz58LTDM97LFrqkZ5tMH+PSc46my2nVIPYJMwqnkkaqOVrwi1TIhKotbMsyDeozolZXH60A6YSFUczZVqwVh5hX0eCNBaDOXkpC63P08phIp88NaRxnYneQW06LZXE= 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 1593368507420247.72051804747377; Sun, 28 Jun 2020 11:21:47 -0700 (PDT) Received: from localhost ([::1]:53136 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpbw1-0003tl-H3 for importer@patchew.org; Sun, 28 Jun 2020 14:21:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51490) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuR-000236-D4; Sun, 28 Jun 2020 14:20:07 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:38347) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuO-0005Kf-Si; Sun, 28 Jun 2020 14:20:06 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id C5E74746335; Sun, 28 Jun 2020 20:20:01 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id A4493746331; Sun, 28 Jun 2020 20:20:01 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 01/11] mac_oldworld: Allow loading binary ROM image Date: Sun, 28 Jun 2020 20:03:36 +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/28 14:20:01 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 Mon Apr 29 14:04:23 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=1593368513; cv=none; d=zohomail.com; s=zohoarc; b=RzAbbP3MoOFWPaxEDLY1A8VHkAgE9tuCJoKMxHB9IzTylP0tRnaHJWqoLSfLMTjCSqMVsQzUatIBVbnDQ6CNahidDGIBwghs7aMk9ir5VLUPPypAaVWqwRbPQpp7tLw5JfFeZVzpNPJBS9gU/ICgHQq2S3a8rb/fAnFzgbucess= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368513; 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=B5na+OeFbeQDiB3sUG8nmC/Mgm9diKx6u43yof8QbKYvJeN54uPX3bPK/zxGUtMza8S2wxUEUmvV2DvTIUa65StUIYKLdl0aIWfJYMGsHbj7lU4sbFcV2qllzsrdmYAzLqAFmirE59MUQBTkE7r0BmWhfcQwh0jRWDiMploYEAk= 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 1593368513929660.4362291770651; Sun, 28 Jun 2020 11:21:53 -0700 (PDT) Received: from localhost ([::1]:53222 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpbw7-0003vr-Q5 for importer@patchew.org; Sun, 28 Jun 2020 14:21:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51502) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuR-00023S-EK; Sun, 28 Jun 2020 14:20:07 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:38354) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuO-0005Km-Tv; Sun, 28 Jun 2020 14:20:07 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id CEE5C7475FA; Sun, 28 Jun 2020 20:20:02 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id ACAF0746331; Sun, 28 Jun 2020 20:20:02 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 02/11] mac_newworld: Allow loading binary ROM image Date: Sun, 28 Jun 2020 20:03:36 +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/28 14:20:01 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" 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 --- 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 Mon Apr 29 14:04:23 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=1593368658; cv=none; d=zohomail.com; s=zohoarc; b=JT11lsKO7nxastk3ks86/PQSgcRK8hk3geZ/Jw9KrrHI8ZbS7fXuCIGDRQg6pxnzVZysHwfo1OalS2SdEwUkCZFw08eADhIOm3jldg1itCPcTvq8dnzwViQRybLrE0fg5M8kd+XUEAit5i0pUGJVeMuMseOcM30LSNgzAIdVlhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368658; 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=l6z2iUtDuQkXjtMoiJC0dwqZu2g3fepchgUk2WScSoU5wjhWI+u9P9CiEbPY4nWiNkCsHMn1FwQxKYv9/VzO9vc7EUg30WWO4Vrmyf33w4sHVmqI0cAKzJ9uIXYsmFnCiFXCU03ToJtXNeMtlNeTUHkIcZpj4n7SLAMrcjfi1kc= 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 15933686586910.8394816789736979; Sun, 28 Jun 2020 11:24:18 -0700 (PDT) Received: from localhost ([::1]:33512 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpbyT-0007OQ-C4 for importer@patchew.org; Sun, 28 Jun 2020 14:24:17 -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 1jpbuS-00024m-Hm; Sun, 28 Jun 2020 14:20:08 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:38359) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuP-0005Ky-K7; Sun, 28 Jun 2020 14:20:08 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id D91177482CD; Sun, 28 Jun 2020 20:20:03 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id BBCE5746331; Sun, 28 Jun 2020 20:20:03 +0200 (CEST) Message-Id: <8ece4381702aa5d5f004616e1818dd9b33dab620.1593367416.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 03/11] mac_oldworld: Drop a variable, use get_system_memory() directly Date: Sun, 28 Jun 2020 20:03:36 +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" 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 --- 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 Mon Apr 29 14:04:23 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=1593368535; cv=none; d=zohomail.com; s=zohoarc; b=IJT0wPuASxyIpW9av8L/t/4HPmRVOmxiv5mWewbIbvWWjEMbGQxMGQJzL5nzXULWLSabRrjlc1qwQC+hbYmfTnudMIn37pqg2fpgc+7o5UOfXUtroaPGQH/Au2T/bddQp0VcK3LF+n7uBZzLtZSgR12YztLEZB2VVlwK4PuOk0Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368535; 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=kyY6rzqd716FVlgj5AHBWQrYvfACz+pt5RW2VbaveS94QQrTQYjiwfJYNxChBJLZpgrtIM7aURKOHt9FwSsb/w+yw5LTVkAvVFEtbAw+zUWP11SAyJ80T6hD3mr3u1rNXh26UtjI4YB4ckqFpaioKSa1rDYFE3IgtVdBvu2xkVY= 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 1593368535172997.306393975803; Sun, 28 Jun 2020 11:22:15 -0700 (PDT) Received: from localhost ([::1]:55078 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpbwT-0004fi-P5 for importer@patchew.org; Sun, 28 Jun 2020 14:22:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51564) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuT-00025v-9q; Sun, 28 Jun 2020 14:20:09 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:38364) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuQ-0005LV-Cl; Sun, 28 Jun 2020 14:20:08 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id EE3727482D3; Sun, 28 Jun 2020 20:20:04 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id C4918746331; Sun, 28 Jun 2020 20:20:04 +0200 (CEST) Message-Id: <5e9db897c3b48bce89891599c55752acfae1b892.1593367416.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 04/11] mac_oldworld: Drop some variables Date: Sun, 28 Jun 2020 20:03:36 +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/28 14:20:01 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" 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 --- 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 Mon Apr 29 14:04:23 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=1593368670; cv=none; d=zohomail.com; s=zohoarc; b=h9V+LCKXFP2mViHR3RLSNB4eFSJZAnuXWPvgdoEYZtKkZ823E3XAz9QU0ae0yQVKlXehWCeggINn/FmjWzQWE0y8PkTiUKN8lU/AyCVchhfdTeFveKlQI+DIO3DPhegdGxrAZbS7/CAuGy4ZQZPSPsHSQrZ7hMXMQQoQll5N02E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368670; 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=sAyhLKn6Pm1LlKro5M5sNdbZoX5YC7d9QVpuSmV3LhM=; b=YiklWgsJHNIPnkoZqAZ7KdOtwMXDSYzlPHsOPqJ8HpquGzPwZZKXMcQZE0XE5PHf0HaNffgUXtPPPwKYHf0bCy9PG2s9EPbZb+xl3n+OsQdi7hISK2UhDlw0qityPDPtg3Yt3XpTECoeRA5jPhsIr29ZTPQJLHWjQBpWLUp2cbY= 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 1593368670275498.3395921889851; Sun, 28 Jun 2020 11:24:30 -0700 (PDT) Received: from localhost ([::1]:34260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpbye-0007jO-Sd for importer@patchew.org; Sun, 28 Jun 2020 14:24:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuT-00026i-Tj; Sun, 28 Jun 2020 14:20:09 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:38368) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuS-0005Lw-8m; Sun, 28 Jun 2020 14:20:09 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id EF9EC748DC8; Sun, 28 Jun 2020 20:20:05 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id D51FE746331; Sun, 28 Jun 2020 20:20:05 +0200 (CEST) Message-Id: <5c983137c0dc79ccaf26daf8d5321bac444898da.1593367416.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 05/11] grackle: Set revision in PCI config to match hardware Date: Sun, 28 Jun 2020 20:03:36 +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/28 14:20:01 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" Signed-off-by: BALATON Zoltan --- hw/pci-host/grackle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/pci-host/grackle.c b/hw/pci-host/grackle.c index 4b3af0c704..48d11f13ab 100644 --- a/hw/pci-host/grackle.c +++ b/hw/pci-host/grackle.c @@ -130,7 +130,7 @@ static void grackle_pci_class_init(ObjectClass *klass, = void *data) k->realize =3D grackle_pci_realize; k->vendor_id =3D PCI_VENDOR_ID_MOTOROLA; k->device_id =3D PCI_DEVICE_ID_MOTOROLA_MPC106; - k->revision =3D 0x00; + k->revision =3D 0x40; k->class_id =3D PCI_CLASS_BRIDGE_HOST; /* * PCI-facing part of the host bridge, not usable without the --=20 2.21.3 From nobody Mon Apr 29 14:04:23 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=1593368832; cv=none; d=zohomail.com; s=zohoarc; b=EO68mrOPZ7JNhVQesoFhZ5DwYWolT+iE5YZ4ZTK14N3VxcOmXHDY88oYby0TLr8UZaw5C25+SsNis6zGcVDM0y1WbFsNBjneik+zQUkhGCXLJ/GKhPhHUeVzjnZPeDXI8hiB2mEcxJgE5hGN+geLmAKtzdKsu8xpkpBBEXfhEAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368832; 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=WDGNggQunKir69JhTxQSYppWA3CV9q8nrUvKhmoNQws=; b=BPGdBJFTydyEAgNPovO3+rdHcf3oEhY3iV4YTaJIHTwLelz6Bz3mCNSTxbOfSz3gRwTLEa45O5MAKYpEhYDBTNqytNXUm1F1ggIFH3BbhUEky4Z+fTP57nxfGgRp7ZrTkPEEr2UjMXIWwGePxArSDyolGQfBULElxzK5GvLEz1c= 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 1593368832208184.0643024503222; Sun, 28 Jun 2020 11:27:12 -0700 (PDT) Received: from localhost ([::1]:44500 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpc1G-0003ZT-UN for importer@patchew.org; Sun, 28 Jun 2020 14:27:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51588) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuU-00027Z-AJ; Sun, 28 Jun 2020 14:20:10 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:38372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuS-0005M0-KJ; Sun, 28 Jun 2020 14:20:09 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 057C6748DCA; Sun, 28 Jun 2020 20:20:07 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id DD3B3746331; Sun, 28 Jun 2020 20:20:06 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 06/11] mac_oldworld: Rename ppc_heathrow_reset to ppc_heathrow_cpu_reset Date: Sun, 28 Jun 2020 20:03:36 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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/28 14:20:01 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" This function resets a CPU not the whole machine so reflect that in its name. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/mac_oldworld.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 4200008851..f97f241e0c 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -73,7 +73,7 @@ static uint64_t translate_kernel_address(void *opaque, ui= nt64_t addr) return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; } =20 -static void ppc_heathrow_reset(void *opaque) +static void ppc_heathrow_cpu_reset(void *opaque) { PowerPCCPU *cpu =3D opaque; =20 @@ -112,7 +112,7 @@ static void ppc_heathrow_init(MachineState *machine) =20 /* Set time-base frequency to 16.6 Mhz */ cpu_ppc_tb_init(env, TBFREQ); - qemu_register_reset(ppc_heathrow_reset, cpu); + qemu_register_reset(ppc_heathrow_cpu_reset, cpu); } =20 /* allocate RAM */ --=20 2.21.3 From nobody Mon Apr 29 14:04:23 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=1593368682; cv=none; d=zohomail.com; s=zohoarc; b=lbOANgEVYJ6d4vQeaN+cGEGV00NmQsYo8Y1XvAJA5U4orACIvC7CJ6eMkChtz40RJyydeE1ZS5oZ4dKCrkoEDPSz9WvMBeN65nF+RMxgpdDbFG5BuQrCMGVgE5bKZCeDjysDNOCusz/JCscsJliDVZ0WADJwqCeT4Fy8kRVrmPU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368682; 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=kOblapNSkpyb0DcOP6JUKuKmnTxMZLLXbq7eBHqSJNY=; b=WlYJSUL8P+rS4jYsSVNu0rNlwnXAIlfnEEYcRkzsKNTn5n+NkycEM5mvbWN8fUyWqdh12NXXrExowPNdLYWslLYr2/SUfzZy3nMtQjc618NuQwFMAL3ODPs+Bp6BBEvoNV4ueSH0FxPsEJM3mym1Uy5cog7U/VsYvL6GQXordQc= 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 1593368682846446.942514154333; Sun, 28 Jun 2020 11:24:42 -0700 (PDT) Received: from localhost ([::1]:35282 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpbyr-0008A5-LE for importer@patchew.org; Sun, 28 Jun 2020 14:24:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51610) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuV-0002Aw-DX; Sun, 28 Jun 2020 14:20:11 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]:38375) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuT-0005MQ-KE; Sun, 28 Jun 2020 14:20:11 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 1CE59748DCB; Sun, 28 Jun 2020 20:20:08 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id EC81E746331; Sun, 28 Jun 2020 20:20:07 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 07/11] mac_oldworld: Map macio to expected address at reset Date: Sun, 28 Jun 2020 20:03:36 +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/28 14:20:01 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" Add a reset function that maps macio to the address expected by the firmware of the board at startup. Signed-off-by: BALATON Zoltan --- hw/ppc/mac.h | 12 ++++++++++++ hw/ppc/mac_oldworld.c | 15 ++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h index 195967facd..58ae5a2226 100644 --- a/hw/ppc/mac.h +++ b/hw/ppc/mac.h @@ -60,6 +60,18 @@ #define OLDWORLD_SCREAMER_TX_DMA_IRQ 0x08 #define OLDWORLD_SCREAMER_RX_IRQ 0x09 =20 +/* g3beige machine */ +#define TYPE_HEATHROW_MACHINE MACHINE_TYPE_NAME("g3beige") +#define HEATHROW_MACHINE(obj) OBJECT_CHECK(HeathrowMachineState, (obj), \ + TYPE_HEATHROW_MACHINE) + +typedef struct HeathrowMachineState { + /*< private >*/ + MachineState parent; + + PCIDevice *macio; +} HeathrowMachineState; + /* New World IRQs */ #define NEWWORLD_CUDA_IRQ 0x19 #define NEWWORLD_PMU_IRQ 0x19 diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index f97f241e0c..13562e26e6 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -73,6 +73,15 @@ static uint64_t translate_kernel_address(void *opaque, u= int64_t addr) return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR; } =20 +static void ppc_heathrow_reset(MachineState *machine) +{ + HeathrowMachineState *m =3D HEATHROW_MACHINE(machine); + + qemu_devices_reset(); + pci_default_write_config(m->macio, PCI_COMMAND, PCI_COMMAND_MEMORY, 2); + pci_default_write_config(m->macio, PCI_BASE_ADDRESS_0, 0xf3000000, 4); +} + static void ppc_heathrow_cpu_reset(void *opaque) { PowerPCCPU *cpu =3D opaque; @@ -82,6 +91,7 @@ static void ppc_heathrow_cpu_reset(void *opaque) =20 static void ppc_heathrow_init(MachineState *machine) { + HeathrowMachineState *hm =3D HEATHROW_MACHINE(machine); ram_addr_t ram_size =3D machine->ram_size; const char *boot_device =3D machine->boot_order; PowerPCCPU *cpu =3D NULL; @@ -287,6 +297,7 @@ static void ppc_heathrow_init(MachineState *machine) =20 /* MacIO */ macio =3D pci_new(-1, TYPE_OLDWORLD_MACIO); + hm->macio =3D macio; dev =3D DEVICE(macio); qdev_prop_set_uint64(dev, "frequency", tbfreq); object_property_set_link(OBJECT(macio), OBJECT(pic_dev), "pic", @@ -439,6 +450,7 @@ static void heathrow_class_init(ObjectClass *oc, void *= data) =20 mc->desc =3D "Heathrow based PowerMAC"; mc->init =3D ppc_heathrow_init; + mc->reset =3D ppc_heathrow_reset; mc->block_default_type =3D IF_IDE; mc->max_cpus =3D MAX_CPUS; #ifndef TARGET_PPC64 @@ -455,9 +467,10 @@ static void heathrow_class_init(ObjectClass *oc, void = *data) } =20 static const TypeInfo ppc_heathrow_machine_info =3D { - .name =3D MACHINE_TYPE_NAME("g3beige"), + .name =3D TYPE_HEATHROW_MACHINE, .parent =3D TYPE_MACHINE, .class_init =3D heathrow_class_init, + .instance_size =3D sizeof(HeathrowMachineState), .interfaces =3D (InterfaceInfo[]) { { TYPE_FW_PATH_PROVIDER }, { } --=20 2.21.3 From nobody Mon Apr 29 14:04:23 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=1593368822; cv=none; d=zohomail.com; s=zohoarc; b=VKXJ9ZJvnTm3j894MX+AzOVxqFP3bSyBCpwXKf1z/UddbgfowwtMsIT6WatUGcti/sWE7CZhA8cclzwmAVNVjJSkPtnnGLZAYo6HutBOrDUVJhTh2XCxrLmKLApVamjGyQX5azc4xr3yMWL/9UEK5DZ/K9pRXf+t91dMAfSpOA4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368822; 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=OmoKSmcu2UCVOpfvk2qZ5FEIe5J6lTOlQ1tUxa0W4RM=; b=DZlfVMDzyut4LcDqwMTEdkOankecBaVtd/C4U2seClbjXy8VLJ+HBYw32OJ0fWne2y7VCqcDKLilfD+41T3NhPfIrsTWUl0N2u5D2z80aSpFodkXXyiENa8itOwmD3EbHcqtXMTnaQci4h/wnoUYojzzzL+GDlzuvPJLG3caVVQ= 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 1593368822730993.5447681009038; Sun, 28 Jun 2020 11:27:02 -0700 (PDT) Received: from localhost ([::1]:43654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpc17-0003Ew-Ih for importer@patchew.org; Sun, 28 Jun 2020 14:27:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuW-0002Dj-Ik; Sun, 28 Jun 2020 14:20:12 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:38378) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuU-0005N3-Mb; Sun, 28 Jun 2020 14:20:12 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 23982748DCC; Sun, 28 Jun 2020 20:20:09 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 04188746331; Sun, 28 Jun 2020 20:20:09 +0200 (CEST) Message-Id: <73921e8573a7888cb97cf974aa789318fafaa399.1593367416.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 08/11] mac_oldworld: Add machine ID register Date: Sun, 28 Jun 2020 20:03:36 +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" The G3 beige machine has a machine ID register that is accessed by the firmware to deternine the board config. Add basic emulation of it. Signed-off-by: BALATON Zoltan --- v6: Make MemoryRegionOps static const v4: Move MermoryRegion to MachineState, use constants hw/ppc/mac.h | 1 + hw/ppc/mac_oldworld.c | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h index 58ae5a2226..75f1853a7b 100644 --- a/hw/ppc/mac.h +++ b/hw/ppc/mac.h @@ -69,6 +69,7 @@ typedef struct HeathrowMachineState { /*< private >*/ MachineState parent; =20 + MemoryRegion machine_id; PCIDevice *macio; } HeathrowMachineState; =20 diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index 13562e26e6..8fbddba4eb 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -52,6 +52,9 @@ =20 #define MAX_IDE_BUS 2 #define CFG_ADDR 0xf0000510 +#define MACHINE_ID_ADDR 0xff000004 +#define MACHINE_ID_VAL 0x3d8c + #define TBFREQ 16600000UL #define CLOCKFREQ 266000000UL #define BUSFREQ 66000000UL @@ -89,6 +92,22 @@ static void ppc_heathrow_cpu_reset(void *opaque) cpu_reset(CPU(cpu)); } =20 +static uint64_t machine_id_read(void *opaque, hwaddr addr, unsigned size) +{ + return (addr =3D=3D 0 && size =3D=3D 2 ? MACHINE_ID_VAL : 0); +} + +static void machine_id_write(void *opaque, hwaddr addr, + uint64_t val, unsigned size) +{ + return; +} + +static const MemoryRegionOps machine_id_reg_ops =3D { + .read =3D machine_id_read, + .write =3D machine_id_write, +}; + static void ppc_heathrow_init(MachineState *machine) { HeathrowMachineState *hm =3D HEATHROW_MACHINE(machine); @@ -239,6 +258,11 @@ static void ppc_heathrow_init(MachineState *machine) } } =20 + memory_region_init_io(&hm->machine_id, OBJECT(machine), + &machine_id_reg_ops, NULL, "machine_id", 2); + memory_region_add_subregion(get_system_memory(), MACHINE_ID_ADDR, + &hm->machine_id); + /* XXX: we register only 1 output pin for heathrow PIC */ pic_dev =3D qdev_new(TYPE_HEATHROW); sysbus_realize_and_unref(SYS_BUS_DEVICE(pic_dev), &error_fatal); --=20 2.21.3 From nobody Mon Apr 29 14:04:23 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=1593368824; cv=none; d=zohomail.com; s=zohoarc; b=fZ5yNG/EKVJEqfkGZ0G+XPf6Uz9R+LsbjpDVmsQn47c5pmpixy3cvSASmqvIoabYbHsxTQPVVmJDjDRLMmtwh/RVOL9VeDhW86KzAzx+D5Wi88p0A33ZG9l04Wwun+72/Fbbi8XXajehqC07T20yg/ouw7g5G92iKWn19Ix1I98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368824; 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=ROBMg1aYv/LsDD76D/KG1xu3PLp1h/7VbLgmQ6QVUXJvJ+52exVBACmYDjpsUpZqcIZGrcny+7WPzoKfsQhbSJgP96/JOuP8lFSC2H7AvyXKuEn6ynO7B5Kb7VbEws8yAXNPTvcOIRyIEkcGZF7GO9D1q6/vp/rhyQ6hYiaAGvQ= 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 1593368824989580.5967477388784; Sun, 28 Jun 2020 11:27:04 -0700 (PDT) Received: from localhost ([::1]:43910 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpc19-0003LE-MK for importer@patchew.org; Sun, 28 Jun 2020 14:27:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51662) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuY-0002HP-84; Sun, 28 Jun 2020 14:20:14 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:38387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuV-0005NQ-SR; Sun, 28 Jun 2020 14:20:13 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 58EC0748DCD; Sun, 28 Jun 2020 20:20:10 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 11777746331; Sun, 28 Jun 2020 20:20:10 +0200 (CEST) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 09/11] i2c: Match parameters of i2c_start_transfer and i2c_send_recv Date: Sun, 28 Jun 2020 20:03:36 +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 Mon Apr 29 14:04:23 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=1593368734; cv=none; d=zohomail.com; s=zohoarc; b=Hj+QBSeCze6VtJIloGP10PSZ7wOwrU2Wv/hAEL0zVwjmlRDCZsggq8a1E7IFsPQvGsqTFskyo4gJcz0mdl+ey6xygsJWRoUChCgvvUYjqjyMn9UEnw2CdFktbQg6axwU27Wcb9rDgb2N8oCWUMYiOKDpBluLRnCad6Vg/DFI4kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368734; 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=AaY5abZyfnu7Q7ZpwNOlyA/3mvEBf2x1CaSFp6dPWoxhP9RMG0EownXYOcoWT6VMd1tI6hx/u6+ZVB09bFp9n8bkDSGMgimTtRJBxT97O5hG71q0BENqWCPeVRX93cqvJkF8u42YC2iApGBwTl0Hs+EBQPiFUSh+acV792C9oac= 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 1593368734497969.6884022139926; Sun, 28 Jun 2020 11:25:34 -0700 (PDT) Received: from localhost ([::1]:37520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpbzh-0000cX-4H for importer@patchew.org; Sun, 28 Jun 2020 14:25:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51686) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuZ-0002Jz-Av; Sun, 28 Jun 2020 14:20:15 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:38392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuW-0005Nw-Td; Sun, 28 Jun 2020 14:20:14 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 54C9074633D; Sun, 28 Jun 2020 20:20:11 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 20A76746331; Sun, 28 Jun 2020 20:20:11 +0200 (CEST) Message-Id: <2d6ab0ef6aef80311a24089ab2f1152f554dcd98.1593367416.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [RFC PATCH v6 10/11] WIP macio/cuda: Attempt to add i2c support Date: Sun, 28 Jun 2020 20:03:36 +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" 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 Mon Apr 29 14:04:23 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=1593368938; cv=none; d=zohomail.com; s=zohoarc; b=le+mqAemPYQ5gEwn9Z7Sx9A3LlRZe1+uVrUIS8voXpdL2ph8+bv4fsRH/xv8iiCzV3D0ezH9caRAVRiiOwMDX705wC6fCB+mX5hhprPQ7SrJ4hMnVy5vw7qT2eGj+BUASAJC/euAJL0Amw+TytBMVxBDbzQ2FqDbeSkRAd9QJQE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1593368938; 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=Q/UGzu4kAIDIDHSE4TgVoj+VV8xqzMBU8snYjEpU6N0=; b=FNmI/OyNvLO2qL7k7UYatIoi1sIbJY24/MHENw8FMfpDzp1rvRa+DX4NesaoOA07wozsKpbSqLzG4FiMEUDBsQqblvvfXV9uAMb2jDA6bsqKZUNV3nREhAkokg8wuo/BNKYAx0wwXWxKEM7d8GLaYe4vRk7M6V8L4gAb5kZ2cCw= 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 1593368938178668.7491770517074; Sun, 28 Jun 2020 11:28:58 -0700 (PDT) Received: from localhost ([::1]:49942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jpc2z-0005sa-1y for importer@patchew.org; Sun, 28 Jun 2020 14:28:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51698) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbua-0002MM-DG; Sun, 28 Jun 2020 14:20:16 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:38396) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jpbuY-0005OP-BL; Sun, 28 Jun 2020 14:20:16 -0400 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 4FF50748DCF; Sun, 28 Jun 2020 20:20:12 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 2D50A746331; Sun, 28 Jun 2020 20:20:12 +0200 (CEST) Message-Id: <3f45213b3ef8435340e0f4c34922be6706129d18.1593367416.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v6 11/11] mac_oldworld: Add SPD data to cover RAM Date: Sun, 28 Jun 2020 20:03:36 +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" 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 8fbddba4eb..5ad54370d0 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" @@ -133,6 +134,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++) { @@ -150,8 +153,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, @@ -337,6 +348,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