Files
RedBear-OS/local/docs/archived/COMPREHENSIVE-DRIVER-AUDIT-2026-05-04.md
T
vasilito 8b872979ef fix: udev-shim panic, sessiond duplicate, scheme Bad-fd handling
- udev-shim: replace .expect() with graceful errors (no more panic on Broken pipe)
- P4-initfs: remove duplicate sessiond (conflicted with config)
- accessibility/ime/keymapd: break instead of exit(1) on EBADF
- P6 driver patches rebased
- Docs: archive old reports, add implementation master plan
2026-05-04 14:04:03 +01:00

15 KiB

Red Bear OS — Comprehensive Driver & Hardware Audit

Date: 2026-05-04 Source of truth: Linux kernel 7.0 (local/reference/linux-7.0/, 2.0 GB) Method: Cross-reference every Red Bear daemon/driver/hardware-init component with its Linux counterpart. Prefer Linux as ground truth for correctness and completeness.


1. Size Comparison Summary

Subsystem Red Bear (lines) Linux (lines) Ratio Existing Plan
ACPI (acpid + kernel) 2,187 + 727 ~60,000+ ~20x ACPI-IMPROVEMENT-PLAN.md
PCI 1,192 ~15,000+ ~12x IRQ-AND-LOWLEVEL-CONTROLLERS
AHCI storage 109 2,173 (ahci.c only) ~20x NONE — gap
xHCI USB ~1,100 12,188 (3 files) ~11x USB-IMPLEMENTATION-PLAN.md
Network (e1000+r8168) 918 37,893 ~41x NONE — gap
Audio (HDA+AC97) 610 ~10,000+ ~16x NONE — gap
GPU/DRM 8,427 1,284,210 (amd+i915) ~152x DRM-MODERNIZATION-EXECUTION
Kernel IRQ 570 ~10,000+ ~17x IRQ-AND-LOWLEVEL-CONTROLLERS
Input (PS/2 + USB HID) ~500 38,000+ (i8042 + HID) ~76x Partial (USB-IMPLEMENTATION)

Note: Size ratios reflect architectural differences (microkernel userspace drivers vs monolithic kernel). Red Bear targets a narrower hardware set. However, feature gaps are real and impactful.


2. Detailed Component Assessment

2.1 ACPI (Covered: ACPI-IMPROVEMENT-PLAN.md)

Red Bear: acpid daemon (2,187 lines) + kernel ACPI tables (727 lines) Linux: drivers/acpi/ (~60K lines) + arch/x86/kernel/acpi/ + ACPICA interpreter

What Red Bear has (verified):

  • ACPI table parsing (RSDP, RSDT/XSDT, FADT, MADT, DSDT/SSDT)
  • AML interpreter (bounded subset, v6.1.1)
  • S5 shutdown via PM1a/PM1b + keyboard controller fallback
  • Power methods (_PS0, _PS3, _PPC)
  • RSDP forwarding from bootloader

What Linux has that Red Bear is missing:

  • S3 (suspend-to-RAM) / S4 (hibernate) — Linux: arch/x86/kernel/acpi/sleep.c
  • Thermal zones — Linux: drivers/acpi/thermal.c
  • Battery/AC status — Linux: drivers/acpi/battery.c, ac.c
  • Fan control — Linux: drivers/acpi/fan.c
  • Embedded Controller runtime — Linux: drivers/acpi/ec.c (62KB)
  • Processor performance states (_PSS) — Linux: drivers/acpi/processor_perflib.c
  • C-states — Linux: arch/x86/kernel/acpi/cstate.c
  • PCI IRQ routing overrides (_PRT) — Linux: drivers/acpi/pci_irq.c
  • ACPI Platform Error Interface (APEI) — Linux: drivers/acpi/apei/

Priority: S3/S4 sleep and thermal shutdown are critical for laptop/desktop use.


2.2 PCI / IRQ (Covered: IRQ-AND-LOWLEVEL-CONTROLLERS-ENHANCEMENT-PLAN.md)

Red Bear: pcid + pcid-spawner (1,192 lines) Linux: drivers/pci/ (~15K lines) + drivers/pci/pcie/ + drivers/pci/msi/

What Red Bear has:

  • PCI enumeration (bus/device/function scanning)
  • Driver spawning via pcid-spawner
  • Basic MSI/MSI-X enable/disable
  • PCIe capability parsing

