- fix compile error on loongarch
- hw/loongarch: fix cpu hotplug reset
- hw/loongarch/boot: Use warn_report when no kernel filename
- hw/loongarch: clean code
- hw/loongarch: Add KVM pch msi device support
- hw/loongarch: Add KVM pch pic device support
- hw/loongarch: Add KVM extioi device support
- hw/loongarch: Add KVM IPI device support
- hw/loongarch/virt: Update the ACPI table for hotplug cpu
- hw/loongarch/virt: Add basic CPU plug support
- hw/loongarch/virt: Add CPU topology support
- accel/kvm/kvm-all: Fixes the missing break in vCPU unpark logic
- gdbstub: Add helper function to unregister GDB register space
- physmem: Add helper function to destroy CPU AddressSpace
- hw/acpi: Update CPUs AML with cpu-(ctrl)dev change
- hw/acpi: Update ACPI GED framework to support vCPU Hotplug
- hw/acpi: Move CPU ctrl-dev MMIO region len macro to common header file
- accel/kvm: Extract common KVM vCPU {creation,parking} code
- target/loongarch: Add steal time support on migration
- linux-headers: loongarch: Add kvm_para.h and unistd_64.h
- target/loongarch/kvm: Implement LoongArch PMU extension
- target/loongarch: Implement lbt registers save/restore function
- target/loongarch: Add loongson binary translation feature
- sync loongarch linux-headers
- target/loongarch: Avoid bits shift exceeding width of bool type
- target/loongarch: Use explicit little-endian LD/ST API
- target/loongarch: fix -Werror=maybe-uninitialized false-positive
- target/loongarch: Support QMP dump-guest-memory
- target/loongarch/kvm: Add vCPU reset function
- target/loongarch: Add compatible support about VM reboot
- target/loongarch: Fix cpu_reset set wrong CSR_CRMD
- target/loongarch: Set CSR_PRCFG1 and CSR_PRCFG2 values
- target/loongarch: Remove avail_64 in trans_srai_w() and simplify it
- target/loongarch/kvm: Add software breakpoint support
- target/loongarch: Add loongarch vector property unconditionally
- target/loongarch/kvm: Fix VM recovery from disk failures
- target/loongarch: Put cpucfg operation before CSR register
- target/loongarch: Add TCG macro in structure CPUArchState
- hw/arm/virt-acpi-build.c: Migrate SPCR creation to common location
- hw/loongarch/virt: Add FDT table support with acpi ged pm register
- hw/loongarch/virt: Add description for virt machine type
- hw/loongarch: Add acpi SPCR table support
- hw/loongarch: virt: pass random seed to fdt
- hw/loongarch: virt: support up to 4 serial ports
- hw/loongarch: Remove default enable with VIRTIO_VGA device
- hw/loongarch: Fix length for lowram in ACPI SRAT
- hw/loongarch/virt: Remove unused assignment
- hw/loongarch: Change the tpm support by default
- hw/loongarch/boot.c: fix out-of-bound reading
- hw/loongarch/virt: Use MemTxAttrs interface for misc ops
- tests/libqos: Add loongarch virt machine node
- hw/loongarch: Remove minimum and default memory size
- hw/loongarch: Refine system dram memory region
- hw/loongarch: Refine fwcfg memory map
- hw/loongarch: Refine fadt memory table for numa memory
- hw/loongarch: Refine acpi srat table for numa memory
- hw/loongarch: Add VM mode in IOCSR feature register in kvm mode
- hw/loongarch: Refine default numa id calculation
- hw/loongarch: Rename LoongArchMachineState with LoongArchVirtMachineState
- hw/loongarch: Rename LOONGARCH_MACHINE with LOONGARCH_VIRT_MACHINE
- hw/loongarch: move memory map to boot.c
- loongarch: switch boards to "default y"
- hw/loongarch: Add cells missing from rtc node
- hw/loongarch: Add cells missing from uart node
- hw/loongarch: fdt remove unused irqchip node
- hw/loongarch: fdt adds pcie irq_map node
- hw/loongarch: fdt adds pch_msi Controller
- hw/loongarch: fdt adds pch_pic Controller
- hw/loongarch: fdt adds Extend I/O Interrupt Controller
- hw/loongarch: fdt adds cpu interrupt controller node
- hw/loongarch: Init efi_fdt table
- hw/loongarch: Init efi_initrd table
- hw/loongarch: Init efi_boot_memmap table
- hw/loongarch: Init efi_system_table
- hw/loongarch: Add init_cmdline
- hw/loongarch: Add slave cpu boot_code
- hw/loongarch: Add load initrd
- hw/loongarch: Move boot functions to boot.c
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
(cherry picked from commit 04ca9e6c8ff19630116722240ae0136cea831c5c)
238 lines
9.3 KiB
Diff
238 lines
9.3 KiB
Diff
From f6b4a18ba78b1daa2a69fccfb768ec2bdcafb1d4 Mon Sep 17 00:00:00 2001
|
|
From: Sia Jee Heng <jeeheng.sia@starfivetech.com>
|
|
Date: Sun, 28 Jan 2024 18:14:39 -0800
|
|
Subject: [PATCH] hw/arm/virt-acpi-build.c: Migrate SPCR creation to common
|
|
location
|
|
|
|
RISC-V should also generate the SPCR in a manner similar to ARM.
|
|
Therefore, instead of replicating the code, relocate this function
|
|
to the common AML build.
|
|
|
|
Signed-off-by: Sia Jee Heng <jeeheng.sia@starfivetech.com>
|
|
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
|
|
Message-ID: <20240129021440.17640-2-jeeheng.sia@starfivetech.com>
|
|
[ Changes by AF:
|
|
- Add missing Language SPCR entry
|
|
]
|
|
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
|
|
Signed-off-by: Xianglai Li <lixianglai@loongson.cn>
|
|
---
|
|
hw/acpi/aml-build.c | 53 +++++++++++++++++++++++++++++
|
|
hw/arm/virt-acpi-build.c | 68 +++++++++++++++----------------------
|
|
include/hw/acpi/acpi-defs.h | 33 ++++++++++++++++++
|
|
include/hw/acpi/aml-build.h | 4 +++
|
|
4 files changed, 117 insertions(+), 41 deletions(-)
|
|
|
|
diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
|
|
index 0d4994baf..3fb996c03 100644
|
|
--- a/hw/acpi/aml-build.c
|
|
+++ b/hw/acpi/aml-build.c
|
|
@@ -2016,6 +2016,59 @@ void build_processor_hierarchy_node(GArray *tbl, uint32_t flags,
|
|
}
|
|
}
|
|
|
|
+void build_spcr(GArray *table_data, BIOSLinker *linker,
|
|
+ const AcpiSpcrData *f, const uint8_t rev,
|
|
+ const char *oem_id, const char *oem_table_id)
|
|
+{
|
|
+ AcpiTable table = { .sig = "SPCR", .rev = rev, .oem_id = oem_id,
|
|
+ .oem_table_id = oem_table_id };
|
|
+
|
|
+ acpi_table_begin(&table, table_data);
|
|
+ /* Interface type */
|
|
+ build_append_int_noprefix(table_data, f->interface_type, 1);
|
|
+ /* Reserved */
|
|
+ build_append_int_noprefix(table_data, 0, 3);
|
|
+ /* Base Address */
|
|
+ build_append_gas(table_data, f->base_addr.id, f->base_addr.width,
|
|
+ f->base_addr.offset, f->base_addr.size,
|
|
+ f->base_addr.addr);
|
|
+ /* Interrupt type */
|
|
+ build_append_int_noprefix(table_data, f->interrupt_type, 1);
|
|
+ /* IRQ */
|
|
+ build_append_int_noprefix(table_data, f->pc_interrupt, 1);
|
|
+ /* Global System Interrupt */
|
|
+ build_append_int_noprefix(table_data, f->interrupt, 4);
|
|
+ /* Baud Rate */
|
|
+ build_append_int_noprefix(table_data, f->baud_rate, 1);
|
|
+ /* Parity */
|
|
+ build_append_int_noprefix(table_data, f->parity, 1);
|
|
+ /* Stop Bits */
|
|
+ build_append_int_noprefix(table_data, f->stop_bits, 1);
|
|
+ /* Flow Control */
|
|
+ build_append_int_noprefix(table_data, f->flow_control, 1);
|
|
+ /* Language */
|
|
+ build_append_int_noprefix(table_data, f->language, 1);
|
|
+ /* Terminal Type */
|
|
+ build_append_int_noprefix(table_data, f->terminal_type, 1);
|
|
+ /* PCI Device ID */
|
|
+ build_append_int_noprefix(table_data, f->pci_device_id, 2);
|
|
+ /* PCI Vendor ID */
|
|
+ build_append_int_noprefix(table_data, f->pci_vendor_id, 2);
|
|
+ /* PCI Bus Number */
|
|
+ build_append_int_noprefix(table_data, f->pci_bus, 1);
|
|
+ /* PCI Device Number */
|
|
+ build_append_int_noprefix(table_data, f->pci_device, 1);
|
|
+ /* PCI Function Number */
|
|
+ build_append_int_noprefix(table_data, f->pci_function, 1);
|
|
+ /* PCI Flags */
|
|
+ build_append_int_noprefix(table_data, f->pci_flags, 4);
|
|
+ /* PCI Segment */
|
|
+ build_append_int_noprefix(table_data, f->pci_segment, 1);
|
|
+ /* Reserved */
|
|
+ build_append_int_noprefix(table_data, 0, 4);
|
|
+
|
|
+ acpi_table_end(linker, &table);
|
|
+}
|
|
/*
|
|
* ACPI spec, Revision 6.3
|
|
* 5.2.29 Processor Properties Topology Table (PPTT)
|
|
diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
|
|
index 86984b716..076781423 100644
|
|
--- a/hw/arm/virt-acpi-build.c
|
|
+++ b/hw/arm/virt-acpi-build.c
|
|
@@ -717,48 +717,34 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
* Rev: 1.07
|
|
*/
|
|
static void
|
|
-build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
+spcr_setup(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
|
|
{
|
|
- AcpiTable table = { .sig = "SPCR", .rev = 2, .oem_id = vms->oem_id,
|
|
- .oem_table_id = vms->oem_table_id };
|
|
-
|
|
- acpi_table_begin(&table, table_data);
|
|
-
|
|
- /* Interface Type */
|
|
- build_append_int_noprefix(table_data, 3, 1); /* ARM PL011 UART */
|
|
- build_append_int_noprefix(table_data, 0, 3); /* Reserved */
|
|
- /* Base Address */
|
|
- build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 32, 0, 3,
|
|
- vms->memmap[VIRT_UART].base);
|
|
- /* Interrupt Type */
|
|
- build_append_int_noprefix(table_data,
|
|
- (1 << 3) /* Bit[3] ARMH GIC interrupt */, 1);
|
|
- build_append_int_noprefix(table_data, 0, 1); /* IRQ */
|
|
- /* Global System Interrupt */
|
|
- build_append_int_noprefix(table_data,
|
|
- vms->irqmap[VIRT_UART] + ARM_SPI_BASE, 4);
|
|
- build_append_int_noprefix(table_data, 3 /* 9600 */, 1); /* Baud Rate */
|
|
- build_append_int_noprefix(table_data, 0 /* No Parity */, 1); /* Parity */
|
|
- /* Stop Bits */
|
|
- build_append_int_noprefix(table_data, 1 /* 1 Stop bit */, 1);
|
|
- /* Flow Control */
|
|
- build_append_int_noprefix(table_data,
|
|
- (1 << 1) /* RTS/CTS hardware flow control */, 1);
|
|
- /* Terminal Type */
|
|
- build_append_int_noprefix(table_data, 0 /* VT100 */, 1);
|
|
- build_append_int_noprefix(table_data, 0, 1); /* Language */
|
|
- /* PCI Device ID */
|
|
- build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2);
|
|
- /* PCI Vendor ID */
|
|
- build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2);
|
|
- build_append_int_noprefix(table_data, 0, 1); /* PCI Bus Number */
|
|
- build_append_int_noprefix(table_data, 0, 1); /* PCI Device Number */
|
|
- build_append_int_noprefix(table_data, 0, 1); /* PCI Function Number */
|
|
- build_append_int_noprefix(table_data, 0, 4); /* PCI Flags */
|
|
- build_append_int_noprefix(table_data, 0, 1); /* PCI Segment */
|
|
- build_append_int_noprefix(table_data, 0, 4); /* Reserved */
|
|
+ AcpiSpcrData serial = {
|
|
+ .interface_type = 3, /* ARM PL011 UART */
|
|
+ .base_addr.id = AML_AS_SYSTEM_MEMORY,
|
|
+ .base_addr.width = 32,
|
|
+ .base_addr.offset = 0,
|
|
+ .base_addr.size = 3,
|
|
+ .base_addr.addr = vms->memmap[VIRT_UART].base,
|
|
+ .interrupt_type = (1 << 3),/* Bit[3] ARMH GIC interrupt*/
|
|
+ .pc_interrupt = 0, /* IRQ */
|
|
+ .interrupt = (vms->irqmap[VIRT_UART] + ARM_SPI_BASE),
|
|
+ .baud_rate = 3, /* 9600 */
|
|
+ .parity = 0, /* No Parity */
|
|
+ .stop_bits = 1, /* 1 Stop bit */
|
|
+ .flow_control = 1 << 1, /* RTS/CTS hardware flow control */
|
|
+ .terminal_type = 0, /* VT100 */
|
|
+ .language = 0, /* Language */
|
|
+ .pci_device_id = 0xffff, /* not a PCI device*/
|
|
+ .pci_vendor_id = 0xffff, /* not a PCI device*/
|
|
+ .pci_bus = 0,
|
|
+ .pci_device = 0,
|
|
+ .pci_function = 0,
|
|
+ .pci_flags = 0,
|
|
+ .pci_segment = 0,
|
|
+ };
|
|
|
|
- acpi_table_end(linker, &table);
|
|
+ build_spcr(table_data, linker, &serial, 2, vms->oem_id, vms->oem_table_id);
|
|
}
|
|
|
|
/*
|
|
@@ -1316,7 +1302,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)
|
|
}
|
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
|
- build_spcr(tables_blob, tables->linker, vms);
|
|
+ spcr_setup(tables_blob, tables->linker, vms);
|
|
|
|
acpi_add_table(table_offsets, tables_blob);
|
|
build_dbg2(tables_blob, tables->linker, vms);
|
|
diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
|
|
index b1f389fb4..7a8b708cd 100644
|
|
--- a/include/hw/acpi/acpi-defs.h
|
|
+++ b/include/hw/acpi/acpi-defs.h
|
|
@@ -90,6 +90,39 @@ typedef struct AcpiFadtData {
|
|
unsigned *xdsdt_tbl_offset;
|
|
} AcpiFadtData;
|
|
|
|
+typedef struct AcpiGas {
|
|
+ uint8_t id; /* Address space ID */
|
|
+ uint8_t width; /* Register bit width */
|
|
+ uint8_t offset; /* Register bit offset */
|
|
+ uint8_t size; /* Access size */
|
|
+ uint64_t addr; /* Address */
|
|
+} AcpiGas;
|
|
+
|
|
+/* SPCR (Serial Port Console Redirection table) */
|
|
+typedef struct AcpiSpcrData {
|
|
+ uint8_t interface_type;
|
|
+ uint8_t reserved[3];
|
|
+ struct AcpiGas base_addr;
|
|
+ uint8_t interrupt_type;
|
|
+ uint8_t pc_interrupt;
|
|
+ uint32_t interrupt; /* Global system interrupt */
|
|
+ uint8_t baud_rate;
|
|
+ uint8_t parity;
|
|
+ uint8_t stop_bits;
|
|
+ uint8_t flow_control;
|
|
+ uint8_t terminal_type;
|
|
+ uint8_t language;
|
|
+ uint8_t reserved1;
|
|
+ uint16_t pci_device_id; /* Must be 0xffff if not PCI device */
|
|
+ uint16_t pci_vendor_id; /* Must be 0xffff if not PCI device */
|
|
+ uint8_t pci_bus;
|
|
+ uint8_t pci_device;
|
|
+ uint8_t pci_function;
|
|
+ uint32_t pci_flags;
|
|
+ uint8_t pci_segment;
|
|
+ uint32_t reserved2;
|
|
+} AcpiSpcrData;
|
|
+
|
|
#define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
|
|
#define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)
|
|
|
|
diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
|
|
index 91f9cbf4f..381ad4a8a 100644
|
|
--- a/include/hw/acpi/aml-build.h
|
|
+++ b/include/hw/acpi/aml-build.h
|
|
@@ -506,4 +506,8 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
|
|
|
|
void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
|
|
const char *oem_id, const char *oem_table_id);
|
|
+
|
|
+void build_spcr(GArray *table_data, BIOSLinker *linker,
|
|
+ const AcpiSpcrData *f, const uint8_t rev,
|
|
+ const char *oem_id, const char *oem_table_id);
|
|
#endif
|
|
--
|
|
2.43.0
|
|
|