OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
AcpiParser.c File Reference
#include <Uefi.h>
#include <IndustryStandard/Acpi62.h>
#include <Library/OcAcpiLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiApplicationEntryPoint.h>
#include <Library/UefiBootServicesTableLib.h>
#include <IndustryStandard/AcpiAml.h>
#include "AcpiParser.h"

Go to the source code of this file.

Functions

STATIC EFI_STATUS ParseNameString (IN OUT ACPI_PARSER_CONTEXT *Context, IN OUT UINT8 **NamePathStart OPTIONAL, IN OUT UINT8 *PathLength OPTIONAL, IN OUT UINT8 *IsRootPath OPTIONAL)
 
STATIC EFI_STATUS ParsePkgLength (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT32 *PkgLength)
 
STATIC EFI_STATUS ParseAlias (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseScopeOrDevice (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
STATIC EFI_STATUS ParseName (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseBankField (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
STATIC EFI_STATUS ParseCreateField (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
STATIC EFI_STATUS ParseExternal (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseOpRegion (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParsePowerRes (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseProcessor (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseThermalZone (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseMethod (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
STATIC EFI_STATUS ParseIfElse (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
STATIC EFI_STATUS ParseEvent (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseField (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
STATIC EFI_STATUS ParseMutex (IN OUT ACPI_PARSER_CONTEXT *Context)
 
STATIC EFI_STATUS ParseIndexField (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
EFI_STATUS InternalAcpiParseTerm (IN OUT ACPI_PARSER_CONTEXT *Context, OUT UINT8 **Result)
 
EFI_STATUS TranslateNameToOpcodes (IN CONST CHAR8 *Name, IN CONST CHAR8 *NameEnd, OUT UINT32 *OpcodeName)
 
EFI_STATUS GetOpcodeArray (IN OUT ACPI_PARSER_CONTEXT *Context, IN CONST CHAR8 *PathString)
 
VOID InitContext (OUT ACPI_PARSER_CONTEXT *Context)
 
VOID ClearContext (IN OUT ACPI_PARSER_CONTEXT *Context)
 
EFI_STATUS AcpiFindEntryInMemory (IN UINT8 *Table, IN CONST CHAR8 *PathString, IN UINT8 Entry, OUT UINT32 *Offset, IN UINT32 TableLength OPTIONAL)
 

Detailed Description

Copyright (c) 2020-2021, Ubsefor & koralexa. All rights reserved. Copyright (c) 2021, vit9696. All rights reserved. SPDX-License-Identifier: BSD-3-Clause

Definition in file AcpiParser.c.

Function Documentation

◆ AcpiFindEntryInMemory()

EFI_STATUS AcpiFindEntryInMemory ( IN UINT8 * Table,
IN CONST CHAR8 * PathString,
IN UINT8 Entry,
OUT UINT32 * Offset,
IN UINT32 TableLength OPTIONAL )

Finds offset of required entry in ACPI table in case it exists.

Parameters
[in]TablePointer to start of ACPI table.
[in]PathStringPath to entry which must be found.
[in]EntryNumber of entry which must be found.
[out]OffsetOffset of the entry if it was found.
[out]TableLengthLength of ACPI table.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDRequired entry was not found.
EFI_DEVICE_ERRORError occured during parsing ACPI table.
EFI_OUT_OF_RESOURCESNesting limit has been reached.
EFI_INVALID_PARAMETERGot wrong path to the entry.

Definition at line 2021 of file AcpiParser.c.

◆ ClearContext()

VOID ClearContext ( IN OUT ACPI_PARSER_CONTEXT * Context)

Deinitialises ACPI Context parser variable which stores ACPI header.

Parameters
[in,out]ContextAddress to a context structure, containing the parser context.

Definition at line 2008 of file AcpiParser.c.

◆ GetOpcodeArray()

EFI_STATUS GetOpcodeArray ( IN OUT ACPI_PARSER_CONTEXT * Context,
IN CONST CHAR8 * PathString )

Translates path (one or more identifiers) to AML opcodes.

Parameters
[in,out]ContextStructure containing the parser context.
[in]PathStringOriginal path.
Return values
EFI_SUCCESSPath was translated successfuly.
EFI_INVALID_PARAMETERPath can't be translated to opcodes.

Definition at line 1917 of file AcpiParser.c.

◆ InitContext()

VOID InitContext ( OUT ACPI_PARSER_CONTEXT * Context)

Initializes ACPI Context parser variable which stores ACPI header.

Parameters
[out]ContextAddress to a context structure, containing the parser context.

Definition at line 1993 of file AcpiParser.c.

◆ InternalAcpiParseTerm()

EFI_STATUS InternalAcpiParseTerm ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Determines which object to parse (depending on the opcode) and calls the corresponding parser function.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found (search complete).
EFI_NOT_FOUNDRequired entry was not found (more terms need to be parsed).
EFI_DEVICE_ERRORError occured during parsing (must abort).
EFI_OUT_OF_RESOURCESNesting limit has been reached (must abort).

Definition at line 1728 of file AcpiParser.c.

◆ ParseAlias()

STATIC EFI_STATUS ParseAlias ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses alias section to skip it correctly.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDAlias was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing alias.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 172 of file AcpiParser.c.

◆ ParseBankField()

STATIC EFI_STATUS ParseBankField ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Parses bank field section. In case it's name is suitable returns pointer to it's opcode. Otherwise skips this section.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDBank field was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing bank field.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 456 of file AcpiParser.c.

◆ ParseCreateField()

STATIC EFI_STATUS ParseCreateField ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Parses create field section (any of CreateDwordField, CreateWordField, CreateByteField, CreateBitField, CreateQWordField, CreateField sections). In case it's name is suitable returns pointer to it's opcode. Otherwise skips this section.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDField was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing field.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 603 of file AcpiParser.c.

◆ ParseEvent()

STATIC EFI_STATUS ParseEvent ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses event section to skip it correctly.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDEvent was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing event.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1416 of file AcpiParser.c.

◆ ParseExternal()

STATIC EFI_STATUS ParseExternal ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses external section to correctly skip it.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDExternal was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing external.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 767 of file AcpiParser.c.

◆ ParseField()

STATIC EFI_STATUS ParseField ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Parses field section. In case it's name is suitable returns pointer to it's opcode. Otherwise skips this section.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDField was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing field.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1453 of file AcpiParser.c.

◆ ParseIfElse()

STATIC EFI_STATUS ParseIfElse ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Parses if-else section. Looks for other sections inside it.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDIf-else section was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing if-else section.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1300 of file AcpiParser.c.

◆ ParseIndexField()

STATIC EFI_STATUS ParseIndexField ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Parses index field section. In case it's name is suitable returns pointer to it's opcode. Otherwise skips this section.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDIndex field was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing index field.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1597 of file AcpiParser.c.

◆ ParseMethod()

STATIC EFI_STATUS ParseMethod ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Parses method section. In case it's name is suitable returns pointer to it's opcode. Otherwise skips this section.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDMethod was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing method.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1190 of file AcpiParser.c.

◆ ParseMutex()

STATIC EFI_STATUS ParseMutex ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses mutex to correctly skip it.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDMutex was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing mutex.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1559 of file AcpiParser.c.

◆ ParseName()

STATIC EFI_STATUS ParseName ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses name section to correctly skip it.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDName was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing name.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 354 of file AcpiParser.c.

◆ ParseNameString()

STATIC EFI_STATUS ParseNameString ( IN OUT ACPI_PARSER_CONTEXT * Context,
IN OUT UINT8 **NamePathStart OPTIONAL,
IN OUT UINT8 *PathLength OPTIONAL,
IN OUT UINT8 *IsRootPath OPTIONAL )

Parses identifier or path (several identifiers). Returns info about the identifier / path if necessary.

Parameters
[in,out]ContextStructure containing the parser context.
[in,out]NamePathStartPointer to first opcode of identifier / path.
[in,out]PathLengthQuantity of identifiers in path.
[in,out]IsRootPath1 if parsed path was a root path, 0 otherwise.
Return values
EFI_SUCCESSName was parsed successfuly.
EFI_DEVICE_ERRORError occured during parsing.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 35 of file AcpiParser.c.

◆ ParseOpRegion()

STATIC EFI_STATUS ParseOpRegion ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses operation region to skip it correctly.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDOpRegion was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing OpRegion.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 801 of file AcpiParser.c.

◆ ParsePkgLength()

STATIC EFI_STATUS ParsePkgLength ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT32 * PkgLength )

Parses package length (length of current section).

Parameters
[in,out]ContextStructure containing the parser context.
[out]PkgLengthTotal length of section.
Return values
EFI_SUCCESSLength was parsed successfuly.
EFI_DEVICE_ERRORError occured during parsing length.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 123 of file AcpiParser.c.

◆ ParsePowerRes()

STATIC EFI_STATUS ParsePowerRes ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses PowerRes to skip it correctly.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDPowerRes was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing PowerRes.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1072 of file AcpiParser.c.

◆ ParseProcessor()

STATIC EFI_STATUS ParseProcessor ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses processor section to skip it correctly.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDProcessor was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing processor.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1110 of file AcpiParser.c.

◆ ParseScopeOrDevice()

STATIC EFI_STATUS ParseScopeOrDevice ( IN OUT ACPI_PARSER_CONTEXT * Context,
OUT UINT8 ** Result )

Parses scope or device section. In case it's name is suitable parses elements inside it, or returns pointer to it's opcode if this scope / device was sought. Otherwise skips this section.

Parameters
[in,out]ContextStructure containing the parser context.
[out]ResultPointer to sought opcode if required entry was found.
Return values
EFI_SUCCESSRequired entry was found.
EFI_NOT_FOUNDScope / device was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing scope / device.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 221 of file AcpiParser.c.

◆ ParseThermalZone()

STATIC EFI_STATUS ParseThermalZone ( IN OUT ACPI_PARSER_CONTEXT * Context)

Parses thermal zone to skip it correctly.

Parameters
[in,out]ContextStructure containing the parser context.
Return values
EFI_NOT_FOUNDProcessor was parsed and skipped successfuly.
EFI_DEVICE_ERRORError occured during parsing processor.
EFI_OUT_OF_RESOURCESNesting limit has been reached.

Definition at line 1148 of file AcpiParser.c.

◆ TranslateNameToOpcodes()

EFI_STATUS TranslateNameToOpcodes ( IN CONST CHAR8 * Name,
IN CONST CHAR8 * NameEnd,
OUT UINT32 * OpcodeName )

Translates one identifier to AML opcodes. Complements it with '_' opcodes if identifier length is under 4.

Parameters
[in]NamePointer to the start of the identifier.
[in]NameEndPointer to the end of the identifier.
[out]OpcodeNameIdentifier translated to opcodes.
Return values
EFI_SUCCESSIdentifier was translated successfuly.
EFI_INVALID_PARAMETERIdentifier can't be translated to opcodes.

Definition at line 1860 of file AcpiParser.c.