TianoCore EDK2 master
|
#include <Parser/AmlParser.h>
#include <AmlCoreInterface.h>
#include <AmlDbgPrint/AmlDbgPrint.h>
#include <Parser/AmlFieldListParser.h>
#include <Parser/AmlMethodParser.h>
#include <Parser/AmlResourceDataParser.h>
#include <String/AmlString.h>
#include <Tree/AmlNode.h>
#include <Tree/AmlTree.h>
Go to the source code of this file.
Typedefs | |
typedef EFI_STATUS(EFIAPI * | AML_PARSE_FUNCTION) (IN CONST AML_NODE_HEADER *Node, IN AML_PARSE_FORMAT ExpectedFormat, IN OUT AML_STREAM *FStream, OUT AML_NODE_HEADER **OutNode) |
Variables | |
AML_PARSE_FUNCTION | mParseType [EAmlParseFormatMax] |
AML Parser.
Copyright (c) 2019 - 2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file AmlParser.c.
typedef EFI_STATUS(EFIAPI * AML_PARSE_FUNCTION) (IN CONST AML_NODE_HEADER *Node, IN AML_PARSE_FORMAT ExpectedFormat, IN OUT AML_STREAM *FStream, OUT AML_NODE_HEADER **OutNode) |
Function pointer to parse an AML construct.
The expected format of the AML construct is passed in the ExpectedFormat argument. The available formats are available in the AML_PARSE_FORMAT enum definition.
An object node or a data node is created in the function, and returned through the OutNode parameter. This node should be attached after this function returns.
[in] | ParentNode | Parent node to which the parsed AML construct will be attached. |
[in] | ExpectedFormat | Format of the AML construct to parse. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[out] | OutNode | Pointer holding the node created from the parsed AML bytecode. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 102 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlCheckAndParseMethodInvoc | ( | IN CONST AML_NODE_HEADER * | ParentNode, |
IN AML_DATA_NODE * | DataNode, | ||
IN OUT LIST_ENTRY * | NameSpaceRefList, | ||
OUT AML_OBJECT_NODE ** | OutNode | ||
) |
Check whether the NameString stored in the data node is a method invocation. If so, create a method invocation node and return it.
[in] | ParentNode | Node to which the parsed AML construct will be attached. |
[in] | DataNode | Data node containing a NameString, potentially being a method invocation. |
[in,out] | NameSpaceRefList | List of namespace reference nodes. |
[out] | OutNode | Pointer holding the method invocation node if the NameString contained in the data node is a method invocation. NULL otherwise. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 622 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseArgument | ( | IN CONST AML_NODE_HEADER * | ParentNode, |
IN AML_PARSE_FORMAT | ExpectedFormat, | ||
IN OUT AML_STREAM * | FStream, | ||
IN OUT LIST_ENTRY * | NameSpaceRefList, | ||
OUT AML_NODE_HEADER ** | OutNode | ||
) |
Call the appropriate function to parse the AML construct in the stream.
The ExpectedFormat parameter allows to choose the right parsing function. An object node or a data node is created according to format.
[in] | ParentNode | Node to which the parsed AML construct will be attached. |
[in] | ExpectedFormat | Format of the AML construct to parse. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[in,out] | NameSpaceRefList | List of namespace reference nodes. |
[out] | OutNode | Pointer holding the node created from the parsed AML bytecode. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 713 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseByteList | ( | IN AML_OBJECT_NODE * | BufferNode, |
IN OUT AML_STREAM * | FStream | ||
) |
Parse the Bytelist in the stream. According to the content of the stream, create data node(s) and add them to the variable list of arguments. The byte list may be a list of resource data element or a simple byte list.
[in] | BufferNode | Object node having a byte list. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 804 of file AmlParser.c.
EFI_STATUS EFIAPI AmlParseDefinitionBlock | ( | IN CONST EFI_ACPI_DESCRIPTION_HEADER * | DefinitionBlock, |
OUT AML_ROOT_NODE ** | RootPtr | ||
) |
Parse the definition block.
This function parses the whole AML blob. It starts with the ACPI DSDT/SSDT header and then parses the AML bytestream. A tree structure is returned via the RootPtr. The tree must be deleted with the AmlDeleteTree function.
[in] | DefinitionBlock | Pointer to the definition block. |
[out] | RootPtr | Pointer to the root node of the tree. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 1370 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseFieldPkgLen | ( | IN CONST AML_NODE_HEADER * | ParentNode, |
IN AML_PARSE_FORMAT | ExpectedFormat, | ||
IN OUT AML_STREAM * | FStream, | ||
OUT AML_NODE_HEADER ** | OutNode | ||
) |
Parse a FieldPkgLen.
A FieldPkgLen can only be found in a field list, i.e. in a NamedField field element. The PkgLen is otherwise part of the object node structure. A data node is created and returned through the OutNode parameter.
[in] | ParentNode | Parent node to which the parsed AML construct will be attached. |
[in] | ExpectedFormat | Format of the AML construct to parse. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[out] | OutNode | Pointer holding the node created from the parsed AML bytecode. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 523 of file AmlParser.c.
EFI_STATUS EFIAPI AmlParseFixedArguments | ( | IN AML_OBJECT_NODE * | ObjectNode, |
IN AML_STREAM * | FStream, | ||
IN LIST_ENTRY * | NameSpaceRefList | ||
) |
Parse the list of fixed arguments of the input ObjectNode.
For each argument, create a node and add it to the fixed argument list of the Node. If a fixed argument has children, parse them.
[in] | ObjectNode | Object node to parse the fixed arguments from. |
[in] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[in] | NameSpaceRefList | List of namespace reference nodes. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 893 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseNameString | ( | IN CONST AML_NODE_HEADER * | ParentNode, |
IN AML_PARSE_FORMAT | ExpectedFormat, | ||
IN OUT AML_STREAM * | FStream, | ||
OUT AML_NODE_HEADER ** | OutNode | ||
) |
Parse an AML NameString.
A data node is created and returned through the OutNode parameter.
[in] | ParentNode | Parent node to which the parsed AML construct will be attached. |
[in] | ExpectedFormat | Format of the AML construct to parse. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[out] | OutNode | Pointer holding the node created from the parsed AML bytecode. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 218 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseObject | ( | IN CONST AML_NODE_HEADER * | ParentNode, |
IN AML_PARSE_FORMAT | ExpectedFormat, | ||
IN OUT AML_STREAM * | FStream, | ||
OUT AML_NODE_HEADER ** | OutNode | ||
) |
Parse an AML object.
An object can be resolved as an AML object with an OpCode, or a NameString. An object node or a data node is created and returned through the OutNode parameter.
[in] | ParentNode | Parent node to which the parsed AML construct will be attached. |
[in] | ExpectedFormat | Format of the AML construct to parse. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[out] | OutNode | Pointer holding the node created from the parsed AML bytecode. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 379 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseStream | ( | IN AML_NODE_HEADER * | Node, |
IN AML_STREAM * | FStream, | ||
IN LIST_ENTRY * | NameSpaceRefList | ||
) |
Invoke the appropriate parsing functions based on the Node type.
[in] | Node | Node from which the children are parsed. Must be a root node or an object node. |
[in] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[in] | NameSpaceRefList | List of namespace reference nodes. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 1318 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseString | ( | IN CONST AML_NODE_HEADER * | ParentNode, |
IN AML_PARSE_FORMAT | ExpectedFormat, | ||
IN OUT AML_STREAM * | FStream, | ||
OUT AML_NODE_HEADER ** | OutNode | ||
) |
Parse an AML String.
A data node is created and returned through the OutNode parameter.
[in] | ParentNode | Parent node to which the parsed AML construct will be attached. |
[in] | ExpectedFormat | Format of the AML construct to parse. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[out] | OutNode | Pointer holding the node created from the parsed AML bytecode. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 305 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlParseUIntX | ( | IN CONST AML_NODE_HEADER * | ParentNode, |
IN AML_PARSE_FORMAT | ExpectedFormat, | ||
IN OUT AML_STREAM * | FStream, | ||
OUT AML_NODE_HEADER ** | OutNode | ||
) |
Parse a UInt<X> (where X=8, 16, 32 or 64).
A data node is created and returned through the OutNode parameter.
[in] | ParentNode | Parent node to which the parsed AML construct will be attached. |
[in] | ExpectedFormat | Format of the AML construct to parse. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[out] | OutNode | Pointer holding the node created from the parsed AML bytecode. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 131 of file AmlParser.c.
EFI_STATUS EFIAPI AmlParseVariableArguments | ( | IN AML_NODE_HEADER * | Node, |
IN AML_STREAM * | FStream, | ||
IN LIST_ENTRY * | NameSpaceRefList | ||
) |
Parse the variable list of arguments of the input ObjectNode.
For each variable argument, create a node and add it to the variable list of arguments of the Node. If a variable argument has children, parse them recursively.
The arguments of method invocation nodes are added to the variable list of arguments of the method invocation node. It is necessary to first get the number of arguments to parse for this kind of node. A method invocation can have at most 7 fixed arguments.
[in] | Node | Node to parse the variable arguments from. |
[in] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[in] | NameSpaceRefList | List of namespace reference nodes. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 1031 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlPopulateObjectNode | ( | IN AML_OBJECT_NODE * | ObjectNode, |
IN OUT AML_STREAM * | FStream, | ||
IN OUT LIST_ENTRY * | NameSpaceRefList | ||
) |
Parse the AML stream an populate the object node.
[in] | ObjectNode | ObjectNode to which the children are added. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[in,out] | NameSpaceRefList | List of namespace reference nodes. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 1207 of file AmlParser.c.
STATIC EFI_STATUS EFIAPI AmlPopulateRootNode | ( | IN AML_ROOT_NODE * | RootNode, |
IN OUT AML_STREAM * | FStream, | ||
IN OUT LIST_ENTRY * | NameSpaceRefList | ||
) |
Parse the AML stream and populate the root node.
[in] | RootNode | RootNode to which the children are added. |
[in,out] | FStream | Forward stream containing the AML bytecode to parse. The stream must not be at its end. |
[in,out] | NameSpaceRefList | List of namespace reference nodes. |
EFI_SUCCESS | The function completed successfully. |
EFI_BUFFER_TOO_SMALL | No space left in the buffer. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Could not allocate memory. |
Definition at line 1161 of file AmlParser.c.
AML_PARSE_FUNCTION mParseType[EAmlParseFormatMax] |
Array of functions pointers to parse the AML constructs.
The AML Byte encoding tables in Aml.c describe the format of the AML statements. The AML_PARSE_FORMAT enum definition lists these constructs and the corresponding parsing functions.
Definition at line 589 of file AmlParser.c.