Allow userspace to handle IRQs (WIP). Create basic keyboard handler
This commit is contained in:
parent
4bcee99d9f
commit
36fde7c7c5
8 changed files with 115 additions and 24 deletions
6
drivers/ps2d/Cargo.toml
Normal file
6
drivers/ps2d/Cargo.toml
Normal file
|
@ -0,0 +1,6 @@
|
|||
[package]
|
||||
name = "ps2d"
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies.syscall]
|
||||
path = "../../syscall/"
|
59
drivers/ps2d/src/main.rs
Normal file
59
drivers/ps2d/src/main.rs
Normal file
|
@ -0,0 +1,59 @@
|
|||
#![feature(asm)]
|
||||
|
||||
extern crate syscall;
|
||||
|
||||
use std::fs::File;
|
||||
use std::io::{Read, Write};
|
||||
use std::thread;
|
||||
|
||||
use syscall::iopl;
|
||||
|
||||
fn main() {
|
||||
if true {
|
||||
unsafe {
|
||||
iopl(3).expect("pskbd: failed to get I/O permission");
|
||||
asm!("cli" :::: "intel", "volatile");
|
||||
}
|
||||
|
||||
let mut file = File::open("irq:1").expect("pskbd: failed to open irq:1");
|
||||
|
||||
println!("pskbd: Reading keyboard IRQs");
|
||||
|
||||
loop {
|
||||
let mut irqs = [0; 8];
|
||||
file.read(&mut irqs).expect("pskbd: failed to read irq:1");
|
||||
|
||||
let data: u8;
|
||||
unsafe {
|
||||
asm!("in al, dx" : "={al}"(data) : "{dx}"(0x60) : : "intel", "volatile");
|
||||
}
|
||||
|
||||
println!("pskbd: IRQ {}: {:X}", unsafe { *(irqs.as_ptr() as *const usize) }, data);
|
||||
|
||||
file.write(&irqs).expect("pskbd: failed to write irq:1");
|
||||
}
|
||||
} else {
|
||||
unsafe {
|
||||
iopl(3).expect("psmsd: failed to get I/O permission");
|
||||
asm!("cli" :::: "intel", "volatile");
|
||||
}
|
||||
|
||||
let mut file = File::open("irq:12").expect("psmsd: failed to open irq:12");
|
||||
|
||||
println!("psmsd: Reading mouse IRQs");
|
||||
|
||||
loop {
|
||||
let mut count = [0; 8];
|
||||
file.read(&mut count).expect("psmsd: failed to read irq:12");
|
||||
|
||||
let data: u8;
|
||||
unsafe {
|
||||
asm!("in al, dx" : "={al}"(data) : "{dx}"(0x60) : : "intel", "volatile");
|
||||
}
|
||||
|
||||
println!("psmsd: IRQ: {:X}", data);
|
||||
|
||||
file.write(&count).expect("psmsd: failed to write irq:12");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue