| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| [global] | ||
| core = edk2 | ||
|
|
||
| #################################################################################### | ||
| # options | ||
|
|
||
| [opts.common] | ||
| NETWORK_HTTP_BOOT_ENABLE = TRUE | ||
| NETWORK_IP6_ENABLE = TRUE | ||
| NETWORK_TLS_ENABLE = TRUE | ||
| NETWORK_ISCSI_ENABLE = TRUE | ||
| NETWORK_ALLOW_HTTP_CONNECTIONS = TRUE | ||
| TPM2_ENABLE = TRUE | ||
| TPM2_CONFIG_ENABLE = TRUE | ||
| TPM1_ENABLE = TRUE | ||
| CAVIUM_ERRATUM_27456 = TRUE | ||
|
|
||
| [opts.ovmf.sb.smm] | ||
| SECURE_BOOT_ENABLE = TRUE | ||
| SMM_REQUIRE = TRUE | ||
|
|
||
| [pcds.nx.broken.grub] | ||
| # grub.efi uses EfiLoaderData for code | ||
| PcdDxeNxMemoryProtectionPolicy = 0xC000000000007FD1 | ||
|
|
||
| #################################################################################### | ||
| # i386 | ||
|
|
||
| [build.ovmf.i386] | ||
| desc = ovmf build (32-bit) | ||
| conf = OvmfPkg/OvmfPkgIa32.dsc | ||
| arch = IA32 | ||
| opts = common | ||
| plat = OvmfIa32 | ||
| dest = ../pc-bios | ||
| cpy1 = FV/OVMF_CODE.fd edk2-i386-code.fd | ||
| cpy2 = FV/OVMF_VARS.fd edk2-i386-vars.fd | ||
|
|
||
| [build.ovmf.i386.secure] | ||
| desc = ovmf build (32-bit, secure boot) | ||
| conf = OvmfPkg/OvmfPkgIa32.dsc | ||
| arch = IA32 | ||
| opts = common | ||
| ovmf.sb.smm | ||
| plat = OvmfIa32 | ||
| dest = ../pc-bios | ||
| cpy1 = FV/OVMF_CODE.fd edk2-i386-secure-code.fd | ||
|
|
||
| #################################################################################### | ||
| # x86_64 | ||
|
|
||
| [build.ovmf.x86_64] | ||
| desc = ovmf build (64-bit) | ||
| conf = OvmfPkg/OvmfPkgX64.dsc | ||
| arch = X64 | ||
| opts = common | ||
| plat = OvmfX64 | ||
| dest = ../pc-bios | ||
| cpy1 = FV/OVMF_CODE.fd edk2-x86_64-code.fd | ||
|
|
||
| [build.ovmf.x86_64.secure] | ||
| desc = ovmf build (64-bit, secure boot) | ||
| conf = OvmfPkg/OvmfPkgIa32X64.dsc | ||
| arch = IA32 X64 | ||
| opts = common | ||
| ovmf.sb.smm | ||
| plat = Ovmf3264 | ||
| dest = ../pc-bios | ||
| cpy1 = FV/OVMF_CODE.fd edk2-x86_64-secure-code.fd | ||
|
|
||
| [build.ovmf.microvm] | ||
| desc = ovmf build for microvm | ||
| conf = OvmfPkg/Microvm/MicrovmX64.dsc | ||
| arch = X64 | ||
| opts = common | ||
| plat = MicrovmX64 | ||
| dest = ../pc-bios | ||
| cpy1 = FV/MICROVM.fd edk2-x86_64-microvm.fd | ||
|
|
||
| #################################################################################### | ||
| # arm | ||
|
|
||
| [build.armvirt.arm] | ||
| desc = ArmVirt build, 32-bit (arm v7) | ||
| conf = ArmVirtPkg/ArmVirtQemu.dsc | ||
| arch = ARM | ||
| opts = common | ||
| pcds = nx.broken.grub | ||
| plat = ArmVirtQemu-ARM | ||
| dest = ../pc-bios | ||
| cpy1 = FV/QEMU_EFI.fd edk2-arm-code.fd | ||
| cpy2 = FV/QEMU_VARS.fd edk2-arm-vars.fd | ||
| pad1 = edk2-arm-code.fd 64m | ||
| pad2 = edk2-arm-vars.fd 64m | ||
|
|
||
| #################################################################################### | ||
| # aarch64 | ||
|
|
||
| [build.armvirt.aa64] | ||
| desc = ArmVirt build, 64-bit (arm v8) | ||
| conf = ArmVirtPkg/ArmVirtQemu.dsc | ||
| arch = AARCH64 | ||
| opts = common | ||
| pcds = nx.broken.grub | ||
| plat = ArmVirtQemu-AARCH64 | ||
| dest = ../pc-bios | ||
| cpy1 = FV/QEMU_EFI.fd edk2-aarch64-code.fd | ||
| pad1 = edk2-aarch64-code.fd 64m | ||
|
|
||
| #################################################################################### | ||
| # riscv64 | ||
|
|
||
| [build.riscv.qemu] | ||
| conf = OvmfPkg/RiscVVirt/RiscVVirtQemu.dsc | ||
| arch = RISCV64 | ||
| plat = RiscVVirtQemu | ||
| dest = ../pc-bios | ||
| cpy1 = FV/RISCV_VIRT.fd edk2-riscv.fd | ||
| pad1 = edk2-riscv.fd 32m |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,372 @@ | ||
| #!/usr/bin/python3 | ||
| """ | ||
| build helper script for edk2, see | ||
| https://gitlab.com/kraxel/edk2-build-config | ||
| """ | ||
| import os | ||
| import sys | ||
| import glob | ||
| import shutil | ||
| import optparse | ||
| import subprocess | ||
| import configparser | ||
|
|
||
| rebase_prefix = "" | ||
| version_override = None | ||
| release_date = None | ||
|
|
||
| def check_rebase(): | ||
| """ detect 'git rebase -x edk2-build.py master' testbuilds """ | ||
| global rebase_prefix | ||
| global version_override | ||
| gitdir = '.git' | ||
|
|
||
| if os.path.isfile(gitdir): | ||
| with open(gitdir) as f: | ||
| (unused, gitdir) = f.read().split() | ||
|
|
||
| if not os.path.exists(f'{gitdir}/rebase-merge/msgnum'): | ||
| return "" | ||
| with open(f'{gitdir}/rebase-merge/msgnum', 'r') as f: | ||
| msgnum = int(f.read()) | ||
| with open(f'{gitdir}/rebase-merge/end', 'r') as f: | ||
| end = int(f.read()) | ||
| with open(f'{gitdir}/rebase-merge/head-name', 'r') as f: | ||
| head = f.read().strip().split('/') | ||
|
|
||
| rebase_prefix = f'[ {int(msgnum/2)} / {int(end/2)} - {head[-1]} ] ' | ||
| if msgnum != end and not version_override: | ||
| # fixed version speeds up builds | ||
| version_override = "test-build-patch-series" | ||
|
|
||
| def get_coredir(cfg): | ||
| if cfg.has_option('global', 'core'): | ||
| return os.path.abspath(cfg['global']['core']) | ||
| else: | ||
| return os.getcwd() | ||
|
|
||
| def get_version(cfg): | ||
| coredir = get_coredir(cfg) | ||
| if version_override: | ||
| version = version_override | ||
| print('') | ||
| print(f'### version [override]: {version}') | ||
| return version | ||
| if os.environ.get('RPM_PACKAGE_NAME'): | ||
| version = os.environ.get('RPM_PACKAGE_NAME'); | ||
| version += '-' + os.environ.get('RPM_PACKAGE_VERSION'); | ||
| version += '-' + os.environ.get('RPM_PACKAGE_RELEASE'); | ||
| print('') | ||
| print(f'### version [rpmbuild]: {version}') | ||
| return version | ||
| if os.path.exists(coredir + '/.git'): | ||
| cmdline = [ 'git', 'describe', '--tags', '--abbrev=8', | ||
| '--match=edk2-stable*' ] | ||
| result = subprocess.run(cmdline, cwd = coredir, | ||
| stdout = subprocess.PIPE) | ||
| version = result.stdout.decode().strip() | ||
| print('') | ||
| print(f'### version [git]: {version}') | ||
| return version | ||
| return None | ||
|
|
||
| def pcd_string(name, value): | ||
| return f'{name}=L{value}\\0' | ||
|
|
||
| def pcd_version(cfg): | ||
| version = get_version(cfg) | ||
| if version is None: | ||
| return [] | ||
| return [ '--pcd', pcd_string('PcdFirmwareVersionString', version) ] | ||
|
|
||
| def pcd_release_date(cfg): | ||
| if release_date is None: | ||
| return [] | ||
| return [ '--pcd', pcd_string('PcdFirmwareReleaseDateString', release_date) ] | ||
|
|
||
| def build_message(line, line2 = None): | ||
| if os.environ.get('TERM') in [ 'xterm', 'xterm-256color' ]: | ||
| # setxterm title | ||
| start = '\x1b]2;' | ||
| end = '\x07' | ||
| print(f'{start}{rebase_prefix}{line}{end}', end = '') | ||
|
|
||
| print('') | ||
| print('###') | ||
| print(f'### {rebase_prefix}{line}') | ||
| if line2: | ||
| print(f'### {line2}') | ||
| print('###') | ||
|
|
||
| def build_run(cmdline, name, section, silent = False): | ||
| print(cmdline) | ||
| if silent: | ||
| print('### building in silent mode ...', flush = True) | ||
| result = subprocess.run(cmdline, | ||
| stdout = subprocess.PIPE, | ||
| stderr = subprocess.STDOUT) | ||
|
|
||
| logfile = f'{section}.log' | ||
| print(f'### writing log to {logfile} ...') | ||
| with open(logfile, 'wb') as f: | ||
| f.write(result.stdout) | ||
|
|
||
| if result.returncode: | ||
| print('### BUILD FAILURE') | ||
| print('### output') | ||
| print(result.stdout.decode()) | ||
| print(f'### exit code: {result.returncode}') | ||
| else: | ||
| print('### OK') | ||
| else: | ||
| result = subprocess.run(cmdline) | ||
| if result.returncode: | ||
| print(f'ERROR: {cmdline[0]} exited with {result.returncode}' | ||
| f' while building {name}') | ||
| sys.exit(result.returncode) | ||
|
|
||
| def build_copy(plat, tgt, dstdir, copy): | ||
| srcdir = f'Build/{plat}/{tgt}_GCC5' | ||
| names = copy.split() | ||
| srcfile = names[0] | ||
| if len(names) > 1: | ||
| dstfile = names[1] | ||
| else: | ||
| dstfile = os.path.basename(srcfile) | ||
| print(f'# copy: {srcdir} / {srcfile} => {dstdir} / {dstfile}') | ||
|
|
||
| src = srcdir + '/' + srcfile | ||
| dst = dstdir + '/' + dstfile | ||
| os.makedirs(os.path.dirname(dst), exist_ok = True) | ||
| shutil.copy(src, dst) | ||
|
|
||
| def pad_file(dstdir, pad): | ||
| args = pad.split() | ||
| if len(args) < 2: | ||
| raise RuntimeError(f'missing arg for pad ({args})') | ||
| name = args[0] | ||
| size = args[1] | ||
| cmdline = [ | ||
| 'truncate', | ||
| '--size', size, | ||
| dstdir + '/' + name, | ||
| ] | ||
| print(f'# padding: {dstdir} / {name} => {size}') | ||
| subprocess.run(cmdline) | ||
|
|
||
| def build_one(cfg, build, jobs = None, silent = False): | ||
| cmdline = [ 'build' ] | ||
| cmdline += [ '-t', 'GCC5' ] | ||
| cmdline += [ '-p', cfg[build]['conf'] ] | ||
|
|
||
| if (cfg[build]['conf'].startswith('OvmfPkg/') or | ||
| cfg[build]['conf'].startswith('ArmVirtPkg/')): | ||
| cmdline += pcd_version(cfg) | ||
| cmdline += pcd_release_date(cfg) | ||
|
|
||
| if jobs: | ||
| cmdline += [ '-n', jobs ] | ||
| for arch in cfg[build]['arch'].split(): | ||
| cmdline += [ '-a', arch ] | ||
| if 'opts' in cfg[build]: | ||
| for name in cfg[build]['opts'].split(): | ||
| section = 'opts.' + name | ||
| for opt in cfg[section]: | ||
| cmdline += [ '-D', opt + '=' + cfg[section][opt] ] | ||
| if 'pcds' in cfg[build]: | ||
| for name in cfg[build]['pcds'].split(): | ||
| section = 'pcds.' + name | ||
| for pcd in cfg[section]: | ||
| cmdline += [ '--pcd', pcd + '=' + cfg[section][pcd] ] | ||
| if 'tgts' in cfg[build]: | ||
| tgts = cfg[build]['tgts'].split() | ||
| else: | ||
| tgts = [ 'DEBUG' ] | ||
| for tgt in tgts: | ||
| desc = None | ||
| if 'desc' in cfg[build]: | ||
| desc = cfg[build]['desc'] | ||
| build_message(f'building: {cfg[build]["conf"]} ({cfg[build]["arch"]}, {tgt})', | ||
| f'description: {desc}') | ||
| build_run(cmdline + [ '-b', tgt ], | ||
| cfg[build]['conf'], | ||
| build + '.' + tgt, | ||
| silent) | ||
|
|
||
| if 'plat' in cfg[build]: | ||
| # copy files | ||
| for cpy in cfg[build]: | ||
| if not cpy.startswith('cpy'): | ||
| continue | ||
| build_copy(cfg[build]['plat'], | ||
| tgt, | ||
| cfg[build]['dest'], | ||
| cfg[build][cpy]) | ||
| # pad builds | ||
| for pad in cfg[build]: | ||
| if not pad.startswith('pad'): | ||
| continue | ||
| pad_file(cfg[build]['dest'], | ||
| cfg[build][pad]) | ||
|
|
||
| def build_basetools(silent = False): | ||
| build_message(f'building: BaseTools') | ||
| basedir = os.environ['EDK_TOOLS_PATH'] | ||
| cmdline = [ 'make', '-C', basedir ] | ||
| build_run(cmdline, 'BaseTools', 'build.basetools', silent) | ||
|
|
||
| def binary_exists(name): | ||
| for dir in os.environ['PATH'].split(':'): | ||
| if os.path.exists(dir + '/' + name): | ||
| return True | ||
| return False | ||
|
|
||
| def prepare_env(cfg): | ||
| """ mimic Conf/BuildEnv.sh """ | ||
| workspace = os.getcwd() | ||
| packages = [ workspace, ] | ||
| path = os.environ['PATH'].split(':') | ||
| dirs = [ | ||
| 'BaseTools/Bin/Linux-x86_64', | ||
| 'BaseTools/BinWrappers/PosixLike' | ||
| ] | ||
|
|
||
| if cfg.has_option('global', 'pkgs'): | ||
| for pkgdir in cfg['global']['pkgs'].split(): | ||
| packages.append(os.path.abspath(pkgdir)) | ||
| coredir = get_coredir(cfg) | ||
| if coredir != workspace: | ||
| packages.append(coredir) | ||
|
|
||
| # add basetools to path | ||
| for dir in dirs: | ||
| p = coredir + '/' + dir | ||
| if not os.path.exists(p): | ||
| continue | ||
| if p in path: | ||
| continue | ||
| path.insert(0, p) | ||
|
|
||
| # run edksetup if needed | ||
| toolsdef = coredir + '/Conf/tools_def.txt'; | ||
| if not os.path.exists(toolsdef): | ||
| os.makedirs(os.path.dirname(toolsdef), exist_ok = True) | ||
| build_message('running BaseTools/BuildEnv') | ||
| cmdline = [ 'sh', 'BaseTools/BuildEnv' ] | ||
| subprocess.run(cmdline, cwd = coredir) | ||
|
|
||
| # set variables | ||
| os.environ['PATH'] = ':'.join(path) | ||
| os.environ['PACKAGES_PATH'] = ':'.join(packages) | ||
| os.environ['WORKSPACE'] = workspace | ||
| os.environ['EDK_TOOLS_PATH'] = coredir + '/BaseTools' | ||
| os.environ['CONF_PATH'] = coredir + '/Conf' | ||
| os.environ['PYTHON_COMMAND'] = '/usr/bin/python3' | ||
| os.environ['PYTHONHASHSEED'] = '1' | ||
|
|
||
| # for cross builds | ||
| if binary_exists('arm-linux-gnu-gcc'): | ||
| os.environ['GCC5_ARM_PREFIX'] = 'arm-linux-gnu-' | ||
| if binary_exists('loongarch64-linux-gnu-gcc'): | ||
| os.environ['GCC5_LOONGARCH64_PREFIX'] = 'loongarch64-linux-gnu-' | ||
|
|
||
| hostarch = os.uname().machine | ||
| if binary_exists('aarch64-linux-gnu-gcc') and hostarch != 'aarch64': | ||
| os.environ['GCC5_AARCH64_PREFIX'] = 'aarch64-linux-gnu-' | ||
| if binary_exists('riscv64-linux-gnu-gcc') and hostarch != 'riscv64': | ||
| os.environ['GCC5_RISCV64_PREFIX'] = 'riscv64-linux-gnu-' | ||
| if binary_exists('x86_64-linux-gnu-gcc') and hostarch != 'x86_64': | ||
| os.environ['GCC5_IA32_PREFIX'] = 'x86_64-linux-gnu-' | ||
| os.environ['GCC5_X64_PREFIX'] = 'x86_64-linux-gnu-' | ||
| os.environ['GCC5_BIN'] = 'x86_64-linux-gnu-' | ||
|
|
||
| def build_list(cfg): | ||
| for build in cfg.sections(): | ||
| if not build.startswith('build.'): | ||
| continue | ||
| name = build.lstrip('build.') | ||
| desc = 'no description' | ||
| if 'desc' in cfg[build]: | ||
| desc = cfg[build]['desc'] | ||
| print(f'# {name:20s} - {desc}') | ||
|
|
||
| def main(): | ||
| parser = optparse.OptionParser() | ||
| parser.add_option('-c', '--config', dest = 'configfile', | ||
| type = 'string', default = '.edk2.builds', metavar = 'FILE', | ||
| help = 'read configuration from FILE (default: .edk2.builds)') | ||
| parser.add_option('-C', '--directory', dest = 'directory', type = 'string', | ||
| help = 'change to DIR before building', metavar = 'DIR') | ||
| parser.add_option('-j', '--jobs', dest = 'jobs', type = 'string', | ||
| help = 'allow up to JOBS parallel build jobs', | ||
| metavar = 'JOBS') | ||
| parser.add_option('-m', '--match', dest = 'match', type = 'string', | ||
| help = 'only run builds matching INCLUDE (substring)', | ||
| metavar = 'INCLUDE') | ||
| parser.add_option('-x', '--exclude', dest = 'exclude', type = 'string', | ||
| help = 'skip builds matching EXCLUDE (substring)', | ||
| metavar = 'EXCLUDE') | ||
| parser.add_option('-l', '--list', dest = 'list', | ||
| action = 'store_true', default = False, | ||
| help = 'list build configs available') | ||
| parser.add_option('--silent', dest = 'silent', | ||
| action = 'store_true', default = False, | ||
| help = 'write build output to logfiles, ' | ||
| 'write to console only on errors') | ||
| parser.add_option('--core', dest = 'core', type = 'string', metavar = 'DIR', | ||
| help = 'location of the core edk2 repository ' | ||
| '(i.e. where BuildTools are located)') | ||
| parser.add_option('--pkg', '--package', dest = 'pkgs', | ||
| type = 'string', action = 'append', metavar = 'DIR', | ||
| help = 'location(s) of additional packages ' | ||
| '(can be specified multiple times)') | ||
| parser.add_option('--version-override', dest = 'version_override', | ||
| type = 'string', metavar = 'VERSION', | ||
| help = 'set firmware build version') | ||
| parser.add_option('--release-date', dest = 'release_date', | ||
| type = 'string', metavar = 'DATE', | ||
| help = 'set firmware build release date (in MM/DD/YYYY format)') | ||
| (options, args) = parser.parse_args() | ||
|
|
||
| if options.directory: | ||
| os.chdir(options.directory) | ||
|
|
||
| cfg = configparser.ConfigParser() | ||
| cfg.optionxform = str | ||
| cfg.read(options.configfile) | ||
|
|
||
| if options.list: | ||
| build_list(cfg) | ||
| return | ||
|
|
||
| if not cfg.has_section('global'): | ||
| cfg.add_section('global') | ||
| if options.core: | ||
| cfg.set('global', 'core', options.core) | ||
| if options.pkgs: | ||
| cfg.set('global', 'pkgs', ' '.join(options.pkgs)) | ||
|
|
||
| global version_override | ||
| global release_date | ||
| check_rebase() | ||
| if options.version_override: | ||
| version_override = options.version_override | ||
| if options.release_date: | ||
| release_date = options.release_date | ||
|
|
||
| prepare_env(cfg) | ||
| build_basetools(options.silent) | ||
| for build in cfg.sections(): | ||
| if not build.startswith('build.'): | ||
| continue | ||
| if options.match and options.match not in build: | ||
| print(f'# skipping "{build}" (not matching "{options.match}")') | ||
| continue | ||
| if options.exclude and options.exclude in build: | ||
| print(f'# skipping "{build}" (matching "{options.exclude}")') | ||
| continue | ||
| build_one(cfg, build, options.jobs, options.silent) | ||
|
|
||
| if __name__ == '__main__': | ||
| sys.exit(main()) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,252 @@ | ||
| #!/usr/bin/env python3 | ||
|
|
||
| ## | ||
| ## Copyright(c) 2022-2023 Qualcomm Innovation Center, Inc. All Rights Reserved. | ||
| ## | ||
| ## This program is free software; you can redistribute it and/or modify | ||
| ## it under the terms of the GNU General Public License as published by | ||
| ## the Free Software Foundation; either version 2 of the License, or | ||
| ## (at your option) any later version. | ||
| ## | ||
| ## This program is distributed in the hope that it will be useful, | ||
| ## but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| ## GNU General Public License for more details. | ||
| ## | ||
| ## You should have received a copy of the GNU General Public License | ||
| ## along with this program; if not, see <http://www.gnu.org/licenses/>. | ||
| ## | ||
|
|
||
| import sys | ||
| import re | ||
| import string | ||
| import hex_common | ||
|
|
||
| ## | ||
| ## Helpers for gen_analyze_func | ||
| ## | ||
| def is_predicated(tag): | ||
| return 'A_CONDEXEC' in hex_common.attribdict[tag] | ||
|
|
||
| def analyze_opn_old(f, tag, regtype, regid, regno): | ||
| regN = "%s%sN" % (regtype, regid) | ||
| predicated = "true" if is_predicated(tag) else "false" | ||
| if (regtype == "R"): | ||
| if (regid in {"ss", "tt"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"dd", "ee", "xx", "yy"}): | ||
| f.write(" const int %s = insn->regno[%d];\n" % (regN, regno)) | ||
| f.write(" ctx_log_reg_write_pair(ctx, %s, %s);\n" % \ | ||
| (regN, predicated)) | ||
| elif (regid in {"s", "t", "u", "v"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"d", "e", "x", "y"}): | ||
| f.write(" const int %s = insn->regno[%d];\n" % (regN, regno)) | ||
| f.write(" ctx_log_reg_write(ctx, %s, %s);\n" % \ | ||
| (regN, predicated)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "P"): | ||
| if (regid in {"s", "t", "u", "v"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"d", "e", "x"}): | ||
| f.write(" const int %s = insn->regno[%d];\n" % (regN, regno)) | ||
| f.write(" ctx_log_pred_write(ctx, %s);\n" % (regN)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "C"): | ||
| if (regid == "ss"): | ||
| f.write("// const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \ | ||
| (regN, regno)) | ||
| elif (regid == "dd"): | ||
| f.write(" const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \ | ||
| (regN, regno)) | ||
| f.write(" ctx_log_reg_write_pair(ctx, %s, %s);\n" % \ | ||
| (regN, predicated)) | ||
| elif (regid == "s"): | ||
| f.write("// const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \ | ||
| (regN, regno)) | ||
| elif (regid == "d"): | ||
| f.write(" const int %s = insn->regno[%d] + HEX_REG_SA0;\n" % \ | ||
| (regN, regno)) | ||
| f.write(" ctx_log_reg_write(ctx, %s, %s);\n" % \ | ||
| (regN, predicated)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "M"): | ||
| if (regid == "u"): | ||
| f.write("// const int %s = insn->regno[%d];\n"% \ | ||
| (regN, regno)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "V"): | ||
| newv = "EXT_DFL" | ||
| if (hex_common.is_new_result(tag)): | ||
| newv = "EXT_NEW" | ||
| elif (hex_common.is_tmp_result(tag)): | ||
| newv = "EXT_TMP" | ||
| if (regid in {"dd", "xx"}): | ||
| f.write(" const int %s = insn->regno[%d];\n" %\ | ||
| (regN, regno)) | ||
| f.write(" ctx_log_vreg_write_pair(ctx, %s, %s, %s);\n" % \ | ||
| (regN, newv, predicated)) | ||
| elif (regid in {"uu", "vv"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"s", "u", "v", "w"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"d", "x", "y"}): | ||
| f.write(" const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| f.write(" ctx_log_vreg_write(ctx, %s, %s, %s);\n" % \ | ||
| (regN, newv, predicated)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "Q"): | ||
| if (regid in {"d", "e", "x"}): | ||
| f.write(" const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| f.write(" ctx_log_qreg_write(ctx, %s);\n" % (regN)) | ||
| elif (regid in {"s", "t", "u", "v"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "G"): | ||
| if (regid in {"dd"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"d"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"ss"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"s"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "S"): | ||
| if (regid in {"dd"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"d"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"ss"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| elif (regid in {"s"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
|
|
||
| def analyze_opn_new(f, tag, regtype, regid, regno): | ||
| regN = "%s%sN" % (regtype, regid) | ||
| if (regtype == "N"): | ||
| if (regid in {"s", "t"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "P"): | ||
| if (regid in {"t", "u", "v"}): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| elif (regtype == "O"): | ||
| if (regid == "s"): | ||
| f.write("// const int %s = insn->regno[%d];\n" % \ | ||
| (regN, regno)) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid) | ||
|
|
||
| def analyze_opn(f, tag, regtype, regid, toss, numregs, i): | ||
| if (hex_common.is_pair(regid)): | ||
| analyze_opn_old(f, tag, regtype, regid, i) | ||
| elif (hex_common.is_single(regid)): | ||
| if hex_common.is_old_val(regtype, regid, tag): | ||
| analyze_opn_old(f,tag, regtype, regid, i) | ||
| elif hex_common.is_new_val(regtype, regid, tag): | ||
| analyze_opn_new(f, tag, regtype, regid, i) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid, toss, numregs) | ||
| else: | ||
| print("Bad register parse: ", regtype, regid, toss, numregs) | ||
|
|
||
| ## | ||
| ## Generate the code to analyze the instruction | ||
| ## For A2_add: Rd32=add(Rs32,Rt32), { RdV=RsV+RtV;} | ||
| ## We produce: | ||
| ## static void analyze_A2_add(DisasContext *ctx) | ||
| ## { | ||
| ## Insn *insn G_GNUC_UNUSED = ctx->insn; | ||
| ## const int RdN = insn->regno[0]; | ||
| ## ctx_log_reg_write(ctx, RdN, false); | ||
| ## // const int RsN = insn->regno[1]; | ||
| ## // const int RtN = insn->regno[2]; | ||
| ## } | ||
| ## | ||
| def gen_analyze_func(f, tag, regs, imms): | ||
| f.write("static void analyze_%s(DisasContext *ctx)\n" %tag) | ||
| f.write('{\n') | ||
|
|
||
| f.write(" Insn *insn G_GNUC_UNUSED = ctx->insn;\n") | ||
|
|
||
| i=0 | ||
| ## Analyze all the registers | ||
| for regtype, regid, toss, numregs in regs: | ||
| analyze_opn(f, tag, regtype, regid, toss, numregs, i) | ||
| i += 1 | ||
|
|
||
| has_generated_helper = (not hex_common.skip_qemu_helper(tag) and | ||
| not hex_common.is_idef_parser_enabled(tag)) | ||
| if (has_generated_helper and | ||
| 'A_SCALAR_LOAD' in hex_common.attribdict[tag]): | ||
| f.write(" ctx->need_pkt_has_store_s1 = true;\n") | ||
|
|
||
| f.write("}\n\n") | ||
|
|
||
| def main(): | ||
| hex_common.read_semantics_file(sys.argv[1]) | ||
| hex_common.read_attribs_file(sys.argv[2]) | ||
| hex_common.read_overrides_file(sys.argv[3]) | ||
| hex_common.read_overrides_file(sys.argv[4]) | ||
| ## Whether or not idef-parser is enabled is | ||
| ## determined by the number of arguments to | ||
| ## this script: | ||
| ## | ||
| ## 5 args. -> not enabled, | ||
| ## 6 args. -> idef-parser enabled. | ||
| ## | ||
| ## The 6:th arg. then holds a list of the successfully | ||
| ## parsed instructions. | ||
| is_idef_parser_enabled = len(sys.argv) > 6 | ||
| if is_idef_parser_enabled: | ||
| hex_common.read_idef_parser_enabled_file(sys.argv[5]) | ||
| hex_common.calculate_attribs() | ||
| tagregs = hex_common.get_tagregs() | ||
| tagimms = hex_common.get_tagimms() | ||
|
|
||
| with open(sys.argv[-1], 'w') as f: | ||
| f.write("#ifndef HEXAGON_TCG_FUNCS_H\n") | ||
| f.write("#define HEXAGON_TCG_FUNCS_H\n\n") | ||
|
|
||
| for tag in hex_common.tags: | ||
| gen_analyze_func(f, tag, tagregs[tag], tagimms[tag]) | ||
|
|
||
| f.write("#endif /* HEXAGON_TCG_FUNCS_H */\n") | ||
|
|
||
| if __name__ == "__main__": | ||
| main() |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,7 +82,6 @@ enum ImmUnionTag { | |
| VALUE, | ||
| QEMU_TMP, | ||
| IMM_PC, | ||
| IMM_CONSTEXT, | ||
| }; | ||
|
|
||
|
|
||