Skip to content

Commit

Permalink
Ensure the PcdPlatformBootTimeOut is not updated to make it the defau…
Browse files Browse the repository at this point in the history
…lt value

Signed-off-by: Michał Żygowski <[email protected]>
  • Loading branch information
miczyg1 committed Oct 18, 2023
1 parent 51d7fb4 commit ffd2c67
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,6 @@ BootMaintRouteConfig (
Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootTimeOut);
goto Exit;
}
PcdSet16S (PcdPlatformBootTimeOut, NewBmmData->BootTimeOut);
Private->BmmOldFakeNVData.BootTimeOut = NewBmmData->BootTimeOut;
}

Expand Down Expand Up @@ -1498,13 +1497,13 @@ InitializeBmmConfig (
&DataSize,
&BootTimeout
);
if (!EFI_ERROR (Status) && BootTimeout != 0xFFFF) {
if (!EFI_ERROR (Status)) {
DEBUG ((EFI_D_INFO, "%a: Timeout from variable: %d\n", __FUNCTION__, BootTimeout));
PcdSet16S (PcdPlatformBootTimeOut, BootTimeout);
CallbackData->BmmFakeNvData.BootTimeOut = BootTimeout;
} else {
CallbackData->BmmFakeNvData.BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);
}

CallbackData->BmmFakeNvData.BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);

//
// Initialize data which located in Boot Options Menu
//
Expand Down
23 changes: 18 additions & 5 deletions MdeModulePkg/Universal/BdsDxe/BdsEntry.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,10 +313,25 @@ BdsWait (
{
EFI_STATUS Status;
UINT16 TimeoutRemain;
UINT16 BootTimeout;
UINTN DataSize;

DEBUG ((EFI_D_INFO, "[Bds]BdsWait ...Zzzzzzzzzzzz...\n"));

TimeoutRemain = PcdGet16 (PcdPlatformBootTimeOut);
DataSize = sizeof(BootTimeout);
Status = gRT->GetVariable(
EFI_TIME_OUT_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
NULL,
&DataSize,
&BootTimeout
);
if (EFI_ERROR (Status)) {
BootTimeout = PcdGet16 (PcdPlatformBootTimeOut);
}

TimeoutRemain = BootTimeout;

while (TimeoutRemain != 0) {
DEBUG ((EFI_D_INFO, "[Bds]BdsWait(%d)..Zzzz...\n", (UINTN) TimeoutRemain));
PlatformBootManagerWaitCallback (TimeoutRemain);
Expand Down Expand Up @@ -349,7 +364,7 @@ BdsWait (
// Note that the (TimeoutRemain == 0) condition excludes
// PcdPlatformBootTimeOut=0xFFFF, and that's deliberate.
//
if (PcdGet16 (PcdPlatformBootTimeOut) != 0 && TimeoutRemain == 0) {
if (BootTimeout != 0 && TimeoutRemain == 0) {
PlatformBootManagerWaitCallback (0);
}
DEBUG ((EFI_D_INFO, "[Bds]Exit the waiting!\n"));
Expand Down Expand Up @@ -737,9 +752,7 @@ BdsEntry (
&DataSize,
&BootTimeOut
);
if (!EFI_ERROR (Status) && BootTimeOut != 0xFFFF) {
PcdSet16S (PcdPlatformBootTimeOut, BootTimeOut);
} else {
if (EFI_ERROR (Status)) {
BootTimeOut = PcdGet16 (PcdPlatformBootTimeOut);
if (BootTimeOut != 0xFFFF) {
//
Expand Down
64 changes: 43 additions & 21 deletions OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ PlatformBootManagerBeforeConsole (
EFI_HANDLE Handle;
EFI_STATUS Status;
UINT16 FrontPageTimeout;
RETURN_STATUS PcdStatus;
UINTN DataSize;

DEBUG ((EFI_D_INFO, "PlatformBootManagerBeforeConsole\n"));
InstallDevicePathCallback ();
Expand Down Expand Up @@ -550,29 +550,37 @@ PlatformBootManagerBeforeConsole (
PlatformInitializeConsole (
XenDetected() ? gXenPlatformConsole : gPlatformConsole);

FrontPageTimeout = GetFrontPageTimeoutFromQemu ();
PcdStatus = PcdSet16S (PcdPlatformBootTimeOut, FrontPageTimeout);
ASSERT_RETURN_ERROR (PcdStatus);
//
// Reflect the PCD in the standard Timeout variable.
//
Status = gRT->SetVariable (
DataSize = sizeof(FrontPageTimeout);
Status = gRT->GetVariable(
EFI_TIME_OUT_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
(EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS),
sizeof FrontPageTimeout,
NULL,
&DataSize,
&FrontPageTimeout
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
"%a: SetVariable(%s, %u): %r\n",
__FUNCTION__,
EFI_TIME_OUT_VARIABLE_NAME,
FrontPageTimeout,
Status
));
if (EFI_ERROR (Status)) {
FrontPageTimeout = GetFrontPageTimeoutFromQemu ();
//
// Reflect the PCD in the standard Timeout variable.
//
Status = gRT->SetVariable (
EFI_TIME_OUT_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
(EFI_VARIABLE_NON_VOLATILE |
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS),
sizeof FrontPageTimeout,
&FrontPageTimeout
);
DEBUG ((
EFI_ERROR (Status) ? DEBUG_ERROR : DEBUG_VERBOSE,
"%a: SetVariable(%s, %u): %r\n",
__FUNCTION__,
EFI_TIME_OUT_VARIABLE_NAME,
FrontPageTimeout,
Status
));
}

PlatformRegisterOptionsAndKeys ();

Expand Down Expand Up @@ -1813,8 +1821,22 @@ PlatformBootManagerWaitCallback (
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
UINT16 TimeoutInitial;
UINTN DataSize;
EFI_STATUS Status;

DEBUG ((EFI_D_INFO, "[Bds]BdsWait ...Zzzzzzzzzzzz...\n"));

TimeoutInitial = PcdGet16 (PcdPlatformBootTimeOut);
DataSize = sizeof (TimeoutInitial);
Status = gRT->GetVariable(
EFI_TIME_OUT_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
NULL,
&DataSize,
&TimeoutInitial
);
if (EFI_ERROR (Status)) {
TimeoutInitial = PcdGet16 (PcdPlatformBootTimeOut);
}

//
// If PcdPlatformBootTimeOut is set to zero, then we consider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1660,8 +1660,22 @@ PlatformBootManagerWaitCallback (
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
UINT16 Timeout;

Timeout = PcdGet16 (PcdPlatformBootTimeOut);
UINTN DataSize;
EFI_STATUS Status;

DEBUG ((EFI_D_INFO, "[Bds]BdsWait ...Zzzzzzzzzzzz...\n"));

DataSize = sizeof(Timeout);
Status = gRT->GetVariable(
EFI_TIME_OUT_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
NULL,
&DataSize,
&Timeout
);
if (EFI_ERROR (Status)) {
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
}

Black.Raw = 0x00000000;
White.Raw = 0x00FFFFFF;
Expand Down

0 comments on commit ffd2c67

Please sign in to comment.