From patchwork Sat Jan 24 09:21:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 432394 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 927471402A0 for ; Sat, 24 Jan 2015 20:26:41 +1100 (AEDT) Received: from localhost ([::1]:34448 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEwzH-0003m8-OS for incoming@patchwork.ozlabs.org; Sat, 24 Jan 2015 04:26:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEwwp-0007XR-Rz for qemu-devel@nongnu.org; Sat, 24 Jan 2015 04:24:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEwwn-0004bm-Eq for qemu-devel@nongnu.org; Sat, 24 Jan 2015 04:24:07 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:40106) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEwwm-0004aI-O5 for qemu-devel@nongnu.org; Sat, 24 Jan 2015 04:24:05 -0500 Received: from 172.24.2.119 (EHLO szxeml427-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BAW28198; Sat, 24 Jan 2015 17:23:39 +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; Sat, 24 Jan 2015 17:23:31 +0800 From: Shannon Zhao To: , , , , , , , , , Date: Sat, 24 Jan 2015 17:21:13 +0800 Message-ID: <1422091280-14532-5-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1422091280-14532-1-git-send-email-zhaoshenglong@huawei.com> References: <1422091280-14532-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.54C3649B.00D9, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 38367e580d767e01e9275f71ef4f5cc2 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: wanghaibin.wang@huawei.com, hangaohuai@huawei.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [RFC PATCH 04/11] hw/arm/virt-acpi-build: Generate XSDT table and add a build_header function 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. Implement a common header helper functions for generating ACPI tables. Signed-off-by: Shannon Zhao --- hw/arm/virt-acpi-build.c | 34 ++++++++++++++++++++++++++++++++++ include/hw/acpi/acpi-defs.h | 9 +++++++++ 2 files changed, 43 insertions(+), 0 deletions(-) diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 9c3971a..446947a 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -61,6 +61,22 @@ #define ACPI_BUILD_RSDP_FILE "etc/acpi/rsdp" #define ACPI_BUILD_TPMLOG_FILE "etc/tpm/log" +static void +build_header(GArray *linker, GArray *table_data, + AcpiTableHeader *h, const char *sig, int len, uint8_t rev) +{ + memcpy(&h->signature, sig, sizeof(h->signature)); + h->length = cpu_to_le32(len); + h->revision = rev; + memcpy(h->oem_id, ACPI_VIRT_QEMU_STR_6, sizeof(h->oem_id)); + memcpy(h->oem_table_id, ACPI_VIRT_MACH_STR_8, sizeof(h->oem_table_id)); + h->oem_revision = cpu_to_le32(1); + h->checksum = 0; + /* Checksum to be filled in by Guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, + table_data->data, h, len, &h->checksum); +} + static inline void *acpi_data_push(GArray *table_data, uint64_t size) { unsigned off = table_data->len; @@ -115,6 +131,24 @@ build_rsdp(GArray *rsdp_table, GArray *linker, uint64_t 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) { + /* rsdt->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", xsdt_len, 1); } /* MADT */ diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index c4468f8..779f872 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 1.0 Fixed ACPI Description Table (FADT) */ struct AcpiFadtDescriptorRev1