static const char *hostname;
/// Target uname() handler.
- static int
+ static SyscallReturn
unameFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
strcpy(name->machine, "alpha");
name.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
/// Target osf_getsysyinfo() handler. Even though this call is
/// borrowed from Tru64, the subcases that get used appear to be
/// different in practice from those used by Tru64 processes.
- static int
+ static SyscallReturn
osf_getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
// I don't think this exactly matches the HW FPCR
*fpcr = 0;
fpcr.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
default:
break;
}
- return 1;
+ return SyscallReturn(1);
}
/// Target osf_setsysinfo() handler.
- static int
+ static SyscallReturn
osf_setsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
fpcr.copyIn(xc->mem);
DPRINTFR(SyscallVerbose, "osf_setsysinfo(SSI_IEEE_FP_CONTROL): "
" setting FPCR to 0x%x\n", *(uint64_t*)fpcr);
- return 0;
+ return SyscallReturn(0);
}
default:
break;
}
- return 1;
+ return SyscallReturn(1);
}
/// Target fnctl() handler.
- static int
+ static SyscallReturn
fcntlFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
int fd = xc->getSyscallArg(0);
if (fd < 0 || process->sim_fd(fd) < 0)
- return -EBADF;
+ return SyscallReturn(-EBADF);
int cmd = xc->getSyscallArg(1);
switch (cmd) {
// if we really wanted to support this, we'd need to do it
// in the target fd space.
warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd);
- return -EMFILE;
+ return SyscallReturn(-EMFILE);
case 1: // F_GETFD (get close-on-exec flag)
case 2: // F_SETFD (set close-on-exec flag)
- return 0;
+ return SyscallReturn(0);
case 3: // F_GETFL (get file flags)
case 4: // F_SETFL (set file flags)
// not sure if this is totally valid, but we'll pass it through
// to the underlying OS
warn("fcntl(%d, %d) passed through to host\n", fd, cmd);
- return fcntl(process->sim_fd(fd), cmd);
+ return SyscallReturn(fcntl(process->sim_fd(fd), cmd));
// return 0;
case 7: // F_GETLK (get lock)
case 9: // F_SETLKW (set lock and wait)
// don't mess with file locking... just act like it's OK
warn("File lock call (fcntl(%d, %d)) ignored.\n", fd, cmd);
- return 0;
+ return SyscallReturn(0);
default:
warn("Unknown fcntl command %d\n", cmd);
- return 0;
+ return SyscallReturn(0);
}
}
static const char *hostname;
/// Target uname() handler.
- static int
+ static SyscallReturn
unameFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
strcpy(name->machine, "alpha");
name.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
/// Target getsysyinfo() handler.
- static int
+ static SyscallReturn
getsysinfoFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
TypedBufferArg<uint32_t> max_cpu(xc->getSyscallArg(1));
*max_cpu = process->numCpus();
max_cpu.copyOut(xc->mem);
- return 1;
+ return SyscallReturn(1);
}
case Tru64::GSI_CPUS_IN_BOX: {
TypedBufferArg<uint32_t> cpus_in_box(xc->getSyscallArg(1));
*cpus_in_box = process->numCpus();
cpus_in_box.copyOut(xc->mem);
- return 1;
+ return SyscallReturn(1);
}
case Tru64::GSI_PHYSMEM: {
TypedBufferArg<uint64_t> physmem(xc->getSyscallArg(1));
*physmem = 1024 * 1024; // physical memory in KB
physmem.copyOut(xc->mem);
- return 1;
+ return SyscallReturn(1);
}
case Tru64::GSI_CPU_INFO: {
infop->mhz = 667;
infop.copyOut(xc->mem);
- return 1;
+ return SyscallReturn(1);
}
case Tru64::GSI_PROC_TYPE: {
TypedBufferArg<uint64_t> proc_type(xc->getSyscallArg(1));
*proc_type = 11;
proc_type.copyOut(xc->mem);
- return 1;
+ return SyscallReturn(1);
}
case Tru64::GSI_PLATFORM_NAME: {
"COMPAQ Professional Workstation XP1000",
nbytes);
bufArg.copyOut(xc->mem);
- return 1;
+ return SyscallReturn(1);
}
case Tru64::GSI_CLK_TCK: {
TypedBufferArg<uint64_t> clk_hz(xc->getSyscallArg(1));
*clk_hz = 1024;
clk_hz.copyOut(xc->mem);
- return 1;
+ return SyscallReturn(1);
}
default:
break;
}
- return 0;
+ return SyscallReturn(0);
}
/// Target fnctl() handler.
- static int
+ static SyscallReturn
fcntlFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
int fd = xc->getSyscallArg(0);
if (fd < 0 || process->sim_fd(fd) < 0)
- return -EBADF;
+ return SyscallReturn(-EBADF);
int cmd = xc->getSyscallArg(1);
switch (cmd) {
// if we really wanted to support this, we'd need to do it
// in the target fd space.
warn("fcntl(%d, F_DUPFD) not supported, error returned\n", fd);
- return -EMFILE;
+ return SyscallReturn(-EMFILE);
case 1: // F_GETFD (get close-on-exec flag)
case 2: // F_SETFD (set close-on-exec flag)
- return 0;
+ return SyscallReturn(0);
case 3: // F_GETFL (get file flags)
case 4: // F_SETFL (set file flags)
// not sure if this is totally valid, but we'll pass it through
// to the underlying OS
warn("fcntl(%d, %d) passed through to host\n", fd, cmd);
- return fcntl(process->sim_fd(fd), cmd);
+ return SyscallReturn(fcntl(process->sim_fd(fd), cmd));
// return 0;
case 7: // F_GETLK (get lock)
case 9: // F_SETLKW (set lock and wait)
// don't mess with file locking... just act like it's OK
warn("File lock call (fcntl(%d, %d)) ignored.\n", fd, cmd);
- return 0;
+ return SyscallReturn(0);
default:
warn("Unknown fcntl command %d\n", cmd);
- return 0;
+ return SyscallReturn(0);
}
}
/// Target getdirentries() handler.
- static int
+ static SyscallReturn
getdirentriesFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
// check for error
if (host_result < 0) {
delete [] host_buf;
- return -errno;
+ return SyscallReturn(-errno);
}
// no error: copy results back to target space
*basep = host_basep;
basep.copyOut(xc->mem);
- return (tgt_buf_ptr - tgt_buf);
+ return SyscallReturn(tgt_buf_ptr - tgt_buf);
}
/// Target sigreturn() handler.
- static int
+ static SyscallReturn
sigreturnFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
regs->miscRegs.fpcr = sc->sc_fpcr;
- return 0;
+ return SyscallReturn(0);
}
/// Target table() handler.
- static int
+ static SyscallReturn
tableFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
switch (id) {
case Tru64::TBL_SYSINFO: {
if (index != 0 || nel != 1 || lel != sizeof(Tru64::tbl_sysinfo))
- return -EINVAL;
+ return SyscallReturn(-EINVAL);
TypedBufferArg<Tru64::tbl_sysinfo> elp(xc->getSyscallArg(2));
const int clk_hz = one_million;
elp->si_boottime = seconds_since_epoch; // seconds since epoch?
elp->si_max_procs = process->numCpus();
elp.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
default:
cerr << "table(): id " << id << " unknown." << endl;
- return -EINVAL;
+ return SyscallReturn(-EINVAL);
}
}
//
/// Create a stack region for a thread.
- static int
+ static SyscallReturn
stack_createFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
argp.copyOut(xc->mem);
}
- return 0;
+ return SyscallReturn(0);
}
/// NXM library version stamp.
/// This call sets up the interface between the user and kernel
/// schedulers by creating a shared-memory region. The shared memory
/// region has several structs, some global, some per-RAD, some per-VP.
- static int
+ static SyscallReturn
nxm_task_initFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
*configptr_ptr = config_addr;
configptr_ptr.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
/// Initialize execution context.
}
/// Create thread.
- static int
+ static SyscallReturn
nxm_thread_createFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
*kidp = 99;
kidp.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
} else if (attrp->type == Tru64::NXM_TYPE_VP) {
// A real "virtual processor" kernel thread. Need to fork
// this thread on another CPU.
*kidp = thread_index;
kidp.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
}
abort();
}
- return 0;
+ return SyscallReturn(0);
}
/// Thread idle call (like yield()).
- static int
+ static SyscallReturn
nxm_idleFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
- return 0;
+ return SyscallReturn(0);
}
/// Block thread.
- static int
+ static SyscallReturn
nxm_thread_blockFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
cout << xc->cpu->name() << ": nxm_thread_block " << tid << " " << secs
<< " " << flags << " " << action << " " << usecs << endl;
- return 0;
+ return SyscallReturn(0);
}
/// block.
- static int
+ static SyscallReturn
nxm_blockFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
<< " " << secs << " " << usecs
<< " " << flags << endl;
- return 0;
+ return SyscallReturn(0);
}
/// Unblock thread.
- static int
+ static SyscallReturn
nxm_unblockFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
cout << xc->cpu->name() << ": nxm_unblock "
<< hex << uaddr << dec << endl;
- return 0;
+ return SyscallReturn(0);
}
/// Switch thread priority.
- static int
+ static SyscallReturn
swtch_priFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
//
// Since we assume at most one "kernel" thread per CPU, it's
// always safe to return false here.
- return false;
+ return SyscallReturn(0); //false;
}
}
/// Lock acquire syscall handler.
- static int
+ static SyscallReturn
m5_mutex_lockFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
// Return 0 since we will always return to the user with the lock
// acquired. We will just keep the context inactive until that is
// true.
- return 0;
+ return SyscallReturn(0);
}
/// Try lock (non-blocking).
- static int
+ static SyscallReturn
m5_mutex_trylockFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
// lock is free: grab it
*lockp = 1;
lockp.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
} else {
- return 1;
+ return SyscallReturn(1);
}
}
/// Unlock syscall handler.
- static int
+ static SyscallReturn
m5_mutex_unlockFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
m5_unlock_mutex(uaddr, process, xc);
- return 0;
+ return SyscallReturn(0);
}
/// Signal ocndition.
- static int
+ static SyscallReturn
m5_cond_signalFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
// Wake up one process waiting on the condition variable.
activate_waiting_context(cond_addr, process);
- return 0;
+ return SyscallReturn(0);
}
/// Wake up all processes waiting on the condition variable.
- static int
+ static SyscallReturn
m5_cond_broadcastFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
activate_waiting_context(cond_addr, process, true);
- return 0;
+ return SyscallReturn(0);
}
/// Wait on a condition.
- static int
+ static SyscallReturn
m5_cond_waitFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
process->waitList.push_back(Process::WaitRec(cond_addr, xc));
xc->suspend();
- return 0;
+ return SyscallReturn(0);
}
/// Thread exit.
- static int
+ static SyscallReturn
m5_thread_exitFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
assert(xc->status() == ExecContext::Active);
xc->deallocate();
- return 0;
+ return SyscallReturn(0);
}
/// Array of syscall descriptors for Mach syscalls, indexed by
}
/// Indirect syscall invocation (call #0).
- static int
+ static SyscallReturn
indirectSyscallFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
doSyscall(new_callnum, process, xc);
- return 0;
+ return SyscallReturn(0);
}
}; // class Tru64
const int BranchPredAddrShiftAmt = TheISA::BranchPredAddrShiftAmt;
const int MaxAddr = (Addr)-1;
+#ifndef FULL_SYSTEM
+class SyscallReturn {
+ public:
+ template <class T>
+ SyscallReturn(T v, bool s)
+ {
+ retval = (uint64_t)v;
+ success = s;
+ }
+
+ template <class T>
+ SyscallReturn(T v)
+ {
+ success = (v >= 0);
+ retval = (uint64_t)v;
+ }
+
+ ~SyscallReturn() {}
+
+ SyscallReturn& operator=(const SyscallReturn& s) {
+ retval = s.retval;
+ success = s.success;
+ return *this;
+ }
+
+ uint64_t successful() { return success; }
+ bool value() { return retval; }
+
+
+ private:
+ uint64_t retval;
+ bool success;
+};
+
+#endif
+
+
#ifdef FULL_SYSTEM
typedef TheISA::InternalProcReg InternalProcReg;
const int NumInternalProcRegs = TheISA::NumInternalProcRegs;
regs.intRegFile[ArgumentReg0 + i] = val;
}
- void setSyscallReturn(int64_t return_value)
+ void setSyscallReturn(SyscallReturn return_value)
{
// check for error condition. Alpha syscall convention is to
// indicate success/failure in reg a3 (r19) and put the
// return value itself in the standard return value reg (v0).
const int RegA3 = 19; // only place this is used
- if (return_value >= 0) {
+ if (return_value.successful()) {
// no error
regs.intRegFile[RegA3] = 0;
- regs.intRegFile[ReturnValueReg] = return_value;
+ regs.intRegFile[ReturnValueReg] = return_value.value();
} else {
// got an error, return details
regs.intRegFile[RegA3] = (IntReg) -1;
- regs.intRegFile[ReturnValueReg] = -return_value;
+ regs.intRegFile[ReturnValueReg] = -return_value.value();
}
}
// current number of allocated processes
int num_processes = 0;
-Process::Process(const string &name,
+Process::Process(const string &nm,
int stdin_fd, // initial I/O descriptors
int stdout_fd,
int stderr_fd)
- : SimObject(name)
+ : SimObject(nm)
{
// allocate memory space
- memory = new MainMemory(name + ".MainMem");
+ memory = new MainMemory(nm + ".MainMem");
// allocate initial register file
init_regs = new RegFile;
fd_map[i] = -1;
}
+ mmap_start = mmap_end = 0;
// other parameters will be initialized when the program is loaded
}
memory->access(Write, array_ptr, &data_ptr, sizeof(Addr));
}
-LiveProcess::LiveProcess(const string &name, ObjectFile *objFile,
+LiveProcess::LiveProcess(const string &nm, ObjectFile *objFile,
int stdin_fd, int stdout_fd, int stderr_fd,
vector<string> &argv, vector<string> &envp)
- : Process(name, stdin_fd, stdout_fd, stderr_fd)
+ : Process(nm, stdin_fd, stdout_fd, stderr_fd)
{
prog_fname = argv[0];
LiveProcess *
-LiveProcess::create(const string &name,
+LiveProcess::create(const string &nm,
int stdin_fd, int stdout_fd, int stderr_fd,
vector<string> &argv, vector<string> &envp)
{
if (objFile->getArch() == ObjectFile::Alpha) {
switch (objFile->getOpSys()) {
case ObjectFile::Tru64:
- process = new AlphaTru64Process(name, objFile,
+ process = new AlphaTru64Process(nm, objFile,
stdin_fd, stdout_fd, stderr_fd,
argv, envp);
break;
case ObjectFile::Linux:
- process = new AlphaLinuxProcess(name, objFile,
+ process = new AlphaLinuxProcess(nm, objFile,
stdin_fd, stdout_fd, stderr_fd,
argv, envp);
break;
#include "sim/sim_object.hh"
#include "sim/stats.hh"
#include "base/statistics.hh"
+#include "base/trace.hh"
class ExecContext;
class FunctionalMemory;
protected:
// constructor
- Process(const std::string &name,
+ Process(const std::string &nm,
int stdin_fd, // initial I/O descriptors
int stdout_fd,
int stderr_fd);
class LiveProcess : public Process
{
protected:
- LiveProcess(const std::string &name, ObjectFile *objFile,
+ LiveProcess(const std::string &nm, ObjectFile *objFile,
int stdin_fd, int stdout_fd, int stderr_fd,
std::vector<std::string> &argv,
std::vector<std::string> &envp);
// this function is used to create the LiveProcess object, since
// we can't tell which subclass of LiveProcess to use until we
// open and look at the object file.
- static LiveProcess *create(const std::string &name,
+ static LiveProcess *create(const std::string &nm,
int stdin_fd, int stdout_fd, int stderr_fd,
std::vector<std::string> &argv,
std::vector<std::string> &envp);
DPRINTFR(SyscallVerbose, "%s: syscall %s called\n",
xc->cpu->name(), name);
- int retval = (*funcPtr)(this, callnum, process, xc);
+ SyscallReturn retval = (*funcPtr)(this, callnum, process, xc);
DPRINTFR(SyscallVerbose, "%s: syscall %s returns %d\n",
- xc->cpu->name(), name, retval);
+ xc->cpu->name(), name, retval.value());
- if (!((flags & SyscallDesc::SuppressReturnValue) && retval == 0))
+ if (!(flags & SyscallDesc::SuppressReturnValue))
xc->setSyscallReturn(retval);
}
-int
+SyscallReturn
unimplementedFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
}
-int
+SyscallReturn
ignoreFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
<< ", " << xc->getSyscallArg(1)
<< ", ...)" << endl;
- return 0;
+ return SyscallReturn(0);
}
-int
+SyscallReturn
exitFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
new SimExitEvent("syscall caused exit", xc->getSyscallArg(0) & 0xff);
- return 1;
+ return SyscallReturn(1);
}
-int
+SyscallReturn
getpagesizeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
- return VMPageSize;
+ return SyscallReturn(VMPageSize);
}
-int
+SyscallReturn
obreakFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
// change brk addr to first arg
Addr new_brk = xc->getSyscallArg(0);
if (new_brk != 0)
+ {
p->brk_point = xc->getSyscallArg(0);
- return p->brk_point;
+ }
+ return SyscallReturn(p->brk_point);
}
-int
+SyscallReturn
closeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
- return close(fd);
+ return SyscallReturn(close(fd));
}
-int
+SyscallReturn
readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
if (bytes_read != -1)
bufArg.copyOut(xc->mem);
- return bytes_read;
+ return SyscallReturn(bytes_read);
}
-int
+SyscallReturn
writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
fsync(fd);
- return bytes_written;
+ return SyscallReturn(bytes_written);
}
-int
+SyscallReturn
lseekFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
off_t result = lseek(fd, offs, whence);
- return (result == (off_t)-1) ? -errno : result;
+ return (result == (off_t)-1) ? SyscallReturn(-errno) :
+ SyscallReturn(result);
}
-int
+SyscallReturn
munmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
// given that we don't really implement mmap, munmap is really easy
- return 0;
+ return SyscallReturn(0);
}
const char *hostname = "m5.eecs.umich.edu";
-int
+SyscallReturn
gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int name_len = xc->getSyscallArg(1);
name.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
-int
+SyscallReturn
unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
std::string path;
if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;
+ return (TheISA::IntReg)-EFAULT;
int result = unlink(path.c_str());
- return (result == -1) ? -errno : result;
+ return (result == -1) ? SyscallReturn(-errno) : SyscallReturn(result);
}
-int
+SyscallReturn
renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
std::string old_name;
if (xc->mem->readString(old_name, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;
+ return SyscallReturn(-EFAULT);
std::string new_name;
if (xc->mem->readString(new_name, xc->getSyscallArg(1)) != No_Fault)
- return -EFAULT;
+ return SyscallReturn(-EFAULT);
- int result = rename(old_name.c_str(),new_name.c_str());
- return (result == -1) ? -errno : result;
+ int64_t result = rename(old_name.c_str(),new_name.c_str());
+ return (result == -1) ? SyscallReturn(-errno) : SyscallReturn(result);
}
public:
/// Typedef for target syscall handler functions.
- typedef int (*FuncPtr)(SyscallDesc *, int num,
+ typedef SyscallReturn (*FuncPtr)(SyscallDesc *, int num,
Process *, ExecContext *);
const char *name; //!< Syscall name (e.g., "open").
/// Handler for unimplemented syscalls that we haven't thought about.
-int unimplementedFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn unimplementedFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Handler for unimplemented syscalls that we never intend to
/// implement (signal handling, etc.) and should not affect the correct
/// behavior of the program. Print a warning only if the appropriate
/// trace flag is enabled. Return success to the target program.
-int ignoreFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn ignoreFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target exit() handler: terminate simulation.
-int exitFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn exitFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target getpagesize() handler.
-int getpagesizeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn getpagesizeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target obreak() handler: set brk address.
-int obreakFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn obreakFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target close() handler.
-int closeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn closeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target read() handler.
-int readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target write() handler.
-int writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target lseek() handler.
-int lseekFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn lseekFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target munmap() handler.
-int munmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn munmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target gethostname() handler.
-int gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target unlink() handler.
-int unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// Target rename() handler.
-int renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
+SyscallReturn renameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc);
/// This struct is used to build an target-OS-dependent table that
/// maps the target's open() flags to the host open() flags.
/// only to find out if their stdout is a tty, to determine whether to
/// do line or block buffering.
template <class OS>
-int
+SyscallReturn
ioctlFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
if (fd < 0 || process->sim_fd(fd) < 0) {
// doesn't map to any simulator fd: not a valid target fd
- return -EBADF;
+ return SyscallReturn(-EBADF);
}
switch (req) {
case OS::TIOCGETC:
case OS::TIOCGETS:
case OS::TIOCGETA:
- return -ENOTTY;
+ return SyscallReturn(-ENOTTY);
default:
fatal("Unsupported ioctl call: ioctl(%d, 0x%x, ...) @ 0x%llx\n", fd, req, xc->readPC());
/// Target open() handler.
template <class OS>
-int
+SyscallReturn
openFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
std::string path;
if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;
+ return SyscallReturn(-EFAULT);
if (path == "/dev/sysdev0") {
// This is a memory-mapped high-resolution timer device on Alpha.
// We don't support it, so just punt.
DCOUT(SyscallWarnings) << "Ignoring open(" << path << ", ...)" << std::endl;
- return -ENOENT;
+ return SyscallReturn(-ENOENT);
}
int tgtFlags = xc->getSyscallArg(1);
// open the file
int fd = open(path.c_str(), hostFlags, mode);
- return (fd == -1) ? -errno : process->open_fd(fd);
+ return (fd == -1) ? SyscallReturn(-errno) : SyscallReturn(process->open_fd(fd));
}
/// Target stat() handler.
template <class OS>
-int
+SyscallReturn
statFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
std::string path;
if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;
+ return SyscallReturn(-EFAULT);
struct stat hostBuf;
int result = stat(path.c_str(), &hostBuf);
if (result < 0)
- return -errno;
+ return SyscallReturn(errno);
OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf);
- return 0;
+ return SyscallReturn(0);
}
/// Target lstat() handler.
template <class OS>
-int
+SyscallReturn
lstatFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
std::string path;
if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault)
- return -EFAULT;
+ return SyscallReturn(-EFAULT);
struct stat hostBuf;
int result = lstat(path.c_str(), &hostBuf);
if (result < 0)
- return -errno;
+ return SyscallReturn(-errno);
OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf);
- return 0;
+ return SyscallReturn(0);
}
/// Target fstat() handler.
template <class OS>
-int
+SyscallReturn
fstatFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
// DPRINTFR(SyscallVerbose, "fstat(%d, ...)\n", fd);
if (fd < 0)
- return -EBADF;
+ return SyscallReturn(-EBADF);
struct stat hostBuf;
int result = fstat(fd, &hostBuf);
if (result < 0)
- return -errno;
+ return SyscallReturn(-errno);
OS::copyOutStatBuf(xc->mem, xc->getSyscallArg(1), &hostBuf);
- return 0;
+ return SyscallReturn(0);
}
/// file descriptor, and fail (or implement!) a non-anonymous mmap to
/// anything else.
template <class OS>
-int
+SyscallReturn
mmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
Addr start = xc->getSyscallArg(0);
"This will break if not /dev/zero.", xc->getSyscallArg(4));
}
- return start;
+ return SyscallReturn(start);
}
/// Target getrlimit() handler.
template <class OS>
-int
+SyscallReturn
getrlimitFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
}
rlp.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
/// Target gettimeofday() handler.
template <class OS>
-int
+SyscallReturn
gettimeofdayFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
tp.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
/// Target getrusage() function.
template <class OS>
-int
+SyscallReturn
getrusageFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
rup.copyOut(xc->mem);
- return 0;
+ return SyscallReturn(0);
}
#endif // __SIM_SYSCALL_EMUL_HH__