From: "Laszlo Ersek" <lersek@redhat.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: "Ard Biesheuvel" <ard.biesheuvel@arm.com>,
"Jordan Justen" <jordan.l.justen@intel.com>,
"Philippe Mathieu-Daudé" <philmd@redhat.com>,
"Rebecca Cran" <rebecca@bsdio.com>
Subject: [PATCH 4/6] OvmfPkg/ResetSystemLib: factor out ResetShutdown()
Date: Fri, 17 Apr 2020 17:37:49 +0200 [thread overview]
Message-ID: <20200417153751.7110-5-lersek@redhat.com> (raw)
In-Reply-To: <20200417153751.7110-1-lersek@redhat.com>
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>
---
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf | 1 +
OvmfPkg/Library/ResetSystemLib/ResetShutdown.c | 51 ++++++++++++++++++++
OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c | 49 -------------------
3 files changed, 52 insertions(+), 49 deletions(-)
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
index af20f516c035..9362f884f124 100644
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
+++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.inf
@@ -22,6 +22,7 @@ [Defines]
#
[Sources]
+ ResetShutdown.c
ResetSystemLib.c
[Packages]
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetShutdown.c b/OvmfPkg/Library/ResetSystemLib/ResetShutdown.c
new file mode 100644
index 000000000000..971d94fa5766
--- /dev/null
+++ b/OvmfPkg/Library/ResetSystemLib/ResetShutdown.c
@@ -0,0 +1,51 @@
+/** @file
+ Reset System Library Shutdown API implementation for OVMF.
+
+ Copyright (C) 2020, Red Hat, Inc.
+ Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Base.h> // BIT13
+
+#include <Library/BaseLib.h> // CpuDeadLoop()
+#include <Library/DebugLib.h> // ASSERT()
+#include <Library/IoLib.h> // IoOr16()
+#include <Library/PciLib.h> // PciRead16()
+#include <Library/ResetSystemLib.h> // ResetShutdown()
+#include <OvmfPlatforms.h> // OVMF_HOSTBRIDGE_DID
+
+/**
+ Calling this function causes the system to enter a power state equivalent
+ to the ACPI G2/S5 or G3 states.
+
+ System shutdown should not return, if it returns, it means the system does
+ not support shut down reset.
+**/
+VOID
+EFIAPI
+ResetShutdown (
+ VOID
+ )
+{
+ UINT16 AcpiPmBaseAddress;
+ UINT16 HostBridgeDevId;
+
+ AcpiPmBaseAddress = 0;
+ HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
+ switch (HostBridgeDevId) {
+ case INTEL_82441_DEVICE_ID:
+ AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
+ break;
+ case INTEL_Q35_MCH_DEVICE_ID:
+ AcpiPmBaseAddress = ICH9_PMBASE_VALUE;
+ break;
+ default:
+ ASSERT (FALSE);
+ CpuDeadLoop ();
+ }
+
+ IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, 0);
+ IoOr16 (AcpiPmBaseAddress + 4, BIT13);
+ CpuDeadLoop ();
+}
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
index 0fc142325ece..fe51f53d1df2 100644
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -9,41 +9,9 @@
#include <Base.h> // BIT1
#include <Library/BaseLib.h> // CpuDeadLoop()
-#include <Library/DebugLib.h> // ASSERT()
#include <Library/IoLib.h> // IoWrite8()
-#include <Library/PciLib.h> // PciRead16()
#include <Library/ResetSystemLib.h> // ResetCold()
#include <Library/TimerLib.h> // MicroSecondDelay()
-#include <OvmfPlatforms.h> // OVMF_HOSTBRIDGE_DID
-
-VOID
-AcpiPmControl (
- UINTN SuspendType
- )
-{
- UINT16 AcpiPmBaseAddress;
- UINT16 HostBridgeDevId;
-
- ASSERT (SuspendType < 6);
-
- AcpiPmBaseAddress = 0;
- HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
- switch (HostBridgeDevId) {
- case INTEL_82441_DEVICE_ID:
- AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
- break;
- case INTEL_Q35_MCH_DEVICE_ID:
- AcpiPmBaseAddress = ICH9_PMBASE_VALUE;
- break;
- default:
- ASSERT (FALSE);
- CpuDeadLoop ();
- }
-
- IoBitFieldWrite16 (AcpiPmBaseAddress + 4, 10, 13, (UINT16) SuspendType);
- IoOr16 (AcpiPmBaseAddress + 4, BIT13);
- CpuDeadLoop ();
-}
/**
Calling this function causes a system-wide reset. This sets
@@ -84,23 +52,6 @@ ResetWarm (
CpuDeadLoop ();
}
-/**
- Calling this function causes the system to enter a power state equivalent
- to the ACPI G2/S5 or G3 states.
-
- System shutdown should not return, if it returns, it means the system does
- not support shut down reset.
-**/
-VOID
-EFIAPI
-ResetShutdown (
- VOID
- )
-{
- AcpiPmControl (0);
- ASSERT (FALSE);
-}
-
/**
This function causes a systemwide reset. The exact type of the reset is
--
2.19.1.3.g30247aa5d201
next prev parent reply other threads:[~2020-04-17 15:38 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-17 15:37 [PATCH 0/6] OvmfPkg/ResetSystemLib: clean up, refactor, fix Laszlo Ersek
2020-04-17 15:37 ` [PATCH 1/6] OvmfPkg/ResetSystemLib: wrap long lines Laszlo Ersek
2020-04-17 16:01 ` Philippe Mathieu-Daudé
2020-04-17 15:37 ` [PATCH 2/6] OvmfPkg/ResetSystemLib: clean up library dependencies Laszlo Ersek
2020-04-17 16:02 ` Philippe Mathieu-Daudé
2020-04-17 15:37 ` [PATCH 3/6] OvmfPkg/ResetSystemLib: improve coding style in ResetSystem() Laszlo Ersek
2020-04-17 16:02 ` Philippe Mathieu-Daudé
2020-04-17 15:37 ` Laszlo Ersek [this message]
2020-04-17 16:05 ` [PATCH 4/6] OvmfPkg/ResetSystemLib: factor out ResetShutdown() Philippe Mathieu-Daudé
2020-04-17 15:37 ` [PATCH 5/6] OvmfPkg/ResetSystemLib: rename to BaseResetSystemLib Laszlo Ersek
2020-04-21 17:27 ` [edk2-devel] " Laszlo Ersek
2020-04-21 18:08 ` Philippe Mathieu-Daudé
2020-04-17 15:37 ` [PATCH 6/6] OvmfPkg/ResetSystemLib: introduce the DxeResetSystemLib instance Laszlo Ersek
2020-04-17 16:23 ` Philippe Mathieu-Daudé
2020-04-17 15:59 ` [PATCH 0/6] OvmfPkg/ResetSystemLib: clean up, refactor, fix Ard Biesheuvel
2020-04-17 16:19 ` Philippe Mathieu-Daudé
2020-04-20 9:48 ` Laszlo Ersek
2020-04-20 10:17 ` Philippe Mathieu-Daudé
2020-04-20 9:46 ` Laszlo Ersek
2020-04-21 17:49 ` Rebecca Cran
2020-04-22 20:35 ` [edk2-devel] " Laszlo Ersek
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=20200417153751.7110-5-lersek@redhat.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