From patchwork Thu Jun 23 03:16:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 70715 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp217310qgy; Wed, 22 Jun 2016 20:20:39 -0700 (PDT) X-Received: by 10.107.17.31 with SMTP id z31mr45130249ioi.150.1466652028624; Wed, 22 Jun 2016 20:20:28 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v70si5330006ioi.97.2016.06.22.20.20.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 20:20:28 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFv9v-0000Rg-9L; Thu, 23 Jun 2016 03:18:27 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFv9u-0000Qe-DD for xen-devel@lists.xen.org; Thu, 23 Jun 2016 03:18:26 +0000 Received: from [193.109.254.147] by server-13.bemta-14.messagelabs.com id 86/56-09524-1055B675; Thu, 23 Jun 2016 03:18:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSZcxNDv cYPYHdoslHxezODB6HN39mymAMYo1My8pvyKBNePM2b0sBR8FK6Z37WFqYFzC18XIySEkcIpR 4sOTVAh7D6PEm60cIDabgK7Ex41T2EFsEQFZidVdc4BsLg5mgeuMEnfeb2MFSQgL2EnM+7sJr IhFQFXi4btuFhCbV8Bd4njPCrC4hICGxMreCWBxTgEPiZOznjBDLHOXmLNmL1S9oMTJmU/AbG YBCYmDL14wQ/QqSrStP8kGYUtKHFxxgwXkCAmQoy/f74cqMpVoXtTEOIFRcBaSWbOQzFrAyLS KUaM4tagstUjX0FgvqSgzPaMkNzEzR9fQ0EQvN7W4ODE9NScxqVgvOT93EyMwQOsZGBh3MO7a 7nmIUZKDSUmU18ohO1yILyk/pTIjsTgjvqg0J7X4EKMMB4eSBO+3AKCcYFFqempFWmYOMFZg0 hIcPEoivE0gad7igsTc4sx0iNQpRkUpcd4SkIQASCKjNA+uDRaflxhlpYR5GRkYGIR4ClKLcj NLUOVfMYpzMCoJ814FmcKTmVcCN/0V0GImoMXL+tNBFpckIqSkGhhrNTOFT1/XeNEgYsWh5uf jJzPHsPrfZ5HG5snn5Pnb5CtTovmFdky49v/mOW19Fv7jNQICrUqXWU2v2CQdbt/X2zZ5siDH s8JTF5c4q6utmSxldPVr5ePz3Bena6+ZrFhw+qrGq2WFthdW6jW8+rW4XC1Y9OHq9puOalNNl G9uEDTbmMO7hUGJpTgj0VCLuag4EQB3erQdygIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-10.tower-27.messagelabs.com!1466651901!49405577!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 13620 invoked from network); 23 Jun 2016 03:18:24 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-10.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jun 2016 03:18:24 -0000 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CDT13168; Thu, 23 Jun 2016 11:17:39 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Thu, 23 Jun 2016 11:17:29 +0800 From: Shannon Zhao To: Date: Thu, 23 Jun 2016 11:16:53 +0800 Message-ID: <1466651824-6964-7-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1466651824-6964-1-git-send-email-zhaoshenglong@huawei.com> References: <1466651824-6964-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.0A090202.576B54D4.0039, ss=1, re=0.000, 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: a753240dc1ce807317b093201ef4b249 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v2 06/17] libxl/arm: Construct ACPI XSDT table X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" From: Shannon Zhao Signed-off-by: Shannon Zhao --- tools/libxl/libxl_arm_acpi.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index 5f332fa..d5ffedf 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -36,6 +36,9 @@ typedef uint64_t u64; #include #include +#define ACPI_BUILD_APPNAME6 "XenARM" +#define ACPI_BUILD_APPNAME4 "Xen " + enum { RSDP, XSDT, @@ -71,6 +74,42 @@ static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom) dom->acpitable_size += ROUNDUP(acpitables[RSDP].size, 3); } +static void make_acpi_header(struct acpi_table_header *h, const char *sig, + int len, uint8_t rev) +{ + memcpy(h->signature, sig, 4); + h->length = len; + h->revision = rev; + memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6); + memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); + memcpy(h->oem_table_id + 4, sig, 4); + h->oem_revision = 1; + memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4); + h->asl_compiler_revision = 1; + h->checksum = 0; +} + +static void make_acpi_xsdt(libxl__gc *gc, struct xc_dom_image *dom) +{ + uint32_t size; + struct acpi_table_xsdt *xsdt; + + /* + * Currently only 3 tables(GTDT, FADT, MADT) are pointed by XSDT. Alloc + * entries for them but the entry values will be specified when the tables + * are linked together later. + */ + size = sizeof(*xsdt) + sizeof(uint64_t) * 2; + xsdt = libxl__zalloc(gc, size); + + make_acpi_header(&xsdt->header, "XSDT", size, 1); + + acpitables[XSDT].table = xsdt; + acpitables[XSDT].size = size; + /* Align to 64bit. */ + dom->acpitable_size += ROUNDUP(acpitables[XSDT].size, 3); +} + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) @@ -92,6 +131,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, dom->acpitable_size = 0; make_acpi_rsdp(gc, dom); + make_acpi_xsdt(gc, dom); return 0; }