This commit is contained in:
Yifan Wu 2020-12-14 16:18:33 +08:00
parent e93a4a0b76
commit 2d34cab989
14 changed files with 218 additions and 18 deletions

View file

@ -1,3 +1,5 @@
const SYSCALL_CLOSE: usize = 57;
const SYSCALL_PIPE: usize = 59;
const SYSCALL_READ: usize = 63;
const SYSCALL_WRITE: usize = 64;
const SYSCALL_EXIT: usize = 93;
@ -21,6 +23,14 @@ fn syscall(id: usize, args: [usize; 3]) -> isize {
ret
}
pub fn sys_close(fd: usize) -> isize {
syscall(SYSCALL_CLOSE, [fd, 0, 0])
}
pub fn sys_pipe(pipe: &mut [usize]) -> isize {
syscall(SYSCALL_PIPE, [pipe.as_mut_ptr() as usize, 0, 0])
}
pub fn sys_read(fd: usize, buffer: &mut [u8]) -> isize {
syscall(SYSCALL_READ, [fd, buffer.as_mut_ptr() as usize, buffer.len()])
}