Skip to content

Commit 05d6bcd

Browse files
committed
kernel: Create dpc for keyboard interrupt, so it doesn't block other dpcs (like hardclock)
1 parent 49d1bd5 commit 05d6bcd

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

kernel/src/arch/amd64/interrupts/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ pub mod idt;
33
use crate::arch::amd64::apic::APIC;
44
use crate::arch::amd64::{ports::outb, read_cr2};
55
use crate::dpc::dispatch_dpcs;
6-
use crate::drivers::ps2::keyboard::keyboard;
6+
use crate::drivers::ps2::keyboard::keyboard_handler;
77
use crate::sched::context::TrapFrame;
88
use core::arch::asm;
99
use core::sync::atomic::{compiler_fence, Ordering};
@@ -26,7 +26,7 @@ pub fn init() {
2626
handlers[0xF0] = IRQHandler::Handler(apic_spurious_interrupt);
2727
// TODO: allocate vectors accordingly or manually set all known interrupt handlers here
2828
handlers[0x2f] = IRQHandler::Handler(dispatch_dpcs);
29-
handlers[0xd0] = IRQHandler::Handler(keyboard);
29+
handlers[0xd0] = IRQHandler::Handler(keyboard_handler);
3030
}
3131

3232
#[no_mangle]

kernel/src/drivers/ps2/keyboard.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
1-
use crate::{arch::amd64::ports::inb, sched::context::TrapFrame};
1+
use alloc::boxed::Box;
22

3-
pub fn keyboard(_: &mut TrapFrame) {
3+
use crate::{
4+
arch::amd64::ports::inb,
5+
dpc::{enqueue_dpc, Dpc},
6+
sched::context::TrapFrame,
7+
};
8+
9+
pub fn keyboard_handler(_: &mut TrapFrame) {
10+
let dpc = Dpc::new(keyboard, ());
11+
12+
enqueue_dpc(Box::new(dpc));
13+
}
14+
15+
pub fn keyboard<T>(_: T) {
416
dbg!("keyboard hit");
517
let scancode = unsafe { inb(0x60) };
618
dbg!("scancode: {}", scancode);

0 commit comments

Comments
 (0)