TianoCore EDK2 master
Loading...
Searching...
No Matches
AmlUtility.c File Reference
#include <Utils/AmlUtility.h>
#include <AmlCoreInterface.h>
#include <Tree/AmlNode.h>
#include <Tree/AmlTree.h>

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI AcpiPlatformChecksum (IN EFI_ACPI_DESCRIPTION_HEADER *AcpiTable)
 
STATIC BOOLEAN EFIAPI AmlComputeSizeCallback (IN AML_NODE_HEADER *Node, IN OUT VOID *Context, IN OUT EFI_STATUS *Status OPTIONAL)
 
EFI_STATUS EFIAPI AmlComputeSize (IN CONST AML_NODE_HEADER *Node, IN OUT UINT32 *Size)
 
EFI_STATUS EFIAPI AmlNodeGetIntegerValue (IN AML_OBJECT_NODE *Node, OUT UINT64 *Value)
 
STATIC EFI_STATUS EFIAPI AmlUnwindSpecialInteger (IN AML_OBJECT_NODE *Node)
 
EFI_STATUS EFIAPI AmlNodeSetIntegerValue (IN AML_OBJECT_NODE *Node, IN UINT64 NewValue, OUT INT8 *ValueWidthDiff)
 
STATIC EFI_STATUS EFIAPI AmlNodeUpdateIntegerValue (IN AML_OBJECT_NODE *IntegerNode, IN BOOLEAN IsIncrement, IN UINT64 Diff, OUT INT8 *ValueWidthDiff)
 
STATIC EFI_STATUS EFIAPI AmlPropagateSize (IN AML_NODE_HEADER *Node, IN BOOLEAN IsIncrement, IN UINT32 *Diff)
 
STATIC EFI_STATUS EFIAPI AmlPropagateNodeCount (IN AML_OBJECT_NODE *ObjectNode, IN BOOLEAN IsIncrement, IN UINT8 NodeCount, OUT INT8 *FieldWidthChange)
 
EFI_STATUS EFIAPI AmlPropagateInformation (IN AML_NODE_HEADER *Node, IN BOOLEAN IsIncrement, IN UINT32 Diff, IN UINT8 NodeCount)
 
EFI_STATUS EFIAPI AmlSetRdListCheckSum (IN AML_OBJECT_NODE *BufferOpNode, IN UINT8 CheckSum)
 

Detailed Description

AML Utility.

Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file AmlUtility.c.

Function Documentation

◆ AcpiPlatformChecksum()

EFI_STATUS EFIAPI AcpiPlatformChecksum ( IN EFI_ACPI_DESCRIPTION_HEADER AcpiTable)

This function computes and updates the ACPI table checksum.

Parameters
[in]AcpiTablePointer to an Acpi table.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 24 of file AmlUtility.c.

◆ AmlComputeSize()

EFI_STATUS EFIAPI AmlComputeSize ( IN CONST AML_NODE_HEADER Node,
IN OUT UINT32 *  Size 
)

Compute the size of a tree/sub-tree.

Parameters
[in]NodeNode to compute the size.
[in,out]SizePointer holding the computed size.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 169 of file AmlUtility.c.

◆ AmlComputeSizeCallback()

STATIC BOOLEAN EFIAPI AmlComputeSizeCallback ( IN AML_NODE_HEADER Node,
IN OUT VOID *  Context,
IN OUT EFI_STATUS *Status  OPTIONAL 
)

A callback function that computes the size of a Node and adds it to the Size pointer stored in the Context. Calling this function on the root node will compute the total size of the AML bytestream.

Parameters
[in]NodeNode to compute the size.
[in,out]ContextPointer holding the computed size. (UINT32 *) Context.
[in,out]StatusPointer holding:
  • At entry, the Status returned by the last call to this exact function during the enumeration;
  • At exit, he returned status of the call to this function. Optional, can be NULL.
Return values
TRUEif the enumeration can continue or has finished without interruption.
FALSEif the enumeration needs to stopped or has stopped.

Definition at line 78 of file AmlUtility.c.

◆ AmlNodeGetIntegerValue()

EFI_STATUS EFIAPI AmlNodeGetIntegerValue ( IN AML_OBJECT_NODE Node,
OUT UINT64 *  Value 
)

Get the value contained in an integer node.

Parameters
[in]NodePointer to an integer node. Must be an object node.
[out]ValueValue contained in the integer node.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 206 of file AmlUtility.c.

◆ AmlNodeSetIntegerValue()

EFI_STATUS EFIAPI AmlNodeSetIntegerValue ( IN AML_OBJECT_NODE Node,
IN UINT64  NewValue,
OUT INT8 *  ValueWidthDiff 
)

Set the value contained in an integer node.

The OpCode is updated accordingly to the new value (e.g.: If the original value was a UINT8 value, then the OpCode would be AML_BYTE_PREFIX. If it the new value is a UINT16 value then the OpCode will be updated to AML_WORD_PREFIX).

