1# 2# Copyright (c) 2004, Intel Corporation. 3# 4# This program is free software; you can redistribute it and/or modify 5# it under the terms of the GNU Lesser General Public License as published 6# by the Free Software Foundation; version 2.1 only. with the special 7# exception on linking described in file LICENSE. 8# 9# This program is distributed in the hope that it will be useful, 10# but WITHOUT ANY WARRANTY; without even the implied warranty of 11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12# GNU Lesser General Public License for more details. 13# 14 15XEN_ROOT = $(CURDIR)/../.. 16include $(XEN_ROOT)/tools/Rules.mk 17 18ifeq ($(ACPI_BUILD_DIR),) 19$(error ACPI_BUILD_DIR not set) 20endif 21 22MK_DSDT = $(ACPI_BUILD_DIR)/mk_dsdt 23 24C_SRC-$(CONFIG_X86) = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c dsdt_pvh.c 25C_SRC-$(CONFIG_ARM_64) = dsdt_anycpu_arm.c 26DSDT_FILES ?= $(C_SRC-y) 27C_SRC = $(addprefix $(ACPI_BUILD_DIR)/, $(DSDT_FILES)) 28H_SRC = $(addprefix $(ACPI_BUILD_DIR)/, ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h ssdt_laptop_slate.h) 29 30MKDSDT_CFLAGS-$(CONFIG_ARM_64) = -DCONFIG_ARM_64 31MKDSDT_CFLAGS-$(CONFIG_X86) = -DCONFIG_X86 32 33# Suffix for temporary files. 34# 35# We will also use this suffix to workaround a bug in older iasl 36# versions where the tool will ignore everything after last '.' in the 37# path ('-p' argument). By adding ".<suffix>" we force iasl to use 38# complete $(ACPI_BUILD_DIR) as path, even if it has '.' symbols. 39TMP_SUFFIX = tmp 40 41vpath iasl $(PATH) 42all: $(C_SRC) $(H_SRC) 43 44$(H_SRC): $(ACPI_BUILD_DIR)/%.h: %.asl iasl 45 iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $< 46 sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex >$@ 47 rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex) 48 49$(MK_DSDT): mk_dsdt.c 50 $(HOSTCC) $(HOSTCFLAGS) $(MKDSDT_CFLAGS-y) $(CFLAGS_xeninclude) -D__XEN_TOOLS__ -o $@ mk_dsdt.c 51 52$(ACPI_BUILD_DIR)/dsdt_anycpu_qemu_xen.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT) 53 # Remove last bracket 54 awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) 55 cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) 56 $(MK_DSDT) --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX) 57 mv -f $@.$(TMP_SUFFIX) $@ 58 59# NB. awk invocation is a portable alternative to 'head -n -1' 60$(ACPI_BUILD_DIR)/dsdt_%cpu.asl: dsdt.asl dsdt_acpi_info.asl $(MK_DSDT) 61 # Remove last bracket 62 awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX) 63 cat dsdt_acpi_info.asl >> $@.$(TMP_SUFFIX) 64 $(MK_DSDT) --debug=$(debug) --maxcpu $* >> $@.$(TMP_SUFFIX) 65 mv -f $@.$(TMP_SUFFIX) $@ 66 67$(ACPI_BUILD_DIR)/dsdt_pvh.asl: dsdt_acpi_info.asl $(MK_DSDT) 68 printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 5, \"Xen\", \"HVM\", 0)\n{" > $@ 69 cat dsdt_acpi_info.asl >> $@ 70 $(MK_DSDT) --debug=$(debug) --maxcpu any --dm-version none >> $@ 71 72$(ACPI_BUILD_DIR)/dsdt_anycpu_arm.asl: $(MK_DSDT) 73 printf "DefinitionBlock (\"DSDT.aml\", \"DSDT\", 3, \"Xen\", \"ARM\", 1)\n{" > $@.$(TMP_SUFFIX) 74 $(MK_DSDT) --debug=$(debug) >> $@.$(TMP_SUFFIX) 75 mv -f $@.$(TMP_SUFFIX) $@ 76 77$(C_SRC): $(ACPI_BUILD_DIR)/%.c: iasl $(ACPI_BUILD_DIR)/%.asl 78 iasl -vs -p $(ACPI_BUILD_DIR)/$*.$(TMP_SUFFIX) -tc $(ACPI_BUILD_DIR)/$*.asl 79 sed -e 's/AmlCode/$*/g' $(ACPI_BUILD_DIR)/$*.hex > $@.$(TMP_SUFFIX) 80 echo "int $*_len=sizeof($*);" >> $@.$(TMP_SUFFIX) 81 mv -f $@.$(TMP_SUFFIX) $@ 82 rm -f $(addprefix $(ACPI_BUILD_DIR)/, $*.aml $*.hex) 83 84iasl: 85 @echo 86 @echo "ACPI ASL compiler (iasl) is needed" 87 @echo "Download and install Intel ACPI CA from" 88 @echo "http://acpica.org/downloads/" 89 @echo 90 @exit 1 91 92build.o: ssdt_s3.h ssdt_s4.h ssdt_pm.h ssdt_tpm.h ssdt_laptop_slate.h 93 94acpi.a: $(OBJS) 95 $(AR) rc $@ $(OBJS) 96 97clean: 98 rm -f $(C_SRC) $(H_SRC) $(MK_DSDT) $(C_SRC:=.$(TMP_SUFFIX)) 99 rm -f $(patsubst %.c,%.hex,$(C_SRC)) $(patsubst %.c,%.aml,$(C_SRC)) $(patsubst %.c,%.asl,$(C_SRC)) 100 101distclean: clean 102 103install: all 104 105-include $(DEPS_INCLUDE) 106