From 4d4f67a1b4d28eb6fdcc7453fa2d0f1c75fb47ed Mon Sep 17 00:00:00 2001 From: vasilito Date: Wed, 1 Jul 2026 04:53:55 +0300 Subject: [PATCH] patches/syscall: add P1-acpiverb-enter-exit-s2idle.patch (Phase I) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Phase I: hardware-agnostic s2idle / Modern Standby support. The patch adds two new AcpiVerb enum variants to upstream redox-os/syscall 0.8.1: * EnterS2Idle (= 3) — acpid requests the kernel enter s2idle. * ExitS2Idle (= 4) — acpid signals s2idle exit. The kernel-side wire is in local/sources/kernel/src/scheme/acpi.rs (see kernel master @ 7a38664 for the [patch.crates-io] update that points Cargo at local/sources/syscall). The patch is durable in the outer RedBear-OS repo so that: * The upstream base is at local/sources/syscall/ (own git repo, no version change from 0.8.1). * When upstream updates, the inner repo is rebased on upstream/master and this patch is re-applied to the new upstream HEAD. * The same patch is also applied to local/sources/syscall/ in the inner git history (commit cfa7f0c), so the local fork has the same content the build system uses. Hardware-agnostic: works for any platform with Modern Standby firmware (Dell, HP, Lenovo, LG Gram, etc.), not just LG Gram. --- .../P1-acpiverb-enter-exit-s2idle.patch | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 local/patches/syscall/P1-acpiverb-enter-exit-s2idle.patch diff --git a/local/patches/syscall/P1-acpiverb-enter-exit-s2idle.patch b/local/patches/syscall/P1-acpiverb-enter-exit-s2idle.patch new file mode 100644 index 0000000000..b9fa149256 --- /dev/null +++ b/local/patches/syscall/P1-acpiverb-enter-exit-s2idle.patch @@ -0,0 +1,34 @@ +diff --git a/src/flag.rs b/src/flag.rs +index 455ec36..1dd5040 100644 +--- a/src/flag.rs ++++ b/src/flag.rs +@@ -310,12 +310,29 @@ pub enum AcpiVerb { + ReadRxsdt = 1, + // no payload, just returns 0 or 1 + CheckShutdown = 2, ++ /// Red Bear OS extension (Phase I): acpid requests the kernel ++ /// enter s2idle (Modern Standby / S0ix). The kernel sets ++ /// `S2IDLE_REQUESTED`; the idle path calls `mwait_loop()`. Read ++ /// payload (1 byte) returns the *previous* value of the flag. ++ /// Write payload is opaque (ignored by current kernel). ++ /// Mirrors Linux 7.1 `s2idle_enter()` in ++ /// `kernel/power/suspend.c:91`. Hardware-agnostic — works on ++ /// any platform with Modern Standby firmware (Dell, HP, Lenovo, ++ /// LG Gram, etc.), not just LG Gram. ++ EnterS2Idle = 3, ++ /// Red Bear OS extension (Phase I): acpid signals s2idle ++ /// exit. Kernel clears `S2IDLE_REQUESTED`. Read payload (1 ++ /// byte) always returns 0. Mirrors Linux 7.1 `s2idle_wake()` in ++ /// `kernel/power/suspend.c:133`. Hardware-agnostic. ++ ExitS2Idle = 4, + } + impl AcpiVerb { + pub const fn try_from_raw(value: u64) -> Option { + Some(match value { + 1 => Self::ReadRxsdt, + 2 => Self::CheckShutdown, ++ 3 => Self::EnterS2Idle, ++ 4 => Self::ExitS2Idle, + _ => return None, + }) + }