public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Ruiyu Ni <ruiyu.ni@intel.com>
To: edk2-devel@lists.01.org
Cc: HuajingLi <huajing.li@intel.com>
Subject: [PATCH] Nt32Pkg: Add the ResetSystemLib in Nt32 Platform.
Date: Tue, 25 Jul 2017 17:05:27 +0800	[thread overview]
Message-ID: <20170725090527.22460-1-ruiyu.ni@intel.com> (raw)

From: HuajingLi <huajing.li@intel.com>

Signed-off-by: Huajing Li <huajing.li@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
---
 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.<BR>
+  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 <Uefi.h>
+#include <Library/DebugLib.h>
+#include <Library/WinNtLib.h>
+
+/**
+  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.<BR>
+#  
+#  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
 #
 #  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.<BR>
-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 <Uefi.h>
-#include <WinNtDxe.h>
-#include <Protocol/Reset.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/WinNtLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-
-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



                 reply	other threads:[~2017-07-25  9:03 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170725090527.22460-1-ruiyu.ni@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox