Give each driver a per-device ID
This commit is contained in:
parent
5db62208db
commit
09ace0dfed
27
src/main.rs
27
src/main.rs
@ -1,9 +1,6 @@
|
|||||||
#![allow(clippy::verbose_bit_mask)]
|
#![allow(clippy::verbose_bit_mask)]
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
collections::HashMap, fs, io::Cursor, os::mikros::{ipc, syscalls}, path::{Path, PathBuf}
|
||||||
io::Cursor,
|
|
||||||
os::mikros::{ipc, syscalls},
|
|
||||||
path::{Path, PathBuf},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use binread::prelude::*;
|
use binread::prelude::*;
|
||||||
@ -362,6 +359,7 @@ fn main() {
|
|||||||
scan_bus(0, &mut device_vec);
|
scan_bus(0, &mut device_vec);
|
||||||
let srv = PCIServer(device_vec.clone());
|
let srv = PCIServer(device_vec.clone());
|
||||||
pci_rpc::register_server(Box::new(srv));
|
pci_rpc::register_server(Box::new(srv));
|
||||||
|
let mut driver_map: HashMap<PathBuf, Vec<(u8, u8, u8)>> = HashMap::new();
|
||||||
for device in &device_vec {
|
for device in &device_vec {
|
||||||
syslog_client.send_text_message(
|
syslog_client.send_text_message(
|
||||||
"pci",
|
"pci",
|
||||||
@ -399,19 +397,26 @@ fn main() {
|
|||||||
syslog_client
|
syslog_client
|
||||||
.send_text_message("pci", format!(" Driver {}", driver.display()))
|
.send_text_message("pci", format!(" Driver {}", driver.display()))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
std::process::Command::new(driver)
|
|
||||||
.arg(device.bus.to_string())
|
driver_map.entry(driver.to_owned()).or_default().push((device.bus, device.device, device.function));
|
||||||
.arg(device.device.to_string())
|
|
||||||
.arg(device.function.to_string())
|
|
||||||
.arg(syscalls::get_pid().to_string())
|
|
||||||
.spawn()
|
|
||||||
.unwrap();
|
|
||||||
} else {
|
} else {
|
||||||
syslog_client
|
syslog_client
|
||||||
.send_text_message("pci", " WARN: No driver")
|
.send_text_message("pci", " WARN: No driver")
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for (driver, device_list) in driver_map.iter() {
|
||||||
|
for (i, (bus, device, function)) in device_list.iter().enumerate() {
|
||||||
|
std::process::Command::new(driver)
|
||||||
|
.arg(bus.to_string())
|
||||||
|
.arg(device.to_string())
|
||||||
|
.arg(function.to_string())
|
||||||
|
.arg(syscalls::get_pid().to_string())
|
||||||
|
.arg(i.to_string())
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
}
|
||||||
loop {
|
loop {
|
||||||
ipc::process_messages();
|
ipc::process_messages();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user