From d3ce92cab255985b4f395c80592b26320d0f24ac Mon Sep 17 00:00:00 2001 From: timhe Date: Fri, 4 Dec 2015 08:00:53 +0000 Subject: Vlv2TbltDevicePkg/Vlv2DeviceRefCodePkg: Reset BIOS Setup when the jumper is present on Turbot board. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shifei Lu Reviewed-by: Tim He git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2014.SP1@19122 6f19259b-4bc3-4df7-8a09-765794883524 --- 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 ++- 25 files changed, 291 insertions(+), 41 deletions(-) (limited to 'Vlv2TbltDevicePkg') diff --git a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c index 2ff14ec6bb..a7e54e3284 100644 --- a/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c +++ b/Vlv2TbltDevicePkg/AcpiPlatform/AcpiPlatform.c @@ -648,6 +648,7 @@ OnReadyToBoot ( EFI_PLATFORM_CPU_INFO *PlatformCpuInfoPtr = NULL; EFI_PLATFORM_CPU_INFO PlatformCpuInfo; EFI_PEI_HOB_POINTERS GuidHob; + UINT32 DxeGpioValue; if (mFirstNotify) { return; @@ -686,6 +687,8 @@ OnReadyToBoot ( CopyMem(&PlatformCpuInfo, PlatformCpuInfoPtr, sizeof(EFI_PLATFORM_CPU_INFO)); } + DxeGpioValue = DetectGpioPinValue(); + // // Update the ACPI parameter blocks finally. // @@ -697,8 +700,8 @@ OnReadyToBoot ( &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", @@ -796,6 +799,7 @@ AcpiPlatformEntryPoint ( UINTN NumberOfEnabledCPUs; UINT32 Data32; PCH_STEPPING pchStepping; + UINT32 DxeGpioValue; mFirstNotify = FALSE; @@ -815,7 +819,8 @@ AcpiPlatformEntryPoint ( 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. @@ -828,8 +833,8 @@ AcpiPlatformEntryPoint ( &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", @@ -864,8 +869,8 @@ AcpiPlatformEntryPoint ( &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", diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c index e38633b2b3..e278e31555 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.c @@ -282,7 +282,9 @@ ConfigurePlatformClocks ( UINT8 ClockAddress = CLOCK_GENERATOR_ADDRESS; UINTN VariableSize; EFI_PEI_READ_ONLY_VARIABLE2_PPI *Variable; + UINT32 PeiGpioValue; + PeiGpioValue = DetectGpioPinValue(); // // Obtain Platform Info from HOB. // @@ -346,8 +348,8 @@ ConfigurePlatformClocks ( 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", diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h index 4ec5b881ab..8d15da9533 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardClkGens/BoardClkGens.h @@ -19,6 +19,7 @@ #define _BOARD_CLK_GEN_H_ #include +#include "PchAccess.h" #include #include #include @@ -26,6 +27,7 @@ #include #include #include +#include #define CLOCK_GENERATOR_ADDRESS 0xd2 diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c index 5209a74d71..7b7f03f1b7 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.c @@ -141,6 +141,9 @@ MultiPlatformGpioTableInit ( EFI_PEI_READ_ONLY_VARIABLE2_PPI *PeiReadOnlyVarPpi; UINTN VarSize; SYSTEM_CONFIGURATION SystemConfiguration; + UINT32 PeiGpioValue; + + PeiGpioValue = DetectGpioPinValue(); DEBUG ((EFI_D_INFO, "MultiPlatformGpioTableInit()...\n")); @@ -169,6 +172,18 @@ MultiPlatformGpioTableInit ( &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; diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h index d8cd98e688..a165dcc0c0 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/BoardGpios/BoardGpios.h @@ -28,6 +28,7 @@ #include #include #include +#include GPIO_CONF_PAD_INIT mNB_BB_FAB3_GpioInitData_SC_TRI[] = diff --git a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf index 74ffc78c91..741abe2410 100644 --- a/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf +++ b/Vlv2TbltDevicePkg/Library/MultiPlatformLib/MultiPlatformLib.inf @@ -71,6 +71,7 @@ DebugLib HobLib IoLib + PchPlatformLib # PeiKscLib [Ppis] diff --git a/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c index a509b07c69..d8226425ef 100644 --- a/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c +++ b/Vlv2TbltDevicePkg/Library/PchPlatformLib/PchPlatformLibrary.c @@ -134,3 +134,111 @@ IsPchSupported ( } 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 195d734189..2334c95a2c 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/BdsPlatform.c @@ -44,6 +44,7 @@ Abstract: #include #include #include +#include EFI_GUID *ConnectDriverTable[] = { &gEfiMmioDeviceProtocolGuid, @@ -284,6 +285,7 @@ GetGopDevicePath ( UINTN VarSize; SYSTEM_CONFIGURATION mSystemConfiguration; + UINT32 DxeGpioValue; if (PciDevicePath == NULL || GopDevicePath == NULL) { return EFI_INVALID_PARAMETER; @@ -304,6 +306,7 @@ GetGopDevicePath ( 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 @@ -322,8 +325,8 @@ GetGopDevicePath ( &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", @@ -613,6 +616,7 @@ PlatformBdsForceActiveVga ( EFI_DEVICE_PATH_PROTOCOL *GopDevicePath; UINTN VarSize; SYSTEM_CONFIGURATION mSystemConfiguration; + UINT32 DxeGpioValue; Status = EFI_SUCCESS; PlugInPciVgaDevicePath = NULL; @@ -627,6 +631,8 @@ PlatformBdsForceActiveVga ( return EFI_UNSUPPORTED; } + DxeGpioValue = DetectGpioPinValue(); + VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( L"Setup", @@ -635,8 +641,8 @@ PlatformBdsForceActiveVga ( &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", @@ -689,10 +695,12 @@ UpdateConsoleResolution( 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( @@ -702,8 +710,8 @@ UpdateConsoleResolution( &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", @@ -1607,13 +1615,16 @@ PlatformBdsPolicyBehavior ( 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, @@ -1623,8 +1634,8 @@ PlatformBdsPolicyBehavior ( &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", diff --git a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf index 45578e8df4..ff5edc31c5 100644 --- a/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf +++ b/Vlv2TbltDevicePkg/Library/PlatformBdsLib/PlatformBdsLib.inf @@ -72,6 +72,7 @@ FileHandleLib S3BootScriptLib SerialPortLib + PchPlatformLib [Protocols] gEfiFirmwareVolume2ProtocolGuid diff --git a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c index 08f5df2a25..90fee6585e 100644 --- a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c +++ b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.c @@ -39,6 +39,7 @@ Abstract: #include #include #include +#include extern PCI_OPTION_ROM_TABLE mPciOptionRomTable[]; extern UINTN mSizeOptionRomTable; @@ -334,6 +335,9 @@ PciPlatformDriverEntry ( { EFI_STATUS Status; UINTN VarSize; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( @@ -343,8 +347,8 @@ PciPlatformDriverEntry ( &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", diff --git a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf index a296c24b75..81f1afd0f9 100644 --- a/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf +++ b/Vlv2TbltDevicePkg/PciPlatform/PciPlatform.inf @@ -62,6 +62,7 @@ UefiBootServicesTableLib UefiRuntimeServicesTableLib DxeServicesTableLib + PchPlatformLib [BuildOptions] diff --git a/Vlv2TbltDevicePkg/PlatformDxe/ExI.c b/Vlv2TbltDevicePkg/PlatformDxe/ExI.c index 603b44aa82..b645ed0ef4 100644 --- a/Vlv2TbltDevicePkg/PlatformDxe/ExI.c +++ b/Vlv2TbltDevicePkg/PlatformDxe/ExI.c @@ -25,6 +25,7 @@ Abstract: #include "PlatformDxe.h" +#include #define PchLpcPciCfg32(Register) MmioRead32 (MmPciAddress (0, DEFAULT_PCI_BUS_NUMBER_PCH, PCI_DEVICE_NUMBER_PCH_LPC, 0, Register)) @@ -62,6 +63,9 @@ InitExI ( SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); @@ -73,8 +77,8 @@ InitExI ( &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", diff --git a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c index 645b865cdd..6ddc305f3a 100644 --- a/Vlv2TbltDevicePkg/PlatformDxe/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformDxe/Platform.c @@ -50,6 +50,7 @@ Abstract: #include #include #include +#include // @@ -201,6 +202,10 @@ InitRC6Policy( VOID ); +EFI_STATUS +DxeDetectGpioPinToResetSetup( + VOID + ); EFI_STATUS EFIAPI @@ -594,6 +599,40 @@ InitThermalZone ( #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 @@ -816,6 +855,11 @@ InitializePlatform ( &mSystemConfiguration ); } + + // + // Detect GPIO_S5_17 Pin to reset setup to default in Dxe Phase. + // + DxeDetectGpioPinToResetSetup(); Status = EfiCreateEventReadyToBootEx ( TPL_CALLBACK, @@ -1688,6 +1732,9 @@ UpdateDVMTSetup( SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; EFI_STATUS Status; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( @@ -1698,8 +1745,8 @@ UpdateDVMTSetup( &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", diff --git a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c index 0abe1b27d9..62cd18878f 100644 --- a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c +++ b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.c @@ -24,6 +24,8 @@ Copyright (c) 1999 - 2014, Intel Corporation. All rights reserved #include #include #include +#include "PchAccess.h" +#include EFI_BOOT_SERVICES *gBS; @@ -156,6 +158,7 @@ PlatformGOPPolicyEntryPoint ( EFI_STATUS Status = EFI_SUCCESS; SYSTEM_CONFIGURATION SystemConfiguration; UINTN VarSize; + UINT32 DxeGpioValue; gBS = SystemTable->BootServices; @@ -170,6 +173,8 @@ PlatformGOPPolicyEntryPoint ( mPlatformGOPPolicy.GetPlatformLidStatus = GetPlatformLidStatus; mPlatformGOPPolicy.GetVbtData = GetVbtData; + DxeGpioValue = DetectGpioPinValue(); + // // Install protocol to allow access to this Policy. // @@ -181,8 +186,8 @@ PlatformGOPPolicyEntryPoint ( &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", diff --git a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf index 6fcf93b819..bb24d19711 100644 --- a/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf +++ b/Vlv2TbltDevicePkg/PlatformGopPolicy/PlatformGopPolicy.inf @@ -36,11 +36,14 @@ MdePkg/MdePkg.dec IntelFrameworkPkg/IntelFrameworkPkg.dec Vlv2TbltDevicePkg/PlatformPkg.dec + Vlv2DeviceRefCodePkg/Vlv2DeviceRefCodePkg.dec + [LibraryClasses] BaseLib DebugLib UefiDriverEntryPoint UefiRuntimeServicesTableLib + PchPlatformLib # DxeKscLib [Guids] diff --git a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c index 8bdcaee7c9..92219a5f4e 100644 --- a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c +++ b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.c @@ -21,6 +21,8 @@ Abstract: --*/ #include "PlatformInfoDxe.h" +#include "PchAccess.h" +#include /** Entry point for the driver. @@ -53,6 +55,9 @@ PlatformInfoInit ( UINT8 *LpssDataHobPtr; UINT8 *LpssDataVarPtr; UINTN i; + UINT32 DxeGpioValue; + + DxeGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); Status = gRT->GetVariable( @@ -63,8 +68,8 @@ PlatformInfoInit ( &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", diff --git a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf index e507d498d5..40ee6b7bd7 100644 --- a/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf +++ b/Vlv2TbltDevicePkg/PlatformInfoDxe/PlatformInfoDxe.inf @@ -52,6 +52,7 @@ UefiRuntimeServicesTableLib UefiDriverEntryPoint BaseMemoryLib + PchPlatformLib [Depex] gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c b/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c index 3b94e3b54f..d0e9f3d772 100644 --- a/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c +++ b/Vlv2TbltDevicePkg/PlatformInitPei/BootMode.c @@ -148,6 +148,7 @@ UpdateBootMode ( volatile UINT32 GpioValue; BOOLEAN IsFirstBoot; UINT32 Data32; + UINT32 PeiGpioValue; Status = (*PeiServices)->GetBootMode( PeiServices, @@ -168,6 +169,7 @@ 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, @@ -202,8 +204,8 @@ UpdateBootMode ( &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, diff --git a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c index 6e2d592f5f..27a6b078fc 100644 --- a/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c +++ b/Vlv2TbltDevicePkg/PlatformInitPei/PlatformEarlyInit.c @@ -170,6 +170,9 @@ 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)); @@ -196,8 +199,8 @@ GetSetupVariable ( &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, diff --git a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c index 4d933a09db..04a20e385f 100644 --- a/Vlv2TbltDevicePkg/PlatformPei/BootMode.c +++ b/Vlv2TbltDevicePkg/PlatformPei/BootMode.c @@ -30,6 +30,7 @@ Abstract: #include #include +#include // // Priority of our boot modes, highest priority first @@ -318,6 +319,9 @@ IsFastBootEnabled ( UINTN VarSize; SYSTEM_CONFIGURATION SystemConfiguration; BOOLEAN FastBootEnabledStatus; + UINT32 PeiGpioValue; + + PeiGpioValue = DetectGpioPinValue(); FastBootEnabledStatus = FALSE; Status = (**PeiServices).LocatePpi ( @@ -337,6 +341,18 @@ IsFastBootEnabled ( &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 b0ab3e1c98..493c09679a 100644 --- a/Vlv2TbltDevicePkg/PlatformPei/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformPei/Platform.c @@ -29,6 +29,7 @@ Module Name: #include #include #include +#include // // Start::Alpine Valley platform @@ -699,6 +700,7 @@ PeiInitPlatform ( EFI_PEI_PPI_DESCRIPTOR *mVlvMmioPolicyPpiDesc; VLV_MMIO_POLICY_PPI *mVlvMmioPolicyPpi; + UINT32 PeiGpioValue; ZeroMem (&PlatformInfo, sizeof(PlatformInfo)); @@ -744,6 +746,7 @@ PeiInitPlatform ( PchMmPci32( 0, 0, 2, 0, 0x50) = 0x210; + PeiGpioValue = DetectGpioPinValue(); VariableSize = sizeof (SYSTEM_CONFIGURATION); ZeroMem (&SystemConfiguration, VariableSize); @@ -767,8 +770,8 @@ PeiInitPlatform ( &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, diff --git a/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf b/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf index 9c1cd08db5..9b95a9b63a 100644 --- a/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf +++ b/Vlv2TbltDevicePkg/PlatformPei/PlatformPei.inf @@ -87,6 +87,7 @@ MonoStatusCodeLib BaseCryptLib PciLib + PchPlatformLib [Ppis] gEfiPeiStallPpiGuid diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf index 50c9190859..51fd77c797 100644 --- a/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf +++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/PlatformSetupDxe.inf @@ -89,6 +89,7 @@ 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. diff --git a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c index 3c6f8f447c..c7f85b9231 100644 --- a/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c +++ b/Vlv2TbltDevicePkg/PlatformSetupDxe/SetupInfoRecords.c @@ -45,6 +45,7 @@ Revision History: #include "SetupMode.h" #include "PchCommonDefinitions.h" #include +#include typedef struct { @@ -1736,10 +1737,12 @@ 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( @@ -1750,8 +1753,8 @@ SetupInfo (void) &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", diff --git a/Vlv2TbltDevicePkg/PlatformSmm/Platform.c b/Vlv2TbltDevicePkg/PlatformSmm/Platform.c index 3a5b20a984..d918913e00 100644 --- a/Vlv2TbltDevicePkg/PlatformSmm/Platform.c +++ b/Vlv2TbltDevicePkg/PlatformSmm/Platform.c @@ -24,7 +24,7 @@ Abstract: #include "SmmPlatform.h" #include - +#include // // Local variables @@ -142,6 +142,9 @@ InitializePlatformSmm ( EFI_SMM_SW_DISPATCH_CONTEXT SwContext; UINTN VarSize; EFI_BOOT_MODE BootMode; + UINT32 SmmGpioValue; + + SmmGpioValue = DetectGpioPinValue(); Handle = NULL; @@ -170,8 +173,8 @@ InitializePlatformSmm ( &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", @@ -840,6 +843,7 @@ EnableS5WakeOnRtc() UINTN i; EFI_STATUS Status; UINTN VarSize; + UINT32 SmmGpioValue; // // make sure EFI_SMM_VARIABLE_PROTOCOL is available @@ -847,6 +851,7 @@ EnableS5WakeOnRtc() if (!mSmmVariable) { return; } + SmmGpioValue = DetectGpioPinValue(); VarSize = sizeof(SYSTEM_CONFIGURATION); @@ -860,8 +865,8 @@ EnableS5WakeOnRtc() &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", -- cgit v1.2.3