config_tools: use ASL_COMPILER as the path to the "iasl" compiler

At build time (on the *dev* machine), config_tools depends on "iasl" to
generate the binary of ACPI tables for pre-launched VMs.

This patch does:
- pass ASL_COMPILER to config_tools
  By default, ASL_COMPILER is initialized by "which iasl" at build time.
  User could override it by specifying ASL_COMPILER as the build option,
  like below:
    make BOARD=xxxx SCENARIO=yyyy ASL_COMPILER=/usr/local/bin/iasl

- use ASL_COMPILER as the path to the "iasl" compiler in config_tools

v1 -> v2:
 - add a check to make sure ASL_COMPILER is initialized to a value

Tracked-On: #7880

Signed-off-by: Shiqing Gao <shiqing.gao@intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
Shiqing Gao
2022-07-04 13:53:36 +08:00
committed by acrnsi-robot
parent 59b6d7b404
commit 3f0fae81b2
3 changed files with 19 additions and 10 deletions

View File

@@ -46,7 +46,7 @@ def move_rtct_ssram_and_bin_entries(rtct, new_base_addr, new_area_max_size):
rtct.header.checksum = 0
rtct.header.checksum = 0 - sum(bytes(rtct))
def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree):
def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree, iasl_path):
'''
compile asl code of ACPI table to aml code.
:param dest_vm_acpi_path: the path of the asl code of ACPI tables
@@ -61,7 +61,7 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocat
for acpi_table in ACPI_TABLE_LIST:
if acpi_table[0] == 'tpm2.asl':
if 'tpm2.asl' in os.listdir(dest_vm_acpi_path):
rc = exec_command('iasl {}'.format(acpi_table[0]))
rc = exec_command('{} {}'.format(iasl_path, acpi_table[0]))
if rc == 0 and os.path.isfile(os.path.join(dest_vm_acpi_path, acpi_table[1])):
shutil.move(os.path.join(dest_vm_acpi_path, acpi_table[1]),
os.path.join(dest_vm_acpi_bin_path, acpi_table[1]))
@@ -86,7 +86,7 @@ def asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocat
fp.close()
else:
if acpi_table[0].endswith(".asl"):
rc = exec_command('iasl {}'.format(acpi_table[0]))
rc = exec_command('{} {}'.format(iasl_path, acpi_table[0]))
if rc == 0 and os.path.isfile(os.path.join(dest_vm_acpi_path, acpi_table[1])):
shutil.move(os.path.join(dest_vm_acpi_path, acpi_table[1]),
os.path.join(dest_vm_acpi_bin_path, acpi_table[1]))
@@ -218,7 +218,7 @@ def exec_command(cmd):
return rc
def check_iasl():
def check_iasl(iasl_path):
'''
check iasl installed
:return: True if iasl installed.
@@ -226,7 +226,7 @@ def check_iasl():
try:
p_version = 'ASL+ Optimizing Compiler/Disassembler version'
min_version = 20190703
output = subprocess.check_output(['iasl', '-v']).decode('utf8')
output = subprocess.check_output([iasl_path, '-v']).decode('utf8')
if p_version in output:
try:
for line in output.split('\n'):
@@ -269,7 +269,7 @@ def main(args):
if os.path.isdir(DEST_ACPI_BIN_PATH):
shutil.rmtree(DEST_ACPI_BIN_PATH)
if not check_iasl():
if not check_iasl(args.iasl_path):
print("Please install iasl tool with version >= 20190703 from https://www.acpica.org/downloads before ACPI generation.")
return 1
@@ -279,7 +279,7 @@ def main(args):
dest_vm_acpi_path = os.path.join(DEST_ACPI_PATH, config)
dest_vm_acpi_bin_path = os.path.join(DEST_ACPI_BIN_PATH, config)
os.makedirs(dest_vm_acpi_bin_path)
if asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree):
if asl_to_aml(dest_vm_acpi_path, dest_vm_acpi_bin_path, scenario_etree, allocation_etree, args.iasl_path):
return 1
aml_to_bin(dest_vm_acpi_path, dest_vm_acpi_bin_path, config+'.bin', board_etree, scenario_etree, allocation_etree)
@@ -287,11 +287,13 @@ def main(args):
if __name__ == '__main__':
parser = argparse.ArgumentParser(usage="python3 bin_gen.py --board [board] --scenario [scenario]"
" --iasl_path [the path to the iasl compiler]"
"[ --out [output dir of acpi ASL code]]",
description="the tool to generate ACPI binary for Pre-launched VMs")
parser.add_argument("--board", required=True, help="the XML file summarizing characteristics of the target board")
parser.add_argument("--scenario", required=True, help="the XML file specifying the scenario to be set up")
parser.add_argument("--asl", default=None, help="the input folder to store the ACPI ASL code. ")
parser.add_argument("--iasl_path", default=None, help="the path to the iasl compiler.")
parser.add_argument("--out", default=None, help="the output folder to store the ACPI binary code. "
"If not specified, the path for the binary code is"
"build/hypervisor/acpi/")