Add CUB implementation plan spec and update project documentation

New docs/_CUB_RBPKGBUILD_IMPL_PLAN.md with full CUB package builder specification
covering RBPKGBUILD format, CLI commands, build flow, BUR repository, and AUR conversion.
Updated AGENTS.md with pkgutils extensions and CUB integration details.
Updated AMD GPU integration docs with current P2 progress.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
2026-04-12 23:52:47 +01:00
parent cefc9b8936
commit ba09482def
7 changed files with 476 additions and 30 deletions
+14 -12
View File
@@ -1,6 +1,6 @@
# RED BEAR OS BUILD SYSTEM — PROJECT KNOWLEDGE BASE # RED BEAR OS BUILD SYSTEM — PROJECT KNOWLEDGE BASE
**Generated:** 2026-04-11 (AMD-first reassessment) **Generated:** 2026-04-12 (P1/P2 complete)
**Toolchain:** Rust nightly-2025-10-03 (edition 2024) **Toolchain:** Rust nightly-2025-10-03 (edition 2024)
**Architecture:** Microkernel OS in Rust, ~38k files, ~294k LoC Rust **Architecture:** Microkernel OS in Rust, ~38k files, ~294k LoC Rust
**Target Hardware**: AMD64 bare metal, AMD GPU (RDNA2/RDNA3), then Intel **Target Hardware**: AMD64 bare metal, AMD GPU (RDNA2/RDNA3), then Intel
@@ -62,6 +62,7 @@ redox-master/
| Cross-toolchain setup | `mk/prefix.mk`, `prefix/x86_64-unknown-redox/` | Downloads Clang/LLVM toolchain | | Cross-toolchain setup | `mk/prefix.mk`, `prefix/x86_64-unknown-redox/` | Downloads Clang/LLVM toolchain |
| Display server | Orbital: `recipes/gui/orbital/` | Userspace scheme-based display server | | Display server | Orbital: `recipes/gui/orbital/` | Userspace scheme-based display server |
| GPU/graphics stack | `recipes/libs/mesa/` | OSMesa + LLVMpipe (software only) | | GPU/graphics stack | `recipes/libs/mesa/` | OSMesa + LLVMpipe (software only) |
| GPU hardware drivers | `local/recipes/gpu/redox-drm/source/` | AMD + Intel DRM/KMS via redox-driver-sys |
| Boot config | `config/*.toml` | TOML hierarchy, include-based | | Boot config | `config/*.toml` | TOML hierarchy, include-based |
## BUILD COMMANDS ## BUILD COMMANDS
@@ -222,15 +223,15 @@ See `local/docs/AMD-FIRST-INTEGRATION.md` for the full plan.
| ACPI power | ✅ | `\_PS0`/`\_PS3`/`\_PPC` AML methods available | | ACPI power | ✅ | `\_PS0`/`\_PS3`/`\_PPC` AML methods available |
| x2APIC/SMP | ✅ | Multi-core works | | x2APIC/SMP | ✅ | Multi-core works |
| IOMMU | ❌ | No AMD-Vi support | | IOMMU | ❌ | No AMD-Vi support |
| AMD GPU | | Only VESA/GOP, no acceleration | | AMD GPU | 🚧 | MMIO mapped, DC port compiles, MSI-X wired, no hardware validation yet |
### Phased Roadmap ### Phased Roadmap
| Phase | Duration | Delivers | | Phase | Duration | Delivers |
|-------|----------|----------| |-------|----------|----------|
| ~~P0: Fix ACPI for AMD~~ | ~~4-6 weeks~~ | ✅ Complete — boots on modern AMD bare metal | | ~~P0: Fix ACPI for AMD~~ | ~~4-6 weeks~~ | ✅ Complete — boots on modern AMD bare metal |
| P1: Driver infrastructure | 8-12 weeks | redox-driver-sys + linux-kpi + firmware-loader | | ~~P1: Driver infrastructure~~ | ~~8-12 weeks~~ | ✅ Complete — redox-driver-sys + linux-kpi + firmware-loader + pcid /config + MSI-X (compiles) |
| P2: AMD GPU display | 12-16 weeks | redox-drm + AMD DC modesetting → scheme:drm | | ~~P2: AMD GPU display~~ | ~~12-16 weeks~~ | ✅ Complete — redox-drm + AMD DC port + Intel driver (compiles, no HW validation) |
| P3: POSIX + input | 4-8 weeks | relibc gaps + evdevd (parallel with P1/P2) | | P3: POSIX + input | 4-8 weeks | relibc gaps + evdevd (parallel with P1/P2) |
| P4: Wayland compositor | 4-6 weeks | Smithay Redox backends | | P4: Wayland compositor | 4-6 weeks | Smithay Redox backends |
| P5: Full amdgpu | 16-24 weeks | Complete GPU driver via LinuxKPI (parallel) | | P5: Full amdgpu | 16-24 weeks | Complete GPU driver via LinuxKPI (parallel) |
@@ -240,16 +241,17 @@ See `local/docs/AMD-FIRST-INTEGRATION.md` for the full plan.
### Critical Path ### Critical Path
``` ```
P0 (ACPI boot) ✅ DONE → P1 (driver infra) → P2 (AMD display) → P4 (Wayland) → P6 (KDE) P0 (ACPI boot) ✅ DONE → P1 (driver infra) ✅ DONE → P2 (AMD display) ✅ DONE → P4 (Wayland) → P6 (KDE)
P3 (POSIX+input) ──┘ P3 (POSIX+input) ──────────────┘
P5 (full amdgpu, parallel) P5 (full amdgpu, parallel)
``` ```
### New Crates Needed ### Custom Crates (P1/P2)
1. `redox-driver-sys` — Safe Rust wrappers for scheme:memory, scheme:irq, scheme:pci 1. `redox-driver-sys` — `local/recipes/drivers/redox-driver-sys/source/` — Safe Rust wrappers for scheme:memory, scheme:irq, scheme:pci
2. `linux-kpi` — C headers translating Linux kernel APIs → redox-driver-sys 2. `linux-kpi` — `local/recipes/drivers/linux-kpi/source/` — C headers translating Linux kernel APIs → redox-driver-sys
3. `redox-drm` — DRM scheme daemon (AMD DC port) 3. `redox-drm` — `local/recipes/gpu/redox-drm/source/` — DRM scheme daemon (AMD + Intel drivers)
4. Firmware loader daemon — scheme:firmware for AMD GPU blobs 4. `firmware-loader` — `local/recipes/system/firmware-loader/source/` — scheme:firmware for GPU blobs
5. `amdgpu` — `local/recipes/gpu/amdgpu/source/` — AMD DC C port with linux-kpi compat
All custom work goes in `local/` — see `local/AGENTS.md` for overlay usage. All custom work goes in `local/` — see `local/AGENTS.md` for overlay usage.
+3 -2
View File
@@ -22,9 +22,10 @@ Red Bear OS is a derivative of [Redox OS](https://www.redox-os.org) — a genera
| Component | Status | Detail | | Component | Status | Detail |
|-----------|--------|--------| |-----------|--------|--------|
| AMD GPU driver (amdgpu) | 🚧 In progress | LinuxKPI compat layer + AMD DC modesetting | | AMD GPU driver (amdgpu) | ✅ Compiles | LinuxKPI compat + AMD DC modesetting + MSI-X (no HW validation) |
| Intel GPU driver | ✅ Compiles | Display pipe modesetting + MSI-X (no HW validation) |
| ext4 filesystem | ✅ Compiles | Read/write ext4 alongside RedoxFS | | ext4 filesystem | ✅ Compiles | Read/write ext4 alongside RedoxFS |
| ACPI for AMD bare metal | ⚠️ Partial | x2APIC, DMAR, IVRS, MCFG parsing | | ACPI for AMD bare metal | ✅ Complete | x2APIC, MADT, FADT shutdown/reboot, power methods |
| Custom branding | ✅ | Boot identity, hostname, os-release | | Custom branding | ✅ | Boot identity, hostname, os-release |
| POSIX gaps (relibc) | 🚧 In progress | eventfd, signalfd, timerfd, open_memstream | | POSIX gaps (relibc) | 🚧 In progress | eventfd, signalfd, timerfd, open_memstream |
+368
View File
@@ -0,0 +1,368 @@
Red Bear OS Packaging System — Formal Spec v0.1
0. Guiding Principles
Native-first
All builds target: x86_64-unknown-redox
All install artifacts: pkgar packages
Cookbook is the build engine
RBPKGBUILD = thin wrapper over Cookbook recipe
PKGBUILD is input, not execution
Never execute arbitrary PKGBUILD on host
Always convert → RBPKGBUILD → Cookbook
Single tool
cub = one CLI binary with subcommands/flags
Deterministic builds
Controlled env
No implicit host dependencies
Security-first
Sandbox builds
Review BUR packages before install
1. RBPKGBUILD Specification
1.1 File Format
Format: TOML
Filename: RBPKGBUILD
Versioned schema
format = 1
1.2 Top-Level Sections
format = 1
[package]
[source]
[dependencies]
[build]
[install]
[patches]
[compat]
[policy]
1.3 [package]
[package]
name = "ripgrep"
version = "14.1.0"
release = 1
description = "Fast recursive search tool"
homepage = "https://github.com/BurntSushi/ripgrep"
license = ["MIT", "Unlicense"]
architectures = ["x86_64-unknown-redox"]
maintainers = ["name <email>"]
Rules
name: lowercase, [a-z0-9-_]+
version: upstream version
release: integer (Red Bear-specific revision)
architectures: must include x86_64-unknown-redox
1.4 [source]
[source]
sources = [
{ type = "tar", url = "...", sha256 = "..." },
{ type = "git", url = "...", rev = "..." }
]
Supported types
tar
git
Rules
All sources must be verifiable (hash or commit)
No implicit downloads during build
1.5 [dependencies]
[dependencies]
build = ["cargo", "rust"]
runtime = []
check = []
optional = []
provides = []
conflicts = []
Rules
Names must resolve via system mapping
Must not reference Arch package names directly
1.6 [build]
Maps directly to Cookbook templates.
[build]
template = "cargo" # or configure, cmake, meson, custom
Optional fields
cargo
[build]
template = "cargo"
release = true
features = []
configure
[build]
template = "configure"
args = ["--prefix=/usr"]
cmake
[build]
template = "cmake"
build_dir = "build"
custom
[build]
template = "custom"
prepare = [
"patch -p1 < patches/fix.patch"
]
build = [
"make -j$CORES"
]
check = [
"make test"
]
install = [
"make DESTDIR=$DESTDIR install"
]
1.7 [install]
Declarative install mapping.
[install]
bins = [
{ from = "target/.../rg", to = "/usr/bin/rg" }
]
libs = []
headers = []
docs = ["README.md"]
man = []
Rules
All paths relative to build output
Must install into staged root (DESTDIR)
1.8 [patches]
[patches]
files = [
"patches/0001-fix-redox.patch"
]
1.9 [compat]
Tracks conversion origin.
[compat]
imported_from = "aur"
original_pkgbuild = "PKGBUILD"
conversion_status = "partial" # full | partial | manual
target = "x86_64-unknown-redox"
1.10 [policy]
[policy]
allow_network = false
allow_tests = true
review_required = true
2. .RBSRCINFO (Metadata Cache)
Purpose
Fast search/index
No recipe parsing needed
Format (INI-like)
pkgname = ripgrep
pkgver = 14.1.0
pkgrel = 1
pkgdesc = Fast recursive search tool
arch = x86_64-unknown-redox
depends =
makedepends = cargo rust
source = https://...
sha256sums = ...
provides =
conflicts =
3. BUR Repository Spec
Structure
ripgrep/
RBPKGBUILD
.RBSRCINFO
patches/
import/
PKGBUILD
report.txt
4. cub CLI Specification
4.1 General
Single binary: cub
Rust implementation
Subcommands via flags (not separate tools)
4.2 Core Commands
Search
cub -Ss <query>
Install
cub -S <package>
Resolution order:
official repo
BUR (RBPKGBUILD)
AUR import (optional flag)
Build local
cub -B .
Fetch recipe
cub -G <package>
Inspect
cub -Pi <package|RBPKGBUILD>
Update system
cub -Sua
Clean cache
cub -Sc
Convert AUR
cub --import-aur <url|name>
Outputs:
RBPKGBUILD
patches/
report.txt
5. PKGBUILD → RBPKGBUILD Conversion
5.1 Conversion Stages
Stage 1 — Parse
Extract:
pkgname
pkgver
depends
source
functions
Stage 2 — Normalize
Resolve arrays
Expand variables
Strip bash constructs
Stage 3 — Map
PKGBUILD RBPKGBUILD
pkgname package.name
pkgver package.version
depends dependencies.runtime
makedepends dependencies.build
source source.sources
Stage 4 — Detect build system
Patterns:
Pattern Template
cargo build cargo
./configure configure
cmake cmake
meson meson
none custom
Stage 5 — Generate RBPKGBUILD
Fill required fields
Insert detected template
Add compat section
Stage 6 — Patch generation
If:
/usr/lib/systemd
/proc
systemctl
→ generate:
patch stub
warning entry
Stage 7 — Report
report.txt
Conversion: PARTIAL
Warnings:
- Uses systemd
- Hardcoded /usr/lib
Actions required:
- Patch install paths
- Remove systemctl usage
5.2 Conversion Modes
Mode Description
full fully automated
partial needs patches
manual user intervention
6. Build Execution
Environment
TARGET=x86_64-unknown-redox
GNU_TARGET=x86_64-redox
DESTDIR=/build/stage
PREFIX=/usr
CORES=8
Sandbox Rules
No network after fetch
Isolated filesystem
No host writes
Controlled PATH
Execution Flow
cub
→ parse RBPKGBUILD
→ generate Cookbook recipe
→ run build
→ stage files
→ create pkgar
→ install
7. Dependency Mapping
Mapping file
[mapping]
glibc = "relibc-compat"
base-devel = "build-base"
8. Error Handling
Hard Fail
Missing source hash
Unknown build template
Unsupported architecture
Soft Fail (warn)
Linux-specific paths
missing tests
partial conversion
9. Security Model
BUR = untrusted
Require review on first install
Signed packages preferred
Build sandbox enforced
10. MVP Scope
MUST implement
RBPKGBUILD parser
Cookbook adapter
pkgar integration
cub CLI core commands
basic AUR conversion
dependency mapping
sandbox build
MUST NOT implement yet
full PKGBUILD shell compatibility
split packages
pacman compatibility
hook system
11. Final Definition
RBPKGBUILD is a declarative Red Bear build wrapper over Cookbook recipes.
cub is a Rust CLI tool that manages installation, building, and conversion from AUR PKGBUILD into RBPKGBUILD, using BUR as the community repository.
All builds target x86_64-unknown-redox and produce pkgar packages.
+3 -3
View File
@@ -71,13 +71,13 @@ redox-master/ ← git pull updates mainline Redox
│ │ ├── core/ ← ext4d (ext4 filesystem scheme daemon + mkfs tool) │ │ ├── core/ ← ext4d (ext4 filesystem scheme daemon + mkfs tool)
│ │ ├── branding/ ← redbear-release (os-release, hostname, motd) │ │ ├── branding/ ← redbear-release (os-release, hostname, motd)
│ │ ├── drivers/ ← redox-driver-sys, linux-kpi │ │ ├── drivers/ ← redox-driver-sys, linux-kpi
│ │ ├── gpu/ ← redox-drm (AMD + Intel display drivers) │ │ ├── gpu/ ← redox-drm (AMD + Intel display drivers), amdgpu (C port)
│ │ ├── system/ ← evdevd, udev-shim, firmware-loader, redbear-meta │ │ ├── system/ ← evdevd, udev-shim, firmware-loader, redbear-meta
│ │ ├── wayland/ ← Wayland compositor (Phase 4) │ │ ├── wayland/ ← Wayland compositor (Phase 4)
│ │ └── kde/ ← KDE Plasma (Phase 6) │ │ └── kde/ ← KDE Plasma (Phase 6)
│ ├── patches/ │ ├── patches/
│ │ ├── kernel/ ← Kernel patches (ACPI, x2APIC) │ │ ├── kernel/ ← Kernel patches (ACPI, x2APIC)
│ │ ├── base/ ← Base patches (acpid fixes, power methods) │ │ ├── base/ ← Base patches (acpid fixes, power methods, pcid /config endpoint)
│ │ ├── relibc/ ← relibc patches (POSIX: eventfd, signalfd, timerfd) │ │ ├── relibc/ ← relibc patches (POSIX: eventfd, signalfd, timerfd)
│ │ ├── bootloader/ ← Bootloader patches │ │ ├── bootloader/ ← Bootloader patches
│ │ └── installer/ ← Installer patches (ext4 filesystem support) │ │ └── installer/ ← Installer patches (ext4 filesystem support)
@@ -224,7 +224,7 @@ local/Assets/
| loading background.png | Boot splash | Convert to framebuffer-compatible format, display before orbital starts | | loading background.png | Boot splash | Convert to framebuffer-compatible format, display before orbital starts |
| loading background.png | Login screen | Set as orblogin/orbital background | | loading background.png | Login screen | Set as orblogin/orbital background |
**Current status**: Assets are committed to git. Not yet integrated into the build — requires bootloader and display server changes (Phase 2+). **Current status**: Assets are committed to git. Not yet integrated into the build — requires bootloader and display server integration (P2 hardware validation).
## ANTI-PATTERNS ## ANTI-PATTERNS
+5 -5
View File
@@ -20,15 +20,15 @@ P0 ACPI work is **complete**. Kernel patch is 574 lines, base/acpid patch is 558
| DSDT (Differentiated System Description Table) | Parsed by `acpi` crate AML interpreter | Working | Platform-specific device config via AML bytecode | | DSDT (Differentiated System Description Table) | Parsed by `acpi` crate AML interpreter | Working | Platform-specific device config via AML bytecode |
| SSDT (Secondary System Description Table) | Parsed by `acpi` crate AML interpreter | Working | Secondary AML tables (hotplug, etc.) | | SSDT (Secondary System Description Table) | Parsed by `acpi` crate AML interpreter | Working | Secondary AML tables (hotplug, etc.) |
| FACP/FADT | ✅ Full parse in acpid | ✅ Done | PM registers, reset register, sleep states, `\_S5` | | FACP/FADT | ✅ Full parse in acpid | ✅ Done | PM registers, reset register, sleep states, `\_S5` |
| IVRS (AMD-Vi IOMMU) | Removed (broken stub) | Deferred to P2+ | Needs real AMD IOMMU implementation | | IVRS (AMD-Vi IOMMU) | Removed (broken stub) | Deferred to P5+ | Needs real AMD IOMMU implementation |
| MCFG (PCI Express config space) | Removed (broken stub) | Deferred to P2+ | Handled by pcid instead | | MCFG (PCI Express config space) | Removed (broken stub) | ✅ Handled by pcid | pcid /config endpoint provides direct PCI config space access |
| DBG2 (Debug port) | Not implemented | Low | Serial debug port discovery | | DBG2 (Debug port) | Not implemented | Low | Serial debug port discovery |
| BGRT (Boot graphics) | Not implemented | Low | Boot logo preservation | | BGRT (Boot graphics) | Not implemented | Low | Boot logo preservation |
| FPDT (Firmware perf data) | Not implemented | Low | Boot performance metrics | | FPDT (Firmware perf data) | Not implemented | Low | Boot performance metrics |
IVRS and MCFG were previously listed as "implemented" but the stubs were broken. They have IVRS was previously listed as "implemented" but the stub was broken. It has been removed
been removed from acpid. IVRS needs a real AMD IOMMU driver (P2+ scope). MCFG is better from acpid. IVRS needs a real AMD IOMMU driver (P5+ scope). MCFG is now handled by
handled by pcid discovering PCIe config space directly. pcid's /config endpoint (P1 complete) which provides direct PCI config space access.
## Implemented ACPI Tables ## Implemented ACPI Tables
+53 -2
View File
@@ -23,11 +23,11 @@ the LinuxKPI compatibility approach — a clean Rust rewrite would take 5+ years
|-----------|--------|--------| |-----------|--------|--------|
| UEFI boot | ✅ Works | x86_64 UEFI bootloader functional | | UEFI boot | ✅ Works | x86_64 UEFI bootloader functional |
| AMD CPUs | ✅ Works | AMD 32/64-bit supported, Ryzen Threadripper verified | | AMD CPUs | ✅ Works | AMD 32/64-bit supported, Ryzen Threadripper verified |
| ACPI | ⚠️ Incomplete | Framework Laptop 16 crashes on unimplemented ACPI function | | ACPI | ✅ Complete | RSDP/SDT checksums, MADT types 0x4/0x5/0x9/0xA, LVT NMI, FADT shutdown/reboot |
| x2APIC | ✅ Works | Auto-detected via CPUID, APIC/SMP functional | | x2APIC | ✅ Works | Auto-detected via CPUID, APIC/SMP functional |
| HPET | ✅ Works | Timer initialized from ACPI | | HPET | ✅ Works | Timer initialized from ACPI |
| IOMMU | ❌ Missing | No VT-d or AMD-Vi support | | IOMMU | ❌ Missing | No VT-d or AMD-Vi support |
| AMD GPU | ❌ Missing | Only VESA/GOP framebuffer, no acceleration | | AMD GPU | 🚧 In progress | MMIO mapped, DC port compiles, MSI-X wired, no hardware validation yet |
| Wi-Fi/BT | ❌ Missing | No wireless support | | Wi-Fi/BT | ❌ Missing | No wireless support |
| USB | ⚠️ Variable | Some USB controllers work, others don't | | USB | ⚠️ Variable | Some USB controllers work, others don't |
@@ -223,6 +223,57 @@ ONLY the display/modesetting portion first, using linux-kpi headers.
--- ---
## P1/P2 IMPLEMENTATION STATUS (2026-04-12)
### P1: Driver Infrastructure — COMPLETE (compiles)
| Component | Status | Files |
|-----------|--------|-------|
| redox-driver-sys | ✅ | `local/recipes/drivers/redox-driver-sys/source/` — PCI, IRQ (MSI-X), MMIO, DMA |
| linux-kpi | ✅ | `local/recipes/drivers/linux-kpi/source/` — C compat headers + Rust shims |
| firmware-loader | ✅ | `local/recipes/system/firmware-loader/source/` — scheme:firmware daemon |
| pcid /config endpoint | ✅ | `local/patches/base/P0-pcid-config-endpoint.patch` — raw PCI config space via scheme:pci |
| MSI-X interrupt support | ✅ | `local/recipes/gpu/redox-drm/source/src/drivers/interrupt.rs` — shared MSI-X/legacy abstraction |
| Intel pcid-spawner config | ✅ | `local/config/pcid.d/intel_gpu.toml` — auto-detect Intel GPUs |
### P2: AMD GPU Display — COMPLETE (compiles, no HW validation)
| Component | Status | Files |
|-----------|--------|-------|
| redox-drm daemon | ✅ | `local/recipes/gpu/redox-drm/source/` — DRM scheme daemon |
| AMD driver (Rust) | ✅ | `local/recipes/gpu/redox-drm/source/src/drivers/amd/mod.rs` |
| AMD DisplayCore (FFI) | ✅ | `local/recipes/gpu/redox-drm/source/src/drivers/amd/display.rs` |
| AMD PCI stubs (dynamic) | ✅ | `local/recipes/gpu/amdgpu/source/redox_stubs.c` — populated from Rust via FFI |
| AMD DC init (C) | ✅ | `local/recipes/gpu/amdgpu/source/amdgpu_redox_main.c` — modesetting, connector detect |
| AMD glue headers | ✅ | `local/recipes/gpu/amdgpu/source/redox_glue.h` — Linux compat surface |
| GTT manager | ✅ | `local/recipes/gpu/redox-drm/source/src/drivers/amd/gtt.rs` |
| Ring buffer | ✅ | `local/recipes/gpu/redox-drm/source/src/drivers/amd/ring.rs` |
| GEM buffer mgmt | ✅ | `local/recipes/gpu/redox-drm/source/src/gem.rs` |
| DMA-BUF | ✅ | `local/recipes/gpu/redox-drm/source/src/dmabuf.rs` |
| Intel driver | ✅ | `local/recipes/gpu/redox-drm/source/src/drivers/intel/mod.rs` + `display.rs` |
### Build Verification
All crates compile with `cargo check` (0 errors):
- `redox-driver-sys`
- `linux-kpi`
- `redox-drm`
- `firmware-loader`
- `evdevd`
- `udev-shim`
- `ext4d`
### Next Steps (P2 → P3)
P2 code compiles but has NOT been validated on real hardware. Remaining:
1. Flash Red Bear OS image to USB, boot on AMD hardware with RDNA2/RDNA3 GPU
2. Verify pcid exposes `/scheme/pci/{addr}/config` and MSI-X vectors allocate
3. Verify redox-drm detects GPU, maps MMIO, initializes DC
4. Test connector detection and modesetting via scheme:drm
5. Begin P3 (POSIX gaps + evdevd) in parallel with hardware validation
---
## PHASE 3: INPUT + POSIX (4-8 weeks, parallel with Phase 2) ## PHASE 3: INPUT + POSIX (4-8 weeks, parallel with Phase 2)
### P3-1: relibc POSIX Gaps (2-4 weeks) ### P3-1: relibc POSIX Gaps (2-4 weeks)
+30 -6
View File
@@ -25,7 +25,7 @@ DRM scheme daemon. Registers scheme:drm/card0.
- GEM: buffer object create/mmap/close - GEM: buffer object create/mmap/close
- Dispatches to AMD driver backend - Dispatches to AMD driver backend
### amdgpu source (local/recipes/gpu/amdgpu-source/) ### amdgpu C port (local/recipes/gpu/amdgpu/source/)
AMD GPU driver source extracted from Linux 7.0-rc7: AMD GPU driver source extracted from Linux 7.0-rc7:
- drivers/gpu/drm/amd/ — full AMD driver (269k lines) - drivers/gpu/drm/amd/ — full AMD driver (269k lines)
- drivers/gpu/drm/ttm/ — TTM memory manager - drivers/gpu/drm/ttm/ — TTM memory manager
@@ -38,11 +38,10 @@ Compiles AMD DC display code against linux-kpi headers with -D__redox__:
- redox_glue.h — type compatibility, function stubs, macro replacements - redox_glue.h — type compatibility, function stubs, macro replacements
- redox_stubs.c — C implementations of Linux kernel API stubs - redox_stubs.c — C implementations of Linux kernel API stubs
- amdgpu_redox_main.c — daemon entry point replacing module_init - amdgpu_redox_main.c — daemon entry point replacing module_init
- Makefile.redox — standalone build for development
## Build Integration ## Build Integration
Config: local/config/my-amd-desktop.toml Config: config/redbear-desktop.toml (includes desktop.toml + Red Bear GPU packages)
- Includes redox-drm and amdgpu packages - Includes redox-drm and amdgpu packages
- filesystem_size = 8196 (8GB, needs space for firmware blobs) - filesystem_size = 8196 (8GB, needs space for firmware blobs)
@@ -89,9 +88,12 @@ pcid: local/config/pcid.d/amd_gpu.toml
|------|---------| |------|---------|
| local/recipes/gpu/redox-drm/ | DRM scheme daemon | | local/recipes/gpu/redox-drm/ | DRM scheme daemon |
| local/recipes/gpu/amdgpu/ | Build recipe + integration glue | | local/recipes/gpu/amdgpu/ | Build recipe + integration glue |
| local/recipes/gpu/amdgpu-source/ | AMD driver source (from Linux 7.0-rc7) | | local/recipes/gpu/amdgpu/source/ | AMD driver C port source (from Linux 7.0-rc7) |
| local/config/my-amd-desktop.toml | Build config | | config/redbear-desktop.toml | Build config |
| local/config/pcid.d/amd_gpu.toml | PCI auto-detection | | local/config/pcid.d/amd_gpu.toml | PCI auto-detection (AMD) |
| local/recipes/gpu/redox-drm/source/src/drivers/interrupt.rs | MSI-X/legacy interrupt abstraction |
| local/config/pcid.d/intel_gpu.toml | Intel GPU PCI auto-detection |
| local/patches/base/P0-pcid-config-endpoint.patch | pcid /config file endpoint |
| local/scripts/build-amd.sh | Build wrapper | | local/scripts/build-amd.sh | Build wrapper |
| local/scripts/test-amd-gpu.sh | Test script | | local/scripts/test-amd-gpu.sh | Test script |
@@ -102,3 +104,25 @@ pcid: local/config/pcid.d/amd_gpu.toml
| redox-driver-sys | ✅ | MmioRegion, PciDevice, IrqHandle, DmaBuffer | | redox-driver-sys | ✅ | MmioRegion, PciDevice, IrqHandle, DmaBuffer |
| linux-kpi | ✅ | C headers, FFI stubs (kmalloc, mutex, spinlock...) | | linux-kpi | ✅ | C headers, FFI stubs (kmalloc, mutex, spinlock...) |
| firmware-loader | ✅ | scheme:firmware daemon | | firmware-loader | ✅ | scheme:firmware daemon |
## P1/P2 Changes Since Initial Implementation
### pcid /config endpoint (T1)
- Added `Config { addr: PciAddress }` handle to pcid scheme
- Routes `/scheme/pci/{addr}/config` to raw PCI config space read/write
- Enables redox-driver-sys PciDevice to access config space for MSI-X, BAR parsing
### MSI-X interrupt support (T2-T4)
- Created shared `InterruptHandle` enum in `redox-drm/src/drivers/interrupt.rs`
- Tries MSI-X first (find capability → parse → map table → mask_all → enable → request_vector)
- Falls back to legacy IRQ if MSI-X unavailable
- Both AMD and Intel drivers use `InterruptHandle::setup()`
### Dynamic PCI device info (T6)
- Replaced hardcoded `redox_pci_find_amd_gpu()` stub with `redox_pci_set_device_info()`
- Rust side passes real PciDeviceInfo (vendor, device, revision, IRQ, BAR0/BAR2) to C via FFI
- C layer validates the struct is populated before `amdgpu_redox_init()` uses it
### Intel GPU support (T4-T5)
- Intel driver switched to shared `InterruptHandle` (MSI-X + legacy)
- Added `local/config/pcid.d/intel_gpu.toml` for auto-detection (vendor 0x8086, class 0x03)