diff --git a/src/drivers/atapi/mod.rs b/src/drivers/atapi/mod.rs index e296595..a2ffe2b 100644 --- a/src/drivers/atapi/mod.rs +++ b/src/drivers/atapi/mod.rs @@ -106,10 +106,7 @@ impl ATABus { fn discover_atapi_drive() -> Option { let mut primary_bus = ATABus::new(ATA_BUS_PRIMARY); - unsafe { - primary_bus.dcr.write(ATA_SRST); - primary_bus.dcr.write(0); - } + primary_bus.software_reset(); primary_bus.select_drive(ATA_DRIVE_MASTER); if primary_bus.is_atapi() { @@ -123,10 +120,7 @@ impl ATABus { let mut secondary_bus = ATABus::new(ATA_BUS_SECONDARY); - unsafe { - secondary_bus.dcr.write(ATA_SRST); - primary_bus.dcr.write(0); - } + secondary_bus.software_reset(); secondary_bus.select_drive(ATA_DRIVE_MASTER); if secondary_bus.is_atapi() { @@ -140,6 +134,13 @@ impl ATABus { None } + fn software_reset(&mut self) { + unsafe { + self.dcr.write(ATA_SRST); + self.dcr.write(0); + } + } + fn new(port: u16) -> Self { ATABus { base_port: port, diff --git a/src/interrupts/pic/disk.rs b/src/interrupts/pic/disk.rs index 2288cf9..3747b89 100644 --- a/src/interrupts/pic/disk.rs +++ b/src/interrupts/pic/disk.rs @@ -21,4 +21,4 @@ pub extern "x86-interrupt" fn disk2_interrupt_handler(_stack_frame: InterruptSta PICS.lock() .notify_end_of_interrupt(InterruptIndex::HardDisk2.as_u8()); } -} \ No newline at end of file +} diff --git a/src/interrupts/pic/mod.rs b/src/interrupts/pic/mod.rs index f27d68d..ca8d510 100644 --- a/src/interrupts/pic/mod.rs +++ b/src/interrupts/pic/mod.rs @@ -35,5 +35,8 @@ pub static PICS: spin::Mutex = pub fn init_pic() { println!("Initializing PIC"); - unsafe { PICS.lock().initialize() }; + unsafe { + PICS.lock().initialize(); + PICS.lock().write_masks(0b10111000, 0b00001110); + }; }