gem5  v21.1.0.2
Namespaces | Macros | Typedefs | Functions | Variables
syscall_emul.hh File Reference
#include <sys/mount.h>
#include <fcntl.h>
#include <net/if.h>
#include <poll.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
#include <cerrno>
#include <memory>
#include <string>
#include "arch/generic/tlb.hh"
#include "base/intmath.hh"
#include "base/loader/object_file.hh"
#include "base/logging.hh"
#include "base/trace.hh"
#include "base/types.hh"
#include "config/the_isa.hh"
#include "cpu/base.hh"
#include "cpu/thread_context.hh"
#include "kern/linux/linux.hh"
#include "mem/page_table.hh"
#include "params/Process.hh"
#include "sim/emul_driver.hh"
#include "sim/futex_map.hh"
#include "sim/guest_abi.hh"
#include "sim/process.hh"
#include "sim/proxy_ptr.hh"
#include "sim/syscall_debug_macros.hh"
#include "sim/syscall_desc.hh"
#include "sim/syscall_emul_buf.hh"
#include "sim/syscall_return.hh"

Go to the source code of this file.

Namespaces

 gem5
 Reference material can be found at the JEDEC website: UFS standard http://www.jedec.org/standards-documents/results/jesd220 UFS HCI specification http://www.jedec.org/standards-documents/results/jesd223.
 

Macros

#define NO_STAT64   0
 

Typedefs

typedef struct statfs gem5::hst_statfs
 
typedef struct stat gem5::hst_stat
 
typedef struct stat64 gem5::hst_stat64
 

Functions

void gem5::warnUnsupportedOS (std::string syscall_name)
 
SyscallReturn gem5::unimplementedFunc (SyscallDesc *desc, ThreadContext *tc)
 Handler for unimplemented syscalls that we haven't thought about. More...
 
SyscallReturn gem5::ignoreFunc (SyscallDesc *desc, ThreadContext *tc)
 Handler for unimplemented syscalls that we never intend to implement (signal handling, etc.) and should not affect the correct behavior of the program. More...
 
SyscallReturn gem5::ignoreWarnOnceFunc (SyscallDesc *desc, ThreadContext *tc)
 Like above, but only prints a warning once per syscall desc it's used with. More...
 
SyscallReturn gem5::fallocateFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int mode, off_t offset, off_t len)
 
SyscallReturn gem5::exitFunc (SyscallDesc *desc, ThreadContext *tc, int status)
 Target exit() handler: terminate current context. More...
 
SyscallReturn gem5::exitGroupFunc (SyscallDesc *desc, ThreadContext *tc, int status)
 Target exit_group() handler: terminate simulation. (exit all threads) More...
 
SyscallReturn gem5::setTidAddressFunc (SyscallDesc *desc, ThreadContext *tc, uint64_t tidPtr)
 Target set_tid_address() handler. More...
 
SyscallReturn gem5::getpagesizeFunc (SyscallDesc *desc, ThreadContext *tc)
 Target getpagesize() handler. More...
 
SyscallReturn gem5::brkFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> new_brk)
 Target brk() handler: set brk address. More...
 
SyscallReturn gem5::closeFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
 Target close() handler. More...
 
SyscallReturn gem5::lseekFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offs, int whence)
 Target lseek() handler. More...
 
SyscallReturn gem5::_llseekFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t offset_high, uint32_t offset_low, VPtr<> result_ptr, int whence)
 Target _llseek() handler. More...
 
SyscallReturn gem5::munmapFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> start, size_t length)
 Target munmap() handler. More...
 
SyscallReturn gem5::shutdownFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int how)
 Target shutdown() handler. More...
 
SyscallReturn gem5::gethostnameFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> buf_ptr, int name_len)
 Target gethostname() handler. More...
 
SyscallReturn gem5::getcwdFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> buf_ptr, unsigned long size)
 Target getcwd() handler. More...
 
SyscallReturn gem5::readlinkFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> buf, size_t bufsiz)
 Target readlink() handler. More...
 
SyscallReturn gem5::unlinkFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
 Target unlink() handler. More...
 
SyscallReturn gem5::linkFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> new_pathname)
 Target link() handler. More...
 
SyscallReturn gem5::symlinkFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> new_pathname)
 Target symlink() handler. More...
 
SyscallReturn gem5::mkdirFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
 Target mkdir() handler. More...
 
SyscallReturn gem5::mknodFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode, dev_t dev)
 Target mknod() handler. More...
 
SyscallReturn gem5::chdirFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
 Target chdir() handler. More...
 
SyscallReturn gem5::rmdirFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname)
 
SyscallReturn gem5::renameFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> oldpath, VPtr<> newpath)
 Target rename() handler. More...
 
SyscallReturn gem5::truncateFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, off_t length)
 Target truncate() handler. More...
 
SyscallReturn gem5::ftruncateFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, off_t length)
 Target ftruncate() handler. More...
 
SyscallReturn gem5::truncate64Func (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, int64_t length)
 Target truncate64() handler. More...
 
SyscallReturn gem5::ftruncate64Func (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int64_t length)
 Target ftruncate64() handler. More...
 
SyscallReturn gem5::umaskFunc (SyscallDesc *desc, ThreadContext *tc)
 Target umask() handler. More...
 
SyscallReturn gem5::gettidFunc (SyscallDesc *desc, ThreadContext *tc)
 Target gettid() handler. More...
 
SyscallReturn gem5::chownFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, uint32_t owner, uint32_t group)
 Target chown() handler. More...
 
SyscallReturn gem5::getpgrpFunc (SyscallDesc *desc, ThreadContext *tc)
 Target getpgrpFunc() handler. More...
 
SyscallReturn gem5::setpgidFunc (SyscallDesc *desc, ThreadContext *tc, int pid, int pgid)
 Target setpgid() handler. More...
 
SyscallReturn gem5::fchownFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t owner, uint32_t group)
 Target fchown() handler. More...
 
SyscallReturn gem5::dupFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd)
 FIXME: The file description is not shared among file descriptors created with dup. More...
 
SyscallReturn gem5::dup2Func (SyscallDesc *desc, ThreadContext *tc, int old_tgt_fd, int new_tgt_fd)
 Target dup2() handler. More...
 
SyscallReturn gem5::fcntlFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd, guest_abi::VarArgs< int > varargs)
 Target fcntl() handler. More...
 
SyscallReturn gem5::fcntl64Func (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int cmd)
 Target fcntl64() handler. More...
 
SyscallReturn gem5::pipeFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> tgt_addr)
 Target pipe() handler. More...
 
SyscallReturn gem5::pipe2Func (SyscallDesc *desc, ThreadContext *tc, VPtr<> tgt_addr, int flags)
 Target pipe() handler. More...
 
SyscallReturn gem5::getpidFunc (SyscallDesc *desc, ThreadContext *tc)
 Target getpid() handler. More...
 
SyscallReturn gem5::getpeernameFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> sockAddrPtr, VPtr<> addrlenPtr)
 
SyscallReturn gem5::bindFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int addrlen)
 
SyscallReturn gem5::listenFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int backlog)
 
SyscallReturn gem5::connectFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int addrlen)
 
SyscallReturn gem5::sendtoFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> bufrPtr, size_t bufrLen, int flags, VPtr<> addrPtr, socklen_t addrLen)
 
SyscallReturn gem5::recvfromFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> bufrPtr, size_t bufrLen, int flags, VPtr<> addrPtr, VPtr<> addrlenPtr)
 
SyscallReturn gem5::recvmsgFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> msgPtr, int flags)
 
SyscallReturn gem5::sendmsgFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> msgPtr, int flags)
 
SyscallReturn gem5::getuidFunc (SyscallDesc *desc, ThreadContext *tc)
 
SyscallReturn gem5::getgidFunc (SyscallDesc *desc, ThreadContext *tc)
 Target getgid() handler. More...
 
SyscallReturn gem5::getppidFunc (SyscallDesc *desc, ThreadContext *tc)
 Target getppid() handler. More...
 
SyscallReturn gem5::geteuidFunc (SyscallDesc *desc, ThreadContext *tc)
 Target geteuid() handler. More...
 
SyscallReturn gem5::getegidFunc (SyscallDesc *desc, ThreadContext *tc)
 Target getegid() handler. More...
 
SyscallReturn gem5::accessFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
 Target access() handler. More...
 
SyscallReturn gem5::getsockoptFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, VPtr<> valPtr, VPtr<> lenPtr)
 
SyscallReturn gem5::setsockoptFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, int level, int optname, VPtr<> valPtr, socklen_t len)
 
SyscallReturn gem5::getcpuFunc (SyscallDesc *desc, ThreadContext *tc, VPtr< uint32_t > cpu, VPtr< uint32_t > node, VPtr< uint32_t > tcache)
 
SyscallReturn gem5::getsocknameFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> addrPtr, VPtr<> lenPtr)
 
template<class OS >
SyscallReturn gem5::futexFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> uaddr, int op, int val, int timeout, VPtr<> uaddr2, int val3)
 Futex system call Implemented by Daniel Sanchez Used by printf's in multi-threaded apps. More...
 
SyscallReturn gem5::pipePseudoFunc (SyscallDesc *desc, ThreadContext *tc)
 Pseudo Funcs - These functions use a different return convension, returning a second value in a register other than the normal return register. More...
 
template<class T1 , class T2 >
void gem5::getElapsedTimeMicro (T1 &sec, T2 &usec)
 Helper function to convert current elapsed time to seconds and microseconds. More...
 
template<class T1 , class T2 >
void gem5::getElapsedTimeNano (T1 &sec, T2 &nsec)
 Helper function to convert current elapsed time to seconds and nanoseconds. More...
 
template<typename OS , typename TgtStatPtr , typename HostStatPtr >
void gem5::copyOutStatBuf (TgtStatPtr tgt, HostStatPtr host, bool fakeTTY=false)
 
template<typename OS , typename TgtStatPtr , typename HostStatPtr >
void gem5::copyOutStat64Buf (TgtStatPtr tgt, HostStatPtr host, bool fakeTTY=false)
 
template<class OS , typename TgtStatPtr , typename HostStatPtr >
void gem5::copyOutStatfsBuf (TgtStatPtr tgt, HostStatPtr host)
 
template<class OS >
SyscallReturn gem5::ioctlFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, unsigned req, VPtr<> addr)
 Target ioctl() handler. More...
 
template<class OS >
SyscallReturn gem5::openatFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_dirfd, VPtr<> pathname, int tgt_flags, int mode)
 Target open() handler. More...
 
template<class OS >
SyscallReturn gem5::openFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, int tgt_flags, int mode)
 Target open() handler. More...
 
template<class OS >
SyscallReturn gem5::unlinkatFunc (SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname)
 Target unlinkat() handler. More...
 
template<class OS >
SyscallReturn gem5::faccessatFunc (SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, int mode)
 Target facessat() handler. More...
 
template<class OS >
SyscallReturn gem5::readlinkatFunc (SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, VPtr<> buf, size_t bufsiz)
 Target readlinkat() handler. More...
 
template<class OS >
SyscallReturn gem5::renameatFunc (SyscallDesc *desc, ThreadContext *tc, int olddirfd, VPtr<> oldpath, int newdirfd, VPtr<> newpath)
 Target renameat() handler. More...
 
template<class OS >
SyscallReturn gem5::sysinfoFunc (SyscallDesc *desc, ThreadContext *tc, VPtr< typename OS::tgt_sysinfo > sysinfo)
 Target sysinfo() handler. More...
 
template<class OS >
SyscallReturn gem5::chmodFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, mode_t mode)
 Target chmod() handler. More...
 
template<class OS >
SyscallReturn gem5::pollFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> fdsPtr, int nfds, int tmout)
 
template<class OS >
SyscallReturn gem5::fchmodFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint32_t mode)
 Target fchmod() handler. More...
 
template<class OS >
SyscallReturn gem5::mremapFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> start, uint64_t old_length, uint64_t new_length, uint64_t flags, guest_abi::VarArgs< uint64_t > varargs)
 Target mremap() handler. More...
 
template<class OS >
SyscallReturn gem5::statFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat > tgt_stat)
 Target stat() handler. More...
 
template<class OS >
SyscallReturn gem5::stat64Func (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat)
 Target stat64() handler. More...
 
template<class OS >
SyscallReturn gem5::fstatat64Func (SyscallDesc *desc, ThreadContext *tc, int dirfd, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat)
 Target fstatat64() handler. More...
 
template<class OS >
SyscallReturn gem5::fstat64Func (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_stat64 > tgt_stat)
 Target fstat64() handler. More...
 
template<class OS >
SyscallReturn gem5::lstatFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat > tgt_stat)
 Target lstat() handler. More...
 
template<class OS >
SyscallReturn gem5::lstat64Func (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_stat64 > tgt_stat)
 Target lstat64() handler. More...
 
template<class OS >
SyscallReturn gem5::fstatFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_stat > tgt_stat)
 Target fstat() handler. More...
 
template<class OS >
SyscallReturn gem5::statfsFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::tgt_statfs > tgt_stat)
 Target statfs() handler. More...
 
template<class OS >
SyscallReturn gem5::cloneFunc (SyscallDesc *desc, ThreadContext *tc, RegVal flags, RegVal newStack, VPtr<> ptidPtr, VPtr<> ctidPtr, VPtr<> tlsPtr)
 
template<class OS >
SyscallReturn gem5::cloneBackwardsFunc (SyscallDesc *desc, ThreadContext *tc, RegVal flags, RegVal newStack, VPtr<> ptidPtr, VPtr<> tlsPtr, VPtr<> ctidPtr)
 
template<class OS >
SyscallReturn gem5::fstatfsFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr< typename OS::tgt_statfs > tgt_stat)
 Target fstatfs() handler. More...
 
template<class OS >
SyscallReturn gem5::readvFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t tiov_base, size_t count)
 Target readv() handler. More...
 
template<class OS >
SyscallReturn gem5::writevFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, uint64_t tiov_base, size_t count)
 Target writev() handler. More...
 
template<class OS >
SyscallReturn gem5::mmapFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> start, typename OS::size_t length, int prot, int tgt_flags, int tgt_fd, typename OS::off_t offset)
 Target mmap() handler. More...
 
template<class OS >
SyscallReturn gem5::pread64Func (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> bufPtr, int nbytes, int offset)
 
template<class OS >
SyscallReturn gem5::pwrite64Func (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> bufPtr, int nbytes, int offset)
 
template<class OS >
SyscallReturn gem5::mmap2Func (SyscallDesc *desc, ThreadContext *tc, VPtr<> start, typename OS::size_t length, int prot, int tgt_flags, int tgt_fd, typename OS::off_t offset)
 Target mmap2() handler. More...
 
template<class OS >
SyscallReturn gem5::getrlimitFunc (SyscallDesc *desc, ThreadContext *tc, unsigned resource, VPtr< typename OS::rlimit > rlp)
 Target getrlimit() handler. More...
 
template<class OS >
SyscallReturn gem5::prlimitFunc (SyscallDesc *desc, ThreadContext *tc, int pid, int resource, VPtr<> n, VPtr< typename OS::rlimit > rlp)
 
template<class OS >
SyscallReturn gem5::clock_gettimeFunc (SyscallDesc *desc, ThreadContext *tc, int clk_id, VPtr< typename OS::timespec > tp)
 Target clock_gettime() function. More...
 
template<class OS >
SyscallReturn gem5::clock_getresFunc (SyscallDesc *desc, ThreadContext *tc, int clk_id, VPtr< typename OS::timespec > tp)
 Target clock_getres() function. More...
 
template<class OS >
SyscallReturn gem5::gettimeofdayFunc (SyscallDesc *desc, ThreadContext *tc, VPtr< typename OS::timeval > tp, VPtr<> tz_ptr)
 Target gettimeofday() handler. More...
 
template<class OS >
SyscallReturn gem5::utimesFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr< typename OS::timeval[2]> tp)
 Target utimes() handler. More...
 
template<class OS >
SyscallReturn gem5::execveFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> pathname, VPtr<> argv_mem_loc, VPtr<> envp_mem_loc)
 
template<class OS >
SyscallReturn gem5::getrusageFunc (SyscallDesc *desc, ThreadContext *tc, int who, VPtr< typename OS::rusage > rup)
 Target getrusage() function. More...
 
template<class OS >
SyscallReturn gem5::timesFunc (SyscallDesc *desc, ThreadContext *tc, VPtr< typename OS::tms > bufp)
 Target times() function. More...
 
template<class OS >
SyscallReturn gem5::timeFunc (SyscallDesc *desc, ThreadContext *tc, VPtr<> taddr)
 Target time() function. More...
 
template<class OS >
SyscallReturn gem5::tgkillFunc (SyscallDesc *desc, ThreadContext *tc, int tgid, int tid, int sig)
 
template<class OS >
SyscallReturn gem5::socketFunc (SyscallDesc *desc, ThreadContext *tc, int domain, int type, int prot)
 
template<class OS >
SyscallReturn gem5::socketpairFunc (SyscallDesc *desc, ThreadContext *tc, int domain, int type, int prot, VPtr<> svPtr)
 
template<class OS >
SyscallReturn gem5::selectFunc (SyscallDesc *desc, ThreadContext *tc, int nfds, VPtr< typename OS::fd_set > readfds, VPtr< typename OS::fd_set > writefds, VPtr< typename OS::fd_set > errorfds, VPtr< typename OS::timeval > timeout)
 
template<class OS >
SyscallReturn gem5::readFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int nbytes)
 
template<class OS >
SyscallReturn gem5::writeFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> buf_ptr, int nbytes)
 
template<class OS >
SyscallReturn gem5::wait4Func (SyscallDesc *desc, ThreadContext *tc, pid_t pid, VPtr<> statPtr, int options, VPtr<> rusagePtr)
 
template<class OS >
SyscallReturn gem5::acceptFunc (SyscallDesc *desc, ThreadContext *tc, int tgt_fd, VPtr<> addrPtr, VPtr<> lenPtr)
 
template<class OS >
SyscallReturn gem5::eventfdFunc (SyscallDesc *desc, ThreadContext *tc, unsigned initval, int in_flags)
 Target eventfd() function. More...
 
template<class OS >
SyscallReturn gem5::schedGetaffinityFunc (SyscallDesc *desc, ThreadContext *tc, pid_t pid, size_t cpusetsize, VPtr<> cpu_set_mask)
 Target sched_getaffinity. More...
 

Variables

const unsigned gem5::seconds_since_epoch = 1000 * 1000 * 1000
 Approximate seconds since the epoch (1/1/1970). More...
 

Detailed Description

This file defines objects used to emulate syscalls from the target application on the host machine.

Definition in file syscall_emul.hh.

Macro Definition Documentation

◆ NO_STAT64

#define NO_STAT64   0

Definition at line 50 of file syscall_emul.hh.


Generated on Tue Sep 21 2021 12:26:45 for gem5 by doxygen 1.8.17