From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761177987897746.5461443083242; Wed, 22 Oct 2025 17:06:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqO-0007X3-8s; Wed, 22 Oct 2025 20:06:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqN-0007Vu-1P; Wed, 22 Oct 2025 20:06:15 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqK-0004Y1-1V; Wed, 22 Oct 2025 20:06:14 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id D2F5B5972EC; Thu, 23 Oct 2025 02:06:09 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id IXvh2wpz9IbW; Thu, 23 Oct 2025 02:06:07 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id C542F5972EB; Thu, 23 Oct 2025 02:06:07 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: <366f14ce852415cc079727c54ac21a2aa6ff3917.1761176219.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 01/12] ppc/vof: Make nextprop behave more like Open Firmware MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:07 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178002128158500 Content-Type: text/plain; charset="utf-8" The FDT does not normally store name properties but reconstructs it from path but Open Firmware specification says each node should at least have this property. This is correctly handled in getprop but nextprop should also return it even if not present as a property. Explicit name properties are still allowed because they are needed e.g. on the root node that guests expect to have specific names as seen on real machines instead of being empty so sometimes the node name may need to be overriden. For example on pegasos MorphOS checks the name of "/" and expects to find bplan,Pegasos2 which is how it identifies the machine. Signed-off-by: BALATON Zoltan Reviewed-by: Alexey Kardashevskiy --- hw/ppc/vof.c | 50 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c index f14efa3a7c..5ecfc68910 100644 --- a/hw/ppc/vof.c +++ b/hw/ppc/vof.c @@ -353,34 +353,50 @@ static uint32_t vof_nextprop(const void *fdt, uint32_= t phandle, { int offset, nodeoff =3D fdt_node_offset_by_phandle(fdt, phandle); char prev[OF_PROPNAME_LEN_MAX + 1]; - const char *tmp; + const char *tmp =3D NULL; + bool match =3D false; =20 if (readstr(prevaddr, prev, sizeof(prev))) { return PROM_ERROR; } - - fdt_for_each_property_offset(offset, fdt, nodeoff) { - if (!fdt_getprop_by_offset(fdt, offset, &tmp, NULL)) { - return 0; + /* + * "name" may or may not be present in fdt but we should still return = it. + * Do that first and then skip it if seen later. + */ + if (prev[0] =3D=3D '\0') { + tmp =3D "name"; + } else { + if (strcmp(prev, "name") =3D=3D 0) { + prev[0] =3D '\0'; } - if (prev[0] =3D=3D '\0' || strcmp(prev, tmp) =3D=3D 0) { - if (prev[0] !=3D '\0') { - offset =3D fdt_next_property_offset(fdt, offset); - if (offset < 0) { - return 0; - } - } + fdt_for_each_property_offset(offset, fdt, nodeoff) { if (!fdt_getprop_by_offset(fdt, offset, &tmp, NULL)) { return 0; } - - if (VOF_MEM_WRITE(nameaddr, tmp, strlen(tmp) + 1) !=3D MEMTX_O= K) { - return PROM_ERROR; + if (strcmp(tmp, "name") =3D=3D 0) { + continue; + } + if (match) { + break; } - return 1; + if (strcmp(prev, tmp) =3D=3D 0) { + match =3D true; + continue; + } + if (prev[0] =3D=3D '\0') { + break; + } + } + if (offset < 0) { + return 0; } } - + if (tmp) { + if (VOF_MEM_WRITE(nameaddr, tmp, strlen(tmp) + 1) !=3D MEMTX_OK) { + return PROM_ERROR; + } + return 1; + } return 0; } =20 --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 176117802516269.88867809400199; Wed, 22 Oct 2025 17:07:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqV-0007bj-Am; Wed, 22 Oct 2025 20:06:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqO-0007Y2-IW; Wed, 22 Oct 2025 20:06:17 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqK-0004Y4-NW; Wed, 22 Oct 2025 20:06:16 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id D8BC65972E3; Thu, 23 Oct 2025 02:06:10 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id hlByTPxKlI5q; Thu, 23 Oct 2025 02:06:08 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id D3ADD5972ED; Thu, 23 Oct 2025 02:06:08 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 02/12] hw/ppc/pegasos2: Remove explicit name properties from device tree MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:08 +0200 (CEST) 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-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178031663154100 Content-Type: text/plain; charset="utf-8" These are not needed any more now that VOF can handle it. Signed-off-by: BALATON Zoltan Reviewed-by: Harsh Prateek Bora --- hw/ppc/pegasos2.c | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index e15cf96427..73995624e5 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -662,7 +662,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) qemu_fdt_setprop_cell(fi->fdt, fi->path, "#size-cells", 1); qemu_fdt_setprop_cell(fi->fdt, fi->path, "#address-cells", 2); qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "isa"); - qemu_fdt_setprop_string(fi->fdt, fi->path, "name", "isa"); =20 /* additional devices */ g_string_printf(name, "%s/lpt@i3bc", fi->path); @@ -677,7 +676,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) cells[2] =3D cpu_to_be32(8); qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "lpt"); - qemu_fdt_setprop_string(fi->fdt, name->str, "name", "lpt"); =20 g_string_printf(name, "%s/fdc@i3f0", fi->path); qemu_fdt_add_subnode(fi->fdt, name->str); @@ -691,7 +689,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) cells[2] =3D cpu_to_be32(8); qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "fdc"); - qemu_fdt_setprop_string(fi->fdt, name->str, "name", "fdc"); =20 g_string_printf(name, "%s/timer@i40", fi->path); qemu_fdt_add_subnode(fi->fdt, name->str); @@ -701,7 +698,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) cells[2] =3D cpu_to_be32(8); qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "timer"); - qemu_fdt_setprop_string(fi->fdt, name->str, "name", "timer"); =20 g_string_printf(name, "%s/rtc@i70", fi->path); qemu_fdt_add_subnode(fi->fdt, name->str); @@ -716,7 +712,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) cells[2] =3D cpu_to_be32(2); qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "rtc"); - qemu_fdt_setprop_string(fi->fdt, name->str, "name", "rtc"); =20 g_string_printf(name, "%s/keyboard@i60", fi->path); qemu_fdt_add_subnode(fi->fdt, name->str); @@ -729,7 +724,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) cells[2] =3D cpu_to_be32(5); qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "keyboard"); - qemu_fdt_setprop_string(fi->fdt, name->str, "name", "keyboard"); =20 g_string_printf(name, "%s/8042@i60", fi->path); qemu_fdt_add_subnode(fi->fdt, name->str); @@ -743,7 +737,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) cells[2] =3D cpu_to_be32(5); qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", ""); - qemu_fdt_setprop_string(fi->fdt, name->str, "name", "8042"); =20 g_string_printf(name, "%s/serial@i2f8", fi->path); qemu_fdt_add_subnode(fi->fdt, name->str); @@ -757,7 +750,6 @@ static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *= fi) cells[2] =3D cpu_to_be32(8); qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "serial"); - qemu_fdt_setprop_string(fi->fdt, name->str, "name", "serial"); =20 g_string_free(name, TRUE); } @@ -846,7 +838,6 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, v= oid *opaque) j +=3D 5; } qemu_fdt_setprop(fi->fdt, node->str, "reg", cells, j * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, node->str, "name", name ?: pn); if (pci_get_byte(&d->config[PCI_INTERRUPT_PIN])) { qemu_fdt_setprop_cell(fi->fdt, node->str, "interrupts", pci_get_byte(&d->config[PCI_INTERRUPT_PIN])); @@ -916,7 +907,6 @@ static void *build_fdt(MachineState *machine, int *fdt_= size) qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#size-cells", 2); qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#address-cells", 3); qemu_fdt_setprop_string(fdt, "/pci@c0000000", "device_type", "pci"); - qemu_fdt_setprop_string(fdt, "/pci@c0000000", "name", "pci"); =20 fi.path =3D "/pci@c0000000"; pci_bus =3D mv64361_get_pci_bus(pm->mv, 0); @@ -951,7 +941,6 @@ static void *build_fdt(MachineState *machine, int *fdt_= size) qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#size-cells", 2); qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#address-cells", 3); qemu_fdt_setprop_string(fdt, "/pci@80000000", "device_type", "pci"); - qemu_fdt_setprop_string(fdt, "/pci@80000000", "name", "pci"); =20 fi.path =3D "/pci@80000000"; pci_bus =3D mv64361_get_pci_bus(pm->mv, 1); @@ -959,7 +948,6 @@ static void *build_fdt(MachineState *machine, int *fdt_= size) =20 qemu_fdt_add_subnode(fdt, "/failsafe"); qemu_fdt_setprop_string(fdt, "/failsafe", "device_type", "serial"); - qemu_fdt_setprop_string(fdt, "/failsafe", "name", "failsafe"); =20 qemu_fdt_add_subnode(fdt, "/rtas"); qemu_fdt_setprop_cell(fdt, "/rtas", "system-reboot", RTAS_SYSTEM_REBOO= T); @@ -989,14 +977,12 @@ static void *build_fdt(MachineState *machine, int *fd= t_size) qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-display-device", 0); qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size", 20); qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-version", 1); - qemu_fdt_setprop_string(fdt, "/rtas", "name", "rtas"); =20 /* cpus */ qemu_fdt_add_subnode(fdt, "/cpus"); qemu_fdt_setprop_cell(fdt, "/cpus", "#cpus", 1); qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 1); qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0); - qemu_fdt_setprop_string(fdt, "/cpus", "name", "cpus"); =20 /* FIXME Get CPU name from CPU object */ const char *cp =3D "/cpus/PowerPC,G4"; @@ -1048,7 +1034,6 @@ static void *build_fdt(MachineState *machine, int *fd= t_size) cells[1] =3D 0; qemu_fdt_setprop(fdt, cp, "reg", cells, 2 * sizeof(cells[0])); qemu_fdt_setprop_string(fdt, cp, "device_type", "cpu"); - qemu_fdt_setprop_string(fdt, cp, "name", strrchr(cp, '/') + 1); =20 /* memory */ qemu_fdt_add_subnode(fdt, "/memory@0"); @@ -1056,7 +1041,6 @@ static void *build_fdt(MachineState *machine, int *fd= t_size) cells[1] =3D cpu_to_be32(machine->ram_size); qemu_fdt_setprop(fdt, "/memory@0", "reg", cells, 2 * sizeof(cells[0])); qemu_fdt_setprop_string(fdt, "/memory@0", "device_type", "memory"); - qemu_fdt_setprop_string(fdt, "/memory@0", "name", "memory"); =20 qemu_fdt_add_subnode(fdt, "/chosen"); if (pm->initrd_addr && pm->initrd_size) { @@ -1067,7 +1051,6 @@ static void *build_fdt(MachineState *machine, int *fd= t_size) } qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", machine->kernel_cmdline ?: ""); - qemu_fdt_setprop_string(fdt, "/chosen", "name", "chosen"); =20 qemu_fdt_add_subnode(fdt, "/openprom"); qemu_fdt_setprop_string(fdt, "/openprom", "model", "Pegasos2,1.1"); --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178048479941.2508458675716; Wed, 22 Oct 2025 17:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqk-0007ky-QY; Wed, 22 Oct 2025 20:06:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqQ-0007aW-3y; Wed, 22 Oct 2025 20:06:20 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqL-0004YH-Lw; Wed, 22 Oct 2025 20:06:17 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 0C5AF5972F2; Thu, 23 Oct 2025 02:06:12 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id np4QdAhO_r1c; Thu, 23 Oct 2025 02:06:09 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id DDB625972EB; Thu, 23 Oct 2025 02:06:09 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: <383891fc2696609b27d2de9773efe1b4f493e333.1761176219.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 03/12] hw/ppc/pegasos2: Change device tree generation 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 Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:09 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178049598158500 We generate a flattened device tree programmatically for VOF. Change this to load the static parts from a device tree blob and only generate the parts that depend on run time conditions such as CPU type, memory size and PCI devices. Moving the static parts in a dts makes the board code simpler and more generic. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 291 +++++++-------------------------------- pc-bios/dtb/meson.build | 1 + pc-bios/dtb/pegasos2.dtb | Bin 0 -> 1701 bytes pc-bios/dtb/pegasos2.dts | 167 ++++++++++++++++++++++ 4 files changed, 219 insertions(+), 240 deletions(-) create mode 100644 pc-bios/dtb/pegasos2.dtb create mode 100644 pc-bios/dtb/pegasos2.dts diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 73995624e5..f4787397dc 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -58,16 +58,8 @@ #define BUS_FREQ_HZ 133333333 =20 #define PCI0_CFG_ADDR 0xcf8 -#define PCI0_MEM_BASE 0xc0000000 -#define PCI0_MEM_SIZE 0x20000000 -#define PCI0_IO_BASE 0xf8000000 -#define PCI0_IO_SIZE 0x10000 - #define PCI1_CFG_ADDR 0xc78 -#define PCI1_MEM_BASE 0x80000000 -#define PCI1_MEM_SIZE 0x40000000 #define PCI1_IO_BASE 0xfe000000 -#define PCI1_IO_SIZE 0x10000 =20 #define TYPE_PEGASOS2_MACHINE MACHINE_TYPE_NAME("pegasos2") OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE) @@ -411,7 +403,11 @@ static void pegasos2_machine_reset(MachineState *machi= ne, ResetType type) error_report("Memory for initrd is in use"); exit(1); } + fdt =3D build_fdt(machine, &sz); + if (!fdt) { + exit(1); + } /* FIXME: VOF assumes entry is same as load address */ d[0] =3D cpu_to_be64(pm->kernel_entry); d[1] =3D cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_= addr)); @@ -654,113 +650,12 @@ static void dt_usb(PCIBus *bus, PCIDevice *d, FDTInf= o *fi) qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "usb"); } =20 -static void dt_isa(PCIBus *bus, PCIDevice *d, FDTInfo *fi) -{ - GString *name =3D g_string_sized_new(64); - uint32_t cells[3]; - - qemu_fdt_setprop_cell(fi->fdt, fi->path, "#size-cells", 1); - qemu_fdt_setprop_cell(fi->fdt, fi->path, "#address-cells", 2); - qemu_fdt_setprop_string(fi->fdt, fi->path, "device_type", "isa"); - - /* additional devices */ - g_string_printf(name, "%s/lpt@i3bc", fi->path); - qemu_fdt_add_subnode(fi->fdt, name->str); - qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0); - cells[0] =3D cpu_to_be32(7); - cells[1] =3D 0; - qemu_fdt_setprop(fi->fdt, name->str, "interrupts", - cells, 2 * sizeof(cells[0])); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D cpu_to_be32(0x3bc); - cells[2] =3D cpu_to_be32(8); - qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "lpt"); - - g_string_printf(name, "%s/fdc@i3f0", fi->path); - qemu_fdt_add_subnode(fi->fdt, name->str); - qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0); - cells[0] =3D cpu_to_be32(6); - cells[1] =3D 0; - qemu_fdt_setprop(fi->fdt, name->str, "interrupts", - cells, 2 * sizeof(cells[0])); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D cpu_to_be32(0x3f0); - cells[2] =3D cpu_to_be32(8); - qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "fdc"); - - g_string_printf(name, "%s/timer@i40", fi->path); - qemu_fdt_add_subnode(fi->fdt, name->str); - qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D cpu_to_be32(0x40); - cells[2] =3D cpu_to_be32(8); - qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "timer"); - - g_string_printf(name, "%s/rtc@i70", fi->path); - qemu_fdt_add_subnode(fi->fdt, name->str); - qemu_fdt_setprop_string(fi->fdt, name->str, "compatible", "ds1385-rtc"= ); - qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0); - cells[0] =3D cpu_to_be32(8); - cells[1] =3D 0; - qemu_fdt_setprop(fi->fdt, name->str, "interrupts", - cells, 2 * sizeof(cells[0])); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D cpu_to_be32(0x70); - cells[2] =3D cpu_to_be32(2); - qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "rtc"); - - g_string_printf(name, "%s/keyboard@i60", fi->path); - qemu_fdt_add_subnode(fi->fdt, name->str); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D 0; - qemu_fdt_setprop(fi->fdt, name->str, "interrupts", - cells, 2 * sizeof(cells[0])); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D cpu_to_be32(0x60); - cells[2] =3D cpu_to_be32(5); - qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "keyboard"); - - g_string_printf(name, "%s/8042@i60", fi->path); - qemu_fdt_add_subnode(fi->fdt, name->str); - qemu_fdt_setprop_cell(fi->fdt, name->str, "#interrupt-cells", 2); - qemu_fdt_setprop_cell(fi->fdt, name->str, "#size-cells", 0); - qemu_fdt_setprop_cell(fi->fdt, name->str, "#address-cells", 1); - qemu_fdt_setprop_string(fi->fdt, name->str, "interrupt-controller", ""= ); - qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D cpu_to_be32(0x60); - cells[2] =3D cpu_to_be32(5); - qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", ""); - - g_string_printf(name, "%s/serial@i2f8", fi->path); - qemu_fdt_add_subnode(fi->fdt, name->str); - qemu_fdt_setprop_cell(fi->fdt, name->str, "clock-frequency", 0); - cells[0] =3D cpu_to_be32(3); - cells[1] =3D 0; - qemu_fdt_setprop(fi->fdt, name->str, "interrupts", - cells, 2 * sizeof(cells[0])); - cells[0] =3D cpu_to_be32(1); - cells[1] =3D cpu_to_be32(0x2f8); - cells[2] =3D cpu_to_be32(8); - qemu_fdt_setprop(fi->fdt, name->str, "reg", cells, 3 * sizeof(cells[0]= )); - qemu_fdt_setprop_string(fi->fdt, name->str, "device_type", "serial"); - - g_string_free(name, TRUE); -} - static struct { const char *id; const char *name; void (*dtf)(PCIBus *bus, PCIDevice *d, FDTInfo *fi); } device_map[] =3D { { "pci11ab,6460", "host", NULL }, - { "pci1106,8231", "isa", dt_isa }, { "pci1106,571", "ide", dt_ide }, { "pci1106,3044", "firewire", NULL }, { "pci1106,3038", "usb", dt_usb }, @@ -780,7 +675,10 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, = void *opaque) pci_get_word(&d->config[PCI_VENDOR_ID= ]), pci_get_word(&d->config[PCI_DEVICE_ID= ])); =20 - if (pci_get_word(&d->config[PCI_CLASS_DEVICE]) =3D=3D + if (!strcmp(pn, "pci1106,8231")) { + return; /* ISA bridge and devices are included in dtb */ + } + if (pci_get_word(&d->config[PCI_CLASS_DEVICE]) =3D=3D PCI_CLASS_NETWORK_ETHERNET) { name =3D "ethernet"; } else if (pci_get_word(&d->config[PCI_CLASS_DEVICE]) >> 8 =3D=3D @@ -858,131 +756,9 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d,= void *opaque) g_string_free(node, TRUE); } =20 -static void *build_fdt(MachineState *machine, int *fdt_size) +static void add_cpu_info(void *fdt, PowerPCCPU *cpu) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); - PowerPCCPU *cpu =3D pm->cpu; - PCIBus *pci_bus; - FDTInfo fi; - uint32_t cells[16]; - void *fdt =3D create_device_tree(fdt_size); - - fi.fdt =3D fdt; - - /* root node */ - qemu_fdt_setprop_string(fdt, "/", "CODEGEN,description", - "Pegasos CHRP PowerPC System"); - qemu_fdt_setprop_string(fdt, "/", "CODEGEN,board", "Pegasos2"); - qemu_fdt_setprop_string(fdt, "/", "CODEGEN,vendor", "bplan GmbH"); - qemu_fdt_setprop_string(fdt, "/", "revision", "2B"); - qemu_fdt_setprop_string(fdt, "/", "model", "Pegasos2"); - qemu_fdt_setprop_string(fdt, "/", "device_type", "chrp"); - qemu_fdt_setprop_cell(fdt, "/", "#address-cells", 1); - qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2"); - - /* pci@c0000000 */ - qemu_fdt_add_subnode(fdt, "/pci@c0000000"); - cells[0] =3D 0; - cells[1] =3D 0; - qemu_fdt_setprop(fdt, "/pci@c0000000", "bus-range", - cells, 2 * sizeof(cells[0])); - qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "pci-bridge-number", 1); - cells[0] =3D cpu_to_be32(PCI0_MEM_BASE); - cells[1] =3D cpu_to_be32(PCI0_MEM_SIZE); - qemu_fdt_setprop(fdt, "/pci@c0000000", "reg", cells, 2 * sizeof(cells[= 0])); - cells[0] =3D cpu_to_be32(0x01000000); - cells[1] =3D 0; - cells[2] =3D 0; - cells[3] =3D cpu_to_be32(PCI0_IO_BASE); - cells[4] =3D 0; - cells[5] =3D cpu_to_be32(PCI0_IO_SIZE); - cells[6] =3D cpu_to_be32(0x02000000); - cells[7] =3D 0; - cells[8] =3D cpu_to_be32(PCI0_MEM_BASE); - cells[9] =3D cpu_to_be32(PCI0_MEM_BASE); - cells[10] =3D 0; - cells[11] =3D cpu_to_be32(PCI0_MEM_SIZE); - qemu_fdt_setprop(fdt, "/pci@c0000000", "ranges", - cells, 12 * sizeof(cells[0])); - qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#size-cells", 2); - qemu_fdt_setprop_cell(fdt, "/pci@c0000000", "#address-cells", 3); - qemu_fdt_setprop_string(fdt, "/pci@c0000000", "device_type", "pci"); - - fi.path =3D "/pci@c0000000"; - pci_bus =3D mv64361_get_pci_bus(pm->mv, 0); - pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi); - - /* pci@80000000 */ - qemu_fdt_add_subnode(fdt, "/pci@80000000"); - cells[0] =3D 0; - cells[1] =3D 0; - qemu_fdt_setprop(fdt, "/pci@80000000", "bus-range", - cells, 2 * sizeof(cells[0])); - qemu_fdt_setprop_cell(fdt, "/pci@80000000", "pci-bridge-number", 0); - cells[0] =3D cpu_to_be32(PCI1_MEM_BASE); - cells[1] =3D cpu_to_be32(PCI1_MEM_SIZE); - qemu_fdt_setprop(fdt, "/pci@80000000", "reg", cells, 2 * sizeof(cells[= 0])); - qemu_fdt_setprop_cell(fdt, "/pci@80000000", "8259-interrupt-acknowledg= e", - 0xf1000cb4); - cells[0] =3D cpu_to_be32(0x01000000); - cells[1] =3D 0; - cells[2] =3D 0; - cells[3] =3D cpu_to_be32(PCI1_IO_BASE); - cells[4] =3D 0; - cells[5] =3D cpu_to_be32(PCI1_IO_SIZE); - cells[6] =3D cpu_to_be32(0x02000000); - cells[7] =3D 0; - cells[8] =3D cpu_to_be32(PCI1_MEM_BASE); - cells[9] =3D cpu_to_be32(PCI1_MEM_BASE); - cells[10] =3D 0; - cells[11] =3D cpu_to_be32(PCI1_MEM_SIZE); - qemu_fdt_setprop(fdt, "/pci@80000000", "ranges", - cells, 12 * sizeof(cells[0])); - qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#size-cells", 2); - qemu_fdt_setprop_cell(fdt, "/pci@80000000", "#address-cells", 3); - qemu_fdt_setprop_string(fdt, "/pci@80000000", "device_type", "pci"); - - fi.path =3D "/pci@80000000"; - pci_bus =3D mv64361_get_pci_bus(pm->mv, 1); - pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi); - - qemu_fdt_add_subnode(fdt, "/failsafe"); - qemu_fdt_setprop_string(fdt, "/failsafe", "device_type", "serial"); - - qemu_fdt_add_subnode(fdt, "/rtas"); - qemu_fdt_setprop_cell(fdt, "/rtas", "system-reboot", RTAS_SYSTEM_REBOO= T); - qemu_fdt_setprop_cell(fdt, "/rtas", "hibernate", RTAS_HIBERNATE); - qemu_fdt_setprop_cell(fdt, "/rtas", "suspend", RTAS_SUSPEND); - qemu_fdt_setprop_cell(fdt, "/rtas", "power-off", RTAS_POWER_OFF); - qemu_fdt_setprop_cell(fdt, "/rtas", "set-indicator", RTAS_SET_INDICATO= R); - qemu_fdt_setprop_cell(fdt, "/rtas", "display-character", - RTAS_DISPLAY_CHARACTER); - qemu_fdt_setprop_cell(fdt, "/rtas", "write-pci-config", - RTAS_WRITE_PCI_CONFIG); - qemu_fdt_setprop_cell(fdt, "/rtas", "read-pci-config", - RTAS_READ_PCI_CONFIG); - /* Pegasos2 firmware misspells check-exception and guests use that */ - qemu_fdt_setprop_cell(fdt, "/rtas", "check-execption", - RTAS_CHECK_EXCEPTION); - qemu_fdt_setprop_cell(fdt, "/rtas", "event-scan", RTAS_EVENT_SCAN); - qemu_fdt_setprop_cell(fdt, "/rtas", "set-time-of-day", - RTAS_SET_TIME_OF_DAY); - qemu_fdt_setprop_cell(fdt, "/rtas", "get-time-of-day", - RTAS_GET_TIME_OF_DAY); - qemu_fdt_setprop_cell(fdt, "/rtas", "nvram-store", RTAS_NVRAM_STORE); - qemu_fdt_setprop_cell(fdt, "/rtas", "nvram-fetch", RTAS_NVRAM_FETCH); - qemu_fdt_setprop_cell(fdt, "/rtas", "restart-rtas", RTAS_RESTART_RTAS); - qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-error-log-max", 0); - qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-event-scan-rate", 0); - qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-display-device", 0); - qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-size", 20); - qemu_fdt_setprop_cell(fdt, "/rtas", "rtas-version", 1); - - /* cpus */ - qemu_fdt_add_subnode(fdt, "/cpus"); - qemu_fdt_setprop_cell(fdt, "/cpus", "#cpus", 1); - qemu_fdt_setprop_cell(fdt, "/cpus", "#address-cells", 1); - qemu_fdt_setprop_cell(fdt, "/cpus", "#size-cells", 0); + uint32_t cells[2]; =20 /* FIXME Get CPU name from CPU object */ const char *cp =3D "/cpus/PowerPC,G4"; @@ -1034,15 +810,43 @@ static void *build_fdt(MachineState *machine, int *f= dt_size) cells[1] =3D 0; qemu_fdt_setprop(fdt, cp, "reg", cells, 2 * sizeof(cells[0])); qemu_fdt_setprop_string(fdt, cp, "device_type", "cpu"); +} + +static void *load_dtb(const char *filename, int *fdt_size) +{ + void *fdt; + g_autofree char *name =3D qemu_find_file(QEMU_FILE_TYPE_DTB, filename); + + if (!name) { + error_report("Could not find dtb file '%s'", filename); + return NULL; + } + fdt =3D load_device_tree(name, fdt_size); + if (!fdt) { + error_report("Could not load dtb file '%s'", name); + } + return fdt; +} =20 - /* memory */ - qemu_fdt_add_subnode(fdt, "/memory@0"); +static void *build_fdt(MachineState *machine, int *fdt_size) +{ + Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); + FDTInfo fi; + PCIBus *pci_bus; + uint32_t cells[2]; + void *fdt =3D load_dtb("pegasos2.dtb", fdt_size); + + if (!fdt) { + return NULL; + } + qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2"); + + /* Set memory size */ cells[0] =3D 0; cells[1] =3D cpu_to_be32(machine->ram_size); qemu_fdt_setprop(fdt, "/memory@0", "reg", cells, 2 * sizeof(cells[0])); - qemu_fdt_setprop_string(fdt, "/memory@0", "device_type", "memory"); =20 - qemu_fdt_add_subnode(fdt, "/chosen"); + /* Boot parameters */ if (pm->initrd_addr && pm->initrd_size) { qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", pm->initrd_addr + pm->initrd_size); @@ -1052,8 +856,15 @@ static void *build_fdt(MachineState *machine, int *fd= t_size) qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", machine->kernel_cmdline ?: ""); =20 - qemu_fdt_add_subnode(fdt, "/openprom"); - qemu_fdt_setprop_string(fdt, "/openprom", "model", "Pegasos2,1.1"); + add_cpu_info(fdt, pm->cpu); + + fi.fdt =3D fdt; + fi.path =3D "/pci@c0000000"; + pci_bus =3D mv64361_get_pci_bus(pm->mv, 0); + pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi); + fi.path =3D "/pci@80000000"; + pci_bus =3D mv64361_get_pci_bus(pm->mv, 1); + pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi); =20 return fdt; } diff --git a/pc-bios/dtb/meson.build b/pc-bios/dtb/meson.build index 993032949f..f14648f3a4 100644 --- a/pc-bios/dtb/meson.build +++ b/pc-bios/dtb/meson.build @@ -1,6 +1,7 @@ dtbs =3D [ 'bamboo.dtb', 'canyonlands.dtb', + 'pegasos2.dtb', 'petalogix-ml605.dtb', 'petalogix-s3adsp1800.dtb', ] diff --git a/pc-bios/dtb/pegasos2.dtb b/pc-bios/dtb/pegasos2.dtb new file mode 100644 index 0000000000000000000000000000000000000000..29c35216ec2d77e4083a3ef618c= a185925fb5d61 GIT binary patch literal 1701 zcmb_cyKWRQ6!nns2oQw;9TbZ~fl!Q+2&AN25u&7m6$nwJh`gS=3DyH;k#6WhC+r9h#h zgAYK01`0YPJ|IXGlptz8fP#XKNGRf7&v-N0P;#X^bI!5v!;hISllwmzJMo4ww#eA{ zXMA5npGH52juw4K{Y8NfJ)@G1;d{Kqq!B-kJ|#OQFLlx;&@VNhEv&W+6`jVeEZp`A z;WOyhn|UI#+G^Td8|oCl^pE(9#znxB_TRbQMd%&WutYzoInD*N%HgafDZr5q)Xo=3D1OP zKP)-kq39KDZm|6TP^2KToze-{>2Z+j?JsurL&^Pp+d)!CM+@~n7SwZ`6MZW=3Dy{JS) zYm@(JZDV`&cbJoEA6eUP6uni}wu=3DHeS5yu9s z5MJkyR)*oa(A`|S**>FHnlMEki}r7QMsc418p{A z)nh1g&q(^7>7(R5Fg~XzG^LPZW%2hl;6)dO23XH=3DD@DeQaOFfWMjM{!Hc!Pi7P3wl z$Nl%7^^8b)3!Ln*0$ZmIur@gER0>?Tcq|6Yj_`vzOm;wSa@YnL79wJf2hXL>TB^Np{Mo0(7XIELQq`=3D}Vr~fJzZZX@n_(P3ZM>WA@v>xmKwcJ2cYsX}wv2@G8 zRu?ikU`AwZuxxSR))H44W;Wg2aUnM|-A^EH1Eap0Mj_-`H^r>1*|oS;7{~qsTcHaV literal 0 HcmV?d00001 diff --git a/pc-bios/dtb/pegasos2.dts b/pc-bios/dtb/pegasos2.dts new file mode 100644 index 0000000000..0ddb9e3bec --- /dev/null +++ b/pc-bios/dtb/pegasos2.dts @@ -0,0 +1,167 @@ +/* + * QEMU Pegasos2 Device Tree Source + * + * Copyright 2025 BALATON Zoltan + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This is partial source, more info will be filled in by board code. + */ + +/dts-v1/; + +/ { + #address-cells =3D <1>; + device_type =3D "chrp"; + model =3D "Pegasos2"; + revision =3D "2B"; + CODEGEN,vendor =3D "bplan GmbH"; + CODEGEN,board =3D "Pegasos2"; + CODEGEN,description =3D "Pegasos CHRP PowerPC System"; + + openprom { + model =3D "Pegasos2,1.1"; + }; + + chosen { + }; + + memory@0 { + device_type =3D "memory"; + reg =3D <0 0>; + }; + + cpus { + #size-cells =3D <0>; + #address-cells =3D <1>; + #cpus =3D <1>; + }; + + rtas { + rtas-version =3D <1>; + rtas-size =3D <20>; + rtas-display-device =3D <0>; + rtas-event-scan-rate =3D <0>; + rtas-error-log-max =3D <0>; + restart-rtas =3D <0>; + nvram-fetch =3D <1>; + nvram-store =3D <2>; + get-time-of-day =3D <3>; + set-time-of-day =3D <4>; + event-scan =3D <6>; + /* Pegasos2 firmware misspells check-exception */ + check-execption =3D <7>; + read-pci-config =3D <8>; + write-pci-config =3D <9>; + display-character =3D <10>; + set-indicator =3D <11>; + power-off =3D <17>; + suspend =3D <18>; + hibernate =3D <19>; + system-reboot =3D <20>; + }; + + failsafe { + device_type =3D "serial"; + }; + + pci@80000000 { + device_type =3D "pci"; + #address-cells =3D <3>; + #size-cells =3D <2>; + clock-frequency =3D <33333333>; + ranges =3D <0x01000000 0 0x00000000 0xfe000000 0 0x00010000 + 0x02000000 0 0x80000000 0x80000000 0 0x40000000>; + 8259-interrupt-acknowledge =3D <0xf1000cb4>; + reg =3D <0x80000000 0x40000000>; + pci-bridge-number =3D <0>; + bus-range =3D <0 0>; + + isa@c { + vendor-id =3D <0x1106>; + device-id =3D <0x8231>; + revision-id =3D <0x10>; + class-code =3D <0x60100>; + /* Pegasos firmware has subsystem-id and + subsystem-vendor-id swapped */ + subsystem-id =3D <0x1af4>; + subsystem-vendor-id =3D <0x1100>; + reg =3D <0x6000 0 0 0 0>; + device_type =3D "isa"; + #address-cells =3D <2>; + #size-cells =3D <1>; + eisa-slots =3D <0>; + clock-frequency =3D <8333333>; + slot-names =3D <0>; + + serial@i2f8 { + device_type =3D "serial"; + reg =3D <1 0x2f8 8>; + interrupts =3D <3 0>; + clock-frequency =3D <1843200>; + compatible =3D "pnpPNP,501"; + }; + + 8042@i60 { + device_type =3D ""; + reg =3D <1 0x60 5>; + clock-frequency =3D <0>; + compatible =3D "chrp,8042"; + interrupt-controller =3D ""; + #address-cells =3D <1>; + #size-cells =3D <0>; + #interrupt-cells =3D <2>; + + }; + + keyboard@i60 { + device_type =3D "keyboard"; + reg =3D <1 0x60 5>; + interrupts =3D <1 0>; + compatible =3D "pnpPNP,303"; + }; + + rtc@i70 { + device_type =3D "rtc"; + reg =3D <1 0x70 2>; + interrupts =3D <8 0>; + clock-frequency =3D <0>; + compatible =3D "ds1385-rtc"; + }; + + timer@i40 { + device_type =3D "timer"; + reg =3D <1 0x40 8>; + clock-frequency =3D <0>; + compatible =3D "pnpPNP,100"; + }; + + fdc@i3f0 { + device_type =3D "fdc"; + reg =3D <1 0x3f0 8>; + interrupts =3D <6 0>; + clock-frequency =3D <0>; + compatible =3D "pnpPNP,700"; + }; + + lpt@i3bc { + device_type =3D "lpt"; + reg =3D <1 0x3bc 8>; + interrupts =3D <7 0>; + clock-frequency =3D <0>; + compatible =3D "pnpPNP,400"; + }; + }; + }; + + pci@c0000000 { + device_type =3D "pci"; + #address-cells =3D <3>; + #size-cells =3D <2>; + clock-frequency =3D <66666666>; + ranges =3D <0x01000000 0 0x00000000 0xf8000000 0 0x00010000 + 0x02000000 0 0xc0000000 0xc0000000 0 0x20000000>; + reg =3D <0xc0000000 0x20000000>; + pci-bridge-number =3D <1>; + bus-range =3D <0 0>; + }; +}; --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178047570589.247410819171; Wed, 22 Oct 2025 17:07:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqb-0007h0-FE; Wed, 22 Oct 2025 20:06:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqQ-0007aV-47; Wed, 22 Oct 2025 20:06:20 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqN-0004YX-2s; Wed, 22 Oct 2025 20:06:16 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id E975C5972F0; Thu, 23 Oct 2025 02:06:12 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id TtW3tEwDY18D; Thu, 23 Oct 2025 02:06:10 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id EB5D85972ED; Thu, 23 Oct 2025 02:06:10 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 04/12] hw/ppc/pegasos2: Remove fdt pointer from machine state 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 Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:10 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178059671158500 The machine class has a field for storing the fdt so we don't need our own and can use that instead. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index f4787397dc..2ba579dddf 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -74,7 +74,6 @@ struct Pegasos2MachineState { qemu_irq mv_pirq[PCI_NUM_PINS]; qemu_irq via_pirq[PCI_NUM_PINS]; Vof *vof; - void *fdt_blob; uint64_t kernel_addr; uint64_t kernel_entry; uint64_t kernel_size; @@ -413,13 +412,11 @@ static void pegasos2_machine_reset(MachineState *mach= ine, ResetType type) d[1] =3D cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_= addr)); qemu_fdt_setprop(fdt, "/chosen", "qemu,boot-kernel", d, sizeof(d)); =20 - g_free(pm->fdt_blob); - pm->fdt_blob =3D fdt; - vof_build_dt(fdt, pm->vof); vof_client_open_store(fdt, pm->vof, "/chosen", "stdout", "/failsafe"); =20 /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ + g_free(machine->fdt); machine->fdt =3D fdt; =20 pm->cpu->vhyp =3D PPC_VIRTUAL_HYPERVISOR(machine); @@ -559,7 +556,7 @@ static void pegasos2_hypercall(PPCVirtualHypervisor *vh= yp, PowerPCCPU *cpu) } else if (env->gpr[3] =3D=3D KVMPPC_H_RTAS) { env->gpr[3] =3D pegasos2_rtas(cpu, pm, env->gpr[4]); } else if (env->gpr[3] =3D=3D KVMPPC_H_VOF_CLIENT) { - int ret =3D vof_client_call(MACHINE(pm), pm->vof, pm->fdt_blob, + int ret =3D vof_client_call(MACHINE(pm), pm->vof, MACHINE(pm)->fdt, env->gpr[4]); env->gpr[3] =3D (ret ? H_PARAMETER : H_SUCCESS); } else { --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178078645184.2982753447775; Wed, 22 Oct 2025 17:07:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqk-0007jy-9L; Wed, 22 Oct 2025 20:06:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqR-0007ak-5s; Wed, 22 Oct 2025 20:06:20 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqO-0004Yu-JA; Wed, 22 Oct 2025 20:06:18 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 060895972E5; Thu, 23 Oct 2025 02:06:14 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id cj_4yOuR3VQ9; Thu, 23 Oct 2025 02:06:12 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 057B75972F1; Thu, 23 Oct 2025 02:06:12 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 05/12] hw/ppc/pegasos2: Rename mv field in machine state 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 Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:12 +0200 (CEST) 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-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178081295154101 Use more generic name for the field used to store the north bridge in the machine state. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 2ba579dddf..9b89c7ecc2 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -68,7 +68,7 @@ struct Pegasos2MachineState { MachineState parent_obj; =20 PowerPCCPU *cpu; - DeviceState *mv; + DeviceState *nb; /* north bridge */ IRQState pci_irqs[PCI_NUM_PINS]; OrIRQState orirq[PCI_NUM_PINS]; qemu_irq mv_pirq[PCI_NUM_PINS]; @@ -166,12 +166,12 @@ static void pegasos2_init(MachineState *machine) } =20 /* Marvell Discovery II system controller */ - pm->mv =3D DEVICE(sysbus_create_simple(TYPE_MV64361, -1, + pm->nb =3D DEVICE(sysbus_create_simple(TYPE_MV64361, -1, qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_I= NT))); for (i =3D 0; i < PCI_NUM_PINS; i++) { - pm->mv_pirq[i] =3D qdev_get_gpio_in_named(pm->mv, "gpp", 12 + i); + pm->mv_pirq[i] =3D qdev_get_gpio_in_named(pm->nb, "gpp", 12 + i); } - pci_bus =3D mv64361_get_pci_bus(pm->mv, 1); + pci_bus =3D mv64361_get_pci_bus(pm->nb, 1); =20 /* VIA VT8231 South Bridge (multifunction PCI device) */ via =3D OBJECT(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_ISA= )); @@ -190,7 +190,7 @@ static void pegasos2_init(MachineState *machine) object_resolve_path_component(via, "rtc"), "date"); qdev_connect_gpio_out_named(DEVICE(via), "intr", 0, - qdev_get_gpio_in_named(pm->mv, "gpp", 31)); + qdev_get_gpio_in_named(pm->nb, "gpp", 31)); =20 dev =3D PCI_DEVICE(object_resolve_path_component(via, "ide")); pci_ide_create_devs(dev); @@ -208,7 +208,7 @@ static void pegasos2_init(MachineState *machine) DeviceState *pd; g_autofree const char *pn =3D g_strdup_printf("pcihost%d", h); =20 - pd =3D DEVICE(object_resolve_path_component(OBJECT(pm->mv), pn)); + pd =3D DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn)); assert(pd); for (i =3D 0; i < PCI_NUM_PINS; i++) { OrIRQState *ori =3D &pm->orirq[i]; @@ -267,7 +267,7 @@ static void pegasos2_init(MachineState *machine) static uint32_t pegasos2_mv_reg_read(Pegasos2MachineState *pm, uint32_t addr, uint32_t len) { - MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->mv), 0); + MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0); uint64_t val =3D 0xffffffffULL; memory_region_dispatch_read(r, addr, &val, size_memop(len) | MO_LE, MEMTXATTRS_UNSPECIFIED); @@ -277,7 +277,7 @@ static uint32_t pegasos2_mv_reg_read(Pegasos2MachineSta= te *pm, static void pegasos2_mv_reg_write(Pegasos2MachineState *pm, uint32_t addr, uint32_t len, uint32_t val) { - MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->mv), 0); + MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0); memory_region_dispatch_write(r, addr, val, size_memop(len) | MO_LE, MEMTXATTRS_UNSPECIFIED); } @@ -857,10 +857,10 @@ static void *build_fdt(MachineState *machine, int *fd= t_size) =20 fi.fdt =3D fdt; fi.path =3D "/pci@c0000000"; - pci_bus =3D mv64361_get_pci_bus(pm->mv, 0); + pci_bus =3D mv64361_get_pci_bus(pm->nb, 0); pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi); fi.path =3D "/pci@80000000"; - pci_bus =3D mv64361_get_pci_bus(pm->mv, 1); + pci_bus =3D mv64361_get_pci_bus(pm->nb, 1); pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi); =20 return fdt; --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178056655913.2478805976889; Wed, 22 Oct 2025 17:07:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqb-0007hD-Fw; Wed, 22 Oct 2025 20:06:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqR-0007al-Ko; Wed, 22 Oct 2025 20:06:20 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqO-0004Yz-QJ; Wed, 22 Oct 2025 20:06:19 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 1DC9F5972EB; Thu, 23 Oct 2025 02:06:15 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id 7p6ci2A5romY; Thu, 23 Oct 2025 02:06:13 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 1EFF15972ED; Thu, 23 Oct 2025 02:06:13 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: <654d3223b418d5bb2ba08a2b014375c2abf341aa.1761176219.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 06/12] hw/ppc/pegasos2: Add south bridge pointer in the machine state 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 Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:13 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178059664158501 Add field for the south bridge in machine state to have both north and south bridges in it. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 9b89c7ecc2..4b63f0e175 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -69,6 +69,7 @@ struct Pegasos2MachineState { =20 PowerPCCPU *cpu; DeviceState *nb; /* north bridge */ + DeviceState *sb; /* south bridge */ IRQState pci_irqs[PCI_NUM_PINS]; OrIRQState orirq[PCI_NUM_PINS]; qemu_irq mv_pirq[PCI_NUM_PINS]; @@ -174,7 +175,8 @@ static void pegasos2_init(MachineState *machine) pci_bus =3D mv64361_get_pci_bus(pm->nb, 1); =20 /* VIA VT8231 South Bridge (multifunction PCI device) */ - via =3D OBJECT(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_ISA= )); + pm->sb =3D DEVICE(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_= ISA)); + via =3D OBJECT(pm->sb); =20 /* Set properties on individual devices before realizing the south bri= dge */ if (machine->audiodev) { --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178077776345.6193734488528; Wed, 22 Oct 2025 17:07:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiql-0007lS-3j; Wed, 22 Oct 2025 20:06:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqT-0007bO-4p; Wed, 22 Oct 2025 20:06:21 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqQ-0004ZH-5F; Wed, 22 Oct 2025 20:06:20 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 3C63F5972ED; Thu, 23 Oct 2025 02:06:16 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id KyD_pGqDfg0y; Thu, 23 Oct 2025 02:06:14 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 3A1285972F1; Thu, 23 Oct 2025 02:06:14 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 07/12] hw/ppc/pegasos2: Move PCI IRQ routing setup to a function MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:14 +0200 (CEST) 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-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178082240158500 Content-Type: text/plain; charset="utf-8" Collect steps of setting up PCI IRQ routing in one function. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 66 +++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 4b63f0e175..2f9bd3eac5 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -107,6 +107,38 @@ static void pegasos2_pci_irq(void *opaque, int n, int = level) qemu_set_irq(pm->via_pirq[n], level); } =20 +/* Set up PCI interrupt routing: lines from pci.0 and pci.1 are ORed */ +static void pegasos2_setup_pci_irq(Pegasos2MachineState *pm) +{ + for (int h =3D 0; h < 2; h++) { + DeviceState *pd; + g_autofree const char *pn =3D g_strdup_printf("pcihost%d", h); + + pd =3D DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn)); + assert(pd); + for (int i =3D 0; i < PCI_NUM_PINS; i++) { + OrIRQState *ori =3D &pm->orirq[i]; + + if (h =3D=3D 0) { + g_autofree const char *n =3D g_strdup_printf("pci-orirq[%d= ]", i); + + object_initialize_child_with_props(OBJECT(pm), n, + ori, sizeof(*ori), + TYPE_OR_IRQ, &error_fat= al, + "num-lines", "2", NULL); + qdev_realize(DEVICE(ori), NULL, &error_fatal); + qemu_init_irq(&pm->pci_irqs[i], pegasos2_pci_irq, pm, i); + qdev_connect_gpio_out(DEVICE(ori), 0, &pm->pci_irqs[i]); + pm->mv_pirq[i] =3D qdev_get_gpio_in_named(pm->nb, "gpp", 1= 2 + i); + pm->via_pirq[i] =3D qdev_get_gpio_in_named(pm->sb, "pirq",= i); + } + qdev_connect_gpio_out(pd, i, qdev_get_gpio_in(DEVICE(ori), h)); + } + } + qdev_connect_gpio_out_named(pm->sb, "intr", 0, + qdev_get_gpio_in_named(pm->nb, "gpp", 31)); +} + static void pegasos2_init(MachineState *machine) { Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); @@ -118,7 +150,6 @@ static void pegasos2_init(MachineState *machine) I2CBus *i2c_bus; const char *fwname =3D machine->firmware ?: PROM_FILENAME; char *filename; - int i; ssize_t sz; uint8_t *spd_data; =20 @@ -169,9 +200,6 @@ static void pegasos2_init(MachineState *machine) /* Marvell Discovery II system controller */ pm->nb =3D DEVICE(sysbus_create_simple(TYPE_MV64361, -1, qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_I= NT))); - for (i =3D 0; i < PCI_NUM_PINS; i++) { - pm->mv_pirq[i] =3D qdev_get_gpio_in_named(pm->nb, "gpp", 12 + i); - } pci_bus =3D mv64361_get_pci_bus(pm->nb, 1); =20 /* VIA VT8231 South Bridge (multifunction PCI device) */ @@ -185,14 +213,9 @@ static void pegasos2_init(MachineState *machine) } =20 pci_realize_and_unref(PCI_DEVICE(via), pci_bus, &error_abort); - for (i =3D 0; i < PCI_NUM_PINS; i++) { - pm->via_pirq[i] =3D qdev_get_gpio_in_named(DEVICE(via), "pirq", i); - } object_property_add_alias(OBJECT(machine), "rtc-time", object_resolve_path_component(via, "rtc"), "date"); - qdev_connect_gpio_out_named(DEVICE(via), "intr", 0, - qdev_get_gpio_in_named(pm->nb, "gpp", 31)); =20 dev =3D PCI_DEVICE(object_resolve_path_component(via, "ide")); pci_ide_create_devs(dev); @@ -205,30 +228,7 @@ static void pegasos2_init(MachineState *machine) /* other PC hardware */ pci_vga_init(pci_bus); =20 - /* PCI interrupt routing: lines from pci.0 and pci.1 are ORed */ - for (int h =3D 0; h < 2; h++) { - DeviceState *pd; - g_autofree const char *pn =3D g_strdup_printf("pcihost%d", h); - - pd =3D DEVICE(object_resolve_path_component(OBJECT(pm->nb), pn)); - assert(pd); - for (i =3D 0; i < PCI_NUM_PINS; i++) { - OrIRQState *ori =3D &pm->orirq[i]; - - if (h =3D=3D 0) { - g_autofree const char *n =3D g_strdup_printf("pci-orirq[%d= ]", i); - - object_initialize_child_with_props(OBJECT(pm), n, - ori, sizeof(*ori), - TYPE_OR_IRQ, &error_fat= al, - "num-lines", "2", NULL); - qdev_realize(DEVICE(ori), NULL, &error_fatal); - qemu_init_irq(&pm->pci_irqs[i], pegasos2_pci_irq, pm, i); - qdev_connect_gpio_out(DEVICE(ori), 0, &pm->pci_irqs[i]); - } - qdev_connect_gpio_out(pd, i, qdev_get_gpio_in(DEVICE(ori), h)); - } - } + pegasos2_setup_pci_irq(pm); =20 if (machine->kernel_filename) { sz =3D load_elf(machine->kernel_filename, NULL, NULL, NULL, --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178076412284.9451464260368; Wed, 22 Oct 2025 17:07:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqr-0007ou-AE; Wed, 22 Oct 2025 20:06:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqU-0007cX-B5; Wed, 22 Oct 2025 20:06:22 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqR-0004ZP-92; Wed, 22 Oct 2025 20:06:21 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 439BC5972F6; Thu, 23 Oct 2025 02:06:17 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id 40ME9rr2LdVk; Thu, 23 Oct 2025 02:06:15 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 469ED5972EC; Thu, 23 Oct 2025 02:06:15 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 08/12] hw/ppc/pegasos2: Move hardware specific parts out of machine reset MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:15 +0200 (CEST) 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-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178079690154100 Content-Type: text/plain; charset="utf-8" Move the pegasos2 specific chipset reset out from machine reset to a separate function and move generic parts that are not pegasos2 specific from build_fdt to machine reset so now build_fdt only contains pegasos2 specific parts and can be renamed accordingly. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 79 ++++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 38 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 2f9bd3eac5..ed3070204b 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -57,10 +57,6 @@ =20 #define BUS_FREQ_HZ 133333333 =20 -#define PCI0_CFG_ADDR 0xcf8 -#define PCI1_CFG_ADDR 0xc78 -#define PCI1_IO_BASE 0xfe000000 - #define TYPE_PEGASOS2_MACHINE MACHINE_TYPE_NAME("pegasos2") OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE) =20 @@ -82,7 +78,7 @@ struct Pegasos2MachineState { uint64_t initrd_size; }; =20 -static void *build_fdt(MachineState *machine, int *fdt_size); +static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size); =20 static void pegasos2_cpu_reset(void *opaque) { @@ -284,6 +280,9 @@ static void pegasos2_mv_reg_write(Pegasos2MachineState = *pm, uint32_t addr, MEMTXATTRS_UNSPECIFIED); } =20 +#define PCI0_CFG_ADDR 0xcf8 +#define PCI1_CFG_ADDR 0xc78 + static uint32_t pegasos2_pci_config_read(Pegasos2MachineState *pm, int bus, uint32_t addr, uint32_t len) { @@ -308,23 +307,12 @@ static void pegasos2_pci_config_write(Pegasos2Machine= State *pm, int bus, =20 static void pegasos2_superio_write(uint8_t addr, uint8_t val) { - cpu_physical_memory_write(PCI1_IO_BASE + 0x3f0, &addr, 1); - cpu_physical_memory_write(PCI1_IO_BASE + 0x3f1, &val, 1); + cpu_physical_memory_write(0xfe0003f0, &addr, 1); + cpu_physical_memory_write(0xfe0003f1, &val, 1); } =20 -static void pegasos2_machine_reset(MachineState *machine, ResetType type) +static void pegasos2_chipset_reset(Pegasos2MachineState *pm) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); - void *fdt; - uint64_t d[2]; - int sz; - - qemu_devices_reset(type); - if (!pm->vof) { - return; /* Firmware should set up machine so nothing to do */ - } - - /* Otherwise, set up devices that board firmware would normally do */ pegasos2_mv_reg_write(pm, 0, 4, 0x28020ff); pegasos2_mv_reg_write(pm, 0x278, 4, 0xa31fc); pegasos2_mv_reg_write(pm, 0xf300, 4, 0x11ff0400); @@ -387,6 +375,23 @@ static void pegasos2_machine_reset(MachineState *machi= ne, ResetType type) =20 pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 6) << 8) | PCI_INTERRUPT_LINE, 2, 0x309); +} + +static void pegasos2_machine_reset(MachineState *machine, ResetType type) +{ + Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); + void *fdt; + uint32_t c[2]; + uint64_t d[2]; + int sz; + + qemu_devices_reset(type); + if (!pm->vof) { + return; /* Firmware should set up machine so nothing to do */ + } + + /* Otherwise, set up devices that board firmware would normally do */ + pegasos2_chipset_reset(pm); =20 /* Device tree and VOF set up */ vof_init(pm->vof, machine->ram_size, &error_fatal); @@ -405,10 +410,25 @@ static void pegasos2_machine_reset(MachineState *mach= ine, ResetType type) exit(1); } =20 - fdt =3D build_fdt(machine, &sz); + fdt =3D pegasos2_build_fdt(pm, &sz); if (!fdt) { exit(1); } + + /* Set memory size */ + c[0] =3D 0; + c[1] =3D cpu_to_be32(machine->ram_size); + qemu_fdt_setprop(fdt, "/memory@0", "reg", c, sizeof(c)); + + /* Boot parameters */ + if (pm->initrd_addr && pm->initrd_size) { + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", + pm->initrd_addr + pm->initrd_size); + qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", + pm->initrd_addr); + } + qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", + machine->kernel_cmdline ?: ""); /* FIXME: VOF assumes entry is same as load address */ d[0] =3D cpu_to_be64(pm->kernel_entry); d[1] =3D cpu_to_be64(pm->kernel_size - (pm->kernel_entry - pm->kernel_= addr)); @@ -827,12 +847,10 @@ static void *load_dtb(const char *filename, int *fdt_= size) return fdt; } =20 -static void *build_fdt(MachineState *machine, int *fdt_size) +static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); FDTInfo fi; PCIBus *pci_bus; - uint32_t cells[2]; void *fdt =3D load_dtb("pegasos2.dtb", fdt_size); =20 if (!fdt) { @@ -840,21 +858,6 @@ static void *build_fdt(MachineState *machine, int *fdt= _size) } qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2"); =20 - /* Set memory size */ - cells[0] =3D 0; - cells[1] =3D cpu_to_be32(machine->ram_size); - qemu_fdt_setprop(fdt, "/memory@0", "reg", cells, 2 * sizeof(cells[0])); - - /* Boot parameters */ - if (pm->initrd_addr && pm->initrd_size) { - qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-end", - pm->initrd_addr + pm->initrd_size); - qemu_fdt_setprop_cell(fdt, "/chosen", "linux,initrd-start", - pm->initrd_addr); - } - qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", - machine->kernel_cmdline ?: ""); - add_cpu_info(fdt, pm->cpu); =20 fi.fdt =3D fdt; --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178079911400.8622328140889; Wed, 22 Oct 2025 17:07:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqp-0007ni-Jr; Wed, 22 Oct 2025 20:06:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqV-0007fH-QI; Wed, 22 Oct 2025 20:06:24 -0400 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqS-0004Zi-Jf; Wed, 22 Oct 2025 20:06:22 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 5B4EE5972EC; Thu, 23 Oct 2025 02:06:18 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id 1Eeg9TaMZKyt; Thu, 23 Oct 2025 02:06:16 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 538D35972F1; Thu, 23 Oct 2025 02:06:16 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 09/12] hw/ppc/pegasos2: Introduce abstract superclass 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 Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:16 +0200 (CEST) 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-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178081383154100 Rename machine state struct to PegasosMachineState as it will be used for pegasos1 too. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 66 ++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index ed3070204b..f5b56c0e94 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -57,10 +57,10 @@ =20 #define BUS_FREQ_HZ 133333333 =20 -#define TYPE_PEGASOS2_MACHINE MACHINE_TYPE_NAME("pegasos2") -OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE) +#define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos") +OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE) =20 -struct Pegasos2MachineState { +struct PegasosMachineState { MachineState parent_obj; =20 PowerPCCPU *cpu; @@ -78,12 +78,12 @@ struct Pegasos2MachineState { uint64_t initrd_size; }; =20 -static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size); +static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size); =20 static void pegasos2_cpu_reset(void *opaque) { PowerPCCPU *cpu =3D opaque; - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(current_machine); + PegasosMachineState *pm =3D PEGASOS_MACHINE(current_machine); =20 cpu_reset(CPU(cpu)); cpu->env.spr[SPR_HID1] =3D 7ULL << 28; @@ -96,7 +96,7 @@ static void pegasos2_cpu_reset(void *opaque) =20 static void pegasos2_pci_irq(void *opaque, int n, int level) { - Pegasos2MachineState *pm =3D opaque; + PegasosMachineState *pm =3D opaque; =20 /* PCI interrupt lines are connected to both MV64361 and VT8231 */ qemu_set_irq(pm->mv_pirq[n], level); @@ -104,7 +104,7 @@ static void pegasos2_pci_irq(void *opaque, int n, int l= evel) } =20 /* Set up PCI interrupt routing: lines from pci.0 and pci.1 are ORed */ -static void pegasos2_setup_pci_irq(Pegasos2MachineState *pm) +static void pegasos2_setup_pci_irq(PegasosMachineState *pm) { for (int h =3D 0; h < 2; h++) { DeviceState *pd; @@ -137,7 +137,7 @@ static void pegasos2_setup_pci_irq(Pegasos2MachineState= *pm) =20 static void pegasos2_init(MachineState *machine) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); + PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); CPUPPCState *env; MemoryRegion *rom =3D g_new(MemoryRegion, 1); PCIBus *pci_bus; @@ -262,7 +262,7 @@ static void pegasos2_init(MachineState *machine) } } =20 -static uint32_t pegasos2_mv_reg_read(Pegasos2MachineState *pm, +static uint32_t pegasos2_mv_reg_read(PegasosMachineState *pm, uint32_t addr, uint32_t len) { MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0); @@ -272,7 +272,7 @@ static uint32_t pegasos2_mv_reg_read(Pegasos2MachineSta= te *pm, return val; } =20 -static void pegasos2_mv_reg_write(Pegasos2MachineState *pm, uint32_t addr, +static void pegasos2_mv_reg_write(PegasosMachineState *pm, uint32_t addr, uint32_t len, uint32_t val) { MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0); @@ -283,7 +283,7 @@ static void pegasos2_mv_reg_write(Pegasos2MachineState = *pm, uint32_t addr, #define PCI0_CFG_ADDR 0xcf8 #define PCI1_CFG_ADDR 0xc78 =20 -static uint32_t pegasos2_pci_config_read(Pegasos2MachineState *pm, int bus, +static uint32_t pegasos2_pci_config_read(PegasosMachineState *pm, int bus, uint32_t addr, uint32_t len) { hwaddr pcicfg =3D bus ? PCI1_CFG_ADDR : PCI0_CFG_ADDR; @@ -296,7 +296,7 @@ static uint32_t pegasos2_pci_config_read(Pegasos2Machin= eState *pm, int bus, return val; } =20 -static void pegasos2_pci_config_write(Pegasos2MachineState *pm, int bus, +static void pegasos2_pci_config_write(PegasosMachineState *pm, int bus, uint32_t addr, uint32_t len, uint32_= t val) { hwaddr pcicfg =3D bus ? PCI1_CFG_ADDR : PCI0_CFG_ADDR; @@ -311,7 +311,7 @@ static void pegasos2_superio_write(uint8_t addr, uint8_= t val) cpu_physical_memory_write(0xfe0003f1, &val, 1); } =20 -static void pegasos2_chipset_reset(Pegasos2MachineState *pm) +static void pegasos2_chipset_reset(PegasosMachineState *pm) { pegasos2_mv_reg_write(pm, 0, 4, 0x28020ff); pegasos2_mv_reg_write(pm, 0x278, 4, 0xa31fc); @@ -379,7 +379,7 @@ static void pegasos2_chipset_reset(Pegasos2MachineState= *pm) =20 static void pegasos2_machine_reset(MachineState *machine, ResetType type) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); + PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); void *fdt; uint32_t c[2]; uint64_t d[2]; @@ -463,7 +463,7 @@ enum pegasos2_rtas_tokens { RTAS_SYSTEM_REBOOT =3D 20, }; =20 -static target_ulong pegasos2_rtas(PowerPCCPU *cpu, Pegasos2MachineState *p= m, +static target_ulong pegasos2_rtas(PowerPCCPU *cpu, PegasosMachineState *pm, target_ulong args_real) { AddressSpace *as =3D CPU(cpu)->as; @@ -566,7 +566,7 @@ static bool pegasos2_cpu_in_nested(PowerPCCPU *cpu) =20 static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(vhyp); + PegasosMachineState *pm =3D PEGASOS_MACHINE(vhyp); CPUPPCState *env =3D &cpu->env; =20 /* The TCG path should also be holding the BQL at this point */ @@ -629,24 +629,26 @@ static void pegasos2_machine_class_init(ObjectClass *= oc, const void *data) vmc->setprop =3D pegasos2_setprop; } =20 -static const TypeInfo pegasos2_machine_info =3D { - .name =3D TYPE_PEGASOS2_MACHINE, - .parent =3D TYPE_MACHINE, - .class_init =3D pegasos2_machine_class_init, - .instance_size =3D sizeof(Pegasos2MachineState), - .interfaces =3D (const InterfaceInfo[]) { - { TYPE_PPC_VIRTUAL_HYPERVISOR }, - { TYPE_VOF_MACHINE_IF }, - { } +static const TypeInfo pegasos_machine_types[] =3D { + { + .name =3D TYPE_PEGASOS_MACHINE, + .parent =3D TYPE_MACHINE, + .instance_size =3D sizeof(PegasosMachineState), + .abstract =3D true, + .interfaces =3D (const InterfaceInfo[]) { + { TYPE_PPC_VIRTUAL_HYPERVISOR }, + { TYPE_VOF_MACHINE_IF }, + { } + }, + }, + { + .name =3D MACHINE_TYPE_NAME("pegasos2"), + .parent =3D TYPE_PEGASOS_MACHINE, + .class_init =3D pegasos2_machine_class_init, }, }; =20 -static void pegasos2_machine_register_types(void) -{ - type_register_static(&pegasos2_machine_info); -} - -type_init(pegasos2_machine_register_types) +DEFINE_TYPES(pegasos_machine_types) =20 /* FDT creation for passing to firmware */ =20 @@ -847,7 +849,7 @@ static void *load_dtb(const char *filename, int *fdt_si= ze) return fdt; } =20 -static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size) +static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size) { FDTInfo fi; PCIBus *pci_bus; --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178032242164.41647218874402; Wed, 22 Oct 2025 17:07:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqs-0007p9-0J; Wed, 22 Oct 2025 20:06:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqY-0007g7-U3; Wed, 22 Oct 2025 20:06:27 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqT-0004Zz-7R; Wed, 22 Oct 2025 20:06:26 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 5B9E75972F1; Thu, 23 Oct 2025 02:06:19 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id UI87-wBVk5UI; Thu, 23 Oct 2025 02:06:17 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 60E825972E3; Thu, 23 Oct 2025 02:06:17 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 10/12] hw/ppc/pegasos2: Add bus frequency to machine state MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:17 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178034881154100 Content-Type: text/plain; charset="utf-8" Store the bus frequency in the machine state and set it from instance init method. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index f5b56c0e94..7eaefcf9a0 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -55,8 +55,6 @@ #define H_PRIVILEGE -3 /* Caller not privileged */ #define H_PARAMETER -4 /* Parameter invalid, out-of-range or conflicting= */ =20 -#define BUS_FREQ_HZ 133333333 - #define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos") OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE) =20 @@ -66,6 +64,7 @@ struct PegasosMachineState { PowerPCCPU *cpu; DeviceState *nb; /* north bridge */ DeviceState *sb; /* south bridge */ + int bus_freq_hz; IRQState pci_irqs[PCI_NUM_PINS]; OrIRQState orirq[PCI_NUM_PINS]; qemu_irq mv_pirq[PCI_NUM_PINS]; @@ -135,7 +134,7 @@ static void pegasos2_setup_pci_irq(PegasosMachineState = *pm) qdev_get_gpio_in_named(pm->nb, "gpp", 31)); } =20 -static void pegasos2_init(MachineState *machine) +static void pegasos_init(MachineState *machine) { PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); CPUPPCState *env; @@ -158,7 +157,7 @@ static void pegasos2_init(MachineState *machine) } =20 /* Set time-base frequency */ - cpu_ppc_tb_init(env, BUS_FREQ_HZ / 4); + cpu_ppc_tb_init(env, pm->bus_freq_hz / 4); qemu_register_reset(pegasos2_cpu_reset, pm->cpu); =20 /* RAM */ @@ -610,7 +609,7 @@ static void pegasos2_machine_class_init(ObjectClass *oc= , const void *data) VofMachineIfClass *vmc =3D VOF_MACHINE_CLASS(oc); =20 mc->desc =3D "Genesi/bPlan Pegasos II"; - mc->init =3D pegasos2_init; + mc->init =3D pegasos_init; mc->reset =3D pegasos2_machine_reset; mc->block_default_type =3D IF_IDE; mc->default_boot_order =3D "cd"; @@ -629,6 +628,13 @@ static void pegasos2_machine_class_init(ObjectClass *o= c, const void *data) vmc->setprop =3D pegasos2_setprop; } =20 +static void pegasos2_init(Object *obj) +{ + PegasosMachineState *pm =3D PEGASOS_MACHINE(obj); + + pm->bus_freq_hz =3D 133333333; +} + static const TypeInfo pegasos_machine_types[] =3D { { .name =3D TYPE_PEGASOS_MACHINE, @@ -645,6 +651,7 @@ static const TypeInfo pegasos_machine_types[] =3D { .name =3D MACHINE_TYPE_NAME("pegasos2"), .parent =3D TYPE_PEGASOS_MACHINE, .class_init =3D pegasos2_machine_class_init, + .instance_init =3D pegasos2_init, }, }; =20 @@ -777,7 +784,7 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, v= oid *opaque) g_string_free(node, TRUE); } =20 -static void add_cpu_info(void *fdt, PowerPCCPU *cpu) +static void add_cpu_info(void *fdt, PowerPCCPU *cpu, int bus_freq) { uint32_t cells[2]; =20 @@ -824,8 +831,8 @@ static void add_cpu_info(void *fdt, PowerPCCPU *cpu) qemu_fdt_setprop_cell(fdt, cp, "reservation-granule-size", 4); qemu_fdt_setprop_cell(fdt, cp, "timebase-frequency", cpu->env.tb_env->tb_freq); - qemu_fdt_setprop_cell(fdt, cp, "bus-frequency", BUS_FREQ_HZ); - qemu_fdt_setprop_cell(fdt, cp, "clock-frequency", BUS_FREQ_HZ * 7.5); + qemu_fdt_setprop_cell(fdt, cp, "bus-frequency", bus_freq); + qemu_fdt_setprop_cell(fdt, cp, "clock-frequency", bus_freq * 7.5); qemu_fdt_setprop_cell(fdt, cp, "cpu-version", cpu->env.spr[SPR_PVR]); cells[0] =3D 0; cells[1] =3D 0; @@ -860,7 +867,7 @@ static void *pegasos2_build_fdt(PegasosMachineState *pm= , int *fdt_size) } qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos2"); =20 - add_cpu_info(fdt, pm->cpu); + add_cpu_info(fdt, pm->cpu, pm->bus_freq_hz); =20 fi.fdt =3D fdt; fi.path =3D "/pci@c0000000"; --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178127796630.7200570627282; Wed, 22 Oct 2025 17:08:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqn-0007m1-3X; Wed, 22 Oct 2025 20:06:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqY-0007g6-Pw; Wed, 22 Oct 2025 20:06:27 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqU-0004a7-AG; Wed, 22 Oct 2025 20:06:25 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 77B905972E5; Thu, 23 Oct 2025 02:06:20 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id zwf_xx3SMn8E; Thu, 23 Oct 2025 02:06:18 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 7452C5972F0; Thu, 23 Oct 2025 02:06:18 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: <8f5bd07553b41d83a54f9df0bb93b76b22dea5c5.1761176219.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 11/12] hw/ppc/pegasos2: Add Pegasos I emulation MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:18 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178132832158500 Content-Type: text/plain; charset="utf-8" The Pegasos II is a redesign of the original Pegasos (later marked I) that replaces the north bridge and has updated firmware but otherwise these are very similar. The Pegasos uses the same north bridge that AmigaOne used which we already emulate so we can also easily emulate Pegasos I. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/ppc/pegasos2.c | 156 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 117 insertions(+), 39 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 7eaefcf9a0..a11f3c99ed 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -1,5 +1,5 @@ /* - * QEMU PowerPC CHRP (Genesi/bPlan Pegasos II) hardware System Emulator + * QEMU PowerPC CHRP (Genesi/bPlan Pegasos I/II) hardware System Emulator * * Copyright (c) 2018-2021 BALATON Zoltan * @@ -15,6 +15,7 @@ #include "hw/pci/pci_host.h" #include "hw/irq.h" #include "hw/or-irq.h" +#include "hw/pci-host/articia.h" #include "hw/pci-host/mv64361.h" #include "hw/isa/vt82c686.h" #include "hw/ide/pci.h" @@ -55,12 +56,18 @@ #define H_PRIVILEGE -3 /* Caller not privileged */ #define H_PARAMETER -4 /* Parameter invalid, out-of-range or conflicting= */ =20 +typedef enum { + PEGASOS1 =3D 1, + PEGASOS2 =3D 2, +} PegasosMachineType; + #define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos") OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE) =20 struct PegasosMachineState { MachineState parent_obj; =20 + PegasosMachineType type; PowerPCCPU *cpu; DeviceState *nb; /* north bridge */ DeviceState *sb; /* south bridge */ @@ -79,7 +86,7 @@ struct PegasosMachineState { =20 static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size); =20 -static void pegasos2_cpu_reset(void *opaque) +static void pegasos_cpu_reset(void *opaque) { PowerPCCPU *cpu =3D opaque; PegasosMachineState *pm =3D PEGASOS_MACHINE(current_machine); @@ -89,6 +96,8 @@ static void pegasos2_cpu_reset(void *opaque) if (pm->vof) { cpu->env.gpr[1] =3D 2 * VOF_STACK_SIZE - 0x20; cpu->env.nip =3D 0x100; + } else if (pm->type =3D=3D PEGASOS1) { + cpu->env.nip =3D 0xfffc0100; } cpu_ppc_tb_reset(&cpu->env); } @@ -139,13 +148,15 @@ static void pegasos_init(MachineState *machine) PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); CPUPPCState *env; MemoryRegion *rom =3D g_new(MemoryRegion, 1); - PCIBus *pci_bus; + PCIBus *pci_bus =3D NULL; Object *via; PCIDevice *dev; I2CBus *i2c_bus; const char *fwname =3D machine->firmware ?: PROM_FILENAME; char *filename; + hwaddr prom_addr; ssize_t sz; + int devfn; uint8_t *spd_data; =20 /* init CPU */ @@ -158,7 +169,7 @@ static void pegasos_init(MachineState *machine) =20 /* Set time-base frequency */ cpu_ppc_tb_init(env, pm->bus_freq_hz / 4); - qemu_register_reset(pegasos2_cpu_reset, pm->cpu); + qemu_register_reset(pegasos_cpu_reset, pm->cpu); =20 /* RAM */ if (machine->ram_size > 2 * GiB) { @@ -176,12 +187,16 @@ static void pegasos_init(MachineState *machine) if (!machine->firmware && !pm->vof) { pm->vof =3D g_malloc0(sizeof(*pm->vof)); } - memory_region_init_rom(rom, NULL, "pegasos2.rom", PROM_SIZE, &error_fa= tal); - memory_region_add_subregion(get_system_memory(), PROM_ADDR, rom); + prom_addr =3D PROM_ADDR; + if (pm->type =3D=3D PEGASOS1) { + prom_addr +=3D PROM_SIZE; + } + memory_region_init_rom(rom, NULL, "rom", PROM_SIZE, &error_fatal); + memory_region_add_subregion(get_system_memory(), prom_addr, rom); sz =3D load_elf(filename, NULL, NULL, NULL, NULL, NULL, NULL, NULL, ELFDATA2MSB, PPC_ELF_MACHINE, 0, 0); if (sz <=3D 0) { - sz =3D load_image_targphys(filename, pm->vof ? 0 : PROM_ADDR, PROM= _SIZE); + sz =3D load_image_targphys(filename, pm->vof ? 0 : prom_addr, PROM= _SIZE); } if (sz <=3D 0 || sz > PROM_SIZE) { error_report("Could not load firmware '%s'", filename); @@ -192,13 +207,37 @@ static void pegasos_init(MachineState *machine) pm->vof->fw_size =3D sz; } =20 - /* Marvell Discovery II system controller */ - pm->nb =3D DEVICE(sysbus_create_simple(TYPE_MV64361, -1, - qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_I= NT))); - pci_bus =3D mv64361_get_pci_bus(pm->nb, 1); + /* north bridge */ + switch (pm->type) { + case PEGASOS1: + { + MemoryRegion *pci_mem, *mr; + + /* Articia S */ + pm->nb =3D DEVICE(sysbus_create_simple(TYPE_ARTICIA, 0xfe000000, N= ULL)); + pci_mem =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 1); + mr =3D g_new(MemoryRegion, 1); + memory_region_init_alias(mr, OBJECT(pm->nb), "pci-mem-low", pci_me= m, + 0, 0x1000000); + memory_region_add_subregion(get_system_memory(), 0xfd000000, mr); + mr =3D g_new(MemoryRegion, 1); + memory_region_init_alias(mr, OBJECT(pm->nb), "pci-mem-high", pci_m= em, + 0x80000000, 0x7d000000); + memory_region_add_subregion(get_system_memory(), 0x80000000, mr); + pci_bus =3D PCI_BUS(qdev_get_child_bus(pm->nb, "pci.0")); + break; + } + case PEGASOS2: + /* Marvell Discovery II system controller */ + pm->nb =3D DEVICE(sysbus_create_simple(TYPE_MV64361, -1, + qdev_get_gpio_in(DEVICE(pm->cpu), PPC6xx_INPUT_INT= ))); + pci_bus =3D mv64361_get_pci_bus(pm->nb, 1); + break; + } =20 /* VIA VT8231 South Bridge (multifunction PCI device) */ - pm->sb =3D DEVICE(pci_new_multifunction(PCI_DEVFN(12, 0), TYPE_VT8231_= ISA)); + devfn =3D PCI_DEVFN(pm->type =3D=3D PEGASOS1 ? 7 : 12, 0); + pm->sb =3D DEVICE(pci_new_multifunction(devfn, TYPE_VT8231_ISA)); via =3D OBJECT(pm->sb); =20 /* Set properties on individual devices before realizing the south bri= dge */ @@ -223,7 +262,21 @@ static void pegasos_init(MachineState *machine) /* other PC hardware */ pci_vga_init(pci_bus); =20 - pegasos2_setup_pci_irq(pm); + /* pci interrupt routing */ + switch (pm->type) { + case PEGASOS1: + qdev_connect_gpio_out_named(pm->sb, "intr", 0, + qdev_get_gpio_in(DEVICE(pm->cpu), + PPC6xx_INPUT_INT)); + for (int i =3D 0; i < PCI_NUM_PINS; i++) { + qdev_connect_gpio_out(pm->nb, i, + qdev_get_gpio_in_named(pm->sb, "pirq", i= )); + } + break; + case PEGASOS2: + pegasos2_setup_pci_irq(pm); + break; + } =20 if (machine->kernel_filename) { sz =3D load_elf(machine->kernel_filename, NULL, NULL, NULL, @@ -376,7 +429,7 @@ static void pegasos2_chipset_reset(PegasosMachineState = *pm) PCI_INTERRUPT_LINE, 2, 0x309); } =20 -static void pegasos2_machine_reset(MachineState *machine, ResetType type) +static void pegasos_machine_reset(MachineState *machine, ResetType type) { PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); void *fdt; @@ -387,6 +440,9 @@ static void pegasos2_machine_reset(MachineState *machin= e, ResetType type) qemu_devices_reset(type); if (!pm->vof) { return; /* Firmware should set up machine so nothing to do */ + } else if (pm->type =3D=3D PEGASOS1) { + error_report("VOF is not supported by this machine"); + exit(1); } =20 /* Otherwise, set up devices that board firmware would normally do */ @@ -558,12 +614,12 @@ static target_ulong pegasos2_rtas(PowerPCCPU *cpu, Pe= gasosMachineState *pm, } } =20 -static bool pegasos2_cpu_in_nested(PowerPCCPU *cpu) +static bool pegasos_cpu_in_nested(PowerPCCPU *cpu) { return false; } =20 -static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu) +static void pegasos_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu) { PegasosMachineState *pm =3D PEGASOS_MACHINE(vhyp); CPUPPCState *env =3D &cpu->env; @@ -574,7 +630,7 @@ static void pegasos2_hypercall(PPCVirtualHypervisor *vh= yp, PowerPCCPU *cpu) if (FIELD_EX64(env->msr, MSR, PR)) { qemu_log_mask(LOG_GUEST_ERROR, "Hypercall made with MSR[PR]=3D1\n"= ); env->gpr[3] =3D H_PRIVILEGE; - } else if (env->gpr[3] =3D=3D KVMPPC_H_RTAS) { + } else if (env->gpr[3] =3D=3D KVMPPC_H_RTAS && pm->type =3D=3D PEGASOS= 2) { env->gpr[3] =3D pegasos2_rtas(cpu, pm, env->gpr[4]); } else if (env->gpr[3] =3D=3D KVMPPC_H_VOF_CLIENT) { int ret =3D vof_client_call(MACHINE(pm), pm->vof, MACHINE(pm)->fdt, @@ -596,56 +652,78 @@ static target_ulong vhyp_encode_hpt_for_kvm_pr(PPCVir= tualHypervisor *vhyp) return POWERPC_CPU(current_cpu)->env.spr[SPR_SDR1]; } =20 -static bool pegasos2_setprop(MachineState *ms, const char *path, - const char *propname, void *val, int vallen) +static bool pegasos_setprop(MachineState *ms, const char *path, + const char *propname, void *val, int vallen) { return true; } =20 -static void pegasos2_machine_class_init(ObjectClass *oc, const void *data) +static void pegasos_machine_init(MachineClass *mc) { - MachineClass *mc =3D MACHINE_CLASS(oc); - PPCVirtualHypervisorClass *vhc =3D PPC_VIRTUAL_HYPERVISOR_CLASS(oc); - VofMachineIfClass *vmc =3D VOF_MACHINE_CLASS(oc); + PPCVirtualHypervisorClass *vhc =3D PPC_VIRTUAL_HYPERVISOR_CLASS(mc); + VofMachineIfClass *vmc =3D VOF_MACHINE_CLASS(mc); =20 - mc->desc =3D "Genesi/bPlan Pegasos II"; mc->init =3D pegasos_init; - mc->reset =3D pegasos2_machine_reset; + mc->reset =3D pegasos_machine_reset; mc->block_default_type =3D IF_IDE; mc->default_boot_order =3D "cd"; mc->default_display =3D "std"; - mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("7457_v1.2"); - mc->default_ram_id =3D "pegasos2.ram"; + mc->default_ram_id =3D "ram"; mc->default_ram_size =3D 512 * MiB; machine_add_audiodev_property(mc); =20 - vhc->cpu_in_nested =3D pegasos2_cpu_in_nested; - vhc->hypercall =3D pegasos2_hypercall; + vhc->cpu_in_nested =3D pegasos_cpu_in_nested; + vhc->hypercall =3D pegasos_hypercall; vhc->cpu_exec_enter =3D vhyp_nop; vhc->cpu_exec_exit =3D vhyp_nop; vhc->encode_hpt_for_kvm_pr =3D vhyp_encode_hpt_for_kvm_pr; =20 - vmc->setprop =3D pegasos2_setprop; + vmc->setprop =3D pegasos_setprop; +} + +static void pegasos1_init(Object *obj) +{ + PegasosMachineState *pm =3D PEGASOS_MACHINE(obj); + + pm->type =3D PEGASOS1; + pm->bus_freq_hz =3D 33000000; +} + +static void pegasos1_machine_class_init(ObjectClass *oc, const void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->desc =3D "Genesi/bPlan Pegasos I"; + mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("750cxe_v3.1b"); } =20 static void pegasos2_init(Object *obj) { PegasosMachineState *pm =3D PEGASOS_MACHINE(obj); =20 + pm->type =3D PEGASOS2; pm->bus_freq_hz =3D 133333333; } =20 +static void pegasos2_machine_class_init(ObjectClass *oc, const void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->desc =3D "Genesi/bPlan Pegasos II"; + mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("7457_v1.2"); +} + +DEFINE_MACHINE_EXTENDED("pegasos", MACHINE, PegasosMachineState, + pegasos_machine_init, true, (const InterfaceInfo[]= ) { + { TYPE_PPC_VIRTUAL_HYPERVISOR }, + { TYPE_VOF_MACHINE_IF }, { } }) + static const TypeInfo pegasos_machine_types[] =3D { { - .name =3D TYPE_PEGASOS_MACHINE, - .parent =3D TYPE_MACHINE, - .instance_size =3D sizeof(PegasosMachineState), - .abstract =3D true, - .interfaces =3D (const InterfaceInfo[]) { - { TYPE_PPC_VIRTUAL_HYPERVISOR }, - { TYPE_VOF_MACHINE_IF }, - { } - }, + .name =3D MACHINE_TYPE_NAME("pegasos1"), + .parent =3D TYPE_PEGASOS_MACHINE, + .class_init =3D pegasos1_machine_class_init, + .instance_init =3D pegasos1_init, }, { .name =3D MACHINE_TYPE_NAME("pegasos2"), --=20 2.41.3 From nobody Sat Nov 8 15:09:22 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1761178122488630.8212346137885; Wed, 22 Oct 2025 17:08:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vBiqn-0007m5-6t; Wed, 22 Oct 2025 20:06:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqZ-0007gd-Vd; Wed, 22 Oct 2025 20:06:28 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1vBiqV-0004aW-8j; Wed, 22 Oct 2025 20:06:27 -0400 Received: from localhost (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id 8F5E95972EB; Thu, 23 Oct 2025 02:06:21 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by localhost (zero.eik.bme.hu [127.0.0.1]) (amavis, port 10028) with ESMTP id JXUT3D_LZhLc; Thu, 23 Oct 2025 02:06:19 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 82AB95972E3; Thu, 23 Oct 2025 02:06:19 +0200 (CEST) X-Virus-Scanned: amavis at eik.bme.hu Message-ID: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH v4 12/12] hw/ppc/pegasos2: Add VOF support for pegasos1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin , Markus Armbruster , Harsh Prateek Bora Date: Thu, 23 Oct 2025 02:06:19 +0200 (CEST) Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1761178125897154100 Content-Type: text/plain; charset="utf-8" When running without firmware ROM using Virtual Open Firmware we need to do some hardware initialisation and provide the device tree as the machine firmware would normally do. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- MAINTAINERS | 1 + hw/ppc/pegasos2.c | 140 +++++++++++++++++++++++++++++++++------ pc-bios/dtb/meson.build | 1 + pc-bios/dtb/pegasos1.dtb | Bin 0 -> 857 bytes pc-bios/dtb/pegasos1.dts | 125 ++++++++++++++++++++++++++++++++++ 5 files changed, 246 insertions(+), 21 deletions(-) create mode 100644 pc-bios/dtb/pegasos1.dtb create mode 100644 pc-bios/dtb/pegasos1.dts diff --git a/MAINTAINERS b/MAINTAINERS index 36eef27b41..684d7a5b37 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1652,6 +1652,7 @@ F: hw/ppc/pegasos2.c F: hw/pci-host/mv64361.c F: hw/pci-host/mv643xx.h F: include/hw/pci-host/mv64361.h +F: pc-bios/dtb/pegasos[12].dt[sb] =20 amigaone M: BALATON Zoltan diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index a11f3c99ed..93696ed381 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -84,6 +84,7 @@ struct PegasosMachineState { uint64_t initrd_size; }; =20 +static void *pegasos1_build_fdt(PegasosMachineState *pm, int *fdt_size); static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size); =20 static void pegasos_cpu_reset(void *opaque) @@ -314,6 +315,82 @@ static void pegasos_init(MachineState *machine) } } =20 +static void pegasos_superio_write(uint8_t addr, uint8_t val) +{ + cpu_physical_memory_write(0xfe0003f0, &addr, 1); + cpu_physical_memory_write(0xfe0003f1, &val, 1); +} + +static void pegasos1_pci_config_write(PegasosMachineState *pm, int bus, + uint32_t addr, uint32_t len, uint32_= t val) +{ + addr |=3D BIT(31); + cpu_physical_memory_write(0xfec00cf8, &addr, 4); + cpu_physical_memory_write(0xfee00cfc, &val, len); +} + +static void pegasos1_chipset_reset(PegasosMachineState *pm) +{ + uint8_t elcr =3D 0x2e; + cpu_physical_memory_write(0xfe0004d1, &elcr, sizeof(elcr)); + + pegasos1_pci_config_write(pm, 0, PCI_COMMAND, 2, PCI_COMMAND_IO | + PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); + + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 0) << 8) | + PCI_INTERRUPT_LINE, 2, 0x9); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 0) << 8) | + 0x50, 1, 0x6); + pegasos_superio_write(0xf4, 0xbe); + pegasos_superio_write(0xf6, 0xef); + pegasos_superio_write(0xf7, 0xfc); + pegasos_superio_write(0xf2, 0x14); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 0) << 8) | + 0x51, 1, 0x3d); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 0) << 8) | + 0x55, 1, 0x90); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 0) << 8) | + 0x56, 1, 0x99); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 0) << 8) | + 0x57, 1, 0x90); + + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 1) << 8) | + PCI_INTERRUPT_LINE, 2, 0x10e); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 1) << 8) | + PCI_CLASS_PROG, 1, 0xf); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 1) << 8) | + 0x40, 1, 0xb); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 1) << 8) | + 0x50, 4, 0x17171717); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 1) << 8) | + PCI_COMMAND, 2, 0x87); + + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 2) << 8) | + PCI_INTERRUPT_LINE, 2, 0x409); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 2) << 8) | + PCI_COMMAND, 2, 0x7); + + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 3) << 8) | + PCI_INTERRUPT_LINE, 2, 0x409); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 3) << 8) | + PCI_COMMAND, 2, 0x7); + + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 4) << 8) | + PCI_INTERRUPT_LINE, 2, 0x9); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 4) << 8) | + 0x48, 4, 0x2001); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 4) << 8) | + 0x41, 1, 0); + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 4) << 8) | + 0x90, 4, 0x1000); + + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 5) << 8) | + PCI_INTERRUPT_LINE, 2, 0x309); + + pegasos1_pci_config_write(pm, 0, (PCI_DEVFN(7, 6) << 8) | + PCI_INTERRUPT_LINE, 2, 0x309); +} + static uint32_t pegasos2_mv_reg_read(PegasosMachineState *pm, uint32_t addr, uint32_t len) { @@ -357,12 +434,6 @@ static void pegasos2_pci_config_write(PegasosMachineSt= ate *pm, int bus, pegasos2_mv_reg_write(pm, pcicfg + 4, len, val); } =20 -static void pegasos2_superio_write(uint8_t addr, uint8_t val) -{ - cpu_physical_memory_write(0xfe0003f0, &addr, 1); - cpu_physical_memory_write(0xfe0003f1, &val, 1); -} - static void pegasos2_chipset_reset(PegasosMachineState *pm) { pegasos2_mv_reg_write(pm, 0, 4, 0x28020ff); @@ -379,10 +450,10 @@ static void pegasos2_chipset_reset(PegasosMachineStat= e *pm) PCI_INTERRUPT_LINE, 2, 0x9); pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | 0x50, 1, 0x6); - pegasos2_superio_write(0xf4, 0xbe); - pegasos2_superio_write(0xf6, 0xef); - pegasos2_superio_write(0xf7, 0xfc); - pegasos2_superio_write(0xf2, 0x14); + pegasos_superio_write(0xf4, 0xbe); + pegasos_superio_write(0xf6, 0xef); + pegasos_superio_write(0xf7, 0xfc); + pegasos_superio_write(0xf2, 0x14); pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | 0x50, 1, 0x2); pegasos2_pci_config_write(pm, 1, (PCI_DEVFN(12, 0) << 8) | @@ -432,7 +503,7 @@ static void pegasos2_chipset_reset(PegasosMachineState = *pm) static void pegasos_machine_reset(MachineState *machine, ResetType type) { PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); - void *fdt; + void *fdt =3D NULL; uint32_t c[2]; uint64_t d[2]; int sz; @@ -440,13 +511,22 @@ static void pegasos_machine_reset(MachineState *machi= ne, ResetType type) qemu_devices_reset(type); if (!pm->vof) { return; /* Firmware should set up machine so nothing to do */ - } else if (pm->type =3D=3D PEGASOS1) { - error_report("VOF is not supported by this machine"); - exit(1); } =20 /* Otherwise, set up devices that board firmware would normally do */ - pegasos2_chipset_reset(pm); + switch (pm->type) { + case PEGASOS1: + pegasos1_chipset_reset(pm); + fdt =3D pegasos1_build_fdt(pm, &sz); + break; + case PEGASOS2: + pegasos2_chipset_reset(pm); + fdt =3D pegasos2_build_fdt(pm, &sz); + break; + } + if (!fdt) { + exit(1); + } =20 /* Device tree and VOF set up */ vof_init(pm->vof, machine->ram_size, &error_fatal); @@ -465,11 +545,6 @@ static void pegasos_machine_reset(MachineState *machin= e, ResetType type) exit(1); } =20 - fdt =3D pegasos2_build_fdt(pm, &sz); - if (!fdt) { - exit(1); - } - /* Set memory size */ c[0] =3D 0; c[1] =3D cpu_to_be32(machine->ram_size); @@ -761,6 +836,8 @@ static struct { const char *name; void (*dtf)(PCIBus *bus, PCIDevice *d, FDTInfo *fi); } device_map[] =3D { + { "pci10cc,660", "host", NULL }, + { "pci10cc,661", "host", NULL }, { "pci11ab,6460", "host", NULL }, { "pci1106,571", "ide", dt_ide }, { "pci1106,3044", "firewire", NULL }, @@ -846,7 +923,7 @@ static void add_pci_device(PCIBus *bus, PCIDevice *d, v= oid *opaque) qemu_fdt_setprop_cell(fi->fdt, node->str, "interrupts", pci_get_byte(&d->config[PCI_INTERRUPT_PIN])); } - /* Pegasos2 firmware has subsystem-id amd subsystem-vendor-id swapped = */ + /* Pegasos firmware has subsystem-id and subsystem-vendor-id swapped */ qemu_fdt_setprop_cell(fi->fdt, node->str, "subsystem-vendor-id", pci_get_word(&d->config[PCI_SUBSYSTEM_ID])); qemu_fdt_setprop_cell(fi->fdt, node->str, "subsystem-id", @@ -934,6 +1011,27 @@ static void *load_dtb(const char *filename, int *fdt_= size) return fdt; } =20 +static void *pegasos1_build_fdt(PegasosMachineState *pm, int *fdt_size) +{ + FDTInfo fi; + PCIBus *pci_bus; + void *fdt =3D load_dtb("pegasos1.dtb", fdt_size); + + if (!fdt) { + return NULL; + } + qemu_fdt_setprop_string(fdt, "/", "name", "bplan,Pegasos"); + + add_cpu_info(fdt, pm->cpu, pm->bus_freq_hz); + + fi.fdt =3D fdt; + fi.path =3D "/pci@80000000"; + pci_bus =3D PCI_BUS(qdev_get_child_bus(pm->nb, "pci.0")); + pci_for_each_device_reverse(pci_bus, 0, add_pci_device, &fi); + + return fdt; +} + static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size) { FDTInfo fi; diff --git a/pc-bios/dtb/meson.build b/pc-bios/dtb/meson.build index f14648f3a4..81bdd7580e 100644 --- a/pc-bios/dtb/meson.build +++ b/pc-bios/dtb/meson.build @@ -1,6 +1,7 @@ dtbs =3D [ 'bamboo.dtb', 'canyonlands.dtb', + 'pegasos1.dtb', 'pegasos2.dtb', 'petalogix-ml605.dtb', 'petalogix-s3adsp1800.dtb', diff --git a/pc-bios/dtb/pegasos1.dtb b/pc-bios/dtb/pegasos1.dtb new file mode 100644 index 0000000000000000000000000000000000000000..3b863b25288a59bcede9459ff42= afad713dde741 GIT binary patch literal 857 zcmZ8fO>Yx15OvxjK&T3w=3D^-c=3DRCQ5Ogp}S|g(^KkM8yI1P1Ue)2P zwH4Vq`;8bw1HZ>;t21Y#4($Qs>6oU{8xI*8@T`9T8sbOnw^Lh4-5HhX(Mm_{-ksVl z)<#k543FN8J7aT6ZanN9FMLHMid)8#w$22?9P@Cm<{Ue{7yY!q`;sNG#%QTC<4J?o zyrj~&#eOd+b^U#g+qE9l=3D58l32d?gA=3Di#Evk%Mn^%78T-ar4cvKZ`unPh?(rIUyvm zp(f1smX2*md1FhM>Vd@`{15zY&OI5A?*GZ_uJ49eCK4S?0+5L{U+AknfX#fBK literal 0 HcmV?d00001 diff --git a/pc-bios/dtb/pegasos1.dts b/pc-bios/dtb/pegasos1.dts new file mode 100644 index 0000000000..e5ef9db866 --- /dev/null +++ b/pc-bios/dtb/pegasos1.dts @@ -0,0 +1,125 @@ +/* + * QEMU Pegasos1 Device Tree Source + * + * Copyright 2025 BALATON Zoltan + * SPDX-License-Identifier: GPL-2.0-or-later + * + * This is partial source, more info will be filled in by board code. + */ + +/dts-v1/; + +/ { + #address-cells =3D <1>; + device_type =3D "chrp"; + model =3D "Pegasos"; + revision =3D "1A"; + CODEGEN,vendor =3D "bplan GmbH"; + CODEGEN,board =3D "Pegasos"; + CODEGEN,description =3D "Pegasos CHRP PowerPC System"; + + openprom { + model =3D "Pegasos,0.1b123"; + }; + + chosen { + }; + + memory@0 { + device_type =3D "memory"; + reg =3D <0 0>; + }; + + cpus { + #size-cells =3D <0>; + #address-cells =3D <1>; + #cpus =3D <1>; + }; + + failsafe { + device_type =3D "serial"; + }; + + pci@80000000 { + device_type =3D "pci"; + #address-cells =3D <3>; + #size-cells =3D <2>; + clock-frequency =3D <33333333>; + 8259-interrupt-acknowledge =3D <0xfef00000>; + reg =3D <0x80000000 0x7f000000>; + ranges =3D <0x01000000 0 0x00000000 0xfe000000 0 0x00800000 + 0x02000000 0 0x80000000 0x80000000 0 0x7d000000 + 0x02000000 0 0xfd000000 0xfd000000 0 0x01000000>; + bus-range =3D <0 0>; + + isa@7 { + vendor-id =3D <0x1106>; + device-id =3D <0x8231>; + revision-id =3D <0x10>; + class-code =3D <0x60100>; + /* Pegasos firmware has subsystem-id and */ + /* subsystem-vendor-id swapped */ + subsystem-id =3D <0x1af4>; + subsystem-vendor-id =3D <0x1100>; + reg =3D <0x3800 0 0 0 0>; + device_type =3D "isa"; + #address-cells =3D <2>; + #size-cells =3D <1>; + eisa-slots =3D <0>; + clock-frequency =3D <8333333>; + slot-names =3D <0>; + + serial@i2f8 { + device_type =3D "serial"; + reg =3D <1 0x2f8 8>; + interrupts =3D <3 0>; + clock-frequency =3D <0>; + }; + + 8042@i60 { + device_type =3D ""; + reg =3D <1 0x60 5>; + clock-frequency =3D <0>; + interrupt-controller =3D ""; + #address-cells =3D <1>; + #size-cells =3D <0>; + #interrupt-cells =3D <2>; + + }; + + keyboard@i60 { + device_type =3D "keyboard"; + reg =3D <1 0x60 5>; + interrupts =3D <1 0>; + }; + + rtc@i70 { + device_type =3D "rtc"; + reg =3D <1 0x70 2>; + interrupts =3D <8 0>; + clock-frequency =3D <0>; + compatible =3D "ds1385-rtc"; + }; + + timer@i40 { + device_type =3D "timer"; + reg =3D <1 0x40 8>; + clock-frequency =3D <0>; + }; + + fdc@i3f0 { + device_type =3D "fdc"; + reg =3D <1 0x3f0 8>; + interrupts =3D <6 0>; + clock-frequency =3D <0>; + }; + + lpt@i3bc { + device_type =3D "lpt"; + reg =3D <1 0x3bc 8>; + interrupts =3D <7 0>; + clock-frequency =3D <0>; + }; + }; + }; +}; --=20 2.41.3