gem5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
SyscallDesc Class Reference

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...
 

Detailed Description

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.

Member Typedef Documentation

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.

Member Enumeration Documentation

Provide a mechanism to specify behavior for abnormal system calls.

Enumerator
SuppressReturnValue 

Do not set return registers according to executor return value.

Used for system calls with non-standard return conventions that explicitly set the thread context regs (e.g., sigreturn, clone)

WarnOnce 

Warn only once for unimplemented system calls.

Definition at line 75 of file syscall_desc.hh.

Constructor & Destructor Documentation

SyscallDesc::SyscallDesc ( const char *  name,
SyscallExecutor  sys_exec,
int  flags = 0 
)
inline

Definition at line 69 of file syscall_desc.hh.

Member Function Documentation

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.

Parameters
callnumNumber associated with call (by operating system)
procHandle for the owning Process to pass information
tcHandle 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().

int SyscallDesc::getFlags ( ) const
inline

Definition at line 110 of file syscall_desc.hh.

References _flags.

std::string SyscallDesc::name ( )
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().

void SyscallDesc::setFlags ( int  flags)
inline

Definition at line 112 of file syscall_desc.hh.

References _flags.

Referenced by execveFunc().

bool SyscallDesc::warnOnce ( ) const
inline

Definition at line 106 of file syscall_desc.hh.

References _flags, and WarnOnce.

Referenced by ignoreFunc(), and needWarning().

Member Data Documentation

int SyscallDesc::_flags
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().

std::string SyscallDesc::_name
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().

bool SyscallDesc::_warned
private

Set if WarnOnce is specified in flags AFTER first call.

Definition at line 129 of file syscall_desc.hh.

Referenced by needWarning().

SyscallExecutor SyscallDesc::executor
private

Mechanism for ISAs to connect to the emul function definitions.

Definition at line 119 of file syscall_desc.hh.


The documentation for this class was generated from the following files:

Generated on Fri Jun 9 2017 13:04:20 for gem5 by doxygen 1.8.6