From patchwork Tue Jun 9 12:01:04 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Jones X-Patchwork-Id: 482209 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B7D61140345 for ; Tue, 9 Jun 2015 22:02:54 +1000 (AEST) Received: from localhost ([::1]:34750 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2IF2-0007r6-QA for incoming@patchwork.ozlabs.org; Tue, 09 Jun 2015 08:02:52 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2IDR-0005dz-Se for qemu-devel@nongnu.org; Tue, 09 Jun 2015 08:01:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z2IDM-0006zr-UF for qemu-devel@nongnu.org; Tue, 09 Jun 2015 08:01:13 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57661) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z2IDM-0006z5-Pq for qemu-devel@nongnu.org; Tue, 09 Jun 2015 08:01:08 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 5B16E8E506; Tue, 9 Jun 2015 12:01:08 +0000 (UTC) Received: from hp-moonshot-02-c07.khw.lab.eng.bos.redhat.com (hp-moonshot-02-c07.khw.lab.eng.bos.redhat.com [10.16.184.135]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t59C15nW005552; Tue, 9 Jun 2015 08:01:07 -0400 From: Andrew Jones To: qemu-devel@nongnu.org Date: Tue, 9 Jun 2015 08:01:04 -0400 Message-Id: <1433851264-15443-3-git-send-email-drjones@redhat.com> In-Reply-To: <1433851264-15443-1-git-send-email-drjones@redhat.com> References: <1433851264-15443-1-git-send-email-drjones@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: peter.maydell@linaro.org, mst@redhat.com, shannon.zhao@linaro.org, imammedo@redhat.com Subject: [Qemu-devel] [PATCH v2 2/2] hw/arm/virt-acpi-build: Add SPCR table X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Andrew Jones Tested-by: Shannon Zhao --- hw/arm/virt-acpi-build.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index a9373ccaca6cb..9adc0eaa1ac24 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -84,6 +84,12 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH, AML_EXCLUSIVE, uart_irq)); aml_append(dev, aml_name_decl("_CRS", crs)); + + /* The _ADR entry is used to link this device to the UART described + * in the SPCR table. + */ + aml_append(dev, aml_name_decl("_ADR", aml_int(uart_memmap->base))); + aml_append(scope, dev); } @@ -334,6 +340,38 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) } static void +build_spcr(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) +{ + AcpiSerialPortConsoleRedirection *spcr; + const MemMapEntry *memmap = &guest_info->memmap[VIRT_UART]; + int irq = guest_info->irqmap[VIRT_UART] + ARM_SPI_BASE; + + spcr = acpi_data_push(table_data, sizeof(*spcr)); + + spcr->interface_type = ACPI_SERIAL_ARM_PL011_UART; + + spcr->base_address.space_id = AML_SYSTEM_MEMORY; + spcr->base_address.bit_width = 8; + spcr->base_address.bit_offset = 0; + spcr->base_address.access_width = 1; + spcr->base_address.address = cpu_to_le64(memmap->base); + + spcr->interrupt_types = ACPI_SERIAL_ITYPE_ARMH_GIC; + spcr->gsi = cpu_to_le32(irq); + + spcr->baud = ACPI_SERIAL_BAUD_9600; + spcr->parity = 0; + spcr->stopbits = 1; + spcr->flowctrl = ACPI_SERIAL_FLOW_HW; + spcr->term_type = ACPI_SERIAL_TERM_VT100; + + spcr->pci_device_id = 0xffff; + spcr->pci_vendor_id = 0xffff; + + build_header(linker, table_data, (void *)spcr, "SPCR", sizeof(*spcr), 2); +} + +static void build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) { AcpiTableMcfg *mcfg; @@ -514,7 +552,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) dsdt = tables_blob->len; build_dsdt(tables_blob, tables->linker, guest_info); - /* FADT MADT GTDT pointed to by RSDT */ + /* FADT MADT GTDT SPCR pointed to by RSDT */ acpi_add_table(table_offsets, tables_blob); build_fadt(tables_blob, tables->linker, dsdt); @@ -527,6 +565,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) acpi_add_table(table_offsets, tables_blob); build_mcfg(tables_blob, tables->linker, guest_info); + acpi_add_table(table_offsets, tables_blob); + build_spcr(tables_blob, tables->linker, guest_info); + /* RSDT is pointed to by RSDP */ rsdt = tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets);