Sync all bug fixes between EDK1.04 and EDK1.06 into EdkCompatibilityPkg.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11094 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
lgao4
2010-11-26 01:54:49 +00:00
parent 68bb5ce77e
commit 3e99020dbf
183 changed files with 15250 additions and 2636 deletions

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 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
@@ -502,13 +502,6 @@ Routine Description:
Initialize a Firmware Volume (FV) Media Device Path node.
Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
so as we move to UEFI 2.0 support we must use a mechanism that conforms with
the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
device path is defined for PIWG extensions of device path. If the code
is compiled to conform with the UEFI 2.0 specification use the new device path
else use the old form for backwards compatability.
Arguments:
FvDevicePathNode - Pointer to a FV device path node to initialize
@@ -520,12 +513,6 @@ Returns:
--*/
{
//
// EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
// In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
// EFI 1.10 and UEFI 2.10.
//
FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
@@ -544,15 +531,6 @@ Routine Description:
Check to see if the Firmware Volume (FV) Media Device Path is valid.
Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
so as we move to UEFI 2.0 support we must use a mechanism that conforms with
the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
device path is defined for PIWG extensions of device path. If the code
is compiled to conform with the UEFI 2.0 specification use the new device path
else use the old form for backwards compatability. The return value to this
function points to a location in FvDevicePathNode and it does not allocate
new memory for the GUID pointer that is returned.
Arguments:
FvDevicePathNode - Pointer to FV device path to check
@@ -564,11 +542,6 @@ Returns:
--*/
{
//
// EFI Specification extension on Media Device Path. MEDIA_FW_VOL_FILEPATH_DEVICE_PATH is adopted by UEFI later and added in UEFI2.10.
// In EdkCompatibility Package, we only support MEDIA_FW_VOL_FILEPATH_DEVICE_PATH that complies with
// EFI 1.10 and UEFI 2.10.
//
if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
return &FvDevicePathNode->NameGuid;

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 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
@@ -21,6 +21,18 @@ Abstract:
#include "Tiano.h"
#include "EfiDriverLib.h"
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
VOID
EFIAPI
OnStatusCodeInstall (
IN EFI_EVENT Event,
IN VOID *Context
);
#endif
//
// Global Interface for Debug Mask Protocol
@@ -50,6 +62,10 @@ Returns:
--*/
{
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
VOID *Registration;
#endif
gST = SystemTable;
ASSERT (gST != NULL);
@@ -70,6 +86,21 @@ Returns:
(VOID *) &gDebugMaskInterface
);
#endif
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
//
// Register EFI_STATUS_CODE_PROTOCOL notify function
//
EfiLibCreateProtocolNotifyEvent (
&gEfiStatusCodeRuntimeProtocolGuid,
EFI_TPL_CALLBACK,
OnStatusCodeInstall,
NULL,
&Registration
);
#endif
//
// Should be at EFI_D_INFO, but lets us know things are running
//
@@ -78,55 +109,107 @@ Returns:
return EFI_SUCCESS;
}
STATIC
BOOLEAN
EfiLibCompareLanguage (
IN CHAR8 *Language1,
IN CHAR8 *Language2
IsIso639LanguageCode (
IN CHAR8 *Languages
)
/*++
Routine Description:
Compare whether two names of languages are identical.
Tests whether a language code has format of ISO639-2.
Arguments:
Language1 - Name of language 1
Language2 - Name of language 2
Languages - The language code to be tested.
Returns:
TRUE - same
FALSE - not same
TRUE - Language code format is ISO 639-2.
FALSE - Language code format is not ISO 639-2.
--*/
{
UINTN Index;
//
// Find out format of Languages
//
for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++);
if (Languages[Index] != 0) {
//
// RFC4646 language code
//
return FALSE;
}
//
// No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code
//
if (Index == 2) {
//
// Single RFC4646 language code without country code, e.g. "en"
//
return FALSE;
}
//
// Languages in format of ISO639-2
//
return TRUE;
}
BOOLEAN
EfiLibCompareLanguage (
IN CHAR8 *Language1,
IN CHAR8 *Language2
)
/*++
Routine Description:
Compare the first language instance of two language codes, either could be a
single language code or a language code list. This function assume Language1
and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646.
Arguments:
Language1 - The first language code to be tested.
Language2 - The second language code to be tested.
Returns:
TRUE - Language code match.
FALSE - Language code mismatch.
--*/
{
UINTN Index;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
for (Index = 0; (Language1[Index] != 0) && (Language2[Index] != 0); Index++) {
if (Language1[Index] != Language2[Index]) {
return FALSE;
}
//
// Compare first two bytes of language tag
//
if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {
return FALSE;
}
if (((Language1[Index] == 0) && (Language2[Index] == 0)) ||
((Language1[Index] == 0) && (Language2[Index] != ';')) ||
((Language1[Index] == ';') && (Language2[Index] != 0)) ||
((Language1[Index] == ';') && (Language2[Index] != ';'))) {
if (IsIso639LanguageCode (Language1)) {
//
// ISO639-2 language code, compare the third byte of language tag
//
return (BOOLEAN) ((Language1[2] == Language2[2]) ? TRUE : FALSE);
}
//
// RFC4646 language code
//
for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++);
if ((EfiAsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {
return TRUE;
}
return FALSE;
#else
for (Index = 0; Index < 3; Index++) {
if (Language1[Index] != Language2[Index]) {
return FALSE;
}
}
return TRUE;
#endif
}
STATIC
@@ -134,19 +217,39 @@ CHAR8 *
NextSupportedLanguage (
IN CHAR8 *Languages
)
{
#ifdef LANGUAGE_RFC_3066 // LANGUAGE_RFC_3066
for (; (*Languages != 0) && (*Languages != ';'); Languages++)
;
/*++
if (*Languages == ';') {
Languages++;
Routine Description:
Step to next language code of a language code list.
Arguments:
Languages - The language code list to traverse.
Returns:
Pointer to next language code or NULL terminator if it's the last one.
--*/
{
UINTN Index;
if (IsIso639LanguageCode (Languages)) {
//
// ISO639-2 language code
//
return (Languages + 3);
}
return Languages;
#else // LANGUAGE_ISO_639_2
return (Languages + 3);
#endif
//
// Search in RFC4646 language code list
//
for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);
if (Languages[Index] == ';') {
Index++;
}
return (Languages + Index);
}
EFI_STATUS
@@ -217,7 +320,7 @@ Returns:
return EFI_UNSUPPORTED;
}
SupportedLanguages = NextSupportedLanguage(SupportedLanguages);
SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;
@@ -326,7 +429,7 @@ Returns:
//
// Allocate space for a copy of the Language specifier
//
NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrLen(Language) + 1, Language);
NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrSize (Language), Language);
if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {
gBS->FreePool (NewUnicodeStringTable);
return EFI_OUT_OF_RESOURCES;
@@ -372,7 +475,7 @@ Returns:
return EFI_SUCCESS;
}
SupportedLanguages = NextSupportedLanguage(SupportedLanguages);
SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2004 - 2006, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 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
@@ -19,12 +19,85 @@ Abstract:
#include "Tiano.h"
#include "EfiDriverLib.h"
#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (DevicePath)
#include EFI_GUID_DEFINITION (Hob)
#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
STATIC EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
VOID
EFIAPI
OnStatusCodeInstall (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
EFI_STATUS_CODE_PROTOCOL *StatusCode;
Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **) &StatusCode);
if (!EFI_ERROR (Status)) {
gReportStatusCode = StatusCode->ReportStatusCode;
}
}
EFI_STATUS
GetPeiProtocol (
IN EFI_GUID *ProtocolGuid,
IN VOID **Interface
)
/*++
Routine Description:
Searches for a Protocol Interface passed from PEI through a HOB
Arguments:
ProtocolGuid - The Protocol GUID to search for in the HOB List
Interface - A pointer to the interface for the Protocol GUID
Returns:
EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
--*/
{
EFI_STATUS Status;
EFI_PEI_HOB_POINTERS GuidHob;
//
// Get Hob list
//
Status = EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &GuidHob.Raw);
if (EFI_ERROR (Status)) {
return Status;
}
for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
if (END_OF_HOB_LIST (GuidHob)) {
Status = EFI_NOT_FOUND;
break;
}
if (GET_HOB_TYPE (GuidHob) == EFI_HOB_TYPE_GUID_EXTENSION) {
if (EfiCompareGuid (ProtocolGuid, &GuidHob.Guid->Name)) {
Status = EFI_SUCCESS;
*Interface = (VOID *) *(UINTN *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
}
}
GuidHob.Raw = GET_NEXT_HOB (GuidHob);
}
return Status;
}
#endif
EFI_STATUS
@@ -59,18 +132,28 @@ Returns:
{
EFI_STATUS Status;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
if (gStatusCode == NULL) {
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
if (gReportStatusCode == NULL) {
//
// Because we've installed the protocol notification on EfiStatusCodeRuntimeProtocol,
// running here indicates that the StatusCode driver has not started yet.
//
if (gBS == NULL) {
//
// Running here only when StatusCode driver never starts.
//
return EFI_UNSUPPORTED;
}
Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
if (EFI_ERROR (Status) || gStatusCode == NULL) {
//
// Try to get the PEI version of ReportStatusCode.
//
Status = GetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **) &gReportStatusCode);
if (EFI_ERROR (Status)) {
return EFI_UNSUPPORTED;
}
}
Status = gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data);
return Status;
Status = gReportStatusCode (Type, Value, Instance, CallerId, Data);
#else
if (gRT == NULL) {
return EFI_UNSUPPORTED;
@@ -84,8 +167,8 @@ Returns:
gRT->ReportStatusCode != NULL) {
Status = gRT->ReportStatusCode (Type, Value, Instance, CallerId, Data);
}
return Status;
#endif
return Status;
}
EFI_STATUS

