Files
RedBear-OS/drivers
Red Bear OS d844111937 base: close SLP_TYPb, parse_lnk_irc, AML mutex, and S5 gaps
Phase C of the ACPI fork-sync plan. Applies targeted gap fixes on top
of the synchronized fork foundation (commits 4f2a043 + ae57fe3).

Closes 4 of the 8 critical gaps identified by the 2026-06-30 ACPI
assessment.

Gap 5 - SLP_TYPb PM1b write (acpid/src/acpi.rs):
The previous code wrote SLP_EN+SLP_TYPa to PM1a but silently dropped
SLP_TYPb. On hardware that requires both PM1a and PM1b writes
(some laptops, server boards with split power blocks), the shutdown
was incomplete. Now writes SLP_EN+SLP_TYPb to PM1b when
pm1b_control_block is non-zero. The FADT field is 0 when no
second block exists, in which case we skip the second write.

Gap 6 - parse_lnk_irc range validation (hwd/src/backend/acpi.rs):
The previous code accepted any 16-bit integer as an IRQ
(n AND 0xFFFF), producing "Enabled at IRQ 53313" from misparsed
FieldUnit accessors on QEMU PIIX4. Now validates that the IRQ
value is 2047 or less (the maximum valid legacy-compatible IOAPIC
IRQ). Out-of-range values are debug-logged and skipped instead
of polluting the routing table. Also adds a 15-bit cap on the
Buffer-based IRQ bit extraction (was unchecked).

Gap 3 - AML mutex create/acquire/release (acpid/src/aml_physmem.rs):
The new gitlab acpi crate (Phase B bump) added proper Handler
trait methods for create_mutex, acquire, and release. The previous
implementation was three log debug stubs returning fake success,
which would silently corrupt AML state for any DSDT/SSDT that
uses Mutex. Now implements a real mutex table backed by
std::sync.Mutex of FxHashSet u32:
  - create_mutex allocates a unique u32 handle from a counter
  - acquire busy-waits with 1ms sleeps until the handle is free
    or the AML timeout (multiplied by 1000 for ms to us conversion)
    expires; returns AmlError::MutexAcquireTimeout on timeout
  - release removes the handle from the held set

Gap 4a - set_global_s_state non-S5 explicit warning (acpid/src/acpi.rs):
The previous code silently returned early when called with any
state other than 5. Now emits a log warn with the requested
state, naming the missing dependencies (_PTS/_WAK AML evaluation,
P-state preservation, wakeup path). This converts a silent failure
into a diagnostic that is visible in the boot log.

Also includes drivers/acpid/src/dmi.rs:158 - convert e.errno
(private field) to e.errno() (method call). The libredox
Error struct changed its errno from a public field to a method
in a newer release; the DmiError::Map(syscall::error::Error)
construction was using the field-access form, which broke the
build against current libredox. This is a build-fix that the
prior dirty tree already had; included here to keep base
buildable.

Verified by: CI=1 ./local/scripts/build-redbear.sh redbear-mini
succeeded with exit 0. ISO at build/x86_64/redbear-mini.iso
(512 MB) at 2026-06-30 05:28.
2026-06-30 05:31:07 +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