diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c index e3f375793e..96affaa109 100644 --- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c +++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenance.c @@ -880,7 +880,6 @@ BootMaintRouteConfig ( Offset = OFFSET_OF (BMM_FAKE_NV_DATA, BootTimeOut); goto Exit; } - PcdSet16S (PcdPlatformBootTimeOut, NewBmmData->BootTimeOut); Private->BmmOldFakeNVData.BootTimeOut = NewBmmData->BootTimeOut; } @@ -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 // diff --git a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c index e165add099..666e6d7eb1 100644 --- a/MdeModulePkg/Universal/BdsDxe/BdsEntry.c +++ b/MdeModulePkg/Universal/BdsDxe/BdsEntry.c @@ -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); @@ -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")); @@ -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) { // diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c index da9ea5f33b..3af4231b27 100644 --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c @@ -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 (); @@ -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 (); @@ -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 diff --git a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c index eccaec3ccd..d0c61e0b24 100644 --- a/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c +++ b/UefiPayloadPkg/Library/PlatformBootManagerLib/PlatformBootManager.c @@ -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;