git: f41ef9d80b3d - main - ACPI: Implement power button on !x86

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Tue, 22 Oct 2024 14:56:28 UTC
The branch main has been updated by cperciva:

URL: https://cgit.FreeBSD.org/src/commit/?id=f41ef9d80b3d272e08dd9e2ea3c1d8d3f2818066

commit f41ef9d80b3d272e08dd9e2ea3c1d8d3f2818066
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2024-10-12 17:27:39 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-10-22 14:56:20 +0000

    ACPI: Implement power button on !x86
    
    ACPI sleep states are only implemented on x86 systems, so having the
    ACPI power button attempt to enter "S5" (or other state as configured
    via the hw.acpi.power_button_state sysctl) is not useful.
    
    On non-x86 systems, implement the power button with a call to
        shutdown_nice(RB_POWEROFF)
    to shut down the system.
    
    Reviewed by:    Andrew
    Tested on:      Graviton 2
    MFC after:      2 weeks
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D47094
---
 sys/dev/acpica/acpi.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/sys/dev/acpica/acpi.c b/sys/dev/acpica/acpi.c
index b7d7277eb310..ea95f57fc22e 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -3903,13 +3903,22 @@ acpi_invoke_wake_eventhandler(void *context)
 UINT32
 acpi_event_power_button_sleep(void *context)
 {
+#if defined(__amd64__) || defined(__i386__)
     struct acpi_softc	*sc = (struct acpi_softc *)context;
+#else
+    (void)context;
+#endif
 
     ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
 
+#if defined(__amd64__) || defined(__i386__)
     if (ACPI_FAILURE(AcpiOsExecute(OSL_NOTIFY_HANDLER,
 	acpi_invoke_sleep_eventhandler, &sc->acpi_power_button_sx)))
 	return_VALUE (ACPI_INTERRUPT_NOT_HANDLED);
+#else
+    shutdown_nice(RB_POWEROFF);
+#endif
+
     return_VALUE (ACPI_INTERRUPT_HANDLED);
 }