summaryrefslogtreecommitdiff
path: root/src/sim
diff options
context:
space:
mode:
Diffstat (limited to 'src/sim')
-rw-r--r--src/sim/process.cc52
-rw-r--r--src/sim/process.hh18
-rw-r--r--src/sim/syscall_emul.cc32
-rw-r--r--src/sim/syscall_emul.hh16
4 files changed, 60 insertions, 58 deletions
diff --git a/src/sim/process.cc b/src/sim/process.cc
index f27b70853..575627367 100644
--- a/src/sim/process.cc
+++ b/src/sim/process.cc
@@ -95,6 +95,7 @@ using namespace TheISA;
int num_processes = 0;
template<class IntType>
+
AuxVector<IntType>::AuxVector(IntType type, IntType val)
{
a_type = TheISA::htog(type);
@@ -153,7 +154,7 @@ Process::Process(ProcessParams * params)
// Search through the input options and set fd if match is found;
// otherwise, open an input file and seek to location.
- FDEntry *fde_stdin = get_fd_entry(STDIN_FILENO);
+ FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
if ((it = imap.find(params->input)) != imap.end())
sim_fd = it->second;
else
@@ -162,7 +163,7 @@ Process::Process(ProcessParams * params)
// Search through the output/error options and set fd if match is found;
// otherwise, open an output file and seek to location.
- FDEntry *fde_stdout = get_fd_entry(STDOUT_FILENO);
+ FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
if ((it = oemap.find(params->output)) != oemap.end())
sim_fd = it->second;
else
@@ -170,7 +171,7 @@ Process::Process(ProcessParams * params)
fde_stdout->set(sim_fd, params->output, O_WRONLY | O_CREAT | O_TRUNC,
0664, false);
- FDEntry *fde_stderr = get_fd_entry(STDERR_FILENO);
+ FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
if (params->output == params->errout)
// Reuse the same file descriptor if these match.
sim_fd = fde_stdout->fd;
@@ -199,7 +200,7 @@ Process::regStats()
}
void
-Process::inheritFdArray(Process *p)
+Process::inheritFDArray(Process *p)
{
fd_array = p->fd_array;
}
@@ -233,19 +234,19 @@ Process::initState()
DrainState
Process::drain()
{
- find_file_offsets();
+ findFileOffsets();
return DrainState::Drained;
}
int
-Process::alloc_fd(int sim_fd, const string& filename, int flags, int mode,
- bool pipe)
+Process::allocFD(int sim_fd, const string& filename, int flags, int mode,
+ bool pipe)
{
if (sim_fd == -1)
return -1;
for (int free_fd = 0; free_fd < fd_array->size(); free_fd++) {
- FDEntry *fde = get_fd_entry(free_fd);
+ FDEntry *fde = getFDEntry(free_fd);
if (fde->isFree()) {
fde->set(sim_fd, filename, flags, mode, pipe);
return free_fd;
@@ -256,30 +257,30 @@ Process::alloc_fd(int sim_fd, const string& filename, int flags, int mode,
}
void
-Process::reset_fd_entry(int tgt_fd)
+Process::resetFDEntry(int tgt_fd)
{
- FDEntry *fde = get_fd_entry(tgt_fd);
+ FDEntry *fde = getFDEntry(tgt_fd);
assert(fde->fd > -1);
fde->reset();
}
int
-Process::sim_fd(int tgt_fd)
+Process::getSimFD(int tgt_fd)
{
- FDEntry *entry = get_fd_entry(tgt_fd);
+ FDEntry *entry = getFDEntry(tgt_fd);
return entry ? entry->fd : -1;
}
FDEntry *
-Process::get_fd_entry(int tgt_fd)
+Process::getFDEntry(int tgt_fd)
{
assert(0 <= tgt_fd && tgt_fd < fd_array->size());
return &(*fd_array)[tgt_fd];
}
int
-Process::tgt_fd(int sim_fd)
+Process::getTgtFD(int sim_fd)
{
for (int index = 0; index < fd_array->size(); index++)
if ((*fd_array)[index].fd == sim_fd)
@@ -321,7 +322,7 @@ Process::fixupStackFault(Addr vaddr)
}
void
-Process::fix_file_offsets()
+Process::fixFileOffsets()
{
auto seek = [] (FDEntry *fde)
{
@@ -333,7 +334,7 @@ Process::fix_file_offsets()
// Search through the input options and set fd if match is found;
// otherwise, open an input file and seek to location.
- FDEntry *fde_stdin = get_fd_entry(STDIN_FILENO);
+ FDEntry *fde_stdin = getFDEntry(STDIN_FILENO);
if ((it = imap.find(fde_stdin->filename)) != imap.end()) {
fde_stdin->fd = it->second;
} else {
@@ -343,7 +344,7 @@ Process::fix_file_offsets()
// Search through the output/error options and set fd if match is found;
// otherwise, open an output file and seek to location.
- FDEntry *fde_stdout = get_fd_entry(STDOUT_FILENO);
+ FDEntry *fde_stdout = getFDEntry(STDOUT_FILENO);
if ((it = oemap.find(fde_stdout->filename)) != oemap.end()) {
fde_stdout->fd = it->second;
} else {
@@ -351,7 +352,7 @@ Process::fix_file_offsets()
seek(fde_stdout);
}
- FDEntry *fde_stderr = get_fd_entry(STDERR_FILENO);
+ FDEntry *fde_stderr = getFDEntry(STDERR_FILENO);
if (fde_stdout->filename == fde_stderr->filename) {
// Reuse the same file descriptor if these match.
fde_stderr->fd = fde_stdout->fd;
@@ -363,7 +364,7 @@ Process::fix_file_offsets()
}
for (int tgt_fd = 3; tgt_fd < fd_array->size(); tgt_fd++) {
- FDEntry *fde = get_fd_entry(tgt_fd);
+ FDEntry *fde = getFDEntry(tgt_fd);
if (fde->fd == -1)
continue;
@@ -378,8 +379,9 @@ Process::fix_file_offsets()
fde->fd = fds[0];
- FDEntry *fde_write = get_fd_entry(fde->readPipeSource);
- assert(fde_write->filename == "PIPE-WRITE");
+ FDEntry *fde_write = getFDEntry(fde->readPipeSource);
+ assert(
+ fde_write->filename == "PIPE-WRITE");
fde_write->fd = fds[1];
} else {
fde->fd = openFile(fde->filename.c_str(), fde->flags, fde->mode);
@@ -389,7 +391,7 @@ Process::fix_file_offsets()
}
void
-Process::find_file_offsets()
+Process::findFileOffsets()
{
for (auto& fde : *fd_array) {
if (fde.fd != -1)
@@ -400,7 +402,7 @@ Process::find_file_offsets()
void
Process::setReadPipeSource(int read_pipe_fd, int source_fd)
{
- FDEntry *fde = get_fd_entry(read_pipe_fd);
+ FDEntry *fde = getFDEntry(read_pipe_fd);
assert(source_fd >= -1);
fde->readPipeSource = source_fd;
}
@@ -439,10 +441,10 @@ Process::unserialize(CheckpointIn &cp)
UNSERIALIZE_SCALAR(nxm_end);
pTable->unserialize(cp);
for (int x = 0; x < fd_array->size(); x++) {
- FDEntry *fde = get_fd_entry(x);
+ FDEntry *fde = getFDEntry(x);
fde->unserializeSection(cp, csprintf("FDEntry%d", x));
}
- fix_file_offsets();
+ fixFileOffsets();
UNSERIALIZE_OPT_SCALAR(M5_pid);
// The above returns a bool so that you could do something if you don't
// find the param in the checkpoint if you wanted to, like set a default
diff --git a/src/sim/process.hh b/src/sim/process.hh
index 2de83565c..82a84a935 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -153,7 +153,7 @@ class Process : public SimObject
public:
// inherit file descriptor map from another process (necessary for clone)
- void inheritFdArray(Process *p);
+ void inheritFDArray(Process *p);
// override of virtual SimObject method: register statistics
virtual void regStats();
@@ -172,30 +172,30 @@ class Process : public SimObject
virtual const char *progName() const { return "<unknown>"; }
// generate new target fd for sim_fd
- int alloc_fd(int sim_fd, const std::string& filename, int flags, int mode,
- bool pipe);
+ int allocFD(int sim_fd, const std::string& filename, int flags, int mode,
+ bool pipe);
// disassociate target fd with simulator fd and cleanup subsidiary fields
- void reset_fd_entry(int tgt_fd);
+ void resetFDEntry(int tgt_fd);
// look up simulator fd for given target fd
- int sim_fd(int tgt_fd);
+ int getSimFD(int tgt_fd);
// look up fd entry for a given target fd
- FDEntry *get_fd_entry(int tgt_fd);
+ FDEntry *getFDEntry(int tgt_fd);
// look up target fd for given host fd
// Assumes a 1:1 mapping between target file descriptor and host file
// descriptor. Given the current API, this must be true given that it's
// not possible to map multiple target file descriptors to the same host
// file descriptor
- int tgt_fd(int sim_fd);
+ int getTgtFD(int sim_fd);
// fix all offsets for currently open files and save them
- void fix_file_offsets();
+ void fixFileOffsets();
// find all offsets for currently open files and save them
- void find_file_offsets();
+ void findFileOffsets();
// set the source of this read pipe for a checkpoint resume
void setReadPipeSource(int read_pipe_fd, int source_fd);
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 97b91331e..d62836532 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -212,7 +212,7 @@ closeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
int index = 0;
int tgt_fd = p->getSyscallArg(tc, index);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -220,7 +220,7 @@ closeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
if (sim_fd > 2)
status = close(sim_fd);
if (status >= 0)
- p->reset_fd_entry(tgt_fd);
+ p->resetFDEntry(tgt_fd);
return status;
}
@@ -234,7 +234,7 @@ readFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
int nbytes = p->getSyscallArg(tc, index);
BufferArg bufArg(bufPtr, nbytes);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -255,7 +255,7 @@ writeFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
int nbytes = p->getSyscallArg(tc, index);
BufferArg bufArg(bufPtr, nbytes);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -277,7 +277,7 @@ lseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
uint64_t offs = p->getSyscallArg(tc, index);
int whence = p->getSyscallArg(tc, index);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -297,7 +297,7 @@ _llseekFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
Addr result_ptr = p->getSyscallArg(tc, index);
int whence = p->getSyscallArg(tc, index);
- int sim_fd = p->sim_fd(tgt_fd);
+ int sim_fd = p->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -501,7 +501,7 @@ ftruncateFunc(SyscallDesc *desc, int num,
int tgt_fd = process->getSyscallArg(tc, index);
off_t length = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -540,7 +540,7 @@ ftruncate64Func(SyscallDesc *desc, int num,
int tgt_fd = process->getSyscallArg(tc, index);
int64_t length = process->getSyscallArg(tc, index, 64);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -591,7 +591,7 @@ fchownFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -612,15 +612,15 @@ dupFunc(SyscallDesc *desc, int num, LiveProcess *process, ThreadContext *tc)
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
- FDEntry *fde = process->get_fd_entry(tgt_fd);
+ FDEntry *fde = process->getFDEntry(tgt_fd);
int result = dup(sim_fd);
return (result == -1) ? -errno :
- process->alloc_fd(result, fde->filename, fde->flags, fde->mode, false);
+ process->allocFD(result, fde->filename, fde->flags, fde->mode, false);
}
@@ -631,7 +631,7 @@ fcntlFunc(SyscallDesc *desc, int num, LiveProcess *process,
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -675,7 +675,7 @@ fcntl64Func(SyscallDesc *desc, int num, LiveProcess *process,
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -712,8 +712,8 @@ pipePseudoFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
return pipe_retval;
}
- sim_fds[0] = process->alloc_fd(fds[0], "PIPE-READ", O_WRONLY, -1, true);
- sim_fds[1] = process->alloc_fd(fds[1], "PIPE-WRITE", O_RDONLY, -1, true);
+ sim_fds[0] = process->allocFD(fds[0], "PIPE-READ", O_WRONLY, -1, true);
+ sim_fds[1] = process->allocFD(fds[1], "PIPE-WRITE", O_RDONLY, -1, true);
process->setReadPipeSource(sim_fds[0], sim_fds[1]);
// Alpha Linux convention for pipe() is that fd[0] is returned as
diff --git a/src/sim/syscall_emul.hh b/src/sim/syscall_emul.hh
index 5ed697314..1fd16e236 100644
--- a/src/sim/syscall_emul.hh
+++ b/src/sim/syscall_emul.hh
@@ -558,7 +558,7 @@ ioctlFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
DPRINTF(SyscallVerbose, "ioctl(%d, 0x%x, ...)\n", tgt_fd, req);
- FDEntry *fde = process->get_fd_entry(tgt_fd);
+ FDEntry *fde = process->getFDEntry(tgt_fd);
if (fde == NULL) {
// doesn't map to any simulator fd: not a valid target fd
@@ -650,7 +650,7 @@ openFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
if (fd == -1)
return -local_errno;
- return process->alloc_fd(fd, path.c_str(), hostFlags, mode, false);
+ return process->allocFD(fd, path.c_str(), hostFlags, mode, false);
}
/// Target open() handler.
@@ -812,7 +812,7 @@ fchmodFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
int tgt_fd = process->getSyscallArg(tc, index);
uint32_t mode = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -1006,7 +1006,7 @@ fstat64Func(SyscallDesc *desc, int callnum, LiveProcess *process,
int tgt_fd = process->getSyscallArg(tc, index);
Addr bufPtr = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -1102,7 +1102,7 @@ fstatFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
DPRINTF(SyscallVerbose, "fstat(%d, ...)\n", tgt_fd);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -1158,7 +1158,7 @@ fstatfsFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
int tgt_fd = process->getSyscallArg(tc, index);
Addr bufPtr = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -1183,7 +1183,7 @@ writevFunc(SyscallDesc *desc, int callnum, LiveProcess *process,
int index = 0;
int tgt_fd = process->getSyscallArg(tc, index);
- int sim_fd = process->sim_fd(tgt_fd);
+ int sim_fd = process->getSimFD(tgt_fd);
if (sim_fd < 0)
return -EBADF;
@@ -1237,7 +1237,7 @@ mmapFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
warn("mmap length argument %#x is unreasonably large.\n", length);
if (!(flags & OS::TGT_MAP_ANONYMOUS)) {
- FDEntry *fde = p->get_fd_entry(tgt_fd);
+ FDEntry *fde = p->getFDEntry(tgt_fd);
if (!fde || fde->fd < 0) {
warn("mmap failing: target fd %d is not valid\n", tgt_fd);
return -EBADF;