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 e177e64294)
This commit is contained in:
Colin Percival 2024-10-12 10:27:39 -07:00
parent 574e7bad4a
commit c90ebd3fa3

View file

@ -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);
}