summaryrefslogtreecommitdiff
path: root/Vlv2TbltDevicePkg
diff options
context:
space:
mode:
authorTim He <tim.he@intel.com>2015-06-11 02:50:20 +0000
committertimhe <timhe@Edk2>2015-06-11 02:50:20 +0000
commit620f289162b08d319fe1e73b3c7e2baff6b388e4 (patch)
treedb0955f5012f93e7aca96b11c6f39b0da158fafc /Vlv2TbltDevicePkg
parent2a697cb579972d1b849c396499dd0a1d2e911d35 (diff)
downloadedk2-platforms-620f289162b08d319fe1e73b3c7e2baff6b388e4.tar.xz
Sync the branch changes to trunk.
Update the FCE tool to remove “runtime access” . and recovery "Setup" variable in case of “Setup” variable size is incorrect somehow. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Tim He <tim.he@intel.com> Reviewed-by: David Wei <david.wei@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17620 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'Vlv2TbltDevicePkg')
-rw-r--r--Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c39
-rw-r--r--Vlv2TbltDevicePkg/FCE.exebin630784 -> 632832 bytes
-rw-r--r--Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c13
-rw-r--r--Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c60
-rw-r--r--Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c13
-rw-r--r--Vlv2TbltDevicePkg/PlatformDxe/ExI.c13
-rw-r--r--Vlv2TbltDevicePkg/PlatformDxe/Platform.c134
-rw-r--r--Vlv2TbltDevicePkg/PlatformDxe/PlatformDxe.inf1
-rw-r--r--Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c14
-rw-r--r--Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c17
-rw-r--r--Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c21
-rw-r--r--Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c14
-rw-r--r--Vlv2TbltDevicePkg/PlatformPei/Platform.c15
-rw-r--r--Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.c49
-rw-r--r--Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf1
-rw-r--r--Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c13
-rw-r--r--Vlv2TbltDevicePkg/PlatformSmm/Platform.c27
-rw-r--r--Vlv2TbltDevicePkg/bld_vlv.bat6
18 files changed, 384 insertions, 66 deletions
diff --git a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c
index 824f237777..c39c36daad 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
index 2b787be830..18300115d0 100644
--- a/Vlv2TbltDevicePkg/FCE.exe
+++ b/Vlv2TbltDevicePkg/FCE.exe
Binary files differ
diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c
index 1fc731205b..86cd67cea8 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 ad16267eca..195d734189 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 1b59eee74f..08f5df2a25 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 2dad89f606..603b44aa82 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 dba84fb659..a1cd072c8f 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 27216b7879..63ccf03029 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 59c73c62ba..0abe1b27d9 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 6bf276246e..8bdcaee7c9 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 174d8e974e..3b94e3b54f 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 1a12c53e96..0b0acf5d2f 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 899b4a9791..23be887ca4 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 1490e2c030..de7830ffe8 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 9cd774b427..50c9190859 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 99684e72d7..3c6f8f447c 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 d8bfeb4371..3a5b20a984 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 fc97f42534..547b2b110a 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