diff --git a/misc/config_tools/target/README b/misc/config_tools/board_inspector/README similarity index 86% rename from misc/config_tools/target/README rename to misc/config_tools/board_inspector/README index 88fd0e927..8a3d1adef 100644 --- a/misc/config_tools/target/README +++ b/misc/config_tools/board_inspector/README @@ -1,9 +1,9 @@ board_parser.py will collect all board related info and then generate a board info file for acrn-config host tool usage. -usage: python3 board_parser.py [--out board_info_file] +usage: python3 run.py [--out board_info_file] board_name : the name of board that run ACRN hypervisor, like apl-up2/nuc7i7dnb. It will be used as name of the board configurations folder which created by acrn-config host tool. -board_info_file : (optional) the name of board info file. if it is not specified, a name of .xml will be generated under ./out/ folder by default. +board_info_file : (optional) the name of board info file. if it is not specified, a name of .xml will be generated under the current working directory by default. Please run this script under native Linux environment with root privilege. diff --git a/misc/config_tools/target/acpiparser/__init__.py b/misc/config_tools/board_inspector/acpiparser/__init__.py similarity index 92% rename from misc/config_tools/target/acpiparser/__init__.py rename to misc/config_tools/board_inspector/acpiparser/__init__.py index 1f28c6cfd..989920d22 100644 --- a/misc/config_tools/target/acpiparser/__init__.py +++ b/misc/config_tools/board_inspector/acpiparser/__init__.py @@ -8,6 +8,7 @@ import sys from acpiparser.apic import APIC from acpiparser.asf import ASF from acpiparser.dmar import DMAR +from acpiparser.dsdt import DSDT from acpiparser.facp import FACP from acpiparser.rtct import RTCT @@ -25,6 +26,7 @@ def make_parser(signature): parse_apic = make_parser('APIC') parse_asf = make_parser('ASF!') +parse_dsdt = make_parser('DSDT') parse_dmar = make_parser('DMAR') parse_facp = make_parser('FACP') parse_rtct = make_parser('RTCT') diff --git a/misc/config_tools/target/acpiparser/_utils.py b/misc/config_tools/board_inspector/acpiparser/_utils.py similarity index 96% rename from misc/config_tools/target/acpiparser/_utils.py rename to misc/config_tools/board_inspector/acpiparser/_utils.py index 720ea7ddb..698f67d63 100644 --- a/misc/config_tools/target/acpiparser/_utils.py +++ b/misc/config_tools/board_inspector/acpiparser/_utils.py @@ -5,8 +5,8 @@ import ctypes -import acpiparser.cdata as cdata -import acpiparser.unpack as unpack +import lib.cdata as cdata +import lib.unpack as unpack class TableHeader(cdata.Struct): _pack_ = 1 diff --git a/misc/config_tools/target/acpiparser/apic.py b/misc/config_tools/board_inspector/acpiparser/apic.py similarity index 99% rename from misc/config_tools/target/acpiparser/apic.py rename to misc/config_tools/board_inspector/acpiparser/apic.py index 86bc75f56..4c6187885 100644 --- a/misc/config_tools/target/acpiparser/apic.py +++ b/misc/config_tools/board_inspector/acpiparser/apic.py @@ -6,8 +6,8 @@ import ctypes import copy -import acpiparser.cdata as cdata -import acpiparser.unpack as unpack +import lib.cdata as cdata +import lib.unpack as unpack from acpiparser._utils import TableHeader class APICSubtable(cdata.Struct): diff --git a/misc/config_tools/target/acpiparser/asf.py b/misc/config_tools/board_inspector/acpiparser/asf.py similarity index 99% rename from misc/config_tools/target/acpiparser/asf.py rename to misc/config_tools/board_inspector/acpiparser/asf.py index 0602fbe37..cedcd80fb 100644 --- a/misc/config_tools/target/acpiparser/asf.py +++ b/misc/config_tools/board_inspector/acpiparser/asf.py @@ -6,7 +6,7 @@ import ctypes import copy -import acpiparser.cdata as cdata +import lib.cdata as cdata from acpiparser._utils import TableHeader class ASFSubtable(cdata.Struct): diff --git a/misc/config_tools/target/acpiparser/dmar.py b/misc/config_tools/board_inspector/acpiparser/dmar.py similarity index 99% rename from misc/config_tools/target/acpiparser/dmar.py rename to misc/config_tools/board_inspector/acpiparser/dmar.py index 3179138bd..7b841e196 100644 --- a/misc/config_tools/target/acpiparser/dmar.py +++ b/misc/config_tools/board_inspector/acpiparser/dmar.py @@ -6,7 +6,7 @@ import ctypes import copy -import acpiparser.cdata as cdata +import lib.cdata as cdata from acpiparser._utils import TableHeader class DMARSubtable(cdata.Struct): diff --git a/misc/config_tools/target/acpiparser/facp.py b/misc/config_tools/board_inspector/acpiparser/facp.py similarity index 99% rename from misc/config_tools/target/acpiparser/facp.py rename to misc/config_tools/board_inspector/acpiparser/facp.py index 1d9faaf0c..5ff64436d 100644 --- a/misc/config_tools/target/acpiparser/facp.py +++ b/misc/config_tools/board_inspector/acpiparser/facp.py @@ -6,8 +6,8 @@ import ctypes import copy -import acpiparser.cdata as cdata -import acpiparser.unpack as unpack +import lib.cdata as cdata +import lib.unpack as unpack from acpiparser._utils import TableHeader, GAS _preferred_pm_profile = { diff --git a/misc/config_tools/target/acpiparser/rtct.py b/misc/config_tools/board_inspector/acpiparser/rtct.py similarity index 99% rename from misc/config_tools/target/acpiparser/rtct.py rename to misc/config_tools/board_inspector/acpiparser/rtct.py index 99b1ee6aa..b88bfe4b4 100644 --- a/misc/config_tools/target/acpiparser/rtct.py +++ b/misc/config_tools/board_inspector/acpiparser/rtct.py @@ -6,7 +6,7 @@ import ctypes import copy -import acpiparser.cdata as cdata +import lib.cdata as cdata from acpiparser._utils import TableHeader class RTCTSubtable(cdata.Struct): diff --git a/misc/config_tools/board_inspector/cli.py b/misc/config_tools/board_inspector/cli.py new file mode 100755 index 000000000..f768079e5 --- /dev/null +++ b/misc/config_tools/board_inspector/cli.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python3 +# +# Copyright (C) 2021 Intel Corporation. All rights reserved. +# +# SPDX-License-Identifier: BSD-3-Clause +# + +import sys, os +import logging +import subprocess +import lxml.etree +import argparse +from importlib import import_module + +script_dir = os.path.dirname(os.path.realpath(__file__)) +sys.path.append(os.path.join(script_dir)) + +def main(board_name, board_xml): + try: + # First invoke the legacy board parser to create the board XML ... + legacy_parser = os.path.join(script_dir, "legacy", "board_parser.py") + env = { "PYTHONPATH": script_dir } + subprocess.run([sys.executable, legacy_parser, args.board_name, "--out", board_xml], check=True, env=env) + + # ... then load the created board XML and append it with additional data by invoking the extractors. + board_etree = lxml.etree.parse(board_xml) + + # Clear the whitespaces between adjacent children under the root node + board_etree.getroot().text = None + for elem in board_etree.getroot(): + elem.tail = None + + # Finally overwrite the output with the updated XML + board_etree.write(board_xml, pretty_print=True) + + except subprocess.CalledProcessError as e: + print(e) + sys.exit(1) + +if __name__ == "__main__": + logging.basicConfig(level=logging.INFO) + parser = argparse.ArgumentParser() + parser.add_argument("board_name", help="the name of the board that runs the ACRN hypervisor") + parser.add_argument("--out", help="the name of board info file") + args = parser.parse_args() + + board_xml = args.out if args.out else f"{args.board_name}.xml" + main(args.board_name, board_xml) diff --git a/misc/config_tools/target/acpi.py b/misc/config_tools/board_inspector/legacy/acpi.py similarity index 100% rename from misc/config_tools/target/acpi.py rename to misc/config_tools/board_inspector/legacy/acpi.py diff --git a/misc/config_tools/target/board_parser.py b/misc/config_tools/board_inspector/legacy/board_parser.py similarity index 100% rename from misc/config_tools/target/board_parser.py rename to misc/config_tools/board_inspector/legacy/board_parser.py diff --git a/misc/config_tools/target/clos.py b/misc/config_tools/board_inspector/legacy/clos.py similarity index 100% rename from misc/config_tools/target/clos.py rename to misc/config_tools/board_inspector/legacy/clos.py diff --git a/misc/config_tools/target/dmar.py b/misc/config_tools/board_inspector/legacy/dmar.py similarity index 100% rename from misc/config_tools/target/dmar.py rename to misc/config_tools/board_inspector/legacy/dmar.py diff --git a/misc/config_tools/target/dmi.py b/misc/config_tools/board_inspector/legacy/dmi.py similarity index 100% rename from misc/config_tools/target/dmi.py rename to misc/config_tools/board_inspector/legacy/dmi.py diff --git a/misc/config_tools/target/misc.py b/misc/config_tools/board_inspector/legacy/misc.py similarity index 100% rename from misc/config_tools/target/misc.py rename to misc/config_tools/board_inspector/legacy/misc.py diff --git a/misc/config_tools/target/parser_lib.py b/misc/config_tools/board_inspector/legacy/parser_lib.py similarity index 100% rename from misc/config_tools/target/parser_lib.py rename to misc/config_tools/board_inspector/legacy/parser_lib.py diff --git a/misc/config_tools/target/pci_dev.py b/misc/config_tools/board_inspector/legacy/pci_dev.py similarity index 100% rename from misc/config_tools/target/pci_dev.py rename to misc/config_tools/board_inspector/legacy/pci_dev.py diff --git a/misc/config_tools/target/rtct.py b/misc/config_tools/board_inspector/legacy/rtct.py similarity index 100% rename from misc/config_tools/target/rtct.py rename to misc/config_tools/board_inspector/legacy/rtct.py diff --git a/misc/config_tools/target/acpiparser/bitfields.py b/misc/config_tools/board_inspector/lib/bitfields.py similarity index 100% rename from misc/config_tools/target/acpiparser/bitfields.py rename to misc/config_tools/board_inspector/lib/bitfields.py diff --git a/misc/config_tools/target/acpiparser/cdata.py b/misc/config_tools/board_inspector/lib/cdata.py similarity index 100% rename from misc/config_tools/target/acpiparser/cdata.py rename to misc/config_tools/board_inspector/lib/cdata.py diff --git a/misc/config_tools/target/acpiparser/unpack.py b/misc/config_tools/board_inspector/lib/unpack.py similarity index 100% rename from misc/config_tools/target/acpiparser/unpack.py rename to misc/config_tools/board_inspector/lib/unpack.py