Seperate PS/2 keyboard and mouse driver

This commit is contained in:
Jeremy Soller 2016-09-19 09:43:30 -06:00
parent 70a2faa0c7
commit 727647dbf1
6 changed files with 49 additions and 44 deletions

View file

@ -22,7 +22,7 @@ impl InitFsScheme {
files.insert(b"bin/ion", include_bytes!("../../build/userspace/ion"));
files.insert(b"bin/pcid", include_bytes!("../../build/userspace/pcid"));
files.insert(b"bin/ps2d", include_bytes!("../../build/userspace/ps2d"));
files.insert(b"etc/init.rc", b"echo testing\n#initfs:bin/pcid\ninitfs:bin/ps2d\n#initfs:bin/ion");
files.insert(b"etc/init.rc", b"#initfs:bin/pcid\ninitfs:bin/ps2d\n#initfs:bin/ion");
InitFsScheme {
next_id: 0,

View file

@ -1,6 +1,6 @@
use core::{mem, str};
use arch::interrupt::irq::{COUNTS, acknowledge};
use arch::interrupt::irq::{ACKS, COUNTS, acknowledge};
use context;
use syscall::{Error, Result};
use super::Scheme;
@ -27,20 +27,15 @@ impl Scheme for IrqScheme {
fn read(&mut self, file: usize, buffer: &mut [u8]) -> Result<usize> {
// Ensures that the length of the buffer is larger than the size of a usize
if buffer.len() >= mem::size_of::<usize>() {
let prev = { COUNTS.lock()[file] };
loop {
{
let current = COUNTS.lock()[file];
if prev != current {
// Safe if the length of the buffer is larger than the size of a usize
assert!(buffer.len() >= mem::size_of::<usize>());
unsafe { *(buffer.as_mut_ptr() as *mut usize) = current; }
return Ok(mem::size_of::<usize>());
}
}
// Safe if all locks have been dropped
unsafe { context::switch(); }
let ack = ACKS.lock()[file];
let current = COUNTS.lock()[file];
if ack != current {
// Safe if the length of the buffer is larger than the size of a usize
assert!(buffer.len() >= mem::size_of::<usize>());
unsafe { *(buffer.as_mut_ptr() as *mut usize) = current; }
return Ok(mem::size_of::<usize>());
} else {
return Ok(0);
}
} else {
Err(Error::InvalidValue)
@ -50,9 +45,10 @@ impl Scheme for IrqScheme {
fn write(&mut self, file: usize, buffer: &[u8]) -> Result<usize> {
if buffer.len() >= mem::size_of::<usize>() {
assert!(buffer.len() >= mem::size_of::<usize>());
let prev = unsafe { *(buffer.as_ptr() as *const usize) };
let ack = unsafe { *(buffer.as_ptr() as *const usize) };
let current = COUNTS.lock()[file];
if prev == current {
if ack == current {
ACKS.lock()[file] = ack;
unsafe { acknowledge(file); }
return Ok(mem::size_of::<usize>());
} else {