AML grammar definitions.
Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.
Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Aml.h.
AML types.
In the AML bytestream, data is represented using one of the following types. These types are used in the parsing logic to know what kind of data is expected next in the bytestream. This allows to parse data according to the AML_PARSE_FORMAT type. E.g.: A string will not be parsed in the same way as a UINT8.
These are internal types.
Enumerator |
---|
EAmlNone | No data expected.
|
EAmlUInt8 | One byte value evaluated as a UINT8.
|
EAmlUInt16 | Two byte value evaluated as a UINT16.
|
EAmlUInt32 | Four byte value evaluated as a UINT32.
|
EAmlUInt64 | Eight byte value evaluated as a UINT64.
|
EAmlObject | AML object, starting with an OpCode/SubOpCode couple, potentially followed by package length. EAmlName is a subtype of an EAmlObject. Indeed, an EAmlName can also be evaluated as an EAmlObject in the parsing.
|
EAmlName | Name corresponding to the NameString keyword in the ACPI specification. E.g.: "\_SB_.DEV0"
|
EAmlString | NULL terminated string.
|
EAmlFieldPkgLen | A field package length (PkgLen). A data node of this type can only be found in a field list, in a NamedField statement. The PkgLen is otherwise part of the object node structure.
|
EAmlParseFormatMax | Max enum.
|
Definition at line 33 of file Aml.h.
EFI_STATUS EFIAPI AmlComputePkgLength |
( |
IN UINT32 |
Length, |
|
|
OUT UINT32 * |
PkgLen |
|
) |
| |
Given a length, compute the value of a PkgLen.
In AML, some object have a PkgLen, telling the size of the AML object. It can be encoded in 1 to 4 bytes. The bytes used to encode the PkgLen is itself counted in the PkgLen value. This means that if an AML object sees its size increment/decrement, the number of bytes used to encode the PkgLen value can itself increment/decrement.
For instance, the AML encoding of a DeviceOp is: DefDevice := DeviceOp PkgLength NameString TermList If:
- sizeof (NameString) = 4 (the name is "DEV0" for instance);
- sizeof (TermList) = (2^6-6) then the PkgLen is encoded on 1 byte. Indeed, its value is: sizeof (PkgLen) + sizeof (NameString) + sizeof (TermList) = sizeof (PkgLen) + 4 + (2^6-6) So: PkgLen = sizeof (PkgLen) + (2^6-2)
The input arguments Length and PkgLen represent, for the DefDevice: DefDevice := DeviceOp PkgLength NameString TermList |---—Length--—| |-----—*PgkLength------—|
- Parameters
-
[in] | Length | The length to encode as a PkgLen. Length cannot exceed 2^28 - 4 (4 bytes for the PkgLen encoding). The size of the PkgLen encoding bytes should not be counted in this length value. |
[out] | PkgLen | If success, contains the value of the PkgLen, ready to encode in the PkgLen format. This value takes into account the size of PkgLen encoding. |
- Return values
-
EFI_SUCCESS | The function completed successfully. |
EFI_INVALID_PARAMETER | Invalid parameter. |
Definition at line 862 of file Aml.c.