]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/loongarch/virt: Add field gpex in LoongArchVirtMachineState
authorBibo Mao <maobibo@loongson.cn>
Fri, 17 Oct 2025 06:45:18 +0000 (14:45 +0800)
committerBibo Mao <maobibo@loongson.cn>
Mon, 12 Jan 2026 06:51:30 +0000 (14:51 +0800)
Add field gpex in structure LoongArchVirtMachineState, type of field gpex
is structure GPEXConfig and it is to record configuration information
about GPEX host bridge. And remove field pci_bus in structure
LoongArchVirtMachineState since the information is in field gpex already.

Signed-off-by: Bibo Mao <maobibo@loongson.cn>
Reviewed-by: Song Gao <gaosong@loongson.cn>
hw/loongarch/virt-acpi-build.c
hw/loongarch/virt.c
include/hw/loongarch/virt.h

index 8ff9ebdcd9ed013cf86ab7f8bb2d666f1227705c..012e0c23b87ffca2097175daa18b71bab7fb79fc 100644 (file)
@@ -383,18 +383,7 @@ build_la_ged_aml(Aml *dsdt, MachineState *machine)
 
 static void build_pci_device_aml(Aml *scope, LoongArchVirtMachineState *lvms)
 {
-    struct GPEXConfig cfg = {
-        .mmio64.base = VIRT_PCI_MEM_BASE,
-        .mmio64.size = VIRT_PCI_MEM_SIZE,
-        .pio.base    = VIRT_PCI_IO_BASE,
-        .pio.size    = VIRT_PCI_IO_SIZE,
-        .ecam.base   = VIRT_PCI_CFG_BASE,
-        .ecam.size   = VIRT_PCI_CFG_SIZE,
-        .irq         = VIRT_GSI_BASE + VIRT_DEVICE_IRQS,
-        .bus         = lvms->pci_bus,
-    };
-
-    acpi_dsdt_add_gpex(scope, &cfg);
+    acpi_dsdt_add_gpex(scope, &lvms->gpex);
 }
 
 static void build_flash_aml(Aml *scope, LoongArchVirtMachineState *lvms)
index 9d189e5a77104be5a44bc2166b80c34b4a302f48..b00393565f120cc57267c57b3eb0d4149f372715 100644 (file)
@@ -298,7 +298,14 @@ static void virt_devices_init(DeviceState *pch_pic,
     d = SYS_BUS_DEVICE(gpex_dev);
     sysbus_realize_and_unref(d, &error_fatal);
     pci_bus = PCI_HOST_BRIDGE(gpex_dev)->bus;
-    lvms->pci_bus = pci_bus;
+    lvms->gpex.mmio64.base = VIRT_PCI_MEM_BASE;
+    lvms->gpex.mmio64.size = VIRT_PCI_MEM_SIZE;
+    lvms->gpex.pio.base = VIRT_PCI_IO_BASE;
+    lvms->gpex.pio.size = VIRT_PCI_IO_SIZE;
+    lvms->gpex.ecam.base = VIRT_PCI_CFG_BASE;
+    lvms->gpex.ecam.size = VIRT_PCI_CFG_SIZE;
+    lvms->gpex.irq = VIRT_GSI_BASE + VIRT_DEVICE_IRQS;
+    lvms->gpex.bus = pci_bus;
 
     /* Map only part size_ecam bytes of ECAM space */
     ecam_alias = g_new0(MemoryRegion, 1);
index d7e94428f099c411ad575b10796ca7cebda3dac2..cdc03f4c876c0b6450a394aec2e0e95e0211471c 100644 (file)
@@ -12,6 +12,7 @@
 #include "qemu/queue.h"
 #include "hw/block/flash.h"
 #include "hw/loongarch/boot.h"
+#include "hw/pci-host/gpex.h"
 
 /* IOCSR region */
 #define VERSION_REG             0x0
@@ -112,7 +113,6 @@ struct LoongArchVirtMachineState {
     DeviceState  *acpi_ged;
     int          fdt_size;
     DeviceState *platform_bus_dev;
-    PCIBus       *pci_bus;
     PFlashCFI01  *flash[2];
     MemoryRegion system_iocsr;
     MemoryRegion iocsr_mem;
@@ -126,6 +126,7 @@ struct LoongArchVirtMachineState {
     uint64_t misc_status;
     DeviceState *dintc;
     hwaddr ram_end;
+    struct GPEXConfig gpex;
 };
 
 #define TYPE_LOONGARCH_VIRT_MACHINE  MACHINE_TYPE_NAME("virt")