summaryrefslogtreecommitdiff
path: root/shutdown/shutdown.c
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2022-09-12 10:39:45 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-09-12 20:32:59 +0200
commit4830c981325d53f8a4372288dbf0ef77a22059da (patch)
tree892cd79901ed178e964cbfc25da90ec2bbb99fa9 /shutdown/shutdown.c
parent160fb63ee0c72f165ab131c4d725d9badaa646ab (diff)
shutdown: Use new acpi RPC to halt machine, clean up
This allows clean shutdown of all modern x86 machines (not just qemu) by using the acpi translator to call into libacpica code. Message-Id: <20220912103837.556815-3-damien@zamaudio.com>
Diffstat (limited to 'shutdown/shutdown.c')
-rw-r--r--shutdown/shutdown.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/shutdown/shutdown.c b/shutdown/shutdown.c
index f821b1f2..e4247397 100644
--- a/shutdown/shutdown.c
+++ b/shutdown/shutdown.c
@@ -35,8 +35,10 @@
#include <sys/file.h>
#include <version.h>
-#include "acpi_shutdown.h"
#include "shutdown_S.h"
+#include "acpi_U.h"
+
+#define SLEEP_STATE_S5 5
/* Port bucket we service requests on. */
struct port_bucket *port_bucket;
@@ -56,8 +58,16 @@ struct port_class *trivfs_control_class;
kern_return_t
S_shutdown_shutdown(trivfs_protid_t server)
{
- disappear_via_acpi();
- return 0;
+ kern_return_t err;
+ mach_port_t acpi;
+
+ acpi = file_name_lookup (_SERVERS_ACPI, O_RDWR, 0);
+ if (acpi == MACH_PORT_NULL)
+ return EIO;
+
+ err = acpi_sleep(acpi, SLEEP_STATE_S5);
+
+ return err;
}
static int