summaryrefslogtreecommitdiff
path: root/sim
diff options
context:
space:
mode:
authorAli Saidi <saidi@eecs.umich.edu>2006-03-09 15:56:42 -0500
committerAli Saidi <saidi@eecs.umich.edu>2006-03-09 15:56:42 -0500
commit56cc760f6f53138c133c5d4e1f9d3e3199965d99 (patch)
tree991271751791743eb9db33508fd3d183e61772be /sim
parent91545ac2bf5ac47ecbfc403ef6e2b2ce340ae551 (diff)
parentce3a6343b6c54e95d63403d46c9ddea384e49476 (diff)
downloadgem5-56cc760f6f53138c133c5d4e1f9d3e3199965d99.tar.xz
Merge zizzer:/bk/multiarch
into zeep.eecs.umich.edu:/z/saidi/work/m5.ma2 arch/alpha/isa_traits.hh: arch/alpha/linux/process.cc: arch/sparc/isa_traits.hh: arch/sparc/linux/process.cc: sim/process.cc: merge --HG-- rename : cpu/exec_context.hh => cpu/cpu_exec_context.hh extra : convert_revision : fea0155c8e23abbd0d5d5251abbd0f4d223fe935
Diffstat (limited to 'sim')
-rw-r--r--sim/process.cc2
-rw-r--r--sim/syscall_emul.cc114
-rw-r--r--sim/syscall_emul.hh48
3 files changed, 163 insertions, 1 deletions
diff --git a/sim/process.cc b/sim/process.cc
index 851192dcd..f02ca8bfd 100644
--- a/sim/process.cc
+++ b/sim/process.cc
@@ -357,7 +357,7 @@ LiveProcess::syscall(ExecContext *xc)
{
num_syscalls++;
- int64_t callnum = xc->readIntReg(ReturnValueReg);
+ int64_t callnum = xc->readIntReg(SyscallNumReg);
SyscallDesc *desc = getDesc(callnum);
if (desc == NULL)
diff --git a/sim/syscall_emul.cc b/sim/syscall_emul.cc
index 2f6ed128d..793c0c6cb 100644
--- a/sim/syscall_emul.cc
+++ b/sim/syscall_emul.cc
@@ -324,4 +324,118 @@ fcntlFunc(SyscallDesc *desc, int num, Process *process,
}
}
+SyscallReturn
+pipePseudoFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ int fds[2], sim_fds[2];
+ int pipe_retval = pipe(fds);
+
+ if (pipe_retval < 0) {
+ // error
+ return pipe_retval;
+ }
+
+ sim_fds[0] = process->alloc_fd(fds[0]);
+ sim_fds[1] = process->alloc_fd(fds[1]);
+
+ // Alpha Linux convention for pipe() is that fd[0] is returned as
+ // the return value of the function, and fd[1] is returned in r20.
+ xc->regs.intRegFile[SyscallPseudoReturnReg] = sim_fds[1];
+ return sim_fds[0];
+}
+
+
+SyscallReturn
+getpidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ // Make up a PID. There's no interprocess communication in
+ // fake_syscall mode, so there's no way for a process to know it's
+ // not getting a unique value.
+
+ xc->regs.intRegFile[SyscallPseudoReturnReg] = 99;
+ return 100;
+}
+
+
+SyscallReturn
+getuidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ // Make up a UID and EUID... it shouldn't matter, and we want the
+ // simulation to be deterministic.
+
+ // EUID goes in r20.
+ xc->regs.intRegFile[SyscallPseudoReturnReg] = 100; // EUID
+ return 100; // UID
+}
+
+
+SyscallReturn
+getgidPseudoFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ // Get current group ID. EGID goes in r20.
+ xc->regs.intRegFile[SyscallPseudoReturnReg] = 100;
+ return 100;
+}
+
+
+SyscallReturn
+setuidFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ // can't fathom why a benchmark would call this.
+ warn("Ignoring call to setuid(%d)\n", xc->getSyscallArg(0));
+ return 0;
+}
+
+SyscallReturn
+getpidFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ // Make up a PID. There's no interprocess communication in
+ // fake_syscall mode, so there's no way for a process to know it's
+ // not getting a unique value.
+
+ xc->regs.intRegFile[SyscallPseudoReturnReg] = 99;
+ return 100;
+}
+
+SyscallReturn
+getppidFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ return 99;
+}
+
+SyscallReturn
+getuidFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ return 100; // UID
+}
+
+SyscallReturn
+geteuidFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ return 100; // UID
+}
+
+SyscallReturn
+getgidFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ return 100;
+}
+
+SyscallReturn
+getegidFunc(SyscallDesc *desc, int callnum, Process *process,
+ ExecContext *xc)
+{
+ return 100;
+}
+
diff --git a/sim/syscall_emul.hh b/sim/syscall_emul.hh
index cadaa1cd3..35129bcb4 100644
--- a/sim/syscall_emul.hh
+++ b/sim/syscall_emul.hh
@@ -243,6 +243,54 @@ SyscallReturn fchownFunc(SyscallDesc *desc, int num,
SyscallReturn fcntlFunc(SyscallDesc *desc, int num,
Process *process, ExecContext *xc);
+/// Target setuid() handler.
+SyscallReturn setuidFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target getpid() handler.
+SyscallReturn getpidFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target getuid() handler.
+SyscallReturn getuidFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target getgid() handler.
+SyscallReturn getgidFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target getppid() handler.
+SyscallReturn getppidFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target geteuid() handler.
+SyscallReturn geteuidFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target getegid() handler.
+SyscallReturn getegidFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+
+
+/// Pseudo Funcs - These functions use a different return convension,
+/// returning a second value in a register other than the normal return register
+SyscallReturn pipePseudoFunc(SyscallDesc *desc, int num,
+ Process *process, ExecContext *xc);
+
+/// Target getpidPseudo() handler.
+SyscallReturn getpidPseudoFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target getuidPseudo() handler.
+SyscallReturn getuidPseudoFunc(SyscallDesc *desc, int num,
+ Process *p, ExecContext *xc);
+
+/// Target getgidPseudo() handler.
+SyscallReturn getgidPseudoFunc(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.
struct OpenFlagTransTable {