]> xenbits.xensource.com Git - people/julieng/freebsd.git/commitdiff
HACK: allow proper poweroff when running as Dom0
authorRoger Pau Monne <roger.pau@citrix.com>
Tue, 23 Sep 2014 17:02:33 +0000 (19:02 +0200)
committerJulien Grall <julien.grall@citrix.com>
Sun, 4 Oct 2015 18:26:46 +0000 (19:26 +0100)
sys/amd64/include/xen/hypercall.h
sys/contrib/dev/acpica/components/hardware/hwsleep.c
sys/i386/include/xen/hypercall.h

index e427bbf4d43f7870d9241cb8ff7683e0b9b177bd..600adf7b2ac5eac49261cb5fd0997e7705419d29 100644 (file)
@@ -388,6 +388,13 @@ HYPERVISOR_suspend(
        return rc;
 }
 
+static inline int
+HYPERVISOR_dom0_op(struct xen_platform_op *platform_op)
+{
+
+       return _hypercall1(int, platform_op, platform_op);
+}
+
 #if CONFIG_XEN_COMPAT <= 0x030002
 static inline int
 HYPERVISOR_nmi_op(
index 2bc434eda7f6feb9069c0c475796de2739eae368..473704652a3de0c4839e54b42561d8bc224d5900 100644 (file)
 #include <contrib/dev/acpica/include/acpi.h>
 #include <contrib/dev/acpica/include/accommon.h>
 
+#ifdef XENHVM
+#include <xen/xen-os.h>
+#include <xen/hypervisor.h>
+#include <xen/interface/platform.h>
+#endif
+
 #define _COMPONENT          ACPI_HARDWARE
         ACPI_MODULE_NAME    ("hwsleep")
 
@@ -74,6 +80,16 @@ AcpiHwLegacySleep (
     UINT32                  InValue;
     ACPI_STATUS             Status;
 
+#ifdef XENHVM
+    struct xen_platform_op op = {
+        .cmd = XENPF_enter_acpi_sleep,
+        .interface_version = XENPF_INTERFACE_VERSION,
+        .u.enter_acpi_sleep = {
+            .sleep_state = SleepState,
+            .flags = 0,
+        },
+    };
+#endif
 
     ACPI_FUNCTION_TRACE (HwLegacySleep);
 
@@ -158,6 +174,14 @@ AcpiHwLegacySleep (
 
     ACPI_FLUSH_CPU_CACHE ();
 
+#ifdef XENHVM
+    if (xen_initial_domain()) {
+            op.u.enter_acpi_sleep.pm1a_cnt_val = Pm1aControl;
+            op.u.enter_acpi_sleep.pm1b_cnt_val = Pm1bControl;
+            HYPERVISOR_dom0_op(&op);
+    }
+#endif
+
     /* Write #2: Write both SLP_TYP + SLP_EN */
 
     Status = AcpiHwWritePm1Control (Pm1aControl, Pm1bControl);
index 7e18f9ed1317f4fb10dba2cc24233e5cd9fa14b9..3f7062fd4974295cae3e97ce1fc812cfb56bb9fe 100644 (file)
@@ -366,6 +366,13 @@ HYPERVISOR_suspend(
        return (rc);
 }
 
+static inline int
+HYPERVISOR_dom0_op(struct xen_platform_op *platform_op)
+{
+
+       return _hypercall1(int, platform_op, platform_op);
+}
+
 #if CONFIG_XEN_COMPAT <= 0x030002
 static inline int
 HYPERVISOR_nmi_op(