diff mbox

[v2,repost,3/9] acpi: add rules to compile ASL source

Message ID 1373464153-18979-4-git-send-email-mst@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin July 10, 2013, 1:51 p.m. UTC
Detect presence of IASL compiler and use it
to process ASL source. If not there, use pre-compiled
files in-tree. Add script to update the in-tree files.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 configure              |  9 ++++++++-
 hw/i386/Makefile.objs  | 22 ++++++++++++++++++++++
 scripts/update-acpi.sh |  4 ++++
 3 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 scripts/update-acpi.sh

Comments

Laszlo Ersek July 11, 2013, 4:55 p.m. UTC | #1
On 07/10/13 15:51, Michael S. Tsirkin wrote:
> Detect presence of IASL compiler and use it
> to process ASL source. If not there, use pre-compiled
> files in-tree. Add script to update the in-tree files.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  configure              |  9 ++++++++-
>  hw/i386/Makefile.objs  | 22 ++++++++++++++++++++++
>  scripts/update-acpi.sh |  4 ++++
>  3 files changed, 34 insertions(+), 1 deletion(-)
>  create mode 100644 scripts/update-acpi.sh
> 
> diff --git a/configure b/configure
> index 0e0adde..4fb54e2 100755
> --- a/configure
> +++ b/configure
> @@ -119,6 +119,7 @@ path_of() {
>  # default parameters
>  source_path=`dirname "$0"`
>  cpu=""
> +iasl="iasl"
>  interp_prefix="/usr/gnemul/qemu-%M"
>  static="no"
>  cross_prefix=""
> @@ -251,6 +252,8 @@ for opt do
>    ;;
>    --cc=*) CC="$optarg"
>    ;;
> +  --iasl=*) iasl="$optarg"
> +  ;;
>    --source-path=*) source_path="$optarg"
>    ;;
>    --cpu=*) cpu="$optarg"
> @@ -1020,6 +1023,7 @@ echo "Advanced options (experts only):"
>  echo "  --source-path=PATH       path of source code [$source_path]"
>  echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
>  echo "  --cc=CC                  use C compiler CC [$cc]"
> +echo "  --iasl=IASL              use ACPI compiler IASL [$iasl]"
>  echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
>  echo "                           build time"
>  echo "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
> @@ -4037,6 +4041,9 @@ else
>  fi
>  echo "PYTHON=$python" >> $config_host_mak
>  echo "CC=$cc" >> $config_host_mak
> +if $iasl -h > /dev/null 2>&1; then
> +  echo "IASL=$iasl" >> $config_host_mak
> +fi
>  echo "CC_I386=$cc_i386" >> $config_host_mak
>  echo "HOST_CC=$host_cc" >> $config_host_mak
>  echo "OBJCC=$objcc" >> $config_host_mak
> @@ -4509,7 +4516,7 @@ for rom in seabios vgabios ; do
>      echo "BCC=bcc" >> $config_mak
>      echo "CPP=$cpp" >> $config_mak
>      echo "OBJCOPY=objcopy" >> $config_mak
> -    echo "IASL=iasl" >> $config_mak
> +    echo "IASL=$iasl" >> $config_mak
>      echo "LD=$ld" >> $config_mak
>  done
>  
> diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
> index 205d22e..013d250 100644
> --- a/hw/i386/Makefile.objs
> +++ b/hw/i386/Makefile.objs
> @@ -4,3 +4,25 @@ obj-y += pc.o pc_piix.o pc_q35.o
>  obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
>  
>  obj-y += kvmvapic.o
> +
> +iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
> +    ; then echo "$(2)"; else echo "$(3)"; fi ;)
> +
> +ifdef IASL
> +#IASL Present. Generate hex files from .dsl
> +hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
> +	$(call quiet-command, cpp -P $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
> +	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
> +	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
> +	$(call quiet-command, $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
> +	$(call quiet-command, cat $*.off > $@, "  CAT $(TARGET_DIR)$@")
> +else
> +#IASL Not present. Restore pre-generated hex files.
> +hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.hex.generated
> +	$(call quiet-command, cp -f $< $@, "  CP $(TARGET_DIR)$@")
> +endif
> +
> +.PHONY: cleanhex
> +cleanhex:
> +	rm -f hw/i386/*hex
> +clean: cleanhex
> diff --git a/scripts/update-acpi.sh b/scripts/update-acpi.sh
> new file mode 100644
> index 0000000..b5f05ff
> --- /dev/null
> +++ b/scripts/update-acpi.sh
> @@ -0,0 +1,4 @@
> +cd x86_64-softmmu
> +for file in hw/i386/*.hex; do
> +    cp -f $file ../$file.generated
> +done
> 

I think:
- this patch (3/9) should be swapped with the next one (4/9), so that
the pre-generated files are available earlier than the build code
potentially relying on them,
- the "iasl-option" trick should be moved to ./configure perhaps.

Patches 1 & 2 look OK to me.

Laszlo
Laszlo Ersek July 11, 2013, 4:58 p.m. UTC | #2
On 07/11/13 18:55, Laszlo Ersek wrote:
> On 07/10/13 15:51, Michael S. Tsirkin wrote:
>> Detect presence of IASL compiler and use it
>> to process ASL source. If not there, use pre-compiled
>> files in-tree. Add script to update the in-tree files.
>>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>>  configure              |  9 ++++++++-
>>  hw/i386/Makefile.objs  | 22 ++++++++++++++++++++++
>>  scripts/update-acpi.sh |  4 ++++
>>  3 files changed, 34 insertions(+), 1 deletion(-)
>>  create mode 100644 scripts/update-acpi.sh

> 
> I think:
> - this patch (3/9) should be swapped with the next one (4/9), so that
> the pre-generated files are available earlier than the build code
> potentially relying on them,
> - the "iasl-option" trick should be moved to ./configure perhaps.

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

anyway
Michael S. Tsirkin July 11, 2013, 5:10 p.m. UTC | #3
On Thu, Jul 11, 2013 at 06:55:37PM +0200, Laszlo Ersek wrote:
> On 07/10/13 15:51, Michael S. Tsirkin wrote:
> > Detect presence of IASL compiler and use it
> > to process ASL source. If not there, use pre-compiled
> > files in-tree. Add script to update the in-tree files.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  configure              |  9 ++++++++-
> >  hw/i386/Makefile.objs  | 22 ++++++++++++++++++++++
> >  scripts/update-acpi.sh |  4 ++++
> >  3 files changed, 34 insertions(+), 1 deletion(-)
> >  create mode 100644 scripts/update-acpi.sh
> > 
> > diff --git a/configure b/configure
> > index 0e0adde..4fb54e2 100755
> > --- a/configure
> > +++ b/configure
> > @@ -119,6 +119,7 @@ path_of() {
> >  # default parameters
> >  source_path=`dirname "$0"`
> >  cpu=""
> > +iasl="iasl"
> >  interp_prefix="/usr/gnemul/qemu-%M"
> >  static="no"
> >  cross_prefix=""
> > @@ -251,6 +252,8 @@ for opt do
> >    ;;
> >    --cc=*) CC="$optarg"
> >    ;;
> > +  --iasl=*) iasl="$optarg"
> > +  ;;
> >    --source-path=*) source_path="$optarg"
> >    ;;
> >    --cpu=*) cpu="$optarg"
> > @@ -1020,6 +1023,7 @@ echo "Advanced options (experts only):"
> >  echo "  --source-path=PATH       path of source code [$source_path]"
> >  echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
> >  echo "  --cc=CC                  use C compiler CC [$cc]"
> > +echo "  --iasl=IASL              use ACPI compiler IASL [$iasl]"
> >  echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
> >  echo "                           build time"
> >  echo "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
> > @@ -4037,6 +4041,9 @@ else
> >  fi
> >  echo "PYTHON=$python" >> $config_host_mak
> >  echo "CC=$cc" >> $config_host_mak
> > +if $iasl -h > /dev/null 2>&1; then
> > +  echo "IASL=$iasl" >> $config_host_mak
> > +fi
> >  echo "CC_I386=$cc_i386" >> $config_host_mak
> >  echo "HOST_CC=$host_cc" >> $config_host_mak
> >  echo "OBJCC=$objcc" >> $config_host_mak
> > @@ -4509,7 +4516,7 @@ for rom in seabios vgabios ; do
> >      echo "BCC=bcc" >> $config_mak
> >      echo "CPP=$cpp" >> $config_mak
> >      echo "OBJCOPY=objcopy" >> $config_mak
> > -    echo "IASL=iasl" >> $config_mak
> > +    echo "IASL=$iasl" >> $config_mak
> >      echo "LD=$ld" >> $config_mak
> >  done
> >  
> > diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
> > index 205d22e..013d250 100644
> > --- a/hw/i386/Makefile.objs
> > +++ b/hw/i386/Makefile.objs
> > @@ -4,3 +4,25 @@ obj-y += pc.o pc_piix.o pc_q35.o
> >  obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
> >  
> >  obj-y += kvmvapic.o
> > +
> > +iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
> > +    ; then echo "$(2)"; else echo "$(3)"; fi ;)
> > +
> > +ifdef IASL
> > +#IASL Present. Generate hex files from .dsl
> > +hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
> > +	$(call quiet-command, cpp -P $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
> > +	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
> > +	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
> > +	$(call quiet-command, $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
> > +	$(call quiet-command, cat $*.off > $@, "  CAT $(TARGET_DIR)$@")
> > +else
> > +#IASL Not present. Restore pre-generated hex files.
> > +hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.hex.generated
> > +	$(call quiet-command, cp -f $< $@, "  CP $(TARGET_DIR)$@")
> > +endif
> > +
> > +.PHONY: cleanhex
> > +cleanhex:
> > +	rm -f hw/i386/*hex
> > +clean: cleanhex
> > diff --git a/scripts/update-acpi.sh b/scripts/update-acpi.sh
> > new file mode 100644
> > index 0000000..b5f05ff
> > --- /dev/null
> > +++ b/scripts/update-acpi.sh
> > @@ -0,0 +1,4 @@
> > +cd x86_64-softmmu
> > +for file in hw/i386/*.hex; do
> > +    cp -f $file ../$file.generated
> > +done
> > 
> 
> I think:
> - this patch (3/9) should be swapped with the next one (4/9), so that
> the pre-generated files are available earlier than the build code
> potentially relying on them,

they are only added to build later, with patch 5, so it should not
matter.

> - the "iasl-option" trick should be moved to ./configure perhaps.

I prefer makefile since distros can update iasl silently, and you generally
won't know that you need to re-run configure.

> Patches 1 & 2 look OK to me.
> 
> Laszlo
Hu Tao July 15, 2013, 8 a.m. UTC | #4
On Wed, Jul 10, 2013 at 04:51:41PM +0300, Michael S. Tsirkin wrote:
> Detect presence of IASL compiler and use it
> to process ASL source. If not there, use pre-compiled
> files in-tree. Add script to update the in-tree files.

Do you want to check for iasl version for now?  See:
http://www.seabios.org/pipermail/seabios/2013-May/006188.html
Michael S. Tsirkin July 15, 2013, 8:19 a.m. UTC | #5
On Mon, Jul 15, 2013 at 04:00:23PM +0800, Hu Tao wrote:
> On Wed, Jul 10, 2013 at 04:51:41PM +0300, Michael S. Tsirkin wrote:
> > Detect presence of IASL compiler and use it
> > to process ASL source. If not there, use pre-compiled
> > files in-tree. Add script to update the in-tree files.
> 
> Do you want to check for iasl version for now?  See:
> http://www.seabios.org/pipermail/seabios/2013-May/006188.html

This patch does this in the makefile (same as seabios does), this is just in case a
distro updates iasl versions.
diff mbox

Patch

diff --git a/configure b/configure
index 0e0adde..4fb54e2 100755
--- a/configure
+++ b/configure
@@ -119,6 +119,7 @@  path_of() {
 # default parameters
 source_path=`dirname "$0"`
 cpu=""
+iasl="iasl"
 interp_prefix="/usr/gnemul/qemu-%M"
 static="no"
 cross_prefix=""
@@ -251,6 +252,8 @@  for opt do
   ;;
   --cc=*) CC="$optarg"
   ;;
+  --iasl=*) iasl="$optarg"
+  ;;
   --source-path=*) source_path="$optarg"
   ;;
   --cpu=*) cpu="$optarg"
@@ -1020,6 +1023,7 @@  echo "Advanced options (experts only):"
 echo "  --source-path=PATH       path of source code [$source_path]"
 echo "  --cross-prefix=PREFIX    use PREFIX for compile tools [$cross_prefix]"
 echo "  --cc=CC                  use C compiler CC [$cc]"
+echo "  --iasl=IASL              use ACPI compiler IASL [$iasl]"
 echo "  --host-cc=CC             use C compiler CC [$host_cc] for code run at"
 echo "                           build time"
 echo "  --objcc=OBJCC            use Objective-C compiler OBJCC [$objcc]"
@@ -4037,6 +4041,9 @@  else
 fi
 echo "PYTHON=$python" >> $config_host_mak
 echo "CC=$cc" >> $config_host_mak
+if $iasl -h > /dev/null 2>&1; then
+  echo "IASL=$iasl" >> $config_host_mak
+fi
 echo "CC_I386=$cc_i386" >> $config_host_mak
 echo "HOST_CC=$host_cc" >> $config_host_mak
 echo "OBJCC=$objcc" >> $config_host_mak
@@ -4509,7 +4516,7 @@  for rom in seabios vgabios ; do
     echo "BCC=bcc" >> $config_mak
     echo "CPP=$cpp" >> $config_mak
     echo "OBJCOPY=objcopy" >> $config_mak
-    echo "IASL=iasl" >> $config_mak
+    echo "IASL=$iasl" >> $config_mak
     echo "LD=$ld" >> $config_mak
 done
 
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 205d22e..013d250 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -4,3 +4,25 @@  obj-y += pc.o pc_piix.o pc_q35.o
 obj-$(CONFIG_XEN) += xen_domainbuild.o xen_machine_pv.o
 
 obj-y += kvmvapic.o
+
+iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \
+    ; then echo "$(2)"; else echo "$(3)"; fi ;)
+
+ifdef IASL
+#IASL Present. Generate hex files from .dsl
+hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.dsl $(SRC_PATH)/scripts/acpi_extract_preprocess.py $(SRC_PATH)/scripts/acpi_extract.py
+	$(call quiet-command, cpp -P $< -o $*.dsl.i.orig, "  CPP $(TARGET_DIR)$*.dsl.i.orig")
+	$(call quiet-command, $(PYTHON) $(SRC_PATH)/scripts/acpi_extract_preprocess.py $*.dsl.i.orig > $*.dsl.i, "  ACPI_PREPROCESS $(TARGET_DIR)$*.dsl.i")
+	$(call quiet-command, $(IASL) $(call iasl-option,$(IASL),-Pn,) -vs -l -tc -p $* $*.dsl.i $(if $(V), , > /dev/null) 2>&1 ,"  IASL $(TARGET_DIR)$*.dsl.i")
+	$(call quiet-command, $(SRC_PATH)/scripts/acpi_extract.py $*.lst > $*.off, "  ACPI_EXTRACT $(TARGET_DIR)$*.off")
+	$(call quiet-command, cat $*.off > $@, "  CAT $(TARGET_DIR)$@")
+else
+#IASL Not present. Restore pre-generated hex files.
+hw/i386/%.hex: $(SRC_PATH)/hw/i386/%.hex.generated
+	$(call quiet-command, cp -f $< $@, "  CP $(TARGET_DIR)$@")
+endif
+
+.PHONY: cleanhex
+cleanhex:
+	rm -f hw/i386/*hex
+clean: cleanhex
diff --git a/scripts/update-acpi.sh b/scripts/update-acpi.sh
new file mode 100644
index 0000000..b5f05ff
--- /dev/null
+++ b/scripts/update-acpi.sh
@@ -0,0 +1,4 @@ 
+cd x86_64-softmmu
+for file in hw/i386/*.hex; do
+    cp -f $file ../$file.generated
+done