diff --git a/rust/src/syscall.rs b/rust/src/syscall.rs index d743b69..7647d64 100644 --- a/rust/src/syscall.rs +++ b/rust/src/syscall.rs @@ -13,7 +13,7 @@ fn sys_call( ) -> i32 { let id = syscall_id as usize; let mut ret: i32; - let mut failed: i32 = 0; + let failed: i32; unsafe { #[cfg(any(target_arch = "riscv32", target_arch = "riscv64"))] @@ -325,7 +325,46 @@ enum SyscallId { GetPaddr = 998, } -#[cfg(not(target_arch = "x86_64"))] +// only for mips N32 abi +// see https://git.linux-mips.org/cgit/ralf/linux.git/tree/arch/mips/include/uapi/asm/unistd.h +#[cfg(target_arch = "mips")] +#[allow(dead_code)] +enum SyscallId { + Read = 4003, + Write = 4004, + Close = 4006, + Fstat = 4198, + Seek = 4018, + Mmap = 4090, + Munmap = 4091, + Ioctl = 4054, + Yield = 4162, + Sleep = 4166, + GetPid = 4020, + Socket = 4183, + SendTo = 4180, + SetSockOpt = 4181, + Clone = 4120, + Exec = 4011, + Exit = 4001, + Wait = 4007, + Kill = 4037, + Fsync = 4118, + GetCwd = 4203, + Chdir = 4012, + GetTime = 4078, + SetPriority = 4097, + ArchPrctl = -1, + GetDirEntry64 = 4219, + Openat = 4288, + FAccessAt = 4300, + Dup3 = 4327, + // custom + MapPciDevice = 999, + GetPaddr = 998, +} + +#[cfg(any(all(target_arch = "x86_64", target_arch = "mips")))] #[allow(dead_code)] enum SyscallId { Read = 63, diff --git a/ucore/src/libs/unistd.h b/ucore/src/libs/unistd.h index 1e2e833..088237e 100644 --- a/ucore/src/libs/unistd.h +++ b/ucore/src/libs/unistd.h @@ -33,6 +33,35 @@ /* ONLY FOR LAB6 */ #define SYS_set_priority 141 +#elif defined(__mips__) +#define MIPS_SYSCALL 6000 +#define SYS_exit (MIPS_SYSCALL + 1) +#define SYS_fork (MIPS_SYSCALL + 2) +#define SYS_wait (MIPS_SYSCALL + 7) +#define SYS_exec (MIPS_SYSCALL + 11) +#define SYS_clone (MIPS_SYSCALL + 120) +#define SYS_yield (MIPS_SYSCALL + 162) +#define SYS_sleep (MIPS_SYSCALL + 166) +#define SYS_kill (MIPS_SYSCALL + 37) +#define SYS_gettime (MIPS_SYSCALL + 78) +#define SYS_getpid (MIPS_SYSCALL + 20) +#define SYS_mmap (MIPS_SYSCALL + 90) +#define SYS_munmap (MIPS_SYSCALL + 91) +#define SYS_shmem (-1) +#define SYS_pgdir (-1) +#define SYS_openat (MIPS_SYSCALL + 288) +#define SYS_close (MIPS_SYSCALL + 6) +#define SYS_read (MIPS_SYSCALL + 3) +#define SYS_write (MIPS_SYSCALL + 4) +#define SYS_seek (MIPS_SYSCALL + 18) +#define SYS_fstat (MIPS_SYSCALL + 198) +#define SYS_fsync (MIPS_SYSCALL + 118) +#define SYS_getcwd (MIPS_SYSCALL + 203) +#define SYS_getdirentry64 (MIPS_SYSCALL + 219) +#define SYS_dup3 (MIPS_SYSCALL + 327) +/* ONLY FOR LAB6 */ +#define SYS_set_priority 141 + #else #define SYS_exit 93