syscall: handle architecture aliases scemu
authorDmitry Selyutin <ghostmansd@gmail.com>
Mon, 23 Oct 2023 20:32:57 +0000 (23:32 +0300)
committerDmitry Selyutin <ghostmansd@gmail.com>
Mon, 23 Oct 2023 20:32:57 +0000 (23:32 +0300)
src/openpower/syscalls/__init__.py
src/openpower/syscalls/__main__.py

index a7676a20acf055f02b6055c1c1ae03c1a29a9d7f..fcf247a928e0b24aac918b2be044ba1a372ec0b1 100644 (file)
@@ -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()
 
index 7c6e2bdf49f536c573242918ca7481cb3b89de89..3165e1a3a5b980f1718b8ccd6898b115903674bd 100644 (file)
@@ -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()))