summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg
Commit message (Collapse)AuthorAgeFilesLines
* DynamicTablesPkg: Set the Access size for the DBG2 tableJoey Gouly2021-04-191-1/+23
| | | | | | | | | | | | | | | | The DBG2 table generator set the access size for the UART to DWORD (4 bytes) by default. However, according to Section B Generic UART, Arm Base System Architecture 1.0, Platform Design Document, a Generic UART can have BYTE, WORD or DWORD access sizes. To address this an AccessSize field has been introduced in CM_ARM_SERIAL_PORT_INFO object. This patch updates the DBG2 generator to setup the AccessSize field in the Generic Address Structure (GAS) for the UART in the DBG2 table with information provided by the platform. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Set the Access size for the SPCR tableJoey Gouly2021-04-191-1/+21
| | | | | | | | | | | | | | | | The SPCR table generator set the access size for the UART to DWORD (4 bytes) by default. However, according to Section B Generic UART, Arm Base System Architecture 1.0, Platform Design Document, a Generic UART can have BYTE, WORD or DWORD access sizes. To address this an AccessSize field has been introduced in CM_ARM_SERIAL_PORT_INFO object. This patch updates the SPCR generator to setup the AccessSize field in the Generic Address Structure (GAS) for the UART in the SPCR table with information provided by the platform. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Add access size to CM_ARM_SERIAL_PORT_INFOJoey Gouly2021-04-191-0/+3
| | | | | | | | Add access size to CM_ARM_SERIAL_PORT_INFO so that this can be passed down to the Generic Address Structure. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Remove EArmObjExtendedInterruptInfoPierre Gondois2021-04-131-2/+0
| | | | | | | | The EArmObjExtendedInterruptInfo doesn't exist. Remove any reference to this enum. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Re-order GicItsIdentifierArray structPierre Gondois2021-04-131-11/+11
| | | | | | | | The structure is not correctly placed in the file. Move it so it follows the EARM_OBJECT_ID enum order. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: add validation for PcdNonBsaCompliant16550SerialHidJoey Gouly2021-04-133-2/+113
| | | | | | | | | | | | According to ACPI 6.4, 6.1.5 _HID states: - A valid PNP ID must be of the form "AAA####" where A is an uppercase letter and # is a hex digit. - A valid ACPI ID must be of the form "NNNN####" where N is an uppercase letter or a digit ('0'-'9') and # is a hex digit. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Consume MdeLibs.dsc.inc for RegisterFilterLibDandan Bi2021-03-311-0/+2
| | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3246 MdeLibs.dsc.inc was added for some basic/default library instances provided by MdePkg and RegisterFilterLibNull Library was also added into it as the first version of MdeLibs.dsc.inc. So update platform dsc to consume MdeLibs.dsc.inc for RegisterFilterLibNull which will be consumed by IoLib and BaseLib. Cc: Sami Mujawar <Sami.Mujawar@arm.com> Cc: Alexei Fedorov <Alexei.Fedorov@arm.com> Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Acked-by: Ard Biesheuvel <ardb@kernel.org> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg/AmlLib: Remove unused variablesPierre Gondois2021-02-151-6/+1
| | | | | | | | | | | | Building the DynamicTablesPkg for a NOOPT target fails because unused variables are set. Remove these variables. Fixes: d9800046ea43 Reported-by: Leif Lindholm <leif@nuviainc.com> Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Leif Lindholm <leif@nuviainc.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Add an override for 16550 HID in SSDTJoey Gouly2021-02-113-4/+17
| | | | | | | | | | Some platforms advertise support for a 16550 UART, but are not compatible with the PNP0500 HID. Allow them to override the HID by setting PcdNonBsaCompliant16550SerialHid. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Don't use gEfiMdeModulePkgTokenSpaceGuidJoey Gouly2021-02-112-8/+10
| | | | | | | | | Introduce gEdkiiDynamicTablesPkgTokenSpaceGuid and use that instead. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* DynamicTablesPkg: Add SSDT CMN-600 Table generatorPierre Gondois2020-11-038-6/+943
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Generic ACPI for Arm Components 1.0 Platform Design Document, s2.6.4 "ASL code examples" provides information to describe an Arm CoreLink CMN-600 Coherent Mesh Network using an ASL definition block table. The SSDT CMN-600 Table Generator uses the Configuration Manager protocol to obtain the following information about the CMN-600 device on the platform: - the PERIPHBASE address location and address range; - the ROOTNODEBASE address location; - the number of Debug and Trace Controller (DTC) and their respective interrupt number; The CMN-600 mesh is described using the CM_ARM_CMN_600_INFO and CM_ARM_EXTENDED_INTERRUPT structures in the Configuration Manager. The SSDT CMN-600 Table generator: - gets the CMN-600 hardware information from the configuration manager. - uses the AmlLib interfaces to parse the AML template BLOB and construct an AML tree. - uses the AmlLib to update: - the "_UID" value; - the address location and range of the PERIPHBASE; - the address location of the ROOTNODEBASE; - the number of Debug and Trace Controller (DTC) and their respective interrupt number; - serializes the AML tree to an output buffer. This output buffer contains the fixed-up AML code, which is then installed as an ACPI SSDT table. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Co-authored-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: SsdtSerialPortFixupLib fix ECC errorsSami Mujawar2020-10-211-9/+9
| | | | | | | | | | Fix the following ECC reported errors in SsdtSerialPortFixupLib. - [9002] The function headers should follow Doxygen special documentation blocks in section 2.3.5 in Comment, <@param [in]> does NOT have [in, out] Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: AmlEncoding change debug macroSami Mujawar2020-10-212-154/+154
| | | | | | | | | | Change the AML_DEBUG_STR() macro to AML_OPCODE_DEF() that takes a string and the AML OpCode as input so that the text description and the AML OpCode are grouped. The AML_OPCODE_DEF() macro also strips the string description for release builds. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: AmlLib\AmlDbgPrint fix ECC errorSami Mujawar2020-10-218-30/+55
| | | | | | | | | Fix ECC error 8001 reported errors in AmlDbgPrint. [8001] Only capital letters are allowed to be used for #define declarations. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: AmlLib fix ECC errorsSami Mujawar2020-10-2110-19/+19
| | | | | | | | | | | Fix the following ECC reported errors in AmlLib. - [1008] File has invalid Non-ACSII char. - [9002] The function headers should follow Doxygen special documentation blocks in section 2.3.5 Comment does NOT have tail **/ Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: AcpiSratLibArm fix ECC errorSami Mujawar2020-10-211-2/+2
| | | | | | | | | | Fix the following ECC reported error in AcpiSratLibArm. - [9002] The function headers should follow Doxygen special documentation blocks in section 2.3.5 Comment does NOT have tail **/ Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: SsdtSerialPortLibArm fix ECC errorSami Mujawar2020-10-211-1/+5
| | | | | | | | | Fix the following ECC reported error in SsdtSerialPortLibArm. - [5007] There should be no initialization of a variable as part of its declaration Variable Name. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: Fix order of assert checksSami Mujawar2020-10-211-2/+2
| | | | | | | | Reordered the asserts to first check if the pointer is valid before de-referencing the pointer. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: Add SSDT Serial port for DBG2Pierre Gondois2020-08-132-70/+165
| | | | | | | | | | | | | | | The SSDT Serial port fixup library provides interfaces to generate a SSDT Serial port table based on the serial port information. Update the DBG2 Generator to use the SSDT serial port fixup library to build a serial port definition block for the DBG2 serial port and install the SSDT table. 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: Add SSDT Serial port for SPCRPierre Gondois2020-08-132-62/+164
| | | | | | | | | | | | | | | | | | | | According to Arm Server Base Boot Requirements, Platform Design Document version 1.2 revision D, September 2, 2019, section '4.2.1.8 SPCR'; the SPCR console device must be included in the DSDT. The SSDT Serial port fixup library provides interfaces to generate a SSDT Serial port table based on the serial port information. Update the SPCR Generator to use the SSDT serial port fixup library to build a serial port definition block corresponding to the SPCR serial port and install the SSDT table. 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: SSDT Serial Port generatorPierre Gondois2020-08-133-0/+406
| | | | | | | | | | | | | | | | | | | | | | Most platforms have several serial ports. These serial ports are described to an operating system using definition block tables. The SSDT Serial Port Table Generator uses the Configuration Manager protocol to obtain information for the Serial Ports on the platform. The serial ports are described using the CM_ARM_SERIAL_PORT_INFO structure. The EArmObjSerialPortInfo ID is used to represent a standard serial port. The SSDT Serial port fixup library provides interfaces to generate a SSDT Serial port table based on the serial port information. The SSDT Serial Port Table Generator uses the SSDT serial port fixup library to build serial port definition blocks and installs the SSDT tables. 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: SSDT Serial Port Fixup libraryPierre Gondois2020-08-1310-3/+703
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | According to Arm Server Base Boot Requirements, Platform Design Document version 1.2 revision D, September 2, 2019, section '4.2.1.8 SPCR'; The SPCR console device must be included in the DSDT. Additionally, it is often desirable to describe the serial ports available on a platform so that they are available for use by a rich OS. To facilitate the description of serial ports on a platform a common SSDT Serial Port Fixup library is introduced. It provides interfaces to build a SSDT serial port definition block table based on the serial port information. The SSDT Serial Port Fixup library is used by the SPCR, DBG2 and SSDT Serial Port generator to describe the serial port information in a definition block. +------------+ +------------+ +------------+ | SPCR Gen | | DBG2 Gen | | SERIAL Gen | +------------+ +------------+ +------------+ +----------------------------------+ | SSDT Serial Port Fixup library | +----------------------------------+ The SSDT Serial Port Fixup library: - Parses the SSDT Serial Port template using the AmlLib library to generate an AML tree. - Updates the _UID, _HID and _CID values. - Fixes up the Serial port base address, length and the interrupt number in the _CRS descriptor. - Fixes up the serial-port name. - Serialises the AML Tree to a buffer containing the definition block data. The definition block data is then installed by the corresponding table generator. 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: Add AsciiFromHex helper functionSami Mujawar2020-08-132-3/+42
| | | | | | | | | | AsciiFromHex is a function converts a hex number to an ASCII character. This function is used across multiple generators, so add it to the TableHelperLib. 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: Dynamic AML: Add AmlLib libraryPierre Gondois2020-08-135-3/+88
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ACPI Definition blocks are implemented using AML which has a complex grammar making run-time generation of definition blocks difficult. Dynamic AML is a feature of Dynamic Tables framework that provides a solution for dynamic generation of ACPI Definition block tables. Since, AML bytecode represents complex AML grammar, an AmlLib library is introduced to assist parsing and traversing of the AML bytecode at run-time. The AmlLib library parses a definition block and represents it as an AML tree. The AML objects, methods and data are represented as tree nodes. Since the AML data is represented as tree nodes, it is possible to traverse the tree, locate a node and modify the node data. The tree can then be serialized to a buffer (that represents the definition block). This definition block containing the fixed-up AML code can then be installed as an ACPI Definition Block table. Dynamic AML introduces the following techniques: * AML Fixup * AML Codegen * AML Fixup + Codegen AML Fixup is a technique that involves compiling an ASL template file to generate AML bytecode. This template AML bytecode can be parsed at run-time and a fixup code can update the required fields in the AML template. AML Codegen employs generating small segments of AML code. AmlLib provides a rich set of APIs to operate on AML data for AML Fixup and Codegen. 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: AmlLib APIsPierre Gondois2020-08-135-0/+1645
| | | | | | | | | | | | | | | | AmlLib library implements an AML parser, AML tree interface, serialiser, code generator and other interfaces to generate Definition Block tables. The AmlLib APIs are a collection of interfaces that enable parsing, iterating, modifying, adding, and serialising AML data to generate a Definition Block table. The AmlLib APIs are declared in Include\AmlLib\AmlLib.h 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: AML Core interfacePierre Gondois2020-08-131-0/+767
| | | | | | | | | | | | AML Core interface APIs are internal APIs of the AmlLib library. These APIs can be used to: - Create/Delete/Clone an AML tree/node - Get/update Fixed and Variable arguments - Serialize an AML tree. 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: AML Resource Data CodegenPierre Gondois2020-08-132-0/+315
| | | | | | | | | | | | | | | AML Codegen is a Dynamic AML technique that facilitates generation of small segments of AML code. The AML code generated using AML Codegen is represented as nodes in the AML Tree. AML Resource Data Codegen implements interfaces required for generating Resource Data elements that can be attached to an AML tree. 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: AML CodegenPierre Gondois2020-08-131-0/+701
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AML Codegen is a Dynamic AML technique that facilitates generation of small segments of AML code. The AML code generated using AML Codegen is represented as nodes in the AML Tree. Some examples where AML Codegen can be used are: - AML Codegen APIs can be used to generate a simple AML tree. - An AML template can be parsed to create an AML tree. This AML Tree can be searched to locate a node that needs updating. The AML Codegen APIs can be used to attach new AML nodes. - A combination of AML Fixup and AML Codegen can be used to generate an AML tree. The AML tree can then be serialised as a Definition Block table. Following AML Codegen APIs are implemented: - AmlCodeGenDefinitionBlock() - AmlCodeGenScope() - AmlCodeGenNameString() - AmlCodeGenNameInteger() - AmlCodeGenDevice() These AML Codegen APIs in combination with AML Resource Data Codegen APIs can be used to generate a simple AML tree. 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: AML Field list parserPierre Gondois2020-08-132-0/+452
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The AML language allows defining field lists in a Definition Block. Although Dynamic AML does not provide interfaces to modify Field Lists; an AML template code may contain Field lists and the AML parser must be capable of parsing and representing the Field lists in the AML tree. The AML parser creates an Object node that represents the 'Field Node'. The AML Field list parser creates an object node for each field element parsed in the AML byte stream, and adds them to the variable list of arguments of the 'Field Node'. Nodes that can have a field list are referred as 'Field nodes'. They have the AML_HAS_FIELD_LIST attribute set in the AML encoding. According to the ACPI 6.3 specification, s20.2.5.2 "Named Objects Encoding", field elements can be: - NamedField := NameSeg PkgLength; - ReservedField := 0x00 PkgLength; - AccessField := 0x01 AccessType AccessAttrib; - ConnectField := <0x02 NameString> | <0x02 BufferData>; - ExtendedAccessField := 0x03 AccessType ExtendedAccessAttrib AccessLength. A small set of opcodes describes the field elements. They are referred as field opcodes. An AML_BYTE_ENCODING table has been created for field OpCodes. Field elements: - don't have a SubOpCode; - have at most 3 fixed arguments (as opposed to 6 for standard AML objects); - don't have a variable list of arguments; - only the NamedField field element is part of the AML namespace. ConnectField's BufferData is a buffer node containing a single resource data element. NamedField field elements do not have an AML OpCode. NameSeg starts with a Char type and can thus be differentiated from the Opcodes for other fields. A pseudo OpCode has been created to simplify the parser. Following is a representation of a field node in an AML tree: (FieldNode) \ |- [0][1][3] # Fixed Arguments |- {(FldEl0)->(FldEl1)->...)} # Variable Arguments Where FldEl[n] is one of NamedField, ReservedField, AccessField, ConnectField, ExtendedAccessField. 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: AML Method parserPierre Gondois2020-08-132-0/+1646
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The AML language allows a Definition Block to implement methods that an Operating System can invoke at runtime. Although Dynamic AML does not provide interfaces to modify AML methods; an AML template code may contain methods and/or method invocations. Method definitions have an opcode defined in the AML encoding and can be easily parsed. However, the language does not define an opcode for method invocation. Method invocations are represented as a NameString followed by the arguments to the method. This poses a significant challenge for the AML parser as it has to determine if a NameString appearing in the AML byte stream is a method invocation and if it is a method invocation, then how many arguments follow. This also means the Method definition must occur prior to the method invocation in the AML byte stream. This is a hard requirement for the AML parser. The AML method parser maintains a NameSpaceRefList that keeps a track of every namespace node and its raw AML absolute path. The AmlIsMethodInvocation() searches the NameSpaceRefList to determine if a NameString matches a Method definition. A pseudo opcode has been defined in the AML encoding to represent the Method invocation in the AML tree. The AML encoding for method invocations in the ACPI specification 6.3 is: MethodInvocation := NameString TermArgList The AmlLib library redefines this as: MethodInvocation := MethodInvocationOp NameString ArgumentCount TermArgList ArgumentCount := ByteData Where MethodInvocationOp is the pseudo opcode and ArgumentCount is the number of arguments passed to the method. NOTE: The AmlLib library's definition for a method invocation only applies to the representation of method invocation node in the AML tree. When computing the size of a tree or serialising it, the additional data is not taken into account i.e. the MethodInvocationOp and the ArgumentCount are stripped before serialising. Method invocation nodes have the AML_METHOD_INVOVATION attribute set in the AmlLib library's representation of the AML encoding. 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: AML resource data parserPierre Gondois2020-08-132-0/+399
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resource data are defined in the ACPI 6.3 specification, s6.4 "Resource Data Types for ACPI". They can be created using the ASL ResourceTemplate () statement, cf s19.3.3 "ASL Resource Templates". Resource data can be of the small or large type and are defined by their encoding. The resource data is stored in the Bytelist of a BufferOp node. The Bytelist of a BufferOp node is represented by an AML Data node in the AML tree. The resource data parser, examines the Bytelist (Data node buffer) to detect the presence of resource data. If the Bytelist data matches the encoding for resource data types, the resource data parser fragments the Bytelist containing the resource data buffer into resource data elements represented as individual Data nodes and stores them in the variable arguments list of the BufferOp object nodes. Example: ASL code and the corresponding AML tree representation for the resource data. ASL Code -------- Name (_CRS, ResourceTemplate() { QWordMemory (...) Interrupt (...) } AML Tree -------- (NameOp) \ |-[_CRS]-[BufferOp] # Fixed Arguments |-{NULL} \ # Variable Argument \ list |-[BuffSize] # Fixed Arguments |-{(Rd1)->(Rd2)->(EndTag)} # Variable Argument list Where: Rd1 - QWordMemory resource data element. Rd2 - Interrupt resource data element. EndTag - Resource data end tag. 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: AML resource data helperPierre Gondois2020-08-132-0/+277
| | | | | | | | | | | | | | | | | | | | | | | | | Resource data are defined in the ACPI 6.3 specification, s6.4 "Resource Data Types for ACPI". They can be created using the ASL ResourceTemplate () statement, cf s19.3.3 "ASL Resource Templates". Resource data can be of the small or large type and are defined by their encoding. The resource data is stored in the Bytelist of a BufferOp node. To simplify operations on resource data, the resource data parser examines the Bytelist to detect the presence of resource data. If the data matches the encoding of resource data type(s), the parser fragments the resource data buffer into resource data elements (data nodes) and stores them in the variable arguments list of the BufferOp node. The resource data helper provides functions and macros to assist operations on resource data elements. 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: AML ParserPierre Gondois2020-08-132-0/+1520
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both ASL and AML are declarative language. The ASL code is compiled to AML bytecode. The AML bytecode is processed by the ACPI AML interpreter that runs as part of an OS. AML has a complex encoding making dynamic generation of Definition Block tables difficult. Dynamic AML generation involves techniques like AML Fixup and AML Codegen, both requiring parsing of AML bytecode. The AML parser is a module that parses an AML byte stream and represents it as an AML tree. Representing the AML bytecode as an AML tree is key to reducing the complexity and enabling Dynamic AML generation. In an AML Tree each AML statement (that also corresponds to an ASL statement) is represented as an 'Object Node'. Each Object Node has an OpCode and up to 6 Fixed Arguments followed by a list of Variable Arguments. (ObjectNode) \ |- [0][1][2][3][4][5] # Fixed Arguments |- {(VarArg1)->(VarArg2)->...N} # Variable Arguments A Fixed Argument or Variable Argument can be either an Object Node or a Data Node. A 'Data Node' consists of a data buffer. A 'Root Node' is a special type of Object Node that does not have an Opcode or Fixed Arguments. It only has a list of Variable Arguments. The Root Node is at the top of the AML tree and contains the Definition Block Header. The AML parser uses the 'AML Encoding' to parse an AML byte stream and represents it as an AML Tree. Representing in the form of an AML tree simplifies modification, addition and removal of the tree nodes. The modified tree can then be serialised to a buffer representing a Definition Block table. 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: AML ACPI Namespace interfacePierre Gondois2020-08-132-0/+1575
| | | | | | | | | | | | | | | | | | AML is a declarative language that is processed by the ACPI AML interpreter. The ACPI AML interpreter will compile the set of declarations into the ACPI Namespace at definition block load time. The hardware information described in AML is effectively mapped in the ACPI Namespace. The AML ACPI namespace interface implement the functionality to search the ACPI Namespace. Example: The AmlFindNode() can be used to locate a device node in the ACPI namespace using an ASL path as the search input. 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: AML debug loggingPierre Gondois2020-08-132-0/+700
| | | | | | | | | | | | | The AML debug print functions enable logging of the operations on the AML tree and the data output. The debug logging functionality is enabled for debug builds when the DEBUG_INFO or DEBUG_VERBOSE mask is enabled in the PCD gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel 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: AML serialise interfacePierre Gondois2020-08-131-0/+324
| | | | | | | | | | | | | | | | | | AML Fixup and AML Codegen facilitate dynamic generation of Definition Block tables. The AML byte stream that is generated is represented in an AML tree. Once the AML table generation is completed, the AML tree needs to be serialised for installing as an ACPI table. The AML serialise interface implements the functionality to iterate the nodes in the AML tree, collating the AML bytecode, computing the checksum and writing the AML byte stream to a buffer that represents the Definition Block table. Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> Co-authored-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: AML stream interfaceSami Mujawar2020-08-132-0/+1116
| | | | | | | | | | | | Dynamic AML involves parsing/packing of AML opcode and data into AML byte streams. The AML stream interface provides safe buffer management as well as supports forward and reverse streams. It provides functions to create, read, write, clone and compare AML streams. Co-authored-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: AML and ASL string helperPierre Gondois2020-08-132-0/+1423
| | | | | | | | | | Dynamic AML requires encoding/decoding and conversion of AML and ASL strings. A collection of helper functions have been provided for internal use in the AmlLib Library. 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: AML utility interfacesPierre Gondois2020-08-132-0/+1001
| | | | | | | | | | The AML utility interfaces are a collection of helper functions that assist in computing the checksum, size and to propagate the node information as a result of addition or update of AML nodes. 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: AML tree/node cloningPierre Gondois2020-08-131-0/+205
| | | | | | | | | | | | | | | | | It is often desirable to clone an AML branch/tree or an AML node. An example of could be to clone an AML template before fixup so that the original AML template remains unmodified. Another example would be replicating a device branch in the AML tree and fixing up the device information. To facilitate such scenarios the AmlLib library provides functions that can be used to clone an AML branch/tree or an AML node. 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: AML tree iteratorPierre Gondois2020-08-132-0/+573
| | | | | | | | | | | | | | | The AML tree iterator provides interfaces to traverse the nodes in the AML tree. The iterator can traverse the AML tree nodes in the following order: - Linear progression: Iterate following the AML byte stream order (depth first). - Branch progression: Iterate following the AML byte stream order (depth first), but stop iterating at the end of the branch. 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: AML tree traversalPierre Gondois2020-08-132-0/+686
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The AML tree traversal provides interfaces to traverse the nodes in the AML tree. It provides interfaces to traverse the AML tree in the following order: - Traverse sibling nodes. (Node) /-i # Child of fixed argument b \ / |- [a][b][c][d] # Fixed Arguments |- {(e)->(f)->(g)} # Variable Arguments \ \-h # Child of variable argument e Traversal Order: - AmlGetNextSibling() : a, b, c, d, e, f, g, NULL - AmlGetPreviousSibling(): g, f, e, d, c, b, a, NULL - Iterate depth-first path (follow AML byte stream). (Node) /-i # Child of fixed argument b \ / |- [a][b][c][d] # Fixed Arguments |- {(e)->(f)->(g)} # Variable Arguments \ \-h # Child of variable argument e Traversal Order: - AmlGetNextNode(): a, b, i, c, d, e, h, f, g, NULL - AmlGetPreviousNode() g, f, h, e, d, c, i, b, a, NULL Note: The branch i and h will be traversed if it has any children. 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: AML tree enumeratorPierre Gondois2020-08-131-0/+98
| | | | | | | | | | The AML tree enumerator interface allows enumeration of the nodes in the AML tree. The enumerator interface can be useful to search, serialise, print etc. the nodes in the AML tree. 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: AML tree interfacePierre Gondois2020-08-132-0/+1174
| | | | | | | | | | | | | | | | | The AML tree is composite and has the following node types: - Root node. - Object node. - Data node. These nodes are part of the Fixed Arguments or the Variable arguments list in the AML tree. The AML tree interface provides functions to manage the fixed and the variable argument nodes in the AML tree. 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: AML node definitionsPierre Gondois2020-08-134-0/+1634
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | AML has a complex grammar, and this makes runtime modifications on an AML byte stream difficult. A solution is to parse the AML bytecode and represent it in a tree data structure, henceforth called the AML tree. The AML tree is composite in the sense it has the following node types: - A 'Root node' that represents the root of the AML tree. - An 'Object node' that contains the OP Code (AML Encoding). - A 'Data node' that contains a data buffer. The Root node contains the Definition block header (ACPI header) and a Variable Argument list. The Object node is composed of an array of Fixed Arguments and a Variable Argument list. Fixed arguments can be either Object Nodes or Data nodes. Their placement (index) in the Fixed Argument array is defined by the AML encoding of the enclosing Object Node. Variable arguments can be Object nodes or Data nodes. Following is a depiction of a typical AML tree: (/) # Root Node \ |-{(N1)->...} # Variable Argument list, N1 is \ # an Object Node \ /-i # Child of fixed argument b \ / |- [a][b][c][d] # Fixed Arguments |- {(e)->(f)->(g)} # Variable Arguments \ \-h # Child of variable argument e 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: AML grammar definitionPierre Gondois2020-08-132-0/+1135
| | | | | | | | | | | | | | | | | | | | | | | | | ASL is a source language for defining ACPI objects including writing ACPI control methods. An ASL file is compiled using an ASL compiler tool to generate ACPI Machine Language (AML). This AML bytecode is processed by the ACPI AML interpreter that runs as part of an Operating System (OS). Both ASL and AML are declarative languages. Although they are closely related they are different languages. ASL statements declare objects. Each object has three parts, two of which can be NULL: Object := ObjectType FixedList VariableList The AML grammar defines corresponding encodings that makes up the AML byte stream. This patch introduces the AML grammar definitions used by AmlLib for encoding/decoding AML byte streams. 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: AmlLib definitionsPierre Gondois2020-08-132-0/+206
| | | | | | | | | | | | | | | | | | | | | | | | | 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> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: Introduction to Dynamic AMLSami Mujawar2020-08-131-17/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Update release build flagsSami Mujawar2020-08-071-0/+1
| | | | | | | | | | If MDEPKG_NDEBUG is defined, then debug and assert related macros wrapped by it are mapped to NULL implementations. Therefore, add MDEPKG_NDEBUG flags for release builds of DynamicTablesPkg. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
* DynamicTablesPkg: Update ASL build optionsPierre Gondois2020-08-072-28/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The EdkII BaseTools have been updated to facilitate the generation of C file containing AML data using the AmlToC script. The build system follows the following sequence for an ASL file compilation: - The ASL file is preprocessed using the C preprocessor - The Trim utility prunes the preprocessed file to removed unwanted data. - This file is compiled using an ASL compiler to generate an AML file. - The AmlToC python script reads the AML data and generates a C file with an array containing the AML data. - This C file containing a unique symbol name for the AML data array is then compiled with the firmware module. This removes the dependency on the ACPICA iASL compiler's "-tc" option which achieved the same effect but was less portable. Therefore, remove the "-tc" option from the ASL flags as this option is only been supported by the ACPICA iASL compiler. 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>