From: Dmitry Selyutin Date: Mon, 23 Oct 2023 20:32:57 +0000 (+0300) Subject: syscall: handle architecture aliases X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=refs%2Fheads%2Fscemu;p=openpower-isa.git syscall: handle architecture aliases --- diff --git a/src/openpower/syscalls/__init__.py b/src/openpower/syscalls/__init__.py index a7676a20..fcf247a9 100644 --- a/src/openpower/syscalls/__init__.py +++ b/src/openpower/syscalls/__init__.py @@ -5,6 +5,21 @@ import json import pathlib + +ARCH = { + "powerpc": "ppc", + "powerpc64": "ppc64", + "ppc64le": "ppc64", + "i686": "i386", + "x86_64": "amd64", + "x64": "amd64", + "arm64": "aarch64", + "aarch64_be": "aarch64", + "armv8b": "aarch64", + "armv8l": "aarch64", +} + + class Syscall: def __init__(self, entry, guest, host, parameters): if not isinstance(entry, str): @@ -90,6 +105,9 @@ class Dispatcher: if logger is None: logger = lambda *args, **kwargs: None + guest = ARCH.get(guest, guest) + host = ARCH.get(host, host) + def i386(sysnums): yield from sysnums["x86-32"]["i386"].items() diff --git a/src/openpower/syscalls/__main__.py b/src/openpower/syscalls/__main__.py index 7c6e2bdf..3165e1a3 100644 --- a/src/openpower/syscalls/__main__.py +++ b/src/openpower/syscalls/__main__.py @@ -6,6 +6,7 @@ import pathlib import re +from . import ARCH from . import Dispatcher from . import UnknownSyscall @@ -247,7 +248,6 @@ class ECallGenerator: self.print("}") - def main(): main_parser = argparse.ArgumentParser("lscmg", description="Linux system calls mapping generator") @@ -262,10 +262,10 @@ def main(): ecall_parser = main_subparsers.add_parser("ecall") ecall_parser.add_argument("guest", help="guest architecture", - choices=("riscv64", "ppc", "ppc64")) + type=lambda arch: ARCH.get(arch, arch)) ecall_parser.add_argument("host", help="amd64 architecture", - choices=("amd64", "arm", "aarch64")) + type=lambda arch: ARCH.get(arch, arch)) ecall_parser.set_defaults(generate=ECallGenerator()) arguments = dict(vars(main_parser.parse_args()))