TianoCore EDK2 master
|
#include <AmlNodeDefines.h>
#include <AcpiTableGenerator.h>
#include <AmlCoreInterface.h>
#include <AcpiObjects.h>
#include <AmlEncoding/Aml.h>
#include <Api/AmlApiHelper.h>
#include <CodeGen/AmlResourceDataCodeGen.h>
#include <Tree/AmlNode.h>
#include <Tree/AmlTree.h>
#include <String/AmlString.h>
#include <Utils/AmlUtility.h>
Go to the source code of this file.
AML Code Generation.
Copyright (c) 2020 - 2023, Arm Limited. All rights reserved.
Copyright (C) 2023 - 2024, Advanced Micro Devices, Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlAddDeviceDataDescriptorPackage | ( | IN CONST EFI_GUID * | Uuid, |
IN AML_OBJECT_NODE_HANDLE | DsdNode, | ||
OUT AML_OBJECT_NODE_HANDLE * | PackageNode | ||
) |
AML code generation for a _DSD device data object.
AmlAddDeviceDataDescriptorPackage (Uuid, DsdNode, PackageNode) is equivalent of the following ASL code: ToUUID(Uuid), Package () {}
Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".
_DSD (Device Specific Data) Implementation Guide https://github.com/UEFI/DSD-Guide Per s3. "'Well-Known _DSD UUIDs and Data Structure Formats'" If creating a Device Properties data then UUID daffd814-6eba-4d8c-8a91-bc9bbf4aa301 should be used.
[in] | Uuid | The Uuid of the descriptor to be created |
[in] | DsdNode | Node of the DSD Package. |
[out] | PackageNode | If success, contains the created package node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 3070 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlAddIntegerToNamedPackage | ( | IN UINT32 | Integer, |
IN OUT AML_OBJECT_NODE_HANDLE | NameNode | ||
) |
Add an integer value to the named package node.
AmlCodeGenNamePackage ("_CID", NULL, &PackageNode); AmlGetEisaIdFromString ("PNP0A03", &EisaId); AmlAddIntegerToNamedPackage (EisaId, NameNode); AmlGetEisaIdFromString ("PNP0A08", &EisaId); AmlAddIntegerToNamedPackage (EisaId, NameNode);
equivalent of the following ASL code: Name (_CID, Package (0x02) // _CID: Compatible ID { EisaId ("PNP0A03"), EisaId ("PNP0A08") })
The package is added at the tail of the list of the input package node name: Name ("NamePackageNode", Package () { [Pre-existing package entries], [Newly created integer entry] })
[in] | Integer | Integer value that need to be added to package node. |
[in,out] | NameNode | Package named node to add the object to. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Others | Error occurred during the operation. |
Definition at line 3908 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlAddLpiState | ( | IN UINT32 | MinResidency, |
IN UINT32 | WorstCaseWakeLatency, | ||
IN UINT32 | Flags, | ||
IN UINT32 | ArchFlags, | ||
IN UINT32 | ResCntFreq, | ||
IN UINT32 | EnableParentState, | ||
IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *GenericRegisterDescriptor | OPTIONAL, | ||
IN UINT64 Integer | OPTIONAL, | ||
IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *ResidencyCounterRegister | OPTIONAL, | ||
IN EFI_ACPI_6_3_GENERIC_ADDRESS_STRUCTURE *UsageCounterRegister | OPTIONAL, | ||
IN CONST CHAR8 *StateName | OPTIONAL, | ||
IN AML_OBJECT_NODE_HANDLE | LpiNode | ||
) |
Add an _LPI state to a LPI node created using AmlCreateLpiNode.
AmlAddLpiState increments the Count of LPI states in the LPI node by one, and adds the following package: Package() { MinResidency, WorstCaseWakeLatency, Flags, ArchFlags, ResCntFreq, EnableParentState, (GenericRegisterDescriptor != NULL) ? // Entry method. If a ResourceTemplate(GenericRegisterDescriptor) : // Register is given, Integer, // use it. Use the Integer otherwise. ResourceTemplate() { // NULL Residency Counter Register (SystemMemory, 0, 0, 0, 0) }, ResourceTemplate() { // NULL Usage Counter Register (SystemMemory, 0, 0, 0, 0) }, "" // NULL State Name },
Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".
[in] | MinResidency | Minimum Residency. |
[in] | WorstCaseWakeLatency | Worst case wake-up latency. |
[in] | Flags | Flags. |
[in] | ArchFlags | Architectural flags. |
[in] | ResCntFreq | Residency Counter Frequency. |
[in] | EnableParentState | Enabled Parent State. |
[in] | GenericRegisterDescriptor | Entry Method. If not NULL, use this Register to describe the entry method address. |
[in] | Integer | Entry Method. If GenericRegisterDescriptor is NULL, take this value. |
[in] | ResidencyCounterRegister | If not NULL, use it to populate the residency counter register. |
[in] | UsageCounterRegister | If not NULL, use it to populate the usage counter register. |
[in] | StateName | If not NULL, use it to populate the state name. |
[in] | LpiNode | Lpi node created with the function AmlCreateLpiNode to which the new LPI state is appended. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 2607 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlAddNameIntegerPackage | ( | IN CONST CHAR8 * | Name, |
IN UINT64 | Value, | ||
IN AML_OBJECT_NODE_HANDLE | PackageNode | ||
) |
AML code generation to add a package with a name and value, to a parent package. This is useful to build the _DSD package but can be used in other cases.
AmlAddNameIntegerPackage ("Name", Value, PackageNode) is equivalent of the following ASL code: Package (2) {"Name", Value}
Cf ACPI 6.4 specification, s6.2.5 "_DSD (Device Specific Data)".
[in] | Name | String to place in first entry of package |
[in] | Value | Integer to place in second entry of package |
[in] | PackageNode | Package to add new sub package to. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 3206 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlAddNameStringToNamedPackage | ( | IN CONST CHAR8 * | NameString, |
IN AML_OBJECT_NODE_HANDLE | NamedNode | ||
) |
AML code generation to add a NameString to the package in a named node.
[in] | NameString | NameString to add |
[in] | NamedNode | Node to add the string to the included package. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 3802 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlAddPrtEntry | ( | IN UINT32 | Address, |
IN UINT8 | Pin, | ||
IN CONST CHAR8 * | LinkName, | ||
IN UINT32 | SourceIndex, | ||
IN AML_OBJECT_NODE_HANDLE | PrtNameNode | ||
) |
Add a _PRT entry.
AmlCodeGenPrtEntry (0x0FFFF, 0, "LNKA", 0, PrtNameNode) is equivalent of the following ASL code: Package (4) { 0x0FFFF, // Address: Device address (([Device Id] << 16) | 0xFFFF). 0, // Pin: PCI pin number of the device (0-INTA, ...). LNKA // Source: Name of the device that allocates the interrupt to which the above pin is connected. 0 // Source Index: Source is assumed to only describe one interrupt, so let it to index 0. }
The 2 models described in ACPI 6.4, s6.2.13 "_PRT (PCI Routing Table)" can be generated by this function. The example above matches the first model.
The package is added at the tail of the list of the input _PRT node name: Name (_PRT, Package () { [Pre-existing _PRT entries], [Newly created _PRT entry] })
Cf. ACPI 6.4 specification:
[in] | Address | Address. Cf ACPI 6.4 specification, Table 6.2: "ADR Object Address Encodings": High word-Device #, Low word-Function #. (for example, device 3, function 2 is 0x00030002). To refer to all the functions on a device #, use a function number of FFFF). |
[in] | Pin | PCI pin number of the device (0-INTA ... 3-INTD). Must be between 0-3. |
[in] | LinkName | Link Name, i.e. device in the AML NameSpace describing the interrupt used. The input string is copied. If NULL, generate 0 in the 'Source' field (cf. second model, using GSIV). |
[in] | SourceIndex | Source index or GSIV. |
[in] | PrtNameNode | Prt Named node to add the object to .... |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1008 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlAddRegisterOrIntegerToPackage | ( | IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register | OPTIONAL, |
IN UINT32 | Integer, | ||
IN AML_OBJECT_NODE_HANDLE | PackageNode | ||
) |
Adds an integer or register to the package
[in] | Register | If provided, register that will be added to package |
[in] | Integer | If Register is NULL, integer that will be added to the package |
[in] | PackageNode | Package to add value to |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 3425 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlAddRegisterToPackage | ( | IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE *Register | OPTIONAL, |
IN AML_OBJECT_NODE_HANDLE | PackageNode | ||
) |
Adds a register to the package
[in] | Register | If provided, register that will be added to package. otherwise NULL register will be added |
[in] | PackageNode | Package to add value to |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 3311 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenBuffer | ( | IN CONST UINT8 *Buffer | OPTIONAL, |
IN UINT32 BufferSize | OPTIONAL, | ||
OUT AML_OBJECT_NODE ** | NewObjectNode | ||
) |
AML code generation for a Buffer object node.
To create a Buffer object node with an empty buffer, call the function with (Buffer=NULL, BufferSize=0).
[in] | Buffer | Buffer to set for the created Buffer object node. The Buffer's content is copied. NULL if there is no buffer to set for the Buffer node. |
[in] | BufferSize | Size of the Buffer. 0 if there is no buffer to set for the Buffer node. |
[out] | NewObjectNode | If success, contains the created Buffer object node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 348 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenDefinitionBlock | ( | IN CONST CHAR8 * | TableSignature, |
IN CONST CHAR8 * | OemId, | ||
IN CONST CHAR8 * | OemTableId, | ||
IN UINT32 | OemRevision, | ||
OUT AML_ROOT_NODE ** | NewRootNode | ||
) |
AML code generation for DefinitionBlock.
Create a Root Node handle. It is the caller's responsibility to free the allocated memory with the AmlDeleteTree function.
AmlCodeGenDefinitionBlock (TableSignature, OemID, TableID, OEMRevision) is equivalent to the following ASL code: DefinitionBlock (AMLFileName, TableSignature, ComplianceRevision, OemID, TableID, OEMRevision) {} with the ComplianceRevision set to 2 and the AMLFileName is ignored.
[in] | TableSignature | 4-character ACPI signature. Must be 'DSDT' or 'SSDT'. |
[in] | OemId | 6-character string OEM identifier. |
[in] | OemTableId | 8-character string OEM table identifier. |
[in] | OemRevision | OEM revision number. |
[out] | NewRootNode | Pointer to the root node representing a Definition Block. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 93 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenDevice | ( | IN CONST CHAR8 * | NameString, |
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Device object node.
AmlCodeGenDevice ("COM0", ParentNode, NewObjectNode) is equivalent of the following ASL code: Device(COM0) {}
[in] | NameString | The new Device's name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1214 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenInteger | ( | IN UINT64 | Integer, |
OUT AML_OBJECT_NODE ** | NewObjectNode | ||
) |
AML code generation for an Integer object node.
[in] | Integer | Integer of the Integer object node. |
[out] | NewObjectNode | If success, contains the created Integer object node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 212 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenInvokeMethod | ( | IN CONST CHAR8 * | MethodNameString, |
IN UINT8 | NumArgs, | ||
IN AML_METHOD_PARAM *Parameters | OPTIONAL, | ||
IN AML_NODE_HANDLE | ParentNode | ||
) |
AML code generation to invoke/call another method.
This method is a subset implementation of MethodInvocation defined in the ACPI specification 6.5, section 20.2.5 "Term Objects Encoding". Added integer, string, ArgObj and LocalObj support.
Example 1: AmlCodeGenInvokeMethod ("MET0", 0, NULL, ParentNode); is equivalent to the following ASL code: MET0 ();
Example 2: AML_METHOD_PARAM Param[4]; Param[0].Data.Integer = 0x100; Param[0].Type = AmlMethodParamTypeInteger; Param[1].Data.Buffer = "TEST"; Param[1].Type = AmlMethodParamTypeString; Param[2].Data.Arg = 0; Param[2].Type = AmlMethodParamTypeArg; Param[3].Data.Local = 2; Param[3].Type = AmlMethodParamTypeLocal; AmlCodeGenInvokeMethod ("MET0", 4, Param, ParentNode);
is equivalent to the following ASL code: MET0 (0x100, "TEST", Arg0, Local2);
Example 3: AML_METHOD_PARAM Param[2]; Param[0].Data.Arg = 0; Param[0].Type = AmlMethodParamTypeArg; Param[1].Data.Integer = 0x100; Param[1].Type = AmlMethodParamTypeInteger; AmlCodeGenMethodRetNameString ("MET2", NULL, 2, TRUE, 0, ParentNode, &MethodNode); AmlCodeGenInvokeMethod ("MET3", 2, Param, MethodNode);
is equivalent to the following ASL code: Method (MET2, 2, Serialized) { MET3 (Arg0, 0x0100) }
[in] | MethodNameString | The method name to be called or invoked. |
[in] | NumArgs | Number of arguments to be passed, 0 to 7 are permissible values. |
[in] | Parameters | Contains the parameter data. |
[in] | ParentNode | The parent node to which the method invocation nodes are attached. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Allocate space to store methodname, object, data node pointers
Create a called or invoked method name string.
Validate and convert the Parameters to the stream of nodes.
Index <= NumArgs, because an additional method name was added.
The index contains the last successful node attached.
Index contains the node number that is failed for AmlVarListAddTail(). Hence, start detaching from the last successful
Index <= NumArgs, because an additional method name was added.
Definition at line 3997 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenMethod | ( | IN CONST CHAR8 * | NameString, |
IN UINT8 | NumArgs, | ||
IN BOOLEAN | IsSerialized, | ||
IN UINT8 | SyncLevel, | ||
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Method object node.
AmlCodeGenMethod ("MET0", 1, TRUE, 3, ParentNode, NewObjectNode) is equivalent of the following ASL code: Method(MET0, 1, Serialized, 3) {}
ACPI 6.4, s20.2.5.2 "Named Objects Encoding": DefMethod := MethodOp PkgLength NameString MethodFlags TermList MethodOp := 0x14
The ASL parameters "ReturnType" and "ParameterTypes" are not asked in this function. They are optional parameters in ASL.
[in] | NameString | The new Method's name. Must be a NULL-terminated ASL NameString e.g.: "MET0", "_SB.MET0", etc. The input string is copied. |
[in] | NumArgs | Number of arguments. Must be 0 <= NumArgs <= 6. |
[in] | IsSerialized | TRUE is equivalent to Serialized. FALSE is equivalent to NotSerialized. Default is NotSerialized in ASL spec. |
[in] | SyncLevel | Synchronization level for the method. Must be 0 <= SyncLevel <= 15. Default is 0 in ASL. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1574 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenMethodRetInteger | ( | IN CONST CHAR8 * | MethodNameString, |
IN UINT64 | ReturnedInteger, | ||
IN UINT8 | NumArgs, | ||
IN BOOLEAN | IsSerialized, | ||
IN UINT8 | SyncLevel, | ||
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode | OPTIONAL | ||
) |
AML code generation for a method returning an Integer.
AmlCodeGenMethodRetInteger ( "_CBA", 0, 1, TRUE, 3, ParentNode, NewObjectNode ); is equivalent of the following ASL code: Method(_CBA, 1, Serialized, 3) { Return (0) }
The ASL parameters "ReturnType" and "ParameterTypes" are not asked in this function. They are optional parameters in ASL.
[in] | MethodNameString | The new Method's name. Must be a NULL-terminated ASL NameString e.g.: "MET0", "_SB.MET0", etc. The input string is copied. |
[in] | ReturnedInteger | The value of the integer returned by the method. |
[in] | NumArgs | Number of arguments. Must be 0 <= NumArgs <= 6. |
[in] | IsSerialized | TRUE is equivalent to Serialized. FALSE is equivalent to NotSerialized. Default is NotSerialized in ASL spec. |
[in] | SyncLevel | Synchronization level for the method. Must be 0 <= SyncLevel <= 15. Default is 0 in ASL. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 2354 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenMethodRetNameString | ( | IN CONST CHAR8 * | MethodNameString, |
IN CONST CHAR8 *ReturnedNameString | OPTIONAL, | ||
IN UINT8 | NumArgs, | ||
IN BOOLEAN | IsSerialized, | ||
IN UINT8 | SyncLevel, | ||
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode | OPTIONAL | ||
) |
AML code generation for a method returning a NameString.
AmlCodeGenMethodRetNameString ( "MET0", "_CRS", 1, TRUE, 3, ParentNode, NewObjectNode ); is equivalent of the following ASL code: Method(MET0, 1, Serialized, 3) { Return (_CRS) }
The ASL parameters "ReturnType" and "ParameterTypes" are not asked in this function. They are optional parameters in ASL.
[in] | MethodNameString | The new Method's name. Must be a NULL-terminated ASL NameString e.g.: "MET0", "_SB.MET0", etc. The input string is copied. |
[in] | ReturnedNameString | The name of the object returned by the method. Optional parameter, can be:
|
[in] | NumArgs | Number of arguments. Must be 0 <= NumArgs <= 6. |
[in] | IsSerialized | TRUE is equivalent to Serialized. FALSE is equivalent to NotSerialized. Default is NotSerialized in ASL spec. |
[in] | SyncLevel | Synchronization level for the method. Must be 0 <= SyncLevel <= 15. Default is 0 in ASL. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 2138 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenMethodRetNameStringIntegerArgument | ( | IN CONST CHAR8 * | MethodNameString, |
IN CONST CHAR8 *ReturnedNameString | OPTIONAL, | ||
IN UINT8 | NumArgs, | ||
IN BOOLEAN | IsSerialized, | ||
IN UINT8 | SyncLevel, | ||
IN UINT64 | IntegerArgument, | ||
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode | OPTIONAL | ||
) |
AML code generation for a method returning a NameString that takes an integer argument.
AmlCodeGenMethodRetNameStringIntegerArgument ( "MET0", "MET1", 1, TRUE, 3, 5, ParentNode, NewObjectNode ); is equivalent of the following ASL code: Method(MET0, 1, Serialized, 3) { Return (MET1 (5)) }
The ASL parameters "ReturnType" and "ParameterTypes" are not asked in this function. They are optional parameters in ASL.
[in] | MethodNameString | The new Method's name. Must be a NULL-terminated ASL NameString e.g.: "MET0", "_SB.MET0", etc. The input string is copied. |
[in] | ReturnedNameString | The name of the object returned by the method. Optional parameter, can be:
|
[in] | NumArgs | Number of arguments. Must be 0 <= NumArgs <= 6. |
[in] | IsSerialized | TRUE is equivalent to Serialized. FALSE is equivalent to NotSerialized. Default is NotSerialized in ASL spec. |
[in] | SyncLevel | Synchronization level for the method. Must be 0 <= SyncLevel <= 15. Default is 0 in ASL. |
[in] | IntegerArgument | Argument to pass to the NameString. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 2248 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenName | ( | IN CONST CHAR8 * | NameString, |
IN AML_OBJECT_NODE * | Object, | ||
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Name object node.
[in] | NameString | The new variable name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. This input string is copied. |
[in] | Object | Object associated to the NameString. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 537 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenNameInteger | ( | IN CONST CHAR8 * | NameString, |
IN UINT64 | Integer, | ||
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Name object node, containing an Integer.
AmlCodeGenNameInteger ("_UID", 1, ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(_UID, One)
[in] | NameString | The new variable name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | Integer | Integer to associate to the NameString. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 724 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenNamePackage | ( | IN CONST CHAR8 * | NameString, |
IN AML_NODE_HEADER * | ParentNode, | ||
OPTIONAL OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Name object node, containing a Package.
AmlCodeGenNamePackage ("PKG0", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(PKG0, Package () {})
[in] | NameString | The new variable name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 781 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenNameResourceTemplate | ( | IN CONST CHAR8 * | NameString, |
IN AML_NODE_HEADER * | ParentNode, | ||
OPTIONAL OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Name object node, containing a ResourceTemplate.
AmlCodeGenNameResourceTemplate ("PRS0", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(PRS0, ResourceTemplate () {})
[in] | NameString | The new variable name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 837 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenNameString | ( | IN CONST CHAR8 * | NameString, |
IN CONST CHAR8 * | String, | ||
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Name object node, containing a String.
AmlCodeGenNameString ("_HID", "HID0000", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(_HID, "HID0000")
[in] | NameString | The new variable name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | String | NULL terminated String to associate to the NameString. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 665 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenNameUnicodeString | ( | IN CONST CHAR8 * | NameString, |
IN CHAR16 * | String, | ||
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Name object node, containing a String.
AmlCodeGenNameUnicodeString ("_STR", L"String", ParentNode, NewObjectNode) is equivalent of the following ASL code: Name(_STR, Unicode ("String"))
[in] | NameString | The new variable name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | String | NULL terminated Unicode String to associate to the NameString. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 897 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenPackage | ( | OUT AML_OBJECT_NODE ** | NewObjectNode | ) |
AML code generation for a Package object node.
The package generated is empty. New elements can be added via its list of variable arguments.
[out] | NewObjectNode | If success, contains the created Package object node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 261 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenResourceTemplate | ( | OUT AML_OBJECT_NODE ** | NewObjectNode | ) |
AML code generation for a ResourceTemplate.
"ResourceTemplate" is a macro defined in ACPI 6.3, s19.3.3 "ASL Resource Templates". It allows to store resource data elements.
In AML, a ResourceTemplate is implemented as a Buffer storing resource data elements. An EndTag resource data descriptor must be at the end of the list of resource data elements. This function generates a Buffer node with an EndTag resource data descriptor. It can be seen as an empty list of resource data elements.
[out] | NewObjectNode | If success, contains the created ResourceTemplate object node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 488 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenReturn | ( | IN AML_NODE_HEADER * | ReturnNode, |
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Return object node.
AmlCodeGenReturn (ReturnNode, ParentNode, NewObjectNode) is equivalent of the following ASL code: Return([Content of the ReturnNode])
The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states: DefReturn := ReturnOp ArgObject ReturnOp := 0xA4 ArgObject := TermArg => DataRefObject
Thus, the ReturnNode must be evaluated as a DataRefObject. It can be a NameString referencing an object. As this CodeGen Api doesn't do semantic checking, it is strongly advised to check the AML bytecode generated by this function against an ASL compiler.
The ReturnNode must be generated inside a Method body scope.
[in] | ReturnNode | The object returned by the Return ASL statement. This node is deleted if an error occurs. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. Must be a MethodOp node. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1757 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenReturnInteger | ( | IN UINT64 | Integer, |
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Return object node, returning an Integer.
AmlCodeGenReturn (0), ParentNode, NewObjectNode) is equivalent of the following ASL code: Return (0)
The ACPI 6.3 specification, 20.2.8 "Statement Opcodes Encoding" states: DefReturn := ReturnOp ArgObject ReturnOp := 0xA4 ArgObject := TermArg => DataRefObject
Thus, the ReturnNode must be evaluated as a DataRefObject.
The ReturnNode must be generated inside a Method body scope.
[in] | Integer | The integer is returned by the Return ASL statement. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. Must be a MethodOp node. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1943 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenReturnNameString | ( | IN CONST CHAR8 * | NameString, |
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Return object node, returning the object as an input NameString.
AmlCodeGenReturn ("NAM1", ParentNode, NewObjectNode) is equivalent of the following ASL code: Return(NAM1)
The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states: DefReturn := ReturnOp ArgObject ReturnOp := 0xA4 ArgObject := TermArg => DataRefObject
Thus, the ReturnNode must be evaluated as a DataRefObject. It can be a NameString referencing an object. As this CodeGen Api doesn't do semantic checking, it is strongly advised to check the AML bytecode generated by this function against an ASL compiler.
The ReturnNode must be generated inside a Method body scope.
[in] | NameString | The object referenced by this NameString is returned by the Return ASL statement. Must be a NULL-terminated ASL NameString e.g.: "NAM1", "_SB.NAM1", etc. The input string is copied. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. Must be a MethodOp node. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1861 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenReturnNameStringIntegerArgument | ( | IN CONST CHAR8 * | NameString, |
IN UINT64 | Integer, | ||
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Return object node, returning the object as an input NameString with a integer argument.
AmlCodeGenReturn ("NAM1", 6, ParentNode, NewObjectNode) is equivalent of the following ASL code: Return(NAM1 (6))
The ACPI 6.3 specification, s20.2.5.3 "Type 1 Opcodes Encoding" states: DefReturn := ReturnOp ArgObject ReturnOp := 0xA4 ArgObject := TermArg => DataRefObject
Thus, the ReturnNode must be evaluated as a DataRefObject. It can be a NameString referencing an object. As this CodeGen Api doesn't do semantic checking, it is strongly advised to check the AML bytecode generated by this function against an ASL compiler.
The ReturnNode must be generated inside a Method body scope.
[in] | NameString | The object referenced by this NameString is returned by the Return ASL statement. Must be a NULL-terminated ASL NameString e.g.: "NAM1", "_SB.NAM1", etc. The input string is copied. |
[in] | Integer | Argument to pass to the NameString |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. Must be a MethodOp node. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 2008 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenScope | ( | IN CONST CHAR8 * | NameString, |
IN AML_NODE_HEADER *ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE **NewObjectNode | OPTIONAL | ||
) |
AML code generation for a Scope object node.
AmlCodeGenScope ("_SB", ParentNode, NewObjectNode) is equivalent of the following ASL code: Scope(_SB) {}
[in] | NameString | The new Scope's name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1444 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI AmlCodeGenString | ( | IN CONST CHAR8 * | String, |
OUT AML_OBJECT_NODE ** | NewObjectNode | ||
) |
AML code generation for a String object node.
[in] | String | Pointer to a NULL terminated string. |
[out] | NewObjectNode | If success, contains the created String object node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 141 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCodeGenThermalZone | ( | IN CONST CHAR8 * | NameString, |
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewObjectNode | OPTIONAL | ||
) |
AML code generation for a ThermalZone object node.
AmlCodeGenThermalZone ("TZ00", ParentNode, NewObjectNode) is equivalent of the following ASL code: ThermalZone(TZ00) {}
[in] | NameString | The new ThermalZone's name. Must be a NULL-terminated ASL NameString e.g.: "DEV0", "DV15.DEV0", etc. The input string is copied. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If success, contains the created node. |
EFI_SUCCESS | Success. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 1330 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCreateCpcNode | ( | IN AML_CPC_INFO * | CpcInfo, |
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewCpcNode | OPTIONAL | ||
) |
Create a _CPC node.
Creates and optionally adds the following node Name(_CPC, Package() { NumEntries, // Integer Revision, // Integer HighestPerformance, // Integer or Buffer (Resource Descriptor) NominalPerformance, // Integer or Buffer (Resource Descriptor) LowestNonlinearPerformance, // Integer or Buffer (Resource Descriptor) LowestPerformance, // Integer or Buffer (Resource Descriptor) GuaranteedPerformanceRegister, // Buffer (Resource Descriptor) DesiredPerformanceRegister , // Buffer (Resource Descriptor) MinimumPerformanceRegister , // Buffer (Resource Descriptor) MaximumPerformanceRegister , // Buffer (Resource Descriptor) PerformanceReductionToleranceRegister, // Buffer (Resource Descriptor) TimeWindowRegister, // Buffer (Resource Descriptor) CounterWraparoundTime, // Integer or Buffer (Resource Descriptor) ReferencePerformanceCounterRegister, // Buffer (Resource Descriptor) DeliveredPerformanceCounterRegister, // Buffer (Resource Descriptor) PerformanceLimitedRegister, // Buffer (Resource Descriptor) CPPCEnableRegister // Buffer (Resource Descriptor) AutonomousSelectionEnable, // Integer or Buffer (Resource Descriptor) AutonomousActivityWindowRegister, // Buffer (Resource Descriptor) EnergyPerformancePreferenceRegister, // Buffer (Resource Descriptor) ReferencePerformance // Integer or Buffer (Resource Descriptor) LowestFrequency, // Integer or Buffer (Resource Descriptor) NominalFrequency // Integer or Buffer (Resource Descriptor) })
If resource buffer is NULL then integer will be used.
Cf. ACPI 6.4, s8.4.7.1 _CPC (Continuous Performance Control)
[in] | CpcInfo | CpcInfo object |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewCpcNode | If success and provided, contains the created node. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
The following fields are theoretically mandatory, but not supported by some platforms.
Definition at line 3508 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCreateLpiNode | ( | IN CONST CHAR8 * | LpiNameString, |
IN UINT16 | Revision, | ||
IN UINT64 | LevelId, | ||
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewLpiNode | OPTIONAL | ||
) |
Create a _LPI name.
AmlCreateLpiNode ("_LPI", 0, 1, ParentNode, &LpiNode) is equivalent of the following ASL code: Name (_LPI, Package ( 0, // Revision 1, // LevelId 0 // Count ))
This function doesn't define any LPI state. As shown above, the count of _LPI state is set to 0. The AmlAddLpiState () function allows to add LPI states.
Cf ACPI 6.3 specification, s8.4.4 "Lower Power Idle States".
[in] | LpiNameString | The new LPI 's object name. Must be a NULL-terminated ASL NameString e.g.: "_LPI", "DEV0.PLPI", etc. The input string is copied. |
[in] | Revision | Revision number of the _LPI states. |
[in] | LevelId | A platform defined number that identifies the level of hierarchy of the processor node to which the LPI states apply. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewLpiNode | If success, contains the created node. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 2452 of file AmlCodeGen.c.
EFI_STATUS EFIAPI AmlCreatePsdNode | ( | IN AML_PSD_INFO * | PsdInfo, |
IN AML_NODE_HANDLE ParentNode | OPTIONAL, | ||
OUT AML_OBJECT_NODE_HANDLE *NewPsdNode | OPTIONAL | ||
) |
Create a _PSD node.
Creates and optionally adds the following node Name(_PSD, Package() { Package () { NumEntries, // Integer Revision, // Integer Domain, // Integer CoordType, // Integer NumProc, // Integer } })
Cf. ACPI 6.5, s8.4.5.5 _PSD (P-State Dependency)
[in] | PsdInfo | PsdInfo object |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewPsdNode | If success and provided, contains the created node. |
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
EFI_OUT_OF_RESOURCES | Failed to allocate memory. |
Definition at line 4210 of file AmlCodeGen.c.
STATIC BOOLEAN EFIAPI IsNullGenericAddress | ( | IN EFI_ACPI_6_4_GENERIC_ADDRESS_STRUCTURE * | Address | ) |
Utility function to check if generic address points to NULL
[in] | Address | Pointer to the Generic address |
TRUE | Address is system memory with an Address of 0. |
FALSE | Address does not point to NULL. |
Definition at line 3396 of file AmlCodeGen.c.
STATIC EFI_STATUS EFIAPI LinkNode | ( | IN AML_OBJECT_NODE * | Node, |
IN AML_NODE_HEADER * | ParentNode, | ||
OUT AML_OBJECT_NODE ** | NewObjectNode | ||
) |
Utility function to link a node when returning from a CodeGen function.
[in] | Node | Newly created node. |
[in] | ParentNode | If provided, set ParentNode as the parent of the node created. |
[out] | NewObjectNode | If not NULL:
|
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 39 of file AmlCodeGen.c.