mips: Use a mips specific GuestABI for mips system calls.
Change-Id: Ice9fb867b47e56bc00b171399a82b2892b16c9e4 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23451 Reviewed-by: Bobby R. Bruce <bbruce@ucdavis.edu> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -151,7 +151,7 @@ setThreadAreaFunc(SyscallDesc *desc, int callnum, ThreadContext *tc, Addr addr)
|
||||
return 0;
|
||||
}
|
||||
|
||||
SyscallDescABI<DefaultSyscallABI> MipsLinuxProcess::syscallDescs[] = {
|
||||
SyscallDescABI<MipsProcess::SyscallABI> MipsLinuxProcess::syscallDescs[] = {
|
||||
/* 0 */ { "syscall" },
|
||||
/* 1 */ { "exit", exitFunc },
|
||||
/* 2 */ { "fork" },
|
||||
|
||||
@@ -52,7 +52,7 @@ class MipsLinuxProcess : public MipsProcess
|
||||
void syscall(ThreadContext *tc, Fault *fault) override;
|
||||
|
||||
/// Array of syscall descriptors, indexed by call number.
|
||||
static SyscallDescABI<DefaultSyscallABI> syscallDescs[];
|
||||
static SyscallDescABI<SyscallABI> syscallDescs[];
|
||||
const int Num_Syscall_Descs;
|
||||
};
|
||||
|
||||
|
||||
@@ -211,3 +211,7 @@ MipsProcess::setSyscallReturn(ThreadContext *tc, SyscallReturn sysret)
|
||||
if (sysret.count() > 1)
|
||||
tc->setIntReg(SyscallPseudoReturnReg, sysret.value2());
|
||||
}
|
||||
|
||||
const std::vector<int> MipsProcess::SyscallABI::ArgumentRegs = {
|
||||
4, 5, 6, 7, 8, 9
|
||||
};
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include "mem/page_table.hh"
|
||||
#include "sim/process.hh"
|
||||
#include "sim/syscall_abi.hh"
|
||||
|
||||
class ObjectFile;
|
||||
|
||||
@@ -52,6 +53,39 @@ class MipsProcess : public Process
|
||||
/// Explicitly import the otherwise hidden getSyscallArg
|
||||
using Process::getSyscallArg;
|
||||
void setSyscallReturn(ThreadContext *tc, SyscallReturn return_value);
|
||||
|
||||
struct SyscallABI : public GenericSyscallABI64
|
||||
{
|
||||
static const std::vector<int> ArgumentRegs;
|
||||
};
|
||||
};
|
||||
|
||||
namespace GuestABI
|
||||
{
|
||||
|
||||
template <>
|
||||
struct Result<MipsProcess::SyscallABI, SyscallReturn>
|
||||
{
|
||||
static void
|
||||
store(ThreadContext *tc, const SyscallReturn &ret)
|
||||
{
|
||||
if (ret.suppressed() || ret.needsRetry())
|
||||
return;
|
||||
|
||||
if (ret.successful()) {
|
||||
// no error
|
||||
tc->setIntReg(MipsISA::SyscallSuccessReg, 0);
|
||||
tc->setIntReg(MipsISA::ReturnValueReg, ret.returnValue());
|
||||
} else {
|
||||
// got an error, return details
|
||||
tc->setIntReg(MipsISA::SyscallSuccessReg, (uint32_t)(-1));
|
||||
tc->setIntReg(MipsISA::ReturnValueReg, ret.errnoValue());
|
||||
}
|
||||
if (ret.count() > 1)
|
||||
tc->setIntReg(MipsISA::SyscallPseudoReturnReg, ret.value2());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace GuestABI
|
||||
|
||||
#endif // __MIPS_PROCESS_HH__
|
||||
|
||||
Reference in New Issue
Block a user