What Linux has that Red Bear is missing:

  • AER (Advanced Error Reporting) — Linux: drivers/pci/pcie/aer.c
  • ASPM (Active State Power Management) — Linux: drivers/pci/pcie/aspm.c
  • PCIe hotplug — Linux: drivers/pci/hotplug/
  • SR-IOV virtualization — Linux: drivers/pci/iov.c
  • Access Control Services (ACS) — Linux: drivers/pci/pcie/acs.c
  • Address Translation Services (ATS/PRI/PASID) — Linux: drivers/pci/ats.c
  • DPC (Downstream Port Containment) — Linux: drivers/pci/pcie/dpc.c

Priority: AER is critical for hardware reliability. ASPM for power efficiency on laptops.


2.3 Storage — AHCI (No existing plan — CRITICAL GAP)

Red Bear: ahcid (109 lines — main.rs only) Linux: drivers/ata/ahci.c (2,173 lines) + libahci.c (2,447 lines) + libata-core.c (5,296 lines)

Red Bear current state: Minimal — only basic SATA IDENTIFY and PIO/DMA read/write.

What Linux has that Red Bear is missing (cross-referenced from drivers/ata/ahci.c and libata-core.c):

  • NCQ (Native Command Queuing) — 32-command depth, critical for SSD performance
    • Linux: libata-sata.cata_scsi_queuecmd(), ata_qc_issue()
    • Red Bear reference: drivers/ata/libata-sata.c:35sata_fsl_host_intr() with NCQ error handling
  • FIS-based switching (port multiplier support)
    • Linux: drivers/ata/ahci.c:1423ahci_qc_prep() handles FIS registers
  • TRIM/Discard (SSD optimization)
    • Linux: drivers/ata/libata-scsi.cata_scsi_unmap_xlat() maps DISCARD to DATA SET MANAGEMENT
  • Power management (Partial/Slumber link states)
    • Linux: drivers/ata/libata-eh.c:3682ata_eh_handle_port_suspend()
  • Hotplug detection
    • Linux: drivers/ata/libata-core.c:5465ata_port_detect() with PHY event polling
  • LED control (activity/locate/fault LEDs)
    • Linux: drivers/ata/libata-core.c:4938ata_led_* functions
  • ATAPI (CD/DVD) support — present in Linux at drivers/ata/libata-scsi.c
  • SMART passthrough — Linux: drivers/ata/libata-scsi.cata_scsi_pass_thru()
  • Error recovery — Linux has extensive EH (Error Handler) in libata-eh.c (3,915 lines)

Priority: NCQ alone can improve SSD throughput 3-5x. TRIM prevents SSD degradation. Power management critical for laptops.


2.4 Storage — NVMe (No existing plan)

Red Bear: nvmed (present but minimal) Linux: drivers/nvme/host/core.c + pci.c + ioctl.c + fabrics.c + multipath.c + zns.c

What Linux has that Red Bear is missing:

  • Multiple I/O queues (NVMe supports up to 64K queues)
  • Submission/completion queue management
  • PRP/SGL scatter-gather lists
  • Namespace management
  • NVMe-MI (Management Interface)
  • Fabrics (NVMe-oF) — Linux: drivers/nvme/host/fabrics.c
  • ZNS (Zoned Namespaces) — Linux: drivers/nvme/host/zns.c
  • Multipath I/O — Linux: drivers/nvme/host/multipath.c

Priority: Lower than AHCI — most VMs use SATA or virtio-blk.


2.5 Network — e1000 / r8168 (No existing plan — CRITICAL GAP)

Red Bear: e1000d (458 lines) + rtl8168d (460 lines) = 918 lines total Linux: e1000e (30,203 lines) + r8169 (7,690 lines) = 37,893 lines total

What Linux has that Red Bear is missing (cross-referenced from drivers/net/ethernet/intel/e1000e/ and drivers/net/ethernet/realtek/r8169_main.c):

e1000/e1000e:

  • Interrupt moderation (ITR) — critical for throughput
    • Linux: e1000e/netdev.c:4200e1000_configure_itr()
  • Hardware checksum offload (TCP/UDP checksum)
    • Linux: e1000e/netdev.ce1000_tx_csum(), e1000_rx_checksum()
  • TSO/GSO (TCP Segmentation Offload)
    • Linux: e1000e/netdev.c:5305e1000_tso()
  • Jumbo frames (>1500 MTU)
  • Wake-on-LAN — Linux: e1000e/netdev.c:5512e1000e_set_wol()
  • VLAN hardware acceleration
  • EEE (Energy Efficient Ethernet) — Linux: e1000e/ethtool.c
  • Multiple TX/RX queues (MSI-X based)

