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]]
name = "isomorphic_drivers"
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 = [
"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)",

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

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

Loading…
Cancel
Save