summaryrefslogtreecommitdiff
path: root/src/arch/power/linux
diff options
context:
space:
mode:
authorGabe Black <gblack@eecs.umich.edu>2009-10-30 00:44:55 -0700
committerGabe Black <gblack@eecs.umich.edu>2009-10-30 00:44:55 -0700
commit3f722b991fcb33ca21330501960406a8a58e2be2 (patch)
tree69f446fd29600df013ae0695399a986c779f363b /src/arch/power/linux
parent25d932868998db26054910078721433ab430c836 (diff)
downloadgem5-3f722b991fcb33ca21330501960406a8a58e2be2.tar.xz
Syscalls: Make system calls access arguments like a stack, not an array.
When accessing arguments for a syscall, the position of an argument depends on the policies of the ISA, how much space preceding arguments took up, and the "alignment" of the index for this particular argument into the number of possible storate locations. This change adjusts getSyscallArg to take its index parameter by reference instead of value and to adjust it to point to the possible location of the next argument on the stack, basically just after the current one. This way, the rules for the new argument can be applied locally without knowing about other arguments since those have already been taken into account implicitly. All system calls have also been changed to reflect the new interface. In a number of cases this made the implementation clearer since it encourages arguments to be collected in one place in order and then used as necessary later, as opposed to scattering them throughout the function or using them in place in long expressions. It also discourages using getSyscallArg over and over to retrieve the same value when a temporary would do the job.
Diffstat (limited to 'src/arch/power/linux')
-rw-r--r--src/arch/power/linux/process.cc7
-rw-r--r--src/arch/power/linux/process.hh2
2 files changed, 5 insertions, 4 deletions
diff --git a/src/arch/power/linux/process.cc b/src/arch/power/linux/process.cc
index b03ccfc8c..504d0e334 100644
--- a/src/arch/power/linux/process.cc
+++ b/src/arch/power/linux/process.cc
@@ -52,7 +52,8 @@ static SyscallReturn
unameFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, 0));
+ int index = 0;
+ TypedBufferArg<Linux::utsname> name(process->getSyscallArg(tc, index));
strcpy(name->sysname, "Linux");
strcpy(name->nodename, "m5.eecs.umich.edu");
@@ -437,12 +438,12 @@ PowerLinuxProcess::startup()
}
PowerISA::IntReg
-PowerLinuxProcess::getSyscallArg(ThreadContext *tc, int i)
+PowerLinuxProcess::getSyscallArg(ThreadContext *tc, int &i)
{
// Linux apparently allows more parameter than the ABI says it should.
// This limit may need to be increased even further.
assert(i < 6);
- return tc->readIntReg(ArgumentReg0 + i);
+ return tc->readIntReg(ArgumentReg0 + i++);
}
void
diff --git a/src/arch/power/linux/process.hh b/src/arch/power/linux/process.hh
index 78b0eef7f..db6759a77 100644
--- a/src/arch/power/linux/process.hh
+++ b/src/arch/power/linux/process.hh
@@ -46,7 +46,7 @@ class PowerLinuxProcess : public PowerLiveProcess
void startup();
- PowerISA::IntReg getSyscallArg(ThreadContext *tc, int i);
+ PowerISA::IntReg getSyscallArg(ThreadContext *tc, int &i);
void setSyscallArg(ThreadContext *tc, int i, PowerISA::IntReg val);
/// Array of syscall descriptors, indexed by call number.