summaryrefslogtreecommitdiff
path: root/kernel/src/interrupts/interrupt_handlers.rs
blob: e7af0e16aa5853b9a9e8bb96e9d3a6d7bdc5ce62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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) {
    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()
    }
}