diff options
Diffstat (limited to 'sim/syscall_emul.cc')
-rw-r--r-- | sim/syscall_emul.cc | 67 |
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); } |