From c3c9754c26de5351d7fcea104dd1fbfa76d08994 Mon Sep 17 00:00:00 2001 From: Download-Fritz Date: Wed, 22 May 2019 16:02:26 +0200 Subject: [PATCH] OcConsoleControlEntryModeLib: Initial import --- .../OcConsoleControlEntryModeLib.c | 47 +++++++++++++++++++ .../OcConsoleControlEntryModeLib.inf | 45 ++++++++++++++++++ OcSupportPkg.dec | 7 +++ 3 files changed, 99 insertions(+) create mode 100644 Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c create mode 100644 Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf diff --git a/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c new file mode 100644 index 00000000..6179a72f --- /dev/null +++ b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.c @@ -0,0 +1,47 @@ +/** @file + 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. + +**/ + +#include + +#include + +#include +#include + +EFI_STATUS +EFIAPI +OcConsoleControlEntryModeInit ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + 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)) { + ConsoleControl->SetMode ( + ConsoleControl, + PcdGet8 (PcdConsoleControlEntryMode) + ); + } + + return EFI_SUCCESS; +} diff --git a/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.inf new file mode 100644 index 00000000..4488f44f --- /dev/null +++ b/Library/OcConsoleControlEntryModeLib/OcConsoleControlEntryModeLib.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 = OcConsoleControlEntryModeLib + FILE_GUID = 74B78F70-2959-47C7-8EAB-62DED119972B + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + CONSTRUCTOR = OcConsoleControlEntryModeInit + LIBRARY_CLASS = OcConsoleControlEntryModeLib|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 + OcSupportPkg/OcSupportPkg.dec + +[Pcd] + gOcSupportPkgTokenSpaceGuid.PcdConsoleControlEntryMode + +[Protocols] + gEfiConsoleControlProtocolGuid + +[LibraryClasses] + PcdLib + UefiBootServicesTableLib + +[Sources] + OcConsoleControlEntryModeLib.c diff --git a/OcSupportPkg.dec b/OcSupportPkg.dec index 263811c1..127eb3a5 100644 --- a/OcSupportPkg.dec +++ b/OcSupportPkg.dec @@ -57,6 +57,13 @@ # @Prompt Register a protocol installation notify for Apple KeyMap Database when not found initially. gOcSupportPkgTokenSpaceGuid.PcNvramInitDevicePropertyDatabase|FALSE|BOOLEAN|0x00000001 +[PcdsFixedAtBuild] + ## Defines the Console Control initialization mode set on entry.

+ # 0 - EfiConsoleControlScreenText
+ # 1 - EfiConsoleControlScreenGraphics
+ # @Prompt Initialize the console to the specified mode on entry. + gOcSupportPkgTokenSpaceGuid.PcdConsoleControlEntryMode|0|UINT8|0x00000100 + [LibraryClasses] ## @libraryclass OcAcpiLib|Include/Library/OcAcpiLib.h