]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
OvmfPkg/QemuBootOrderLib: sort [Sources*] sections in the INF file
[mirror_edk2.git] / OvmfPkg / Library / ResetSystemLib / ResetSystemLib.c
index d9de12e8735503411585c23d731895b28d11e055..cc75d046a8e9b3e6d2888c28082a6fc71bbd18a4 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Reset System Library functions for OVMF\r
 \r
-  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 #include <Library/BaseLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/IoLib.h>\r
+#include <Library/TimerLib.h>\r
+#include <OvmfPlatforms.h>\r
+\r
+#include <OvmfPlatforms.h>\r
 \r
 VOID\r
 AcpiPmControl (\r
   UINTN SuspendType\r
   )\r
 {\r
+  UINT16 AcpiPmBaseAddress;\r
+  UINT16 HostBridgeDevId;\r
+\r
   ASSERT (SuspendType < 6);\r
 \r
-  IoAndThenOr16 (0x404, ~0x3c00, SuspendType << 10);\r
-  IoOr16 (0x404, BIT13);\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
@@ -45,7 +66,11 @@ ResetCold (
   VOID\r
   )\r
 {\r
-  IoWrite8 (0x64, 0xfe);\r
+  IoWrite8 (0xCF9, BIT2 | BIT1); // 1st choice: PIIX3 RCR, RCPU|SRST\r
+  MicroSecondDelay (50);\r
+\r
+  IoWrite8 (0x64, 0xfe);         // 2nd choice: keyboard controller\r
+  CpuDeadLoop ();\r
 }\r
 \r
 /**\r
@@ -62,6 +87,7 @@ ResetWarm (
   )\r
 {\r
   IoWrite8 (0x64, 0xfe);\r
+  CpuDeadLoop ();\r
 }\r
 \r
 /**\r
@@ -99,3 +125,24 @@ EnterS3WithImmediateWake (
   AcpiPmControl (1);\r
   ASSERT (FALSE);\r
 }\r
+\r
+/**\r
+  This function causes a systemwide reset. The exact type of the reset is\r
+  defined by the EFI_GUID that follows the Null-terminated Unicode string passed\r
+  into ResetData. If the platform does not recognize the EFI_GUID in ResetData\r
+  the platform must pick a supported reset type to perform.The platform may\r
+  optionally log the parameters from any non-normal reset that occurs.\r
+\r
+  @param[in]  DataSize   The size, in bytes, of ResetData.\r
+  @param[in]  ResetData  The data buffer starts with a Null-terminated string,\r
+                         followed by the EFI_GUID.\r
+**/\r
+VOID\r
+EFIAPI\r
+ResetPlatformSpecific (\r
+  IN UINTN   DataSize,\r
+  IN VOID    *ResetData\r
+  )\r
+{\r
+  ResetCold ();\r
+}\r