#ifndef __PROCESS_HH__
#define __PROCESS_HH__
+#include <array>
#include <string>
#include <vector>
#include "base/types.hh"
#include "config/the_isa.hh"
#include "mem/se_translating_port_proxy.hh"
+#include "sim/fd_entry.hh"
#include "sim/sim_object.hh"
#include "sim/syscallreturn.hh"
virtual void initState();
+ DrainState drain() M5_ATTR_OVERRIDE;
+
public:
//This id is assigned by m5 and is used to keep process' tlb entries
PageTableBase* pTable;
- class FdMap
- {
- public:
- int fd;
- std::string filename;
- int mode;
- int flags;
- bool isPipe;
- int readPipeSource;
- uint64_t fileOffset;
- EmulatedDriver *driver;
-
- FdMap()
- : fd(-1), filename("NULL"), mode(0), flags(0),
- isPipe(false), readPipeSource(0), fileOffset(0), driver(NULL)
- { }
-
- void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string §ion);
- };
-
protected:
/// Memory proxy for initialization (image loading)
SETranslatingPortProxy initVirtMem;
private:
- // file descriptor remapping support
- static const int MAX_FD = 256; // max legal fd value
- FdMap fd_map[MAX_FD+1];
+ 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;
public:
- // static helper functions to generate file descriptors for constructor
- static int openInputFile(const std::string &filename);
- static int openOutputFile(const std::string &filename);
+ // inherit file descriptor map from another process (necessary for clone)
+ void inheritFdArray(Process *p);
// override of virtual SimObject method: register statistics
virtual void regStats();
// provide program name for debug messages
virtual const char *progName() const { return "<unknown>"; }
- // map simulator fd sim_fd to target fd tgt_fd
- void dup_fd(int sim_fd, int tgt_fd);
-
// generate new target fd for sim_fd
int alloc_fd(int sim_fd, const std::string& filename, int flags, int mode,
bool pipe);
- // free target fd (e.g., after close)
- void free_fd(int tgt_fd);
+ // disassociate target fd with simulator fd and cleanup subsidiary fields
+ void reset_fd_entry(int tgt_fd);
// look up simulator fd for given target fd
int sim_fd(int tgt_fd);
- // look up simulator fd_map object for a given target fd
- FdMap *sim_fd_obj(int tgt_fd);
+ // look up fd entry for a given target fd
+ FDEntry *get_fd_entry(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);
// fix all offsets for currently open files and save them
void fix_file_offsets();
*/
bool map(Addr vaddr, Addr paddr, int size, bool cacheable = true);
- void serialize(std::ostream &os);
- void unserialize(Checkpoint *cp, const std::string §ion);
+ void serialize(CheckpointOut &cp) const M5_ATTR_OVERRIDE;
+ void unserialize(CheckpointIn &cp) M5_ATTR_OVERRIDE;
};
//