From: Dmitry Selyutin Date: Tue, 19 Sep 2023 17:14:20 +0000 (+0300) Subject: syscalls: support identifiers lookup X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=69b1ac09c26238cfdf615d1689413b7e22ad254b;p=openpower-isa.git syscalls: support identifiers lookup --- diff --git a/src/openpower/syscalls/__init__.py b/src/openpower/syscalls/__init__.py index 9f3e8474..053e45f3 100644 --- a/src/openpower/syscalls/__init__.py +++ b/src/openpower/syscalls/__init__.py @@ -54,6 +54,15 @@ class Dispatcher: return super().__init__() + def __getitem__(self, identifier): + if not isinstance(identifier, int): + raise ValueError(identifier) + + identifier = str(identifier) + entry = self.__guest[identifier][1][0] + + return getattr(self, entry) + def __getattr__(self, entry): if entry.startswith("compat_sys_"): identifier = entry[len("compat_sys_"):] @@ -98,11 +107,6 @@ class Dispatcher: return syscall def __call__(self, identifier, *arguments): - if not isinstance(identifier, int): - raise ValueError(identifier) - - identifier = str(identifier) - entry = self.__guest[identifier][1][0] - syscall = getattr(self, entry) + syscall = self[identifier] return syscall(*arguments)