View File

@@ -1,6 +1,6 @@
#/*++
#
# Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2004 - 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
@@ -41,7 +41,6 @@ COMPONENT_TYPE = LIBRARY
$(EDK_SOURCE)/Foundation/Include/IndustryStandard
$(EDK_SOURCE)/Foundation/Core/Dxe
$(EDK_SOURCE)/Foundation/Library/Dxe/Include
$(EDK_SOURCE)/Foundation/Library/Dxe/EfiDriverLib
[libraries.common]
EfiGuidLib

View File

@@ -30,7 +30,6 @@ COMPONENT_TYPE = LIBRARY
[includes.common]
$(EDK_SOURCE)/Foundation/Framework
$(EDK_SOURCE)/Foundation/Efi
# $(EFI_SOURCE)/Framework
.
$(EDK_SOURCE)/Foundation/Include
$(EDK_SOURCE)/Foundation/Efi/Include

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2007 - 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
@@ -23,7 +23,6 @@ Revision History:
#define IS_DIGIT(Ch) (((Ch) >= L'0') && ((Ch) <= L'9'))
STATIC
EFI_STATUS
EfiStringToValue (
OUT UINT64 *Val,
@@ -37,8 +36,6 @@ Routine Description:
The returned value is 64-bit.
The string is expected in decimal format,
the string is parsed and format verified.
This function is missing from the libs. One day it maybe
replaced with a lib function when it'll become available.
Arguments:
Val - pointer to the variable to store the value to

View File

@@ -106,10 +106,8 @@ typedef struct {
CHAR16 *UnicodeString;
} EFI_UNICODE_STRING_TABLE;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
#define LANGUAGE_RFC_3066
#define LANGUAGE_CODE_ENGLISH "en-US"
#else
#define LANGUAGE_ISO_639_2
#define LANGUAGE_CODE_ENGLISH "eng"
#endif
@@ -1179,13 +1177,6 @@ EfiInitializeFwVolDevicepathNode (
Routine Description:
Initialize a Firmware Volume (FV) Media Device Path node.
Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
so as we move to UEFI 2.0 support we must use a mechanism that conforms with
the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
device path is defined for PIWG extensions of device path. If the code
is compiled to conform with the UEFI 2.0 specification use the new device path
else use the old form for backwards compatability.
Arguments:
FvDevicePathNode - Pointer to a FV device path node to initialize
NameGuid - FV file name to use in FvDevicePathNode
@@ -1202,15 +1193,6 @@ EfiGetNameGuidFromFwVolDevicePathNode (
Routine Description:
Check to see if the Firmware Volume (FV) Media Device Path is valid.
Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
so as we move to UEFI 2.0 support we must use a mechanism that conforms with
the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
device path is defined for PIWG extensions of device path. If the code
is compiled to conform with the UEFI 2.0 specification use the new device path
else use the old form for backwards compatability. The return value to this
function points to a location in FvDevicePathNode and it does not allocate
new memory for the GUID pointer that is returned.
Arguments:
FvDevicePathNode - Pointer to FV device path to check

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2004 - 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
@@ -202,4 +202,33 @@ Returns:
--*/
;
EFI_STATUS
EfiStringToValue (
OUT UINT64 *Val,
IN CHAR16 *String,
OUT UINT8 *EndIdx OPTIONAL
)
/*++
Routine Description:
Parses and converts Unicode string to decimal value.
The returned value is 64-bit.
The string is expected in decimal format,
the string is parsed and format verified.
Arguments:
Val - pointer to the variable to store the value to
String - string that contains the value to parse and convert
EndIdx - index on which the parsing stopped. It points to the
first character that was not part of the returned Val.
It's valid only if the function returns success.
It's optional and it could be NULL.
Returns:
EFI_SUCCESS - if successful
EFI_INVALID_PARAMETER - if String is in unexpected format
--*/
;
#endif

View File

@@ -1,6 +1,6 @@
#/*++
#
# Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2007 - 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
@@ -41,7 +41,6 @@ COMPONENT_TYPE = LIBRARY
$(EDK_SOURCE)/Foundation/Include/IndustryStandard
$(EDK_SOURCE)/Foundation/Core/Dxe
$(EDK_SOURCE)/Foundation/Library/Dxe/Include
$(EDK_SOURCE)/Foundation/Library/Dxe/EfiDriverLib
[libraries.common]
EfiGuidLib

View File

@@ -37,6 +37,7 @@ HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {
},
EFI_IFR_TIANO_GUID,
},
0,
0
},
{
@@ -181,22 +182,23 @@ Returns:
{
EFI_STATUS Status;
HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;
UINT64 MonotonicCount;
VendorDevicePath = EfiLibAllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);
if (VendorDevicePath == NULL) {
return EFI_OUT_OF_RESOURCES;
}
gBS->GetNextMonotonicCount (&MonotonicCount);
VendorDevicePath->MonotonicCount = (UINT32) MonotonicCount;
//
// Use memory address as unique ID to distinguish from different device paths
//
VendorDevicePath->UniqueId = (UINT64) ((UINTN) VendorDevicePath);
*DriverHandle = NULL;
Status = gBS->InstallProtocolInterface (
Status = gBS->InstallMultipleProtocolInterfaces (
DriverHandle,
&gEfiDevicePathProtocolGuid,
EFI_NATIVE_INTERFACE,
VendorDevicePath
VendorDevicePath,
NULL
);
if (EFI_ERROR (Status)) {
return Status;
@@ -240,7 +242,7 @@ Returns:
&gEfiDevicePathProtocolGuid,
DevicePath
);
gBS->FreePool (DevicePath);
return Status;
}
@@ -511,6 +513,7 @@ Arguments:
Returns:
EFI_SUCCESS - Successfully extract Class for specified Hii handle.
EFI_NOT_FOUND - Class not found.
--*/
{
@@ -525,10 +528,12 @@ Returns:
UINT32 Offset2;
UINT32 PackageListLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
BOOLEAN ClassFound;
*Class = EFI_NON_DEVICE_CLASS;
*FormSetTitle = 0;
*FormSetHelp = 0;
ClassFound = FALSE;
//
// Locate HII Database protocol
@@ -574,7 +579,7 @@ Returns:
Package = ((UINT8 *) HiiPackageList) + Offset;
EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
//
// Search Class Opcode in this Form Package
//
@@ -602,6 +607,139 @@ Returns:
//
// Till now, we ought to have found the formset Opcode
//
ClassFound = TRUE;
break;
}
Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
}
if (Offset2 < PackageHeader.Length) {
//
// Target formset found
//
break;
}
}
Offset += PackageHeader.Length;
}
gBS->FreePool (HiiPackageList);
return ClassFound ? EFI_SUCCESS : EFI_NOT_FOUND;
}
EFI_STATUS
ExtractClassGuidFromHiiHandle (
IN EFI_HII_HANDLE Handle,
OUT UINT8 *NumberOfClassGuid,
OUT EFI_GUID **ClassGuid,
OUT EFI_STRING_ID *FormSetTitle,
OUT EFI_STRING_ID *FormSetHelp
)
/*++
Routine Description:
Extract formset ClassGuid for given HII handle.
Arguments:
HiiHandle - Hii handle
NumberOfClassGuid - Number of ClassGuid
ClassGuid - Pointer to callee allocated buffer, an array of ClassGuid
FormSetTitle - Formset title string
FormSetHelp - Formset help string
Returns:
EFI_SUCCESS - Successfully extract Class for specified Hii handle.
--*/
{
EFI_STATUS Status;
UINTN BufferSize;
EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
UINT8 *Package;
UINT8 *FormSet;
UINT8 *OpCodeData;
UINT32 Offset;
UINT32 Offset2;
UINT32 PackageListLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
if (NumberOfClassGuid == NULL || ClassGuid == NULL || FormSetTitle == NULL || FormSetHelp == NULL) {
return EFI_INVALID_PARAMETER;
}
*NumberOfClassGuid = 0;
*ClassGuid = NULL;
*FormSetTitle = 0;
*FormSetHelp = 0;
//
// Locate HII Database protocol
//
Status = gBS->LocateProtocol (
&gEfiHiiDatabaseProtocolGuid,
NULL,
(VOID **) &HiiDatabase
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Get HII PackageList
//
BufferSize = 0;
HiiPackageList = NULL;
Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
if (Status == EFI_BUFFER_TOO_SMALL) {
HiiPackageList = EfiLibAllocatePool (BufferSize);
ASSERT (HiiPackageList != NULL);
Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
}
if (EFI_ERROR (Status)) {
return Status;
}
//
// Get Form package from this HII package List
//
Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
Offset2 = 0;
FormSet = NULL;
EfiCopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
while (Offset < PackageListLength) {
Package = ((UINT8 *) HiiPackageList) + Offset;
EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
//
// Search Class Opcode in this Form Package
//
Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
while (Offset2 < PackageHeader.Length) {
OpCodeData = Package + Offset2;
if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
//
// Find FormSet OpCode
//
EfiCopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
EfiCopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > ((UINTN) &((EFI_IFR_FORM_SET *) 0)->Flags)) {
//
// New version of formset OpCode
//
*NumberOfClassGuid = (UINT8) (((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3);
*ClassGuid = EfiLibAllocateCopyPool (
*NumberOfClassGuid * sizeof (EFI_GUID),
((EFI_IFR_FORM_SET *) OpCodeData)->ClassGuid
);
}
break;
}

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2007 - 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
@@ -26,7 +26,6 @@ Abstract:
//
UINT16 mFakeConfigHdr[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=0";
STATIC
EFI_STATUS
GetPackageDataFromPackageList (
IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
@@ -72,7 +71,6 @@ GetPackageDataFromPackageList (
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
UpdateFormPackageData (
IN EFI_GUID *FormSetGuid,
@@ -86,17 +84,15 @@ UpdateFormPackageData (
OUT UINT32 *TempBufferSize
)
{
UINTN AddSize;
UINT8 *BufferPos;
EFI_HII_PACKAGE_HEADER PackageHeader;
UINTN Offset;
UINT32 Offset;
EFI_IFR_OP_HEADER *IfrOpHdr;
BOOLEAN GetFormSet;
BOOLEAN GetForm;
UINT8 ExtendOpCode;
UINT16 LabelNumber;
BOOLEAN Updated;
EFI_IFR_OP_HEADER *AddOpCode;
if ((TempBuffer == NULL) || (TempBufferSize == NULL)) {
return EFI_INVALID_PARAMETER;
@@ -122,7 +118,7 @@ UpdateFormPackageData (
GetForm = FALSE;
Updated = FALSE;
while (Offset < PackageHeader.Length) {
while (!Updated && Offset < PackageHeader.Length) {
EfiCopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
BufferPos += IfrOpHdr->Length;
*TempBufferSize += IfrOpHdr->Length;
@@ -132,6 +128,8 @@ UpdateFormPackageData (
if (FormSetGuid != NULL) {
if (EfiCompareMem (&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid, sizeof (EFI_GUID)) == 0) {
GetFormSet = TRUE;
} else {
GetFormSet = FALSE;
}
}
break;
@@ -139,17 +137,24 @@ UpdateFormPackageData (
case EFI_IFR_FORM_OP:
if (EfiCompareMem (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
GetForm = TRUE;
} else {
GetForm = FALSE;
}
break;
case EFI_IFR_GUID_OP :
if (!GetFormSet || !GetForm || Updated) {
if (!GetFormSet || !GetForm) {
//
// Go to the next Op-Code
//
Offset += IfrOpHdr->Length;
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
continue;
break;
}
if (!EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid)) {
//
// GUID mismatch, skip this op-code
//
break;
}
ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
@@ -158,29 +163,18 @@ UpdateFormPackageData (
//
// Go to the next Op-Code
//
Offset += IfrOpHdr->Length;
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
continue;
break;
}
if (Insert && (Data != NULL)) {
if (Insert) {
//
// insert the DataCount amount of opcodes to TempBuffer if Data is NULL remove
// DataCount amount of opcodes unless runing into a label.
// Insert data after current Label, skip myself
//
AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;
AddSize = 0;
while (AddSize < Data->Offset) {
EfiCopyMem (BufferPos, AddOpCode, AddOpCode->Length);
BufferPos += AddOpCode->Length;
*TempBufferSize += AddOpCode->Length;
AddSize += AddOpCode->Length;
AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);
}
Offset += IfrOpHdr->Length;
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
} else {
//
// Search the next Label.
// Replace data between two paired Label, try to find the next Label.
//
while (TRUE) {
Offset += IfrOpHdr->Length;
@@ -193,33 +187,28 @@ UpdateFormPackageData (
IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
if (IfrOpHdr->OpCode == EFI_IFR_GUID_OP) {
ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
if (ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {
if (EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid) && ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {
break;
}
}
}
if (Data != NULL) {
AddOpCode = (EFI_IFR_OP_HEADER *)Data->Data;
AddSize = 0;
while (AddSize < Data->Offset) {
EfiCopyMem (BufferPos, AddOpCode, AddOpCode->Length);
BufferPos += AddOpCode->Length;
*TempBufferSize += AddOpCode->Length;
AddSize += AddOpCode->Length;
AddOpCode = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (AddOpCode) + AddOpCode->Length);
}
}
//
// copy the next label
//
EfiCopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
BufferPos += IfrOpHdr->Length;
*TempBufferSize += IfrOpHdr->Length;
}
//
// Fill in the update data
//
if (Data != NULL) {
EfiCopyMem (BufferPos, Data->Data, Data->Offset);
BufferPos += Data->Offset;
*TempBufferSize += Data->Offset;
}
//
// Copy the reset data
//
EfiCopyMem (BufferPos, IfrOpHdr, PackageHeader.Length - Offset);
*TempBufferSize += PackageHeader.Length - Offset;
Updated = TRUE;
break;
default :
@@ -249,6 +238,68 @@ Fail:
return EFI_SUCCESS;
}
EFI_STATUS
IfrLibInitUpdateData (
IN OUT EFI_HII_UPDATE_DATA *UpdateData,
IN UINT32 BufferSize
)
/*++
Routine Description:
This function initialize the data structure for dynamic opcode.
Arguments:
UpdateData - The adding data;
BufferSize - Length of the buffer to fill dynamic opcodes.
Returns:
EFI_SUCCESS - Update data is initialized.
EFI_INVALID_PARAMETER - UpdateData is NULL.
EFI_OUT_OF_RESOURCES - No enough memory to allocate.
--*/
{
if (UpdateData == NULL) {
return EFI_INVALID_PARAMETER;
}
UpdateData->BufferSize = BufferSize;
UpdateData->Offset = 0;
UpdateData->Data = EfiLibAllocatePool (BufferSize);
return (UpdateData->Data != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
}
EFI_STATUS
IfrLibFreeUpdateData (
IN EFI_HII_UPDATE_DATA *UpdateData
)
/*++
Routine Description:
This function free the resource of update data.
Arguments:
UpdateData - The adding data;
Returns:
EFI_SUCCESS - Resource in UpdateData is released.
EFI_INVALID_PARAMETER - UpdateData is NULL.
--*/
{
EFI_STATUS Status;
if (UpdateData == NULL) {
return EFI_INVALID_PARAMETER;
}
Status = gBS->FreePool (UpdateData->Data);
UpdateData->Data = NULL;
return Status;
}
EFI_STATUS
IfrLibUpdateForm (
IN EFI_HII_HANDLE Handle,
@@ -339,7 +390,7 @@ Returns:
Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);
if (Status == EFI_SUCCESS) {
EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
if ((PackageHeader.Type == EFI_HII_PACKAGE_FORM) && !Updated) {
if ((PackageHeader.Type == EFI_HII_PACKAGE_FORMS) && !Updated) {
Status = UpdateFormPackageData (FormSetGuid, FormId, Package, PackageLength, Label, Insert, Data, (UINT8 **)&TempBuffer, &TempBufferSize);
if (!EFI_ERROR(Status)) {
if (FormSetGuid == NULL) {
@@ -644,7 +695,376 @@ ExtractDefault(
return EFI_SUCCESS;
}
STATIC
EFI_STATUS
ExtractBlockName (
IN UINT8 *Buffer,
OUT CHAR16 **BlockName
)
/*++
Routine Description:
Extract block name from the array generated by VFR compiler. The name of
this array is "Vfr + <StorageName> + BlockName", e.g. "VfrMyIfrNVDataBlockName".
Format of this array is:
Array length | 4-bytes
Offset | 2-bytes
Width | 2-bytes
Offset | 2-bytes
Width | 2-bytes
... ...
Arguments:
Buffer - Array generated by VFR compiler.
BlockName - The returned <BlockName>
Returns:
EFI_OUT_OF_RESOURCES - Run out of memory resource.
EFI_INVALID_PARAMETER - Buffer is NULL or BlockName is NULL.
EFI_SUCCESS - Operation successful.
--*/
{
UINTN Index;
UINT32 Length;
UINT32 BlockNameNumber;
UINTN HexStringBufferLen;
CHAR16 *StringPtr;
if ((Buffer == NULL) || (BlockName == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Calculate number of Offset/Width pair
//
EfiCopyMem (&Length, Buffer, sizeof (UINT32));
BlockNameNumber = (Length - sizeof (UINT32)) / (sizeof (UINT16) * 2);
//
// <BlockName> ::= &OFFSET=1234&WIDTH=1234
// | 8 | 4 | 7 | 4 |
//
StringPtr = EfiLibAllocateZeroPool ((BlockNameNumber * (8 + 4 + 7 + 4) + 1) * sizeof (CHAR16));
*BlockName = StringPtr;
if (StringPtr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
Buffer += sizeof (UINT32);
for (Index = 0; Index < BlockNameNumber; Index++) {
EfiStrCpy (StringPtr, L"&OFFSET=");
StringPtr += 8;
HexStringBufferLen = 5;
BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
Buffer += sizeof (UINT16);
StringPtr += 4;
EfiStrCpy (StringPtr, L"&WIDTH=");
StringPtr += 7;
HexStringBufferLen = 5;
BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
Buffer += sizeof (UINT16);
StringPtr += 4;
}
return EFI_SUCCESS;
}
EFI_STATUS
ExtractBlockConfig (
IN UINT8 *Buffer,
OUT CHAR16 **BlockConfig
)
/*++
Routine Description:
Extract block config from the array generated by VFR compiler. The name of
this array is "Vfr + <StorageName> + Default<HexCh>4", e.g. "VfrMyIfrNVDataDefault0000".
Arguments:
Buffer - Array generated by VFR compiler.
BlockConfig - The returned <BlockConfig>
Returns:
EFI_OUT_OF_RESOURCES - Run out of memory resource.
EFI_INVALID_PARAMETER - Buffer is NULL or BlockConfig is NULL.
EFI_SUCCESS - Operation successful.
--*/
{
UINT32 Length;
UINT16 Width;
UINTN HexStringBufferLen;
CHAR16 *StringPtr;
UINT8 *BufferEnd;
CHAR16 *StringEnd;
EFI_STATUS Status;
if ((Buffer == NULL) || (BlockConfig == NULL)) {
return EFI_INVALID_PARAMETER;
}
//
// Calculate length of AltResp string
// Format of Default value array is:
// Array length | 4-bytes
// Offset | 2-bytes
// Width | 2-bytes
// Value | Variable length
// Offset | 2-bytes
// Width | 2-bytes
// Value | Variable length
// ... ...
// When value is 1 byte in length, overhead of AltResp string will be maximum,
// BlockConfig ::= <&OFFSET=1234&WIDTH=1234&VALUE=12>+
// | 8 | 4 | 7 | 4 | 7 |2|
// so the maximum length of BlockConfig could be calculated as:
// (ArrayLength / 5) * (8 + 4 + 7 + 4 + 7 + 2) = ArrayLength * 6.4 < ArrayLength * 7
//
EfiCopyMem (&Length, Buffer, sizeof (UINT32));
BufferEnd = Buffer + Length;
StringPtr = EfiLibAllocatePool (Length * 7 * sizeof (CHAR16));
*BlockConfig = StringPtr;
if (StringPtr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
StringEnd = StringPtr + (Length * 7);
Buffer += sizeof (UINT32);
while (Buffer < BufferEnd) {
EfiStrCpy (StringPtr, L"&OFFSET=");
StringPtr += 8;
HexStringBufferLen = 5;
BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
Buffer += sizeof (UINT16);
StringPtr += 4;
EfiStrCpy (StringPtr, L"&WIDTH=");
StringPtr += 7;
HexStringBufferLen = 5;
BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
EfiCopyMem (&Width, Buffer, sizeof (UINT16));
Buffer += sizeof (UINT16);
StringPtr += 4;
EfiStrCpy (StringPtr, L"&VALUE=");
StringPtr += 7;
HexStringBufferLen = StringEnd - StringPtr;
Status = BufToHexString (StringPtr, &HexStringBufferLen, Buffer, Width);
if (EFI_ERROR (Status)) {
return Status;
}
Buffer += Width;
StringPtr += (Width * 2);
}
return EFI_SUCCESS;
}
EFI_STATUS
ConstructConfigAltResp (
IN EFI_STRING ConfigRequest, OPTIONAL
OUT EFI_STRING *Progress,
OUT EFI_STRING *ConfigAltResp,
IN EFI_GUID *Guid,
IN CHAR16 *Name,
IN EFI_HANDLE *DriverHandle,
IN VOID *BufferStorage,
IN UINTN BufferStorageSize,
IN VOID *BlockNameArray, OPTIONAL
IN UINTN NumberAltCfg,
...
//IN UINT16 AltCfgId,
//IN VOID *DefaultValueArray,
)
/*++
Routine Description:
Construct <ConfigAltResp> for a buffer storage.
Arguments:
ConfigRequest - The Config request string. If set to NULL, all the
configurable elements will be extracted from BlockNameArray.
ConfigAltResp - The returned <ConfigAltResp>.
Progress - On return, points to a character in the Request.
Guid - GUID of the buffer storage.
Name - Name of the buffer storage.
DriverHandle - The DriverHandle which is used to invoke HiiDatabase
protocol interface NewPackageList().
BufferStorage - Content of the buffer storage.
BufferStorageSize - Length in bytes of the buffer storage.
BlockNameArray - Array generated by VFR compiler.
NumberAltCfg - Number of Default value array generated by VFR compiler.
The sequential input parameters will be number of
AltCfgId and DefaultValueArray pairs. When set to 0,
there will be no <AltResp>.
Returns:
EFI_OUT_OF_RESOURCES - Run out of memory resource.
EFI_INVALID_PARAMETER - ConfigAltResp is NULL.
EFI_SUCCESS - Operation successful.
--*/
{
EFI_STATUS Status;
CHAR16 *ConfigHdr;
CHAR16 *BlockName;
CHAR16 *DescHdr;
CHAR16 *StringPtr;
CHAR16 **AltCfg;
UINT16 AltCfgId;
VOID *DefaultValueArray;
UINTN StrBufferLen;
EFI_STRING ConfigResp;
EFI_STRING TempStr;
VA_LIST Args;
UINTN AltRespLen;
UINTN Index;
BOOLEAN NeedFreeConfigRequest;
EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
if (ConfigAltResp == NULL) {
return EFI_INVALID_PARAMETER;
}
//
// Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..."
//
ConfigHdr = NULL;
StrBufferLen = 0;
Status = ConstructConfigHdr (
ConfigHdr,
&StrBufferLen,
Guid,
Name,
DriverHandle
);
if (Status == EFI_BUFFER_TOO_SMALL) {
ConfigHdr = EfiLibAllocateZeroPool (StrBufferLen);
Status = ConstructConfigHdr (
ConfigHdr,
&StrBufferLen,
Guid,
Name,
DriverHandle
);
}
if (EFI_ERROR (Status)) {
return Status;
}
//
// Construct <ConfigResp>
//
NeedFreeConfigRequest = FALSE;
if (ConfigRequest == NULL) {
//
// If ConfigRequest is set to NULL, export all configurable elements in BlockNameArray
//
Status = ExtractBlockName (BlockNameArray, &BlockName);
if (EFI_ERROR (Status)) {
return Status;
}
StrBufferLen = EfiStrSize (ConfigHdr);
StrBufferLen = StrBufferLen + EfiStrSize (BlockName) - sizeof (CHAR16);
ConfigRequest = EfiLibAllocateZeroPool (StrBufferLen);
EfiStrCpy (ConfigRequest, ConfigHdr);
EfiStrCat (ConfigRequest, BlockName);
NeedFreeConfigRequest = TRUE;
}
Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);
if (EFI_ERROR (Status)) {
return Status;
}
Status = HiiConfigRouting->BlockToConfig (
HiiConfigRouting,
ConfigRequest,
BufferStorage,
BufferStorageSize,
&ConfigResp,
(Progress == NULL) ? &TempStr : Progress
);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Construct <AltResp>
//
DescHdr = EfiLibAllocateZeroPool (NumberAltCfg * 16 * sizeof (CHAR16));
StringPtr = DescHdr;
AltCfg = EfiLibAllocateZeroPool (NumberAltCfg * sizeof (CHAR16 *));
AltRespLen = 0;
VA_START (Args, NumberAltCfg);
for (Index = 0; Index < NumberAltCfg; Index++) {
AltCfgId = (UINT16) VA_ARG (Args, UINT16);
DefaultValueArray = (UINT8 *) VA_ARG (Args, VOID *);
//
// '&' <ConfigHdr>
//
AltRespLen += (EfiStrLen (ConfigHdr) + 1);
StringPtr = DescHdr + Index * 16;
EfiStrCpy (StringPtr, L"&ALTCFG=");
AltRespLen += (8 + sizeof (UINT16) * 2);
StrBufferLen = 5;
BufToHexString (StringPtr + 8, &StrBufferLen, (UINT8 *) &AltCfgId, sizeof (UINT16));
Status = ExtractBlockConfig (DefaultValueArray, &AltCfg[Index]);
if (EFI_ERROR (Status)) {
return Status;
}
AltRespLen += EfiStrLen (AltCfg[Index]);
}
VA_END (Args);
//
// Generate the final <ConfigAltResp>
//
StrBufferLen = (EfiStrLen ((CHAR16 *) ConfigResp) + AltRespLen + 1) * sizeof (CHAR16);
TempStr = EfiLibAllocateZeroPool (StrBufferLen);
*ConfigAltResp = TempStr;
if (TempStr == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// <ConfigAltResp> ::= <ConfigResp> ['&' <AltResp>]*
//
EfiStrCpy (TempStr, ConfigResp);
for (Index = 0; Index < NumberAltCfg; Index++) {
EfiStrCat (TempStr, L"&");
EfiStrCat (TempStr, ConfigHdr);
EfiStrCat (TempStr, DescHdr + Index * 16);
EfiStrCat (TempStr, AltCfg[Index]);
gBS->FreePool (AltCfg[Index]);
}
if (NeedFreeConfigRequest) {
gBS->FreePool (ConfigRequest);
}
gBS->FreePool (ConfigHdr);
gBS->FreePool (ConfigResp);
gBS->FreePool (DescHdr);
gBS->FreePool (AltCfg);
return EFI_SUCCESS;
}
VOID
SwapBuffer (
IN OUT UINT8 *Buffer,
@@ -668,7 +1088,7 @@ Returns:
UINT8 Temp;
UINTN SwapCount;
SwapCount = (BufferSize - 1) / 2;
SwapCount = BufferSize / 2;
for (Index = 0; Index < SwapCount; Index++) {
Temp = Buffer[Index];
Buffer[Index] = Buffer[BufferSize - 1 - Index];
@@ -676,6 +1096,31 @@ Returns:
}
}
VOID
ToLower (
IN OUT CHAR16 *Str
)
/*++
Routine Description:
Converts the unicode character of the string from uppercase to lowercase.
Arguments:
Str - String to be converted
Returns:
--*/
{
CHAR16 *Ptr;
for (Ptr = Str; *Ptr != L'\0'; Ptr++) {
if (*Ptr >= L'A' && *Ptr <= L'Z') {
*Ptr = (CHAR16) (*Ptr - L'A' + L'a');
}
}
}
EFI_STATUS
BufferToHexString (
IN OUT CHAR16 *Str,
@@ -704,10 +1149,14 @@ Returns:
NewBuffer = EfiLibAllocateCopyPool (BufferSize, Buffer);
SwapBuffer (NewBuffer, BufferSize);
StrBufferLen = (BufferSize + 1) * sizeof (CHAR16);
StrBufferLen = BufferSize * 2 + 1;
Status = BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize);
gBS->FreePool (NewBuffer);
//
// Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
//
ToLower (Str);
return Status;
}
@@ -741,12 +1190,138 @@ Returns:
ConvertedStrLen = 0;
Status = HexStringToBuf (Buffer, BufferSize, Str, &ConvertedStrLen);
if (!EFI_ERROR (Status)) {
SwapBuffer (Buffer, ConvertedStrLen);
SwapBuffer (Buffer, (ConvertedStrLen + 1) / 2);
}
return Status;
}
EFI_STATUS
ConfigStringToUnicode (
IN OUT CHAR16 *UnicodeString,
IN OUT UINTN *StrBufferLen,
IN CHAR16 *ConfigString
)
/*++
Routine Description:
Convert binary representation Config string (e.g. "0041004200430044") to the
original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
"&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
Arguments:
UnicodeString - Original Unicode string.
StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
Includes tailing '\0' character.
On output:
If return EFI_SUCCESS, containing length of Unicode string buffer.
If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
Returns:
EFI_SUCCESS - Routine success.
EFI_BUFFER_TOO_SMALL - The string buffer is too small.
--*/
{
UINTN Index;
UINTN Len;
UINTN BufferSize;
CHAR16 BackupChar;
Len = EfiStrLen (ConfigString) / 4;
BufferSize = (Len + 1) * sizeof (CHAR16);
if (*StrBufferLen < BufferSize) {
*StrBufferLen = BufferSize;
return EFI_BUFFER_TOO_SMALL;
}
*StrBufferLen = BufferSize;
for (Index = 0; Index < Len; Index++) {
BackupChar = ConfigString[4];
ConfigString[4] = L'\0';
HexStringToBuf ((UINT8 *) UnicodeString, &BufferSize, ConfigString, NULL);
ConfigString[4] = BackupChar;
ConfigString += 4;
UnicodeString += 1;
}
//
// Add tailing '\0' character
//
*UnicodeString = L'\0';
return EFI_SUCCESS;
}
EFI_STATUS
UnicodeToConfigString (
IN OUT CHAR16 *ConfigString,
IN OUT UINTN *StrBufferLen,
IN CHAR16 *UnicodeString
)
/*++
Routine Description:
Convert Unicode string to binary representation Config string, e.g.
"ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
"&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
Arguments:
ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
Includes tailing '\0' character.
On output:
If return EFI_SUCCESS, containing length of Unicode string buffer.
If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
UnicodeString - Original Unicode string.
Returns:
EFI_SUCCESS - Routine success.
EFI_BUFFER_TOO_SMALL - The string buffer is too small.
--*/
{
UINTN Index;
UINTN Len;
UINTN BufferSize;
CHAR16 *String;
Len = EfiStrLen (UnicodeString);
BufferSize = (Len * 4 + 1) * sizeof (CHAR16);
if (*StrBufferLen < BufferSize) {
*StrBufferLen = BufferSize;
return EFI_BUFFER_TOO_SMALL;
}
*StrBufferLen = BufferSize;
String = ConfigString;
for (Index = 0; Index < Len; Index++) {
BufToHexString (ConfigString, &BufferSize, (UINT8 *) UnicodeString, 2);
ConfigString += 4;
UnicodeString += 1;
}
//
// Add tailing '\0' character
//
*ConfigString = L'\0';
//
// Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
//
ToLower (String);
return EFI_SUCCESS;
}
EFI_STATUS
ConstructConfigHdr (
IN OUT CHAR16 *ConfigHdr,
@@ -811,10 +1386,10 @@ Returns:
DevicePathSize = EfiDevicePathSize (DevicePath);
//
// GUID=<HexCh>32&NAME=<Alpha>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
// | 5 | 32 | 6 | NameStrLen | 6 | DevicePathStrLen |
// GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
// | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
//
BufferSize = (5 + 32 + 6 + NameStrLen + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
BufferSize = (5 + 32 + 6 + NameStrLen * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
if (*StrBufferLen < BufferSize) {
*StrBufferLen = BufferSize;
return EFI_BUFFER_TOO_SMALL;
@@ -829,11 +1404,15 @@ Returns:
BufferToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID));
StrPtr += 32;
//
// Convert name string, e.g. name "ABCD" => "&NAME=0041004200430044"
//
EfiStrCpy (StrPtr, L"&NAME=");
StrPtr += 6;
if (Name != NULL) {
EfiStrCpy (StrPtr, Name);
StrPtr += NameStrLen;
BufferSize = (NameStrLen * 4 + 1) * sizeof (CHAR16);
UnicodeToConfigString (StrPtr, &BufferSize, Name);
StrPtr += (NameStrLen * 4);
}
EfiStrCpy (StrPtr, L"&PATH=");
@@ -843,6 +1422,105 @@ Returns:
return EFI_SUCCESS;
}
BOOLEAN
IsConfigHdrMatch (
IN EFI_STRING ConfigString,
IN EFI_GUID *StorageGuid, OPTIONAL
IN CHAR16 *StorageName OPTIONAL
)
/*++
Routine Description:
Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
Arguments:
ConfigString - Either <ConfigRequest> or <ConfigResp>.
StorageGuid - GUID of the storage.
StorageName - Name of the stoarge.
Returns:
TRUE - Routing information is correct in ConfigString.
FALSE - Routing information is incorrect in ConfigString.
--*/
{
EFI_STATUS Status;
BOOLEAN Match;
EFI_GUID Guid;
CHAR16 *Name;
CHAR16 *StrPtr;
UINTN BufferSize;
//
// <ConfigHdr> ::=
// GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
// | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
//
if (EfiStrLen (ConfigString) <= (5 + 32 + 6)) {
return FALSE;
}
//
// Compare GUID
//
if (StorageGuid != NULL) {
StrPtr = ConfigString + 5 + 32;
if (*StrPtr != L'&') {
return FALSE;
}
*StrPtr = L'\0';
BufferSize = sizeof (EFI_GUID);
Status = HexStringToBuffer (
(UINT8 *) &Guid,
&BufferSize,
ConfigString + 5
);
*StrPtr = L'&';
if (EFI_ERROR (Status)) {
return FALSE;
}
if (!EfiCompareGuid (&Guid, StorageGuid)) {
return FALSE;
}
}
//
// Compare Name
//
Match = TRUE;
if (StorageName != NULL) {
StrPtr = ConfigString + 5 + 32 + 6;
while (*StrPtr != L'\0' && *StrPtr != L'&') {
StrPtr++;
}
if (*StrPtr != L'&') {
return FALSE;
}
*StrPtr = L'\0';
BufferSize = (EfiStrLen (ConfigString + 5 + 32 + 6) + 1) * sizeof (CHAR16);
Name = EfiLibAllocatePool (BufferSize);
ASSERT (Name != NULL);
Status = ConfigStringToUnicode (
Name,
&BufferSize,
ConfigString + 5 + 32 + 6
);
*StrPtr = L'&';
if (EFI_ERROR (Status) || (EfiStrCmp (Name, StorageName) != 0)) {
Match = FALSE;
}
gBS->FreePool (Name);
}
return Match;
}
BOOLEAN
FindBlockName (
IN OUT CHAR16 *String,
@@ -965,7 +1643,7 @@ Returns:
HeaderLen = EfiStrLen (ConfigHdr);
BufferLen = 0x4000;
ConfigResp = EfiLibAllocateZeroPool (BufferLen + HeaderLen);
ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));
StringPtr = ConfigResp + HeaderLen;
*StringPtr = L'&';
@@ -981,7 +1659,7 @@ Returns:
);
if (Status == EFI_BUFFER_TOO_SMALL) {
gBS->FreePool (ConfigResp);
ConfigResp = EfiLibAllocateZeroPool (BufferLen + HeaderLen);
ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));
StringPtr = ConfigResp + HeaderLen;
*StringPtr = L'&';
@@ -1116,7 +1794,7 @@ Returns:
&Progress
);
if (EFI_ERROR (Status)) {
gBS->FreePool (ConfigResp);
gBS->FreePool (ConfigRequest);
return Status;
}
@@ -1133,9 +1811,10 @@ Returns:
&BufferSize,
StringPtr,
FALSE,
NULL,
NULL
VariableGuid,
VariableName
);
gBS->FreePool (ConfigResp);
gBS->FreePool (ConfigRequest);
return Status;
}

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2007 - 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
@@ -78,10 +78,13 @@ typedef struct {
} IFR_OPTION;
#pragma pack()
#pragma pack(1)
typedef struct {
VENDOR_DEVICE_PATH VendorDevicePath;
UINT32 MonotonicCount;
UINT32 Reserved;
UINT64 UniqueId;
} HII_VENDOR_DEVICE_PATH_NODE;
#pragma pack()
typedef struct {
HII_VENDOR_DEVICE_PATH_NODE Node;
@@ -280,7 +283,8 @@ CreateOneOfOptionOpCode (
IN IFR_OPTION *OptionsList,
IN UINT8 Type,
IN OUT EFI_HII_UPDATE_DATA *Data
);
)
;
EFI_STATUS
CreateOneOfOpCode (
@@ -599,6 +603,53 @@ ExtractDefault(
--*/
;
EFI_STATUS
ConstructConfigAltResp (
IN EFI_STRING ConfigRequest, OPTIONAL
OUT EFI_STRING *Progress,
OUT EFI_STRING *ConfigAltResp,
IN EFI_GUID *Guid,
IN CHAR16 *Name,
IN EFI_HANDLE *DriverHandle,
IN VOID *BufferStorage,
IN UINTN BufferStorageSize,
IN VOID *BlockNameArray, OPTIONAL
IN UINTN NumberAltCfg,
...
//IN UINT16 AltCfgId,
//IN VOID *DefaultValueArray,
)
/*++
Routine Description:
Construct <ConfigAltResp> for a buffer storage.
Arguments:
ConfigRequest - The Config request string. If set to NULL, all the
configurable elements will be extracted from BlockNameArray.
ConfigAltResp - The returned <ConfigAltResp>.
Progress - On return, points to a character in the Request.
Guid - GUID of the buffer storage.
Name - Name of the buffer storage.
DriverHandle - The DriverHandle which is used to invoke HiiDatabase
protocol interface NewPackageList().
BufferStorage - Content of the buffer storage.
BufferStorageSize - Length in bytes of the buffer storage.
BlockNameArray - Array generated by VFR compiler.
NumberAltCfg - Number of Default value array generated by VFR compiler.
The sequential input parameters will be number of
AltCfgId and DefaultValueArray pairs. When set to 0,
there will be no <AltResp>.
Returns:
EFI_OUT_OF_RESOURCES - Run out of memory resource.
EFI_INVALID_PARAMETER - ConfigAltResp is NULL.
EFI_SUCCESS - Operation successful.
--*/
;
EFI_STATUS
ExtractGuidFromHiiHandle (
IN EFI_HII_HANDLE Handle,
@@ -643,6 +694,49 @@ Returns:
--*/
;
EFI_STATUS
ExtractClassGuidFromHiiHandle (
IN EFI_HII_HANDLE Handle,
OUT UINT8 *NumberOfClassGuid,
OUT EFI_GUID **ClassGuid,
OUT EFI_STRING_ID *FormSetTitle,
OUT EFI_STRING_ID *FormSetHelp
)
/*++
Routine Description:
Extract formset ClassGuid for given HII handle.
Arguments:
HiiHandle - Hii handle
NumberOfClassGuid - Number of ClassGuid
ClassGuid - Pointer to callee allocated buffer, an array of ClassGuid
FormSetTitle - Formset title string
FormSetHelp - Formset help string
Returns:
EFI_SUCCESS - Successfully extract Class for specified Hii handle.
--*/
;
VOID
ToLower (
IN OUT CHAR16 *Str
)
/*++
Routine Description:
Converts the unicode character from uppercase to lowercase.
Arguments:
Str - String to be converted
Returns:
--*/
;
EFI_STATUS
BufferToHexString (
IN OUT CHAR16 *Str,
@@ -689,6 +783,64 @@ Returns:
--*/
;
EFI_STATUS
ConfigStringToUnicode (
IN OUT CHAR16 *UnicodeString,
IN OUT UINTN *StrBufferLen,
IN CHAR16 *ConfigString
)
/*++
Routine Description:
Convert binary representation Config string (e.g. "0041004200430044") to the
original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
"&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
Arguments:
UnicodeString - Original Unicode string.
StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
Includes tailing '\0' character.
On output:
If return EFI_SUCCESS, containing length of Unicode string buffer.
If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
Returns:
EFI_SUCCESS - Routine success.
EFI_BUFFER_TOO_SMALL - The string buffer is too small.
--*/
;
EFI_STATUS
UnicodeToConfigString (
IN OUT CHAR16 *ConfigString,
IN OUT UINTN *StrBufferLen,
IN CHAR16 *UnicodeString
)
/*++
Routine Description:
Convert Unicode string to binary representation Config string, e.g.
"ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
"&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
Arguments:
ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
Includes tailing '\0' character.
On output:
If return EFI_SUCCESS, containing length of Unicode string buffer.
If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
UnicodeString - Original Unicode string.
Returns:
EFI_SUCCESS - Routine success.
EFI_BUFFER_TOO_SMALL - The string buffer is too small.
--*/
;
EFI_STATUS
ConstructConfigHdr (
IN OUT CHAR16 *ConfigHdr,
@@ -719,6 +871,29 @@ Returns:
--*/
;
BOOLEAN
IsConfigHdrMatch (
IN EFI_STRING ConfigString,
IN EFI_GUID *StorageGuid, OPTIONAL
IN CHAR16 *StorageName OPTIONAL
)
/*++
Routine Description:
Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
Arguments:
ConfigString - Either <ConfigRequest> or <ConfigResp>.
StorageGuid - GUID of the storage.
StorageName - Name of the stoarge.
Returns:
TRUE - Routing information is correct in ConfigString.
FALSE - Routing information is incorrect in ConfigString.
--*/
;
BOOLEAN
FindBlockName (
IN OUT CHAR16 *String,
@@ -1093,6 +1268,47 @@ Returns:
--*/
;
EFI_STATUS
IfrLibInitUpdateData (
IN OUT EFI_HII_UPDATE_DATA *UpdateData,
IN UINT32 BufferSize
)
/*++
Routine Description:
This function initialize the data structure for dynamic opcode.
Arguments:
UpdateData - The adding data;
BufferSize - Length of the buffer to fill dynamic opcodes.
Returns:
EFI_SUCCESS - Update data is initialized.
EFI_INVALID_PARAMETER - UpdateData is NULL.
EFI_OUT_OF_RESOURCES - No enough memory to allocate.
--*/
;
EFI_STATUS
IfrLibFreeUpdateData (
IN EFI_HII_UPDATE_DATA *UpdateData
)
/*++
Routine Description:
This function free the resource of update data.
Arguments:
UpdateData - The adding data;
Returns:
EFI_SUCCESS - Resource in UpdateData is released.
EFI_INVALID_PARAMETER - UpdateData is NULL.
--*/
;
EFI_STATUS
IfrLibUpdateForm (
IN EFI_HII_HANDLE Handle,

View File

@@ -1,6 +1,6 @@
/*++
Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2007 - 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
@@ -394,9 +394,7 @@ CreateOrderedListOpCode (
return EFI_INVALID_PARAMETER;
}
if ((OrderedListFlags != 0) &&
(OrderedListFlags != EFI_IFR_UNIQUE_SET) &&
(OrderedListFlags != EFI_IFR_NO_EMPTY_SET)) {
if ((OrderedListFlags & (~(EFI_IFR_UNIQUE_SET | EFI_IFR_NO_EMPTY_SET))) != 0) {
return EFI_INVALID_PARAMETER;
}

View File

@@ -555,20 +555,37 @@ IfrLibNewString (
if (Languages == NULL) {
return EFI_NOT_FOUND;
}
if (StringId == NULL) {
return EFI_INVALID_PARAMETER;
}
*StringId = 0;
LangStrings = Languages;
while (*LangStrings != 0) {
GetNextLanguage (&LangStrings, Lang);
Status = gIfrLibHiiString->NewString (
gIfrLibHiiString,
PackageList,
StringId,
Lang,
NULL,
String,
NULL
);
if (*StringId == 0) {
Status = gIfrLibHiiString->NewString (
gIfrLibHiiString,
PackageList,
StringId,
Lang,
NULL,
String,
NULL
);
} else {
Status = gIfrLibHiiString->SetString (
gIfrLibHiiString,
PackageList,
*StringId,
Lang,
String,
NULL
);
}
if (EFI_ERROR (Status)) {
break;
}