WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 1/5] hvmloader/acpi: Introduce --maxcpu option to mk_

To: Xen Devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 1/5] hvmloader/acpi: Introduce --maxcpu option to mk_dsdt
From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
Date: Thu, 27 Oct 2011 16:12:33 +0100
Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Delivery-date: Thu, 27 Oct 2011 08:26:47 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1319728357-18112-1-git-send-email-anthony.perard@xxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <1319728357-18112-1-git-send-email-anthony.perard@xxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
With this new option, there is no need to compile mk_dsdt for each DSDT table
that we want.  The Makefile is a bit reorganize to handle this new option and
to prepare more change in a coming patch.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 .hgignore                               |    2 +
 tools/firmware/hvmloader/acpi/Makefile  |   16 +++++++++-----
 tools/firmware/hvmloader/acpi/mk_dsdt.c |   34 +++++++++++++++++++++++++++++-
 3 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/.hgignore b/.hgignore
index 9d4f864..9c286f4 100644
--- a/.hgignore
+++ b/.hgignore
@@ -140,7 +140,9 @@
 ^tools/firmware/etherboot/ipxe\.git/.*$
 ^tools/firmware/extboot/extboot.img$
 ^tools/firmware/extboot/signrom$
+^tools/firmware/hvmloader/acpi/mk_dsdt$
 ^tools/firmware/hvmloader/acpi/dsdt.*\.c$
+^tools/firmware/hvmloader/acpi/dsdt_.*\.asl$
 ^tools/firmware/hvmloader/acpi/ssdt_.*\.h$
 ^tools/firmware/hvmloader/hvmloader$
 ^tools/firmware/hvmloader/roms\.inc$
diff --git a/tools/firmware/hvmloader/acpi/Makefile 
b/tools/firmware/hvmloader/acpi/Makefile
index d32e055..7746a1c 100644
--- a/tools/firmware/hvmloader/acpi/Makefile
+++ b/tools/firmware/hvmloader/acpi/Makefile
@@ -31,15 +31,19 @@ ssdt_pm.h ssdt_tpm.h: %.h: %.asl iasl
        sed -e 's/AmlCode/$*/g' $*.hex >$@
        rm -f $*.hex $*.aml
 
+mk_dsdt: mk_dsdt.c
+       $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
+
 # NB. awk invocation is a portable alternative to 'head -n -1'
-dsdt_15cpu.c dsdt_anycpu.c: %.c: dsdt.asl mk_dsdt.c iasl
-       $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o mk_$* mk_dsdt.c
-       awk 'NR > 1 {print s} {s=$$0}' $< >$*.asl
-       ./mk_$* >>$*.asl
+dsdt_%cpu.asl: dsdt.asl mk_dsdt
+       awk 'NR > 1 {print s} {s=$$0}' $< > $@
+       ./mk_dsdt --maxcpu $*  >> $@
+
+$(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
        iasl -vs -p $* -tc $*.asl
        sed -e 's/AmlCode/$*/g' $*.hex >$@
        echo "int $*_len=sizeof($*);" >>$@
-       rm -f $*.hex $*.aml $*.asl mk_$*
+       rm -f $*.aml $*.hex
 
 iasl:
        @echo
@@ -56,7 +60,7 @@ acpi.a: $(OBJS)
 
 clean:
        rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
-       rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt mk_dsdt15 dsdt_*cpu.asl
+       rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl
 
 install: all
 
diff --git a/tools/firmware/hvmloader/acpi/mk_dsdt.c 
b/tools/firmware/hvmloader/acpi/mk_dsdt.c
index f97da50..ab8a4fb 100644
--- a/tools/firmware/hvmloader/acpi/mk_dsdt.c
+++ b/tools/firmware/hvmloader/acpi/mk_dsdt.c
@@ -1,6 +1,9 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include <stdint.h>
+#include <string.h>
+#include <getopt.h>
+#include <stdlib.h>
 #include <xen/hvm/hvm_info_table.h>
 
 static unsigned int indent_level;
@@ -71,12 +74,39 @@ static void decision_tree(
     pop_block();
 }
 
+static struct option options[] = {
+    { "maxcpu", 1, 0, 'c' },
+    { 0, 0, 0, 0 }
+};
+
 int main(int argc, char **argv)
 {
     unsigned int slot, dev, intx, link, cpu, max_cpus = HVM_MAX_VCPUS;
 
-    /* Extract optional maximum-cpu specification from invocation name. */
-    sscanf(argv[0], "%*[^0-9]%u", &max_cpus); /* e.g., ./mk_dsdt15 */
+    while (1) {
+        int opt = getopt_long(argc, argv, "", options, NULL);
+        if (opt == -1)
+            break;
+
+        switch (opt) {
+        case 'c': {
+            long i = 0;
+            char *endptr;
+
+            i = strtol(optarg, &endptr, 10);
+            if (*optarg != '\0' && *endptr == '\0' && i >= 0) {
+                max_cpus = i;
+            } else if (!(strcmp(optarg, "any") == 0)){
+                fprintf(stderr, "`%s' is not a number or is bellow 0.\n", 
optarg);
+                return -1;
+            }
+            break;
+        }
+        default:
+            fprintf(stderr, "options not supported.\n");
+            return -1;
+        }
+    }
 
     /**** DSDT DefinitionBlock start ****/
     /* (we append to existing DSDT definition block) */
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel