mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-09-07 20:00:13 +00:00
HV:Acrn-hypvervisor Root Directory Clean-up and create misc/ folder for Acrn daemons, services and tools.
This patch is to clean-up acrn-hypervisor root directory, targt only 5 folders under acrn-hypervisor:1.hypervisor,2.devicemodel,3.misc,4.doc,5.build Tracked-On: #3482 Signed-off-by: Terry Zou <terry.zou@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
5
misc/acrn-config/kconfig/LICENSE.kconfiglib
Normal file
5
misc/acrn-config/kconfig/LICENSE.kconfiglib
Normal file
@@ -0,0 +1,5 @@
|
||||
Copyright (c) 2011-2018, Ulf Magnusson <ulfalizer@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
57
misc/acrn-config/kconfig/defconfig.py
Normal file
57
misc/acrn-config/kconfig/defconfig.py
Normal file
@@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2018 Intel Corporation.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# This script takes a Kconfig and a defconfig file, and expands it to a .config
|
||||
# with all default values listed explicitly.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Kconfiglib: Copyright (c) 2011-2018, Ulf Magnusson
|
||||
# SPDX-License-Identifier: ISC
|
||||
# Refer to scripts/kconfig/LICENSE.kconfiglib for the permission notice.
|
||||
import kconfiglib
|
||||
|
||||
def usage():
|
||||
sys.stdout.write("%s: <Kconfig file> <path to .config>\n" % sys.argv[0])
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 3:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
target_board = os.environ['BOARD']
|
||||
|
||||
kconfig_path = sys.argv[1]
|
||||
if not os.path.isfile(kconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % kconfig_path)
|
||||
sys.exit(1)
|
||||
|
||||
kconfig = kconfiglib.Kconfig(kconfig_path)
|
||||
defconfig_path = kconfig.defconfig_filename
|
||||
if not defconfig_path or not os.path.isfile(defconfig_path):
|
||||
sys.stderr.write("No defconfig found for board %s.\n" % target_board)
|
||||
sys.exit(1)
|
||||
|
||||
kconfig.load_config(defconfig_path)
|
||||
|
||||
config_path = sys.argv[2]
|
||||
if os.path.isfile(config_path):
|
||||
# No need to change .config if it is already equivalent to the specified
|
||||
# default.
|
||||
kconfig_current = kconfiglib.Kconfig(kconfig_path)
|
||||
kconfig_current.load_config(config_path)
|
||||
same_config = True
|
||||
for sym in kconfig_current.syms:
|
||||
if kconfig_current.syms[sym].str_value != kconfig.syms[sym].str_value:
|
||||
same_config = False
|
||||
break
|
||||
if same_config:
|
||||
sys.exit(0)
|
||||
|
||||
sys.stdout.write("Default configuration based on %s.\n" % defconfig_path)
|
||||
kconfig.write_config(config_path)
|
||||
sys.stdout.write("Configuration written to %s.\n" % config_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
97
misc/acrn-config/kconfig/generate_header.py
Normal file
97
misc/acrn-config/kconfig/generate_header.py
Normal file
@@ -0,0 +1,97 @@
|
||||
# Copyright (C) 2018 Intel Corporation.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# This script takes a Kconfig and a .config, and generates a C header file with
|
||||
# all the configuration data defined as object-like macros.
|
||||
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
|
||||
# Kconfiglib: Copyright (c) 2011-2018, Ulf Magnusson
|
||||
# SPDX-License-Identifier: ISC
|
||||
# Refer to scripts/kconfig/LICENSE.kconfiglib for the permission notice.
|
||||
import kconfiglib
|
||||
|
||||
class AcrnConfig(kconfiglib.Kconfig):
|
||||
help_regex = re.compile("64-bit[\s\n]+integer")
|
||||
def __init__(self, filename="Kconfig", warn=True, warn_to_stderr=True, encoding="utf-8"):
|
||||
kconfiglib.Kconfig.__init__(self, filename, warn, warn_to_stderr, encoding)
|
||||
|
||||
def write_autoconf(self, filename,
|
||||
header="/* Generated by Kconfiglib (https://github.com/ulfalizer/"
|
||||
"Kconfiglib) */\n"):
|
||||
|
||||
guard_begin = "#ifndef HV_KCONFIG\n#define HV_KCONFIG\n"
|
||||
guard_end = "#endif"
|
||||
|
||||
with open(filename, "w") as f_autoconf:
|
||||
f_autoconf.write(header)
|
||||
f_autoconf.write(guard_begin)
|
||||
|
||||
for sym in self.defined_syms:
|
||||
if sym.config_string in ("", None):
|
||||
continue
|
||||
else:
|
||||
val = sym.str_value
|
||||
if sym.orig_type in (kconfiglib.BOOL, kconfiglib.TRISTATE):
|
||||
if val != "n":
|
||||
f_autoconf.write("#define {}{}{} 1\n"
|
||||
.format(self.config_prefix, sym.name,
|
||||
"_MODULE" if val == "m" else ""))
|
||||
elif sym.orig_type == kconfiglib.STRING:
|
||||
f_autoconf.write('#define {}{} "{}"\n'
|
||||
.format(self.config_prefix, sym.name,
|
||||
kconfiglib.escape(val)))
|
||||
elif sym.orig_type in (kconfiglib.INT, kconfiglib.HEX):
|
||||
if sym.orig_type == kconfiglib.HEX:
|
||||
val = val + "U"
|
||||
if not val.startswith(("0x", "0X")):
|
||||
val = "0x" + val
|
||||
elif sym.orig_type == kconfiglib.INT and len(sym.ranges) > 0:
|
||||
left_sym = sym.ranges[0][0]
|
||||
right_sym = sym.ranges[0][1]
|
||||
left_value = int(left_sym.str_value)
|
||||
right_value = int(right_sym.str_value)
|
||||
if left_value >= 0 and right_value >= 0:
|
||||
val = val + "U"
|
||||
|
||||
_help = sym.nodes[0].help
|
||||
if _help not in (None, "") and len(self.help_regex.findall(_help)) > 0:
|
||||
val = val + "L"
|
||||
f_autoconf.write("#define {}{} {}\n"
|
||||
.format(self.config_prefix, sym.name, val))
|
||||
else:
|
||||
raise Exception(
|
||||
'Internal error while creating C header: unknown type "{}".' \
|
||||
.format(sym.orig_type))
|
||||
|
||||
f_autoconf.write(guard_end)
|
||||
|
||||
|
||||
def usage():
|
||||
sys.stdout.write("%s: <Kconfig file> <.config file> <path to config.h>\n" % sys.argv[0])
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 4:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
header = "/* Generated by Kconfiglib */\n"
|
||||
kconfig_path = sys.argv[1]
|
||||
if not os.path.isfile(kconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % kconfig_path)
|
||||
sys.exit(1)
|
||||
|
||||
config_path = sys.argv[2]
|
||||
if not os.path.isfile(config_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % config_path)
|
||||
sys.exit(1)
|
||||
|
||||
kconfig = AcrnConfig(kconfig_path)
|
||||
kconfig.load_config(config_path)
|
||||
kconfig.write_autoconf(sys.argv[3], header)
|
||||
sys.stdout.write("Configuration header written to %s.\n" % sys.argv[3])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
40
misc/acrn-config/kconfig/savedefconfig.py
Normal file
40
misc/acrn-config/kconfig/savedefconfig.py
Normal file
@@ -0,0 +1,40 @@
|
||||
# Copyright (C) 2018 Intel Corporation.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# Given a Kconfig, this script minimize a given .config by removing the symbols
|
||||
# having the default values. The minimized config can act as a defconfig for
|
||||
# future use.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Kconfiglib: Copyright (c) 2011-2018, Ulf Magnusson
|
||||
# SPDX-License-Identifier: ISC
|
||||
# Refer to scripts/kconfig/LICENSE.kconfiglib for the permission notice.
|
||||
import kconfiglib
|
||||
|
||||
def usage():
|
||||
sys.stdout.write("%s: <Kconfig file> <.config file> <path to output .config>\n" % sys.argv[0])
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 4:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
kconfig_path = sys.argv[1]
|
||||
if not os.path.isfile(kconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % kconfig_path)
|
||||
sys.exit(1)
|
||||
|
||||
config_path = sys.argv[2]
|
||||
if not os.path.isfile(config_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % config_path)
|
||||
sys.exit(1)
|
||||
|
||||
kconfig = kconfiglib.Kconfig(kconfig_path)
|
||||
kconfig.load_config(config_path)
|
||||
kconfig.write_min_config(sys.argv[3])
|
||||
sys.stdout.write("Minimized configuration written to %s.\n" % sys.argv[3])
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
125
misc/acrn-config/kconfig/silentoldconfig.py
Normal file
125
misc/acrn-config/kconfig/silentoldconfig.py
Normal file
@@ -0,0 +1,125 @@
|
||||
# Copyright (C) 2018 Intel Corporation.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
# This script
|
||||
#
|
||||
# 1. takes a Kconfig and a .config and an optional list of symbol-value pairs,
|
||||
# 2. checks whether the specified symbols have the specified values in the
|
||||
# given .config, and
|
||||
# 3. reconstruct .config with the given list of symbol-value pairs if there
|
||||
# is any disagreement.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Kconfiglib: Copyright (c) 2011-2018, Ulf Magnusson
|
||||
# SPDX-License-Identifier: ISC
|
||||
# Refer to scripts/kconfig/LICENSE.kconfiglib for the permission notice.
|
||||
import kconfiglib
|
||||
|
||||
def usage():
|
||||
sys.stdout.write("%s: <Kconfig file> <.config file> [<symbol1>=<value1> ...]\n" % sys.argv[0])
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 3:
|
||||
usage()
|
||||
sys.exit(1)
|
||||
|
||||
kconfig_path = sys.argv[1]
|
||||
if not os.path.isfile(kconfig_path):
|
||||
sys.stderr.write("Cannot find file %s\n" % kconfig_path)
|
||||
sys.exit(1)
|
||||
|
||||
kconfig = kconfiglib.Kconfig(kconfig_path)
|
||||
|
||||
# Parse the configs specified on cmdline
|
||||
|
||||
cmdline_conf = {}
|
||||
for sym_val in sys.argv[3:]:
|
||||
if sym_val.find("=") == -1:
|
||||
continue
|
||||
sym_name, val = sym_val.split("=")[:2]
|
||||
if sym_name in kconfig.syms.keys() and val:
|
||||
cmdline_conf[sym_name] = val
|
||||
|
||||
# Determine the base config.
|
||||
#
|
||||
# If either
|
||||
#
|
||||
# 1. no .config exists, or
|
||||
# 2. the BOARD in the existing .config is different from the BOARD
|
||||
# specified in the environment variable
|
||||
#
|
||||
# the defconfig will be used as the base config. Otherwise the existing
|
||||
# .config is used as the base.
|
||||
#
|
||||
# If .config does not exist, it is required that Kconfig specifies an
|
||||
# existing defconfig, otherwise this script will refuse to generate a
|
||||
# .config.
|
||||
config_path = sys.argv[2]
|
||||
defconfig_path = kconfig.defconfig_filename
|
||||
if defconfig_path and os.path.isfile(defconfig_path):
|
||||
kdefconfig = kconfiglib.Kconfig(kconfig_path)
|
||||
kdefconfig.load_config(defconfig_path)
|
||||
else:
|
||||
kdefconfig = None
|
||||
|
||||
need_update = False
|
||||
if os.path.isfile(config_path):
|
||||
kconfig.load_config(config_path)
|
||||
# The BOARD given by the environment variable may be different from what
|
||||
# is specified in the corresponding defconfig. So compare the value of
|
||||
# CONFIG_BOARD directly. This is applicable only when CONFIG_BOARD
|
||||
# exists in the Kconfig.
|
||||
if kdefconfig and 'BOARD' in kconfig.syms and \
|
||||
kconfig.syms['BOARD'].str_value != kdefconfig.syms['BOARD'].str_value:
|
||||
kconfig = kdefconfig
|
||||
sys.stdout.write("Overwrite with default configuration based on %s.\n" % defconfig_path)
|
||||
need_update = True
|
||||
else:
|
||||
# Use the existing .config as the base.
|
||||
#
|
||||
# Mark need_update if any visible symbol picks a different value
|
||||
# from what is specified in .config.
|
||||
for sym in [x for x in kconfig.unique_defined_syms if x.visibility]:
|
||||
if sym.type in [kconfiglib.BOOL, kconfiglib.TRISTATE]:
|
||||
picked_value = sym.tri_value
|
||||
else:
|
||||
picked_value = sym.str_value
|
||||
need_update = (picked_value != sym.user_value)
|
||||
if need_update:
|
||||
break
|
||||
else:
|
||||
# base on a default configuration
|
||||
if kdefconfig:
|
||||
kconfig = kdefconfig
|
||||
sys.stdout.write("Default configuration based on %s.\n" % defconfig_path)
|
||||
need_update = True
|
||||
else:
|
||||
# report an error if no known defconfig exists
|
||||
sys.stderr.write(".config does not exist and no defconfig available.\n")
|
||||
sys.exit(1)
|
||||
|
||||
# Update the old .config with those specified on cmdline
|
||||
#
|
||||
# Note: the user shall be careful what configuration symbols to overwrite by
|
||||
# silentoldconfig. After changing a symbol value, the invisible symbols are
|
||||
# updated accordingly because they always use the default value, while
|
||||
# visible symbols keep their original value in the old .config. This may
|
||||
# lead to invalid .config for a specific platform.
|
||||
#
|
||||
# Currently it is recommended to use the following update only for
|
||||
# RELEASE. For PLATFORM reinvoke defconfig is preferred.
|
||||
|
||||
for sym_name, val in cmdline_conf.items():
|
||||
sym = kconfig.syms[sym_name]
|
||||
if sym.str_value and sym.str_value != val:
|
||||
kconfig.syms[sym_name].set_value(val)
|
||||
need_update = True
|
||||
|
||||
if need_update:
|
||||
kconfig.write_config(config_path)
|
||||
sys.stdout.write("Configuration written to %s.\n" % config_path)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
31
misc/acrn-config/library/deps.mk
Normal file
31
misc/acrn-config/library/deps.mk
Normal file
@@ -0,0 +1,31 @@
|
||||
# usage: check_dep_exec <executable name> <variable>
|
||||
#
|
||||
# Create a target that checks the existence of the specified executable, and
|
||||
# append that target to the given variable.
|
||||
define check_dep_exec =
|
||||
$(2) += check_exec_$(1)
|
||||
check_exec_$(1):
|
||||
@if ! which $(1) > /dev/null; then \
|
||||
echo "******** Missing prerequisite tool ********"; \
|
||||
echo "Cannot find executable *$(1)*"; \
|
||||
echo "Please refer to the Getting Started Guide" \
|
||||
"for installation instructions"; \
|
||||
exit 1; \
|
||||
fi
|
||||
endef
|
||||
|
||||
# usage: check_dep_py3lib <library name> <variable>
|
||||
#
|
||||
# Create a target that checks the existence of the specified python 3 library, and
|
||||
# append that target to the given variable.
|
||||
define check_dep_py3lib =
|
||||
$(2) += check_py3lib_$(1)
|
||||
check_py3lib_$(1):
|
||||
@if ! python3 -c "import $(1)" > /dev/null 2>&1; then \
|
||||
echo "******** Missing prerequisite tool ********"; \
|
||||
echo "The python3 library *$(1)* is not installed"; \
|
||||
echo "Please refer to the Getting Started Guide" \
|
||||
"for installation instructions"; \
|
||||
exit 1; \
|
||||
fi
|
||||
endef
|
Reference in New Issue
Block a user