mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
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 <junjie.mao@intel.com>
This commit is contained in:
parent
d58ef5e2aa
commit
6ccd7660a4
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user