]> git.proxmox.com Git - mirror_edk2.git/blame - DynamicTablesPkg/Readme.md
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / DynamicTablesPkg / Readme.md
CommitLineData
056b0f1b 1# Dynamic Tables Framework\r
dacba2b2
SM
2\r
3Dynamic Tables Framework provides mechanisms to reduce the amount\r
4of effort required in porting firmware to new platforms. The aim is\r
5to provide an implementation capable of generating the firmware\r
6tables from an external source. This is potentially a management\r
7node, either local or remote, or, where suitable, a file that might\r
8be generated from the system construction. This initial release\r
9does not fully implement that - the configuration is held in local\r
10UEFI modules.\r
11\r
056b0f1b
SM
12# Feature Summary\r
13\r
dacba2b2
SM
14The dynamic tables framework is designed to generate standardised\r
15firmware tables that describe the hardware information at\r
16run-time. A goal of standardised firmware is to have a common\r
17firmware for a platform capable of booting both Windows and Linux\r
18operating systems.\r
19\r
20Traditionally the firmware tables are handcrafted using ACPI\r
21Source Language (ASL), Table Definition Language (TDL) and\r
22C-code. This approach can be error prone and involves time\r
23consuming debugging. In addition, it may be desirable to configure\r
24platform hardware at runtime such as: configuring the number of\r
25cores available for use by the OS, or turning SoC features ON or\r
26OFF.\r
27\r
28The dynamic tables framework simplifies this by providing a set\r
29of standard table generators, that are implemented as libraries.\r
30These generators query a platform specific component, the\r
31'Configuration Manager', to collate the information required\r
32for generating the tables at run-time.\r
33\r
34The framework also provides the ability to implement custom/OEM\r
35generators; thereby facilitating support for custom tables. The\r
36custom generators can also utilize the existing standard generators\r
37and override any functionality if needed.\r
38\r
39The framework currently implements a set of standard ACPI table\r
40generators for ARM architecture, that can generate Server Base Boot\r
41Requirement (SBBR) compliant tables. Although, the set of standard\r
42generators implement the functionality required for ARM architecture;\r
43the framework is extensible, and support for other architectures can\r
44be added easily.\r
45\r
46The framework currently supports the following table generators for ARM:\r
47* DBG2 - Debug Port Table 2\r
48* DSDT - Differentiated system description table. This is essentially\r
49 a RAW table generator.\r
50* FADT - Fixed ACPI Description Table\r
51* GTDT - Generic Timer Description Table\r
52* IORT - IO Remapping Table\r
53* MADT - Multiple APIC Description Table\r
54* MCFG - PCI Express memory mapped configuration space base address\r
55 Description Table\r
c9a4df88
PG
56* PCCT - Platform Communications Channel Table\r
57* PPTT - Processor Properties Topology Table\r
dacba2b2 58* SPCR - Serial Port Console Redirection Table\r
c9a4df88 59* SRAT - System Resource Affinity Table\r
dacba2b2
SM
60* SSDT - Secondary System Description Table. This is essentially\r
61 a RAW table generator.\r
62\r
056b0f1b
SM
63## Dynamic AML\r
64\r
65ACPI Definition block (e.g. DSDT or SSDT) tables are used to describe system\r
66devices along with other control and power management information. These tables\r
67are written using ACPI Source Language (ASL). The ASL code is compiled using an\r
68ASL compiler (e.g. Intel iASL compiler) to generate ACPI Machine Language (AML)\r
69bytecode.\r
70\r
71Since, definition blocks are represented using AML grammar, run-time generation\r
72of definition blocks is complex. Dynamic AML is a feature of Dynamic Tables\r
73framework that provides a solution for dynamic generation of ACPI Definition\r
74block tables.\r
75\r
76Dynamic AML introduces the following techniques:\r
77* AML Fixup\r
78* AML Codegen\r
79* AML Fixup + Codegen\r
80\r
81### AML Fixup\r
82AML fixup is a technique that involves compiling an ASL template file to\r
83generate AML bytecode. This template AML bytecode can be parsed at run-time\r
84and a fixup code can update the required fields in the AML template.\r
85\r
86To simplify AML Fixup, the Dynamic Tables Framework provides an *AmlLib*\r
87library with a rich set of APIs that can be used to fixup the AML code.\r
88\r
89### AML Codegen\r
90AML Codegen employs generating small segments of AML code. The *AmlLib*\r
91library provides AML Codegen APIs that generate the AML code segments.\r
92\r
93 Example: The following table depicts the AML Codegen APIs and the\r
94 corresponding ASL code that would be generated.\r
95\r
96 | AML Codegen API | ASL Code |\r
97 |--------------------------------|--------------------------------|\r
98 | AmlCodeGenDefinitionBlock ( | DefinitionBlock ( |\r
99 | .., | ... |\r
100 | &RootNode); | ) { |\r
101 | AmlCodeGenScope ( | Scope (_SB) { |\r
102 | "\_SB", | |\r
103 | RootNode, | |\r
104 | &ScopeNode); | |\r
105 | AmlCodeGenDevice ( | Device (CPU0) { |\r
106 | "CPU0", | |\r
107 | ScopeNode, | |\r
108 | &CpuNode); | |\r
109 | AmlCodeGenNameString ( | Name (_HID, "ACPI0007") |\r
110 | "_HID", | |\r
111 | "ACPI0007", | |\r
112 | CpuNode, | |\r
113 | &HidNode); | |\r
114 | AmlCodeGenNameInteger ( | Name (_UID, Zero) |\r
115 | "_UID", | |\r
116 | 0, | |\r
117 | CpuNode, | |\r
118 | &UidNode); | |\r
119 | | } // Device |\r
120 | | } // Scope |\r
121 | | } // DefinitionBlock |\r
122\r
123### AML Fixup + Codegen\r
124A combination of AML Fixup and AML Codegen could be used for generating\r
125Definition Blocks. For example the AML Fixup could be used to fixup certain\r
126parts of the AML template while the AML Codegen APIs could be used to inserted\r
127small fragments of AML code in the AML template.\r
128\r
129### AmlLib Library\r
130Since, AML bytecode represents complex AML grammar, an **AmlLib** library is\r
131introduced to assist parsing and traversing of the AML bytecode at run-time.\r
132\r
133The AmlLib library parses a definition block and represents it as an AML\r
134tree. This tree representation is based on the AML grammar defined by the\r
135ACPI 6.3 specification, section - 20 'ACPI Machine Language (AML)\r
136Specification'.\r
137\r
138AML objects, methods and data are represented as tree nodes. Since the AML\r
139data is represented as tree nodes, it is possible to traverse the tree, locate\r
140a node and modify the node data. The tree can then be serialized to a buffer\r
141(that represents the definition block). This definition block containing\r
142the fixed up AML code can then be installed as an ACPI table (DSDT/SSDT).\r
143\r
144AmlLib provides a rich API to operate on AML data. For example it provides\r
145APIs to update a device's name, the value of a "_UID" object, and the memory\r
146and interrupt number stored in a "_CRS" node.\r
147\r
148Although the AmlLib performs checks to a reasonable extent while modifying a\r
149definition block, these checks may not cover all aspects due to the complexity\r
150of the ASL/AML language. It is therefore recommended to review any operation\r
151performed, and validate the generated output.\r
152\r
153 Example: The serialized AML code could be validated by\r
154 - Saving the generated AML to a file and comparing with\r
155 a reference output.\r
156 or\r
157 - Disassemble the generated AML using the iASL compiler\r
158 and verifying the output.\r
159\r
160# Roadmap\r
161\r
dacba2b2
SM
162The current implementation of the Configuration Manager populates the\r
163platform information statically as a C structure. Further enhancements\r
164to introduce runtime loading of platform information from a platform\r
165information file is planned.\r
166\r
167Also support for generating SMBIOS tables is planned and will be added\r
168subsequently.\r
169\r
056b0f1b
SM
170# Supported Platforms\r
171\r
dacba2b2
SM
1721. Juno\r
1732. FVP Models\r
174\r
056b0f1b
SM
175# Build Instructions\r
176\r
dacba2b2
SM
1771. Set path for the iASL compiler with support for generating a C header\r
178 file as output.\r
179\r
1802. Set PACKAGES_PATH to point to the locations of the following repositories:\r
181\r
182Example:\r
183\r
184> set PACKAGES_PATH=%CD%\edk2;%CD%\edk2-platforms;\r
185\r
186 or\r
187\r
188> export PACKAGES_PATH=$PWD/edk2:$PWD/edk2-platforms\r
189\r
1903. To enable Dynamic tables framework the *'DYNAMIC_TABLES_FRAMEWORK'*\r
191option must be defined. This can be passed as a command line\r
192parameter to the edk2 build system.\r
193\r
194Example:\r
195\r
196>build -a AARCH64 -p Platform\ARM\JunoPkg\ArmJuno.dsc\r
197 -t GCC5 **-D DYNAMIC_TABLES_FRAMEWORK**\r
198\r
199or\r
200\r
201>build -a AARCH64 -p Platform\ARM\VExpressPkg\ArmVExpress-FVP-AArch64.dsc\r
202 -t GCC5 **-D DYNAMIC_TABLES_FRAMEWORK**\r
203\r
056b0f1b
SM
204# Prerequisites\r
205\r
b88d95bb
PG
206Ensure that the latest ACPICA iASL compiler is used for building *Dynamic Tables Framework*.\r
207*Dynamic Tables Framework* has been tested using the following iASL compiler version:\r
056b0f1b 208[Version 20200717](https://www.acpica.org/node/183), dated 17 July, 2020.\r
dacba2b2 209\r
2d0c42fd 210\r
056b0f1b 211#Running CI builds locally\r
2d0c42fd
SM
212\r
213The TianoCore EDKII project has introduced Core CI infrastructure using TianoCore EDKII Tools PIP modules:\r
214\r
215 - *[edk2-pytool-library](https://pypi.org/project/edk2-pytool-library)*\r
216\r
217 - *[edk2-pytool-extensions](https://pypi.org/project/edk2-pytool-extensions)*\r
218\r
219\r
220The instructions to setup the CI environment are in *'edk2\\.pytool\\Readme.md'*\r
221\r
222## Building DynamicTablesPkg with Pytools\r
223\r
2241. [Optional] Create a Python Virtual Environment - generally once per workspace\r
225\r
226 ```\r
227 python -m venv <name of virtual environment>\r
228\r
229 e.g. python -m venv edk2-ci\r
230 ```\r
231\r
2322. [Optional] Activate Virtual Environment - each time new shell/command window is opened\r
233\r
234 ```\r
235 <name of virtual environment>/Scripts/activate\r
236\r
237 e.g. On a windows host PC run:\r
238 edk2-ci\Scripts\activate.bat\r
239 ```\r
2403. Install Pytools - generally once per virtual env or whenever pip-requirements.txt changes\r
241\r
242 ```\r
243 pip install --upgrade -r pip-requirements.txt\r
244 ```\r
245\r
2464. Initialize & Update Submodules - only when submodules updated\r
247\r
248 ```\r
249 stuart_setup -c .pytool/CISettings.py TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH>\r
250\r
251 e.g. stuart_setup -c .pytool/CISettings.py TOOL_CHAIN_TAG=GCC5\r
252 ```\r
253\r
2545. Initialize & Update Dependencies - only as needed when ext_deps change\r
255\r
256 ```\r
257 stuart_update -c .pytool/CISettings.py TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH>\r
258\r
259 e.g. stuart_update -c .pytool/CISettings.py TOOL_CHAIN_TAG=GCC5\r
260 ```\r
261\r
2626. Compile the basetools if necessary - only when basetools C source files change\r
263\r
264 ```\r
265 python BaseTools/Edk2ToolsBuild.py -t <ToolChainTag>\r
266 ```\r
267\r
2687. Compile DynamicTablesPkg\r
269\r
270 ```\r
271 stuart_build-c .pytool/CISettings.py TOOL_CHAIN_TAG=<TOOL_CHAIN_TAG> -a <TARGET_ARCH>\r
272\r
273 e.g. stuart_ci_build -c .pytool/CISettings.py TOOL_CHAIN_TAG=GCC5 -p DynamicTablesPkg -a AARCH64 --verbose\r
274 ```\r
275\r
276 - use `stuart_build -c .pytool/CISettings.py -h` option to see help on additional options.\r
277\r
278\r
056b0f1b 279# Documentation\r
dacba2b2
SM
280\r
281Refer to the following presentation from *UEFI Plugfest Seattle 2018*:\r
282\r
e3f8605a 283[Dynamic Tables Framework: A Step Towards Automatic Generation of Advanced Configuration and Power Interface (ACPI) & System Management BIOS (SMBIOS) Tables](http://www.uefi.org/sites/default/files/resources/Arm_Dynamic%20Tables%20Framework%20A%20Step%20Towards%20Automatic%20Generation%20of%20Advanced%20Configuration%20and%20Power%20Interface%20%28ACPI%29%20%26%20System%20Management%20BIOS%20%28SMBIOS%29%20Tables%20_0.pdf)\r
2d0c42fd 284\r