r8169:

  • Hardware checksum offload
  • TSO/GSO
  • Jumbo frames — Linux: r8169_main.c:4352rtl_jumbo_config()
  • EEPROM/MDIO access — Linux: r8169_main.crtl_read_eeprom()
  • Firmware loading (some chips need firmware) — Linux: r8169_firmware.c
  • PHY configuration (per-chip phy init sequences) — Linux: r8169_phy_config.c (1,354 lines)
  • Power management / ASPM — Linux: r8169_main.c:5073rtl8169_runtime_suspend()

Priority: Hardware offloads can improve throughput 3-10x. Interrupt moderation is essential for high packet rates.


2.6 Audio — HDA / AC97 (No existing plan — GAP)

Red Bear: ihdad (143 lines) + ac97d (467 lines) = 610 lines total Linux: sound/hda/ + sound/pci/ac97/ (~10K lines)

What Linux has that Red Bear is missing:

  • HDA codec auto-detection (Realtek, Conexant, IDT, VIA, etc.)
    • Linux: sound/hda/hda_codec.csnd_hda_codec_new()
  • HDA codec-specific initialization (pin configs, EAPD, GPIO)
    • Linux: sound/hda/hda_generic.c — generic parser
  • HDA power management (codec power states, D0/D3)
    • Linux: sound/hda/hda_codec.csnd_hda_codec_set_power_state()
  • Mixer controls (volume, mute, capture, jack sensing)
    • Linux: sound/hda/hda_generic.ccreate_mute_volume_ctl()
  • Jack detection (headphone/mic plug/unplug)
    • Linux: sound/hda/hda_jack.csnd_hda_jack_detect()
  • HDMI/DP audio (digital audio over display)
    • Linux: sound/hda/hda_eld.c — ELD (EDID-Like Data) parsing
  • AC97 multiple codec support
    • Linux: sound/pci/ac97/ac97_codec.c (3,134 lines)
  • Sample rate conversion / format negotiation

Priority: Codec auto-detection is the minimum needed for real hardware audio to work beyond basic beeps. Without it, audio works on zero real machines.


2.7 USB — xHCI (Covered: USB-IMPLEMENTATION-PLAN.md)

Red Bear: xhcid (~1,100 lines) Linux: drivers/usb/host/xhci.c (5,705) + xhci-ring.c (4,488) + xhci-hub.c (1,995) = 12,188 lines

What Red Bear has:

  • Basic control/bulk/interrupt/isochronous transfers
  • Device enumeration (basic)

What Linux has that Red Bear is missing (cross-referenced):

  • Transfer ring management (TRB dequeue, cycle bit tracking)
    • Linux: xhci-ring.c:253inc_deq() with cycle state handling
  • Stream support (bulk streams for UAS)
    • Linux: xhci-ring.c:3500xhci_queue_stream_transfer()
  • USB 3.x SuperSpeed features (U1/U2/U3 link states)
    • Linux: xhci.c:4560xhci_set_link_state()
  • Isochronous scheduling (proper bandwidth calculation)
    • Linux: xhci-ring.c:3718xhci_queue_isoc_tx()
  • Command ring handling (TRB abort, stop endpoint)
    • Linux: xhci-ring.c:173xhci_abort_cmd_ring()
  • Error recovery (transfer event TRB error handling)
    • Linux: xhci-ring.c:2636handle_tx_event() with extensive error cases
  • Controller reset/recovery (xHCI controller hang detection)
    • Linux: xhci.c:5173xhci_handle_command_timeout()

Priority: Referenced by USB-IMPLEMENTATION-PLAN.md.


2.8 GPU / DRM (Covered: DRM-MODERNIZATION-EXECUTION-PLAN.md)

Redox-drm (8,427 lines) vs Linux AMD+i915 (1,284,210 lines). Referenced by existing plan. Key gaps already documented.


2.9 Input — PS/2 + USB HID

Red Bear: ps2d + usbhidd (~500 lines) Linux: drivers/input/serio/i8042.c (1,254 lines) + drivers/hid/usbhid/ + drivers/input/evdev.c

What Linux has that Red Bear is missing:

  • i8042 controller detection and reset — Linux: i8042.c:522i8042_controller_check()
  • PS/2 hotplug — Linux: i8042.ci8042_interrupt() with AUX detection
  • LED feedback — Red Bear has basic LED support (P3 patch)
  • Touchpad protocol detection (Synaptics, ALPS, Elantech)
  • Multitouch support (USB HID digitizer class)
  • Force feedback (game controllers) — Linux: drivers/hid/hid-pidff.c

