- P19-init-startup-hardening: Replace panic-grade expect/unwrap in init startup paths (getns, register_scheme_to_ns, setrens, filename parsing) with graceful error handling and logging - P19-acpid-startup-hardening: Replace panic-grade calls in acpid with graceful degradation (rxsdt read failure → warn + exit 0, SDT parse → error + exit 1, I/O privilege → fatal, scheme registration → fatal, setrens → warn + continue, event loop errors → log + continue) - P18-9-msi-allocation-resilience: Regenerate with git diff -U0 -w format for maximum context resilience - fetch.rs: Change --fuzz=0 to --fuzz=3 for resilient patch application - AGENTS.md: Document robust patch generation technique as mandatory - Add P4/P5/P6/P7 patches (estale, dmi, i2c, ps2d hardening) - Add P21 kernel x2apic SMP fix patch - Multiple local recipe source improvements (redox-drm, driver-manager, driver-acpi, thermald) - Config updates for redbear-mini and redbear-device-services - Subsystem assessment document
20 KiB
Red Bear OS Subsystem Assessment vs Linux Reference
Date: 2026-05-17 Scope: Input devices, ACPI/PCID, Intel DRM/KMS, boot process Reference: Linux kernel 7.1 (local/reference/linux-7.1/)
Executive Summary
Red Bear OS has real, functional architectural scaffolding across all five subsystems. The critical gaps are in hardware-facing paths that are stubbed or incomplete — most notably Intel EDID/DDC, hardware vblank, display watermarks, AML interpreter depth, and boot dependency ordering. The single most impactful immediate fix is adding the missing acpid service to boot configs, which prevents ACPI-dependent drivers from enumerating correctly.
Critical blockers for bare-metal desktop:
- Missing
acpidservice in redbear configs → ACPI devices never discovered - Intel
read_edid_block()returns error → synthetic EDID is 112 bytes (should be 128) → no real monitor modes - Intel
get_vblank()is a fake atomic counter → no real vblank for page flip synchronization - No display watermarks → FIFO underruns cause visible glitching
- No boot dependency declarations → i2c-hidd/i2cd may race with acpid
1. Input Devices (Keyboard, Mouse, HID, I2C-HID, Touch)
Current Implementation Inventory
| Component | Path | Quality | Key Notes |
|---|---|---|---|
| ps2d (PS/2) | base/source/drivers/input/ps2d/ (5 files) |
Real | Keyboard scancodes + mouse protocol. x86-only (non-x86 is unimplemented!()). Many TODOs, QEMU-specific hacks. No ImPS/2 scroll or trackpoint. |
| usbhidd (USB HID) | base/source/drivers/input/usbhidd/ (2 files, 520 lines) |
Real | Full HID report descriptor parsing, USB usage→orbclient scancode table, mouse relative+absolute, scroll, buttons. Retry with exponential backoff. Polling-based (1ms sleep loop). |
| i2c-hidd (I2C HID) | base/source/drivers/input/i2c-hidd/ (5 files, 500+ lines) |
Real | ACPI PNP0C50/ACPI0C50 device scan, _CRS resource parsing, _DSM HID descriptor address, I2C transfer via /scheme/i2c/. Probe failure quirk system with DMI matching. |
| intel-thc-hidd (Intel THC) | base/source/drivers/input/intel-thc-hidd/ (3 files, 282 lines) |
Partial | PCI init works, QuickI2C transport setup works, ACPI companion resolution works. Main loop is thread::sleep(Duration::from_secs(5)) — no input report streaming. |
| inputd (multiplexer) | base/source/drivers/inputd/ (3 files, 663 lines) |
Real | Producer/consumer scheme, VT switching, keymap support (US/Dvorak/GB/AZERTY/Bepo/IT). ESTALE handoff for display driver transitions. |
| evdevd (evdev adapter) | local/recipes/system/evdevd/ (5+ files) |
Real | evdev scheme, device model, orbclient→evdev translation, gesture recognizer, key filter. |
| redbear-keymapd | local/recipes/system/redbear-keymapd/ |
Real | Keymap scheme registration and management. |
| udev-shim | local/recipes/system/udev-shim/ |
Real | Device node synthesis from scheme registrations, heuristic mapping. |
| I2C bus drivers | base/source/drivers/i2c/ (5 modules) |
Real | amd-mp2-i2cd, dw-acpi-i2cd, intel-lpss-i2cd, generic i2cd, i2c-interface library. |
| redbear-input-headers | local/recipes/drivers/redbear-input-headers/ |
Real | linux/input.h, linux/input-event-codes.h, linux/uinput.h — replaces policy-violating linux-input-headers from libevdev tarball. |
| libinput (WIP) | local/recipes/libs/libinput/ |
WIP | Port of upstream libinput with touchpad/trackpoint filtering. Not yet runtime-trusted. |
| libevdev (WIP) | local/recipes/libs/libevdev/ |
WIP | Port of upstream libevdev. |
Gaps vs Linux
| Gap | Severity | Linux Reference | Red Bear Status |
|---|---|---|---|
| intel-thc-hidd doesn't stream | High | drivers/hid/intel-thc-hid/ full probe+report streaming |
Main loop sleeps 5s; no HID reports |
| No multitouch/ABS_MT | High | drivers/input/input-mt.c slot tracking, pointer emulation |
Not implemented |
| No libinput acceleration/gestures | High | libinput: velocity curves, palm detection, gesture recognition | inputd does raw keymap only |
| No PS/2 extended protocols | Medium | libps2.c ImPS/2 scroll, Explorer 5-btn, trackpoint |
Basic protocol only |
| No HID quirks table | Medium | hid-quirks.c 4000+ device entries |
Only probe_failure quirks |
| No input hotplug | Medium | udev + inotify on /dev/input/ |
Static scan at startup |
| Polling-based USB HID | Low | URB interrupt-driven | 1ms sleep loop (functional but power-inefficient) |
| inputd keymap incompleteness | Low | Full xkb/keyboard-layout support | TODO for configurable keymap, AltGr, NumLock |
Linux I2C-HID Reference (from local/reference/linux-7.1/)
The Linux I2C-HID probe sequence is:
- Verify IRQ exists
- Wake/power up device (_PS0/HID_POWER_ON)
- Read HID descriptor from controller register
- Read report descriptor
- Parse descriptor
- Size buffers from actual reports
- Register IRQ
hid_add_device()
Red Bear's i2c-hidd follows this sequence correctly. The Intel THC driver does steps 1-5 but never reaches step 7-8.
2. ACPI and PCID
Current Implementation Inventory
| Component | Path | Quality | Key Notes |
|---|---|---|---|
| Kernel ACPI | kernel/source/src/acpi/ (9+ files) |
Real, partial | RSDP, RSDT/XSDT, MADT, FADT, DSDT parsing. New: SLIT, SRAT. AML evaluation for basic methods (_STA, _PS0, _PS3, _INI). No While/If-Else, no OperationRegion for PCI/I2C, no method locals. |
| Kernel ACPI scheme | kernel/source/src/scheme/acpi.rs |
Real | Exposes ACPI tables, symbols, resources, method evaluation to userspace. |
| Kernel DMAR/IOMMU | kernel/source/src/acpi/dmar/ |
Partial | DMAR table parsing for IOMMU. DRHD entries parsed but not wired to allocator. |
| Kernel sleep/S3 | kernel/source/src/arch/x86_shared/sleep.rs (new, uncommitted) |
New | S3 suspend/wakeup assembly. Not yet wired to power management. |
| acpid | base/source/drivers/acpid/ |
Real | Scheme-based ACPI access, symbol evaluation, resource serialization. ESTALE-graceful handling. |
| pcid | base/source/drivers/pcid/ |
Real | PCI enumeration, config space, BAR mapping, pcid-spawner. MSI/MSI-X support via recent patches. |
| redox-driver-acpi | local/recipes/drivers/redox-driver-acpi/ |
Real | ACPI bus driver bridging ACPI discovery to pcid-spawner. |
| driver-manager | local/recipes/system/driver-manager/ |
Real | Manages PCI/ACPI driver matching and spawning. |
| redox-driver-sys quirks | local/recipes/drivers/redox-driver-sys/source/src/quirks/ |
Real | Compiled-in + TOML + DMI quirk tables. MSI/MSI-X fallback, DISABLE_ACCEL. |
| IOMMU daemon | local/recipes/system/iommu/ |
Partial | Builds, QEMU first-use proof passes. Real hardware validation pending. |
Gaps vs Linux
| Gap | Severity | Linux Reference | Red Bear Status |
|---|---|---|---|
| AML interpreter incomplete | Critical | Full AML bytecode VM (While/If/Else, OperationRegion, Method locals, Notify) | Basic method calls only (_STA, _PS0, _PS3, _INI). No control flow. |
| No _PRW wake resources | High | drivers/acpi/wakeup.c |
Not present |
| No thermal zones | High | drivers/acpi/thermal.c _TMP/_ACx/_PSV/_CRT |
Not present |
| No ACPI battery | Medium | drivers/acpi/battery.c _BIF/_BST |
Not present |
| No ACPI buttons | High | drivers/acpi/button.c LID/Power/Sleep |
Not present |
| SRAT/SLIT not wired to NUMA | Medium | mm/numa.c |
Parsed but not connected to page allocator |
| No _OSC OS capabilities | Medium | drivers/acpi/osc.c |
Not present |
| No PCI ASPM | Medium | drivers/pci/pcie/aspm.c |
Not present |
| No PCI hotplug | Low | drivers/pci/hotplug/ |
Not present |
| No suspend/resume | Critical | drivers/acpi/sleep.c S1-S5 |
sleep.rs + wakeup.asm in uncommitted changes, not wired |
| DMAR/IOMMU path commented out | High | drivers/iommu/intel-iommu.c |
acpid/src/acpi/dmar/mod.rs has iterator bug (len_bytes from wrong slice), hangs on real hardware — entire DMAR path commented out |
| DMI quirk matching dead | High | /sys/firmware/dmi |
redox-driver-sys/quirks/dmi.rs depends on /scheme/acpi/dmi but that source doesn't exist in the ACPI stack |
| ACPI resource parsing panics | Medium | N/A | redox-driver-acpi/resource.rs and prt.rs panic on unexpected ACPI resource shapes instead of returning errors |
madt/arch/other.rs stub |
Low | drivers/acpi/madt.c |
Non-x86 MADT handling is effectively unimplemented |
PCI config: non-x86 todo!() |
Low | drivers/pci/ |
pcid/src/cfg_access/fallback.rs has todo!() for non-x86 PCI config access |
| Missing acpid service in configs | Critical | N/A (config bug) | No acpid = {} in redbear-full.toml or redbear-device-services.toml |
acpid Missing From Configs — Critical Bug
The boot process agent found that no active acpid = {} service entry exists in the redbear TOML configs. This means acpid may never start, which prevents ACPI symbol/resource discovery for all ACPI-dependent drivers (i2c-hidd, intel-thc-hidd, thermald, driver-manager ACPI path). This is the single highest-priority fix.
3. Intel DRM/KMS
Current Implementation Inventory
| Component | Path | Quality | Key Notes |
|---|---|---|---|
| IntelDriver | redox-drm/source/src/drivers/intel/mod.rs (682 lines) |
Partial | PCIe init, MMIO mapping, FORCEWAKE, connector detection, CRTC set_mode, page_flip, GEM create/mmap/close, IRQ handling. |
| IntelDisplay | .../intel/display.rs (404 lines) |
Partial | Pipe detection, DDI port detection, mode setting (real HTOTAL/HBLANK/HSYNC/VTOTAL/VSYNC/PIPE_SRC register writes). EDID: read_edid_block returns error → synthetic_edid(). DPCD: returns fake 4 bytes. |
| IntelGtt | .../intel/gtt.rs |
Real | GGTT allocation, mapping, unmapping. |
| IntelRing | .../intel/ring.rs (267 lines) |
Partial | DMA ring buffer, GPU address binding. Only MI_FLUSH_DW + MI_NOOP submitted — no rendering commands. |
| DRM scheme | redox-drm/source/src/scheme.rs |
Real | Full DRM/KMS ioctl surface. SETPLANE is empty, GETENCODER hardcoded. |
| KMS infrastructure | redox-drm/source/src/kms/ (5 files) |
Real | ConnectorInfo, ModeInfo with EDID parsing, synthetic_edid fallback. |
| Interrupt handling | redox-drm/source/src/drivers/interrupt.rs |
Real | MSI/MSI-X/INTx setup, try_wait polling. |
| Linux-kpi DRM headers | linux-kpi/source/src/c_headers/drm/ |
Minimal | drm.h, drm_crtc.h, drm_gem.h, drm_ioctl.h — type definitions only. |
| ihdgd (legacy) | base/source/drivers/graphics/ihdgd/ |
Old/Partial | Separate Intel framebuffer driver. Many TODOs. Being superseded by redox-drm. |
| vesad | base/source/drivers/graphics/vesad/ |
Legacy | VESA framebuffer driver. No cursor support. |
| Mesa | recipes/libs/mesa/ |
Software only | Only swrast+virgl Gallium. No Intel iris/crocus/anv driver build. |
Critical Bugs Found
-
synthetic_edid() is 112 bytes, not 128 —
ModeInfo::from_edid()requiresedid.len() >= 128and checks for the 8-byte EDID header. The synthetic EDID is only 112 bytes so it always fails validation, forcingdefault_1080p()fallback on every Intel connector. -
Intel
get_vblank()returnsAtomicU64::fetch_add(1, SeqCst)— This is NOT a real vblank counter. It increments on every IRQ regardless of display state. Real i915 reads thePIPEFRAMEregister (offset0x70040 + pipe * 0x1000) for per-pipe frame count.
Gaps vs Linux i915
| Gap | Severity | Impact |
|---|---|---|
| EDID I2C/DDC stubbed | Critical | No real monitor modes — always falls back to synthetic/default |
| Vblank counter is fake | Critical | Page flip has no synchronization — tearing |
| Display watermarks absent | Critical | FIFO underruns → visible glitching on real hardware |
| No panel power sequencing | High | eDP panels won't turn on/off properly on laptops |
| No hardware cursor | High | No visible cursor in DRM mode |
| No DP AUX channel | High | No DisplayPort monitor support |
| synthetic_edid too short (bug) | Critical | EDID validation always fails |
| No DMC firmware loading | Medium | No DC5/DC6 power state for Gen9+ |
| No HPD pulse detection | Medium | Monitor hotplug is crude |
| No render commands | Medium | Ring only does flush — no 2D/3D acceleration |
| No GGTT PTE invalidation | Medium | Stale TLB entries after GGTT updates |
| Mesa has no Intel driver | High | No hardware-accelerated OpenGL/Vulkan |
4. Boot Process
Boot Sequence (as configured)
UEFI bootloader
→ kernel (startup, ACPI, scheme registration)
→ init (PID 1)
→ logd
→ scheme registration (memory, irq, event, pipe, debug, etc.)
→ numbered services from init.d/:
00_* : base daemons (ipcd, ptyd, randd)
02_* : driver-manager (or legacy pcid-spawner)
04_* : device drivers
06_* : D-Bus, sessiond, seatd
08_* : console/greeter
Dependency Analysis
The init system supports requires_weak for service dependencies, but most services don't declare dependencies. The boot agent found:
requires_weakmeans "if the dependency exists, wait for it; if not, proceed anyway." This is good for optional services but inadequate for strict ordering.- No explicit
acpid = {}service in redbear-full.toml or redbear-device-services.toml — ACPI-dependent drivers may never discover their devices. driver-managerretries deferred probes, but missing schemes (especiallyacpi) can leave drivers permanently skipped.- Greeter/session path works only if dbus, seatd, redox-drm, and authd are all present.
redbear-greeterdwaits for Wayland socket, not a stronger compositor readiness signal.
Gaps
| Gap | Severity | Notes |
|---|---|---|
| Missing acpid service in configs | Critical | No ACPI symbol discovery for i2c-hidd, thermald, driver-manager ACPI path |
| No dependency declarations | High | Services use number-based ordering only |
| No service readiness signaling | High | No sd_notify equivalent; init doesn't gate on daemon.ready() |
| No filesystem check | Medium | No fsck on boot; dirty filesystem mounts anyway |
| initfs→rootfs transition | Medium | No re-evaluation of service readiness after root switch |
5. Phased Implementation Plan
Phase 1: Boot Dependency Fix (1–2 weeks)
Priority: Unblocks everything downstream.
| # | Task | Files | Complexity |
|---|---|---|---|
| 1.1 | Add acpid = {} to redbear-device-services.toml and redbear-full.toml |
config/redbear-device-services.toml, config/redbear-full.toml |
Low |
| 1.2 | Add requires= / wants= declarations to init service format |
recipes/core/base/source/init/src/ |
Medium |
| 1.3 | Implement dependency-aware startup: wait for scheme:<dep> before starting dependents |
recipes/core/base/source/init/src/ |
Medium |
| 1.4 | Add provides= scheme:acpi / requires= scheme:acpi to ACPI-dependent services |
Service TOML files | Low |
| 1.5 | Wire ESTALE-retry into i2c-hidd/intel-thc-hidd as fallback (already partial) | drivers/input/i2c-hidd/, intel-thc-hidd/ |
Low |
Phase 2: Intel Display Critical Fixes (3–5 weeks)
Priority: Highest impact for bare-metal desktop.
| # | Task | Complexity | Risk | Blocks |
|---|---|---|---|---|
| 2.1 | Implement I2C master-mode in i2cd | High | Medium | 2.2, 2.7, 3.1 |
| 2.2 | Implement real EDID via DDC (I2C at 0xA0). Fix synthetic_edid to 128 bytes as fallback | High | Medium | — |
| 2.3 | Implement hardware vblank (read PIPEFRAME register) | Medium | Low | — |
| 2.4 | Implement display watermarks (WM_LINETIME, WM levels per pipe) | High | Medium | — |
| 2.5 | Implement eDP panel power sequencing (PP_ON/OFF/CYCLE) | Medium | Medium | — |
| 2.6 | Implement hardware cursor (CUR_CTL/CUR_BASE/CUR_POS) | Medium | Low | — |
| 2.7 | Implement DP AUX channel (I2C-over-AUX for DisplayPort) | High | Medium | Depends on 2.1 |
Ordering: EDID (2.2) → vblank (2.3) → watermarks (2.4) → panel (2.5) → cursor (2.6) → DP AUX (2.7)
Phase 3: Input Stack Completion (2–4 weeks)
Can parallel with Phase 2 once I2C master-mode (2.1) is done.
| # | Task | Complexity |
|---|---|---|
| 3.1 | Complete intel-thc-hidd input streaming (replace sleep loop with HID report read) | Medium |
| 3.2 | Add PS/2 extended protocols (ImPS/2 scroll, Explorer 5-btn, trackpoint) | Medium |
| 3.3 | Add input device hotplug (dynamic producer registration in inputd) | Medium |
| 3.4 | Add multitouch protocol (ABS_MT slots, touch report parsing) | Medium |
| 3.5 | Add pointer acceleration to inputd | Low |
| 3.6 | Port bounded subset of Linux hid-quirks for device workarounds | Medium |
Phase 4: AML Interpreter Depth (4–8 weeks)
Risk gate: scope strictly to _PS0/_PS3/_PRW/_BIF/_BST opcodes first.
| # | Task | Complexity |
|---|---|---|
| 4.1 | AML While/If-Else/Method-with-locals (bounded, not full spec) | Very High |
| 4.2 | OperationRegion handlers for PCI config and I2C | High |
| 4.3 | _PRW (power resources for wake) | Medium |
| 4.4 | ACPI battery (_BIF/_BST) | Medium |
| 4.5 | ACPI buttons (LID, power, sleep) | Low |
| 4.6 | Thermal zone evaluation (_TMP, _ACx, _PSV, _CRT) | Medium |
Phase 5: Advanced Features (4–8 weeks)
After Phases 2–4 are stable.
| # | Task |
|---|---|
| 5.1 | PCI ASPM power management (_OSC, L0s/L1) |
| 5.2 | PCI hotplug (acpiphp/pciehp) |
| 5.3 | SRAT/SLIT → NUMA allocator wiring |
| 5.4 | Display FIFO underrun recovery |
| 5.5 | HPD pulse detection |
| 5.6 | I2C bus error recovery (SMBus timeout, multi-controller) |
Dependency Graph
Phase 1 (boot deps)
│
├──→ Phase 2 (Intel display) ──→ Phase 5.4, 5.5
│ │
│ └──→ 2.1 (I2C master) blocks 2.2, 2.7, 3.1
│
├──→ Phase 3 (input) ──→ 3.1 needs I2C (shared with 2.1)
│
├──→ Phase 4 (AML) ──→ Phase 5.1, 5.2
│ │
│ └──→ 4.1 gates 4.3–4.6
│
└──→ Phase 5 (advanced) ──→ depends on Phases 2, 3, 4
Effort Estimate (2 developers)
| Phase | Duration | Parallelizable? |
|---|---|---|
| Phase 1 | 1–2 weeks | Yes (with Phase 2 start) |
| Phase 2 | 3–5 weeks | Partially (2.1 blocks 2.2–2.7) |
| Phase 3 | 2–4 weeks | Yes (parallel with Phase 2) |
| Phase 4 | 4–8 weeks | Partially (4.1 gates rest) |
| Phase 5 | 4–8 weeks | After Phases 2–4 |
| Total | 14–27 weeks | ~8–14 months |
Key Risks
- I2C master-mode is a shared dependency between EDID (2.2), THC input (3.1), and DDC (2.2). Implement it first in i2cd.
- AML interpreter scope creep — the full AML spec is enormous. Strictly bound the first pass to opcodes needed for _PS0/_PS3/_PRW/_BIF/_BST. Fallback: bounded userspace AML evaluator in acpid.
- Intel watermark programming varies by generation — start with Gen9 Skylake, then generalize.
- synthetic_edid 112-byte bug must be fixed IMMEDIATELY — it affects every Intel display attempt.
- Missing acpid service in configs must be fixed IMMEDIATELY — it blocks all ACPI-dependent device discovery.
- DMAR/IOMMU iterator bug in
acpid/src/acpi/dmar/mod.rscauses hangs on real hardware; entire DMAR path is commented out. - DMI quirk matching is dead —
redox-driver-sys/quirks/dmi.rsreads/scheme/acpi/dmibut no code provides that scheme.
Appendix A: Linux Reference File Map
From local/reference/linux-7.1/:
| Subsystem | Key Files |
|---|---|
| HID core | drivers/hid/hid-core.c, hid-input.c, hid-quirks.c |
| I2C-HID | drivers/hid/i2c-hid/i2c-hid-core.c, i2c-hid-acpi.c |
| USB HID | drivers/hid/usbhid/hid-core.c, usbkbd.c, usbmouse.c |
| Input core | drivers/input/input.c, input-mt.c, evdev.c |
| PS/2 | drivers/input/serio/i8042.c, libps2.c, atkbd.c, psmouse-base.c |
| I2C core | drivers/i2c/i2c-core-acpi.c, i2c-core-base.c |
| i915 | drivers/gpu/drm/i915/ (6M+ lines) |
| ACPI | drivers/acpi/ (full AML interpreter, 15k+ lines) |
Appendix B: Uncommitted Changes (as of 2026-05-17)
The bootprocess branch has 63 changed files including:
- Kernel ACPI:
slit.rs,srat.rs(NUMA),msi.rs,vector.rs(MSI/MSI-X),sleep.rs+s3_wakeup.asm(S3) - Kernel:
numa.rs,mcs.rs(MCS lock), context/percpu/event/sync improvements - Base patches:
P4-acpi-estale-graceful.patch,P4-hwd-estale-graceful.patch,P4-ucsid-estale-graceful.patch - Kernel patch:
P21-x2apic-smp-fix.patch - Modified: pcid, driver-manager, thermald, redox-drm, redox-driver-acpi source files