From: "Sami Mujawar" <sami.mujawar@arm.com>
To: <devel@edk2.groups.io>
Cc: Sami Mujawar <sami.mujawar@arm.com>, <Alexei.Fedorov@arm.com>,
<pierre.gondois@arm.com>, <ard.biesheuvel@arm.com>,
<Matteo.Carlini@arm.com>, <Ben.Adderson@arm.com>, <nd@arm.com>
Subject: [PATCH v1 02/30] DynamicTablesPkg: AmlLib definitions
Date: Wed, 12 Aug 2020 16:22:08 +0100 [thread overview]
Message-ID: <20200812152236.31164-3-sami.mujawar@arm.com> (raw)
In-Reply-To: <20200812152236.31164-1-sami.mujawar@arm.com>
From: Pierre Gondois <pierre.gondois@arm.com>
Dynamic AML is a solution to generate Definition Block tables
at runtime. Dynamic AML provides the following techniques for
generating AML tables.
- AML Fixup
- AML Codegen
- AML Fixup + Codegen
AML fixup involves patching small sections of a template AML
code at runtime, while AML Codegen provides APIs to generate
small sections of AML code at runtime. A combination of
Fixup and Codegen can also be used.
AML has a complex grammar. To simplify the generation of
AML tables, Dynamic AML introduces AmlLib that provides a
rich set of APIs for parsing, traversing, fixup, codegen
and serialisation of AML byte code.
This patch introduces the definitions used by AmlLib.
Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
---
DynamicTablesPkg/Library/Common/AmlLib/AmlDefines.h | 188 ++++++++++++++++++++
DynamicTablesPkg/Library/Common/AmlLib/AmlInclude.h | 18 ++
2 files changed, 206 insertions(+)
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/AmlDefines.h b/DynamicTablesPkg/Library/Common/AmlLib/AmlDefines.h
new file mode 100644
index 0000000000000000000000000000000000000000..cbae14d78802005c9b7610e8085a484610e8b18f
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/AmlLib/AmlDefines.h
@@ -0,0 +1,188 @@
+/** @file
+ AML Defines.
+
+ Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef AML_DEFINES_H_
+#define AML_DEFINES_H_
+
+/**
+ @defgroup TreeStructures Tree structures
+ @ingroup AMLLib
+ @{
+ The AML tree created by the AMLLib relies on enum/define values and
+ structures defined here.
+ @}
+*/
+
+/** AML tree node types.
+
+ Data nodes are tagged with the data type they contain.
+ Some data types cannot be used for data nodes (None, Object).
+ EAmlUIntX types are converted to the EAML_NODE_DATA_TYPE enum type.
+ These types are accessible externally.
+
+ @ingroup TreeStructures
+*/
+typedef enum EAmlNodeDataType {
+ EAmlNodeDataTypeNone = 0, ///< EAmlNone, not accessible.
+ EAmlNodeDataTypeReserved1, ///< EAmlUInt8, converted to the UInt type.
+ EAmlNodeDataTypeReserved2, ///< EAmlUInt16, converted to the UInt type.
+ EAmlNodeDataTypeReserved3, ///< EAmlUInt32, converted to the UInt type.
+ EAmlNodeDataTypeReserved4, ///< EAmlUInt64, converted to the UInt type.
+ EAmlNodeDataTypeReserved5, ///< EAmlObject, not accessible.
+ EAmlNodeDataTypeNameString, ///< EAmlName, name corresponding to the
+ /// NameString keyword in the ACPI
+ /// specification. E.g.: "\_SB_.DEV0"
+ EAmlNodeDataTypeString, ///< EAmlString, NULL terminated string.
+ EAmlNodeDataTypeUInt, ///< Integer data of any length, EAmlUIntX
+ /// are converted to this type.
+ EAmlNodeDataTypeRaw, ///< Raw bytes contained in a buffer.
+ EAmlNodeDataTypeResourceData, ///< Resource data element.
+ EAmlNodeDataTypeFieldPkgLen, ///< FieldPkgLen data element.
+ /// PkgLen are usually stored as
+ /// part of object node structures.
+ /// However, they can be found
+ /// standalone in a FieldList.
+ EAmlNodeDataTypeMax ///< Max enum.
+} EAML_NODE_DATA_TYPE;
+
+/** Indexes of fixed arguments.
+
+ AML objects defined the ACPI 6.3 specification,
+ s20.3 "AML Byte Stream Byte Values" can have at most 6 fixed arguments.
+
+ Method and functions can have at most 7 arguments, cf
+ s19.6.83 "Method (Declare Control Method)". The enum goes to 8 to store the
+ name of the method invocation.
+
+ @ingroup TreeStructures
+*/
+typedef enum EAmlParseIndex {
+ EAmlParseIndexTerm0 = 0, ///< First fixed argument index.
+ EAmlParseIndexTerm1, ///< Second fixed argument index.
+ EAmlParseIndexTerm2, ///< Third fixed argument index.
+ EAmlParseIndexTerm3, ///< Fourth fixed argument index.
+ EAmlParseIndexTerm4, ///< Fifth fixed argument index.
+ EAmlParseIndexTerm5, ///< Sixth fixed argument index.
+ EAmlParseIndexMax ///< Maximum fixed argument index (=6).
+} EAML_PARSE_INDEX;
+
+/** Maximum size of an AML NameString.
+
+ An AML NameString can be at most (255 * 4) + 255 + 2 = 1277 bytes long.
+ Indeed, according to ACPI 6.3 specification, s20.2.2,
+ an AML NameString can be resolved as a MultiNamePath.
+
+ The encoding of this MultiNamePath can be made of at most:
+ - 255 carets ('^'), one for each level in the namespace;
+ - 255 NameSeg of 4 bytes;
+ - 2 bytes for the MultiNamePrefix and SegCount.
+
+ @ingroup TreeStructures
+*/
+#define MAX_AML_NAMESTRING_SIZE 1277U
+
+/** Maximum size of an ASL NameString.
+
+ An ASL NameString can be at most (255 * 4) + 255 + 254 = 1529 bytes long.
+ Cf the ASL grammar available in ACPI 6.3 specification, 19.2.2.
+
+ The encoding of an ASL NameString can be made of at most:
+ - 255 carets ('^'), one for each level in the namespace;
+ - 255 NameSeg of 4 bytes;
+ - 254 NameSeg separators ('.').
+
+ @ingroup TreeStructures
+*/
+#define MAX_ASL_NAMESTRING_SIZE 1529U
+
+/** Pseudo OpCode for method invocations.
+
+ The AML grammar does not attribute an OpCode/SubOpCode couple for
+ method invocations. This library is representing method invocations
+ as if they had one.
+
+ The AML encoding for method invocations in the ACPI specification 6.3 is:
+ MethodInvocation := NameString TermArgList
+ In this library, it is:
+ MethodInvocation := MethodInvocationOp NameString ArgumentCount TermArgList
+ ArgumentCount := ByteData
+
+ When computing the size of a tree or serializing it, the additional data is
+ not taken into account (i.e. the MethodInvocationOp and the ArgumentCount).
+
+ @ingroup TreeStructures
+*/
+#define AML_METHOD_INVOC_OP 0xD0
+
+/** Pseudo OpCode for NamedField field elements.
+
+ The AML grammar does not attribute an OpCode/SubOpCode couple for
+ the NamedField field element. This library is representing NamedField field
+ elements as if they had one.
+
+ The AML encoding for NamedField field elements in the ACPI specification 6.3
+ is:
+ NamedField := NameSeg PkgLength
+ In this library, it is:
+ NamedField := NamedFieldOp NameSeg PkgLength
+
+ When computing the size of a tree or serializing it, the additional data is
+ not taken into account (i.e. the NamedFieldOp).
+
+ @ingroup TreeStructures
+*/
+#define AML_FIELD_NAMED_OP 0x04
+
+/** Size of a NameSeg.
+ Cf. ACPI 6.3 specification, s20.2.
+
+ @ingroup TreeStructures
+*/
+ #define AML_NAME_SEG_SIZE 4U
+
+/** AML object types.
+
+ The ACPI specification defines several object types. They are listed
+ with the definition of ObjectTypeKeyword.
+
+ @ingroup TreeStructures
+*/
+typedef enum EAmlObjType {
+ EAmlObjTypeUnknown = 0x0,
+ EAmlObjTypeInt,
+ EAmlObjTypeStrObj,
+ EAmlObjTypeBuffObj,
+ EAmlObjTypePkgObj,
+ EAmlObjTypeFieldUnitObj,
+ EAmlObjTypeDeviceObj,
+ EAmlObjTypeEventObj,
+ EAmlObjTypeMethodObj,
+ EAmlObjTypeMutexObj,
+ EAmlObjTypeOpRegionObj,
+ EAmlObjTypePowerResObj,
+ EAmlObjTypeProcessorObj,
+ EAmlObjTypeThermalZoneObj,
+ EAmlObjTypeBuffFieldObj,
+ EAmlObjTypeDDBHandleObj,
+} EAML_OBJ_TYPE;
+
+/** Node types.
+
+ @ingroup TreeStructures
+*/
+typedef enum EAmlNodeType {
+ EAmlNodeUnknown, ///< Unknown/Invalid AML Node Type.
+ EAmlNodeRoot, ///< AML Root Node, typically represents a DefinitionBlock.
+ EAmlNodeObject, ///< AML Object Node, typically represents an ASL statement
+ /// or its arguments.
+ EAmlNodeData, ///< AML Data Node, typically represents arguments for an
+ /// ASL statement.
+ EAmlNodeMax ///< Max enum.
+} EAML_NODE_TYPE;
+
+#endif // AML_DEFINES_H_
diff --git a/DynamicTablesPkg/Library/Common/AmlLib/AmlInclude.h b/DynamicTablesPkg/Library/Common/AmlLib/AmlInclude.h
new file mode 100644
index 0000000000000000000000000000000000000000..274482f0d1244cdabc5436c5542a2b829083ae93
--- /dev/null
+++ b/DynamicTablesPkg/Library/Common/AmlLib/AmlInclude.h
@@ -0,0 +1,18 @@
+/** @file
+ AML Include file
+
+ Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.<BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef AML_INCLUDE_H_
+#define AML_INCLUDE_H_
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
+
+#endif // AML_INCLUDE_H_
--
'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'
next prev parent reply other threads:[~2020-08-12 15:23 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-12 15:22 [PATCH v1 00/30] Add Dynamic AML generation support Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 01/30] DynamicTablesPkg: Introduction to Dynamic AML Sami Mujawar
2020-08-12 15:22 ` Sami Mujawar [this message]
2020-08-12 15:22 ` [PATCH v1 03/30] DynamicTablesPkg: AML grammar definition Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 04/30] DynamicTablesPkg: AML node definitions Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 05/30] DynamicTablesPkg: AML tree interface Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 06/30] DynamicTablesPkg: AML tree enumerator Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 07/30] DynamicTablesPkg: AML tree traversal Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 08/30] DynamicTablesPkg: AML tree iterator Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 09/30] DynamicTablesPkg: AML tree/node cloning Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 10/30] DynamicTablesPkg: AML utility interfaces Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 11/30] DynamicTablesPkg: AML and ASL string helper Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 12/30] DynamicTablesPkg: AML stream interface Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 13/30] DynamicTablesPkg: AML serialise interface Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 14/30] DynamicTablesPkg: AML debug logging Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 15/30] DynamicTablesPkg: AML ACPI Namespace interface Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 16/30] DynamicTablesPkg: AML Parser Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 17/30] DynamicTablesPkg: AML resource data helper Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 18/30] DynamicTablesPkg: AML resource data parser Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 19/30] DynamicTablesPkg: AML Method parser Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 20/30] DynamicTablesPkg: AML Field list parser Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 21/30] DynamicTablesPkg: AML Codegen Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 22/30] DynamicTablesPkg: AML Resource Data Codegen Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 23/30] DynamicTablesPkg: AML Core interface Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 24/30] DynamicTablesPkg: AmlLib APIs Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 25/30] DynamicTablesPkg: Dynamic AML: Add AmlLib library Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 26/30] DynamicTablesPkg: Add AsciiFromHex helper function Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 27/30] DynamicTablesPkg: SSDT Serial Port Fixup library Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 28/30] DynamicTablesPkg: SSDT Serial Port generator Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 29/30] DynamicTablesPkg: Add SSDT Serial port for SPCR Sami Mujawar
2020-08-12 15:22 ` [PATCH v1 30/30] DynamicTablesPkg: Add SSDT Serial port for DBG2 Sami Mujawar
2020-08-13 15:16 ` [edk2-devel] [PATCH v1 00/30] Add Dynamic AML generation support Alexei Fedorov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200812152236.31164-3-sami.mujawar@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox