[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v2 11/17] libxl/arm: Construct ACPI DSDT table
On Thu, 23 Jun 2016, Shannon Zhao wrote: > From: Shannon Zhao <shannon.zhao@xxxxxxxxxx> > > 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 <shannon.zhao@xxxxxxxxxx> > --- > 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 <xc_dom.h> > > +#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 <http://www.gnu.org/licenses/>. > + */ > + > +DefinitionBlock ("DSDT.aml", "DSDT", 3, "XenARM", "Xen DSDT", 1) > +{ > + > +} Why do we need C code to generate the "static" asl? Can't we just manually writing the asl code here and get rid of libxl_mk_dsdt_arm.c? > 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 <stdio.h> > +#include <stdarg.h> > +#include <stdint.h> > +#include <string.h> > +#include <stdlib.h> > +#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: > + */ > -- > 2.0.4 > > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |