From: Alec Roelke Date: Sat, 28 Oct 2017 16:35:20 +0000 (-0400) Subject: arch-riscv: Add missing system calls X-Git-Tag: v19.0.0.0~2522 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e27ed32d9dcd7591c3a794fc1c9ca5b29ce0d91d;p=gem5.git arch-riscv: Add missing system calls This patch adds all system calls present in riscv-gnu-toolchain at commit hash 65cb174. Many of them do not have implementations in gem5, so they are just placeholders. [Remove the variadic macro and replace it with a function that has default arguments because variadic macros may not be portable across compilers] [Remove spaces around default arguments of createSyscall for better style] [Switch from using a loose function to using SyscallDesc's new constructor] Change-Id: Iff97c689109121b39df423c72d0e79c6366e31b9 Reviewed-on: https://gem5-review.googlesource.com/5322 Reviewed-by: Gabe Black Maintainer: Alec Roelke --- diff --git a/src/arch/riscv/linux/linux.hh b/src/arch/riscv/linux/linux.hh index 0c76fa6ed..cfc1d4fd7 100644 --- a/src/arch/riscv/linux/linux.hh +++ b/src/arch/riscv/linux/linux.hh @@ -152,6 +152,41 @@ class RiscvLinux : public Linux uint64_t st_ctime_nsec; int32_t ___glibc_reserved[2]; } tgt_stat64; + + typedef struct { + int32_t val[2]; + } tgt_fsid_t; + + typedef struct { + uint64_t f_type; + uint64_t f_bsize; + uint64_t f_blocks; + uint64_t f_bfree; + uint64_t f_bavail; + uint64_t f_files; + uint64_t f_ffree; + tgt_fsid_t f_fsid; + uint64_t f_namelen; + uint64_t f_frsize; + uint64_t f_flags; + uint64_t f_spare[4]; + } tgt_statfs; + + typedef struct { + int64_t uptime; + uint64_t loads[3]; + uint64_t totalram; + uint64_t freeram; + uint64_t sharedram; + uint64_t bufferram; + uint64_t totalswap; + uint64_t freeswap; + uint16_t procs; + uint16_t pad; + uint64_t totalhigh; + uint64_t freehigh; + uint32_t mem_unit; + } tgt_sysinfo; }; #endif diff --git a/src/arch/riscv/linux/process.cc b/src/arch/riscv/linux/process.cc index 24ea056cd..1749aa8b6 100644 --- a/src/arch/riscv/linux/process.cc +++ b/src/arch/riscv/linux/process.cc @@ -70,60 +70,334 @@ unameFunc(SyscallDesc *desc, int callnum, Process *process, } std::map RiscvLinuxProcess::syscallDescs = { - {17, SyscallDesc("getcwd", getcwdFunc)}, - {23, SyscallDesc("dup", dupFunc)}, - {25, SyscallDesc("fcntl", fcntl64Func)}, - {29, SyscallDesc("ioctl", ioctlFunc)}, - {34, SyscallDesc("mkdirat", unimplementedFunc)}, - {35, SyscallDesc("unlinkat", unlinkatFunc)}, - {37, SyscallDesc("linkat", unimplementedFunc)}, - {38, SyscallDesc("renameat", renameatFunc)}, - {46, SyscallDesc("ftruncate", ftruncate64Func)}, - {48, SyscallDesc("faccessat", faccessatFunc)}, - {49, SyscallDesc("chdir", unimplementedFunc)}, - {56, SyscallDesc("openat", openatFunc)}, - {57, SyscallDesc("close", closeFunc)}, - {61, SyscallDesc("getdents", unimplementedFunc)}, - {62, SyscallDesc("lseek", lseekFunc)}, - {63, SyscallDesc("read", readFunc)}, - {64, SyscallDesc("write", writeFunc)}, - {66, SyscallDesc("writev", writevFunc)}, - {67, SyscallDesc("pread", unimplementedFunc)}, - {68, SyscallDesc("pwrite", pwrite64Func)}, - {78, SyscallDesc("readlinkat", readlinkatFunc)}, - {79, SyscallDesc("fstatat", fstatat64Func)}, - {80, SyscallDesc("fstat", fstat64Func)}, - {93, SyscallDesc("exit", exitFunc)}, - {94, SyscallDesc("exit_group", exitGroupFunc)}, - {113, SyscallDesc("clock_gettime", clock_gettimeFunc)}, - {129, SyscallDesc("kill", unimplementedFunc)}, - {134, SyscallDesc("rt_sigaction", ignoreFunc, SyscallDesc::WarnOnce)}, - {135, SyscallDesc("rt_sigprocmask", ignoreFunc, SyscallDesc::WarnOnce)}, - {153, SyscallDesc("times", timesFunc)}, - {160, SyscallDesc("uname", unameFunc)}, - {163, SyscallDesc("getrlimit", getrlimitFunc)}, - {164, SyscallDesc("setrlimit", ignoreFunc)}, - {165, SyscallDesc("getrusage", getrusageFunc)}, - {169, SyscallDesc("gettimeofday", gettimeofdayFunc)}, - {172, SyscallDesc("getpid", getpidFunc)}, - {174, SyscallDesc("getuid", getuidFunc)}, - {175, SyscallDesc("geteuid", geteuidFunc)}, - {176, SyscallDesc("getgid", getgidFunc)}, - {177, SyscallDesc("getegid", getegidFunc)}, - {214, SyscallDesc("brk", brkFunc)}, - {215, SyscallDesc("munmap", munmapFunc)}, - {216, SyscallDesc("mremap", mremapFunc)}, - {222, SyscallDesc("mmap", mmapFunc)}, - {226, SyscallDesc("mprotect", ignoreFunc)}, + {0, SyscallDesc("io_setup")}, + {1, SyscallDesc("io_destroy")}, + {2, SyscallDesc("io_submit")}, + {3, SyscallDesc("io_cancel")}, + {4, SyscallDesc("io_getevents")}, + {5, SyscallDesc("setxattr")}, + {6, SyscallDesc("lsetxattr")}, + {7, SyscallDesc("fsetxattr")}, + {8, SyscallDesc("getxattr")}, + {9, SyscallDesc("lgetxattr")}, + {10, SyscallDesc("fgetxattr")}, + {11, SyscallDesc("listxattr")}, + {12, SyscallDesc("llistxattr")}, + {13, SyscallDesc("flistxattr")}, + {14, SyscallDesc("removexattr")}, + {15, SyscallDesc("lremovexattr")}, + {16, SyscallDesc("fremovexattr")}, + {17, SyscallDesc("getcwd", getcwdFunc)}, + {18, SyscallDesc("lookup_dcookie")}, + {19, SyscallDesc("eventfd2")}, + {20, SyscallDesc("epoll_create1")}, + {21, SyscallDesc("epoll_ctl")}, + {22, SyscallDesc("epoll_pwait")}, + {23, SyscallDesc("dup", dupFunc)}, + {24, SyscallDesc("dup3")}, + {25, SyscallDesc("fcntl", fcntl64Func)}, + {26, SyscallDesc("inotify_init1")}, + {27, SyscallDesc("inotify_add_watch")}, + {28, SyscallDesc("inotify_rm_watch")}, + {29, SyscallDesc("ioctl", ioctlFunc)}, + {30, SyscallDesc("ioprio_get")}, + {31, SyscallDesc("ioprio_set")}, + {32, SyscallDesc("flock")}, + {33, SyscallDesc("mknodat")}, + {34, SyscallDesc("mkdirat")}, + {35, SyscallDesc("unlinkat", unlinkatFunc)}, + {36, SyscallDesc("symlinkat")}, + {37, SyscallDesc("linkat")}, + {38, SyscallDesc("renameat", renameatFunc)}, + {39, SyscallDesc("umount2")}, + {40, SyscallDesc("mount")}, + {41, SyscallDesc("pivot_root")}, + {42, SyscallDesc("nfsservctl")}, + {43, SyscallDesc("statfs", statfsFunc)}, + {44, SyscallDesc("fstatfs", fstatfsFunc)}, + {45, SyscallDesc("truncate", truncateFunc)}, + {46, SyscallDesc("ftruncate", ftruncate64Func)}, + {47, SyscallDesc("fallocate", fallocateFunc)}, + {48, SyscallDesc("faccessat", faccessatFunc)}, + {49, SyscallDesc("chdir")}, + {50, SyscallDesc("fchdir")}, + {51, SyscallDesc("chroot")}, + {52, SyscallDesc("fchmod", fchmodFunc)}, + {53, SyscallDesc("fchmodat")}, + {54, SyscallDesc("fchownat")}, + {55, SyscallDesc("fchown", fchownFunc)}, + {56, SyscallDesc("openat", openatFunc)}, + {57, SyscallDesc("close", closeFunc)}, + {58, SyscallDesc("vhangup")}, + {59, SyscallDesc("pipe2")}, + {60, SyscallDesc("quotactl")}, + {61, SyscallDesc("getdents64")}, + {62, SyscallDesc("lseek", lseekFunc)}, + {63, SyscallDesc("read", readFunc)}, + {64, SyscallDesc("write", writeFunc)}, + {66, SyscallDesc("writev", writevFunc)}, + {67, SyscallDesc("pread64")}, + {68, SyscallDesc("pwrite64", pwrite64Func)}, + {69, SyscallDesc("preadv")}, + {70, SyscallDesc("pwritev")}, + {71, SyscallDesc("sendfile")}, + {72, SyscallDesc("pselect6")}, + {73, SyscallDesc("ppoll")}, + {74, SyscallDesc("signalfd64")}, + {75, SyscallDesc("vmsplice")}, + {76, SyscallDesc("splice")}, + {77, SyscallDesc("tee")}, + {78, SyscallDesc("readlinkat", readlinkatFunc)}, + {79, SyscallDesc("fstatat", fstatat64Func)}, + {80, SyscallDesc("fstat", fstat64Func)}, + {81, SyscallDesc("sync")}, + {82, SyscallDesc("fsync")}, + {83, SyscallDesc("fdatasync")}, + {84, SyscallDesc("sync_file_range2")}, + {85, SyscallDesc("timerfd_create")}, + {86, SyscallDesc("timerfd_settime")}, + {87, SyscallDesc("timerfd_gettime")}, + {88, SyscallDesc("utimensat")}, + {89, SyscallDesc("acct")}, + {90, SyscallDesc("capget")}, + {91, SyscallDesc("capset")}, + {92, SyscallDesc("personality")}, + {93, SyscallDesc("exit", exitFunc)}, + {94, SyscallDesc("exit_group", exitGroupFunc)}, + {95, SyscallDesc("waitid")}, + {96, SyscallDesc("set_tid_address")}, + {97, SyscallDesc("unshare")}, + {98, SyscallDesc("futex", futexFunc)}, + {99, SyscallDesc("set_robust_list")}, + {100, SyscallDesc("get_robust_list")}, + {101, SyscallDesc("nanosleep")}, + {102, SyscallDesc("getitimer")}, + {103, SyscallDesc("setitimer")}, + {104, SyscallDesc("kexec_load")}, + {105, SyscallDesc("init_module")}, + {106, SyscallDesc("delete_module")}, + {107, SyscallDesc("timer_create")}, + {108, SyscallDesc("timer_gettime")}, + {109, SyscallDesc("timer_getoverrun")}, + {110, SyscallDesc("timer_settime")}, + {111, SyscallDesc("timer_delete")}, + {112, SyscallDesc("clock_settime")}, + {113, SyscallDesc("clock_gettime", clock_gettimeFunc)}, + {114, SyscallDesc("clock_getres", clock_getresFunc)}, + {115, SyscallDesc("clock_nanosleep")}, + {116, SyscallDesc("syslog")}, + {117, SyscallDesc("ptrace")}, + {118, SyscallDesc("sched_setparam")}, + {119, SyscallDesc("sched_setscheduler")}, + {120, SyscallDesc("sched_getscheduler")}, + {121, SyscallDesc("sched_getparam")}, + {122, SyscallDesc("sched_setaffinity")}, + {123, SyscallDesc("sched_getaffinity")}, + {124, SyscallDesc("sched_yield")}, + {125, SyscallDesc("sched_get_priority_max")}, + {126, SyscallDesc("sched_get_priority_min")}, + {127, SyscallDesc("scheD_rr_get_interval")}, + {128, SyscallDesc("restart_syscall")}, + {129, SyscallDesc("kill")}, + {130, SyscallDesc("tkill")}, + {131, SyscallDesc("tgkill", tgkillFunc)}, + {132, SyscallDesc("sigaltstack")}, + {133, SyscallDesc("rt_sigsuspend", ignoreFunc, SyscallDesc::WarnOnce)}, + {134, SyscallDesc("rt_sigaction", ignoreFunc, SyscallDesc::WarnOnce)}, + {135, SyscallDesc("rt_sigprocmask", ignoreFunc, SyscallDesc::WarnOnce)}, + {136, SyscallDesc("rt_sigpending", ignoreFunc, SyscallDesc::WarnOnce)}, + {137, SyscallDesc("rt_sigtimedwait", ignoreFunc,SyscallDesc::WarnOnce)}, + {138, SyscallDesc("rt_sigqueueinfo", ignoreFunc,SyscallDesc::WarnOnce)}, + {139, SyscallDesc("rt_sigreturn", ignoreFunc, SyscallDesc::WarnOnce)}, + {140, SyscallDesc("setpriority")}, + {141, SyscallDesc("getpriority")}, + {142, SyscallDesc("reboot")}, + {143, SyscallDesc("setregid")}, + {144, SyscallDesc("setgid")}, + {145, SyscallDesc("setreuid")}, + {146, SyscallDesc("setuid", setuidFunc)}, + {147, SyscallDesc("setresuid")}, + {148, SyscallDesc("getresuid")}, + {149, SyscallDesc("getresgid")}, + {150, SyscallDesc("getresgid")}, + {151, SyscallDesc("setfsuid")}, + {152, SyscallDesc("setfsgid")}, + {153, SyscallDesc("times", timesFunc)}, + {154, SyscallDesc("setpgid", setpgidFunc)}, + {155, SyscallDesc("getpgid")}, + {156, SyscallDesc("getsid")}, + {157, SyscallDesc("setsid")}, + {158, SyscallDesc("getgroups")}, + {159, SyscallDesc("setgroups")}, + {160, SyscallDesc("uname", unameFunc)}, + {161, SyscallDesc("sethostname")}, + {162, SyscallDesc("setdomainname")}, + {163, SyscallDesc("getrlimit", getrlimitFunc)}, + {164, SyscallDesc("setrlimit", ignoreFunc)}, + {165, SyscallDesc("getrusage", getrusageFunc)}, + {166, SyscallDesc("umask", umaskFunc)}, + {167, SyscallDesc("prctl")}, + {168, SyscallDesc("getcpu")}, + {169, SyscallDesc("gettimeofday", gettimeofdayFunc)}, + {170, SyscallDesc("settimeofday")}, + {171, SyscallDesc("adjtimex")}, + {172, SyscallDesc("getpid", getpidFunc)}, + {173, SyscallDesc("getppid", getppidFunc)}, + {174, SyscallDesc("getuid", getuidFunc)}, + {175, SyscallDesc("geteuid", geteuidFunc)}, + {176, SyscallDesc("getgid", getgidFunc)}, + {177, SyscallDesc("getegid", getegidFunc)}, + {178, SyscallDesc("gettid", gettidFunc)}, + {179, SyscallDesc("sysinfo", sysinfoFunc)}, + {180, SyscallDesc("mq_open")}, + {181, SyscallDesc("mq_unlink")}, + {182, SyscallDesc("mq_timedsend")}, + {183, SyscallDesc("mq_timedrecieve")}, + {184, SyscallDesc("mq_notify")}, + {185, SyscallDesc("mq_getsetattr")}, + {186, SyscallDesc("msgget")}, + {187, SyscallDesc("msgctl")}, + {188, SyscallDesc("msgrcv")}, + {189, SyscallDesc("msgsnd")}, + {190, SyscallDesc("semget")}, + {191, SyscallDesc("semctl")}, + {192, SyscallDesc("semtimedop")}, + {193, SyscallDesc("semop")}, + {194, SyscallDesc("shmget")}, + {195, SyscallDesc("shmctl")}, + {196, SyscallDesc("shmat")}, + {197, SyscallDesc("shmdt")}, + {198, SyscallDesc("socket")}, + {199, SyscallDesc("socketpair")}, + {200, SyscallDesc("bind")}, + {201, SyscallDesc("listen")}, + {202, SyscallDesc("accept")}, + {203, SyscallDesc("connect")}, + {204, SyscallDesc("getsockname")}, + {205, SyscallDesc("getpeername")}, + {206, SyscallDesc("sendo")}, + {207, SyscallDesc("recvfrom")}, + {208, SyscallDesc("setsockopt")}, + {209, SyscallDesc("getsockopt")}, + {210, SyscallDesc("shutdown")}, + {211, SyscallDesc("sendmsg")}, + {212, SyscallDesc("recvmsg")}, + {213, SyscallDesc("readahead")}, + {214, SyscallDesc("brk", brkFunc)}, + {215, SyscallDesc("munmap", munmapFunc)}, + {216, SyscallDesc("mremap", mremapFunc)}, + {217, SyscallDesc("add_key")}, + {218, SyscallDesc("request_key")}, + {219, SyscallDesc("keyctl")}, + {220, SyscallDesc("clone", cloneFunc)}, + {221, SyscallDesc("execve", execveFunc)}, + {222, SyscallDesc("mmap", mmapFunc)}, + {223, SyscallDesc("fadvise64")}, + {224, SyscallDesc("swapon")}, + {225, SyscallDesc("swapoff")}, + {226, SyscallDesc("mprotect", ignoreFunc)}, + {227, SyscallDesc("msync", ignoreFunc)}, + {228, SyscallDesc("mlock", ignoreFunc)}, + {229, SyscallDesc("munlock", ignoreFunc)}, + {230, SyscallDesc("mlockall", ignoreFunc)}, + {231, SyscallDesc("munlockall", ignoreFunc)}, + {232, SyscallDesc("mincore", ignoreFunc)}, + {233, SyscallDesc("madvise", ignoreFunc)}, + {234, SyscallDesc("remap_file_pages")}, + {235, SyscallDesc("mbind", ignoreFunc)}, + {236, SyscallDesc("get_mempolicy")}, + {237, SyscallDesc("set_mempolicy")}, + {238, SyscallDesc("migrate_pages")}, + {239, SyscallDesc("move_pages")}, + {240, SyscallDesc("tgsigqueueinfo")}, + {241, SyscallDesc("perf_event_open")}, + {242, SyscallDesc("accept4")}, + {243, SyscallDesc("recvmmsg")}, + {260, SyscallDesc("wait4")}, + {261, SyscallDesc("prlimit64", prlimitFunc)}, + {262, SyscallDesc("fanotify_init")}, + {263, SyscallDesc("fanotify_mark")}, + {264, SyscallDesc("name_to_handle_at")}, + {265, SyscallDesc("open_by_handle_at")}, + {266, SyscallDesc("clock_adjtime")}, + {267, SyscallDesc("syncfs")}, + {268, SyscallDesc("setns")}, + {269, SyscallDesc("sendmmsg")}, + {270, SyscallDesc("process_vm_ready")}, + {271, SyscallDesc("process_vm_writev")}, + {272, SyscallDesc("kcmp")}, + {273, SyscallDesc("finit_module")}, + {274, SyscallDesc("sched_setattr")}, + {275, SyscallDesc("sched_getattr")}, + {276, SyscallDesc("renameat2")}, + {277, SyscallDesc("seccomp")}, + {278, SyscallDesc("getrandom")}, + {279, SyscallDesc("memfd_create")}, + {280, SyscallDesc("bpf")}, + {281, SyscallDesc("execveat")}, + {282, SyscallDesc("userfaultid")}, + {283, SyscallDesc("membarrier")}, + {284, SyscallDesc("mlock2")}, + {285, SyscallDesc("copy_file_range")}, + {286, SyscallDesc("preadv2")}, + {287, SyscallDesc("pwritev2")}, {1024, SyscallDesc("open", openFunc)}, - {1025, SyscallDesc("link", unimplementedFunc)}, + {1025, SyscallDesc("link")}, {1026, SyscallDesc("unlink", unlinkFunc)}, + {1027, SyscallDesc("mknod")}, + {1028, SyscallDesc("chmod", chmodFunc)}, + {1029, SyscallDesc("chown", chownFunc)}, {1030, SyscallDesc("mkdir", mkdirFunc)}, + {1031, SyscallDesc("rmdir")}, + {1032, SyscallDesc("lchown")}, {1033, SyscallDesc("access", accessFunc)}, + {1034, SyscallDesc("rename", renameFunc)}, + {1035, SyscallDesc("readlink", readlinkFunc)}, + {1036, SyscallDesc("symlink")}, + {1037, SyscallDesc("utimes", utimesFunc)}, {1038, SyscallDesc("stat", stat64Func)}, {1039, SyscallDesc("lstat", lstat64Func)}, + {1040, SyscallDesc("pipe", pipeFunc)}, + {1041, SyscallDesc("dup2", dup2Func)}, + {1042, SyscallDesc("epoll_create")}, + {1043, SyscallDesc("inotifiy_init")}, + {1044, SyscallDesc("eventfd")}, + {1045, SyscallDesc("signalfd")}, + {1046, SyscallDesc("sendfile")}, + {1047, SyscallDesc("ftruncate", ftruncate64Func)}, + {1048, SyscallDesc("truncate", truncate64Func)}, + {1049, SyscallDesc("stat", stat64Func)}, + {1050, SyscallDesc("lstat", lstat64Func)}, + {1051, SyscallDesc("fstat", fstat64Func)}, + {1052, SyscallDesc("fcntl", fcntl64Func)}, + {1053, SyscallDesc("fadvise64")}, + {1054, SyscallDesc("newfstatat")}, + {1055, SyscallDesc("fstatfs", fstatfsFunc)}, + {1056, SyscallDesc("statfs", statfsFunc)}, + {1057, SyscallDesc("lseek", lseekFunc)}, + {1058, SyscallDesc("mmap", mmapFunc)}, + {1059, SyscallDesc("alarm")}, + {1060, SyscallDesc("getpgrp")}, + {1061, SyscallDesc("pause")}, {1062, SyscallDesc("time", timeFunc)}, - {2011, SyscallDesc("getmainvars", unimplementedFunc)}, + {1063, SyscallDesc("utime")}, + {1064, SyscallDesc("creat")}, + {1065, SyscallDesc("getdents")}, + {1066, SyscallDesc("futimesat")}, + {1067, SyscallDesc("select")}, + {1068, SyscallDesc("poll")}, + {1069, SyscallDesc("epoll_wait")}, + {1070, SyscallDesc("ustat")}, + {1071, SyscallDesc("vfork")}, + {1072, SyscallDesc("oldwait4")}, + {1073, SyscallDesc("recv")}, + {1074, SyscallDesc("send")}, + {1075, SyscallDesc("bdflush")}, + {1076, SyscallDesc("umount")}, + {1077, SyscallDesc("uselib")}, + {1078, SyscallDesc("sysctl")}, + {1079, SyscallDesc("fork")}, + {2011, SyscallDesc("getmainvars")} }; RiscvLinuxProcess::RiscvLinuxProcess(ProcessParams * params,