diff --git a/Cargo.lock b/Cargo.lock index bb4deae74f..b414217d61 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -641,6 +641,7 @@ dependencies = [ "common", "fdt 0.1.5", "log", + "redox-daemon", "ron", ] diff --git a/hwd/Cargo.toml b/hwd/Cargo.toml index b592f2da71..9089880e81 100644 --- a/hwd/Cargo.toml +++ b/hwd/Cargo.toml @@ -6,6 +6,7 @@ edition = "2018" [dependencies] fdt = "0.1.5" log = "0.4" +redox-daemon = "0.1" ron = "0.8.1" amlserde = { path = "../amlserde" } diff --git a/hwd/src/main.rs b/hwd/src/main.rs index afe85a1f45..b5dc4db127 100644 --- a/hwd/src/main.rs +++ b/hwd/src/main.rs @@ -1,9 +1,9 @@ -use std::process::Command; +use std::process; mod backend; use self::backend::{AcpiBackend, Backend, DeviceTreeBackend, LegacyBackend}; -fn main() { +fn daemon(daemon: redox_daemon::Daemon) -> ! { common::setup_logging( "misc", "hwd", @@ -37,7 +37,7 @@ fn main() { //TODO: launch pcid based on backend information? // Must launch after acpid but before probe calls /scheme/acpi/symbols - match Command::new("pcid").spawn() { + match process::Command::new("pcid").spawn() { Ok(mut child) => match child.wait() { Ok(status) => if !status.success() { log::error!("pcid exited with status {}", status); @@ -50,12 +50,21 @@ fn main() { log::error!("failed to spawn pcid: {}", err); } } + + daemon.ready().expect("hwd: failed to notify parent"); //TODO: HWD is meant to locate PCI/XHCI/etc devices in ACPI and DeviceTree definitions and start their drivers match backend.probe() { - Ok(()) => {} + Ok(()) => { + process::exit(0); + } Err(err) => { log::error!("failed to probe with error {}", err); + process::exit(1); } } } + +fn main() { + redox_daemon::Daemon::new(daemon).expect("hwd: failed to daemonize"); +} \ No newline at end of file