diff options
author | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
---|---|---|
committer | raywu <raywu0301@gmail.com> | 2018-06-15 00:00:50 +0800 |
commit | b7c51c9cf4864df6aabb99a1ae843becd577237c (patch) | |
tree | eebe9b0d0ca03062955223097e57da84dd618b9a /ReferenceCode/Chipset/LynxPoint/Wdt/Dxe | |
download | zprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz |
Diffstat (limited to 'ReferenceCode/Chipset/LynxPoint/Wdt/Dxe')
-rw-r--r-- | ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.c | 218 | ||||
-rw-r--r-- | ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.cif | 12 | ||||
-rw-r--r-- | ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.dxs | 30 | ||||
-rw-r--r-- | ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.inf | 87 | ||||
-rw-r--r-- | ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.mak | 102 | ||||
-rw-r--r-- | ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.sdl | 68 |
6 files changed, 517 insertions, 0 deletions
diff --git a/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.c b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.c new file mode 100644 index 0000000..ea5bd2f --- /dev/null +++ b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.c @@ -0,0 +1,218 @@ +/** @file + Implementation file for Watchdog Timer functionality + +@copyright + Copyright (c) 2010 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains an 'Intel Peripheral Driver' and uniquely + identified as "Intel Reference Module" and is + licensed for Intel CPUs and chipsets under the terms of your + license agreement with Intel or your vendor. This file may + be modified by the user, subject to additional terms of the + license agreement +**/ +#if !defined(EDK_RELEASE_VERSION) || (EDK_RELEASE_VERSION < 0x00020000) +#include "EdkIIGlueDxe.h" +#endif + +#include EFI_PROTOCOL_CONSUMER (PchReset) +#include "WdtCommon.h" +#include EFI_PROTOCOL_PRODUCER (Wdt) + +VOID +EFIAPI +WdtRunBeforeOsBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ); + +EFI_STATUS +EFIAPI +WdtPchResetCallback ( + IN PCH_RESET_TYPE PchResetType + ); + +#define TIMEOUT_AFTER_POST_MULTIPLIER 16 +#define MINIMUM_TIMEOUT_AT_S4_EXIT 600 ///< 10 minutes +EFI_HANDLE mImageHandle; +WDT_PROTOCOL mWdtProtocol = { + WdtReloadAndStart, + WdtCheckStatus, + WdtDisable, + WdtAllowKnownReset, + IsWdtRequired, + IsWdtEnabled +}; + +PCH_RESET_CALLBACK_PROTOCOL mPchResetCallbackProtocol = { WdtPchResetCallback }; + +/** + Installs WDT protocol. + Registers a function to be executed just before booting to OS. + + @param[in] ImageHandle Image handle for this driver image + @param[in] SystemTable Pointer to the EFI System Table + + @retval EFI_SUCCESS WDT DXE driver initialization completed successfully +**/ +EFI_STATUS +WdtDxeEntryPoint ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + EFI_EVENT Event; + + DEBUG ((EFI_D_INFO, "(Wdt) Entry Point to WdtDxe\n")); + + mImageHandle = ImageHandle; + + Status = gBS->CreateEvent ( + EVENT_SIGNAL_EXIT_BOOT_SERVICES, + EFI_TPL_CALLBACK, + WdtRunBeforeOsBoot, + NULL, + &Event + ); + ASSERT_EFI_ERROR (Status); + + Status = EfiCreateEventLegacyBootEx ( + EFI_TPL_CALLBACK, + WdtRunBeforeOsBoot, + NULL, + &Event + ); + ASSERT_EFI_ERROR (Status); + + DEBUG ((EFI_D_INFO, "(Wdt) WDT event registration; Status = %r\n", Status)); + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gWdtProtocolGuid, + EFI_NATIVE_INTERFACE, + &mWdtProtocol + ); + ASSERT_EFI_ERROR (Status); + + Status = gBS->InstallProtocolInterface ( + &ImageHandle, + &gPchResetCallbackProtocolGuid, + EFI_NATIVE_INTERFACE, + &mPchResetCallbackProtocol + ); + ASSERT_EFI_ERROR (Status); + + return EFI_SUCCESS; +} + +/** + Turns on watchdog timer just before booting to OS, if an OS application requested that. + Clears request status. + Uninstalls Wdt protocol to prevent other modules from interfering with actions described above. + + @param[in] Event useless here, but required in functions invoked by events + @param[in] Context useless here, but required in functions invoked by events + + @retval None +**/ +VOID +EFIAPI +WdtRunBeforeOsBoot ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + UINT32 ReloadValue; + UINT32 Readback; + EFI_STATUS Status; + EFI_BOOT_MODE BootMode; + EFI_PEI_HOB_POINTERS HobList; + WDT_HOB *WdtHob; + + gBS->CloseEvent (Event); + + DEBUG ((EFI_D_INFO, "(Wdt) RunWdtBeforeOsBoot\n")); + Status = gBS->UninstallProtocolInterface ( + mImageHandle, + &gWdtProtocolGuid, + &mWdtProtocol + ); + + Status = gBS->UninstallProtocolInterface ( + mImageHandle, + &gPchResetCallbackProtocolGuid, + &mPchResetCallbackProtocol + ); + /// + /// check boot type, there are different flows for S4/S5 + /// + EfiGetSystemConfigurationTable (&gEfiHobListGuid, (VOID **) &HobList.Raw); + if (HobList.Header->HobType != EFI_HOB_TYPE_HANDOFF) { + DEBUG ((EFI_D_ERROR, "(Wdt) Handoff Hob missing!\n")); + return; + } + + BootMode = HobList.HandoffInformationTable->BootMode; + + WdtHob = GetFirstGuidHob (&mWdtHobGuid); + if (WdtHob == NULL) { + return; + } + + Readback = IoRead32 (WdtGetAddress ()); + ReloadValue = TIMEOUT_AFTER_POST_MULTIPLIER * ((Readback & B_PCH_OC_WDT_CTL_AFTER_POST) >> 16); + + if (BootMode == BOOT_ON_S4_RESUME) { + /// + /// S4 resume: if WDT was enabled before S0->S4 transition, + /// then WDT must be turned on even though TimeoutValueAfterPost == 0 + /// unlike in S5->S0 flow, ToVaP is not set to zero after being consumed + /// + if (WdtHob->Active == 1) { + if (ReloadValue != 0) { + WdtReloadAndStart (ReloadValue); + } else { + WdtReloadAndStart (MINIMUM_TIMEOUT_AT_S4_EXIT); + } + } else { + WdtDisable (); + } + } else if (ReloadValue != 0) { + /// + /// start WDT with TimeoutValueAfterPost and clear that value from register + /// + Readback &= ~(B_PCH_OC_WDT_CTL_AFTER_POST); + IoWrite32 (WdtGetAddress (), Readback); + WdtReloadAndStart (ReloadValue); + } else { + WdtDisable (); + } + + return; +} + +/** + WDT call back function for Pch Reset. + + @param[in] PchResetType Pch Reset Types which includes PowerCycle, Globalreset. + + @retval EFI_SUCCESS The function completed successfully + @retval Others All other error conditions encountered result in an ASSERT. +**/ +EFI_STATUS +EFIAPI +WdtPchResetCallback ( + IN PCH_RESET_TYPE PchResetType + ) +{ + WdtAllowKnownReset (); + return EFI_SUCCESS; +} diff --git a/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.cif b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.cif new file mode 100644 index 0000000..84a9fad --- /dev/null +++ b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.cif @@ -0,0 +1,12 @@ +<component> + name = "WdtDxe" + category = ModulePart + LocalRoot = "ReferenceCode\Chipset\LynxPoint\Wdt\Dxe\" + RefName = "WdtDxe" +[files] +"WdtDxe.sdl" +"WdtDxe.dxs" +"WdtDxe.mak" +"WdtDxe.c" +"WdtDxe.inf" +<endComponent> diff --git a/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.dxs b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.dxs new file mode 100644 index 0000000..b64a661 --- /dev/null +++ b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.dxs @@ -0,0 +1,30 @@ +/** @file + Dependencies file for Watchdog Timer functionality + +@copyright + Copyright (c) 2010 - 2012 Intel Corporation. All rights reserved + This software and associated documentation (if any) is furnished + under a license and may only be used or copied in accordance + with the terms of the license. Except as permitted by such + license, no part of this software or documentation may be + reproduced, stored in a retrieval system, or transmitted in any + form or by any means without the express written consent of + Intel Corporation. + + This file contains a 'Sample Driver' and is licensed as such + under the terms of your license agreement with Intel or your + vendor. This file may be modified by the user, subject to + the additional terms of the license agreement + +**/ + + +#include "AutoGen.h" +#include "DxeDepex.h" +#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB) +#include "EfiDepex.h" +#endif + +DEPENDENCY_START + TRUE +DEPENDENCY_END diff --git a/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.inf b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.inf new file mode 100644 index 0000000..ceff3c7 --- /dev/null +++ b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.inf @@ -0,0 +1,87 @@ +## @file +# Component description file for the watchdog timer driver. +# +#@copyright +# Copyright (c) 2010 - 2012 Intel Corporation. All rights reserved +# This software and associated documentation (if any) is furnished +# under a license and may only be used or copied in accordance +# with the terms of the license. Except as permitted by such +# license, no part of this software or documentation may be +# reproduced, stored in a retrieval system, or transmitted in any +# form or by any means without the express written consent of +# Intel Corporation. +# +# This file contains a 'Sample Driver' and is licensed as such +# under the terms of your license agreement with Intel or your +# vendor. This file may be modified by the user, subject to +# the additional terms of the license agreement +# + +[defines] +BASE_NAME = WdtDxe +FILE_GUID = 5AAB83E5-F027-4ca7-BFD0-16358CC9E453 +COMPONENT_TYPE = BS_DRIVER + +[sources.common] + WdtDxe.c + ../Common/WdtCommon.h + ../Common/WdtCommon.c + +# +# Edk II Glue Driver Entry Point +# + EdkIIGlueDxeDriverEntryPoint.c + + +[includes.common] + . + ../Common + $(EDK_SOURCE)/Foundation/Efi + $(EDK_SOURCE)/Foundation/Include + $(EDK_SOURCE)/Foundation/Efi/Include + $(EDK_SOURCE)/Foundation/Framework/Include + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT) + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include + $(EFI_SOURCE)/$(PROJECT_PCH_ROOT)/Include/Library +# +# EDK II Glue Library utilizes some standard headers from EDK +# + $(EFI_SOURCE) + $(EDK_SOURCE)/Foundation + $(EDK_SOURCE)/Foundation/Framework + $(EDK_SOURCE)/Foundation/Include/IndustryStandard + $(EDK_SOURCE)/Foundation/Core/Dxe + $(EDK_SOURCE)/Foundation/Include/Pei + $(EDK_SOURCE)/Foundation/Library/Dxe/Include + $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include + $(EDK_SOURCE)/Foundation/Library/EdkIIGlueLib/Include/Library + +[libraries.common] + EdkIIGlueBaseIoLibIntrinsic + EdkIIGlueBaseMemoryLib + EdkIIGlueBasePciLibPciExpress + EdkIIGlueDxeReportStatusCodeLib + EdkIIGlueDxeDebugLibReportStatusCode + EdkIIGlueUefiBootServicesTableLib + EdkIIGlueUefiRuntimeServicesTableLib + EdkIIGlueDxeServicesTableLib + EdkProtocolLib + EdkIIGlueDxeHobLib + $(PROJECT_PCH_FAMILY)ProtocolLib + EfiGuidLib + +[nmake.common] + IMAGE_ENTRY_POINT = _ModuleEntryPoint + DPX_SOURCE = WdtDxe.dxs +# +# Module Entry Point +# + C_FLAGS = $(C_FLAGS) -D __EDKII_GLUE_MODULE_ENTRY_POINT__=WdtDxeEntryPoint \ + -D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \ + -D __EDKII_GLUE_BASE_MEMORY_LIB__ \ + -D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \ + -D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \ + -D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__ \ + -D __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__ \ + -D __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ \ + -D __EDKII_GLUE_DXE_HOB_LIB__
\ No newline at end of file diff --git a/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.mak b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.mak new file mode 100644 index 0000000..a36f6cd --- /dev/null +++ b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.mak @@ -0,0 +1,102 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + +#************************************************************************* +# $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Refcode/Wdt/WdtDxe/WdtDxe.mak 3 9/26/12 3:43a Victortu $ +# +# $Revision: 3 $ +# +# $Date: 9/26/12 3:43a $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Refcode/Wdt/WdtDxe/WdtDxe.mak $ +# +# 3 9/26/12 3:43a Victortu +# Lynx Point PCH Chipset Framework Reference Code Beta 0.7.0 +# +# 2 2/24/12 2:31a Victortu +# Updated to support 4.6.5.3_IntelEDK_1117_Patch7_00. +# +# 1 2/08/12 9:32a Yurenlai +# Intel Lynx Point/SB eChipset initially releases. +# +#************************************************************************* +EDK : WdtDxe +WdtDxe : $(BUILD_DIR)\WdtDxe.mak WdtDxeBin + +$(BUILD_DIR)\WdtDxe.mak : $(WdtDxe_DIR)\$(@B).cif $(BUILD_RULES) + $(CIF2MAK) $(WdtDxe_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +WdtDxe_INCLUDES=\ + $(EdkIIGlueLib_INCLUDES)\ + $(INTEL_PCH_INCLUDES)\ + $(WdtCommonLib_INCLUDES) + +WdtDxe_LIBS=\ +!IF "$(x64_BUILD)"=="1" + $(EdkIIGlueBaseLibX64_LIB)\ +!ELSE + $(EdkIIGlueBaseLibIA32_LIB)\ +!ENDIF + $(EdkIIGlueBaseIoLibIntrinsic_LIB)\ + $(EdkIIGlueBaseMemoryLib_LIB)\ + $(EdkIIGlueBasePciLibPciExpress_LIB)\ + $(EdkIIGlueDxeReportStatusCodeLib_LIB)\ + $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\ + $(EdkIIGlueUefiBootServicesTableLib_LIB)\ + $(EdkIIGlueDxeServicesTableLib_LIB)\ + $(EDKPROTOCOLLIB)\ + $(EdkIIGlueDxeHobLib_LIB)\ + $(INTEL_PCH_PROTOCOL_LIB)\ + $(EFIGUIDLIB)\ + $(WdtCommonDxeLib_LIB) + +WdtDxe_DEFINES=\ + $(MY_DEFINES)\ + /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=WdtDxeEntryPoint"\ + /D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \ + /D __EDKII_GLUE_BASE_MEMORY_LIB__ \ + /D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \ + /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \ + /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\ + /D __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__\ + /D __EDKII_GLUE_DXE_HOB_LIB__ + +WdtDxeBin : $(WdtDxe_LIBS) + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + /f $(BUILD_DIR)\WdtDxe.mak all\ + "MY_INCLUDES=$(WdtDxe_INCLUDES)"\ + "MY_DEFINES=$(WdtDxe_DEFINES)"\ + GUID=5AAB83E5-F027-4ca7-BFD0-16358CC9E453\ + ENTRY_POINT=_ModuleEntryPoint \ + EDKIIModule=DXEDRIVER\ + TYPE=BS_DRIVER \ + DEPEX1=$(WdtDxe_DIR)\WdtDxe.dxs \ + DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX \ + COMPRESS=1 + +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* diff --git a/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.sdl b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.sdl new file mode 100644 index 0000000..edfd5a6 --- /dev/null +++ b/ReferenceCode/Chipset/LynxPoint/Wdt/Dxe/WdtDxe.sdl @@ -0,0 +1,68 @@ +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* + +#************************************************************************* +# $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Refcode/Wdt/WdtDxe/WdtDxe.sdl 1 2/08/12 9:32a Yurenlai $ +# +# $Revision: 1 $ +# +# $Date: 2/08/12 9:32a $ +#************************************************************************* +# Revision History +# ---------------- +# $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Refcode/Wdt/WdtDxe/WdtDxe.sdl $ +# +# 1 2/08/12 9:32a Yurenlai +# Intel Lynx Point/SB eChipset initially releases. +# +#************************************************************************* +TOKEN + Name = "WdtDxe_SUPPORT" + Value = "1" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Master = Yes + Help = "Main switch to enable ICC support in Project in DXE Phase" +End + +MODULE + Help = "Includes WdtDxe.mak to Project" + File = "WdtDxe.mak" +End + +PATH + Name = "WdtDxe_DIR" + Help = "Icc Support commands" +End + +ELINK + Name = "$(BUILD_DIR)\WdtDxe.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End +#************************************************************************* +#************************************************************************* +#** ** +#** (C)Copyright 1985-2011, American Megatrends, Inc. ** +#** ** +#** All Rights Reserved. ** +#** ** +#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 ** +#** ** +#** Phone: (770)-246-8600 ** +#** ** +#************************************************************************* +#************************************************************************* |