From: vanjeff Date: Tue, 10 Mar 2009 03:10:15 +0000 (+0000) Subject: 1. retried PrimaryConsoleInDeviceGuid, PrimaryConsoleOutDeviceGuid and PrimaryStandar... X-Git-Tag: edk2-stable201903~18409 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=dad608335f432ce7a30a7a0d5496546254633bba 1. retried PrimaryConsoleInDeviceGuid, PrimaryConsoleOutDeviceGuid and PrimaryStandardErrorDeviceGuid. Consplitter will not install these protocols any more. 2. added logic in Bds to check console handles in System table, if no console handle assigned. Bds module will fill these handles in system table accordingly. 3. fixed one bug before call ConsoleControl->SetMode in FrontPage.c. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7841 6f19259b-4bc3-4df7-8a09-765794883524 --- diff --git a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c index f9860a2477..1e34c03e20 100644 --- a/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c +++ b/IntelFrameworkModulePkg/Library/GenericBdsLib/BdsConsole.c @@ -48,6 +48,117 @@ IsNvNeed ( } } +/** + Fill console handle in System Table if there are no valid console handle in. + + Firstly, check the validation of console handle in System Table. If it is invalid, + update it by the first console device handle from EFI console variable. + + @param VarName The name of the EFI console variable. + @param ConsoleGuid Specified Console protocol GUID. + @param ConsoleHandle On IN, console handle in System Table to be checked. + On OUT, new console hanlde in system table. + @param ProtocolInterface On IN, console protocol on console handle in System Table to be checked. + On OUT, new console protocol on new console hanlde in system table. +**/ +VOID +UpdateSystemTableConsole ( + IN CHAR16 *VarName, + IN EFI_GUID *ConsoleGuid, + IN OUT EFI_HANDLE *ConsoleHandle, + IN OUT VOID **ProtocolInterface + ) +{ + EFI_STATUS Status; + UINTN DevicePathSize; + EFI_DEVICE_PATH_PROTOCOL *FullDevicePath; + EFI_DEVICE_PATH_PROTOCOL *VarConsole; + EFI_DEVICE_PATH_PROTOCOL *Instance; + VOID *Interface; + EFI_HANDLE NewHandle; + + ASSERT (VarName != NULL); + ASSERT (ConsoleHandle != NULL); + ASSERT (ConsoleGuid != NULL); + ASSERT (ProtocolInterface != NULL); + + if (*ConsoleHandle != NULL) { + Status = gBS->HandleProtocol ( + *ConsoleHandle, + ConsoleGuid, + &Interface + ); + if (Status == EFI_SUCCESS && Interface == *ProtocolInterface) { + // + // If ConsoleHandle is valid and console protocol on this handle also + // also matched, just return. + // + return; + } + } + + // + // Get all possible consoles device path from EFI variable + // + VarConsole = BdsLibGetVariableAndSize ( + VarName, + &gEfiGlobalVariableGuid, + &DevicePathSize + ); + if (VarConsole == NULL) { + // + // If there is no any console device, just return. + // + return ; + } + + FullDevicePath = VarConsole; + + do { + // + // Check every instance of the console variable + // + Instance = GetNextDevicePathInstance (&VarConsole, &DevicePathSize); + if (Instance == NULL) { + FreePool (FullDevicePath); + ASSERT (FALSE); + } + + // + // Find console device handle by device path instance + // + Status = gBS->LocateDevicePath ( + ConsoleGuid, + &Instance, + &NewHandle + ); + if (!EFI_ERROR (Status)) { + // + // Get the console protocol on this console device handle + // + Status = gBS->HandleProtocol ( + NewHandle, + ConsoleGuid, + &Interface + ); + if (!EFI_ERROR (Status)) { + // + // Update new console handle in System Table. + // + *ConsoleHandle = NewHandle; + *ProtocolInterface = Interface; + return ; + } + } + + } while (Instance != NULL); + + // + // No any available console devcie found. + // + ASSERT (FALSE); +} + /** This function update console variable based on ConVarName, it can add or remove one specific console device path from the variable @@ -406,6 +517,13 @@ BdsLibConnectAllDefaultConsoles ( // BdsLibConnectConsoleVariable (L"ErrOut"); + // + // Fill console handles in System Table if no console device assignd. + // + UpdateSystemTableConsole (L"ConIn", &gEfiSimpleTextInProtocolGuid, &gST->ConsoleInHandle, (VOID **) &gST->ConIn); + UpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut); + UpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr); + return EFI_SUCCESS; } diff --git a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c index 44a1e08689..c1b4eff1cd 100644 --- a/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c +++ b/IntelFrameworkModulePkg/Universal/BdsDxe/FrontPage.c @@ -971,6 +971,7 @@ Exit: // PERF_END (0, "BdsTimeOut", "BDS", 0); Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID **) &ConsoleControl); - ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText); - + if (Status == EFI_SUCCESS) { + ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText); + } } diff --git a/MdeModulePkg/Include/Guid/PrimaryConsoleInDevice.h b/MdeModulePkg/Include/Guid/PrimaryConsoleInDevice.h deleted file mode 100644 index 1d60bb5f2e..0000000000 --- a/MdeModulePkg/Include/Guid/PrimaryConsoleInDevice.h +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - This guid is used to specify the primary console in device. - It will be installed as the protocol guid into the virtual device handle for ConIn Splitter. - -Copyright (c) 2006 - 2009, 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. - -**/ - -#ifndef __PRIMARY_CONSOLE_IN_DEVICE_H__ -#define __PRIMARY_CONSOLE_IN_DEVICE_H__ - -#define EFI_PRIMARY_CONSOLE_IN_DEVICE_GUID \ - { 0xe451dcbe, 0x96a1, 0x4729, {0xa5, 0xcf, 0x6b, 0x9c, 0x2c, 0xff, 0x47, 0xfd } } - -extern EFI_GUID gEfiPrimaryConsoleInDeviceGuid; - -#endif diff --git a/MdeModulePkg/Include/Guid/PrimaryConsoleOutDevice.h b/MdeModulePkg/Include/Guid/PrimaryConsoleOutDevice.h deleted file mode 100644 index 3ea238b43e..0000000000 --- a/MdeModulePkg/Include/Guid/PrimaryConsoleOutDevice.h +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - This guid is used to specify the primary console out device. - It will be installed as the protocol guid into the virtual device handle for ConOut Splitter. - -Copyright (c) 2006 - 2009, 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. - -**/ - -#ifndef __PRIMARY_CONSOLE_OUT_DEVICE_H__ -#define __PRIMARY_CONSOLE_OUT_DEVICE_H__ - -#define EFI_PRIMARY_CONSOLE_OUT_DEVICE_GUID \ - { 0x62bdf38a, 0xe3d5, 0x492c, {0x95, 0xc, 0x23, 0xa7, 0xf6, 0x6e, 0x67, 0x2e } } - -extern EFI_GUID gEfiPrimaryConsoleOutDeviceGuid; - -#endif diff --git a/MdeModulePkg/Include/Guid/PrimaryStandardErrorDevice.h b/MdeModulePkg/Include/Guid/PrimaryStandardErrorDevice.h deleted file mode 100644 index b53f86b7f9..0000000000 --- a/MdeModulePkg/Include/Guid/PrimaryStandardErrorDevice.h +++ /dev/null @@ -1,24 +0,0 @@ -/** @file - This guid is used to specify the primary StdErr device. - It will be installed as the protocol guid into the virtual device handle for StdErr Splitter. - -Copyright (c) 2006 - 2009, 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. - -**/ - -#ifndef __PRIMARY_STANDARD_ERROR_DEVICE_H__ -#define __PRIMARY_STANDARD_ERROR_DEVICE_H__ - -#define EFI_PRIMARY_STANDARD_ERROR_DEVICE_GUID \ - { 0x5a68191b, 0x9b97, 0x4752, {0x99, 0x46, 0xe3, 0x6a, 0x5d, 0xa9, 0x42, 0xb1 } } - -extern EFI_GUID gEfiPrimaryStandardErrorDeviceGuid; - -#endif diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9db9d4a0ba..f056046c88 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -114,18 +114,6 @@ ## Include/Guid/ConsoleInDevice.h gEfiConsoleInDeviceGuid = { 0xD3B36F2B, 0xD551, 0x11D4, { 0x9A, 0x46, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }} - ## Guid specify the primary console out device. - ## Include/Guid/PrimaryConsoleOutDevice.h - gEfiPrimaryConsoleOutDeviceGuid = { 0x62BDF38A, 0xE3D5, 0x492C, { 0x95, 0x0C, 0x23, 0xA7, 0xF6, 0x6E, 0x67, 0x2E }} - - ## Guid specify the primary console in device. - ## Include/Guid/PrimaryConsoleInDevice.h - gEfiPrimaryConsoleInDeviceGuid = { 0xE451DCBE, 0x96A1, 0x4729, { 0xA5, 0xCF, 0x6B, 0x9C, 0x2C, 0xFF, 0x47, 0xFD }} - - ## Guid specify the primary StdErr device. - ## Include/Guid/PrimaryStandardErrorDevice.h - gEfiPrimaryStandardErrorDeviceGuid = { 0x5A68191B, 0x9B97, 0x4752, { 0x99, 0x46, 0xE3, 0x6A, 0x5D, 0xA9, 0x42, 0xB1 }} - ## Hob and Variable guid specify the platform memory type information. ## Include/Guid/MemoryTypeInformation.h gEfiMemoryTypeInformationGuid = { 0x4C19049F, 0x4137, 0x4DD3, { 0x9C, 0x10, 0x8B, 0x97, 0xA8, 0x3F, 0xFD, 0xFA }} diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c index 7650ce4b6d..04ea719e59 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c @@ -429,8 +429,6 @@ ConSplitterDriverEntry( &mStdErr.VirtualHandle, &gEfiSimpleTextOutProtocolGuid, &mStdErr.TextOut, - &gEfiPrimaryStandardErrorDeviceGuid, - NULL, NULL ); } @@ -449,8 +447,6 @@ ConSplitterDriverEntry( &mConIn.SimplePointer, &gEfiAbsolutePointerProtocolGuid, &mConIn.AbsolutePointer, - &gEfiPrimaryConsoleInDeviceGuid, - NULL, NULL ); if (!EFI_ERROR (Status)) { @@ -480,8 +476,6 @@ ConSplitterDriverEntry( &mConOut.UgaDraw, &gEfiConsoleControlProtocolGuid, &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, NULL ); } else if (!FeaturePcdGet (PcdConOutUgaSupport)) { @@ -497,8 +491,6 @@ ConSplitterDriverEntry( &mConOut.GraphicsOutput, &gEfiConsoleControlProtocolGuid, &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, NULL ); } else { @@ -516,8 +508,6 @@ ConSplitterDriverEntry( &mConOut.UgaDraw, &gEfiConsoleControlProtocolGuid, &mConOut.ConsoleControl, - &gEfiPrimaryConsoleOutDeviceGuid, - NULL, NULL ); } diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h index 8c505740c3..0069405242 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.h @@ -29,9 +29,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include -#include -#include -#include #include #include #include diff --git a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf index 730149d6c0..fcb42475f1 100644 --- a/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf +++ b/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf @@ -73,9 +73,7 @@ gEfiConsoleInDeviceGuid ## SOMETIMES_CONSUMES gEfiStandardErrorDeviceGuid ## SOMETIMES_CONSUMES gEfiConsoleOutDeviceGuid ## SOMETIMES_CONSUMES - gEfiPrimaryConsoleOutDeviceGuid ## PRODUCES - gEfiPrimaryConsoleInDeviceGuid ## PRODUCES - gEfiPrimaryStandardErrorDeviceGuid ## PRODUCES + [Protocols] gEfiConsoleControlProtocolGuid ## PRODUCES