acpi: generate and parse mixed asl/aml listing

Use iasl -l flag to produce a mixed listing, where a
source line is followed by matching AML.

Add a tool tools/ to process this
listing. The tool looks for ACPI_EXTRACT tags
in the ASL source and outputs matching AML offsets
in an array.

To make these directives pass through ASL without affecting AML,
and to make it possible to match AML to source exactly,
add a preprocessing stage, which prepares input for iasl,
and puts each ACPI_EXTRACT tag within a comment,
on a line by itself.

Signed-off-by: Michael S. Tsirkin <>
diff --git a/Makefile b/Makefile
index f5e3087..7a06d67 100644
--- a/Makefile
+++ b/Makefile
@@ -192,11 +192,13 @@
 	$(Q)./tools/ $< $@
 ####### dsdt build rules
-src/%.hex: src/%.dsl
+src/%.hex: src/%.dsl ./tools/ ./tools/
 	@echo "Compiling DSDT"
-	$(Q)cpp -P $< > $(OUT)$*.dsl.i
-	$(Q)iasl -tc -p $(OUT)$* $(OUT)$*.dsl.i
-	$(Q)cp $(OUT)$*.hex $@
+	$(Q)cpp -P $< > $(OUT)$*.dsl.i.orig
+	$(Q)./tools/ $(OUT)$*.dsl.i.orig > $(OUT)$*.dsl.i
+	$(Q)iasl -l -tc -p $(OUT)$* $(OUT)$*.dsl.i
+	$(Q)./tools/ $(OUT)$*.lst > $(OUT)$*.off
+	$(Q)cat $(OUT)$*.hex $(OUT)$*.off > $@
 $(OUT)ccode32flat.o: src/acpi-dsdt.hex