Files
RedBear-OS/drivers
Red Bear OS 5d2d114bf9 acpid: complete Linux-compatible AML S-state sequence + s2idle stubs
Phase I (LG Gram 16 (2025) / Arrow Lake-H S-state work).

This commit implements the full Linux 7.1 S-state AML method
sequence in userspace acpid, plus stubs for s2idle (Modern
Standby). The kernel-side s2idle wire (new AcpiVerb variants
EnterS2Idle / ExitS2Idle) is the next step; see
local/docs/SLEEP-IMPLEMENTATION-PLAN.md for the gap analysis.

Changes:

* FACS: add set_waking_vector / set_x_waking_vector methods.
  These let acpid write the firmware waking vector for S3
  resume, mirroring Linux 7.1
  drivers/acpi/acpica/hwxfsleep.c:92
  (acpi_set_firmware_waking_vector).
* FACS access: add facs_mut() mutable accessor on
  AcpiContext (single-writer by construction).
* AML methods: add set_system_status_indicator() that calls
  \_SI._SST(n). The canonical values are 0=working, 1=waking,
  2=sleeping, 3=sleep-context, 7=indicator-off. Mirrors Linux
  ACPI 6.5 §6.5.1 (System Status Indicator).
* wake_from_s_state(): wrap \_WAK(n) with the full Linux wake
  sequence (\_SI._SST(2) before, \_SI._SST(1) after). Mirrors
  drivers/acpi/acpica/hwsleep.c:255-314.
* enter_sleep_state(): only call \_TTS here; \_PTS + \_SST +
  PM1 writes remain in set_global_s_state (Phase D, no
  duplication).
* s2idle: add enter_s2idle() and exit_s2idle() methods on
  AcpiContext. These prepare/finish the s2idle path on systems
  without \_S3 (LG Gram 2025). Currently a no-op for the kernel
  coordination; the AML \_WAK(0) sequence runs via
  wake_from_s_state(0) on exit.

Cross-references:
* drivers/acpi/sleep.c (Linux 7.1) — acpi_suspend_begin/enter
* drivers/acpi/acpica/hwxfsleep.c — acpi_enter_sleep_state_prep
* drivers/acpi/acpica/hwsleep.c — acpi_hw_legacy_wake
* kernel/power/suspend.c — s2idle_loop, s2idle_state
* drivers/acpi/acpica/hwesleep.c — acpi_hw_execute_sleep_method

Files changed:
  drivers/acpid/src/acpi.rs (+203 -14)
2026-07-01 01:17:15 +03:00
..

Drivers

Libraries

  • amlserde - Library to provide serialization/deserialization of the AML symbol table from ACPI
  • common - Library with shared driver code
  • executor - Library to run Rust futures and integrate the executor in an interrupt+queue model without a separated reactor thread
  • graphics/console-draw - Library with shared terminal drawing code
  • graphics/driver-graphics - Library with shared graphics code
  • graphics/graphics-ipc - Library with graphics IPC shared code
  • net/driver-network - Library with shared networking code
  • storage/partitionlib - Library with MBR and GPT code
  • storage/driver-block - Library with shared storage code
  • virtio-core - VirtIO driver library

Services

  • graphics/fbbootlogd - Daemon for boot log drawing
  • graphics/fbcond - Terminal daemon
  • hwd - Daemon that handle the ACPI and DeviceTree booting
  • inputd - Multiplexes input from multiple input drivers and provides that to Orbital
  • pcid-spawner - Daemon for PCI-based device driver spawn
  • storage/lived - Daemon for live disk
  • redoxerd - Daemon that send/receive terminal text between the host system and QEMU

Hardware Interfaces

  • acpid - ACPI interface driver
  • pcid - PCI and PCI Express driver

Devices

CPU

  • rtcd - x86 Real Time Clock driver

Controllers

Storage

Graphics

Input

Sound

Networking

Virtualization

  • vboxd - VirtualBox driver

Some drivers are work-in-progress and incomplete, read this tracking issue to verify.

System Interfaces

This section explain the system interfaces used by drivers.

System Calls

  • iopl : system call that sets the I/O privilege level. x86 has four privilege rings (0/1/2/3), of which the kernel runs in ring 0 and userspace in ring 3. IOPL can only be changed by the kernel, for obvious security reasons, and therefore the Redox kernel needs root to set it. It is unique for each process. Processes with IOPL=3 can access I/O ports, and the kernel can access them as well.

Schemes

  • /scheme/memory/physical : Allows mapping physical memory frames to driver-accessible virtual memory pages, with various available memory types:
    • /scheme/memory/physical : Default memory type (currently writeback)
    • /scheme/memory/physical@wb Writeback cached memory
    • /scheme/memory/physical@uc : Uncacheable memory
    • /scheme/memory/physical@wc : Write-combining memory
  • /scheme/irq : Allows getting events from interrupts. It is used primarily by listening for its file descriptors using the /scheme/event scheme.

Contribution Details

Driver Design

A device driver on Redox is an user-space daemon that use system calls and schemes to work, while operating systems with monolithic kernels drivers use internal kernel APIs instead of common program APIs.

If you want to port a driver from a monolithic operating system to Redox you will need to rewrite the driver with reverse enginnering of the code logic, because the logic is adapted to internal kernel APIs (it's a hard task if the device is complex, datasheets are much more easy).

Write a Driver

Datasheets are preferable (much more easy depending on device complexity), when they are freely available. Be aware that datasheets are often provided under a Non-Disclosure Agreement from hardware vendors, which can affect the ability to create an MIT-licensed driver.

If datasheets aren't available you need to do reverse-engineering of BSD or Linux drivers (if you want use a Linux driver as reference for your Redox driver please ask in the Chat before the implementation to know/satisfy the license requirements and not waste your time, also if you use a BSD driver not licensed as BSD as reference).

Libraries

You should use the redox-scheme and redox_event libraries to create your drivers, you can also read the example driver or read the code of other drivers with the same type of your device.

Before testing your changes be aware of this.

References

If you want to reverse enginner the existing drivers, you can access the BSD code using these links:

How To Contribute

To learn how to contribute to this system component you need to read the following document:

Development

To learn how to do development with this system component inside the Redox build system you need to read the Build System and Coding and Building pages.

How To Build

To build this system component you need to download the Redox build system, you can learn how to do it on the Building Redox page.

This is necessary because they only work with cross-compilation to a Redox virtual machine or real hardware, but you can do some testing from Linux.

Back to top