Small Fix && cargo fmt
This commit is contained in:
parent
c9583b0f53
commit
ae3ba9c26f
83 changed files with 1085 additions and 1079 deletions
|
@ -1,5 +1,5 @@
|
|||
use super::File;
|
||||
use crate::mm::{UserBuffer};
|
||||
use crate::mm::UserBuffer;
|
||||
use crate::sbi::console_getchar;
|
||||
use crate::task::suspend_current_and_run_next;
|
||||
|
||||
|
@ -8,8 +8,12 @@ pub struct Stdin;
|
|||
pub struct Stdout;
|
||||
|
||||
impl File for Stdin {
|
||||
fn readable(&self) -> bool { true }
|
||||
fn writable(&self) -> bool { false }
|
||||
fn readable(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn writable(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn read(&self, mut user_buf: UserBuffer) -> usize {
|
||||
assert_eq!(user_buf.len(), 1);
|
||||
// busy loop
|
||||
|
@ -24,7 +28,9 @@ impl File for Stdin {
|
|||
}
|
||||
}
|
||||
let ch = c as u8;
|
||||
unsafe { user_buf.buffers[0].as_mut_ptr().write_volatile(ch); }
|
||||
unsafe {
|
||||
user_buf.buffers[0].as_mut_ptr().write_volatile(ch);
|
||||
}
|
||||
1
|
||||
}
|
||||
fn write(&self, _user_buf: UserBuffer) -> usize {
|
||||
|
@ -33,9 +39,13 @@ impl File for Stdin {
|
|||
}
|
||||
|
||||
impl File for Stdout {
|
||||
fn readable(&self) -> bool { false }
|
||||
fn writable(&self) -> bool { true }
|
||||
fn read(&self, _user_buf: UserBuffer) -> usize{
|
||||
fn readable(&self) -> bool {
|
||||
false
|
||||
}
|
||||
fn writable(&self) -> bool {
|
||||
true
|
||||
}
|
||||
fn read(&self, _user_buf: UserBuffer) -> usize {
|
||||
panic!("Cannot read from stdout!");
|
||||
}
|
||||
fn write(&self, user_buf: UserBuffer) -> usize {
|
||||
|
@ -44,4 +54,4 @@ impl File for Stdout {
|
|||
}
|
||||
user_buf.len()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue