From patchwork Wed Apr 15 13:25:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 461526 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 EFB26140079 for ; Wed, 15 Apr 2015 23:28:21 +1000 (AEST) Received: from localhost ([::1]:60482 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiNMZ-0008Fs-H7 for incoming@patchwork.ozlabs.org; Wed, 15 Apr 2015 09:28:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiNLO-0006H9-7l for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:27:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiNLK-0004uc-T5 for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:27:06 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:41901) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiNLJ-0004rp-Nm for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:27:02 -0400 Received: from 172.24.2.119 (EHLO szxeml427-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CME19613; Wed, 15 Apr 2015 21:26:43 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.158.1; Wed, 15 Apr 2015 21:26:31 +0800 From: Shannon Zhao To: , , , , , , , , , , Date: Wed, 15 Apr 2015 21:25:01 +0800 Message-ID: <1429104309-3844-13-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1429104309-3844-1-git-send-email-zhaoshenglong@huawei.com> References: <1429104309-3844-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: hangaohuai@huawei.com, shannon.zhao@linaro.org, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [PATCH v5 12/20] hw/arm/virt-acpi-build: Add PCIe info and generate MCFG 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 From: Shannon Zhao Add PCIe info struct, prepare for building PCIe table. And generate MCFG table. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/arm/virt-acpi-build.c | 21 +++++++++++++++++++++ include/hw/arm/virt-acpi-build.h | 9 +++++++++ 2 files changed, 30 insertions(+) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index aa4acc6..85e8242 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -189,6 +189,24 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) return rsdp_table; } +static void +build_mcfg(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) +{ + AcpiTableMcfg *mcfg; + AcpiPcieInfo *info = guest_info->pcie_info; + int len = sizeof(*mcfg) + sizeof(mcfg->allocation[0]); + + mcfg = acpi_data_push(table_data, len); + mcfg->allocation[0].address = cpu_to_le64(info->pcie_ecam.addr); + + /* Only a single allocation so no need to play with segments */ + mcfg->allocation[0].pci_segment = cpu_to_le16(0); + mcfg->allocation[0].start_bus_number = 0; + mcfg->allocation[0].end_bus_number = info->nr_pcie_buses - 1; + + build_header(linker, table_data, (void *)mcfg, "MCFG", len, 1); +} + /* GTDT */ static void build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) @@ -361,6 +379,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) acpi_add_table(table_offsets, tables_blob); build_gtdt(tables_blob, tables->linker, guest_info); + acpi_add_table(table_offsets, tables_blob); + build_mcfg(tables_blob, tables->linker, guest_info); + /* RSDT is pointed to by RSDP */ rsdt = tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets); diff --git a/include/hw/arm/virt-acpi-build.h b/include/hw/arm/virt-acpi-build.h index 8f0b4a7..572864a 100644 --- a/include/hw/arm/virt-acpi-build.h +++ b/include/hw/arm/virt-acpi-build.h @@ -52,6 +52,14 @@ typedef struct AcpiDsdtInfo { const MemMap *flash_memmap; } AcpiDsdtInfo; +typedef struct AcpiPcieInfo { + const int *pcie_irq; + MemMap pcie_mmio; + MemMap pcie_ioport; + MemMap pcie_ecam; + int nr_pcie_buses; +} AcpiPcieInfo; + typedef struct VirtGuestInfo { int smp_cpus; int max_cpus; @@ -59,6 +67,7 @@ typedef struct VirtGuestInfo { AcpiMadtInfo *madt_info; AcpiDsdtInfo *dsdt_info; AcpiGtdtInfo *gtdt_info; + AcpiPcieInfo *pcie_info; } VirtGuestInfo;