Syscall: Make the syscall function available in both SE and FS modes.

In FS mode the syscall function will panic, but the interface will be
consistent and code which calls syscall can be compiled in. This will allow,
for instance, instructions that use syscall to be built unconditionally but
then not returned by the decoder.
This commit is contained in:
Gabe Black 2011-09-19 02:46:48 -07:00
parent 83aa47adca
commit 10c2e37f60
5 changed files with 28 additions and 12 deletions

View file

@ -311,14 +311,18 @@ InOrderDynInst::simPalCheck(int palFunc)
#endif #endif
return this->cpu->simPalCheck(palFunc, this->threadNumber); return this->cpu->simPalCheck(palFunc, this->threadNumber);
} }
#else #endif
void void
InOrderDynInst::syscall(int64_t callnum) InOrderDynInst::syscall(int64_t callnum)
{ {
#if FULL_SYSTEM
panic("Syscall emulation isn't available in FS mode.\n");
#else
syscallNum = callnum; syscallNum = callnum;
cpu->syscallContext(NoFault, this->threadNumber, this); cpu->syscallContext(NoFault, this->threadNumber, this);
}
#endif #endif
}
void void
InOrderDynInst::setSquashInfo(unsigned stage_num) InOrderDynInst::setSquashInfo(unsigned stage_num)

View file

@ -525,11 +525,11 @@ class InOrderDynInst : public FastAlloc, public RefCounted
bool simPalCheck(int palFunc); bool simPalCheck(int palFunc);
#else #else
short syscallNum; short syscallNum;
/** Calls a syscall. */
void syscall(int64_t callnum);
#endif #endif
/** Emulates a syscall. */
void syscall(int64_t callnum);
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
// //
// MULTITHREADING INTERFACE TO CPU MODELS // MULTITHREADING INTERFACE TO CPU MODELS

View file

@ -205,11 +205,11 @@ class BaseO3DynInst : public BaseDynInst<Impl>
/** Traps to handle specified fault. */ /** Traps to handle specified fault. */
void trap(Fault fault); void trap(Fault fault);
bool simPalCheck(int palFunc); bool simPalCheck(int palFunc);
#else
/** Calls a syscall. */
void syscall(int64_t callnum);
#endif #endif
/** Emulates a syscall. */
void syscall(int64_t callnum);
public: public:
// The register accessor methods provide the index of the // The register accessor methods provide the index of the

View file

@ -188,11 +188,15 @@ BaseO3DynInst<Impl>::simPalCheck(int palFunc)
#endif #endif
return this->cpu->simPalCheck(palFunc, this->threadNumber); return this->cpu->simPalCheck(palFunc, this->threadNumber);
} }
#else #endif
template <class Impl> template <class Impl>
void void
BaseO3DynInst<Impl>::syscall(int64_t callnum) BaseO3DynInst<Impl>::syscall(int64_t callnum)
{ {
#if FULL_SYSTEM
panic("Syscall emulation isn't available in FS mode.\n");
#else
// HACK: check CPU's nextPC before and after syscall. If it // HACK: check CPU's nextPC before and after syscall. If it
// changes, update this instruction's nextPC because the syscall // changes, update this instruction's nextPC because the syscall
// must have changed the nextPC. // must have changed the nextPC.
@ -202,6 +206,6 @@ BaseO3DynInst<Impl>::syscall(int64_t callnum)
if (!(curPC == newPC)) { if (!(curPC == newPC)) {
this->pcState(newPC); this->pcState(newPC);
} }
}
#endif #endif
}

View file

@ -402,10 +402,18 @@ class BaseSimpleCPU : public BaseCPU
#if FULL_SYSTEM #if FULL_SYSTEM
Fault hwrei() { return thread->hwrei(); } Fault hwrei() { return thread->hwrei(); }
bool simPalCheck(int palFunc) { return thread->simPalCheck(palFunc); } bool simPalCheck(int palFunc) { return thread->simPalCheck(palFunc); }
#else
void syscall(int64_t callnum) { thread->syscall(callnum); }
#endif #endif
void
syscall(int64_t callnum)
{
#if FULL_SYSTEM
panic("Syscall emulation isn't available in FS mode.\n");
#else
thread->syscall(callnum);
#endif
}
bool misspeculating() { return thread->misspeculating(); } bool misspeculating() { return thread->misspeculating(); }
ThreadContext *tcBase() { return tc; } ThreadContext *tcBase() { return tc; }
}; };