git: c90ebd3fa356 - releng/14.2 - ACPI: Implement power button on !x86

From: Colin Percival <cperciva_at_FreeBSD.org>
Date: Sun, 03 Nov 2024 16:16:49 UTC
The branch releng/14.2 has been updated by cperciva:

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

commit c90ebd3fa356406e152fff4475431c9fd66ea84e
Author:     Colin Percival <cperciva@FreeBSD.org>
AuthorDate: 2024-10-12 17:27:39 +0000
Commit:     Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2024-11-03 16:15:12 +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
    Approved by:    re (kib)
    MFC after:      2 weeks
    Sponsored by:   Amazon
    Differential Revision:  https://reviews.freebsd.org/D47094
    
    (cherry picked from commit f41ef9d80b3d272e08dd9e2ea3c1d8d3f2818066)
    (cherry picked from commit e177e64294556bdece642442d6691523a4294b67)
---
 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 71b19067707b..c2bfe5f2fa5d 100644
--- a/sys/dev/acpica/acpi.c
+++ b/sys/dev/acpica/acpi.c
@@ -3858,13 +3858,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);
 }