Files
RedBear-OS/local/patches/base/P2-hwd-misc.patch
T
vasilito 220f053ad8 Complete base patch split and update rust toolchain
Base patch extraction (12 new patches, 11,017 lines from the 17k monolith):
- P2-acpid-core-refactor: acpi.rs, dmar, aml_physmem, ec, scheme (3,150 lines)
- P2-ihdad-device-refactor: CodecTopology, ControllerPolicy, InputStream (1,022 lines)
- P2-ac97d-ihdad-main: AC97 + ihdad daemon error handling (287 lines)
- P2-inputd: inputd lib + main with named producers (896 lines)
- P2-network-driver-mains: e1000/ixgbe/rtl8139/rtl8168d/virtio-net mains (607 lines)
- P2-pcid-driver-interface: BAR, cap, config, IRQ helpers, MSI, scheme (1,463 lines)
- P2-storage-driver-mains: ahcid/ided/nvmed/virtio-blk main.rs files (625 lines)
- P2-xhcid-remaining: xhcid main, device_enumerator, xhci mod+scheme (2,033 lines)
- P2-virtio-core-vbox: virtio-core arch/probe/transport + vboxd (413 lines)
- P2-init-subsystems: scheduler, service, unit management (292 lines)
- P2-logd: logd main + scheme (164 lines)
- P2-hwd-misc: hwd Cargo.toml + main.rs (64 lines)

Graphics drivers (ihdgd, vesad, virtio-gpud, fbcond scheme/text, graphics-ipc)
already fully covered by existing P2-daemon-hardening.patch — no duplicates created.

Rust toolchain: nightly-2025-10-03 → nightly-2026-04-01 (1.96.0-nightly).
Cookbook builds clean, no feature gates in codebase.
2026-04-25 19:30:53 +01:00

65 lines
2.3 KiB
Diff

# P2-hwd-misc.patch
# Extract hwd (hardware daemon) Cargo.toml and main.rs improvements.
#
# Files: drivers/hwd/Cargo.toml, drivers/hwd/src/main.rs
diff --git a/drivers/hwd/Cargo.toml b/drivers/hwd/Cargo.toml
index 3d37cfb3..40b51a1b 100644
--- a/drivers/hwd/Cargo.toml
+++ b/drivers/hwd/Cargo.toml
@@ -6,6 +6,7 @@ edition = "2018"
[dependencies]
fdt.workspace = true
+libc.workspace = true
log.workspace = true
ron.workspace = true
libredox = { workspace = true, default-features = false, features = ["std", "call"] }
diff --git a/drivers/hwd/src/main.rs b/drivers/hwd/src/main.rs
index 79360e34..a0462f51 100644
--- a/drivers/hwd/src/main.rs
+++ b/drivers/hwd/src/main.rs
@@ -1,3 +1,5 @@
+use std::os::fd::AsRawFd;
+use std::os::unix::process::CommandExt;
use std::process;
mod backend;
@@ -37,8 +39,34 @@ fn daemon(daemon: daemon::Daemon) -> ! {
//TODO: launch pcid based on backend information?
// Must launch after acpid but before probe calls /scheme/acpi/symbols
- #[allow(deprecated, reason = "we can't yet move this to init")]
- daemon::Daemon::spawn(process::Command::new("pcid"));
+ // Fire-and-forget: daemon::Daemon::spawn blocks until pcid signals readiness,
+ // but pcid only signals after full PCI enumeration. If enumeration hangs on
+ // real hardware (unresponsive device, complex AML), hwd deadlocks initfs.
+ {
+ match std::io::pipe() {
+ Ok((_read_end, write_end)) => {
+ let write_fd: std::os::fd::OwnedFd = write_end.into();
+ let raw_fd = write_fd.as_raw_fd();
+ let mut cmd = std::process::Command::new("pcid");
+ cmd.env("INIT_NOTIFY", raw_fd.to_string());
+ unsafe {
+ cmd.pre_exec(move || {
+ if libc::fcntl(raw_fd, libc::F_SETFD, 0) == -1 {
+ return Err(std::io::Error::last_os_error());
+ }
+ Ok(())
+ });
+ }
+ match cmd.spawn() {
+ Ok(_) => {}
+ Err(err) => log::error!("hwd: failed to spawn pcid: {}", err),
+ }
+ }
+ Err(err) => {
+ log::error!("hwd: failed to create pcid notification pipe: {}", err);
+ }
+ }
+ }
daemon.ready();