X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;ds=sidebyside;f=MdeModulePkg%2FUniversal%2FResetSystemRuntimeDxe%2FResetSystem.c;h=77aedcba6e04ad04b0427a2cb8e1c9fa29b8881e;hb=HEAD;hp=4c7107faeab1812ffc8354cea010bd497f8db3ba;hpb=e2531da3b861fe80c4b18d90b6b12a14c98eef81;p=mirror_edk2.git diff --git a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c index 4c7107faea..42f1b1d015 100644 --- a/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c +++ b/MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystem.c @@ -3,19 +3,13 @@ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.
- This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "ResetSystem.h" -GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = { +GLOBAL_REMOVE_IF_UNREFERENCED CHAR16 *mResetTypeStr[] = { L"Cold", L"Warm", L"Shutdown", L"PlatformSpecific" }; @@ -48,13 +42,13 @@ UINTN mResetNotifyDepth = 0; EFI_STATUS EFIAPI RegisterResetNotify ( - IN EFI_RESET_NOTIFICATION_PROTOCOL *This, - IN EFI_RESET_SYSTEM ResetFunction + IN EFI_RESET_NOTIFICATION_PROTOCOL *This, + IN EFI_RESET_SYSTEM ResetFunction ) { - RESET_NOTIFICATION_INSTANCE *Instance; - LIST_ENTRY *Link; - RESET_NOTIFY_ENTRY *Entry; + RESET_NOTIFICATION_INSTANCE *Instance; + LIST_ENTRY *Link; + RESET_NOTIFY_ENTRY *Entry; if (ResetFunction == NULL) { return EFI_INVALID_PARAMETER; @@ -63,9 +57,10 @@ RegisterResetNotify ( Instance = RESET_NOTIFICATION_INSTANCE_FROM_THIS (This); for ( Link = GetFirstNode (&Instance->ResetNotifies) - ; !IsNull (&Instance->ResetNotifies, Link) - ; Link = GetNextNode (&Instance->ResetNotifies, Link) - ) { + ; !IsNull (&Instance->ResetNotifies, Link) + ; Link = GetNextNode (&Instance->ResetNotifies, Link) + ) + { Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link); if (Entry->ResetNotify == ResetFunction) { return EFI_ALREADY_STARTED; @@ -77,6 +72,7 @@ RegisterResetNotify ( if (Entry == NULL) { return EFI_OUT_OF_RESOURCES; } + Entry->Signature = RESET_NOTIFY_ENTRY_SIGNATURE; Entry->ResetNotify = ResetFunction; InsertTailList (&Instance->ResetNotifies, &Entry->Link); @@ -101,13 +97,13 @@ RegisterResetNotify ( EFI_STATUS EFIAPI UnregisterResetNotify ( - IN EFI_RESET_NOTIFICATION_PROTOCOL *This, - IN EFI_RESET_SYSTEM ResetFunction + IN EFI_RESET_NOTIFICATION_PROTOCOL *This, + IN EFI_RESET_SYSTEM ResetFunction ) { - RESET_NOTIFICATION_INSTANCE *Instance; - LIST_ENTRY *Link; - RESET_NOTIFY_ENTRY *Entry; + RESET_NOTIFICATION_INSTANCE *Instance; + LIST_ENTRY *Link; + RESET_NOTIFY_ENTRY *Entry; if (ResetFunction == NULL) { return EFI_INVALID_PARAMETER; @@ -116,9 +112,10 @@ UnregisterResetNotify ( Instance = RESET_NOTIFICATION_INSTANCE_FROM_THIS (This); for ( Link = GetFirstNode (&Instance->ResetNotifies) - ; !IsNull (&Instance->ResetNotifies, Link) - ; Link = GetNextNode (&Instance->ResetNotifies, Link) - ) { + ; !IsNull (&Instance->ResetNotifies, Link) + ; Link = GetNextNode (&Instance->ResetNotifies, Link) + ) + { Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link); if (Entry->ResetNotify == ResetFunction) { RemoveEntryList (&Entry->Link); @@ -130,7 +127,7 @@ UnregisterResetNotify ( return EFI_INVALID_PARAMETER; } -RESET_NOTIFICATION_INSTANCE mResetNotification = { +RESET_NOTIFICATION_INSTANCE mResetNotification = { RESET_NOTIFICATION_INSTANCE_SIGNATURE, { RegisterResetNotify, @@ -139,7 +136,7 @@ RESET_NOTIFICATION_INSTANCE mResetNotification = { INITIALIZE_LIST_HEAD_VARIABLE (mResetNotification.ResetNotifies) }; -RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetFilter = { +RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetFilter = { RESET_NOTIFICATION_INSTANCE_SIGNATURE, { RegisterResetNotify, @@ -148,7 +145,7 @@ RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetFilter = { INITIALIZE_LIST_HEAD_VARIABLE (mPlatformSpecificResetFilter.ResetNotifies) }; -RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetHandler = { +RESET_NOTIFICATION_INSTANCE mPlatformSpecificResetHandler = { RESET_NOTIFICATION_INSTANCE_SIGNATURE, { RegisterResetNotify, @@ -195,10 +192,14 @@ InitializeResetSystem ( Handle = NULL; Status = gBS->InstallMultipleProtocolInterfaces ( &Handle, - &gEfiResetArchProtocolGuid, NULL, - &gEfiResetNotificationProtocolGuid, &mResetNotification.ResetNotification, - &gEdkiiPlatformSpecificResetFilterProtocolGuid, &mPlatformSpecificResetFilter.ResetNotification, - &gEdkiiPlatformSpecificResetHandlerProtocolGuid, &mPlatformSpecificResetHandler.ResetNotification, + &gEfiResetArchProtocolGuid, + NULL, + &gEfiResetNotificationProtocolGuid, + &mResetNotification.ResetNotification, + &gEdkiiPlatformSpecificResetFilterProtocolGuid, + &mPlatformSpecificResetFilter.ResetNotification, + &gEdkiiPlatformSpecificResetHandlerProtocolGuid, + &mPlatformSpecificResetHandler.ResetNotification, NULL ); ASSERT_EFI_ERROR (Status); @@ -206,22 +207,6 @@ InitializeResetSystem ( return Status; } -/** - Put the system into S3 power state. -**/ -VOID -DoS3 ( - VOID - ) -{ - EnterS3WithImmediateWake (); - - // - // Should not return - // - CpuDeadLoop (); -} - /** Resets the entire platform. @@ -232,10 +217,7 @@ DoS3 ( EfiResetShutdown the data buffer starts with a Null-terminated string, optionally followed by additional binary data. The string is a description that the caller may use to further - indicate the reason for the system reset. ResetData is only - valid if ResetStatus is something other than EFI_SUCCESS - unless the ResetType is EfiResetPlatformSpecific - where a minimum amount of ResetData is always required. + indicate the reason for the system reset. For a ResetType of EfiResetPlatformSpecific the data buffer also starts with a Null-terminated string that is followed by an EFI_GUID that describes the specific type of reset to perform. @@ -243,15 +225,12 @@ DoS3 ( VOID EFIAPI RuntimeServiceResetSystem ( - IN EFI_RESET_TYPE ResetType, - IN EFI_STATUS ResetStatus, - IN UINTN DataSize, - IN VOID *ResetData OPTIONAL + IN EFI_RESET_TYPE ResetType, + IN EFI_STATUS ResetStatus, + IN UINTN DataSize, + IN VOID *ResetData OPTIONAL ) { - EFI_STATUS Status; - UINTN Size; - UINTN CapsuleDataPtr; LIST_ENTRY *Link; RESET_NOTIFY_ENTRY *Entry; @@ -267,8 +246,10 @@ RuntimeServiceResetSystem ( mResetNotifyDepth++; DEBUG (( - DEBUG_INFO, "DXE ResetSystem2: ResetType %s, Call Depth = %d.\n", - mResetTypeStr[ResetType], mResetNotifyDepth + DEBUG_INFO, + "DXE ResetSystem2: ResetType %s, Call Depth = %d.\n", + mResetTypeStr[ResetType], + mResetNotifyDepth )); if (mResetNotifyDepth <= MAX_RESET_NOTIFY_DEPTH) { @@ -278,31 +259,36 @@ RuntimeServiceResetSystem ( // EDKII_PLATFORM_SPECIFIC_RESET_FILTER_PROTOCOL. // for ( Link = GetFirstNode (&mPlatformSpecificResetFilter.ResetNotifies) - ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link) - ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link) - ) { + ; !IsNull (&mPlatformSpecificResetFilter.ResetNotifies, Link) + ; Link = GetNextNode (&mPlatformSpecificResetFilter.ResetNotifies, Link) + ) + { Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link); Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); } + // // Call reset notification functions registered through the // EFI_RESET_NOTIFICATION_PROTOCOL. // for ( Link = GetFirstNode (&mResetNotification.ResetNotifies) - ; !IsNull (&mResetNotification.ResetNotifies, Link) - ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link) - ) { + ; !IsNull (&mResetNotification.ResetNotifies, Link) + ; Link = GetNextNode (&mResetNotification.ResetNotifies, Link) + ) + { Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link); Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); } + // // call reset notification functions registered through the // EDKII_PLATFORM_SPECIFIC_RESET_HANDLER_PROTOCOL. // for ( Link = GetFirstNode (&mPlatformSpecificResetHandler.ResetNotifies) - ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link) - ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link) - ) { + ; !IsNull (&mPlatformSpecificResetHandler.ResetNotifies, Link) + ; Link = GetNextNode (&mPlatformSpecificResetHandler.ResetNotifies, Link) + ) + { Entry = RESET_NOTIFY_ENTRY_FROM_LINK (Link); Entry->ResetNotify (ResetType, ResetStatus, DataSize, ResetData); } @@ -313,44 +299,25 @@ RuntimeServiceResetSystem ( } switch (ResetType) { - case EfiResetWarm: - - // - //Check if there are pending capsules to process - // - Size = sizeof (CapsuleDataPtr); - Status = EfiGetVariable ( - EFI_CAPSULE_VARIABLE_NAME, - &gEfiCapsuleVendorGuid, - NULL, - &Size, - (VOID *) &CapsuleDataPtr - ); - - if (Status == EFI_SUCCESS) { - // - //Process capsules across a system reset. - // - DoS3(); - } + case EfiResetWarm: - ResetWarm (); - break; + ResetWarm (); + break; - case EfiResetCold: - ResetCold (); - break; + case EfiResetCold: + ResetCold (); + break; - case EfiResetShutdown: - ResetShutdown (); - return ; + case EfiResetShutdown: + ResetShutdown (); + return; - case EfiResetPlatformSpecific: - ResetPlatformSpecific (DataSize, ResetData); - return; + case EfiResetPlatformSpecific: + ResetPlatformSpecific (DataSize, ResetData); + return; - default: - return ; + default: + return; } //