Parameters
[in]NodePointer to an integer node. Must be an object node.
[in]NewValueNew value to write in the integer node.
[out]ValueWidthDiffDifference in number of bytes used to store the new value. Can be negative.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_OUT_OF_RESOURCESCould not allocate memory.

Definition at line 374 of file AmlUtility.c.

◆ AmlNodeUpdateIntegerValue()

STATIC EFI_STATUS EFIAPI AmlNodeUpdateIntegerValue ( IN AML_OBJECT_NODE IntegerNode,
IN BOOLEAN  IsIncrement,
IN UINT64  Diff,
OUT INT8 *  ValueWidthDiff 
)

Increment/decrement the value contained in the IntegerNode.

Parameters
[in]IntegerNodePointer to an object node containing an integer.
[in]IsIncrementChoose the operation to do:
  • TRUE: Increment the Node's size and the Node's count;
  • FALSE: Decrement the Node's size and the Node's count.
[in]DiffValue to add/subtract to the integer.
[out]ValueWidthDiffWhen modifying the integer, it can be promoted/demoted, e.g. from UINT8 to UINT16. Stores the change in width. Can be negative.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 522 of file AmlUtility.c.

◆ AmlPropagateInformation()

EFI_STATUS EFIAPI AmlPropagateInformation ( IN AML_NODE_HEADER Node,
IN BOOLEAN  IsIncrement,
IN UINT32  Diff,
IN UINT8  NodeCount 
)

Propagate information up the tree.

The information can be a new size, a new number of arguments.

Parameters
[in]NodePointer to a node. Must be a root node or an object node.
[in]IsIncrementChoose the operation to do:
  • TRUE: Increment the Node's size and the Node's count;
  • FALSE: Decrement the Node's size and the Node's count.
[in]DiffValue to add/subtract to the Node's size.
[in]NodeCountNumber of nodes added/removed.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 870 of file AmlUtility.c.

◆ AmlPropagateNodeCount()

STATIC EFI_STATUS EFIAPI AmlPropagateNodeCount ( IN AML_OBJECT_NODE ObjectNode,
IN BOOLEAN  IsIncrement,
IN UINT8  NodeCount,
OUT INT8 *  FieldWidthChange 
)

Propagate the node count information up the tree.

Parameters
[in]ObjectNodePointer to an object node.
[in]IsIncrementChoose the operation to do:
  • TRUE: Increment the Node's size and the Node's count;
  • FALSE: Decrement the Node's size and the Node's count.
[in]NodeCountNumber of nodes added/removed (depends on the value of Operation).
[out]FieldWidthChangeWhen modifying the integer, it can be promoted/demoted, e.g. from UINT8 to UINT16. Stores the change in width. Can be negative.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 785 of file AmlUtility.c.

◆ AmlPropagateSize()

STATIC EFI_STATUS EFIAPI AmlPropagateSize ( IN AML_NODE_HEADER Node,
IN BOOLEAN  IsIncrement,
IN UINT32 *  Diff 
)

Propagate the size information up the tree.

The length of the ACPI table is updated in the RootNode, but not the checksum.

Parameters
[in]NodePointer to a node. Must be a root node or an object node.
[in]IsIncrementChoose the operation to do:
  • TRUE: Increment the Node's size and the Node's count;
  • FALSE: Decrement the Node's size and the Node's count.
[in]DiffValue to add/subtract to the Node's size.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 589 of file AmlUtility.c.

◆ AmlSetRdListCheckSum()

EFI_STATUS EFIAPI AmlSetRdListCheckSum ( IN AML_OBJECT_NODE BufferOpNode,
IN UINT8  CheckSum 
)

Find and set the EndTag's Checksum of a list of Resource Data elements.

Lists of Resource Data elements end with an EndTag (most of the time). This function finds the EndTag (if present) in a list of Resource Data elements and sets the checksum.

ACPI 6.4, s6.4.2.9 "End Tag": "This checksum is generated such that adding it to the sum of all the data bytes will produce a zero sum." "If the checksum field is zero, the resource data is treated as if the checksum operation succeeded. Configuration proceeds normally."

To avoid re-computing checksums, if a new resource data elements is added/removed/modified in a list of resource data elements, the AmlLib resets the checksum to 0.

Parameters
[in]BufferOpNodeNode having a list of Resource Data elements.
[in]CheckSumCheckSum to store in the EndTag. To ignore/avoid computing the checksum, give 0.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.
EFI_NOT_FOUNDNo EndTag found.

Definition at line 961 of file AmlUtility.c.

◆ AmlUnwindSpecialInteger()

STATIC EFI_STATUS EFIAPI AmlUnwindSpecialInteger ( IN AML_OBJECT_NODE Node)

Replace a Zero (AML_ZERO_OP) or One (AML_ONE_OP) object node with a byte integer (AML_BYTE_PREFIX) object node having the same value.

Parameters
[in]NodePointer to an integer node. Must be an object node having ZeroOp or OneOp.
Return values
EFI_SUCCESSThe function completed successfully.
EFI_INVALID_PARAMETERInvalid parameter.

Definition at line 288 of file AmlUtility.c.