/** @file
ACPI Sdt Protocol Driver
Copyright (c) 2010 - 2011, 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"
/**
Check if it is AML Root name
@param[in] Buffer AML path.
@retval TRUE AML path is root.
@retval FALSE AML path is not root.
**/
)
{
return TRUE;
} else {
return FALSE;
}
}
/**
Check if it is AML LeadName.
@param[in] Ch Char.
@retval TRUE Char is AML LeadName.
@retval FALSE Char is not AML LeadName.
**/
)
{
return TRUE;
} else {
return FALSE;
}
}
/**
Check if it is AML Name.
@param[in] Ch Char.
@retval TRUE Char is AML Name.
@retval FALSE Char is not AML Name.
**/
)
{
return TRUE;
} else {
return FALSE;
}
}
/**
Return is buffer is AML NameSeg.
@param[in] Buffer AML NameSement.
@retval TRUE It is AML NameSegment.
@retval FALSE It is not AML NameSegment.
**/
)
{
if (!AmlIsLeadName (Buffer[0])) {
return FALSE;
}
return FALSE;
}
}
return TRUE;
}
/**
Get AML NameString size.
@param[in] Buffer AML NameString.
@param[out] BufferSize AML NameString size
@retval EFI_SUCCESS Success.
@retval EFI_INVALID_PARAMETER Buffer does not refer to a valid AML NameString.
**/
)
{
Length = 0;
//
// Parse root or parent prefix
//
if (*Buffer == AML_ROOT_CHAR) {
Buffer ++;
Length ++;
} else if (*Buffer == AML_PARENT_PREFIX_CHAR) {
do {
Buffer ++;
Length ++;
} while (*Buffer == AML_PARENT_PREFIX_CHAR);
}
//
// Parse name segment
//
if (*Buffer == AML_DUAL_NAME_PREFIX) {
Buffer ++;
Length ++;
SegCount = 2;
} else if (*Buffer == AML_MULTI_NAME_PREFIX) {
Buffer ++;
Length ++;
Buffer ++;
Length ++;
} else if (*Buffer == 0) {
//
// NULL Name, only for Root
//
SegCount = 0;
Buffer --;
*BufferSize = 2;
return EFI_SUCCESS;
} else {
return EFI_INVALID_PARAMETER;
}
} else {
//
// NameSeg
//
SegCount = 1;
}
Index = 0;
do {
if (!AmlIsNameSeg (Buffer)) {
return EFI_INVALID_PARAMETER;
}
Index ++;
*BufferSize = Length;
return EFI_SUCCESS;
}
/**
Check if it is ASL LeadName.
@param[in] Ch Char.
@retval TRUE Char is ASL LeadName.
@retval FALSE Char is not ASL LeadName.
**/
)
{
return TRUE;
} else {
return FALSE;
}
}
/**
Check if it is ASL Name.
@param[in] Ch Char.
@retval TRUE Char is ASL Name.
@retval FALSE Char is not ASL Name.
**/
)
{
return TRUE;
} else {
return FALSE;
}
}
/**
Get ASL NameString size.
@param[in] Buffer ASL NameString.
@return ASL NameString size.
**/
)
{
if (*Buffer == 0) {
return 0;
}
Length = 0;
//
// 1st
//
if (AmlIsAslLeadName (*Buffer)) {
Length ++;
Buffer ++;
}
return Length;
}
//
// 2, 3, 4 name char
//
if (AmlIsAslName (*Buffer)) {
Length ++;
Buffer ++;
}
return Length;
}
}
//
// Invalid ASL name
//
return 0;
}
/**
Get ASL NameString size.
@param[in] Buffer ASL NameString.
@param[out] Root On return, points to Root char number.
@param[out] Parent On return, points to Parent char number.
@param[out] SegCount On return, points to Segment count.
@return ASL NameString size.
**/
)
{
*Root = 0;
*Parent = 0;
*SegCount = 0;
TotalLength = 0;
NameLength = 0;
if (*Buffer == AML_ROOT_CHAR) {
*Root = 1;
Buffer ++;
} else if (*Buffer == AML_PARENT_PREFIX_CHAR) {
do {
Buffer ++;
(*Parent) ++;
} while (*Buffer == AML_PARENT_PREFIX_CHAR);
}
//
// Now parse name
//
while (*Buffer != 0) {
return 0;
}
(*SegCount) ++;
Buffer += NameLength;
if (*Buffer == 0) {
break;
}
Buffer ++;
}
//
// Check SegCoount
//
if (*SegCount > 0xFF) {
return 0;
}
//
// Calculate total length
//
if (*SegCount > 2) {
TotalLength += 2;
} else if (*SegCount == 2) {
TotalLength += 1;
}
//
// Add NULL char
//
TotalLength ++;
return TotalLength;
}
/**
Copy mem, and cast all the char in dest to be upper case.
@param[in] DstBuffer Destination buffer.
@param[in] SrcBuffer Source buffer.
@param[in] Length Buffer length.
**/
)
{
} else {
}
}
}
/**
Return AML name according to ASL name.
The caller need free the AmlName returned.
@param[in] AslPath ASL name.
@return AmlName
**/
UINT8 *
)
{
if (TotalLength == 0) {
return NULL;
}
//
// Handle Root and Parent
//
if (Root == 1) {
AmlBuffer ++;
Buffer ++;
} else if (Parent > 0) {
}
//
// Handle SegCount
//
if (SegCount > 2) {
AmlBuffer ++;
AmlBuffer ++;
} else if (SegCount == 2) {
AmlBuffer ++;
}
//
// Now to name
//
while (*Buffer != 0) {
Buffer += NameLength;
if (*Buffer == 0) {
break;
}
Buffer ++;
}
//
// Add NULL
//
return AmlPath;
}
/**
Print AML NameSeg.
@param[in] Buffer AML NameSeg.
**/
)
{
return ;
}
return ;
}
return ;
}
return ;
}
/**
Print AML NameString.
@param[in] Buffer AML NameString.
**/
)
{
if (*Buffer == AML_ROOT_CHAR) {
//
// RootChar
//
Buffer ++;
} else if (*Buffer == AML_PARENT_PREFIX_CHAR) {
//
// ParentPrefixChar
//
do {
Buffer ++;
} while (*Buffer == AML_PARENT_PREFIX_CHAR);
}
if (*Buffer == AML_DUAL_NAME_PREFIX) {
//
// DualName
//
Buffer ++;
SegCount = 2;
} else if (*Buffer == AML_MULTI_NAME_PREFIX) {
//
// MultiName
//
Buffer ++;
Buffer ++;
} else if (*Buffer == 0) {
//
// NULL Name
//
return ;
} else {
//
// NameSeg
//
SegCount = 1;
}
}
return ;
}