]> git.proxmox.com Git - mirror_edk2.git/commitdiff
DynamicTablesPkg: Introduction to Dynamic AML
authorSami Mujawar <sami.mujawar@arm.com>
Tue, 28 Jul 2020 13:19:18 +0000 (14:19 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Thu, 13 Aug 2020 18:00:06 +0000 (18:00 +0000)
ACPI Definition block (e.g. DSDT or SSDT) tables are implemented
using ACPI source language (ASL) and compiled to ACPI Machine
language (AML). The AML bytecode runs in the OS ACPI Interpreter.
AML has a complex grammar which makes generation of ACPI Definition
block tables difficult.

Dynamic Tables Framework introduces a new feature 'Dynamic AML' that
aims at simplifying the generation of ACPI Definition block tables.

Dynamic AML provides the following techniques for generating ACPI
Definition blocks.
  - AML Fixup
  - AML Codegen
  - AML Fixup + Codegen

AML Fixup involves patching an AML template code at runtime and then
installing the fixed-up AML code as an ACPI table.

AML Codegen provides APIs to generate small segments of AML code that
can be serialised for installation as an ACPI table.

AML Fixup + Codegen is an approach where parts of an AML template are
fixed-up at runtime as well as the AML Codegen APIs are used to insert
small segments of AML code in the AML template. This AML code is then
serialised for installation as an ACPI table.

To assist Dynamic AML generation an AmlLib library is introduced that
provides a rich set of APIs that can be used to parse, traverse, fixup,
codegen and serialise AML definition blocks.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
DynamicTablesPkg/Readme.md

index 34000cf73bc7da5fce2e520d41318af908353969..5f92d4c6cb2efd77bbc3306f827088216b7a32e0 100644 (file)
@@ -1,5 +1,4 @@
-Dynamic Tables Framework\r
-------------------------\r
+# Dynamic Tables Framework\r
 \r
 Dynamic Tables Framework provides mechanisms to reduce the amount\r
 of effort required in porting firmware to new platforms. The aim is\r
@@ -10,8 +9,8 @@ be generated from the system construction.  This initial release
 does not fully implement that - the configuration is held in local\r
 UEFI modules.\r
 \r
-Feature Summary\r
----------------\r
+Feature Summary\r
+\r
 The dynamic tables framework is designed to generate standardised\r
 firmware tables that describe the hardware information at\r
 run-time. A goal of standardised firmware is to have a common\r
@@ -58,8 +57,105 @@ The framework currently supports the following table generators for ARM:
 * SSDT - Secondary System Description Table. This is essentially\r
          a RAW table generator.\r
 \r
-Roadmap\r
--------\r
+## Dynamic AML\r
+\r
+ACPI Definition block (e.g. DSDT or SSDT) tables are used to describe system\r
+devices along with other control and power management information. These tables\r
+are written using ACPI Source Language (ASL). The ASL code is compiled using an\r
+ASL compiler (e.g. Intel iASL compiler) to generate ACPI Machine Language (AML)\r
+bytecode.\r
+\r
+Since, definition blocks are represented using AML grammar, run-time generation\r
+of definition blocks is complex. Dynamic AML is a feature of Dynamic Tables\r
+framework that provides a solution for dynamic generation of ACPI Definition\r
+block tables.\r
+\r
+Dynamic AML introduces the following techniques:\r
+* AML Fixup\r
+* AML Codegen\r
+* AML Fixup + Codegen\r
+\r
+### AML Fixup\r
+AML fixup is a technique that involves compiling an ASL template file to\r
+generate AML bytecode. This template AML bytecode can be parsed at run-time\r
+and a fixup code can update the required fields in the AML template.\r
+\r
+To simplify AML Fixup, the Dynamic Tables Framework provides an *AmlLib*\r
+library with a rich set of APIs that can be used to fixup the AML code.\r
+\r
+### AML Codegen\r
+AML Codegen employs generating small segments of AML code. The *AmlLib*\r
+library provides AML Codegen APIs that generate the AML code segments.\r
+\r
+    Example: The following table depicts the AML Codegen APIs and the\r
+             corresponding ASL code that would be generated.\r
+\r
+    | AML Codegen API                | ASL Code                       |\r
+    |--------------------------------|--------------------------------|\r
+    |  AmlCodeGenDefinitionBlock (   |  DefinitionBlock (             |\r
+    |    ..,                         |    ...                         |\r
+    |    &RootNode);                 |  ) {                           |\r
+    |  AmlCodeGenScope (             |    Scope (_SB) {               |\r
+    |    "\_SB",                     |                                |\r
+    |    RootNode,                   |                                |\r
+    |    &ScopeNode);                |                                |\r
+    |  AmlCodeGenDevice (            |    Device (CPU0) {             |\r
+    |    "CPU0",                     |                                |\r
+    |    ScopeNode,                  |                                |\r
+    |    &CpuNode);                  |                                |\r
+    |  AmlCodeGenNameString (        |      Name (_HID, "ACPI0007")   |\r
+    |    "_HID",                     |                                |\r
+    |    "ACPI0007",                 |                                |\r
+    |    CpuNode,                    |                                |\r
+    |    &HidNode);                  |                                |\r
+    |  AmlCodeGenNameInteger (       |      Name (_UID, Zero)         |\r
+    |    "_UID",                     |                                |\r
+    |    0,                          |                                |\r
+    |    CpuNode,                    |                                |\r
+    |    &UidNode);                  |                                |\r
+    |                                |      } // Device               |\r
+    |                                |    } // Scope                  |\r
+    |                                |  } // DefinitionBlock          |\r
+\r
+### AML Fixup + Codegen\r
+A combination of AML Fixup and AML Codegen could be used for generating\r
+Definition Blocks. For example the AML Fixup could be used to fixup certain\r
+parts of the AML template while the AML Codegen APIs could be used to inserted\r
+small fragments of AML code in the AML template.\r
+\r
+### AmlLib Library\r
+Since, AML bytecode represents complex AML grammar, an **AmlLib** library is\r
+introduced to assist parsing and traversing of the AML bytecode at run-time.\r
+\r
+The AmlLib library parses a definition block and represents it as an AML\r
+tree. This tree representation is based on the AML grammar defined by the\r
+ACPI 6.3 specification, section - 20 'ACPI Machine Language (AML)\r
+Specification'.\r
+\r
+AML objects, methods and data are represented as tree nodes. Since the AML\r
+data is represented as tree nodes, it is possible to traverse the tree, locate\r
+a node and modify the node data. The tree can then be serialized to a buffer\r
+(that represents the definition block). This definition block containing\r
+the fixed up AML code can then be installed as an ACPI table (DSDT/SSDT).\r
+\r
+AmlLib provides a rich API to operate on AML data. For example it provides\r
+APIs to update a device's name, the value of a "_UID" object, and the memory\r
+and interrupt number stored in a "_CRS" node.\r
+\r
+Although the AmlLib performs checks to a reasonable extent while modifying a\r
+definition block, these checks may not cover all aspects due to the complexity\r
+of the ASL/AML language. It is therefore recommended to review any operation\r
+performed, and validate the generated output.\r
+\r
+    Example: The serialized AML code could be validated by\r
+     - Saving the generated AML to a file and comparing with\r
+       a reference output.\r
+     or\r
+     - Disassemble the generated AML using the iASL compiler\r
+       and verifying the output.\r
+\r
+# Roadmap\r
+\r
 The current implementation of the Configuration Manager populates the\r
 platform information statically as a C structure. Further enhancements\r
 to introduce runtime loading of platform information from a platform\r
@@ -68,13 +164,13 @@ information file is planned.
 Also support for generating SMBIOS tables is planned and will be added\r
 subsequently.\r
 \r
-Supported Platforms\r
--------------------\r
+Supported Platforms\r
+\r
 1. Juno\r
 2. FVP Models\r
 \r
-Build Instructions\r
-------------------\r
+Build Instructions\r
+\r
 1. Set path for the iASL compiler with support for generating a C header\r
    file as output.\r
 \r
@@ -102,15 +198,14 @@ or
 >build -a AARCH64 -p Platform\ARM\VExpressPkg\ArmVExpress-FVP-AArch64.dsc\r
    -t GCC5 **-D DYNAMIC_TABLES_FRAMEWORK**\r
 \r
-Prerequisites\r
--------------\r
+Prerequisites\r
+\r
 Ensure that the latest ACPICA iASL compiler is used for building *Dynamic Tables Framework*.\r
 *Dynamic Tables Framework* has been tested using the following iASL compiler version:\r
-[Version 20200717](https://www.acpica.org/node/183)*, dated 17 July, 2020.\r
+[Version 20200717](https://www.acpica.org/node/183), dated 17 July, 2020.\r
 \r
 \r
-Running CI builds locally\r
--------------------------\r
+#Running CI builds locally\r
 \r
 The TianoCore EDKII project has introduced Core CI infrastructure using TianoCore EDKII Tools PIP modules:\r
 \r
@@ -178,8 +273,7 @@ The instructions to setup the CI environment are in *'edk2\\.pytool\\Readme.md'*
     - use `stuart_build -c .pytool/CISettings.py -h` option to see help on additional options.\r
 \r
 \r
-Documentation\r
--------------\r
+# Documentation\r
 \r
 Refer to the following presentation from *UEFI Plugfest Seattle 2018*:\r
 \r