summaryrefslogtreecommitdiff
path: root/src/sim/syscall_emul.cc
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2016-11-09 14:27:40 -0600
committerBrandon Potter <brandon.potter@amd.com>2016-11-09 14:27:40 -0600
commit1ced08c85055d5da845ca549c0f5fcea65ee3e08 (patch)
treed0e6b2bbd69b07281a35ac561697a1b145591042 /src/sim/syscall_emul.cc
parent7a8dda49a4ec33be17bbd101ebd68e02562b9c3d (diff)
downloadgem5-1ced08c85055d5da845ca549c0f5fcea65ee3e08.tar.xz
syscall_emul: [patch 2/22] move SyscallDesc into its own .hh and .cc
The class was crammed into syscall_emul.hh which has tons of forward declarations and template definitions. To clean it up a bit, moved the class into separate files and commented the class with doxygen style comments. Also, provided some encapsulation by adding some accessors and a mutator. The syscallreturn.hh file was renamed syscall_return.hh to make it consistent with other similarly named files in the src/sim directory. The DPRINTF_SYSCALL macro was moved into its own header file with the include the Base and Verbose flags as well. --HG-- rename : src/sim/syscallreturn.hh => src/sim/syscall_return.hh
Diffstat (limited to 'src/sim/syscall_emul.cc')
-rw-r--r--src/sim/syscall_emul.cc56
1 files changed, 6 insertions, 50 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 499cd2557..da89f7a08 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -44,56 +44,21 @@
#include "config/the_isa.hh"
#include "cpu/base.hh"
#include "cpu/thread_context.hh"
-#include "debug/SyscallBase.hh"
-#include "debug/SyscallVerbose.hh"
#include "mem/page_table.hh"
#include "sim/process.hh"
#include "sim/sim_exit.hh"
+#include "sim/syscall_debug_macros.hh"
+#include "sim/syscall_desc.hh"
#include "sim/system.hh"
using namespace std;
using namespace TheISA;
-void
-SyscallDesc::doSyscall(int callnum, LiveProcess *process, ThreadContext *tc)
-{
- if (DTRACE(SyscallBase)) {
- int index = 0;
- IntReg arg[6] M5_VAR_USED;
-
- // we can't just put the calls to getSyscallArg() in the
- // DPRINTF arg list, because C++ doesn't guarantee their order
- for (int i = 0; i < 6; ++i)
- arg[i] = process->getSyscallArg(tc, index);
-
- // Linux supports up to six system call arguments through registers
- // so we want to print all six. Check to the relevant man page to
- // verify how many are actually used by a given system call.
- DPRINTF_SYSCALL(Base,
- "%s called w/arguments %d, %d, %d, %d, %d, %d\n",
- name, arg[0], arg[1], arg[2], arg[3], arg[4],
- arg[5]);
- }
-
- SyscallReturn retval = (*funcPtr)(this, callnum, process, tc);
-
- if (retval.needsRetry()) {
- DPRINTF_SYSCALL(Base, "%s needs retry\n", name);
- } else {
- DPRINTF_SYSCALL(Base, "%s returns %d\n", name,
- retval.encodedValue());
- }
-
- if (!(flags & SyscallDesc::SuppressReturnValue) && !retval.needsRetry())
- process->setSyscallReturn(tc, retval);
-}
-
-
SyscallReturn
unimplementedFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- fatal("syscall %s (#%d) unimplemented.", desc->name, callnum);
+ fatal("syscall %s (#%d) unimplemented.", desc->name(), callnum);
return 1;
}
@@ -103,20 +68,11 @@ SyscallReturn
ignoreFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
ThreadContext *tc)
{
- int index = 0;
- const char *extra_text = "";
-
- if (desc->warnOnce()) {
- if (desc->warned)
- return 0;
-
- desc->warned = true;
- extra_text = "\n (further warnings will be suppressed)";
+ if (desc->needWarning()) {
+ warn("ignoring syscall %s(...)%s", desc->name(), desc->warnOnce() ?
+ "\n (further warnings will be suppressed)" : "");
}
- warn("ignoring syscall %s(%d, ...)%s", desc->name,
- process->getSyscallArg(tc, index), extra_text);
-
return 0;
}