diff --git a/src/interrupts.rs b/src/interrupts.rs index 2caf624..6ff253d 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -16,6 +16,9 @@ lazy_static! { } idt[InterruptIndex::Timer.as_usize()] .set_handler_fn(timer_interrupt_handler); + + idt[InterruptIndex::Keyboard.as_usize()] + .set_handler_fn(keyboard_interrupt_handler); idt }; @@ -53,6 +56,7 @@ pub static PICS: spin::Mutex = #[repr(u8)] pub enum InterruptIndex { Timer = PIC_1_OFFSET, + Keyboard, } impl InterruptIndex { @@ -74,4 +78,18 @@ extern "x86-interrupt" fn timer_interrupt_handler( PICS.lock() .notify_end_of_interrupt(InterruptIndex::Timer.as_u8()); } +} +extern "x86-interrupt" fn keyboard_interrupt_handler( + _stack_frame: InterruptStackFrame) +{ + use x86_64::instructions::port::Port; + + let mut port = Port::new(0x60); + let scancode: u8 = unsafe { port.read() }; + print!("{}", scancode); + + unsafe { + PICS.lock() + .notify_end_of_interrupt(InterruptIndex::Keyboard.as_u8()); + } } \ No newline at end of file