Signed-off-by: lushifex <shifeix.a...@intel.com> --- .../SouthCluster/Include/Library/PchPlatformLib.h | 9 ++ Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c | 19 ++-- .../MultiPlatformLib/BoardClkGens/BoardClkGens.c | 6 +- .../MultiPlatformLib/BoardClkGens/BoardClkGens.h | 2 + .../MultiPlatformLib/BoardGpios/BoardGpios.c | 15 +++ .../MultiPlatformLib/BoardGpios/BoardGpios.h | 1 + .../Library/MultiPlatformLib/MultiPlatformLib.inf | 1 + .../Library/PchPlatformLib/PchPlatformLibrary.c | 108 +++++++++++++++++++++ .../Library/PlatformBdsLib/BdsPlatform.c | 29 ++++-- .../Library/PlatformBdsLib/PlatformBdsLib.inf | 1 + Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c | 8 +- Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf | 1 + Vlv2TbltDevicePkg/PlatformDxe/ExI.c | 8 +- Vlv2TbltDevicePkg/PlatformDxe/Platform.c | 51 +++++++++- .../PlatformGopPolicy/PlatformGopPolicy.c | 9 +- .../PlatformGopPolicy/PlatformGopPolicy.inf | 3 + .../PlatformInfoDxe/PlatformInfoDxe.c | 9 +- .../PlatformInfoDxe/PlatformInfoDxe.inf | 1 + Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c | 6 +- .../PlatformInitPei/PlatformEarlyInit.c | 7 +- Vlv2TbltDevicePkg/PlatformPei/BootMode.c | 16 +++ Vlv2TbltDevicePkg/PlatformPei/Platform.c | 7 +- Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf | 1 + .../PlatformSetupDxe/PlatformSetupDxe.inf | 1 + .../PlatformSetupDxe/SetupInfoRecords.c | 7 +- Vlv2TbltDevicePkg/PlatformSmm/Platform.c | 15 ++- 26 files changed, 300 insertions(+), 41 deletions(-)
diff --git a/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h b/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h index 8f0ca02..9651f94 100644 --- a/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h +++ b/Vlv2DeviceRefCodePkg/ValleyView2Soc/SouthCluster/Include/Library/PchPlatformLib.h @@ -115,7 +115,16 @@ PchAlternateAccessMode ( @retval NONE **/ ; +UINT32 +DetectTurbotBoard ( +VOID + ); + +UINT32 +DetectGpioPinValue ( +VOID + ); #endif diff --git a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c index 2ff14ec..a7e54e3 100644 --- a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c +++ b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c @@ -646,10 +646,11 @@ OnReadyToBoot ( SYSTEM_CONFIGURATION SetupVarBuffer; UINTN VariableSize; EFI_PLATFORM_CPU_INFO *PlatformCpuInfoPtr = NULL; EFI_PLATFORM_CPU_INFO PlatformCpuInfo; EFI_PEI_HOB_POINTERS GuidHob; + UINT32 DxeGpioValue; if (mFirstNotify) { return; } @@ -684,10 +685,12 @@ OnReadyToBoot ( if ((PlatformCpuInfoPtr != NULL)) { CopyMem(&PlatformCpuInfo, PlatformCpuInfoPtr, sizeof(EFI_PLATFORM_CPU_INFO)); } + DxeGpioValue = DetectGpioPinValue(); + // // Update the ACPI parameter blocks finally. // VariableSize = sizeof (SYSTEM_CONFIGURATION); Status = gRT->GetVariable ( @@ -695,12 +698,12 @@ OnReadyToBoot ( &mSystemConfigurationGuid, NULL, &VariableSize, &SetupVarBuffer ); - if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VariableSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &mSystemConfigurationGuid, NULL, @@ -794,10 +797,11 @@ AcpiPlatformEntryPoint ( EFI_MP_SERVICES_PROTOCOL *MpService; UINTN MaximumNumberOfCPUs; UINTN NumberOfEnabledCPUs; UINT32 Data32; PCH_STEPPING pchStepping; + UINT32 DxeGpioValue; mFirstNotify = FALSE; TableVersion = EFI_ACPI_TABLE_VERSION_2_0; Instance = 0; @@ -813,11 +817,12 @@ AcpiPlatformEntryPoint ( if (GuidHob.Raw != NULL) { if ((GuidHob.Raw = GetNextGuidHob (&gEfiPlatformInfoGuid, GuidHob.Raw)) != NULL) { mPlatformInfo = GET_GUID_HOB_DATA (GuidHob.Guid); } } - + + DxeGpioValue = DetectGpioPinValue(); // // Search for the Memory Configuration GUID HOB. If it is not present, then // there's nothing we can do. It may not exist on the update path. // VarSize = sizeof(SYSTEM_CONFIGURATION); @@ -826,12 +831,12 @@ AcpiPlatformEntryPoint ( &mSystemConfigurationGuid, NULL, &VarSize, &mSystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &mSystemConfigurationGuid, NULL, @@ -862,12 +867,12 @@ AcpiPlatformEntryPoint ( &gEfiNormalSetupGuid, NULL, &SysCfgSize, &mSystemConfig ); - if (EFI_ERROR (Status) || SysCfgSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || SysCfgSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low SysCfgSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c index e38633b..e278e31 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c @@ -280,11 +280,13 @@ ConfigurePlatformClocks ( UINT8 Data; UINT8 ClockAddress = CLOCK_GENERATOR_ADDRESS; UINTN VariableSize; EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable; + UINT32 PeiGpioValue; + PeiGpioValue = DetectGpioPinValue(); // // Obtain Platform Info from HOB. // Status = GetPlatformInfoHob ((CONST EFI_PEI_SERVICES **) PeiServices, &PlatformInfoHob); ASSERT_EFI_ERROR (Status); @@ -344,12 +346,12 @@ ConfigurePlatformClocks ( L"Setup", &gEfiSetupVariableGuid, NULL, &VariableSize, &SystemConfiguration); - if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION) || PeiGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VariableSize = sizeof(SYSTEM_CONFIGURATION); Status = Variable->GetVariable(Variable, L"SetupRecovery", &gEfiSetupVariableGuid, NULL, diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h index 4ec5b88..8d15da9 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h @@ -17,17 +17,19 @@ #ifndef _BOARD_CLK_GEN_H_ #define _BOARD_CLK_GEN_H_ #include <PiPei.h> +#include "PchAccess.h" #include <Library/HobLib.h> #include <Library/IoLib.h> #include <Library/DebugLib.h> #include <Library/SmbusLib.h> #include <Ppi/Smbus.h> #include <IndustryStandard/SmBus.h> #include <Guid/PlatformInfo.h> +#include <Library/PchPlatformLib.h> #define CLOCK_GENERATOR_ADDRESS 0xd2 #define CLOCK_GENERATOR_SEETINGS_TABLET {0xB1, 0x82, 0xFF, 0xBF, 0xFF, 0x80} diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c index 5209a74..7b7f03f 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c @@ -139,10 +139,13 @@ MultiPlatformGpioTableInit ( { EFI_STATUS Status; EFI_PEI_READ_ONLY_VARIABLE2_PPI *PeiReadOnlyVarPpi; UINTN VarSize; SYSTEM_CONFIGURATION SystemConfiguration; + UINT32 PeiGpioValue; + + PeiGpioValue = DetectGpioPinValue(); DEBUG ((EFI_D_INFO, "MultiPlatformGpioTableInit()...\n")); // // Select/modify the GPIO initialization data based on the Board ID. @@ -167,10 +170,22 @@ MultiPlatformGpioTableInit ( &gEfiSetupVariableGuid, NULL, &VarSize, &SystemConfiguration ); + if (PeiGpioValue == 0) { + VarSize = sizeof(SYSTEM_CONFIGURATION); + Status = PeiReadOnlyVarPpi->GetVariable ( + PeiReadOnlyVarPpi, + L"SetupRecovery", + &gEfiSetupVariableGuid, + NULL, + &VarSize, + &SystemConfiguration + ); + ASSERT_EFI_ERROR (Status); + } if (SystemConfiguration.GpioWakeCapability == 1) { PlatformInfoHob->PlatformCfioData = (EFI_PHYSICAL_ADDRESS)(UINTN) &mMinnow2CfioInitData2; } else { diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h index d8cd98e..a165dcc 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h @@ -26,10 +26,11 @@ #include <Library/HobLib.h> #include <Guid/PlatformInfo.h> #include <Ppi/Smbus.h> #include <Ppi/ReadOnlyVariable2.h> #include <Guid/SetupVariable.h> +#include <Library/PchPlatformLib.h> GPIO_CONF_PAD_INIT mNB_BB_FAB3_GpioInitData_SC_TRI[] = { // Pad Name GPIO Number Used As GPO Default Function# INT Capable Interrupt Type PULL H/L MMIO Offset diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf index 74ffc78..741abe2 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf @@ -69,10 +69,11 @@ [LibraryClasses] DebugLib HobLib IoLib + PchPlatformLib # PeiKscLib [Ppis] gEfiPeiReadOnlyVariable2PpiGuid diff --git a/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c index 6be4188..3c5dd21 100644 --- a/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c +++ b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c @@ -132,5 +132,113 @@ IsPchSupported ( DEBUG ((EFI_D_ERROR, "VLV SC code doesn't support the PcuDeviceId: 0x%04x!\n", PcuDeviceId)); return FALSE; } return TRUE; } + +/** + Detect Turbot board + + @param None + + @retval 0 Not Turbot board + @retval 1 Turbot board + +**/ +UINT32 +DetectTurbotBoard ( + void + ) +{ + UINTN PciD31F0RegBase = 0; + UINT32 GpioValue = 0; + UINT32 TmpVal = 0; + UINT32 MmioConf0 = 0; + UINT32 MmioPadval = 0; + UINT32 PConf0Offset = 0x200; //GPIO_S5_4 pad_conf0 register offset + UINT32 PValueOffset = 0x208; //GPIO_S5_4 pad_value register offset + UINT32 SSUSOffset = 0x2000; + UINT32 IoBase = 0; + + DEBUG ((EFI_D_ERROR, "DetermineTurbotBoard() Entry\n")); + PciD31F0RegBase = MmPciAddress (0, + 0, + PCI_DEVICE_NUMBER_PCH_LPC, + PCI_FUNCTION_NUMBER_PCH_LPC, + 0 + ); + IoBase = MmioRead32 (PciD31F0RegBase + R_PCH_LPC_IO_BASE) & B_PCH_LPC_IO_BASE_BAR; + + MmioConf0 = IoBase + SSUSOffset + PConf0Offset; + MmioPadval = IoBase + SSUSOffset + PValueOffset; + //0xFED0E200/0xFED0E208 is pad_Conf/pad_val register address of GPIO_S5_4 + DEBUG ((EFI_D_ERROR, "MmioConf0[0x%x], MmioPadval[0x%x]\n", MmioConf0, MmioPadval)); + + MmioWrite32 (MmioConf0, 0x2003CC00); + + TmpVal = MmioRead32 (MmioPadval); + TmpVal &= ~0x6; //Clear bit 1:2 + TmpVal |= 0x2; // Set the pin as GPI + MmioWrite32 (MmioPadval, TmpVal); + + GpioValue = MmioRead32 (MmioPadval); + + DEBUG ((EFI_D_ERROR, "Gpio_S5_4 value is 0x%x\n", GpioValue)); + return (GpioValue & 0x1); +} + +/** + Detect if "Reset BIOS Setup" jumper is plugged. + Only for MinnowBoard Turbot. + + @param None + + @retval 0 Jumper is present. + @retval 1 Jumper is not present. + +**/ + +UINT32 +DetectGpioPinValue ( +VOID + ) +{ + UINTN PciD31F0RegBase = 0; + UINT32 GpioValue; + UINT32 TmpVal = 0; + UINT32 SSUSOffset = 0x2000; + UINT32 IoBase = 0; + UINT32 MmioConf0 = 0; + UINT32 MmioPadval = 0; + UINT32 PConf0Offset = 0xA0; //GPIO_S5_17 pad_conf0 register offset + UINT32 PValueOffset = 0xA8; //GPIO_S5_17 pad_value register offset + + if (DetectTurbotBoard() == 0) { + return 1; + } + + PciD31F0RegBase = MmPciAddress (0, + 0, + PCI_DEVICE_NUMBER_PCH_LPC, + PCI_FUNCTION_NUMBER_PCH_LPC, + 0 + ); + IoBase = MmioRead32 (PciD31F0RegBase + R_PCH_LPC_IO_BASE) & B_PCH_LPC_IO_BASE_BAR; + + // + // 0xFED0E0A0/0xFED0E0A8 is pad_Conf/pad_val register address of GPIO_S5_17 + // + MmioConf0 = IoBase + SSUSOffset + PConf0Offset; + MmioPadval = IoBase + SSUSOffset + PValueOffset; + + MmioWrite32 (MmioConf0, 0x2003CC01); + + TmpVal = MmioRead32 (MmioPadval); + TmpVal &= ~0x6; //Clear bit 1:2 + TmpVal |= 0x2; // Set the pin as GPI + MmioWrite32 (MmioPadval, TmpVal); + + GpioValue = MmioRead32 (MmioPadval); + DEBUG ((EFI_D_INFO, "Gpio_S5_17 value is 0x%x\n", GpioValue)); + + return (GpioValue & 0x1); +} diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c index 195d734..2334c95 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c @@ -42,10 +42,11 @@ Abstract: #include <Library/DebugLib.h> #include <Library/GenericBdsLib/InternalBdsLib.h> #include <Library/GenericBdsLib/String.h> #include <Library/NetLib.h> +#include <Library/PchPlatformLib.h> EFI_GUID *ConnectDriverTable[] = { &gEfiMmioDeviceProtocolGuid, &gEfiI2cMasterProtocolGuid, &gEfiI2cHostProtocolGuid @@ -282,10 +283,11 @@ GetGopDevicePath ( UINTN GopHandleCount; EFI_HANDLE *GopHandleBuffer; UINTN VarSize; SYSTEM_CONFIGURATION mSystemConfiguration; + UINT32 DxeGpioValue; if (PciDevicePath == NULL || GopDevicePath == NULL) { return EFI_INVALID_PARAMETER; } @@ -302,10 +304,11 @@ GetGopDevicePath ( ); if (EFI_ERROR (Status)) { return Status; } + DxeGpioValue = DetectGpioPinValue(); // // Try to connect this handle, so that GOP dirver could start on this // device and create child handles with GraphicsOutput Protocol installed // on them, then we get device paths of these child handles and select // them as possible console device. @@ -320,12 +323,12 @@ GetGopDevicePath ( &gEfiNormalSetupGuid, NULL, &VarSize, &mSystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, @@ -611,10 +614,11 @@ PlatformBdsForceActiveVga ( EFI_DEVICE_PATH_PROTOCOL *DevicePathFirst; EFI_DEVICE_PATH_PROTOCOL *DevicePathSecond; EFI_DEVICE_PATH_PROTOCOL *GopDevicePath; UINTN VarSize; SYSTEM_CONFIGURATION mSystemConfiguration; + UINT32 DxeGpioValue; Status = EFI_SUCCESS; PlugInPciVgaDevicePath = NULL; OnboardPciVgaDevicePath = NULL; @@ -625,20 +629,22 @@ PlatformBdsForceActiveVga ( if (PlugInPciVgaDevicePath == NULL && OnboardPciVgaDevicePath == NULL) { return EFI_UNSUPPORTED; } + DxeGpioValue = DetectGpioPinValue(); + VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"Setup", &gEfiNormalSetupGuid, NULL, &VarSize, &mSystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, @@ -687,25 +693,27 @@ UpdateConsoleResolution( UINT32 HorizontalResolution; UINT32 VerticalResolution; SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; EFI_STATUS Status; + UINT32 DxeGpioValue; HorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution); VerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution); + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"Setup", &gEfiNormalSetupGuid, NULL, &VarSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, @@ -1605,28 +1613,31 @@ PlatformBdsPolicyBehavior ( VOID *RegistrationExitPmAuth = NULL; EFI_EVENT Event; BOOLEAN IsFirstBoot; UINT16 *BootOrder; UINTN BootOrderSize; + UINT32 DxeGpioValue; Timeout = PcdGet16 (PcdPlatformBootTimeOut); if (Timeout > 10 ) { //we think the Timeout variable is corrupted Timeout = 10; } - + + DxeGpioValue = DetectGpioPinValue(); + VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( NORMAL_SETUP_NAME, &gEfiNormalSetupGuid, NULL, &VarSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf index 55f8914..110d629 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf @@ -70,10 +70,11 @@ # TcgPhysicalPresenceLib TrEEPhysicalPresenceLib FileHandleLib S3BootScriptLib SerialPortLib + PchPlatformLib [Protocols] gEfiFirmwareVolume2ProtocolGuid gEfiSimpleNetworkProtocolGuid gEfiLoadFileProtocolGuid diff --git a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c index 08f5df2..90fee65 100644 --- a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c +++ b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c @@ -37,10 +37,11 @@ Abstract: #include <Library/UefiRuntimeServicesTableLib.h> #include <Library/DebugLib.h> #include <Protocol/FirmwareVolume.h> #include <Library/HobLib.h> #include <IndustryStandard/Pci22.h> +#include <Library/PchPlatformLib.h> extern PCI_OPTION_ROM_TABLE mPciOptionRomTable[]; extern UINTN mSizeOptionRomTable; EFI_PCI_PLATFORM_PROTOCOL mPciPlatform = { @@ -332,21 +333,24 @@ PciPlatformDriverEntry ( IN EFI_SYSTEM_TABLE *SystemTable ) { EFI_STATUS Status; UINTN VarSize; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"Setup", &gEfiNormalSetupGuid, NULL, &VarSize, &mSystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf index a296c24..81f1afd 100644 --- a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf +++ b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf @@ -60,10 +60,11 @@ BaseMemoryLib UefiDriverEntryPoint UefiBootServicesTableLib UefiRuntimeServicesTableLib DxeServicesTableLib + PchPlatformLib [BuildOptions] [Depex] gEfiVariableArchProtocolGuid AND diff --git a/Vlv2TbltDevicePkg/PlatformDxe/ExI.c b/Vlv2TbltDevicePkg/PlatformDxe/ExI.c index 603b44a..b645ed0 100644 --- a/Vlv2TbltDevicePkg/PlatformDxe/ExI.c +++ b/Vlv2TbltDevicePkg/PlatformDxe/ExI.c @@ -23,10 +23,11 @@ Abstract: --*/ #include "PlatformDxe.h" +#include <Library/PchPlatformLib.h> #define PchLpcPciCfg32(Register) MmioRead32 (MmPciAddress (0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, Register)) // // Procedure: GetPmcBase @@ -60,10 +61,13 @@ InitExI ( { EFI_STATUS Status; SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"Setup", @@ -71,12 +75,12 @@ InitExI ( NULL, &VarSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c index 645b865..6ddc305 100644 --- a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c @@ -48,10 +48,11 @@ Abstract: #include <Guid/Vlv2Variable.h> #include <Protocol/GlobalNvsArea.h> #include <Protocol/IgdOpRegion.h> #include <Library/PcdLib.h> #include <Protocol/VariableLock.h> +#include <Library/PchPlatformLib.h> // // VLV2 GPIO GROUP OFFSET // @@ -199,10 +200,14 @@ InitPlatformUsbPolicy ( VOID InitRC6Policy( VOID ); +EFI_STATUS +DxeDetectGpioPinToResetSetup( + VOID + ); EFI_STATUS EFIAPI SaveSetupRecoveryVar( VOID @@ -592,10 +597,44 @@ InitThermalZone ( } #if defined SUPPORT_LVDS_DISPLAY && SUPPORT_LVDS_DISPLAY #endif +EFI_STATUS +DxeDetectGpioPinToResetSetup ( + VOID + ) +{ + EFI_STATUS Status; + UINTN VarSize; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); + + if (DxeGpioValue == 0) { + 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 + ); + } + + return EFI_SUCCESS; +} EFI_STATUS EFIAPI TristateLpcGpioS0i3Config ( UINT32 Gpio_Mmio_Offset, @@ -814,10 +853,15 @@ InitializePlatform ( EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, sizeof(SYSTEM_CONFIGURATION), &mSystemConfiguration ); } + + // + // Detect GPIO_S5_17 Pin to reset setup to default in Dxe Phase. + // + DxeDetectGpioPinToResetSetup(); Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, ReadyToBootFunction, NULL, @@ -1686,22 +1730,25 @@ UpdateDVMTSetup( // SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; EFI_STATUS Status; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( NORMAL_SETUP_NAME, &gEfiNormalSetupGuid, NULL, &VarSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c index 0abe1b2..62cd188 100644 --- a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c +++ b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c @@ -22,10 +22,12 @@ Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved #include <Protocol/PlatformGopPolicy.h> #include <Guid/SetupVariable.h> #include <SetupMode.h> #include <Library/UefiRuntimeServicesTableLib.h> +#include "PchAccess.h" +#include <Library/PchPlatformLib.h> EFI_BOOT_SERVICES *gBS; PLATFORM_GOP_POLICY_PROTOCOL mPlatformGOPPolicy; @@ -154,10 +156,11 @@ PlatformGOPPolicyEntryPoint ( { EFI_STATUS Status = EFI_SUCCESS; SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; + UINT32 DxeGpioValue; gBS = SystemTable->BootServices; gBS->SetMem ( @@ -168,10 +171,12 @@ PlatformGOPPolicyEntryPoint ( mPlatformGOPPolicy.Revision = PLATFORM_GOP_POLICY_PROTOCOL_REVISION_01; mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus; mPlatformGOPPolicy.GetVbtData = GetVbtData; + DxeGpioValue = DetectGpioPinValue(); + // // Install protocol to allow access to this Policy. // VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( @@ -179,12 +184,12 @@ PlatformGOPPolicyEntryPoint ( &gEfiNormalSetupGuid, NULL, &VarSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf index 6fcf93b..bb24d19 100644 --- a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf +++ b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf @@ -34,15 +34,18 @@ [Packages] MdePkg/MdePkg.dec IntelFrameworkPkg/IntelFrameworkPkg.dec Vlv2TbltDevicePkg/PlatformPkg.dec + Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec + [LibraryClasses] BaseLib DebugLib UefiDriverEntryPoint UefiRuntimeServicesTableLib + PchPlatformLib # DxeKscLib [Guids] gBmpImageGuid gEfiNormalSetupGuid diff --git a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c index 8bdcaee..92219a5 100644 --- a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c +++ b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c @@ -19,10 +19,12 @@ Abstract: Platform Info driver to public platform related HOB data --*/ #include "PlatformInfoDxe.h" +#include "PchAccess.h" +#include <Library/PchPlatformLib.h> /** Entry point for the driver. This routine get the platform HOB data from PEI and publish @@ -51,22 +53,25 @@ PlatformInfoInit ( UINT8 Selection; SYSTEM_CONFIGURATION SystemConfiguration; UINT8 *LpssDataHobPtr; UINT8 *LpssDataVarPtr; UINTN i; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( NORMAL_SETUP_NAME, &gEfiNormalSetupGuid, NULL, &VarSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf index e507d49..40ee6b7 100644 --- a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf +++ b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf @@ -50,8 +50,9 @@ [LibraryClasses] HobLib UefiRuntimeServicesTableLib UefiDriverEntryPoint BaseMemoryLib + PchPlatformLib [Depex] gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c b/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c index 3b94e3b..d0e9f3d 100644 --- a/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c +++ b/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c @@ -146,10 +146,11 @@ UpdateBootMode ( SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; volatile UINT32 GpioValue; BOOLEAN IsFirstBoot; UINT32 Data32; + UINT32 PeiGpioValue; Status = (*PeiServices)->GetBootMode( PeiServices, &BootMode ); @@ -166,10 +167,11 @@ UpdateBootMode ( // // When this boot is WDT reset, the system needs booting with CrashDump function eanbled. // Data32 = IoRead32 (ACPI_BASE_ADDRESS + R_PCH_TCO_STS); + PeiGpioValue = DetectGpioPinValue(); // // Check Power Button, click the power button, the system will boot in fast boot mode, // if it is pressed and hold for a second, it will boot in FullConfiguration/setup mode. // @@ -200,12 +202,12 @@ UpdateBootMode ( &gEfiSetupVariableGuid, NULL, &VarSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || PeiGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = Variable->GetVariable( Variable, L"SetupRecovery", &gEfiSetupVariableGuid, diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c index 6e2d592..27a6b07 100644 --- a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c +++ b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c @@ -168,10 +168,13 @@ GetSetupVariable ( ) { UINTN VariableSize; EFI_STATUS Status; EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable; + UINT32 PeiGpioValue; + + PeiGpioValue = DetectGpioPinValue(); VariableSize = sizeof (SYSTEM_CONFIGURATION); ZeroMem (SystemConfiguration, sizeof (SYSTEM_CONFIGURATION)); Status = (*PeiServices)->LocatePpi ( @@ -194,12 +197,12 @@ GetSetupVariable ( &gEfiSetupVariableGuid, NULL, &VariableSize, SystemConfiguration ); - if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION) || PeiGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VariableSize = sizeof(SYSTEM_CONFIGURATION); Status = Variable->GetVariable( Variable, L"SetupRecovery", &gEfiSetupVariableGuid, diff --git a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c index 4d933a0..04a20e3 100644 --- a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c +++ b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c @@ -28,10 +28,11 @@ Abstract: #include "PchAccess.h" #include "PlatformBootMode.h" #include <Guid/SetupVariable.h> #include <Guid/BootState.h> +#include <Library/PchPlatformLib.h> // // Priority of our boot modes, highest priority first // EFI_BOOT_MODE mBootModePriority[] = { @@ -316,10 +317,13 @@ IsFastBootEnabled ( EFI_STATUS Status; EFI_PEI_READ_ONLY_VARIABLE2_PPI *PeiReadOnlyVarPpi; UINTN VarSize; SYSTEM_CONFIGURATION SystemConfiguration; BOOLEAN FastBootEnabledStatus; + UINT32 PeiGpioValue; + + PeiGpioValue = DetectGpioPinValue(); FastBootEnabledStatus = FALSE; Status = (**PeiServices).LocatePpi ( PeiServices, &gEfiPeiReadOnlyVariable2PpiGuid, @@ -335,10 +339,22 @@ IsFastBootEnabled ( &gEfiSetupVariableGuid, NULL, &VarSize, &SystemConfiguration ); + if (PeiGpioValue == 0) { + VarSize = sizeof(SYSTEM_CONFIGURATION); + Status = PeiReadOnlyVarPpi->GetVariable ( + PeiReadOnlyVarPpi, + L"SetupRecovery", + &gEfiSetupVariableGuid, + NULL, + &VarSize, + &SystemConfiguration + ); + ASSERT_EFI_ERROR (Status); + } if (Status == EFI_SUCCESS) { if (SystemConfiguration.FastBoot != 0) { FastBootEnabledStatus = TRUE; } } diff --git a/Vlv2TbltDevicePkg/PlatformPei/Platform.c b/Vlv2TbltDevicePkg/PlatformPei/Platform.c index b0ab3e1..493c096 100644 --- a/Vlv2TbltDevicePkg/PlatformPei/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformPei/Platform.c @@ -27,10 +27,11 @@ Module Name: #include "PchCommonDefinitions.h" #include <Ppi/MfgMemoryTest.h> #include <Guid/SetupVariable.h> #include <Guid/Vlv2Variable.h> #include <Ppi/fTPMPolicy.h> +#include <Library/PchPlatformLib.h> // // Start::Alpine Valley platform // enum { @@ -697,10 +698,11 @@ PeiInitPlatform ( SYSTEM_CONFIGURATION SystemConfiguration; UINT32 GGC = 0; EFI_PEI_PPI_DESCRIPTOR *mVlvMmioPolicyPpiDesc; VLV_MMIO_POLICY_PPI *mVlvMmioPolicyPpi; + UINT32 PeiGpioValue; ZeroMem (&PlatformInfo, sizeof(PlatformInfo)); Status = InstallMonoStatusCode(FileHandle, PeiServices); ASSERT_EFI_ERROR (Status); @@ -742,10 +744,11 @@ PeiInitPlatform ( // RtcPowerFailureHandler (PeiServices); PchMmPci32( 0, 0, 2, 0, 0x50) = 0x210; + PeiGpioValue = DetectGpioPinValue(); VariableSize = sizeof (SYSTEM_CONFIGURATION); ZeroMem (&SystemConfiguration, VariableSize); // @@ -765,12 +768,12 @@ PeiInitPlatform ( &gEfiSetupVariableGuid, NULL, &VariableSize, &SystemConfiguration ); - if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VariableSize != sizeof(SYSTEM_CONFIGURATION) || PeiGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VariableSize = sizeof(SYSTEM_CONFIGURATION); Status = Variable->GetVariable( Variable, L"SetupRecovery", &gEfiSetupVariableGuid, diff --git a/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf b/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf index 9c1cd08..9b95a9b 100644 --- a/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf +++ b/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf @@ -85,10 +85,11 @@ MtrrLib PerformanceLib MonoStatusCodeLib BaseCryptLib PciLib + PchPlatformLib [Ppis] gEfiPeiStallPpiGuid gPeiSpeakerInterfacePpiGuid gEfiPeiMemoryDiscoveredPpiGuid diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf index 50c9190..51fd77c 100644 --- a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf +++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf @@ -87,10 +87,11 @@ UefiRuntimeServicesTableLib PrintLib BiosIdLib CpuIA32Lib IoLib + PchPlatformLib [Guids] ## This GUID C Name is not required for build since it is from UefiLib and not directly used by this module source. ## gEfiGlobalVariableGuid ## SOMETIMES_CONSUMED ## Variable:L"PlatformLang" this variable specifies the platform supported language string (RFC 4646 format) ## gEfiGlobalVariableGuid ## SOMETIMES_CONSUMED ## Variable:L"Lang" this variable specifies the platform supported language string (ISO 639-2 format) diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c index 3c6f8f4..c7f85b9 100644 --- a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c +++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c @@ -43,10 +43,11 @@ Revision History: #include "VlvAccess.h" #include "PchAccess.h" #include "SetupMode.h" #include "PchCommonDefinitions.h" #include <PlatformBaseAddresses.h> +#include <Library/PchPlatformLib.h> typedef struct { UINT8 ID; CHAR8 String[16]; @@ -1734,26 +1735,28 @@ EFIAPI SetupInfo (void) { EFI_STATUS Status; UINTN VarSize; EFI_PEI_HOB_POINTERS GuidHob; + UINT32 DxeGpioValue; if (mSetupInfoDone) { return; } + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( NORMAL_SETUP_NAME, &gEfiNormalSetupGuid, NULL, &VarSize, &mSystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)|| DxeGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"SetupRecovery", &gEfiNormalSetupGuid, NULL, diff --git a/Vlv2TbltDevicePkg/PlatformSmm/Platform.c b/Vlv2TbltDevicePkg/PlatformSmm/Platform.c index 3a5b20a..d918913 100644 --- a/Vlv2TbltDevicePkg/PlatformSmm/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformSmm/Platform.c @@ -22,11 +22,11 @@ Abstract: --*/ #include "SmmPlatform.h" #include <Protocol/CpuIo2.h> - +#include <Library/PchPlatformLib.h> // // Local variables // typedef struct { @@ -140,10 +140,13 @@ InitializePlatformSmm ( EFI_SMM_SX_DISPATCH_CONTEXT EntryDispatchContext; EFI_SMM_SW_DISPATCH_PROTOCOL *SwDispatch; EFI_SMM_SW_DISPATCH_CONTEXT SwContext; UINTN VarSize; EFI_BOOT_MODE BootMode; + UINT32 SmmGpioValue; + + SmmGpioValue = DetectGpioPinValue(); Handle = NULL; // // Locate the Global NVS Protocol. @@ -168,12 +171,12 @@ InitializePlatformSmm ( &gEfiSetupVariableGuid, NULL, &VarSize, &mSystemConfiguration ); - if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR (Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || SmmGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = SystemTable->RuntimeServices->GetVariable( L"SetupRecovery", &gEfiSetupVariableGuid, NULL, @@ -838,17 +841,19 @@ EnableS5WakeOnRtc() { UINT8 CmosData; UINTN i; EFI_STATUS Status; UINTN VarSize; + UINT32 SmmGpioValue; // // make sure EFI_SMM_VARIABLE_PROTOCOL is available // if (!mSmmVariable) { return; } + SmmGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); // // read the variable into the buffer @@ -858,12 +863,12 @@ EnableS5WakeOnRtc() &gEfiSetupVariableGuid, NULL, &VarSize, &mSystemConfiguration ); - if (EFI_ERROR(Status) || VarSize != sizeof(SYSTEM_CONFIGURATION)) { - //The setup variable is corrupted + if (EFI_ERROR(Status) || VarSize != sizeof(SYSTEM_CONFIGURATION) || SmmGpioValue == 0) { + //The setup variable is corrupted or detect GPIO_S5_17 Pin is low VarSize = sizeof(SYSTEM_CONFIGURATION); Status = mSmmVariable->SmmGetVariable( L"SetupRecovery", &gEfiSetupVariableGuid, NULL, -- 2.6.2.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel