40ba2caaf6
Graceful init patches for fbcond, graphics scheme, smolnetd, vesad, PCI interrupt allocation, BAR probing, common init, inputd fallback, and dhcpd hard dependency ordering.
177 lines
6.9 KiB
Diff
177 lines
6.9 KiB
Diff
diff --git a/drivers/acpid/src/main.rs b/drivers/acpid/src/main.rs
|
|
index b05102f6..a9d47e09 100644
|
|
--- a/drivers/acpid/src/main.rs
|
|
+++ b/drivers/acpid/src/main.rs
|
|
@@ -204,6 +204,6 @@ fn daemon(daemon: daemon::Daemon) -> ! {
|
|
}
|
|
|
|
fn main() {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("acpid: failed to initialize common: {err}"); std::process::exit(1); }
|
|
daemon::Daemon::new(daemon);
|
|
}
|
|
diff --git a/drivers/common/src/lib.rs b/drivers/common/src/lib.rs
|
|
index b6661e3a..a55014b9 100644
|
|
--- a/drivers/common/src/lib.rs
|
|
+++ b/drivers/common/src/lib.rs
|
|
@@ -29,22 +29,13 @@ use std::sync::OnceLock;
|
|
static MEMORY_ROOT_FD: OnceLock<libredox::Fd> = OnceLock::new();
|
|
|
|
/// Initializes a file descriptor to be used as the root memory for a driver.
|
|
-///
|
|
-/// # Panics
|
|
-///
|
|
-/// This function will panic if:
|
|
-/// - `libredox` is unable to open a file descriptor.
|
|
-/// - The memory root file descriptor has already been set (this function has already been called).
|
|
-pub fn init() {
|
|
- if MEMORY_ROOT_FD
|
|
- .set(
|
|
- libredox::Fd::open("/scheme/memory/scheme-root", 0, 0)
|
|
- .expect("drivers common: failed to open memory root fd"),
|
|
- )
|
|
- .is_err()
|
|
- {
|
|
- panic!("drivers common: failed to set memory root fd");
|
|
- }
|
|
+pub fn init() -> std::io::Result<()> {
|
|
+ let fd = libredox::Fd::open("/scheme/memory/scheme-root", 0, 0)
|
|
+ .map_err(|err| std::io::Error::new(std::io::ErrorKind::Other, format!("failed to open memory root fd: {err}")))?;
|
|
+ MEMORY_ROOT_FD
|
|
+ .set(fd)
|
|
+ .map_err(|_| std::io::Error::new(std::io::ErrorKind::AlreadyExists, "memory root fd already initialized"))?;
|
|
+ Ok(())
|
|
}
|
|
|
|
/// Gets the memory root file descriptor.
|
|
diff --git a/drivers/gpio/intel-gpiod/src/main.rs b/drivers/gpio/intel-gpiod/src/main.rs
|
|
index aa651713..e9671068 100644
|
|
--- a/drivers/gpio/intel-gpiod/src/main.rs
|
|
+++ b/drivers/gpio/intel-gpiod/src/main.rs
|
|
@@ -95,7 +95,7 @@ fn daemon_runner(daemon: daemon::Daemon) -> ! {
|
|
}
|
|
|
|
fn daemon_main(daemon: daemon::Daemon) -> Result<()> {
|
|
- common::init();
|
|
+ common::init().map_err(|err| anyhow::anyhow!("failed to initialize common: {err}"))?;
|
|
|
|
let controllers =
|
|
discover_controllers(SUPPORTED_IDS).context("failed to discover Intel GPIO controllers")?;
|
|
diff --git a/drivers/graphics/fbbootlogd/src/main.rs b/drivers/graphics/fbbootlogd/src/main.rs
|
|
index 055e1db6..b8ad2294 100644
|
|
--- a/drivers/graphics/fbbootlogd/src/main.rs
|
|
+++ b/drivers/graphics/fbbootlogd/src/main.rs
|
|
@@ -21,7 +21,7 @@ use crate::scheme::FbbootlogScheme;
|
|
mod scheme;
|
|
|
|
fn main() {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("fbbootlogd: failed to initialize common: {err}"); std::process::exit(1); }
|
|
daemon::SchemeDaemon::new(daemon);
|
|
}
|
|
fn daemon(daemon: daemon::SchemeDaemon) -> ! {
|
|
diff --git a/drivers/graphics/fbcond/src/main.rs b/drivers/graphics/fbcond/src/main.rs
|
|
index 2e428353..003527ba 100644
|
|
--- a/drivers/graphics/fbcond/src/main.rs
|
|
+++ b/drivers/graphics/fbcond/src/main.rs
|
|
@@ -16,7 +16,7 @@ mod scheme;
|
|
mod text;
|
|
|
|
fn main() {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("fbcond: failed to initialize common: {err}"); std::process::exit(1); }
|
|
daemon::SchemeDaemon::new(daemon);
|
|
}
|
|
fn daemon(daemon: daemon::SchemeDaemon) -> ! {
|
|
diff --git a/drivers/graphics/vesad/src/main.rs b/drivers/graphics/vesad/src/main.rs
|
|
index 6f55913b..5fee9041 100644
|
|
--- a/drivers/graphics/vesad/src/main.rs
|
|
+++ b/drivers/graphics/vesad/src/main.rs
|
|
@@ -12,7 +12,7 @@ use crate::scheme::{FbAdapter, FrameBuffer};
|
|
mod scheme;
|
|
|
|
fn main() {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("vesad: failed to initialize common: {err}"); std::process::exit(1); }
|
|
daemon::Daemon::new(daemon);
|
|
}
|
|
fn daemon(daemon: daemon::Daemon) -> ! {
|
|
diff --git a/drivers/i2c/dw-acpi-i2cd/src/main.rs b/drivers/i2c/dw-acpi-i2cd/src/main.rs
|
|
index 796d0ed3..f3491103 100644
|
|
--- a/drivers/i2c/dw-acpi-i2cd/src/main.rs
|
|
+++ b/drivers/i2c/dw-acpi-i2cd/src/main.rs
|
|
@@ -80,7 +80,7 @@ fn daemon_runner(daemon: daemon::Daemon) -> ! {
|
|
}
|
|
|
|
fn daemon_main(daemon: daemon::Daemon) -> Result<()> {
|
|
- common::init();
|
|
+ common::init().map_err(|err| anyhow::anyhow!("failed to initialize common: {err}"))?;
|
|
|
|
let controllers = discover_controllers(SUPPORTED_IDS)
|
|
.context("failed to discover DesignWare ACPI I2C controllers")?;
|
|
diff --git a/drivers/i2c/intel-lpss-i2cd/src/main.rs b/drivers/i2c/intel-lpss-i2cd/src/main.rs
|
|
index 7b29d737..e651610b 100644
|
|
--- a/drivers/i2c/intel-lpss-i2cd/src/main.rs
|
|
+++ b/drivers/i2c/intel-lpss-i2cd/src/main.rs
|
|
@@ -80,7 +80,7 @@ fn daemon_runner(daemon: daemon::Daemon) -> ! {
|
|
}
|
|
|
|
fn daemon_main(daemon: daemon::Daemon) -> Result<()> {
|
|
- common::init();
|
|
+ common::init().map_err(|err| anyhow::anyhow!("failed to initialize common: {err}"))?;
|
|
|
|
let controllers = discover_controllers(SUPPORTED_IDS)
|
|
.context("failed to discover Intel LPSS ACPI I2C controllers")?;
|
|
diff --git a/drivers/pcid/src/driver_interface/mod.rs b/drivers/pcid/src/driver_interface/mod.rs
|
|
index 8776dd4a..3b6a98a1 100644
|
|
--- a/drivers/pcid/src/driver_interface/mod.rs
|
|
+++ b/drivers/pcid/src/driver_interface/mod.rs
|
|
@@ -491,7 +491,7 @@ impl PciFunctionHandle {
|
|
|
|
pub fn pci_daemon<F: FnOnce(Daemon, PciFunctionHandle) -> !>(f: F) -> ! {
|
|
Daemon::new(|daemon| {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("pci_daemon: failed to initialize common: {err}"); std::process::exit(1); }
|
|
let pcid_handle = PciFunctionHandle::connect_default();
|
|
f(daemon, pcid_handle)
|
|
})
|
|
diff --git a/drivers/pcid/src/main.rs b/drivers/pcid/src/main.rs
|
|
index bda473e4..e844249f 100644
|
|
--- a/drivers/pcid/src/main.rs
|
|
+++ b/drivers/pcid/src/main.rs
|
|
@@ -245,7 +245,7 @@ fn enable_function(
|
|
}
|
|
|
|
fn main() {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("pcid: failed to initialize common: {err}"); std::process::exit(1); }
|
|
daemon::Daemon::new(daemon);
|
|
}
|
|
|
|
diff --git a/drivers/usb/usbctl/src/main.rs b/drivers/usb/usbctl/src/main.rs
|
|
index 9b5773d9..51a63f75 100644
|
|
--- a/drivers/usb/usbctl/src/main.rs
|
|
+++ b/drivers/usb/usbctl/src/main.rs
|
|
@@ -2,7 +2,7 @@ use clap::{Arg, Command};
|
|
use xhcid_interface::{PortId, XhciClientHandle};
|
|
|
|
fn main() {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("usbctl: failed to initialize common: {err}"); std::process::exit(1); }
|
|
let matches = Command::new("usbctl")
|
|
.arg(
|
|
Arg::new("SCHEME")
|
|
diff --git a/drivers/usb/usbhubd/src/main.rs b/drivers/usb/usbhubd/src/main.rs
|
|
index 2c8b9876..7e69842a 100644
|
|
--- a/drivers/usb/usbhubd/src/main.rs
|
|
+++ b/drivers/usb/usbhubd/src/main.rs
|
|
@@ -6,7 +6,7 @@ use xhcid_interface::{
|
|
};
|
|
|
|
fn main() {
|
|
- common::init();
|
|
+ if let Err(err) = common::init() { eprintln!("usbhubd: failed to initialize common: {err}"); std::process::exit(1); }
|
|
let mut args = env::args().skip(1);
|
|
|
|
const USAGE: &'static str = "usbhubd <scheme> <port> <interface>";
|