summaryrefslogtreecommitdiff
path: root/src/sim/process.hh
diff options
context:
space:
mode:
authorBrandon Potter <brandon.potter@amd.com>2016-11-09 14:27:42 -0600
committerBrandon Potter <brandon.potter@amd.com>2016-11-09 14:27:42 -0600
commitd3d983caf94375b992940b017aeb4a73da28833c (patch)
tree7e6bf4226c9235ad187c0137c6518b3897b64752 /src/sim/process.hh
parent6c41181b8e39e776ea2f018bf383fed2782c3d4a (diff)
downloadgem5-d3d983caf94375b992940b017aeb4a73da28833c.tar.xz
syscall_emul: [patch 10/22] refactor fdentry and add fdarray class
Several large changes happen in this patch. The FDEntry class is rewritten so that file descriptors now correspond to types: 'File' which is normal file-backed file with the file open on the host machine, 'Pipe' which is a pipe that has been opened on the host machine, and 'Device' which does not have an open file on the host yet acts as a pseudo device with which to issue ioctls. Other types which might be added in the future are directory entries and sockets (off the top of my head). The FDArray class was create to hold most of the file descriptor handling that was stuffed into the Process class. It uses shared pointers and the std::array type to hold the FDEntries mentioned above. The changes to these two classes needed to be propagated out to the rest of the code so there were quite a few changes for that. Also, comments were added where I thought they were needed to help others and extend our DOxygen coverage.
Diffstat (limited to 'src/sim/process.hh')
-rw-r--r--src/sim/process.hh49
1 files changed, 5 insertions, 44 deletions
diff --git a/src/sim/process.hh b/src/sim/process.hh
index dde131628..2191c3cd0 100644
--- a/src/sim/process.hh
+++ b/src/sim/process.hh
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 Advanced Micro Devices, Inc.
+ * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
* Copyright (c) 2001-2005 The Regents of The University of Michigan
* All rights reserved.
*
@@ -28,6 +28,7 @@
*
* Authors: Nathan Binkert
* Steve Reinhardt
+ * Brandon Potter
*/
#ifndef __PROCESS_HH__
@@ -35,7 +36,6 @@
#include <inttypes.h>
-#include <array>
#include <map>
#include <string>
#include <vector>
@@ -45,6 +45,7 @@
#include "base/types.hh"
#include "config/the_isa.hh"
#include "mem/se_translating_port_proxy.hh"
+#include "sim/fd_array.hh"
#include "sim/fd_entry.hh"
#include "sim/sim_object.hh"
@@ -115,42 +116,9 @@ class Process : public SimObject
Addr getStartPC();
ObjectFile *getInterpreter();
- // inherit file descriptor map from another process (necessary for clone)
- void inheritFDArray(Process *p);
-
// override of virtual SimObject method: register statistics
void regStats() override;
- // generate new target fd for sim_fd
- 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 resetFDEntry(int tgt_fd);
-
- // look up simulator fd for given target fd
- int getSimFD(int tgt_fd);
-
- // look up fd entry for a given target 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 getTgtFD(int sim_fd);
-
- // fix all offsets for currently open files and save them
- void fixFileOffsets();
-
- // find all offsets for currently open files and save them
- void findFileOffsets();
-
- // set the source of this read pipe for a checkpoint resume
- void setReadPipeSource(int read_pipe_fd, int source_fd);
-
-
void allocateMem(Addr vaddr, int64_t size, bool clobber = false);
/// Attempt to fix up a fault at vaddr by allocating a page on the stack.
@@ -216,15 +184,6 @@ class Process : public SimObject
SETranslatingPortProxy initVirtMem; // memory proxy for initial image load
- static const int NUM_FDS = 1024;
-
- // File descriptor remapping support.
- std::shared_ptr<std::array<FDEntry, NUM_FDS>> fd_array;
-
- // Standard file descriptor options for initialization and checkpoints.
- std::map<std::string, int> imap;
- std::map<std::string, int> oemap;
-
ObjectFile *objFile;
std::vector<std::string> argv;
std::vector<std::string> envp;
@@ -243,6 +202,8 @@ class Process : public SimObject
// Emulated drivers available to this process
std::vector<EmulatedDriver *> drivers;
+
+ std::shared_ptr<FDArray> fds;
};
#endif // __PROCESS_HH__