diff options
18 files changed, 384 insertions, 66 deletions
diff --git a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c index 824f237..c39c36d 100644 --- a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c +++ b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c @@ -697,7 +697,18 @@ OnReadyToBoot ( &VariableSize,
&SetupVarBuffer
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VariableSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &mSystemConfigurationGuid,
+ NULL,
+ &VariableSize,
+ &SetupVarBuffer
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
//
// Find the AcpiSupport protocol.
@@ -817,7 +828,18 @@ AcpiPlatformEntryPoint ( &VarSize,
&mSystemConfiguration
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &mSystemConfigurationGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
//
// Find the AcpiSupport protocol.
@@ -842,6 +864,19 @@ AcpiPlatformEntryPoint ( &SysCfgSize,
&mSystemConfig
);
+ if (EFI_ERROR (Status) || SysCfgSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ SysCfgSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &SysCfgSize,
+ &mSystemConfig
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
Status = EFI_SUCCESS;
Instance = 0;
diff --git a/Vlv2TbltDevicePkg/FCE.exe b/Vlv2TbltDevicePkg/FCE.exe Binary files differindex 2b787be..1830011 100644 --- a/Vlv2TbltDevicePkg/FCE.exe +++ b/Vlv2TbltDevicePkg/FCE.exe diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c index 1fc7312..86cd67c 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c @@ -346,7 +346,18 @@ ConfigurePlatformClocks ( NULL,
&VariableSize,
&SystemConfiguration);
-
+ if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VariableSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = Variable->GetVariable(Variable,
+ L"SetupRecovery",
+ &gEfiSetupVariableGuid,
+ NULL,
+ &VariableSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
if(!EFI_ERROR (Status)){
EnableSpreadSpectrum = SystemConfiguration.EnableClockSpreadSpec;
}
diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c index ad16267..195d734 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c @@ -322,7 +322,18 @@ GetGopDevicePath ( &VarSize,
&mSystemConfiguration
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
if(mSystemConfiguration.BootDisplayDevice != 0x0)
{
@@ -624,7 +635,18 @@ PlatformBdsForceActiveVga ( &VarSize,
&mSystemConfiguration
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
if ((PlugInPciVgaDevicePath == NULL && OnboardPciVgaDevicePath != NULL) ) {
@@ -680,7 +702,18 @@ UpdateConsoleResolution( &VarSize,
&SystemConfiguration
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
switch (SystemConfiguration.IgdFlatPanel) {
@@ -1576,6 +1609,11 @@ PlatformBdsPolicyBehavior ( UINTN BootOrderSize;
Timeout = PcdGet16 (PcdPlatformBootTimeOut);
+ if (Timeout > 10 ) {
+ //we think the Timeout variable is corrupted
+ Timeout = 10;
+ }
+
VarSize = sizeof(SYSTEM_CONFIGURATION);
Status = gRT->GetVariable(
NORMAL_SETUP_NAME,
@@ -1584,9 +1622,19 @@ PlatformBdsPolicyBehavior ( &VarSize,
&SystemConfiguration
);
- if (EFI_ERROR (Status)) {
- return;
- }
+
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
//
// Load the driver option as the driver option list
diff --git a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c index 1b59eee..08f5df2 100644 --- a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c +++ b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c @@ -343,7 +343,18 @@ PciPlatformDriverEntry ( &VarSize,
&mSystemConfiguration
);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
//
// Install on a new handle
diff --git a/Vlv2TbltDevicePkg/PlatformDxe/ExI.c b/Vlv2TbltDevicePkg/PlatformDxe/ExI.c index 2dad89f..603b44a 100644 --- a/Vlv2TbltDevicePkg/PlatformDxe/ExI.c +++ b/Vlv2TbltDevicePkg/PlatformDxe/ExI.c @@ -73,7 +73,18 @@ InitExI ( &SystemConfiguration
);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
if (SystemConfiguration.ExISupport == 1) {
MmioOr32 ((UINTN) (GetPmcBase() + R_PCH_PMC_MTPMC1), (UINT32) BIT0+BIT1+BIT2);
diff --git a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c index dba84fb..a1cd072 100644 --- a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c @@ -49,6 +49,8 @@ Abstract: #include <Protocol/GlobalNvsArea.h>
#include <Protocol/IgdOpRegion.h>
#include <Library/PcdLib.h>
+#include <Protocol/VariableLock.h>
+
//
// VLV2 GPIO GROUP OFFSET
@@ -200,6 +202,82 @@ InitRC6Policy( );
+EFI_STATUS
+EFIAPI
+SaveSetupRecoveryVar(
+ VOID
+ )
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN SizeOfNvStore = 0;
+ UINTN SizeOfSetupVar = 0;
+ SYSTEM_CONFIGURATION *SetupData = NULL;
+ SYSTEM_CONFIGURATION *RecoveryNvData = NULL;
+ EDKII_VARIABLE_LOCK_PROTOCOL *VariableLock = NULL;
+
+
+ DEBUG ((EFI_D_INFO, "SaveSetupRecoveryVar() Entry \n"));
+ SizeOfNvStore = sizeof(SYSTEM_CONFIGURATION);
+ RecoveryNvData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));
+ if (NULL == RecoveryNvData) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &SizeOfNvStore,
+ RecoveryNvData
+ );
+
+ if (EFI_ERROR (Status)) {
+ // Don't find the "SetupRecovery" variable.
+ // have to copy "Setup" variable to "SetupRecovery" variable.
+ SetupData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));
+ if (NULL == SetupData) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Exit;
+ }
+ SizeOfSetupVar = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ NORMAL_SETUP_NAME,
+ &gEfiNormalSetupGuid,
+ NULL,
+ &SizeOfSetupVar,
+ SetupData
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gRT->SetVariable (
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(SYSTEM_CONFIGURATION),
+ SetupData
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->LocateProtocol (&gEdkiiVariableLockProtocolGuid, NULL, (VOID **) &VariableLock);
+ if (!EFI_ERROR (Status)) {
+ Status = VariableLock->RequestToLock (VariableLock, L"SetupRecovery", &gEfiNormalSetupGuid);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ }
+
+Exit:
+ if (RecoveryNvData)
+ FreePool (RecoveryNvData);
+ if (SetupData)
+ FreePool (SetupData);
+
+ return Status;
+
+}
+
+
VOID
TristateLpcGpioConfig (
IN UINT32 Gpio_Mmio_Offset,
@@ -692,6 +770,10 @@ InitializePlatform ( //
InitializeObservableProtocol();
+ Status = SaveSetupRecoveryVar();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "InitializePlatform() Save SetupRecovery variable failed \n"));
+ }
VarSize = sizeof(SYSTEM_CONFIGURATION);
Status = gRT->GetVariable(
@@ -701,8 +783,26 @@ InitializePlatform ( &VarSize,
&mSystemConfiguration
);
-
-
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ Status = gRT->SetVariable (
+ NORMAL_SETUP_NAME,
+ &gEfiNormalSetupGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(SYSTEM_CONFIGURATION),
+ &mSystemConfiguration
+ );
+ }
+
Status = EfiCreateEventReadyToBootEx (
TPL_CALLBACK,
ReadyToBootFunction,
@@ -1394,12 +1494,7 @@ InitMfgAndConfigModeStateVar() {
EFI_PLATFORM_SETUP_ID *BootModeBuffer;
VOID *HobList;
- UINT16 State;
- //
- // Variable initialization
- //
- State = FALSE;
HobList = GetFirstGuidHob(&gEfiPlatformBootModeGuid);
if (HobList != NULL) {
@@ -1416,16 +1511,8 @@ InitMfgAndConfigModeStateVar() mMfgMode = TRUE;
}
- //
- // Check if in safe mode
- //
- if ( !CompareMem (
- &BootModeBuffer->SetupName,
- SAFE_SETUP_NAME,
- StrSize (SAFE_SETUP_NAME)
- ) ) {
- State = TRUE;
- }
+
+
}
}
@@ -1588,6 +1675,19 @@ UpdateDVMTSetup( &SystemConfiguration
);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
if((SystemConfiguration.GraphicsDriverMemorySize < 4) && !EFI_ERROR(Status) ) {
switch (SystemConfiguration.GraphicsDriverMemorySize){
case 1:
diff --git a/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf b/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf index 27216b7..63ccf03 100644 --- a/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf +++ b/Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf @@ -128,6 +128,7 @@ gEfiCpuIo2ProtocolGuid
gIgdOpRegionProtocolGuid
gExitPmAuthProtocolGuid
+ gEdkiiVariableLockProtocolGuid
[Pcd.common]
gPlatformModuleTokenSpaceGuid.PcdPBTNDisableInterval
diff --git a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c index 59c73c6..0abe1b2 100644 --- a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c +++ b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c @@ -181,7 +181,19 @@ PlatformGOPPolicyEntryPoint ( &VarSize,
&SystemConfiguration
);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
if (SystemConfiguration.GOPEnable == 1)
{
Status = gBS->InstallMultipleProtocolInterfaces (
diff --git a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c index 6bf2762..8bdcaee 100644 --- a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c +++ b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c @@ -62,6 +62,19 @@ PlatformInfoInit ( &VarSize,
&SystemConfiguration
);
+
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
VarSize = sizeof(Selection);
Status = gRT->GetVariable(
@@ -113,7 +126,7 @@ PlatformInfoInit ( Status = gRT->SetVariable (
NORMAL_SETUP_NAME,
&gEfiNormalSetupGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
sizeof(SYSTEM_CONFIGURATION),
&SystemConfiguration
);
@@ -146,7 +159,7 @@ PlatformInfoInit ( Status = gRT->SetVariable(
L"PlatformInfo",
&gEfiVlv2VariableGuid,
- EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
sizeof(EFI_PLATFORM_INFO_HOB),
PlatformInfoHobPtr
);
diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c b/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c index 174d8e9..3b94e3b 100644 --- a/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c +++ b/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c @@ -202,6 +202,19 @@ UpdateBootMode ( &VarSize,
&SystemConfiguration
);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = Variable->GetVariable(
+ Variable,
+ L"SetupRecovery",
+ &gEfiSetupVariableGuid,
+ NULL,
+ &VarSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
if (SystemConfiguration.FastBoot == 1) {
BootMode = BOOT_WITH_MINIMAL_CONFIGURATION;
@@ -386,16 +399,16 @@ SetPlatformBootMode ( // Recovery mode
//
CopyMem (&PlatformSetupId.SetupName,
- SAFE_SETUP_NAME,
- StrSize (SAFE_SETUP_NAME));
+ &NORMAL_SETUP_NAME,
+ StrSize (NORMAL_SETUP_NAME));
PlatformSetupId.PlatformBootMode = PLATFORM_RECOVERY_MODE;
} else if (CheckIfSafeMode(PeiServices, PlatformInfoHob)) {
//
// Safe mode also called config mode or maintenace mode.
//
CopyMem (&PlatformSetupId.SetupName,
- SAFE_SETUP_NAME,
- StrSize (SAFE_SETUP_NAME));
+ &NORMAL_SETUP_NAME,
+ StrSize (NORMAL_SETUP_NAME));
PlatformSetupId.PlatformBootMode = PLATFORM_SAFE_MODE;
} else if(0) { // else if (CheckIfManufacturingMode(PeiServices)) {
diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c index 1a12c53..0b0acf5 100644 --- a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c +++ b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c @@ -196,7 +196,19 @@ GetSetupVariable ( &VariableSize,
SystemConfiguration
);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VariableSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = Variable->GetVariable(
+ Variable,
+ L"SetupRecovery",
+ &gEfiSetupVariableGuid,
+ NULL,
+ &VariableSize,
+ SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
return Status;
}
diff --git a/Vlv2TbltDevicePkg/PlatformPei/Platform.c b/Vlv2TbltDevicePkg/PlatformPei/Platform.c index 899b4a9..23be887 100644 --- a/Vlv2TbltDevicePkg/PlatformPei/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformPei/Platform.c @@ -716,7 +716,20 @@ PeiInitPlatform ( &VariableSize,
&SystemConfiguration
);
- ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VariableSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = Variable->GetVariable(
+ Variable,
+ L"SetupRecovery",
+ &gEfiSetupVariableGuid,
+ NULL,
+ &VariableSize,
+ &SystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
if (EFI_ERROR (Status)) {
GGC = ((2 << 3) | 0x200);
PciCfg16Write(EC_BASE, 0, 2, 0, 0x50, GGC);
diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c index 1490e2c..de7830f 100644 --- a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c +++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c @@ -17,6 +17,8 @@ Module Name: #include "PlatformSetupDxe.h"
#include "Guid/SetupVariable.h"
+#include <Protocol/FormBrowserEx2.h>
+
#define EFI_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('C', 'l', 'b', 'k')
#define EFI_CALLBACK_INFO_FROM_THIS(a) CR (a, EFI_CALLBACK_INFO, ConfigAccess, EFI_CALLBACK_INFO_SIGNATURE)
@@ -306,7 +308,7 @@ SystemConfigRouteConfig ( gRT->SetVariable(
mSetupName,
&mNormalSetupGuid,
- EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof(SYSTEM_CONFIGURATION),
&Private->FakeNvData
);
@@ -358,6 +360,7 @@ SystemConfigCallback ( EFI_STATUS Status;
UINTN DataSize;
UINT8 OsSelection;
+ EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;
StringBuffer1 = AllocateZeroPool (200 * sizeof (CHAR16));
ASSERT (StringBuffer1 != NULL);
@@ -474,7 +477,7 @@ SystemConfigCallback ( Status = gRT->SetVariable (
L"Setup",
&mNormalSetupGuid,
- EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof(SYSTEM_CONFIGURATION),
&Private->FakeNvData
);
@@ -525,7 +528,7 @@ SystemConfigCallback ( Status = gRT->SetVariable (
L"Setup",
&mNormalSetupGuid,
- EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
sizeof(SYSTEM_CONFIGURATION),
&Private->FakeNvData
);
@@ -596,33 +599,31 @@ SystemConfigCallback ( // If the user hits the YES Response key
//
if (Key.UnicodeChar == CHAR_CARRIAGE_RETURN) {
- //
- // Load default
- //
+
+ Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **) &FormBrowserEx2);
+ FormBrowserEx2->ExecuteAction(BROWSER_ACTION_DEFAULT, EFI_HII_DEFAULT_CLASS_STANDARD);
+
FakeNvData = AllocateZeroPool (sizeof(SYSTEM_CONFIGURATION));
if (FakeNvData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
-
- SizeOfNvStore = sizeof(SYSTEM_CONFIGURATION);
- Status = gRT->GetVariable(
- L"SetupDefault",
- &mNormalSetupGuid,
- NULL,
- &SizeOfNvStore,
- FakeNvData
- );
+
+ Status = HiiGetBrowserData (
+ &mSystemConfigGuid,
+ mVariableName,
+ sizeof (SYSTEM_CONFIGURATION),
+ (UINT8 *) FakeNvData
+ );
+
if (!EFI_ERROR (Status)) {
- if(SizeOfNvStore >= sizeof(SYSTEM_CONFIGURATION)) {
- Status = gRT->SetVariable (
- L"Setup",
- &mNormalSetupGuid,
- EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
- sizeof(SYSTEM_CONFIGURATION),
- FakeNvData
- );
- }
+ Status = gRT->SetVariable (
+ L"Setup",
+ &mNormalSetupGuid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(SYSTEM_CONFIGURATION),
+ FakeNvData
+ );
}
FreePool (FakeNvData);
diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf index 9cd774b..50c9190 100644 --- a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf +++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf @@ -126,6 +126,7 @@ gEfiHiiConfigRoutingProtocolGuid ## CONSUMED
gEfiHiiConfigAccessProtocolGuid ## PRODUCED
gEfiDevicePathToTextProtocolGuid ## CONSUMED
+ gEdkiiFormBrowserEx2ProtocolGuid
gEfiDataHubProtocolGuid
gEfiLegacyBiosProtocolGuid
diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c index 99684e7..3c6f8f4 100644 --- a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c +++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c @@ -1750,7 +1750,18 @@ SetupInfo (void) &mSystemConfiguration
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = gRT->GetVariable(
+ L"SetupRecovery",
+ &gEfiNormalSetupGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
//
// Update HOB variable for PCI resource information
diff --git a/Vlv2TbltDevicePkg/PlatformSmm/Platform.c b/Vlv2TbltDevicePkg/PlatformSmm/Platform.c index d8bfeb4..3a5b20a 100644 --- a/Vlv2TbltDevicePkg/PlatformSmm/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformSmm/Platform.c @@ -170,6 +170,18 @@ InitializePlatformSmm ( &VarSize,
&mSystemConfiguration
);
+ if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = SystemTable->RuntimeServices->GetVariable(
+ L"SetupRecovery",
+ &gEfiSetupVariableGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
if (!EFI_ERROR(Status)) {
mAcLossVariable = mSystemConfiguration.StateAfterG3;
@@ -848,7 +860,20 @@ EnableS5WakeOnRtc() &VarSize,
&mSystemConfiguration
);
- if (EFI_ERROR(Status) || (!mSystemConfiguration.WakeOnRtcS5)) {
+ if (EFI_ERROR(Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) {
+ //The setup variable is corrupted
+ VarSize = sizeof(SYSTEM_CONFIGURATION);
+ Status = mSmmVariable->SmmGetVariable(
+ L"SetupRecovery",
+ &gEfiSetupVariableGuid,
+ NULL,
+ &VarSize,
+ &mSystemConfiguration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ if (!mSystemConfiguration.WakeOnRtcS5) {
return;
}
mWakeupDay = HexToBcd((UINT8)mSystemConfiguration.RTCWakeupDate);
diff --git a/Vlv2TbltDevicePkg/bld_vlv.bat b/Vlv2TbltDevicePkg/bld_vlv.bat index fc97f42..547b2b1 100644 --- a/Vlv2TbltDevicePkg/bld_vlv.bat +++ b/Vlv2TbltDevicePkg/bld_vlv.bat @@ -217,10 +217,10 @@ echo Running fce... pushd %PLATFORM_PACKAGE%
:: Extract Hii data from build and store in HiiDefaultData.txt
-fce read -i ..\%BUILD_PATH%\FV\Vlv.fd > ..\%BUILD_PATH%\FV\HiiDefaultData.txt 1>>EDK2.log 2>&1
+fce read -i ..\%BUILD_PATH%\FV\Vlv.fd > ..\%BUILD_PATH%\FV\HiiDefaultData.txt
-:: copy the Setup variable to the SetupDefault variable and save changes to VlvXXX.fd
-fce mirror -i ..\%BUILD_PATH%\FV\Vlv.fd -o ..\%BUILD_PATH%\FV\Vlv%Arch%.fd Setup SetupDefault 1>>EDK2.log 2>&1
+:: save changes to VlvXXX.fd
+fce update -i ..\%BUILD_PATH%\FV\Vlv.fd -s ..\%BUILD_PATH%\FV\HiiDefaultData.txt -o ..\%BUILD_PATH%\FV\Vlv%Arch%.fd
popd
|