We should disable sie before trapping back to user.

This commit is contained in:
Yifan Wu 2022-03-10 16:27:05 -08:00
parent 26f44233f6
commit ba611a1458
8 changed files with 43 additions and 33 deletions

View file

@ -146,15 +146,15 @@ impl<const BASE_ADDR: usize> NS16550a<BASE_ADDR> {
impl<const BASE_ADDR: usize> CharDevice for NS16550a<BASE_ADDR> {
fn read(&self) -> u8 {
println!("NS16550a::read");
//println!("NS16550a::read");
loop {
let mut inner = self.inner.exclusive_access();
if let Some(ch) = inner.read_buffer.pop_front() {
return ch;
} else {
println!("no ch yet!");
let task_cx_ptr = self.condvar.wait_no_sched();
drop(inner);
//println!("before scheduling");
schedule(task_cx_ptr);
}
}
@ -167,7 +167,7 @@ impl<const BASE_ADDR: usize> CharDevice for NS16550a<BASE_ADDR> {
let mut inner = self.inner.exclusive_access();
let mut count = 0;
while let Some(ch) = inner.ns16550a.read() {
println!("got {}", ch as char);
//println!("got {}", ch as char);
count += 1;
inner.read_buffer.push_back(ch);
}