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