From patchwork Thu Jun 23 03:16:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 70723 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp217426qgy; Wed, 22 Jun 2016 20:21:10 -0700 (PDT) X-Received: by 10.107.161.71 with SMTP id k68mr36094615ioe.103.1466652070501; Wed, 22 Jun 2016 20:21:10 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id z70si3001092ita.65.2016.06.22.20.21.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 20:21:10 -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 1bFvAr-00013P-MX; Thu, 23 Jun 2016 03:19:25 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFvAq-00012J-Fg for xen-devel@lists.xen.org; Thu, 23 Jun 2016 03:19:24 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id 1B/30-26908-B355B675; Thu, 23 Jun 2016 03:19:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMIsWRWlGSWpSXmKPExsVi9XuGg651aHa 4wZsn/BZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8alxbNYC46bVqza+4ulgbFJq4uRi0NI4BSj xLz1LSxdjJxAzh5GiSdN0iA2m4CuxMeNU9hBbBEBWYnVXXPYQRqYBa4zStx5v40VJCEsYCdxZ OEfMJtFQFXiVsc0JhCbV8BDYtvrHrC4hICGxMreCWALOIHiJ2c9YYZY5i4xZ81eFoh6QYmTM5 +A2cwCEhIHX7xghuhVlGhbf5INwpaUOLjiBgvIERIgV9/YvB0qYSpxc8FR5gmMgrOQzJqFZNY CRqZVjOrFqUVlqUW6FnpJRZnpGSW5iZk5uoYGpnq5qcXFiempOYlJxXrJ+bmbGIEBygAEOxgP NjsfYpTkYFIS5bVyyA4X4kvKT6nMSCzOiC8qzUktPsQow8GhJMEbEwSUEyxKTU+tSMvMAcYKT FqCg0dJhNciECjNW1yQmFucmQ6ROsWoy3Fs7o21TEIsefl5qVLivL4gMwRAijJK8+BGwOL2Eq OslDAvI9BRQjwFqUW5mSWo8q8YxTkYlYR5GUCm8GTmlcBtegV0BBPQEcv600GOKElESEk1MO4 Nv2JRdTb3CDv/RJFDTZacyxsSrrTM+r2x1uCg3909ZU5JHJtCY35xTl/xftqBI7tVC8REo9fI Cecc6cjJWpOl39jX7LUufc/+m9niNUx93h3rzzq6fP5ryOyo7um+TaYqa8+jmIY4p/gPks4Rr 1yMTyTqhKnoPvSaETKrLeuz3YYv0xIslViKMxINtZiLihMBKxvs4dYCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-9.tower-206.messagelabs.com!1466651958!46359515!1 X-Originating-IP: [58.251.152.64] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9619 invoked from network); 23 Jun 2016 03:19:22 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-9.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jun 2016 03:19:22 -0000 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DMQ09546; Thu, 23 Jun 2016 11:17:45 +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:33 +0800 From: Shannon Zhao To: Date: Thu, 23 Jun 2016 11:16:58 +0800 Message-ID: <1466651824-6964-12-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.0A020203.576B54D9.018C, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 9244a0576539c44a4beabd6b64ea1ea2 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 11/17] libxl/arm: Construct ACPI DSDT 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 It uses static DSDT table like the way x86 uses. Currently the DSDT table only contains processor device objects and it generates the maximal objects which so far is 128. Signed-off-by: Shannon Zhao --- tools/libxl/Makefile | 24 ++++++++- tools/libxl/libxl_arm_acpi.c | 15 ++++++ tools/libxl/libxl_arm_acpi.h | 2 + tools/libxl/libxl_empty_dsdt_arm.asl | 22 +++++++++ tools/libxl/libxl_mk_dsdt_arm.c | 94 ++++++++++++++++++++++++++++++++++++ 5 files changed, 156 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_empty_dsdt_arm.asl create mode 100644 tools/libxl/libxl_mk_dsdt_arm.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index 264b6ef..5347480 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -77,7 +77,29 @@ endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o -LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o +LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o libxl_dsdt_anycpu_arm.o + +vpath iasl $(PATH) +libxl_mk_dsdt_arm: libxl_mk_dsdt_arm.c + $(CC) $(CFLAGS) -o $@ libxl_mk_dsdt_arm.c + +libxl_dsdt_anycpu_arm.asl: libxl_empty_dsdt_arm.asl libxl_mk_dsdt_arm + awk 'NR > 1 {print s} {s=$$0}' $< > $@ + ./libxl_mk_dsdt_arm >> $@ + +libxl_dsdt_anycpu_arm.c: %.c: iasl %.asl + iasl -vs -p $* -tc $*.asl + sed -e 's/AmlCode/$*/g' $*.hex >$@ + echo "int $*_len=sizeof($*);" >>$@ + rm -f $*.aml $*.hex + +iasl: + @echo + @echo "ACPI ASL compiler (iasl) is needed" + @echo "Download and install Intel ACPI CA from" + @echo "http://acpica.org/downloads/" + @echo + @exit 1 libxl_arm_acpi.o: libxl_arm_acpi.c $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index 353d774..45fc354 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -54,6 +54,9 @@ enum { NUMS, }; +extern unsigned char libxl_dsdt_anycpu_arm[]; +extern int libxl_dsdt_anycpu_arm_len; + struct acpitable { void *table; size_t size; @@ -256,6 +259,17 @@ static void make_acpi_fadt(libxl__gc *gc, struct xc_dom_image *dom) dom->acpitable_size += ROUNDUP(acpitables[FADT].size, 3); } +static void make_acpi_dsdt(libxl__gc *gc, struct xc_dom_image *dom) +{ + acpitables[DSDT].table = libxl__zalloc(gc, libxl_dsdt_anycpu_arm_len); + memcpy(acpitables[DSDT].table, libxl_dsdt_anycpu_arm, + libxl_dsdt_anycpu_arm_len); + + acpitables[DSDT].size = libxl_dsdt_anycpu_arm_len; + /* Align to 64bit. */ + dom->acpitable_size += ROUNDUP(acpitables[DSDT].size, 3); +} + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) @@ -284,6 +298,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, return rc; make_acpi_fadt(gc, dom); + make_acpi_dsdt(gc, dom); return 0; } diff --git a/tools/libxl/libxl_arm_acpi.h b/tools/libxl/libxl_arm_acpi.h index 9b58de6..b0fd9ce 100644 --- a/tools/libxl/libxl_arm_acpi.h +++ b/tools/libxl/libxl_arm_acpi.h @@ -19,6 +19,8 @@ #include +#define DOMU_MAX_VCPUS 128 + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom); diff --git a/tools/libxl/libxl_empty_dsdt_arm.asl b/tools/libxl/libxl_empty_dsdt_arm.asl new file mode 100644 index 0000000..005fa6a --- /dev/null +++ b/tools/libxl/libxl_empty_dsdt_arm.asl @@ -0,0 +1,22 @@ +/****************************************************************************** + * DSDT for Xen ARM DomU + * + * Copyright (c) 2004, Intel Corporation. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; If not, see . + */ + +DefinitionBlock ("DSDT.aml", "DSDT", 3, "XenARM", "Xen DSDT", 1) +{ + +} diff --git a/tools/libxl/libxl_mk_dsdt_arm.c b/tools/libxl/libxl_mk_dsdt_arm.c new file mode 100644 index 0000000..96fadbd --- /dev/null +++ b/tools/libxl/libxl_mk_dsdt_arm.c @@ -0,0 +1,94 @@ +#include +#include +#include +#include +#include +#include "libxl_arm_acpi.h" + +static unsigned int indent_level; + +static void indent(void) +{ + unsigned int i; + for ( i = 0; i < indent_level; i++ ) + printf(" "); +} + +static __attribute__((format(printf, 2, 3))) +void _stmt(const char *name, const char *fmt, ...) +{ + va_list args; + + indent(); + printf("%s", name); + + if ( !fmt ) + return; + + printf(" ( "); + va_start(args, fmt); + vprintf(fmt, args); + va_end(args); + printf(" )"); +} + +#define stmt(n, f, a...) \ + do { \ + _stmt(n, f , ## a ); \ + printf("\n"); \ + } while (0) + +#define push_block(n, f, a...) \ + do { \ + _stmt(n, f , ## a ); \ + printf(" {\n"); \ + indent_level++; \ + } while (0) + +static void pop_block(void) +{ + indent_level--; + indent(); + printf("}\n"); +} + +int main(int argc, char **argv) +{ + unsigned int cpu, max_cpus = DOMU_MAX_VCPUS; + + /**** DSDT DefinitionBlock start ****/ + /* (we append to existing DSDT definition block) */ + indent_level++; + + /**** Processor start ****/ + push_block("Scope", "\\_SB"); + + /* Define processor objects and control methods. */ + for ( cpu = 0; cpu < max_cpus; cpu++) + { + push_block("Processor", "PR%02X, %d, 0x0000b010, 0x06", cpu, cpu); + + stmt("Name", "_HID, \"ACPI0007\""); + stmt("Name", "_UID, %d", cpu); + + pop_block(); + } + + pop_block(); + /**** Processor end ****/ + + pop_block(); + /**** DSDT DefinitionBlock end ****/ + + return 0; +} + +/* + * Local variables: + * mode: C + * c-file-style: "BSD" + * c-basic-offset: 4 + * tab-width: 4 + * indent-tabs-mode: nil + * End: + */