From 6ccd7660a4d95eeec76905c96797dbc5768f0a17 Mon Sep 17 00:00:00 2001 From: Junjie Mao Date: Mon, 2 Aug 2021 16:11:32 +0800 Subject: [PATCH] board_inspector: add object_type codes in Decls Object type codes are used to identify, as the name suggests, type of objects. Typical object types in AML include integers, strings, methods, devices, buffers, packages and operation regions. In DefExternal terms the object type codes help specify the type of the external objects so that an AML parser can parse the code without knowing the concrete definition of these objects. The per-device AML templates in board XMLs need DefExternal terms to declare the objects in other devices, as these templates are meant to be parsed and integrated separately. This patch adds a static method to object declaration classes to make it easier to generate such DefExternal terms for a given declaration. A complete definition of object type codes can be found in section 19.6.96 of ACPI specification 6.4. v1 -> v2: * Remove the object_type of FieldDecl and OperationFieldDecl as 0x5 is not a proper object type for buffer fields. Tracked-On: #6287 Signed-off-by: Junjie Mao --- .../board_inspector/acpiparser/aml/context.py | 16 ++++++++++++++++ .../board_inspector/acpiparser/aml/parser.py | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/misc/config_tools/board_inspector/acpiparser/aml/context.py b/misc/config_tools/board_inspector/acpiparser/aml/context.py index 075379340..ebb0dfe9d 100644 --- a/misc/config_tools/board_inspector/acpiparser/aml/context.py +++ b/misc/config_tools/board_inspector/acpiparser/aml/context.py @@ -11,6 +11,10 @@ from .exception import * from .stream import Stream class NamedDecl: + @staticmethod + def object_type(): + return 0 + def __init__(self, name, tree): self.tree = tree self.name = name @@ -66,6 +70,10 @@ class AliasDecl(NamedDecl): print(f"{self.name}: {self.__class__.__name__}, aliasing {self.source}") class MethodDecl(NamedDecl): + @staticmethod + def object_type(): + return 8 + def __init__(self, name, nargs, tree): super().__init__(name, tree) self.nargs = nargs @@ -74,6 +82,10 @@ class MethodDecl(NamedDecl): print(f"{self.name}: {self.__class__.__name__}, {self.nargs} args") class PredefinedMethodDecl(NamedDecl): + @staticmethod + def object_type(): + return 8 + def __init__(self, name, nargs, fn): super().__init__(name, None) self.nargs = nargs @@ -83,6 +95,10 @@ class PredefinedMethodDecl(NamedDecl): print(f"{self.name}: {self.__class__.__name__}, {self.nargs} args") class DeviceDecl(NamedDecl): + @staticmethod + def object_type(): + return 6 + def __init__(self, name, tree): super().__init__(name, tree) diff --git a/misc/config_tools/board_inspector/acpiparser/aml/parser.py b/misc/config_tools/board_inspector/acpiparser/aml/parser.py index 6fcbf153b..324a17028 100644 --- a/misc/config_tools/board_inspector/acpiparser/aml/parser.py +++ b/misc/config_tools/board_inspector/acpiparser/aml/parser.py @@ -501,7 +501,7 @@ def DefExternal_hook_post(context, tree): ty = tree.ObjectType.value nargs = tree.ArgumentCount.value - if ty == 0x8: # an external method + if ty == MethodDecl.object_type(): sym = MethodDecl(name, nargs, tree) else: sym = NamedDecl(name, tree)