diff options
Diffstat (limited to 'ReferenceCode/ME/SampleCode/PlatformReset')
6 files changed, 343 insertions, 0 deletions
diff --git a/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.c b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.c new file mode 100644 index 0000000..55cdf11 --- /dev/null +++ b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.c @@ -0,0 +1,168 @@ +/** @file + Provide the ResetSystem AP + +@copyright + Copyright (c) 2011 - 2013 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 +**/ +#include "PlatformReset.h" +#include "MeLib.h" +PCH_RESET_PROTOCOL *mPchReset; + +/** + Reset the system + + @param[in] ResetType Warm or cold + @param[in] ResetStatus Possible cause of reset + @param[in] DataSize Size of ResetData in bytes + @param[in] ResetData Optional Unicode string + + @retval Does not return if the reset takes place. +**/ +VOID +EFIAPI +PlatformResetSystem ( + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN CHAR16 *ResetData OPTIONAL + ) +{ + EFI_STATUS Status; + ME_PLATFORM_GET_RESET_TYPE_PROTOCOL *MePlatformGetResetType; + PCH_RESET_TYPE OverridePchResetType; + PCH_RESET_TYPE PchResetType; + UINTN NumberMePlatformGetResetHandles; + EFI_HANDLE *MePlatformGetResetHandles; + UINTN Index; + + PchResetType = ResetType; + OverridePchResetType = ResetType; + + if (!EfiAtRuntime ()) { + Status = gBS->LocateHandleBuffer ( + ByProtocol, + &gMePlatformGetResetTypeGuid, + NULL, + &NumberMePlatformGetResetHandles, + &MePlatformGetResetHandles + ); + if (!EFI_ERROR (Status)) { + for (Index = 0; Index < NumberMePlatformGetResetHandles; Index++) { + Status = gBS->HandleProtocol ( + MePlatformGetResetHandles[Index], + &gMePlatformGetResetTypeGuid, + (VOID **) &MePlatformGetResetType + ); + if (!EFI_ERROR (Status)) { + PchResetType = MePlatformGetResetType->GetResetType (ResetType); + DEBUG ((EFI_D_INFO, "Returned Pch ResetType is: %x\n", PchResetType)); + if (PchResetType >= MaxRestReq) { + DEBUG ((EFI_D_ERROR, "Platform Reset failed, invalid parameter\n")); + ASSERT (FALSE); + } + if (OverridePchResetType < PchResetType) { + DEBUG ((EFI_D_INFO, "Previous Pch ResetType is: %x\n", OverridePchResetType)); + OverridePchResetType = PchResetType; + } + DEBUG ((EFI_D_INFO, "Current Pch ResetType is: %x\n", OverridePchResetType)); + } + } + } + PchResetType = OverridePchResetType; + if ((PchResetType == GlobalReset) || (PchResetType == GlobalResetWithEc)) { + /// + /// Let ME do global reset if Me Fw is available + /// + Status = HeciSendCbmResetRequest (CBM_RR_REQ_ORIGIN_BIOS_POST, CBM_HRR_GLOBAL_RESET); + if (!EFI_ERROR (Status)) { + /// + /// ME Global Reset should fail after EOP is sent. + /// Go to use PCH Reset + /// + gBS->Stall (1000000); + } + } + } + + mPchReset->Reset (mPchReset, PchResetType); + + ASSERT (FALSE); +} + +/** + Entry point of Platform Reset driver. + + @param[in] ImageHandle Standard entry point parameter + @param[in] SystemTable Standard entry point parameter + + @retval EFI_SUCCESS Reset RT protocol installed + @retval All other error conditions encountered result in an ASSERT +**/ +EFI_STATUS +InitializePlatformReset ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_HANDLE Handle; + EFI_STATUS Status; + + Status = gBS->LocateProtocol (&gPchResetProtocolGuid, NULL, (VOID **) &mPchReset); + ASSERT_EFI_ERROR (Status); + + /// + /// Make sure the Reset Architectural Protocol is not already installed in the system + /// + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid); + + /// + /// Hook the runtime service table + /// + SystemTable->RuntimeServices->ResetSystem = PlatformResetSystem; + + /// + /// Now install the Reset RT AP on a new handle + /// + Handle = NULL; + Status = gBS->InstallMultipleProtocolInterfaces ( + &Handle, + &gEfiResetArchProtocolGuid, + NULL, + NULL + ); + ASSERT_EFI_ERROR (Status); + + return Status; +} + +/** + Fixup internal data pointers so that the services can be called in virtual mode. + + @param[in] Event The event registered. + @param[in] Context Event context. Not used in this event handler. + + @retval None +**/ +EFI_RUNTIMESERVICE +VOID +PchResetVirtualddressChangeEvent ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + gRT->ConvertPointer (EFI_INTERNAL_POINTER, (VOID *) &mPchReset); +} diff --git a/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.cif b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.cif new file mode 100644 index 0000000..6403a09 --- /dev/null +++ b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.cif @@ -0,0 +1,12 @@ +<component> + name = "PlatformReset" + category = ModulePart + LocalRoot = "ReferenceCode\ME\SampleCode\PlatformReset\RuntimeDxe" + RefName = "PlatformReset" +[files] +"PlatformReset.sdl" +"PlatformReset.mak" +"PlatformReset.h" +"PlatformReset.c" +"PlatformReset.dxs" +<endComponent> diff --git a/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.dxs b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.dxs new file mode 100644 index 0000000..62919fa --- /dev/null +++ b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.dxs @@ -0,0 +1,41 @@ +/** @file + Dependency expression source file. + +@copyright + Copyright (c) 2011 - 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 + +**/ + + +// +// Common for R8 and R9 codebase +// +#include "AutoGen.h" +#include "DxeDepex.h" + +// +// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are both "defined" in R8 codebase; +// BUILD_WITH_EDKII_GLUE_LIB is defined in Edk-Dev-Snapshot-20070228 and later version +// BUILD_WITH_GLUELIB and BUILD_WITH_EDKII_GLUE_LIB are "not defined" in R9 codebase. +// +#if defined (BUILD_WITH_GLUELIB) || defined (BUILD_WITH_EDKII_GLUE_LIB) +#include "EfiDepex.h" +#include EFI_PROTOCOL_DEFINITION (PchReset) +#endif + +DEPENDENCY_START + PCH_RESET_PROTOCOL_GUID +DEPENDENCY_END + diff --git a/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.h b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.h new file mode 100644 index 0000000..9847b5e --- /dev/null +++ b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.h @@ -0,0 +1,29 @@ +/** @file + Definitions for PlatformReset driver + +@copyright + Copyright (c) 2011 - 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 +**/ +#ifndef _PLATFORM_RESET_H_ +#define _PLATFORM_RESET_H_ + +#include "EdkIIGlueDxe.h" +#include EFI_PROTOCOL_CONSUMER (PchReset) +#include EFI_PROTOCOL_CONSUMER (MePlatformGetResetType) +#include EFI_ARCH_PROTOCOL_DEFINITION (Reset) + +#endif // _PLATFORM_RESET_H_ diff --git a/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.mak b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.mak new file mode 100644 index 0000000..7ad1b51 --- /dev/null +++ b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.mak @@ -0,0 +1,67 @@ +#--------------------------------------------------------------------------- +# Create PlatformReset Driver +#--------------------------------------------------------------------------- + +All : PlatformReset + +PlatformReset : $(BUILD_DIR)\PlatformReset.mak PlatformResetBin + +$(BUILD_DIR)\PlatformReset.mak : $(PlatformReset_DIR)\$(@B).cif $(PlatformReset_DIR)\$(@B).mak $(BUILD_RULES) + $(CIF2MAK) $(PlatformReset_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) + +PlatformReset_INCLUDES=\ + $(ME_INCLUDES) \ + /I$(ME_DIR)\SampleCode \ + $(INTEL_PCH_INCLUDES)\ + $(EdkIIGlueLib_INCLUDES)\ + +PlatformReset_DEFINES = $(MY_DEFINES)\ + /D"__EDKII_GLUE_MODULE_ENTRY_POINT__=InitializePlatformReset"\ + /D"__EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__=PchResetVirtualddressChangeEvent"\ + /D __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__ \ + /D __EDKII_GLUE_BASE_LIB__ \ + /D __EDKII_GLUE_BASE_MEMORY_LIB__ \ + /D __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__ \ + /D __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__ \ + /D __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__ \ + /D __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__\ + +PlatformReset_LIBS=\ + $(MeLibDxe_LIB)\ + $(MeSampleCodeProtocolLib_LIB)\ + $(INTEL_PCH_PROTOCOL_LIB)\ + $(EDKPROTOCOLLIB)\ + $(EDKFRAMEWORKPROTOCOLLIB)\ + $(IntelMpgProtocolLib_LIB)\ + $(EdkIIGlueBaseLib_LIB)\ + $(EdkIIGlueBaseIoLibIntrinsic_LIB)\ +!IF "$(x64_BUILD)"=="1" + $(EdkIIGlueBaseLibX64_LIB)\ +!ELSE + $(EdkIIGlueBaseLibIA32_LIB)\ +!ENDIF + $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\ + $(EdkIIGlueUefiBootServicesTableLib_LIB)\ + $(EdkIIGlueDxeServicesTableLib_LIB)\ + $(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)\ + $(EdkIIGlueDxeReportStatusCodeLib_LIB)\ + $(MePlatformGetResetTypeProtocolLib_LIB) +# $(EFIDRIVERLIB)\ +# $(EdkIIGlueUefiRuntimeServicesTableLib_LIB)\ +# $(EdkIIGlueDxeDebugLibReportStatusCode_LIB)\ + + +PlatformResetBin : $(PlatformReset_LIBS) + $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\ + /f $(BUILD_DIR)\PlatformReset.mak all \ + GUID=9A9A912B-5F53-4586-8820-704485A29D21\ + "MY_INCLUDES=$(PlatformReset_INCLUDES)"\ + "MY_DEFINES=$(PlatformReset_DEFINES)"\ + ENTRY_POINT=_ModuleEntryPoint\ + TYPE=RT_DRIVER\ + EDKIIModule=DXEDRIVER\ + DEPEX1=$(PlatformReset_DIR)\PlatformReset.dxs\ + DEPEX1_TYPE=EFI_SECTION_DXE_DEPEX\ + COMPRESS=1 + + diff --git a/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.sdl b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.sdl new file mode 100644 index 0000000..97fc45e --- /dev/null +++ b/ReferenceCode/ME/SampleCode/PlatformReset/RuntimeDxe/PlatformReset.sdl @@ -0,0 +1,26 @@ +TOKEN + Name = "PlatformReset_SUPPORT" + Value = "1" + Help = "Main switch to enable PlatformReset support in Project" + TokenType = Boolean + TargetEQU = Yes + TargetMAK = Yes + TargetH = Yes + Master = Yes +End + +PATH + Name = "PlatformReset_DIR" +End + +MODULE + Help = "Includes PlatformReset.mak to Project" + File = "PlatformReset.mak" +End + +ELINK + Name = "$(BUILD_DIR)\PlatformReset.ffs" + Parent = "FV_MAIN" + InvokeOrder = AfterParent +End + |