base: Phase J [patch.crates-io] libredox + kstop_enter_s2idle helper
Phase J: add the libredox override to the base's [patch.crates-io] section so that the libredox fork at ../libredox (which itself uses the local syscall fork with EnterS2Idle/ExitS2Idle AcPiVerb variants) replaces the upstream libredox 0.1.17. This breaks the libredox::error::Error <-> syscall::Error type-identity barrier that previously caused E0277 errors in scheme-utils and daemon. The new scheme.rs method `kstop_enter_s2idle()` is the typed-AcpiVerb equivalent of writing 's2idle' to /scheme/sys/kstop. Phase I.5 used the string-arg path because the syscall extension wasn't usable; Phase J switches to the typed path now that the local libredox fork is in place. Hardware-agnostic: works for any platform with Modern Standby firmware (Dell, HP, Lenovo, LG Gram, etc.).
This commit is contained in:
+10
@@ -145,6 +145,16 @@ precedence = "deny"
|
|||||||
# for any platform with Modern Standby firmware (Dell, HP,
|
# for any platform with Modern Standby firmware (Dell, HP,
|
||||||
# Lenovo, LG Gram, etc.).
|
# Lenovo, LG Gram, etc.).
|
||||||
redox_syscall = { path = "../syscall" }
|
redox_syscall = { path = "../syscall" }
|
||||||
|
# Red Bear OS Phase J: libredox 0.1.17 has its own vendored
|
||||||
|
# redox_syscall dep. Without the libredox override here,
|
||||||
|
# libredox::error::Error is the upstream syscall::error::Error
|
||||||
|
# (a different compile-time type than the local fork's
|
||||||
|
# syscall::Error) and the conversion `?` operator in
|
||||||
|
# scheme-utils / daemon fails with E0277. Override libredox
|
||||||
|
# to use the local fork at ../libredox/ (which itself uses
|
||||||
|
# the local syscall fork). Now libredox::error::Error and
|
||||||
|
# syscall::Error are the same type.
|
||||||
|
libredox = { path = "../libredox" }
|
||||||
|
|
||||||
[patch."https://gitlab.redox-os.org/redox-os/relibc.git"]
|
[patch."https://gitlab.redox-os.org/redox-os/relibc.git"]
|
||||||
#redox-ioctl = { path = "../../relibc/source/redox-ioctl" }
|
#redox-ioctl = { path = "../../relibc/source/redox-ioctl" }
|
||||||
|
|||||||
@@ -169,6 +169,32 @@ impl<'acpi, 'sock> AcpiScheme<'acpi, 'sock> {
|
|||||||
let result = handle.call_ro(&mut payload, CallFlags::empty(), &[verb])?;
|
let result = handle.call_ro(&mut payload, CallFlags::empty(), &[verb])?;
|
||||||
Ok(u64::from_ne_bytes(payload))
|
Ok(u64::from_ne_bytes(payload))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Phase J: ask the kernel to enter s2idle (Modern
|
||||||
|
/// Standby / S0ix). This is the typed-AcpiVerb equivalent
|
||||||
|
/// of writing "s2idle" to /scheme/sys/kstop — the kstop
|
||||||
|
/// string-arg path was Phase I.5's fallback while we
|
||||||
|
/// couldn't extend the syscall crate due to the libredox
|
||||||
|
/// cross-version issue. Phase J: with the local libredox
|
||||||
|
/// fork (which uses the local syscall fork with
|
||||||
|
/// EnterS2Idle/ExitS2Idle), this typed path is the
|
||||||
|
/// preferred API. The kstop string-arg path remains for
|
||||||
|
/// backward compatibility with older acpid builds.
|
||||||
|
///
|
||||||
|
/// Hardware-agnostic: works for any platform with Modern
|
||||||
|
/// Standby firmware (Dell, HP, Lenovo, LG Gram, etc.).
|
||||||
|
/// Mirrors Linux 7.1 `acpi_s2idle_begin` in
|
||||||
|
/// `kernel/power/suspend.c:91`.
|
||||||
|
pub fn kstop_enter_s2idle(&self) -> syscall::Result<()> {
|
||||||
|
let handle = self.kstop_fd.ok_or(syscall::error::Error::new(syscall::error::EBADF))?;
|
||||||
|
let verb = AcpiVerb::EnterS2Idle as u64;
|
||||||
|
// AcpiVerb::EnterS2Idle doesn't need a write payload;
|
||||||
|
// the verb code itself is the signal. The kernel
|
||||||
|
// sets S2IDLE_REQUESTED + signals the kstop handle's
|
||||||
|
// EVENT_READ.
|
||||||
|
handle.call_wo(&[], CallFlags::empty(), &[verb])?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_hex_digit(hex: u8) -> Option<u8> {
|
fn parse_hex_digit(hex: u8) -> Option<u8> {
|
||||||
|
|||||||
Reference in New Issue
Block a user