[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH v2] plat/common: perform ACPI poweroff on shutdown for x86



Note that this is hypervisor/emulator-specific and currently only
supports QEMU (and whoever is compatible with QEMU).

Signed-off-by: Florian Schmidt <florian.schmidt@xxxxxxxxx>
---
 plat/common/x86/cpu_native.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/plat/common/x86/cpu_native.c b/plat/common/x86/cpu_native.c
index 57ea3a21..2f49c9d5 100644
--- a/plat/common/x86/cpu_native.c
+++ b/plat/common/x86/cpu_native.c
@@ -51,10 +51,19 @@ unsigned long read_cr2(void)
 void system_off(void)
 {
        /*
-        * Poke the QEMU "isa-debug-exit" device to "shutdown". Should be
-        * harmless if it is not present. This is used to enable automated
-        * tests on virtio.  Note that the actual QEMU exit() status will
-        * be 83 ('S', 41 << 1 | 1).
+        * Perform an ACPI shutdown by writing (SLP_TYPa | SLP_EN) to PM1a_CNT.
+        * Generally speaking, we'd have to jump through a lot hoops to collect
+        * those values, however, for QEMU, those are static.  Should be
+        * harmless if we're not running on QEMU, especially considering we're
+        * already shutting down, so who cares if we crash.
+        */
+       outw(0x604, 0x2000);
+
+       /*
+        * If that didn't work for whatever reason, try poking the QEMU
+        * "isa-debug-exit" device to "shutdown". Should be harmless if it is
+        * not present. This is used to enable automated tests on virtio.  Note
+        * that the actual QEMU exit() status will be 83 ('S', 41 << 1 | 1).
         */
        outw(0x501, 41);
 }
-- 
2.21.0


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.