/** @file
ACPI Sdt Protocol Driver
Copyright (c) 2010, Intel Corporation. All rights reserved. <BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "AcpiTable.h"
/**
Retrieve option term according to AmlByteEncoding and Buffer.
@param[in] AmlByteEncoding AML Byte Encoding.
@param[in] Buffer AML buffer.
@param[in] MaxBufferSize AML buffer MAX size. The parser can not parse any data exceed this region.
@param[in] TermIndex Index of the data to retrieve from the object.
@param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
for the specified index.
@param[out] Data Upon return, points to the pointer to the data.
@param[out] DataSize Upon return, points to the size of Data.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Buffer does not refer to a valid ACPI object.
**/
)
{
}
}
//
// Parse term according to AML type
//
case AML_UINT8:
break;
case AML_UINT16:
break;
case AML_UINT32:
break;
case AML_UINT64:
break;
case AML_STRING:
break;
case AML_NAME:
return EFI_INVALID_PARAMETER;
}
break;
case AML_OBJECT:
if (ChildAmlByteEncoding == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// NOTE: We need override DataType here, if there is a case the AML_OBJECT is AML_NAME.
// We need convert type from EFI_ACPI_DATA_TYPE_CHILD to EFI_ACPI_DATA_TYPE_NAME_STRING.
// We should not return CHILD because there is NO OpCode for NameString.
//
}
return EFI_INVALID_PARAMETER;
}
break;
}
//
// It is real AML_OBJECT
//
*DataSize = AmlGetObjectSize (
);
if (*DataSize == 0) {
return EFI_INVALID_PARAMETER;
}
break;
case AML_NONE:
//
// No term
//
case AML_OPCODE:
default:
return EFI_INVALID_PARAMETER;
}
if (*DataSize > MaxBufferSize) {
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
/**
Retrieve information according to AmlByteEncoding and Buffer.
@param[in] AmlByteEncoding AML Byte Encoding.
@param[in] Buffer AML buffer.
@param[in] MaxBufferSize AML buffer MAX size. The parser can not parse any data exceed this region.
@param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
in the ACPI encoding, with index 0 always being the ACPI opcode.
@param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
for the specified index.
@param[out] Data Upon return, points to the pointer to the data.
@param[out] DataSize Upon return, points to the size of Data.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Buffer does not refer to a valid ACPI object.
**/
)
{
//
// 0. Check if this is NAME string.
//
//
// Only allow GET_SIZE
//
if (Index != AML_OP_PARSE_INDEX_GET_SIZE) {
return EFI_INVALID_PARAMETER;
}
//
// return NameString size
//
return EFI_INVALID_PARAMETER;
}
if (*DataSize > MaxBufferSize) {
return EFI_INVALID_PARAMETER;
}
return EFI_SUCCESS;
}
//
// Not NAME string, start parsing
//
//
// 1. Get OpCode
//
if (Index != AML_OP_PARSE_INDEX_GET_SIZE) {
}
if (*CurrentBuffer == AML_EXT_OP) {
OpLength = 2;
} else {
OpLength = 1;
}
if (Index == AML_OP_PARSE_INDEX_GET_OPCODE) {
return EFI_SUCCESS;
}
if (OpLength > MaxBufferSize) {
return EFI_INVALID_PARAMETER;
}
//
// 2. Skip PkgLength field, if have
//
//
// Override MaxBufferSize if it is valid PkgLength
//
return EFI_INVALID_PARAMETER;
} else {
}
} else {
PkgOffset = 0;
PkgLength = 0;
}
//
// 3. Get Term one by one.
//
while ((Index >= TermIndex) && (TermIndex <= AmlByteEncoding->MaxIndex) && ((UINTN)CurrentBuffer < (UINTN)Buffer + MaxBufferSize)) {
Data,
);
return EFI_INVALID_PARAMETER;
}
//
// Done
//
return EFI_SUCCESS;
}
//
// Parse next one
//
CurrentBuffer += *DataSize;
TermIndex ++;
}
//
// Finish all options, but no option found.
//
return EFI_INVALID_PARAMETER;
}
if (Index != AML_OP_PARSE_INDEX_GET_SIZE) {
return EFI_INVALID_PARAMETER;
}
}
//
// 4. Finish parsing all node, return size
//
} else {
}
return EFI_SUCCESS;
}
/**
Return object size.
@param[in] AmlByteEncoding AML Byte Encoding.
@param[in] Buffer AML object buffer.
@param[in] MaxBufferSize AML object buffer MAX size. The parser can not parse any data exceed this region.
@return Size of the object.
**/
)
{
NULL,
NULL,
);
return 0;
} else {
return DataSize;
}
}
/**
Return object name.
@param[in] AmlHandle AML handle.
@return Name of the object.
**/
CHAR8 *
)
{
//
// Find out Last Name index, accroding to OpCode table.
// The last name will be the node name by design.
//
break;
}
}
//
// Get Name for this node.
//
&DataType,
);
return NULL;
}
return NameString;
}
/**
Return offset of last option.
@param[in] AmlHandle AML Handle.
@param[out] Buffer Upon return, points to the offset after last option.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
**/
)
{
&DataType,
&Data,
);
return EFI_INVALID_PARAMETER;
}
//
// We need to parse the rest buffer after last node.
//
//
// We need skip PkgLength if no Option
//
if (DataType == EFI_ACPI_DATA_TYPE_OPCODE) {
}
return EFI_SUCCESS;
}
/**
Retrieve information according to AmlHandle
@param[in] AmlHandle AML handle.
@param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
in the ACPI encoding, with index 0 always being the ACPI opcode.
@param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
for the specified index.
@param[out] Data Upon return, points to the pointer to the data.
@param[out] DataSize Upon return, points to the size of Data.
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
**/
)
{
return AmlParseOptionCommon (
Data,
);
}