3. Prioritized Improvement Plan

Tier 1 — CRITICAL (blocks real hardware use)

# Task Subsystem Effort Reference
1 ACPI S3/S4 sleep + thermal shutdown ACPI 2-3 weeks drivers/acpi/sleep.c, arch/x86/kernel/acpi/sleep.c
2 NCQ support in AHCI Storage 1-2 weeks drivers/ata/libata-sata.cata_qc_issue()
3 HDA codec auto-detection Audio 2-3 weeks sound/hda/hda_codec.csnd_hda_codec_new()
4 Network interrupt moderation + checksum offload Network 1-2 weeks e1000e/netdev.ce1000_configure_itr()

Tier 2 — HIGH (major quality improvements)

# Task Subsystem Effort Reference
5 TRIM/Discard for AHCI Storage 3-5 days drivers/ata/libata-scsi.cata_scsi_unmap_xlat()
6 AHCI power management (Partial/Slumber) Storage 3-5 days drivers/ata/libata-eh.c — suspend/resume
7 r8169 PHY configuration Network 1 week r8169_phy_config.c (1,354 lines)
8 PCIe AER (Advanced Error Reporting) PCI 1 week drivers/pci/pcie/aer.c
9 Jack detection + mixer controls for HDA Audio 1 week sound/hda/hda_jack.c, hda_generic.c

Tier 3 — MEDIUM (polish and completeness)

# Task Subsystem Effort Reference
10 NVMe multiple I/O queues Storage 1-2 weeks drivers/nvme/host/pci.c
11 PCIe ASPM PCI 3-5 days drivers/pci/pcie/aspm.c
12 AHCI FIS-based switching Storage 1 week drivers/ata/ahci.cahci_qc_prep()
13 HDMI/DP audio over HDA Audio 1 week sound/hda/hda_eld.c
14 PS/2 touchpad protocols Input 1-2 weeks drivers/input/mouse/synaptics.c
15 I/OMMU runtime validation (QEMU proof exists) IOMMU 1 week drivers/iommu/amd/

Tier 4 — LOW (future work)

# Task Subsystem Effort Reference
16 SR-IOV virtualization PCI 2-3 weeks drivers/pci/iov.c
17 Wake-on-LAN for e1000/r8169 Network 3-5 days e1000e/netdev.ce1000e_set_wol()
18 NVMe multipath + fabrics Storage 2-4 weeks drivers/nvme/host/multipath.c
19 PCIe hotplug PCI 1-2 weeks drivers/pci/hotplug/
20 Force feedback for game controllers Input 3-5 days drivers/hid/hid-pidff.c

4. Linux Cross-Reference Quick Reference

For each Red Bear daemon, here is the primary Linux source file(s) to consult:

Red Bear Daemon Linux Reference
acpid drivers/acpi/bus.c + arch/x86/kernel/acpi/sleep.c
pcid drivers/pci/probe.c + drivers/pci/pci.c
ahcid drivers/ata/ahci.c + drivers/ata/libata-core.c
nvmed drivers/nvme/host/pci.c + core.c
e1000d drivers/net/ethernet/intel/e1000e/netdev.c
rtl8168d drivers/net/ethernet/realtek/r8169_main.c
xhcid drivers/usb/host/xhci.c + xhci-ring.c
ihdad sound/hda/hda_codec.c + hda_generic.c
ac97d sound/pci/ac97/ac97_codec.c
ps2d drivers/input/serio/i8042.c
usbhidd drivers/hid/usbhid/hid-core.c
vesad drivers/video/fbdev/vesafb.c
virtio-netd drivers/net/virtio_net.c
virtio-blkd drivers/block/virtio_blk.c
virtio-gpud drivers/gpu/drm/virtio/virtgpu*
iommu drivers/iommu/amd/ or intel/
redox-drm drivers/gpu/drm/drm_ioctl.c + drm_framebuffer.c

5. Execution Priority

Tier 1 (weeks 1-6):   ACPI sleep + AHCI NCQ + HDA codec detect + Network offload
Tier 2 (weeks 7-10):  AHCI TRIM + AHCI PM + r8169 PHY + PCIe AER + HDA jack/mixer
Tier 3 (weeks 11-16): NVMe queues + PCIe ASPM + AHCI FIS + HDMI audio + Touchpad
Tier 4 (future):      SR-IOV + WoL + NVMe fabrics + Hotplug + Force feedback

Total estimated effort: 10-16 weeks for Tiers 1-2 (minimum viable hardware support). 26-40 weeks for all 4 tiers.