summaryrefslogtreecommitdiff
path: root/kernel/src/interrupts
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/src/interrupts')
-rw-r--r--kernel/src/interrupts/idt.rs2
-rw-r--r--kernel/src/interrupts/interrupt_handlers.rs12
2 files changed, 13 insertions, 1 deletions
diff --git a/kernel/src/interrupts/idt.rs b/kernel/src/interrupts/idt.rs
index e41f957..c901916 100644
--- a/kernel/src/interrupts/idt.rs
+++ b/kernel/src/interrupts/idt.rs
@@ -26,6 +26,8 @@ lazy_static! {
.set_stack_index(gdt::PAGE_FAULT_IST_INDEX);
}
idt[InterruptType::Timer.as_usize()].set_handler_fn(interrupt_handlers::timer_handler);
+ idt[InterruptType::Keyboard.as_usize()]
+ .set_handler_fn(interrupt_handlers::keyboard_handler);
idt
};
diff --git a/kernel/src/interrupts/interrupt_handlers.rs b/kernel/src/interrupts/interrupt_handlers.rs
index 4624723..e7af0e1 100644
--- a/kernel/src/interrupts/interrupt_handlers.rs
+++ b/kernel/src/interrupts/interrupt_handlers.rs
@@ -1,11 +1,21 @@
use super::InterruptType;
use crate::io::qemu;
+use core::fmt::Write;
use x86_64::structures::idt::{InterruptStackFrame, PageFaultErrorCode};
+use x86_64::structures::port;
pub extern "x86-interrupt" fn timer_handler(stack_frame: &mut InterruptStackFrame) {
- panic!("Timer interrupt recieved\n\n");
+ write!(crate::io::vga_text::OStream::new(), "Timer");
if let Some(apic) = unsafe { super::apic::get_local_apic() } {
apic.end_of_interrupt()
}
}
+
+pub extern "x86-interrupt" fn keyboard_handler(stack_frame: &mut InterruptStackFrame) {
+ let code: u8 = unsafe { port::PortRead::read_from_port(0x60) };
+ write!(crate::io::vga_text::OStream::new(), "{}", code);
+ if let Some(apic) = unsafe { super::apic::get_local_apic() } {
+ apic.end_of_interrupt()
+ }
+}