Allow ahci port init to fail

master
Jiajie Chen 6 years ago
parent 0be1b1e56b
commit 22946c699d

2
kernel/Cargo.lock generated

@ -204,7 +204,7 @@ dependencies = [
[[package]] [[package]]
name = "isomorphic_drivers" name = "isomorphic_drivers"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/rcore-os/isomorphic_drivers#fe4af36d5f7bf3ac32be77597ccc61fc8cf8bd98" source = "git+https://github.com/rcore-os/isomorphic_drivers#b6492b0759e4d6819f6591c3d29ef5ed83138531"
dependencies = [ dependencies = [
"bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)",

@ -43,10 +43,13 @@ impl Driver for AHCIDriver {
} }
} }
pub fn init(_irq: Option<u32>, header: usize, size: usize) -> Arc<AHCIDriver> { pub fn init(_irq: Option<u32>, header: usize, size: usize) -> Option<Arc<AHCIDriver>> {
let ahci = AHCI::new(header, size); if let Some(ahci) = AHCI::new(header, size) {
let driver = Arc::new(AHCIDriver(Mutex::new(ahci))); let driver = Arc::new(AHCIDriver(Mutex::new(ahci)));
DRIVERS.write().push(driver.clone()); DRIVERS.write().push(driver.clone());
BLK_DRIVERS.write().push(driver.clone()); BLK_DRIVERS.write().push(driver.clone());
driver Some(driver)
} else {
None
}
} }

@ -174,9 +174,11 @@ pub fn init_driver(dev: &PCIDevice) {
let irq = unsafe { enable(dev.loc) }; let irq = unsafe { enable(dev.loc) };
assert!(len as usize <= PAGE_SIZE); assert!(len as usize <= PAGE_SIZE);
let vaddr = phys_to_virt(addr as usize); let vaddr = phys_to_virt(addr as usize);
PCI_DRIVERS if let Some(driver) = ahci::init(irq, vaddr, len as usize) {
.lock() PCI_DRIVERS
.insert(dev.loc, ahci::init(irq, vaddr, len as usize)); .lock()
.insert(dev.loc, driver);
}
} }
} }
_ => {} _ => {}

Loading…
Cancel
Save