From patchwork Thu Jan 29 08:37:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 434385 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 6DA11140146 for ; Thu, 29 Jan 2015 19:39:12 +1100 (AEDT) Received: from localhost ([::1]:58223 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGkd4-0006MP-L9 for incoming@patchwork.ozlabs.org; Thu, 29 Jan 2015 03:39:10 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGkcV-0005OH-Aq for qemu-devel@nongnu.org; Thu, 29 Jan 2015 03:38:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGkcN-00043B-23 for qemu-devel@nongnu.org; Thu, 29 Jan 2015 03:38:32 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:33013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGkcM-00042p-EI for qemu-devel@nongnu.org; Thu, 29 Jan 2015 03:38:26 -0500 Received: from 172.24.2.119 (EHLO szxeml426-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CGM46913; Thu, 29 Jan 2015 16:38:11 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.158.1; Thu, 29 Jan 2015 16:37:50 +0800 From: Shannon Zhao To: , , , , , , , , , Date: Thu, 29 Jan 2015 16:37:11 +0800 Message-ID: <1422520633-13456-10-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1422520633-13456-1-git-send-email-zhaoshenglong@huawei.com> References: <1422520633-13456-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: 119.145.14.65 Cc: wanghaibin.wang@huawei.com, hangaohuai@huawei.com, peter.huangpeng@huawei.com Subject: [Qemu-devel] [RFC PATCH v2 09/11] hw/arm/virt-acpi-build: Generate XSDT 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 XDST points to other tables except FACS & DSDT. Signed-off-by: Shannon Zhao --- hw/arm/virt-acpi-build.c | 32 +++++++++++++++++++++++++++++++- include/hw/acpi/acpi-defs.h | 9 +++++++++ 2 files changed, 40 insertions(+), 1 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index ac0a864..2a2b2ab 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -176,6 +176,32 @@ static void acpi_dsdt_add_virtio(AcpiAml *scope, const hwaddr *mmio_addrs, } } + +/* XSDT */ +static void +build_xsdt(GArray *table_data, GArray *linker, GArray *table_offsets) +{ + AcpiXsdtDescriptor *xsdt; + size_t xsdt_len; + int i; + + xsdt_len = sizeof(*xsdt) + sizeof(uint64_t) * table_offsets->len; + xsdt = acpi_data_push(table_data, xsdt_len); + memcpy(xsdt->table_offset_entry, table_offsets->data, + sizeof(uint64_t) * table_offsets->len); + for (i = 0; i < table_offsets->len; ++i) { + /* xsdt->table_offset_entry to be filled by Guest linker */ + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, + ACPI_BUILD_TABLE_FILE, + table_data, &xsdt->table_offset_entry[i], + sizeof(uint64_t)); + } + build_header(linker, table_data, (void *)xsdt, "XSDT", + ACPI_BUILD_APPNAME6, ACPI_BUILD_APPNAME4, + xsdt_len, 1); +} + /* GTDT */ static void build_gtdt(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info) @@ -311,7 +337,7 @@ static void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) { GArray *table_offsets; - unsigned dsdt; + unsigned dsdt, xsdt; VirtAcpiCpuInfo cpuinfo; virt_acpi_get_cpu_info(&cpuinfo); @@ -346,6 +372,10 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables) acpi_add_table(table_offsets, tables->table_data.buf); build_gtdt(tables->table_data.buf, tables->linker, guest_info); + /* XSDT is pointed to by RSDP */ + xsdt = tables->table_data.buf->len; + build_xsdt(tables->table_data.buf, tables->linker, table_offsets); + /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); } diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index ee40a5e..47c8c41 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -88,6 +88,15 @@ struct AcpiTableHeader /* ACPI common table header */ typedef struct AcpiTableHeader AcpiTableHeader; /* + * Extended System Description Table (XSDT) + */ +struct AcpiXsdtDescriptor { + ACPI_TABLE_HEADER_DEF + uint64_t table_offset_entry[1]; /* Array of pointers to ACPI tables */ +} QEMU_PACKED; +typedef struct AcpiXsdtDescriptor AcpiXsdtDescriptor; + +/* * ACPI Fixed ACPI Description Table (FADT) */ #define ACPI_FADT_COMMON_DEF /* FADT common definition */ \