From 4830c981325d53f8a4372288dbf0ef77a22059da Mon Sep 17 00:00:00 2001 From: Damien Zammit Date: Mon, 12 Sep 2022 10:39:45 +0000 Subject: 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> --- shutdown/shutdown.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'shutdown/shutdown.c') 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 #include -#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 -- cgit v1.2.3