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
|