ArmProcess64(params, objFile, _arch)
{}
-SyscallDesc*
-ArmFreebsdProcess32::getDesc(int callnum)
-{
- return syscallDescs32.get(callnum);
-}
-
-SyscallDesc*
-ArmFreebsdProcess64::getDesc(int callnum)
-{
- return syscallDescs64.get(callnum);
-}
-
void
ArmFreebsdProcess32::initState()
{
void
ArmFreebsdProcess32::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(INTREG_R7), tc, fault);
+ ArmProcess32::syscall(tc, fault);
+ syscallDescs32.get(tc->readIntReg(INTREG_R7))->doSyscall(tc, fault);
}
void
ArmFreebsdProcess64::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(INTREG_X8), tc, fault);
+ ArmProcess64::syscall(tc, fault);
+ syscallDescs64.get(tc->readIntReg(INTREG_X8))->doSyscall(tc, fault);
}
/// A page to hold "kernel" provided functions. The name might be wrong.
static const Addr commPage;
- SyscallDesc* getDesc(int callnum) override;
-
struct SyscallABI : public ArmProcess32::SyscallABI,
public ArmFreebsdProcessBits::SyscallABI
{};
void initState() override;
void syscall(ThreadContext *tc, Fault *fault) override;
- SyscallDesc* getDesc(int callnum) override;
struct SyscallABI : public ArmProcess64::SyscallABI,
public ArmFreebsdProcessBits::SyscallABI
const Addr ArmLinuxProcess32::commPage = 0xffff0000;
-SyscallDesc*
-ArmLinuxProcess32::getDesc(int callnum)
-{
- SyscallDesc *desc = syscallDescs32Low.get(callnum);
- if (desc)
- return desc;
- desc = syscallDescs32Low.get(callnum);
- if (desc)
- return desc;
- return privSyscallDescs32.get(callnum);
-}
-
-SyscallDesc*
-ArmLinuxProcess64::getDesc(int callnum)
-{
- SyscallDesc *desc = syscallDescs64Low.get(callnum);
- if (desc)
- return desc;
- desc = syscallDescs64Low.get(callnum);
- if (desc)
- return desc;
- return privSyscallDescs64.get(callnum);
-}
-
void
ArmLinuxProcess32::initState()
{
void
ArmLinuxProcess32::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(INTREG_R7), tc, fault);
+ ArmProcess32::syscall(tc, fault);
+
+ int num = tc->readIntReg(INTREG_R7);
+ SyscallDesc *desc = syscallDescs32Low.get(num, false);
+ if (!desc)
+ desc = syscallDescs32Low.get(num, false);
+ if (!desc)
+ desc = privSyscallDescs32.get(num);
+ desc->doSyscall(tc, fault);
}
void
ArmLinuxProcess64::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(INTREG_X8), tc, fault);
+ ArmProcess64::syscall(tc, fault);
+
+ int num = tc->readIntReg(INTREG_X8);
+ SyscallDesc *desc = syscallDescs64Low.get(num, false);
+ if (!desc)
+ desc = syscallDescs64Low.get(num, false);
+ if (!desc)
+ desc = privSyscallDescs64.get(num);
+ desc->doSyscall(tc, fault);
}
/// A page to hold "kernel" provided functions. The name might be wrong.
static const Addr commPage;
- SyscallDesc* getDesc(int callnum) override;
-
struct SyscallABI : public ArmProcess32::SyscallABI,
public ArmLinuxProcessBits::SyscallABI
{};
void initState() override;
void syscall(ThreadContext *tc, Fault *fault) override;
- SyscallDesc* getDesc(int callnum) override;
struct SyscallABI : public ArmProcess64::SyscallABI,
public ArmLinuxProcessBits::SyscallABI
MipsProcess(params, objFile)
{}
-SyscallDesc*
-MipsLinuxProcess::getDesc(int callnum)
-{
- return syscallDescs.get(callnum);
-}
-
void
MipsLinuxProcess::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(2), tc, fault);
+ MipsProcess::syscall(tc, fault);
+ syscallDescs.get(tc->readIntReg(2))->doSyscall(tc, fault);
}
/// Constructor.
MipsLinuxProcess(ProcessParams * params, ObjectFile *objFile);
- SyscallDesc* getDesc(int callnum) override;
-
/// The target system's hostname.
static const char *hostname;
PowerProcess(params, objFile)
{}
-SyscallDesc*
-PowerLinuxProcess::getDesc(int callnum)
-{
- return syscallDescs.get(callnum);
-}
-
void
PowerLinuxProcess::initState()
{
void
PowerLinuxProcess::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(0), tc, fault);
+ PowerProcess::syscall(tc, fault);
+ syscallDescs.get(tc->readIntReg(0))->doSyscall(tc, fault);
}
public:
PowerLinuxProcess(ProcessParams * params, ObjectFile *objFile);
- SyscallDesc *getDesc(int callnum) override;
-
void initState() override;
void syscall(ThreadContext *tc, Fault *fault) override;
ObjectFile *objFile) : RiscvProcess64(params, objFile)
{}
-SyscallDesc*
-RiscvLinuxProcess64::getDesc(int callnum)
-{
- return syscallDescs.get(callnum);
-}
-
void
RiscvLinuxProcess64::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(SyscallNumReg), tc, fault);
+ RiscvProcess64::syscall(tc, fault);
+ syscallDescs.get(tc->readIntReg(SyscallNumReg))->doSyscall(tc, fault);
}
RiscvLinuxProcess32::RiscvLinuxProcess32(ProcessParams * params,
ObjectFile *objFile) : RiscvProcess32(params, objFile)
{}
-SyscallDesc*
-RiscvLinuxProcess32::getDesc(int callnum)
-{
- return syscallDescs.get(callnum);
-}
-
void
RiscvLinuxProcess32::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(SyscallNumReg), tc, fault);
+ RiscvProcess32::syscall(tc, fault);
+ syscallDescs.get(tc->readIntReg(SyscallNumReg))->doSyscall(tc, fault);
}
/// Constructor.
RiscvLinuxProcess64(ProcessParams * params, ObjectFile *objFile);
- SyscallDesc* getDesc(int callnum) override;
-
/// The target system's hostname.
static const char *hostname;
/// Constructor.
RiscvLinuxProcess32(ProcessParams * params, ObjectFile *objFile);
- SyscallDesc* getDesc(int callnum) override;
-
/// The target system's hostname.
static const char *hostname;
} // anonymous namespace
-SyscallDesc*
-SparcLinuxProcess::getDesc(int callnum)
-{
- return syscallDescs.get(callnum);
-}
-
-SyscallDesc*
-SparcLinuxProcess::getDesc32(int callnum)
-{
- return syscall32Descs.get(callnum);
-}
-
Sparc32LinuxProcess::Sparc32LinuxProcess(ProcessParams * params,
ObjectFile *objFile)
: Sparc32Process(params, objFile)
void
Sparc32LinuxProcess::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(1), tc, fault);
+ Sparc32Process::syscall(tc, fault);
+ syscall32Descs.get(tc->readIntReg(1))->doSyscall(tc, fault);
}
void
void
Sparc64LinuxProcess::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(1), tc, fault);
+ Sparc64Process::syscall(tc, fault);
+ syscallDescs.get(tc->readIntReg(1))->doSyscall(tc, fault);
}
void
/// 32 bit compatibility syscall descriptors, indexed by call number.
static SyscallDescTable<Sparc32Process::SyscallABI> syscall32Descs;
-
- SyscallDesc *getDesc(int callnum);
- SyscallDesc *getDesc32(int callnum);
-
- static const int Num_Syscall_Descs;
- static const int Num_Syscall32_Descs;
};
/// A process with emulated SPARC/Linux syscalls.
/// Constructor.
Sparc32LinuxProcess(ProcessParams * params, ObjectFile *objFile);
- SyscallDesc*
- getDesc(int callnum) override
- {
- return SparcLinuxProcess::getDesc32(callnum);
- }
-
void syscall(ThreadContext *tc, Fault *fault) override;
void handleTrap(int trapNum, ThreadContext *tc, Fault *fault) override;
/// Constructor.
Sparc64LinuxProcess(ProcessParams * params, ObjectFile *objFile);
- SyscallDesc*
- getDesc(int callnum) override
- {
- return SparcLinuxProcess::getDesc(callnum);
- }
-
void syscall(ThreadContext *tc, Fault *fault) override;
void handleTrap(int trapNum, ThreadContext *tc, Fault *fault) override;
: Sparc64Process(params, objFile)
{}
-SyscallDesc*
-SparcSolarisProcess::getDesc(int callnum)
-{
- return syscallDescs.get(callnum);
-}
-
void
SparcSolarisProcess::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(1), tc, fault);
+ Sparc64Process::syscall(tc, fault);
+ syscallDescs.get(tc->readIntReg(1))->doSyscall(tc, fault);
}
/// Constructor.
SparcSolarisProcess(ProcessParams * params, ObjectFile *objFile);
- SyscallDesc *getDesc(int callnum) override;
-
/// The target system's hostname.
static const char *hostname;
void
X86_64LinuxProcess::syscall(ThreadContext *tc, Fault *fault)
{
- doSyscall(tc->readIntReg(INTREG_RAX), tc, fault);
-}
-
-SyscallDesc *
-X86_64LinuxProcess::getDesc(int callnum)
-{
- return syscallDescs64.get(callnum);
+ X86_64Process::syscall(tc, fault);
+ syscallDescs64.get(tc->readIntReg(INTREG_RAX))->doSyscall(tc, fault);
}
void
void
I386LinuxProcess::syscall(ThreadContext *tc, Fault *fault)
{
+ I386Process::syscall(tc, fault);
PCState pc = tc->pcState();
Addr eip = pc.pc();
if (eip >= vsyscallPage.base &&
pc.npc(vsyscallPage.base + vsyscallPage.vsysexitOffset);
tc->pcState(pc);
}
- doSyscall(tc->readIntReg(INTREG_RAX), tc, fault);
-}
-
-SyscallDesc *
-I386LinuxProcess::getDesc(int callnum)
-{
- return syscallDescs32.get(callnum);
+ syscallDescs32.get(tc->readIntReg(INTREG_RAX))->doSyscall(tc, fault);
}
void
public:
using X86_64Process::X86_64Process;
void syscall(ThreadContext *tc, Fault *fault) override;
- SyscallDesc *getDesc(int callnum) override;
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process,
RegVal flags) override;
public:
using I386Process::I386Process;
void syscall(ThreadContext *tc, Fault *fault) override;
- SyscallDesc *getDesc(int callnum) override;
void clone(ThreadContext *old_tc, ThreadContext *new_tc, Process *process,
RegVal flags) override;
return true;
}
-void
-Process::doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault)
-{
- numSyscalls++;
-
- SyscallDesc *desc = getDesc(callnum);
- if (desc == nullptr)
- fatal("Syscall %d out of range", callnum);
-
- desc->doSyscall(tc, fault);
-}
-
EmulatedDriver *
Process::findDriver(std::string filename)
{
class Process : public SimObject
{
- protected:
- void doSyscall(int64_t callnum, ThreadContext *tc, Fault *fault);
-
public:
Process(ProcessParams *params, EmulationPageTable *pTable,
ObjectFile *obj_file);
void initState() override;
DrainState drain() override;
- virtual void syscall(ThreadContext *tc, Fault *fault) = 0;
- virtual SyscallDesc *getDesc(int callnum) = 0;
+ virtual void syscall(ThreadContext *tc, Fault *fault) { numSyscalls++; }
inline uint64_t uid() { return _uid; }
inline uint64_t euid() { return _euid; }
}
SyscallDesc
- *get(int num)
+ *get(int num, bool fatal_if_missing=true)
{
auto it = _descs.find(num);
- if (it == _descs.end())
- return nullptr;
+ if (it == _descs.end()) {
+ if (fatal_if_missing)
+ fatal("Syscall %d out of range", num);
+ else
+ return nullptr;
+ }
return &it->second;
}
};