main.rs 805 Bytes
Newer Older
1 2
#![feature(asm)]

Jeremy Soller's avatar
Jeremy Soller committed
3 4 5
#[macro_use]
extern crate bitflags;
extern crate io;
6 7 8 9 10 11
extern crate syscall;

use std::thread;

use syscall::iopl;

Jeremy Soller's avatar
Jeremy Soller committed
12 13
mod controller;
mod keyboard;
Jeremy Soller's avatar
Jeremy Soller committed
14
mod keymap;
Jeremy Soller's avatar
Jeremy Soller committed
15
mod mouse;
16

Jeremy Soller's avatar
Jeremy Soller committed
17 18 19 20
fn main() {
    unsafe {
        iopl(3).expect("ps2d: failed to get I/O permission");
        asm!("cli" :::: "intel", "volatile");
Jeremy Soller's avatar
Jeremy Soller committed
21
    }
22

Jeremy Soller's avatar
Jeremy Soller committed
23
    let extra_packet = controller::Ps2::new().init();
Jeremy Soller's avatar
Jeremy Soller committed
24

25
    thread::spawn(|| {
26
        unsafe {
Jeremy Soller's avatar
Jeremy Soller committed
27
            iopl(3).expect("ps2d: failed to get I/O permission");
28 29 30
            asm!("cli" :::: "intel", "volatile");
        }

Jeremy Soller's avatar
Jeremy Soller committed
31
        keyboard::keyboard();
Jeremy Soller's avatar
Jeremy Soller committed
32
    });
33

Jeremy Soller's avatar
Jeremy Soller committed
34
    thread::spawn(move || {
Jeremy Soller's avatar
Jeremy Soller committed
35
        unsafe {
Jeremy Soller's avatar
Jeremy Soller committed
36
            iopl(3).expect("ps2d: failed to get I/O permission");
Jeremy Soller's avatar
Jeremy Soller committed
37
            asm!("cli" :::: "intel", "volatile");
38
        }
39

Jeremy Soller's avatar
Jeremy Soller committed
40
        mouse::mouse(extra_packet);
Jeremy Soller's avatar
Jeremy Soller committed
41
    });
42
}