summaryrefslogtreecommitdiff
path: root/src/kern/tru64
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/kern/tru64
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/kern/tru64')
-rw-r--r--src/kern/tru64/tru64.hh77
1 files changed, 46 insertions, 31 deletions
diff --git a/src/kern/tru64/tru64.hh b/src/kern/tru64/tru64.hh
index c2bdd2776..033f30946 100644
--- a/src/kern/tru64/tru64.hh
+++ b/src/kern/tru64/tru64.hh
@@ -440,10 +440,11 @@ class Tru64 : public OperatingSystem
#ifdef __CYGWIN__
panic("getdirent not implemented on cygwin!");
#else
- int fd = process->sim_fd(process->getSyscallArg(tc, 0));
- Addr tgt_buf = process->getSyscallArg(tc, 1);
- int tgt_nbytes = process->getSyscallArg(tc, 2);
- Addr tgt_basep = process->getSyscallArg(tc, 3);
+ int index = 0;
+ int fd = process->sim_fd(process->getSyscallArg(tc, index));
+ Addr tgt_buf = process->getSyscallArg(tc, index);
+ int tgt_nbytes = process->getSyscallArg(tc, index);
+ Addr tgt_basep = process->getSyscallArg(tc, index);
char * const host_buf = new char[tgt_nbytes];
@@ -498,7 +499,8 @@ class Tru64 : public OperatingSystem
{
using namespace TheISA;
- TypedBufferArg<Tru64::sigcontext> sc(process->getSyscallArg(tc, 0));
+ int index = 0;
+ TypedBufferArg<Tru64::sigcontext> sc(process->getSyscallArg(tc, index));
sc.copyIn(tc->getMemPort());
@@ -530,7 +532,8 @@ class Tru64 : public OperatingSystem
{
using namespace TheISA;
- TypedBufferArg<Tru64::vm_stack> argp(process->getSyscallArg(tc, 0));
+ int index = 0;
+ TypedBufferArg<Tru64::vm_stack> argp(process->getSyscallArg(tc, index));
argp.copyIn(tc->getMemPort());
@@ -578,9 +581,10 @@ class Tru64 : public OperatingSystem
using namespace std;
using namespace TheISA;
+ int index = 0;
TypedBufferArg<Tru64::nxm_task_attr>
- attrp(process->getSyscallArg(tc, 0));
- TypedBufferArg<Addr> configptr_ptr(process->getSyscallArg(tc, 1));
+ attrp(process->getSyscallArg(tc, index));
+ TypedBufferArg<Addr> configptr_ptr(process->getSyscallArg(tc, index));
attrp.copyIn(tc->getMemPort());
@@ -712,10 +716,11 @@ class Tru64 : public OperatingSystem
using namespace std;
using namespace TheISA;
+ int index = 0;
TypedBufferArg<Tru64::nxm_thread_attr>
- attrp(process->getSyscallArg(tc, 0));
- TypedBufferArg<uint64_t> kidp(process->getSyscallArg(tc, 1));
- int thread_index = process->getSyscallArg(tc, 2);
+ attrp(process->getSyscallArg(tc, index));
+ TypedBufferArg<uint64_t> kidp(process->getSyscallArg(tc, index));
+ int thread_index = process->getSyscallArg(tc, index);
// get attribute args
attrp.copyIn(tc->getMemPort());
@@ -834,11 +839,12 @@ class Tru64 : public OperatingSystem
{
using namespace std;
- uint64_t tid = process->getSyscallArg(tc, 0);
- uint64_t secs = process->getSyscallArg(tc, 1);
- uint64_t flags = process->getSyscallArg(tc, 2);
- uint64_t action = process->getSyscallArg(tc, 3);
- uint64_t usecs = process->getSyscallArg(tc, 4);
+ int index = 0;
+ uint64_t tid = process->getSyscallArg(tc, index);
+ uint64_t secs = process->getSyscallArg(tc, index);
+ uint64_t flags = process->getSyscallArg(tc, index);
+ uint64_t action = process->getSyscallArg(tc, index);
+ uint64_t usecs = process->getSyscallArg(tc, index);
cout << tc->getCpuPtr()->name() << ": nxm_thread_block " << tid << " "
<< secs << " " << flags << " " << action << " " << usecs << endl;
@@ -853,11 +859,12 @@ class Tru64 : public OperatingSystem
{
using namespace std;
- Addr uaddr = process->getSyscallArg(tc, 0);
- uint64_t val = process->getSyscallArg(tc, 1);
- uint64_t secs = process->getSyscallArg(tc, 2);
- uint64_t usecs = process->getSyscallArg(tc, 3);
- uint64_t flags = process->getSyscallArg(tc, 4);
+ int index = 0;
+ Addr uaddr = process->getSyscallArg(tc, index);
+ uint64_t val = process->getSyscallArg(tc, index);
+ uint64_t secs = process->getSyscallArg(tc, index);
+ uint64_t usecs = process->getSyscallArg(tc, index);
+ uint64_t flags = process->getSyscallArg(tc, index);
BaseCPU *cpu = tc->getCpuPtr();
@@ -876,7 +883,8 @@ class Tru64 : public OperatingSystem
{
using namespace std;
- Addr uaddr = process->getSyscallArg(tc, 0);
+ int index = 0;
+ Addr uaddr = process->getSyscallArg(tc, index);
cout << tc->getCpuPtr()->name() << ": nxm_unblock "
<< hex << uaddr << dec << endl;
@@ -977,7 +985,8 @@ class Tru64 : public OperatingSystem
m5_mutex_lockFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- Addr uaddr = process->getSyscallArg(tc, 0);
+ int index = 0;
+ Addr uaddr = process->getSyscallArg(tc, index);
m5_lock_mutex(uaddr, process, tc);
@@ -994,7 +1003,8 @@ class Tru64 : public OperatingSystem
{
using namespace TheISA;
- Addr uaddr = process->getSyscallArg(tc, 0);
+ int index = 0;
+ Addr uaddr = process->getSyscallArg(tc, index);
TypedBufferArg<uint64_t> lockp(uaddr);
lockp.copyIn(tc->getMemPort());
@@ -1014,7 +1024,8 @@ class Tru64 : public OperatingSystem
m5_mutex_unlockFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- Addr uaddr = process->getSyscallArg(tc, 0);
+ int index = 0;
+ Addr uaddr = process->getSyscallArg(tc, index);
m5_unlock_mutex(uaddr, process, tc);
@@ -1026,7 +1037,8 @@ class Tru64 : public OperatingSystem
m5_cond_signalFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- Addr cond_addr = process->getSyscallArg(tc, 0);
+ int index = 0;
+ Addr cond_addr = process->getSyscallArg(tc, index);
// Wake up one process waiting on the condition variable.
activate_waiting_context(cond_addr, process);
@@ -1039,7 +1051,8 @@ class Tru64 : public OperatingSystem
m5_cond_broadcastFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- Addr cond_addr = process->getSyscallArg(tc, 0);
+ int index = 0;
+ Addr cond_addr = process->getSyscallArg(tc, index);
activate_waiting_context(cond_addr, process, true);
@@ -1053,8 +1066,9 @@ class Tru64 : public OperatingSystem
{
using namespace TheISA;
- Addr cond_addr = process->getSyscallArg(tc, 0);
- Addr lock_addr = process->getSyscallArg(tc, 1);
+ int index = 0;
+ Addr cond_addr = process->getSyscallArg(tc, index);
+ Addr lock_addr = process->getSyscallArg(tc, index);
TypedBufferArg<uint64_t> condp(cond_addr);
TypedBufferArg<uint64_t> lockp(lock_addr);
@@ -1086,10 +1100,11 @@ class Tru64 : public OperatingSystem
indirectSyscallFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- int new_callnum = process->getSyscallArg(tc, 0);
+ int index = 0;
+ int new_callnum = process->getSyscallArg(tc, index);
for (int i = 0; i < 5; ++i)
- process->setSyscallArg(tc, i, process->getSyscallArg(tc, i+1));
+ process->setSyscallArg(tc, i, process->getSyscallArg(tc, index));
SyscallDesc *new_desc = process->getDesc(new_callnum);