summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Foundation/Library
diff options
context:
space:
mode:
Diffstat (limited to 'EdkCompatibilityPkg/Foundation/Library')
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c29
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c179
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c101
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf3
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf1
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c5
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h31
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf3
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c154
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c805
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h222
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c35
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c160
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c95
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h13
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h19
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c15
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c32
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c8
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c257
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c166
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c100
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm6
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c9
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c10
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm2
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c17
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c14
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h12
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c82
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c16
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h4
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c5
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c176
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c30
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c176
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S24
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S18
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm21
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h9
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm26
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S20
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm24
-rw-r--r--EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c96
63 files changed, 2815 insertions, 637 deletions
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
index d0aef2f1b6..72f19fbca7 100644
--- a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
@@ -34,8 +34,8 @@ COMPONENT_TYPE = LIBRARY
memset.c | GCC
[sources.x64]
- x64/memcpyRep1.asm | MSFT
- x64/memcpyRep1.asm | INTEL
+ x64/memcpyRep4.asm | MSFT
+ x64/memcpyRep4.asm | INTEL
x64/memsetRep4.asm | MSFT
x64/memsetRep4.asm | INTEL
memcpy.c | GCC
diff --git a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf
index 909ee60936..bbe3f33d5d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/CompilerStub/CompilerStubLib_Edk2.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
@@ -34,7 +34,7 @@ COMPONENT_TYPE = LIBRARY
[sources.x64]
memcpy.c | GCC
- x64/memcpyRep1.asm
+ x64/memcpyRep4.asm
x64/memsetRep4.asm
# x64/memcpy.asm
# x64/memset.asm
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
index 568ac12613..daa01a29a7 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
@@ -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;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
index 3de6c59dc2..ef10d41702 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
@@ -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
+IsIso639LanguageCode (
+ IN CHAR8 *Languages
+ )
+/*++
+
+Routine Description:
+
+ Tests whether a language code has format of ISO639-2.
+
+Arguments:
+
+ Languages - The language code to be tested.
+
+Returns:
+
+ 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
+ IN CHAR8 *Language1,
+ IN CHAR8 *Language2
)
/*++
Routine Description:
- Compare whether two names of languages are identical.
+ 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 - Name of language 1
- Language2 - Name of language 2
+ Language1 - The first language code to be tested.
+ Language2 - The second language code to be tested.
Returns:
- TRUE - same
- FALSE - not same
+ 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] != ';'))) {
- return TRUE;
+ if (IsIso639LanguageCode (Language1)) {
+ //
+ // ISO639-2 language code, compare the third byte of language tag
+ //
+ return (BOOLEAN) ((Language1[2] == Language2[2]) ? TRUE : FALSE);
}
- return FALSE;
-#else
- for (Index = 0; Index < 3; Index++) {
- if (Language1[Index] != Language2[Index]) {
- return 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 TRUE;
-#endif
+ return FALSE;
}
STATIC
@@ -134,19 +217,39 @@ CHAR8 *
NextSupportedLanguage (
IN CHAR8 *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.
+
+--*/
{
-#ifdef LANGUAGE_RFC_3066 // LANGUAGE_RFC_3066
- for (; (*Languages != 0) && (*Languages != ';'); Languages++)
- ;
+ UINTN Index;
- if (*Languages == ';') {
- Languages++;
+ 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;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
index 547c203a83..e5b84d205a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
@@ -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
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
index 63e09d0087..5cbbe02104 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
@@ -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
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
index 47b084e09b..a6b7f06a50 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
@@ -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
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
index b913d3fac2..9d4260768c 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/EfiUiLib/EfiUiLib.c
@@ -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
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
index bd8de3a1cf..c417242552 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiDriverLib.h
@@ -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
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
index 7cfeffe5fb..946742cb17 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/Include/EfiUiLib.h
@@ -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
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
index c70fb87e79..ae771b13a5 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
@@ -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
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
index 90afafe837..c41a85c38d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
@@ -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;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
index fbb46075c4..355935322c 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
@@ -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 :
@@ -250,6 +239,68 @@ Fail:
}
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,
IN EFI_GUID *FormSetGuid, OPTIONAL
@@ -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,13 +1190,139 @@ 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,
IN OUT UINTN *StrBufferLen,
@@ -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=");
@@ -844,6 +1423,105 @@ 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.
+
+--*/
+{
+ 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,
UINTN Offset,
@@ -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;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
index bd85764d4a..3de0efb651 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
@@ -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 (
@@ -600,6 +604,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,
OUT EFI_GUID *Guid
@@ -644,6 +695,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,
IN UINT8 *Buffer,
@@ -690,6 +784,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,
IN OUT UINTN *StrBufferLen,
@@ -720,6 +872,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,
UINTN Offset,
@@ -1094,6 +1269,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,
IN EFI_GUID *FormSetGuid, OPTIONAL
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
index c46bc7d73e..2c454de951 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
@@ -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;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
index 0a5739965a..ece78bfb44 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
@@ -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;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
index 7968995794..be5bf00f7c 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
@@ -23,6 +23,81 @@ Abstract:
#include "EdkIIGlueDxe.h"
#include "Common/EdkIIGlueDependencies.h"
+//
+// Check definitions in .inf file to determine __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+//
+// __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+// 1: only install ComponentName, DriverConfiguration and DriverDiagnostics
+// 2: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+// 3: install all including ComponentName, DriverConfiguration, DriverDiagnostics AND
+// ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+// 4: install automatically according to EFI_SPECIFICATION_VERSION:
+// if EFI_SPECIFICATION_VERSION < 0x00020000: only install ComponentName, DriverConfiguration and DriverDiagnostics
+// if EFI_SPECIFICATION_VERSION >= 0x00020000: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+//
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#endif
+
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#endif
+
+#ifdef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1
+#endif
+
+#if !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 3
+#endif
+
+//
+// To use Auto-Select, it must be:
+// 1. both Protocol and Protocol2 are defined
+// 2. The Protocol and Protocol2 must use same names, for example, gDriverControllerName as __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__ and __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__
+//
+#if defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#if !(defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__))
+#error "To use Auto-Select please define both Protocol and Protocol2 instances"
+#endif
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 4
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 4)
+#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2
+#else
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1
+#endif
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 1;
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 2;
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 3;
+#else
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 0;
+#endif
+
STATIC EFI_EVENT _mDriverExitBootServicesNotifyEvent;
//
@@ -31,27 +106,38 @@ STATIC EFI_EVENT _mDriverExitBootServicesNotifyEvent;
// In case where multiple Driver Model protocols need to be installed in a single driver,
// manually edit this file and compile/link the modified file with the driver.
//
-
-#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__)
extern EFI_DRIVER_BINDING_PROTOCOL __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__;
#endif
-#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-extern EFI_COMPONENT_NAME2_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;
-#else
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__)
extern EFI_COMPONENT_NAME_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;
#endif
-#endif
-#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__)
extern EFI_DRIVER_CONFIGURATION_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__;
#endif
+#endif
-#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)
extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__;
#endif
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__)
+extern EFI_COMPONENT_NAME2_PROTOCOL __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__;
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_CONFIGURATION2_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__;
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__;
+#endif
+#endif
+
GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {
{
#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__
@@ -60,23 +146,41 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverMode
NULL,
#endif
-#ifdef __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
&__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__,
#else
NULL,
#endif
-#ifdef __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
&__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__,
#else
NULL,
#endif
-#ifdef __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
&__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__,
#else
NULL,
#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
}
};
@@ -249,15 +353,15 @@ ProcessLibraryConstructorList (
// NOTE: the constructors must be called according to dependency order
//
// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
+// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
+// DxeServicesTableLib DxeServicesTableLibConstructor()
// DxeIoLibCpuIo IoLibConstructor()
// DxeSalLib DxeSalLibConstructor(), IPF only
// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct()
-// DxeHobLib HobLibConstructor()
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
// UefiDriverModelLib UefiDriverModelLibConstructor()
+// DxeHobLib HobLibConstructor()
// DxeSmbusLib SmbusLibConstructor()
-// DxeServicesTableLib DxeServicesTableLibConstructor()
-// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
-// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
//
#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
@@ -265,6 +369,16 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+ Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__
Status = IoLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
@@ -280,8 +394,8 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
-#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
- Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+ Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
@@ -290,16 +404,6 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
-#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
- Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
- ASSERT_EFI_ERROR (Status);
-#endif
-
-#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
- Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
- ASSERT_EFI_ERROR (Status);
-#endif
-
#ifdef __EDKII_GLUE_DXE_HOB_LIB__
Status = HobLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
index c83b28efbb..13cddfbe1d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
@@ -83,23 +83,18 @@ ProcessLibraryConstructorList (
// here
//
// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
+// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
+// DxeServicesTableLib DxeServicesTableLibConstructor()
// DxeIoLibCpuIo IoLibConstructor
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
// DxeHobLib HobLibConstructor()
// DxeSmbusLib SmbusLibConstructor()
-// DxeServicesTableLib DxeServicesTableLibConstructor()
-// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
-// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
-// check here: check lib usage
+
#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
#endif
-#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__
- Status = IoLibConstructor (ImageHandle, SystemTable);
- ASSERT_EFI_ERROR (Status);
-#endif
-
#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
@@ -110,6 +105,11 @@ ProcessLibraryConstructorList (
ASSERT_EFI_ERROR (Status);
#endif
+#ifdef __EDKII_GLUE_DXE_IO_LIB_CPU_IO__
+ Status = IoLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
ASSERT_EFI_ERROR (Status);
@@ -321,14 +321,26 @@ _ModuleEntryPoint (
EFI_HANDLE Handle;
//
- // Call constructor for all libraries
+ // Cache a pointer to the Boot Services Table
//
- ProcessLibraryConstructorList (ImageHandle, SystemTable);
+ mBS = SystemTable->BootServices;
//
- // Cache a pointer to the Boot Services Table
+ // Initialize gBS as ASSERT needs it
+ // Both DxeReportStatusCodeLib and SmmRuntimeDxeReportStatusCodeLib implementations
+ // Can handle this cleanly before lib constructors are called.
//
- mBS = SystemTable->BootServices;
+ gBS = mBS;
+
+ //
+ // Retrieve the Loaded Image Protocol
+ //
+ Status = mBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID*)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
//
// Retrieve SMM Base Protocol
@@ -350,27 +362,6 @@ _ModuleEntryPoint (
//
if (!InSmm) {
//
- // Retrieve the Loaded Image Protocol
- //
- Status = mBS->HandleProtocol (
- ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID*)&LoadedImage
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Install the unload handler
- //
- Status = mBS->HandleProtocol (
- ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID **)&LoadedImage
- );
- ASSERT_EFI_ERROR (Status);
- LoadedImage->Unload = _DriverUnloadHandler;
-
- //
// Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from
//
Status = mBS->HandleProtocol (
@@ -391,18 +382,34 @@ _ModuleEntryPoint (
//
Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE);
ASSERT_EFI_ERROR (Status);
- } else {
-
- //
- // Call the list of driver entry points
- //
- #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
- Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));
- #else
- Status = EFI_SUCCESS;
- #endif
+ return Status;
}
+ //
+ // Call constructor for all libraries
+ //
+ ProcessLibraryConstructorList (ImageHandle, SystemTable);
+
+ //
+ // Install the unload handler
+ //
+ Status = mBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+ LoadedImage->Unload = _DriverUnloadHandler;
+
+ //
+ // Call the list of driver entry points
+ //
+ #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
+ Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));
+ #else
+ Status = EFI_SUCCESS;
+ #endif
+
if (EFI_ERROR (Status)) {
ProcessLibraryDestructorList (ImageHandle, SystemTable);
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
index b3b1f0ef73..321e5fb0ec 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
@@ -333,6 +333,15 @@ Abstract:
#endif
//
+// DxeServicesTableLib
+//
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+ #ifndef __EDKII_GLUE_UEFI_LIB__
+ #define __EDKII_GLUE_UEFI_LIB__
+ #endif
+#endif
+
+//
// UefiLib
//
#ifdef __EDKII_GLUE_UEFI_LIB__
@@ -490,15 +499,6 @@ Abstract:
#endif
//
-// DxeServicesTableLib
-//
-#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
- #ifndef __EDKII_GLUE_UEFI_LIB__
- #define __EDKII_GLUE_UEFI_LIB__
- #endif
-#endif
-
-//
// BasePrintLib
//
#ifdef __EDKII_GLUE_BASE_PRINT_LIB__
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
index 2650379ba9..3513f87d69 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
@@ -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
@@ -33,10 +33,15 @@ Abstract:
// 0x6000 - support EBC. Feb, 2007
// 0x7000 - size reduction, Jun, 2007
// 0x7100 - backward compatibility supported, Jun, 2007
+// 0x8000 - Driver model protocols2 supported, May, 2008
+// 0x9000 - add SmmRuntimeDxeReportStatusCodeLib and OemHookStatusCodeLibNull, Feb, 2009
+// 0x9100 - change to use unique member RT variable names in various library instances, June, 2009
+// 0x9200 - Update LEGACY_BOOT and READY_TO_BOOT event handling in UefiLib, July, 2009
+// 0x9300 - Remove OemHookStatusCodeLibNull. SmmRuntimeDxeReportStatusCodeLib uses SMM StatusCode Protocol, Oct, 2009
//
// For reference only, don't change the value
//
-#define EDKII_GLUE_LIBRARY_VERSION 0x7100
+#define EDKII_GLUE_LIBRARY_VERSION 0x9300
//
@@ -120,7 +125,9 @@ Abstract:
// This value is FSB Clock frequency. Its unit is Hz and its
// default value is 200000000, that means FSB frequency is 200Mhz.
//
+#ifndef EDKII_GLUE_FSBClock
#define EDKII_GLUE_FSBClock 200000000
+#endif
//
// post code property mask
@@ -142,7 +149,9 @@ Abstract:
// The base address of IPF IO Block
//
#ifdef MDE_CPU_IPF
+#ifndef EDKII_GLUE_IoBlockBaseAddressForIpf
#define EDKII_GLUE_IoBlockBaseAddressForIpf 0x0ffffc000000
#endif
+#endif
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
index 5482785b77..8c4e2ae946 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
@@ -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
@@ -173,4 +173,6 @@ Abstract:
#include "Library/EdkIIGlueUefiLib.h"
#include "Library/EdkIIGlueUefiRuntimeServicesTableLib.h"
+extern UINT8 _gEdkIIGlueDriverModelProtocolSelection;
+
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
index 9bb057f5ab..ef947fa7eb 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
@@ -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
@@ -34,15 +34,14 @@ Abstract:
// Data structure that declares pointers to the Driver Model
// Protocols.
//
-typedef struct {
- const EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- const EFI_COMPONENT_NAME2_PROTOCOL *ComponentName;
-#else
- const EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
-#endif
- const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
- const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
+typedef struct {
+ const EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ const EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
+ const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
+ const EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ const EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2;
+ const EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2;
} EFI_DRIVER_MODEL_PROTOCOL_LIST;
//
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
index 15d5f2e730..48c8f5e8be 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
@@ -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
@@ -585,13 +585,6 @@ EfiCreateEventReadyToBootEx (
/**
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 Tiano 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.
-
@param FvDevicePathNode Pointer to a FV device path node to initialize
@param NameGuid FV file name to use in FvDevicePathNode
@@ -606,15 +599,6 @@ GlueEfiInitializeFwVolDevicepathNode (
/**
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 Tiano 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.
-
@param FvDevicePathNode Pointer to FV device path to check.
@retval NULL FvDevicePathNode is not valid.
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
index 4caec5f371..9562460e0f 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
@@ -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
@@ -51,7 +51,7 @@ GlueCompareMem (
IN UINTN Length
)
{
- if (Length == 0) {
+ if (Length == 0 || DestinationBuffer == SourceBuffer) {
return 0;
}
ASSERT (DestinationBuffer != NULL);
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
index 6cc2da31b0..387a6835a6 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
@@ -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
@@ -29,7 +29,7 @@ Abstract:
STATIC EFI_EVENT mEfiVirtualNotifyEvent;
STATIC BOOLEAN mEfiGoneVirtual = FALSE;
STATIC BOOLEAN mEfiAtRuntime = FALSE;
-EFI_RUNTIME_SERVICES *mRT;
+EFI_RUNTIME_SERVICES *mRTEdkDxeRuntimeDriverLib;
/**
Set AtRuntime flag as TRUE after ExitBootServices
@@ -44,6 +44,11 @@ RuntimeDriverExitBootServices (
IN VOID *Context
)
{
+ //
+ // Clear out BootService globals
+ //
+ gBS = NULL;
+
mEfiAtRuntime = TRUE;
}
@@ -76,7 +81,7 @@ RuntimeLibVirtualNotifyEvent (
//
// Update global for Runtime Services Table and IO
//
- EfiConvertPointer (0, (VOID **) &mRT);
+ EfiConvertPointer (0, (VOID **) &mRTEdkDxeRuntimeDriverLib);
mEfiGoneVirtual = TRUE;
}
@@ -99,8 +104,8 @@ RuntimeDriverLibConstruct (
EFI_STATUS Status;
ASSERT (SystemTable != NULL);
- mRT = SystemTable->RuntimeServices;
- ASSERT (mRT != NULL);
+ mRTEdkDxeRuntimeDriverLib = SystemTable->RuntimeServices;
+ ASSERT (mRTEdkDxeRuntimeDriverLib != NULL);
//
// Register SetVirtualAddressMap () notify function
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
index 1fcfddb585..c57588c770 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
@@ -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
@@ -50,11 +50,11 @@ Returns:
--*/
{
- mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
+ mRTEdkDxeRuntimeDriverLib->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
}
//
-// The following functions hide the mRT local global from the call to
+// The following functions hide the mRTEdkDxeRuntimeDriverLib local global from the call to
// runtime service in the EFI system table.
//
EFI_STATUS
@@ -82,7 +82,7 @@ Returns:
--*/
{
- return mRT->GetTime (Time, Capabilities);
+ return mRTEdkDxeRuntimeDriverLib->GetTime (Time, Capabilities);
}
EFI_STATUS
@@ -106,7 +106,7 @@ Returns:
--*/
{
- return mRT->SetTime (Time);
+ return mRTEdkDxeRuntimeDriverLib->SetTime (Time);
}
EFI_STATUS
@@ -134,7 +134,7 @@ Returns:
--*/
{
- return mRT->GetWakeupTime (Enabled, Pending, Time);
+ return mRTEdkDxeRuntimeDriverLib->GetWakeupTime (Enabled, Pending, Time);
}
EFI_STATUS
@@ -161,7 +161,7 @@ Returns:
--*/
{
- return mRT->SetWakeupTime (Enable, Time);
+ return mRTEdkDxeRuntimeDriverLib->SetWakeupTime (Enable, Time);
}
@@ -199,7 +199,7 @@ Returns:
--*/
{
- return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+ return mRTEdkDxeRuntimeDriverLib->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
}
EFI_STATUS
@@ -232,7 +232,7 @@ Returns:
--*/
{
- return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
+ return mRTEdkDxeRuntimeDriverLib->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
}
EFI_STATUS
@@ -265,7 +265,7 @@ Returns:
--*/
{
- return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+ return mRTEdkDxeRuntimeDriverLib->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
}
EFI_STATUS
@@ -289,7 +289,7 @@ Returns:
--*/
{
- return mRT->GetNextHighMonotonicCount (HighCount);
+ return mRTEdkDxeRuntimeDriverLib->GetNextHighMonotonicCount (HighCount);
}
EFI_STATUS
@@ -316,7 +316,7 @@ Returns:
--*/
{
- return mRT->ConvertPointer (DebugDisposition, Address);
+ return mRTEdkDxeRuntimeDriverLib->ConvertPointer (DebugDisposition, Address);
}
EFI_STATUS
@@ -399,7 +399,7 @@ EfiSetVirtualAddressMap (
IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
)
{
- return mRT->SetVirtualAddressMap (
+ return mRTEdkDxeRuntimeDriverLib->SetVirtualAddressMap (
MemoryMapSize,
DescriptorSize,
DescriptorVersion,
@@ -417,7 +417,7 @@ EfiUpdateCapsule (
)
{
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- return mRT->UpdateCapsule (
+ return mRTEdkDxeRuntimeDriverLib->UpdateCapsule (
CapsuleHeaderArray,
CapsuleCount,
ScatterGatherList
@@ -437,7 +437,7 @@ EfiQueryCapsuleCapabilities (
)
{
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- return mRT->QueryCapsuleCapabilities (
+ return mRTEdkDxeRuntimeDriverLib->QueryCapsuleCapabilities (
CapsuleHeaderArray,
CapsuleCount,
MaximumCapsuleSize,
@@ -459,7 +459,7 @@ EfiQueryVariableInfo (
)
{
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- return mRT->QueryVariableInfo (
+ return mRTEdkDxeRuntimeDriverLib->QueryVariableInfo (
Attributes,
MaximumVariableStorageSize,
RemainingVariableStorageSize,
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
index 8f154a888c..e0f4deb6ce 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeLib.c
@@ -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
@@ -26,7 +26,7 @@ Abstract:
// Driver Lib Module Globals
//
static EFI_EVENT mEfiVirtualNotifyEvent;
-EFI_RUNTIME_SERVICES *mRT;
+EFI_RUNTIME_SERVICES *mRTEdkDxeRuntimeDriverLib;
VOID
EFIAPI
@@ -95,7 +95,7 @@ Returns:
//
// Update global for Runtime Services Table
//
- EfiConvertPointer (0, (VOID **) &mRT);
+ EfiConvertPointer (0, (VOID **) &mRTEdkDxeRuntimeDriverLib);
}
EFI_STATUS
@@ -126,7 +126,7 @@ Returns:
{
EFI_STATUS Status;
- mRT = SystemTable->RuntimeServices;
+ mRTEdkDxeRuntimeDriverLib = SystemTable->RuntimeServices;
//
// Register SetVirtualAddressMap () notify function
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
index bcaa7448bd..a270fc5508 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Ipf/RuntimeService.c
@@ -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
@@ -70,7 +70,7 @@ Returns:
//
-// The following functions hide the mRT local global from the call to
+// The following functions hide the mRTEdkDxeRuntimeDriverLib local global from the call to
// runtime service in the EFI system table.
//
EFI_STATUS
@@ -415,7 +415,7 @@ Returns:
--*/
{
- return mRT->ConvertPointer (DebugDisposition, Address);
+ return mRTEdkDxeRuntimeDriverLib->ConvertPointer (DebugDisposition, Address);
}
EFI_STATUS
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
index 2d8e4e7760..287f525cb9 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
@@ -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
@@ -25,6 +25,6 @@ Abstract:
#include "EdkIIGlueDxe.h"
-extern EFI_RUNTIME_SERVICES *mRT;
+extern EFI_RUNTIME_SERVICES *mRTEdkDxeRuntimeDriverLib;
#endif //__RUNTIMELIBINTERNAL_H__
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
index cd8da602b8..c82736c74b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
@@ -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
@@ -22,13 +22,6 @@ Abstract:
#include "EdkIIGlueUefi.h"
-#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID gEfiComponentName2ProtocolGuid
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME2_PROTOCOL
-#else
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID gEfiComponentNameProtocolGuid
- #define EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL EFI_COMPONENT_NAME_PROTOCOL
-#endif
/**
The constructor function installs the standard EFI Driver Model Protocols.
@@ -46,7 +39,7 @@ UefiDriverModelLibConstructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
EFI_HANDLE DriverBindingHandle;
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
@@ -60,16 +53,17 @@ UefiDriverModelLibConstructor (
// EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1
//
- //
- // The Driver Binding Protocol must never be NULL
- //
- ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
+ //
+ // The Driver Binding Protocol must never be NULL
+ //
+ ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
- //
- // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
- // These are all checks against const pointers, so the optimizing compiler will only select one of the
- // calls to InstallMultipleProtocolInterfaces()
- //
+ //
+ // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
+ // These are all checks against const pointers, so the optimizing compiler will only select one of the
+ // calls to InstallMultipleProtocolInterfaces()
+ //
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {
if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
if (_gDriverModelProtocolList[0].ComponentName == NULL) {
@@ -82,7 +76,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
NULL
);
}
@@ -98,7 +92,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
NULL
);
@@ -117,7 +111,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
);
@@ -135,7 +129,7 @@ UefiDriverModelLibConstructor (
Status = gBS->InstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
@@ -143,18 +137,95 @@ UefiDriverModelLibConstructor (
}
}
}
+ } // selection == 1 or 3
- //
- // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
- //
- ASSERT_EFI_ERROR (Status);
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics2== NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2== NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2== NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 2 or 3
- //
- // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
- //
- DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;
- DriverBinding->ImageHandle = ImageHandle;
- DriverBinding->DriverBindingHandle = DriverBindingHandle;
+ //
+ // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
+ //
+ DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;
+ DriverBinding->ImageHandle = ImageHandle;
+ DriverBinding->DriverBindingHandle = DriverBindingHandle;
return EFI_SUCCESS;
@@ -176,7 +247,7 @@ UefiDriverModelLibDestructor (
IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status = EFI_UNSUPPORTED;
EFI_HANDLE DriverBindingHandle;
//
@@ -184,21 +255,22 @@ UefiDriverModelLibDestructor (
// EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1
//
- //
- // The Driver Binding Protocol must never be NULL
- //
- ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
+ //
+ // The Driver Binding Protocol must never be NULL
+ //
+ ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
- //
- // Retrieve the DriverBindingHandle from the Driver Binding Protocol
- //
- DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;
+ //
+ // Retrieve the DriverBindingHandle from the Driver Binding Protocol
+ //
+ DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;
- //
- // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
- // These are all checks against const pointers, so the optimizing compiler will only select one of the
- // calls to InstallMultipleProtocolInterfaces()
- //
+ //
+ // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
+ // These are all checks against const pointers, so the optimizing compiler will only select one of the
+ // calls to InstallMultipleProtocolInterfaces()
+ //
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {
if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
if (_gDriverModelProtocolList[0].ComponentName == NULL) {
@@ -211,7 +283,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
NULL
);
}
@@ -227,7 +299,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
NULL
);
@@ -246,7 +318,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
);
@@ -264,7 +336,7 @@ UefiDriverModelLibDestructor (
Status = gBS->UninstallMultipleProtocolInterfaces (
&DriverBindingHandle,
&gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
- &EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL_GUID, (EDKII_GLUE_SELECTED_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
&gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
&gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
NULL
@@ -272,11 +344,88 @@ UefiDriverModelLibDestructor (
}
}
}
+ } // selection == 1 or 3
+
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics2 == NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 2 or 3
- //
- // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
- //
- ASSERT_EFI_ERROR (Status);
+ //
+ // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
+ //
+ ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
index b8852e43f3..cdfea2daf3 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
@@ -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
@@ -17,32 +17,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
/**
- Compare whether two names of languages are identical.
-
- @param Language1 Name of language 1.
- @param Language2 Name of language 2.
-
- @retval TRUE Language 1 and language 2 are the same.
- @retval FALSE Language 1 and language 2 are not the same.
-
-**/
-STATIC
-BOOLEAN
-CompareIso639LanguageCode (
- IN CONST CHAR8 *Language1,
- IN CONST CHAR8 *Language2
- )
-{
- UINT32 Name1;
- UINT32 Name2;
-
- Name1 = ReadUnaligned24 ((CONST UINT32 *) Language1);
- Name2 = ReadUnaligned24 ((CONST UINT32 *) Language2);
-
- return (BOOLEAN) (Name1 == Name2);
-}
-
-/**
This function searches the list of configuration tables stored in the EFI System
Table for a table with a GUID that matches TableGuid. If a match is found,
then a pointer to the configuration table is returned in Table, and EFI_SUCCESS
@@ -510,6 +484,130 @@ EfiTestChildHandle (
}
/**
+ Tests whether a language code has format of ISO639-2.
+
+ @param Languages The language code to be tested.
+
+ @retval TRUE Language code format is ISO 639-2.
+ @retval FALSE Language code format is not ISO639-2.
+
+**/
+STATIC
+BOOLEAN
+IsIso639LanguageCode (
+ IN CONST CHAR8 *Languages
+ )
+{
+ 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;
+}
+
+/**
+ 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.
+
+ @param Language1 The first language code to be tested.
+ @param Language2 The second language code to be tested.
+
+ @retval TRUE Language code match.
+ @retval FALSE Language code mismatch.
+
+**/
+STATIC
+BOOLEAN
+CompareLanguageCode (
+ IN CONST CHAR8 *Language1,
+ IN CONST CHAR8 *Language2
+ )
+{
+ UINTN Index;
+
+ //
+ // Compare first two bytes of language tag
+ //
+ if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {
+ return FALSE;
+ }
+
+ 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 ((AsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Step to next language code of a language code list.
+
+ @param Languages The language code list to traverse.
+
+ @return Pointer to next language code or NULL terminator if it's the last one.
+
+**/
+STATIC
+CONST
+CHAR8 *
+NextSupportedLanguage (
+ IN CONST CHAR8 *Languages
+ )
+{
+ UINTN Index;
+
+ if (IsIso639LanguageCode (Languages)) {
+ //
+ // ISO639-2 language code
+ //
+ return (Languages + 3);
+ }
+
+ //
+ // Search in RFC4646 language code list
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);
+ if (Languages[Index] == ';') {
+ Index++;
+ }
+ return (Languages + Index);
+}
+
+/**
This function looks up a Unicode string in UnicodeStringTable. If Language is
a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable
that matches the language code specified by Language, then it is returned in
@@ -566,13 +664,13 @@ LookupUnicodeString (
// Make sure Language is in the set of Supported Languages
//
while (*SupportedLanguages != 0) {
- if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
+ if (CompareLanguageCode (Language, SupportedLanguages)) {
//
// Search the Unicode String Table for the matching Language specifier
//
while (UnicodeStringTable->Language != NULL) {
- if (CompareIso639LanguageCode (Language, UnicodeStringTable->Language)) {
+ if (CompareLanguageCode (Language, UnicodeStringTable->Language)) {
//
// A matching string was found, so return it
@@ -587,7 +685,7 @@ LookupUnicodeString (
return EFI_UNSUPPORTED;
}
- SupportedLanguages += 3;
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;
@@ -664,7 +762,7 @@ AddUnicodeString (
// Make sure Language is a member of SupportedLanguages
//
while (*SupportedLanguages != 0) {
- if (CompareIso639LanguageCode (Language, SupportedLanguages)) {
+ if (CompareLanguageCode (Language, SupportedLanguages)) {
//
// Determine the size of the Unicode String Table by looking for a NULL Language entry
@@ -673,7 +771,7 @@ AddUnicodeString (
if (*UnicodeStringTable != NULL) {
OldUnicodeStringTable = *UnicodeStringTable;
while (OldUnicodeStringTable->Language != NULL) {
- if (CompareIso639LanguageCode (Language, OldUnicodeStringTable->Language)) {
+ if (CompareLanguageCode (Language, OldUnicodeStringTable->Language)) {
return EFI_ALREADY_STARTED;
}
@@ -707,7 +805,7 @@ AddUnicodeString (
//
// Allocate space for a copy of the Language specifier
//
- NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (3, Language);
+ NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize (Language), Language);
if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {
(gBS->FreePool) (NewUnicodeStringTable);
return EFI_OUT_OF_RESOURCES;
@@ -753,7 +851,7 @@ AddUnicodeString (
return EFI_SUCCESS;
}
- SupportedLanguages += 3;
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
}
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
index c995b92bc9..bccb35a44b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
@@ -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
@@ -67,7 +67,7 @@ GlueEfiCreateEventLegacyBoot (
{
return EfiCreateEventLegacyBootEx (
EFI_TPL_CALLBACK,
- InternalEmptyFuntion,
+ NULL,
NULL,
LegacyBootEvent
);
@@ -101,29 +101,50 @@ EfiCreateEventLegacyBootEx (
OUT EFI_EVENT *LegacyBootEvent
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
ASSERT (LegacyBootEvent != NULL);
#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
//
// prior to UEFI 2.0 use Tiano extension to EFI
//
Status = gBS->CreateEvent (
- EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
LegacyBootEvent
);
#else
+
+ EventType = EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = InternalEmptyFuntion;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
//
// For UEFI 2.0 and the future use an Event Group
//
Status = gBS->CreateEventEx (
- EVENT_NOTIFY_SIGNAL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
&gEfiEventLegacyBootGuid,
LegacyBootEvent
@@ -157,7 +178,7 @@ GlueEfiCreateEventReadyToBoot (
{
return EfiCreateEventReadyToBootEx (
EFI_TPL_CALLBACK,
- InternalEmptyFuntion,
+ NULL,
NULL,
ReadyToBootEvent
);
@@ -191,29 +212,51 @@ EfiCreateEventReadyToBootEx (
OUT EFI_EVENT *ReadyToBootEvent
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
ASSERT (ReadyToBootEvent != NULL);
-#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
//
// prior to UEFI 2.0 use Tiano extension to EFI
//
Status = gBS->CreateEvent (
- EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
ReadyToBootEvent
);
#else
+
+ EventType = EVENT_NOTIFY_SIGNAL;
+
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = InternalEmptyFuntion;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
//
// For UEFI 2.0 and the future use an Event Group
//
Status = gBS->CreateEventEx (
- EVENT_NOTIFY_SIGNAL,
+ EventType,
NotifyTpl,
- NotifyFunction,
+ WorkerNotifyFunction,
NotifyContext,
&gEfiEventReadyToBootGuid,
ReadyToBootEvent
@@ -274,15 +317,6 @@ EfiSignalEventLegacyBoot (
/**
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.
-
@param FvDevicePathNode Pointer to FV device path to check.
@retval NULL FvDevicePathNode is not valid.
@@ -297,11 +331,6 @@ GlueEfiGetNameGuidFromFwVolDevicePathNode (
{
ASSERT (FvDevicePathNode != NULL);
- //
- // 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 (EFI_GUID *) &FvDevicePathNode->NameGuid;
@@ -314,13 +343,6 @@ GlueEfiGetNameGuidFromFwVolDevicePathNode (
/**
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.
-
@param FvDevicePathNode Pointer to a FV device path node to initialize
@param NameGuid FV file name to use in FvDevicePathNode
@@ -335,16 +357,10 @@ GlueEfiInitializeFwVolDevicepathNode (
ASSERT (FvDevicePathNode != NULL);
ASSERT (NameGuid != NULL);
- //
- // 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));
-
- CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);
+ CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
index 8aff8813ad..722c9a9664 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
@@ -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
@@ -60,7 +60,7 @@ COMPONENT_TYPE = LIBRARY
Math.c
[sources.x64]
- X64/EfiCopyMemRep1.asm
+ X64/EfiCopyMemRep4.asm
X64/EfiSetMemRep4.asm
X64/EfiZeroMemRep4.asm
# X64/EfiCopyMem.asm
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf
index a6f930dacf..fd183c1d6a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/EfiCommonLib_Edk2.inf
@@ -1,6 +1,6 @@
#/*++
#
-# Copyright (c) 2004 - 2008, 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
@@ -85,14 +85,14 @@ COMPONENT_TYPE = LIBRARY
Math.c
[sources.x64]
- X64/EfiCopyMemRep1.asm | MSFT
+ X64/EfiCopyMemRep4.asm | MSFT
X64/EfiSetMemRep4.asm | MSFT
X64/EfiZeroMemRep4.asm | MSFT
# X64/EfiCopyMem.asm | MSFT
# X64/EfiSetMem.asm | MSFT
# X64/EfiZeroMem.asm | MSFT
- X64/EfiCopyMemRep1.asm | INTEL
+ X64/EfiCopyMemRep4.asm | INTEL
X64/EfiSetMemRep4.asm | INTEL
X64/EfiZeroMemRep4.asm | INTEL
# X64/EfiCopyMem.asm | INTEL
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S
index ed41ff994d..580c3fe94b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.S
@@ -75,16 +75,16 @@ ASM_PFX(EfiCommonLibCopyMem):
movl %esi, %eax
addl %ecx, %eax # Source + Count
cmpl %edi, %eax
- jle _StartByteCopy
+ jbe _StartByteCopy
movl %edi, %eax
addl %ecx, %eax # Dest + Count
cmpl %esi, %eax
- jle _StartByteCopy
+ jbe _StartByteCopy
cmpl %edi, %esi
je _CopyMemDone
- jl _CopyOverlapped # too bad -- overlaps
+ jb _CopyOverlapped # too bad -- overlaps
# Pick up misaligned start bytes to get destination pointer 4-byte aligned
_StartByteCopy:
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
index 7cf8b7f630..275e29b0c5 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
@@ -73,16 +73,16 @@ EfiCommonLibCopyMem PROC
mov eax, esi
add eax, ecx ; Source + Count
cmp eax, edi
- jle _StartByteCopy
+ jbe _StartByteCopy
mov eax, edi
add eax, ecx ; Dest + Count
cmp eax, esi
- jle _StartByteCopy
+ jbe _StartByteCopy
cmp esi, edi
je _CopyMemDone
- jl _CopyOverlapped ; too bad -- overlaps
+ jb _CopyOverlapped ; too bad -- overlaps
; Pick up misaligned start bytes to get destination pointer 4-byte aligned
_StartByteCopy:
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
index 0acfdc9e5c..cb6b8ffe89 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -58,20 +58,21 @@ Returns:
; if (Source == Destination) => do nothing
; if (Source + Count <= Destination) => regular copy
; if (Destination + Count <= Source) => regular copy
+ ; if (Source >= Destination) => regular copy
; otherwise, do a reverse copy
mov eax, esi
add eax, ecx ; Source + Count
cmp eax, edi
- jle _StartByteCopy
+ jbe _StartByteCopy
mov eax, edi
add eax, ecx ; Dest + Count
cmp eax, esi
- jle _StartByteCopy
+ jbe _StartByteCopy
cmp esi, edi
je _CopyMemDone
- jl _CopyOverlapped ; too bad -- overlaps
+ jb _CopyOverlapped ; too bad -- overlaps
; Pick up misaligned start bytes to get destination pointer 4-byte aligned
_StartByteCopy:
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
index 9a15288f5c..595c008a04 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -104,13 +104,13 @@ _CopyBlocks:
copyxmm:
movdqu xmm0, OWORD PTR ds:[esi]
- movdqu QWORD PTR ds:[edi], xmm0
+ movdqu OWORD PTR ds:[edi], xmm0
movdqu xmm1, OWORD PTR ds:[esi+16]
- movdqu QWORD PTR ds:[edi+16], xmm1
+ movdqu OWORD PTR ds:[edi+16], xmm1
movdqu xmm2, OWORD PTR ds:[esi+32]
- movdqu QWORD PTR ds:[edi+32], xmm2
+ movdqu OWORD PTR ds:[edi+32], xmm2
movdqu xmm3, OWORD PTR ds:[esi+48]
- movdqu QWORD PTR ds:[edi+48], xmm3
+ movdqu OWORD PTR ds:[edi+48], xmm3
add edi, 64
add esi, 64
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S
index b22609afb3..a40c56bcb1 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.S
@@ -65,11 +65,13 @@ ASM_PFX(Power10U64):
jcxz _Power10U64_Done
_Power10U64_Wend:
+ pushl %ecx
pushl $10
push 0xC(%ebp)
push 0x8(%ebp)
call ASM_PFX(MultU64x32)
addl $0xc, %esp
+ popl %ecx
movl %eax, 8(%ebp) # dword ptr Operand[0]
movl %edx, 0xC(%ebp) # dword ptr Operand[4]
loopl _Power10U64_Wend
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
index b7d3373fd3..b6e25320d4 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
@@ -64,11 +64,13 @@ Power10U64 PROC
jcxz _Power10U64_Done
_Power10U64_Wend:
+ push ecx
push 10
push [ebp + 0Ch]; dword ptr Operand[4]
push [ebp + 8]; dword ptr Operand[0]
call MultU64x32
add esp, 0cH
+ pop ecx
mov [ebp + 8] , eax; dword ptr Operand[0]
mov [ebp + 0Ch] , edx; dword ptr Operand[4]
loop _Power10U64_Wend
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
index c74e7933dd..2a31fe133e 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Ia32/Power10U64.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -56,11 +56,13 @@ Returns:
jcxz _Power10U64_Done
_Power10U64_Wend:
+ push ecx
push 10
push dword ptr Operand[4]
push dword ptr Operand[0]
call MultU64x32
add esp, 0Ch
+ pop ecx
mov dword ptr Operand[0], eax
mov dword ptr Operand[4], edx
loop _Power10U64_Wend
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
index a931b533ea..c558869149 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Math.c
@@ -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
@@ -76,6 +76,21 @@ Returns:
}
UINT64
+Power10U64 (
+ IN UINT64 Operand,
+ IN UINTN Power
+ )
+{
+ UINT64 Result;
+
+ Result = Operand;
+ while (Power-- > 0) {
+ Result *= 10;
+ }
+ return Result;
+}
+
+UINT64
RShiftU64 (
IN UINT64 Operand,
IN UINTN Count
diff --git a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
index 5356e235e8..ef68647569 100644
--- a/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
+++ b/EdkCompatibilityPkg/Foundation/Library/EfiCommonLib/Misc.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2009, 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
@@ -20,8 +20,8 @@ Abstract:
#include "Tiano.h"
#include "pei.h"
#include "cpuio.h"
-#include "pcicfg.h"
-#include "pcicfg2.h"
+#include EFI_PPI_CONSUMER (PciCfg)
+#include EFI_PPI_CONSUMER (PciCfg2)
#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)
//
@@ -68,8 +68,6 @@ Returns:
--*/
{
- EFI_STATUS Status;
-
mPeiServices = NULL;
CpuIoPpi = NULL;
PciCfgPpi = NULL;
@@ -136,7 +134,7 @@ Returns:
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
- if (mPeiServices == NULL) {
+ if (mPeiServices != NULL) {
//
// The function is called in PEI phase, use PEI interfaces
//
@@ -197,7 +195,7 @@ Returns:
EFI_STATUS Status;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
- if (mPeiServices == NULL) {
+ if (mPeiServices != NULL) {
//
// The function is called in PEI phase, use PEI interfaces
//
@@ -260,7 +258,7 @@ Returns:
UINT8 *Buffer8;
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
- if (mPeiServices == NULL) {
+ if (mPeiServices != NULL) {
//
// The function is called in PEI phase, use PEI interfaces
//
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
index b2fde2721d..8fd3f93247 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/Include/PeiLib.h
@@ -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
@@ -195,8 +195,8 @@ EFI_STATUS
EFIAPI
PeiLibFfsFindNextFile (
IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE FwVolHeader,
- IN OUT EFI_PEI_FILE_HANDLE *FileHeader
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
/*++
@@ -207,7 +207,7 @@ Routine Description:
Arguments:
SearchType - Filter to find only file of this type.
- FwVolHeader - Pointer to the current FV to search.
+ FvHandle - Pointer to the current FV to search.
FileHandle - Pointer to the file matching SearchType in FwVolHeader.
- NULL if file not found
@@ -271,7 +271,7 @@ Returns:
EFI_STATUS
EFIAPI
PeiLibFfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE *VolumeHandle,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
)
/*++
@@ -464,7 +464,7 @@ MigrateIdtTable (
Routine Description:
- Migrate IDT from temporary memory to real memory where preceded with 4 bytes for
+ Migrate IDT from CAR to real memory where preceded with 4 bytes for
storing PeiService pointer.
Arguments:
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
index bc4ca8ee66..1904902c78 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
@@ -70,7 +70,7 @@ PeCoffLoaderLoadImage (
EFI_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
- IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
);
#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
@@ -565,7 +565,10 @@ Returns:
// Pe image and in Te image header there is not a field to describe the imagesize,
// we use the largest VirtualAddress plus Size in each directory entry to describe the imagesize
//
- ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);
+ if(Hdr.Te->DataDirectory[1].VirtualAddress > Hdr.Te->DataDirectory[0].VirtualAddress) {
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[1].VirtualAddress + Hdr.Te->DataDirectory[1].Size);
+ }
ImageContext->SectionAlignment = 4096;
ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) Hdr.Te->BaseOfCode - (UINTN) Hdr.Te->StrippedSize;
@@ -1013,6 +1016,12 @@ Returns:
UINT32 TempDebugEntryRva;
UINT32 NumberOfRvaAndSizes;
UINT16 Magic;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *ResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString;
+ EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
+#endif
if (NULL == ImageContext) {
return EFI_INVALID_PARAMETER;
@@ -1368,6 +1377,73 @@ Returns:
}
}
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // Get Image's HII resource section
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ }
+
+ if (DirectoryEntry->Size != 0) {
+ Base = PeCoffLoaderImageAddress (ImageContext, DirectoryEntry->VirtualAddress);
+
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {
+ if (ResourceDirectoryEntry->u1.s.NameIsString) {
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);
+
+ if (ResourceDirectoryString->Length == 3 &&
+ ResourceDirectoryString->String[0] == L'H' &&
+ ResourceDirectoryString->String[1] == L'I' &&
+ ResourceDirectoryString->String[2] == L'I') {
+ //
+ // Resource Type "HII" found
+ //
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Name
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Language
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+ }
+ }
+
+ //
+ // Now it ought to be resource Data
+ //
+ if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);
+ ImageContext->HiiResourceData = (EFI_PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);
+ break;
+ }
+ }
+ }
+
+ ResourceDirectoryEntry++;
+ }
+ }
+ }
+#endif
+
#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
AsmEfiSetBreakSupport ((UINTN)(ImageContext->ImageAddress));
#endif
@@ -1378,7 +1454,7 @@ Returns:
EFI_STATUS
EFIAPI
PeCoffLoaderUnloadImage (
- IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
)
/*++
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
index 824ab4b8ce..11ae5a17f0 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/PeiLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, 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
@@ -383,8 +383,8 @@ EFI_STATUS
EFIAPI
PeiLibFfsFindNextFile (
IN EFI_FV_FILETYPE SearchType,
- IN EFI_PEI_FV_HANDLE FwVolHeader,
- IN OUT EFI_PEI_FILE_HANDLE *FileHeader
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
)
/*++
@@ -395,9 +395,9 @@ Routine Description:
Arguments:
SearchType - Filter to find only file of this type.
- FwVolHeader - Pointer to the current FV to search.
+ FvHandle - Pointer to the current FV to search.
FileHandle - Pointer to the file matching SearchType in FwVolHeader.
- - NULL if file not found
+ - NULL if file not found
Returns:
EFI_STATUS
@@ -407,7 +407,7 @@ Returns:
EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer();
- return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, &FwVolHeader, &FileHeader);
+ return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FvHandle, FileHandle);
}
@@ -471,13 +471,13 @@ Returns:
EFI_PEI_SERVICES **PeiServices;
PeiServices = GetPeiServicesTablePointer();
- return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, &FfsFileHeader, SectionData);
+ return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, (EFI_PEI_FILE_HANDLE)FfsFileHeader, SectionData);
}
EFI_STATUS
EFIAPI
PeiLibFfsGetVolumeInfo (
- IN EFI_PEI_FV_HANDLE *VolumeHandle,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
OUT EFI_FV_INFO *VolumeInfo
)
/*++
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
index 9e01b2cd9e..884ec1cc27 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/EfiJump.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -35,6 +35,8 @@ typedef struct {
UINT64 R14;
UINT64 R15;
UINT64 Rip;
+ UINT32 MxCsr;
+ UINT8 XmmBuffer[160]; // XMM6-XMM15
} EFI_JUMP_BUFFER;
#endif
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
index aa366c2a1f..c930486183 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/Processor.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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
@@ -84,8 +84,6 @@ Returns:
--*/
{
*This = &mTransferControl;
- mTransferControl.SetJump = TransferControlSetJump;
- mTransferControl.LongJump = TransferControlLongJump;
return EFI_SUCCESS;
}
@@ -112,7 +110,6 @@ Returns:
--*/
{
*This = &mFlushInstructionCache;
- mFlushInstructionCache.Flush = FlushInstructionCacheFlush;
return EFI_SUCCESS;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
index b6be0b2f60..418400c15a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.Asm
@@ -1,6 +1,6 @@
;------------------------------------------------------------------------------
;
-; Copyright (c) 2005 - 2007, Intel Corporation. All rights reserved.<BR>
+; Copyright (c) 2005 - 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
@@ -73,6 +73,8 @@ _r13 QWORD ?
_r14 QWORD ?
_r15 QWORD ?
_rip QWORD ?
+_MxCsr DWORD ?
+_XmmBuffer DB 160 DUP (?)
_EFI_JUMP_BUFFER ENDS
EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
@@ -116,6 +118,19 @@ TransferControlSetJump PROC
mov (EFI_JUMP_BUFFER PTR [rdx])._r13, r13
mov (EFI_JUMP_BUFFER PTR [rdx])._r14, r14
mov (EFI_JUMP_BUFFER PTR [rdx])._r15, r15
+ ; save non-volatile fp registers
+ stmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu [rax], xmm6
+ movdqu [rax + 10h], xmm7
+ movdqu [rax + 20h], xmm8
+ movdqu [rax + 30h], xmm9
+ movdqu [rax + 40h], xmm10
+ movdqu [rax + 50h], xmm11
+ movdqu [rax + 60h], xmm12
+ movdqu [rax + 70h], xmm13
+ movdqu [rax + 80h], xmm14
+ movdqu [rax + 90h], xmm15
mov rax, QWORD PTR [rsp+0]
mov (EFI_JUMP_BUFFER PTR [rdx])._rip, rax
mov rax, EFI_SUCCESS
@@ -134,6 +149,19 @@ TransferControlSetJump ENDP
;
PUBLIC TransferControlLongJump
TransferControlLongJump PROC
+ ; load non-volatile fp registers
+ ldmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu xmm6, [rax]
+ movdqu xmm7, [rax + 10h]
+ movdqu xmm8, [rax + 20h]
+ movdqu xmm9, [rax + 30h]
+ movdqu xmm10, [rax + 40h]
+ movdqu xmm11, [rax + 50h]
+ movdqu xmm12, [rax + 60h]
+ movdqu xmm13, [rax + 70h]
+ movdqu xmm14, [rax + 80h]
+ movdqu xmm15, [rax + 90h]
; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP
mov rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx
diff --git a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
index 5253c0e2d1..2d464488cc 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Pei/PeiLib/X64/ProcessorAsms.S
@@ -1,6 +1,6 @@
#------------------------------------------------------------------------------
#
-# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2008 - 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
@@ -99,6 +99,19 @@ ASM_PFX(TransferControlSetJump):
mov %r13,0x40(%rdx)
mov %r14,0x48(%rdx)
mov %r15,0x50(%rdx)
+ #; save non-volatile fp registers
+ stmxcsr 0x60(%rdx)
+ lea 0x68(%rdx), %rax
+ movdqu %xmm6, (%rax)
+ movdqu %xmm7, 0x10(%rax)
+ movdqu %xmm8, 0x20(%rax)
+ movdqu %xmm9, 0x30(%rax)
+ movdqu %xmm10, 0x40(%rax)
+ movdqu %xmm11, 0x50(%rax)
+ movdqu %xmm12, 0x60(%rax)
+ movdqu %xmm13, 0x70(%rax)
+ movdqu %xmm14, 0x80(%rax)
+ movdqu %xmm15, 0x90(%rax)
mov (%rsp),%rax
mov %rax,0x58(%rdx)
mov $0x0,%rax
@@ -115,7 +128,20 @@ ASM_PFX(TransferControlSetJump):
#
#
ASM_PFX(TransferControlLongJump):
- # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+ # set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+ #; load non-volatile fp registers
+ ldmxcsr 0x60(%rdx)
+ lea 0x68(%rdx), %rax
+ movdqu (%rax), %xmm6
+ movdqu 0x10(%rax), %xmm7
+ movdqu 0x20(%rax), %xmm8
+ movdqu 0x30(%rax), %xmm9
+ movdqu 0x40(%rax), %xmm10
+ movdqu 0x50(%rax), %xmm11
+ movdqu 0x60(%rax), %xmm12
+ movdqu 0x70(%rax), %xmm13
+ movdqu 0x80(%rax), %xmm14
+ movdqu 0x90(%rax), %xmm15
mov $0x5,%rax
mov (%rdx),%rbx
mov 0x8(%rdx),%rsp
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
index 9807b45035..29cdeb967a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ia32/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2004 - 2008, 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,9 +21,11 @@ Abstract:
#include "Tiano.h"
#include "EfiRuntimeLib.h"
+#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (CpuIo)
#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
//
@@ -43,7 +45,81 @@ BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
+EFI_EVENT gEfiStatusCodeNotifyEvent = 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
@@ -214,9 +290,8 @@ Returns:
//
EfiConvertInternalPointer ((VOID **) &gCpuIo);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode != NULL) {
- EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
- EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ if (gReportStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gReportStatusCode);
}
#endif
EfiConvertInternalPointer ((VOID **) &mRT);
@@ -256,6 +331,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -275,10 +353,26 @@ Returns:
ASSERT_EFI_ERROR (Status);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -363,6 +457,16 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // Close EfiStatusCodeRuntimeProtocol notify function
+ //
+ if (gEfiStatusCodeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+#endif
+
return EFI_SUCCESS;
}
@@ -390,6 +494,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -406,10 +513,26 @@ Returns:
ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -761,8 +884,8 @@ EfiReportStatusCode (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
- IN EFI_GUID * CallerId,
- IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
/*++
@@ -788,19 +911,30 @@ Returns:
--*/
{
- EFI_STATUS Status;
+ 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 (EfiAtRuntime ()) {
+ //
+ // 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 (CodeType, Value, Instance, CallerId, Data);
+ Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);
#else
if (mRT == NULL) {
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
index c94ee431ef..ac169a1166 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -599,13 +599,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
@@ -617,11 +610,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));
@@ -640,15 +628,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
@@ -660,16 +639,11 @@ 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;
}
- return NULL;
+ return NULL;
}
diff --git a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
index 8771e2bcd3..11b36e056d 100644
--- a/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
+++ b/EdkCompatibilityPkg/Foundation/Library/RuntimeDxe/EfiRuntimeLib/X64/RuntimeLib.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2005 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2005 - 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,9 +21,11 @@ Abstract:
#include "Tiano.h"
#include "EfiRuntimeLib.h"
+#include "PeiHob.h"
#include EFI_PROTOCOL_DEFINITION (CpuIo)
#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (Hob)
#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
//
@@ -43,7 +45,81 @@ BOOLEAN mEfiAtRuntime = FALSE;
FVB_ENTRY *mFvbEntry;
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
-static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+EFI_REPORT_STATUS_CODE gReportStatusCode = NULL;
+EFI_EVENT gEfiStatusCodeNotifyEvent = 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
@@ -214,9 +290,8 @@ Returns:
//
EfiConvertInternalPointer ((VOID **) &gCpuIo);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- if (gStatusCode != NULL) {
- EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
- EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ if (gReportStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gReportStatusCode);
}
#endif
EfiConvertInternalPointer ((VOID **) &mRT);
@@ -256,6 +331,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -275,10 +353,26 @@ Returns:
ASSERT_EFI_ERROR (Status);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -363,6 +457,16 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // Close EfiStatusCodeRuntimeProtocol notify function
+ //
+ if (gEfiStatusCodeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (gEfiStatusCodeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+#endif
+
return EFI_SUCCESS;
}
@@ -390,6 +494,9 @@ Returns:
--*/
{
EFI_STATUS Status;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ VOID *Registration;
+#endif
if (mRuntimeLibInitialized) {
return EFI_ALREADY_STARTED;
@@ -406,10 +513,26 @@ Returns:
ASSERT (mRT != NULL);
#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
- Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
- if (EFI_ERROR (Status)) {
- gStatusCode = NULL;
- }
+ //
+ // Register EFI_STATUS_CODE_PROTOCOL notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ OnStatusCodeInstall,
+ NULL,
+ &gEfiStatusCodeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiStatusCodeRuntimeProtocolGuid,
+ gEfiStatusCodeNotifyEvent,
+ &Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ gBS->SignalEvent (gEfiStatusCodeNotifyEvent);
#endif
Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, (VOID **) &gCpuIo);
@@ -761,8 +884,8 @@ EfiReportStatusCode (
IN EFI_STATUS_CODE_TYPE CodeType,
IN EFI_STATUS_CODE_VALUE Value,
IN UINT32 Instance,
- IN EFI_GUID * CallerId,
- IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
)
/*++
@@ -788,19 +911,30 @@ Returns:
--*/
{
- EFI_STATUS Status;
+ 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 (EfiAtRuntime ()) {
+ //
+ // 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 (CodeType, Value, Instance, CallerId, Data);
+ Status = gReportStatusCode (CodeType, Value, Instance, CallerId, Data);
#else
if (mRT == NULL) {
return EFI_UNSUPPORTED;
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S
index fcf7ff44d4..dd1cb289fc 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.S
@@ -1,6 +1,6 @@
#*****************************************************************************
#*
-#* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+#* Copyright (c) 2006 - 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
@@ -51,4 +51,26 @@ ASM_PFX(AsmFxRestore):
ret
#AsmFxRestore ENDP
+#------------------------------------------------------------------------------
+# UINTN
+# AsmGetEflags (
+# VOID
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmGetEflags):
+ pushfl
+ pop %eax
+ ret
+#AsmGetEflags ENDP
+#------------------------------------------------------------------------------
+# VOID
+# AsmSetEflags (
+# IN UINTN Eflags
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmSetEflags):
+ push 4(%esp)
+ popfl
+ ret
+#AsmSetEflags ENDP
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
index e07b52a46c..7f3f275b37 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Fx.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -48,4 +48,28 @@ AsmFxRestore PROC
ret
AsmFxRestore ENDP
+;------------------------------------------------------------------------------
+; UINTN
+; AsmGetEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmGetEflags PROC
+ pushfd
+ pop eax
+ ret
+AsmGetEflags ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; AsmSetEflags (
+; IN UINTN Eflags
+; );
+;------------------------------------------------------------------------------
+AsmSetEflags PROC
+ push [esp + 4]
+ popfd
+ ret
+AsmSetEflags ENDP
+
END
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
index d1feb9972e..55415d8703 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
@@ -1,6 +1,6 @@
#*****************************************************************************
#*
-#* Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
+#* Copyright (c) 2006 - 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
@@ -72,6 +72,9 @@ ASM_PFX(Thunk16):
push $0xd
pop %ecx
rep movsl %ds:(%esi),%es:(%edi) #; copy context to 16-bit stack
+ #; copy eflags to stack frame
+ mov -12(%esi), %eax
+ mov %eax, -72(%edi)
pop %ebx #; ebx <- 16-bit stack offset
mov $L_Lable1,%eax
stos %eax,%es:(%edi)
@@ -140,20 +143,23 @@ ASM_PFX(RealMode):
popw %es
popw %fs
popw %gs
- addw $4, %sp # skip EFlags
- testw $1, 14(%esp) #(_STK16 ptr [esp + 8]).ThunkFlags, 1
+ sub 60, %esp
+ popfw
+ testw $1, 74(%esp) #(_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
+
jz 1f
- pushf
+ pushf # push Flags when it's INT#
1:
pushw %cs
# push @FarCallRet - _Code16Addr
.byte 0x68 # push /iw
.word FarCallRet - _Code16Addr
jz 2f
- ljmp *6(%esp) #bugbug
+ ljmp *66(%esp) #[esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
2:
- ljmp *4(%esp) #bugbug
+ ljmp *64(%esp) #[esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
FarCallRet:
+ add 60, %esp
pushfl
pushw %gs
pushw %fs
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
index 410347764a..76c1317469 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -55,6 +55,8 @@ _DATA ENDS
_TEXT SEGMENT FLAT "CODE" PARA
+STACK_PARAM_SIZE EQU 16
+
IA32_REGS STRUC 4t
_EDI DD ?
_ESI DD ?
@@ -99,6 +101,11 @@ __Thunk16 PROC USES ebp ebx esi edi ds es fs gs
push sizeof (IA32_REGS) / 4
pop ecx
rep movsd ; copy context to 16-bit stack
+
+ ; copy eflags to stack frame
+ mov eax, [esi - sizeof(IA32_REGS)]._EFLAGS
+ mov [edi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 4], eax
+
pop ebx ; ebx <- 16-bit stack offset
mov eax, offset @F ; return offset
stosd
@@ -158,20 +165,22 @@ RealMode PROC
pop es
pop fs
pop gs
- add sp, 4 ; skip EFlags
- test (_STK16 ptr [esp + 8]).ThunkFlags, 1
+ sub esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4
+ popfd
+ test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
jz @F
- pushf
+ pushf ; push Flags when it's INT#
@@:
push cs
; push @FarCallRet - _Code16Addr
DB 68h ; push /iw
DW @FarCallRet - _Code16Addr
jz @F
- jmp fword ptr [esp + 6]
+ jmp fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@@:
- jmp fword ptr [esp + 4]
+ jmp fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@FarCallRet:
+ add esp, (sizeof(IA32_REGS) - 12) + STACK_PARAM_SIZE + 4
pushfd
push gs
push fs
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
index 8a865616c1..6c16e25e4b 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/Thunk16Lib.h
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -237,6 +237,13 @@ Returns:
--*/
;
+BOOLEAN
+AsmThunk16SetUserStack (
+ IN THUNK_CONTEXT *ThunkContext,
+ IN VOID *Stack,
+ IN UINTN StackSize
+ );
+
VOID
EFIAPI
AsmThunk16Destroy (
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S
index 30c76974e2..c0807bc523 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.S
@@ -41,8 +41,30 @@ ASM_PFX(AsmFxSave):
# IN CONST IA32_FX_BUFFER *Buffer
# );
#------------------------------------------------------------------------------
-
ASM_PFX(AsmFxRestore):
fxrstor (%rcx)
retq
- \ No newline at end of file
+
+#------------------------------------------------------------------------------
+# UINTN
+# AsmGetEflags (
+# VOID
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmGetEflags):
+ pushfq
+ popq %rax
+ ret
+#AsmGetEflags ENDP
+
+#------------------------------------------------------------------------------
+# VOID
+# AsmSetEflags (
+# IN UINTN Eflags
+# );
+#------------------------------------------------------------------------------
+ASM_PFX(AsmSetEflags):
+ pushq %rcx
+ popfq
+ ret
+#AsmSetEflags ENDP
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
index f9c2e4d57b..ab4a97f23a 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Fx.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -43,4 +43,28 @@ AsmFxRestore PROC
ret
AsmFxRestore ENDP
+;------------------------------------------------------------------------------
+; UINTN
+; AsmGetEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmGetEflags PROC
+ pushfq
+ pop rax
+ ret
+AsmGetEflags ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; AsmSetEflags (
+; IN UINTN Eflags
+; );
+;------------------------------------------------------------------------------
+AsmSetEflags PROC
+ push rcx
+ popfq
+ ret
+AsmSetEflags ENDP
+
END
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
index 888801b1ab..10f3a34c19 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.S
@@ -1,6 +1,6 @@
#*****************************************************************************
#*
-#* Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>
+#* Copyright (c) 2008 - 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
@@ -106,6 +106,9 @@ ASM_PFX(Thunk16):
pushq $0xe #push sizeof (IA32_REGS) / 4
pop %rcx
rep movsl %ds:(%rsi),%es:(%rdi)
+ #; copy eflags to stack frame
+ mov -16(%rsi), %rax
+ mov %rax, -80(%rsi)
pop %rbx #rbx <- 16-bit stack offset
lea Label,%eax #42 <_Thunk16+0x42>
stos %eax,%es:(%rdi)
@@ -183,27 +186,30 @@ ASM_PFX(RealMode):
.byte 0x07 #pop es
popq %fs
popq %gs
- add $0x8,%esp #skip RFLAGS
- .byte 0x67 #test [esp + 0eh], 1
+ sub 64, %esp
+ .byte 0x66, 0x9d #popfd
+ add $0x4,%esp #skip high part of RFLAGS
+ .byte 0x67 #; test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
.byte 0xf7
.byte 0x44
.byte 0x24
- .byte 0x0e
+ .byte 0x4e
.byte 0x01
.byte 0x00
jz 1f
- pushfq #pushf, actually
+ pushfq #pushf, actually, when it's INT#
1:
.byte 0x0e #push cs
.byte 0x68 #push /iw
.word FarCallRet - _Code16Addr
jz 2f
.byte 0x66
- ljmp *6(%esp)
+ ljmp *70(%esp)
2:
.byte 0x66
- ljmp *4(%esp)
+ ljmp *68(%esp)
FarCallRet:
+ add 64, %esp
.byte 0x66
push $0x00 #push a dword of zero
.byte 0x66
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
index b6a8f86879..0638d5faa8 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X64/Thunk16.asm
@@ -1,6 +1,6 @@
;*****************************************************************************
;*
-;* Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+;* Copyright (c) 2006 - 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
@@ -49,6 +49,8 @@ _16Gdtr LABEL FWORD
.code
+STACK_PARAM_SIZE EQU 16
+
IA32_REGS STRUC 4t
_EDI DD ?
_ESI DD ?
@@ -98,6 +100,11 @@ _Thunk16 PROC USES rbp rbx rsi rdi r12 r13 r14 r15
push sizeof (IA32_REGS) / 4
pop rcx
rep movsd
+
+ ; copy eflags to stack frame
+ mov rax, (IA32_REGS ptr [rsi - sizeof(IA32_REGS)])._RFLAGS
+ mov [rdi - sizeof(IA32_REGS) - STACK_PARAM_SIZE - 8], rax
+
pop rbx ; rbx <- 16-bit stack offset
lea eax, @F ; return offset
stosd
@@ -165,22 +172,27 @@ RealMode PROC
DB 7 ; pop es
pop fs
pop gs
+ sub esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8
- add esp, 8 ; skip RFLAGS
- DB 67h, 0f7h, 44h, 24h, 0eh, 1, 0 ; test [esp + 0eh], 1
+ DB 66h, 9Dh ; popfd
+ add esp, 4 ; skip high part of RFLAGS
+ DB 67h, 0f7h, 44h, 24h ; test (_STK16 ptr [esp + STACK_PARAM_SIZE + sizeof(IA32_REGS)]).ThunkFlags, 1
+ DB (STACK_PARAM_SIZE + sizeof(IA32_REGS) + 6)
+ DB 1, 0
jz @F
- pushfq ; pushf, actually
+ pushfq ; pushf, actually, when it's INT#
@@:
DB 0eh ; push cs
DB 68h ; push /iw
DW @FarCallRet - _Code16Addr
jz @F
DB 66h
- jmp fword ptr [esp + 6]
+ jmp fword ptr [esp + 6 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@@:
DB 66h
- jmp fword ptr [esp + 4]
+ jmp fword ptr [esp + 4 + STACK_PARAM_SIZE + sizeof(IA32_REGS) - 8]
@FarCallRet:
+ add esp, (sizeof(IA32_REGS) - 16) + STACK_PARAM_SIZE + 8
DB 66h
push 0 ; push a dword of zero
pushf ; pushfd, actually
diff --git a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c
index c9aafd36aa..ed24663b48 100644
--- a/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c
+++ b/EdkCompatibilityPkg/Foundation/Library/Thunk16/X86Thunk.c
@@ -1,6 +1,6 @@
/*++
-Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 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
@@ -53,6 +53,18 @@ AsmFxSave (
OUT IA32_FX_BUFFER *Buffer
);
+UINTN
+EFIAPI
+AsmGetEflags (
+ VOID
+ );
+
+VOID
+EFIAPI
+AsmSetEflags (
+ IN UINTN Eflags
+ );
+
//
// Implementation
//
@@ -98,6 +110,7 @@ Returns:
{
IA32_FX_BUFFER *FpSavedState;
UINT8 FpBuffer[sizeof (*FpSavedState) + 0x10];
+ UINTN Eflags;
FpSavedState = (IA32_FX_BUFFER*)(((UINTN)FpBuffer + 0xf) & ~0xf);
@@ -110,6 +123,8 @@ Returns:
AsmFxSave (FpSavedState);
}
+ Eflags = AsmGetEflags ();
+
EfiCommonLibCopyMem (
RegisterSet,
_Thunk16 (
@@ -120,6 +135,8 @@ Returns:
sizeof (*RegisterSet)
);
+ AsmSetEflags (Eflags);
+
if (ThunkFlags & THUNK_SAVE_FP_STATE) {
AsmFxRestore (FpSavedState);
}
@@ -200,6 +217,67 @@ Returns:
return ThunkContext;
}
+#pragma pack (1)
+
+typedef struct {
+ UINT32 EDI;
+ UINT32 ESI;
+ UINT32 EBP;
+ UINT32 ESP;
+ UINT32 EBX;
+ UINT32 EDX;
+ UINT32 ECX;
+ UINT32 EAX;
+ UINT16 DS;
+ UINT16 ES;
+ UINT16 FS;
+ UINT16 GS;
+ UINTN EFLAGS;
+ UINT32 EIP;
+ UINT16 CS;
+ UINT16 SS;
+} IA32_REGS;
+
+typedef struct {
+ UINT16 Limit;
+ UINT32 Base;
+} IA32_DESC;
+
+typedef struct {
+ UINT32 RetEip;
+ UINT16 RetCs;
+ UINT16 ThunkFlags;
+#ifdef EFI32
+ UINT32 SavedEsp;
+ UINT16 SavedSs;
+#endif
+ IA32_DESC SavedGdtr;
+#ifdef EFIX64
+ UINT16 Resvd1;
+#endif
+ UINT32 SavedCr0;
+ UINT32 SavedCr4;
+} _STK16;
+#pragma pack ()
+
+#define STACK_PARAM_SIZE 16
+
+BOOLEAN
+AsmThunk16SetUserStack (
+ IN THUNK_CONTEXT *ThunkContext,
+ IN VOID *Stack,
+ IN UINTN StackSize
+ )
+{
+ if (StackSize > STACK_PARAM_SIZE) {
+ return FALSE;
+ }
+
+ EfiCommonLibCopyMem ((VOID *)(UINTN)(ThunkContext->DefaultStack - sizeof(_STK16) - sizeof(IA32_REGS) - STACK_PARAM_SIZE), Stack, StackSize);
+
+ return TRUE;
+}
+
VOID
EFIAPI
AsmThunk16Destroy (
@@ -253,12 +331,8 @@ Arguments:
set on input, otherwise ignored.
EFlages is ignored on input.
On output, values of CS, EIP, SS and ESP should be ignored.
- ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and
- THUNK_USER_STACK.
- THUNK_SAVE_FP_STATE - FPU state would be saved/restored
- before/after calling real mode code.
- THUNK_USER_STACK - The stack specified by SS:ESP would be
- used instead of the default stack.
+ ThunkFlags - THUNK_USER_STACK: The stack specified by SS:ESP would be
+ used instead of the default stack.
Returns:
@@ -298,12 +372,8 @@ Arguments:
set on input, otherwise ignored.
EFlages is ignored on input.
On output, values of CS, EIP, SS and ESP should be ignored.
- ThunkFlags - 2 flags have currently been defined, THUNK_SAVE_FP_STATE and
- THUNK_USER_STACK.
- THUNK_SAVE_FP_STATE - FPU state would be saved/restored
- before/after calling real mode code.
- THUNK_USER_STACK - The stack specified by SS:ESP would be
- used instead of the default stack.
+ ThunkFlags - THUNK_USER_STACK: The stack specified by SS:ESP would be
+ used instead of the default stack.
Returns: