From nobody Sun Nov 24 06:47:13 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725694296050355.8148558202565; Sat, 7 Sep 2024 00:31:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smpuF-0002SO-79; Sat, 07 Sep 2024 03:30:51 -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 1smpuB-0002Rc-I5 for qemu-devel@nongnu.org; Sat, 07 Sep 2024 03:30:47 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1smpu9-0006ss-19 for qemu-devel@nongnu.org; Sat, 07 Sep 2024 03:30:47 -0400 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxneoeAdxmLAkBAA--.3507S3; Sat, 07 Sep 2024 15:30:38 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by front1 (Coremail) with SMTP id qMiowMBxHeQdAdxm++MAAA--.6247S2; Sat, 07 Sep 2024 15:30:38 +0800 (CST) From: Bibo Mao To: Song Gao Cc: Jiaxun Yang , qemu-devel@nongnu.org, "Jason A . Donenfeld" Subject: [PATCH] hw/loongarch: Add acpi SPCR table support Date: Sat, 7 Sep 2024 15:30:37 +0800 Message-Id: <20240907073037.243353-1-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxHeQdAdxm++MAAA--.6247S2 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: 1 X-Spam_score: 0.1 X-Spam_bar: / X-Spam_report: (0.1 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URI_TRY_3LD=1.999 autolearn=no 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: 1725694298464116600 Content-Type: text/plain; charset="utf-8" Serial port console redirection table can be used for default serial port selection, like chosen stdout-path selection with FDT method. With acpi SPCR table added, early debug console can be parsed from SPCR table with simple kernel parameter earlycon rather than earlycon=3Duart,mmio,0x1fe001e0 Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/acpi-build.c | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c index 2638f87434..3912c8d307 100644 --- a/hw/loongarch/acpi-build.c +++ b/hw/loongarch/acpi-build.c @@ -241,6 +241,44 @@ build_srat(GArray *table_data, BIOSLinker *linker, Mac= hineState *machine) acpi_table_end(linker, &table); } =20 +/* + * Serial Port Console Redirection Table (SPCR) + * https://learn.microsoft.com/en-us/windows-hardware/drivers/serports/ser= ial-port-console-redirection-table + */ +static void +spcr_setup(GArray *table_data, BIOSLinker *linker, MachineState *machine) +{ + LoongArchVirtMachineState *lvms; + AcpiSpcrData serial =3D { + .interface_type =3D 0, /* 16550 compatible */ + .base_addr.id =3D AML_AS_SYSTEM_MEMORY, + .base_addr.width =3D 32, + .base_addr.offset =3D 0, + .base_addr.size =3D 1, + .base_addr.addr =3D VIRT_UART_BASE, + .interrupt_type =3D 0, /* Interrupt not supported */ + .pc_interrupt =3D 0, + .interrupt =3D VIRT_UART_IRQ, + .baud_rate =3D 7, /* 115200 */ + .parity =3D 0, + .stop_bits =3D 1, + .flow_control =3D 0, + .terminal_type =3D 3, /* ANSI */ + .language =3D 0, /* Language */ + .pci_device_id =3D 0xffff, /* not a PCI device*/ + .pci_vendor_id =3D 0xffff, /* not a PCI device*/ + .pci_bus =3D 0, + .pci_device =3D 0, + .pci_function =3D 0, + .pci_flags =3D 0, + .pci_segment =3D 0, + }; + + lvms =3D LOONGARCH_VIRT_MACHINE(machine); + build_spcr(table_data, linker, &serial, 2, lvms->oem_id, + lvms->oem_table_id); +} + typedef struct AcpiBuildState { /* Copy of table in RAM (for patching). */ @@ -477,6 +515,8 @@ static void acpi_build(AcpiBuildTables *tables, Machine= State *machine) =20 acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, machine); + acpi_add_table(table_offsets, tables_blob); + spcr_setup(tables_blob, tables->linker, machine); =20 if (machine->numa_state->num_nodes) { if (machine->numa_state->have_numa_distance) { base-commit: 7b87a25f49a301d3377f3e71e0b4a62540c6f6e4 --=20 2.39.3