]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/ResetSystemLib: factor out ResetShutdown()
authorLaszlo Ersek <lersek@redhat.com>
Fri, 17 Apr 2020 15:37:49 +0000 (17:37 +0200)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 22 Apr 2020 19:42:32 +0000 (19:42 +0000)
Move the ResetShutdown() definition to its own file. This will help us
introduce:

- a new library instance that is not broken in runtime modules (the
  current library instance is broken in runtime modules),

- another new library instance for bhyve support.

While at it, squash AcpiPmControl() into ResetShutdown(), open-coding
SuspendType=0. This is justified because we've had no other callers for
AcpiPmControl() since commit 2d9950a2bff8 ("OvmfPkg: remove
EnterS3WithImmediateWake () from ResetSystemLib", 2020-01-10).

Tested with the "reset -s" UEFI shell command, on both i440fx and q35.

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2675
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20200417153751.7110-5-lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
OvmfPkg/Library/ResetSystemLib/ResetShutdown.c [new file with mode: 0644]
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf

diff --git a/OvmfPkg/Library/ResetSystemLib/ResetShutdown.c b/OvmfPkg/Library/ResetSystemLib/ResetShutdown.c
new file mode 100644 (file)
index 0000000..971d94f
--- /dev/null
@@ -0,0 +1,51 @@
+/** @file\r
+  Reset System Library Shutdown API implementation for OVMF.\r
+\r
+  Copyright (C) 2020, Red Hat, Inc.\r
+  Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+**/\r
+\r
+#include <Base.h>                   // BIT13\r
+\r
+#include <Library/BaseLib.h>        // CpuDeadLoop()\r
+#include <Library/DebugLib.h>       // ASSERT()\r
+#include <Library/IoLib.h>          // IoOr16()\r
+#include <Library/PciLib.h>         // PciRead16()\r
+#include <Library/ResetSystemLib.h> // ResetShutdown()\r
+#include <OvmfPlatforms.h>          // OVMF_HOSTBRIDGE_DID\r
+\r
+/**\r
+  Calling this function causes the system to enter a power state equivalent\r
+  to the ACPI G2/S5 or G3 states.\r
+\r
+  System shutdown should not return, if it returns, it means the system does\r
+  not support shut down reset.\r
+**/\r
+VOID\r
+EFIAPI\r
+ResetShutdown (\r
+  VOID\r
+  )\r
+{\r
+  UINT16 AcpiPmBaseAddress;\r
+  UINT16 HostBridgeDevId;\r
+\r
+  AcpiPmBaseAddress = 0;\r
+  HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
+  switch (HostBridgeDevId) {\r
+  case INTEL_82441_DEVICE_ID:\r
+    AcpiPmBaseAddress = PIIX4_PMBA_VALUE;\r
+    break;\r
+  case INTEL_Q35_MCH_DEVICE_ID:\r
+    AcpiPmBaseAddress = ICH9_PMBASE_VALUE;\r
+    break;\r
+  default:\r
+    ASSERT (FALSE);\r
+    CpuDeadLoop ();\r
+  }\r
+\r
+  IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, 0);\r
+  IoOr16 (AcpiPmBaseAddress + 4, BIT13);\r
+  CpuDeadLoop ();\r
+}\r
index 0fc142325ecead8aa6998a2295e808102a712c26..fe51f53d1df2d057aeb959fb7161e579b4359f13 100644 (file)
@@ -9,41 +9,9 @@
 #include <Base.h>                   // BIT1\r
 \r
 #include <Library/BaseLib.h>        // CpuDeadLoop()\r
-#include <Library/DebugLib.h>       // ASSERT()\r
 #include <Library/IoLib.h>          // IoWrite8()\r
-#include <Library/PciLib.h>         // PciRead16()\r
 #include <Library/ResetSystemLib.h> // ResetCold()\r
 #include <Library/TimerLib.h>       // MicroSecondDelay()\r
-#include <OvmfPlatforms.h>          // OVMF_HOSTBRIDGE_DID\r
-\r
-VOID\r
-AcpiPmControl (\r
-  UINTN SuspendType\r
-  )\r
-{\r
-  UINT16 AcpiPmBaseAddress;\r
-  UINT16 HostBridgeDevId;\r
-\r
-  ASSERT (SuspendType < 6);\r
-\r
-  AcpiPmBaseAddress = 0;\r
-  HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);\r
-  switch (HostBridgeDevId) {\r
-  case INTEL_82441_DEVICE_ID:\r
-    AcpiPmBaseAddress = PIIX4_PMBA_VALUE;\r
-    break;\r
-  case INTEL_Q35_MCH_DEVICE_ID:\r
-    AcpiPmBaseAddress = ICH9_PMBASE_VALUE;\r
-    break;\r
-  default:\r
-    ASSERT (FALSE);\r
-    CpuDeadLoop ();\r
-  }\r
-\r
-  IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType);\r
-  IoOr16 (AcpiPmBaseAddress + 4, BIT13);\r
-  CpuDeadLoop ();\r
-}\r
 \r
 /**\r
   Calling this function causes a system-wide reset. This sets\r
@@ -84,23 +52,6 @@ ResetWarm (
   CpuDeadLoop ();\r
 }\r
 \r
-/**\r
-  Calling this function causes the system to enter a power state equivalent\r
-  to the ACPI G2/S5 or G3 states.\r
-\r
-  System shutdown should not return, if it returns, it means the system does\r
-  not support shut down reset.\r
-**/\r
-VOID\r
-EFIAPI\r
-ResetShutdown (\r
-  VOID\r
-  )\r
-{\r
-  AcpiPmControl (0);\r
-  ASSERT (FALSE);\r
-}\r
-\r
 \r
 /**\r
   This function causes a systemwide reset. The exact type of the reset is\r
index af20f516c03537c55da58aca022d6f92afc54a31..9362f884f12423ced95f13f72c8e13865f825dba 100644 (file)
@@ -22,6 +22,7 @@
 #\r
 \r
 [Sources]\r
+  ResetShutdown.c\r
   ResetSystemLib.c\r
 \r
 [Packages]\r