diff --git a/Application/CleanNvram/CleanNvram.inf b/Application/CleanNvram/CleanNvram.inf
index 2434fe2d..70a595de 100644
--- a/Application/CleanNvram/CleanNvram.inf
+++ b/Application/CleanNvram/CleanNvram.inf
@@ -43,6 +43,6 @@
[LibraryClasses]
OcBootManagementLib
- OcConsoleControlEntryModeLib
+ OcConsoleControlEntryModeGenericLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
diff --git a/Application/FwProtect/FwProtect.inf b/Application/FwProtect/FwProtect.inf
index 7145e099..fd038e52 100644
--- a/Application/FwProtect/FwProtect.inf
+++ b/Application/FwProtect/FwProtect.inf
@@ -46,7 +46,7 @@
[LibraryClasses]
BaseLib
BaseMemoryLib
- OcConsoleControlEntryModeLib
+ OcConsoleControlEntryModeGenericLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
UefiLib
diff --git a/Application/HdaCodecDump/HdaCodecDump.inf b/Application/HdaCodecDump/HdaCodecDump.inf
index 6d44a573..31314a19 100644
--- a/Application/HdaCodecDump/HdaCodecDump.inf
+++ b/Application/HdaCodecDump/HdaCodecDump.inf
@@ -28,7 +28,7 @@
BaseMemoryLib
DebugLib
MemoryAllocationLib
- OcConsoleControlEntryModeLib
+ OcConsoleControlEntryModeGenericLib
PcdLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
diff --git a/Application/KeyTester/KeyTester.inf b/Application/KeyTester/KeyTester.inf
index 5d4b9332..1b78aeaf 100644
--- a/Application/KeyTester/KeyTester.inf
+++ b/Application/KeyTester/KeyTester.inf
@@ -41,7 +41,7 @@
[LibraryClasses]
DebugLib
- OcConsoleControlEntryModeLib
+ OcConsoleControlEntryModeGenericLib
UefiApplicationEntryPoint
UefiBootServicesTableLib
UefiLib
diff --git a/Application/PavpProvision/PavpProvision.inf b/Application/PavpProvision/PavpProvision.inf
index 56e5c27f..c6843b38 100644
--- a/Application/PavpProvision/PavpProvision.inf
+++ b/Application/PavpProvision/PavpProvision.inf
@@ -53,7 +53,7 @@
gEfiFirmwareVolumeProtocolGuid
[LibraryClasses]
- OcConsoleControlEntryModeLib
+ OcConsoleControlEntryModeGenericLib
OcHeciLib
UefiApplicationEntryPoint
UefiLib
diff --git a/Application/VerifyMsrE2/VerifyMsrE2.inf b/Application/VerifyMsrE2/VerifyMsrE2.inf
index 06d79640..1b14de61 100644
--- a/Application/VerifyMsrE2/VerifyMsrE2.inf
+++ b/Application/VerifyMsrE2/VerifyMsrE2.inf
@@ -44,7 +44,7 @@
gEfiMpServiceProtocolGuid ## CONSUMES
[LibraryClasses]
- OcConsoleControlEntryModeLib
+ OcConsoleControlEntryModeGenericLib
UefiApplicationEntryPoint
UefiLib
PcdLib
diff --git a/Include/Library/OcUnicodeCollationEngLib.h b/Include/Library/OcUnicodeCollationEngGenericLib.h
similarity index 100%
rename from Include/Library/OcUnicodeCollationEngLib.h
rename to Include/Library/OcUnicodeCollationEngGenericLib.h
diff --git a/Library/OcBootServicesTableLib/OcBootServicesTableLib.c b/Library/OcBootServicesTableLib/OcBootServicesTableLib.c
index 8a6ea23c..2b413eb6 100644
--- a/Library/OcBootServicesTableLib/OcBootServicesTableLib.c
+++ b/Library/OcBootServicesTableLib/OcBootServicesTableLib.c
@@ -3,7 +3,7 @@
library's constructor and allow overriding its properties.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
- Copyright (c) 2020, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, vit9696. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
diff --git a/Library/OcBootServicesTableLib/OcBootServicesTableLib.inf b/Library/OcBootServicesTableLib/OcBootServicesTableLib.inf
index ade232e4..b8cad54c 100644
--- a/Library/OcBootServicesTableLib/OcBootServicesTableLib.inf
+++ b/Library/OcBootServicesTableLib/OcBootServicesTableLib.inf
@@ -10,11 +10,11 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = UefiBootServicesTableLib
+ BASE_NAME = OcBootServicesTableLib
FILE_GUID = 64CCF528-1707-4DCB-84B7-EA02FEBB6A16
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = UefiBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+ LIBRARY_CLASS = OcBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
CONSTRUCTOR = OcBootServicesTableLibConstructor
DESTRUCTOR = OcBootServicesTableLibDestructor
diff --git a/Library/OcBootServicesTableLib/UefiBootServicesTableLib.c b/Library/OcBootServicesTableLib/UefiBootServicesTableLib.c
new file mode 100644
index 00000000..7422fe66
--- /dev/null
+++ b/Library/OcBootServicesTableLib/UefiBootServicesTableLib.c
@@ -0,0 +1,7 @@
+/** @file
+ Dummy library for dependency ordering.
+
+ Copyright (c) 2020, vit9696. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
diff --git a/Library/OcBootServicesTableLib/UefiBootServicesTableLib.inf b/Library/OcBootServicesTableLib/UefiBootServicesTableLib.inf
new file mode 100644
index 00000000..9135bd27
--- /dev/null
+++ b/Library/OcBootServicesTableLib/UefiBootServicesTableLib.inf
@@ -0,0 +1,40 @@
+## @file
+# UEFI Boot Services Table Library implementation with override support.
+#
+# Copyright (c) 2020, vit9696. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = UefiBootServicesTableLib
+ FILE_GUID = FEA6B92A-B21D-46DE-A74C-CDFB334CFBE3
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = UefiBootServicesTableLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE
+
+
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ UefiBootServicesTableLib.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OpenCorePkg/OpenCorePkg.dec
+
+[Protocols]
+ gEfiDevicePathProtocolGuid
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ OcBootServicesTableLib
+ # Libraries supporting local installation go here
+ OcConsoleControlEntryModeLocalLib
+ OcUnicodeCollationEngLocalLib
diff --git a/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeGenericLib.inf
similarity index 89%
rename from Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf
rename to Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeGenericLib.inf
index 2684c79c..ed779bdf 100644
--- a/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf
+++ b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeGenericLib.inf
@@ -15,11 +15,11 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = OcConsoleControlEntryModeLib
+ BASE_NAME = OcConsoleControlEntryGenericModeLib
FILE_GUID = 74B78F70-2959-47C7-8EAB-62DED119972B
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- CONSTRUCTOR = OcConsoleControlEntryModeInit
+ CONSTRUCTOR = OcConsoleControlEntryModeConstructor
LIBRARY_CLASS = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVER
#
diff --git a/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c
index 16e68960..1986d4d2 100644
--- a/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c
+++ b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c
@@ -20,7 +20,7 @@
EFI_STATUS
EFIAPI
-OcConsoleControlEntryModeInit (
+OcConsoleControlEntryModeConstructor (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
@@ -28,28 +28,30 @@ OcConsoleControlEntryModeInit (
EFI_STATUS Status;
EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
- //
- // On several firmwares we need to use legacy console control protocol to
- // switch to text mode, otherwise a black screen will be shown.
- //
- Status = gBS->HandleProtocol (
- gST->ConsoleOutHandle,
- &gEfiConsoleControlProtocolGuid,
- (VOID **) &ConsoleControl
- );
- if (EFI_ERROR (Status)) {
- Status = gBS->LocateProtocol (
- &gEfiConsoleControlProtocolGuid,
- NULL,
- (VOID **) &ConsoleControl
- );
- }
-
- if (!EFI_ERROR (Status)) {
- ConsoleControl->SetMode (
- ConsoleControl,
- PcdGet8 (PcdConsoleControlEntryMode)
+ if (FixedPcdGet8 (PcdConsoleControlEntryMode) < EfiConsoleControlScreenMaxValue) {
+ //
+ // On several firmwares we need to use legacy console control protocol to
+ // switch to text mode, otherwise a black screen will be shown.
+ //
+ Status = gBS->HandleProtocol (
+ gST->ConsoleOutHandle,
+ &gEfiConsoleControlProtocolGuid,
+ (VOID **) &ConsoleControl
);
+ if (EFI_ERROR (Status)) {
+ Status = gBS->LocateProtocol (
+ &gEfiConsoleControlProtocolGuid,
+ NULL,
+ (VOID **) &ConsoleControl
+ );
+ }
+
+ if (!EFI_ERROR (Status)) {
+ ConsoleControl->SetMode (
+ ConsoleControl,
+ FixedPcdGet8 (PcdConsoleControlEntryMode)
+ );
+ }
}
return EFI_SUCCESS;
diff --git a/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLocalLib.inf b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLocalLib.inf
new file mode 100644
index 00000000..40e2916a
--- /dev/null
+++ b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLocalLib.inf
@@ -0,0 +1,45 @@
+## @file
+# OcConsoleControlEntryModeLib
+#
+# Copyright (c) 2019, Download-Fritz. All rights reserved.
+#
+# 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
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = OcConsoleControlEntryModeLocalLib
+ FILE_GUID = 987B4FC6-929A-4F34-9C1B-1876484C92FE
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ CONSTRUCTOR = OcConsoleControlEntryModeConstructor
+ LIBRARY_CLASS = NULL|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SAL_DRIVER DXE_SMM_DRIVER SMM_CORE UEFI_APPLICATION UEFI_DRIVER
+
+#
+# VALID_ARCHITECTURES = X64
+#
+
+[Packages]
+ EfiPkg/EfiPkg.dec
+ MdePkg/MdePkg.dec
+ OpenCorePkg/OpenCorePkg.dec
+
+[Pcd]
+ gOpenCorePkgTokenSpaceGuid.PcdConsoleControlEntryMode
+
+[Protocols]
+ gEfiConsoleControlProtocolGuid
+
+[LibraryClasses]
+ PcdLib
+ OcBootServicesTableLib
+
+[Sources]
+ OcConsoleControlEntryModeLib.c
diff --git a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.c b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngCommon.c
similarity index 71%
rename from Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.c
rename to Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngCommon.c
index dcae6127..3538ebe5 100644
--- a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.c
+++ b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngCommon.c
@@ -1,24 +1,13 @@
/** @file
Driver to implement English version of Unicode Collation Protocol.
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
-#include
-#include
-#include
-#include
-
-#include "OcUnicodeCollationEngLibInternal.h"
+#include "OcUnicodeCollationEngInternal.h"
CHAR8 mEngUpperMap[MAP_TABLE_SIZE];
CHAR8 mEngLowerMap[MAP_TABLE_SIZE];
@@ -64,7 +53,7 @@ STATIC CHAR8 UnicodeLanguages[6] = "en";
//
// EFI Unicode Collation2 Protocol supporting RFC 4646 language code
//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_COLLATION_PROTOCOL Unicode2Eng = {
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_COLLATION_PROTOCOL gInternalUnicode2Eng = {
EngStriColl,
EngMetaiMatch,
EngStrLwr,
@@ -74,74 +63,75 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_COLLATION_PROTOCOL Unicode2Eng = {
UnicodeLanguages
};
-/**
- The user Entry Point for English module.
-
- This function initializes unicode character mapping and then installs Unicode
- Collation & Unicode Collation 2 Protocols based on the feature flags.
-
- @param[in] Reinstall Replace any installed protocol.
-
- @returns Installed protocol.
- @retval NULL There was an error installing the protocol.
-**/
-EFI_UNICODE_COLLATION_PROTOCOL *
-OcUnicodeCollationEngInstallProtocol (
- IN BOOLEAN Reinstall
+VOID
+OcUnicodeCollationUpdatePlatformLanguage (
+ VOID
)
{
EFI_STATUS Status;
- BOOLEAN OverwroteLang = FALSE;
- UINTN Index = 0;
- UINTN Index2 = 0;
- EFI_UNICODE_COLLATION_PROTOCOL *Existing = NULL;
- CHAR8 *PlatformLang = NULL;
- UINTN Size = 0;
- EFI_HANDLE NewHandle = NULL;
+ CHAR8 *PlatformLang;
+ UINTN Size;
//
// On several platforms EFI_PLATFORM_LANG_VARIABLE_NAME is not available.
- // Fallback to "en-US" which is supported by this driver and the wide majority of others.
+ // Fallback to "en-US" which is supported by this library and the wide majority of others.
//
- Status = GetVariable2 (EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid, (VOID **) &PlatformLang, &Size);
- //
- // No value or something broken, discard and fallback.
- //
- if (EFI_ERROR (Status) || AsciiStrLen (PlatformLang) < 2) {
- gRT->SetVariable (
- EFI_PLATFORM_LANG_VARIABLE_NAME, &gEfiGlobalVariableGuid,
- EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- 6, "en-US");
- OverwroteLang = TRUE;
+ Size = 0;
+ PlatformLang = NULL;
+ Status = gRT->GetVariable (
+ EFI_PLATFORM_LANG_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &Size,
+ PlatformLang
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ Size,
+ (VOID **) &PlatformLang
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = gRT->GetVariable (
+ EFI_PLATFORM_LANG_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &Size,
+ PlatformLang
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (PlatformLang);
+ }
+ }
}
- if (Reinstall) {
- Status = UninstallAllProtocolInstances (&gEfiUnicodeCollation2ProtocolGuid);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "OCUC: Uninstall failed: %r\n", Status));
- return NULL;
+ if (!EFI_ERROR (Status)) {
+ if (AsciiStrnLenS (PlatformLang, Size) < 2) {
+ gBS->FreePool (PlatformLang);
+ PlatformLang = NULL;
}
} else {
- Status = gBS->LocateProtocol (
- &gEfiUnicodeCollation2ProtocolGuid,
- NULL,
- (VOID **) &Existing);
-
- if (!EFI_ERROR (Status)) {
- //
- // We do not need to install an existing collation.
- //
- return Existing;
- }
+ PlatformLang = NULL;
}
- //
- // On some platforms with missing gEfiUnicodeCollation2ProtocolGuid EFI_PLATFORM_LANG_VARIABLE_NAME is set
- // to the value different from "en" or "en-...". This is not going to work with our driver UEFI Shell load failures:
- // we did not overwrite EFI_PLATFORM_LANG_VARIABLE_NAME, but it uses some other language.
- // Workaround by appending the other language to the list of supported ones.
- //
- if (!OverwroteLang && AsciiStrnCmp (PlatformLang, "en", 2)) {
+ if (PlatformLang == NULL) {
+ //
+ // No value or something broken, discard and fallback.
+ //
+ gRT->SetVariable (
+ EFI_PLATFORM_LANG_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ sizeof ("en-US"),
+ "en-US"
+ );
+ } else if (AsciiStrnCmp (PlatformLang, "en", 2) != 0) {
+ //
+ // On some platforms with missing gEfiUnicodeCollation2ProtocolGuid EFI_PLATFORM_LANG_VARIABLE_NAME is set
+ // to the value different from "en" or "en-...". This is not going to work with our driver and UEFI Shell
+ // will fail to load. Since we did not overwrite EFI_PLATFORM_LANG_VARIABLE_NAME, and it uses some other language,
+ // workaround by appending the other language to the list of supported ones.
+ //
STATIC_ASSERT (sizeof (UnicodeLanguages) == 6 && sizeof (UnicodeLanguages[0]) == 1,
"UnicodeLanguages must contain one extra language");
UnicodeLanguages[2] = ';';
@@ -153,9 +143,18 @@ OcUnicodeCollationEngInstallProtocol (
//
// Free allocated memory for platform languages
//
- if (PlatformLang) {
+ if (PlatformLang != NULL) {
gBS->FreePool (PlatformLang);
}
+}
+
+VOID
+OcUnicodeCollationInitializeMappingTables (
+ VOID
+ )
+{
+ UINTN Index;
+ UINTN Index2;
//
// Initialize mapping tables for the supported languages
@@ -180,21 +179,8 @@ OcUnicodeCollationEngInstallProtocol (
Index2 = mOtherChars[Index];
mEngInfoMap[Index2] |= CHAR_FAT_VALID;
}
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &NewHandle,
- &gEfiUnicodeCollation2ProtocolGuid,
- &Unicode2Eng,
- NULL
- );
- if (EFI_ERROR (Status)) {
- return NULL;
- }
-
- return &Unicode2Eng;
}
-
/**
Performs a case-insensitive comparison of two Null-terminated strings.
diff --git a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGeneric.c b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGeneric.c
new file mode 100644
index 00000000..376ff0df
--- /dev/null
+++ b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGeneric.c
@@ -0,0 +1,57 @@
+/** @file
+ Normal library constructor routines.
+
+ Copyright (c) 2020, vit9696. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "OcUnicodeCollationEngInternal.h"
+#include
+
+EFI_UNICODE_COLLATION_PROTOCOL *
+OcUnicodeCollationEngInstallProtocol (
+ IN BOOLEAN Reinstall
+ )
+{
+ EFI_STATUS Status;
+ EFI_UNICODE_COLLATION_PROTOCOL *Existing;
+ EFI_HANDLE NewHandle;
+
+ OcUnicodeCollationUpdatePlatformLanguage ();
+ OcUnicodeCollationInitializeMappingTables ();
+
+ if (Reinstall) {
+ Status = UninstallAllProtocolInstances (&gEfiUnicodeCollation2ProtocolGuid);
+ if (EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_ERROR, "OCUC: Uninstall failed: %r\n", Status));
+ return NULL;
+ }
+ } else {
+ Status = gBS->LocateProtocol (
+ &gEfiUnicodeCollation2ProtocolGuid,
+ NULL,
+ (VOID **) &Existing
+ );
+
+ if (!EFI_ERROR (Status)) {
+ //
+ // We do not need to install an existing collation.
+ //
+ return Existing;
+ }
+ }
+
+ NewHandle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &NewHandle,
+ &gEfiUnicodeCollation2ProtocolGuid,
+ &gInternalUnicode2Eng,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ return &gInternalUnicode2Eng;
+}
diff --git a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.inf b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf
similarity index 79%
rename from Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.inf
rename to Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf
index 30aaa552..558b2d76 100644
--- a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.inf
+++ b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf
@@ -16,11 +16,11 @@
[Defines]
INF_VERSION = 0x00010005
- BASE_NAME = OcUnicodeCollationEngLib
+ BASE_NAME = OcUnicodeCollationEngGenericLib
FILE_GUID = 5D91AD3D-05B2-497F-BF82-A8707174FCBD
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = OcUnicodeCollationEngLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION DXE_SMM_DRIVER DXE_SAL_DRIVER
+ LIBRARY_CLASS = OcUnicodeCollationEngGenericLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION DXE_SMM_DRIVER DXE_SAL_DRIVER
#
# The following information is for reference only and not required by the build tools.
@@ -29,12 +29,12 @@
#
[Sources]
- OcUnicodeCollationEngLib.c
- OcUnicodeCollationEngLibInternal.h
+ OcUnicodeCollationEngCommon.c
+ OcUnicodeCollationEngGeneric.c
+ OcUnicodeCollationEngInternal.h
[Packages]
MdePkg/MdePkg.dec
- EfiPkg/EfiPkg.dec
OpenCorePkg/OpenCorePkg.dec
[Guids]
@@ -46,6 +46,5 @@
[LibraryClasses]
BaseLib
DebugLib
- UefiLib
UefiBootServicesTableLib
UefiRuntimeServicesTableLib
diff --git a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLibInternal.h b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngInternal.h
similarity index 85%
rename from Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLibInternal.h
rename to Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngInternal.h
index 15965e63..2a9e7de9 100644
--- a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLibInternal.h
+++ b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngInternal.h
@@ -1,14 +1,8 @@
/** @file
Head file for Unicode Collation Protocol (English)
-Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
-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
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -23,7 +17,10 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
+#include
#include
+#include
+#include
#include
#include
#include
@@ -165,5 +162,27 @@ EngStrToFat (
OUT CHAR8 *Fat
);
+/**
+ Initializes mapping tables for the protocol.
+**/
+VOID
+OcUnicodeCollationInitializeMappingTables (
+ VOID
+ );
+
+/**
+ Sets EFI_PLATFORM_LANG_VARIABLE_NAME when it is missing and ensures
+ that our installed protocol supports the language obtained from
+ the existing EFI_PLATFORM_LANG_VARIABLE_NAME.
+**/
+VOID
+OcUnicodeCollationUpdatePlatformLanguage (
+ VOID
+ );
+
+/**
+ Unicode collation instance.
+**/
+extern EFI_UNICODE_COLLATION_PROTOCOL gInternalUnicode2Eng;
#endif
diff --git a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocal.c b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocal.c
new file mode 100644
index 00000000..60a6d83e
--- /dev/null
+++ b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocal.c
@@ -0,0 +1,28 @@
+/** @file
+ Local library constructor routines.
+
+ Copyright (c) 2020, vit9696. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "OcUnicodeCollationEngInternal.h"
+#include
+
+EFI_STATUS
+EFIAPI
+OcUnicodeCollationEngLocalLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ OcUnicodeCollationUpdatePlatformLanguage ();
+ OcUnicodeCollationInitializeMappingTables ();
+ OcRegisterBootServicesProtocol (
+ &gEfiUnicodeCollation2ProtocolGuid,
+ &gInternalUnicode2Eng,
+ FALSE
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocalLib.inf b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocalLib.inf
new file mode 100644
index 00000000..dbc1e61b
--- /dev/null
+++ b/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocalLib.inf
@@ -0,0 +1,52 @@
+## @file
+#
+# Component description file for the library producing the English version of Unicode Collation Protocol.
+#
+# Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.
+#
+# 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
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = OcUnicodeCollationEngLocalLib
+ FILE_GUID = 342AB6E7-B87F-41C4-B8D3-51CB24065446
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = OcUnicodeCollationEngLocalLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER UEFI_APPLICATION DXE_SMM_DRIVER DXE_SAL_DRIVER
+
+ CONSTRUCTOR = OcUnicodeCollationEngLocalLibConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 IPF EBC
+#
+
+[Sources]
+ OcUnicodeCollationEngCommon.c
+ OcUnicodeCollationEngInternal.h
+ OcUnicodeCollationEngLocal.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ OpenCorePkg/OpenCorePkg.dec
+
+[Guids]
+ gEfiGlobalVariableGuid # CONSUMES
+
+[Protocols]
+ gEfiUnicodeCollation2ProtocolGuid # SOMETIMES_PRODUCES
+
+[LibraryClasses]
+ BaseLib
+ DebugLib
+ OcBootServicesTableLib
+ UefiRuntimeServicesTableLib
diff --git a/OpenCorePkg.dec b/OpenCorePkg.dec
index c84f327d..34c745ac 100755
--- a/OpenCorePkg.dec
+++ b/OpenCorePkg.dec
@@ -122,6 +122,7 @@
## Defines the Console Control initialization mode set on entry.
# 0 - EfiConsoleControlScreenText
# 1 - EfiConsoleControlScreenGraphics
+ # 2 - EfiConsoleControlScreenMaxValue (does nothing)
# @Prompt Initialize the console to the specified mode on entry.
gOpenCorePkgTokenSpaceGuid.PcdConsoleControlEntryMode|0|UINT8|0x00000100
@@ -189,6 +190,9 @@
## @libraryclass
OcBootManagementLib|Include/Library/OcBootManagementLib.h
+ ## @libraryclass
+ OcBootServicesTableLib|Include/Library/OcBootServicesTableLib.h
+
## @libraryclass
OcCompressionLib|Include/Library/OcCompressionLib.h
@@ -286,7 +290,7 @@
OcTimerLib|Include/Library/OcTimerLib.h
## @libraryclass
- OcUnicodeCollationEngLib|Include/Library/OcUnicodeCollationEngLib.h
+ OcUnicodeCollationEngGenericLib|Include/Library/OcUnicodeCollationEngGenericLib.h
## @libraryclass
OcVirtualFsLib|Include/Library/OcVirtualFsLib.h
diff --git a/OpenCorePkg.dsc b/OpenCorePkg.dsc
index 1f186932..cbbdd89f 100755
--- a/OpenCorePkg.dsc
+++ b/OpenCorePkg.dsc
@@ -60,9 +60,11 @@
OcAppleUserInterfaceThemeLib|OpenCorePkg/Library/OcAppleUserInterfaceThemeLib/OcAppleUserInterfaceThemeLib.inf
OcAudioLib|OpenCorePkg/Library/OcAudioLib/OcAudioLib.inf
OcBootManagementLib|OpenCorePkg/Library/OcBootManagementLib/OcBootManagementLib.inf
+ OcBootServicesTableLib|OpenCorePkg/Library/OcBootServicesTableLib/OcBootServicesTableLib.inf
OcCompressionLib|OpenCorePkg/Library/OcCompressionLib/OcCompressionLib.inf
OcConfigurationLib|OpenCorePkg/Library/OcConfigurationLib/OcConfigurationLib.inf
- OcConsoleControlEntryModeLib|OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf
+ OcConsoleControlEntryModeGenericLib|OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeGenericLib.inf
+ OcConsoleControlEntryModeLocalLib|OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLocalLib.inf
OcConsoleLib|OpenCorePkg/Library/OcConsoleLib/OcConsoleLib.inf
OcCpuLib|OpenCorePkg/Library/OcCpuLib/OcCpuLib.inf
OcCryptoLib|OpenCorePkg/Library/OcCryptoLib/OcCryptoLib.inf
@@ -94,7 +96,8 @@
OcStringLib|OpenCorePkg/Library/OcStringLib/OcStringLib.inf
OcTemplateLib|OpenCorePkg/Library/OcTemplateLib/OcTemplateLib.inf
OcTimerLib|OpenCorePkg/Library/OcTimerLib/OcTimerLib.inf
- OcUnicodeCollationEngLib|OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.inf
+ OcUnicodeCollationEngGenericLib|OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf
+ OcUnicodeCollationEngLocalLib|OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocalLib.inf
OcVirtualFsLib|OpenCorePkg/Library/OcVirtualFsLib/OcVirtualFsLib.inf
OcXmlLib|OpenCorePkg/Library/OcXmlLib/OcXmlLib.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
@@ -165,7 +168,8 @@
OpenCorePkg/Library/OcCompilerIntrinsicsLib/OcCompilerIntrinsicsLib.inf
OpenCorePkg/Library/OcCompressionLib/OcCompressionLib.inf
OpenCorePkg/Library/OcConfigurationLib/OcConfigurationLib.inf
- OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf
+ OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeGenericLib.inf
+ OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLocalLib.inf
OpenCorePkg/Library/OcConsoleLib/OcConsoleLib.inf
OpenCorePkg/Library/OcCpuLib/OcCpuLib.inf
OpenCorePkg/Library/OcCryptoLib/OcCryptoLib.inf
@@ -196,7 +200,8 @@
OpenCorePkg/Library/OcStringLib/OcStringLib.inf
OpenCorePkg/Library/OcTemplateLib/OcTemplateLib.inf
OpenCorePkg/Library/OcTimerLib/OcTimerLib.inf
- OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLib.inf
+ OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngGenericLib.inf
+ OpenCorePkg/Library/OcUnicodeCollationEngLib/OcUnicodeCollationEngLocalLib.inf
OpenCorePkg/Library/OcVirtualFsLib/OcVirtualFsLib.inf
OpenCorePkg/Library/OcXmlLib/OcXmlLib.inf
OpenCorePkg/Platform/AppleUsbKbDxe/UsbKbDxe.inf
@@ -227,10 +232,8 @@
# For some reason ShellPkg overrides this, so do we.
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|16000
- # Switch to console mode at startup.
- NULL|OpenCorePkg/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf
# Use custom BootServicesTable
- UefiBootServicesTableLib|OpenCorePkg/Library/OcBootServicesTableLib/OcBootServicesTableLib.inf
+ UefiBootServicesTableLib|OpenCorePkg/Library/OcBootServicesTableLib/UefiBootServicesTableLib.inf
# Add the original commands.
NULL|ShellPkg/Library/UefiShellLevel2CommandsLib/UefiShellLevel2CommandsLib.inf
NULL|ShellPkg/Library/UefiShellLevel1CommandsLib/UefiShellLevel1CommandsLib.inf
diff --git a/Platform/OpenCore/OpenCore.inf b/Platform/OpenCore/OpenCore.inf
index 32de458c..065140ae 100644
--- a/Platform/OpenCore/OpenCore.inf
+++ b/Platform/OpenCore/OpenCore.inf
@@ -96,7 +96,7 @@
OcSmbiosLib
OcSmcLib
OcStorageLib
- OcUnicodeCollationEngLib
+ OcUnicodeCollationEngGenericLib
OcVirtualFsLib
MacInfoLib
PcdLib
diff --git a/Platform/OpenCore/OpenCoreUefi.c b/Platform/OpenCore/OpenCoreUefi.c
index a7f9e133..f9e056bb 100644
--- a/Platform/OpenCore/OpenCoreUefi.c
+++ b/Platform/OpenCore/OpenCoreUefi.c
@@ -39,7 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
#include
#include
-#include
+#include
#include
#include
#include
diff --git a/Platform/OpenCore/OpenCoreUefiAudio.c b/Platform/OpenCore/OpenCoreUefiAudio.c
index dbab5f8f..b648f140 100644
--- a/Platform/OpenCore/OpenCoreUefiAudio.c
+++ b/Platform/OpenCore/OpenCoreUefiAudio.c
@@ -40,7 +40,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
#include
#include
-#include
#include
#include
#include
diff --git a/Platform/OpenCore/OpenCoreUefiInOut.c b/Platform/OpenCore/OpenCoreUefiInOut.c
index c9f51e12..bc223ad6 100644
--- a/Platform/OpenCore/OpenCoreUefiInOut.c
+++ b/Platform/OpenCore/OpenCoreUefiInOut.c
@@ -40,7 +40,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include
#include
#include
-#include
#include
#include
#include