Add comments in ch6
This commit is contained in:
parent
cea2febe35
commit
f9346edad1
35 changed files with 374 additions and 116 deletions
|
@ -1,3 +1,4 @@
|
|||
//! File and filesystem-related syscalls
|
||||
use crate::fs::{open_file, OpenFlags};
|
||||
use crate::mm::{translated_byte_buffer, translated_str, UserBuffer};
|
||||
use crate::task::{current_task, current_user_token};
|
||||
|
|
|
@ -1,3 +1,14 @@
|
|||
//! Implementation of syscalls
|
||||
//!
|
||||
//! The single entry point to all system calls, [`syscall()`], is called
|
||||
//! whenever userspace wishes to perform a system call using the `ecall`
|
||||
//! instruction. In this case, the processor raises an 'Environment call from
|
||||
//! U-mode' exception, which is handled as one of the cases in
|
||||
//! [`crate::trap::trap_handler`].
|
||||
//!
|
||||
//! For clarity, each single syscall is implemented as its own function, named
|
||||
//! `sys_` then the name of the syscall. You can find functions like this in
|
||||
//! submodules, and you should also implement syscalls this way.
|
||||
const SYSCALL_OPEN: usize = 56;
|
||||
const SYSCALL_CLOSE: usize = 57;
|
||||
const SYSCALL_READ: usize = 63;
|
||||
|
@ -15,7 +26,7 @@ mod process;
|
|||
|
||||
use fs::*;
|
||||
use process::*;
|
||||
|
||||
/// handle syscall exception with `syscall_id` and other arguments
|
||||
pub fn syscall(syscall_id: usize, args: [usize; 3]) -> isize {
|
||||
match syscall_id {
|
||||
SYSCALL_OPEN => sys_open(args[0] as *const u8, args[1] as u32),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue