gem5
|
This class provides the wrapper interface for the system call implementations which are defined in the sim/syscall_emul files and bound to the ISAs in the architecture specific code (i.e. More...
#include <syscall_desc.hh>
Public Types | |
enum | Flags { SuppressReturnValue = 1, WarnOnce = 2 } |
Provide a mechanism to specify behavior for abnormal system calls. More... | |
typedef SyscallReturn(* | SyscallExecutor )(SyscallDesc *, int num, Process *, ThreadContext *) |
Typedef the function pointer here to clean up code below. More... | |
Public Member Functions | |
SyscallDesc (const char *name, SyscallExecutor sys_exec, int flags=0) | |
void | doSyscall (int callnum, Process *proc, ThreadContext *tc, Fault *fault) |
Interface for invoking the system call funcion pointer. More... | |
bool | needWarning () |
Return false if WarnOnce is set and a warning has already been issued. More... | |
bool | warnOnce () const |
std::string | name () |
int | getFlags () const |
void | setFlags (int flags) |
Private Attributes | |
std::string | _name |
System call name (e.g., open, mmap, clone, socket, etc.) More... | |
SyscallExecutor | executor |
Mechanism for ISAs to connect to the emul function definitions. More... | |
int | _flags |
Holds values set with the preceding enum; note that this has been used primarily for features that are mutually exclusive, but there's no reason that this needs to be true going forward. More... | |
bool | _warned |
Set if WarnOnce is specified in flags AFTER first call. More... | |
This class provides the wrapper interface for the system call implementations which are defined in the sim/syscall_emul files and bound to the ISAs in the architecture specific code (i.e.
arch/X86/linux/process.cc).
Definition at line 63 of file syscall_desc.hh.
typedef SyscallReturn(* SyscallDesc::SyscallExecutor)(SyscallDesc *, int num, Process *, ThreadContext *) |
Typedef the function pointer here to clean up code below.
Definition at line 66 of file syscall_desc.hh.
enum SyscallDesc::Flags |
Provide a mechanism to specify behavior for abnormal system calls.
Definition at line 75 of file syscall_desc.hh.
|
inline |
Definition at line 69 of file syscall_desc.hh.
void SyscallDesc::doSyscall | ( | int | callnum, |
Process * | proc, | ||
ThreadContext * | tc, | ||
Fault * | fault | ||
) |
Interface for invoking the system call funcion pointer.
Note that this acts as a gateway for all system calls and serves a good point to add filters for behaviors or apply checks for all system calls.
callnum | Number associated with call (by operating system) |
proc | Handle for the owning Process to pass information |
tc | Handle for owning ThreadContext to pass information |
Step through the first six parameters for the system call and retrieve their values. Note that index is incremented as a side-effect of the getSyscallArg method.
Linux supports up to six system call arguments through registers so we want to print all six. Check to the relevant man page to verify how many are actually used by a given system call.
Invoke the system call
If the system call needs to be restarted, most likely due to blocking behavior, warn that the system call will retry; alternatively, print the return value.
Definition at line 49 of file syscall_desc.cc.
References _flags, _name, DPRINTF_SYSCALL, SyscallReturn::encodedValue(), Process::getSyscallArg(), ArmISA::i, MipsISA::index, M5_VAR_USED, SyscallReturn::needsRetry(), and SuppressReturnValue.
Referenced by Process::syscall().
|
inline |
Definition at line 110 of file syscall_desc.hh.
References _flags.
|
inline |
Definition at line 108 of file syscall_desc.hh.
References _name.
Referenced by ignoreFunc(), setThreadArea32Func(), and unimplementedFunc().
bool SyscallDesc::needWarning | ( | ) |
Return false if WarnOnce is set and a warning has already been issued.
Otherwise, return true. Updates state as a side effect to help keep track of issued warnings.
Definition at line 90 of file syscall_desc.cc.
References _warned, and warnOnce().
Referenced by ignoreFunc().
|
inline |
|
inline |
Definition at line 106 of file syscall_desc.hh.
References _flags, and WarnOnce.
Referenced by ignoreFunc(), and needWarning().
|
private |
Holds values set with the preceding enum; note that this has been used primarily for features that are mutually exclusive, but there's no reason that this needs to be true going forward.
Definition at line 126 of file syscall_desc.hh.
Referenced by doSyscall(), getFlags(), setFlags(), and warnOnce().
|
private |
System call name (e.g., open, mmap, clone, socket, etc.)
Definition at line 116 of file syscall_desc.hh.
Referenced by doSyscall(), and name().
|
private |
Set if WarnOnce is specified in flags AFTER first call.
Definition at line 129 of file syscall_desc.hh.
Referenced by needWarning().
|
private |
Mechanism for ISAs to connect to the emul function definitions.
Definition at line 119 of file syscall_desc.hh.