WIP: Predictable naming

This commit is contained in:
Jeremy Soller 2016-11-21 12:23:17 -07:00
parent 86d676b540
commit 9d37f38849
8 changed files with 26 additions and 11 deletions

View file

@ -7,7 +7,7 @@ pub mod disk;
pub mod fis;
pub mod hba;
pub fn disks(base: usize) -> Vec<Disk> {
pub fn disks(base: usize, name: &str) -> Vec<Disk> {
unsafe { &mut *(base as *mut HbaMem) }.init();
let pi = unsafe { &mut *(base as *mut HbaMem) }.pi.read();
let ret: Vec<Disk> = (0..32)
@ -15,7 +15,7 @@ pub fn disks(base: usize) -> Vec<Disk> {
.filter_map(|i| {
let port = &mut unsafe { &mut *(base as *mut HbaMem) }.ports[i];
let port_type = port.probe();
print!("{}", format!("{}: {:?}\n", i, port_type));
print!("{}", format!("{}-{}: {:?}\n", name, i, port_type));
match port_type {
HbaPortType::SATA => {
match Disk::new(i, port) {

View file

@ -21,13 +21,16 @@ pub mod scheme;
fn main() {
let mut args = env::args().skip(1);
let mut name = args.next().expect("ahcid: no name provided");
name.push_str("_ahci");
let bar_str = args.next().expect("ahcid: no address provided");
let bar = usize::from_str_radix(&bar_str, 16).expect("ahcid: failed to parse address");
let irq_str = args.next().expect("ahcid: no irq provided");
let irq = irq_str.parse::<u8>().expect("ahcid: failed to parse irq");
print!("{}", format!(" + AHCI on: {:X} IRQ: {}\n", bar, irq));
print!("{}", format!(" + AHCI {} on: {:X} IRQ: {}\n", name, bar, irq));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {
@ -43,7 +46,7 @@ fn main() {
let mut event_file = File::open("event:").expect("ahcid: failed to open event file");
let scheme = DiskScheme::new(ahci::disks(address));
let scheme = DiskScheme::new(ahci::disks(address, &name));
loop {
let mut event = Event::default();
if event_file.read(&mut event).expect("ahcid: failed to read event file") == 0 {

View file

@ -21,13 +21,16 @@ pub mod device;
fn main() {
let mut args = env::args().skip(1);
let mut name = args.next().expect("e1000d: no name provided");
name.push_str("_e1000");
let bar_str = args.next().expect("e1000d: no address provided");
let bar = usize::from_str_radix(&bar_str, 16).expect("e1000d: failed to parse address");
let irq_str = args.next().expect("e1000d: no irq provided");
let irq = irq_str.parse::<u8>().expect("e1000d: failed to parse irq");
print!("{}", format!(" + E1000 on: {:X}, IRQ: {}\n", bar, irq));
print!("{}", format!(" + E1000 {} on: {:X}, IRQ: {}\n", name, bar, irq));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {

View file

@ -125,6 +125,10 @@ fn main() {
}
};
let arg = match arg.as_str() {
"$BUS" => format!("{:>02X}", bus.num),
"$DEV" => format!("{:>02X}", dev.num),
"$FUNC" => format!("{:>02X}", func.num),
"$NAME" => format!("pci-{:>02X}.{:>02X}.{:>02X}", bus.num, dev.num, func.num),
"$BAR0" => bar_arg(0),
"$BAR1" => bar_arg(1),
"$BAR2" => bar_arg(2),
@ -137,6 +141,8 @@ fn main() {
command.arg(&arg);
}
println!("PCID SPAWN {:?}", command);
match command.spawn() {
Ok(mut child) => match child.wait() {
Ok(_status) => (), //println!("pcid: waited for {}: {:?}", line, status.code()),

View file

@ -22,13 +22,16 @@ pub mod device;
fn main() {
let mut args = env::args().skip(1);
let mut name = args.next().expect("rtl8168d: no name provided");
name.push_str("_rtl8168");
let bar_str = args.next().expect("rtl8168d: no address provided");
let bar = usize::from_str_radix(&bar_str, 16).expect("rtl8168d: failed to parse address");
let irq_str = args.next().expect("rtl8168d: no irq provided");
let irq = irq_str.parse::<u8>().expect("rtl8168d: failed to parse irq");
print!("{}", format!(" + RTL8168 on: {:X}, IRQ: {}\n", bar, irq));
print!("{}", format!(" + RTL8168 {} on: {:X}, IRQ: {}\n", name, bar, irq));
// Daemonize
if unsafe { syscall::clone(0).unwrap() } == 0 {

View file

@ -1,6 +1,6 @@
initfs:bin/pcid /etc/pcid.toml
ptyd
randd
ptyd
initfs:bin/pcid /etc/pcid.toml
ethernetd
ipd
tcpd

View file

@ -3,11 +3,11 @@ name = "E1000 NIC"
class = 2
vendor = 32902
device = 4110
command = ["e1000d", "$BAR0", "$IRQ"]
command = ["e1000d", "$NAME", "$BAR0", "$IRQ"]
[[drivers]]
name = "RTL8168 NIC"
class = 2
vendor = 4332
device = 33128
command = ["rtl8168d", "$BAR2", "$IRQ"]
command = ["rtl8168d", "$NAME", "$BAR2", "$IRQ"]

View file

@ -2,4 +2,4 @@
name = "AHCI storage"
class = 1
subclass = 6
command = ["initfs:bin/ahcid", "$BAR5", "$IRQ"]
command = ["initfs:bin/ahcid", "$NAME", "$BAR5", "$IRQ"]