Update ResetSystemLib to support powering off bhyve guests instead of
having them enter the CpuDeadLoop.

On bhyve, the Power Management 1 Control Register is located at 0x404;
a write with SLP_TYP set to 5 will power off the guest.

Signed-off-by: Rebecca Cran <rebe...@bsdio.com>
---
 OvmfPkg/Include/IndustryStandard/Bhyve.h        | 4 ++++
 OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c | 6 ++++++
 2 files changed, 10 insertions(+)

diff --git a/OvmfPkg/Include/IndustryStandard/Bhyve.h 
b/OvmfPkg/Include/IndustryStandard/Bhyve.h
index 950f87048b..ceabc54d59 100644
--- a/OvmfPkg/Include/IndustryStandard/Bhyve.h
+++ b/OvmfPkg/Include/IndustryStandard/Bhyve.h
@@ -18,4 +18,8 @@
 
 #define BHYVE_ACPI_TIMER_IO_ADDR 0x408
 
+#define BHYVE_PMBASE_VALUE 0x400
+
+#define BHYVE_PCI_DEVICE_ID 0x1275 // NetApp vendor ID
+
 #endif // __BHYVE_H__
diff --git a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c 
b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
index 2f2e1293a3..8d9b9dfcf5 100644
--- a/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/OvmfPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -28,6 +28,12 @@ AcpiPmControl (
   AcpiPmBaseAddress = 0;
   HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
   switch (HostBridgeDevId) {
+  case BHYVE_PCI_DEVICE_ID:
+    AcpiPmBaseAddress = BHYVE_PMBASE_VALUE;
+    // Bhyve needs a value of 5 to enter S5 (power off)
+    if (SuspendType == 0)
+      SuspendType = 5;
+    break;
   case INTEL_82441_DEVICE_ID:
     AcpiPmBaseAddress = PIIX4_PMBA_VALUE;
     break;
-- 
2.26.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#57450): https://edk2.groups.io/g/devel/message/57450
Mute This Topic: https://groups.io/mt/73045196/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to