Disable PIC

master
WangRunji 7 years ago
parent cf099ffa99
commit 8af7220d25

@ -1,6 +1,6 @@
pub fn init() { pub fn init() {
use consts::irq::IRQ_KBD; use consts::irq::IRQ_KBD;
// TODO set irq handler // TODO set irq handler
super::pic::enable_irq(IRQ_KBD); // super::pic::enable_irq(IRQ_KBD);
super::apic::IOAPIC.lock().enable(IRQ_KBD, 0); super::apic::IOAPIC.lock().enable(IRQ_KBD, 0);
} }

@ -1,9 +1,18 @@
// Copy from Redox
use syscall::io::*; use syscall::io::*;
use spin::Mutex; use spin::Mutex;
static MASTER: Mutex<Pic> = Mutex::new(Pic::new(0x20)); static MASTER: Mutex<Pic> = Mutex::new(Pic::new(0x20));
static SLAVE: Mutex<Pic> = Mutex::new(Pic::new(0xA0)); static SLAVE: Mutex<Pic> = Mutex::new(Pic::new(0xA0));
pub fn disable() {
// Mask all interrupts (Copy from xv6 x86_64)
MASTER.lock().cmd.write(0xFF);
SLAVE.lock().cmd.write(0xFF);
debug!("pic: disabled");
}
pub fn init() { pub fn init() {
assert_has_not_been_called!("pic::init must be called only once"); assert_has_not_been_called!("pic::init must be called only once");
@ -33,6 +42,8 @@ pub fn init() {
// Ack remaining interrupts // Ack remaining interrupts
master.ack(); master.ack();
slave.ack(); slave.ack();
debug!("pic: init end");
} }
pub fn enable_irq(irq: u8) pub fn enable_irq(irq: u8)

@ -76,12 +76,12 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) {
let acpi = arch::driver::acpi::init().expect("Failed to init ACPI"); let acpi = arch::driver::acpi::init().expect("Failed to init ACPI");
debug!("{:?}", acpi); debug!("{:?}", acpi);
arch::driver::pic::disable();
memory_controller.map_page_identity(acpi.lapic_addr as usize); // LAPIC memory_controller.map_page_identity(acpi.lapic_addr as usize); // LAPIC
memory_controller.map_page_identity(0xFEC00000); // IOAPIC memory_controller.map_page_identity(0xFEC00000); // IOAPIC
arch::driver::apic::init(acpi.lapic_addr, acpi.ioapic_id); arch::driver::apic::init(acpi.lapic_addr, acpi.ioapic_id);
arch::driver::pic::init();
test_end!(); test_end!();
} }

Loading…
Cancel
Save