Add 2 new Bds features
1. Lazy ConIn 2. OsIndicationsSupported & OsIndications Signed-off-by: Chao Zhang<chao.b.zhang@intel.com> Reviewed-by: Hot Tian<Hot.Tian@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13566 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -4,7 +4,7 @@
|
|||||||
2) BDS boot device connect interface.
|
2) BDS boot device connect interface.
|
||||||
3) BDS Misc interfaces for mainting boot variable, ouput string.
|
3) BDS Misc interfaces for mainting boot variable, ouput string.
|
||||||
|
|
||||||
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available under
|
This program and the accompanying materials are licensed and made available under
|
||||||
the terms and conditions of the BSD License that accompanies this distribution.
|
the terms and conditions of the BSD License that accompanies this distribution.
|
||||||
The full text of the license may be found at
|
The full text of the license may be found at
|
||||||
@ -465,6 +465,23 @@ BdsLibConnectAllDefaultConsoles (
|
|||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function will connect console device except ConIn base on the console
|
||||||
|
device variable ConOut and ErrOut.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS At least one of the ConOut device have
|
||||||
|
been connected success.
|
||||||
|
@retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BdsLibConnectAllDefaultConsolesWithOutConIn (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function updates the console variable based on ConVarName. It can
|
This function updates the console variable based on ConVarName. It can
|
||||||
add or remove one specific console device path from the variable
|
add or remove one specific console device path from the variable
|
||||||
|
@ -561,6 +561,75 @@ BdsLibConnectAllDefaultConsoles (
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function will connect console device except ConIn base on the console
|
||||||
|
device variable ConOut and ErrOut.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS At least one of the ConOut device have
|
||||||
|
been connected success.
|
||||||
|
@retval EFI_STATUS Return the status of BdsLibConnectConsoleVariable ().
|
||||||
|
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
BdsLibConnectAllDefaultConsolesWithOutConIn (
|
||||||
|
VOID
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
BOOLEAN SystemTableUpdated;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Connect all default console variables except ConIn
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// It seems impossible not to have any ConOut device on platform,
|
||||||
|
// so we check the status here.
|
||||||
|
//
|
||||||
|
Status = BdsLibConnectConsoleVariable (L"ConOut");
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Insert the performance probe for Console Out
|
||||||
|
//
|
||||||
|
PERF_START (NULL, "ConOut", "BDS", 1);
|
||||||
|
PERF_END (NULL, "ConOut", "BDS", 0);
|
||||||
|
|
||||||
|
//
|
||||||
|
// The _ModuleEntryPoint err out var is legal.
|
||||||
|
//
|
||||||
|
BdsLibConnectConsoleVariable (L"ErrOut");
|
||||||
|
|
||||||
|
SystemTableUpdated = FALSE;
|
||||||
|
//
|
||||||
|
// Fill console handles in System Table if no console device assignd.
|
||||||
|
//
|
||||||
|
if (UpdateSystemTableConsole (L"ConOut", &gEfiSimpleTextOutProtocolGuid, &gST->ConsoleOutHandle, (VOID **) &gST->ConOut)) {
|
||||||
|
SystemTableUpdated = TRUE;
|
||||||
|
}
|
||||||
|
if (UpdateSystemTableConsole (L"ErrOut", &gEfiSimpleTextOutProtocolGuid, &gST->StandardErrorHandle, (VOID **) &gST->StdErr)) {
|
||||||
|
SystemTableUpdated = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SystemTableUpdated) {
|
||||||
|
//
|
||||||
|
// Update the CRC32 in the EFI System Table header
|
||||||
|
//
|
||||||
|
gST->Hdr.CRC32 = 0;
|
||||||
|
gBS->CalculateCrc32 (
|
||||||
|
(UINT8 *) &gST->Hdr,
|
||||||
|
gST->Hdr.HeaderSize,
|
||||||
|
&gST->Hdr.CRC32
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
|
Convert a *.BMP graphics image to a GOP blt buffer. If a NULL Blt buffer
|
||||||
is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
|
is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
|
||||||
|
@ -180,6 +180,7 @@
|
|||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision
|
gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareRevision
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
|
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand
|
||||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutColumn
|
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutColumn
|
||||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutRow
|
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupConOutRow
|
||||||
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
|
gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdSetupVideoHorizontalResolution
|
||||||
|
@ -361,22 +361,80 @@ BdsFormalizeConsoleVariable (
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Validate variables.
|
Formalize Bds global variables.
|
||||||
|
|
||||||
If found the device path is not a valid device path, remove the variable.
|
|
||||||
|
|
||||||
|
1. For ConIn/ConOut/ConErr, if found the device path is not a valid device path, remove the variable.
|
||||||
|
2. For OsIndicationsSupported, Create a BS/RT/UINT64 variable to report caps
|
||||||
|
3. Delete OsIndications variable if it is not NV/BS/RT UINT64
|
||||||
|
Item 3 is used to solve case when OS corrupts OsIndications. Here simply delete this NV variable.
|
||||||
|
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
BdsFormalizeEfiGlobalVariable (
|
BdsFormalizeEfiGlobalVariable (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
UINT64 OsIndicationSupport;
|
||||||
|
UINT64 OsIndication;
|
||||||
|
UINTN DataSize;
|
||||||
|
UINT32 Attributes;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Console variable.
|
// Validate Console variable.
|
||||||
//
|
//
|
||||||
BdsFormalizeConsoleVariable (L"ConIn");
|
BdsFormalizeConsoleVariable (L"ConIn");
|
||||||
BdsFormalizeConsoleVariable (L"ConOut");
|
BdsFormalizeConsoleVariable (L"ConOut");
|
||||||
BdsFormalizeConsoleVariable (L"ErrOut");
|
BdsFormalizeConsoleVariable (L"ErrOut");
|
||||||
|
|
||||||
|
//
|
||||||
|
// OS indicater support variable
|
||||||
|
//
|
||||||
|
OsIndicationSupport = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
|
||||||
|
Status = gRT->SetVariable (
|
||||||
|
L"OsIndicationsSupported",
|
||||||
|
&gEfiGlobalVariableGuid,
|
||||||
|
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
|
||||||
|
sizeof(UINT64),
|
||||||
|
&OsIndicationSupport
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// If OsIndications is invalid, remove it.
|
||||||
|
// Invalid case
|
||||||
|
// 1. Data size != UINT64
|
||||||
|
// 2. OsIndication value inconsistence
|
||||||
|
// 3. OsIndication attribute inconsistence
|
||||||
|
//
|
||||||
|
OsIndication = 0;
|
||||||
|
Attributes = 0;
|
||||||
|
DataSize = sizeof(UINT64);
|
||||||
|
Status = gRT->GetVariable (
|
||||||
|
L"OsIndications",
|
||||||
|
&gEfiGlobalVariableGuid,
|
||||||
|
&Attributes,
|
||||||
|
&DataSize,
|
||||||
|
&OsIndication
|
||||||
|
);
|
||||||
|
|
||||||
|
if (!EFI_ERROR(Status)) {
|
||||||
|
if (DataSize != sizeof(UINT64) ||
|
||||||
|
(OsIndication & ~OsIndicationSupport) != 0 ||
|
||||||
|
Attributes != (EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE)){
|
||||||
|
|
||||||
|
DEBUG ((EFI_D_ERROR, "Unformalized OsIndications variable exists. Delete it\n"));
|
||||||
|
Status = gRT->SetVariable (
|
||||||
|
L"OsIndications",
|
||||||
|
&gEfiGlobalVariableGuid,
|
||||||
|
Attributes,
|
||||||
|
0,
|
||||||
|
&OsIndication
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -902,7 +902,7 @@ ShowProgress (
|
|||||||
if (TimeoutDefault == 0) {
|
if (TimeoutDefault == 0) {
|
||||||
return EFI_TIMEOUT;
|
return EFI_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
|
DEBUG ((EFI_D_INFO, "\n\nStart showing progress bar... Press any key to stop it! ...Zzz....\n"));
|
||||||
|
|
||||||
SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
|
SetMem (&Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), 0xff);
|
||||||
@ -962,16 +962,18 @@ ShowProgress (
|
|||||||
//
|
//
|
||||||
// User pressed some key
|
// User pressed some key
|
||||||
//
|
//
|
||||||
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
if (!PcdGetBool (PcdConInConnectOnDemand)) {
|
||||||
if (EFI_ERROR (Status)) {
|
Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||||
return Status;
|
if (EFI_ERROR (Status)) {
|
||||||
}
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
|
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
|
||||||
//
|
//
|
||||||
// User pressed enter, equivalent to select "continue"
|
// User pressed enter, equivalent to select "continue"
|
||||||
//
|
//
|
||||||
return EFI_TIMEOUT;
|
return EFI_TIMEOUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
@ -1002,7 +1004,10 @@ PlatformBdsEnterFrontPage (
|
|||||||
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
|
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;
|
||||||
UINTN BootTextColumn;
|
UINTN BootTextColumn;
|
||||||
UINTN BootTextRow;
|
UINTN BootTextRow;
|
||||||
|
UINT64 OsIndication;
|
||||||
|
UINTN DataSize;
|
||||||
|
EFI_INPUT_KEY Key;
|
||||||
|
|
||||||
GraphicsOutput = NULL;
|
GraphicsOutput = NULL;
|
||||||
SimpleTextOut = NULL;
|
SimpleTextOut = NULL;
|
||||||
|
|
||||||
@ -1013,7 +1018,7 @@ PlatformBdsEnterFrontPage (
|
|||||||
if (ConnectAllHappened) {
|
if (ConnectAllHappened) {
|
||||||
gConnectAllHappened = TRUE;
|
gConnectAllHappened = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mModeInitialized) {
|
if (!mModeInitialized) {
|
||||||
//
|
//
|
||||||
// After the console is ready, get current video resolution
|
// After the console is ready, get current video resolution
|
||||||
@ -1067,27 +1072,72 @@ PlatformBdsEnterFrontPage (
|
|||||||
mModeInitialized = TRUE;
|
mModeInitialized = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
HotkeyBoot ();
|
//
|
||||||
if (TimeoutDefault != 0xffff) {
|
// goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set
|
||||||
Status = ShowProgress (TimeoutDefault);
|
//
|
||||||
StatusHotkey = HotkeyBoot ();
|
OsIndication = 0;
|
||||||
|
DataSize = sizeof(UINT64);
|
||||||
|
Status = gRT->GetVariable (
|
||||||
|
L"OsIndications",
|
||||||
|
&gEfiGlobalVariableGuid,
|
||||||
|
NULL,
|
||||||
|
&DataSize,
|
||||||
|
&OsIndication
|
||||||
|
);
|
||||||
|
|
||||||
if (!FeaturePcdGet(PcdBootlogoOnlyEnable) || !EFI_ERROR(Status) || !EFI_ERROR(StatusHotkey)){
|
//
|
||||||
//
|
// goto FrontPage directly when EFI_OS_INDICATIONS_BOOT_TO_FW_UI is set. Skip HotkeyBoot
|
||||||
// Ensure screen is clear when switch Console from Graphics mode to Text mode
|
//
|
||||||
// Skip it in normal boot
|
if (!EFI_ERROR(Status) && (OsIndication & EFI_OS_INDICATIONS_BOOT_TO_FW_UI)) {
|
||||||
//
|
//
|
||||||
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
|
// Clear EFI_OS_INDICATIONS_BOOT_TO_FW_UI to acknowledge OS
|
||||||
gST->ConOut->ClearScreen (gST->ConOut);
|
//
|
||||||
|
OsIndication &= ~EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
|
||||||
|
Status = gRT->SetVariable (
|
||||||
|
L"OsIndications",
|
||||||
|
&gEfiGlobalVariableGuid,
|
||||||
|
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
|
||||||
|
sizeof(UINT64),
|
||||||
|
&OsIndication
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Follow generic rule, Call ReadKeyStroke to connect ConIn before enter UI
|
||||||
|
//
|
||||||
|
if (PcdGetBool (PcdConInConnectOnDemand)) {
|
||||||
|
gST->ConIn->ReadKeyStroke(gST->ConIn, &Key);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR (Status)) {
|
//
|
||||||
//
|
// Ensure screen is clear when switch Console from Graphics mode to Text mode
|
||||||
// Timeout or user press enter to continue
|
//
|
||||||
//
|
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
|
||||||
goto Exit;
|
gST->ConOut->ClearScreen (gST->ConOut);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
HotkeyBoot ();
|
||||||
|
if (TimeoutDefault != 0xffff) {
|
||||||
|
Status = ShowProgress (TimeoutDefault);
|
||||||
|
StatusHotkey = HotkeyBoot ();
|
||||||
|
|
||||||
|
if (!FeaturePcdGet(PcdBootlogoOnlyEnable) || !EFI_ERROR(Status) || !EFI_ERROR(StatusHotkey)){
|
||||||
|
//
|
||||||
|
// Ensure screen is clear when switch Console from Graphics mode to Text mode
|
||||||
|
// Skip it in normal boot
|
||||||
|
//
|
||||||
|
gST->ConOut->EnableCursor (gST->ConOut, TRUE);
|
||||||
|
gST->ConOut->ClearScreen (gST->ConOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
//
|
||||||
|
// Timeout or user press enter to continue
|
||||||
|
//
|
||||||
|
goto Exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,30 +346,32 @@ BdsMemoryTest (
|
|||||||
DEBUG ((EFI_D_INFO, "Perform memory test (ESC to skip).\n"));
|
DEBUG ((EFI_D_INFO, "Perform memory test (ESC to skip).\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
if (!PcdGetBool (PcdConInConnectOnDemand)) {
|
||||||
if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
|
KeyStatus = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
|
||||||
if (!RequireSoftECCInit) {
|
if (!EFI_ERROR (KeyStatus) && (Key.ScanCode == SCAN_ESC)) {
|
||||||
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
|
if (!RequireSoftECCInit) {
|
||||||
TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));
|
if (!FeaturePcdGet(PcdBootlogoOnlyEnable)) {
|
||||||
if (TmpStr != NULL) {
|
TmpStr = GetStringById (STRING_TOKEN (STR_PERFORM_MEM_TEST));
|
||||||
PlatformBdsShowProgress (
|
if (TmpStr != NULL) {
|
||||||
Foreground,
|
PlatformBdsShowProgress (
|
||||||
Background,
|
Foreground,
|
||||||
TmpStr,
|
Background,
|
||||||
Color,
|
TmpStr,
|
||||||
100,
|
Color,
|
||||||
(UINTN) PreviousValue
|
100,
|
||||||
);
|
(UINTN) PreviousValue
|
||||||
FreePool (TmpStr);
|
);
|
||||||
|
FreePool (TmpStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
PrintXY (10, 10, NULL, NULL, L"100");
|
||||||
}
|
}
|
||||||
|
Status = GenMemoryTest->Finished (GenMemoryTest);
|
||||||
PrintXY (10, 10, NULL, NULL, L"100");
|
goto Done;
|
||||||
}
|
}
|
||||||
Status = GenMemoryTest->Finished (GenMemoryTest);
|
|
||||||
goto Done;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestAbort = TRUE;
|
TestAbort = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} while (Status != EFI_NOT_FOUND);
|
} while (Status != EFI_NOT_FOUND);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user