ACK for APIC IRQ

master
WangRunji 7 years ago
parent 156034c3d1
commit 3b792baf5b

@ -11,6 +11,7 @@ assembly_source_files := $(wildcard $(boot_src)/*.asm)
assembly_object_files := $(patsubst $(boot_src)/%.asm, \
build/arch/$(arch)/boot/%.o, $(assembly_source_files))
qemu_opts := -cdrom $(iso) -smp 2 -serial mon:stdio
features := use_apic
ifdef travis
test := 1

@ -97,4 +97,12 @@ lapicinit(void)
// Enable interrupts on the APIC (but not on the processor).
lapicw(TPR, 0);
}
// Acknowledge interrupt.
void
lapiceoi(void)
{
if(lapic)
lapicw(EOI, 0);
}

@ -1,6 +1,7 @@
extern {
static mut lapic: *const ();
fn lapicinit(); // must set `lapic` first
fn lapiceoi(); // ack
}
pub fn init(lapic_addr: *const ()) {
@ -10,4 +11,10 @@ pub fn init(lapic_addr: *const ()) {
lapicinit();
}
debug!("lapic: init end");
}
pub fn ack(_irq: u8) {
unsafe {
lapiceoi();
}
}

@ -1,4 +1,5 @@
pub use self::ioapic::IOAPIC;
pub use self::lapic::ack;
mod lapic;
mod ioapic;

@ -0,0 +1,9 @@
use x86_64;
pub fn enable() {
unsafe{ x86_64::instructions::interrupts::enable(); }
}
pub fn disable() {
unsafe{ x86_64::instructions::interrupts::disable(); }
}

@ -4,4 +4,5 @@ pub mod apic;
pub mod mp;
pub mod serial;
pub mod pic;
pub mod console;
pub mod console;
pub mod interrupt;

@ -20,26 +20,30 @@ pub extern "x86-interrupt" fn page_fault_handler(
loop {}
}
use arch::driver::pic;
#[cfg(feature = "use_apic")]
use arch::driver::apic::ack;
#[cfg(not(feature = "use_apic"))]
use arch::driver::pic::ack;
use consts::irq::*;
pub extern "x86-interrupt" fn keyboard_handler(
stack_frame: &mut ExceptionStackFrame)
{
println!("\nInterupt: Keyboard \n{:#?}", stack_frame);
pic::ack(IRQ_KBD);
ack(IRQ_KBD);
}
pub extern "x86-interrupt" fn serial_handler(
stack_frame: &mut ExceptionStackFrame)
{
println!("\nInterupt: Serial \n{:#?}", stack_frame);
pic::ack(IRQ_COM1);
ack(IRQ_COM1);
}
pub extern "x86-interrupt" fn timer_handler(
stack_frame: &mut ExceptionStackFrame)
{
println!("\nInterupt: Timer \n{:#?}", stack_frame);
pic::ack(IRQ_TIMER);
ack(IRQ_TIMER);
}

@ -85,7 +85,7 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) {
} else {
arch::driver::pic::init();
}
unsafe{ x86_64::instructions::interrupts::enable(); }
arch::driver::interrupt::enable();
loop{}
test_end!();
}

Loading…
Cancel
Save