Give each driver a per-device ID

This commit is contained in:
pjht 2024-08-25 11:13:35 -05:00
parent 5db62208db
commit 09ace0dfed
Signed by: pjht
GPG Key ID: 7B5F6AFBEC7EE78E

View File

@ -1,9 +1,6 @@
#![allow(clippy::verbose_bit_mask)]
use std::{
fs,
io::Cursor,
os::mikros::{ipc, syscalls},
path::{Path, PathBuf},
collections::HashMap, fs, io::Cursor, os::mikros::{ipc, syscalls}, path::{Path, PathBuf}
};
use binread::prelude::*;
@ -362,6 +359,7 @@ fn main() {
scan_bus(0, &mut device_vec);
let srv = PCIServer(device_vec.clone());
pci_rpc::register_server(Box::new(srv));
let mut driver_map: HashMap<PathBuf, Vec<(u8, u8, u8)>> = HashMap::new();
for device in &device_vec {
syslog_client.send_text_message(
"pci",
@ -399,19 +397,26 @@ fn main() {
syslog_client
.send_text_message("pci", format!(" Driver {}", driver.display()))
.unwrap();
std::process::Command::new(driver)
.arg(device.bus.to_string())
.arg(device.device.to_string())
.arg(device.function.to_string())
.arg(syscalls::get_pid().to_string())
.spawn()
.unwrap();
driver_map.entry(driver.to_owned()).or_default().push((device.bus, device.device, device.function));
} else {
syslog_client
.send_text_message("pci", " WARN: No driver")
.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 {
ipc::process_messages();
}