summaryrefslogtreecommitdiff
path: root/sim/syscall_emul.cc
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2005-03-09 15:52:10 -0500
committerAli Saidi <saidi@eecs.umich.edu>2005-03-09 15:52:10 -0500
commit232134a8169e35931a34140c57dc7a8dfb4b1546 (patch)
treec178f1b301ee284d81522ecc14ac40f927a0df13 /sim/syscall_emul.cc
parent761d104f7b5771ad7c854a6e6474c30ce55e217e (diff)
downloadgem5-232134a8169e35931a34140c57dc7a8dfb4b1546.tar.xz
Changed all syscalls to use syscall return object.
arch/alpha/alpha_linux_process.cc: arch/alpha/alpha_tru64_process.cc: cpu/exec_context.hh: sim/process.hh: sim/syscall_emul.cc: sim/syscall_emul.hh: Changed all syscalls to use syscall return object arch/alpha/isa_traits.hh: Added syscall return object that packages return value and return status into an object. sim/process.cc: renamed variable name to nm so base class function name() can be called --HG-- extra : convert_revision : 6609c5ffecc9e3519d7a0cd160879fd21d54abfc
Diffstat (limited to 'sim/syscall_emul.cc')
-rw-r--r--sim/syscall_emul.cc67
1 files changed, 35 insertions, 32 deletions
diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc
index a0cbdf414..ae865be86 100644
--- a/sim/syscall_emul.cc
+++ b/sim/syscall_emul.cc
@@ -47,17 +47,17 @@ SyscallDesc::doSyscall(int callnum, Process *process, ExecContext *xc)
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)
{
@@ -70,7 +70,7 @@ unimplementedFunc(SyscallDesc *desc, int callnum, Process *process,
}
-int
+SyscallReturn
ignoreFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
@@ -79,47 +79,49 @@ ignoreFunc(SyscallDesc *desc, int callnum, Process *process,
<< ", " << 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));
@@ -131,10 +133,10 @@ readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
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));
@@ -147,11 +149,11 @@ writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
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));
@@ -160,21 +162,22 @@ lseekFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
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);
@@ -184,35 +187,35 @@ gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
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);
}