/*
- * Copyright (c) 2003 The Regents of The University of Michigan
+ * Copyright (c) 2003-2005 The Regents of The University of Michigan
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
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)
{
}
-int
+SyscallReturn
exitFunc(SyscallDesc *desc, int callnum, Process *process,
ExecContext *xc)
{
}
-int
+SyscallReturn
getpagesizeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
return VMPageSize;
}
-int
+SyscallReturn
obreakFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
// change brk addr to first arg
- p->brk_point = xc->getSyscallArg(0);
+ Addr new_brk = xc->getSyscallArg(0);
+ if (new_brk != 0)
+ {
+ p->brk_point = xc->getSyscallArg(0);
+ }
+ DPRINTF(SyscallVerbose, "Break Point changed to: %#X\n", p->brk_point);
return p->brk_point;
}
-int
+SyscallReturn
closeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
}
-int
+SyscallReturn
readFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
return bytes_read;
}
-int
+SyscallReturn
writeFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
}
-int
+SyscallReturn
lseekFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int fd = p->sim_fd(xc->getSyscallArg(0));
}
-int
+SyscallReturn
munmapFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
// given that we don't really implement mmap, munmap is really easy
const char *hostname = "m5.eecs.umich.edu";
-int
+SyscallReturn
gethostnameFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
{
int name_len = xc->getSyscallArg(1);
return 0;
}
+SyscallReturn
+unlinkFunc(SyscallDesc *desc, int num, Process *p, ExecContext *xc)
+{
+ std::string path;
+
+ if (xc->mem->readString(path, xc->getSyscallArg(0)) != No_Fault)
+ return (TheISA::IntReg)-EFAULT;
+
+ int result = unlink(path.c_str());
+ return (result == -1) ? -errno : result;
+}
+
+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;
+
+ std::string new_name;
+
+ if (xc->mem->readString(new_name, xc->getSyscallArg(1)) != No_Fault)
+ return -EFAULT;
+
+ int64_t result = rename(old_name.c_str(),new_name.c_str());
+ return (result == -1) ? -errno : result;
+}