--- /dev/null
+/** @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