From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E3BE121CE7481 for ; Tue, 25 Jul 2017 02:03:35 -0700 (PDT) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Jul 2017 02:05:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,411,1496127600"; d="scan'208";a="1176184138" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.7]) by fmsmga001.fm.intel.com with ESMTP; 25 Jul 2017 02:05:32 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: HuajingLi Date: Tue, 25 Jul 2017 17:05:27 +0800 Message-Id: <20170725090527.22460-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [PATCH] Nt32Pkg: Add the ResetSystemLib in Nt32 Platform. X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 25 Jul 2017 09:03:36 -0000 From: HuajingLi Signed-off-by: Huajing Li Reviewed-by: Ruiyu Ni --- Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c | 98 ++++++++++++++++ .../ResetSystemLib/ResetSystemLib.inf} | 27 ++--- Nt32Pkg/Nt32Pkg.dsc | 3 +- Nt32Pkg/Nt32Pkg.fdf | 2 +- Nt32Pkg/ResetRuntimeDxe/reset.c | 126 --------------------- 5 files changed, 108 insertions(+), 148 deletions(-) create mode 100644 Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c rename Nt32Pkg/{ResetRuntimeDxe/ResetRuntimeDxe.inf => Library/ResetSystemLib/ResetSystemLib.inf} (54%) delete mode 100644 Nt32Pkg/ResetRuntimeDxe/reset.c diff --git a/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c b/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c new file mode 100644 index 0000000000..743b61cbb9 --- /dev/null +++ b/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.c @@ -0,0 +1,98 @@ +/** @file + + Copyright (c) 2017, 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. + +**/ +#include +#include +#include + +/** + This function causes a system-wide reset (cold reset), in which + all circuitry within the system returns to its initial state. This type of reset + is asynchronous to system operation and operates without regard to + cycle boundaries. + + If this function returns, it means that the system does not support cold reset. +**/ +VOID +EFIAPI +ResetCold ( + VOID + ) +{ + gWinNt->ExitProcess (0); + ASSERT (FALSE); +} + +/** + This function causes a system-wide initialization (warm reset), in which all processors + are set to their initial state. Pending cycles are not corrupted. + + If this function returns, it means that the system does not support warm reset. +**/ +VOID +EFIAPI +ResetWarm ( + VOID + ) +{ + ResetCold (); +} + +/** + This function causes the system to enter a power state equivalent + to the ACPI G2/S5 or G3 states. + + If this function returns, it means that the system does not support shut down reset. +**/ +VOID +EFIAPI +ResetShutdown ( + VOID + ) +{ + ResetCold (); +} + +/** + This function causes the system to enter S3 and then wake up immediately. + + If this function returns, it means that the system does not support S3 feature. +**/ +VOID +EFIAPI +EnterS3WithImmediateWake ( + VOID + ) +{ + ResetCold (); +} + +/** + This function causes a systemwide reset. The exact type of the reset is + defined by the EFI_GUID that follows the Null-terminated Unicode string passed + into ResetData. If the platform does not recognize the EFI_GUID in ResetData + the platform must pick a supported reset type to perform.The platform may + optionally log the parameters from any non-normal reset that occurs. + + @param[in] DataSize The size, in bytes, of ResetData. + @param[in] ResetData The data buffer starts with a Null-terminated string, + followed by the EFI_GUID. +**/ +VOID +EFIAPI +ResetPlatformSpecific ( + IN UINTN DataSize, + IN VOID *ResetData + ) +{ + ResetCold (); +} diff --git a/Nt32Pkg/ResetRuntimeDxe/ResetRuntimeDxe.inf b/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf similarity index 54% rename from Nt32Pkg/ResetRuntimeDxe/ResetRuntimeDxe.inf rename to Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf index 4e21e21afb..b39f63ab6f 100644 --- a/Nt32Pkg/ResetRuntimeDxe/ResetRuntimeDxe.inf +++ b/Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf @@ -1,8 +1,6 @@ ## @file -# NT Emulation Reset Architectural Protocol Driver as defined in TIANO -# -# This Reset module simulates system reset by process exit on NT. -# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+# +# Copyright (c) 2017, 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 @@ -11,17 +9,15 @@ # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # -# ## [Defines] INF_VERSION = 0x00010005 - BASE_NAME = Reset - FILE_GUID = BA929954-35B0-4dd3-90CD-9634BD7E1CF1 - MODULE_TYPE = DXE_DRIVER + BASE_NAME = Nt32ResetSystemLib + FILE_GUID = A7EBA1F6-5505-4fba-8895-386EE02B2FAC + MODULE_TYPE = BASE VERSION_STRING = 1.0 - - ENTRY_POINT = InitializeNtReset + LIBRARY_CLASS = ResetSystemLib # # The following information is for reference only and not required by the build tools. @@ -30,21 +26,12 @@ [Defines] # [Sources] - reset.c + ResetSystemLib.c [Packages] MdePkg/MdePkg.dec Nt32Pkg/Nt32Pkg.dec [LibraryClasses] - UefiBootServicesTableLib WinNtLib - UefiDriverEntryPoint DebugLib - -[Protocols] - gEfiResetArchProtocolGuid # PROTOCOL ALWAYS_PRODUCED - -[Depex] - TRUE - diff --git a/Nt32Pkg/Nt32Pkg.dsc b/Nt32Pkg/Nt32Pkg.dsc index fa3446be06..00848907cf 100644 --- a/Nt32Pkg/Nt32Pkg.dsc +++ b/Nt32Pkg/Nt32Pkg.dsc @@ -167,6 +167,7 @@ [LibraryClasses] CpuExceptionHandlerLib|MdeModulePkg/Library/CpuExceptionHandlerLibNull/CpuExceptionHandlerLibNull.inf LockBoxLib|MdeModulePkg/Library/LockBoxNullLib/LockBoxNullLib.inf IntrinsicLib|CryptoPkg/Library/IntrinsicLib/IntrinsicLib.inf + ResetSystemLib|Nt32Pkg/Library/ResetSystemLib/ResetSystemLib.inf !if $(TLS_ENABLE) == TRUE OpensslLib|CryptoPkg/Library/OpensslLib/OpensslLib.inf !else @@ -394,7 +395,7 @@ [Components] } Nt32Pkg/MetronomeDxe/MetronomeDxe.inf Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf - Nt32Pkg/ResetRuntimeDxe/ResetRuntimeDxe.inf + MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf { diff --git a/Nt32Pkg/Nt32Pkg.fdf b/Nt32Pkg/Nt32Pkg.fdf index ffa4b0a4a5..e03999b0cb 100644 --- a/Nt32Pkg/Nt32Pkg.fdf +++ b/Nt32Pkg/Nt32Pkg.fdf @@ -200,7 +200,7 @@ [FV.FvRecovery] INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf INF Nt32Pkg/MetronomeDxe/MetronomeDxe.inf INF Nt32Pkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf -INF Nt32Pkg/ResetRuntimeDxe/ResetRuntimeDxe.inf +INF MdeModulePkg/Universal/ResetSystemRuntimeDxe/ResetSystemRuntimeDxe.inf INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf INF Nt32Pkg/FvbServicesRuntimeDxe/FvbServicesRuntimeDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf diff --git a/Nt32Pkg/ResetRuntimeDxe/reset.c b/Nt32Pkg/ResetRuntimeDxe/reset.c deleted file mode 100644 index 468f7128fb..0000000000 --- a/Nt32Pkg/ResetRuntimeDxe/reset.c +++ /dev/null @@ -1,126 +0,0 @@ -/**@file - -Copyright (c) 2006, 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. - -Module Name: - - Reset.c - -Abstract: - - Reset Architectural Protocol as defined in Tiano under NT Emulation - -**/ - -#include -#include -#include -#include -#include -#include -#include - - -EFI_STATUS -EFIAPI -InitializeNtReset ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ); - -VOID -EFIAPI -WinNtResetSystem ( - IN EFI_RESET_TYPE ResetType, - IN EFI_STATUS ResetStatus, - IN UINTN DataSize, - IN VOID *ResetData OPTIONAL - ); - - -EFI_STATUS -EFIAPI -InitializeNtReset ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable - ) -/*++ - -Routine Description: - - -Arguments: - - ImageHandle of the loaded driver - Pointer to the System Table - -Returns: - - Status ---*/ -// TODO: SystemTable - add argument and description to function comment -{ - EFI_STATUS Status; - EFI_HANDLE Handle; - - SystemTable->RuntimeServices->ResetSystem = WinNtResetSystem; - - Handle = NULL; - Status = gBS->InstallMultipleProtocolInterfaces ( - &Handle, - &gEfiResetArchProtocolGuid, - NULL, - NULL - ); - ASSERT_EFI_ERROR (Status); - - return Status; -} - -VOID -EFIAPI -WinNtResetSystem ( - IN EFI_RESET_TYPE ResetType, - IN EFI_STATUS ResetStatus, - IN UINTN DataSize, - IN VOID *ResetData OPTIONAL - ) -/*++ - -Routine Description: - - TODO: Add function description - -Arguments: - - ResetType - TODO: add argument description - ResetStatus - TODO: add argument description - DataSize - TODO: add argument description - ResetData - TODO: add argument description - -Returns: - - EFI_SUCCESS - TODO: Add description for return value - ---*/ -{ - // - // BUGBUG Need to kill all console windows later - // - // - // Discard ResetType, always return 0 as exit code - // - gWinNt->ExitProcess (0); - - // - // Should never go here - // - ASSERT (FALSE); -} -- 2.12.2.windows.2